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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameclient): time the builder chord and let escape cancel first
Olcay Seygand40364efd0a5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1eeb1ed44..564292e58 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -180,6 +180,13 @@ ground you cannot build on is a soft red wash instead of a scribble. Three more:- **A click clears a half-typed building shortcut.** With the structure grid armed and waiting forits second key, a click could leave it armed, and the next A or S you pressed became a building toplace instead of an attack-move or a stop — which cancelled your selection.+- **The building shortcut now waits the two seconds it promises.** It was counting drawn frames+ rather than time, so on a fast machine it gave up in a third of a second — press Q, take a breath,+ and the second key was an attack-move again. It waits two real seconds now, whatever your frame+ rate.+- **Escape takes back what you were doing before it opens the menu.** With a building on the cursor,+ a targeting order armed, or a half-typed shortcut waiting, Escape drops that and nothing else.+ Press it again with nothing pending and the pause menu comes up as always.**Health bars are in the owner's colour.** They used to run green to red by how damaged somethingwas — which is what the length of the bar was already telling you — and told you nothing about whosediff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex bf8ccc94c..a442cea7c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -726,7 +726,7 @@ public:(a click, a new selection, a key that is not part of the chord, or simply time passing)must drop it. */void dropChord( void );- enum { CHORD_TIMEOUT_FRAMES = 60 }; ///< two seconds at 30Hz, then the chord expires+ enum { CHORD_TIMEOUT_MS = 2000 }; ///< real time, not frames: the client frame rate is uncapped/// is the drawable the currently selected drawable for the context sensitive UI?Bool isDrivingContextUI( Drawable *draw ) const { return draw == m_currentSelectedDrawable; }@@ -1001,7 +1001,7 @@ protected:Int m_buildPage; ///< BUILD_PAGE_ROOT, or the page being shownObjectID m_buildPageObjectID; ///< builder the page belongs to; a new one starts at the menuInt m_chordGroup; ///< -1, or the structure group (0 = Q, 1 = W) armed by the first chord key- UnsignedInt m_chordFrame; ///< client frame the chord was armed on, for CHORD_TIMEOUT_FRAMES+ UnsignedInt m_chordStartMs; ///< millisecond the chord was armed on, for CHORD_TIMEOUT_MSDrawableID m_standInBuilderID; ///< with nothing selected, the builder whose command bar is shown (INVALID_DRAWABLE_ID otherwise)Drawable *findStandInBuilder( Bool freeOnly ); ///< the local player's free builder (or, unless freeOnly, any builder) to stand in for an empty selectiondiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 37a102266..5771cb6c2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -173,7 +173,7 @@ void ControlBar::pressCommandButton( Int index )if( index == CHORD_SLOT_Q || index == CHORD_SLOT_W ){m_chordGroup = ( index == CHORD_SLOT_Q ) ? 0 : 1;- m_chordFrame = TheGameClient ? TheGameClient->getFrame() : 0;+ m_chordStartMs = timeGetTime();markUIDirty(); // the group that is armed greys the other one outreturn;}@@ -1098,7 +1098,7 @@ ControlBar::ControlBar( void )m_buildPageButton[ i ] = NULL;m_buildPageBackButton = NULL;m_chordGroup = -1;- m_chordFrame = 0;+ m_chordStartMs = 0;m_standInBuilderID = INVALID_DRAWABLE_ID;for( i = 0; i < MAX_MULTI_SELECT_GROUPS; i++ ){@@ -1603,8 +1603,7 @@ void ControlBar::update( void )// a chord the player armed and then walked away from expires on its own, so it cannot be// waiting to eat a keystroke a minute later//- if( m_chordGroup >= 0 && TheGameClient &&- TheGameClient->getFrame() - m_chordFrame > CHORD_TIMEOUT_FRAMES )+ if( m_chordGroup >= 0 && timeGetTime() - m_chordStartMs > CHORD_TIMEOUT_MS ){dropChord();}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex 733f0ed7b..f07a31e17 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -3141,10 +3141,40 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage//-----------------------------------------------------------------------------------------case GameMessage::MSG_META_OPTIONS:-- ToggleQuitMenu();+ {++ //+ // Escape is "take that back" before it is "open the menu": a structure waiting to be+ // placed, a targeting command armed off the command bar, or a half-typed builder chord+ // are all dropped first, and the pause menu only comes up on a press with nothing+ // pending.+ //+ Bool cancelledSomething = FALSE;++ if( TheControlBar && TheControlBar->isChordArmed() )+ {+ TheControlBar->dropChord();+ cancelledSomething = TRUE;+ }++ if( TheInGameUI->getPendingPlaceType() != NULL )+ {+ TheInGameUI->placeBuildAvailable( NULL, NULL );+ cancelledSomething = TRUE;+ }++ if( TheInGameUI->getGUICommand() != NULL )+ {+ TheInGameUI->setGUICommand( NULL );+ cancelledSomething = TRUE;+ }++ if( cancelledSomething == FALSE )+ ToggleQuitMenu();+disp = DESTROY_MESSAGE;break;+ }//-----------------------------------------------------------------------------------------case GameMessage::MSG_META_TOGGLE_LOWER_DETAILS: