浏览代码

Try to handle crash on map selection screen

Ivan Savenko 9 月之前
父节点
当前提交
51ceb068a7
共有 2 个文件被更改,包括 11 次插入1 次删除
  1. 8 1
      client/lobby/CSelectionBase.cpp
  2. 3 0
      client/lobby/OptionsTab.cpp

+ 8 - 1
client/lobby/CSelectionBase.cpp

@@ -74,7 +74,14 @@ int ISelectionScreenInfo::getCurrentDifficulty()
 
 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)

+ 3 - 0
client/lobby/OptionsTab.cpp

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