From af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 26 Jun 2021 00:25:59 +0300 Subject: Revert "Redo ReadSaveBuf + common.h cleanup" This reverts commit 2b67aba94cb6448fb24c869559465eddf2bad069. --- src/control/Script5.cpp | 85 +++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 48 deletions(-) (limited to 'src/control/Script5.cpp') diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp index a9aec18e..c83c3edc 100644 --- a/src/control/Script5.cpp +++ b/src/control/Script5.cpp @@ -12,7 +12,6 @@ #include "Pools.h" #include "Population.h" #include "RpAnimBlend.h" -#include "SaveBuf.h" #include "Shadows.h" #include "SpecialFX.h" #include "World.h" @@ -2003,25 +2002,21 @@ void CTheScripts::LoadAllScripts(uint8* buf, uint32 size) Init(); INITSAVEBUF CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE); - uint32 varSpace, type, handle; - uint32 tmp; - - ReadSaveBuf(&varSpace, buf); + uint32 varSpace = ReadSaveBuf(buf); for (uint32 i = 0; i < varSpace; i++) - ReadSaveBuf(&ScriptSpace[i], buf); - ReadSaveBuf(&tmp, buf); - script_assert(tmp == SCRIPT_DATA_SIZE); - ReadSaveBuf(&OnAMissionFlag, buf); + ScriptSpace[i] = ReadSaveBuf(buf); + script_assert(ReadSaveBuf(buf) == SCRIPT_DATA_SIZE); + OnAMissionFlag = ReadSaveBuf(buf); for (uint32 i = 0; i < MAX_NUM_CONTACTS; i++) { - ReadSaveBuf(&OnAMissionForContactFlag[i], buf); - ReadSaveBuf(&BaseBriefIdForContact[i], buf); + OnAMissionForContactFlag[i] = ReadSaveBuf(buf); + BaseBriefIdForContact[i] = ReadSaveBuf(buf); } for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++) - ReadSaveBuf(&CollectiveArray[i], buf); - ReadSaveBuf(&NextFreeCollectiveIndex, buf); + CollectiveArray[i] = ReadSaveBuf(buf); + NextFreeCollectiveIndex = ReadSaveBuf(buf); for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) { - ReadSaveBuf(&type, buf); - ReadSaveBuf(&handle, buf); + uint32 type = ReadSaveBuf(buf); + uint32 handle = ReadSaveBuf(buf); switch (type) { case 0: BuildingSwapArray[i].m_pBuilding = nil; @@ -2035,14 +2030,14 @@ INITSAVEBUF default: script_assert(false); } - ReadSaveBuf(&BuildingSwapArray[i].m_nNewModel, buf); - ReadSaveBuf(&BuildingSwapArray[i].m_nOldModel, buf); + BuildingSwapArray[i].m_nNewModel = ReadSaveBuf(buf); + BuildingSwapArray[i].m_nOldModel = ReadSaveBuf(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++) { - ReadSaveBuf(&type, buf); - ReadSaveBuf(&handle, buf); + uint32 type = ReadSaveBuf(buf); + uint32 handle = ReadSaveBuf(buf); switch (type) { case 0: InvisibilitySettingArray[i] = nil; @@ -2065,20 +2060,14 @@ INITSAVEBUF if (InvisibilitySettingArray[i]) InvisibilitySettingArray[i]->bIsVisible = false; } - bool tmpBool; - ReadSaveBuf(&tmpBool, buf); - script_assert(tmpBool == bUsingAMultiScriptFile); - 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); - SkipSaveBuf(buf, 2); - uint32 runningScripts; - ReadSaveBuf(&runningScripts, buf); + script_assert(ReadSaveBuf(buf) == bUsingAMultiScriptFile); + ReadSaveBuf(buf); + ReadSaveBuf(buf); + script_assert(ReadSaveBuf(buf) == MainScriptSize); + script_assert(ReadSaveBuf(buf) == LargestMissionScriptSize); + script_assert(ReadSaveBuf(buf) == NumberOfMissionScripts); + ReadSaveBuf(buf); + uint32 runningScripts = ReadSaveBuf(buf); for (uint32 i = 0; i < runningScripts; i++) StartNewScript(0)->Load(buf); VALIDATESAVEBUF(size) @@ -2126,35 +2115,35 @@ void CRunningScript::Load(uint8*& buf) #ifdef COMPATIBLE_SAVES SkipSaveBuf(buf, 8); for (int i = 0; i < 8; i++) - ReadSaveBuf(&m_abScriptName[i], buf); - ReadSaveBuf(&m_nIp, buf); + m_abScriptName[i] = ReadSaveBuf(buf); + m_nIp = ReadSaveBuf(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++) - ReadSaveBuf(&m_anStack[i], buf); - ReadSaveBuf(&m_nStackPointer, buf); + m_anStack[i] = ReadSaveBuf(buf); + m_nStackPointer = ReadSaveBuf(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++) - ReadSaveBuf(&m_anLocalVariables[i], buf); - ReadSaveBuf(&m_bCondResult, buf); - ReadSaveBuf(&m_bIsMissionScript, buf); - ReadSaveBuf(&m_bSkipWakeTime, buf); + m_anLocalVariables[i] = ReadSaveBuf(buf); + m_bCondResult = ReadSaveBuf(buf); + m_bIsMissionScript = ReadSaveBuf(buf); + m_bSkipWakeTime = ReadSaveBuf(buf); SkipSaveBuf(buf, 1); - ReadSaveBuf(&m_nWakeTime, buf); - ReadSaveBuf(&m_nAndOrState, buf); - ReadSaveBuf(&m_bNotFlag, buf); - ReadSaveBuf(&m_bDeatharrestEnabled, buf); - ReadSaveBuf(&m_bDeatharrestExecuted, buf); - ReadSaveBuf(&m_bMissionFlag, buf); + m_nWakeTime = ReadSaveBuf(buf); + m_nAndOrState = ReadSaveBuf(buf); + m_bNotFlag = ReadSaveBuf(buf); + m_bDeatharrestEnabled = ReadSaveBuf(buf); + m_bDeatharrestExecuted = ReadSaveBuf(buf); + m_bMissionFlag = ReadSaveBuf(buf); SkipSaveBuf(buf, 2); #else CRunningScript* n = next; CRunningScript* p = prev; - ReadSaveBuf(this, buf); + *this = ReadSaveBuf(buf); next = n; prev = p; #endif -- cgit v1.2.3