summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorwithmorten <morten.with@gmail.com>2021-06-26 19:14:46 +0200
committerwithmorten <morten.with@gmail.com>2021-06-26 19:14:46 +0200
commitf3a931e1c99372ae4bc224ef482d4052a09580cb (patch)
tree13992380234e68b8f1a32030b4df6aa3d6ebbaca /src/core
parentMerge pull request #1155 from leanndroguedes/master (diff)
downloadre3-f3a931e1c99372ae4bc224ef482d4052a09580cb.tar
re3-f3a931e1c99372ae4bc224ef482d4052a09580cb.tar.gz
re3-f3a931e1c99372ae4bc224ef482d4052a09580cb.tar.bz2
re3-f3a931e1c99372ae4bc224ef482d4052a09580cb.tar.lz
re3-f3a931e1c99372ae4bc224ef482d4052a09580cb.tar.xz
re3-f3a931e1c99372ae4bc224ef482d4052a09580cb.tar.zst
re3-f3a931e1c99372ae4bc224ef482d4052a09580cb.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Pools.cpp16
-rw-r--r--src/core/Radar.cpp3
-rw-r--r--src/core/Zones.cpp28
-rw-r--r--src/core/common.h170
4 files changed, 28 insertions, 189 deletions
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index 39cfb1d4..5cffe9e4 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -9,6 +9,7 @@
#endif
#include "Population.h"
#include "ProjectileInfo.h"
+#include "SaveBuf.h"
#include "Streaming.h"
#include "Wanted.h"
#include "World.h"
@@ -130,14 +131,19 @@ CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
void CPools::LoadVehiclePool(uint8* buf, uint32 size)
{
INITSAVEBUF
- int nNumCars = ReadSaveBuf<int>(buf);
- int nNumBoats = ReadSaveBuf<int>(buf);
+ int nNumCars, nNumBoats;
+ ReadSaveBuf(&nNumCars, buf);
+ ReadSaveBuf(&nNumBoats, buf);
for (int i = 0; i < nNumCars + nNumBoats; i++) {
- uint32 type = ReadSaveBuf<uint32>(buf);
- int16 model = ReadSaveBuf<int16>(buf);
+ uint32 type;
+ int16 model;
+ int32 slot;
+
+ ReadSaveBuf(&type, buf);
+ ReadSaveBuf(&model, buf);
CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY);
CStreaming::LoadAllRequestedModels(false);
- int32 slot = ReadSaveBuf<int32>(buf);
+ ReadSaveBuf(&slot, buf);
CVehicle* pVehicle;
#ifdef COMPATIBLE_SAVES
if (type == VEHICLE_TYPE_BOAT)
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 8f2c1747..77d6cc7f 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -16,6 +16,7 @@
#include "Script.h"
#include "TxdStore.h"
#include "World.h"
+#include "SaveBuf.h"
#include "Streaming.h"
#include "SpecialFX.h"
@@ -1055,7 +1056,7 @@ INITSAVEBUF
CheckSaveHeader(buf, 'R', 'D', 'R', '\0', size - SAVE_HEADER_SIZE);
for (int i = 0; i < NUMRADARBLIPS; i++)
- ms_RadarTrace[i] = ReadSaveBuf<sRadarTrace>(buf);
+ ReadSaveBuf(&ms_RadarTrace[i], buf);
VALIDATESAVEBUF(size);
}
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index cdae85e1..107b1db8 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -8,6 +8,7 @@
#include "Text.h"
#include "World.h"
#include "Timer.h"
+#include "SaveBuf.h"
eLevelName CTheZones::m_CurrLevel;
CZone *CTheZones::m_pPlayersZone;
@@ -696,17 +697,18 @@ void
CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
{
INITSAVEBUF
- int i;
+ int32 i;
CheckSaveHeader(buffer, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE);
- m_pPlayersZone = GetPointerForZoneIndex(ReadSaveBuf<int32>(buffer));
- m_CurrLevel = ReadSaveBuf<eLevelName>(buffer);
- FindIndex = ReadSaveBuf<int16>(buffer);
- ReadSaveBuf<int16>(buffer);
+ ReadSaveBuf(&i, buffer);
+ m_pPlayersZone = GetPointerForZoneIndex(i);
+ ReadSaveBuf(&m_CurrLevel, buffer);
+ ReadSaveBuf(&FindIndex, buffer);
+ SkipSaveBuf(buffer, 2);
for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){
- ZoneArray[i] = ReadSaveBuf<CZone>(buffer);
+ ReadSaveBuf(&ZoneArray[i], buffer);
ZoneArray[i].child = GetPointerForZoneIndex((uintptr)ZoneArray[i].child);
ZoneArray[i].parent = GetPointerForZoneIndex((uintptr)ZoneArray[i].parent);
@@ -714,13 +716,13 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
}
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
- ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer);
+ ReadSaveBuf(&ZoneInfoArray[i], buffer);
- TotalNumberOfZones = ReadSaveBuf<int16>(buffer);
- TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer);
+ ReadSaveBuf(&TotalNumberOfZones, buffer);
+ ReadSaveBuf(&TotalNumberOfZoneInfos, buffer);
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++){
- MapZoneArray[i] = ReadSaveBuf<CZone>(buffer);
+ ReadSaveBuf(&MapZoneArray[i], buffer);
/*
The call of GetPointerForZoneIndex is wrong, as it is
@@ -736,10 +738,10 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
}
for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
- AudioZoneArray[i] = ReadSaveBuf<int16>(buffer);
+ ReadSaveBuf(&AudioZoneArray[i], buffer);
- TotalNumberOfMapZones = ReadSaveBuf<uint16>(buffer);
- NumberOfAudioZones = ReadSaveBuf<uint16>(buffer);
+ ReadSaveBuf(&TotalNumberOfMapZones, buffer);
+ ReadSaveBuf(&NumberOfAudioZones, buffer);
VALIDATESAVEBUF(size)
}
diff --git a/src/core/common.h b/src/core/common.h
index e5077611..7207f08d 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -393,173 +393,3 @@ template<int s, int t> struct check_size {
#define STR(x) STRINGIFY(x)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
-
-#ifdef DEBUGMENU
-// Tweaking stuff for debugmenu
-#define TWEAKPATH ___tw___TWEAKPATH
-#define SETTWEAKPATH(path) static const char *___tw___TWEAKPATH = path;
-#define TWEAKFUNC(v) static CTweakFunc CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), TWEAKPATH);
-#define TWEAKFUNCN(v, name) static CTweakFunc CONCAT(___tw___tweak, __COUNTER__)(&v, name, TWEAKPATH);
-#define TWEAKBOOL(v) static CTweakBool CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), TWEAKPATH);
-#define TWEAKBOOLN(v, name) static CTweakBool CONCAT(___tw___tweak, __COUNTER__)(&v, name, TWEAKPATH);
-#define TWEAKINT32(v, lower, upper, step) static CTweakInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKINT32N(v, lower, upper, step, name) static CTweakInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKUINT32(v, lower, upper, step) static CTweakUInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKUINT32N(v, lower, upper, step, name) static CTweakUInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKINT16(v, lower, upper, step) static CTweakInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKINT16N(v, lower, upper, step, name) static CTweakInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKUINT16(v, lower, upper, step) static CTweakUInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKUINT16N(v, lower, upper, step, name) static CTweakUInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKINT8(v, lower, upper, step) static CTweakInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKINT8N(v, lower, upper, step, name) static CTweakInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKUINT8(v, lower, upper, step) static CTweakUInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKUINT8N(v, lower, upper, step, name) static CTweakUInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKFLOAT(v, lower, upper, step) static CTweakFloat CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKFLOATN(v, lower, upper, step, name) static CTweakFloat CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKSWITCH(v, lower, upper, str, f) static CTweakSwitch CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, str, f, TWEAKPATH);
-#define TWEAKSWITCHN(v, lower, upper, str, f, name) static CTweakSwitch CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, str, f, TWEAKPATH);
-
-// interface
-class CTweakVar
-{
-public:
- virtual void AddDBG(const char *path) = 0;
-};
-
-class CTweakVars
-{
-public:
- static void Add(CTweakVar *var);
- static void AddDBG(const char *path);
-};
-
-class CTweakFunc : public CTweakVar
-{
- const char *m_pPath, *m_pVarName;
- void (*m_pFunc)();
-public:
- CTweakFunc(void (*pFunc)(), const char *strName, const char *strPath) :
- m_pPath(strPath), m_pVarName(strName), m_pFunc(pFunc)
- {
- CTweakVars::Add(this);
- }
-
- void AddDBG(const char *path);
-};
-
-class CTweakBool : public CTweakVar
-{
- const char *m_pPath, *m_pVarName;
- bool *m_pBoolVar;
-public:
- CTweakBool(bool *pBool, const char *strName, const char *strPath) :
- m_pPath(strPath), m_pVarName(strName), m_pBoolVar(pBool)
- {
- CTweakVars::Add(this);
- }
-
- void AddDBG(const char *path);
-};
-
-class CTweakSwitch : public CTweakVar
-{
- const char *m_pPath, *m_pVarName;
- void *m_pIntVar;
- int32 m_nMin, m_nMax;
- const char **m_aStr;
- void (*m_pFunc)();
-public:
- CTweakSwitch(void *pInt, const char *strName, int32 nMin, int32 nMax, const char **aStr,
- void (*pFunc)(), const char *strPath)
- : m_pPath(strPath), m_pVarName(strName), m_pIntVar(pInt), m_nMin(nMin), m_nMax(nMax),
- m_aStr(aStr)
- {
- CTweakVars::Add(this);
- }
-
- void AddDBG(const char *path);
-};
-
-#define _TWEEKCLASS(name, type) \
- class name : public CTweakVar \
- { \
- public: \
- const char *m_pPath, *m_pVarName; \
- type *m_pIntVar, m_nLoawerBound, m_nUpperBound, m_nStep; \
- \
- name(type *pInt, const char *strName, type nLower, type nUpper, type nStep, \
- const char *strPath) \
- : m_pPath(strPath), m_pVarName(strName), m_pIntVar(pInt), \
- m_nLoawerBound(nLower), m_nUpperBound(nUpper), m_nStep(nStep) \
- \
- { \
- CTweakVars::Add(this); \
- } \
- \
- void AddDBG(const char *path); \
- };
-
-_TWEEKCLASS(CTweakInt8, int8);
-_TWEEKCLASS(CTweakUInt8, uint8);
-_TWEEKCLASS(CTweakInt16, int16);
-_TWEEKCLASS(CTweakUInt16, uint16);
-_TWEEKCLASS(CTweakInt32, int32);
-_TWEEKCLASS(CTweakUInt32, uint32);
-_TWEEKCLASS(CTweakFloat, float);
-
-#undef _TWEEKCLASS
-#endif
-
-#ifdef VALIDATE_SAVE_SIZE
-extern int32 _saveBufCount;
-#define INITSAVEBUF _saveBufCount = 0;
-#define VALIDATESAVEBUF(b) assert(_saveBufCount == b);
-#else
-#define INITSAVEBUF
-#define VALIDATESAVEBUF(b)
-#endif
-
-inline void SkipSaveBuf(uint8 *&buf, int32 skip)
-{
- buf += skip;
-#ifdef VALIDATE_SAVE_SIZE
- _saveBufCount += skip;
-#endif
-}
-
-template<typename T>
-inline const T ReadSaveBuf(uint8 *&buf)
-{
- T &value = *(T*)buf;
- SkipSaveBuf(buf, sizeof(T));
- return value;
-}
-
-template<typename T>
-inline T *WriteSaveBuf(uint8 *&buf, const T &value)
-{
- T *p = (T*)buf;
- *p = value;
- SkipSaveBuf(buf, sizeof(T));
- return p;
-}
-
-
-#define SAVE_HEADER_SIZE (4*sizeof(char)+sizeof(uint32))
-
-#define WriteSaveHeader(buf,a,b,c,d,size) \
- WriteSaveBuf(buf, a);\
- WriteSaveBuf(buf, b);\
- WriteSaveBuf(buf, c);\
- WriteSaveBuf(buf, d);\
- WriteSaveBuf<uint32>(buf, size);
-
-#define CheckSaveHeader(buf,a,b,c,d,size)\
- assert(ReadSaveBuf<char>(buf) == a);\
- assert(ReadSaveBuf<char>(buf) == b);\
- assert(ReadSaveBuf<char>(buf) == c);\
- assert(ReadSaveBuf<char>(buf) == d);\
- assert(ReadSaveBuf<uint32>(buf) == size);
-
-
-void cprintf(char*, ...);