Skip to content

Commit 4df4584

Browse files
committed
refactor: Reorder functions
1 parent 133a0d9 commit 4df4584

File tree

4 files changed

+68
-62
lines changed

4 files changed

+68
-62
lines changed

Generals/Code/GameEngine/Include/GameLogic/Object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ class Object : public Thing, public Snapshot
237237
void setCustomIndicatorColor(Color c);
238238
void removeCustomIndicatorColor();
239239

240+
Bool isLogicallyVisible() const; ///< Returns whether the object is logically visible to the player.
241+
240242
Bool isLocallyControlled() const;
241243
Bool isLocallyViewed() const;
242244
Bool isNeutralControlled() const;
@@ -420,7 +422,6 @@ class Object : public Thing, public Snapshot
420422
void friend_setContainedBy( Object *containedBy ) { m_containedBy = containedBy; }
421423
const Object* getEnclosingContainedBy() const; ///< Find the first enclosing container in the containment chain.
422424
const Object* getOuterObject() const; ///< Get the top-level object
423-
Bool isLogicallyVisible() const; ///< Returns whether the object is logically visible to the player.
424425

425426
// Special Powers -------------------------------------------------------------------------------
426427
SpecialPowerModuleInterface *getSpecialPowerModule( const SpecialPowerTemplate *specialPowerTemplate ) const;

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

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -685,36 +685,6 @@ const Object* Object::getOuterObject() const
685685
return this;
686686
}
687687

688-
//-------------------------------------------------------------------------------------------------
689-
Bool Object::isLogicallyVisible() const
690-
{
691-
if (isLocallyViewed())
692-
return true;
693-
694-
if (TheControlBar->isObserverControlBarOn())
695-
{
696-
const Player* observedPlayer = TheControlBar->getObserverLookAtPlayer();
697-
if (!observedPlayer || !observedPlayer->isPlayerActive())
698-
return true;
699-
}
700-
701-
const Object* obj = getOuterObject();
702-
703-
if (obj->isKindOf(KINDOF_DISGUISER))
704-
return true;
705-
706-
if (obj->testStatus(OBJECT_STATUS_STEALTHED) && !obj->testStatus(OBJECT_STATUS_DETECTED))
707-
{
708-
const Player* player = rts::getObservedOrLocalPlayer();
709-
const Relationship relationship = player->getRelationship(getTeam());
710-
711-
if (relationship != ALLIES)
712-
return false;
713-
}
714-
715-
return true;
716-
}
717-
718688
//-------------------------------------------------------------------------------------------------
719689
/** Run from GameLogic::destroyObject */
720690
//-------------------------------------------------------------------------------------------------
@@ -1571,6 +1541,38 @@ Color Object::getNightIndicatorColor() const
15711541
}
15721542
}
15731543

1544+
//=============================================================================
1545+
// Object::isLogicallyVisible
1546+
//=============================================================================
1547+
Bool Object::isLogicallyVisible() const
1548+
{
1549+
if (isLocallyViewed())
1550+
return true;
1551+
1552+
if (TheControlBar->isObserverControlBarOn())
1553+
{
1554+
const Player* observedPlayer = TheControlBar->getObserverLookAtPlayer();
1555+
if (!observedPlayer || !observedPlayer->isPlayerActive())
1556+
return true;
1557+
}
1558+
1559+
const Object* obj = getOuterObject();
1560+
1561+
if (obj->isKindOf(KINDOF_DISGUISER))
1562+
return true;
1563+
1564+
if (obj->testStatus(OBJECT_STATUS_STEALTHED) && !obj->testStatus(OBJECT_STATUS_DETECTED))
1565+
{
1566+
const Player* player = rts::getObservedOrLocalPlayer();
1567+
const Relationship relationship = player->getRelationship(getTeam());
1568+
1569+
if (relationship != ALLIES)
1570+
return false;
1571+
}
1572+
1573+
return true;
1574+
}
1575+
15741576
//=============================================================================
15751577
// Object::isLocallyControlled
15761578
//=============================================================================

GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ class Object : public Thing, public Snapshot
253253
void setCustomIndicatorColor(Color c);
254254
void removeCustomIndicatorColor();
255255

256+
Bool isLogicallyVisible() const; ///< Returns whether the object is logically visible to the player.
257+
256258
Bool isLocallyControlled() const;
257259
Bool isLocallyViewed() const;
258260
Bool isNeutralControlled() const;
@@ -445,7 +447,6 @@ class Object : public Thing, public Snapshot
445447
void friend_setContainedBy( Object *containedBy ) { m_containedBy = containedBy; }
446448
const Object* getEnclosingContainedBy() const; ///< Find the first enclosing container in the containment chain.
447449
const Object* getOuterObject() const; ///< Get the top-level object
448-
Bool isLogicallyVisible() const; ///< Returns whether the object is logically visible to the player.
449450

450451
// Special Powers -------------------------------------------------------------------------------
451452
SpecialPowerModuleInterface *getSpecialPowerModule( const SpecialPowerTemplate *specialPowerTemplate ) const;

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

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -749,36 +749,6 @@ const Object* Object::getOuterObject() const
749749
return this;
750750
}
751751

752-
//-------------------------------------------------------------------------------------------------
753-
Bool Object::isLogicallyVisible() const
754-
{
755-
if (isLocallyViewed())
756-
return true;
757-
758-
if (TheControlBar->isObserverControlBarOn())
759-
{
760-
const Player* observedPlayer = TheControlBar->getObserverLookAtPlayer();
761-
if (!observedPlayer || !observedPlayer->isPlayerActive())
762-
return true;
763-
}
764-
765-
const Object* obj = getOuterObject();
766-
767-
if (obj->isKindOf(KINDOF_DISGUISER))
768-
return true;
769-
770-
if (obj->testStatus(OBJECT_STATUS_STEALTHED) && !obj->testStatus(OBJECT_STATUS_DETECTED))
771-
{
772-
const Player* player = rts::getObservedOrLocalPlayer();
773-
const Relationship relationship = player->getRelationship(getTeam());
774-
775-
if (relationship != ALLIES)
776-
return false;
777-
}
778-
779-
return true;
780-
}
781-
782752
//-------------------------------------------------------------------------------------------------
783753
/** Run from GameLogic::destroyObject */
784754
//-------------------------------------------------------------------------------------------------
@@ -1726,6 +1696,38 @@ Color Object::getNightIndicatorColor() const
17261696
}
17271697
}
17281698

1699+
//=============================================================================
1700+
// Object::isLogicallyVisible
1701+
//=============================================================================
1702+
Bool Object::isLogicallyVisible() const
1703+
{
1704+
if (isLocallyViewed())
1705+
return true;
1706+
1707+
if (TheControlBar->isObserverControlBarOn())
1708+
{
1709+
const Player* observedPlayer = TheControlBar->getObserverLookAtPlayer();
1710+
if (!observedPlayer || !observedPlayer->isPlayerActive())
1711+
return true;
1712+
}
1713+
1714+
const Object* obj = getOuterObject();
1715+
1716+
if (obj->isKindOf(KINDOF_DISGUISER))
1717+
return true;
1718+
1719+
if (obj->testStatus(OBJECT_STATUS_STEALTHED) && !obj->testStatus(OBJECT_STATUS_DETECTED))
1720+
{
1721+
const Player* player = rts::getObservedOrLocalPlayer();
1722+
const Relationship relationship = player->getRelationship(getTeam());
1723+
1724+
if (relationship != ALLIES)
1725+
return false;
1726+
}
1727+
1728+
return true;
1729+
}
1730+
17291731
//=============================================================================
17301732
// Object::isLocallyControlled
17311733
//=============================================================================

0 commit comments

Comments
 (0)