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
feat(gameengine): Force Attack button under attack move
Olcay Seygan221c2ff4ed6f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 777e7844c..f1ad7ea22 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -53,6 +53,7 @@ found and fixed — EA's own, not port damage.**- The choice between a Classic and a Reforged interface is gone. There is one, laid out the way Zero Hour shipped, and the orders Reforged added now live on the keys you already know: A attack-moves, holding Ctrl fires on whatever is under the cursor as it did in 2003, a guard order can cover a patch of ground instead of one spot, and orders queue up one after another. Everything your base is building stands on the screen as a line of text each, the six closest to done first and "+N more" for the rest. Superweapon countdowns are listed the same way, up to eighteen. Both lists are in bold type, the build list in white and each countdown in its owner's colour. The promotion screen no longer darkens the battlefield behind it. Whether the right button gives orders, or the left as in 1.04, is a setting in the launcher.- An attack move and a Ctrl attack fire on the left click in every mouse setup. With the right button giving orders, A then a right click attack-moved, and Ctrl fired only on a right click, so the same hands did different things depending on one checkbox. Now A, or Ctrl held, then a left click is the attack everywhere, and a right click with A armed puts the key down without an order. Ctrl with a right click gives none. Plain orders stay on whichever button your setup gives them.+- Combat units that attack-move now have a Force Attack button on the command bar, under Attack Move and left of Stop. It arms the same fire-on-whatever-is-under-the-pointer mode holding Ctrl has always given, and the launcher's Hotkeys page can give that button its own letter. This version's data checksum differs, so it cannot join a game hosted on an older one.- Buildings select together again, which the one interface had taken away. Shift-click them, drag a box over them, or double-click one for every building of its kind on the screen; select four War Factories and each tank you click goes to whichever has the shortest queue. Double-click a unit and every one of that kind whose feet sit in the picture is taken, including the ones sitting past the camera's far clip that used to be skipped. A building and a unit still never share a selection.- Formation lines are back for everyone. With move, attack move or guard armed, a left drag spreads the selection along the line you draw again; since the one interface it drew a selection box instead, because the line was switched off for the Classic mouse that every player now runs. A drag with no order armed is still the selection box.- Every key is yours to move. The launcher's Hotkeys page draws the command bar of every building and unit each general can field, cameos and letters as the game shows them, and a click and a keypress gives any button a new letter or none. Two buttons on one bar that would share a letter are marked before you play. The keyboard commands are there too, from bookmarks and team keys to the camera, along with the ones Zero Hour never bound: select every fighting unit, vehicle or aircraft, every barracks, war factory or airfield, the next idle worker or unit, pause, the general's promotions, the three signals to your allies and the general's powers. Your keys are yours alone; the other players in a match keep theirs, and a match never refuses you for them. Every mod you install brings its own generals to the page, ShockWave's fifteen next to Zero Hour's thirteen, and a key you give a ShockWave button stays with ShockWave.diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedForceAttack.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedForceAttack.tganew file mode 100644index 000000000..1b09faf2aBinary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedForceAttack.tga differdiff --git a/GeneralsMD/Code/Data/German/Generals.str b/GeneralsMD/Code/Data/German/Generals.strindex 63e80067b..ace810672 100644--- a/GeneralsMD/Code/Data/German/Generals.str+++ b/GeneralsMD/Code/Data/German/Generals.str@@ -3581,6 +3581,10 @@ CONTROLBAR:AttackMove"Angriffs&marsch"END+CONTROLBAR:ForceAttack+"Zwangangri&ff"+END+CONTROLBAR:Stop"&Stopp"END@@ -6517,6 +6521,10 @@ CONTROLBAR:ToolTipAttackMove"Einheit zieht zum Zielgebiet und stoppt, um unterwegs Feinde zu bekämpfen"END+CONTROLBAR:ToolTipForceAttack+"Der nächste Klick greift alles unter dem Zeiger an, auch den Boden und deine eigene Seite. Klicke die Schaltfläche erneut, um abzubrechen."+END+CONTROLBAR:ToolTipCommandStop"Einheit bricht ab, was sie gerade tut"ENDdiff --git a/GeneralsMD/Code/Data/INI/CommandSetReforged.ini b/GeneralsMD/Code/Data/INI/CommandSetReforged.iniindex 006f1ffab..10f81acef 100644--- a/GeneralsMD/Code/Data/INI/CommandSetReforged.ini+++ b/GeneralsMD/Code/Data/INI/CommandSetReforged.ini@@ -12,6 +12,19 @@ CommandButton Command_UpgradeChinaTacticalNukeMigOptions = IGNORES_UNDERPOWEREDEnd+; Force Attack: the bar button that arms the same targeting Ctrl has always given. Combat sets+; already leave slot 12 empty under Attack Move; ControlBar::populateCommand fills that hole from+; this button, and so does the launcher's Hotkeys page. Slot 12 already used (China CC mines) stays.++CommandButton Command_ForceAttack+ Command = FORCE_ATTACK+ Options = OK_FOR_MULTI_SELECT+ TextLabel = CONTROLBAR:ForceAttack+ ButtonImage = SNForceAttack+ ButtonBorderType = SYSTEM+ DescriptLabel = CONTROLBAR:ToolTipForceAttack+End+; ==== China Command Centers after Mines ===========================================================; Buying Mines swaps the Command Center to its Upgrade set, and the Infantry and Nuke copies of thatdiff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedForceAttack.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedForceAttack.ininew file mode 100644index 000000000..be4d0737c--- /dev/null+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedForceAttack.ini@@ -0,0 +1,7 @@+MappedImage SNForceAttack+ Texture = ReforgedForceAttack.tga+ TextureWidth = 128+ TextureHeight = 128+ Coords = Left:0 Top:0 Right:128 Bottom:128+ Status = NONE+Enddiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex ee60b9ef4..8c5e80d86 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -30,6 +30,14 @@ GUI:OrderForceAttackDescription"The next click attacks whatever is under the pointer, the ground and your own side included. Click the key again to call it off."END+CONTROLBAR:ForceAttack+"&Force Attack"+END++CONTROLBAR:ToolTipForceAttack+"The next click attacks whatever is under the pointer, the ground and your own side included. Click the button again to call it off."+END+GUI:OrderHoldPositionDescription"The selected units guard the spot they stand on and fight whatever comes near, without chasing it out of the area."ENDdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex eb924dabf..ae43b0df0 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -3701,6 +3701,10 @@ CONTROLBAR:AttackMove"&Saldırarak İlerle"END+CONTROLBAR:ForceAttack+"&Zorla Saldır"+END+CONTROLBAR:Stop"&Dur"END@@ -6841,6 +6845,10 @@ CONTROLBAR:ToolTipAttackMove"Birliğe hedef bölgeye ilerleme ve yolda karşılaştığı düşmanlarla çatışmak için durma emri verin"END+CONTROLBAR:ToolTipForceAttack+"Bir sonraki tıklama imlecin altındaki her şeye saldırır, zemin ve kendi tarafınız da buna dahil. Vazgeçmek için düğmeye yeniden tıklayın."+END+CONTROLBAR:ToolTipCommandStop"Birliğe ne yapıyorsa bırakıp durma emri verin"ENDdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex fd6152e6f..2c24d77b1 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -221,6 +221,7 @@ enum GUICommandType : IntGUI_COMMAND_SPECIAL_POWER_CONSTRUCT_FROM_SHORTCUT, ///< do a shortcut special power using the construct building interfaceGUI_COMMAND_SELECT_ALL_UNITS_OF_TYPE,+ GUI_COMMAND_FORCE_ATTACK, ///< arm force-fire; the next click attacks whatever is under the pointer// add more commands here, don't forget to update the string command list below too ...@@ -271,6 +272,7 @@ static const char *TheGuiCommandNames[] ="SPECIAL_POWER_CONSTRUCT","SPECIAL_POWER_CONSTRUCT_FROM_SHORTCUT","SELECT_ALL_UNITS_OF_TYPE",+ "FORCE_ATTACK",NULL};@@ -507,6 +509,10 @@ Bool ControlBar_commandPlaces( const Int *types, const Int *groups, const Int *p* when free, anything else to the first empty one. */void ControlBar_fitCommandSlots( const Int *types, const Bool *windowed, Int count, Int *shown );+/** Slot 12 (0-based 11) when the set already has Attack Move and that hole is empty: left of Stop,+ * under Attack Move. -1 when the set has no Attack Move, or already uses 12 (China CC mines). */+Int ControlBar_forceAttackSlot( const Int *types, Int count );+/** Grid keys' second pass over ControlBar_fitCommandSlots' `shown`: a button in window w with no key* there (`unkeyed[ w ]`) moves to the first empty window, leftmost first, whose place has a key* (`keyed`), so a set that leaves the keyless top of the last two columns busy and a keyed windowdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex b4427d7d7..e3e0241eb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -415,6 +415,18 @@ void ControlBar_fitCommandSlots( const Int *types, const Bool *windowed, Int cou}}+//-------------------------------------------------------------------------------------------------+Int ControlBar_forceAttackSlot( const Int *types, Int count )+{+ enum { SLOT = 11 };+ if( count <= SLOT || types[ SLOT ] != GUI_COMMAND_NONE )+ return -1;+ for( Int slot = 0; slot < count; slot++ )+ if( types[ slot ] == GUI_COMMAND_ATTACK_MOVE )+ return SLOT;+ return -1;+}+//-------------------------------------------------------------------------------------------------void ControlBar_packKeyedSlots( const Bool *keyed, const Bool *unkeyed, Int count, Int *shown ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cppindex 542ec41d5..5d4824f19 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp@@ -390,6 +390,15 @@ void ControlBar::populateCommand( Object *obj )names[ i ] = shows ? button->getName() : AsciiString::TheEmptyString;types[ i ] = shows ? button->getCommandType() : GUI_COMMAND_NONE;}+ {+ const Int forceSlot = ControlBar_forceAttackSlot( types, MAX_COMMANDS_PER_SET );+ const CommandButton *force = forceSlot >= 0 ? findCommandButton( AsciiString( "Command_ForceAttack" ) ) : NULL;+ if( force )+ {+ names[ forceSlot ] = force->getName();+ types[ forceSlot ] = force->getCommandType();+ }+ }HotKeyManager::lendFixedKeys( names, types, MAX_COMMANDS_PER_SET );}@@ -411,6 +420,15 @@ void ControlBar::populateCommand( Object *obj )types[ i ] = ( set[ i ] && !BitTest( set[ i ]->getOptions(), SCRIPT_ONLY ) ) ? set[ i ]->getCommandType() : GUI_COMMAND_NONE;windowed[ i ] = m_commandWindows[ i ] != NULL;}+ {+ const Int forceSlot = ControlBar_forceAttackSlot( types, MAX_COMMANDS_PER_SET );+ const CommandButton *force = forceSlot >= 0 ? findCommandButton( AsciiString( "Command_ForceAttack" ) ) : NULL;+ if( force )+ {+ set[ forceSlot ] = force;+ types[ forceSlot ] = force->getCommandType();+ }+ }ControlBar_fitCommandSlots( types, windowed, MAX_COMMANDS_PER_SET, shown );// with grid keys on a button on a keyless place moves to a free keyed one, so the right of thediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cppindex a400e46c4..58c862a0c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp@@ -337,6 +337,11 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control,TheInGameUI->setGUICommand( NULL );TheMessageStream->appendMessage( GameMessage::MSG_META_TOGGLE_ATTACKMOVE );}+ else if( commandButton->getCommandType() == GUI_COMMAND_FORCE_ATTACK )+ {+ TheInGameUI->setGUICommand( NULL );+ TheMessageStream->appendMessage( GameMessage::MSG_META_TOGGLE_FORCEATTACK );+ }else if( BitTest( commandButton->getOptions(), COMMAND_OPTION_NEED_TARGET ) ){if (commandButton->getOptions() & USES_MINE_CLEARING_WEAPONSET)diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex da662dba1..ec73d6ab3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -6109,6 +6109,7 @@ void Object::doCommandButton( const CommandButton *commandButton, CommandSourceTcase GUI_COMMAND_CANCEL_UNIT_BUILD:case GUI_COMMAND_CANCEL_UPGRADE:case GUI_COMMAND_ATTACK_MOVE:+ case GUI_COMMAND_FORCE_ATTACK:case GUI_COMMAND_GUARD:case GUI_COMMAND_GUARD_WITHOUT_PURSUIT:case GUI_COMMAND_GUARD_FLYING_UNITS_ONLY:@@ -6224,6 +6225,7 @@ void Object::doCommandButtonAtObject( const CommandButton *commandButton, Objectcase GUI_COMMAND_OBJECT_UPGRADE:case GUI_COMMAND_CANCEL_UPGRADE:case GUI_COMMAND_ATTACK_MOVE:+ case GUI_COMMAND_FORCE_ATTACK:case GUI_COMMAND_GUARD:case GUI_COMMAND_GUARD_WITHOUT_PURSUIT:case GUI_COMMAND_GUARD_FLYING_UNITS_ONLY:@@ -6318,6 +6320,7 @@ void Object::doCommandButtonAtPosition( const CommandButton *commandButton, conscase GUI_COMMAND_PLAYER_UPGRADE:case GUI_COMMAND_OBJECT_UPGRADE:case GUI_COMMAND_CANCEL_UPGRADE:+ case GUI_COMMAND_FORCE_ATTACK:case GUI_COMMAND_GUARD:case GUI_COMMAND_GUARD_WITHOUT_PURSUIT:case GUI_COMMAND_GUARD_FLYING_UNITS_ONLY:@@ -6376,6 +6379,7 @@ void Object::doCommandButtonUsingWaypoints( const CommandButton *commandButton,break;}case GUI_COMMAND_ATTACK_MOVE:+ case GUI_COMMAND_FORCE_ATTACK:case GUI_COMMAND_STOP:case GUI_COMMAND_DOZER_CONSTRUCT:case GUI_COMMAND_DOZER_CONSTRUCT_CANCEL:diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cppindex f9f815644..fd5b5c7f4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp@@ -2118,6 +2118,7 @@ void ScriptActions::doTeamHuntWithCommandButton(const AsciiString& teamName, concase GUI_COMMAND_CANCEL_UNIT_BUILD:case GUI_COMMAND_CANCEL_UPGRADE:case GUI_COMMAND_ATTACK_MOVE:+ case GUI_COMMAND_FORCE_ATTACK:case GUI_COMMAND_GUARD:case GUI_COMMAND_GUARD_WITHOUT_PURSUIT:case GUI_COMMAND_GUARD_FLYING_UNITS_ONLY:diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex db6dd37ec..861e4dd92 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -4134,6 +4134,42 @@ TEST(controlbar_mod_slots_past_the_bar_fit_its_windows)CHECK_EQ( shown[ slot ], humvee[ slot ] != N && slot < WINDOWS ? slot : -1 );}+TEST(controlbar_force_attack_slot_is_under_attack_move)+{+ enum { SLOTS = MAX_COMMANDS_PER_SET, WINDOWS = 14 };+ const Int N = GUI_COMMAND_NONE, U = GUI_COMMAND_OBJECT_UPGRADE, W = GUI_COMMAND_SWITCH_WEAPON;+ Int types[ SLOTS ];+ for( Int slot = 0; slot < SLOTS; slot++ )+ types[ slot ] = N;+ types[ 10 ] = GUI_COMMAND_ATTACK_MOVE;+ types[ 12 ] = GUI_COMMAND_GUARD;+ types[ 13 ] = GUI_COMMAND_STOP;+ CHECK_EQ( ControlBar_forceAttackSlot( types, SLOTS ), 11 );++ types[ 11 ] = GUI_COMMAND_OBJECT_UPGRADE;+ CHECK_EQ( ControlBar_forceAttackSlot( types, SLOTS ), -1 );++ types[ 11 ] = N;+ types[ 10 ] = N;+ CHECK_EQ( ControlBar_forceAttackSlot( types, SLOTS ), -1 );++ /* Contra ranger: Attack Move in 15, slot 12 empty. Inject then fit keeps Force Attack in 12+ and still maps Attack Move, Guard and Stop to 11, 13 and 14 */+ Bool windowed[ SLOTS ];+ Int shown[ SLOTS ];+ for( Int slot = 0; slot < SLOTS; slot++ )+ windowed[ slot ] = slot < WINDOWS;+ Int ranger[ SLOTS ] = { U, U, U, U, U, N, GUI_COMMAND_SPECIAL_POWER, W, N, W, N, N, N, N,+ GUI_COMMAND_ATTACK_MOVE, N, GUI_COMMAND_GUARD, GUI_COMMAND_STOP };+ CHECK_EQ( ControlBar_forceAttackSlot( ranger, SLOTS ), 11 );+ ranger[ 11 ] = GUI_COMMAND_FORCE_ATTACK;+ ControlBar_fitCommandSlots( ranger, windowed, SLOTS, shown );+ CHECK_EQ( shown[ 10 ], 14 );+ CHECK_EQ( shown[ 11 ], 11 );+ CHECK_EQ( shown[ 12 ], 16 );+ CHECK_EQ( shown[ 13 ], 17 );+}+/* Grid keys leave windows 11 and 13 keyless. The USA War Factory's TOW upgrade in 11 moves to thefirst free keyed window, leftmost first; attack move in 11 has its own A and is never unkeyed */TEST(controlbar_grid_packs_keyless_buttons_into_keyed_windows)