Skip to content

Commit b868561

Browse files
authored
[GEN][ZH] Remove unnecessary NULL pointer test in UpdateSlotList() (#1120)
1 parent d96ccec commit b868561

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

Generals/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,14 @@ void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
339339
for( int i =0; i < MAX_SLOTS; i++ )
340340
{
341341
GameSlot * slot = myGame->getSlot(i);
342+
342343
// if i'm host, enable the controls for AI
343-
if(myGame->amIHost() && slot && slot->isAI())
344+
if(myGame->amIHost() && slot->isAI())
344345
{
345346
EnableAcceptControls(TRUE, myGame, comboPlayer, comboColor, comboPlayerTemplate,
346347
comboTeam, buttonAccept, buttonStart, buttonMapStartPosition, i);
347348
}
348-
else if (slot && myGame->getLocalSlotNum() == i)
349+
else if (myGame->getLocalSlotNum() == i)
349350
{
350351
if(slot->isAccepted() && !myGame->amIHost())
351352
{
@@ -371,7 +372,7 @@ void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
371372
EnableAcceptControls(FALSE, myGame, comboPlayer, comboColor, comboPlayerTemplate,
372373
comboTeam, buttonAccept, buttonStart, buttonMapStartPosition, i);
373374
}
374-
if(slot && slot->isHuman())
375+
if(slot->isHuman())
375376
{
376377
UnicodeString newName = slot->getName();
377378
UnicodeString oldName = GadgetComboBoxGetText(comboPlayer[i]);

Generals/Code/GameEngine/Source/GameNetwork/GameInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ GameSlot* GameInfo::getSlot( Int slotNum )
449449
if (slotNum < 0 || slotNum >= MAX_SLOTS)
450450
return NULL;
451451

452+
DEBUG_ASSERTCRASH( m_slot[slotNum], ("NULL slot pointer") );
452453
return m_slot[slotNum];
453454
}
454455

@@ -458,6 +459,7 @@ const GameSlot* GameInfo::getConstSlot( Int slotNum ) const
458459
if (slotNum < 0 || slotNum >= MAX_SLOTS)
459460
return NULL;
460461

462+
DEBUG_ASSERTCRASH( m_slot[slotNum], ("NULL slot pointer") );
461463
return m_slot[slotNum];
462464
}
463465

GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,14 @@ void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
393393
for( int i =0; i < MAX_SLOTS; i++ )
394394
{
395395
GameSlot * slot = myGame->getSlot(i);
396+
396397
// if i'm host, enable the controls for AI
397-
if(myGame->amIHost() && slot && slot->isAI())
398+
if(myGame->amIHost() && slot->isAI())
398399
{
399400
EnableAcceptControls(TRUE, myGame, comboPlayer, comboColor, comboPlayerTemplate,
400401
comboTeam, buttonAccept, buttonStart, buttonMapStartPosition, i);
401402
}
402-
else if (slot && myGame->getLocalSlotNum() == i)
403+
else if (myGame->getLocalSlotNum() == i)
403404
{
404405
if(slot->isAccepted() && !myGame->amIHost())
405406
{
@@ -425,7 +426,7 @@ void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
425426
EnableAcceptControls(FALSE, myGame, comboPlayer, comboColor, comboPlayerTemplate,
426427
comboTeam, buttonAccept, buttonStart, buttonMapStartPosition, i);
427428
}
428-
if(slot && slot->isHuman())
429+
if(slot->isHuman())
429430
{
430431
UnicodeString newName = slot->getName();
431432
UnicodeString oldName = GadgetComboBoxGetText(comboPlayer[i]);

GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ GameSlot* GameInfo::getSlot( Int slotNum )
454454
if (slotNum < 0 || slotNum >= MAX_SLOTS)
455455
return NULL;
456456

457+
DEBUG_ASSERTCRASH( m_slot[slotNum], ("NULL slot pointer") );
457458
return m_slot[slotNum];
458459
}
459460

@@ -463,6 +464,7 @@ const GameSlot* GameInfo::getConstSlot( Int slotNum ) const
463464
if (slotNum < 0 || slotNum >= MAX_SLOTS)
464465
return NULL;
465466

467+
DEBUG_ASSERTCRASH( m_slot[slotNum], ("NULL slot pointer") );
466468
return m_slot[slotNum];
467469
}
468470

0 commit comments

Comments
 (0)