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
2 changes: 0 additions & 2 deletions Generals/Code/GameEngine/Include/GameClient/ControlBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,6 @@ class ControlBar : public SubsystemInterface
Player* getCurrentlyViewedPlayer();
/// Returns the relationship with the currently viewed player. May return NEUTRAL if no player is selected while observing.
Relationship getCurrentlyViewedPlayerRelationship(const Team* team);
/// Returns the currently viewed player. Returns "Observer" if no player is selected while observing.
AsciiString getCurrentlyViewedPlayerSide();

// ControlBarResizer *getControlBarResizer( void ) {return m_controlBarResizer;}

Expand Down
8 changes: 4 additions & 4 deletions Generals/Code/GameEngine/Source/GameClient/Drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ Bool Drawable::drawsAnyUIText( void )
return FALSE;

const Object *obj = getObject();
if ( !obj || obj->getControllingPlayer() != TheControlBar->getCurrentlyViewedPlayer())
if ( !obj || obj->getControllingPlayer() != rts::getObservedOrLocalPlayer())
return FALSE;

Player *owner = obj->getControllingPlayer();
Expand Down Expand Up @@ -2422,7 +2422,7 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
if (!(
TheGlobalData->m_showObjectHealth &&
(isSelected() || (TheInGameUI && (TheInGameUI->getMousedOverDrawableID() == getID()))) &&
obj->getControllingPlayer() == TheControlBar->getCurrentlyViewedPlayer()
obj->getControllingPlayer() == rts::getObservedOrLocalPlayer()
))
return;

Expand Down Expand Up @@ -2480,7 +2480,7 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
if (!(
TheGlobalData->m_showObjectHealth &&
(isSelected() || (TheInGameUI && (TheInGameUI->getMousedOverDrawableID() == getID()))) &&
obj->getControllingPlayer() == TheControlBar->getCurrentlyViewedPlayer()
obj->getControllingPlayer() == rts::getObservedOrLocalPlayer()
))
return;

Expand Down Expand Up @@ -2953,7 +2953,7 @@ void Drawable::drawBombed(const IRegion2D* healthBarRegion)
UnsignedInt now = TheGameLogic->getFrame();

if( obj->testWeaponSetFlag( WEAPONSET_CARBOMB ) &&
obj->getControllingPlayer() == TheControlBar->getCurrentlyViewedPlayer())
obj->getControllingPlayer() == rts::getObservedOrLocalPlayer())
{
if( !getIconInfo()->m_icon[ ICON_CARBOMB ] )
getIconInfo()->m_icon[ ICON_CARBOMB ] = newInstance(Anim2D)( s_animationTemplates[ ICON_CARBOMB ], TheAnim2DCollection );
Expand Down
5 changes: 3 additions & 2 deletions Generals/Code/GameEngine/Source/GameClient/Eva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "GameClient/ControlBar.h"
#include "GameClient/Eva.h"

#include "Common/GameUtility.h"
#include "Common/Player.h"
#include "Common/PlayerList.h"
#include "GameLogic/GameLogic.h"
Expand Down Expand Up @@ -212,7 +213,7 @@ void Eva::update()
return;
}

m_localPlayer = TheControlBar->getCurrentlyViewedPlayer();
m_localPlayer = rts::getObservedOrLocalPlayer();
UnsignedInt frame = TheGameLogic->getFrame();

// Don't update for the first few frames. This way, we don't have to deal with our initial power
Expand Down Expand Up @@ -429,7 +430,7 @@ void Eva::processPlayingMessages(UnsignedInt currentFrame)
}

// We've got a winner!
AsciiString side = TheControlBar->getCurrentlyViewedPlayerSide();
AsciiString side = rts::getObservedOrLocalPlayer()->getSide();
Int numSides = storedIt->m_evaInfo->m_evaSideSounds.size();

for (Int i = 0; i < numSides; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,6 @@ Relationship ControlBar::getCurrentlyViewedPlayerRelationship(const Team* team)
return NEUTRAL;
}

AsciiString ControlBar::getCurrentlyViewedPlayerSide()
{
if (Player* player = getCurrentlyViewedPlayer())
player->getSide();

return ThePlayerList->getLocalPlayer()->getSide();
}

