Skip to content

Commit 9493ad8

Browse files
committed
tweak: Adjust logic to cover all container hierarchies
1 parent b4fe77a commit 9493ad8

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,19 @@ UpdateSleepTime PropagandaTowerBehavior::update( void )
210210
Bool contained = self->getContainedBy() && self->getContainedBy()->getContainedBy();
211211
#else
212212
Object* container = self->getContainedBy();
213+
Bool contained = false;
213214

214-
while (container && container->getContainedBy())
215-
container = container->getContainedBy();
215+
while (container)
216+
{
217+
ContainModuleInterface* containModule = container->getContain();
218+
if (containModule && containModule->isEnclosingContainerFor(self))
219+
{
220+
contained = true;
221+
break;
222+
}
216223

217-
Bool contained = (container && container->getContain()->isEnclosingContainerFor(self));
224+
container = container->getContainedBy();
225+
}
218226
#endif
219227

220228
if (contained)

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,19 @@ UpdateSleepTime PropagandaTowerBehavior::update( void )
212212
Bool contained = self->getContainedBy() && self->getContainedBy()->getContainedBy();
213213
#else
214214
Object* container = self->getContainedBy();
215+
Bool contained = false;
215216

216-
while (container && container->getContainedBy())
217-
container = container->getContainedBy();
217+
while (container)
218+
{
219+
ContainModuleInterface* containModule = container->getContain();
220+
if (containModule && containModule->isEnclosingContainerFor(self))
221+
{
222+
contained = true;
223+
break;
224+
}
218225

219-
Bool contained = (container && container->getContain()->isEnclosingContainerFor(self));
226+
container = container->getContainedBy();
227+
}
220228
#endif
221229

222230
if (contained)

0 commit comments

Comments
 (0)