Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Ext/TerrainType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void TerrainTypeExt::ExtData::Serialize(T& Stm)
.Process(this->SpawnsTiberium_Range)
.Process(this->SpawnsTiberium_GrowthStage)
.Process(this->SpawnsTiberium_CellsPerAnim)
.Process(this->DestroyAnim)
.Process(this->DestroySound)
;
}

Expand All @@ -43,6 +45,12 @@ void TerrainTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->SpawnsTiberium_Range.Read(exINI, pSection, "SpawnsTiberium.Range");
this->SpawnsTiberium_GrowthStage.Read(exINI, pSection, "SpawnsTiberium.GrowthStage");
this->SpawnsTiberium_CellsPerAnim.Read(exINI, pSection, "SpawnsTiberium.CellsPerAnim");

this->DestroyAnim.Read(exINI, pSection, "DestroyAnim");
this->DestroySound.Read(exINI, pSection, "DestroySound");

//Strength is already part of ObjecTypeClass::ReadIni Duh!
//this->TerrainStrength.Read(exINI, pSection, "Strength");
}

void TerrainTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
Expand Down Expand Up @@ -73,7 +81,6 @@ bool TerrainTypeExt::SaveGlobals(PhobosStreamWriter& Stm)
// container

TerrainTypeExt::ExtContainer::ExtContainer() : Container("TerrainTypeClass") { }

TerrainTypeExt::ExtContainer::~ExtContainer() = default;

// =============================
Expand Down Expand Up @@ -120,8 +127,8 @@ DEFINE_HOOK(0x71E25A, TerrainTypeClass_Save_Suffix, 0x5)
TerrainTypeExt::ExtMap.SaveStatic();

return 0;
}

}
DEFINE_HOOK(0x71E0A6, TerrainTypeClass_LoadFromINI, 0x5)
{
GET(TerrainTypeClass*, pItem, ESI);
Expand Down
5 changes: 5 additions & 0 deletions src/Ext/TerrainType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Helpers/Macro.h>
#include <Utilities/Container.h>
#include <Utilities/TemplateDef.h>
#include <Utilities/Macro.h>

class TerrainTypeExt
{
Expand All @@ -17,12 +18,16 @@ class TerrainTypeExt
Valueable<int> SpawnsTiberium_Range;
Valueable<Point2D> SpawnsTiberium_GrowthStage;
Valueable<Point2D> SpawnsTiberium_CellsPerAnim;
Nullable<AnimTypeClass*> DestroyAnim;
NullableIdx<VocClass> DestroySound;

ExtData(TerrainTypeClass* OwnerObject) : Extension<TerrainTypeClass>(OwnerObject)
, SpawnsTiberium_Type { 0 }
, SpawnsTiberium_Range { 1 }
, SpawnsTiberium_GrowthStage { { 3, 0 } }
, SpawnsTiberium_CellsPerAnim { { 1, 0 } }
, DestroyAnim {}
, DestroySound {}
{ }

virtual ~ExtData() = default;
Expand Down
23 changes: 22 additions & 1 deletion src/Ext/TerrainType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include <ScenarioClass.h>
#include <TiberiumClass.h>
#include <OverlayTypeClass.h>
#include <TerrainClass.h>
#include <SpecificStructures.h>
#include <AnimClass.h>

#include <Utilities/GeneralUtils.h>
#include <Utilities/Macro.h>

namespace TerrainTypeTemp
{
Expand Down Expand Up @@ -90,4 +92,23 @@ DEFINE_HOOK(0x71C8D7, TerrainTypeClass_Context_Unset, 0x5)
TerrainTypeTemp::pCurrentExt = nullptr;

return 0;
}

//This one on Very end of it , let everything play first
DEFINE_HOOK(0x71BB2C, TerrainClass_TakeDamage_NowDead_Add, 0x6)
{
GET(TerrainClass*, pThis, ESI);
//saved for later usage !
//REF_STACK(args_ReceiveDamage const, ReceiveDamageArgs, STACK_OFFS(0x3C, -0x4));

if (auto const pTerrainExt = TerrainTypeExt::ExtMap.Find(pThis->Type))
{
auto const nCoords = pThis->GetCoords();
VocClass::PlayIndexAtPos(pTerrainExt->DestroySound.Get(-1), nCoords);

if (auto const pAnimType = pTerrainExt->DestroyAnim.Get(nullptr))
GameCreate<AnimClass>(pAnimType, nCoords);
}

return 0;
}