void ControlBar::populatePurchaseScience( Player* player )
{
// TheInGameUI->deselectAllDrawables();
Expand Down
16 changes: 7 additions & 9 deletions Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5563,10 +5563,12 @@ void InGameUI::removeIdleWorker( Object *obj, Int playerNumber )

void InGameUI::selectNextIdleWorker( void )
{
Int index = TheControlBar->getCurrentlyViewedPlayer()->getPlayerIndex();
Player* player = rts::getObservedOrLocalPlayer();
Int index = player->getPlayerIndex();

if(m_idleWorkers[index].empty())
{
DEBUG_ASSERTCRASH(FALSE, ("InGameUI::selectNextIdleWorker We're trying to select a worker when our list is empty for player %ls", ThePlayerList->getLocalPlayer()->getPlayerDisplayName().str()));
DEBUG_ASSERTCRASH(FALSE, ("InGameUI::selectNextIdleWorker We're trying to select a worker when our list is empty for player %ls", player->getPlayerDisplayName().str()));
return;
}
Object *selectThisObject = NULL;
Expand Down Expand Up @@ -5653,13 +5655,9 @@ ObjectPtrVector InGameUI::getUniqueIdleWorkers(const ObjectList& idleWorkers)

Int InGameUI::getIdleWorkerCount( void )
{
if (Player* player = TheControlBar->getCurrentlyViewedPlayer())
{
Int index = player->getPlayerIndex();
return m_idleWorkers[index].size();
}

return 0;
Player* player = rts::getObservedOrLocalPlayer();
Int index = player->getPlayerIndex();
return m_idleWorkers[index].size();
}

void InGameUI::showIdleWorkerLayout( void )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ void findCommandCenterOrMostExpensiveBuilding(Object* obj, void* vccl)

static void viewCommandCenter( void )
{
Player* localPlayer = TheControlBar->getCurrentlyViewedPlayer();
if (!localPlayer)
Player* localPlayer = rts::getObservedOrLocalPlayer();
if (!localPlayer->isPlayerActive())
return;

CommandCenterLocator ccl;
Expand Down Expand Up @@ -928,8 +928,8 @@ void amIAHero(Object* obj, void* heroHolder)

static Object *iNeedAHero( void )
{
Player* localPlayer = TheControlBar->getCurrentlyViewedPlayer();
if (!localPlayer)
Player* localPlayer = rts::getObservedOrLocalPlayer();
if (!localPlayer->isPlayerActive())
return NULL;

HeroHolder heroHolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <assetmgr.h>
#include <texture.h>

#include "Common/GameUtility.h"
#include "Common/GlobalData.h"
#include "Common/RandomValue.h"
#include "Common/ThingFactory.h"
Expand Down Expand Up @@ -223,7 +224,7 @@ void W3DWaypointBuffer::drawWaypoints(RenderInfoClass &rinfo)
Int numPoints = 0;
if( obj )
{
if ( obj->getControllingPlayer() != TheControlBar->getCurrentlyViewedPlayer())
if ( obj->getControllingPlayer() != rts::getObservedOrLocalPlayer())
continue;

ExitInterface *exitInterface = obj->getObjectExitInterface();
Expand Down
2 changes: 0 additions & 2 deletions GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,6 @@ class ControlBar : public SubsystemInterface
Player* getCurrentlyViewedPlayer();
/// Returns the relationship with the currently viewed player. May return NEUTRAL if no player is selected while observing.
Relationship getCurrentlyViewedPlayerRelationship(const Team* team);
/// Returns the currently viewed player. Returns "Observer" if no player is selected while observing.
AsciiString getCurrentlyViewedPlayerSide();

// ControlBarResizer *getControlBarResizer( void ) {return m_controlBarResizer;}

Expand Down
8 changes: 4 additions & 4 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2718,7 +2718,7 @@ Bool Drawable::drawsAnyUIText( void )
return FALSE;

const Object *obj = getObject();
if ( !obj || obj->getControllingPlayer() != TheControlBar->getCurrentlyViewedPlayer())
if ( !obj || obj->getControllingPlayer() != rts::getObservedOrLocalPlayer())
return FALSE;

Player *owner = obj->getControllingPlayer();
Expand Down Expand Up @@ -2871,7 +2871,7 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
if (!(
TheGlobalData->m_showObjectHealth &&
(isSelected() || (TheInGameUI && (TheInGameUI->getMousedOverDrawableID() == getID()))) &&
obj->getControllingPlayer() == TheControlBar->getCurrentlyViewedPlayer()
obj->getControllingPlayer() == rts::getObservedOrLocalPlayer()
))
return;

Expand Down Expand Up @@ -2929,7 +2929,7 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
if (!(
TheGlobalData->m_showObjectHealth &&
(isSelected() || (TheInGameUI && (TheInGameUI->getMousedOverDrawableID() == getID()))) &&
obj->getControllingPlayer() == TheControlBar->getCurrentlyViewedPlayer()
obj->getControllingPlayer() == rts::getObservedOrLocalPlayer()
))
return;

Expand Down Expand Up @@ -3447,7 +3447,7 @@ void Drawable::drawBombed(const IRegion2D* healthBarRegion)
UnsignedInt now = TheGameLogic->getFrame();

if( obj->testWeaponSetFlag( WEAPONSET_CARBOMB ) &&
obj->getControllingPlayer() == TheControlBar->getCurrentlyViewedPlayer())
obj->getControllingPlayer() == rts::getObservedOrLocalPlayer())
{
if( !getIconInfo()->m_icon[ ICON_CARBOMB ] )
getIconInfo()->m_icon[ ICON_CARBOMB ] = newInstance(Anim2D)( s_animationTemplates[ ICON_CARBOMB ], TheAnim2DCollection );
Expand Down
5 changes: 3 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Eva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "GameClient/ControlBar.h"
#include "GameClient/Eva.h"

#include "Common/GameUtility.h"
#include "Common/Player.h"
#include "Common/PlayerList.h"
#include "GameLogic/GameLogic.h"
Expand Down Expand Up @@ -284,7 +285,7 @@ void Eva::update()
return;
}

m_localPlayer = TheControlBar->getCurrentlyViewedPlayer();
m_localPlayer = rts::getObservedOrLocalPlayer();
UnsignedInt frame = TheGameLogic->getFrame();

// Don't update for the first few frames. This way, we don't have to deal with our initial power
Expand Down Expand Up @@ -503,7 +504,7 @@ void Eva::processPlayingMessages(UnsignedInt currentFrame)
}

// We've got a winner!
AsciiString side = TheControlBar->getCurrentlyViewedPlayerSide();
AsciiString side = rts::getObservedOrLocalPlayer()->getSide();
Int numSides = storedIt->m_evaInfo->m_evaSideSounds.size();

// clear it. If we can't find the side we want, don't play anything
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,6 @@ Relationship ControlBar::getCurrentlyViewedPlayerRelationship(const Team* team)
return NEUTRAL;
}

AsciiString ControlBar::getCurrentlyViewedPlayerSide()
{
if (Player* player = getCurrentlyViewedPlayer())
return player->getSide();

return ThePlayerList->getLocalPlayer()->getSide();
}

void ControlBar::populatePurchaseScience( Player* player )
{
// TheInGameUI->deselectAllDrawables();
Expand Down
16 changes: 7 additions & 9 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5736,10 +5736,12 @@ void InGameUI::removeIdleWorker( Object *obj, Int playerNumber )

void InGameUI::selectNextIdleWorker( void )
{
Int index = TheControlBar->getCurrentlyViewedPlayer()->getPlayerIndex();
Player* player = rts::getObservedOrLocalPlayer();
Int index = player->getPlayerIndex();

if(m_idleWorkers[index].empty())
{
DEBUG_ASSERTCRASH(FALSE, ("InGameUI::selectNextIdleWorker We're trying to select a worker when our list is empty for player %ls", ThePlayerList->getLocalPlayer()->getPlayerDisplayName().str()));
DEBUG_ASSERTCRASH(FALSE, ("InGameUI::selectNextIdleWorker We're trying to select a worker when our list is empty for player %ls", player->getPlayerDisplayName().str()));
return;
}
Object *selectThisObject = NULL;
Expand Down Expand Up @@ -5826,13 +5828,9 @@ ObjectPtrVector InGameUI::getUniqueIdleWorkers(const ObjectList& idleWorkers)

Int InGameUI::getIdleWorkerCount( void )
{
if (Player* player = TheControlBar->getCurrentlyViewedPlayer())
{
Int index = player->getPlayerIndex();
return m_idleWorkers[index].size();
}

return 0;
Player* player = rts::getObservedOrLocalPlayer();
Int index = player->getPlayerIndex();
return m_idleWorkers[index].size();
}

void InGameUI::showIdleWorkerLayout( void )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,8 @@ void findCommandCenterOrMostExpensiveBuilding(Object* obj, void* vccl)

static void viewCommandCenter( void )
{
Player* localPlayer = TheControlBar->getCurrentlyViewedPlayer();
if (!localPlayer)
Player* localPlayer = rts::getObservedOrLocalPlayer();
if (!localPlayer->isPlayerActive())
return;

CommandCenterLocator ccl;
Expand Down Expand Up @@ -986,8 +986,8 @@ void amIAHero(Object* obj, void* heroHolder)

static Object *iNeedAHero( void )
{
Player* localPlayer = TheControlBar->getCurrentlyViewedPlayer();
if (!localPlayer)
Player* localPlayer = rts::getObservedOrLocalPlayer();
if (!localPlayer->isPlayerActive())
return NULL;

HeroHolder heroHolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <assetmgr.h>
#include <texture.h>

#include "Common/GameUtility.h"
#include "Common/GlobalData.h"
#include "Common/RandomValue.h"
#include "Common/ThingFactory.h"
Expand Down Expand Up @@ -230,7 +231,7 @@ void W3DWaypointBuffer::drawWaypoints(RenderInfoClass &rinfo)
Int numPoints = 0;
if( obj )
{
if ( obj->getControllingPlayer() != TheControlBar->getCurrentlyViewedPlayer())
if ( obj->getControllingPlayer() != rts::getObservedOrLocalPlayer())
continue;


Expand Down
Loading