Skip to content

Commit b5e3186

Browse files
committed
tweak: Always check enclosing container for the direct child
1 parent 1fd5f91 commit b5e3186

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,16 @@ UpdateSleepTime PropagandaTowerBehavior::update( void )
209209
#if RETAIL_COMPATIBLE_CRC
210210
Bool contained = self->getContainedBy() && self->getContainedBy()->getContainedBy();
211211
#else
212-
Object* container = self->getContainedBy();
213212
Bool contained = false;
214213

215-
while (container)
214+
for (Object* child = self, *container = self->getContainedBy(); container; child = container, container = container->getContainedBy())
216215
{
217216
ContainModuleInterface* containModule = container->getContain();
218-
if (containModule && containModule->isEnclosingContainerFor(self))
217+
if (containModule && containModule->isEnclosingContainerFor(child))
219218
{
220219
contained = true;
221220
break;
222221
}
223-
224-
container = container->getContainedBy();
225222
}
226223
#endif
227224

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,16 @@ UpdateSleepTime PropagandaTowerBehavior::update( void )
211211
#if RETAIL_COMPATIBLE_CRC
212212
Bool contained = self->getContainedBy() && self->getContainedBy()->getContainedBy();
213213
#else
214-
Object* container = self->getContainedBy();
215214
Bool contained = false;
216215

217-
while (container)
216+
for (Object* child = self, *container = self->getContainedBy(); container; child = container, container = container->getContainedBy())
218217
{
219218
ContainModuleInterface* containModule = container->getContain();
220-
if (containModule && containModule->isEnclosingContainerFor(self))
219+
if (containModule && containModule->isEnclosingContainerFor(child))
221220
{
222221
contained = true;
223222
break;
224223
}
225-
226-
container = container->getContainedBy();
227224
}
228225
#endif
229226

0 commit comments

Comments
 (0)