From 83c3f3b36fc109fb99829331150bf503b793a0c7 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Tue, 2 Jun 2026 16:49:28 +0200 Subject: [PATCH 1/4] Added first implementation. --- .../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(); From 280922ad16b9f25a6362900a3007232b88f8ce87 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Tue, 2 Jun 2026 16:50:43 +0200 Subject: [PATCH 2/4] Changed implementation. --- .../Include/GameNetwork/LANGameInfo.h | 1 + Core/GameEngine/Source/GameNetwork/LANAPI.cpp | 7 +++++++ .../GUICallbacks/Menus/LanGameOptionsMenu.cpp | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/Core/GameEngine/Include/GameNetwork/LANGameInfo.h b/Core/GameEngine/Include/GameNetwork/LANGameInfo.h index 2d0cdbd202a..a3dc0c1a719 100644 --- a/Core/GameEngine/Include/GameNetwork/LANGameInfo.h +++ b/Core/GameEngine/Include/GameNetwork/LANGameInfo.h @@ -171,6 +171,7 @@ class LANGameInfo : public GameInfo void LANDisplayGameList( GameWindow *gameListbox, LANGameInfo *gameList ); ///< Displays the list of games in a listbox, preserving selections void LANEnableStartButton(Bool enabled); +void LANDisableButtons(); void LANDisplaySlotList(); ///< Displays the slot list according to TheLANGameInfo void LANDisplayGameOptions(); ///< Displays the game options according to TheLANGameInfo diff --git a/Core/GameEngine/Source/GameNetwork/LANAPI.cpp b/Core/GameEngine/Source/GameNetwork/LANAPI.cpp index 1016d26f66b..07215e50405 100644 --- a/Core/GameEngine/Source/GameNetwork/LANAPI.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANAPI.cpp @@ -589,6 +589,13 @@ void LANAPI::update() // m_gameStartTime is when the next message goes out // m_gameStartSeconds is how many seconds remain in the message + if (m_gameStartSeconds == 1) + { + // TheSuperHackers @bugfix Disable LAN controls early to avoid a rare crash + // that may happen when using the buttons at the very last moment (after they're deinitialized). + LANDisableButtons(); + } + RequestGameStartTimer( m_gameStartSeconds ); } else if (m_gameStartTime && m_gameStartTime <= now) 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 118687259b8..f77bbf28e8d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp @@ -389,6 +389,25 @@ void LANEnableStartButton(Bool enabled) buttonSelectMap->winEnable(enabled); } +void LANDisableButtons() +{ + buttonStart->winEnable(false); + buttonBack->winEnable(false); + buttonSelectMap->winEnable(false); + checkboxLimitSuperweapons->winEnable(false); + comboBoxStartingCash->winEnable(false); + + for (Int i = 0; i < MAX_SLOTS; ++i) + { + comboBoxPlayer[i]->winEnable(false); + comboBoxColor[i]->winEnable(false); + comboBoxPlayerTemplate[i]->winEnable(false); + comboBoxTeam[i]->winEnable(false); + buttonAccept[i]->winEnable(false); + buttonMapStartPosition[i]->winEnable(false); + } +} + static void handleColorSelection(int index) { GameWindow *combo = comboBoxColor[index]; From beea96f4596a43e8cf355b401a7713f463c91d72 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Tue, 2 Jun 2026 16:50:51 +0200 Subject: [PATCH 3/4] Revert "Added first implementation." This reverts commit 83c3f3b36fc109fb99829331150bf503b793a0c7. --- .../GUICallbacks/Menus/LanGameOptionsMenu.cpp | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 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 f77bbf28e8d..639b8fbe73c 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp @@ -1171,13 +1171,9 @@ 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 ) { @@ -1243,11 +1239,6 @@ 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(); @@ -1298,7 +1289,7 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m TheLAN->RequestAccept(); // Disable the accept button - EnableAcceptControls(TRUE, myGame, comboBoxPlayer, comboBoxColor, comboBoxPlayerTemplate, + EnableAcceptControls(TRUE, TheLAN->GetMyGame(), comboBoxPlayer, comboBoxColor, comboBoxPlayerTemplate, comboBoxTeam, buttonAccept, buttonStart, buttonMapStartPosition); } @@ -1313,10 +1304,11 @@ 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 = game->getLANSlot(j); if (slot && slot->getStartPos() == i) { playerIdxInPos = j; @@ -1325,8 +1317,8 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m } if (playerIdxInPos >= 0) { - LANGameSlot *slot = myGame->getLANSlot(playerIdxInPos); - if (playerIdxInPos == myGame->getLocalSlotNum() || (myGame->amIHost() && slot && slot->isAI())) + LANGameSlot *slot = game->getLANSlot(playerIdxInPos); + if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI())) { // it's one of my type. Try to change it. Int nextPlayer = getNextSelectablePlayer(playerIdxInPos+1); @@ -1342,7 +1334,7 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m // nobody in the slot - put us in Int nextPlayer = getNextSelectablePlayer(0); if (nextPlayer < 0) - nextPlayer = getFirstSelectablePlayer(myGame); + nextPlayer = getFirstSelectablePlayer(game); handleStartPositionSelection(nextPlayer, i); } } @@ -1357,21 +1349,17 @@ 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 = game->getLANSlot(j); if (slot && slot->getStartPos() == i) { playerIdxInPos = j; @@ -1380,8 +1368,8 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m } if (playerIdxInPos >= 0) { - LANGameSlot *slot = myGame->getLANSlot(playerIdxInPos); - if (playerIdxInPos == myGame->getLocalSlotNum() || (myGame->amIHost() && slot && slot->isAI())) + LANGameSlot *slot = game->getLANSlot(playerIdxInPos); + if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI())) { // it's one of my type. Remove it. handleStartPositionSelection(playerIdxInPos, -1); @@ -1396,11 +1384,6 @@ 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(); From c6beb0647fd253b081671a46737f04979269981f Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Tue, 2 Jun 2026 16:56:29 +0200 Subject: [PATCH 4/4] Tweaked comment. --- Core/GameEngine/Source/GameNetwork/LANAPI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/GameEngine/Source/GameNetwork/LANAPI.cpp b/Core/GameEngine/Source/GameNetwork/LANAPI.cpp index 07215e50405..305422c848d 100644 --- a/Core/GameEngine/Source/GameNetwork/LANAPI.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANAPI.cpp @@ -591,8 +591,8 @@ void LANAPI::update() if (m_gameStartSeconds == 1) { - // TheSuperHackers @bugfix Disable LAN controls early to avoid a rare crash - // that may happen when using the buttons at the very last moment (after they're deinitialized). + // TheSuperHackers @bugfix Disable LAN menu buttons early to avoid a rare crash + // that may happen when using the buttons at the last moment (after they're deinitialized). LANDisableButtons(); }