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): ask allies for an attack, a defence or money by key
Olcay Seyganaf90d68e5d10
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ead82b69c..264178b4f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -119,6 +119,7 @@ found and fixed, EA's own, not port damage.**- Computer allies with a personality answer their team. When an ally's base is hit, an Air Force strikes the attacker, a Supporter comes home to defend, an Attacker or Rusher hits back at the attacker's base and a Tech turns its powers on him. An Economist sends money to an ally who runs dry.- Allied computer players join the attack a teammate has started, so a team hits one enemy together.- You can call them too. A beacon you place asks your computer allies to attack there, and typing `help`, `attack` or `money` in chat (`yardim`, `saldir`, `para` in Turkish) asks for help where you are looking, an attack there, or cash.+- Or without typing a word. Alt+Z asks your allies to attack the spot under the pointer, Alt+X to come and defend it, Alt+V for money, and Alt+C only marks a spot to look at. The pointer can be on the radar as well. People on your team see the smoke, the radar ping and a line in the chat; computer allies with a personality act on it, in a skirmish against the computer too, where the keys used to do nothing. The keys come from the launcher and move on its Hotkeys page like any other.- A personality is a preference, never a bonus: no personality gets extra money, faster building or tougher units.- Computer players with a personality now and then say something in chat, in their own voice, at most once every two and a half minutes. Normal ones stay quiet.- An Infantry computer player no longer crashes the game while one of its factories researches an upgrade. Shopping for a troop carrier, it read the upgrade in the queue as if it were a vehicle.diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 65bfe9a19..805e86e77 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -84,6 +84,11 @@ GUI:SignalAttentionPlaced"%s: look here!"END+// The money request's line in the allies' chat, in the asker's own language.+GUI:RequestMoneyChat+"I need money!"+END+GUI:GamePaused"Game paused."END@@ -911,11 +916,6 @@ TOOLTIP:StatNewWeaponFigures"%d damage, %d range"END-// Under the figures: a unit's upgrades, or on an upgrade's card the units it changes.--TOOLTIP:Upgrades-"UPGRADES"-END// The gloss after each figure on the card: what it counts, as the card computes it. Damage is the// main weapon's primary damage a shot, the weapon that does the most a second; attack speed spreads// a clip's reload over its shots; range is in world units, 10 to a pathfinding cell, the square the@@ -945,16 +945,16 @@ TOOLTIP:StatTimeHint"(with your power and factories now)"END+// Under the figures: a unit's upgrades, or on an upgrade's card the units it changes.-TOOLTIP:UpgradeChanges-"CHANGES"+TOOLTIP:Upgrades+"UPGRADES"END-TOOLTIP:UpgradeOwned-"owned"+TOOLTIP:UpgradeChanges+"CHANGES"END-// Peace time - the lobby combo box, its tooltip, the corner countdown and the three things the gameTOOLTIP:UpgradesHint"(without it → with it)"END@@ -963,6 +963,11 @@ TOOLTIP:UpgradeChangesHint"(plain unit → with this)"END+TOOLTIP:UpgradeOwned+"owned"+END++// Peace time - the lobby combo box, its tooltip, the corner countdown and the three things the game// says while the clock runs. Tools/peacetime_layout.py selfcheck fails if any of these goes missing.GUI:PeaceTimeOff@@ -1801,6 +1806,10 @@ GUI:HotkeysCommandSIGNAL_ATTENTION"Signal: look here"END+GUI:HotkeysCommandREQUEST_MONEY+"Ask allies for money"+END+GUI:HotkeysCommandBEGIN_WAYPOINTS"Queue orders (hold)"ENDdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 3196ac934..58970af72 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -14709,6 +14709,10 @@ GUI:SignalAttentionPlaced"%s: buraya bakın!"END+GUI:RequestMoneyChat+"Paraya ihtiyacım var!"+END+GUI:GamePaused"Oyun duraklatıldı."END@@ -15525,10 +15529,6 @@ TOOLTIP:StatNewWeaponFigures"%d hasar, %d menzil"END-TOOLTIP:Upgrades-"GELİŞTİRMELER"-END-TOOLTIP:StatHealthHint"(zırhtan sonra kaldırabileceği hasar)"END@@ -15553,12 +15553,12 @@ TOOLTIP:StatTimeHint"(şu anki enerjiniz ve fabrikalarınızla)"END-TOOLTIP:UpgradeChanges-"ETKİLEDİKLERİ"+TOOLTIP:Upgrades+"GELİŞTİRMELER"END-TOOLTIP:UpgradeOwned-"alındı"+TOOLTIP:UpgradeChanges+"ETKİLEDİKLERİ"ENDTOOLTIP:UpgradesHint@@ -15569,6 +15569,10 @@ TOOLTIP:UpgradeChangesHint"(yalın birlik → bununla)"END+TOOLTIP:UpgradeOwned+"alındı"+END+GUI:HudStatArmy"Ordu değeri"END@@ -16181,6 +16185,10 @@ GUI:HotkeysCommandSIGNAL_ATTENTION"İşaret: buraya bak"END+GUI:HotkeysCommandREQUEST_MONEY+"Müttefiklerden para iste"+END+GUI:HotkeysCommandBEGIN_WAYPOINTS"Emirleri sıraya koy (basılı tut)"ENDdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.hindex 46bdd7d3e..73be61cdf 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h@@ -490,6 +490,7 @@ public:MSG_META_SIGNAL_ATTACK, ///< smoke for the allies: attack here (fork)MSG_META_SIGNAL_DEFEND, ///< smoke for the allies: defend here (fork)MSG_META_SIGNAL_ATTENTION, ///< smoke for the allies: look here (fork)+ MSG_META_REQUEST_MONEY, ///< ask the allies for money: the computer's team board and a chat line (fork)MSG_END_META_MESSAGES, ///< Marker to delineate "meta" messagesdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.hindex 3e21b5a92..ad54699ca 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.h@@ -153,6 +153,9 @@ extern Bool Command_formationDragArmed( Bool setting, Bool haveMovableSelection,/** Which signal a SIGNAL_* meta key drops; SIGNAL_KIND_COUNT for every other message. */extern SignalKind Command_signalKindForMeta( GameMessage::Type meta );+/** What a signal asks of the computer allies, an AITeamRequestKind; -1 for one that asks nothing. */+extern Int Command_teamRequestForSignal( SignalKind kind );+class Player;/** Single-player test hook: make this player the one at the keyboard, throwing away any AI behind* it first. FALSE if that player cannot be played (yourself, neutral, observer, beaten) or thisdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cppindex cc016aef1..e7f3d31f2 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp@@ -555,6 +555,7 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)CHECK_IF(MSG_META_SIGNAL_ATTACK)CHECK_IF(MSG_META_SIGNAL_DEFEND)CHECK_IF(MSG_META_SIGNAL_ATTENTION)+ CHECK_IF(MSG_META_REQUEST_MONEY)CHECK_IF(MSG_END_META_MESSAGES)CHECK_IF(MSG_MOUSEOVER_DRAWABLE_HINT)CHECK_IF(MSG_MOUSEOVER_LOCATION_HINT)diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex 10f328245..06ed40010 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -72,6 +72,7 @@#include "GameClient/SelectionInfo.h"#include "GameClient/SelectionXlat.h"+#include "GameLogic/AI.h"#include "GameLogic/Module/AIUpdate.h"#include "GameLogic/ExperienceTracker.h"#include "GameLogic/GameLogic.h"@@ -176,6 +177,44 @@ SignalKind Command_signalKindForMeta( GameMessage::Type meta )}}+//-------------------------------------------------------------------------------------------------+/** Attack here is the beacon's request; defend here is the call for help a computer ally makes when+ * its own base is hit, so an Air personality flies to the spot and an Attacker or Rusher hits the+ * base of whoever is fighting there. Look here asks nothing. */+Int Command_teamRequestForSignal( SignalKind kind )+{+ switch( kind )+ {+ case SIGNAL_ATTACK: return AIREQ_ATTACK;+ case SIGNAL_DEFEND: return AIREQ_HELP;+ default: return -1;+ }+}++//-------------------------------------------------------------------------------------------------+/** A request read by people as well as by the computer: the line goes to the allies' chat, or, with+ * no network under a skirmish, to the local feed. */+static void tellAllies( const UnicodeString &line )+{+ Player *localPlayer = ThePlayerList->getLocalPlayer();+ if( TheNetwork == NULL )+ {+ TheInGameUI->playerMessage( localPlayer, line );+ return;+ }+ Int playerMask = 0;+ for( Int i = 0; i < MAX_SLOTS; ++i )+ {+ AsciiString playerName;+ playerName.format( "player%d", i );+ const Player *player = ThePlayerList->findPlayerWithNameKey( TheNameKeyGenerator->nameToKey( playerName ) );+ if( player && ( player == localPlayer || ( player->getRelationship( localPlayer->getDefaultTeam() ) == ALLIES &&+ localPlayer->getRelationship( player->getDefaultTeam() ) == ALLIES ) ) )+ playerMask |= ( 1 << i );+ }+ TheNetwork->sendChat( line, playerMask );+}+static Bool isFormationDragArmed( void ){return Command_formationDragArmed( TheGlobalData->m_formationDrag,@@ -3477,25 +3516,51 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage//-----------------------------------------------------------------------------------------// Smoke for the allies where the cursor points: on the radar, the map spot it stands for,- // otherwise the ground under it.+ // otherwise the ground under it. Attack and defend are requests to the computer allies at+ // the same spot (the team board), so a skirmish against the computer takes them too.case GameMessage::MSG_META_SIGNAL_ATTACK:case GameMessage::MSG_META_SIGNAL_DEFEND:case GameMessage::MSG_META_SIGNAL_ATTENTION:- if (TheGameLogic->isInMultiplayerGame() && !TheGameLogic->isInReplayGame() &&+ if ((TheGameLogic->isInMultiplayerGame() || TheGameLogic->isInSkirmishGame()) && !TheGameLogic->isInReplayGame() &&ThePlayerList->getLocalPlayer()->isPlayerActive()){const ICoord2D *cursor = &TheMouse->getMouseStatus()->pos;Coord3D world;if( TheRadar->screenPixelToWorld( cursor, &world ) || TheTacticalView->screenToTerrain( cursor, &world ) ){+ const SignalKind kind = Command_signalKindForMeta( t );GameMessage *signalMsg = TheMessageStream->appendMessage( GameMessage::MSG_PLACE_SIGNAL );signalMsg->appendLocationArgument( world );- signalMsg->appendIntegerArgument( Command_signalKindForMeta( t ) );+ signalMsg->appendIntegerArgument( kind );+ const Int request = Command_teamRequestForSignal( kind );+ if( request >= 0 )+ {+ GameMessage *requestMsg = TheMessageStream->appendMessage( GameMessage::MSG_TEAM_REQUEST );+ requestMsg->appendIntegerArgument( request );+ requestMsg->appendLocationArgument( world );+ }}}disp = DESTROY_MESSAGE;break;+ //-----------------------------------------------------------------------------------------+ // Money has no place on the map: the board gets the camera's spot, as the chat word does,+ // and the ask goes to the allies' chat for the people among them.+ case GameMessage::MSG_META_REQUEST_MONEY:+ if ((TheGameLogic->isInMultiplayerGame() || TheGameLogic->isInSkirmishGame()) && !TheGameLogic->isInReplayGame() &&+ ThePlayerList->getLocalPlayer()->isPlayerActive())+ {+ Coord3D where;+ TheTacticalView->getPosition( &where );+ GameMessage *requestMsg = TheMessageStream->appendMessage( GameMessage::MSG_TEAM_REQUEST );+ requestMsg->appendIntegerArgument( AIREQ_MONEY );+ requestMsg->appendLocationArgument( where );+ tellAllies( TheGameText->fetch( "GUI:RequestMoneyChat" ) );+ }+ disp = DESTROY_MESSAGE;+ break;+//-----------------------------------------------------------------------------------------case GameMessage::MSG_META_OPTIONS:{diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cppindex 4844089e5..1d2a1ac6b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp@@ -819,6 +819,7 @@ std::vector< HotkeyCommandRow > Hotkeys_commandRows( const std::string& commandMunbound.push_back( commandRow( "SIGNAL_ATTACK", "INFORMATION" ) );unbound.push_back( commandRow( "SIGNAL_DEFEND", "INFORMATION" ) );unbound.push_back( commandRow( "SIGNAL_ATTENTION", "INFORMATION" ) );+ unbound.push_back( commandRow( "REQUEST_MONEY", "INFORMATION" ) );char name[ 32 ];for( Int slot = 1; slot <= 8; slot++ ){@@ -830,13 +831,18 @@ std::vector< HotkeyCommandRow > Hotkeys_commandRows( const std::string& commandMsnprintf( name, sizeof( name ), "COMMAND_SLOT%02d", slot );unbound.push_back( commandRow( name, "GRID" ) );}- // LAUNCHER_DEFAULTS: I, free in the shipped map, for the next idle worker+ // LAUNCHER_DEFAULTS: I, free in the shipped map, for the next idle worker, and Alt with Z, X, C+ // and V, which nothing in the shipped map holds, for the requests to the allies+ static const char *const DEFAULTS[][ 3 ] = { { "SELECT_NEXT_IDLE_WORKER", "KEY_I", "NONE" },+ { "SIGNAL_ATTACK", "KEY_Z", "ALT" }, { "SIGNAL_DEFEND", "KEY_X", "ALT" }, { "SIGNAL_ATTENTION", "KEY_C", "ALT" },+ { "REQUEST_MONEY", "KEY_V", "ALT" } };for( size_t each = 0; each < unbound.size(); each++ )- if( unbound[ each ].id == "SELECT_NEXT_IDLE_WORKER" )- {- unbound[ each ].binding.key = "KEY_I";- unbound[ each ].launcherDefault = TRUE;- }+ for( size_t row = 0; row < sizeof( DEFAULTS ) / sizeof( DEFAULTS[ 0 ] ); row++ )+ if( unbound[ each ].id == DEFAULTS[ row ][ 0 ] )+ {+ unbound[ each ].binding = HotkeyBinding( DEFAULTS[ row ][ 1 ], DEFAULTS[ row ][ 2 ] );+ unbound[ each ].launcherDefault = TRUE;+ }// HOLD_COMMANDS: KEY_NONE and a modifier in the shipped file, which the rows above leave out.// Force Attack's is set from its command bar button, the other two on the commands list.diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cppindex 882e84547..801060fac 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp@@ -208,6 +208,7 @@ static const LookupListRec GameMessageMetaTypeNames[] ={ "SIGNAL_ATTACK", GameMessage::MSG_META_SIGNAL_ATTACK },{ "SIGNAL_DEFEND", GameMessage::MSG_META_SIGNAL_DEFEND },{ "SIGNAL_ATTENTION", GameMessage::MSG_META_SIGNAL_ATTENTION },+ { "REQUEST_MONEY", GameMessage::MSG_META_REQUEST_MONEY },{ "OPTIONS", GameMessage::MSG_META_OPTIONS },{ "TOGGLE_LOWER_DETAILS", GameMessage::MSG_META_TOGGLE_LOWER_DETAILS },{ "TOGGLE_CONTROL_BAR", GameMessage::MSG_META_TOGGLE_CONTROL_BAR },diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 0b57e75b1..8be05281d 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -1963,6 +1963,17 @@ TEST(hotkeys_file_reads_the_launchers_rows_and_leaves_its_defaults_out)// KEY_NONE is not a key the launcher shows, so the shipped hold comes back as its own bar-only rowCHECK( hold != NULL && hold->barOnly && hold->binding == HotkeyBinding( "", "CTRL" ) && hold->pair == "END_FORCEATTACK" );CHECK( idle != NULL && idle->launcherDefault && idle->binding.key == "KEY_I" );+ // the requests to the allies start on Alt and Z, X, C and V, as the launcher writes them (issue 129)+ static const char *const ASKS[][ 2 ] = { { "SIGNAL_ATTACK", "KEY_Z" }, { "SIGNAL_DEFEND", "KEY_X" },+ { "SIGNAL_ATTENTION", "KEY_C" }, { "REQUEST_MONEY", "KEY_V" } };+ for( size_t ask = 0; ask < sizeof( ASKS ) / sizeof( ASKS[ 0 ] ); ask++ )+ {+ Bool found = FALSE;+ for( size_t each = 0; each < rows.size(); each++ )+ found = found || ( rows[ each ].id == ASKS[ ask ][ 0 ] && rows[ each ].launcherDefault+ && rows[ each ].binding == HotkeyBinding( ASKS[ ask ][ 1 ], "ALT" ) && rows[ each ].category == "INFORMATION" );+ CHECK( found );+ }// the launcher's own defaults in the player's part are no change of hisconst HotkeysFile mine = Hotkeys_parse(@@ -2310,6 +2321,15 @@ TEST(each_signal_key_drops_its_own_smoke)CHECK( Command_signalKindForMeta( GameMessage::MSG_META_PLACE_BEACON ) == SIGNAL_KIND_COUNT );}+/* CommandXlat.cpp: attack and defend signals are also requests to the computer allies (issue 129),+ look here is only smoke. */+TEST(attack_and_defend_signals_ask_the_computer_allies)+{+ CHECK( Command_teamRequestForSignal( SIGNAL_ATTACK ) == AIREQ_ATTACK );+ CHECK( Command_teamRequestForSignal( SIGNAL_DEFEND ) == AIREQ_HELP );+ CHECK( Command_teamRequestForSignal( SIGNAL_ATTENTION ) == -1 );+}+/* GameLogicDispatch.cpp: one signal a second per player. */extern Bool Signal_isThrottled( UnsignedInt now, UnsignedInt lastSignalFrame );