Skip to content

Commit 5de3d63

Browse files
authored
tweak(eva): Enable more EVA events for observed players (#1866)
1 parent c645c8f commit 5de3d63

20 files changed

+46
-26
lines changed

Generals/Code/GameEngine/Include/GameLogic/Object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class Object : public Thing, public Snapshot
238238
void removeCustomIndicatorColor();
239239

240240
Bool isLocallyControlled() const;
241+
Bool isLocallyViewed() const;
241242
Bool isNeutralControlled() const;
242243

243244
Bool getIsUndetectedDefector(void) const { return BitIsSet(m_privateStatus, UNDETECTED_DEFECTOR); }

Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Bool ConvertToHijackedVehicleCrateCollide::executeCrateBehavior( Object *other )
144144

145145
//Before the actual defection takes place, play the "vehicle stolen" EVA
146146
//event if the local player is the victim!
147-
if( other->isLocallyControlled() )
147+
if( other->isLocallyViewed() )
148148
{
149149
TheEva->setShouldPlay( EVA_VehicleStolen );
150150
}

Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "Common/Dict.h"
3636
#include "Common/GameEngine.h"
3737
#include "Common/GameState.h"
38+
#include "Common/GameUtility.h"
3839
#include "Common/ModuleFactory.h"
3940
#include "Common/Player.h"
4041
#include "Common/PlayerList.h"
@@ -1543,6 +1544,14 @@ Bool Object::isLocallyControlled() const
15431544
return getControllingPlayer() == ThePlayerList->getLocalPlayer();
15441545
}
15451546

1547+
//=============================================================================
1548+
// Object::isLocallyViewed
1549+
//=============================================================================
1550+
Bool Object::isLocallyViewed() const
1551+
{
1552+
return getControllingPlayer() == rts::getObservedOrLocalPlayer();
1553+
}
1554+
15461555
//=============================================================================
15471556
// Object::isLocallyControlled
15481557
//=============================================================================
@@ -4090,7 +4099,7 @@ void Object::onDie( DamageInfo *damageInfo )
40904099
deathSound.setPlayerIndex( index );
40914100
TheAudio->addAudioEvent(&deathSound);
40924101

4093-
if (isLocallyControlled() && !selfInflicted) // wasLocallyControlled? :-)
4102+
if (isLocallyViewed() && !selfInflicted) // wasLocallyViewed? :-)
40944103
{
40954104
if (isKindOf(KINDOF_STRUCTURE) && isKindOf(KINDOF_MP_COUNT_FOR_VICTORY))
40964105
{

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ StateReturnType DozerActionDoActionState::update( void )
608608
/// @todo need to write this
609609

610610
// do some UI stuff for the constrolling player
611-
if( dozer->isLocallyControlled() )
611+
if( dozer->isLocallyViewed() )
612612
{
613613

614614
// message the the building player

Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ UpdateSleepTime ProductionUpdate::update( void )
903903
us->getID());
904904

905905
// print a message to the local player
906-
if( us->isLocallyControlled() )
906+
if( us->isLocallyViewed() )
907907
{
908908
UnicodeString msg;
909909
UnicodeString format = TheGameText->fetch( "UPGRADE:UpgradeComplete" );

Generals/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ void SpecialAbilityUpdate::startPreparation()
920920
draw->setAnimationCompletionTime(data->m_preparationFrames);
921921

922922
//Warn the victim so he might have a chance to react!
923-
if( target && target->isLocallyControlled() )
923+
if( target && target->isLocallyViewed() )
924924
{
925925
TheEva->setShouldPlay( EVA_BuildingBeingStolen );
926926
}
@@ -954,7 +954,7 @@ void SpecialAbilityUpdate::startPreparation()
954954
}
955955

956956
//Warn the victim so he might have a chance to react!
957-
if( spTemplate->getSpecialPowerType() == SPECIAL_BLACKLOTUS_CAPTURE_BUILDING && target && target->isLocallyControlled() )
957+
if( spTemplate->getSpecialPowerType() == SPECIAL_BLACKLOTUS_CAPTURE_BUILDING && target && target->isLocallyViewed() )
958958
{
959959
TheEva->setShouldPlay( EVA_BuildingBeingStolen );
960960
}
@@ -1308,7 +1308,7 @@ void SpecialAbilityUpdate::triggerAbilityEffect()
13081308
}
13091309

13101310
//Play the "building stolen" EVA event if the local player is the victim!
1311-
if( target && target->isLocallyControlled() )
1311+
if( target && target->isLocallyViewed() )
13121312
{
13131313
TheEva->setShouldPlay( EVA_BuildingStolen );
13141314
}
@@ -1358,7 +1358,7 @@ void SpecialAbilityUpdate::triggerAbilityEffect()
13581358
controller->getScoreKeeper()->addMoneyEarned( cash );
13591359

13601360
//Play the "cash stolen" EVA event if the local player is the victim!
1361-
if( target && target->isLocallyControlled() )
1361+
if( target && target->isLocallyViewed() )
13621362
{
13631363
TheEva->setShouldPlay( EVA_CashStolen );
13641364
}

GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ class Object : public Thing, public Snapshot
254254
void removeCustomIndicatorColor();
255255

256256
Bool isLocallyControlled() const;
257+
Bool isLocallyViewed() const;
257258
Bool isNeutralControlled() const;
258259

259260
Bool getIsUndetectedDefector(void) const { return BitIsSet(m_privateStatus, UNDETECTED_DEFECTOR); }

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/ConvertToHijackedVehicleCrateCollide.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Bool ConvertToHijackedVehicleCrateCollide::executeCrateBehavior( Object *other )
155155

156156
//Before the actual defection takes place, play the "vehicle stolen" EVA
157157
//event if the local player is the victim!
158-
if( other->isLocallyControlled() )
158+
if( other->isLocallyViewed() )
159159
{
160160
TheEva->setShouldPlay( EVA_VehicleStolen );
161161
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageCommandCenterCrateCollide.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Bool SabotageCommandCenterCrateCollide::executeCrateBehavior( Object *other )
136136

137137
//When the sabotage occurs, play the appropriate EVA
138138
//event if the local player is the victim!
139-
if( other->isLocallyControlled() )
139+
if( other->isLocallyViewed() )
140140
{
141141
TheEva->setShouldPlay( EVA_BuildingSabotaged );
142142
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/SabotageFakeBuilding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Bool SabotageFakeBuildingCrateCollide::executeCrateBehavior( Object *other )
131131

132132
//When the sabotage occurs, play the appropriate EVA
133133
//event if the local player is the victim!
134-
if( other->isLocallyControlled() )
134+
if( other->isLocallyViewed() )
135135
{
136136
TheEva->setShouldPlay( EVA_BuildingSabotaged );
137137
}

0 commit comments

Comments
 (0)