diff --git a/Generals/Code/GameEngine/Include/GameLogic/Object.h b/Generals/Code/GameEngine/Include/GameLogic/Object.h index 5b64240b59..a56d824d35 100644 --- a/Generals/Code/GameEngine/Include/GameLogic/Object.h +++ b/Generals/Code/GameEngine/Include/GameLogic/Object.h @@ -241,6 +241,7 @@ class Object : public Thing, public Snapshot void removeCustomIndicatorColor(); Bool isLocallyControlled() const; + Bool isLocallyViewed() const; Bool isNeutralControlled() const; Bool getIsUndetectedDefector(void) const { return BitIsSet(m_privateStatus, UNDETECTED_DEFECTOR); } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp index bdcf187ef0..2eacd9f010 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp @@ -144,7 +144,7 @@ Bool ConvertToHijackedVehicleCrateCollide::executeCrateBehavior( Object *other ) //Before the actual defection takes place, play the "vehicle stolen" EVA //event if the local player is the victim! - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_VehicleStolen ); } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp index a9d887a612..71b27834b0 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -35,6 +35,7 @@ #include "Common/Dict.h" #include "Common/GameEngine.h" #include "Common/GameState.h" +#include "Common/GameUtility.h" #include "Common/ModuleFactory.h" #include "Common/Player.h" #include "Common/PlayerList.h" @@ -1543,6 +1544,14 @@ Bool Object::isLocallyControlled() const return getControllingPlayer() == ThePlayerList->getLocalPlayer(); } +//============================================================================= +// Object::isLocallyViewed +//============================================================================= +Bool Object::isLocallyViewed() const +{ + return getControllingPlayer() == rts::getObservedOrLocalPlayer(); +} + //============================================================================= // Object::isLocallyControlled //============================================================================= @@ -4092,7 +4101,7 @@ void Object::onDie( DamageInfo *damageInfo ) deathSound.setPlayerIndex( index ); TheAudio->addAudioEvent(&deathSound); - if (isLocallyControlled() && !selfInflicted) // wasLocallyControlled? :-) + if (isLocallyViewed() && !selfInflicted) // wasLocallyViewed? :-) { if (isKindOf(KINDOF_STRUCTURE) && isKindOf(KINDOF_MP_COUNT_FOR_VICTORY)) { diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp index d5371bd9a3..c509c0baf6 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp @@ -608,7 +608,7 @@ StateReturnType DozerActionDoActionState::update( void ) /// @todo need to write this // do some UI stuff for the constrolling player - if( dozer->isLocallyControlled() ) + if( dozer->isLocallyViewed() ) { // message the the building player diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp index cd81b573ce..909be605fb 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp @@ -903,7 +903,7 @@ UpdateSleepTime ProductionUpdate::update( void ) us->getID()); // print a message to the local player - if( us->isLocallyControlled() ) + if( us->isLocallyViewed() ) { UnicodeString msg; UnicodeString format = TheGameText->fetch( "UPGRADE:UpgradeComplete" ); diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp index 012b28d2cb..bf24644b32 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp @@ -920,7 +920,7 @@ void SpecialAbilityUpdate::startPreparation() draw->setAnimationCompletionTime(data->m_preparationFrames); //Warn the victim so he might have a chance to react! - if( target && target->isLocallyControlled() ) + if( target && target->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingBeingStolen ); } @@ -954,7 +954,7 @@ void SpecialAbilityUpdate::startPreparation() } //Warn the victim so he might have a chance to react! - if( spTemplate->getSpecialPowerType() == SPECIAL_BLACKLOTUS_CAPTURE_BUILDING && target && target->isLocallyControlled() ) + if( spTemplate->getSpecialPowerType() == SPECIAL_BLACKLOTUS_CAPTURE_BUILDING && target && target->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingBeingStolen ); } @@ -1308,7 +1308,7 @@ void SpecialAbilityUpdate::triggerAbilityEffect() } //Play the "building stolen" EVA event if the local player is the victim! - if( target && target->isLocallyControlled() ) + if( target && target->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingStolen ); } @@ -1358,7 +1358,7 @@ void SpecialAbilityUpdate::triggerAbilityEffect() controller->getScoreKeeper()->addMoneyEarned( cash ); //Play the "cash stolen" EVA event if the local player is the victim! - if( target && target->isLocallyControlled() ) + if( target && target->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_CashStolen ); } diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h index 10f614c047..de39c15de9 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h @@ -257,6 +257,7 @@ class Object : public Thing, public Snapshot void removeCustomIndicatorColor(); Bool isLocallyControlled() const; + Bool isLocallyViewed() const; Bool isNeutralControlled() const; Bool getIsUndetectedDefector(void) const { return BitIsSet(m_privateStatus, UNDETECTED_DEFECTOR); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp index de2d527fd7..44da72449d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp @@ -155,7 +155,7 @@ Bool ConvertToHijackedVehicleCrateCollide::executeCrateBehavior( Object *other ) //Before the actual defection takes place, play the "vehicle stolen" EVA //event if the local player is the victim! - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_VehicleStolen ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageCommandCenterCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageCommandCenterCrateCollide.cpp index c64988be95..1d6e1fc9e6 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageCommandCenterCrateCollide.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageCommandCenterCrateCollide.cpp @@ -136,7 +136,7 @@ Bool SabotageCommandCenterCrateCollide::executeCrateBehavior( Object *other ) //When the sabotage occurs, play the appropriate EVA //event if the local player is the victim! - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingSabotaged ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageFakeBuilding.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageFakeBuilding.cpp index 8c3246a36c..ba7eaa9209 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageFakeBuilding.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageFakeBuilding.cpp @@ -131,7 +131,7 @@ Bool SabotageFakeBuildingCrateCollide::executeCrateBehavior( Object *other ) //When the sabotage occurs, play the appropriate EVA //event if the local player is the victim! - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingSabotaged ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageInternetCenterCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageInternetCenterCrateCollide.cpp index c9febfc397..b9fb327dad 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageInternetCenterCrateCollide.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageInternetCenterCrateCollide.cpp @@ -166,7 +166,7 @@ Bool SabotageInternetCenterCrateCollide::executeCrateBehavior( Object *other ) doSabotageFeedbackFX( other, CrateCollide::SAB_VICTIM_INTERNET_CENTER ); - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingSabotaged ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageMilitaryFactoryCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageMilitaryFactoryCrateCollide.cpp index 2b0ba837dc..16cb150bd9 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageMilitaryFactoryCrateCollide.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageMilitaryFactoryCrateCollide.cpp @@ -139,7 +139,7 @@ Bool SabotageMilitaryFactoryCrateCollide::executeCrateBehavior( Object *other ) doSabotageFeedbackFX( other, CrateCollide::SAB_VICTIM_MILITARY_FACTORY ); - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingSabotaged ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotagePowerPlantCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotagePowerPlantCrateCollide.cpp index 3a4aa5ec2e..9a4968fb08 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotagePowerPlantCrateCollide.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotagePowerPlantCrateCollide.cpp @@ -131,7 +131,7 @@ Bool SabotagePowerPlantCrateCollide::executeCrateBehavior( Object *other ) //When the sabotage occurs, play the appropriate EVA //event if the local player is the victim! - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingSabotaged ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSuperweaponCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSuperweaponCrateCollide.cpp index 1b51dc1376..af44d63584 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSuperweaponCrateCollide.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSuperweaponCrateCollide.cpp @@ -136,7 +136,7 @@ Bool SabotageSuperweaponCrateCollide::executeCrateBehavior( Object *other ) //When the sabotage occurs, play the appropriate EVA //event if the local player is the victim! - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingSabotaged ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSupplyCenterCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSupplyCenterCrateCollide.cpp index 75d16c165b..532fefa024 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSupplyCenterCrateCollide.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSupplyCenterCrateCollide.cpp @@ -152,7 +152,7 @@ Bool SabotageSupplyCenterCrateCollide::executeCrateBehavior( Object *other ) controller->getScoreKeeper()->addMoneyEarned( cash ); //Play the "cash stolen" EVA event if the local player is the victim! - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_CashStolen ); } @@ -173,7 +173,7 @@ Bool SabotageSupplyCenterCrateCollide::executeCrateBehavior( Object *other ) } else { - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingSabotaged ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSupplyDropzoneCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSupplyDropzoneCrateCollide.cpp index b43ce01ccc..8c67c347d9 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSupplyDropzoneCrateCollide.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageSupplyDropzoneCrateCollide.cpp @@ -162,7 +162,7 @@ Bool SabotageSupplyDropzoneCrateCollide::executeCrateBehavior( Object *other ) controller->getScoreKeeper()->addMoneyEarned( cash ); //Play the "cash stolen" EVA event if the local player is the victim! - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_CashStolen ); } @@ -183,7 +183,7 @@ Bool SabotageSupplyDropzoneCrateCollide::executeCrateBehavior( Object *other ) } else { - if( other->isLocallyControlled() ) + if( other->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingSabotaged ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index 0d932d277e..372b8a28bf 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -35,6 +35,7 @@ #include "Common/Dict.h" #include "Common/GameEngine.h" #include "Common/GameState.h" +#include "Common/GameUtility.h" #include "Common/ModuleFactory.h" #include "Common/Player.h" #include "Common/PlayerList.h" @@ -1698,6 +1699,14 @@ Bool Object::isLocallyControlled() const return getControllingPlayer() == ThePlayerList->getLocalPlayer(); } +//============================================================================= +// Object::isLocallyViewed +//============================================================================= +Bool Object::isLocallyViewed() const +{ + return getControllingPlayer() == rts::getObservedOrLocalPlayer(); +} + //============================================================================= // Object::isLocallyControlled //============================================================================= @@ -4595,7 +4604,7 @@ void Object::onDie( DamageInfo *damageInfo ) if(m_team) m_team->notifyTeamOfObjectDeath(); - if (isLocallyControlled() && !selfInflicted) // wasLocallyControlled? :-) + if (isLocallyViewed() && !selfInflicted) // wasLocallyViewed? :-) { if (isKindOf(KINDOF_STRUCTURE) && isKindOf(KINDOF_MP_COUNT_FOR_VICTORY)) { diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp index ea9d64c9a2..1bebdbe441 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp @@ -613,7 +613,7 @@ StateReturnType DozerActionDoActionState::update( void ) /// @todo need to write this // do some UI stuff for the constrolling player - if( dozer->isLocallyControlled() ) + if( dozer->isLocallyViewed() ) { // message the the building player diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp index 38e5080916..1f701859da 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp @@ -906,7 +906,7 @@ UpdateSleepTime ProductionUpdate::update( void ) us->getID()); // print a message to the local player, if it wants one - if( us->isLocallyControlled() && !upgrade->getDisplayNameLabel().isEmpty() ) + if( us->isLocallyViewed() && !upgrade->getDisplayNameLabel().isEmpty() ) { UnicodeString msg; UnicodeString format = TheGameText->fetch( "UPGRADE:UpgradeComplete" ); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp index e50b3f754e..b98fd93195 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp @@ -1033,7 +1033,7 @@ void SpecialAbilityUpdate::startPreparation() draw->setAnimationCompletionTime(data->m_preparationFrames); //Warn the victim so he might have a chance to react! - if( target && target->isLocallyControlled() ) + if( target && target->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingBeingStolen ); } @@ -1068,7 +1068,7 @@ void SpecialAbilityUpdate::startPreparation() } //Warn the victim so he might have a chance to react! - if( spTemplate->getSpecialPowerType() == SPECIAL_BLACKLOTUS_CAPTURE_BUILDING && target && target->isLocallyControlled() ) + if( spTemplate->getSpecialPowerType() == SPECIAL_BLACKLOTUS_CAPTURE_BUILDING && target && target->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingBeingStolen ); } @@ -1454,7 +1454,7 @@ void SpecialAbilityUpdate::triggerAbilityEffect() } //Play the "building stolen" EVA event if the local player is the victim! - if( target && target->isLocallyControlled() ) + if( target && target->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_BuildingStolen ); } @@ -1504,7 +1504,7 @@ void SpecialAbilityUpdate::triggerAbilityEffect() controller->getScoreKeeper()->addMoneyEarned( cash ); //Play the "cash stolen" EVA event if the local player is the victim! - if( target && target->isLocallyControlled() ) + if( target && target->isLocallyViewed() ) { TheEva->setShouldPlay( EVA_CashStolen ); }