Skip to content

Commit

Permalink
Add IsInitialized to type extensions to avoid resetting keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ZivDero committed Oct 17, 2024
1 parent 6dbcbab commit 00c6c72
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/extensions/abstracttype/abstracttypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
AbstractTypeClassExtension::AbstractTypeClassExtension(const AbstractTypeClass *this_ptr) :
AbstractClassExtension(this_ptr),
IniName(),
FullName()
FullName(),
IsInitialized(false)
{
//if (this_ptr) EXT_DEBUG_TRACE("AbstractTypeClassExtension::AbstractTypeClassExtension - Name: %s (0x%08X)\n", Name(), (uintptr_t)(This()));
}
Expand Down
7 changes: 7 additions & 0 deletions src/extensions/abstracttype/abstracttypeext.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class AbstractTypeClassExtension : public AbstractClassExtension
char IniName[24 + 1];
char FullName[48 + 1];

/**
* Has this extension already executed Read_INI?
* Set this to true at the end of Read_INI of the last extension
* in the inheritance hierarchy.
*/
bool IsInitialized;

public:

private:
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/aircrafttype/aircrafttypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,7 @@ bool AircraftTypeClassExtension::Read_INI(CCINIClass &ini)
IsCurleyShuffle = ini.Get_Bool(ini_name, "CurleyShuffle", Rule->IsCurleyShuffle);
ReloadRate = ini.Get_Float(ini_name, "ReloadRate", Rule->ReloadRate);

IsInitialized = true;

return true;
}
4 changes: 3 additions & 1 deletion src/extensions/animtype/animtypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ bool AnimTypeClassExtension::Read_INI(CCINIClass &ini)
AttachLayer = ini.Get_LayerType(ini_name, "Layer", AttachLayer);
ParticleToSpawn = ini.Get_ParticleType(ini_name, "SpawnsParticle", ParticleToSpawn);
NumberOfParticles = ini.Get_Int(ini_name, "NumParticles", NumberOfParticles);


IsInitialized = true;

return true;
}
11 changes: 8 additions & 3 deletions src/extensions/buildingtype/buildingtypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ bool BuildingTypeClassExtension::Read_INI(CCINIClass &ini)

const char *ini_name = Name();

if (!IsInitialized) {
IsEligibleForAllyBuilding = This()->IsConstructionYard;
}

GateUpSound = ini.Get_VocType(ini_name, "GateUpSound", GateUpSound);
GateDownSound = ini.Get_VocType(ini_name, "GateDownSound", GateDownSound);

Expand All @@ -202,8 +206,9 @@ bool BuildingTypeClassExtension::Read_INI(CCINIClass &ini)
IsStartupCashOneTime = ini.Get_Int(ini_name, "ProduceCashStartupOneTime", IsStartupCashOneTime);
IsResetBudgetOnCapture = ini.Get_Bool(ini_name, "ProduceCashResetOnCapture", IsResetBudgetOnCapture);

IsEligibleForAllyBuilding = ini.Get_Bool(ini_name, "EligibleForAllyBuilding",
This()->IsConstructionYard ? true : IsEligibleForAllyBuilding);

IsEligibleForAllyBuilding = ini.Get_Bool(ini_name, "EligibleForAllyBuilding", IsEligibleForAllyBuilding);

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/bullettype/bullettypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ bool BulletTypeClassExtension::Read_INI(CCINIClass &ini)
* The following keys are loaded from the ArtINI database.
*/
SpawnDelay = ArtINI.Get_Int(graphic_name, "SpawnDelay", SpawnDelay);

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/housetype/housetypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ bool HouseTypeClassExtension::Read_INI(CCINIClass &ini)
if (!ini.Is_Present(ini_name)) {
return false;
}

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/infantrytype/infantrytypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ bool InfantryTypeClassExtension::Read_INI(CCINIClass &ini)

