Skip to content

Commit f37c12e

Browse files
committed
refactor: Reduce nesting
1 parent 6337fb3 commit f37c12e

File tree

2 files changed

+58
-58
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar
  • Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar

2 files changed

+58
-58
lines changed

Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,43 +2688,43 @@ void ControlBar::showRallyPoint( const Coord3D *loc )
26882688
// destroy rally point drawable if present
26892689
if( m_rallyPointDrawableID != INVALID_DRAWABLE_ID )
26902690
TheGameClient->destroyDrawable( TheGameClient->findDrawableByID( m_rallyPointDrawableID ) );
2691+
26912692
m_rallyPointDrawableID = INVALID_DRAWABLE_ID;
2693+
return;
26922694
}
2693-
else
2694-
{
2695-
Drawable *marker = NULL;
26962695

2697-
// create a rally point drawble if necessary
2698-
if( m_rallyPointDrawableID == INVALID_DRAWABLE_ID )
2696+
Drawable *marker = NULL;
2697+
2698+
// create a rally point drawble if necessary
2699+
if( m_rallyPointDrawableID == INVALID_DRAWABLE_ID )
2700+
{
2701+
const ThingTemplate* ttn = TheThingFactory->findTemplate("RallyPointMarker");
2702+
marker = TheThingFactory->newDrawable( ttn );
2703+
DEBUG_ASSERTCRASH( marker, ("showRallyPoint: Unable to create rally point drawable") );
2704+
if (marker)
26992705
{
2700-
const ThingTemplate* ttn = TheThingFactory->findTemplate("RallyPointMarker");
2701-
marker = TheThingFactory->newDrawable( ttn );
2702-
DEBUG_ASSERTCRASH( marker, ("showRallyPoint: Unable to create rally point drawable") );
2703-
if (marker)
2704-
{
2705-
marker->setDrawableStatus(DRAWABLE_STATUS_NO_SAVE);
2706-
m_rallyPointDrawableID = marker->getID();
2707-
}
2706+
marker->setDrawableStatus(DRAWABLE_STATUS_NO_SAVE);
2707+
m_rallyPointDrawableID = marker->getID();
27082708
}
2709-
else
2710-
marker = TheGameClient->findDrawableByID( m_rallyPointDrawableID );
2709+
}
2710+
else
2711+
marker = TheGameClient->findDrawableByID( m_rallyPointDrawableID );
27112712

2712-
// sanity
2713-
DEBUG_ASSERTCRASH( marker, ("showRallyPoint: No rally point marker found" ) );
2713+
// sanity
2714+
DEBUG_ASSERTCRASH( marker, ("showRallyPoint: No rally point marker found" ) );
27142715

2715-
// set the position of the rally point drawble to the position passed in
2716-
marker->setPosition( loc );
2717-
marker->setOrientation( TheGlobalData->m_downwindAngle );//To blow down wind -- ML
2716+
// set the position of the rally point drawble to the position passed in
2717+
marker->setPosition( loc );
2718+
marker->setOrientation( TheGlobalData->m_downwindAngle );//To blow down wind -- ML
27182719

2719-
// set the marker colors to that of the local player
2720-
Player* player = TheControlBar->getCurrentlyViewedPlayer();
2721-
if (player)
2722-
{
2723-
if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT)
2724-
marker->setIndicatorColor(player->getPlayerNightColor());
2725-
else
2726-
marker->setIndicatorColor(player->getPlayerColor());
2727-
}
2720+
// set the marker colors to that of the local player
2721+
Player* player = TheControlBar->getCurrentlyViewedPlayer();
2722+
if (player)
2723+
{
2724+
if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT)
2725+
marker->setIndicatorColor(player->getPlayerNightColor());
2726+
else
2727+
marker->setIndicatorColor(player->getPlayerColor());
27282728
}
27292729
}
27302730

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,43 +2711,43 @@ void ControlBar::showRallyPoint( const Coord3D *loc )
27112711
// destroy rally point drawable if present
27122712
if( m_rallyPointDrawableID != INVALID_DRAWABLE_ID )
27132713
TheGameClient->destroyDrawable( TheGameClient->findDrawableByID( m_rallyPointDrawableID ) );
2714+
27142715
m_rallyPointDrawableID = INVALID_DRAWABLE_ID;
2716+
return;
27152717
}
2716-
else
2717-
{
2718-
Drawable *marker = NULL;
27192718

2720-
// create a rally point drawble if necessary
2721-
if( m_rallyPointDrawableID == INVALID_DRAWABLE_ID )
2719+
Drawable *marker = NULL;
2720+
2721+
// create a rally point drawble if necessary
2722+
if( m_rallyPointDrawableID == INVALID_DRAWABLE_ID )
2723+
{
2724+
const ThingTemplate* ttn = TheThingFactory->findTemplate("RallyPointMarker");
2725+
marker = TheThingFactory->newDrawable( ttn );
2726+
DEBUG_ASSERTCRASH( marker, ("showRallyPoint: Unable to create rally point drawable") );
2727+
if (marker)
27222728
{
2723-
const ThingTemplate* ttn = TheThingFactory->findTemplate("RallyPointMarker");
2724-
marker = TheThingFactory->newDrawable( ttn );
2725-
DEBUG_ASSERTCRASH( marker, ("showRallyPoint: Unable to create rally point drawable") );
2726-
if (marker)
2727-
{
2728-
marker->setDrawableStatus(DRAWABLE_STATUS_NO_SAVE);
2729-
m_rallyPointDrawableID = marker->getID();
2730-
}
2729+
marker->setDrawableStatus(DRAWABLE_STATUS_NO_SAVE);
2730+
m_rallyPointDrawableID = marker->getID();
27312731
}
2732-
else
2733-
marker = TheGameClient->findDrawableByID( m_rallyPointDrawableID );
2732+
}
2733+
else
2734+
marker = TheGameClient->findDrawableByID( m_rallyPointDrawableID );
27342735

2735-
// sanity
2736-
DEBUG_ASSERTCRASH( marker, ("showRallyPoint: No rally point marker found" ) );
2736+
// sanity
2737+
DEBUG_ASSERTCRASH( marker, ("showRallyPoint: No rally point marker found" ) );
27372738

2738-
// set the position of the rally point drawble to the position passed in
2739-
marker->setPosition( loc );
2740-
marker->setOrientation( TheGlobalData->m_downwindAngle );//To blow down wind -- ML
2739+
// set the position of the rally point drawble to the position passed in
2740+
marker->setPosition( loc );
2741+
marker->setOrientation( TheGlobalData->m_downwindAngle );//To blow down wind -- ML
27412742

2742-
// set the marker colors to that of the local player
2743-
Player* player = TheControlBar->getCurrentlyViewedPlayer();
2744-
if (player)
2745-
{
2746-
if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT)
2747-
marker->setIndicatorColor(player->getPlayerNightColor());
2748-
else
2749-
marker->setIndicatorColor(player->getPlayerColor());
2750-
}
2743+
// set the marker colors to that of the local player
2744+
Player* player = TheControlBar->getCurrentlyViewedPlayer();
2745+
if (player)
2746+
{
2747+
if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT)
2748+
marker->setIndicatorColor(player->getPlayerNightColor());
2749+
else
2750+
marker->setIndicatorColor(player->getPlayerColor());
27512751
}
27522752
}
27532753

0 commit comments

Comments
 (0)