File tree Expand file tree Collapse file tree 6 files changed +40
-8
lines changed
GeneralsMD/Code/GameEngine Expand file tree Collapse file tree 6 files changed +40
-8
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,7 @@ class Object : public Thing, public Snapshot
421421 void onRemovedFrom ( Object *removedFrom );
422422 Int getTransportSlotCount () const ;
423423 void friend_setContainedBy ( Object *containedBy ) { m_containedBy = containedBy; }
424+ Object* getEnclosingContainedBy (); // /< Find the first enclosing container in the containment chain.
424425
425426 // Special Powers -------------------------------------------------------------------------------
426427 SpecialPowerModuleInterface *getSpecialPowerModule ( const SpecialPowerTemplate *specialPowerTemplate ) const ;
Original file line number Diff line number Diff line change 4040#include " GameLogic/Object.h"
4141#include " GameLogic/PartitionManager.h"
4242#include " GameLogic/Weapon.h"
43+ #include " GameLogic/Module/ContainModule.h"
4344#include " GameLogic/Module/PropagandaTowerBehavior.h"
4445#include " GameLogic/Module/BodyModule.h"
4546
@@ -205,11 +206,13 @@ UpdateSleepTime PropagandaTowerBehavior::update( void )
205206 }
206207 }
207208
208- if ( self->getContainedBy () && self->getContainedBy ()->getContainedBy () )
209+ #if RETAIL_COMPATIBLE_CRC
210+ if (self->getContainedBy () && self->getContainedBy ()->getContainedBy ())
211+ #else
212+ // TheSuperHackers @bugfix If our container or any parent containers are enclosing, we turn the heck off.
213+ if (self->getEnclosingContainedBy ())
214+ #endif
209215 {
210- // If our container is contained, we turn the heck off. Seems like a weird specific check, but all of
211- // attacking is guarded by the same check in isPassengersAllowedToFire. We similarly work in a container,
212- // but not in a double container.
213216 removeAllInfluence ();
214217 return UPDATE_SLEEP_NONE;
215218 }
Original file line number Diff line number Diff line change @@ -667,6 +667,18 @@ Int Object::getTransportSlotCount() const
667667 return count;
668668}
669669
670+ Object* Object::getEnclosingContainedBy ()
671+ {
672+ for (Object* child = this , *container = getContainedBy (); container; child = container, container = container->getContainedBy ())
673+ {
674+ ContainModuleInterface* containModule = container->getContain ();
675+ if (containModule && containModule->isEnclosingContainerFor (child))
676+ return container;
677+ }
678+
679+ return NULL ;
680+ }
681+
670682// -------------------------------------------------------------------------------------------------
671683/* * Run from GameLogic::destroyObject */
672684// -------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -446,6 +446,7 @@ class Object : public Thing, public Snapshot
446446 void onRemovedFrom ( Object *removedFrom );
447447 Int getTransportSlotCount () const ;
448448 void friend_setContainedBy ( Object *containedBy ) { m_containedBy = containedBy; }
449+ Object* getEnclosingContainedBy (); // /< Find the first enclosing container in the containment chain.
449450
450451 // Special Powers -------------------------------------------------------------------------------
451452 SpecialPowerModuleInterface *getSpecialPowerModule ( const SpecialPowerTemplate *specialPowerTemplate ) const ;
Original file line number Diff line number Diff line change 4040#include " GameLogic/Object.h"
4141#include " GameLogic/PartitionManager.h"
4242#include " GameLogic/Weapon.h"
43+ #include " GameLogic/Module/ContainModule.h"
4344#include " GameLogic/Module/PropagandaTowerBehavior.h"
4445#include " GameLogic/Module/BodyModule.h"
4546
@@ -207,11 +208,13 @@ UpdateSleepTime PropagandaTowerBehavior::update( void )
207208 }
208209 }
209210
210- if ( self->getContainedBy () && self->getContainedBy ()->getContainedBy () )
211+ #if RETAIL_COMPATIBLE_CRC
212+ if (self->getContainedBy () && self->getContainedBy ()->getContainedBy ())
213+ #else
214+ // TheSuperHackers @bugfix If our container or any parent containers are enclosing, we turn the heck off.
215+ if (self->getEnclosingContainedBy ())
216+ #endif
211217 {
212- // If our container is contained, we turn the heck off. Seems like a weird specific check, but all of
213- // attacking is guarded by the same check in isPassengersAllowedToFire. We similarly work in a container,
214- // but not in a double container.
215218 removeAllInfluence ();
216219 return UPDATE_SLEEP_NONE;
217220 }
Original file line number Diff line number Diff line change @@ -731,6 +731,18 @@ Int Object::getTransportSlotCount() const
731731 return count;
732732}
733733
734+ Object* Object::getEnclosingContainedBy ()
735+ {
736+ for (Object* child = this , *container = getContainedBy (); container; child = container, container = container->getContainedBy ())
737+ {
738+ ContainModuleInterface* containModule = container->getContain ();
739+ if (containModule && containModule->isEnclosingContainerFor (child))
740+ return container;
741+ }
742+
743+ return NULL ;
744+ }
745+
734746// -------------------------------------------------------------------------------------------------
735747/* * Run from GameLogic::destroyObject */
736748// -------------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments