summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorFilip Gawin <filip.gawin@zoho.com>2020-04-18 12:08:38 +0200
committerFilip Gawin <filip.gawin@zoho.com>2020-04-18 12:08:38 +0200
commit2b1570de703c32ab43c979c286413a3a1c5e3dc0 (patch)
treeff5510329a08fd5b3dca88de1c9fc5e36abef1b9 /src/core
parentPart one (diff)
parentZones save/load (diff)
downloadre3-2b1570de703c32ab43c979c286413a3a1c5e3dc0.tar
re3-2b1570de703c32ab43c979c286413a3a1c5e3dc0.tar.gz
re3-2b1570de703c32ab43c979c286413a3a1c5e3dc0.tar.bz2
re3-2b1570de703c32ab43c979c286413a3a1c5e3dc0.tar.lz
re3-2b1570de703c32ab43c979c286413a3a1c5e3dc0.tar.xz
re3-2b1570de703c32ab43c979c286413a3a1c5e3dc0.tar.zst
re3-2b1570de703c32ab43c979c286413a3a1c5e3dc0.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ControllerConfig.h5
-rw-r--r--src/core/Frontend.cpp15
-rw-r--r--src/core/Frontend.h4
-rw-r--r--src/core/Pad.h1
-rw-r--r--src/core/PlayerInfo.h12
-rw-r--r--src/core/Zones.cpp279
-rw-r--r--src/core/timebars.cpp2
7 files changed, 102 insertions, 216 deletions
diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h
index c328594e..82174343 100644
--- a/src/core/ControllerConfig.h
+++ b/src/core/ControllerConfig.h
@@ -112,20 +112,17 @@ public:
};
bool m_bFirstCapture;
- char _pad0[3];
#ifdef __DINPUT_INCLUDED__
DIJOYSTATE2 m_OldState;
DIJOYSTATE2 m_NewState;
#else
- uint8 ___padd[0x110 * 2];
+ uint32 ___padd[0x110 / 4 * 2];
#endif
wchar m_aActionNames[MAX_CONTROLLERACTIONS][ACTIONNAME_LENGTH];
bool m_aButtonStates[MAX_BUTTONS];
- char _pad1[3];
tControllerConfigBind m_aSettings[MAX_CONTROLLERACTIONS][MAX_CONTROLLERTYPES];
bool m_aSimCheckers[MAX_SIMS][MAX_CONTROLLERTYPES];
bool m_bMouseAssociated;
- char _pad2[3];
CControllerConfigManager();
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 790de046..e9282c44 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -118,7 +118,7 @@ const CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255);
const CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color
#endif
-const float menuXYpadding = MENUACTION_POS_Y; // *(float*)0x5F355C; // not original name
+const float menuXYpadding = MENUACTION_POS_Y; // TODO this is non-existant, remove it
float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE;
float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE;
@@ -754,9 +754,9 @@ CMenuManager::Draw()
#ifdef FIX_BUGS
// Label is wrapped from right by StretchX(40)px, but wrapped from left by 40px. And this is only place R* didn't use StretchX in here.
- CFont::PrintString(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN), MENU_Y(menuXYpadding), str);
+ CFont::PrintString(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN), MENU_Y(MENUACTION_POS_Y), str);
#else
- CFont::PrintString(MENU_X_MARGIN, menuXYpadding, str);
+ CFont::PrintString(MENU_X_MARGIN, MENUACTION_POS_Y, str);
#endif
}
@@ -3181,7 +3181,7 @@ CMenuManager::PrintBriefs()
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why
- float nextY = 40.0f;
+ float nextY = BRIEFS_TOP_MARGIN;
CRGBA newColor;
for (int i = 4; i >= 0; i--) {
tPreviousBrief &brief = CMessages::PreviousBriefs[i];
@@ -3214,8 +3214,8 @@ CMenuManager::PrintBriefs()
newColor.a = FadeIn(255);
CFont::SetColor(newColor);
#endif
- CFont::PrintString(MENU_X_LEFT_ALIGNED(50.0f), nextY, gUString);
- nextY += MENU_Y(menuXYpadding);
+ CFont::PrintString(MENU_X_LEFT_ALIGNED(BRIEFS_LINE_X), nextY, gUString);
+ nextY += MENU_Y(BRIEFS_LINE_HEIGHT);
}
}
@@ -3252,6 +3252,9 @@ void
CMenuManager::PrintStats()
{
int rowNum = ConstructStatLine(99999);
+#ifdef GTA3_1_1_PATCH
+ CFont::SetFontStyle(FONT_BANK);
+#endif
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why
float nextYChange, y, alphaMult;
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index 8fe61a36..41c12122 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -68,6 +68,10 @@
#define STATS_RATING_X 24.0f
#define STATS_RATING_Y 20.0f
+#define BRIEFS_TOP_MARGIN 40.0f
+#define BRIEFS_LINE_X 50.0f
+#define BRIEFS_LINE_HEIGHT 60.0f
+
#define CONTSETUP_STANDARD_ROW_HEIGHT 10.7f
#define CONTSETUP_CLASSIC_ROW_HEIGHT 9.0f
#define CONTSETUP_BOUND_HIGHLIGHT_HEIGHT 10
diff --git a/src/core/Pad.h b/src/core/Pad.h
index 9ebd6396..b3b0849b 100644
--- a/src/core/Pad.h
+++ b/src/core/Pad.h
@@ -155,7 +155,6 @@ public:
uint8 DisablePlayerControls;
int8 bApplyBrakes;
char CheatString[12];
- char _pad0[3];
int32 LastTimeTouched;
int32 AverageWeapon;
int32 AverageEntries;
diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h
index 19c5ce23..ff31418c 100644
--- a/src/core/PlayerInfo.h
+++ b/src/core/PlayerInfo.h
@@ -31,22 +31,13 @@ public:
uint32 m_nLastBumpPlayerCarTimer;
uint32 m_nUnusedTaxiTimer;
bool m_bUnusedTaxiThing;
- int8 field_197;
- int8 field_198;
- int8 field_199;
uint32 m_nNextSexFrequencyUpdateTime;
uint32 m_nNextSexMoneyUpdateTime;
int32 m_nSexFrequency;
CCivilianPed *m_pHooker;
int8 m_WBState; // eWastedBustedState
- int8 field_217;
- int8 field_218;
- int8 field_219;
uint32 m_nWBTime;
bool m_bInRemoteMode;
- int8 field_225;
- int8 field_226;
- int8 field_227;
uint32 m_nTimeLostRemoteCar;
uint32 m_nTimeLastHealthLoss;
uint32 m_nTimeLastArmourLoss;
@@ -54,8 +45,6 @@ public:
int32 m_nUpsideDownCounter;
int32 field_248;
int16 m_nTrafficMultiplier;
- int8 field_254;
- int8 field_255;
float m_fRoadDensity;
uint32 m_nPreviousTimeRewardedForExplosion;
int32 m_nExplosionsSinceLastReward;
@@ -90,7 +79,6 @@ public:
void FindClosestCarSectorList(CPtrList&, CPed*, float, float, float, float, float*, CVehicle**);
~CPlayerInfo() { };
- void dtor(void) { this->CPlayerInfo::~CPlayerInfo(); }
};
static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error");
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 6375de1c..804708b4 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -625,218 +625,113 @@ CTheZones::InitialiseAudioZoneArray(void)
}
void
-CTheZones::SaveAllZones(uint8 *buffer, uint32 *length)
+CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
{
+ INITSAVEBUF
int i;
- *length = 8 + 12 +
- NUMZONES*56 + 2*NUMZONES*58 + 4 +
- NUMMAPZONES*56 + NUMAUDIOZONES*2 + 4;
-
- buffer[0] = 'Z';
- buffer[1] = 'N';
- buffer[2] = 'S';
- buffer[3] = '\0';
- *(uint32*)(buffer+4) = *length - 8;
- buffer += 8;
-
- *(int32*)(buffer) = GetIndexForZonePointer(m_pPlayersZone);
- *(int32*)(buffer+4) = m_CurrLevel;
- *(int16*)(buffer+8) = FindIndex;
- *(int16*)(buffer+10) = 0;
- buffer += 12;
-
- for(i = 0; i < NUMZONES; i++){
- memcpy(buffer, ZoneArray[i].name, 8);
- *(float*)(buffer+8) = ZoneArray[i].minx;
- *(float*)(buffer+12) = ZoneArray[i].miny;
- *(float*)(buffer+16) = ZoneArray[i].minz;
- *(float*)(buffer+20) = ZoneArray[i].maxx;
- *(float*)(buffer+24) = ZoneArray[i].maxy;
- *(float*)(buffer+28) = ZoneArray[i].maxz;
- *(int32*)(buffer+32) = ZoneArray[i].type;
- *(int32*)(buffer+36) = ZoneArray[i].level;
- *(int16*)(buffer+40) = ZoneArray[i].zoneinfoDay;
- *(int16*)(buffer+42) = ZoneArray[i].zoneinfoNight;
- *(int32*)(buffer+44) = GetIndexForZonePointer(ZoneArray[i].child);
- *(int32*)(buffer+48) = GetIndexForZonePointer(ZoneArray[i].parent);
- *(int32*)(buffer+52) = GetIndexForZonePointer(ZoneArray[i].next);
- buffer += 56;
+ *size = SAVE_HEADER_SIZE
+ + sizeof(int32) // GetIndexForZonePointer
+ + sizeof(m_CurrLevel) + sizeof(FindIndex)
+ + sizeof(int16) // padding
+ + sizeof(ZoneArray) + sizeof(ZoneInfoArray)
+ + sizeof(TotalNumberOfZones) + sizeof(TotalNumberOfZoneInfos)
+ + sizeof(MapZoneArray) + sizeof(AudioZoneArray)
+ + sizeof(TotalNumberOfMapZones) + sizeof(NumberOfAudioZones);
+
+ WriteSaveHeader(buffer, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE);
+
+ WriteSaveBuf(buffer, GetIndexForZonePointer(m_pPlayersZone));
+ WriteSaveBuf(buffer, m_CurrLevel);
+ WriteSaveBuf(buffer, FindIndex);
+ WriteSaveBuf(buffer, (int16)0); // padding
+
+ for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){
+ CZone *zone = WriteSaveBuf(buffer, ZoneArray[i]);
+ zone->child = (CZone*)GetIndexForZonePointer(ZoneArray[i].child);
+ zone->parent = (CZone*)GetIndexForZonePointer(ZoneArray[i].parent);
+ zone->next = (CZone*)GetIndexForZonePointer(ZoneArray[i].next);
}
- for(i = 0; i < 2*NUMZONES; i++){
- *(int16*)(buffer) = ZoneInfoArray[i].carDensity;
- *(int16*)(buffer+2) = ZoneInfoArray[i].carThreshold[0];
- *(int16*)(buffer+4) = ZoneInfoArray[i].carThreshold[1];
- *(int16*)(buffer+6) = ZoneInfoArray[i].carThreshold[2];
- *(int16*)(buffer+8) = ZoneInfoArray[i].carThreshold[3];
- *(int16*)(buffer+10) = ZoneInfoArray[i].carThreshold[4];
- *(int16*)(buffer+12) = ZoneInfoArray[i].carThreshold[5];
- *(int16*)(buffer+14) = ZoneInfoArray[i].copThreshold;
- *(int16*)(buffer+16) = ZoneInfoArray[i].gangThreshold[0];
- *(int16*)(buffer+18) = ZoneInfoArray[i].gangThreshold[1];
- *(int16*)(buffer+20) = ZoneInfoArray[i].gangThreshold[2];
- *(int16*)(buffer+22) = ZoneInfoArray[i].gangThreshold[3];
- *(int16*)(buffer+24) = ZoneInfoArray[i].gangThreshold[4];
- *(int16*)(buffer+26) = ZoneInfoArray[i].gangThreshold[5];
- *(int16*)(buffer+28) = ZoneInfoArray[i].gangThreshold[6];
- *(int16*)(buffer+30) = ZoneInfoArray[i].gangThreshold[7];
- *(int16*)(buffer+32) = ZoneInfoArray[i].gangThreshold[8];
- *(uint16*)(buffer+34) = ZoneInfoArray[i].pedDensity;
- *(uint16*)(buffer+36) = ZoneInfoArray[i].copDensity;
- *(uint16*)(buffer+38) = ZoneInfoArray[i].gangDensity[0];
- *(uint16*)(buffer+40) = ZoneInfoArray[i].gangDensity[1];
- *(uint16*)(buffer+42) = ZoneInfoArray[i].gangDensity[2];
- *(uint16*)(buffer+44) = ZoneInfoArray[i].gangDensity[3];
- *(uint16*)(buffer+46) = ZoneInfoArray[i].gangDensity[4];
- *(uint16*)(buffer+48) = ZoneInfoArray[i].gangDensity[5];
- *(uint16*)(buffer+50) = ZoneInfoArray[i].gangDensity[6];
- *(uint16*)(buffer+52) = ZoneInfoArray[i].gangDensity[7];
- *(uint16*)(buffer+54) = ZoneInfoArray[i].gangDensity[8];
- *(uint16*)(buffer+56) = ZoneInfoArray[i].pedGroup;
- buffer += 58;
+ for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
+ WriteSaveBuf(buffer, ZoneInfoArray[i]);
+
+ WriteSaveBuf(buffer, TotalNumberOfZones);
+ WriteSaveBuf(buffer, TotalNumberOfZoneInfos);
+
+ for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++) {
+ CZone* zone = WriteSaveBuf(buffer, MapZoneArray[i]);
+
+ /*
+ The call of GetIndexForZonePointer is wrong, as it is
+ meant for a different array, but the game doesn't brake
+ if those fields are nil. Let's make sure they are.
+ */
+ assert(MapZoneArray[i].child == nil);
+ assert(MapZoneArray[i].parent == nil);
+ assert(MapZoneArray[i].next == nil);
+ zone->child = (CZone*)GetIndexForZonePointer(MapZoneArray[i].child);
+ zone->parent = (CZone*)GetIndexForZonePointer(MapZoneArray[i].parent);
+ zone->next = (CZone*)GetIndexForZonePointer(MapZoneArray[i].next);
}
- *(uint16*)(buffer) = TotalNumberOfZones;
- *(uint16*)(buffer+2) = TotalNumberOfZoneInfos;
- buffer += 4;
-
- for(i = 0; i < NUMMAPZONES; i++){
- memcpy(buffer, MapZoneArray[i].name, 8);
- *(float*)(buffer+8) = MapZoneArray[i].minx;
- *(float*)(buffer+12) = MapZoneArray[i].miny;
- *(float*)(buffer+16) = MapZoneArray[i].minz;
- *(float*)(buffer+20) = MapZoneArray[i].maxx;
- *(float*)(buffer+24) = MapZoneArray[i].maxy;
- *(float*)(buffer+28) = MapZoneArray[i].maxz;
- *(int32*)(buffer+32) = MapZoneArray[i].type;
- *(int32*)(buffer+36) = MapZoneArray[i].level;
- *(int16*)(buffer+40) = MapZoneArray[i].zoneinfoDay;
- *(int16*)(buffer+42) = MapZoneArray[i].zoneinfoNight;
-#ifdef STANDALONE
- // BUG: GetIndexForZonePointer uses ZoneArray
- // so indices will be unpredictable with different memory layout
- assert(0);
-#endif
- *(int32*)(buffer+44) = GetIndexForZonePointer(MapZoneArray[i].child);
- *(int32*)(buffer+48) = GetIndexForZonePointer(MapZoneArray[i].parent);
- *(int32*)(buffer+52) = GetIndexForZonePointer(MapZoneArray[i].next);
- buffer += 56;
- }
+ for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
+ WriteSaveBuf(buffer, AudioZoneArray[i]);
- for(i = 0; i < NUMAUDIOZONES; i++){
- *(int16*)buffer = AudioZoneArray[i];
- buffer += 2;
- }
+ WriteSaveBuf(buffer, TotalNumberOfMapZones);
+ WriteSaveBuf(buffer, NumberOfAudioZones);
- *(uint16*)(buffer) = TotalNumberOfMapZones;
- *(uint16*)(buffer+2) = NumberOfAudioZones;
+ VALIDATESAVEBUF(*size)
}
void
-CTheZones::LoadAllZones(uint8 *buffer, uint32 length)
+CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
{
+ INITSAVEBUF
int i;
- assert(length == 8 + 12 +
- NUMZONES*56 + 2*NUMZONES*58 + 4 +
- NUMMAPZONES*56 + NUMAUDIOZONES*2 + 4);
- assert(buffer[0] == 'Z');
- assert(buffer[1] == 'N');
- assert(buffer[2] == 'S');
- assert(buffer[3] == '\0');
- assert(*(uint32*)(buffer+4) == length - 8);
- buffer += 8;
-
- m_pPlayersZone = GetPointerForZoneIndex(*(int32*)(buffer));
- m_CurrLevel = (eLevelName)*(int32*)(buffer+4);
- FindIndex = *(int16*)(buffer+8);
- assert(*(int16*)(buffer+10) == 0);
- buffer += 12;
-
- for(i = 0; i < NUMZONES; i++){
- memcpy(ZoneArray[i].name, buffer, 8);
- ZoneArray[i].minx = *(float*)(buffer+8);
- ZoneArray[i].miny = *(float*)(buffer+12);
- ZoneArray[i].minz = *(float*)(buffer+16);
- ZoneArray[i].maxx = *(float*)(buffer+20);
- ZoneArray[i].maxy = *(float*)(buffer+24);
- ZoneArray[i].maxz = *(float*)(buffer+28);
- ZoneArray[i].type = (eZoneType)*(int32*)(buffer+32);
- ZoneArray[i].level = (eLevelName)*(int32*)(buffer+36);
- ZoneArray[i].zoneinfoDay = *(int16*)(buffer+40);
- ZoneArray[i].zoneinfoNight = *(int16*)(buffer+42);
- ZoneArray[i].child = GetPointerForZoneIndex(*(int32*)(buffer+44));
- ZoneArray[i].parent = GetPointerForZoneIndex(*(int32*)(buffer+48));
- ZoneArray[i].next = GetPointerForZoneIndex(*(int32*)(buffer+52));
- buffer += 56;
- }
+ CheckSaveHeader(buffer, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE);
- for(i = 0; i < 2*NUMZONES; i++){
- ZoneInfoArray[i].carDensity = *(int16*)(buffer);
- ZoneInfoArray[i].carThreshold[0] = *(int16*)(buffer+2);
- ZoneInfoArray[i].carThreshold[1] = *(int16*)(buffer+4);
- ZoneInfoArray[i].carThreshold[2] = *(int16*)(buffer+6);
- ZoneInfoArray[i].carThreshold[3] = *(int16*)(buffer+8);
- ZoneInfoArray[i].carThreshold[4] = *(int16*)(buffer+10);
- ZoneInfoArray[i].carThreshold[5] = *(int16*)(buffer+12);
- ZoneInfoArray[i].copThreshold = *(int16*)(buffer+14);
- ZoneInfoArray[i].gangThreshold[0] = *(int16*)(buffer+16);
- ZoneInfoArray[i].gangThreshold[1] = *(int16*)(buffer+18);
- ZoneInfoArray[i].gangThreshold[2] = *(int16*)(buffer+20);
- ZoneInfoArray[i].gangThreshold[3] = *(int16*)(buffer+22);
- ZoneInfoArray[i].gangThreshold[4] = *(int16*)(buffer+24);
- ZoneInfoArray[i].gangThreshold[5] = *(int16*)(buffer+26);
- ZoneInfoArray[i].gangThreshold[6] = *(int16*)(buffer+28);
- ZoneInfoArray[i].gangThreshold[7] = *(int16*)(buffer+30);
- ZoneInfoArray[i].gangThreshold[8] = *(int16*)(buffer+32);
- ZoneInfoArray[i].pedDensity = *(uint16*)(buffer+34);
- ZoneInfoArray[i].copDensity = *(uint16*)(buffer+36);
- ZoneInfoArray[i].gangDensity[0] = *(uint16*)(buffer+38);
- ZoneInfoArray[i].gangDensity[1] = *(uint16*)(buffer+40);
- ZoneInfoArray[i].gangDensity[2] = *(uint16*)(buffer+42);
- ZoneInfoArray[i].gangDensity[3] = *(uint16*)(buffer+44);
- ZoneInfoArray[i].gangDensity[4] = *(uint16*)(buffer+46);
- ZoneInfoArray[i].gangDensity[5] = *(uint16*)(buffer+48);
- ZoneInfoArray[i].gangDensity[6] = *(uint16*)(buffer+50);
- ZoneInfoArray[i].gangDensity[7] = *(uint16*)(buffer+52);
- ZoneInfoArray[i].gangDensity[8] = *(uint16*)(buffer+54);
- ZoneInfoArray[i].pedGroup = *(uint16*)(buffer+56);
- buffer += 58;
- }
+ m_pPlayersZone = GetPointerForZoneIndex(ReadSaveBuf<int32>(buffer));
+ m_CurrLevel = ReadSaveBuf<eLevelName>(buffer);
+ FindIndex = ReadSaveBuf<int16>(buffer);
+ ReadSaveBuf<int16>(buffer);
- TotalNumberOfZones = *(uint16*)(buffer);
- TotalNumberOfZoneInfos = *(uint16*)(buffer+2);
- buffer += 4;
+ for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){
+ ZoneArray[i] = ReadSaveBuf<CZone>(buffer);
- for(i = 0; i < NUMMAPZONES; i++){
- memcpy(MapZoneArray[i].name, buffer, 8);
- MapZoneArray[i].minx = *(float*)(buffer+8);
- MapZoneArray[i].miny = *(float*)(buffer+12);
- MapZoneArray[i].minz = *(float*)(buffer+16);
- MapZoneArray[i].maxx = *(float*)(buffer+20);
- MapZoneArray[i].maxy = *(float*)(buffer+24);
- MapZoneArray[i].maxz = *(float*)(buffer+28);
- MapZoneArray[i].type = (eZoneType)*(int32*)(buffer+32);
- MapZoneArray[i].level = (eLevelName)*(int32*)(buffer+36);
- MapZoneArray[i].zoneinfoDay = *(int16*)(buffer+40);
- MapZoneArray[i].zoneinfoNight = *(int16*)(buffer+42);
-#ifdef STANDALONE
- // BUG: GetPointerForZoneIndex uses ZoneArray
- // so pointers will be unpredictable with different memory layout
- assert(0);
-#endif
- MapZoneArray[i].child = GetPointerForZoneIndex(*(int32*)(buffer+44));
- MapZoneArray[i].parent = GetPointerForZoneIndex(*(int32*)(buffer+48));
- MapZoneArray[i].next = GetPointerForZoneIndex(*(int32*)(buffer+52));
- buffer += 56;
+ ZoneArray[i].child = GetPointerForZoneIndex((int32)ZoneArray[i].child);
+ ZoneArray[i].parent = GetPointerForZoneIndex((int32)ZoneArray[i].parent);
+ ZoneArray[i].next = GetPointerForZoneIndex((int32)ZoneArray[i].next);
}
- for(i = 0; i < NUMAUDIOZONES; i++){
- AudioZoneArray[i] = *(int16*)buffer;
- buffer += 2;
+ for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
+ ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer);
+
+ TotalNumberOfZones = ReadSaveBuf<int16>(buffer);
+ TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer);
+
+ for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++){
+ MapZoneArray[i] = ReadSaveBuf<CZone>(buffer);
+
+ /*
+ The call of GetPointerForZoneIndex is wrong, as it is
+ meant for a different array, but the game doesn't brake
+ if save data stored is -1.
+ */
+ MapZoneArray[i].child = GetPointerForZoneIndex((int32)MapZoneArray[i].child);
+ MapZoneArray[i].parent = GetPointerForZoneIndex((int32)MapZoneArray[i].parent);
+ MapZoneArray[i].next = GetPointerForZoneIndex((int32)MapZoneArray[i].next);
+ assert(MapZoneArray[i].child == nil);
+ assert(MapZoneArray[i].parent == nil);
+ assert(MapZoneArray[i].next == nil);
}
- TotalNumberOfMapZones = *(uint16*)(buffer);
- NumberOfAudioZones = *(uint16*)(buffer+2);
+ for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
+ AudioZoneArray[i] = ReadSaveBuf<int16>(buffer);
+
+ TotalNumberOfMapZones = ReadSaveBuf<uint16>(buffer);
+ NumberOfAudioZones = ReadSaveBuf<uint16>(buffer);
+
+ VALIDATESAVEBUF(size)
}
diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp
index 93d85f8d..5c2dbe3a 100644
--- a/src/core/timebars.cpp
+++ b/src/core/timebars.cpp
@@ -1,5 +1,5 @@
-#ifndef MASTER
#include "common.h"
+#ifndef MASTER
#include "Font.h"
#include "Frontend.h"
#include "Timer.h"