-
Notifications
You must be signed in to change notification settings - Fork 189
bugfix(lan): Fix crash when changing settings in the LAN lobby #2676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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()) | ||
|
xezon marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is very suspicious that the menu can still be interacted with after it was shutdown. Why is this possible? Is there maybe a general issue with menus?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is because of a general issues with menus. The game just nulls the button pointers before it changes the window / takes away control from the user. Perhaps from user perspective the cleanest solution would be to disable (grey out) the buttons when the timer has zero seconds remaining. I don't know how to access the buttons in the code that has access to the timer, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good if the window is changed or control is taken before the button pointers are nulled. That way no special safe guards need to be placed in multiple handlers. Is the issue maybe that the handling of a button press is delayed by 1 or multiple frames because of input system updates, and so it can arrive after the menu screen was destroyed? If so, maybe the solution here is to add a condition into every menu input handler and check that the owning menu is still active, and if not, return early and do not handle the input. |
||
| 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; j<MAX_SLOTS; ++j) | ||
| { | ||
| LANGameSlot *slot = game->getLANSlot(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; j<MAX_SLOTS; ++j) | ||
| { | ||
| LANGameSlot *slot = game->getLANSlot(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(); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.