mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-23 16:21:15 +00:00
feat: Implement many ::Serialize functions
This commit is contained in:
parent
165785c434
commit
7dc241176e
@ -25,6 +25,26 @@ class RaceState : public LegoState {
|
||||
inline MxS16 GetUnknown0x02() { return m_unk0x02; }
|
||||
inline MxS16 GetHighScore() { return m_score; }
|
||||
|
||||
inline MxResult Serialize(LegoFile* p_legoFile)
|
||||
{
|
||||
if (p_legoFile->IsReadMode()) {
|
||||
p_legoFile->Read(&m_id, 1);
|
||||
p_legoFile->Read(&m_unk0x02, 2);
|
||||
p_legoFile->Read(&m_score, 2);
|
||||
}
|
||||
else if (p_legoFile->IsWriteMode()) {
|
||||
// A write variable needs to be used here, otherwise
|
||||
// the compiler aggresively optimizes the function
|
||||
MxS8 id = m_id;
|
||||
p_legoFile->Write(&id, 1);
|
||||
MxS16 unk0x02 = m_unk0x02;
|
||||
p_legoFile->Write(&unk0x02, 2);
|
||||
MxS16 score = m_score;
|
||||
p_legoFile->Write(&score, 2);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// TODO: Possibly private
|
||||
MxU8 m_id; // 0x00
|
||||
MxS16 m_unk0x02; // 0x02
|
||||
|
||||
@ -58,6 +58,21 @@ class LegoState : public MxCore {
|
||||
|
||||
inline void SetUnknown0x08(MxS16 p_unk0x08) { m_nextIndex = p_unk0x08; }
|
||||
|
||||
inline MxResult ReadFromFile(LegoFile* p_legoFile)
|
||||
{
|
||||
p_legoFile->Read(&m_nextIndex, 2);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
inline MxResult WriteToFile(LegoFile* p_legoFile)
|
||||
{
|
||||
// A write variable needs to be used here, otherwise
|
||||
// the compiler aggresively optimizes the function
|
||||
MxS16 write = m_nextIndex;
|
||||
p_legoFile->Write(&write, 2);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
private:
|
||||
MxU32* m_objectIds; // 0x00
|
||||
MxS16 m_length; // 0x04
|
||||
|
||||
@ -15,11 +15,41 @@ class PizzaMissionState : public LegoState {
|
||||
// SIZE 0x20
|
||||
struct Entry {
|
||||
public:
|
||||
undefined2 m_unk0x00; // 0x00
|
||||
MxU8 m_id; // 0x02
|
||||
undefined m_unk0x03[0x15]; // 0x03
|
||||
MxS16 m_score; // 0x18
|
||||
undefined m_unk0x18[6]; // 0x1a
|
||||
undefined2 m_unk0x00; // 0x00
|
||||
MxU8 m_id; // 0x02
|
||||
undefined m_unk0x03[3]; // 0x03
|
||||
MxS16 m_unk0x06; // 0x06
|
||||
undefined m_unk0x08[8]; // 0x08
|
||||
MxS16 m_unk0x10; // 0x10
|
||||
MxS16 m_unk0x12; // 0x12
|
||||
MxS16 m_unk0x14; // 0x14
|
||||
MxS16 m_unk0x16; // 0x16
|
||||
MxS16 m_score; // 0x18
|
||||
undefined m_unk0x1a[6]; // 0x1a
|
||||
|
||||
inline MxResult WriteToFile(LegoFile* p_legoFile)
|
||||
{
|
||||
// A write variable needs to be used here, otherwise
|
||||
// the compiler aggresively optimizes the function
|
||||
MxS16 unk0x06 = m_unk0x06;
|
||||
p_legoFile->Write(&unk0x06, 2);
|
||||
MxS16 unk0x14 = m_unk0x14;
|
||||
p_legoFile->Write(&unk0x14, 2);
|
||||
MxS16 unk0x16 = m_unk0x16;
|
||||
p_legoFile->Write(&unk0x16, 2);
|
||||
MxS16 score = m_score;
|
||||
p_legoFile->Write(&score, 2);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
inline MxResult ReadFromFile(LegoFile* p_legoFile)
|
||||
{
|
||||
p_legoFile->Read(&m_unk0x06, 2);
|
||||
p_legoFile->Read(&m_unk0x14, 2);
|
||||
p_legoFile->Read(&m_unk0x16, 2);
|
||||
p_legoFile->Read(&m_score, 2);
|
||||
return SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
PizzaMissionState();
|
||||
|
||||
@ -642,9 +642,46 @@ AmbulanceMissionState::AmbulanceMissionState()
|
||||
m_laHighScore = 0;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10037440
|
||||
// FUNCTION: LEGO1 0x10037440
|
||||
MxResult AmbulanceMissionState::Serialize(LegoFile* p_legoFile)
|
||||
{
|
||||
// TODO
|
||||
return LegoState::Serialize(p_legoFile);
|
||||
LegoState::Serialize(p_legoFile);
|
||||
if (p_legoFile->IsReadMode()) {
|
||||
p_legoFile->Read(&m_unk0x10, 2);
|
||||
p_legoFile->Read(&m_unk0x12, 2);
|
||||
p_legoFile->Read(&m_unk0x14, 2);
|
||||
p_legoFile->Read(&m_unk0x16, 2);
|
||||
p_legoFile->Read(&m_unk0x18, 2);
|
||||
p_legoFile->Read(&m_score1, 2);
|
||||
p_legoFile->Read(&m_score2, 2);
|
||||
p_legoFile->Read(&m_score3, 2);
|
||||
p_legoFile->Read(&m_score4, 2);
|
||||
p_legoFile->Read(&m_score5, 2);
|
||||
}
|
||||
else if (p_legoFile->IsWriteMode()) {
|
||||
// A write variable needs to be used here, otherwise
|
||||
// the compiler aggresively optimizes the function
|
||||
MxS16 write;
|
||||
write = m_unk0x10;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_unk0x12;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_unk0x14;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_unk0x16;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_unk0x18;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_score1;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_score2;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_score3;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_score4;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_score5;
|
||||
p_legoFile->Write(&write, 2);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@ -105,11 +105,22 @@ PizzaMissionState::PizzaMissionState()
|
||||
// TODO
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100393c0
|
||||
// FUNCTION: LEGO1 0x100393c0
|
||||
MxResult PizzaMissionState::Serialize(LegoFile* p_legoFile)
|
||||
{
|
||||
// TODO
|
||||
return LegoState::Serialize(p_legoFile);
|
||||
LegoState::Serialize(p_legoFile);
|
||||
|
||||
if (p_legoFile->IsReadMode()) {
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_state[i].ReadFromFile(p_legoFile);
|
||||
}
|
||||
}
|
||||
else if (p_legoFile->IsWriteMode()) {
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_state[i].WriteToFile(p_legoFile);
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10039510
|
||||
|
||||
@ -76,9 +76,22 @@ MxU32 PizzeriaState::FUN_10017d70()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10017da0
|
||||
// FUNCTION: LEGO1 0x10017da0
|
||||
MxResult PizzeriaState::Serialize(LegoFile* p_legoFile)
|
||||
{
|
||||
// TODO
|
||||
return LegoState::Serialize(p_legoFile);
|
||||
LegoState::Serialize(p_legoFile);
|
||||
if (p_legoFile->IsReadMode()) {
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_unk0x08[i].ReadFromFile(p_legoFile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// A write variable needs to be used here, otherwise
|
||||
// the compiler aggresively optimizes the function
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_unk0x08[i].WriteToFile(p_legoFile);
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@ -134,11 +134,16 @@ RaceState::RaceState()
|
||||
// TODO
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10016140
|
||||
// FUNCTION: LEGO1 0x10016140
|
||||
MxResult RaceState::Serialize(LegoFile* p_legoFile)
|
||||
{
|
||||
// TODO
|
||||
return LegoState::Serialize(p_legoFile);
|
||||
LegoState::Serialize(p_legoFile);
|
||||
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_state[i].Serialize(p_legoFile);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10016280
|
||||
|
||||
@ -435,11 +435,33 @@ GasStationState::GasStationState()
|
||||
unk0x08[2] = -1;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10006300
|
||||
// FUNCTION: LEGO1 0x10006300
|
||||
MxResult GasStationState::Serialize(LegoFile* p_legoFile)
|
||||
{
|
||||
// TODO
|
||||
return LegoState::Serialize(p_legoFile);
|
||||
LegoState::Serialize(p_legoFile);
|
||||
if (p_legoFile->IsWriteMode()) {
|
||||
// A write variable needs to be used here, otherwise
|
||||
// the compiler aggresively optimizes the function
|
||||
MxS16 write;
|
||||
write = m_unk0x18;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_unk0x1a;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_unk0x1c;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_unk0x1e;
|
||||
p_legoFile->Write(&write, 2);
|
||||
write = m_unk0x20;
|
||||
p_legoFile->Write(&write, 2);
|
||||
}
|
||||
else if (p_legoFile->IsReadMode()) {
|
||||
p_legoFile->Read(&m_unk0x18, 2);
|
||||
p_legoFile->Read(&m_unk0x1a, 2);
|
||||
p_legoFile->Read(&m_unk0x1c, 2);
|
||||
p_legoFile->Read(&m_unk0x1e, 2);
|
||||
p_legoFile->Read(&m_unk0x20, 2);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10006430
|
||||
|
||||
Loading…
Reference in New Issue
Block a user