mirror of
https://github.com/GTAmodding/re3.git
synced 2025-01-18 12:26:34 +00:00
Fix script load
This commit is contained in:
parent
eaebaa6db3
commit
1c5a864598
1 changed files with 57 additions and 41 deletions
|
@ -2206,29 +2206,33 @@ bool CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
|
||||||
Init(); // TODO: in LCS CTheScripts::Init call GenericLoad, which then calls LoadAllScripts
|
Init(); // TODO: in LCS CTheScripts::Init call GenericLoad, which then calls LoadAllScripts
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE);
|
||||||
uint32 varSpace = ReadSaveBuf<uint32>(buf);
|
uint32 varSpace, type, handle;
|
||||||
|
uint32 tmp;
|
||||||
|
|
||||||
|
ReadSaveBuf(&varSpace, buf);
|
||||||
if (*(int32*)&ScriptSpace[0] != *(int32*)&buf[0] || *(int32*)&ScriptSpace[4] != *(int32*)&buf[4]) {
|
if (*(int32*)&ScriptSpace[0] != *(int32*)&buf[0] || *(int32*)&ScriptSpace[4] != *(int32*)&buf[4]) {
|
||||||
printf("\n===================================================\nSave Game Mismatch!!!\n");
|
printf("\n===================================================\nSave Game Mismatch!!!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does
|
for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does
|
||||||
if (i < 8)
|
if (i < 8)
|
||||||
ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&ScriptSpace[i], buf);
|
||||||
else if (GetSaveVarIndex(i / 4 * 4) != -1)
|
else if (GetSaveVarIndex(i / 4 * 4) != -1)
|
||||||
ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&ScriptSpace[i], buf);
|
||||||
else
|
else
|
||||||
ReadSaveBuf<uint8>(buf);
|
SkipSaveBuf(buf, 1);
|
||||||
}
|
}
|
||||||
// everything else is... gone? TODO
|
// everything else is... gone? TODO
|
||||||
script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE);
|
ReadSaveBuf(&tmp, buf);
|
||||||
OnAMissionFlag = ReadSaveBuf<uint32>(buf);
|
script_assert(tmp == SCRIPT_DATA_SIZE);
|
||||||
LastMissionPassedTime = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&OnAMissionFlag, buf);
|
||||||
|
ReadSaveBuf(&LastMissionPassedTime, buf);
|
||||||
for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
|
for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
|
||||||
CollectiveArray[i] = ReadSaveBuf<tCollectiveData>(buf);
|
ReadSaveBuf(&CollectiveArray[i], buf);
|
||||||
NextFreeCollectiveIndex = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&NextFreeCollectiveIndex, buf);
|
||||||
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
|
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
|
||||||
uint32 type = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&type, buf);
|
||||||
uint32 handle = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&handle, buf);
|
||||||
/*
|
/*
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -2244,16 +2248,17 @@ INITSAVEBUF
|
||||||
script_assert(false);
|
script_assert(false);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/*BuildingSwapArray[i].m_nNewModel = */ReadSaveBuf<uint32>(buf);
|
/*BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);*/
|
||||||
/*BuildingSwapArray[i].m_nOldModel = */ReadSaveBuf<uint32>(buf);
|
/*BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);*/
|
||||||
|
SkipSaveBuf(buf, 8);
|
||||||
/*
|
/*
|
||||||
if (BuildingSwapArray[i].m_pBuilding)
|
if (BuildingSwapArray[i].m_pBuilding)
|
||||||
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
|
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
|
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
|
||||||
uint32 type = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&type, buf);
|
||||||
uint32 handle = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&handle, buf);
|
||||||
/*
|
/*
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -2278,14 +2283,25 @@ INITSAVEBUF
|
||||||
InvisibilitySettingArray[i]->bIsVisible = false;
|
InvisibilitySettingArray[i]->bIsVisible = false;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
script_assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile);
|
bool tmpBool;
|
||||||
/*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&tmpBool, buf);
|
||||||
ReadSaveBuf<uint16>(buf);
|
script_assert(tmpBool == bUsingAMultiScriptFile);
|
||||||
script_assert(ReadSaveBuf<uint32>(buf) == MainScriptSize);
|
///*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
|
||||||
script_assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize);
|
//ReadSaveBuf<uint16>(buf);
|
||||||
script_assert(ReadSaveBuf<uint16>(buf) == NumberOfMissionScripts);
|
|
||||||
script_assert(ReadSaveBuf<uint16>(buf) == NumberOfExclusiveMissionScripts);
|
SkipSaveBuf(buf, 3);
|
||||||
uint32 runningScripts = ReadSaveBuf<uint32>(buf);
|
|
||||||
|
ReadSaveBuf(&tmp, buf);
|
||||||
|
script_assert(tmp == MainScriptSize);
|
||||||
|
ReadSaveBuf(&tmp, buf);
|
||||||
|
script_assert(tmp == LargestMissionScriptSize);
|
||||||
|
uint16 tmp16;
|
||||||
|
ReadSaveBuf(&tmp16, buf);
|
||||||
|
script_assert(tmp16 == NumberOfMissionScripts);
|
||||||
|
ReadSaveBuf(&tmp16, buf);
|
||||||
|
script_assert(tmp16 == NumberOfExclusiveMissionScripts);
|
||||||
|
uint32 runningScripts;
|
||||||
|
ReadSaveBuf(&runningScripts, buf);
|
||||||
for (uint32 i = 0; i < runningScripts; i++)
|
for (uint32 i = 0; i < runningScripts; i++)
|
||||||
CRunningScript().Load(buf);
|
CRunningScript().Load(buf);
|
||||||
StartTestScript(); // <- tmp hack
|
StartTestScript(); // <- tmp hack
|
||||||
|
@ -2336,38 +2352,38 @@ void CRunningScript::Load(uint8*& buf)
|
||||||
{
|
{
|
||||||
#ifdef COMPATIBLE_SAVES
|
#ifdef COMPATIBLE_SAVES
|
||||||
SkipSaveBuf(buf, 8);
|
SkipSaveBuf(buf, 8);
|
||||||
m_nId = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nId, buf);
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
m_abScriptName[i] = ReadSaveBuf<char>(buf);
|
ReadSaveBuf(&m_abScriptName[i], buf);
|
||||||
m_nIp = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nIp, buf);
|
||||||
#ifdef CHECK_STRUCT_SIZES
|
#ifdef CHECK_STRUCT_SIZES
|
||||||
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
|
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < MAX_STACK_DEPTH; i++)
|
for (int i = 0; i < MAX_STACK_DEPTH; i++)
|
||||||
m_anStack[i] = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_anStack[i], buf);
|
||||||
m_nStackPointer = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&m_nStackPointer, buf);
|
||||||
SkipSaveBuf(buf, 2);
|
SkipSaveBuf(buf, 2);
|
||||||
#ifdef CHECK_STRUCT_SIZES
|
#ifdef CHECK_STRUCT_SIZES
|
||||||
static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106");
|
static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106");
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
|
for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
|
||||||
m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_anLocalVariables[i], buf);
|
||||||
m_nLocalsPointer = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nLocalsPointer, buf);
|
||||||
m_bIsActive = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bIsActive, buf);
|
||||||
m_bCondResult = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bCondResult, buf);
|
||||||
m_bIsMissionScript = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bIsMissionScript, buf);
|
||||||
m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bSkipWakeTime, buf);
|
||||||
m_nWakeTime = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nWakeTime, buf);
|
||||||
m_nAndOrState = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&m_nAndOrState, buf);
|
||||||
m_bNotFlag = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bNotFlag, buf);
|
||||||
m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bDeatharrestEnabled, buf);
|
||||||
m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bDeatharrestExecuted, buf);
|
||||||
m_bMissionFlag = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bMissionFlag, buf);
|
||||||
SkipSaveBuf(buf, 2);
|
SkipSaveBuf(buf, 2);
|
||||||
#else
|
#else
|
||||||
CRunningScript* n = next;
|
CRunningScript* n = next;
|
||||||
CRunningScript* p = prev;
|
CRunningScript* p = prev;
|
||||||
*this = ReadSaveBuf<CRunningScript>(buf);
|
ReadSaveBuf(this, buf);
|
||||||
next = n;
|
next = n;
|
||||||
prev = p;
|
prev = p;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue