summaryrefslogtreecommitdiffstats
path: root/src/control/Script5.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-06-28 02:59:07 +0200
committerSergeanur <s.anureev@yandex.ua>2021-06-28 04:12:54 +0200
commitf8297df9c5a7d65d5658d1a8d85d391fbb15b95a (patch)
tree9dcfac13fc3be99320ca7b546c4ff2007bff4121 /src/control/Script5.cpp
parentRemove waiting for stream closure in multi-thread audio (diff)
downloadre3-f8297df9c5a7d65d5658d1a8d85d391fbb15b95a.tar
re3-f8297df9c5a7d65d5658d1a8d85d391fbb15b95a.tar.gz
re3-f8297df9c5a7d65d5658d1a8d85d391fbb15b95a.tar.bz2
re3-f8297df9c5a7d65d5658d1a8d85d391fbb15b95a.tar.lz
re3-f8297df9c5a7d65d5658d1a8d85d391fbb15b95a.tar.xz
re3-f8297df9c5a7d65d5658d1a8d85d391fbb15b95a.tar.zst
re3-f8297df9c5a7d65d5658d1a8d85d391fbb15b95a.zip
Diffstat (limited to 'src/control/Script5.cpp')
-rw-r--r--src/control/Script5.cpp83
1 files changed, 48 insertions, 35 deletions
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index 9d14b1c4..2806ee30 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"
void CRunningScript::UpdateCompareFlag(bool flag)
{
@@ -2184,15 +2185,19 @@ void CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
Init();
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);
for (uint32 i = 0; i < varSpace; i++)
- ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
- script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE);
- OnAMissionFlag = ReadSaveBuf<uint32>(buf);
- LastMissionPassedTime = ReadSaveBuf<uint32>(buf);
+ ReadSaveBuf(&ScriptSpace[i], buf);
+ ReadSaveBuf(&tmp, buf);
+ script_assert(tmp == SCRIPT_DATA_SIZE);
+ ReadSaveBuf(&OnAMissionFlag, buf);
+ ReadSaveBuf(&LastMissionPassedTime, 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:
BuildingSwapArray[i].m_pBuilding = nil;
@@ -2206,14 +2211,14 @@ INITSAVEBUF
default:
script_assert(false);
}
- BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);
- BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);
+ ReadSaveBuf(&BuildingSwapArray[i].m_nNewModel, buf);
+ ReadSaveBuf(&BuildingSwapArray[i].m_nOldModel, buf);
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:
InvisibilitySettingArray[i] = nil;
@@ -2236,14 +2241,22 @@ INITSAVEBUF
if (InvisibilitySettingArray[i])
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);
+ ReadSaveBuf(&bPlayerHasMetDebbieHarry, buf);
+ SkipSaveBuf(buf, 2);
+ 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++)
StartNewScript(0)->Load(buf);
VALIDATESAVEBUF(size)
@@ -2291,35 +2304,35 @@ void CRunningScript::Load(uint8*& buf)
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
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 + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
#endif
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
- m_anLocalVariables[i] = 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_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