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(gamelogic): computer players build no silo under no superweapons
Olcay Seygan815d5271eca1
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 8fff65250..3352c0fa4 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -1307,7 +1307,7 @@ GUI:SuperweaponsNoneENDTOOLTIP:Superweapons-"How many of each superweapon a player may have standing. Allow: as many as he can pay for. Limit: one each, and four for the USA Superweapon General. No: none at all, except the Superweapon General, who keeps one. He is the exception because his three superweapons are what he pays for a weaker army with."+"How many of each superweapon a player may have standing. Allow: as many as he can pay for. Limit: one each, and four for the USA Superweapon General. No: none at all, except the Superweapon General, who keeps one. He is the exception because his three superweapons are what he pays for a weaker army with. Under No a player may still put up one Nuclear Missile silo for China's upgrades, but it never fires, and computer players build none."ENDGUI:UnitLimitdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 1c9092202..8901829e8 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -2878,7 +2878,7 @@ TOOLTIP:CratesENDTOOLTIP:SuperWeapons-"Bir oyuncunun aynı anda ayakta tutabileceği süper silah sayısı. İzin Ver: parası yettiği kadar. Sınırla: her birinden bir tane, ABD Süper Silah Generali için dört. Yok: hiç yok, yalnızca Süper Silah Generali bir tane tutar. İstisna odur, çünkü zayıf ordusunun bedelini bu üç süper silahla öder."+"Bir oyuncunun aynı anda ayakta tutabileceği süper silah sayısı. İzin Ver: parası yettiği kadar. Sınırla: her birinden bir tane, ABD Süper Silah Generali için dört. Yok: hiç yok, yalnızca Süper Silah Generali bir tane tutar. İstisna odur, çünkü zayıf ordusunun bedelini bu üç süper silahla öder. Yok seçiliyken bir oyuncu Çin'in geliştirmeleri için yine de bir Nükleer Füze silosu kurabilir ama silo asla ateşlemez; bilgisayar oyuncuları hiç kurmaz."ENDDOZER:ConstructionCompletediff --git a/GeneralsMD/Code/GameEngine/Include/Common/Player.h b/GeneralsMD/Code/GameEngine/Include/Common/Player.hindex 5ad6655d9..29e51e60e 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/Player.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/Player.h@@ -141,11 +141,14 @@ static const char *ScienceAvailabilityNames[] =// at all, no superweapon at all, or a number of each type he may have standing. It takes the// player template's name because the rule has one exception, the USA Superweapon General, and// because a name is what a test can hand it. buildingName is the superweapon's own template: the-// nuclear silo is the one No leaves standing, one per player, for the upgrades it sells.+// nuclear silo is the one No leaves standing, one per human player, for the upgrades it sells; a+// computer player builds none, since it put one up as its superweapon. computerPlayer is+// getPlayerType() == PLAYER_COMPUTER, every computer seat on either AI and every difficulty.//enum { SUPERWEAPON_CAP_BANNED = -1, SUPERWEAPON_CAP_UNLIMITED = 0 };Int SuperweaponBuildCap( Int restriction, const AsciiString &playerTemplateName,- const AsciiString &buildingName = AsciiString::TheEmptyString );+ const AsciiString &buildingName = AsciiString::TheEmptyString,+ Bool computerPlayer = FALSE );// The lobby's unit limit is this many units for the whole match, shared out evenly between the// players who are not watching. UnitLimitPerPlayer is one player's share.diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cppindex f01c4f1d9..e17fad965 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp@@ -3260,7 +3260,8 @@ static void countExisting( Object *obj, void *userData )game unrestricted rather than guessing at a number. */static const char theSuperweaponGeneralTemplate[] = "FactionAmericaSuperWeaponGeneral";-Int SuperweaponBuildCap( Int restriction, const AsciiString &playerTemplateName, const AsciiString &buildingName )+Int SuperweaponBuildCap( Int restriction, const AsciiString &playerTemplateName, const AsciiString &buildingName,+ Bool computerPlayer ){const Bool isSuperweaponGeneral =playerTemplateName.compareNoCase( theSuperweaponGeneralTemplate ) == 0;@@ -3268,10 +3269,12 @@ Int SuperweaponBuildCap( Int restriction, const AsciiString &playerTemplateName,if ( restriction == SUPERWEAPONS_LIMIT )return isSuperweaponGeneral ? SUPERWEAPONS_LIMIT_GENERAL : SUPERWEAPONS_LIMIT_OTHERS;- // the silo sells China's Uranium Shells, Nuclear Tanks and Neutron Shells, so under No every- // player still stands one and only its missile is refused (SuperweaponMissileSilenced)+ // the silo sells China's Uranium Shells, Nuclear Tanks and Neutron Shells, so under No a human+ // still stands one and only its missile is refused (SuperweaponMissileSilenced). A computer+ // player builds none: it rushed one up as its superweapon, and a player who picked No saw the+ // AI build a superweapon. The Superweapon General's own silo goes with it, silenced and useless.if ( restriction == SUPERWEAPONS_NONE && ProRulesExemptSuperweapon( buildingName ) )- return SUPERWEAPONS_LIMIT_OTHERS;+ return computerPlayer ? SUPERWEAPON_CAP_BANNED : SUPERWEAPONS_LIMIT_OTHERS;if ( restriction == SUPERWEAPONS_NONE )return isSuperweaponGeneral ? SUPERWEAPONS_NONE_GENERAL : SUPERWEAPON_CAP_BANNED;@@ -3739,7 +3742,8 @@ Bool Player::canBuildMoreOfType( const ThingTemplate *whatToBuild, Int unitsPerOrestriction = SUPERWEAPONS_NONE;const AsciiString templateName =getPlayerTemplate() ? getPlayerTemplate()->getName() : AsciiString::TheEmptyString;- const Int cap = SuperweaponBuildCap( restriction, templateName, whatToBuild->getName() );+ const Int cap = SuperweaponBuildCap( restriction, templateName, whatToBuild->getName(),+ getPlayerType() == PLAYER_COMPUTER );if ( cap == SUPERWEAPON_CAP_BANNED )return false;diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 4e397fc68..717e415ef 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -21263,6 +21263,16 @@ TEST(the_superweapon_rule_is_a_mode_with_one_exception)CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, gla, AsciiString( "ChinaNuclearMissileLauncher" ) ), 1 );CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, gla, AsciiString( "Nuke_ChinaNuclearMissileLauncher" ) ), 1 );CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, superweaponGeneral, AsciiString( "SupW_AmericaNuclearMissileLauncher" ) ), 1 );+ // a human's, that is: a computer player builds no silo under No, whoever its general, since+ // it put one up as its superweapon, and Limit and Allow leave it the same silo as anybody+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, AsciiString( "FactionChina" ), AsciiString( "ChinaNuclearMissileLauncher" ), TRUE ), (Int)SUPERWEAPON_CAP_BANNED );+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, AsciiString( "FactionChinaNukeGeneral" ), AsciiString( "Nuke_ChinaNuclearMissileLauncher" ), TRUE ), (Int)SUPERWEAPON_CAP_BANNED );+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, superweaponGeneral, AsciiString( "SupW_AmericaNuclearMissileLauncher" ), TRUE ), (Int)SUPERWEAPON_CAP_BANNED );+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, AsciiString( "FactionChina" ), AsciiString( "ChinaNuclearMissileLauncher" ), FALSE ), 1 );+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_LIMIT, AsciiString( "FactionChina" ), AsciiString( "ChinaNuclearMissileLauncher" ), TRUE ), 1 );+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_ALLOW, AsciiString( "FactionChina" ), AsciiString( "ChinaNuclearMissileLauncher" ), TRUE ), (Int)SUPERWEAPON_CAP_UNLIMITED );+ // and the Superweapon General's own exception under No is unchanged for a computer+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, superweaponGeneral, AsciiString( "SupW_AmericaParticleCannonUplink" ), TRUE ), 1 );CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, gla, AsciiString( "GLAScudStorm" ) ), (Int)SUPERWEAPON_CAP_BANNED );CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, laserGeneral, AsciiString( "Lazr_AmericaParticleCannonUplink" ) ), (Int)SUPERWEAPON_CAP_BANNED );CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_LIMIT, superweaponGeneral, AsciiString( "SupW_AmericaNuclearMissileLauncher" ) ), 4 );