Add ~CStateManager

This commit is contained in:
Henrique Gemignani Passos Lima 2022-11-15 01:08:47 +02:00
parent 23371108b3
commit 7dc8252b27
No known key found for this signature in database
GPG Key ID: E224F951761145F8
12 changed files with 89 additions and 18 deletions

View File

@ -2897,8 +2897,8 @@ lbl_802126AC:
/* 802126BC 0020F61C 38 21 00 20 */ addi r1, r1, 0x20
/* 802126C0 0020F620 4E 80 00 20 */ blr
.global sub_802126c4
sub_802126c4:
.global Cleanup__13CEnvFxManagerFv
Cleanup__13CEnvFxManagerFv:
/* 802126C4 0020F624 A0 8D A3 8C */ lhz r4, kInvalidUniqueId@sda21(r13)
/* 802126C8 0020F628 38 00 00 00 */ li r0, 0
/* 802126CC 0020F62C B0 83 0B 68 */ sth r4, 0xb68(r3)

View File

@ -8264,7 +8264,7 @@ lbl_8004AB6C:
/* 8004AB90 00047AF0 38 C0 00 00 */ li r6, 0
/* 8004AB94 00047AF4 48 00 D0 19 */ bl TravelToArea__6CWorldFRC7TAreaIdR13CStateManagerb
/* 8004AB98 00047AF8 7F C3 F3 78 */ mr r3, r30
/* 8004AB9C 00047AFC 48 00 15 F9 */ bl BringOutYourDead__13CStateManagerFv
/* 8004AB9C 00047AFC 48 00 15 F9 */ bl ClearGraveyard__13CStateManagerFv
/* 8004ABA0 00047B00 80 7E 08 D8 */ lwz r3, 0x8d8(r30)
/* 8004ABA4 00047B04 38 03 00 01 */ addi r0, r3, 1
/* 8004ABA8 00047B08 90 1E 08 D8 */ stw r0, 0x8d8(r30)
@ -9838,8 +9838,8 @@ lbl_8004C17C:
/* 8004C18C 000490EC 38 21 00 20 */ addi r1, r1, 0x20
/* 8004C190 000490F0 4E 80 00 20 */ blr
.global BringOutYourDead__13CStateManagerFv
BringOutYourDead__13CStateManagerFv:
.global ClearGraveyard__13CStateManagerFv
ClearGraveyard__13CStateManagerFv:
/* 8004C194 000490F4 94 21 FF D0 */ stwu r1, -0x30(r1)
/* 8004C198 000490F8 7C 08 02 A6 */ mflr r0
/* 8004C19C 000490FC 90 01 00 34 */ stw r0, 0x34(r1)
@ -11027,13 +11027,13 @@ __dt__13CStateManagerFv:
/* 8004D1DC 0004A13C 80 7D 08 8C */ lwz r3, 0x88c(r29)
/* 8004D1E0 0004A140 48 31 CB 6D */ bl HardStopAll__16CRumbleGeneratorFv
/* 8004D1E4 0004A144 80 7D 08 80 */ lwz r3, 0x880(r29)
/* 8004D1E8 0004A148 48 1C 54 DD */ bl sub_802126c4
/* 8004D1E8 0004A148 48 1C 54 DD */ bl Cleanup__13CEnvFxManagerFv
/* 8004D1EC 0004A14C 38 1D 08 FC */ addi r0, r29, 0x8fc
/* 8004D1F0 0004A150 3B FD 08 0C */ addi r31, r29, 0x80c
/* 8004D1F4 0004A154 90 1D 09 00 */ stw r0, 0x900(r29)
/* 8004D1F8 0004A158 7F A3 EB 78 */ mr r3, r29
/* 8004D1FC 0004A15C 83 7D 08 10 */ lwz r27, 0x810(r29)
/* 8004D200 0004A160 4B FF EF 95 */ bl BringOutYourDead__13CStateManagerFv
/* 8004D200 0004A160 4B FF EF 95 */ bl ClearGraveyard__13CStateManagerFv
/* 8004D204 0004A164 3B 40 00 00 */ li r26, 0
lbl_8004D208:
/* 8004D208 0004A168 7F 63 DB 78 */ mr r3, r27
@ -11074,7 +11074,7 @@ lbl_8004D28C:
/* 8004D290 0004A1F0 2C 1A 04 00 */ cmpwi r26, 0x400
/* 8004D294 0004A1F4 40 82 FF 74 */ bne lbl_8004D208
/* 8004D298 0004A1F8 7F A3 EB 78 */ mr r3, r29
/* 8004D29C 0004A1FC 4B FF EE F9 */ bl BringOutYourDead__13CStateManagerFv
/* 8004D29C 0004A1FC 4B FF EE F9 */ bl ClearGraveyard__13CStateManagerFv
/* 8004D2A0 0004A200 A0 0D A3 8C */ lhz r0, kInvalidUniqueId@sda21(r13)
/* 8004D2A4 0004A204 7F A6 EB 78 */ mr r6, r29
/* 8004D2A8 0004A208 38 A1 00 10 */ addi r5, r1, 0x10
@ -11114,10 +11114,10 @@ lbl_8004D304:
lbl_8004D32C:
/* 8004D32C 0004A28C 38 7D 0F 54 */ addi r3, r29, 0xf54
/* 8004D330 0004A290 38 80 FF FF */ li r4, -1
/* 8004D334 0004A294 48 00 32 01 */ bl sub_80050534
/* 8004D334 0004A294 48 00 32 01 */ bl "__dt__Q24rstl43list<9TUniqueId,Q24rstl17rmemory_allocator>Fv"
/* 8004D338 0004A298 38 7D 0F 3C */ addi r3, r29, 0xf3c
/* 8004D33C 0004A29C 38 80 FF FF */ li r4, -1
/* 8004D340 0004A2A0 48 00 31 F5 */ bl sub_80050534
/* 8004D340 0004A2A0 48 00 31 F5 */ bl "__dt__Q24rstl43list<9TUniqueId,Q24rstl17rmemory_allocator>Fv"
/* 8004D344 0004A2A4 38 7D 0D 14 */ addi r3, r29, 0xd14
/* 8004D348 0004A2A8 38 80 FF FF */ li r4, -1
/* 8004D34C 0004A2AC 48 00 0C F9 */ bl "__dt__Q24rstl36reserved_vector<15CCameraBlurPass,9>Fv"
@ -14704,8 +14704,8 @@ lbl_80050518:
/* 8005052C 0004D48C 38 21 00 30 */ addi r1, r1, 0x30
/* 80050530 0004D490 4E 80 00 20 */ blr
.global sub_80050534
sub_80050534:
.global "__dt__Q24rstl43list<9TUniqueId,Q24rstl17rmemory_allocator>Fv"
"__dt__Q24rstl43list<9TUniqueId,Q24rstl17rmemory_allocator>Fv":
/* 80050534 0004D494 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 80050538 0004D498 7C 08 02 A6 */ mflr r0
/* 8005053C 0004D49C 90 01 00 24 */ stw r0, 0x24(r1)

