mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-04-27 14:53:47 -04:00
Match Serialize
functions to BETA10 (#1334)
* Begin refactor Serialize functions * Match more Serialize functions * Match `LegoVehicleBuildState::Serialize` * Match `LegoGameState::Username::Serialize` * Match `LegoGameState::ScoreItem::Serialize` * Match `LegoGameState::History::Serialize` * Var name * Var name * Revert "Var name" This reverts commit 1c0cccfba799450cfe4f75566dc1f32db1c76a6b. * Add other Serialize implementations * Add remaining Serialize implementations * Add Read for char* * Improvements
This commit is contained in:
parent
f95eedd0ce
commit
77a3dc0795
20 changed files with 409 additions and 327 deletions
LEGO1/lego
legoomni
include
src
sources/misc
|
@ -15,6 +15,7 @@ class MxSoundPresenter;
|
|||
class MxActionNotificationParam;
|
||||
|
||||
// VTABLE: LEGO1 0x100d66e0
|
||||
// VTABLE: BETA10 0x101bb910
|
||||
// SIZE 0x50
|
||||
class LegoVehicleBuildState : public LegoState {
|
||||
public:
|
||||
|
@ -32,13 +33,13 @@ public:
|
|||
// FUNCTION: LEGO1 0x10025ff0
|
||||
const char* ClassName() const override // vtable+0x0c
|
||||
{
|
||||
return this->m_className.GetData();
|
||||
return m_className.GetData();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10026000
|
||||
MxBool IsA(const char* p_name) const override // vtable+0x10
|
||||
{
|
||||
return !strcmp(p_name, this->m_className.GetData()) || LegoState::IsA(p_name);
|
||||
return !strcmp(p_name, m_className.GetData()) || LegoState::IsA(p_name);
|
||||
}
|
||||
|
||||
MxResult Serialize(LegoFile* p_file) override; // vtable+0x1c
|
||||
|
@ -56,7 +57,7 @@ public:
|
|||
MxString m_className; // 0x38
|
||||
|
||||
AnimationState m_animationState; // 0x48
|
||||
undefined m_unk0x4c; // 0x4c
|
||||
MxU8 m_unk0x4c; // 0x4c
|
||||
MxBool m_unk0x4d; // 0x4d
|
||||
MxBool m_unk0x4e; // 0x4e
|
||||
MxU8 m_placedPartCount; // 0x4f
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
Username(Username& p_other) { Set(p_other); }
|
||||
void Set(Username& p_other) { memcpy(m_letters, p_other.m_letters, sizeof(m_letters)); }
|
||||
|
||||
MxResult Serialize(LegoStorage* p_storage);
|
||||
MxResult Serialize(LegoFile* p_file);
|
||||
Username& operator=(const Username& p_other);
|
||||
|
||||
MxS16 m_letters[7]; // 0x00
|
||||
|
@ -121,10 +121,10 @@ public:
|
|||
struct ScoreItem {
|
||||
MxResult Serialize(LegoFile* p_file);
|
||||
|
||||
MxS16 m_totalScore; // 0x00
|
||||
MxU8 m_scores[5][5]; // 0x02
|
||||
Username m_name; // 0x1c
|
||||
undefined2 m_unk0x2a; // 0x2a
|
||||
MxS16 m_totalScore; // 0x00
|
||||
MxU8 m_scores[5][5]; // 0x02
|
||||
Username m_name; // 0x1c
|
||||
MxS16 m_unk0x2a; // 0x2a
|
||||
};
|
||||
|
||||
// SIZE 0x372
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
|
||||
MxS16 m_count; // 0x00
|
||||
ScoreItem m_scores[20]; // 0x02
|
||||
undefined2 m_unk0x372; // 0x372
|
||||
MxS16 m_unk0x372; // 0x372
|
||||
};
|
||||
|
||||
LegoGameState();
|
||||
|
@ -214,7 +214,7 @@ private:
|
|||
// TODO: Most likely getters/setters are not used according to BETA for the following members:
|
||||
|
||||
public:
|
||||
MxU16 m_unk0x24; // 0x24
|
||||
MxS16 m_unk0x24; // 0x24
|
||||
MxS16 m_playerCount; // 0x26
|
||||
Username m_players[9]; // 0x28
|
||||
History m_history; // 0xa6
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
void SetDirection(const Mx3DPointFloat& p_direction) { m_direction = p_direction; }
|
||||
void SetUp(const Mx3DPointFloat& p_up) { m_up = p_up; }
|
||||
|
||||
// TODO: Unclear whether this was defined
|
||||
MxBool IsPresent() { return strcmp(m_name.GetData(), "") != 0; }
|
||||
void Reset() { m_name = ""; }
|
||||
|
||||
|
@ -31,22 +32,22 @@ public:
|
|||
MxResult Serialize(LegoFile* p_file)
|
||||
{
|
||||
if (p_file->IsWriteMode()) {
|
||||
p_file->WriteString(m_name);
|
||||
p_file->WriteVector3(m_position);
|
||||
p_file->WriteVector3(m_direction);
|
||||
p_file->WriteVector3(m_up);
|
||||
p_file->Write(MxString(m_name));
|
||||
p_file->Write(m_position);
|
||||
p_file->Write(m_direction);
|
||||
p_file->Write(m_up);
|
||||
}
|
||||
else if (p_file->IsReadMode()) {
|
||||
p_file->ReadString(m_name);
|
||||
p_file->ReadVector3(m_position);
|
||||
p_file->ReadVector3(m_direction);
|
||||
p_file->ReadVector3(m_up);
|
||||
p_file->Read(m_name);
|
||||
p_file->Read(m_position);
|
||||
p_file->Read(m_direction);
|
||||
p_file->Read(m_up);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
private:
|
||||
// private:
|
||||
MxString m_name; // 0x00
|
||||
Mx3DPointFloat m_position; // 0x10
|
||||
Mx3DPointFloat m_direction; // 0x24
|
||||
|
|
|
@ -42,14 +42,17 @@ public:
|
|||
MxResult Serialize(LegoFile* p_file)
|
||||
{
|
||||
if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_id);
|
||||
Read(p_file, &m_unk0x02);
|
||||
Read(p_file, &m_score);
|
||||
p_file->Read(m_id);
|
||||
p_file->Read(m_unk0x02);
|
||||
p_file->Read(m_score);
|
||||
}
|
||||
else if (p_file->IsWriteMode()) {
|
||||
Write(p_file, m_id);
|
||||
Write(p_file, m_unk0x02);
|
||||
Write(p_file, m_score);
|
||||
p_file->Write(m_id);
|
||||
p_file->Write(m_unk0x02);
|
||||
p_file->Write(m_score);
|
||||
}
|
||||
else {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
|
@ -18,8 +18,7 @@ public:
|
|||
};
|
||||
|
||||
// SIZE 0x0c
|
||||
class Playlist {
|
||||
public:
|
||||
struct Playlist {
|
||||
enum Mode {
|
||||
e_loop,
|
||||
e_once,
|
||||
|
@ -60,21 +59,6 @@ public:
|
|||
MxU32 Next();
|
||||
MxBool Contains(MxU32 p_objectId);
|
||||
|
||||
void SetNextIndex(MxS16 p_nextIndex) { m_nextIndex = p_nextIndex; }
|
||||
|
||||
MxResult ReadFromFile(LegoFile* p_file)
|
||||
{
|
||||
Read(p_file, &m_nextIndex);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
MxResult WriteToFile(LegoFile* p_file)
|
||||
{
|
||||
Write(p_file, m_nextIndex);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
private:
|
||||
MxU32* m_objectIds; // 0x00
|
||||
MxS16 m_length; // 0x04
|
||||
MxS16 m_mode; // 0x06
|
||||
|
@ -95,7 +79,7 @@ public:
|
|||
virtual MxResult Serialize(LegoFile* p_file)
|
||||
{
|
||||
if (p_file->IsWriteMode()) {
|
||||
p_file->WriteString(ClassName());
|
||||
p_file->Write(MxString(ClassName()));
|
||||
}
|
||||
return SUCCESS;
|
||||
} // vtable+0x1c
|
||||
|
|
|
@ -93,24 +93,6 @@ public:
|
|||
// FUNCTION: BETA10 0x100ef7e0
|
||||
MxLong GetTimeoutTime() { return m_finishTimes[3]; }
|
||||
|
||||
MxResult WriteToFile(LegoFile* p_file)
|
||||
{
|
||||
Write(p_file, m_unk0x06);
|
||||
Write(p_file, m_unk0x14);
|
||||
Write(p_file, m_score);
|
||||
Write(p_file, m_hiScore);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
MxResult ReadFromFile(LegoFile* p_file)
|
||||
{
|
||||
Read(p_file, &m_unk0x06);
|
||||
Read(p_file, &m_unk0x14);
|
||||
Read(p_file, &m_score);
|
||||
Read(p_file, &m_hiScore);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
MxS16 m_numActions; // 0x00
|
||||
MxU8 m_actorId; // 0x02
|
||||
undefined2 m_unk0x04; // 0x04
|
||||
|
|
|
@ -646,33 +646,34 @@ AmbulanceMissionState::AmbulanceMissionState()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10037440
|
||||
// FUNCTION: BETA10 0x10024480
|
||||
MxResult AmbulanceMissionState::Serialize(LegoFile* p_file)
|
||||
{
|
||||
LegoState::Serialize(p_file);
|
||||
|
||||
if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_peScore);
|
||||
Read(p_file, &m_maScore);
|
||||
Read(p_file, &m_paScore);
|
||||
Read(p_file, &m_niScore);
|
||||
Read(p_file, &m_laScore);
|
||||
Read(p_file, &m_peHighScore);
|
||||
Read(p_file, &m_maHighScore);
|
||||
Read(p_file, &m_paHighScore);
|
||||
Read(p_file, &m_niHighScore);
|
||||
Read(p_file, &m_laHighScore);
|
||||
p_file->Read(m_peScore);
|
||||
p_file->Read(m_maScore);
|
||||
p_file->Read(m_paScore);
|
||||
p_file->Read(m_niScore);
|
||||
p_file->Read(m_laScore);
|
||||
p_file->Read(m_peHighScore);
|
||||
p_file->Read(m_maHighScore);
|
||||
p_file->Read(m_paHighScore);
|
||||
p_file->Read(m_niHighScore);
|
||||
p_file->Read(m_laHighScore);
|
||||
}
|
||||
else if (p_file->IsWriteMode()) {
|
||||
Write(p_file, m_peScore);
|
||||
Write(p_file, m_maScore);
|
||||
Write(p_file, m_paScore);
|
||||
Write(p_file, m_niScore);
|
||||
Write(p_file, m_laScore);
|
||||
Write(p_file, m_peHighScore);
|
||||
Write(p_file, m_maHighScore);
|
||||
Write(p_file, m_paHighScore);
|
||||
Write(p_file, m_niHighScore);
|
||||
Write(p_file, m_laHighScore);
|
||||
p_file->Write(m_peScore);
|
||||
p_file->Write(m_maScore);
|
||||
p_file->Write(m_paScore);
|
||||
p_file->Write(m_niScore);
|
||||
p_file->Write(m_laScore);
|
||||
p_file->Write(m_peHighScore);
|
||||
p_file->Write(m_maHighScore);
|
||||
p_file->Write(m_paHighScore);
|
||||
p_file->Write(m_niHighScore);
|
||||
p_file->Write(m_laHighScore);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
|
@ -605,18 +605,25 @@ PizzaMissionState::PizzaMissionState()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100393c0
|
||||
// FUNCTION: BETA10 0x100eebf2
|
||||
MxResult PizzaMissionState::Serialize(LegoFile* p_file)
|
||||
{
|
||||
LegoState::Serialize(p_file);
|
||||
|
||||
if (p_file->IsReadMode()) {
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_missions[i].ReadFromFile(p_file);
|
||||
p_file->Read(m_missions[i].m_unk0x06);
|
||||
p_file->Read(m_missions[i].m_unk0x14);
|
||||
p_file->Read(m_missions[i].m_score);
|
||||
p_file->Read(m_missions[i].m_hiScore);
|
||||
}
|
||||
}
|
||||
else if (p_file->IsWriteMode()) {
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_missions[i].WriteToFile(p_file);
|
||||
p_file->Write(m_missions[i].m_unk0x06);
|
||||
p_file->Write(m_missions[i].m_unk0x14);
|
||||
p_file->Write(m_missions[i].m_score);
|
||||
p_file->Write(m_missions[i].m_hiScore);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -633,6 +640,7 @@ PizzaMissionState::Mission* PizzaMissionState::GetMission(MxU8 p_actorId)
|
|||
}
|
||||
}
|
||||
|
||||
assert("No pizza mission for this character!" == NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,12 +124,12 @@ MxResult PizzeriaState::Serialize(LegoFile* p_file)
|
|||
|
||||
if (p_file->IsReadMode()) {
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_unk0x08[i].ReadFromFile(p_file);
|
||||
p_file->Read(m_unk0x08[i].m_nextIndex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (MxS16 i = 0; i < 5; i++) {
|
||||
m_unk0x08[i].WriteToFile(p_file);
|
||||
p_file->Write(m_unk0x08[i].m_nextIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -209,6 +209,7 @@ void Radio::CreateState()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1002ce10
|
||||
// FUNCTION: BETA10 0x100f20f6
|
||||
RadioState::RadioState()
|
||||
{
|
||||
srand(Timer()->GetTime());
|
||||
|
@ -217,13 +218,13 @@ RadioState::RadioState()
|
|||
m_unk0x2c = random % 3;
|
||||
|
||||
m_unk0x08[0] = Playlist((MxU32*) g_unk0x100f3218, sizeOfArray(g_unk0x100f3218), Playlist::e_loop);
|
||||
m_unk0x08[0].SetNextIndex(rand() % sizeOfArray(g_unk0x100f3218));
|
||||
m_unk0x08[0].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3218));
|
||||
|
||||
m_unk0x08[1] = Playlist((MxU32*) g_unk0x100f3230, sizeOfArray(g_unk0x100f3230), Playlist::e_loop);
|
||||
m_unk0x08[1].SetNextIndex(rand() % sizeOfArray(g_unk0x100f3230));
|
||||
m_unk0x08[1].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3230));
|
||||
|
||||
m_unk0x08[2] = Playlist((MxU32*) g_unk0x100f3268, sizeOfArray(g_unk0x100f3268), Playlist::e_loop);
|
||||
m_unk0x08[2].SetNextIndex(rand() % sizeOfArray(g_unk0x100f3268));
|
||||
m_unk0x08[2].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3268));
|
||||
|
||||
m_active = FALSE;
|
||||
}
|
||||
|
|
|
@ -609,33 +609,34 @@ TowTrackMissionState::TowTrackMissionState()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1004dde0
|
||||
// FUNCTION: BETA10 0x100f8720
|
||||
MxResult TowTrackMissionState::Serialize(LegoFile* p_file)
|
||||
{
|
||||
LegoState::Serialize(p_file);
|
||||
|
||||
if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_peScore);
|
||||
Read(p_file, &m_maScore);
|
||||
Read(p_file, &m_paScore);
|
||||
Read(p_file, &m_niScore);
|
||||
Read(p_file, &m_laScore);
|
||||
Read(p_file, &m_peHighScore);
|
||||
Read(p_file, &m_maHighScore);
|
||||
Read(p_file, &m_paHighScore);
|
||||
Read(p_file, &m_niHighScore);
|
||||
Read(p_file, &m_laHighScore);
|
||||
p_file->Read(m_peScore);
|
||||
p_file->Read(m_maScore);
|
||||
p_file->Read(m_paScore);
|
||||
p_file->Read(m_niScore);
|
||||
p_file->Read(m_laScore);
|
||||
p_file->Read(m_peHighScore);
|
||||
p_file->Read(m_maHighScore);
|
||||
p_file->Read(m_paHighScore);
|
||||
p_file->Read(m_niHighScore);
|
||||
p_file->Read(m_laHighScore);
|
||||
}
|
||||
else if (p_file->IsWriteMode()) {
|
||||
Write(p_file, m_peScore);
|
||||
Write(p_file, m_maScore);
|
||||
Write(p_file, m_paScore);
|
||||
Write(p_file, m_niScore);
|
||||
Write(p_file, m_laScore);
|
||||
Write(p_file, m_peHighScore);
|
||||
Write(p_file, m_maHighScore);
|
||||
Write(p_file, m_paHighScore);
|
||||
Write(p_file, m_niHighScore);
|
||||
Write(p_file, m_laHighScore);
|
||||
p_file->Write(m_peScore);
|
||||
p_file->Write(m_maScore);
|
||||
p_file->Write(m_paScore);
|
||||
p_file->Write(m_niScore);
|
||||
p_file->Write(m_laScore);
|
||||
p_file->Write(m_peHighScore);
|
||||
p_file->Write(m_maHighScore);
|
||||
p_file->Write(m_paHighScore);
|
||||
p_file->Write(m_niHighScore);
|
||||
p_file->Write(m_laHighScore);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
|
@ -1704,21 +1704,26 @@ LegoVehicleBuildState::LegoVehicleBuildState(const char* p_classType)
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10026120
|
||||
// FUNCTION: BETA10 0x1006eef0
|
||||
MxResult LegoVehicleBuildState::Serialize(LegoFile* p_file)
|
||||
{
|
||||
LegoState::Serialize(p_file);
|
||||
|
||||
if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_unk0x4c);
|
||||
Read(p_file, &m_unk0x4d);
|
||||
Read(p_file, &m_unk0x4e);
|
||||
Read(p_file, &m_placedPartCount);
|
||||
p_file->Read(m_unk0x4c);
|
||||
p_file->Read(m_unk0x4d);
|
||||
p_file->Read(m_unk0x4e);
|
||||
#ifndef BETA10
|
||||
p_file->Read(m_placedPartCount);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
Write(p_file, m_unk0x4c);
|
||||
Write(p_file, m_unk0x4d);
|
||||
Write(p_file, m_unk0x4e);
|
||||
Write(p_file, m_placedPartCount);
|
||||
p_file->Write(m_unk0x4c);
|
||||
p_file->Write(m_unk0x4d);
|
||||
p_file->Write(m_unk0x4e);
|
||||
#ifndef BETA10
|
||||
p_file->Write(m_placedPartCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
|
@ -2937,67 +2937,75 @@ void AnimState::InitFromAnims(MxU32 p_animsLength, AnimInfo* p_anims, MxU32 p_ex
|
|||
// FUNCTION: BETA10 0x10046621
|
||||
MxResult AnimState::Serialize(LegoFile* p_file)
|
||||
{
|
||||
// These two are equivalent up to the order of some deallocation.
|
||||
// Choose as needed to get 100 %.
|
||||
// Option 1:
|
||||
// LegoState::Serialize(p_file);
|
||||
// Option 2:
|
||||
if (p_file->IsWriteMode()) {
|
||||
p_file->WriteString(ClassName());
|
||||
}
|
||||
MxResult result = LegoState::Serialize(p_file);
|
||||
|
||||
if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_extraCharacterId);
|
||||
if (result == SUCCESS) {
|
||||
if (p_file->IsReadMode()) {
|
||||
MxS32 i;
|
||||
|
||||
if (m_unk0x10) {
|
||||
delete[] m_unk0x10;
|
||||
}
|
||||
p_file->Read(m_extraCharacterId);
|
||||
|
||||
Read(p_file, &m_unk0x0c);
|
||||
if (m_unk0x0c != 0) {
|
||||
if (m_unk0x10) {
|
||||
delete[] m_unk0x10;
|
||||
}
|
||||
|
||||
p_file->Read(m_unk0x0c);
|
||||
|
||||
#ifndef BETA10
|
||||
if (m_unk0x0c != 0) {
|
||||
m_unk0x10 = new MxU16[m_unk0x0c];
|
||||
}
|
||||
else {
|
||||
m_unk0x10 = NULL;
|
||||
}
|
||||
#else
|
||||
m_unk0x10 = new MxU16[m_unk0x0c];
|
||||
}
|
||||
else {
|
||||
m_unk0x10 = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (MxS32 i = 0; i < m_unk0x0c; i++) {
|
||||
Read(p_file, &m_unk0x10[i]);
|
||||
}
|
||||
for (i = 0; i < m_unk0x0c; i++) {
|
||||
p_file->Read(m_unk0x10[i]);
|
||||
}
|
||||
|
||||
// Note that here we read first and then free memory in contrast to above
|
||||
Read(p_file, &m_locationsFlagsLength);
|
||||
// Note that here we read first and then free memory in contrast to above
|
||||
p_file->Read(m_locationsFlagsLength);
|
||||
|
||||
if (m_locationsFlags) {
|
||||
delete[] m_locationsFlags;
|
||||
}
|
||||
#ifndef BETA10
|
||||
if (m_locationsFlags) {
|
||||
delete[] m_locationsFlags;
|
||||
}
|
||||
|
||||
if (m_locationsFlagsLength != 0) {
|
||||
if (m_locationsFlagsLength != 0) {
|
||||
m_locationsFlags = new MxBool[m_locationsFlagsLength];
|
||||
}
|
||||
else {
|
||||
m_locationsFlags = NULL;
|
||||
}
|
||||
#else
|
||||
m_locationsFlags = new MxBool[m_locationsFlagsLength];
|
||||
}
|
||||
else {
|
||||
m_locationsFlags = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (MxS32 j = 0; j < m_locationsFlagsLength; j++) {
|
||||
Read(p_file, &m_locationsFlags[j]);
|
||||
for (i = 0; i < m_locationsFlagsLength; i++) {
|
||||
p_file->Read(m_locationsFlags[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (p_file->IsWriteMode()) {
|
||||
Write(p_file, m_extraCharacterId);
|
||||
else if (p_file->IsWriteMode()) {
|
||||
MxS32 i;
|
||||
|
||||
Write(p_file, m_unk0x0c);
|
||||
for (MxS32 i = 0; i < m_unk0x0c; i++) {
|
||||
Write(p_file, m_unk0x10[i]);
|
||||
}
|
||||
p_file->Write(m_extraCharacterId);
|
||||
p_file->Write(m_unk0x0c);
|
||||
|
||||
Write(p_file, m_locationsFlagsLength);
|
||||
for (MxS32 j = 0; j < m_locationsFlagsLength; j++) {
|
||||
Write(p_file, m_locationsFlags[j]);
|
||||
for (i = 0; i < m_unk0x0c; i++) {
|
||||
p_file->Write(m_unk0x10[i]);
|
||||
}
|
||||
|
||||
p_file->Write(m_locationsFlagsLength);
|
||||
for (i = 0; i < m_locationsFlagsLength; i++) {
|
||||
p_file->Write(m_locationsFlags[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100654f0
|
||||
|
|
|
@ -171,6 +171,7 @@ LegoGameState::~LegoGameState()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10039780
|
||||
// FUNCTION: BETA10 0x10083d43
|
||||
void LegoGameState::SetActor(MxU8 p_actorId)
|
||||
{
|
||||
if (p_actorId) {
|
||||
|
@ -238,7 +239,7 @@ MxResult LegoGameState::Save(MxULong p_slot)
|
|||
}
|
||||
|
||||
MxResult result = FAILURE;
|
||||
LegoFile fileStorage;
|
||||
LegoFile storage;
|
||||
MxVariableTable* variableTable = VariableTable();
|
||||
MxS16 count = 0;
|
||||
MxU32 i;
|
||||
|
@ -248,32 +249,32 @@ MxResult LegoGameState::Save(MxULong p_slot)
|
|||
MxString savePath;
|
||||
GetFileSavePath(&savePath, p_slot);
|
||||
|
||||
if (fileStorage.Open(savePath.GetData(), LegoFile::c_write) == FAILURE) {
|
||||
if (storage.Open(savePath.GetData(), LegoFile::c_write) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
Write(&fileStorage, 0x1000c);
|
||||
Write(&fileStorage, m_unk0x24);
|
||||
Write(&fileStorage, (MxU16) m_currentAct);
|
||||
Write(&fileStorage, m_actorId);
|
||||
storage.Write(0x1000c);
|
||||
storage.Write(m_unk0x24);
|
||||
storage.Write((MxU16) m_currentAct);
|
||||
storage.Write(m_actorId);
|
||||
|
||||
for (i = 0; i < sizeOfArray(g_colorSaveData); i++) {
|
||||
if (WriteVariable(&fileStorage, variableTable, g_colorSaveData[i].m_targetName) == FAILURE) {
|
||||
if (WriteVariable(&storage, variableTable, g_colorSaveData[i].m_targetName) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (WriteVariable(&fileStorage, variableTable, "backgroundcolor") == FAILURE) {
|
||||
if (WriteVariable(&storage, variableTable, "backgroundcolor") == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (WriteVariable(&fileStorage, variableTable, "lightposition") == FAILURE) {
|
||||
if (WriteVariable(&storage, variableTable, "lightposition") == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
WriteEndOfVariables(&fileStorage);
|
||||
CharacterManager()->Write(&fileStorage);
|
||||
PlantManager()->Write(&fileStorage);
|
||||
result = BuildingManager()->Write(&fileStorage);
|
||||
WriteEndOfVariables(&storage);
|
||||
CharacterManager()->Write(&storage);
|
||||
PlantManager()->Write(&storage);
|
||||
result = BuildingManager()->Write(&storage);
|
||||
|
||||
for (j = 0; j < m_stateCount; j++) {
|
||||
if (m_stateArray[j]->IsSerializable()) {
|
||||
|
@ -281,16 +282,16 @@ MxResult LegoGameState::Save(MxULong p_slot)
|
|||
}
|
||||
}
|
||||
|
||||
Write(&fileStorage, count);
|
||||
storage.Write(count);
|
||||
|
||||
for (j = 0; j < m_stateCount; j++) {
|
||||
if (m_stateArray[j]->IsSerializable()) {
|
||||
m_stateArray[j]->Serialize(&fileStorage);
|
||||
m_stateArray[j]->Serialize(&storage);
|
||||
}
|
||||
}
|
||||
|
||||
area = m_unk0x42c;
|
||||
Write(&fileStorage, (MxU16) area);
|
||||
storage.Write((MxU16) area);
|
||||
SerializeScoreHistory(2);
|
||||
m_isDirty = FALSE;
|
||||
|
||||
|
@ -322,42 +323,43 @@ MxResult LegoGameState::DeleteState()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10039c60
|
||||
// FUNCTION: BETA10 0x10084329
|
||||
MxResult LegoGameState::Load(MxULong p_slot)
|
||||
{
|
||||
MxResult result = FAILURE;
|
||||
LegoFile fileStorage;
|
||||
LegoFile storage;
|
||||
MxVariableTable* variableTable = VariableTable();
|
||||
|
||||
MxString savePath;
|
||||
GetFileSavePath(&savePath, p_slot);
|
||||
|
||||
if (fileStorage.Open(savePath.GetData(), LegoFile::c_read) == FAILURE) {
|
||||
if (storage.Open(savePath.GetData(), LegoFile::c_read) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
MxU32 version, status;
|
||||
MxS32 version;
|
||||
MxU32 status;
|
||||
MxS16 count, actArea;
|
||||
const char* lightPosition;
|
||||
|
||||
Read(&fileStorage, &version);
|
||||
storage.Read(version);
|
||||
|
||||
if (version != 0x1000c) {
|
||||
OmniError("Saved game version mismatch", 0);
|
||||
goto done;
|
||||
}
|
||||
|
||||
Read(&fileStorage, &m_unk0x24);
|
||||
storage.Read(m_unk0x24);
|
||||
storage.Read(actArea);
|
||||
|
||||
Read(&fileStorage, &actArea);
|
||||
SetCurrentAct((Act) actArea);
|
||||
|
||||
Read(&fileStorage, &m_actorId);
|
||||
storage.Read(m_actorId);
|
||||
if (m_actorId) {
|
||||
SetActor(m_actorId);
|
||||
}
|
||||
|
||||
do {
|
||||
status = ReadVariable(&fileStorage, variableTable);
|
||||
status = ReadVariable(&storage, variableTable);
|
||||
if (status == 1) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -370,13 +372,13 @@ MxResult LegoGameState::Load(MxULong p_slot)
|
|||
SetLightPosition(atoi(lightPosition));
|
||||
}
|
||||
|
||||
if (CharacterManager()->Read(&fileStorage) == FAILURE) {
|
||||
if (CharacterManager()->Read(&storage) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (PlantManager()->Read(&fileStorage) == FAILURE) {
|
||||
if (PlantManager()->Read(&storage) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (BuildingManager()->Read(&fileStorage) == FAILURE) {
|
||||
if (BuildingManager()->Read(&storage) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (DeleteState() != SUCCESS) {
|
||||
|
@ -384,14 +386,11 @@ MxResult LegoGameState::Load(MxULong p_slot)
|
|||
}
|
||||
|
||||
char stateName[80];
|
||||
Read(&fileStorage, &count);
|
||||
storage.Read(count);
|
||||
|
||||
if (count) {
|
||||
for (MxS16 i = 0; i < count; i++) {
|
||||
MxS16 stateNameLength;
|
||||
Read(&fileStorage, &stateNameLength);
|
||||
Read(&fileStorage, stateName, (MxULong) stateNameLength);
|
||||
stateName[stateNameLength] = 0;
|
||||
storage.Read(stateName);
|
||||
|
||||
LegoState* state = GetState(stateName);
|
||||
if (!state) {
|
||||
|
@ -402,11 +401,11 @@ MxResult LegoGameState::Load(MxULong p_slot)
|
|||
}
|
||||
}
|
||||
|
||||
state->Serialize(&fileStorage);
|
||||
state->Serialize(&storage);
|
||||
}
|
||||
}
|
||||
|
||||
Read(&fileStorage, &actArea);
|
||||
storage.Read(actArea);
|
||||
|
||||
if (m_currentAct == e_act1) {
|
||||
m_unk0x42c = e_undefined;
|
||||
|
@ -537,10 +536,10 @@ void LegoGameState::SerializePlayersInfo(MxS16 p_flags)
|
|||
|
||||
if (fileStorage.Open(playersGSI.GetData(), p_flags) == SUCCESS) {
|
||||
if (fileStorage.IsReadMode()) {
|
||||
Read(&fileStorage, &m_playerCount);
|
||||
fileStorage.Read(m_playerCount);
|
||||
}
|
||||
else if (fileStorage.IsWriteMode()) {
|
||||
Write(&fileStorage, m_playerCount);
|
||||
fileStorage.Write(m_playerCount);
|
||||
}
|
||||
|
||||
for (MxS16 i = 0; i < m_playerCount; i++) {
|
||||
|
@ -1153,16 +1152,16 @@ LegoGameState::Username::Username()
|
|||
|
||||
// FUNCTION: LEGO1 0x1003c690
|
||||
// FUNCTION: BETA10 0x10086c57
|
||||
MxResult LegoGameState::Username::Serialize(LegoStorage* p_storage)
|
||||
MxResult LegoGameState::Username::Serialize(LegoFile* p_file)
|
||||
{
|
||||
if (p_storage->IsReadMode()) {
|
||||
if (p_file->IsReadMode()) {
|
||||
for (MxS16 i = 0; i < (MxS16) sizeOfArray(m_letters); i++) {
|
||||
Read(p_storage, &m_letters[i]);
|
||||
p_file->Read(m_letters[i]);
|
||||
}
|
||||
}
|
||||
else if (p_storage->IsWriteMode()) {
|
||||
else if (p_file->IsWriteMode()) {
|
||||
for (MxS16 i = 0; i < (MxS16) sizeOfArray(m_letters); i++) {
|
||||
Write(p_storage, m_letters[i]);
|
||||
p_file->Write(m_letters[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1182,28 +1181,28 @@ LegoGameState::Username& LegoGameState::Username::operator=(const Username& p_ot
|
|||
MxResult LegoGameState::ScoreItem::Serialize(LegoFile* p_file)
|
||||
{
|
||||
if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_totalScore);
|
||||
p_file->Read(m_totalScore);
|
||||
|
||||
for (MxS32 i = 0; i < 5; i++) {
|
||||
for (MxS32 j = 0; j < 5; j++) {
|
||||
Read(p_file, &m_scores[i][j]);
|
||||
p_file->Read(m_scores[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
m_name.Serialize(p_file);
|
||||
Read(p_file, &m_unk0x2a);
|
||||
p_file->Read(m_unk0x2a);
|
||||
}
|
||||
else if (p_file->IsWriteMode()) {
|
||||
Write(p_file, m_totalScore);
|
||||
p_file->Write(m_totalScore);
|
||||
|
||||
for (MxS32 i = 0; i < 5; i++) {
|
||||
for (MxS32 j = 0; j < 5; j++) {
|
||||
Write(p_file, m_scores[i][j]);
|
||||
p_file->Write(m_scores[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
m_name.Serialize(p_file);
|
||||
Write(p_file, m_unk0x2a);
|
||||
p_file->Write(m_unk0x2a);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
@ -1328,21 +1327,21 @@ LegoGameState::ScoreItem* LegoGameState::History::FUN_1003cc90(
|
|||
MxResult LegoGameState::History::Serialize(LegoFile* p_file)
|
||||
{
|
||||
if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_unk0x372);
|
||||
Read(p_file, &m_count);
|
||||
p_file->Read(m_unk0x372);
|
||||
p_file->Read(m_count);
|
||||
|
||||
for (MxS16 i = 0; i < m_count; i++) {
|
||||
MxS16 j;
|
||||
Read(p_file, &j);
|
||||
p_file->Read(j);
|
||||
m_scores[i].Serialize(p_file);
|
||||
}
|
||||
}
|
||||
else if (p_file->IsWriteMode()) {
|
||||
Write(p_file, m_unk0x372);
|
||||
Write(p_file, m_count);
|
||||
p_file->Write(m_unk0x372);
|
||||
p_file->Write(m_count);
|
||||
|
||||
for (MxS16 i = 0; i < m_count; i++) {
|
||||
Write(p_file, i);
|
||||
p_file->Write(i);
|
||||
m_scores[i].Serialize(p_file);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -668,7 +668,7 @@ LegoNamedTexture* ReadNamedTexture(LegoFile* p_file)
|
|||
LegoNamedTexture* namedTexture = NULL;
|
||||
MxString string;
|
||||
|
||||
p_file->ReadString(string);
|
||||
p_file->Read(string);
|
||||
|
||||
texture = new LegoTexture();
|
||||
if (texture != NULL) {
|
||||
|
@ -743,7 +743,7 @@ void WriteDefaultTexture(LegoFile* p_file, const char* p_name)
|
|||
LegoTexture texture;
|
||||
texture.SetImage(image);
|
||||
|
||||
p_file->WriteString(name);
|
||||
p_file->Write(MxString(name));
|
||||
texture.Write(p_file);
|
||||
}
|
||||
else {
|
||||
|
@ -760,7 +760,7 @@ void WriteDefaultTexture(LegoFile* p_file, const char* p_name)
|
|||
// FUNCTION: LEGO1 0x1003f8a0
|
||||
void WriteNamedTexture(LegoFile* p_file, LegoNamedTexture* p_namedTexture)
|
||||
{
|
||||
p_file->WriteString(*p_namedTexture->GetName());
|
||||
p_file->Write(MxString(*p_namedTexture->GetName()));
|
||||
p_namedTexture->GetTexture()->Write(p_file);
|
||||
}
|
||||
|
||||
|
|
|
@ -513,18 +513,18 @@ MxResult GasStationState::Serialize(LegoFile* p_file)
|
|||
LegoState::Serialize(p_file);
|
||||
|
||||
if (p_file->IsWriteMode()) {
|
||||
Write(p_file, m_pepperAction);
|
||||
Write(p_file, m_mamaAction);
|
||||
Write(p_file, m_papaAction);
|
||||
Write(p_file, m_nickAction);
|
||||
Write(p_file, m_lauraAction);
|
||||
p_file->Write(m_pepperAction);
|
||||
p_file->Write(m_mamaAction);
|
||||
p_file->Write(m_papaAction);
|
||||
p_file->Write(m_nickAction);
|
||||
p_file->Write(m_lauraAction);
|
||||
}
|
||||
else if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_pepperAction);
|
||||
Read(p_file, &m_mamaAction);
|
||||
Read(p_file, &m_papaAction);
|
||||
Read(p_file, &m_nickAction);
|
||||
Read(p_file, &m_lauraAction);
|
||||
p_file->Read(m_pepperAction);
|
||||
p_file->Read(m_mamaAction);
|
||||
p_file->Read(m_papaAction);
|
||||
p_file->Read(m_nickAction);
|
||||
p_file->Read(m_lauraAction);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
|
@ -694,25 +694,26 @@ HospitalState::HospitalState()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10076530
|
||||
// FUNCTION: BETA10 0x1002db26
|
||||
MxResult HospitalState::Serialize(LegoFile* p_file)
|
||||
{
|
||||
LegoState::Serialize(p_file);
|
||||
|
||||
if (p_file->IsWriteMode()) {
|
||||
Write(p_file, m_unk0x0c);
|
||||
Write(p_file, m_unk0x0e);
|
||||
Write(p_file, m_unk0x10);
|
||||
Write(p_file, m_unk0x12);
|
||||
Write(p_file, m_unk0x14);
|
||||
Write(p_file, m_unk0x16);
|
||||
p_file->Write(m_unk0x0c);
|
||||
p_file->Write(m_unk0x0e);
|
||||
p_file->Write(m_unk0x10);
|
||||
p_file->Write(m_unk0x12);
|
||||
p_file->Write(m_unk0x14);
|
||||
p_file->Write(m_unk0x16);
|
||||
}
|
||||
else if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_unk0x0c);
|
||||
Read(p_file, &m_unk0x0e);
|
||||
Read(p_file, &m_unk0x10);
|
||||
Read(p_file, &m_unk0x12);
|
||||
Read(p_file, &m_unk0x14);
|
||||
Read(p_file, &m_unk0x16);
|
||||
p_file->Read(m_unk0x0c);
|
||||
p_file->Read(m_unk0x0e);
|
||||
p_file->Read(m_unk0x10);
|
||||
p_file->Read(m_unk0x12);
|
||||
p_file->Read(m_unk0x14);
|
||||
p_file->Read(m_unk0x16);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
|
@ -1337,82 +1337,83 @@ MxResult Act1State::Serialize(LegoFile* p_file)
|
|||
m_racecarPlane.Serialize(p_file);
|
||||
|
||||
if (p_file->IsWriteMode()) {
|
||||
if (m_helicopterPlane.IsPresent()) {
|
||||
if (m_helicopterWindshield) {
|
||||
WriteNamedTexture(p_file, m_helicopterWindshield);
|
||||
}
|
||||
else {
|
||||
// TODO: Seems to match better when using strcmp directly instead of IsPresent
|
||||
if (strcmp(m_helicopterPlane.m_name.GetData(), "")) {
|
||||
if (!m_helicopterWindshield) {
|
||||
WriteDefaultTexture(p_file, "chwind.gif");
|
||||
}
|
||||
|
||||
if (m_helicopterJetLeft) {
|
||||
WriteNamedTexture(p_file, m_helicopterJetLeft);
|
||||
}
|
||||
else {
|
||||
WriteNamedTexture(p_file, m_helicopterWindshield);
|
||||
}
|
||||
|
||||
if (!m_helicopterJetLeft) {
|
||||
WriteDefaultTexture(p_file, "chjetl.gif");
|
||||
}
|
||||
|
||||
if (m_helicopterJetRight) {
|
||||
WriteNamedTexture(p_file, m_helicopterJetRight);
|
||||
}
|
||||
else {
|
||||
WriteNamedTexture(p_file, m_helicopterJetLeft);
|
||||
}
|
||||
|
||||
if (!m_helicopterJetRight) {
|
||||
WriteDefaultTexture(p_file, "chjetr.gif");
|
||||
}
|
||||
else {
|
||||
WriteNamedTexture(p_file, m_helicopterJetRight);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_jetskiPlane.IsPresent()) {
|
||||
if (m_jetskiFront) {
|
||||
WriteNamedTexture(p_file, m_jetskiFront);
|
||||
}
|
||||
else {
|
||||
if (strcmp(m_jetskiPlane.m_name.GetData(), "")) {
|
||||
if (!m_jetskiFront) {
|
||||
WriteDefaultTexture(p_file, "jsfrnt.gif");
|
||||
}
|
||||
|
||||
if (m_jetskiWindshield) {
|
||||
WriteNamedTexture(p_file, m_jetskiWindshield);
|
||||
}
|
||||
else {
|
||||
WriteNamedTexture(p_file, m_jetskiFront);
|
||||
}
|
||||
|
||||
if (!m_jetskiWindshield) {
|
||||
WriteDefaultTexture(p_file, "jswnsh.gif");
|
||||
}
|
||||
else {
|
||||
WriteNamedTexture(p_file, m_jetskiWindshield);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_dunebuggyPlane.IsPresent()) {
|
||||
if (m_dunebuggyFront) {
|
||||
WriteNamedTexture(p_file, m_dunebuggyFront);
|
||||
}
|
||||
else {
|
||||
if (strcmp(m_dunebuggyPlane.m_name.GetData(), "")) {
|
||||
if (!m_dunebuggyFront) {
|
||||
WriteDefaultTexture(p_file, "dbfrfn.gif");
|
||||
}
|
||||
else {
|
||||
WriteNamedTexture(p_file, m_dunebuggyFront);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_racecarPlane.IsPresent()) {
|
||||
if (m_racecarFront) {
|
||||
WriteNamedTexture(p_file, m_racecarFront);
|
||||
}
|
||||
else {
|
||||
if (strcmp(m_racecarPlane.m_name.GetData(), "")) {
|
||||
if (!m_racecarFront) {
|
||||
WriteDefaultTexture(p_file, "rcfrnt.gif");
|
||||
}
|
||||
|
||||
if (m_racecarBack) {
|
||||
WriteNamedTexture(p_file, m_racecarBack);
|
||||
}
|
||||
else {
|
||||
WriteNamedTexture(p_file, m_racecarFront);
|
||||
}
|
||||
|
||||
if (!m_racecarBack) {
|
||||
WriteDefaultTexture(p_file, "rcback.gif");
|
||||
}
|
||||
else {
|
||||
WriteNamedTexture(p_file, m_racecarBack);
|
||||
}
|
||||
|
||||
if (m_racecarTail) {
|
||||
WriteNamedTexture(p_file, m_racecarTail);
|
||||
if (!m_racecarTail) {
|
||||
WriteDefaultTexture(p_file, "rctail.gif");
|
||||
}
|
||||
else {
|
||||
WriteDefaultTexture(p_file, "rctail.gif");
|
||||
WriteNamedTexture(p_file, m_racecarTail);
|
||||
}
|
||||
}
|
||||
|
||||
m_cptClickDialogue.WriteToFile(p_file);
|
||||
Write(p_file, m_unk0x022);
|
||||
p_file->Write(m_cptClickDialogue.m_nextIndex);
|
||||
p_file->Write(m_unk0x022);
|
||||
}
|
||||
else if (p_file->IsReadMode()) {
|
||||
if (m_helicopterPlane.IsPresent()) {
|
||||
if (strcmp(m_helicopterPlane.m_name.GetData(), "")) {
|
||||
m_helicopterWindshield = ReadNamedTexture(p_file);
|
||||
if (m_helicopterWindshield == NULL) {
|
||||
return FAILURE;
|
||||
|
@ -1429,7 +1430,7 @@ MxResult Act1State::Serialize(LegoFile* p_file)
|
|||
}
|
||||
}
|
||||
|
||||
if (m_jetskiPlane.IsPresent()) {
|
||||
if (strcmp(m_jetskiPlane.m_name.GetData(), "")) {
|
||||
m_jetskiFront = ReadNamedTexture(p_file);
|
||||
if (m_jetskiFront == NULL) {
|
||||
return FAILURE;
|
||||
|
@ -1441,14 +1442,14 @@ MxResult Act1State::Serialize(LegoFile* p_file)
|
|||
}
|
||||
}
|
||||
|
||||
if (m_dunebuggyPlane.IsPresent()) {
|
||||
if (strcmp(m_dunebuggyPlane.m_name.GetData(), "")) {
|
||||
m_dunebuggyFront = ReadNamedTexture(p_file);
|
||||
if (m_dunebuggyFront == NULL) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_racecarPlane.IsPresent()) {
|
||||
if (strcmp(m_racecarPlane.m_name.GetData(), "")) {
|
||||
m_racecarFront = ReadNamedTexture(p_file);
|
||||
if (m_racecarFront == NULL) {
|
||||
return FAILURE;
|
||||
|
@ -1465,11 +1466,10 @@ MxResult Act1State::Serialize(LegoFile* p_file)
|
|||
}
|
||||
}
|
||||
|
||||
m_cptClickDialogue.ReadFromFile(p_file);
|
||||
Read(p_file, &m_unk0x022);
|
||||
p_file->Read(m_cptClickDialogue.m_nextIndex);
|
||||
p_file->Read(m_unk0x022);
|
||||
}
|
||||
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,15 +208,16 @@ PoliceState::PoliceState()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1005e990
|
||||
// FUNCTION: BETA10 0x100f08b0
|
||||
MxResult PoliceState::Serialize(LegoFile* p_file)
|
||||
{
|
||||
LegoState::Serialize(p_file);
|
||||
|
||||
if (p_file->IsReadMode()) {
|
||||
Read(p_file, &m_policeScript);
|
||||
p_file->Read((MxS32&) m_policeScript);
|
||||
}
|
||||
else {
|
||||
Write(p_file, m_policeScript);
|
||||
p_file->Write((MxS32) m_policeScript);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
|
@ -40,18 +40,6 @@ protected:
|
|||
LegoU8 m_mode; // 0x04
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline void Read(LegoStorage* p_storage, T* p_variable, LegoU32 p_size = sizeof(T))
|
||||
{
|
||||
p_storage->Read(p_variable, p_size);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Write(LegoStorage* p_storage, T p_variable)
|
||||
{
|
||||
p_storage->Write(&p_variable, sizeof(p_variable));
|
||||
}
|
||||
|
||||
// VTABLE: LEGO1 0x100db710
|
||||
// SIZE 0x10
|
||||
class LegoMemory : public LegoStorage {
|
||||
|
@ -98,50 +86,148 @@ public:
|
|||
LegoResult SetPosition(LegoU32 p_position) override; // vtable+0x10
|
||||
LegoResult Open(const char* p_name, LegoU32 p_mode);
|
||||
|
||||
// FUNCTION: LEGO1 0x100343d0
|
||||
LegoStorage* WriteVector3(Mx3DPointFloat p_vec3)
|
||||
// FUNCTION: LEGO1 0x10006030
|
||||
// FUNCTION: BETA10 0x10017bb0
|
||||
LegoStorage* Write(MxString p_data)
|
||||
{
|
||||
::Write(this, p_vec3[0]);
|
||||
::Write(this, p_vec3[1]);
|
||||
::Write(this, p_vec3[2]);
|
||||
Write(p_data.GetData());
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10034430
|
||||
LegoStorage* ReadVector3(Mx3DPointFloat& p_vec3)
|
||||
// FUNCTION: BETA10 0x10017c80
|
||||
LegoStorage* Write(const char* p_data)
|
||||
{
|
||||
::Read(this, &p_vec3[0]);
|
||||
::Read(this, &p_vec3[1]);
|
||||
::Read(this, &p_vec3[2]);
|
||||
LegoS16 length = strlen(p_data);
|
||||
Write(length);
|
||||
Write(p_data, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1004b0d0
|
||||
LegoStorage* Write(LegoU8 p_data)
|
||||
{
|
||||
Write(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x10017ce0
|
||||
LegoStorage* Write(LegoS16 p_data)
|
||||
{
|
||||
Write(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1004b110
|
||||
LegoStorage* Write(LegoU16 p_data)
|
||||
{
|
||||
Write(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Type might be different (LegoS32). MxS32 is incompatible with LegoS32.
|
||||
// FUNCTION: BETA10 0x10088540
|
||||
LegoStorage* Write(MxS32 p_data)
|
||||
{
|
||||
Write(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Type might be different (LegoU32). MxU32 is incompatible with LegoU32.
|
||||
// FUNCTION: BETA10 0x1004b150
|
||||
LegoStorage* Write(MxU32 p_data)
|
||||
{
|
||||
Write(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
LegoStorage* Write(LegoFloat p_data)
|
||||
{
|
||||
Write(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100343d0
|
||||
LegoStorage* Write(Mx3DPointFloat p_vec)
|
||||
{
|
||||
Write(p_vec[0]);
|
||||
Write(p_vec[1]);
|
||||
Write(p_vec[2]);
|
||||
return this;
|
||||
}
|
||||
|
||||
LegoStorage* Read(char* p_data)
|
||||
{
|
||||
LegoS16 length;
|
||||
Read(length);
|
||||
Read(p_data, length);
|
||||
p_data[length] = '\0';
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10034470
|
||||
LegoStorage* ReadString(MxString& p_str)
|
||||
LegoStorage* Read(MxString& p_data)
|
||||
{
|
||||
MxS16 len;
|
||||
Read(&len, sizeof(MxS16));
|
||||
LegoS16 length;
|
||||
Read(length);
|
||||
|
||||
char* text = new char[len + 1];
|
||||
Read(text, len);
|
||||
char* text = new char[length + 1];
|
||||
Read(text, length);
|
||||
|
||||
text[len] = '\0';
|
||||
p_str = text;
|
||||
text[length] = '\0';
|
||||
p_data = text;
|
||||
delete[] text;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10006030
|
||||
LegoStorage* WriteString(MxString p_str)
|
||||
// FUNCTION: BETA10 0x1004b190
|
||||
LegoStorage* Read(LegoU8& p_data)
|
||||
{
|
||||
const char* data = p_str.GetData();
|
||||
LegoU32 fullLength = strlen(data);
|
||||
Read(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
LegoU16 limitedLength = (LegoU16) fullLength;
|
||||
Write(&limitedLength, sizeof(limitedLength));
|
||||
Write((char*) data, (LegoS16) fullLength);
|
||||
// FUNCTION: BETA10 0x10024680
|
||||
LegoStorage* Read(LegoS16& p_data)
|
||||
{
|
||||
Read(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1004b1d0
|
||||
LegoStorage* Read(LegoU16& p_data)
|
||||
{
|
||||
Read(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Type might be different (LegoS32). MxS32 is incompatible with LegoS32.
|
||||
// FUNCTION: BETA10 0x10088580
|
||||
LegoStorage* Read(MxS32& p_data)
|
||||
{
|
||||
Read(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Type might be different (LegoU32). MxU32 is incompatible with LegoU32.
|
||||
// FUNCTION: BETA10 0x1004b210
|
||||
LegoStorage* Read(MxU32& p_data)
|
||||
{
|
||||
Read(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
LegoStorage* Read(LegoFloat& p_data)
|
||||
{
|
||||
Read(&p_data, sizeof(p_data));
|
||||
return this;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10034430
|
||||
LegoStorage* Read(Mx3DPointFloat& p_vec)
|
||||
{
|
||||
Read(p_vec[0]);
|
||||
Read(p_vec[1]);
|
||||
Read(p_vec[2]);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue