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): stand-in builder bar yields command map letters
Olcay Seygancef0491aba07
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8613be6cc..223bf17fb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -368,7 +368,7 @@ found and fixed, EA's own, not port damage.**- Export and Import on the Hotkeys page take your keys to a file and back, for another PC or a fresh install. Before an import the page tells you how many keys it changes and how many would clash; a file with a line it cannot read changes nothing and quotes that line. Keys for a mod you have not installed come along and wait for it.- The arrow keys scroll the camera in the German game, as they do in English. German Zero Hour put next and previous unit and worker on the bare arrows, so the arrows picked units and only Ctrl and an arrow moved the camera; those four now sit on Ctrl and an arrow, as the English game ships them. Any language that puts a command on a bare arrow gets the same, and an arrow you gave a command yourself on the Hotkeys page stays where you put it.- Grid keys are back, keyed by the cell a button sits in. The first grid moved buttons around to give them a place's letter and still left two places without one; this one moves nothing. With the grid on, the top row of the bar is Q W E R T Y U and the bottom row A S D F G H J, column by column, so the first cell is Q on a Barracks, a War Factory and a tank alike, and the cell under it A. A mod's nine-column bar adds I O over K L. Upgrades take X C V B N in the order they stand on the bar, so the first upgrade of any building is X. The fixed keys step aside on the bar: attack move and stop take their cells' letters like every other button, while Ctrl still forces an attack. A letter you give a button still beats its cell, and a letter can now go to one cell alone, which is what a transport needs: its passengers' exit buttons are all one button, and with a key per cell the third passenger out can be M while the rest keep the grid. Accept on the in-game Hotkeys tab keeps the grid and every per-cell key, and the tab's list shows the grid's letters.-- W no longer starts a War Factory. The launcher had moved China's War Factory onto W, which Zero Hour already gives to Select all aircraft. With a tank selected and no aircraft on the map, W dropped the tank, the idle worker's bar took its place, and the same press let go on that bar's War Factory. The launcher now keeps the buttons it moves off every letter a keyboard command holds on its own, W, Q and the idle worker's I among them, and China's War Factory sits on D. Start the launcher once and it rewrites its part of the file. A letter you picked yourself stays where you put it. The game now settles it for any letter, yours and the grid's included: a key press does one thing. If a button on the bar wears the letter when the key goes down, the button gets it and the keyboard command on that letter waits; if none does, the command fires and the bar that comes up after it is left alone. A button that loses its letter to another, on the bar or the strip of general's powers, shows no letter instead of one that does nothing.+- W no longer starts a War Factory. The launcher had moved China's War Factory onto W, which Zero Hour already gives to Select all aircraft. With a tank selected and no aircraft on the map, W dropped the tank, the idle worker's bar took its place, and the same press let go on that bar's War Factory. The launcher now keeps the buttons it moves off every letter a keyboard command holds on its own, W, Q and the idle worker's I among them, and China's War Factory sits on D. Start the launcher once and it rewrites its part of the file. A letter you picked yourself stays where you put it. The game now settles it for any letter, yours and the grid's included: a key press does one thing. If a button on the bar wears the letter when the key goes down, the button gets it and the keyboard command on that letter waits; if none does, the command fires and the bar that comes up after it is left alone. A button that loses its letter to another, on the bar or the strip of general's powers, shows no letter instead of one that does nothing. With nothing selected, the worker's buildings that the bar shows anyway step off any letter a keyboard command uses on its own: on the grid, Q selects everything and W every aircraft again instead of putting down a Power Plant or a Barracks, and the buildings on free letters keep them.## The command bar moves to the middlediff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h b/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.hindex 0c21b877b..3c45c992e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h@@ -152,6 +152,8 @@ public:static Bool strokePressesBar( Int key );/// a showing button in the hotkey map holds the letter this key types, pressed bare or with shiftstatic Bool barHoldsKey( Int key, Int modState );+ /// a command map record fires in a match on the key that types this letter (nameOf), bare+ static Bool commandMapHolds( const AsciiString& key );/// CommandBarGrid in Hotkeys.ini: every command bar button keyed by its window slotstatic Bool commandBarGrid( void );static void setCommandBarGrid( Bool grid );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex e78733a14..baebcdfb4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -4570,14 +4570,16 @@ void ControlBar::setControlCommand( GameWindow *button, const CommandButton *com// A builder standing in for an empty selection lends the keys its buildings and nothing else.// Nobody selected it, so its orders keep no letter: H with nothing selected is the command map's// (view the command center), not the GLA worker's switch to fake buildings, and S stops nothing.+ // Its buildings give up a letter the command map uses bare too (issue 128): with the grid on they+ // sit on Q and W, and with nothing selected those still select everything and every aircraft.// the command bar window slot the button sits in, -1 off the barInt barSlot = -1;for( Int slot = 0; slot < MAX_COMMANDS_PER_SET; slot++ )if( m_commandWindows[ slot ] == button )barSlot = slot;- const Bool standInOrder = barSlot >= 0 && m_standInBuilderID != INVALID_DRAWABLE_ID && m_currentSelectedDrawable- && m_currentSelectedDrawable->getID() == m_standInBuilderID- && commandButton->getCommandType() != GUI_COMMAND_DOZER_CONSTRUCT;+ const Bool standIn = barSlot >= 0 && m_standInBuilderID != INVALID_DRAWABLE_ID && m_currentSelectedDrawable+ && m_currentSelectedDrawable->getID() == m_standInBuilderID;+ const Bool standInOrder = standIn && commandButton->getCommandType() != GUI_COMMAND_DOZER_CONSTRUCT;// the key is the one the player gave the button on the launcher's Hotkeys page, or else the// game's own, the letter after the '&' in the button's label - the English label's in every@@ -4586,9 +4588,11 @@ void ControlBar::setControlCommand( GameWindow *button, const CommandButton *com// window slot's letter unless the player gave it one.if( TheHotKeyManager ){- const WideChar letter = standInOrder ? 0 : HotKeyManager::playerButtonKey( commandButton->getName(),+ WideChar letter = standInOrder ? 0 : HotKeyManager::playerButtonKey( commandButton->getName(),TheGameText ? TheGameText->fetchEnglishHotKey( commandButton->getTextLabel() ) : 0,commandButton->getCommandType(), barSlot, barSlot >= 0 ? m_commandUpgradeRank[ barSlot ] : -1 );+ if( standIn && letter != 0 && HotKeyManager::commandMapHolds( HotKeyManager::nameOf( letter ) ) )+ letter = 0;// the badge shows a letter only while this window holds the key: one that lost it to a// stronger or earlier button shows none, and one that takes it wipes the badge it took it fromGameWindow *displaced = NULL;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cppindex 8a442c9ba..27f7062be 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp@@ -152,6 +152,19 @@ Bool HotKeyManager::barHoldsKey( Int key, Int modState )return win != NULL && !BitTest( win->winGetStatus(), WIN_STATUS_HIDDEN );}+Bool HotKeyManager::commandMapHolds( const AsciiString& key )+{+ if( TheMetaMap == NULL || TheKeyboard == NULL || key.isEmpty() )+ return FALSE;+ // the replay's fast forward lets its key through to the bar (MetaEventTranslator), so it holds none+ for( const MetaMapRec *rec = TheMetaMap->getFirstMetaMapRec(); rec; rec = rec->m_next )+ if( rec->m_modState == NONE && BitTest( rec->m_usableIn, COMMANDUSABLE_GAME ) && rec->m_key != MK_NONE+ && rec->m_meta != GameMessage::MSG_META_TOGGLE_FAST_FORWARD_REPLAY+ && nameOf( typedLetter( (UnsignedByte)rec->m_key ) ) == key )+ return TRUE;+ return FALSE;+}+//-----------------------------------------------------------------------------GameMessageDisposition HotKeyTranslator::translateGameMessage(const GameMessage *msg){