1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Try to handle crash on map selection screen

This commit is contained in:
Ivan Savenko
2025-01-01 21:00:25 +00:00
parent 69ee1a9098
commit 51ceb068a7
2 changed files with 11 additions and 1 deletions

View File

@@ -74,7 +74,14 @@ int ISelectionScreenInfo::getCurrentDifficulty()
PlayerInfo ISelectionScreenInfo::getPlayerInfo(PlayerColor color) PlayerInfo ISelectionScreenInfo::getPlayerInfo(PlayerColor color)
{ {
return getMapInfo()->mapHeader->players.at(color.getNum()); auto mapInfo = getMapInfo();
if (!mapInfo)
throw std::runtime_error("Attempt to get player info for invalid map!");
if (!mapInfo->mapHeader)
throw std::runtime_error("Attempt to get player info for invalid map header!");
return mapInfo->mapHeader->players.at(color.getNum());
} }
CSelectionBase::CSelectionBase(ESelectionScreen type) CSelectionBase::CSelectionBase(ESelectionScreen type)

View File

@@ -933,6 +933,9 @@ void OptionsTab::SelectedBox::showPopupWindow(const Point & cursorPosition)
void OptionsTab::SelectedBox::clickReleased(const Point & cursorPosition) void OptionsTab::SelectedBox::clickReleased(const Point & cursorPosition)
{ {
if (!SEL)
return;
if(SEL->screenType != ESelectionScreen::newGame) if(SEL->screenType != ESelectionScreen::newGame)
return; return;