Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Aug 28, 2024
1 parent f2eb0a1 commit eb01776
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/Ext/TerrainType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int TerrainTypeExt::ExtData::GetCellsPerAnim()
return GeneralUtils::GetRangedRandomOrSingleValue(this->SpawnsTiberium_CellsPerAnim.Get());
}

void TerrainTypeExt::ExtData::PlayDestroyEffects(CoordStruct coords)
void TerrainTypeExt::ExtData::PlayDestroyEffects(const CoordStruct& coords)
{
VocClass::PlayIndexAtPos(this->DestroySound, coords);

Expand Down Expand Up @@ -98,6 +98,9 @@ void TerrainTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

this->PaletteFile.Read(pArtINI, pArtSection, "Palette");
this->Palette = GeneralUtils::BuildPalette(this->PaletteFile);

if (GeneralUtils::IsValidString(this->PaletteFile) && !this->Palette)
Debug::Log("[Developer warning] [%s] has Palette=%s set but no palette file was loaded (missing file or wrong filename). Missing palettes cause issues with lighting recalculations.\n", pArtSection, this->PaletteFile);
}

void TerrainTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
Expand Down
4 changes: 2 additions & 2 deletions src/Ext/TerrainType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TerrainTypeExt
Valueable<bool> CanBeBuiltOn;
Valueable<bool> HasDamagedFrames;
Valueable<bool> HasCrumblingFrames;
NullableIdx<VocClass> CrumblingSound;
ValueableIdx<VocClass> CrumblingSound;
Nullable<int> AnimationLength;

PhobosFixedString<32u> PaletteFile;
Expand Down Expand Up @@ -63,7 +63,7 @@ class TerrainTypeExt

int GetTiberiumGrowthStage();
int GetCellsPerAnim();
void PlayDestroyEffects(CoordStruct coords);
void PlayDestroyEffects(const CoordStruct& coords);

private:
template <typename T>
Expand Down
12 changes: 6 additions & 6 deletions src/Ext/TerrainType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ DEFINE_HOOK(0x71C812, TerrainClass_AI_Crumbling, 0x6)
if (pTypeExt->HasDamagedFrames && pThis->Health > 0)
{
if (!pThis->Type->IsAnimated && !pThis->Type->IsFlammable)
MapClass::Instance->Logics->Remove(pThis);
LogicClass::Instance->Remove(pThis);

pThis->IsCrumbling = false;

Expand Down Expand Up @@ -221,8 +221,8 @@ DEFINE_HOOK(0x71C6EE, TerrainClass_FireOut_Crumbling, 0x6)
if (!pThis->IsCrumbling && pTypeExt->HasCrumblingFrames)
{
// Needs to be added to the logic layer for the anim to work.
MapClass::Instance->Logics->AddObject(pThis, false);
VocClass::PlayIndexAtPos(pTypeExt->CrumblingSound.Get(-1), pThis->GetCoords());
LogicClass::Instance->AddObject(pThis, false);
VocClass::PlayIndexAtPos(pTypeExt->CrumblingSound, pThis->GetCoords());

return StartCrumbling;
}
Expand All @@ -249,7 +249,7 @@ DEFINE_HOOK(0x71B98B, TerrainClass_TakeDamage_RefreshDamageFrame, 0x7)
if (!pThis->Type->IsAnimated && pTypeExt->HasDamagedFrames && TerrainTypeTemp::PriorHealthRatio > condYellow && pThis->GetHealthPercentage() <= condYellow)
{
pThis->IsCrumbling = true; // Dirty hack to get game to redraw the art reliably.
MapClass::Instance->Logics->AddObject(pThis, false);
LogicClass::Instance->AddObject(pThis, false);
}

return 0;
Expand All @@ -268,8 +268,8 @@ DEFINE_HOOK(0x71BB2C, TerrainClass_TakeDamage_NowDead_Add, 0x6)
if (pThis->IsCrumbling && pTypeExt->HasCrumblingFrames)
{
// Needs to be added to the logic layer for the anim to work.
MapClass::Instance->Logics->AddObject(pThis, false);
VocClass::PlayIndexAtPos(pTypeExt->CrumblingSound.Get(-1), pThis->GetCoords());
LogicClass::Instance->AddObject(pThis, false);
VocClass::PlayIndexAtPos(pTypeExt->CrumblingSound, pThis->GetCoords());
pThis->Mark(MarkType::Change);
pThis->Disappear(true);

Expand Down

0 comments on commit eb01776

Please sign in to comment.