View File

@ -15013,12 +15013,12 @@ __sinit_CSpacePirate_cpp:
/* 8012D240 0012A1A0 38 61 00 28 */ addi r3, r1, 0x28
/* 8012D244 0012A1A4 48 21 08 9D */ bl "internal_dereference__Q24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>Fv"
/* 8012D248 0012A1A8 3C 60 80 57 */ lis r3, lbl_8056F85C@ha
/* 8012D24C 0012A1AC 3C 80 80 05 */ lis r4, sub_80050534@ha
/* 8012D24C 0012A1AC 3C 80 80 05 */ lis r4, "__dt__Q24rstl43list<9TUniqueId,Q24rstl17rmemory_allocator>Fv"@ha
/* 8012D250 0012A1B0 38 63 F8 5C */ addi r3, r3, lbl_8056F85C@l
/* 8012D254 0012A1B4 38 00 00 00 */ li r0, 0
/* 8012D258 0012A1B8 38 C3 00 0C */ addi r6, r3, 0xc
/* 8012D25C 0012A1BC 90 03 00 14 */ stw r0, 0x14(r3)
/* 8012D260 0012A1C0 38 84 05 34 */ addi r4, r4, sub_80050534@l
/* 8012D260 0012A1C0 38 84 05 34 */ addi r4, r4, "__dt__Q24rstl43list<9TUniqueId,Q24rstl17rmemory_allocator>Fv"@l
/* 8012D264 0012A1C4 38 BF 01 88 */ addi r5, r31, 0x188
/* 8012D268 0012A1C8 90 C3 00 04 */ stw r6, 4(r3)
/* 8012D26C 0012A1CC 90 C3 00 08 */ stw r6, 8(r3)

View File