IsMechanic = ini.Get_Bool(ini_name, "Mechanic", IsMechanic);
IsOmniHealer = ini.Get_Bool(ini_name, "OmniHealer", IsOmniHealer);

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/isotiletype/isotiletypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ bool IsometricTileTypeClassExtension::Read_INI(CCINIClass &ini)
if (!ini.Is_Present(ini_name)) {
return false;
}

IsInitialized = true;

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/overlaytype/overlaytypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ bool OverlayTypeClassExtension::Read_INI(CCINIClass &ini)
if (!ini.Is_Present(ini_name)) {
return false;
}

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/particlesystype/particlesystypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ bool ParticleSystemTypeClassExtension::Read_INI(CCINIClass &ini)
if (!ini.Is_Present(ini_name)) {
return false;
}

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/particletype/particletypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ bool ParticleTypeClassExtension::Read_INI(CCINIClass &ini)
if (!ini.Is_Present(ini_name)) {
return false;
}

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/smudgetype/smudgetypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ bool SmudgeTypeClassExtension::Read_INI(CCINIClass &ini)
if (!ini.Is_Present(ini_name)) {
return false;
}

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/supertype/supertypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ bool SuperWeaponTypeClassExtension::Read_INI(CCINIClass &ini)
if (imagesurface) {
CameoImageSurface = imagesurface;
}

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/terraintype/terraintypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ bool TerrainTypeClassExtension::Read_INI(CCINIClass &ini)
LightRedTint = ini.Get_Double(ini_name, "LightRedTint", (LightRedTint / 1000)) * 1000.0 + 0.1;
LightGreenTint = ini.Get_Double(ini_name, "LightGreenTint", (LightGreenTint / 1000)) * 1000.0 + 0.1;
LightBlueTint = ini.Get_Double(ini_name, "LightBlueTint", (LightBlueTint / 1000)) * 1000.0 + 0.1;

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/unittype/unittypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,7 @@ bool UnitTypeClassExtension::Read_INI(CCINIClass &ini)
StartIdleFrame = ArtINI.Get_Int(graphic_name, "StartIdleFrame", StartIdleFrame);
IdleFrames = ArtINI.Get_Int(graphic_name, "IdleFrames", IdleFrames);

IsInitialized = true;

return true;
}
2 changes: 2 additions & 0 deletions src/extensions/voxelanimtype/voxelanimtypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ bool VoxelAnimTypeClassExtension::Read_INI(CCINIClass &ini)
if (!ini.Is_Present(ini_name)) {
return false;
}

IsInitialized = true;

return true;
}
8 changes: 7 additions & 1 deletion src/extensions/warheadtype/warheadtypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,16 @@ bool WarheadTypeClassExtension::Read_INI(CCINIClass &ini)
Verses::Set_Retaliate(armor, warheadtype, ini.Get_Bool(ini_name, key_name, Verses::Get_Retaliate(armor, warheadtype)));
}

if (!IsInitialized) {
This()->IsOrganic = Verses::Get_Modifier(ARMOR_STEEL, warheadtype) == 0.0;
}

/**
* Allow overriding IsOrganic.
*/
This()->IsOrganic = ini.Get_Bool(ini_name, "Organic", Verses::Get_Modifier(ARMOR_STEEL, warheadtype) == 0);
This()->IsOrganic = ini.Get_Bool(ini_name, "Organic", This()->IsOrganic);

IsInitialized = true;

return true;
}
3 changes: 2 additions & 1 deletion src/extensions/weapontype/weapontypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ bool WeaponTypeClassExtension::Read_INI(CCINIClass &ini)
ElectricBoltDeviation = ini.Get_Float(ini_name, "EBoltDeviation", ElectricBoltDeviation);
//ElectricBoltSourceBoltParticleSys = ini.Get_ParticleSys(ini_name, "EBoltSourceParticleSys", ElectricBoltSourceBoltParticleSys);
//ElectricBoltTargetBoltParticleSys = ini.Get_ParticleSys(ini_name, "EBoltTargetBoltParticleSys", ElectricBoltTargetBoltParticleSys);


IsInitialized = true;

return true;
}

0 comments on commit 00c6c72

Please sign in to comment.