Skip to content

Commit 091ab3d

Browse files
committed
unify(commandxlat): Merge CommandXlat and related code from Zero Hour (#2765)
1 parent df54e43 commit 091ab3d

11 files changed

Lines changed: 729 additions & 118 deletions

File tree

Generals/Code/GameEngine/Include/GameClient/CommandXlat.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ class CommandTranslator : public GameMessageTranslator
5050
Int m_objective;
5151
Bool m_teamExists; ///< is there a currently selected "team"?
5252

53-
// these are for determining if a drag occurred or it was just a sloppy click
54-
ICoord2D m_mouseRightDragAnchor; // the location of a possible mouse drag start
55-
ICoord2D m_mouseRightDragLift; // the location of a possible mouse drag end
56-
UnsignedInt m_mouseRightDown; // when the mouse down happened
57-
UnsignedInt m_mouseRightUp; // when the mouse up happened
53+
// these are for determining if a drag occurred or it was just a sloppy click
54+
ICoord2D m_mouseRightDragAnchor; // the location of a possible mouse drag start
55+
ICoord2D m_mouseRightDragLift; // the location of a possible mouse drag end
56+
UnsignedInt m_mouseRightDown; // when the mouse down happened
57+
UnsignedInt m_mouseRightUp; // when the mouse up happened
5858

59-
GameMessage::Type createMoveToLocationMessage( Drawable *draw, const Coord3D *dest, CommandEvaluateType commandType );
59+
GameMessage::Type createMoveToLocationMessage( Drawable *draw, const Coord3D *dest, CommandEvaluateType commandType );
6060
GameMessage::Type createAttackMessage( Drawable *draw, Drawable *other, CommandEvaluateType commandType );
6161
GameMessage::Type createEnterMessage( Drawable *enter, CommandEvaluateType commandType );
6262
GameMessage::Type issueMoveToLocationCommand( const Coord3D *pos, Drawable *drawableInWay, CommandEvaluateType commandType );

Generals/Code/GameEngine/Include/GameClient/InGameUI.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ friend class Drawable; // for selection/deselection transactions
342342
ACTIONTYPE_MAKE_DEFECTOR,
343343
ACTIONTYPE_SET_RALLY_POINT,
344344
ACTIONTYPE_COMBATDROP_INTO,
345+
ACTIONTYPE_SABOTAGE_BUILDING,
345346

346347
NUM_ACTIONTYPES
347348
};
@@ -538,10 +539,12 @@ friend class Drawable; // for selection/deselection transactions
538539
void setCameraRotateRight( Bool set ) { m_cameraRotatingRight = set; }
539540
void setCameraZoomIn( Bool set ) { m_cameraZoomingIn = set; }
540541
void setCameraZoomOut( Bool set ) { m_cameraZoomingOut = set; }
542+
void setCameraTrackingDrawable( Bool set ) { m_cameraTrackingDrawable = set; }
541543
Bool isCameraRotatingLeft() const { return m_cameraRotatingLeft; }
542544
Bool isCameraRotatingRight() const { return m_cameraRotatingRight; }
543545
Bool isCameraZoomingIn() const { return m_cameraZoomingIn; }
544546
Bool isCameraZoomingOut() const { return m_cameraZoomingOut; }
547+
Bool isCameraTrackingDrawable() const { return m_cameraTrackingDrawable; }
545548
void resetCamera();
546549

547550
virtual void addIdleWorker( Object *obj );
@@ -586,6 +589,9 @@ friend class Drawable; // for selection/deselection transactions
586589
void registerWindowLayout(WindowLayout *layout); // register a layout for updates
587590
void unregisterWindowLayout(WindowLayout *layout); // stop updates for this layout
588591

