File tree Expand file tree Collapse file tree 6 files changed +30
-28
lines changed
GeneralsMD/Code/GameEngine Expand file tree Collapse file tree 6 files changed +30
-28
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+ ContainModuleInterface* getEnclosingContain (); // <<< 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 @@ -207,23 +207,11 @@ UpdateSleepTime PropagandaTowerBehavior::update( void )
207207 }
208208
209209#if RETAIL_COMPATIBLE_CRC
210- Bool contained = self->getContainedBy () && self->getContainedBy ()->getContainedBy ();
210+ if ( self->getContainedBy () && self->getContainedBy ()->getContainedBy ())
211211#else
212212 // If our container or any parent containers are enclosing, we turn the heck off.
213- Bool contained = false ;
214-
215- for (Object* child = self, *container = self->getContainedBy (); container; child = container, container = container->getContainedBy ())
216- {
217- ContainModuleInterface* containModule = container->getContain ();
218- if (containModule && containModule->isEnclosingContainerFor (child))
219- {
220- contained = true ;
221- break ;
222- }
223- }
213+ if (self->getEnclosingContain ())
224214#endif
225-
226- if (contained)
227215 {
228216 removeAllInfluence ();
229217 return UPDATE_SLEEP_NONE;
Original file line number Diff line number Diff line change @@ -667,6 +667,18 @@ Int Object::getTransportSlotCount() const
667667 return count;
668668}
669669
670+ ContainModuleInterface* Object::getEnclosingContain ()
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 containModule;
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+ ContainModuleInterface* getEnclosingContain (); // <<< 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 @@ -209,23 +209,11 @@ UpdateSleepTime PropagandaTowerBehavior::update( void )
209209 }
210210
211211#if RETAIL_COMPATIBLE_CRC
212- Bool contained = self->getContainedBy () && self->getContainedBy ()->getContainedBy ();
212+ if ( self->getContainedBy () && self->getContainedBy ()->getContainedBy ())
213213#else
214214 // If our container or any parent containers are enclosing, we turn the heck off.
215- Bool contained = false ;
216-
217- for (Object* child = self, *container = self->getContainedBy (); container; child = container, container = container->getContainedBy ())
218- {
219- ContainModuleInterface* containModule = container->getContain ();
220- if (containModule && containModule->isEnclosingContainerFor (child))
221- {
222- contained = true ;
223- break ;
224- }
225- }
215+ if (self->getEnclosingContain ())
226216#endif
227-
228- if (contained)
229217 {
230218 removeAllInfluence ();
231219 return UPDATE_SLEEP_NONE;
Original file line number Diff line number Diff line change @@ -731,6 +731,18 @@ Int Object::getTransportSlotCount() const
731731 return count;
732732}
733733
734+ ContainModuleInterface* Object::getEnclosingContain ()
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 containModule;
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