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
3 changes: 2 additions & 1 deletion Generals/Code/GameEngine/Include/GameLogic/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ 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.
const Object* getEnclosingContainedBy() const; ///< Find the first enclosing container in the containment chain.
const Object* getOuterObject() const; ///< Get the top-level object

// Special Powers -------------------------------------------------------------------------------
SpecialPowerModuleInterface *getSpecialPowerModule( const SpecialPowerTemplate *specialPowerTemplate ) const;
Expand Down
17 changes: 14 additions & 3 deletions Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@ Int Object::getTransportSlotCount() const
return count;
}

Object* Object::getEnclosingContainedBy()
const Object* Object::getEnclosingContainedBy() const
{
for (Object* child = this, *container = getContainedBy(); container; child = container, container = container->getContainedBy())
for (const Object* child = this, *container = getContainedBy(); container; child = container, container = container->getContainedBy())
{
ContainModuleInterface* containModule = container->getContain();
if (containModule && containModule->isEnclosingContainerFor(child))
Expand All @@ -679,6 +679,14 @@ Object* Object::getEnclosingContainedBy()
return NULL;
}

const Object* Object::getOuterObject() const
{
if (const Object* enclosing = getEnclosingContainedBy())
return enclosing;

return this;
}

//-------------------------------------------------------------------------------------------------
/** Run from GameLogic::destroyObject */
//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2821,10 +2829,13 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
break;
}

Drawable* outerDrawable = getOuterObject()->getDrawable();

Bool doAnimation = provideFeedback
&& newLevel > oldLevel
&& !isKindOf(KINDOF_IGNORED_IN_GUI)
&& getDrawable()->isVisible();
&& outerDrawable
&& outerDrawable->isVisible();

if( doAnimation && TheGameLogic->getDrawIconUI() )
{
Expand Down
5 changes: 4 additions & 1 deletion Generals/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,10 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate

// TheSuperHackers @todo: Remove hardcoded KINDOF_MINE check and apply PlayFXWhenStealthed = Yes to the mine weapons instead.

if(!sourceObj->getDrawable()->isVisible() // if user watching cannot see us
Drawable* outerDrawable = sourceObj->getOuterObject()->getDrawable();
const Bool isVisible = outerDrawable && outerDrawable->isVisible();

if (!isVisible // if user watching cannot see us
&& !sourceObj->isKindOf(KINDOF_MINE) // and not a mine (which always do the FX, even if hidden)...
&& !isPlayFXWhenStealthed() // and not a weapon marked to playwhenstealthed
)
Expand Down
3 changes: 2 additions & 1 deletion GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ 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.
const Object* getEnclosingContainedBy() const; ///< Find the first enclosing container in the containment chain.
const Object* getOuterObject() const; ///< Get the top-level object

// Special Powers -------------------------------------------------------------------------------
SpecialPowerModuleInterface *getSpecialPowerModule( const SpecialPowerTemplate *specialPowerTemplate ) const;
Expand Down
17 changes: 14 additions & 3 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,9 @@ Int Object::getTransportSlotCount() const
return count;
}

Object* Object::getEnclosingContainedBy()
const Object* Object::getEnclosingContainedBy() const
{
for (Object* child = this, *container = getContainedBy(); container; child = container, container = container->getContainedBy())
for (const Object* child = this, *container = getContainedBy(); container; child = container, container = container->getContainedBy())
{
ContainModuleInterface* containModule = container->getContain();
if (containModule && containModule->isEnclosingContainerFor(child))
Expand All @@ -743,6 +743,14 @@ Object* Object::getEnclosingContainedBy()
return NULL;
}

const Object* Object::getOuterObject() const
{
if (const Object* enclosing = getEnclosingContainedBy())
return enclosing;

return this;
}

//-------------------------------------------------------------------------------------------------
/** Run from GameLogic::destroyObject */
//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -3136,10 +3144,13 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
break;
}

Drawable* outerDrawable = getOuterObject()->getDrawable();

Bool doAnimation = provideFeedback
&& newLevel > oldLevel
&& !isKindOf(KINDOF_IGNORED_IN_GUI)
&& getDrawable()->isVisible();
&& outerDrawable
&& outerDrawable->isVisible();

if( doAnimation && TheGameLogic->getDrawIconUI() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ StateReturnType HackInternetState::update()
//Grant the unit some experience for a successful hack.
xp->addExperiencePoints( ai->getXpPerCashUpdate() );

if (owner->getDrawable()->isVisible())
Drawable* outerDrawable = owner->getOuterObject()->getDrawable();
if (outerDrawable && outerDrawable->isVisible())
{
// OY LOOK! I AM USING LOCAL PLAYER. Do not put anything other than TheInGameUI->addFloatingText in the block this controls!!!
//Display cash income floating over the hacker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ UpdateSleepTime AutoDepositUpdate::update( void )
getObject()->getControllingPlayer()->getScoreKeeper()->addMoneyEarned( modData->m_depositAmount);
}

if (moneyAmount > 0 && getObject()->getDrawable()->isVisible())
Drawable* outerDrawable = getObject()->getOuterObject()->getDrawable();
if (moneyAmount > 0 && outerDrawable && outerDrawable->isVisible())
{

const Object *owner = getObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ Bool SupplyCenterDockUpdate::action( Object* docker, Object *drone )
}
}

if (value > 0 && getObject()->getDrawable()->isVisible())
Drawable* outerDrawable = getObject()->getOuterObject()->getDrawable();
if (value > 0 && outerDrawable && outerDrawable->isVisible())
{
// OY LOOK! I AM USING LOCAL PLAYER. Do not put anything other than TheInGameUI->addFloatingText in the block this controls!!!
// Setup info for adding a floating text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,10 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate

// TheSuperHackers @todo: Remove hardcoded KINDOF_MINE check and apply PlayFXWhenStealthed = Yes to the mine weapons instead.

if(!sourceObj->getDrawable()->isVisible() // if user watching cannot see us
Drawable* outerDrawable = sourceObj->getOuterObject()->getDrawable();
const Bool isVisible = outerDrawable && outerDrawable->isVisible();

if (!isVisible // if user watching cannot see us
&& !sourceObj->isKindOf(KINDOF_MINE) // and not a mine (which always do the FX, even if hidden)...
&& !isPlayFXWhenStealthed() // and not a weapon marked to playwhenstealthed
)
Expand Down
Loading