summaryrefslogtreecommitdiffstats
path: root/src/control/Script5.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/control/Script5.cpp')
-rw-r--r--src/control/Script5.cpp99
1 files changed, 58 insertions, 41 deletions
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index d9991388..88054f3f 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -16,6 +16,7 @@
#include "SpecialFX.h"
#include "World.h"
#include "main.h"
+#include "SaveBuf.h"
// LCS: file done except TODOs
@@ -2205,29 +2206,33 @@ bool CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
Init(); // TODO: in LCS CTheScripts::Init call GenericLoad, which then calls LoadAllScripts
INITSAVEBUF
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]) {
printf("\n===================================================\nSave Game Mismatch!!!\n");
return false;
}
for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does
if (i < 8)
- ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
+ ReadSaveBuf(&ScriptSpace[i], buf);
else if (GetSaveVarIndex(i / 4 * 4) != -1)
- ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
+ ReadSaveBuf(&ScriptSpace[i], buf);
else
- ReadSaveBuf<uint8>(buf);
+ SkipSaveBuf(buf, 1);
}
// everything else is... gone? TODO
- script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE);
- OnAMissionFlag = ReadSaveBuf<uint32>(buf);
- LastMissionPassedTime = ReadSaveBuf<uint32>(buf);
+ ReadSaveBuf(&tmp, buf);
+ script_assert(tmp == SCRIPT_DATA_SIZE);
+ ReadSaveBuf(&OnAMissionFlag, buf);
+ ReadSaveBuf(&LastMissionPassedTime, buf);
for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
- CollectiveArray[i] = ReadSaveBuf<tCollectiveData>(buf);
- NextFreeCollectiveIndex = ReadSaveBuf<int32>(buf);
+ ReadSaveBuf(&CollectiveArray[i], buf);
+ ReadSaveBuf(&NextFreeCollectiveIndex, buf);
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
- uint32 type = ReadSaveBuf<uint32>(buf);
- uint32 handle = ReadSaveBuf<uint32>(buf);
+ ReadSaveBuf(&type, buf);
+ ReadSaveBuf(&handle, buf);
/*
switch (type) {
case 0:
@@ -2243,16 +2248,17 @@ INITSAVEBUF
script_assert(false);
}
*/
- /*BuildingSwapArray[i].m_nNewModel = */ReadSaveBuf<uint32>(buf);
- /*BuildingSwapArray[i].m_nOldModel = */ReadSaveBuf<uint32>(buf);
+ /*BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);*/
+ /*BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);*/
+ SkipSaveBuf(buf, 8);
/*
if (BuildingSwapArray[i].m_pBuilding)
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
*/
}
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
- uint32 type = ReadSaveBuf<uint32>(buf);
- uint32 handle = ReadSaveBuf<uint32>(buf);
+ ReadSaveBuf(&type, buf);
+ ReadSaveBuf(&handle, buf);
/*
switch (type) {
case 0:
@@ -2277,14 +2283,25 @@ INITSAVEBUF
InvisibilitySettingArray[i]->bIsVisible = false;
*/
}
- script_assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile);
- /*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
- ReadSaveBuf<uint16>(buf);
- script_assert(ReadSaveBuf<uint32>(buf) == MainScriptSize);
- script_assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize);
- script_assert(ReadSaveBuf<uint16>(buf) == NumberOfMissionScripts);
- script_assert(ReadSaveBuf<uint16>(buf) == NumberOfExclusiveMissionScripts);
- uint32 runningScripts = ReadSaveBuf<uint32>(buf);
+ bool tmpBool;
+ ReadSaveBuf(&tmpBool, buf);
+ script_assert(tmpBool == bUsingAMultiScriptFile);
+ ///*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
+ //ReadSaveBuf<uint16>(buf);
+
+ SkipSaveBuf(buf, 3);
+
+ 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++)
CRunningScript().Load(buf);
StartTestScript(); // <- tmp hack
@@ -2335,38 +2352,38 @@ void CRunningScript::Load(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
- m_nId = ReadSaveBuf<int32>(buf);
+ ReadSaveBuf(&m_nId, buf);
for (int i = 0; i < 8; i++)
- m_abScriptName[i] = ReadSaveBuf<char>(buf);
- m_nIp = ReadSaveBuf<uint32>(buf);
+ ReadSaveBuf(&m_abScriptName[i], buf);
+ ReadSaveBuf(&m_nIp, buf);
#ifdef CHECK_STRUCT_SIZES
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
#endif
for (int i = 0; i < MAX_STACK_DEPTH; i++)
- m_anStack[i] = ReadSaveBuf<uint32>(buf);
- m_nStackPointer = ReadSaveBuf<uint16>(buf);
+ ReadSaveBuf(&m_anStack[i], buf);
+ ReadSaveBuf(&m_nStackPointer, buf);
SkipSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106");
#endif
for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
- m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
- m_nLocalsPointer = ReadSaveBuf<int32>(buf);
- m_bIsActive = ReadSaveBuf<bool>(buf);
- m_bCondResult = ReadSaveBuf<bool>(buf);
- m_bIsMissionScript = ReadSaveBuf<bool>(buf);
- m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
- m_nWakeTime = ReadSaveBuf<uint32>(buf);
- m_nAndOrState = ReadSaveBuf<uint16>(buf);
- m_bNotFlag = ReadSaveBuf<bool>(buf);
- m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
- m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
- m_bMissionFlag = ReadSaveBuf<bool>(buf);
+ ReadSaveBuf(&m_anLocalVariables[i], buf);
+ ReadSaveBuf(&m_nLocalsPointer, buf);
+ ReadSaveBuf(&m_bIsActive, buf);
+ ReadSaveBuf(&m_bCondResult, buf);
+ ReadSaveBuf(&m_bIsMissionScript, buf);
+ ReadSaveBuf(&m_bSkipWakeTime, buf);
+ ReadSaveBuf(&m_nWakeTime, buf);
+ ReadSaveBuf(&m_nAndOrState, buf);
+ ReadSaveBuf(&m_bNotFlag, buf);
+ ReadSaveBuf(&m_bDeatharrestEnabled, buf);
+ ReadSaveBuf(&m_bDeatharrestExecuted, buf);
+ ReadSaveBuf(&m_bMissionFlag, buf);
SkipSaveBuf(buf, 2);
#else
CRunningScript* n = next;
CRunningScript* p = prev;
- *this = ReadSaveBuf<CRunningScript>(buf);
+ ReadSaveBuf(this, buf);
next = n;
prev = p;
#endif