diff --git a/src/engine/actors/Text.cpp b/src/engine/actors/Text.cpp index ad99430eb..f6ab19373 100644 --- a/src/engine/actors/Text.cpp +++ b/src/engine/actors/Text.cpp @@ -21,9 +21,12 @@ extern "C" { #include "code_80005FD0.h" } +size_t AText::_count; + AText::AText(const SpawnParams& params) : AActor(params) { Name = "Text"; ResourceName = "hm:text"; + _idx = _count; SpawnPos = params.Location.value_or(FVector(0.0f, 100.0f, 0.0f)); Pos[0] = SpawnPos.x; @@ -65,6 +68,8 @@ AText::AText(const SpawnParams& params) : AActor(params) { Text = ValidateString(params.Skin.value_or("Harbour Masters")); AText::Print3D((char*)Text.c_str(), 0, CENTER_TEXT_MODE_2); + + _count += 1; } /** @@ -360,7 +365,7 @@ void AText::DrawText3D(Camera* camera) { // Based on func_80095BD0 AddObjectMatrix(mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - FrameInterpolation_RecordOpenChild("actor_text", ((uintptr_t)this << 6) | camera->cameraId); + FrameInterpolation_RecordOpenChild("actor_text", ((uintptr_t)_idx << 6) | camera->cameraId); gSPDisplayList(gDisplayListHead++, (Gfx*)D_020077A8); for (CharacterList& tex : TextureList) { diff --git a/src/engine/actors/Text.h b/src/engine/actors/Text.h index 554f35c7f..8d981828c 100644 --- a/src/engine/actors/Text.h +++ b/src/engine/actors/Text.h @@ -60,7 +60,13 @@ public: // Constructor AText(const SpawnParams& params); - virtual ~AText() override = default; + virtual ~AText() { + _count--; + }; + + static size_t GetCount() { + return _count; + } /** * This is simply a helper function to keep Spawning code clean @@ -147,4 +153,7 @@ public: {{{30, 0, 0}, 0, {1856, 1984}, {0xff, 0xff, 0xff, 0xff}}}, {{{ 0, 0, 0}, 0, { 0, 1984}, {0xff, 0xff, 0xff, 0xff}}}, }; +private: + static size_t _count; + size_t _idx; }; diff --git a/src/engine/cameras/GameCamera.h b/src/engine/cameras/GameCamera.h index 1a2ef7d5b..9031334ae 100644 --- a/src/engine/cameras/GameCamera.h +++ b/src/engine/cameras/GameCamera.h @@ -11,7 +11,7 @@ class GameCamera { public: GameCamera(); GameCamera(FVector spawn, s16 rot, u32 mode); - ~GameCamera() { + virtual ~GameCamera() { _count--; }