roughly expanded overlay pic buffer to 0x1000, and added some safety guardian to avoid crash .

This commit is contained in:
Zero Fanker 2024-03-26 23:21:54 -04:00
parent 172e67823d
commit a2117f8c25
2 changed files with 17 additions and 7 deletions

View file

@ -238,8 +238,15 @@ CString* CIniFileSection::GetValue(std::size_t index) noexcept
return NULL;
auto i = values.begin();
for (auto e = 0;e < index;e++)
for (auto e = 0; e < index; e++) {
if (i == values.end()) {
break;
}
i++;
}
if (i == values.end()) {
return nullptr;
}
return &i->second;
}

View file

@ -65,7 +65,7 @@ void GetNodeName(CString& name, int n);
/* --------- */
/* Overlay picture table (maximum overlay count=0xFF) */
PICDATA* ovrlpics[0xFF][max_ovrl_img];
PICDATA* ovrlpics[0x1000][max_ovrl_img];
// cancel draw flag
BOOL bCancelDraw = FALSE;
@ -5911,11 +5911,14 @@ void CIsoView::DrawMap()
{
if (!pic.bTried)
{
SetError("Loading graphics");
theApp.m_loading->LoadOverlayGraphic(*rules.sections["OverlayTypes"].GetValue(m.overlay), m.overlay);
UpdateOverlayPictures(m.overlay);
if (ovrlpics[m.overlay][m.overlaydata] != NULL)
pic = *ovrlpics[m.overlay][m.overlaydata];
if (auto const pOverlayId = rules.sections["OverlayTypes"].GetValue(m.overlay)) {
SetError("Loading graphics");
theApp.m_loading->LoadOverlayGraphic(*pOverlayId, m.overlay);
UpdateOverlayPictures(m.overlay);
if (ovrlpics[m.overlay][m.overlaydata] != NULL) {
pic = *ovrlpics[m.overlay][m.overlaydata];
}
}
}
if (pic.pic == NULL)