diff --git a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp index 369d76f11e7..79cb042e1e0 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp @@ -346,9 +346,12 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) DEBUG_ASSERTCRASH(msg != nullptr && msg != (GameMessage*)0xdeadbeef, ("bad msg")); #endif - Player *thisPlayer = ThePlayerList->getNthPlayer( msg->getPlayerIndex() ); - DEBUG_ASSERTCRASH( thisPlayer, ("logicMessageDispatcher: Processing message from unknown player (player index '%d')", - msg->getPlayerIndex()) ); + Player *msgPlayer = ThePlayerList->getNthPlayer( msg->getPlayerIndex() ); + if (msgPlayer == nullptr) + { + DEBUG_CRASH(("logicMessageDispatcher: Processing message from unknown player (player index '%d')", msg->getPlayerIndex())); + return; + } AIGroupPtr currentlySelectedGroup = nullptr; @@ -361,9 +364,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) currentlySelectedGroup = TheAI->createGroup(); // can't do this outside a game - it'll cause sync errors galore. CRCGEN_LOG(( "Creating AIGroup %d in GameLogic::logicMessageDispatcher()", currentlySelectedGroup?currentlySelectedGroup->getID():0 )); #if RETAIL_COMPATIBLE_AIGROUP - thisPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup); + msgPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup); #else - thisPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup.Peek()); + msgPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup.Peek()); #endif // We can't issue commands to groups that contain units that don't belong to the issuing player, so pretend like @@ -379,7 +382,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // If there are any units that the player doesn't own, then remove them from the "currentlySelectedGroup" if (currentlySelectedGroup) - if (currentlySelectedGroup->removeAnyObjectsNotOwnedByPlayer(thisPlayer)) + if (currentlySelectedGroup->removeAnyObjectsNotOwnedByPlayer(msgPlayer)) currentlySelectedGroup = nullptr; if(TheStatsCollector) @@ -404,7 +407,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) if (commandName.isNotEmpty() /*&& msg->getType() != GameMessage::MSG_FRAME_TICK*/) { DEBUG_LOG(("Frame %d: GameLogic::logicMessageDispatcher() saw a %s from player %d (%ls)", getFrame(), commandName.str(), - msg->getPlayerIndex(), thisPlayer->getPlayerDisplayName().str())); + msgPlayer->getPlayerIndex(), msgPlayer->getPlayerDisplayName().str())); } #endif #endif // DEBUG_LOGGING @@ -525,10 +528,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 11/03/2026 Validate the owner of the source object - if ( obj->getControllingPlayer() != thisPlayer ) + if ( obj->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_SET_RALLY_POINT: Player '%ls' attempted to set the rally point of object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), obj->getTemplate()->getName().str(), obj->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -690,10 +693,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object - if ( source->getControllingPlayer() != thisPlayer ) + if ( source->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER: Player '%ls' attempted to control the object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), source->getTemplate()->getName().str(), source->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -744,10 +747,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object - if ( source->getControllingPlayer() != thisPlayer ) + if ( source->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_LOCATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), source->getTemplate()->getName().str(), source->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -799,10 +802,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object - if ( source->getControllingPlayer() != thisPlayer ) + if ( source->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_OBJECT: Player '%ls' attempted to control the object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), source->getTemplate()->getName().str(), source->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -1073,7 +1076,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) break; // sanity, the player must actually control this object - if( objectWantingToExit->getControllingPlayer() != thisPlayer ) + if( objectWantingToExit->getControllingPlayer() != msgPlayer ) break; objectWantingToExit->releaseWeaponLock(LOCKED_TEMPORARILY); // release any temporary locks. @@ -1252,10 +1255,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object - if ( source->getControllingPlayer() != thisPlayer ) + if ( source->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), source->getTemplate()->getName().str(), source->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -1393,7 +1396,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) break; // the player must actually control the producer object - if( producer->getControllingPlayer() != thisPlayer ) + if( producer->getControllingPlayer() != msgPlayer ) break; // producer must have a production update @@ -1460,7 +1463,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) break; // sanity, the player must control the producer - if( producer->getControllingPlayer() != thisPlayer ) + if( producer->getControllingPlayer() != msgPlayer ) break; // get the unit production interface @@ -1544,7 +1547,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) break; // the player sending this message must actually control this building - if( building->getControllingPlayer() != thisPlayer ) + if( building->getControllingPlayer() != msgPlayer ) break; // Check to make sure it is actually under construction @@ -1554,8 +1557,8 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // OK, refund the money to the player, unless it is a rebuilding Hole. if( !building->testStatus(OBJECT_STATUS_RECONSTRUCTING)) { - Money *money = thisPlayer->getMoney(); - UnsignedInt amount = building->getTemplate()->calcCostToBuild( thisPlayer ); + Money *money = msgPlayer->getMoney(); + UnsignedInt amount = building->getTemplate()->calcCostToBuild( msgPlayer ); money->deposit( amount, TRUE, FALSE ); } @@ -1634,13 +1637,6 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) case GameMessage::MSG_CREATE_SELECTED_GROUP: { Bool createNewGroup = msg->getArgument( 0 )->boolean; - Player *player = ThePlayerList->getNthPlayer(msg->getPlayerIndex()); - - if (player == nullptr) { - DEBUG_CRASH(("GameLogicDispatch - MSG_CREATE_SELECTED_GROUP had an invalid player number")); - break; - } - Bool firstObject = TRUE; for (Int i = 1; i < msg->getArgumentCount(); ++i) { @@ -1649,7 +1645,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) continue; } - selectObject(obj, createNewGroup && firstObject, player->getPlayerMask()); + selectObject(obj, createNewGroup && firstObject, msgPlayer->getPlayerMask()); firstObject = FALSE; } @@ -1660,13 +1656,6 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) //--------------------------------------------------------------------------------------------- case GameMessage::MSG_REMOVE_FROM_SELECTED_GROUP: { - Player *player = ThePlayerList->getNthPlayer(msg->getPlayerIndex()); - - if (player == nullptr) { - DEBUG_CRASH(("GameLogicDispatch - MSG_CREATE_SELECTED_GROUP had an invalid player number")); - break; - } - for (Int i = 0; i < msg->getArgumentCount(); ++i) { ObjectID objID = msg->getArgument(i)->objectID; Object *objToRemove = findObjectByID(objID); @@ -1674,7 +1663,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) continue; } - deselectObject(objToRemove, player->getPlayerMask()); + deselectObject(objToRemove, msgPlayer->getPlayerMask()); } break; @@ -1684,11 +1673,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) //--------------------------------------------------------------------------------------------- case GameMessage::MSG_DESTROY_SELECTED_GROUP: { - Player *player = ThePlayerList->getNthPlayer(msg->getPlayerIndex()); - if (player != nullptr) - { - player->setCurrentlySelectedAIGroup(nullptr); - } + msgPlayer->setCurrentlySelectedAIGroup(nullptr); break; @@ -1705,23 +1690,23 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // -------------------------------------------------------------------------------------------- case GameMessage::MSG_PLACE_BEACON: { - if (thisPlayer->getPlayerTemplate() == nullptr) + if (msgPlayer->getPlayerTemplate() == nullptr) break; Coord3D pos = msg->getArgument( 0 )->location; Region3D r; TheTerrainLogic->getExtent(&r); if (!r.isInRegionNoZ(&pos)) pos = TheTerrainLogic->findClosestEdgePoint(&pos); - const ThingTemplate *thing = TheThingFactory->findTemplate( thisPlayer->getPlayerTemplate()->getBeaconTemplate() ); - if (thing && !TheVictoryConditions->hasSinglePlayerBeenDefeated(thisPlayer)) + const ThingTemplate *thing = TheThingFactory->findTemplate( msgPlayer->getPlayerTemplate()->getBeaconTemplate() ); + if (thing && !TheVictoryConditions->hasSinglePlayerBeenDefeated(msgPlayer)) { // how many does this player have active? Int count; - thisPlayer->countObjectsByThingTemplate( 1, &thing, false, &count ); + msgPlayer->countObjectsByThingTemplate( 1, &thing, false, &count ); DEBUG_LOG(("Player already has %d beacons active", count)); if (count >= TheMultiplayerSettings->getMaxBeaconsPerPlayer()) { - if (thisPlayer == ThePlayerList->getLocalPlayer()) + if (msgPlayer == ThePlayerList->getLocalPlayer()) { // tell the user TheInGameUI->message( TheGameText->fetch("GUI:TooManyBeacons") ); @@ -1729,33 +1714,33 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // play a sound static AudioEventRTS aSound("BeaconPlacementFailed"); aSound.setPosition(&pos); - aSound.setPlayerIndex(thisPlayer->getPlayerIndex()); + aSound.setPlayerIndex(msgPlayer->getPlayerIndex()); TheAudio->addAudioEvent(&aSound); } break; } - Object *object = TheThingFactory->newObject( thing, thisPlayer->getDefaultTeam() ); + Object *object = TheThingFactory->newObject( thing, msgPlayer->getDefaultTeam() ); object->setPosition( &pos ); object->setProducer(nullptr); - if (thisPlayer->getRelationship( ThePlayerList->getLocalPlayer()->getDefaultTeam() ) == ALLIES || ThePlayerList->getLocalPlayer()->isPlayerObserver()) + if (msgPlayer->getRelationship( ThePlayerList->getLocalPlayer()->getDefaultTeam() ) == ALLIES || ThePlayerList->getLocalPlayer()->isPlayerObserver()) { // tell the user UnicodeString s; - s.format(TheGameText->fetch("GUI:BeaconPlaced"), thisPlayer->getPlayerDisplayName().str()); + s.format(TheGameText->fetch("GUI:BeaconPlaced"), msgPlayer->getPlayerDisplayName().str()); TheInGameUI->message( s ); // play a sound static AudioEventRTS aSound("BeaconPlaced"); - aSound.setPlayerIndex(thisPlayer->getPlayerIndex()); + aSound.setPlayerIndex(msgPlayer->getPlayerIndex()); aSound.setPosition(&pos); TheAudio->addAudioEvent(&aSound); // beacons are a rare event; play a nifty radar event thingy TheRadar->createEvent( object->getPosition(), RADAR_EVENT_INFORMATION ); - if (ThePlayerList->getLocalPlayer()->getRelationship(thisPlayer->getDefaultTeam()) == ALLIES) + if (ThePlayerList->getLocalPlayer()->getRelationship(msgPlayer->getDefaultTeam()) == ALLIES) TheEva->setShouldPlay(EVA_BeaconDetected); TheControlBar->markUIDirty(); // check if we should grey out the button @@ -1791,7 +1776,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // play a sound static AudioEventRTS aSound("BeaconPlacementFailed"); aSound.setPosition(&pos); - aSound.setPlayerIndex(thisPlayer->getPlayerIndex()); + aSound.setPlayerIndex(msgPlayer->getPlayerIndex()); TheAudio->addAudioEvent(&aSound); } break; @@ -1802,9 +1787,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { AIGroupPtr allSelectedObjects = TheAI->createGroup(); #if RETAIL_COMPATIBLE_AIGROUP - thisPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects); // need to act on all objects, so we can hide teammates' beacons. + msgPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects); // need to act on all objects, so we can hide teammates' beacons. #else - thisPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects.Peek()); // need to act on all objects, so we can hide teammates' beacons. + msgPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects.Peek()); // need to act on all objects, so we can hide teammates' beacons. #endif if( allSelectedObjects ) { @@ -1822,13 +1807,13 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) const ThingTemplate *thing = TheThingFactory->findTemplate( playerTemplate->getBeaconTemplate() ); if (thing && thing->isEquivalentTo(beacon->getTemplate())) { - if (beacon->getControllingPlayer() == thisPlayer) + if (beacon->getControllingPlayer() == msgPlayer) { destroyObject(beacon); // the owner is telling it to go away. such is life. TheControlBar->markUIDirty(); // check if we should un-grey out the button } - else if (thisPlayer == ThePlayerList->getLocalPlayer()) + else if (msgPlayer == ThePlayerList->getLocalPlayer()) { Drawable *beaconDrawable = beacon->getDrawable(); if (beaconDrawable) @@ -1902,18 +1887,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) Int i=0; for (; igetPlayerCount(); ++i) { - if (i != msg->getPlayerIndex()) + if (i != msgPlayer->getPlayerIndex()) { Player *otherPlayer = ThePlayerList->getNthPlayer(i); - if (thisPlayer->getRelationship(otherPlayer->getDefaultTeam()) == ALLIES && - otherPlayer->getRelationship(thisPlayer->getDefaultTeam()) == ALLIES) + if (msgPlayer->getRelationship(otherPlayer->getDefaultTeam()) == ALLIES && + otherPlayer->getRelationship(msgPlayer->getDefaultTeam()) == ALLIES) { if (TheVictoryConditions->hasSinglePlayerBeenDefeated(otherPlayer)) continue; // a living ally! hooray! - otherPlayer->transferAssetsFromThat(thisPlayer); - thisPlayer->killPlayer(); // just to be safe (and to kill beacons etc that don't transfer) + otherPlayer->transferAssetsFromThat(msgPlayer); + msgPlayer->killPlayer(); // just to be safe (and to kill beacons etc that don't transfer) break; } } @@ -1921,12 +1906,12 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) if (i == ThePlayerList->getPlayerCount()) { // didn't find any allies. die, loner! - thisPlayer->killPlayer(); + msgPlayer->killPlayer(); } } else { - thisPlayer->killPlayer(); + msgPlayer->killPlayer(); } // There is no reason to do any notification here, it now takes place in the victory conditions. // bonehead. @@ -1936,7 +1921,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // -------------------------------------------------------------------------------------------- case GameMessage::MSG_SET_REPLAY_CAMERA: { - if (TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == thisPlayer) + if (TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == msgPlayer) { if (TheTacticalView->isCameraMovementFinished()) { @@ -1984,13 +1969,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) case GameMessage::MSG_CREATE_TEAM8: case GameMessage::MSG_CREATE_TEAM9: { - Int playerIndex = msg->getPlayerIndex(); - Player *player = ThePlayerList->getNthPlayer(playerIndex); - DEBUG_ASSERTCRASH(player != nullptr, ("Could not find player for create team message")); - // TheSuperHackers @tweak Stubbjax 17/08/2025 The local player processes this message in CommandXlat for immediate assignment. - if (player && !player->isLocalPlayer()) - player->processCreateTeamGameMessage(msg->getType() - GameMessage::MSG_CREATE_TEAM0, msg); + if (!msgPlayer->isLocalPlayer()) + msgPlayer->processCreateTeamGameMessage(msg->getType() - GameMessage::MSG_CREATE_TEAM0, msg); break; } @@ -2006,16 +1987,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) case GameMessage::MSG_SELECT_TEAM8: case GameMessage::MSG_SELECT_TEAM9: { - Int playerIndex = msg->getPlayerIndex(); - Player *player = ThePlayerList->getNthPlayer(playerIndex); - DEBUG_ASSERTCRASH(player != nullptr, ("Could not find player for select team message")); - - if (player == nullptr) - { - break; - } - - player->processSelectTeamGameMessage(msg->getType() - GameMessage::MSG_SELECT_TEAM0, msg); + msgPlayer->processSelectTeamGameMessage(msg->getType() - GameMessage::MSG_SELECT_TEAM0, msg); break; } @@ -2030,16 +2002,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) case GameMessage::MSG_ADD_TEAM8: case GameMessage::MSG_ADD_TEAM9: { - Int playerIndex = msg->getPlayerIndex(); - Player *player = ThePlayerList->getNthPlayer(playerIndex); - DEBUG_ASSERTCRASH(player != nullptr, ("Could not find player for add team message")); - - if (player == nullptr) - { - break; - } - - player->processAddTeamGameMessage(msg->getType() - GameMessage::MSG_ADD_TEAM0, msg); + msgPlayer->processAddTeamGameMessage(msg->getType() - GameMessage::MSG_ADD_TEAM0, msg); break; } @@ -2052,7 +2015,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) Int slotIndex = -1; for (Int i=0; igetPlayerType() == PLAYER_HUMAN && TheNetwork->getPlayerName(i) == thisPlayer->getPlayerDisplayName()) + if (msgPlayer->getPlayerType() == PLAYER_HUMAN && TheNetwork->getPlayerName(i) == msgPlayer->getPlayerDisplayName()) { slotIndex = i; break; @@ -2062,7 +2025,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) if (slotIndex < 0 || !TheNetwork->isPlayerConnected(slotIndex)) break; - if (thisPlayer->isLocalPlayer()) + if (msgPlayer->isLocalPlayer()) { #if defined(RTS_DEBUG) // don't even put this in release, cause someone might hack it. @@ -2075,19 +2038,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) #endif } - //UnsignedInt oldCRC = m_cachedCRCs[msg->getPlayerIndex()]; UnsignedInt newCRC = msg->getArgument(0)->integer; //DEBUG_LOG(("Received CRC of %8.8X from %ls on frame %d", newCRC, - //thisPlayer->getPlayerDisplayName().str(), m_frame)); - m_cachedCRCs[msg->getPlayerIndex()] = newCRC; // to mask problem: = (oldCRC < newCRC)?newCRC:oldCRC; + //msgPlayer->getPlayerDisplayName().str(), m_frame)); + m_cachedCRCs[msgPlayer->getPlayerIndex()] = newCRC; } else if (TheRecorder && TheRecorder->isPlaybackMode()) { UnsignedInt newCRC = msg->getArgument(0)->integer; //DEBUG_LOG(("Saw CRC of %X from player %d. Our CRC is %X. Arg count is %d", - //newCRC, thisPlayer->getPlayerIndex(), getCRC(), msg->getArgumentCount())); + //newCRC, msgPlayer->getPlayerIndex(), getCRC(), msg->getArgumentCount())); - TheRecorder->handleCRCMessage(newCRC, thisPlayer->getPlayerIndex(), (msg->getArgument(1)->boolean)); + TheRecorder->handleCRCMessage(newCRC, msgPlayer->getPlayerIndex(), (msg->getArgument(1)->boolean)); } break; @@ -2099,10 +2061,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) ScienceType science = (ScienceType)msg->getArgument( 0 )->integer; // sanity - if( science == SCIENCE_INVALID || thisPlayer == nullptr ) + if( science == SCIENCE_INVALID ) break; - thisPlayer->attemptToPurchaseScience(science); + msgPlayer->attemptToPurchaseScience(science); break; @@ -2119,7 +2081,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) #endif /**/ /// @todo: multiplayer semantics - if (currentlySelectedGroup && TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == thisPlayer /*&& !TheRecorder->isMultiplayer()*/) + if (currentlySelectedGroup && TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == msgPlayer /*&& !TheRecorder->isMultiplayer()*/) { const VecObjectID& selectedObjects = currentlySelectedGroup->getAllIDs(); TheInGameUI->deselectAllDrawables(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp index a136378ad62..abcfa873397 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp @@ -349,9 +349,12 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) DEBUG_ASSERTCRASH(msg != nullptr && msg != (GameMessage*)0xdeadbeef, ("bad msg")); #endif - Player *thisPlayer = ThePlayerList->getNthPlayer( msg->getPlayerIndex() ); - DEBUG_ASSERTCRASH( thisPlayer, ("logicMessageDispatcher: Processing message from unknown player (player index '%d')", - msg->getPlayerIndex()) ); + Player *msgPlayer = ThePlayerList->getNthPlayer( msg->getPlayerIndex() ); + if (msgPlayer == nullptr) + { + DEBUG_CRASH(("logicMessageDispatcher: Processing message from unknown player (player index '%d')", msg->getPlayerIndex())); + return; + } AIGroupPtr currentlySelectedGroup = nullptr; @@ -364,9 +367,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) currentlySelectedGroup = TheAI->createGroup(); // can't do this outside a game - it'll cause sync errors galore. CRCGEN_LOG(( "Creating AIGroup %d in GameLogic::logicMessageDispatcher()", currentlySelectedGroup?currentlySelectedGroup->getID():0 )); #if RETAIL_COMPATIBLE_AIGROUP - thisPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup); + msgPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup); #else - thisPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup.Peek()); + msgPlayer->getCurrentSelectionAsAIGroup(currentlySelectedGroup.Peek()); #endif // We can't issue commands to groups that contain units that don't belong to the issuing player, so pretend like @@ -382,7 +385,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // If there are any units that the player doesn't own, then remove them from the "currentlySelectedGroup" if (currentlySelectedGroup) - if (currentlySelectedGroup->removeAnyObjectsNotOwnedByPlayer(thisPlayer)) + if (currentlySelectedGroup->removeAnyObjectsNotOwnedByPlayer(msgPlayer)) currentlySelectedGroup = nullptr; if(TheStatsCollector) @@ -407,7 +410,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) if (commandName.isNotEmpty() /*&& msg->getType() != GameMessage::MSG_FRAME_TICK*/) { DEBUG_LOG(("Frame %d: GameLogic::logicMessageDispatcher() saw a %s from player %d (%ls)", getFrame(), commandName.str(), - msg->getPlayerIndex(), thisPlayer->getPlayerDisplayName().str())); + msgPlayer->getPlayerIndex(), msgPlayer->getPlayerDisplayName().str())); } #endif #endif // DEBUG_LOGGING @@ -528,10 +531,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 11/03/2026 Validate the owner of the source object - if ( obj->getControllingPlayer() != thisPlayer ) + if ( obj->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_SET_RALLY_POINT: Player '%ls' attempted to set the rally point of object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), obj->getTemplate()->getName().str(), obj->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -665,9 +668,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) Player *player = ThePlayerList->getNthPlayer( playerIndex ); if( player ) { - DEBUG_ASSERTCRASH(player == thisPlayer, + DEBUG_ASSERTCRASH(player == msgPlayer, ("Retaliation mode of player '%ls' was illegally set by player '%ls'. Before: '%d', after: '%d'.", - player->getPlayerDisplayName().str(), thisPlayer->getPlayerDisplayName().str(), + player->getPlayerDisplayName().str(), msgPlayer->getPlayerDisplayName().str(), player->isLogicalRetaliationModeEnabled(), enableRetaliation) ); player->setLogicalRetaliationModeEnabled( enableRetaliation ); @@ -675,7 +678,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) #else // TheSuperHackers @fix stephanmeesters 08/03/2026 Ensure that players can only set their own retaliation mode. const Bool enableRetaliation = msg->getArgument( 0 )->boolean; - thisPlayer->setLogicalRetaliationModeEnabled( enableRetaliation ); + msgPlayer->setLogicalRetaliationModeEnabled( enableRetaliation ); #endif break; } @@ -718,10 +721,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object - if ( source->getControllingPlayer() != thisPlayer ) + if ( source->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER: Player '%ls' attempted to control the object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), source->getTemplate()->getName().str(), source->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -775,10 +778,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object - if ( source->getControllingPlayer() != thisPlayer ) + if ( source->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_LOCATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), source->getTemplate()->getName().str(), source->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -830,10 +833,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object - if ( source->getControllingPlayer() != thisPlayer ) + if ( source->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_OBJECT: Player '%ls' attempted to control the object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), source->getTemplate()->getName().str(), source->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -1106,7 +1109,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) break; // sanity, the player must actually control this object - if( objectWantingToExit->getControllingPlayer() != thisPlayer ) + if( objectWantingToExit->getControllingPlayer() != msgPlayer ) break; objectWantingToExit->releaseWeaponLock(LOCKED_TEMPORARILY); // release any temporary locks. @@ -1285,10 +1288,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { #if !RETAIL_COMPATIBLE_CRC // TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object - if ( source->getControllingPlayer() != thisPlayer ) + if ( source->getControllingPlayer() != msgPlayer ) { DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.", - thisPlayer->getPlayerDisplayName().str(), + msgPlayer->getPlayerDisplayName().str(), source->getTemplate()->getName().str(), source->getControllingPlayer()->getPlayerDisplayName().str()) ); break; @@ -1426,7 +1429,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) break; // the player must actually control the producer object - if( producer->getControllingPlayer() != thisPlayer ) + if( producer->getControllingPlayer() != msgPlayer ) break; // producer must have a production update @@ -1493,7 +1496,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) break; // sanity, the player must control the producer - if( producer->getControllingPlayer() != thisPlayer ) + if( producer->getControllingPlayer() != msgPlayer ) break; // get the unit production interface @@ -1577,7 +1580,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) break; // the player sending this message must actually control this building - if( building->getControllingPlayer() != thisPlayer ) + if( building->getControllingPlayer() != msgPlayer ) break; // Check to make sure it is actually under construction @@ -1587,8 +1590,8 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // OK, refund the money to the player, unless it is a rebuilding Hole. if( !building->testStatus(OBJECT_STATUS_RECONSTRUCTING)) { - Money *money = thisPlayer->getMoney(); - UnsignedInt amount = building->getTemplate()->calcCostToBuild( thisPlayer ); + Money *money = msgPlayer->getMoney(); + UnsignedInt amount = building->getTemplate()->calcCostToBuild( msgPlayer ); money->deposit( amount, TRUE, FALSE ); } @@ -1667,13 +1670,6 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) case GameMessage::MSG_CREATE_SELECTED_GROUP: { Bool createNewGroup = msg->getArgument( 0 )->boolean; - Player *player = ThePlayerList->getNthPlayer(msg->getPlayerIndex()); - - if (player == nullptr) { - DEBUG_CRASH(("GameLogicDispatch - MSG_CREATE_SELECTED_GROUP had an invalid player number")); - break; - } - Bool firstObject = TRUE; for (Int i = 1; i < msg->getArgumentCount(); ++i) { @@ -1682,7 +1678,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) continue; } - selectObject(obj, createNewGroup && firstObject, player->getPlayerMask()); + selectObject(obj, createNewGroup && firstObject, msgPlayer->getPlayerMask()); firstObject = FALSE; } @@ -1693,13 +1689,6 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) //--------------------------------------------------------------------------------------------- case GameMessage::MSG_REMOVE_FROM_SELECTED_GROUP: { - Player *player = ThePlayerList->getNthPlayer(msg->getPlayerIndex()); - - if (player == nullptr) { - DEBUG_CRASH(("GameLogicDispatch - MSG_CREATE_SELECTED_GROUP had an invalid player number")); - break; - } - for (Int i = 0; i < msg->getArgumentCount(); ++i) { ObjectID objID = msg->getArgument(i)->objectID; Object *objToRemove = findObjectByID(objID); @@ -1707,7 +1696,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) continue; } - deselectObject(objToRemove, player->getPlayerMask()); + deselectObject(objToRemove, msgPlayer->getPlayerMask()); } break; @@ -1717,11 +1706,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) //--------------------------------------------------------------------------------------------- case GameMessage::MSG_DESTROY_SELECTED_GROUP: { - Player *player = ThePlayerList->getNthPlayer(msg->getPlayerIndex()); - if (player != nullptr) - { - player->setCurrentlySelectedAIGroup(nullptr); - } + msgPlayer->setCurrentlySelectedAIGroup(nullptr); break; @@ -1738,23 +1723,23 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // -------------------------------------------------------------------------------------------- case GameMessage::MSG_PLACE_BEACON: { - if (thisPlayer->getPlayerTemplate() == nullptr) + if (msgPlayer->getPlayerTemplate() == nullptr) break; Coord3D pos = msg->getArgument( 0 )->location; Region3D r; TheTerrainLogic->getExtent(&r); if (!r.isInRegionNoZ(&pos)) pos = TheTerrainLogic->findClosestEdgePoint(&pos); - const ThingTemplate *thing = TheThingFactory->findTemplate( thisPlayer->getPlayerTemplate()->getBeaconTemplate() ); - if (thing && !TheVictoryConditions->hasSinglePlayerBeenDefeated(thisPlayer)) + const ThingTemplate *thing = TheThingFactory->findTemplate( msgPlayer->getPlayerTemplate()->getBeaconTemplate() ); + if (thing && !TheVictoryConditions->hasSinglePlayerBeenDefeated(msgPlayer)) { // how many does this player have active? Int count; - thisPlayer->countObjectsByThingTemplate( 1, &thing, false, &count ); + msgPlayer->countObjectsByThingTemplate( 1, &thing, false, &count ); DEBUG_LOG(("Player already has %d beacons active", count)); if (count >= TheMultiplayerSettings->getMaxBeaconsPerPlayer()) { - if (thisPlayer == ThePlayerList->getLocalPlayer()) + if (msgPlayer == ThePlayerList->getLocalPlayer()) { // tell the user TheInGameUI->message( TheGameText->fetch("GUI:TooManyBeacons") ); @@ -1762,33 +1747,33 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // play a sound static AudioEventRTS aSound("BeaconPlacementFailed"); aSound.setPosition(&pos); - aSound.setPlayerIndex(thisPlayer->getPlayerIndex()); + aSound.setPlayerIndex(msgPlayer->getPlayerIndex()); TheAudio->addAudioEvent(&aSound); } break; } - Object *object = TheThingFactory->newObject( thing, thisPlayer->getDefaultTeam() ); + Object *object = TheThingFactory->newObject( thing, msgPlayer->getDefaultTeam() ); object->setPosition( &pos ); object->setProducer(nullptr); - if (thisPlayer->getRelationship( ThePlayerList->getLocalPlayer()->getDefaultTeam() ) == ALLIES || ThePlayerList->getLocalPlayer()->isPlayerObserver()) + if (msgPlayer->getRelationship( ThePlayerList->getLocalPlayer()->getDefaultTeam() ) == ALLIES || ThePlayerList->getLocalPlayer()->isPlayerObserver()) { // tell the user UnicodeString s; - s.format(TheGameText->fetch("GUI:BeaconPlaced"), thisPlayer->getPlayerDisplayName().str()); + s.format(TheGameText->fetch("GUI:BeaconPlaced"), msgPlayer->getPlayerDisplayName().str()); TheInGameUI->message( s ); // play a sound static AudioEventRTS aSound("BeaconPlaced"); - aSound.setPlayerIndex(thisPlayer->getPlayerIndex()); + aSound.setPlayerIndex(msgPlayer->getPlayerIndex()); aSound.setPosition(&pos); TheAudio->addAudioEvent(&aSound); // beacons are a rare event; play a nifty radar event thingy TheRadar->createEvent( object->getPosition(), RADAR_EVENT_INFORMATION ); - if (ThePlayerList->getLocalPlayer()->getRelationship(thisPlayer->getDefaultTeam()) == ALLIES) + if (ThePlayerList->getLocalPlayer()->getRelationship(msgPlayer->getDefaultTeam()) == ALLIES) TheEva->setShouldPlay(EVA_BeaconDetected); TheControlBar->markUIDirty(); // check if we should grey out the button @@ -1824,7 +1809,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // play a sound static AudioEventRTS aSound("BeaconPlacementFailed"); aSound.setPosition(&pos); - aSound.setPlayerIndex(thisPlayer->getPlayerIndex()); + aSound.setPlayerIndex(msgPlayer->getPlayerIndex()); TheAudio->addAudioEvent(&aSound); } break; @@ -1835,9 +1820,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) { AIGroupPtr allSelectedObjects = TheAI->createGroup(); #if RETAIL_COMPATIBLE_AIGROUP - thisPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects); // need to act on all objects, so we can hide teammates' beacons. + msgPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects); // need to act on all objects, so we can hide teammates' beacons. #else - thisPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects.Peek()); // need to act on all objects, so we can hide teammates' beacons. + msgPlayer->getCurrentSelectionAsAIGroup(allSelectedObjects.Peek()); // need to act on all objects, so we can hide teammates' beacons. #endif if( allSelectedObjects ) { @@ -1855,13 +1840,13 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) const ThingTemplate *thing = TheThingFactory->findTemplate( playerTemplate->getBeaconTemplate() ); if (thing && thing->isEquivalentTo(beacon->getTemplate())) { - if (beacon->getControllingPlayer() == thisPlayer) + if (beacon->getControllingPlayer() == msgPlayer) { destroyObject(beacon); // the owner is telling it to go away. such is life. TheControlBar->markUIDirty(); // check if we should un-grey out the button } - else if (thisPlayer == ThePlayerList->getLocalPlayer()) + else if (msgPlayer == ThePlayerList->getLocalPlayer()) { Drawable *beaconDrawable = beacon->getDrawable(); if (beaconDrawable) @@ -1935,18 +1920,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) Int i=0; for (; igetPlayerCount(); ++i) { - if (i != msg->getPlayerIndex()) + if (i != msgPlayer->getPlayerIndex()) { Player *otherPlayer = ThePlayerList->getNthPlayer(i); - if (thisPlayer->getRelationship(otherPlayer->getDefaultTeam()) == ALLIES && - otherPlayer->getRelationship(thisPlayer->getDefaultTeam()) == ALLIES) + if (msgPlayer->getRelationship(otherPlayer->getDefaultTeam()) == ALLIES && + otherPlayer->getRelationship(msgPlayer->getDefaultTeam()) == ALLIES) { if (TheVictoryConditions->hasSinglePlayerBeenDefeated(otherPlayer)) continue; // a living ally! hooray! - otherPlayer->transferAssetsFromThat(thisPlayer); - thisPlayer->killPlayer(); // just to be safe (and to kill beacons etc that don't transfer) + otherPlayer->transferAssetsFromThat(msgPlayer); + msgPlayer->killPlayer(); // just to be safe (and to kill beacons etc that don't transfer) break; } } @@ -1954,12 +1939,12 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) if (i == ThePlayerList->getPlayerCount()) { // didn't find any allies. die, loner! - thisPlayer->killPlayer(); + msgPlayer->killPlayer(); } } else { - thisPlayer->killPlayer(); + msgPlayer->killPlayer(); } // There is no reason to do any notification here, it now takes place in the victory conditions. // bonehead. @@ -1969,7 +1954,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) // -------------------------------------------------------------------------------------------- case GameMessage::MSG_SET_REPLAY_CAMERA: { - if (TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == thisPlayer) + if (TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == msgPlayer) { if (TheTacticalView->isCameraMovementFinished()) { @@ -2017,13 +2002,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) case GameMessage::MSG_CREATE_TEAM8: case GameMessage::MSG_CREATE_TEAM9: { - Int playerIndex = msg->getPlayerIndex(); - Player *player = ThePlayerList->getNthPlayer(playerIndex); - DEBUG_ASSERTCRASH(player != nullptr, ("Could not find player for create team message")); - // TheSuperHackers @tweak Stubbjax 17/08/2025 The local player processes this message in CommandXlat for immediate assignment. - if (player && !player->isLocalPlayer()) - player->processCreateTeamGameMessage(msg->getType() - GameMessage::MSG_CREATE_TEAM0, msg); + if (!msgPlayer->isLocalPlayer()) + msgPlayer->processCreateTeamGameMessage(msg->getType() - GameMessage::MSG_CREATE_TEAM0, msg); break; } @@ -2039,16 +2020,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) case GameMessage::MSG_SELECT_TEAM8: case GameMessage::MSG_SELECT_TEAM9: { - Int playerIndex = msg->getPlayerIndex(); - Player *player = ThePlayerList->getNthPlayer(playerIndex); - DEBUG_ASSERTCRASH(player != nullptr, ("Could not find player for select team message")); - - if (player == nullptr) - { - break; - } - - player->processSelectTeamGameMessage(msg->getType() - GameMessage::MSG_SELECT_TEAM0, msg); + msgPlayer->processSelectTeamGameMessage(msg->getType() - GameMessage::MSG_SELECT_TEAM0, msg); break; } @@ -2063,16 +2035,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) case GameMessage::MSG_ADD_TEAM8: case GameMessage::MSG_ADD_TEAM9: { - Int playerIndex = msg->getPlayerIndex(); - Player *player = ThePlayerList->getNthPlayer(playerIndex); - DEBUG_ASSERTCRASH(player != nullptr, ("Could not find player for add team message")); - - if (player == nullptr) - { - break; - } - - player->processAddTeamGameMessage(msg->getType() - GameMessage::MSG_ADD_TEAM0, msg); + msgPlayer->processAddTeamGameMessage(msg->getType() - GameMessage::MSG_ADD_TEAM0, msg); break; } @@ -2085,7 +2048,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) Int slotIndex = -1; for (Int i=0; igetPlayerType() == PLAYER_HUMAN && TheNetwork->getPlayerName(i) == thisPlayer->getPlayerDisplayName()) + if (msgPlayer->getPlayerType() == PLAYER_HUMAN && TheNetwork->getPlayerName(i) == msgPlayer->getPlayerDisplayName()) { slotIndex = i; break; @@ -2095,7 +2058,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) if (slotIndex < 0 || !TheNetwork->isPlayerConnected(slotIndex)) break; - if (thisPlayer->isLocalPlayer()) + if (msgPlayer->isLocalPlayer()) { #if defined(RTS_DEBUG) // don't even put this in release, cause someone might hack it. @@ -2108,19 +2071,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) #endif } - //UnsignedInt oldCRC = m_cachedCRCs[msg->getPlayerIndex()]; UnsignedInt newCRC = msg->getArgument(0)->integer; //DEBUG_LOG(("Received CRC of %8.8X from %ls on frame %d", newCRC, - //thisPlayer->getPlayerDisplayName().str(), m_frame)); - m_cachedCRCs[msg->getPlayerIndex()] = newCRC; // to mask problem: = (oldCRC < newCRC)?newCRC:oldCRC; + //msgPlayer->getPlayerDisplayName().str(), m_frame)); + m_cachedCRCs[msgPlayer->getPlayerIndex()] = newCRC; } else if (TheRecorder && TheRecorder->isPlaybackMode()) { UnsignedInt newCRC = msg->getArgument(0)->integer; //DEBUG_LOG(("Saw CRC of %X from player %d. Our CRC is %X. Arg count is %d", - //newCRC, thisPlayer->getPlayerIndex(), getCRC(), msg->getArgumentCount())); + //newCRC, msgPlayer->getPlayerIndex(), getCRC(), msg->getArgumentCount())); - TheRecorder->handleCRCMessage(newCRC, thisPlayer->getPlayerIndex(), (msg->getArgument(1)->boolean)); + TheRecorder->handleCRCMessage(newCRC, msgPlayer->getPlayerIndex(), (msg->getArgument(1)->boolean)); } break; @@ -2132,10 +2094,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) ScienceType science = (ScienceType)msg->getArgument( 0 )->integer; // sanity - if( science == SCIENCE_INVALID || thisPlayer == nullptr ) + if( science == SCIENCE_INVALID ) break; - thisPlayer->attemptToPurchaseScience(science); + msgPlayer->attemptToPurchaseScience(science); break; @@ -2152,7 +2114,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) #endif /**/ /// @todo: multiplayer semantics - if (currentlySelectedGroup && TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == thisPlayer /*&& !TheRecorder->isMultiplayer()*/) + if (currentlySelectedGroup && TheRecorder->isPlaybackMode() && TheGlobalData->m_useCameraInReplay && TheControlBar->getObserverLookAtPlayer() == msgPlayer /*&& !TheRecorder->isMultiplayer()*/) { const VecObjectID& selectedObjects = currentlySelectedGroup->getAllIDs(); TheInGameUI->deselectAllDrawables();