Skip to content

Commit 52ffb5c

Browse files
Caball009xezon
authored andcommitted
refactor(logic): Rename thisPlayer to msgPlayer in GameLogic::logicMessageDispatcher (#2383)
1 parent 5a36bdb commit 52ffb5c

File tree

2 files changed

+109
-109
lines changed

2 files changed

+109
-109
lines changed

Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
346346
DEBUG_ASSERTCRASH(msg != nullptr && msg != (GameMessage*)0xdeadbeef, ("bad msg"));
347347
#endif
348348

349-
Player *thisPlayer = ThePlayerList->getNthPlayer( msg->getPlayerIndex() );
350-
DEBUG_ASSERTCRASH( thisPlayer, ("logicMessageDispatcher: Processing message from unknown player (player index '%d')",
349+
Player *msgPlayer = ThePlayerList->getNthPlayer( msg->getPlayerIndex() );
350+
DEBUG_ASSERTCRASH( msgPlayer, ("logicMessageDispatcher: Processing message from unknown player (player index '%d')",
351351
msg->getPlayerIndex()) );
352352

353353
AIGroupPtr currentlySelectedGroup = nullptr;
@@ -361,9 +361,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
361361
currentlySelectedGroup = TheAI->createGroup(); // can't do this outside a game - it'll cause sync errors galore.
362362
CRCGEN_LOG(( "Creating AIGroup %d in GameLogic::logicMessageDispatcher()", currentlySelectedGroup?currentlySelectedGroup->getID():0 ));
363363
#if RETAIL_COMPATIBLE_AIGROUP
364-
thisPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup);
364+
msgPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup);
365365
#else
366-
thisPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup.Peek());
366+
msgPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup.Peek());
367367
#endif
368368

369369
// We can't issue commands to groups that contain units that don't belong to the issuing player, so pretend like
@@ -379,7 +379,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
379379

380380
// If there are any units that the player doesn't own, then remove them from the "currentlySelectedGroup"
381381
if (currentlySelectedGroup)
382-
if (currentlySelectedGroup->removeAnyObjectsNotOwnedByPlayer(thisPlayer))
382+
if (currentlySelectedGroup->removeAnyObjectsNotOwnedByPlayer(msgPlayer))
383383
currentlySelectedGroup = nullptr;
384384

