Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Generals/Code/GameEngine/Include/GameLogic/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
//-------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
//-------------------------------------------------------------------------------------------------
Expand Down
Loading