mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-30 19:51:15 +00:00
More match
This commit is contained in:
parent
7a1b8f1484
commit
8ec140551b
@ -274,84 +274,101 @@ MxResult LegoGameState::Load(MxULong p_slot)
|
|||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
LegoFile fileStream;
|
LegoFile fileStream;
|
||||||
MxVariableTable* variableTable = VariableTable();
|
MxVariableTable* variableTable = VariableTable();
|
||||||
|
|
||||||
MxString savePath;
|
MxString savePath;
|
||||||
GetFileSavePath(&savePath, p_slot);
|
GetFileSavePath(&savePath, p_slot);
|
||||||
|
|
||||||
if (fileStream.Open(savePath.GetData(), LegoFile::c_read) != FAILURE) {
|
if (fileStream.Open(savePath.GetData(), LegoFile::c_read) != FAILURE) {
|
||||||
MxU32 version;
|
MxU32 version;
|
||||||
Read(&fileStream, &version, 4);
|
Read(&fileStream, &version);
|
||||||
if (version != 0x1000C) {
|
|
||||||
|
if (version != 0x1000c) {
|
||||||
OmniError("Saved game version mismatch", 0);
|
OmniError("Saved game version mismatch", 0);
|
||||||
goto checkErr;
|
goto done;
|
||||||
}
|
}
|
||||||
Read(&fileStream, &m_unk0x24, 2);
|
|
||||||
|
Read(&fileStream, &m_unk0x24);
|
||||||
|
|
||||||
MxS16 act;
|
MxS16 act;
|
||||||
Read(&fileStream, &act, 2);
|
Read(&fileStream, &act);
|
||||||
SetCurrentAct((Act) act);
|
SetCurrentAct((Act) act);
|
||||||
Read(&fileStream, &m_actorId, 1);
|
|
||||||
|
Read(&fileStream, &m_actorId);
|
||||||
if (m_actorId) {
|
if (m_actorId) {
|
||||||
SetActor(m_actorId);
|
SetActor(m_actorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
MxU32 status;
|
MxU32 status;
|
||||||
do {
|
do {
|
||||||
MxU32 status = ReadVariable(&fileStream, variableTable);
|
status = ReadVariable(&fileStream, variableTable);
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
goto checkErr;
|
goto done;
|
||||||
}
|
}
|
||||||
} while (status != 2);
|
} while (status != 2);
|
||||||
|
|
||||||
m_backgroundColor->SetLights();
|
m_backgroundColor->SetLights();
|
||||||
const char* lightPosition = VariableTable()->GetVariable("lightposition");
|
const char* lightPosition = VariableTable()->GetVariable("lightposition");
|
||||||
|
|
||||||
if (lightPosition) {
|
if (lightPosition) {
|
||||||
SetLightPosition(atoi(lightPosition));
|
SetLightPosition(atoi(lightPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnkSaveDataWriter()->ReadSaveData3(&fileStream) == FAILURE) {
|
if (UnkSaveDataWriter()->ReadSaveData3(&fileStream) == FAILURE) {
|
||||||
goto checkErr;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlantManager()->Load(&fileStream) == FAILURE) {
|
if (PlantManager()->Load(&fileStream) == FAILURE) {
|
||||||
goto checkErr;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BuildingManager()->Load(&fileStream) == FAILURE) {
|
if (BuildingManager()->Load(&fileStream) == FAILURE) {
|
||||||
goto checkErr;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeleteState() != SUCCESS) {
|
if (DeleteState() != SUCCESS) {
|
||||||
goto checkErr;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
MxS16 count;
|
MxS16 count;
|
||||||
MxS16 stateNameLength;
|
|
||||||
char stateName[80];
|
char stateName[80];
|
||||||
Read(&fileStream, &count, 2);
|
Read(&fileStream, &count);
|
||||||
for (MxS16 i = 0; i < count; i++) {
|
|
||||||
Read(&fileStream, &stateNameLength, 2);
|
if (count) {
|
||||||
Read(&fileStream, stateName, (int) stateNameLength);
|
for (MxS16 i = 0; i < count; i++) {
|
||||||
stateName[stateNameLength] = 0;
|
MxS16 stateNameLength;
|
||||||
LegoState* state = GetState(stateName);
|
Read(&fileStream, &stateNameLength);
|
||||||
if (!state) {
|
Read(&fileStream, stateName, (MxULong) stateNameLength);
|
||||||
state = CreateState(stateName);
|
stateName[stateNameLength] = 0;
|
||||||
|
|
||||||
|
LegoState* state = GetState(stateName);
|
||||||
if (!state) {
|
if (!state) {
|
||||||
goto checkErr;
|
state = CreateState(stateName);
|
||||||
|
|
||||||
|
if (!state) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state->VTable0x1c(&fileStream);
|
||||||
}
|
}
|
||||||
state->VTable0x1c(&fileStream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MxS16 area;
|
MxS16 area;
|
||||||
Read(&fileStream, &area, 2);
|
Read(&fileStream, &area);
|
||||||
|
|
||||||
if (m_currentAct == 0) {
|
if (m_currentAct == 0) {
|
||||||
m_unk0x42c = e_noArea;
|
m_unk0x42c = e_noArea;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_unk0x42c = (Area) area;
|
m_unk0x42c = (Area) area;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = SUCCESS;
|
result = SUCCESS;
|
||||||
m_isDirty = FALSE;
|
m_isDirty = FALSE;
|
||||||
}
|
}
|
||||||
checkErr:
|
|
||||||
|
done:
|
||||||
if (result != SUCCESS) {
|
if (result != SUCCESS) {
|
||||||
OmniError("Game state loading was not successful!", 0);
|
OmniError("Game state loading was not successful!", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,18 +41,11 @@ class LegoStorage {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void Read(LegoStorage* p_storage, T* p_variable, const MxS32 p_size)
|
inline void Read(LegoStorage* p_storage, T* p_variable, LegoU32 p_size = sizeof(T))
|
||||||
{
|
{
|
||||||
p_storage->Read(p_variable, p_size);
|
p_storage->Read(p_variable, p_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
|
||||||
inline void Write(LegoStorage* p_storage, T* p_variable)
|
|
||||||
{
|
|
||||||
T variable = *p_variable;
|
|
||||||
p_storage->Write(&variable, sizeof(variable));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void WriteScalar(LegoStorage* p_storage, T p_variable)
|
inline void WriteScalar(LegoStorage* p_storage, T p_variable)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user