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): turkey copies of every american unit and spawn
Olcay Seygan305881ade60e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9b622485a..4017bd97c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,8 +10,8 @@ found and fixed — EA's own, not port damage.**## Turkey joins the fight-- Turkey is a fourth side in the skirmish and multiplayer lobbies. For now it fields the American army under its own name: the same buildings, tanks, aircraft and generals' powers, with the American voice, load screen and command bar. Its own units, art and powers come later and replace these one at a time.-- The computer plays Turkey too. A Turkish AI builds its base, sends trucks for supplies, trains an army, earns ranks and spends them on powers, and attacks the way an American AI does.+- Turkey is a fourth side in the skirmish and multiplayer lobbies. For now it fields the American army under its own name: the same buildings, tanks, aircraft and generals' powers, with the American voice, load screen and command bar. Every piece of it is already Turkey's own, from the Paladin and Colonel Burton to the pilot climbing out of a wreck, the drones on a Humvee and the A-10s a power calls in, so its own units, art and powers can replace them one at a time.+- The computer plays Turkey too. A Turkish AI builds its base, sends Chinooks for supplies, trains an army, earns ranks and spends them on powers, and attacks the way an American AI does.## Zero Hour on a Mac, on Linux and on the Steam Deckdiff --git a/GeneralsMD/Code/Data/INI/AIDataReforged.ini b/GeneralsMD/Code/Data/INI/AIDataReforged.iniindex 7b4a6b08c..7484ef98c 100644--- a/GeneralsMD/Code/Data/INI/AIDataReforged.ini+++ b/GeneralsMD/Code/Data/INI/AIDataReforged.ini@@ -10,7 +10,7 @@; reskin of the American one (TurkeyReforged.ini), so a Turkey dozer or factory asked for the; American name puts up its own button's Turkey building or unit instead; (BuildAssistant::findBuildButtonTemplate), and the command center adjustBuildList rebuilds in-; place of the starting one is picked by side (AIPlayer::buildStructureNow).+; place of the starting one comes out Turkish too (ThingFactory::newObject).AIDatadiff --git a/GeneralsMD/Code/Data/INI/CommandSetReforged.ini b/GeneralsMD/Code/Data/INI/CommandSetReforged.iniindex 2aae0d871..9b9df21da 100644--- a/GeneralsMD/Code/Data/INI/CommandSetReforged.ini+++ b/GeneralsMD/Code/Data/INI/CommandSetReforged.ini@@ -372,10 +372,10 @@ End; The Turkey faction's buttons and sets (TurkeyReforged.ini). Each button is EA's American one with; Object pointing at the Turkey reskin, so it keeps the American cameo, label and tooltip. Each set-; is the American set with the cloned buildings and units swapped in; the slots for things Turkey-; has no copy of (Paladin, Aurora, Burton and the rest) keep EA's American buttons, which build the-; American unit for a Turkey player. The science and shortcut sets are the American ones under-; Turkey's name, since Turkey buys the American powers.+; is the American set with every build button swapped for its Turkey copy. The science and shortcut+; sets are the American ones under Turkey's name, since Turkey buys the American powers; what those+; powers spawn (planes, paratroopers, drones) is American data that ThingFactory::newObject turns+; into the Turkey reskin for a Turkey player.CommandButton Command_ConstructTurkeyCommandCenterCommand = DOZER_CONSTRUCT@@ -557,6 +557,95 @@ CommandButton Command_ConstructTurkeyVehicleComancheDescriptLabel = CONTROLBAR:ToolTipUSABuildComancheEnd+CommandButton Command_ConstructTurkeyInfantryColonelBurton+ Command = UNIT_BUILD+ Object = TurkeyInfantryColonelBurton+ TextLabel = CONTROLBAR:ConstructAmericaInfantryColonelBurton+ ButtonImage = SABurton+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildColonelBurton+End++CommandButton Command_ConstructTurkeyInfantryPathfinder+ Command = UNIT_BUILD+ Object = TurkeyInfantryPathfinder+ TextLabel = CONTROLBAR:ConstructAmericaInfantryPathfinder+ ButtonImage = SAPathfinder1+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildPathFinder+End++CommandButton Command_ConstructTurkeyInfantryBiohazardTech+ Command = UNIT_BUILD+ Object = TurkeyInfantryBiohazardTech+ TextLabel = CONTROLBAR:ConstructAmericaInfantryBiohazardTech+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:TempDescription+End++CommandButton Command_ConstructTurkeyVehicleMedic+ Command = UNIT_BUILD+ Object = TurkeyVehicleMedic+ TextLabel = CONTROLBAR:ConstructAmericaVehicleMedic+ ButtonImage = SAAmbulance+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildMedic+End++CommandButton Command_ConstructTurkeyVehiclePaladin+ Command = UNIT_BUILD+ Object = TurkeyTankPaladin+ TextLabel = CONTROLBAR:ConstructAmericaTankPaladin+ ButtonImage = SAPaladin+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildPaladin+End++CommandButton Command_ConstructTurkeyVehicleSentryDrone+ Command = UNIT_BUILD+ Object = TurkeyVehicleSentryDrone+ TextLabel = CONTROLBAR:ConstructAmericaVehicleSentryDrone+ ButtonImage = SAsentry+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildSentryDrone+End++CommandButton Command_ConstructTurkeyVehicleAvenger+ Command = UNIT_BUILD+ Object = TurkeyTankAvenger+ TextLabel = CONTROLBAR:ConstructAmericaTankAvenger+ ButtonImage = SAAvnger+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildAvenger+End++CommandButton Command_ConstructTurkeyVehicleMicrowave+ Command = UNIT_BUILD+ Object = TurkeyTankMicrowave+ TextLabel = CONTROLBAR:ConstructAmericaTankMicrowave+ ButtonImage = SAThunderBolt+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildMicrowave+End++CommandButton Command_ConstructTurkeyJetAurora+ Command = UNIT_BUILD+ Object = TurkeyJetAurora+ TextLabel = CONTROLBAR:ConstructAmericaJetAurora+ ButtonImage = SAAurora+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildAurora+End++CommandButton Command_ConstructTurkeyJetStealthFighter+ Command = UNIT_BUILD+ Object = TurkeyJetStealthFighter+ TextLabel = CONTROLBAR:ConstructAmericaJetStealthFighter+ ButtonImage = SAStealth+ ButtonBorderType = BUILD+ DescriptLabel = CONTROLBAR:ToolTipUSABuildStealthFighter+End+CommandSet TurkeyDozerCommandSet1 = Command_ConstructTurkeyPowerPlant2 = Command_ConstructTurkeyStrategyCenter@@ -595,9 +684,9 @@ EndCommandSet TurkeyBarracksCommandSet1 = Command_ConstructTurkeyInfantryRanger2 = Command_ConstructTurkeyInfantryMissileDefender- 3 = Command_ConstructAmericaInfantryColonelBurton- 4 = Command_ConstructAmericaInfantryPathfinder- 6 = Command_ConstructAmericaInfantryBiohazardTech+ 3 = Command_ConstructTurkeyInfantryColonelBurton+ 4 = Command_ConstructTurkeyInfantryPathfinder+ 6 = Command_ConstructTurkeyInfantryBiohazardTech7 = Command_UpgradeAmericaRangerFlashBangGrenade8 = Command_UpgradeAmericaRangerCaptureBuilding13 = Command_SetRallyPoint@@ -608,11 +697,11 @@ CommandSet TurkeyWarFactoryCommandSet1 = Command_ConstructTurkeyTankCrusader2 = Command_ConstructTurkeyVehicleTomahawk3 = Command_ConstructTurkeyVehicleHumvee- 4 = Command_ConstructAmericaVehicleMedic- 5 = Command_ConstructAmericaVehiclePaladin- 6 = Command_ConstructAmericaVehicleSentryDrone- 7 = Command_ConstructAmericaVehicleAvenger- 8 = Command_ConstructAmericaVehicleMicrowave+ 4 = Command_ConstructTurkeyVehicleMedic+ 5 = Command_ConstructTurkeyVehiclePaladin+ 6 = Command_ConstructTurkeyVehicleSentryDrone+ 7 = Command_ConstructTurkeyVehicleAvenger+ 8 = Command_ConstructTurkeyVehicleMicrowave9 = Command_UpgradeAmericaSentryDroneGun11 = Command_UpgradeAmericaTOWMissile13 = Command_SetRallyPoint@@ -622,8 +711,8 @@ EndCommandSet TurkeyAirfieldCommandSet1 = Command_ConstructTurkeyJetRaptor2 = Command_ConstructTurkeyVehicleComanche- 3 = Command_ConstructAmericaJetAurora- 4 = Command_ConstructAmericaJetStealthFighter+ 3 = Command_ConstructTurkeyJetAurora+ 4 = Command_ConstructTurkeyJetStealthFighter7 = Command_UpgradeComancheRocketPods8 = Command_UpgradeAmericaLaserMissiles9 = Command_UpgradeAmericaCountermeasuresdiff --git a/GeneralsMD/Code/Data/INI/TurkeyReforged.ini b/GeneralsMD/Code/Data/INI/TurkeyReforged.iniindex b65bca805..3aeb7ef4f 100644--- a/GeneralsMD/Code/Data/INI/TurkeyReforged.ini+++ b/GeneralsMD/Code/Data/INI/TurkeyReforged.ini@@ -10,7 +10,8 @@; War Factory meets a prerequisite that names AmericaWarFactory, and a Turkey factory asked for an; America-named unit by the skirmish scripts makes the Turkey one its button names; (BuildAssistant::findBuildButtonTemplate). That is what lets a Turkey AI run the SkirmishAmerica-; scripts unchanged. A unit with no Turkey reskin yet keeps its American button and name.+; scripts unchanged. Every American unit and building a skirmish player can own has a Turkey copy;+; the campaign's (the battleship, the carrier, the CINE_ units) do not.;; These are placeholders: American models, weapons, names and cameos under Turkish template names.;@@ -174,6 +175,179 @@ Object TurkeyVehicleComancheSide = TurkeyEnd+ObjectReskin TurkeyInfantryColonelBurton AmericaInfantryColonelBurton+End++Object TurkeyInfantryColonelBurton+ Side = Turkey+End++ObjectReskin TurkeyInfantryPathfinder AmericaInfantryPathfinder+End++Object TurkeyInfantryPathfinder+ Side = Turkey+End++ObjectReskin TurkeyInfantryBiohazardTech AmericaInfantryBiohazardTech+End++Object TurkeyInfantryBiohazardTech+ Side = Turkey+End++ObjectReskin TurkeyVehicleMedic AmericaVehicleMedic+End++Object TurkeyVehicleMedic+ Side = Turkey+End++ObjectReskin TurkeyTankPaladin AmericaTankPaladin+End++Object TurkeyTankPaladin+ Side = Turkey+End++ObjectReskin TurkeyVehicleSentryDrone AmericaVehicleSentryDrone+End++Object TurkeyVehicleSentryDrone+ Side = Turkey+End++ObjectReskin TurkeyTankAvenger AmericaTankAvenger+End++Object TurkeyTankAvenger+ Side = Turkey+End++ObjectReskin TurkeyTankMicrowave AmericaTankMicrowave+End++Object TurkeyTankMicrowave+ Side = Turkey+End++ObjectReskin TurkeyJetAurora AmericaJetAurora+End++Object TurkeyJetAurora+ Side = Turkey+End++ObjectReskin TurkeyJetStealthFighter AmericaJetStealthFighter+End++Object TurkeyJetStealthFighter+ Side = Turkey+End++; Nothing builds the ones below from a button. The American data spawns them by name: a pilot+; out of a dead vehicle, the drones an upgrade adds, the Avenger's turret, the planes, paratroopers'+; chutes and the gunship of the generals' powers. ThingFactory::newObject makes the Turkey copy+; whenever one of them is made for a Turkey player.++ObjectReskin TurkeyInfantryPilot AmericaInfantryPilot+End++Object TurkeyInfantryPilot+ Side = Turkey+End++ObjectReskin TurkeyTankAvengerLaserTurret AmericaTankAvengerLaserTurret+End++Object TurkeyTankAvengerLaserTurret+ Side = Turkey+End++ObjectReskin TurkeyVehicleBattleDrone AmericaVehicleBattleDrone+End++Object TurkeyVehicleBattleDrone+ Side = Turkey+End++ObjectReskin TurkeyVehicleScoutDrone AmericaVehicleScoutDrone+End++Object TurkeyVehicleScoutDrone+ Side = Turkey+End++ObjectReskin TurkeyVehicleHellfireDrone AmericaVehicleHellfireDrone+End++Object TurkeyVehicleHellfireDrone+ Side = Turkey+End++ObjectReskin TurkeyVehicleSpyDrone AmericaVehicleSpyDrone+End++Object TurkeyVehicleSpyDrone+ Side = Turkey+End++ObjectReskin TurkeyJetA10Thunderbolt AmericaJetA10Thunderbolt+End++Object TurkeyJetA10Thunderbolt+ Side = Turkey+End++ObjectReskin TurkeyJetSpectreGunship AmericaJetSpectreGunship+End++Object TurkeyJetSpectreGunship+ Side = Turkey+End++ObjectReskin TurkeyJetB3 AmericaJetB3+End++Object TurkeyJetB3+ Side = Turkey+End++ObjectReskin TurkeyJetB52 AmericaJetB52+End++Object TurkeyJetB52+ Side = Turkey+End++ObjectReskin TurkeyJetCargoPlane AmericaJetCargoPlane+End++Object TurkeyJetCargoPlane+ Side = Turkey+End++ObjectReskin TurkeyParachute AmericaParachute+End++Object TurkeyParachute+ Side = Turkey+End++ObjectReskin TurkeyCrateParachute AmericaCrateParachute+End++Object TurkeyCrateParachute+ Side = Turkey+End++ObjectReskin TurkeyVehicleHumveeDeadHull AmericaVehicleHumveeDeadHull+End++Object TurkeyVehicleHumveeDeadHull+ Side = Turkey+End+; The Reinforcement Pad picks its convoy by the owner's side and had none for Turkey. It sends; Turkey the plain American one.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ThingFactory.h b/GeneralsMD/Code/GameEngine/Include/Common/ThingFactory.hindex 7a05be482..772cea330 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/ThingFactory.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/ThingFactory.h@@ -89,6 +89,11 @@ public:*/Object *newObject( const ThingTemplate *tmplate, Team *team, ObjectStatusMaskType statusMask = OBJECT_STATUS_MASK_NONE );+ /** The reskin of tmplate that belongs to side, when tmplate belongs to another: TurkeyInfantryPilot+ for an AmericaInfantryPilot made for a Turkey player. NULL when there is none. newObject makes+ that one in its place, so a pilot, a drone or a paradrop the American data spawns comes out Turkish. */+ const ThingTemplate *findSideReskin( const ThingTemplate *tmplate, const AsciiString &side );+/** request a new drawable using the given template.this will throw an exception on failure; it will never return null.*/@@ -129,6 +134,9 @@ private:UnsignedShort m_nextTemplateID; ///< next available ID for templatesThingTemplateHashMap m_templateHashMap; ///< all thing templates, for fast lookup.++ /// findSideReskin's answers, NULL ones included; reset() empties it with the map's overrides+ std::map< std::pair< const ThingTemplate*, NameKeyType >, const ThingTemplate* > m_sideReskins;};diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cppindex ed9a6d083..31749d0ca 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp@@ -44,6 +44,7 @@#include "GameLogic/Object.h"#include "Common/Player.h"#include "Common/PlayerList.h"+#include "Common/Team.h"#include "GameLogic/PartitionManager.h"#include "GameLogic/Module/CreateModule.h"#include "GameLogic/Module/AIUpdate.h"@@ -254,6 +255,8 @@ void ThingFactory::reset( void )// whatever the assert had just complained about.DEBUG_ASSERTCRASH( m_firstTemplate != NULL, ("no templates left after deleting overrides") );m_nextTemplateID = m_firstTemplate ? (UnsignedShort)(m_firstTemplate->getTemplateID() + 1) : 1;+ // it may hold the overrides just deleted+ m_sideReskins.clear();} // end reset//-------------------------------------------------------------------------------------------------@@ -331,6 +334,15 @@ Object *ThingFactory::newObject( const ThingTemplate *tmplate, Team *team, Objectmplate = tmp;}+ // a side's own reskin in place of another side's template: Turkey is built on the American data+ const Player *owner = team ? team->getControllingPlayer() : NULL;+ if (owner != NULL)+ {+ const ThingTemplate *own = findSideReskin( tmplate, owner->getSide() );+ if (own != NULL)+ tmplate = own;+ }+DEBUG_ASSERTCRASH(!tmplate->isKindOf(KINDOF_DRAWABLE_ONLY), ("You may not create Objects with the template %s, only Drawables\n",tmplate->getName().str()));// have the game logic create an object of the correct type.@@ -359,7 +371,30 @@ Object *ThingFactory::newObject( const ThingTemplate *tmplate, Team *team, Objecreturn obj;-}+}++//=============================================================================+const ThingTemplate *ThingFactory::findSideReskin( const ThingTemplate *tmplate, const AsciiString &side )+{+ // EA's reskins never cross a side, so this answers NULL for every template of theirs+ const AsciiString &tmplateSide = tmplate->getDefaultOwningSide();+ if (side.isEmpty() || tmplateSide.isEmpty() || tmplateSide == side)+ return NULL;++ const std::pair< const ThingTemplate*, NameKeyType > key( tmplate, NAMEKEY( side ) );+ std::map< std::pair< const ThingTemplate*, NameKeyType >, const ThingTemplate* >::const_iterator it = m_sideReskins.find( key );+ if (it != m_sideReskins.end())+ return it->second;++ const ThingTemplate *found = NULL;+ for (const ThingTemplate *t = m_firstTemplate; t != NULL && found == NULL; t = t->friend_getNextTemplate())+ {+ if (t->getDefaultOwningSide() == side && t->isEquivalentTo( tmplate ))+ found = (const ThingTemplate *)t->getFinalOverride();+ }+ m_sideReskins[ key ] = found;+ return found;+}//=============================================================================Drawable *ThingFactory::newDrawable(const ThingTemplate *tmplate, DrawableStatus statusBits)diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex ddeb3d4e3..5f2215699 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -919,23 +919,8 @@ void AIPlayer::clearTeamsInQueue( void )Object *AIPlayer::buildStructureNow(const ThingTemplate *bldgPlan, BuildListInfo *info){- /* No builder here to pick the side's own building, so pick it from the side. Turkey's build list- names AmericaCommandCenter (the skirmish scripts ask for it by that name), and the command- center adjustBuildList puts up in place of the starting one came out American, with American- dozers that built an American base. */- if (bldgPlan->getDefaultOwningSide() != m_player->getSide())- {- for (const ThingTemplate *t = TheThingFactory->firstTemplate(); t; t = t->friend_getNextTemplate())- {- if (t->getDefaultOwningSide() == m_player->getSide() && t->isEquivalentTo(bldgPlan))- {- bldgPlan = t;- break;- }- }- }-- // inst-construct the building+ // inst-construct the building. Turkey's build list names AmericaCommandCenter (the skirmish+ // scripts ask for it by that name); ThingFactory::newObject makes a Turkey player's the Turkish one.Object *bldg = TheBuildAssistant->buildObjectNow( NULL,bldgPlan,info->getLocation(),