Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameclient): add the camera, HUD and placement quality-of-life options

Olcay Seygand6cd00db32dc
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 00e1546d6..e71db2676 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -326,6 +326,12 @@ public:
Bool m_useGridHotKeys; ///< command bar keys come from the slot grid, not the '&' letter in each button's label
Bool m_edgeScrollInWindowedMode; ///< allow screen-edge scrolling while running in a window
Bool m_snapBuildPlacementTo45; ///< quantize the drag-to-rotate build placement angle to 45 degrees
+ Bool m_snapCameraRotateTo45; ///< quantize the camera heading to 45 degrees when a middle-drag rotate ends
+ Bool m_middleMousePans; ///< middle-button drag pans the camera instead of rotating it
+ Bool m_zoomToCursor; ///< the mouse wheel zooms toward whatever the cursor is over
+ Bool m_showHudOverlay; ///< draw the fps / elapsed time / income line in the corner
+ Bool m_showPlacementRangeRing; ///< while placing a structure, ring its weapon range
+ Bool m_workersReturnToSupply; ///< a worker that finishes a build job goes back to the dock it left
Bool m_buildMapCache;
AsciiString m_initialFile; ///< If this is specified, load a specific map/replay from the command-line
AsciiString m_pendingFile; ///< If this is specified, use this map at the next game start
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
index 46dd0b497..d2ae93066 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
@@ -289,6 +289,10 @@ public:
MSG_META_ALL_CHEER, ///< Yay! :)
MSG_META_TOGGLE_ATTACKMOVE, ///< enter attack-move mode
MSG_META_HOLD_POSITION, ///< hold position: guard in place, no pursuit (fork)
+ MSG_META_TOGGLE_PAUSE, ///< pause/unpause, single player and replay only (fork)
+ MSG_META_GAME_SPEED_UP, ///< raise the logic rate (fork)
+ MSG_META_GAME_SPEED_DOWN, ///< lower the logic rate (fork)
+ MSG_META_GAME_SPEED_RESET, ///< back to the default logic rate (fork)
MSG_META_BEGIN_CAMERA_ROTATE_LEFT,
MSG_META_END_CAMERA_ROTATE_LEFT,
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h b/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h
index 8e3546ca8..af0424839 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h
@@ -111,6 +111,12 @@ public:
Bool getUseGridHotKeys(void);
Bool getEdgeScrollInWindowedMode(void);
Bool getSnapBuildPlacementTo45(void);
+ Bool getSnapCameraRotateTo45(void);
+ Bool getMiddleMousePans(void);
+ Bool getZoomToCursor(void);
+ Bool getShowHudOverlay(void);
+ Bool getShowPlacementRangeRing(void);
+ Bool getWorkersReturnToSupply(void);
Int getTextureReduction(void);
void getResolution(Int *xres, Int *yres);
Bool get3DShadowsEnabled(void);
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index c96fd8865..d443f1317 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -457,6 +457,9 @@ public: // ********************************************************************
virtual void setRadiusCursor(RadiusCursorType r, const SpecialPowerTemplate* sp, WeaponSlotType wslot);
virtual void setRadiusCursorNone() { setRadiusCursor(RADIUSCURSOR_NONE, NULL, PRIMARY_WEAPON); }
+ /// ring an explicit radius with the guard-area decal; used while placing a defensive structure,
+ /// where there is no Object yet to read a weapon range off.
+ virtual void setRadiusCursorForRadius(Real radius);
virtual void setInputEnabled( Bool enable ); ///< Set the input enabled or disabled
virtual Bool getInputEnabled( void ) { return m_inputEnabled; } ///< Get the current input status
@@ -747,6 +750,15 @@ protected:
index 0, and increasing to older ones */
// superweapon timer data
SuperweaponMap m_superweapons[MAX_PLAYER_COUNT];
+ void drawHudOverlay( void ); ///< one-line fps / clock / income overlay (ShowHudOverlay)
+
+ DisplayString * m_hudDisplayString; ///< the ShowHudOverlay line (fps / clock / income)
+ UnsignedInt m_hudLastSampleFrame; ///< client frame the fps sample was last refreshed on
+ Real m_hudFps; ///< smoothed render rate
+ Int m_hudLastMoney; ///< player money at the last income sample
+ UnsignedInt m_hudLastMoneyFrame; ///< logic frame of that sample
+ Int m_hudIncomePerMin; ///< most recent income estimate, cash per minute
+
Coord2D m_superweaponPosition;
Real m_superweaponFlashDuration;
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h
index 09de3ed54..91a998ca3 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h
@@ -55,7 +55,8 @@ private:
SCROLL_NONE = 0,
SCROLL_RMB,
SCROLL_KEY,
- SCROLL_SCREENEDGE
+ SCROLL_SCREENEDGE,
+ SCROLL_MMB // middle-button drag pan (MiddleMousePans in Options.ini)
};
ICoord2D m_anchor;
ICoord2D m_originalAnchor;
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WorkerAIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WorkerAIUpdate.h
index cd316da37..1297daa29 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WorkerAIUpdate.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WorkerAIUpdate.h
@@ -242,6 +242,7 @@ protected:
// Supply Truck data
Int m_numberBoxes;
ObjectID m_preferredDock; ///< Instead of searching, try this one first
+ ObjectID m_dockBeforeBuilding; ///< the dock we left to go build, so we can go back (WorkersReturnToSupply)
Bool m_forcePending; // To prevent a function from doing a setState, forceWanting will latch into here until serviced.
Bool m_isRebuild; // is our current construction task a rebuild?
Bool m_forcedBusyPending; // A supply truck can't tell the difference between Idle since
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp
index 97a214241..de8487263 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp
@@ -367,6 +367,12 @@ void GameLODManager::init(void)
TheWritableGlobalData->m_useGridHotKeys = optionPref.getUseGridHotKeys();
TheWritableGlobalData->m_edgeScrollInWindowedMode = optionPref.getEdgeScrollInWindowedMode();
TheWritableGlobalData->m_snapBuildPlacementTo45 = optionPref.getSnapBuildPlacementTo45();
+ TheWritableGlobalData->m_snapCameraRotateTo45 = optionPref.getSnapCameraRotateTo45();
+ TheWritableGlobalData->m_middleMousePans = optionPref.getMiddleMousePans();
+ TheWritableGlobalData->m_zoomToCursor = optionPref.getZoomToCursor();
+ TheWritableGlobalData->m_showHudOverlay = optionPref.getShowHudOverlay();
+ TheWritableGlobalData->m_showPlacementRangeRing = optionPref.getShowPlacementRangeRing();
+ TheWritableGlobalData->m_workersReturnToSupply = optionPref.getWorkersReturnToSupply();
setStaticLODLevel(userSetDetail);
}
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index d5e17b880..66acf357b 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -183,6 +183,12 @@ GlobalData* GlobalData::m_theOriginal = NULL;
{ "UseGridHotKeys", INI::parseBool, NULL, offsetof( GlobalData, m_useGridHotKeys ) },
{ "EdgeScrollInWindowedMode", INI::parseBool, NULL, offsetof( GlobalData, m_edgeScrollInWindowedMode ) },
{ "SnapBuildPlacementTo45", INI::parseBool, NULL, offsetof( GlobalData, m_snapBuildPlacementTo45 ) },
+ { "SnapCameraRotateTo45", INI::parseBool, NULL, offsetof( GlobalData, m_snapCameraRotateTo45 ) },
+ { "MiddleMousePans", INI::parseBool, NULL, offsetof( GlobalData, m_middleMousePans ) },
+ { "ZoomToCursor", INI::parseBool, NULL, offsetof( GlobalData, m_zoomToCursor ) },
+ { "ShowHudOverlay", INI::parseBool, NULL, offsetof( GlobalData, m_showHudOverlay ) },
+ { "ShowPlacementRangeRing", INI::parseBool, NULL, offsetof( GlobalData, m_showPlacementRangeRing ) },
+ { "WorkersReturnToSupply", INI::parseBool, NULL, offsetof( GlobalData, m_workersReturnToSupply ) },
{ "MinCameraHeight", INI::parseReal, NULL, offsetof( GlobalData, m_minCameraHeight ) },
{ "TerrainHeightAtEdgeOfMap", INI::parseReal, NULL, offsetof( GlobalData, m_terrainHeightAtEdgeOfMap ) },
{ "UnitDamagedThreshold", INI::parseReal, NULL, offsetof( GlobalData, m_unitDamagedThresh ) },
@@ -986,6 +992,12 @@ GlobalData::GlobalData()
m_useGridHotKeys = FALSE;
m_edgeScrollInWindowedMode = FALSE;
m_snapBuildPlacementTo45 = FALSE;
+ m_snapCameraRotateTo45 = FALSE;
+ m_middleMousePans = FALSE;
+ m_zoomToCursor = FALSE;
+ m_showHudOverlay = FALSE;
+ m_showPlacementRangeRing = FALSE;
+ m_workersReturnToSupply = FALSE;
m_animateWindows = TRUE;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
index e252e19ca..da9c4e5ca 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
@@ -394,6 +394,10 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
CHECK_IF(MSG_META_ALL_CHEER)
CHECK_IF(MSG_META_TOGGLE_ATTACKMOVE)
CHECK_IF(MSG_META_HOLD_POSITION)
+ CHECK_IF(MSG_META_TOGGLE_PAUSE)
+ CHECK_IF(MSG_META_GAME_SPEED_UP)
+ CHECK_IF(MSG_META_GAME_SPEED_DOWN)
+ CHECK_IF(MSG_META_GAME_SPEED_RESET)
CHECK_IF(MSG_META_BEGIN_CAMERA_ROTATE_LEFT)
CHECK_IF(MSG_META_END_CAMERA_ROTATE_LEFT)
CHECK_IF(MSG_META_BEGIN_CAMERA_ROTATE_RIGHT)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
index 410e03673..c7e4818da 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
@@ -760,6 +760,60 @@ Bool OptionPreferences::getSnapBuildPlacementTo45(void)
return stricmp(it->second.str(), "yes") == 0;
}
+Bool OptionPreferences::getSnapCameraRotateTo45(void)
+{
+ OptionPreferences::const_iterator it = find("SnapCameraRotateTo45");
+ if (it == end())
+ return TheGlobalData->m_snapCameraRotateTo45;
+
+ return stricmp(it->second.str(), "yes") == 0;
+}
+
+Bool OptionPreferences::getMiddleMousePans(void)
+{
+ OptionPreferences::const_iterator it = find("MiddleMousePans");
+ if (it == end())
+ return TheGlobalData->m_middleMousePans;
+
+ return stricmp(it->second.str(), "yes") == 0;
+}
+
+Bool OptionPreferences::getZoomToCursor(void)
+{
+ OptionPreferences::const_iterator it = find("ZoomToCursor");
+ if (it == end())
+ return TheGlobalData->m_zoomToCursor;
+
+ return stricmp(it->second.str(), "yes") == 0;
+}
+
+Bool OptionPreferences::getShowHudOverlay(void)
+{
+ OptionPreferences::const_iterator it = find("ShowHudOverlay");
+ if (it == end())
+ return TheGlobalData->m_showHudOverlay;
+
+ return stricmp(it->second.str(), "yes") == 0;
+}
+
+Bool OptionPreferences::getShowPlacementRangeRing(void)
+{
+ OptionPreferences::const_iterator it = find("ShowPlacementRangeRing");
+ if (it == end())
+ return TheGlobalData->m_showPlacementRangeRing;
+
+ return stricmp(it->second.str(), "yes") == 0;
+}
+
+Bool OptionPreferences::getWorkersReturnToSupply(void)
+{
+ OptionPreferences::const_iterator it = find("WorkersReturnToSupply");
+ if (it == end())
+ return TheGlobalData->m_workersReturnToSupply;
+
+ return stricmp(it->second.str(), "yes") == 0;
+}
+
Int OptionPreferences::getTextureReduction(void)
{
OptionPreferences::const_iterator it = find("TextureReduction");
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 4ed16fc71..f66e42dd1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -1001,6 +1001,13 @@ InGameUI::InGameUI()
m_replayWindow = NULL;
m_messagesOn = TRUE;
+ m_hudDisplayString = NULL;
+ m_hudLastSampleFrame = 0;
+ m_hudFps = 0.0f;
+ m_hudLastMoney = -1;
+ m_hudLastMoneyFrame = 0;
+ m_hudIncomePerMin = 0;
+
m_superweaponPosition.x = 0.7f;
m_superweaponPosition.y = 0.7f;
m_superweaponFlashDuration = 1.0f;
@@ -1192,6 +1199,32 @@ void InGameUI::init( void )
} // end init
//-------------------------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------------------------
+/** Ring a radius we already know, rather than one derived from a selected object. */
+//-------------------------------------------------------------------------------------------------
+void InGameUI::setRadiusCursorForRadius(Real radius)
+{
+ if (radius <= 0.0f)
+ {
+ setRadiusCursorNone();
+ return;
+ }
+
+ // re-create only when the size actually changed, otherwise the decal restarts every frame
+ static Real s_lastRadius = 0.0f;
+ if (m_curRcType == RADIUSCURSOR_GUARD_AREA && s_lastRadius == radius)
+ return;
+
+ m_curRadiusCursor.clear();
+ Coord3D pos = { 0, 0, 0 }; // handleRadiusCursor() puts it under the cursor
+ m_radiusCursors[RADIUSCURSOR_GUARD_AREA].createRadiusDecal(pos, radius, ThePlayerList->getLocalPlayer(), m_curRadiusCursor);
+ m_curRcType = RADIUSCURSOR_GUARD_AREA;
+ s_lastRadius = radius;
+
+ handleRadiusCursor();
+}
+
//-------------------------------------------------------------------------------------------------
void InGameUI::setRadiusCursor(RadiusCursorType cursorType, const SpecialPowerTemplate* specPowTempl, WeaponSlotType weaponSlot)
{
@@ -1414,6 +1447,28 @@ void InGameUI::handleBuildPlacements( void )
Coord3D world;
Real angle = m_placeIcon[ 0 ]->getOrientation();
+ //
+ // ShowPlacementRangeRing: ring the structure's own weapon range while it is being placed,
+ // so a defense can be sited against what it actually covers. The radius comes off the
+ // template - there is no Object yet - and the ring rides the cursor like any other radius
+ // decal.
+ //
+ if( TheGlobalData->m_showPlacementRangeRing )
+ {
+ Real placeRange = 0.0f;
+ const WeaponTemplateSet *wts = m_pendingPlaceType->findWeaponTemplateSet( WeaponSetFlags() );
+ if( wts )
+ {
+ for( Int ws = PRIMARY_WEAPON; ws < WEAPONSLOT_COUNT; ++ws )
+ {
+ const WeaponTemplate *wt = wts->getNth( (WeaponSlotType)ws );
+ if( wt && wt->getUnmodifiedAttackRange() > placeRange )
+ placeRange = wt->getUnmodifiedAttackRange();
+ }
+ }
+ setRadiusCursorForRadius( placeRange );
+ }
+
// update the angle of the icon to match any placement angle and pick the
// location the icon will be at (anchored is the start, otherwise it's the mouse)
if( isPlacementAnchored() )
@@ -3486,6 +3541,8 @@ void InGameUI::disregardDrawable( Drawable *draw )
//-------------------------------------------------------------------------------------------------
void InGameUI::postDraw( void )
{
+ drawHudOverlay();
+
// render our display strings for the messages if on
if( m_messagesOn )
@@ -5140,6 +5197,88 @@ void InGameUI::updateFloatingText( void )
//-------------------------------------------------------------------------------------------------
/** Itterates through and draws each floating text */
//-------------------------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------------------------
+/** A one-line heads-up overlay: render rate, elapsed game time and the local player's income.
+ * Off unless ShowHudOverlay is set in Options.ini. Retail only ever showed the frame rate, and
+ * only behind -displayDebug together with a screenful of engine internals. */
+//-------------------------------------------------------------------------------------------------
+void InGameUI::drawHudOverlay( void )
+{
+ if( !TheGlobalData->m_showHudOverlay )
+ return;
+
+ if( TheGameLogic == NULL || TheGameLogic->getFrame() == 0 )
+ return;
+
+ Player *player = ThePlayerList ? ThePlayerList->getLocalPlayer() : NULL;
+ if( player == NULL )
+ return;
+
+ //
+ // Render rate, sampled over half a second of wall clock so the number is readable. This counts
+ // client frames, which is the render rate - the logic rate is fixed by the game speed.
+ //
+ const UnsignedInt clientFrame = TheGameClient->getFrame();
+ static UnsignedInt s_lastMs = 0;
+ static UnsignedInt s_lastClientFrame = 0;
+ UnsignedInt nowMs = timeGetTime();
+ if( s_lastMs == 0 )
+ {
+ s_lastMs = nowMs;
+ s_lastClientFrame = clientFrame;
+ }
+ else if( nowMs - s_lastMs >= 500 )
+ {
+ m_hudFps = (clientFrame - s_lastClientFrame) * 1000.0f / (Real)(nowMs - s_lastMs);
+ s_lastMs = nowMs;
+ s_lastClientFrame = clientFrame;
+ }
+
+ //
+ // Income, as cash per minute over the last ten seconds. Deliberately a delta of the balance
+ // rather than a tap into the deposit paths: it counts everything, including crates and refunds,
+ // which is what the player actually wants to compare against a build.
+ //
+ const UnsignedInt logicFrame = TheGameLogic->getFrame();
+ const UnsignedInt SAMPLE_FRAMES = 10 * LOGICFRAMES_PER_SECOND;
+ Int money = player->getMoney()->countMoney();
+ if( m_hudLastMoney < 0 )
+ {
+ m_hudLastMoney = money;
+ m_hudLastMoneyFrame = logicFrame;
+ }
+ else if( logicFrame >= m_hudLastMoneyFrame + SAMPLE_FRAMES )
+ {
+ Int delta = money - m_hudLastMoney;
+ if( delta < 0 )
+ delta = 0; // spending is not negative income
+ m_hudIncomePerMin = delta * 6; // ten seconds -> a minute
+ m_hudLastMoney = money;
+ m_hudLastMoneyFrame = logicFrame;
+ }
+
+ UnsignedInt totalSecs = logicFrame / LOGICFRAMES_PER_SECOND;
+
+ UnicodeString text;
+ text.format( L"%d:%02d:%02d %d fps %d/min",
+ totalSecs / 3600, (totalSecs / 60) % 60, totalSecs % 60,
+ REAL_TO_INT( m_hudFps ), m_hudIncomePerMin );
+
+ if( m_hudDisplayString == NULL )
+ {
+ m_hudDisplayString = TheDisplayStringManager->newDisplayString();
+ m_hudDisplayString->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,
+ TheGlobalLanguageData->adjustFontSize( m_superweaponNormalPointSize ),
+ m_superweaponNormalBold ) );
+ }
+ m_hudDisplayString->setText( text );
+
+ // top right, clear of the radar and of the superweapon timers
+ Int x = TheDisplay->getWidth() - m_hudDisplayString->getWidth() - 12;
+ Int y = 4;
+ m_hudDisplayString->draw( x, y, GameMakeColor( 255, 255, 255, 255 ), GameMakeColor( 0, 0, 0, 255 ) );
+}
+
void InGameUI::drawFloatingText( void )
{
FloatingTextData *ftd;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index 67e4f7762..e0bc831d3 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -3202,6 +3202,50 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
TheInGameUI->toggleAttackMoveToMode( );
break;
+ //
+ // Pause and game speed. Both are local-only: they change how fast THIS machine steps its
+ // logic, so they are refused outright in a network game where every peer has to agree.
+ // Replays and single player are fair game.
+ //
+ case GameMessage::MSG_META_TOGGLE_PAUSE:
+ {
+ if( TheGameLogic && !TheGameLogic->isInMultiplayerGame() )
+ {
+ Bool paused = !TheGameLogic->isGamePaused();
+ TheGameLogic->setGamePaused( paused );
+ TheInGameUI->message( paused ? "GUI:GamePaused" : "GUI:GameResumed" );
+ }
+ disp = DESTROY_MESSAGE;
+ break;
+ }
+
+ case GameMessage::MSG_META_GAME_SPEED_UP:
+ case GameMessage::MSG_META_GAME_SPEED_DOWN:
+ case GameMessage::MSG_META_GAME_SPEED_RESET:
+ {
+ if( TheGameEngine && TheGameLogic && !TheGameLogic->isInMultiplayerGame() )
+ {
+ const Int MIN_LOGIC_FPS = 5;
+ const Int MAX_LOGIC_FPS = 200;
+ Int fps = TheGameEngine->getFramesPerSecondLimit();
+
+ if( t == GameMessage::MSG_META_GAME_SPEED_RESET )
+ fps = DEFAULT_MAX_FPS;
+ else if( t == GameMessage::MSG_META_GAME_SPEED_UP )
+ fps += 5;
+ else
+ fps -= 5;
+
+ if( fps < MIN_LOGIC_FPS ) fps = MIN_LOGIC_FPS;
+ if( fps > MAX_LOGIC_FPS ) fps = MAX_LOGIC_FPS;
+
+ TheGameEngine->setFramesPerSecondLimit( fps );
+ TheInGameUI->message( UnicodeString( L"Game speed: %d" ), fps );
+ }
+ disp = DESTROY_MESSAGE;
+ break;
+ }
+
//
// Hold position: every selected unit guards the spot it is standing on and does not
// pursue. The location has to be resolved per unit on the logic side, so this carries
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
index d10063088..25815eb44 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
@@ -249,11 +249,23 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
{
m_lastMouseMoveFrame = TheGameLogic->getFrame();
- m_isRotating = true;
m_anchor = msg->getArgument( 0 )->pixel;
m_originalAnchor = msg->getArgument( 0 )->pixel;
m_currentPos = msg->getArgument( 0 )->pixel;
m_timestamp = TheGameClient->getFrame();
+
+ // MiddleMousePans in Options.ini swaps the middle-drag from rotate to pan; the
+ // click-to-reset below still works either way.
+ if( TheGlobalData->m_middleMousePans )
+ {
+ m_isRotating = false;
+ if (!TheInGameUI->isSelecting() && !m_isScrolling)
+ setScrolling(SCROLL_MMB);
+ }
+ else
+ {
+ m_isRotating = true;
+ }
break;
}
@@ -265,7 +277,10 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
const UnsignedInt CLICK_DURATION = 5;
const UnsignedInt PIXEL_OFFSET = 5;
+ Bool wasRotating = m_isRotating;
m_isRotating = false;
+ if (m_scrollType == SCROLL_MMB)
+ stopScrolling();
Int dx = m_currentPos.x-m_originalAnchor.x;
if (dx<0) dx = -dx;
Int dy = m_currentPos.y-m_originalAnchor.y;
@@ -276,6 +291,14 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
TheTacticalView->setAngleAndPitchToDefault();
TheTacticalView->setZoomToDefault();
}
+ else if (wasRotating && TheGlobalData->m_snapCameraRotateTo45)
+ {
+ // SnapCameraRotateTo45: let go of a free rotate and the heading clicks to the
+ // nearest eighth, so the map lines up with the screen again.
+ const Real step = PI / 4.0f;
+ Real a = TheTacticalView->getAngle();
+ TheTacticalView->setAngle( ((Real)REAL_TO_INT_FLOOR( a / step + (a >= 0.0f ? 0.5f : -0.5f) )) * step );
+ }
break;
}
@@ -362,6 +385,18 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
Int spin = msg->getArgument( 1 )->integer;
+ //
+ // ZoomToCursor: remember the world point under the cursor, zoom, then shift the camera
+ // by however far that point moved, so it stays put. Doing it by measurement rather
+ // than by projection maths means it stays correct whatever the pitch and FOV are.
+ //
+ const Bool zoomToCursor = TheGlobalData->m_zoomToCursor && TheInGameUI->getInputEnabled();
+ ICoord2D cursor = msg->getArgument( 0 )->pixel;
+ Coord3D worldBefore;
+ worldBefore.zero();
+ if (zoomToCursor)
+ TheTacticalView->screenToTerrain( &cursor, &worldBefore );
+
if (spin > 0)
{
for ( ; spin > 0; spin--)
@@ -372,6 +407,19 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
for ( ;spin < 0; spin++ )
TheTacticalView->zoomOut();
}
+
+ if (zoomToCursor)
+ {
+ Coord3D worldAfter;
+ worldAfter.zero();
+ TheTacticalView->screenToTerrain( &cursor, &worldAfter );
+
+ Coord2D shift;
+ shift.x = worldBefore.x - worldAfter.x;
+ shift.y = worldBefore.y - worldAfter.y;
+ if (shift.x != 0.0f || shift.y != 0.0f)
+ TheTacticalView->scrollBy( &shift );
+ }
break; // without this the case fell into MSG_META_OPTIONS below and every wheel
// notch called stopScrolling(), killing zoom-while-panning and leaving
// m_isScrolling/m_scrollType torn.
@@ -405,6 +453,15 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
{
switch (m_scrollType)
{
+ case SCROLL_MMB:
+ {
+ // straight drag-the-world pan: no anchor chasing and no keyboard minimum,
+ // so the map follows the cursor one-to-one.
+ offset.x = -TheGlobalData->m_horizontalScrollSpeedFactor * (m_currentPos.x - m_anchor.x);
+ offset.y = -TheGlobalData->m_verticalScrollSpeedFactor * (m_currentPos.y - m_anchor.y);
+ m_anchor = m_currentPos;
+ }
+ break;
case SCROLL_RMB:
{
if (TheInGameUI->shouldMoveRMBScrollAnchor())
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
index 086393d91..a728da07c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
@@ -176,6 +176,10 @@ static const LookupListRec GameMessageMetaTypeNames[] =
{ "STOP", GameMessage::MSG_META_STOP },
{ "TOGGLE_ATTACKMOVE", GameMessage::MSG_META_TOGGLE_ATTACKMOVE },
{ "HOLD_POSITION", GameMessage::MSG_META_HOLD_POSITION },
+ { "TOGGLE_PAUSE", GameMessage::MSG_META_TOGGLE_PAUSE },
+ { "GAME_SPEED_UP", GameMessage::MSG_META_GAME_SPEED_UP },
+ { "GAME_SPEED_DOWN", GameMessage::MSG_META_GAME_SPEED_DOWN },
+ { "GAME_SPEED_RESET", GameMessage::MSG_META_GAME_SPEED_RESET },
{ "DEPLOY", GameMessage::MSG_META_DEPLOY },
{ "CREATE_FORMATION", GameMessage::MSG_META_CREATE_FORMATION },
{ "FOLLOW", GameMessage::MSG_META_FOLLOW },
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp
index 40ff36c96..20c602b83 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp
@@ -114,6 +114,9 @@ WorkerAIUpdate::WorkerAIUpdate( Thing *thing, const ModuleData* moduleData ) :
m_supplyTruckStateMachine = NULL;
m_numberBoxes = 0;
+ // deliberately not xfer'd: it is a convenience, and a worker loaded mid-build simply does not
+ // auto-return rather than forcing a save-format bump.
+ m_dockBeforeBuilding = INVALID_ID;
m_forcePending = FALSE;
m_forcedBusyPending = FALSE;
@@ -626,6 +629,10 @@ void WorkerAIUpdate::newTask( DozerTask task, Object* target )
if( target == NULL )
return;
+ // remember where we were gathering before the job, so we can go back to it afterwards
+ // (WorkersReturnToSupply); the dozer brain still gets a clean slate either way.
+ if( m_preferredDock != INVALID_ID )
+ m_dockBeforeBuilding = m_preferredDock;
m_preferredDock = INVALID_ID; // If we are dozing, we don't want any supply truck stuff going on. jba.
//
@@ -828,6 +835,21 @@ void WorkerAIUpdate::internalTaskCompleteOrCancelled( DozerTask task )
// the builder is no longer actively building something
getObject()->clearModelConditionState( MODELCONDITION_ACTIVELY_CONSTRUCTING );
+ //
+ // WorkersReturnToSupply: a worker pulled off a supply run to put up a building used to
+ // just stand there when it finished. Send it back to the dock it came from, if that
+ // dock is still standing.
+ //
+ if( TheGlobalData->m_workersReturnToSupply && m_dockBeforeBuilding != INVALID_ID )
+ {
+ if( TheGameLogic->findObjectByID( m_dockBeforeBuilding ) != NULL )
+ {
+ m_preferredDock = m_dockBeforeBuilding;
+ setForceWantingState( TRUE );
+ }
+ m_dockBeforeBuilding = INVALID_ID;
+ }
+
// And the thing we were working on is no longer being actively built
///@todo This would be correct except that we don't have idle crane animations and it is December.
diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp
index 875e45fb6..969d946a7 100644
--- a/GeneralsMD/Code/Main/WinMain.cpp
+++ b/GeneralsMD/Code/Main/WinMain.cpp
@@ -78,6 +78,7 @@
HINSTANCE ApplicationHInstance = NULL; ///< our application instance
HWND ApplicationHWnd = NULL; ///< our application window handle
Bool ApplicationIsWindowed = false;
+Bool ApplicationIsBorderless = false; ///< -borderless: windowed, but with no caption or frame
Win32Mouse *TheWin32Mouse= NULL; ///< for the WndProc() only
DWORD TheMessageTime = 0; ///< For getting the time that a message was posted from Windows.
@@ -699,8 +700,10 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin
// Create our main window
windowStyle = WS_POPUP|WS_VISIBLE;
- if (runWindowed)
+ if (runWindowed && !ApplicationIsBorderless)
windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU;
+ else if (runWindowed)
+ windowStyle |= WS_SYSMENU; // borderless: keep the system menu for alt+F4, drop the frame
else
windowStyle |= WS_EX_TOPMOST | WS_SYSMENU;
@@ -942,6 +945,14 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
//added a preparse step for this flag because it affects window creation style
if (stricmp(token,"-win")==0)
ApplicationIsWindowed=true;
+ // same reason: -borderless drops the caption and frame, and implies -win. Parsed here
+ // rather than from Options.ini because the window exists long before the engine's
+ // preferences do.
+ if (stricmp(token,"-borderless")==0)
+ {
+ ApplicationIsWindowed=true;
+ ApplicationIsBorderless=true;
+ }
token = nextParam(NULL, "\" ");
}