Skip to content

Commit b23c39e

Browse files
committed
bugfix(lan): Fix crash when changing settings in the LAN options menu.
1 parent a9b260a commit b23c39e

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,9 +1152,13 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
11521152
{
11531153
if (LANbuttonPushed)
11541154
break;
1155+
1156+
LANGameInfo* myGame = TheLAN->GetMyGame();
1157+
if (myGame->isGameInProgress())
1158+
return MSG_IGNORED;
1159+
11551160
GameWindow *control = (GameWindow *)mData1;
11561161
Int controlID = control->winGetWindowId();
1157-
LANGameInfo *myGame = TheLAN->GetMyGame();
11581162

11591163
if ( controlID == comboBoxStartingCashID )
11601164
{
@@ -1220,6 +1224,11 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
12201224
{
12211225
if (LANbuttonPushed)
12221226
break;
1227+
1228+
LANGameInfo* myGame = TheLAN->GetMyGame();
1229+
if (myGame->isGameInProgress())
1230+
return MSG_IGNORED;
1231+
12231232
GameWindow *control = (GameWindow *)mData1;
12241233
Int controlID = control->winGetWindowId();
12251234

@@ -1270,7 +1279,7 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
12701279
TheLAN->RequestAccept();
12711280

12721281
// Disable the accept button
1273-
EnableAcceptControls(TRUE, TheLAN->GetMyGame(), comboBoxPlayer, comboBoxColor, comboBoxPlayerTemplate,
1282+
EnableAcceptControls(TRUE, myGame, comboBoxPlayer, comboBoxColor, comboBoxPlayerTemplate,
12741283
comboBoxTeam, buttonAccept, buttonStart, buttonMapStartPosition);
12751284

12761285
}
@@ -1285,11 +1294,10 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
12851294
{
12861295
if (controlID == buttonMapStartPositionID[i])
12871296
{
1288-
LANGameInfo *game = TheLAN->GetMyGame();
12891297
Int playerIdxInPos = -1;
12901298
for (Int j=0; j<MAX_SLOTS; ++j)
12911299
{
1292-
LANGameSlot *slot = game->getLANSlot(j);
1300+
LANGameSlot *slot = myGame->getLANSlot(j);
12931301
if (slot && slot->getStartPos() == i)
12941302
{
12951303
playerIdxInPos = j;
@@ -1298,8 +1306,8 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
12981306
}
12991307
if (playerIdxInPos >= 0)
13001308
{
1301-
LANGameSlot *slot = game->getLANSlot(playerIdxInPos);
1302-
if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI()))
1309+
LANGameSlot *slot = myGame->getLANSlot(playerIdxInPos);
1310+
if (playerIdxInPos == myGame->getLocalSlotNum() || (myGame->amIHost() && slot && slot->isAI()))
13031311
{
13041312
// it's one of my type. Try to change it.
13051313
Int nextPlayer = getNextSelectablePlayer(playerIdxInPos+1);
@@ -1315,7 +1323,7 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
13151323
// nobody in the slot - put us in
13161324
Int nextPlayer = getNextSelectablePlayer(0);
13171325
if (nextPlayer < 0)
1318-
nextPlayer = getFirstSelectablePlayer(game);
1326+
nextPlayer = getFirstSelectablePlayer(myGame);
13191327
handleStartPositionSelection(nextPlayer, i);
13201328
}
13211329
}
@@ -1330,17 +1338,21 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
13301338
if (LANbuttonPushed)
13311339
break;
13321340

1341+
LANGameInfo* myGame = TheLAN->GetMyGame();
1342+
if (myGame->isGameInProgress())
1343+
return MSG_IGNORED;
1344+
13331345
GameWindow *control = (GameWindow *)mData1;
13341346
Int controlID = control->winGetWindowId();
1347+
13351348
for (Int i = 0; i < MAX_SLOTS; i++)
13361349
{
13371350
if (controlID == buttonMapStartPositionID[i])
13381351
{
1339-
LANGameInfo *game = TheLAN->GetMyGame();
13401352
Int playerIdxInPos = -1;
13411353
for (Int j=0; j<MAX_SLOTS; ++j)
13421354
{
1343-
LANGameSlot *slot = game->getLANSlot(j);
1355+
LANGameSlot *slot = myGame->getLANSlot(j);
13441356
if (slot && slot->getStartPos() == i)
13451357
{
13461358
playerIdxInPos = j;
@@ -1349,8 +1361,8 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
13491361
}
13501362
if (playerIdxInPos >= 0)
13511363
{
1352-
LANGameSlot *slot = game->getLANSlot(playerIdxInPos);
1353-
if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI()))
1364+
LANGameSlot *slot = myGame->getLANSlot(playerIdxInPos);
1365+
if (playerIdxInPos == myGame->getLocalSlotNum() || (myGame->amIHost() && slot && slot->isAI()))
13541366
{
13551367
// it's one of my type. Remove it.
13561368
handleStartPositionSelection(playerIdxInPos, -1);
@@ -1365,6 +1377,11 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
13651377
{
13661378
if (LANbuttonPushed)
13671379
break;
1380+
1381+
LANGameInfo* myGame = TheLAN->GetMyGame();
1382+
if (myGame->isGameInProgress())
1383+
return MSG_IGNORED;
1384+
13681385
GameWindow *control = (GameWindow *)mData1;
13691386
Int controlID = control->winGetWindowId();
13701387

0 commit comments

Comments
 (0)