592+
void triggerDoubleClickAttackMoveGuardHint();
593+
594+
589595
public:
590596
// World 2D animation methods
591597
void addWorldAnimation( Anim2DTemplate *animTemplate,
@@ -647,7 +653,7 @@ friend class Drawable; // for selection/deselection transactions
647653
struct MilitarySubtitleData
648654
{
649655
UnicodeString subtitle; ///< The complete subtitle to be drawn, each line is separated by L"\n"
650-
UnsignedInt index; ///< the current index that we are at through the sibtitle
656+
UnsignedInt index; ///< the current index that we are at through the subtitle
651657
ICoord2D position; ///< Where on the screen the subtitle should be drawn
652658
DisplayString *displayStrings[MAX_SUBTITLE_LINES]; ///< We'll only allow MAX_SUBTITLE_LINES worth of display strings
653659
UnsignedInt currentDisplayString; ///< contains the current display string we're on. (also lets us know the last display string allocated
@@ -726,6 +732,8 @@ friend class Drawable; // for selection/deselection transactions
726732
Int m_maxSelectCount; ///< Max number of objects to select
727733
UnsignedInt m_frameSelectionChanged; ///< Frame when the selection last changed.
728734

735+
Int m_duringDoubleClickAttackMoveGuardHintTimer; ///< Frames left to draw the doubleClickFeedbackTimer
736+
Coord3D m_duringDoubleClickAttackMoveGuardHintStashedPosition;
729737

730738
// Video playback data
731739
VideoBuffer* m_videoBuffer; ///< video playback buffer
@@ -930,6 +938,7 @@ friend class Drawable; // for selection/deselection transactions
930938
Bool m_cameraRotatingLeft;
931939
Bool m_cameraRotatingRight;
932940
Bool m_cameraZoomingIn;
941+
Bool m_cameraTrackingDrawable;
933942
Bool m_cameraZoomingOut;
934943

935944
Bool m_drawRMBScrollAnchor;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ class GameLogic : public SubsystemInterface, public Snapshot
113113

114114
void preUpdate();
115115

116+
#if defined(RTS_DEBUG)
117+
Int getNumberSleepyUpdates() const {return m_sleepyUpdates.size();} //For profiling, so not in Release.
118+
#endif
116119
void processCommandList( CommandList *list ); ///< process the command list
117120

118121
void prepareNewGame( GameMode gameMode, GameDifficulty diff, Int rankPoints ); ///< prepare for new game

Generals/Code/GameEngine/Include/GameLogic/Module/ContainModule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class ContainModuleInterface
165165
virtual PlayerMaskType getPlayerWhoEntered() const = 0;
166166

167167
virtual void processDamageToContained(Real percentDamage) = 0; ///< Do our % damage to units now.
168+
virtual Object* getClosestRider ( const Coord3D *pos ) = 0;
168169

169170
virtual void enableLoadSounds( Bool enable ) = 0;
170171

Generals/Code/GameEngine/Include/GameLogic/Module/OpenContain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class OpenContain : public UpdateModule,
211211

212212
virtual void enableLoadSounds( Bool enable ) override { m_loadSoundsEnabled = enable; }
213213

214+
virtual Object* getClosestRider ( const Coord3D *pos ) override;
214215
protected:
215216

216217
virtual void monitorConditionChanges(); ///< check to see if we need to update our occupant postions from a model change or anything else

Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ static void parseKindOfFromINI(INI* ini, void* instance, void *store, const void
9494
// KINDOF_AIRFIELD became KINDOF_FS_AIRFIELD in Zero Hour.
9595
kindOf->set(KINDOF_FS_AIRFIELD);
9696
}
97+
98+
if (kindOf->test(KINDOF_DRONE))
99+
{
100+
// KINDOF_DRONE was implicitly KINDOF_NO_SELECT in Generals.
101+
kindOf->set(KINDOF_NO_SELECT);
102+
}
97103
#endif
98104
}
99105

Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,8 @@ InGameUI::InGameUI()
10261026
m_nextMoveHint = 0;
10271027
m_selectCount = 0;
10281028
m_frameSelectionChanged = 0;
1029+
m_duringDoubleClickAttackMoveGuardHintTimer = 0;
1030+
m_duringDoubleClickAttackMoveGuardHintStashedPosition.zero();
10291031
m_maxSelectCount = -1;
10301032
m_isScrolling = FALSE;
10311033
m_isSelecting = FALSE;
@@ -1489,11 +1491,31 @@ void InGameUI::handleRadiusCursor()
14891491
if( !rts::localPlayerHasRadar() || (TheRadar->screenPixelToWorld( &mouseIO->pos, &pos ) == FALSE) )// if radar off, or point not on radar
14901492
TheTacticalView->screenToTerrain( &mouseIO->pos, &pos );
14911493

1492-
m_curRadiusCursor.setPosition(pos); //world space position of center of decal
1493-
m_curRadiusCursor.update();
1494-
}
1494+
1495+
if ( TheGlobalData->m_doubleClickAttackMove && m_duringDoubleClickAttackMoveGuardHintTimer > 0 )
1496+
{
1497+
m_curRadiusCursor.setOpacity( m_duringDoubleClickAttackMoveGuardHintTimer * 0.1f );
1498+
m_curRadiusCursor.setPosition( m_duringDoubleClickAttackMoveGuardHintStashedPosition ); //world space position of center of decal
1499+
1500+
}
1501+
else
1502+
{
1503+
m_curRadiusCursor.setPosition(pos); //world space position of center of decal
1504+
m_curRadiusCursor.update();
1505+
}
1506+
1507+
}
1508+
}
1509+
1510+
1511+
void InGameUI::triggerDoubleClickAttackMoveGuardHint()
1512+
{
1513+
m_duringDoubleClickAttackMoveGuardHintTimer = 11;
1514+
const MouseIO* mouseIO = TheMouse->getMouseStatus();
1515+
TheTacticalView->screenToTerrain( &mouseIO->pos, &m_duringDoubleClickAttackMoveGuardHintStashedPosition );
14951516
}
14961517

1518+
14971519
//-------------------------------------------------------------------------------------------------
14981520
/** Handle the placement "icons" that appear at the cursor when we're putting down a
14991521
* structure to build. Note that this has additional logic to also show a line
@@ -2788,6 +2810,24 @@ void InGameUI::createCommandHint( const GameMessage *msg )
27882810
}
27892811
//#endif
27902812

2813+
2814+
setRadiusCursorNone();
2815+
if ( TheGlobalData->m_doubleClickAttackMove )
2816+
{
2817+
if ( --m_duringDoubleClickAttackMoveGuardHintTimer > 0 )
2818+
{
2819+
setMouseCursor(Mouse::FORCE_ATTACK_GROUND);
2820+
setRadiusCursor(RADIUSCURSOR_GUARD_AREA,
2821+
nullptr,
2822+
PRIMARY_WEAPON);
2823+
return;
2824+
}
2825+
}
2826+
2827+
2828+
2829+
2830+
27912831
// set cursor to normal if there is a window under the cursor
27922832
GameWindow *window = nullptr;
27932833
const MouseIO *io = TheMouse->getMouseStatus();

0 commit comments

Comments
 (0)