From b23c39e81bae19d73e1651f953aec06be0bd0d69 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Sat, 2 May 2026 21:34:50 +0200 Subject: [PATCH] bugfix(lan): Fix crash when changing settings in the LAN options menu. --- .../GUICallbacks/Menus/LanGameOptionsMenu.cpp | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp index 4072ce98ad5..118687259b8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp @@ -1152,9 +1152,13 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m { if (LANbuttonPushed) break; + + LANGameInfo* myGame = TheLAN->GetMyGame(); + if (myGame->isGameInProgress()) + return MSG_IGNORED; + GameWindow *control = (GameWindow *)mData1; Int controlID = control->winGetWindowId(); - LANGameInfo *myGame = TheLAN->GetMyGame(); if ( controlID == comboBoxStartingCashID ) { @@ -1220,6 +1224,11 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m { if (LANbuttonPushed) break; + + LANGameInfo* myGame = TheLAN->GetMyGame(); + if (myGame->isGameInProgress()) + return MSG_IGNORED; + GameWindow *control = (GameWindow *)mData1; Int controlID = control->winGetWindowId(); @@ -1270,7 +1279,7 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m TheLAN->RequestAccept(); // Disable the accept button - EnableAcceptControls(TRUE, TheLAN->GetMyGame(), comboBoxPlayer, comboBoxColor, comboBoxPlayerTemplate, + EnableAcceptControls(TRUE, myGame, comboBoxPlayer, comboBoxColor, comboBoxPlayerTemplate, comboBoxTeam, buttonAccept, buttonStart, buttonMapStartPosition); } @@ -1285,11 +1294,10 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m { if (controlID == buttonMapStartPositionID[i]) { - LANGameInfo *game = TheLAN->GetMyGame(); Int playerIdxInPos = -1; for (Int j=0; jgetLANSlot(j); + LANGameSlot *slot = myGame->getLANSlot(j); if (slot && slot->getStartPos() == i) { playerIdxInPos = j; @@ -1298,8 +1306,8 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m } if (playerIdxInPos >= 0) { - LANGameSlot *slot = game->getLANSlot(playerIdxInPos); - if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI())) + LANGameSlot *slot = myGame->getLANSlot(playerIdxInPos); + if (playerIdxInPos == myGame->getLocalSlotNum() || (myGame->amIHost() && slot && slot->isAI())) { // it's one of my type. Try to change it. Int nextPlayer = getNextSelectablePlayer(playerIdxInPos+1); @@ -1315,7 +1323,7 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m // nobody in the slot - put us in Int nextPlayer = getNextSelectablePlayer(0); if (nextPlayer < 0) - nextPlayer = getFirstSelectablePlayer(game); + nextPlayer = getFirstSelectablePlayer(myGame); handleStartPositionSelection(nextPlayer, i); } } @@ -1330,17 +1338,21 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m if (LANbuttonPushed) break; + LANGameInfo* myGame = TheLAN->GetMyGame(); + if (myGame->isGameInProgress()) + return MSG_IGNORED; + GameWindow *control = (GameWindow *)mData1; Int controlID = control->winGetWindowId(); + for (Int i = 0; i < MAX_SLOTS; i++) { if (controlID == buttonMapStartPositionID[i]) { - LANGameInfo *game = TheLAN->GetMyGame(); Int playerIdxInPos = -1; for (Int j=0; jgetLANSlot(j); + LANGameSlot *slot = myGame->getLANSlot(j); if (slot && slot->getStartPos() == i) { playerIdxInPos = j; @@ -1349,8 +1361,8 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m } if (playerIdxInPos >= 0) { - LANGameSlot *slot = game->getLANSlot(playerIdxInPos); - if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI())) + LANGameSlot *slot = myGame->getLANSlot(playerIdxInPos); + if (playerIdxInPos == myGame->getLocalSlotNum() || (myGame->amIHost() && slot && slot->isAI())) { // it's one of my type. Remove it. handleStartPositionSelection(playerIdxInPos, -1); @@ -1365,6 +1377,11 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m { if (LANbuttonPushed) break; + + LANGameInfo* myGame = TheLAN->GetMyGame(); + if (myGame->isGameInProgress()) + return MSG_IGNORED; + GameWindow *control = (GameWindow *)mData1; Int controlID = control->winGetWindowId();