Skip to content

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.

fix(gameengine): drop map.ini weapon edits again, as retail did

Olcay Seyganb80d82ed3c07
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ae216f549..15983c7a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -189,6 +189,7 @@ found and fixed, EA's own, not port damage.**
- A mission with moving water (China's third, GLA's first, America's sixth) loads from a save with its water still running and at the height the mission had raised it to. A load used to freeze the water until the next wave came through and drop it back to the level the map started at, and saving while a script was raising it tore the game down.
- Load the same save twice and the same battle plays out both times. The dice, the paths units were waiting for and the computer players' calls to each other are saved now, so two loads no longer drift apart within a minute. A load also stopped switching a powered player's radar off, stopped forgetting which targets a mission's computer player was told to go after, and no longer counts every unit's sight twice for the first seconds. Saves from earlier versions still load; a save from this version does not load in an earlier one.
- Zero Hour's second GLA mission leaves its opening scene again. The scene ends only when the three terrorists have blown up all three American tanks, and the tanks shoot at the tunnel the terrorists climb out of as they drive past it. From 3.2.0 to 3.4.0 a tank shell did its full 60 to a soldier, so two shells kill one: two shots at the tunnel took out two terrorists as they came out, the third was shot down on his way in, the tanks then wrecked the tunnel and the scene waited for ever. At 18 a shell the terrorists reach the tanks with 102 of their 120 health, and the scene hands you the controls on all three difficulties.
+- The original America's fourth mission ends the way it did in 2003. Once the Tomahawks take out the Stinger sites, the B-52s carpet bomb the GLA base and nothing else. A map can retune a weapon for its own mission, and EA's game always threw those edits away, so the campaign was played and balanced without them. Reforged started honouring them in 2.2.0, and this mission's file asks for bombs that hit for 1000 across a 1000 radius, where the real ones do 300 across 50: the cutscene wiped every unit on the map, yours with it, and either ended the mission in defeat or handed you a victory with the rest of it unplayed. Map edits to weapons are dropped again, as in the original.
## Health bars you can read at a glance
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
index 07f8ba436..f9e185a6c 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
@@ -883,7 +883,6 @@ protected:
WeaponTemplate *findWeaponTemplatePrivate( NameKeyType key ) const;
WeaponTemplate *newWeaponTemplate( AsciiString name );
- WeaponTemplate *newOverride( WeaponTemplate *weaponTemplate );
void deleteAllDelayedDamage();
void deleteWeaponsNow();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
index d3ccecadf..7b9c88017 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
@@ -1740,29 +1740,6 @@ WeaponTemplate *WeaponStore::newWeaponTemplate(AsciiString name)
return wt;
}
-//-------------------------------------------------------------------------------------------------
-/* A map.ini block for a weapon that already exists. EA parsed it into a copy that nothing ever
- pointed at - not the store, not the object templates, which hold the original by pointer - so a
- map could add weapons but every change to an existing one was lost. The block now edits the
- original, and the original's first state is kept aside for reset() to put back after the match. */
-WeaponTemplate *WeaponStore::newOverride(WeaponTemplate *weaponTemplate)
-{
- if (!weaponTemplate->isOverride())
- {
- WeaponTemplate *pristine = newInstance(WeaponTemplate);
- (*pristine) = (*weaponTemplate);
- weaponTemplate->friend_setNextTemplate(pristine);
- // the copy shares the extra-bonus set, and a WeaponBonus line edits that set in place
- if (pristine->m_extraBonus)
- {
- weaponTemplate->m_extraBonus = newInstance(WeaponBonusSet);
- (*weaponTemplate->m_extraBonus) = (*pristine->m_extraBonus);
- }
- }
-
- return weaponTemplate;
-}
-
//-------------------------------------------------------------------------------------------------
void WeaponStore::update()
{
@@ -1815,21 +1792,6 @@ void WeaponStore::resetWeaponTemplates( void )
//-------------------------------------------------------------------------------------------------
void WeaponStore::reset()
{
- // put back every weapon a map.ini edited (see newOverride)
- for (Int i = 0; i < m_weaponTemplateVector.size(); ++i)
- {
- WeaponTemplate *wt = m_weaponTemplateVector[i];
- if (wt->isOverride())
- {
- WeaponTemplate *pristine = wt->friend_clearNextTemplate();
- if (wt->m_extraBonus)
- wt->m_extraBonus->deleteInstance();
- (*wt) = (*pristine);
- pristine->m_extraBonus = NULL; // wt owns it again
- pristine->deleteInstance();
- }
- }
-
/* A weapon the map made from nothing goes too. Left in the store, the next map that defined the
same name edited this one, from the old map's values instead of a new weapon's defaults, and
a machine that had not played the old map built a different weapon. The templates that held
@@ -2005,9 +1967,7 @@ void WeaponStore::postProcessLoad()
WeaponTemplate *weapon = TheWeaponStore->findWeaponTemplatePrivate( TheNameKeyGenerator->nameToKey( name ) );
if (weapon)
{
- if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES)
- weapon = TheWeaponStore->newOverride(weapon);
- else if (ini->getLoadType() == INI_LOAD_MULTIFILE)
+ if (ini->getLoadType() == INI_LOAD_MULTIFILE)
{
// BalanceReforged.ini: edit the weapon in place, the fields it does not name stay as they were
}
@@ -2016,7 +1976,10 @@ void WeaponStore::postProcessLoad()
/* The first definition stands and the block is read and dropped. WeaponReforged.ini keeps
copies of EA weapons FixesReforged.ini hands out, for a mod whose Weapon.ini leaves them out
(Contra has no Demo_DestroyedWeapon); where the loaded data has the weapon, its own wins.
- This used to return mid-block, and the next field line stopped the load as an unknown block. */
+ This used to return mid-block, and the next field line stopped the load as an unknown block.
+ A map.ini block lands here too, as it did in retail: EA parsed it into a copy nothing pointed
+ at, and the campaign was tuned with those edits lost. Applying them gave Generals USA04's
+ cutscene CarpetBombWeapon its 1000 radius, and the bombers wiped every unit on the map. */
DEBUG_LOG(("[LINE: %d in '%s'] Weapon '%s' is already defined; the block is skipped.\n", ini->getLineNum(), ini->getFilename().str(), c));
WeaponTemplate *scratch = newInstance(WeaponTemplate);
ini->initFromINI(scratch, scratch->getFieldParse());