diff --git a/Generals/Code/GameEngine/Include/GameLogic/Object.h b/Generals/Code/GameEngine/Include/GameLogic/Object.h index cf7fbf9dfd..6f9781964f 100644 --- a/Generals/Code/GameEngine/Include/GameLogic/Object.h +++ b/Generals/Code/GameEngine/Include/GameLogic/Object.h @@ -421,6 +421,7 @@ class Object : public Thing, public Snapshot void onRemovedFrom( Object *removedFrom ); Int getTransportSlotCount() const; void friend_setContainedBy( Object *containedBy ) { m_containedBy = containedBy; } + Object* getEnclosingContainedBy(); ///< Find the first enclosing container in the containment chain. // Special Powers ------------------------------------------------------------------------------- SpecialPowerModuleInterface *getSpecialPowerModule( const SpecialPowerTemplate *specialPowerTemplate ) const; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp index cd34783518..f10dd04960 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp @@ -40,6 +40,7 @@ #include "GameLogic/Object.h" #include "GameLogic/PartitionManager.h" #include "GameLogic/Weapon.h" +#include "GameLogic/Module/ContainModule.h" #include "GameLogic/Module/PropagandaTowerBehavior.h" #include "GameLogic/Module/BodyModule.h" @@ -205,11 +206,13 @@ UpdateSleepTime PropagandaTowerBehavior::update( void ) } } - if( self->getContainedBy() && self->getContainedBy()->getContainedBy() ) +#if RETAIL_COMPATIBLE_CRC + if (self->getContainedBy() && self->getContainedBy()->getContainedBy()) +#else + // TheSuperHackers @bugfix If our container or any parent containers are enclosing, we turn the heck off. + if (self->getEnclosingContainedBy()) +#endif { - // If our container is contained, we turn the heck off. Seems like a weird specific check, but all of - // attacking is guarded by the same check in isPassengersAllowedToFire. We similarly work in a container, - // but not in a double container. removeAllInfluence(); return UPDATE_SLEEP_NONE; } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp index f4d7705107..c0dbd47221 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -667,6 +667,18 @@ Int Object::getTransportSlotCount() const return count; } +Object* Object::getEnclosingContainedBy() +{ + for (Object* child = this, *container = getContainedBy(); container; child = container, container = container->getContainedBy()) + { + ContainModuleInterface* containModule = container->getContain(); + if (containModule && containModule->isEnclosingContainerFor(child)) + return container; + } + + return NULL; +} + //------------------------------------------------------------------------------------------------- /** Run from GameLogic::destroyObject */ //------------------------------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h index 70714d8f37..24cdb68781 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h @@ -446,6 +446,7 @@ class Object : public Thing, public Snapshot void onRemovedFrom( Object *removedFrom ); Int getTransportSlotCount() const; void friend_setContainedBy( Object *containedBy ) { m_containedBy = containedBy; } + Object* getEnclosingContainedBy(); ///< Find the first enclosing container in the containment chain. // Special Powers ------------------------------------------------------------------------------- SpecialPowerModuleInterface *getSpecialPowerModule( const SpecialPowerTemplate *specialPowerTemplate ) const; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp index 2d22c47123..abd971772e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp @@ -40,6 +40,7 @@ #include "GameLogic/Object.h" #include "GameLogic/PartitionManager.h" #include "GameLogic/Weapon.h" +#include "GameLogic/Module/ContainModule.h" #include "GameLogic/Module/PropagandaTowerBehavior.h" #include "GameLogic/Module/BodyModule.h" @@ -207,11 +208,13 @@ UpdateSleepTime PropagandaTowerBehavior::update( void ) } } - if( self->getContainedBy() && self->getContainedBy()->getContainedBy() ) +#if RETAIL_COMPATIBLE_CRC + if (self->getContainedBy() && self->getContainedBy()->getContainedBy()) +#else + // TheSuperHackers @bugfix If our container or any parent containers are enclosing, we turn the heck off. + if (self->getEnclosingContainedBy()) +#endif { - // If our container is contained, we turn the heck off. Seems like a weird specific check, but all of - // attacking is guarded by the same check in isPassengersAllowedToFire. We similarly work in a container, - // but not in a double container. removeAllInfluence(); return UPDATE_SLEEP_NONE; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index f48cd78ec0..039b858117 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -731,6 +731,18 @@ Int Object::getTransportSlotCount() const return count; } +Object* Object::getEnclosingContainedBy() +{ + for (Object* child = this, *container = getContainedBy(); container; child = container, container = container->getContainedBy()) + { + ContainModuleInterface* containModule = container->getContain(); + if (containModule && containModule->isEnclosingContainerFor(child)) + return container; + } + + return NULL; +} + //------------------------------------------------------------------------------------------------- /** Run from GameLogic::destroyObject */ //-------------------------------------------------------------------------------------------------