From 9275d073112e4fa8349414efa33969a0312bbf44 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 12 Aug 2026 17:39:04 -0600 Subject: [PATCH] Cleanup CStateManager & friends --- config/GM8E01_00/symbols.txt | 19 +- config/GM8E01_01/symbols.txt | 17 +- config/GM8E01_02/symbols.txt | 19 +- config/GM8E01_48/symbols.txt | 9 +- config/GM8J01_00/symbols.txt | 19 +- config/GM8P01_00/symbols.txt | 19 +- include/Collision/CMRay.hpp | 1 + include/Kyoto/Graphics/CModelFlags.hpp | 1 + include/Kyoto/PVS/CPVSVisSet.hpp | 1 + include/Kyoto/Particles/CParticleElectric.hpp | 3 + include/MetroidPrime/CActor.hpp | 5 + include/MetroidPrime/CDecalManager.hpp | 3 + include/MetroidPrime/CEntity.hpp | 2 + include/MetroidPrime/CGameArea.hpp | 8 +- include/MetroidPrime/CHealthInfo.hpp | 1 + include/MetroidPrime/CStateManager.hpp | 4 +- include/MetroidPrime/CWorld.hpp | 13 +- .../MetroidPrime/Cameras/CCameraManager.hpp | 3 + .../Enemies/CWallCrawlerSwarm.hpp | 2 + include/MetroidPrime/Player/CGameState.hpp | 5 + include/MetroidPrime/Player/CHintOptions.hpp | 1 + include/MetroidPrime/Player/CPlayer.hpp | 3 + include/MetroidPrime/Player/CPlayerState.hpp | 1 + include/MetroidPrime/Player/CSystemState.hpp | 1 + include/MetroidPrime/Player/CWorldState.hpp | 2 + .../ScriptObjects/CScriptEffect.hpp | 2 + .../ScriptObjects/CScriptPlayerActor.hpp | 2 +- .../ScriptObjects/CSnakeWeedSwarm.hpp | 2 + include/rstl/string.hpp | 1 + src/MetaRender/CCubeRenderer.cpp | 21 +- src/MetroidPrime/CStateManager.cpp | 275 ++++++------------ src/MetroidPrime/CWorld.cpp | 9 +- 32 files changed, 210 insertions(+), 264 deletions(-) diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 4728341a9..2c520f7b6 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -1070,7 +1070,7 @@ DrawWorld__13CStateManagerCFv = .text:0x80045F7C; // type:function size:0xD90 sc GetAliveAreasEnd__6CWorldFv = .text:0x80046D0C; // type:function size:0xC scope:global SetupFogForArea3XRange__13CStateManagerCF7TAreaId = .text:0x80046D18; // type:function size:0x68 SetupFogForArea__13CStateManagerCF7TAreaId = .text:0x80046D80; // type:function size:0x68 scope:global -fn_80046DE8 = .text:0x80046DE8; // type:function size:0x88 +SetupFogForArea3XRange__13CStateManagerCFRC9CGameArea = .text:0x80046DE8; // type:function size:0x88 scope:global SetupFogForArea__13CStateManagerCFRC9CGameArea = .text:0x80046E70; // type:function size:0xAC scope:global SetupFogForDraw__13CStateManagerCFv = .text:0x80046F1C; // type:function size:0xC8 scope:global SetupViewForDraw__13CStateManagerCFRC9CViewport = .text:0x80046FE4; // type:function size:0x360 scope:global @@ -1098,7 +1098,7 @@ ApplyKnockBack__13CStateManagerFR6CActorRC11CDamageInfoRC20CDamageVulnerabilityR ApplyDamageToWorld__13CStateManagerF9TUniqueIdRC6CActorRC9CVector3fRC11CDamageInfoRC15CMaterialFilter = .text:0x80048CAC; // type:function size:0x364 scope:global ProcessRadiusDamage__13CStateManagerFRC6CActorR6CActor9TUniqueIdRC11CDamageInfoRC15CMaterialFilter = .text:0x80049010; // type:function size:0x1DC scope:global ApplyRadiusDamage__13CStateManagerFRC6CActorRC9CVector3fR6CActorRC11CDamageInfo = .text:0x800491EC; // type:function size:0x2F4 scope:global -TestRayDamage__13CStateManagerRC9CVector3fRC6CActorRCQ24rstl49reserved_vector<9TUniqueId,1024> = .text:0x800494E0; // type:function size:0x3F8 scope:global +TestRayDamage__13CStateManagerCFRC9CVector3fRC6CActorRCQ24rstl49reserved_vector<9TUniqueId,1024> = .text:0x800494E0; // type:function size:0x3F8 scope:global MultiRayCollideWorld__13CStateManagerFRC5CMRayRC15CMaterialFilter = .text:0x800498D8; // type:function size:0x1F4 scope:global TestBombHittingWater__13CStateManagerFRC6CActorRC9CVector3fR6CActor = .text:0x80049ACC; // type:function size:0x308 scope:global ApplyLocalDamage__13CStateManagerFRC9CVector3fRC9CVector3fR6CActorfRC11CWeaponMode = .text:0x80049DD4; // type:function size:0x2CC scope:global @@ -1111,10 +1111,10 @@ Update__13CStateManagerFf = .text:0x8004A7CC; // type:function size:0x3FC scope: PostUpdatePlayer__13CStateManagerFf = .text:0x8004ABC8; // type:function size:0x28 scope:global PreThinkObjects__13CStateManagerFf = .text:0x8004ABF0; // type:function size:0x158 scope:global Think__13CStateManagerFf = .text:0x8004AD48; // type:function size:0x1E8 scope:global -CrossTouchActors__13CStateManagerFf = .text:0x8004AF30; // type:function size:0x35C scope:global +CrossTouchActors__13CStateManagerFv = .text:0x8004AF30; // type:function size:0x35C scope:global MoveDoors__13CStateManagerFf = .text:0x8004B28C; // type:function size:0x1A0 scope:global MovePlatforms__13CStateManagerFf = .text:0x8004B42C; // type:function size:0xD8 scope:global -fn_8004B504 = .text:0x8004B504; // type:function size:0x4 +nullsub_34 = .text:0x8004B504; // type:function size:0x4 scope:global UpdateGameState__13CStateManagerFv = .text:0x8004B508; // type:function size:0x4 scope:global SwapOutAllPossibleMemory__13CStateManagerFv = .text:0x8004B50C; // type:function size:0x2C scope:global MemoryAllocatorAllocationFailedCallback__13CStateManagerFPCvUi = .text:0x8004B538; // type:function size:0x20 scope:global @@ -1463,7 +1463,7 @@ SetThermalSpeedAndTarget__9CGameAreaFff = .text:0x8005E1FC; // type:function siz SetAreaAttributes__9CGameAreaFP21CScriptAreaAttributes = .text:0x8005E210; // type:function size:0x2C scope:global GetXRayFogDistance__9CGameAreaFv = .text:0x8005E23C; // type:function size:0x20 scope:global SetLoadPauseState__9CGameAreaFb = .text:0x8005E25C; // type:function size:0x90 scope:global -GetLayerScriptBuffer__9CGameAreaFi = .text:0x8005E2EC; // type:function size:0x50 scope:global +GetLayerScriptBuffer__9CGameAreaFRCi = .text:0x8005E2EC; // type:function size:0x50 scope:global IsFinishedOccluding__9CGameAreaCFv = .text:0x8005E33C; // type:function size:0x24 scope:global IGetScriptingMemoryAlways__14CDummyGameAreaCFv = .text:0x8005E360; // type:function size:0x2C scope:global IGetAreaId__14CDummyGameAreaCFv = .text:0x8005E38C; // type:function size:0x8 scope:global @@ -21487,7 +21487,7 @@ lbl_805A89F0 = .sdata:0x805A89F0; // type:object size:0x8 data:byte @327 = .sdata:0x805A8A00; // type:object size:0x4 scope:local align:4 data:float @328 = .sdata:0x805A8A04; // type:object size:0x4 scope:local align:4 data:float @355 = .sdata:0x805A8A08; // type:object size:0x4 scope:local align:4 data:float -lbl_805A8A10 = .sdata:0x805A8A10; // type:object size:0x2 data:2byte +sSeed__17CParticleElectric = .sdata:0x805A8A10; // type:object size:0x2 scope:global data:2byte lbl_805A8A12 = .sdata:0x805A8A12; // type:object size:0x1 data:byte lbl_805A8A14 = .sdata:0x805A8A14; // type:object size:0x4 align:4 data:float lbl_805A8A18 = .sdata:0x805A8A18; // type:object size:0x8 align:4 data:float @@ -21667,8 +21667,7 @@ lbl_805A8D7C = .sbss:0x805A8D7C; // type:object size:0x4 align:4 data:float lbl_805A8D80 = .sbss:0x805A8D80; // type:object size:0x4 align:4 data:float kHandThermalFlag = .sbss:0x805A8D84; // type:object size:0x8 scope:global data:byte kHandHoloFlag = .sbss:0x805A8D8C; // type:object size:0x8 scope:global data:byte -lbl_805A8D98 = .sbss:0x805A8D98; // type:object size:0x4 data:4byte -lbl_805A8D9C = .sbss:0x805A8D9C; // type:object size:0x4 data:4byte +sPreRenderStepTime = .sbss:0x805A8D98; // type:object size:0x8 scope:local data:8byte lbl_805A8DA0 = .sbss:0x805A8DA0; // type:object size:0x1 data:byte lbl_805A8DA1 = .sbss:0x805A8DA1; // type:object size:0x7 data:byte lbl_805A8DA8 = .sbss:0x805A8DA8; // type:object size:0x4 data:4byte @@ -21683,8 +21682,8 @@ lbl_805A8DC8 = .sbss:0x805A8DC8; // type:object size:0x4 align:4 data:float lbl_805A8DCC = .sbss:0x805A8DCC; // type:object size:0x1 data:byte lbl_805A8DD0 = .sbss:0x805A8DD0; // type:object size:0x4 data:4byte lbl_805A8DD4 = .sbss:0x805A8DD4; // type:object size:0x1 data:byte -sAliveAreasEnd = .sbss:0x805A8DD8; // type:object size:0x4 scope:global data:4byte -lbl_805A8DDC = .sbss:0x805A8DDC; // type:object size:0x4 data:4byte +skGlobalEnd__6CWorld = .sbss:0x805A8DD8; // type:object size:0x4 scope:global data:4byte +skGlobalNonConstEnd__6CWorld = .sbss:0x805A8DDC; // type:object size:0x4 scope:global data:4byte lbl_805A8DE0 = .sbss:0x805A8DE0; // type:object size:0x1 data:byte lbl_805A8DE4 = .sbss:0x805A8DE4; // type:object size:0x1 data:byte lbl_805A8DE8 = .sbss:0x805A8DE8; // type:object size:0x8 data:4byte diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index 791fd3db3..4ff979881 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -1070,7 +1070,7 @@ DrawWorld__13CStateManagerCFv = .text:0x80045FF8; // type:function size:0xD90 sc GetAliveAreasEnd__6CWorldFv = .text:0x80046D88; // type:function size:0xC scope:global SetupFogForArea3XRange__13CStateManagerCF7TAreaId = .text:0x80046D94; // type:function size:0x68 scope:global SetupFogForArea__13CStateManagerCF7TAreaId = .text:0x80046DFC; // type:function size:0x68 scope:global -fn_80046DE8 = .text:0x80046E64; // type:function size:0x88 scope:global +SetupFogForArea3XRange__13CStateManagerCFRC9CGameArea = .text:0x80046E64; // type:function size:0x88 scope:global SetupFogForArea__13CStateManagerCFRC9CGameArea = .text:0x80046EEC; // type:function size:0xAC scope:global SetupFogForDraw__13CStateManagerCFv = .text:0x80046F98; // type:function size:0xC8 scope:global SetupViewForDraw__13CStateManagerCFRCQ29CGraphics9CViewport = .text:0x80047060; // type:function size:0x360 scope:global @@ -1098,7 +1098,7 @@ ApplyKnockBack__13CStateManagerFR6CActorRC11CDamageInfoRC20CDamageVulnerabilityR ApplyDamageToWorld__13CStateManagerF9TUniqueIdRC6CActorRC9CVector3fRC11CDamageInfoRC15CMaterialFilter = .text:0x80048D28; // type:function size:0x364 scope:global ProcessRadiusDamage__13CStateManagerFRC6CActorR6CActor9TUniqueIdRC11CDamageInfoRC15CMaterialFilter = .text:0x8004908C; // type:function size:0x1DC scope:global ApplyRadiusDamage__13CStateManagerFRC6CActorRC9CVector3fR6CActorRC11CDamageInfo = .text:0x80049268; // type:function size:0x2F4 scope:global -TestRayDamage__13CStateManagerRC9CVector3fRC6CActorRCQ24rstl49reserved_vector<9TUniqueId,1024> = .text:0x8004955C; // type:function size:0x3F8 scope:global +TestRayDamage__13CStateManagerCFRC9CVector3fRC6CActorRCQ24rstl49reserved_vector<9TUniqueId,1024> = .text:0x8004955C; // type:function size:0x3F8 scope:global MultiRayCollideWorld__13CStateManagerRC5CMRayRC15CMaterialFilter = .text:0x80049954; // type:function size:0x1F4 scope:global TestBombHittingWater__13CStateManagerFRC6CActorRC9CVector3fR6CActor = .text:0x80049B48; // type:function size:0x308 scope:global ApplyLocalDamage__13CStateManagerFRC9CVector3fRC9CVector3fR6CActorfRC11CWeaponMode = .text:0x80049E50; // type:function size:0x2CC scope:global @@ -1111,7 +1111,7 @@ Update__13CStateManagerFf = .text:0x8004A848; // type:function size:0x3FC scope: PostUpdatePlayer__13CStateManagerFf = .text:0x8004AC44; // type:function size:0x28 scope:global PreThinkObjects__13CStateManagerFf = .text:0x8004AC6C; // type:function size:0x158 scope:global Think__13CStateManagerFf = .text:0x8004ADC4; // type:function size:0x1E8 scope:global -CrossTouchActors__13CStateManagerFf = .text:0x8004AFAC; // type:function size:0x35C scope:global +CrossTouchActors__13CStateManagerFv = .text:0x8004AFAC; // type:function size:0x35C scope:global MoveDoors__13CStateManagerFf = .text:0x8004B308; // type:function size:0x1A0 scope:global MovePlatforms__13CStateManagerFf = .text:0x8004B4A8; // type:function size:0xD8 scope:global nullsub_34 = .text:0x8004B580; // type:function size:0x4 scope:global @@ -1463,7 +1463,7 @@ SetThermalSpeedAndTarget__9CGameAreaFff = .text:0x8005E278; // type:function siz SetAreaAttributes__9CGameAreaFP21CScriptAreaAttributes = .text:0x8005E28C; // type:function size:0x2C scope:global GetXRayFogDistance__9CGameAreaFv = .text:0x8005E2B8; // type:function size:0x20 scope:global SetLoadPauseState__9CGameAreaFb = .text:0x8005E2D8; // type:function size:0x90 scope:global -GetLayerScriptBuffer__9CGameAreaFi = .text:0x8005E368; // type:function size:0x50 scope:global +GetLayerScriptBuffer__9CGameAreaFRCi = .text:0x8005E368; // type:function size:0x50 scope:global IsFinishedOccluding__9CGameAreaCFv = .text:0x8005E3B8; // type:function size:0x24 scope:global IGetScriptingMemoryAlways__14CDummyGameAreaCFv = .text:0x8005E3DC; // type:function size:0x2C scope:global IGetAreaId__14CDummyGameAreaCFv = .text:0x8005E408; // type:function size:0x8 scope:global @@ -21429,7 +21429,7 @@ lbl_805A8BD0 = .sdata:0x805A8BD0; // type:object size:0x8 data:byte @327 = .sdata:0x805A8BE0; // type:object size:0x4 scope:local align:4 data:float @328 = .sdata:0x805A8BE4; // type:object size:0x4 scope:local align:4 data:float @355 = .sdata:0x805A8BE8; // type:object size:0x4 scope:local align:4 data:float -lbl_805A8BF0 = .sdata:0x805A8BF0; // type:object size:0x2 data:2byte +sSeed__17CParticleElectric = .sdata:0x805A8BF0; // type:object size:0x2 scope:global data:2byte lbl_805A8BF2 = .sdata:0x805A8BF2; // type:object size:0x1 data:byte lbl_805A8BF4 = .sdata:0x805A8BF4; // type:object size:0x4 align:4 data:float lbl_805A8BF8 = .sdata:0x805A8BF8; // type:object size:0x8 align:4 data:float @@ -21609,8 +21609,7 @@ lbl_805A8F5C = .sbss:0x805A8F5C; // type:object size:0x4 align:4 data:float lbl_805A8F60 = .sbss:0x805A8F60; // type:object size:0x4 align:4 data:float lbl_805A8F64 = .sbss:0x805A8F64; // type:object size:0x8 data:byte lbl_805A8F6C = .sbss:0x805A8F6C; // type:object size:0xC data:byte -lbl_805A8F78 = .sbss:0x805A8F78; // type:object size:0x4 data:4byte -lbl_805A8F7C = .sbss:0x805A8F7C; // type:object size:0x4 data:4byte +sPreRenderStepTime = .sbss:0x805A8F78; // type:object size:0x8 scope:local data:8byte lbl_805A8F80 = .sbss:0x805A8F80; // type:object size:0x1 data:byte lbl_805A8F81 = .sbss:0x805A8F81; // type:object size:0x7 data:byte lbl_805A8F88 = .sbss:0x805A8F88; // type:object size:0x4 data:4byte @@ -21625,8 +21624,8 @@ lbl_805A8FA8 = .sbss:0x805A8FA8; // type:object size:0x4 align:4 data:float lbl_805A8FAC = .sbss:0x805A8FAC; // type:object size:0x1 data:byte lbl_805A8FB0 = .sbss:0x805A8FB0; // type:object size:0x4 data:4byte lbl_805A8FB4 = .sbss:0x805A8FB4; // type:object size:0x1 data:byte -sAliveAreasEnd = .sbss:0x805A8FB8; // type:object size:0x4 scope:global data:4byte -lbl_805A8FBC = .sbss:0x805A8FBC; // type:object size:0x4 data:4byte +skGlobalEnd__6CWorld = .sbss:0x805A8FB8; // type:object size:0x4 scope:global data:4byte +skGlobalNonConstEnd__6CWorld = .sbss:0x805A8FBC; // type:object size:0x4 scope:global data:4byte lbl_805A8FC0 = .sbss:0x805A8FC0; // type:object size:0x1 data:byte lbl_805A8FC4 = .sbss:0x805A8FC4; // type:object size:0x1 data:byte lbl_805A8FC8 = .sbss:0x805A8FC8; // type:object size:0x8 data:4byte diff --git a/config/GM8E01_02/symbols.txt b/config/GM8E01_02/symbols.txt index 24bb44ae3..b6ed06733 100644 --- a/config/GM8E01_02/symbols.txt +++ b/config/GM8E01_02/symbols.txt @@ -1070,7 +1070,7 @@ fn_80046268 = .text:0x80046268; // type:function size:0xD90 fn_80046FF8 = .text:0x80046FF8; // type:function size:0xC fn_80047004 = .text:0x80047004; // type:function size:0x68 fn_8004706C = .text:0x8004706C; // type:function size:0x68 -fn_800470D4 = .text:0x800470D4; // type:function size:0x88 +SetupFogForArea3XRange__13CStateManagerCFRC9CGameArea = .text:0x800470D4; // type:function size:0x88 scope:global fn_8004715C = .text:0x8004715C; // type:function size:0xAC fn_80047208 = .text:0x80047208; // type:function size:0xC8 fn_800472D0 = .text:0x800472D0; // type:function size:0x360 @@ -1098,7 +1098,7 @@ fn_80048D84 = .text:0x80048D84; // type:function size:0x214 fn_80048F98 = .text:0x80048F98; // type:function size:0x364 fn_800492FC = .text:0x800492FC; // type:function size:0x1DC fn_800494D8 = .text:0x800494D8; // type:function size:0x2F4 -fn_800497CC = .text:0x800497CC; // type:function size:0x3F8 +TestRayDamage__13CStateManagerCFRC9CVector3fRC6CActorRCQ24rstl49reserved_vector<9TUniqueId,1024> = .text:0x800497CC; // type:function size:0x3F8 scope:global fn_80049BC4 = .text:0x80049BC4; // type:function size:0x1F4 fn_80049DB8 = .text:0x80049DB8; // type:function size:0x308 fn_8004A0C0 = .text:0x8004A0C0; // type:function size:0x2CC @@ -1111,10 +1111,10 @@ fn_8004AAB8 = .text:0x8004AAB8; // type:function size:0x3FC fn_8004AEB4 = .text:0x8004AEB4; // type:function size:0x28 fn_8004AEDC = .text:0x8004AEDC; // type:function size:0x158 fn_8004B034 = .text:0x8004B034; // type:function size:0x1E8 -fn_8004B21C = .text:0x8004B21C; // type:function size:0x35C +CrossTouchActors__13CStateManagerFv = .text:0x8004B21C; // type:function size:0x35C scope:global fn_8004B578 = .text:0x8004B578; // type:function size:0x1A0 fn_8004B718 = .text:0x8004B718; // type:function size:0xD8 -fn_8004B7F0 = .text:0x8004B7F0; // type:function size:0x4 +nullsub_34 = .text:0x8004B7F0; // type:function size:0x4 scope:global fn_8004B7F4 = .text:0x8004B7F4; // type:function size:0x4 fn_8004B7F8 = .text:0x8004B7F8; // type:function size:0x2C fn_8004B824 = .text:0x8004B824; // type:function size:0x20 @@ -1463,7 +1463,7 @@ fn_8005E780 = .text:0x8005E780; // type:function size:0x14 fn_8005E794 = .text:0x8005E794; // type:function size:0x2C fn_8005E7C0 = .text:0x8005E7C0; // type:function size:0x20 fn_8005E7E0 = .text:0x8005E7E0; // type:function size:0x90 -fn_8005E870 = .text:0x8005E870; // type:function size:0x50 +GetLayerScriptBuffer__9CGameAreaFRCi = .text:0x8005E870; // type:function size:0x50 scope:global fn_8005E8C0 = .text:0x8005E8C0; // type:function size:0x24 fn_8005E8E4 = .text:0x8005E8E4; // type:function size:0x2C fn_8005E910 = .text:0x8005E910; // type:function size:0x8 @@ -21371,7 +21371,7 @@ lbl_805A9A8C = .sdata:0x805A9A8C; // type:object size:0x4 align:4 data:float lbl_805A9A90 = .sdata:0x805A9A90; // type:object size:0x4 align:4 data:float lbl_805A9A94 = .sdata:0x805A9A94; // type:object size:0x4 align:4 data:float lbl_805A9A98 = .sdata:0x805A9A98; // type:object size:0x8 align:4 data:float -lbl_805A9AA0 = .sdata:0x805A9AA0; // type:object size:0x2 data:2byte +sSeed__17CParticleElectric = .sdata:0x805A9AA0; // type:object size:0x2 scope:global data:2byte lbl_805A9AA2 = .sdata:0x805A9AA2; // type:object size:0x1 data:byte lbl_805A9AA4 = .sdata:0x805A9AA4; // type:object size:0x4 align:4 data:float lbl_805A9AA8 = .sdata:0x805A9AA8; // type:object size:0x8 align:4 data:float @@ -21551,8 +21551,7 @@ lbl_805A9E1C = .sbss:0x805A9E1C; // type:object size:0x4 align:4 data:float lbl_805A9E20 = .sbss:0x805A9E20; // type:object size:0x4 align:4 data:float lbl_805A9E24 = .sbss:0x805A9E24; // type:object size:0x8 data:byte lbl_805A9E2C = .sbss:0x805A9E2C; // type:object size:0xC data:byte -lbl_805A9E38 = .sbss:0x805A9E38; // type:object size:0x4 data:4byte -lbl_805A9E3C = .sbss:0x805A9E3C; // type:object size:0x4 data:4byte +sPreRenderStepTime = .sbss:0x805A9E38; // type:object size:0x8 scope:local data:8byte lbl_805A9E40 = .sbss:0x805A9E40; // type:object size:0x1 data:byte lbl_805A9E41 = .sbss:0x805A9E41; // type:object size:0x7 data:byte lbl_805A9E48 = .sbss:0x805A9E48; // type:object size:0x4 data:4byte @@ -21567,8 +21566,8 @@ lbl_805A9E68 = .sbss:0x805A9E68; // type:object size:0x4 align:4 data:float lbl_805A9E6C = .sbss:0x805A9E6C; // type:object size:0x1 data:byte lbl_805A9E70 = .sbss:0x805A9E70; // type:object size:0x4 data:4byte lbl_805A9E74 = .sbss:0x805A9E74; // type:object size:0x1 data:byte -lbl_805A9E78 = .sbss:0x805A9E78; // type:object size:0x4 data:4byte -lbl_805A9E7C = .sbss:0x805A9E7C; // type:object size:0x4 data:4byte +skGlobalEnd__6CWorld = .sbss:0x805A9E78; // type:object size:0x4 scope:global data:4byte +skGlobalNonConstEnd__6CWorld = .sbss:0x805A9E7C; // type:object size:0x4 scope:global data:4byte lbl_805A9E80 = .sbss:0x805A9E80; // type:object size:0x1 data:byte lbl_805A9E84 = .sbss:0x805A9E84; // type:object size:0x1 data:byte lbl_805A9E88 = .sbss:0x805A9E88; // type:object size:0x8 data:4byte diff --git a/config/GM8E01_48/symbols.txt b/config/GM8E01_48/symbols.txt index 17baddea9..d7015c542 100644 --- a/config/GM8E01_48/symbols.txt +++ b/config/GM8E01_48/symbols.txt @@ -21355,7 +21355,7 @@ lbl_805A86DC = .sdata:0x805A86DC; // type:object size:0x4 align:4 data:float lbl_805A86E0 = .sdata:0x805A86E0; // type:object size:0x4 align:4 data:float lbl_805A86E4 = .sdata:0x805A86E4; // type:object size:0x4 align:4 data:float lbl_805A86E8 = .sdata:0x805A86E8; // type:object size:0x8 align:4 data:float -lbl_805A86F0 = .sdata:0x805A86F0; // type:object size:0x2 data:2byte +sSeed__17CParticleElectric = .sdata:0x805A86F0; // type:object size:0x2 scope:global data:2byte lbl_805A86F2 = .sdata:0x805A86F2; // type:object size:0x1 data:byte lbl_805A86F4 = .sdata:0x805A86F4; // type:object size:0x4 align:4 data:float lbl_805A86F8 = .sdata:0x805A86F8; // type:object size:0x8 align:4 data:float @@ -21533,8 +21533,7 @@ lbl_805A8A5C = .sbss:0x805A8A5C; // type:object size:0x4 align:4 data:float lbl_805A8A60 = .sbss:0x805A8A60; // type:object size:0x4 align:4 data:float lbl_805A8A64 = .sbss:0x805A8A64; // type:object size:0x8 data:byte lbl_805A8A6C = .sbss:0x805A8A6C; // type:object size:0xC data:byte -lbl_805A8A78 = .sbss:0x805A8A78; // type:object size:0x4 data:4byte -lbl_805A8A7C = .sbss:0x805A8A7C; // type:object size:0x4 data:4byte +sPreRenderStepTime = .sbss:0x805A8A78; // type:object size:0x8 scope:local data:8byte lbl_805A8A80 = .sbss:0x805A8A80; // type:object size:0x1 data:byte lbl_805A8A81 = .sbss:0x805A8A81; // type:object size:0x7 data:byte lbl_805A8A88 = .sbss:0x805A8A88; // type:object size:0x4 data:4byte @@ -21549,8 +21548,8 @@ lbl_805A8AA8 = .sbss:0x805A8AA8; // type:object size:0x4 align:4 data:float lbl_805A8AAC = .sbss:0x805A8AAC; // type:object size:0x1 data:byte lbl_805A8AB0 = .sbss:0x805A8AB0; // type:object size:0x4 data:4byte lbl_805A8AB4 = .sbss:0x805A8AB4; // type:object size:0x1 data:byte -lbl_805A8AB8 = .sbss:0x805A8AB8; // type:object size:0x4 data:4byte -lbl_805A8ABC = .sbss:0x805A8ABC; // type:object size:0x4 data:4byte +skGlobalEnd__6CWorld = .sbss:0x805A8AB8; // type:object size:0x4 scope:global data:4byte +skGlobalNonConstEnd__6CWorld = .sbss:0x805A8ABC; // type:object size:0x4 scope:global data:4byte lbl_805A8AC0 = .sbss:0x805A8AC0; // type:object size:0x1 data:byte lbl_805A8AC4 = .sbss:0x805A8AC4; // type:object size:0x1 data:byte lbl_805A8AC8 = .sbss:0x805A8AC8; // type:object size:0x8 data:4byte diff --git a/config/GM8J01_00/symbols.txt b/config/GM8J01_00/symbols.txt index 091315e39..bd3e046ba 100644 --- a/config/GM8J01_00/symbols.txt +++ b/config/GM8J01_00/symbols.txt @@ -1262,7 +1262,7 @@ fn_80048E14 = .text:0x80048E14; // type:function size:0x30 fn_80048E44 = .text:0x80048E44; // type:function size:0x58 fn_80048E9C = .text:0x80048E9C; // type:function size:0x68 fn_80048F04 = .text:0x80048F04; // type:function size:0x68 -fn_80048F6C = .text:0x80048F6C; // type:function size:0x88 +SetupFogForArea3XRange__13CStateManagerCFRC9CGameArea = .text:0x80048F6C; // type:function size:0x88 scope:global fn_80048FF4 = .text:0x80048FF4; // type:function size:0xAC fn_800490A0 = .text:0x800490A0; // type:function size:0xC8 fn_80049168 = .text:0x80049168; // type:function size:0x318 @@ -1296,7 +1296,7 @@ fn_8004AC90 = .text:0x8004AC90; // type:function size:0x204 fn_8004AE94 = .text:0x8004AE94; // type:function size:0x340 fn_8004B1D4 = .text:0x8004B1D4; // type:function size:0x1DC fn_8004B3B0 = .text:0x8004B3B0; // type:function size:0x2E4 -fn_8004B694 = .text:0x8004B694; // type:function size:0x31C +TestRayDamage__13CStateManagerCFRC9CVector3fRC6CActorRCQ24rstl49reserved_vector<9TUniqueId,1024> = .text:0x8004B694; // type:function size:0x31C scope:global fn_8004B9B0 = .text:0x8004B9B0; // type:function size:0x74 fn_8004BA24 = .text:0x8004BA24; // type:function size:0x1E0 fn_8004BC04 = .text:0x8004BC04; // type:function size:0x2DC @@ -1313,10 +1313,10 @@ fn_8004CCC0 = .text:0x8004CCC0; // type:function size:0x28 fn_8004CCE8 = .text:0x8004CCE8; // type:function size:0x14C fn_8004CE34 = .text:0x8004CE34; // type:function size:0x168 fn_8004CF9C = .text:0x8004CF9C; // type:function size:0x84 -fn_8004D020 = .text:0x8004D020; // type:function size:0x2DC +CrossTouchActors__13CStateManagerFv = .text:0x8004D020; // type:function size:0x2DC scope:global fn_8004D2FC = .text:0x8004D2FC; // type:function size:0x118 fn_8004D414 = .text:0x8004D414; // type:function size:0xD8 -fn_8004D4EC = .text:0x8004D4EC; // type:function size:0x4 +nullsub_34 = .text:0x8004D4EC; // type:function size:0x4 scope:global fn_8004D4F0 = .text:0x8004D4F0; // type:function size:0x4 fn_8004D4F4 = .text:0x8004D4F4; // type:function size:0x2C fn_8004D520 = .text:0x8004D520; // type:function size:0x20 @@ -1720,7 +1720,7 @@ fn_800601CC = .text:0x800601CC; // type:function size:0x14 fn_800601E0 = .text:0x800601E0; // type:function size:0x2C fn_8006020C = .text:0x8006020C; // type:function size:0x20 fn_8006022C = .text:0x8006022C; // type:function size:0x90 -fn_800602BC = .text:0x800602BC; // type:function size:0x50 +GetLayerScriptBuffer__9CGameAreaFRCi = .text:0x800602BC; // type:function size:0x50 scope:global fn_8006030C = .text:0x8006030C; // type:function size:0x24 fn_80060330 = .text:0x80060330; // type:function size:0x2C fn_8006035C = .text:0x8006035C; // type:function size:0x8 @@ -19307,7 +19307,7 @@ lbl_80591A94 = .sdata:0x80591A94; // type:object size:0x4 align:4 data:float lbl_80591A98 = .sdata:0x80591A98; // type:object size:0x4 align:4 data:float lbl_80591A9C = .sdata:0x80591A9C; // type:object size:0x4 align:4 data:float lbl_80591AA0 = .sdata:0x80591AA0; // type:object size:0x8 align:4 data:float -lbl_80591AA8 = .sdata:0x80591AA8; // type:object size:0x2 data:2byte +sSeed__17CParticleElectric = .sdata:0x80591AA8; // type:object size:0x2 scope:global data:2byte lbl_80591AAA = .sdata:0x80591AAA; // type:object size:0x1 data:byte lbl_80591AAC = .sdata:0x80591AAC; // type:object size:0x4 lbl_80591AB0 = .sdata:0x80591AB0; // type:object size:0x8 align:4 data:float @@ -19491,8 +19491,7 @@ lbl_80591E2C = .sbss:0x80591E2C; // type:object size:0x4 align:4 data:float lbl_80591E30 = .sbss:0x80591E30; // type:object size:0x4 align:4 data:float lbl_80591E34 = .sbss:0x80591E34; // type:object size:0x8 data:byte lbl_80591E3C = .sbss:0x80591E3C; // type:object size:0xC data:byte -lbl_80591E48 = .sbss:0x80591E48; // type:object size:0x4 data:4byte -lbl_80591E4C = .sbss:0x80591E4C; // type:object size:0x4 data:4byte +sPreRenderStepTime = .sbss:0x80591E48; // type:object size:0x8 scope:local data:8byte lbl_80591E50 = .sbss:0x80591E50; // type:object size:0x1 data:byte lbl_80591E51 = .sbss:0x80591E51; // type:object size:0x7 data:byte lbl_80591E58 = .sbss:0x80591E58; // type:object size:0x4 data:4byte @@ -19507,8 +19506,8 @@ lbl_80591E78 = .sbss:0x80591E78; // type:object size:0x4 align:4 data:float lbl_80591E7C = .sbss:0x80591E7C; // type:object size:0x1 data:byte lbl_80591E80 = .sbss:0x80591E80; // type:object size:0x4 data:4byte lbl_80591E84 = .sbss:0x80591E84; // type:object size:0x1 data:byte -lbl_80591E88 = .sbss:0x80591E88; // type:object size:0x4 data:4byte -lbl_80591E8C = .sbss:0x80591E8C; // type:object size:0x4 data:4byte +skGlobalEnd__6CWorld = .sbss:0x80591E88; // type:object size:0x4 scope:global data:4byte +skGlobalNonConstEnd__6CWorld = .sbss:0x80591E8C; // type:object size:0x4 scope:global data:4byte lbl_80591E90 = .sbss:0x80591E90; // type:object size:0x1 data:byte lbl_80591E94 = .sbss:0x80591E94; // type:object size:0x1 data:byte lbl_80591E98 = .sbss:0x80591E98; // type:object size:0x8 data:4byte diff --git a/config/GM8P01_00/symbols.txt b/config/GM8P01_00/symbols.txt index 8bd76817e..a8e5b586a 100644 --- a/config/GM8P01_00/symbols.txt +++ b/config/GM8P01_00/symbols.txt @@ -1264,7 +1264,7 @@ fn_800480A0 = .text:0x800480A0; // type:function size:0x30 fn_800480D0 = .text:0x800480D0; // type:function size:0x58 fn_80048128 = .text:0x80048128; // type:function size:0x68 fn_80048190 = .text:0x80048190; // type:function size:0x68 -fn_800481F8 = .text:0x800481F8; // type:function size:0x88 +SetupFogForArea3XRange__13CStateManagerCFRC9CGameArea = .text:0x800481F8; // type:function size:0x88 scope:global fn_80048280 = .text:0x80048280; // type:function size:0xAC fn_8004832C = .text:0x8004832C; // type:function size:0xC8 fn_800483F4 = .text:0x800483F4; // type:function size:0x2F4 @@ -1298,7 +1298,7 @@ fn_80049EF8 = .text:0x80049EF8; // type:function size:0x204 fn_8004A0FC = .text:0x8004A0FC; // type:function size:0x340 fn_8004A43C = .text:0x8004A43C; // type:function size:0x1DC fn_8004A618 = .text:0x8004A618; // type:function size:0x2E4 -fn_8004A8FC = .text:0x8004A8FC; // type:function size:0x31C +TestRayDamage__13CStateManagerCFRC9CVector3fRC6CActorRCQ24rstl49reserved_vector<9TUniqueId,1024> = .text:0x8004A8FC; // type:function size:0x31C scope:global fn_8004AC18 = .text:0x8004AC18; // type:function size:0x74 fn_8004AC8C = .text:0x8004AC8C; // type:function size:0x1E0 fn_8004AE6C = .text:0x8004AE6C; // type:function size:0x2DC @@ -1315,10 +1315,10 @@ fn_8004BF28 = .text:0x8004BF28; // type:function size:0x28 fn_8004BF50 = .text:0x8004BF50; // type:function size:0x14C fn_8004C09C = .text:0x8004C09C; // type:function size:0x168 fn_8004C204 = .text:0x8004C204; // type:function size:0x84 -fn_8004C288 = .text:0x8004C288; // type:function size:0x2C0 +CrossTouchActors__13CStateManagerFv = .text:0x8004C288; // type:function size:0x2C0 scope:global fn_8004C548 = .text:0x8004C548; // type:function size:0x118 fn_8004C660 = .text:0x8004C660; // type:function size:0xD8 -fn_8004C738 = .text:0x8004C738; // type:function size:0x4 +nullsub_34 = .text:0x8004C738; // type:function size:0x4 scope:global fn_8004C73C = .text:0x8004C73C; // type:function size:0x4 fn_8004C740 = .text:0x8004C740; // type:function size:0x2C fn_8004C76C = .text:0x8004C76C; // type:function size:0x20 @@ -1722,7 +1722,7 @@ fn_8005F3BC = .text:0x8005F3BC; // type:function size:0x14 fn_8005F3D0 = .text:0x8005F3D0; // type:function size:0x2C fn_8005F3FC = .text:0x8005F3FC; // type:function size:0x20 fn_8005F41C = .text:0x8005F41C; // type:function size:0x90 -fn_8005F4AC = .text:0x8005F4AC; // type:function size:0x50 +GetLayerScriptBuffer__9CGameAreaFRCi = .text:0x8005F4AC; // type:function size:0x50 scope:global fn_8005F4FC = .text:0x8005F4FC; // type:function size:0x24 fn_8005F520 = .text:0x8005F520; // type:function size:0x2C fn_8005F54C = .text:0x8005F54C; // type:function size:0x8 @@ -19325,7 +19325,7 @@ lbl_8046AAE4 = .sdata:0x8046AAE4; // type:object size:0x4 align:4 data:float lbl_8046AAE8 = .sdata:0x8046AAE8; // type:object size:0x4 align:4 data:float lbl_8046AAEC = .sdata:0x8046AAEC; // type:object size:0x4 align:4 data:float lbl_8046AAF0 = .sdata:0x8046AAF0; // type:object size:0x8 align:4 data:float -lbl_8046AAF8 = .sdata:0x8046AAF8; // type:object size:0x2 data:2byte +sSeed__17CParticleElectric = .sdata:0x8046AAF8; // type:object size:0x2 scope:global data:2byte lbl_8046AAFA = .sdata:0x8046AAFA; // type:object size:0x1 data:byte lbl_8046AAFC = .sdata:0x8046AAFC; // type:object size:0x4 lbl_8046AB00 = .sdata:0x8046AB00; // type:object size:0x8 align:4 data:float @@ -19510,8 +19510,7 @@ lbl_8046AE94 = .sbss:0x8046AE94; // type:object size:0x4 align:4 data:float lbl_8046AE98 = .sbss:0x8046AE98; // type:object size:0x4 align:4 data:float lbl_8046AE9C = .sbss:0x8046AE9C; // type:object size:0x8 data:byte lbl_8046AEA4 = .sbss:0x8046AEA4; // type:object size:0xC data:byte -lbl_8046AEB0 = .sbss:0x8046AEB0; // type:object size:0x4 data:4byte -lbl_8046AEB4 = .sbss:0x8046AEB4; // type:object size:0x4 data:4byte +sPreRenderStepTime = .sbss:0x8046AEB0; // type:object size:0x8 scope:local data:8byte lbl_8046AEB8 = .sbss:0x8046AEB8; // type:object size:0x1 data:byte lbl_8046AEB9 = .sbss:0x8046AEB9; // type:object size:0x7 data:byte lbl_8046AEC0 = .sbss:0x8046AEC0; // type:object size:0x4 data:4byte @@ -19526,8 +19525,8 @@ lbl_8046AEE0 = .sbss:0x8046AEE0; // type:object size:0x4 align:4 data:float lbl_8046AEE4 = .sbss:0x8046AEE4; // type:object size:0x1 data:byte lbl_8046AEE8 = .sbss:0x8046AEE8; // type:object size:0x4 data:4byte lbl_8046AEEC = .sbss:0x8046AEEC; // type:object size:0x1 data:byte -lbl_8046AEF0 = .sbss:0x8046AEF0; // type:object size:0x4 data:4byte -lbl_8046AEF4 = .sbss:0x8046AEF4; // type:object size:0x4 data:4byte +skGlobalEnd__6CWorld = .sbss:0x8046AEF0; // type:object size:0x4 scope:global data:4byte +skGlobalNonConstEnd__6CWorld = .sbss:0x8046AEF4; // type:object size:0x4 scope:global data:4byte lbl_8046AEF8 = .sbss:0x8046AEF8; // type:object size:0x1 data:byte lbl_8046AEFC = .sbss:0x8046AEFC; // type:object size:0x1 data:byte lbl_8046AF00 = .sbss:0x8046AF00; // type:object size:0x8 data:4byte diff --git a/include/Collision/CMRay.hpp b/include/Collision/CMRay.hpp index 36eed5863..4683088b2 100644 --- a/include/Collision/CMRay.hpp +++ b/include/Collision/CMRay.hpp @@ -14,6 +14,7 @@ class CMRay { const CVector3f& GetNormal() const { return mEnd; } const CVector3f& GetDelta() const { return mDelta; } const CVector3f& GetDirection() const { return mDir; } + float GetLength() const { return mLength; } private: CVector3f mStart; diff --git a/include/Kyoto/Graphics/CModelFlags.hpp b/include/Kyoto/Graphics/CModelFlags.hpp index dde38fbdd..987b9be67 100644 --- a/include/Kyoto/Graphics/CModelFlags.hpp +++ b/include/Kyoto/Graphics/CModelFlags.hpp @@ -90,6 +90,7 @@ class CModelFlags { const int GetShaderSet() const { return x1_matSetIdx; } const int GetOtherFlags() const { return x2_flags; } const CColor GetColor() const { return x4_color; } + const CColor& GetColorRef() const { return x4_color; } bool operator==(const CModelFlags& other) const { // TODO: cast to char for extsb; see CScriptActor::PreRender diff --git a/include/Kyoto/PVS/CPVSVisSet.hpp b/include/Kyoto/PVS/CPVSVisSet.hpp index da7d10688..544398a9b 100644 --- a/include/Kyoto/PVS/CPVSVisSet.hpp +++ b/include/Kyoto/PVS/CPVSVisSet.hpp @@ -17,6 +17,7 @@ class CPVSVisSet { CPVSVisSet(EPVSVisSetState state); EPVSVisSetState GetVisible(int index) const; + EPVSVisSetState GetState() const { return x0_state; } static inline CPVSVisSet MakeFromMemory(const int numBits, const int numLights, const rstl::auto_ptr< const char >& leafPtr) { diff --git a/include/Kyoto/Particles/CParticleElectric.hpp b/include/Kyoto/Particles/CParticleElectric.hpp index 9dfbded76..f04d381b5 100644 --- a/include/Kyoto/Particles/CParticleElectric.hpp +++ b/include/Kyoto/Particles/CParticleElectric.hpp @@ -44,6 +44,7 @@ class CParticleElectric : public CParticleGen { void SetOverrideIVel(const CVector3f& vec) { x188_overrideIVel = vec; } void SetOverrideFPos(const CVector3f& vec) { x198_overrideFPos = vec; } void SetOverrideFVel(const CVector3f& vec) { x1a8_overrideFVel = vec; } + static void SetGlobalSeed(ushort seed) { sSeed = seed; } private: uchar x1c_pad[0x15c]; @@ -52,6 +53,8 @@ class CParticleElectric : public CParticleGen { rstl::optional_object< CVector3f > x198_overrideFPos; rstl::optional_object< CVector3f > x1a8_overrideFVel; uchar x1b8_pad[0x2a0]; + + static ushort sSeed; }; CHECK_SIZEOF(CParticleElectric, 0x458) diff --git a/include/MetroidPrime/CActor.hpp b/include/MetroidPrime/CActor.hpp index 3634a5b7d..095284c7c 100644 --- a/include/MetroidPrime/CActor.hpp +++ b/include/MetroidPrime/CActor.hpp @@ -214,9 +214,14 @@ class CActor : public CEntity { const CAABox& GetRenderBoundsCached() const { return x9c_renderBounds; } void SetRenderBounds(const CAABox& bounds) { x9c_renderBounds = bounds; } + TUniqueId GetDrawParent() const { return xc6_nextDrawNode; } + uint GetDrawToken() const { return xc8_drawnToken; } + uint GetAddedToken() const { return xcc_addedToken; } + void SetDrawToken(uint token) const { const_cast< CActor* >(this)->xc8_drawnToken = token; } void SetAddedToken(unsigned int token) const { const_cast< CActor* >(this)->xcc_addedToken = token; } + bool IsDrawEnabled() const { return xe7_29_drawEnabled; } bool GetUseInSortedLists() const; void SetUseInSortedLists(bool use); diff --git a/include/MetroidPrime/CDecalManager.hpp b/include/MetroidPrime/CDecalManager.hpp index 4de95f809..ae7a7bafb 100644 --- a/include/MetroidPrime/CDecalManager.hpp +++ b/include/MetroidPrime/CDecalManager.hpp @@ -6,6 +6,8 @@ #include "rstl/optional_object.hpp" #include "rstl/reserved_vector.hpp" +class CStateManager; + class CDecalManager { public: struct SDecal { @@ -20,6 +22,7 @@ class CDecalManager { static void Initialize(); static void ShutDown(); static void Reinitialize(); + static void Update(float dt, CStateManager& mgr); static bool mbPoolInitialized; static rstl::reserved_vector< SDecal, 64 > mDecalPool; diff --git a/include/MetroidPrime/CEntity.hpp b/include/MetroidPrime/CEntity.hpp index 9536fe787..423d451f5 100644 --- a/include/MetroidPrime/CEntity.hpp +++ b/include/MetroidPrime/CEntity.hpp @@ -30,6 +30,8 @@ class CEntity { const TAreaId GetAreaId() const; const TAreaId GetCurrentAreaId() const { return x4_areaId; } const bool GetActive() const { return x30_24_active; } + bool IsInGraveyard() const { return x30_25_inGraveyard; } + void SetIsInGraveyard() { x30_25_inGraveyard = true; } bool IsScriptingBlocked() const { return x30_26_scriptingBlocked; } // might be fake? diff --git a/include/MetroidPrime/CGameArea.hpp b/include/MetroidPrime/CGameArea.hpp index ada0c9a3c..3fa6dc6b0 100644 --- a/include/MetroidPrime/CGameArea.hpp +++ b/include/MetroidPrime/CGameArea.hpp @@ -194,7 +194,9 @@ class CGameArea : public IGameArea { const u8* x10d4_firstMatPtr; const CScriptAreaAttributes* x10d8_areaAttributes; EOcclusionState x10dc_occlusionState; - uchar x10e0_pad[0x3c]; + uint x10e0_; + float x10e4_occludedTime; + uchar x10e8_pad[0x34]; float x111c_thermalCurrent; float x1120_thermalSpeed; float x1124_thermalTarget; @@ -217,6 +219,7 @@ class CGameArea : public IGameArea { TAreaId GetId() const { return x4_selfIdx; } const CTransform4f& GetTM() const { return xc_transform; } + const CTransform4f& GetInverseTransform() const { return x3c_invTransform; } bool IsLoaded() const { return xf0_24_postConstructed; } bool IsActive() const { return xf0_25_active; } bool IsValidated() const { return xf0_28_validated; } @@ -228,6 +231,9 @@ class CGameArea : public IGameArea { void SetThermalSpeedAndTarget(float speed, float target); void SetWeaponWorldLighting(float speed, float target); + float GetXRayFogDistance(); + rstl::pair< const uchar*, uint > GetLayerScriptBuffer(const int& layer); + void SetAreaAttributes(CScriptAreaAttributes* areaAttributes); bool TryTakingOutOfARAM(); diff --git a/include/MetroidPrime/CHealthInfo.hpp b/include/MetroidPrime/CHealthInfo.hpp index 15e53aba4..4a7932809 100644 --- a/include/MetroidPrime/CHealthInfo.hpp +++ b/include/MetroidPrime/CHealthInfo.hpp @@ -12,6 +12,7 @@ class CHealthInfo { void SetHP(float hp) { x0_health = hp; } void SetKnockbackResistance(float resist) { x4_knockbackResistance = resist; } float GetHP() const { return x0_health; } + float GetKnockBackResistance() const { return x4_knockbackResistance; } private: float x0_health; diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index be4b34196..10643aedd 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -281,6 +281,7 @@ class CStateManager : public TOneStatic< CStateManager > { // Fog void SetupFogForArea3XRange(TAreaId area) const; + void SetupFogForArea3XRange(const CGameArea& area) const; void SetupFogForArea(TAreaId area) const; void SetupFogForArea(const CGameArea&) const; bool SetupFogForDraw() const; @@ -459,7 +460,7 @@ class CStateManager : public TOneStatic< CStateManager > { void UpdateHintState(float dt); void MovePlatforms(float dt); void MoveDoors(float dt); - void CrossTouchActors(float dt); + void CrossTouchActors(); void Think(float dt); void PreThinkObjects(float dt); void UpdateRoomAcoustics(TAreaId areaId); @@ -470,6 +471,7 @@ class CStateManager : public TOneStatic< CStateManager > { void ProcessRadiusDamage(const CActor&, CActor&, TUniqueId, const CDamageInfo&, const CMaterialFilter&); void ApplyRadiusDamage(const CActor&, const CVector3f&, CActor&, const CDamageInfo&); + bool TestRayDamage(const CVector3f&, const CActor&, const TEntityList&) const; bool MultiRayCollideWorld(const CMRay&, const CMaterialFilter&); void TestBombHittingWater(const CActor&, const CVector3f&, CActor&); rstl::optional_object< CAABox > CalculateObjectBounds(const CActor&); diff --git a/include/MetroidPrime/CWorld.hpp b/include/MetroidPrime/CWorld.hpp index cbe172131..4a7114c60 100644 --- a/include/MetroidPrime/CWorld.hpp +++ b/include/MetroidPrime/CWorld.hpp @@ -73,11 +73,6 @@ class CWorld final : public IWorld { CSoundGroupData(int grpId, CAssetId agsc); }; - enum EAreaTravelType { - kATT_Zero, - kATT_One, - }; - enum EChain { kC_Invalid = -1, kC_ToDeallocate, @@ -108,7 +103,9 @@ class CWorld final : public IWorld { void UnloadSoundGroups(); bool ScheduleAreaToLoad(CGameArea* area, CStateManager& mgr); void MoveToChain(CGameArea* area, EChain chain); - void TravelToArea(TAreaId aid, CStateManager& mgr, EAreaTravelType type); + void TravelToArea(const TAreaId& aid, CStateManager& mgr, bool skipLoadOther); + void Update(float dt); + void PreRender(); CMapWorld* GetMapWorld() const; void LoadSoundGroups(); void LoadSoundGroup(uchar groupId, CAssetId agscId, CSoundGroupData& data); @@ -136,6 +133,7 @@ class CWorld final : public IWorld { return CGameArea::CConstChainIterator(x4c_chainHeads[size_t(chain)]); } static CGameArea::CConstChainIterator GetAliveAreasEnd(); + static CGameArea::CChainIterator AliveAreasEnd(); void StopGlobalSound(ushort soundId); int GetNumAreas() const { return x18_areas.size(); } @@ -147,6 +145,9 @@ class CWorld final : public IWorld { private: + static CGameArea::CConstChainIterator skGlobalEnd; + static CGameArea::CChainIterator skGlobalNonConstEnd; + enum Phase { kP_Loading, kP_LoadingMap, diff --git a/include/MetroidPrime/Cameras/CCameraManager.hpp b/include/MetroidPrime/Cameras/CCameraManager.hpp index ac300b285..d02329596 100644 --- a/include/MetroidPrime/Cameras/CCameraManager.hpp +++ b/include/MetroidPrime/Cameras/CCameraManager.hpp @@ -92,6 +92,9 @@ class CCameraManager { void SetCurrentFov(float fov) { x3bc_curFov = fov; } + CGameArea::CAreaFog& Fog() { return x3c_fog; } + const CGameArea::CAreaFog& GetFog() const { return x3c_fog; } + int GetFluidCounter() const { return x74_fluidCounter; } TUniqueId GetFluidId() const { return x78_fluidId; } bool GetInsideFluid() const { return x74_fluidCounter == 0; } diff --git a/include/MetroidPrime/Enemies/CWallCrawlerSwarm.hpp b/include/MetroidPrime/Enemies/CWallCrawlerSwarm.hpp index 7d8fb2c0b..1f30774a9 100644 --- a/include/MetroidPrime/Enemies/CWallCrawlerSwarm.hpp +++ b/include/MetroidPrime/Enemies/CWallCrawlerSwarm.hpp @@ -32,6 +32,8 @@ class CWallCrawlerSwarm : public CActor { void Accept(IVisitor& visitor) override; + void ApplyRadiusDamage(const CVector3f& pos, const CDamageInfo& info, CStateManager& mgr); + CVector3f GetLastKilledOffset() const { return x130_lastKilledOffset; } private: diff --git a/include/MetroidPrime/Player/CGameState.hpp b/include/MetroidPrime/Player/CGameState.hpp index 271d8e4a6..2bd4d7851 100644 --- a/include/MetroidPrime/Player/CGameState.hpp +++ b/include/MetroidPrime/Player/CGameState.hpp @@ -25,6 +25,8 @@ class CGameState { void WriteSystemOptions(COutputStream& out); void SetCurrentWorldId(CAssetId); + void SetDeferPowerupInit(bool); + void SetTotalPlayTime(double); rstl::rc_ptr< CPlayerState >& PlayerState(); CAssetId CurrentWorldAssetId() const; @@ -47,6 +49,9 @@ class CGameState { void SetCardSerial(u64 serial) { x210_cardSerial = serial; } u64 GetCardSerial() const { return x210_cardSerial; } bool GetHardMode() const { return x228_24_hardMode; } + bool GetInitPowerupsAtFirstSpawn() const { return x228_25_initPowerupsAtFirstSpawn; } + double GetTotalPlayTime() const { return xa0_playTime; } + float GetHardModeDamageMultiplier() const; float GetHardModeWeaponMultiplier() const; rstl::rc_ptr< CWorldTransManager >& WorldTransitionManager(); // { return x9c_transManager.GetPtr(); } diff --git a/include/MetroidPrime/Player/CHintOptions.hpp b/include/MetroidPrime/Player/CHintOptions.hpp index aa1b762ad..011795dc3 100644 --- a/include/MetroidPrime/Player/CHintOptions.hpp +++ b/include/MetroidPrime/Player/CHintOptions.hpp @@ -26,6 +26,7 @@ class CHintOptions { void DelayHint(const rstl::string& name); void ActivateImmediateHintTimer(const rstl::string& name); void ActivateContinueDelayHintTimer(const rstl::string& name); + void DismissDisplayedHint(); const SHintState* GetCurrentDisplayedHint() const; int GetNextHintIdx(); diff --git a/include/MetroidPrime/Player/CPlayer.hpp b/include/MetroidPrime/Player/CPlayer.hpp index 35a1928ad..39906c7a1 100644 --- a/include/MetroidPrime/Player/CPlayer.hpp +++ b/include/MetroidPrime/Player/CPlayer.hpp @@ -306,6 +306,7 @@ class CPlayer : public CPhysicsActor, public TOneStatic< CPlayer > { void UpdateFreeLook(float dt); void UpdatePlayerHints(CStateManager& mgr); void UpdateBombJumpStuff(); + void BombJump(const CVector3f& pos, CStateManager& mgr); void UpdateTransitionFilter(float dt, CStateManager& mgr); void CalculatePlayerMovementDirection(float dt); void UpdatePlayerControlDirection(float dt, CStateManager& mgr); @@ -397,9 +398,11 @@ class CPlayer : public CPhysicsActor, public TOneStatic< CPlayer > { // CPlayer::GetFlipSpiderBallControlY() const weak // CPlayer::GetFlipSpiderBallControlX() const weak float GetDeathTime() const { return x9f4_deathTime; } // name? + void SetAccelerationChangeTimer(float time) { x2d4_accelerationChangeTimer = time; } bool IsCrosshairsOpen() const { return x9c4_25_showCrosshairs; } bool IsInsideFluid() const { return x9c4_31_inWaterMovement; } + bool GetDisableInput() const { return x9c6_29_disableInput; } void Teleport(const CTransform4f& xf, CStateManager& mgr, const bool resetBallCam); void SetSpawnedMorphBallState(const EPlayerMorphBallState state, CStateManager& mgr); diff --git a/include/MetroidPrime/Player/CPlayerState.hpp b/include/MetroidPrime/Player/CPlayerState.hpp index d5f3fb04c..64ad412f9 100644 --- a/include/MetroidPrime/Player/CPlayerState.hpp +++ b/include/MetroidPrime/Player/CPlayerState.hpp @@ -132,6 +132,7 @@ class CPlayerState { void StartTransitionToVisor(EPlayerVisor visor); void ResetVisor(); bool IsAlive() const { return x0_24_alive; } + void SetPlayerAlive(bool alive) { x0_24_alive = alive; } const bool ItemEnabled(const EItemType type) const; void DisableItem(const EItemType type); diff --git a/include/MetroidPrime/Player/CSystemState.hpp b/include/MetroidPrime/Player/CSystemState.hpp index f62b96e74..0dab4e1df 100644 --- a/include/MetroidPrime/Player/CSystemState.hpp +++ b/include/MetroidPrime/Player/CSystemState.hpp @@ -27,6 +27,7 @@ class CSystemState { bool GetShowPowerBombAmmoMessage() const; void IncrementPowerBombAmmoCount(); + void IncrementFrozenBallCount(); bool GetAllItemsCollected() const { return xd0_29_allItemsCollected; } void SetAllItemsCollected(bool); diff --git a/include/MetroidPrime/Player/CWorldState.hpp b/include/MetroidPrime/Player/CWorldState.hpp index ad6e9736a..d724e79b6 100644 --- a/include/MetroidPrime/Player/CWorldState.hpp +++ b/include/MetroidPrime/Player/CWorldState.hpp @@ -2,6 +2,7 @@ #define _CWORLDSTATE #include "Kyoto/SObjectTag.hpp" +#include "MetroidPrime/TGameTypes.hpp" namespace rstl { template < typename T > @@ -14,6 +15,7 @@ class CWorldState { public: ~CWorldState(); void SetDesiredAreaAssetId(CAssetId id); + void SetAreaId(TAreaId id); rstl::rc_ptr< CMapWorldInfo >& MapWorldInfo(); rstl::rc_ptr< CMapWorldInfo > GetMapWorldInfo() const; diff --git a/include/MetroidPrime/ScriptObjects/CScriptEffect.hpp b/include/MetroidPrime/ScriptObjects/CScriptEffect.hpp index 4585f49d5..a665cc878 100644 --- a/include/MetroidPrime/ScriptObjects/CScriptEffect.hpp +++ b/include/MetroidPrime/ScriptObjects/CScriptEffect.hpp @@ -21,6 +21,8 @@ class CScriptEffect : public CActor { float rateCamDistRangeFarRate, bool combatVisorVisible, bool thermalVisorVisible, bool xrayVisorVisible, const CLightParameters& lParms, bool dieWhenSystemsDone); + static void ResetParticleCounts(); + private: TLockedToken< CElectricDescription > xe8_electricToken; rstl::single_ptr< CParticleElectric > xf4_electric; diff --git a/include/MetroidPrime/ScriptObjects/CScriptPlayerActor.hpp b/include/MetroidPrime/ScriptObjects/CScriptPlayerActor.hpp index d452590b3..dd0ab20cf 100644 --- a/include/MetroidPrime/ScriptObjects/CScriptPlayerActor.hpp +++ b/include/MetroidPrime/ScriptObjects/CScriptPlayerActor.hpp @@ -35,7 +35,7 @@ class CScriptPlayerActor : public CScriptActor { void AddToRenderer(const CFrustumPlanes&, const CStateManager&) const override; void Render(const CStateManager&) const override; - void TouchModels(const CStateManager& mgr) const; + void TouchModels(const CStateManager& mgr); private: uint GetSuitCharIdx(const CStateManager& mgr, CPlayerState::EPlayerSuit suit) const; diff --git a/include/MetroidPrime/ScriptObjects/CSnakeWeedSwarm.hpp b/include/MetroidPrime/ScriptObjects/CSnakeWeedSwarm.hpp index 83a83eb28..d8821ef4f 100644 --- a/include/MetroidPrime/ScriptObjects/CSnakeWeedSwarm.hpp +++ b/include/MetroidPrime/ScriptObjects/CSnakeWeedSwarm.hpp @@ -20,6 +20,8 @@ class CSnakeWeedSwarm : public CActor { void Accept(IVisitor& visitor) override; + void ApplyRadiusDamage(const CVector3f& pos, const CDamageInfo& info, CStateManager& mgr); + private: uchar xe8_pad[0x208 - 0xe8]; }; diff --git a/include/rstl/string.hpp b/include/rstl/string.hpp index b8a84ecde..208ff7051 100644 --- a/include/rstl/string.hpp +++ b/include/rstl/string.hpp @@ -99,6 +99,7 @@ class basic_string { ~basic_string() { internal_dereference(); } size_t size() const { return x8_size; } + int refcount() { return x4_cow != nullptr ? x4_cow->x4_refCount : -1; } void reserve(int len) { internal_prepare_to_write(len, true); } void assign(const basic_string&); diff --git a/src/MetaRender/CCubeRenderer.cpp b/src/MetaRender/CCubeRenderer.cpp index 01cb52d26..dd1aa2453 100644 --- a/src/MetaRender/CCubeRenderer.cpp +++ b/src/MetaRender/CCubeRenderer.cpp @@ -2138,8 +2138,7 @@ void CCubeRenderer::DoThermalModelDraw(const CCubeModel& model, const CColor& mu void CCubeRenderer::DrawThermalModel(const CModel& model, const CColor& mulCol, const CColor& addCol, const float* pos, const float* nrm, const CModelFlags& flags) { - const CCubeModel* modelInst = *reinterpret_cast< const CCubeModel* const* >( - reinterpret_cast< const uchar* >(&model) + 0x28); + const CCubeModel* modelInst = model.GetCubeModel(); model.UpdateLastFrame(); DoThermalModelDraw(*modelInst, mulCol, addCol, pos, nrm, flags); } @@ -2165,10 +2164,8 @@ void CCubeRenderer::DrawModelDisintegrate(const CModel& model, const CTexture& t CGX::SetTevKColorSel(GX_TEVSTAGE1, GX_TEV_KCSEL_K0); CGX::SetTevKColor(GX_KCOLOR0, color.GetGXColor()); - const CCubeModel* modelInst = *reinterpret_cast< const CCubeModel* const* >( - reinterpret_cast< const uchar* >(&model) + 0x28); - const CAABox& modelBounds = - *reinterpret_cast< const CAABox* >(reinterpret_cast< const uchar* >(modelInst) + 0x20); + const CCubeModel* modelInst = model.GetCubeModel(); + const CAABox& modelBounds = modelInst->GetBoundingBox(); const CRelAngle rotateAng(-0.7853982f); CTransform4f rotateXf = CTransform4f::RotateX(rotateAng); @@ -2250,8 +2247,7 @@ void CCubeRenderer::DrawModelFlat(const CModel& model, const CModelFlags& flags, CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_KONST); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); - CGX::SetTevKColor(GX_KCOLOR0, *reinterpret_cast< const GXColor* >( - reinterpret_cast< const uchar* >(&flags) + 4)); + CGX::SetTevKColor(GX_KCOLOR0, flags.GetColorRef().GetGXColor()); CGX::SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0); CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL); @@ -2260,8 +2256,7 @@ void CCubeRenderer::DrawModelFlat(const CModel& model, const CModelFlags& flags, CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_POS, GX_IDENTITY, false, GX_PTIDENTITY); model.UpdateLastFrame(); - const CCubeModel* modelInst = *reinterpret_cast< const CCubeModel* const* >( - reinterpret_cast< const uchar* >(&model) + 0x28); + const CCubeModel* modelInst = model.GetCubeModel(); modelInst->DrawFlat(pos, nrm, unsortedOnly ? kSS_Unsorted : kSS_All); } @@ -2302,8 +2297,7 @@ void CCubeRenderer::DrawAreaGeometry(int areaIdx, uint mask, uint targetMask) { continue; } - if (!x44_frustumPlanes.BoxInFrustumPlanes(*reinterpret_cast< const CAABox* >( - reinterpret_cast< const uchar* >(&model) + 0x20))) { + if (!x44_frustumPlanes.BoxInFrustumPlanes(model.GetBoundingBox())) { continue; } @@ -2354,8 +2348,7 @@ CAABox CCubeRenderer::GetAreaModelBounds(int areaIdx, int modelIdx) { const rstl::vector< rstl::auto_ptr< CCubeModel > >& models = *areaIt->GetModelList(); for (AUTO(modelIt, models.begin()); modelIt != models.end(); ++modelIt, ++idx) { if (idx == modelIdx) { - return *reinterpret_cast< const CAABox* >( - reinterpret_cast< const uchar* >(modelIt->get()) + 0x20); + return modelIt->get()->GetBoundingBox(); } } } diff --git a/src/MetroidPrime/CStateManager.cpp b/src/MetroidPrime/CStateManager.cpp index 93987bd9f..047bc7113 100644 --- a/src/MetroidPrime/CStateManager.cpp +++ b/src/MetroidPrime/CStateManager.cpp @@ -38,7 +38,9 @@ #include "MetroidPrime/ScriptObjects/CScriptDoor.hpp" #include "MetroidPrime/ScriptObjects/CScriptEffect.hpp" #include "MetroidPrime/ScriptObjects/CScriptMazeNode.hpp" +#include "MetroidPrime/ScriptObjects/CScriptPlayerActor.hpp" #include "MetroidPrime/ScriptObjects/CScriptRoomAcoustics.hpp" +#include "MetroidPrime/ScriptObjects/CSnakeWeedSwarm.hpp" #include "MetroidPrime/ScriptObjects/CScriptSpawnPoint.hpp" #include "MetroidPrime/ScriptObjects/CScriptSpecialFunction.hpp" #include "MetroidPrime/ScriptObjects/CScriptWater.hpp" @@ -69,6 +71,7 @@ #include "Kyoto/Math/CRelAngle.hpp" #include "Kyoto/Math/CUnitVector3f.hpp" #include "Kyoto/Streams/CMemoryInStream.hpp" +#include "Kyoto/Particles/CParticleElectric.hpp" #include "MetaRender/CCubeRenderer.hpp" #include "Weapons/CDecal.hpp" #include "WorldFormat/CPVSAreaSet.hpp" @@ -121,58 +124,9 @@ static char init = 0; } // namespace -extern "C" void TouchModels__18CScriptPlayerActorFRC13CStateManager(void*, const CStateManager&); -extern "C" void ConvertToScreenSpace__11CGameCameraCFRC9CVector3f(CVector3f*, const CGameCamera*, - const CVector3f*); -extern "C" void DrawReflection__13CStateManagerFRC9CVector3f(CStateManager*, const CVector3f&); -extern "C" void -SetNewPlayerPositionAndTime__10CCubeModelFRC9CVector3fRC10CStopwatch(const CVector3f&, - const CStopwatch&); -extern "C" CGameArea::CChainIterator AliveAreasEnd__6CWorldFv(); -extern "C" void ResetParticleCounts__13CScriptEffectFv(); -extern "C" void Update__15CCameraBlurPassFf(CCameraBlurPass*, float); -extern "C" void Update__13CDecalManagerFfR13CStateManager(float, CStateManager*); -extern "C" void Update__6CWorldFf(CWorld*, float); -extern "C" void PreRender__6CWorldFv(CWorld*); -extern "C" void Update__13CEnvFxManagerFfR13CStateManager(float, CEnvFxManager*, CStateManager*); -extern "C" void AsyncLoadResources__13CEnvFXManagerFR13CStateManager(CEnvFxManager*, - CStateManager*); -extern "C" void DismissDisplayedHint__12CHintOptionsFv(CHintOptions*); -extern "C" void CrossTouchActors__13CStateManagerFf(CStateManager*); -extern "C" void TravelToArea__6CWorldFRC7TAreaIdR13CStateManagerb(CWorld*, const TAreaId&, - CStateManager*, bool); -extern "C" void SetTotalPlayTime__10CGameStateFd(CGameState*, double); -extern "C" void SetDeferPowerupInit__10CGameStateFb(CGameState*, bool); -extern "C" void SetAreaId__11CWorldStateF7TAreaId(CWorldState*, TAreaId); -extern "C" float GetXRayFogDistance__9CGameAreaFv(CGameArea*); -extern "C" ushort lbl_805A88B8; -extern "C" ushort lbl_805A8A10; -extern "C" s64 lbl_805A8D98; -extern "C" uint lbl_805A8D9C; -extern "C" CGameArea* lbl_805A8DDC; -extern "C" float lbl_805AA2D4; -extern "C" void fn_80046DE8(const CStateManager*, const CGameArea*); -extern "C" void fn_8004B504(CStateManager*); -extern "C" float GetHardModeDamageMultiplier__10CGameStateCFv(const CGameState*); -extern "C" void IncrementFrozenBallCount__12CSystemStateFv(CSystemState*); -extern "C" float BombJump__7CPlayerFRC9CVector3fR13CStateManager(CPlayer*, const CVector3f*, - CStateManager*); -extern "C" void ApplyRadiusDamage__17CWallCrawlerSwarmF9CVector3ffR13CStateManager( - CWallCrawlerSwarm*, const CVector3f*, const CDamageInfo*, CStateManager*); -extern "C" void ApplyRadiusDamage__15CSnakeWeedSwarmF9CVector3ffR13CStateManager(CSnakeWeedSwarm*, - const CVector3f*, - const CDamageInfo*, - CStateManager*); - -extern bool TestRayDamage(const CStateManager&, const CVector3f&, const CActor&, - const TEntityList&); - -struct SScriptLayerBuffer { - const void* x0_buf; - uint x4_len; -}; +extern "C" void nullsub_34(CStateManager*); -extern "C" void GetLayerScriptBuffer__9CGameAreaFi(SScriptLayerBuffer*, CGameArea*, int*); +static s64 sPreRenderStepTime; class CLightPredicate { public: @@ -662,11 +616,11 @@ void CStateManager::DeleteObjectRequest(TUniqueId uid) { if (ent == nullptr) { return; } - if ((*reinterpret_cast< const uchar* >(reinterpret_cast< const uchar* >(ent) + 0x30) >> 6) & 1) { + if (ent->IsInGraveyard()) { return; } - ent->x30_25_inGraveyard = true; + ent->SetIsInGraveyard(); if (x854_graveyard.size() == 0) { rstl::reserved_vector< TUniqueId, 32 > newVec; @@ -853,8 +807,8 @@ void CStateManager::InitializeState(unsigned int mlvlId, TAreaId aid, unsigned i } SetCurrentAreaId(x8cc_nextAreaId); - SetAreaId__11CWorldStateF7TAreaId(&gpGameState->CurrentWorldState(), x8cc_nextAreaId); - TravelToArea__6CWorldFRC7TAreaIdR13CStateManagerb(x850_world.get(), x8cc_nextAreaId, this, true); + gpGameState->CurrentWorldState().SetAreaId(x8cc_nextAreaId); + x850_world->TravelToArea(x8cc_nextAreaId, *this, true); UpdateRoomAcoustics(x8cc_nextAreaId); CObjectList* allList = x808_objectLists[kOL_All].get(); @@ -874,10 +828,8 @@ void CStateManager::InitializeState(unsigned int mlvlId, TAreaId aid, unsigned i x84c_player->Teleport(lookAt, *this, true); } - const uchar gameStateFlags = - *reinterpret_cast< const uchar* >(reinterpret_cast< const uchar* >(gpGameState) + 0x228); - if (((gameStateFlags >> 6) & 1) != 0) { - SetDeferPowerupInit__10CGameStateFb(gpGameState, false); + if (gpGameState->GetInitPowerupsAtFirstSpawn()) { + gpGameState->SetDeferPowerupInit(false); for (int i = CPlayerState::kIT_PowerBeam; i < CPlayerState::kIT_Max; ++i) { CPlayerState::EItemType itemType = static_cast< CPlayerState::EItemType >(i); @@ -912,7 +864,7 @@ void CStateManager::InitializeState(unsigned int mlvlId, TAreaId aid, unsigned i x900_random = nullptr; } - AsyncLoadResources__13CEnvFXManagerFR13CStateManager(x880_envFxManager, this); + x880_envFxManager->AsyncLoadResources(*this); } void CStateManager::FrameBegin(unsigned int frame) { @@ -964,8 +916,7 @@ void CStateManager::MoveDoors(float dt) { const CGameArea& area = x850_world->GetAreaAlways(areaId2); float occTime; if (area.IsPostConstructed()) { - occTime = *reinterpret_cast< const float* >( - reinterpret_cast< const uchar* >(area.GetPostConstructed()) + 0x10e4); + occTime = area.GetPostConstructed()->x10e4_occludedTime; } else { occTime = 0.f; } @@ -987,7 +938,7 @@ void CStateManager::MoveDoors(float dt) { } } -void CStateManager::CrossTouchActors(float) { +void CStateManager::CrossTouchActors() { bool visits[kMaxEntities]; memset(visits, 0, sizeof(visits)); TEntityList nearList; @@ -1032,8 +983,7 @@ void CStateManager::CrossTouchActors(float) { } void CStateManager::Think(float dt) { - const float deathTime = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(x84c_player) + 0x9f4); + const float deathTime = x84c_player->GetDeathTime(); if (deathTime > 0.f) { x84c_player->DoThink(dt, *this); return; @@ -1062,8 +1012,7 @@ void CStateManager::Think(float dt) { const CGameArea& area = x850_world->GetAreaAlways(areaId2); float occTime; if (area.IsPostConstructed()) { - occTime = *reinterpret_cast< const float* >( - reinterpret_cast< const uchar* >(area.GetPostConstructed()) + 0x10e4); + occTime = area.GetPostConstructed()->x10e4_occludedTime; } else { occTime = 0.f; } @@ -1086,8 +1035,7 @@ void CStateManager::Think(float dt) { } void CStateManager::PreThinkObjects(float dt) { - const float deathTime = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(x84c_player) + 0x9f4); + const float deathTime = x84c_player->GetDeathTime(); if (deathTime > 0.f) { x84c_player->DoPreThink(dt, *this); return; @@ -1116,8 +1064,8 @@ void CStateManager::PreThinkObjects(float dt) { void CStateManager::PostUpdatePlayer(float dt) { x84c_player->DoPostCameraStuff(dt, *this); } void CStateManager::Update(float dt) { - CElementGen::SetGlobalSeed( static_cast< ushort >(x8d8_updateFrameIdx)); - lbl_805A8A10 = static_cast< ushort >(x8d8_updateFrameIdx); + CElementGen::SetGlobalSeed(static_cast< ushort >(x8d8_updateFrameIdx)); + CParticleElectric::SetGlobalSeed(static_cast< ushort >(x8d8_updateFrameIdx)); CDecal::SetGlobalSeed(static_cast< ushort >(x8d8_updateFrameIdx)); CProjectileWeapon::SetGlobalSeed(x8d8_updateFrameIdx); @@ -1128,21 +1076,18 @@ void CStateManager::Update(float dt) { xf08_pauseHudMessage = kInvalidAssetId; - ResetParticleCounts__13CScriptEffectFv(); + CScriptEffect::ResetParticleCounts(); UpdateThermalVisor(); - fn_8004B504(this); + nullsub_34(this); UpdateGameState(); - const float deathTime = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(x84c_player) + 0x9f4); + const float deathTime = x84c_player->GetDeathTime(); const bool isDead = deathTime > 0.f; if (x904_gameState == kGS_Running) { if (TCastToPtr< CCinematicCamera >( const_cast< CGameCamera& >(x870_cameraManager->GetCurrentCamera(*this))) == nullptr) { - SetTotalPlayTime__10CGameStateFd( - gpGameState, dt + *reinterpret_cast< const double* >( - reinterpret_cast< const uchar* >(gpGameState) + 0xa0)); + gpGameState->SetTotalPlayTime(dt + gpGameState->GetTotalPlayTime()); UpdateHintState(dt); } @@ -1150,7 +1095,7 @@ void CStateManager::Update(float dt) { CCameraBlurPass* blur = xd14_camBlurPasses.data(); for (int i = 0; i < kCFS_Max; ++i) { filt->Update(dt); - Update__15CCameraBlurPassFf(blur, dt); + blur->Update(dt); ++filt; ++blur; } @@ -1163,7 +1108,7 @@ void CStateManager::Update(float dt) { if (x904_gameState == kGS_Running) { if (!isDead) { - Update__13CDecalManagerFfR13CStateManager(dt, this); + CDecalManager::Update(dt, *this); } UpdateSortedLists(); @@ -1182,7 +1127,7 @@ void CStateManager::Update(float dt) { UpdateSortedLists(); if (!isDead) { - CrossTouchActors__13CStateManagerFf(this); + CrossTouchActors(); } } else { ProcessPlayerInput(); @@ -1224,11 +1169,11 @@ void CStateManager::Update(float dt) { UpdateEscapeSequenceTimer(dt); } - Update__6CWorldFf(x850_world.get(), dt); + x850_world->Update(dt); x88c_rumbleManager->Update(dt); if (!isDead) { - Update__13CEnvFxManagerFfR13CStateManager(dt, x880_envFxManager, this); + x880_envFxManager->Update(dt, *this); } UpdateAreaSounds(); @@ -1240,14 +1185,14 @@ void CStateManager::Update(float dt) { CHintOptions::SHintState* hint = const_cast< CHintOptions::SHintState* >(hintOptions.GetCurrentDisplayedHint()); if (hint != nullptr && hint->CanContinue()) { - DismissDisplayedHint__12CHintOptionsFv(&hintOptions); + hintOptions.DismissDisplayedHint(); } xf94_27_inMapScreen = false; } - SetAreaId__11CWorldStateF7TAreaId(&gpGameState->CurrentWorldState(), x8cc_nextAreaId); + gpGameState->CurrentWorldState().SetAreaId(x8cc_nextAreaId); - TravelToArea__6CWorldFRC7TAreaIdR13CStateManagerb(x850_world.get(), x8cc_nextAreaId, this, false); + x850_world->TravelToArea(x8cc_nextAreaId, *this, false); ClearGraveyard(); ++x8d8_updateFrameIdx; @@ -1260,9 +1205,7 @@ void CStateManager::ProcessInput(const CFinalInput& input) { const CGameCamera& cam = x870_cameraManager->GetCurrentCamera(*this); bool disableInput = cam.DisablesInput(); - const uchar playerFlags = - *reinterpret_cast< const uchar* >(reinterpret_cast< const uchar* >(x84c_player) + 0x9c6); - if ((playerFlags >> 2) & 1) { + if (x84c_player->GetDisableInput()) { disableInput = true; } @@ -1363,8 +1306,7 @@ void CStateManager::ApplyDamage(const TUniqueId damagerId, const TUniqueId damag CWallCrawlerSwarm* swarm = TCastToPtr< CWallCrawlerSwarm >(damageeEnt); if (swarm != nullptr && damager != nullptr) { const CVector3f damagerPos = damager->GetTranslation(); - ApplyRadiusDamage__17CWallCrawlerSwarmF9CVector3ffR13CStateManager(swarm, &damagerPos, &info, - this); + swarm->ApplyRadiusDamage(damagerPos, info, *this); } } } @@ -1393,7 +1335,7 @@ bool CStateManager::ApplyLocalDamage(const CVector3f& pos, const CVector3f& dir, } if (gpGameState->GetHardMode()) { - useDamage *= GetHardModeDamageMultiplier__10CGameStateCFv(gpGameState); + useDamage *= gpGameState->GetHardModeDamageMultiplier(); } float damageReduction = 0.f; @@ -1421,10 +1363,7 @@ bool CStateManager::ApplyLocalDamage(const CVector3f& pos, const CVector3f& dir, if (player != nullptr) { player->TakeDamage(significant, pos, useDamage, weaponMode.GetType(), *this); if (newHp <= 0.f) { - struct SPlayerStateFlags { - bool x0_24_alive : 1; - }; - reinterpret_cast< SPlayerStateFlags* >(x8b8_playerState.GetPtr())->x0_24_alive = false; + x8b8_playerState->SetPlayerAlive(false); } } else if (ai != nullptr) { if (significant) { @@ -1498,12 +1437,9 @@ void CStateManager::TestBombHittingWater(const CActor& damager, const CVector3f& } bool CStateManager::MultiRayCollideWorld(const CMRay& ray, const CMaterialFilter& filter) { - const CVector3f& start = - *reinterpret_cast< const CVector3f* >(reinterpret_cast< const uchar* >(&ray) + 0x0); - const CVector3f& dir = - *reinterpret_cast< const CVector3f* >(reinterpret_cast< const uchar* >(&ray) + 0x2c); - const float length = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(&ray) + 0x24); + const CVector3f& start = ray.GetStart(); + const CVector3f& dir = ray.GetDirection(); + const float length = ray.GetLength(); CVector3f crossed(-dir.GetZ() * dir.GetZ() - dir.GetY() * dir.GetX(), dir.GetX() * dir.GetX() - dir.GetZ() * dir.GetY(), @@ -1605,7 +1541,7 @@ void CStateManager::ProcessRadiusDamage(const CActor& damager, CActor& damagee, const TUniqueId actorId = actor->GetUniqueId(); if (damagerId != actorId && radiusSender != actorId && damageeId != actorId) { TestBombHittingWater(damager, pos, *actor); - if (TestRayDamage(*this, pos, *actor, nearList)) { + if (TestRayDamage(pos, *actor, nearList)) { ApplyRadiusDamage(damager, pos, *actor, info); } } @@ -1637,27 +1573,25 @@ void CStateManager::ApplyDamageToWorld(TUniqueId damagerId, const CActor& actor, if (bomb && player != nullptr) { if (player->GetFrozenState()) { - IncrementFrozenBallCount__12CSystemStateFv(&gpGameState->SystemState()); + gpGameState->SystemState().IncrementFrozenBallCount(); CSamusHud::DisplayHudMemo(rstl::wstring_l(L""), CHUDMemoParms(0.f, true, true, true)); player->BreakFrozenState(*this); } else if (weapon != nullptr && (weapon->GetAttribField() & CWeapon::kPA_Bombs) != 0) { - BombJump__7CPlayerFRC9CVector3fR13CStateManager(player, &pos, this); + player->BombJump(pos, *this); } } else if (act != nullptr && act->GetUniqueId() != damagerId) { TestBombHittingWater(actor, pos, *act); - if (TestRayDamage(*this, pos, *act, nearList)) { + if (TestRayDamage(pos, *act, nearList)) { ApplyRadiusDamage(actor, pos, *act, info); } } if (wallSwarm != nullptr) { - ApplyRadiusDamage__17CWallCrawlerSwarmF9CVector3ffR13CStateManager(wallSwarm, &pos, &info, - this); + wallSwarm->ApplyRadiusDamage(pos, info, *this); } if (snakeSwarm != nullptr) { - ApplyRadiusDamage__15CSnakeWeedSwarmF9CVector3ffR13CStateManager(snakeSwarm, &pos, &info, - this); + snakeSwarm->ApplyRadiusDamage(pos, info, *this); } } } @@ -1674,8 +1608,7 @@ void CStateManager::ApplyKnockBack(CActor& actor, const CDamageInfo& info, return; } - const float resistance = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(hInfo) + 0x4); + const float resistance = hInfo->GetKnockBackResistance(); const float dampedPower = (1.f - dampen) * info.GetKnockBackPower(); CPlayer* player = TCastToPtr< CPlayer >(actor); @@ -1736,7 +1669,7 @@ void CStateManager::KnockBackPlayer(CPlayer& player, const CVector3f& dir, float player.ApplyImpulseWR(dir * usePower, CAxisAngle::Identity()); player.UseCollisionImpulses(); - *reinterpret_cast< float* >(reinterpret_cast< uchar* >(&player) + 0x2d4) = 0.25f; + player.SetAccelerationChangeTimer(0.25f); const CVector3f velocity = player.GetVelocityWR(); const float velocityMag = velocity.Magnitude(); @@ -1835,11 +1768,9 @@ rstl::pair< TEditorId, TUniqueId > CStateManager::GenerateObject(const TEditorId CGameArea* area = x850_world->Area(aid); if (area->IsPostConstructed()) { int layer = static_cast< int >(build.second.value >> 26); - SScriptLayerBuffer layerBuf; - GetLayerScriptBuffer__9CGameAreaFi(&layerBuf, area, &layer); + const rstl::pair< const uchar*, uint > layerBuf = area->GetLayerScriptBuffer(layer); - CMemoryInStream stream(static_cast< const uchar* >(layerBuf.x0_buf) + - build.first->x4_position, + CMemoryInStream stream(layerBuf.first + build.first->x4_position, build.first->x8_length); return LoadScriptObject(aid, build.first->x0_type, build.first->x8_length, stream); } @@ -1992,18 +1923,15 @@ void CStateManager::SendScriptMsg(TUniqueId uid, TEditorId target, EScriptObject void CStateManager::RecursiveDrawTree(TUniqueId uid) const { CActor* actor = TCastToPtr< CActor >(const_cast< CEntity* >(GetObjectById(uid))); - if (actor != NULL && - x8dc_objectDrawToken != *reinterpret_cast< int* >(reinterpret_cast< uchar* >(actor) + 0xc8)) { - const TUniqueId nextNode = - *reinterpret_cast< TUniqueId* >(reinterpret_cast< uchar* >(actor) + 0xc6); + if (actor != NULL && x8dc_objectDrawToken != actor->GetDrawToken()) { + const TUniqueId nextNode = actor->GetDrawParent(); if (nextNode != kInvalidUniqueId) { RecursiveDrawTree(nextNode); } - if (x8dc_objectDrawToken == - *reinterpret_cast< int* >(reinterpret_cast< uchar* >(actor) + 0xcc)) { + if (x8dc_objectDrawToken == actor->GetAddedToken()) { actor->Render(*this); } - *reinterpret_cast< int* >(reinterpret_cast< uchar* >(actor) + 0xc8) = x8dc_objectDrawToken; + actor->SetDrawToken(x8dc_objectDrawToken); } } @@ -2062,18 +1990,15 @@ bool CStateManager::GetVisSetForArea(TAreaId areaA, TAreaId areaB, CPVSVisSet& s if (areaSet != nullptr) { setState = 2; - const uint worldAreaArg = *reinterpret_cast< const uint* >( - reinterpret_cast< const uchar* >(x850_world.get()) + 0x20); + const uint worldAreaArg = x850_world->GetNumAreas(); CPVSVisOctree& visOctree = *const_cast< CPVSVisOctree* >(&areaSet->GetVisOctree(worldAreaArg)); - const CTransform4f& invAreaXf = - *reinterpret_cast< const CTransform4f* >(reinterpret_cast< const uchar* >(area) + 0x3c); + const CTransform4f& invAreaXf = x850_world->GetArea(areaA)->GetInverseTransform(); const CVector3f localPoint = invAreaXf * closestDockPoint; CPVSVisSet visSet = visOctree.GetVisSet(localPoint); - if (*reinterpret_cast< const int* >(reinterpret_cast< const uchar* >(&visSet)) == - kVSS_NodeFound) { + if (visSet.GetState() == kVSS_NodeFound) { setOut = visSet; setState = 3; } @@ -2083,9 +2008,7 @@ bool CStateManager::GetVisSetForArea(TAreaId areaA, TAreaId areaB, CPVSVisSet& s return setState == 3; } -extern "C" CGameArea::CChainIterator AliveAreasEnd__6CWorldFv() { - return CGameArea::CChainIterator(lbl_805A8DDC); -} +CGameArea::CChainIterator CWorld::AliveAreasEnd() { return skGlobalNonConstEnd; } void CStateManager::PreRender() { CStateManager* mgr = this; @@ -2099,7 +2022,7 @@ void CStateManager::PreRender() { mgr->x86c_stateManagerContainer->xf39c_renderLast.clear(); mgr->xf7c_projectedShadow = nullptr; - PreRender__6CWorldFv(mgr->x850_world.get()); + mgr->x850_world->PreRender(); mgr->BuildDynamicLightListForWorld(); const CGameCamera& curCam = mgr->x870_cameraManager->GetCurrentCamera(*mgr); @@ -2108,7 +2031,7 @@ void CStateManager::PreRender() { curCam.GetNearClipDistance(), false, 100.f); for (CGameArea::CChainIterator areaIt = mgr->x850_world->ChainHead(CWorld::kC_Alive); - areaIt != AliveAreasEnd__6CWorldFv(); ++areaIt) { + areaIt != CWorld::AliveAreasEnd(); ++areaIt) { CGameArea::EOcclusionState occState; if (areaIt->IsPostConstructed()) { occState = areaIt->GetPostConstructed()->x10dc_occlusionState; @@ -2122,10 +2045,7 @@ void CStateManager::PreRender() { for (int i = areaObjList->GetFirstObjectIndex(); i != -1; i = areaObjList->GetNextObjectIndex(i)) { CActor* actor = TCastToPtr< CActor >((*areaObjList)[i]); - if (actor != nullptr && - ((*reinterpret_cast< const uchar* >(reinterpret_cast< const uchar* >(actor) + 0xe7) >> - 2) & - 1) != 0) { + if (actor != nullptr && actor->IsDrawEnabled()) { actor->CalculateRenderBounds(); actor->PreRender(*mgr, frustum); } @@ -2138,7 +2058,7 @@ void CStateManager::PreRender() { } gpRender->PrepareDynamicLights(mgr->x8e0_dynamicLights); - lbl_805A8D98 = timer.GetElapsedMicros(); + sPreRenderStepTime = timer.GetElapsedMicros(); } CFrustumPlanes CStateManager::SetupViewForDraw(const CViewport& viewport) const { @@ -2147,8 +2067,7 @@ CFrustumPlanes CStateManager::SetupViewForDraw(const CViewport& viewport) const gpRender->SetWorldViewpoint(camXf); const CVector3f playerPos = x84c_player->GetTranslation(); - SetNewPlayerPositionAndTime__10CCubeModelFRC9CVector3fRC10CStopwatch( - playerPos, CStopwatch::GetGlobalTimerObj()); + CCubeModel::SetNewPlayerPositionAndTime(playerPos, CStopwatch::GetGlobalTimerObj()); const float scaledWidth = xf2c_viewportScaleX * static_cast< float >(viewport.mWidth); const float scaledHeight = xf30_viewportScaleY * static_cast< float >(viewport.mHeight); @@ -2166,8 +2085,7 @@ CFrustumPlanes CStateManager::SetupViewForDraw(const CViewport& viewport) const gpRender->SetViewport(left, top, width, halfHeight * 2); CGraphics::SetDepthRange(0.125f, 1.f); - const float zFar = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(&cam) + 0x164); + const float zFar = cam.GetFarClipDistance(); gpRender->SetPerspective(360.f * ((1.f / (2.f * M_PIF)) * fov), scaledWidth, scaledHeight, cam.GetNearClipDistance(), zFar); @@ -2194,8 +2112,7 @@ bool CStateManager::SetupFogForDraw() const { return false; case CPlayerState::kPV_Combat: case CPlayerState::kPV_Scan: { - const CGameArea::CAreaFog* fog = reinterpret_cast< const CGameArea::CAreaFog* >( - reinterpret_cast< const uchar* >(x870_cameraManager) + 0x3c); + const CGameArea::CAreaFog* fog = &x870_cameraManager->GetFog(); if (fog->IsFogDisabled()) { return false; } @@ -2211,7 +2128,7 @@ void CStateManager::SetupFogForArea(const CGameArea& area) const { } if (x8b8_playerState->GetActiveVisor(*this) == CPlayerState::kPV_XRay) { - const float fogDist = GetXRayFogDistance__9CGameAreaFv(const_cast< CGameArea* >(&area)); + const float fogDist = const_cast< CGameArea& >(area).GetXRayFogDistance(); const CTweakGui* tweak = gpTweakGui; const float fogFarZ = tweak->GetXRayFogFarZ(); const float nearZ = tweak->GetXRayFogNearZ(); @@ -2223,6 +2140,21 @@ void CStateManager::SetupFogForArea(const CGameArea& area) const { } } +void CStateManager::SetupFogForArea3XRange(const CGameArea& area) const { + if (x8b8_playerState->GetActiveVisor(*this) != CPlayerState::kPV_XRay) { + return; + } + + const float fogDist = const_cast< CGameArea& >(area).GetXRayFogDistance(); + const CTweakGui* tweak = gpTweakGui; + const float invFogDist = 1.f - fogDist; + const float farTerm = tweak->GetXRayFogFarZ() * fogDist; + const float nearZ = tweak->GetXRayFogNearZ(); + const float farZ = (nearZ * invFogDist + farTerm) * 3.f; + gpRender->SetWorldFog(static_cast< ERglFogMode >(tweak->GetXRayFogMode()), nearZ, farZ, + tweak->GetXRayFogColor()); +} + void CStateManager::SetupFogForArea(TAreaId area) const { TAreaId areaValue; const TAreaId* areaId = &area; @@ -2251,10 +2183,12 @@ void CStateManager::SetupFogForArea3XRange(TAreaId area) const { areaValue = *areaId; const CGameArea* areaObj = x850_world->GetArea(areaValue); if (areaObj->IsPostConstructed()) { - fn_80046DE8(this, areaObj); + SetupFogForArea3XRange(*areaObj); } } +CGameArea::CConstChainIterator CWorld::GetAliveAreasEnd() { return skGlobalEnd; } + void CStateManager::DrawWorld() const { const CTimeProvider timeProvider(xf14_curTimeMod900); @@ -2301,8 +2235,7 @@ void CStateManager::ResetViewAfterDraw(const CViewport& backupViewport, gpRender->SetClippingPlanes(frustum); const CViewport& viewport = CGraphics::GetViewport(); - const float zFar = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(&cam) + 0x164); + const float zFar = cam.GetFarClipDistance(); gpRender->SetPerspective(cam.GetFov(), static_cast< float >(viewport.mWidth), static_cast< float >(viewport.mHeight), cam.GetNearClipDistance(), zFar); } @@ -2319,8 +2252,7 @@ void CStateManager::DrawAdditionalFilters() const { void CStateManager::DrawE3DeathEffect() const { const CPlayer* player = x84c_player; - const float deathTime = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(player) + 0x9f4); + const float deathTime = player->GetDeathTime(); float blurFactor; float whiteFactor; @@ -2335,7 +2267,7 @@ void CStateManager::DrawE3DeathEffect() const { } } - whiteFactor = 1.f - deathTime / (lbl_805AA2D4 * gkBallDeathTime); + whiteFactor = 1.f - deathTime / (0.05f * gkBallDeathTime); const float whiteAmt = CMath::Clamp(0.f, whiteFactor, 1.f); const CColor color = CColor::White().WithAlphaOf(whiteAmt); CCameraFilterPass::DrawFilter(CCameraFilterPass::kFT_Add, CCameraFilterPass::kFS_Fullscreen, @@ -2415,8 +2347,7 @@ void CStateManager::DrawReflection(const CVector3f& point) { const CGraphics::CProjectionState backupProj = CGraphics::GetProjectionState(); const CViewport& viewport = CGraphics::GetViewport(); - const float zFar = - *reinterpret_cast< const float* >(reinterpret_cast< const uchar* >(&curCam) + 0x164); + const float zFar = curCam.GetFarClipDistance(); gpRender->SetPerspective(curCam.GetFov(), static_cast< float >(viewport.mWidth), static_cast< float >(viewport.mHeight), curCam.GetNearClipDistance(), zFar); @@ -2437,9 +2368,7 @@ void CStateManager::DrawSpaceWarp(const CVector3f& point, float strength) const } const CGameCamera& curCam = x870_cameraManager->GetCurrentCamera(*this); - CVector3f screenPoint; - ConvertToScreenSpace__11CGameCameraCFRC9CVector3f(&screenPoint, &curCam, &point); - gpRender->DrawSpaceWarp(screenPoint, strength); + gpRender->DrawSpaceWarp(curCam.ConvertToScreenSpace(point), strength); } void CStateManager::TouchSky() const { x850_world->TouchSky(); } @@ -2448,7 +2377,7 @@ void CStateManager::TouchPlayerActor() const { if (xf6c_playerActorHead != kInvalidUniqueId) { const CEntity* ent = GetObjectById(xf6c_playerActorHead); if (ent != nullptr) { - TouchModels__18CScriptPlayerActorFRC13CStateManager(const_cast< CEntity* >(ent), *this); + static_cast< CScriptPlayerActor* >(const_cast< CEntity* >(ent))->TouchModels(*this); } } } @@ -2503,13 +2432,8 @@ void CStateManager::MurderScriptInstanceNames() { rstl::set< rstl::string >::iterator it = xb40_uniqueInstanceNames.begin(); rstl::set< rstl::string >::iterator end = xb40_uniqueInstanceNames.end(); for (; it != end; ++it) { - const rstl::string* str = *it; - const void* cow = - *reinterpret_cast< const void* const* >(reinterpret_cast< const uchar* >(str) + 0x4); - int refCount = -1; - if (cow != nullptr) { - refCount = *reinterpret_cast< const int* >(reinterpret_cast< const uchar* >(cow) + 0x4); - } + rstl::string* str = *it; + const int refCount = str->refcount(); if (refCount == 1) { xb40_uniqueInstanceNames.erase(it); @@ -2536,10 +2460,7 @@ void CStateManager::UpdateEscapeSequenceTimer(float dt) { if (xf0c_escapeTimer > 0.f) { xf0c_escapeTimer = rstl::max_val(gkEpsilon, xf0c_escapeTimer - dt); if (xf0c_escapeTimer <= FLT_EPSILON) { - struct SPlayerStateFlags { - bool x0_24_alive : 1; - }; - reinterpret_cast< SPlayerStateFlags* >(x8b8_playerState.GetPtr())->x0_24_alive = false; + x8b8_playerState->SetPlayerAlive(false); } if (!init) { @@ -2676,20 +2597,10 @@ void CStateManager::AddDrawableActorPlane(const CActor& actor, const CPlane& pla bool CStateManager::RenderLast(const TUniqueId& uid) { CStateManagerContainer* container = x86c_stateManagerContainer.get(); - CStateManagerContainer* bucket = container; - int count = *reinterpret_cast< int* >(reinterpret_cast< uchar* >(bucket) + 0xf39c); - if (count == 20) { + if (container->xf39c_renderLast.size() == 20) { return false; } - - TUniqueId* id = - reinterpret_cast< TUniqueId* >(reinterpret_cast< uchar* >(bucket) + 0xf3a0) + count; - if (id != nullptr) { - *id = uid; - } - - int* curCount = reinterpret_cast< int* >(reinterpret_cast< uchar* >(container) + 0xf39c); - *curCount = *curCount + 1; + container->xf39c_renderLast.push_back(uid); return true; } diff --git a/src/MetroidPrime/CWorld.cpp b/src/MetroidPrime/CWorld.cpp index 498dd06df..300069147 100644 --- a/src/MetroidPrime/CWorld.cpp +++ b/src/MetroidPrime/CWorld.cpp @@ -20,9 +20,8 @@ #include "MetroidPrime/TGameTypes.hpp" #include "rstl/vector.hpp" -static CGameArea::CConstChainIterator sAliveAreasEnd; - -CGameArea::CConstChainIterator CWorld::GetAliveAreasEnd() { return sAliveAreasEnd; } +CGameArea::CConstChainIterator CWorld::skGlobalEnd; +CGameArea::CChainIterator CWorld::skGlobalNonConstEnd; CWorld::CWorld(IObjectStore& objStore, CResFactory& resFactory, CAssetId mlvlId) : x4_phase(kP_Loading) @@ -87,7 +86,7 @@ bool CWorld::ScheduleAreaToLoad(CGameArea* area, CStateManager& mgr) { } // TOOD nonmatching -void CWorld::TravelToArea(TAreaId aid, CStateManager& mgr, EAreaTravelType type) { +void CWorld::TravelToArea(const TAreaId& aid, CStateManager& mgr, bool skipLoadOther) { if (aid.Value() < 0 || aid.Value() >= x18_areas.size()) return; x70_24_currentAreaNeedsAllocation = false; @@ -122,7 +121,7 @@ void CWorld::TravelToArea(TAreaId aid, CStateManager& mgr, EAreaTravelType type) area->SetOcclusionState(CGameArea::kOS_Visible); CGameArea* otherLoadArea = nullptr; - if (type == kATT_Zero) { + if (!skipLoadOther) { bool otherLoading = false; for (int i = 0; i < area->GetDockCount(); ++i) { const CGameArea::Dock& dock = area->GetDock(i);