some gamestate functions

This commit is contained in:
Misha 2023-12-15 15:56:19 -05:00
parent 540a930494
commit d74d42ddfd
No known key found for this signature in database
GPG Key ID: 8441D12AEF33FED8
4 changed files with 61 additions and 7 deletions

View File

@ -13,6 +13,12 @@
// There may be other members that come after.
DECOMP_SIZE_ASSERT(LegoGameState, 0x430)
// GLOBAL: LEGO1 0x100f3e24
const char* g_historyGSI = "History.gsi";
// GLOBAL: LEGO1 0x100f3e30
const char* g_playersGSI = "Players.gsi";
// GLOBAL: LEGO1 0x100f3e40
const char* g_fileExtensionGS = ".GS";
@ -255,10 +261,30 @@ void LegoGameState::RegisterState(LegoState* p_state)
m_stateArray[targetIndex] = p_state;
}
// STUB: LEGO1 0x1003cdd0
void LegoGameState::SerializeScoreHistory(MxS16)
void LegoGameState::WriteScoreHistory(MxU16*)
{
// TODO
}
// STUB: LEGO1 0x1003ccf0
void FUN_1003ccf0(MxU16*, LegoFileStream&)
{
}
// FUNCTION: LEGO1 0x1003cdd0
void LegoGameState::SerializeScoreHistory(MxS16 m_flags)
{
LegoFileStream stream;
MxString savePath(m_savePath);
savePath += "\\";
savePath += g_historyGSI;
if (m_flags == LegoStream::WriteBit) {
WriteScoreHistory(&m_unk0xa6);
}
if (stream.Open(savePath.GetData(), (LegoStream::OpenFlags) m_flags) == SUCCESS) {
FUN_1003ccf0(&m_unk0xa6, stream);
}
}
// FUNCTION: LEGO1 0x1003cea0
@ -266,3 +292,20 @@ void LegoGameState::SetSomeEnumState(undefined4 p_state)
{
m_unk0x10 = p_state;
}
// FUNCTION: LEGO1 0x1003ceb0
void LegoGameState::FUN_1003ceb0()
{
if (FindEntityByAtomIdOrEntityId(*g_isleScript, 0)) {
m_currentAct = 0;
}
else if (FindEntityByAtomIdOrEntityId(*g_act2mainScript, 0)) {
m_currentAct = 1;
}
else if (FindEntityByAtomIdOrEntityId(*g_act3Script, 0)) {
m_currentAct = 2;
}
else {
m_currentAct = -1;
}
}

View File

@ -4,10 +4,10 @@
#include "decomp.h"
#include "legobackgroundcolor.h"
#include "legofullscreenmovie.h"
#include "legostream.h"
#include "mxtypes.h"
class LegoState;
class LegoStream;
class MxVariable;
class MxString;
@ -24,7 +24,7 @@ class LegoGameState {
__declspec(dllexport) MxResult Load(MxULong);
__declspec(dllexport) MxResult Save(MxULong);
__declspec(dllexport) void SerializePlayersInfo(MxS16);
__declspec(dllexport) void SerializeScoreHistory(MxS16);
__declspec(dllexport) void SerializeScoreHistory(MxS16 m_flags);
__declspec(dllexport) void SetSavePath(char*);
LegoState* GetState(COMPAT_CONST char* p_stateName);
@ -33,12 +33,14 @@ class LegoGameState {
void GetFileSavePath(MxString* p_outPath, MxULong p_slotn);
void FUN_1003a720(MxU32);
void HandleAction(MxU32);
void WriteScoreHistory(MxU16*);
inline MxU8 GetUnknownC() { return m_unk0xc; }
inline MxU32 GetUnknown10() { return m_unk0x10; }
inline void SetUnknown424(undefined4 p_unk0x424) { m_unk0x424 = p_unk0x424; }
void SetSomeEnumState(undefined4 p_state);
void FUN_1003ceb0();
private:
void RegisterState(LegoState* p_state);
@ -51,12 +53,14 @@ class LegoGameState {
LegoState** m_stateArray; // 0x8
MxU8 m_unk0xc; // 0xc
MxU32 m_unk0x10; // 0x10
undefined4 m_unk0x14; // 0x14
undefined4 m_currentAct; // 0x14
LegoBackgroundColor* m_backgroundColor; // 0x18
LegoBackgroundColor* m_tempBackgroundColor; // 0x1c
LegoFullScreenMovie* m_fullScreenMovie; // 0x20
MxU16 m_unk0x24; // 0x24
undefined m_unk0x28[1020]; // 0x28
undefined m_unk0x28[128]; // 0x28
MxU16 m_unk0xa6; // 0xa6
undefined m_unk0xa9[890]; // 0xa9
undefined4 m_unk0x424; // 0x424
undefined4 m_unk0x428; // 0x428
undefined4 m_unk0x42c; // 0x42c

View File

@ -188,6 +188,12 @@ LegoBuildingManager* BuildingManager()
return LegoOmni::GetInstance()->GetLegoBuildingManager();
}
// FUNCTION: LEGO1 0x100158c0
LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid)
{
return LegoOmni::GetInstance()->FindByEntityIdOrAtomId(p_atom, p_entityid);
}
// FUNCTION: LEGO1 0x10015800
GifManager* GetGifManager()
{

View File

@ -157,6 +157,7 @@ IslePathActor* GetCurrentVehicle();
LegoPlantManager* PlantManager();
MxBool KeyValueStringParse(char*, const char*, const char*);
LegoWorld* GetCurrentWorld();
LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid);
GifManager* GetGifManager();
MxDSAction& GetCurrentAction();