@ -62,7 +62,7 @@ LIBS = [
["MetroidPrime/Tweaks/CTweakGame", True],
"MetroidPrime/CGameProjectile",
["MetroidPrime/Player/CPlayerGun", False],
"MetroidPrime/CStateManager",
["MetroidPrime/CStateManager", False],
["MetroidPrime/CEntity", True],
["MetroidPrime/CArchMsgParmInt32", True],
["MetroidPrime/CArchMsgParmInt32Int32VoidPtr", True],

View File

@ -25,6 +25,8 @@ public:
virtual ~CCollisionPrimitive();
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const = 0;
static void Uninitialize();
private:
uint x4_;
CMaterialList x8_material;

View File

@ -41,6 +41,7 @@ public:
static void Initialize();
void SetFxDensity(int, float);
void SetSplashRate(float f) { xb54_baseSplashRate = f; }
void Cleanup();
private:
CAABox x0_particleBounds;

View File

@ -8,6 +8,8 @@
#include "rstl/reserved_vector.hpp"
class CScriptWater;
class CFluidPlaneManager {
public:
// TODO

View File

@ -0,0 +1,8 @@
#ifndef _CMAPWORLDINFO
#define _CMAPWORLDINFO
class CMapWorldInfo {
};
#endif // _CMAPWORLDINFO

View File

@ -17,6 +17,7 @@ public:
short Rumble(CStateManager&, ERumbleFxId, float, ERumblePriority);
void StopRumble(short id);
void HardStopAll() { x0_rumbleGenerator.HardStopAll(); }
void Update(float dt);
private:

View File

@ -49,7 +49,7 @@ class CEntity;
class CMazeState;
class CRayCastResult;
class CMaterialFilter;
class CScriptLayerManager;
class CWorldLayerState;
class CLight;
class CDamageInfo;
class CTexture;
@ -100,6 +100,9 @@ public:
kCFS_Max,
};
CStateManager();
~CStateManager();
bool RenderLast(const TUniqueId&);
void ResetEscapeSequenceTimer(float);
void SendScriptMsg(TUniqueId uid, TEditorId target, EScriptObjectMessage msg,
@ -167,6 +170,8 @@ public:
CObjectList& ObjectListById(EGameObjectList id) { return *x808_objectLists[id]; }
const CObjectList& GetObjectListById(EGameObjectList id) const { return *x808_objectLists[id]; }
void RemoveObject(TUniqueId);
const CFinalInput& GetFinalInput() const { return xb54_finalInput; }
@ -276,7 +281,7 @@ private:
rstl::rc_ptr< CScriptMailbox > x8bc_mailbox;
rstl::rc_ptr< CMapWorldInfo > x8c0_mapWorldInfo;
rstl::rc_ptr< CWorldTransManager > x8c4_worldTransManager;
rstl::rc_ptr< CScriptLayerManager > x8c8_worldLayerState;
rstl::rc_ptr< CWorldLayerState > x8c8_worldLayerState;
TAreaId x8cc_nextAreaId;
TAreaId x8d0_prevAreaId;
@ -330,6 +335,8 @@ private:
bool xf94_28_inSaveUI : 1;
bool xf94_29_cinematicPause : 1;
bool xf94_30_fullThreat : 1;
void ClearGraveyard();
};
CHECK_SIZEOF(CStateManager, 0xf98)

View File

@ -0,0 +1,50 @@
#include "MetroidPrime/CStateManager.hpp"
#include "MetroidPrime/CEnvFxManager.hpp"
#include "MetroidPrime/CMapWorldInfo.hpp"
#include "MetroidPrime/CRipple.hpp"
#include "MetroidPrime/CRumbleManager.hpp"
#include "MetroidPrime/CScriptMailbox.hpp"
#include "MetroidPrime/CStateManagerContainer.hpp"
#include "MetroidPrime/CWorld.hpp"
#include "MetroidPrime/Player/CPlayer.hpp"
#include "MetroidPrime/Player/CPlayerState.hpp"
#include "MetroidPrime/Player/CWorldLayerState.hpp"
#include "MetroidPrime/Player/CWorldTransManager.hpp"
#include "MetroidPrime/ScriptObjects/CScriptMazeNode.hpp"
#include "Collision/CCollisionPrimitive.hpp"
#include "Kyoto/Graphics/CLight.hpp"
// CStateManager::CStateManager();
CStateManager::~CStateManager() {
CMemory::OffsetFakeStatics(
-(x808_objectLists.size() * sizeof(CObjectList) + 0x11c)); // TODO what is this 11c?
x88c_rumbleManager->HardStopAll();
x880_envFxManager->Cleanup();
x900_random = &x8fc_random;
CObjectList& list = *x808_objectLists[0];
ClearGraveyard();
for (int i = 0; i != kMaxObjects; ++i) {
CEntity* ent = list[i];
if (ent && ent->GetUniqueId() != x84c_player->GetUniqueId()) {
ent->AcceptScriptMsg(kSM_Deleted, kInvalidUniqueId, *this);
RemoveObject(ent->GetUniqueId());
delete ent;
}
}
ClearGraveyard();
x84c_player->AcceptScriptMsg(kSM_Deleted, kInvalidUniqueId, *this);
RemoveObject(x84c_player->GetUniqueId());
delete x84c_player;
x84c_player = nullptr;
CCollisionPrimitive::Uninitialize();
CMemory::SetOutOfMemoryCallback(nullptr, nullptr);
}
void CStateManager::RemoveObject(TUniqueId id) {}
void CStateManager::ClearGraveyard() {}

View File

@ -448,7 +448,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
if (msg == kSM_Decrement || msg == kSM_Increment) {
if (x1bc_areaSaveId != -1 && x1c0_layerIdx != -1) {
TAreaId aId = mgr.GetWorld()->GetAreaIdForSaveId(x1bc_areaSaveId);
rstl::rc_ptr< CScriptLayerManager > worldLayerState(NULL);
rstl::rc_ptr< CWorldLayerState > worldLayerState(NULL);
if (aId != kInvalidAreaId) {
// worldLayerState = mgr.WorldLayerState();