385385
if(TheStatsCollector)
@@ -404,7 +404,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
404404
if (commandName.isNotEmpty() /*&& msg->getType() != GameMessage::MSG_FRAME_TICK*/)
405405
{
406406
DEBUG_LOG(("Frame %d: GameLogic::logicMessageDispatcher() saw a %s from player %d (%ls)", getFrame(), commandName.str(),
407-
msg->getPlayerIndex(), thisPlayer->getPlayerDisplayName().str()));
407+
msg->getPlayerIndex(), msgPlayer->getPlayerDisplayName().str()));
408408
}
409409
#endif
410410
#endif // DEBUG_LOGGING
@@ -525,10 +525,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
525525
{
526526
#if !RETAIL_COMPATIBLE_CRC
527527
// TheSuperHackers @fix stephanmeesters 11/03/2026 Validate the owner of the source object
528-
if ( obj->getControllingPlayer() != thisPlayer )
528+
if ( obj->getControllingPlayer() != msgPlayer )
529529
{
530530
DEBUG_CRASH( ("MSG_SET_RALLY_POINT: Player '%ls' attempted to set the rally point of object '%s' owned by player '%ls'.",
531-
thisPlayer->getPlayerDisplayName().str(),
531+
msgPlayer->getPlayerDisplayName().str(),
532532
obj->getTemplate()->getName().str(),
533533
obj->getControllingPlayer()->getPlayerDisplayName().str()) );
534534
break;
@@ -690,10 +690,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
690690
{
691691
#if !RETAIL_COMPATIBLE_CRC
692692
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
693-
if ( source->getControllingPlayer() != thisPlayer )
693+
if ( source->getControllingPlayer() != msgPlayer )
694694
{
695695
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
696-
thisPlayer->getPlayerDisplayName().str(),
696+
msgPlayer->getPlayerDisplayName().str(),
697697
source->getTemplate()->getName().str(),
698698
source->getControllingPlayer()->getPlayerDisplayName().str()) );
699699
break;
@@ -744,10 +744,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
744744
{
745745
#if !RETAIL_COMPATIBLE_CRC
746746
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
747-
if ( source->getControllingPlayer() != thisPlayer )
747+
if ( source->getControllingPlayer() != msgPlayer )
748748
{
749749
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_LOCATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
750-
thisPlayer->getPlayerDisplayName().str(),
750+
msgPlayer->getPlayerDisplayName().str(),
751751
source->getTemplate()->getName().str(),
752752
source->getControllingPlayer()->getPlayerDisplayName().str()) );
753753
break;
@@ -799,10 +799,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
799799
{
800800
#if !RETAIL_COMPATIBLE_CRC
801801
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
802-
if ( source->getControllingPlayer() != thisPlayer )
802+
if ( source->getControllingPlayer() != msgPlayer )
803803
{
804804
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_OBJECT: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
805-
thisPlayer->getPlayerDisplayName().str(),
805+
msgPlayer->getPlayerDisplayName().str(),
806806
source->getTemplate()->getName().str(),
807807
source->getControllingPlayer()->getPlayerDisplayName().str()) );
808808
break;
@@ -1073,7 +1073,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
10731073
break;
10741074

10751075
// sanity, the player must actually control this object
1076-
if( objectWantingToExit->getControllingPlayer() != thisPlayer )
1076+
if( objectWantingToExit->getControllingPlayer() != msgPlayer )
10771077
break;
10781078

10791079
objectWantingToExit->releaseWeaponLock(LOCKED_TEMPORARILY); // release any temporary locks.
@@ -1252,10 +1252,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
12521252
{
12531253
#if !RETAIL_COMPATIBLE_CRC
12541254
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
1255-
if ( source->getControllingPlayer() != thisPlayer )
1255+
if ( source->getControllingPlayer() != msgPlayer )
12561256
{
12571257
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
1258-
thisPlayer->getPlayerDisplayName().str(),
1258+
msgPlayer->getPlayerDisplayName().str(),
12591259
source->getTemplate()->getName().str(),
12601260
source->getControllingPlayer()->getPlayerDisplayName().str()) );
12611261
break;
@@ -1393,7 +1393,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
13931393
break;
13941394

13951395
// the player must actually control the producer object
1396-
if( producer->getControllingPlayer() != thisPlayer )
1396+
if( producer->getControllingPlayer() != msgPlayer )
13971397
break;
13981398

13991399
// producer must have a production update
@@ -1460,7 +1460,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
14601460
break;
14611461

14621462
// sanity, the player must control the producer
1463-
if( producer->getControllingPlayer() != thisPlayer )
1463+
if( producer->getControllingPlayer() != msgPlayer )
14641464
break;
14651465

14661466
// get the unit production interface
@@ -1544,7 +1544,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
15441544
break;
15451545

15461546
// the player sending this message must actually control this building
1547-
if( building->getControllingPlayer() != thisPlayer )
1547+
if( building->getControllingPlayer() != msgPlayer )
15481548
break;
15491549

15501550
// Check to make sure it is actually under construction
@@ -1554,8 +1554,8 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
15541554
// OK, refund the money to the player, unless it is a rebuilding Hole.
15551555
if( !building->testStatus(OBJECT_STATUS_RECONSTRUCTING))
15561556
{
1557-
Money *money = thisPlayer->getMoney();
1558-
UnsignedInt amount = building->getTemplate()->calcCostToBuild( thisPlayer );
1557+
Money *money = msgPlayer->getMoney();
1558+
UnsignedInt amount = building->getTemplate()->calcCostToBuild( msgPlayer );
15591559
money->deposit( amount, TRUE, FALSE );
15601560
}
15611561

@@ -1705,57 +1705,57 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
17051705
// --------------------------------------------------------------------------------------------
17061706
case GameMessage::MSG_PLACE_BEACON:
17071707
{
1708-
if (thisPlayer->getPlayerTemplate() == nullptr)
1708+
if (msgPlayer->getPlayerTemplate() == nullptr)
17091709
break;
17101710
Coord3D pos = msg->getArgument( 0 )->location;
17111711
Region3D r;
17121712
TheTerrainLogic->getExtent(&r);
17131713
if (!r.isInRegionNoZ(&pos))
17141714
pos = TheTerrainLogic->findClosestEdgePoint(&pos);
1715-
const ThingTemplate *thing = TheThingFactory->findTemplate( thisPlayer->getPlayerTemplate()->getBeaconTemplate() );
1716-
if (thing && !TheVictoryConditions->hasSinglePlayerBeenDefeated(thisPlayer))
1715+
const ThingTemplate *thing = TheThingFactory->findTemplate( msgPlayer->getPlayerTemplate()->getBeaconTemplate() );
1716+
if (thing && !TheVictoryConditions->hasSinglePlayerBeenDefeated(msgPlayer))
17171717
{
17181718
// how many does this player have active?
17191719
Int count;
1720-
thisPlayer->countObjectsByThingTemplate( 1, &thing, false, &count );
1720+
msgPlayer->countObjectsByThingTemplate( 1, &thing, false, &count );
17211721
DEBUG_LOG(("Player already has %d beacons active", count));
17221722
if (count >= TheMultiplayerSettings->getMaxBeaconsPerPlayer())
17231723
{
1724-
if (thisPlayer == ThePlayerList->getLocalPlayer())
1724+
if (msgPlayer == ThePlayerList->getLocalPlayer())
17251725
{
17261726
// tell the user
17271727
TheInGameUI->message( TheGameText->fetch("GUI:TooManyBeacons") );
17281728

17291729
// play a sound
17301730
static AudioEventRTS aSound("BeaconPlacementFailed");
17311731
aSound.setPosition(&pos);
1732-
aSound.setPlayerIndex(thisPlayer->getPlayerIndex());
1732+
aSound.setPlayerIndex(msgPlayer->getPlayerIndex());
17331733
TheAudio->addAudioEvent(&aSound);
17341734
}
17351735

17361736
break;
17371737
}
1738-
Object *object = TheThingFactory->newObject( thing, thisPlayer->getDefaultTeam() );
1738+
Object *object = TheThingFactory->newObject( thing, msgPlayer->getDefaultTeam() );
17391739
object->setPosition( &pos );
17401740
object->setProducer(nullptr);
17411741

1742-
if (thisPlayer->getRelationship( ThePlayerList->getLocalPlayer()->getDefaultTeam() ) == ALLIES || ThePlayerList->getLocalPlayer()->isPlayerObserver())
1742+
if (msgPlayer->getRelationship( ThePlayerList->getLocalPlayer()->getDefaultTeam() ) == ALLIES || ThePlayerList->getLocalPlayer()->isPlayerObserver())
17431743
{
17441744
// tell the user
17451745
UnicodeString s;
1746-
s.format(TheGameText->fetch("GUI:BeaconPlaced"), thisPlayer->getPlayerDisplayName().str());
1746+
s.format(TheGameText->fetch("GUI:BeaconPlaced"), msgPlayer->getPlayerDisplayName().str());
17471747
TheInGameUI->message( s );
17481748

17491749
// play a sound
17501750
static AudioEventRTS aSound("BeaconPlaced");
1751-
aSound.setPlayerIndex(thisPlayer->getPlayerIndex());
1751+
aSound.setPlayerIndex(msgPlayer->getPlayerIndex());
17521752
aSound.setPosition(&pos);
17531753
TheAudio->addAudioEvent(&aSound);
17541754

17551755
// beacons are a rare event; play a nifty radar event thingy
17561756
TheRadar->createEvent( object->getPosition(), RADAR_EVENT_INFORMATION );
17571757

1758-
if (ThePlayerList->getLocalPlayer()->getRelationship(thisPlayer->getDefaultTeam()) == ALLIES)
1758+
if (ThePlayerList->getLocalPlayer()->getRelationship(msgPlayer->getDefaultTeam()) == ALLIES)
17591759
TheEva->setShouldPlay(EVA_BeaconDetected);
17601760

17611761
TheControlBar->markUIDirty(); // check if we should grey out the button
@@ -1791,7 +1791,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
17911791
// play a sound
17921792
static AudioEventRTS aSound("BeaconPlacementFailed");
17931793
aSound.setPosition(&pos);
1794-
aSound.setPlayerIndex(thisPlayer->getPlayerIndex());
1794+
aSound.setPlayerIndex(msgPlayer->getPlayerIndex());
17951795
TheAudio->addAudioEvent(&aSound);
17961796
}
17971797
break;
@@ -1802,9 +1802,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
18021802
{
18031803
AIGroupPtr allSelectedObjects = TheAI->createGroup();
18041804
#if RETAIL_COMPATIBLE_AIGROUP
1805-
thisPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects); // need to act on all objects, so we can hide teammates' beacons.
1805+
msgPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects); // need to act on all objects, so we can hide teammates' beacons.
18061806
#else
1807-
thisPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects.Peek()); // need to act on all objects, so we can hide teammates' beacons.
1807+
msgPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects.Peek()); // need to act on all objects, so we can hide teammates' beacons.
18081808
#endif
18091809
if( allSelectedObjects )
18101810
{
@@ -1822,13 +1822,13 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
18221822
const ThingTemplate *thing = TheThingFactory->findTemplate( playerTemplate->getBeaconTemplate() );
18231823
if (thing && thing->isEquivalentTo(beacon->getTemplate()))
18241824
{
1825-
if (beacon->getControllingPlayer() == thisPlayer)
1825+
if (beacon->getControllingPlayer() == msgPlayer)
18261826
{
18271827
destroyObject(beacon); // the owner is telling it to go away. such is life.
18281828

18291829
TheControlBar->markUIDirty(); // check if we should un-grey out the button
18301830
}
1831-
else if (thisPlayer == ThePlayerList->getLocalPlayer())
1831+
else if (msgPlayer == ThePlayerList->getLocalPlayer())
18321832
{
18331833
Drawable *beaconDrawable = beacon->getDrawable();
18341834
if (beaconDrawable)
@@ -1905,28 +1905,28 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
19051905
if (i != msg->getPlayerIndex())
19061906
{
19071907
Player *otherPlayer = ThePlayerList->getNthPlayer(i);
1908-
if (thisPlayer->getRelationship(otherPlayer->getDefaultTeam()) == ALLIES &&
1909-
otherPlayer->getRelationship(thisPlayer->getDefaultTeam()) == ALLIES)
1908+
if (msgPlayer->getRelationship(otherPlayer->getDefaultTeam()) == ALLIES &&
1909+
otherPlayer->getRelationship(msgPlayer->getDefaultTeam()) == ALLIES)
19101910
{
19111911
if (TheVictoryConditions->hasSinglePlayerBeenDefeated(otherPlayer))
19121912
continue;
19131913

19141914
// a living ally! hooray!
1915-
otherPlayer->transferAssetsFromThat(thisPlayer);
1916-
thisPlayer->killPlayer(); // just to be safe (and to kill beacons etc that don't transfer)
1915+
otherPlayer->transferAssetsFromThat(msgPlayer);
1916+
msgPlayer->killPlayer(); // just to be safe (and to kill beacons etc that don't transfer)
19171917
break;
19181918
}
19191919
}
19201920
}
19211921
if (i == ThePlayerList->getPlayerCount())
19221922
{
19231923
// didn't find any allies. die, loner!
1924-
thisPlayer->killPlayer();
1924+
msgPlayer->killPlayer();
19251925
}
19261926
}
19271927
else
19281928
{
1929-
thisPlayer->killPlayer();
1929+
msgPlayer->killPlayer();
19301930
}
19311931
// There is no reason to do any notification here, it now takes place in the victory conditions.
19321932
// bonehead.
@@ -1936,7 +1936,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
19361936
// --------------------------------------------------------------------------------------------
19371937
case GameMessage::MSG_SET_REPLAY_CAMERA:
19381938
{
1939-
if (TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == thisPlayer)
1939+
if (TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == msgPlayer)
19401940
{
19411941
if (TheTacticalView->isCameraMovementFinished())
19421942
{
@@ -2052,7 +2052,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
20522052
Int slotIndex = -1;
20532053
for (Int i=0; i<MAX_SLOTS; ++i)
20542054
{
2055-
if (thisPlayer->getPlayerType() == PLAYER_HUMAN && TheNetwork->getPlayerName(i) == thisPlayer->getPlayerDisplayName())
2055+
if (msgPlayer->getPlayerType() == PLAYER_HUMAN && TheNetwork->getPlayerName(i) == msgPlayer->getPlayerDisplayName())
20562056
{
20572057
slotIndex = i;
20582058
break;
@@ -2062,7 +2062,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
20622062
if (slotIndex < 0 || !TheNetwork->isPlayerConnected(slotIndex))
20632063
break;
20642064

2065-
if (thisPlayer->isLocalPlayer())
2065+
if (msgPlayer->isLocalPlayer())
20662066
{
20672067
#if defined(RTS_DEBUG)
20682068
// don't even put this in release, cause someone might hack it.
@@ -2078,16 +2078,16 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
20782078
//UnsignedInt oldCRC = m_cachedCRCs[msg->getPlayerIndex()];
20792079
UnsignedInt newCRC = msg->getArgument(0)->integer;
20802080
//DEBUG_LOG(("Received CRC of %8.8X from %ls on frame %d", newCRC,
2081-
//thisPlayer->getPlayerDisplayName().str(), m_frame));
2081+
//msgPlayer->getPlayerDisplayName().str(), m_frame));
20822082
m_cachedCRCs[msg->getPlayerIndex()] = newCRC; // to mask problem: = (oldCRC < newCRC)?newCRC:oldCRC;
20832083
}
20842084
else if (TheRecorder && TheRecorder->isPlaybackMode())
20852085
{
20862086
UnsignedInt newCRC = msg->getArgument(0)->integer;
20872087
//DEBUG_LOG(("Saw CRC of %X from player %d. Our CRC is %X. Arg count is %d",
2088-
//newCRC, thisPlayer->getPlayerIndex(), getCRC(), msg->getArgumentCount()));
2088+
//newCRC, msgPlayer->getPlayerIndex(), getCRC(), msg->getArgumentCount()));
20892089

2090-
TheRecorder->handleCRCMessage(newCRC, thisPlayer->getPlayerIndex(), (msg->getArgument(1)->boolean));
2090+
TheRecorder->handleCRCMessage(newCRC, msgPlayer->getPlayerIndex(), (msg->getArgument(1)->boolean));
20912091
}
20922092
break;
20932093

@@ -2099,10 +2099,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
20992099
ScienceType science = (ScienceType)msg->getArgument( 0 )->integer;
21002100

21012101
// sanity
2102-
if( science == SCIENCE_INVALID || thisPlayer == nullptr )
2102+
if( science == SCIENCE_INVALID || msgPlayer == nullptr )
21032103
break;
21042104

2105-
thisPlayer->attemptToPurchaseScience(science);
2105+
msgPlayer->attemptToPurchaseScience(science);
21062106

21072107
break;
21082108

@@ -2119,7 +2119,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
21192119
#endif
21202120

21212121
/**/ /// @todo: multiplayer semantics
2122-
if (currentlySelectedGroup && TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == thisPlayer /*&& !TheRecorder->isMultiplayer()*/)
2122+
if (currentlySelectedGroup && TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == msgPlayer /*&& !TheRecorder->isMultiplayer()*/)
21232123
{
21242124
const VecObjectID& selectedObjects = currentlySelectedGroup->getAllIDs();
21252125
TheInGameUI->deselectAllDrawables();

0 commit comments

Comments
 (0)