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(gameclient): Force Attack on the Bunker and the Combat Chinook
Olcay Seygan86aedc4ef6ca
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 257af3f2b..032d7bda5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -53,7 +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 (that hold is yours to move on the launcher's Command bar page), 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. Base defences that shoot have it too: the Patriot Battery of every general, the Gattling Cannon, the Fire Base and the Stinger Site, wherever their bar has a free place, so a defence can fire on the ground or on a friendly. A Tunnel Network's bar is full and a Bunker has no gun of its own, so neither gets one. It arms the same fire-on-whatever-is-under-the-pointer mode the hold key has always given. The hold is Ctrl until you change it on the launcher's Hotkeys page, Command bar tab, and the button wears whatever you bound. Shift plus that hold still draws a selection box. This version's data checksum differs, so it cannot join a game hosted on an older one.+- Combat units that attack-move now have a Force Attack button on the command bar, under Attack Move and left of Stop. Base defences that shoot have it too: the Patriot Battery of every general, the Gattling Cannon, the Fire Base, the Stinger Site and the Bunker, wherever their bar has a free place, so a defence can fire on the ground or on a friendly. So does the Air Force General's Combat Chinook. In the Bunker and the Chinook it is the soldiers inside who fire, and Ctrl on a garrisoned Bunker now takes a unit as its target as well as the ground; before, only the ground. A Tunnel Network's bar is full, and so is the Infantry General's ten-man Bunker, so neither gets the button. It arms the same fire-on-whatever-is-under-the-pointer mode the hold key has always given. The hold is Ctrl until you change it on the launcher's Hotkeys page, Command bar tab, and the button wears whatever you bound. Shift plus that hold still draws a selection box. This version's data checksum differs, so it cannot join a game hosted on an older one.- The dark plate behind Exit, Restart and the options screen in a match covers the whole picture. It used to sit in a 4:3 frame in the middle, so a widescreen left the battlefield bright down both sides. The box itself keeps the shape it was drawn in.- 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.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex fd9a07903..59eec562c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -510,15 +510,18 @@ Bool ControlBar_commandPlaces( const Int *types, const Int *groups, const Int *pvoid 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. A base defence that shoots (`firingDefense`) takes 12 too, or 11 above it when- * 12 is taken (Gattling Cannon's mines, Stinger Site's camo net, Fire Base's Sell). -1 when neither+ * under Attack Move. An object ControlBar_forceFires names takes 12 too, or 11 above it when 12 is+ * taken (Gattling Cannon's mines, Stinger Site's camo net, Fire Base's Sell). -1 when neither* applies, or the place is used (China CC mines, a Tunnel Network's full bar). */-Int ControlBar_forceAttackSlot( const Int *types, Int count, Bool firingDefense );--/** A base defence that shoots: FS_BASE_DEFENSE with its own gun (CAN_ATTACK: Patriot, Gattling- * Cannon, Fire Base, Tunnel Network) or soldiers for a gun (SPAWNS_ARE_THE_WEAPONS: Stinger Site).- * A Bunker or Speaker Tower is neither. The launcher's Hotkeys page reads KindOf the same way. */-Bool ControlBar_isFiringDefense( const Object *obj );+Int ControlBar_forceAttackSlot( const Int *types, Int count, Bool forceFires );++/** Whether Force Attack belongs on a bar without Attack Move. A base defence (FS_BASE_DEFENSE) with its+ * own gun (CAN_ATTACK: Patriot, Gattling Cannon, Fire Base, Tunnel Network), soldiers for a gun+ * (SPAWNS_ARE_THE_WEAPONS: Stinger Site) or a garrison that shoots out (GARRISONABLE_UNTIL_DESTROYED:+ * Bunker), and a transport whose riders shoot (TRANSPORT with CAN_ATTACK: Combat Chinook; the+ * plain Chinook lacks CAN_ATTACK). A Speaker Tower is none of them. The launcher's Hotkeys page+ * reads KindOf the same way. */+Bool ControlBar_forceFires( const Object *obj );/** 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 keydiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 2ce5ad771..602e79647 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -416,26 +416,28 @@ void ControlBar_fitCommandSlots( const Int *types, const Bool *windowed, Int cou}//--------------------------------------------------------------------------------------------------Int ControlBar_forceAttackSlot( const Int *types, Int count, Bool firingDefense )+Int ControlBar_forceAttackSlot( const Int *types, Int count, Bool forceFires ){enum { SLOT = 11, ABOVE = 10 };if( count <= SLOT )return -1;- Bool fights = firingDefense;+ Bool fights = forceFires;for( Int slot = 0; slot < count && !fights; slot++ )fights = types[ slot ] == GUI_COMMAND_ATTACK_MOVE;if( fights && types[ SLOT ] == GUI_COMMAND_NONE )return SLOT;- if( firingDefense && types[ ABOVE ] == GUI_COMMAND_NONE )+ if( forceFires && types[ ABOVE ] == GUI_COMMAND_NONE )return ABOVE;return -1;}//--------------------------------------------------------------------------------------------------Bool ControlBar_isFiringDefense( const Object *obj )+Bool ControlBar_forceFires( const Object *obj ){- return obj->isKindOf( KINDOF_FS_BASE_DEFENSE )- && ( obj->isKindOf( KINDOF_CAN_ATTACK ) || obj->isKindOf( KINDOF_SPAWNS_ARE_THE_WEAPONS ) );+ if( obj->isKindOf( KINDOF_FS_BASE_DEFENSE ) )+ return obj->isKindOf( KINDOF_CAN_ATTACK ) || obj->isKindOf( KINDOF_SPAWNS_ARE_THE_WEAPONS )+ || obj->isKindOf( KINDOF_GARRISONABLE_UNTIL_DESTROYED );+ return obj->isKindOf( KINDOF_TRANSPORT ) && obj->isKindOf( KINDOF_CAN_ATTACK );}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cppindex 0f8e22574..ca920774d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp@@ -391,7 +391,7 @@ void ControlBar::populateCommand( Object *obj )types[ i ] = shows ? button->getCommandType() : GUI_COMMAND_NONE;}{- const Int forceSlot = ControlBar_forceAttackSlot( types, MAX_COMMANDS_PER_SET, ControlBar_isFiringDefense( obj ) );+ const Int forceSlot = ControlBar_forceAttackSlot( types, MAX_COMMANDS_PER_SET, ControlBar_forceFires( obj ) );const CommandButton *force = forceSlot >= 0 ? findCommandButton( AsciiString( "Command_ForceAttack" ) ) : NULL;if( force ){@@ -421,7 +421,7 @@ void ControlBar::populateCommand( Object *obj )windowed[ i ] = m_commandWindows[ i ] != NULL;}{- const Int forceSlot = ControlBar_forceAttackSlot( types, MAX_COMMANDS_PER_SET, ControlBar_isFiringDefense( obj ) );+ const Int forceSlot = ControlBar_forceAttackSlot( types, MAX_COMMANDS_PER_SET, ControlBar_forceFires( obj ) );const CommandButton *force = forceSlot >= 0 ? findCommandButton( AsciiString( "Command_ForceAttack" ) ) : NULL;if( force ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex 2f5d9d4c5..1f2a03e5d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -261,7 +261,7 @@ static Bool canSelectionSalvage( const Object *targetObj)}//--------------------------------------------------------------------------------------------------static CanAttackResult canObjectForceAttack( Object *obj, const Object *victim, const Coord3D *pos )+static CanAttackResult canObjectItselfForceAttack( Object *obj, const Object *victim, const Coord3D *pos ){CanAttackResult result;result = obj->isAbleToAttack() ? ATTACKRESULT_POSSIBLE : ATTACKRESULT_NOT_POSSIBLE;@@ -355,6 +355,30 @@ static CanAttackResult canObjectForceAttack( Object *obj, const Object *victim,return ATTACKRESULT_NOT_POSSIBLE;}+//-------------------------------------------------------------------------------------------------+/** A container whose passengers shoot (a Bunker, a Combat Chinook) has no gun of its own, so its+ * force fire is its closest rider's. The order itself already reaches the riders:+ * AIGroup::groupAttackObjectPrivate and groupAttackPosition hand it to every passenger that can fire. */+static CanAttackResult canObjectForceAttack( Object *obj, const Object *victim, const Coord3D *pos )+{+ const CanAttackResult result = canObjectItselfForceAttack( obj, victim, pos );+ if( result == ATTACKRESULT_POSSIBLE || result == ATTACKRESULT_POSSIBLE_AFTER_MOVING || ( !victim && !pos ) )+ return result;++ ContainModuleInterface *contain = obj->getContain();+ if( !contain || !contain->isPassengerAllowedToFire() || !obj->isAbleToAttack() )+ return result;++ Object *rider = contain->getClosestRider( victim ? victim->getPosition() : pos );+ if( !rider )+ return result;++ const CanAttackResult riderResult = victim+ ? rider->getAbleToAttackSpecificObject( ATTACK_NEW_TARGET_FORCED, victim, CMD_FROM_PLAYER )+ : rider->getAbleToUseWeaponAgainstTarget( ATTACK_NEW_TARGET, NULL, pos, CMD_FROM_PLAYER );+ return riderResult != ATTACKRESULT_NOT_POSSIBLE ? riderResult : result;+}+//-------------------------------------------------------------------------------------------------static CanAttackResult canAnyForceAttack(const DrawableList *allSelected, const Object *victim, const Coord3D *pos ){diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex f5991f9ea..82a1405f1 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -4153,8 +4153,9 @@ TEST(controlbar_force_attack_slot_is_under_attack_move)types[ 10 ] = N;CHECK_EQ( ControlBar_forceAttackSlot( types, SLOTS, FALSE ), -1 );- /* A base defence that shoots has no Attack Move. Patriot (Stop 13, Sell 14) takes 12; Gattling- Cannon (mines 12) takes 11 above them; GLA Tunnel Network fills 1 to 14 and gets none */+ /* A base defence that shoots, or a Combat Chinook, has no Attack Move. Patriot (Stop 13, Sell 14)+ and the Chinook take 12; Gattling Cannon and Bunker (mines 12) take 11 above them; GLA Tunnel+ Network and the Infantry General's Bunker fill 1 to 14 and get none */types[ 12 ] = GUI_COMMAND_STOP;types[ 13 ] = GUI_COMMAND_SELL;CHECK_EQ( ControlBar_forceAttackSlot( types, SLOTS, TRUE ), 11 );