mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-28 18:51:16 +00:00
Match
This commit is contained in:
parent
8ec140551b
commit
60f65ba340
@ -278,92 +278,94 @@ MxResult LegoGameState::Load(MxULong p_slot)
|
||||
MxString savePath;
|
||||
GetFileSavePath(&savePath, p_slot);
|
||||
|
||||
if (fileStream.Open(savePath.GetData(), LegoFile::c_read) != FAILURE) {
|
||||
MxU32 version;
|
||||
Read(&fileStream, &version);
|
||||
if (fileStream.Open(savePath.GetData(), LegoFile::c_read) == FAILURE)
|
||||
goto done;
|
||||
|
||||
if (version != 0x1000c) {
|
||||
OmniError("Saved game version mismatch", 0);
|
||||
goto done;
|
||||
}
|
||||
MxU32 version;
|
||||
Read(&fileStream, &version);
|
||||
|
||||
Read(&fileStream, &m_unk0x24);
|
||||
|
||||
MxS16 act;
|
||||
Read(&fileStream, &act);
|
||||
SetCurrentAct((Act) act);
|
||||
|
||||
Read(&fileStream, &m_actorId);
|
||||
if (m_actorId) {
|
||||
SetActor(m_actorId);
|
||||
}
|
||||
|
||||
MxU32 status;
|
||||
do {
|
||||
status = ReadVariable(&fileStream, variableTable);
|
||||
if (status == 1) {
|
||||
goto done;
|
||||
}
|
||||
} while (status != 2);
|
||||
|
||||
m_backgroundColor->SetLights();
|
||||
const char* lightPosition = VariableTable()->GetVariable("lightposition");
|
||||
|
||||
if (lightPosition) {
|
||||
SetLightPosition(atoi(lightPosition));
|
||||
}
|
||||
|
||||
if (UnkSaveDataWriter()->ReadSaveData3(&fileStream) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (PlantManager()->Load(&fileStream) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (BuildingManager()->Load(&fileStream) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (DeleteState() != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
MxS16 count;
|
||||
char stateName[80];
|
||||
Read(&fileStream, &count);
|
||||
|
||||
if (count) {
|
||||
for (MxS16 i = 0; i < count; i++) {
|
||||
MxS16 stateNameLength;
|
||||
Read(&fileStream, &stateNameLength);
|
||||
Read(&fileStream, stateName, (MxULong) stateNameLength);
|
||||
stateName[stateNameLength] = 0;
|
||||
|
||||
LegoState* state = GetState(stateName);
|
||||
if (!state) {
|
||||
state = CreateState(stateName);
|
||||
|
||||
if (!state) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
state->VTable0x1c(&fileStream);
|
||||
}
|
||||
}
|
||||
|
||||
MxS16 area;
|
||||
Read(&fileStream, &area);
|
||||
|
||||
if (m_currentAct == 0) {
|
||||
m_unk0x42c = e_noArea;
|
||||
}
|
||||
else {
|
||||
m_unk0x42c = (Area) area;
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
m_isDirty = FALSE;
|
||||
if (version != 0x1000c) {
|
||||
OmniError("Saved game version mismatch", 0);
|
||||
goto done;
|
||||
}
|
||||
|
||||
Read(&fileStream, &m_unk0x24);
|
||||
|
||||
MxS16 act;
|
||||
Read(&fileStream, &act);
|
||||
SetCurrentAct((Act) act);
|
||||
|
||||
Read(&fileStream, &m_actorId);
|
||||
if (m_actorId) {
|
||||
SetActor(m_actorId);
|
||||
}
|
||||
|
||||
const char* lightPosition;
|
||||
MxU32 status;
|
||||
do {
|
||||
status = ReadVariable(&fileStream, variableTable);
|
||||
if (status == 1) {
|
||||
goto done;
|
||||
}
|
||||
} while (status != 2);
|
||||
|
||||
m_backgroundColor->SetLights();
|
||||
lightPosition = VariableTable()->GetVariable("lightposition");
|
||||
|
||||
if (lightPosition) {
|
||||
SetLightPosition(atoi(lightPosition));
|
||||
}
|
||||
|
||||
if (UnkSaveDataWriter()->ReadSaveData3(&fileStream) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (PlantManager()->Load(&fileStream) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (BuildingManager()->Load(&fileStream) == FAILURE) {
|
||||
goto done;
|
||||
}
|
||||
if (DeleteState() != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
MxS16 count;
|
||||
char stateName[80];
|
||||
Read(&fileStream, &count);
|
||||
|
||||
if (count) {
|
||||
for (MxS16 i = 0; i < count; i++) {
|
||||
MxS16 stateNameLength;
|
||||
Read(&fileStream, &stateNameLength);
|
||||
Read(&fileStream, stateName, (MxULong) stateNameLength);
|
||||
stateName[stateNameLength] = 0;
|
||||
|
||||
LegoState* state = GetState(stateName);
|
||||
if (!state) {
|
||||
state = CreateState(stateName);
|
||||
|
||||
if (!state) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
state->VTable0x1c(&fileStream);
|
||||
}
|
||||
}
|
||||
|
||||
MxS16 area;
|
||||
Read(&fileStream, &area);
|
||||
|
||||
if (m_currentAct == 0) {
|
||||
m_unk0x42c = e_noArea;
|
||||
}
|
||||
else {
|
||||
m_unk0x42c = (Area) area;
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
m_isDirty = FALSE;
|
||||
|
||||
done:
|
||||
if (result != SUCCESS) {
|
||||
OmniError("Game state loading was not successful!", 0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user