summaryrefslogtreecommitdiffstats
path: root/src/core/Zones.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/core/Zones.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/core/Zones.cpp')
-rw-r--r--src/core/Zones.cpp75
1 files changed, 43 insertions, 32 deletions
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 26d3efb0..93eca199 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;
int16 CTheZones::FindIndex;
@@ -714,11 +715,11 @@ CTheZones::SaveOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zo
WriteSaveBuf(*buffer, *length, zone->zoneinfoNight);
int32 zoneId;
- zoneId = GetIndexForZonePointer(zone->child);
+ zoneId = GetIndexForNavigationZonePointer(zone->child);
WriteSaveBuf(*buffer, *length, zoneId);
- zoneId = GetIndexForZonePointer(zone->parent);
+ zoneId = GetIndexForNavigationZonePointer(zone->parent);
WriteSaveBuf(*buffer, *length, zoneId);
- zoneId = GetIndexForZonePointer(zone->next);
+ zoneId = GetIndexForNavigationZonePointer(zone->next);
WriteSaveBuf(*buffer, *length, zoneId);
}
@@ -731,9 +732,9 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
uint32 length = 0;
CheckSaveHeaderWithLength(buffer, length, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE);
- m_CurrLevel = ReadSaveBuf<eLevelName>(buffer, length);
- FindIndex = ReadSaveBuf<int16>(buffer, length);
- ReadSaveBuf<int16>(buffer, length);
+ ReadSaveBuf(&m_CurrLevel, buffer);
+ ReadSaveBuf(&FindIndex, buffer);
+ SkipSaveBuf(buffer, 2);
for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++)
LoadOneZone(&NavigationZoneArray[i], &buffer, &length, ZONE_NAVIG);
@@ -742,21 +743,21 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
LoadOneZone(&InfoZoneArray[i], &buffer, &length, ZONE_INFO);
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
- ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer, length);
+ ReadSaveBuf(&ZoneInfoArray[i], buffer);
- TotalNumberOfNavigationZones = ReadSaveBuf<int16>(buffer, length);
- TotalNumberOfInfoZones = ReadSaveBuf<int16>(buffer, length);
- TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer, length);
- ReadSaveBuf<int16>(buffer, length);
+ ReadSaveBuf(&TotalNumberOfNavigationZones, buffer);
+ ReadSaveBuf(&TotalNumberOfInfoZones, buffer);
+ ReadSaveBuf(&TotalNumberOfZoneInfos, buffer);
+ SkipSaveBuf(buffer, 2);
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++)
LoadOneZone(&MapZoneArray[i], &buffer, &length, ZONE_MAPZONE);
for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
- AudioZoneArray[i] = ReadSaveBuf<int16>(buffer, length);
+ ReadSaveBuf(&AudioZoneArray[i], buffer);
- TotalNumberOfMapZones = ReadSaveBuf<uint16>(buffer, length);
- NumberOfAudioZones = ReadSaveBuf<uint16>(buffer, length);
+ ReadSaveBuf(&TotalNumberOfMapZones, buffer);
+ ReadSaveBuf(&NumberOfAudioZones, buffer);
VALIDATESAVEBUF(size)
}
@@ -764,26 +765,36 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
void
CTheZones::LoadOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType)
{
- *(uint32*)&zone->name[0] = ReadSaveBuf<uint32>(*buffer, *length);
- *(uint32*)&zone->name[4] = ReadSaveBuf<uint32>(*buffer, *length);
+#ifdef THIS_IS_STUPID
+ uint32 part1, part2;
+ ReadSaveBuf(&part1, *buffer, *length);
+ ReadSaveBuf(&part2, *buffer, *length);
+
+ *(uint64 *)&zone->name[0] = (uint64)part2;
+ *(uint64 *)&zone->name[0] <<= 32;
+ *(uint64 *)&zone->name[0] |= (uint64)part1;
+#else
+ for(int i = 0; i < sizeof(zone->name); i++)
+ ReadSaveBuf(&zone->name[i], *buffer, *length);
+#endif
- zone->minx = ReadSaveBuf<float>(*buffer, *length);
- zone->miny = ReadSaveBuf<float>(*buffer, *length);
- zone->minz = ReadSaveBuf<float>(*buffer, *length);
- zone->maxx = ReadSaveBuf<float>(*buffer, *length);
- zone->maxy = ReadSaveBuf<float>(*buffer, *length);
- zone->maxz = ReadSaveBuf<float>(*buffer, *length);
+ ReadSaveBuf(&zone->minx, *buffer, *length);
+ ReadSaveBuf(&zone->miny, *buffer, *length);
+ ReadSaveBuf(&zone->minz, *buffer, *length);
+ ReadSaveBuf(&zone->maxx, *buffer, *length);
+ ReadSaveBuf(&zone->maxy, *buffer, *length);
+ ReadSaveBuf(&zone->maxz, *buffer, *length);
- zone->type = ReadSaveBuf<eZoneType>(*buffer, *length);
- zone->level = ReadSaveBuf<eLevelName>(*buffer, *length);
- zone->zoneinfoDay = ReadSaveBuf<int16>(*buffer, *length);
- zone->zoneinfoNight = ReadSaveBuf<int16>(*buffer, *length);
+ ReadSaveBuf(&zone->type, *buffer, *length);
+ ReadSaveBuf(&zone->level, *buffer, *length);
+ ReadSaveBuf(&zone->zoneinfoDay, *buffer, *length);
+ ReadSaveBuf(&zone->zoneinfoNight, *buffer, *length);
int32 zoneId;
- zoneId = ReadSaveBuf<int32>(*buffer, *length);
- zone->child = GetPointerForZoneIndex(zoneId);
- zoneId = ReadSaveBuf<int32>(*buffer, *length);
- zone->parent = GetPointerForZoneIndex(zoneId);
- zoneId = ReadSaveBuf<int32>(*buffer, *length);
- zone->next = GetPointerForZoneIndex(zoneId);
+ ReadSaveBuf(&zoneId, *buffer, *length);
+ zone->child = GetPointerForNavigationZoneIndex(zoneId);
+ ReadSaveBuf(&zoneId, *buffer, *length);
+ zone->parent = GetPointerForNavigationZoneIndex(zoneId);
+ ReadSaveBuf(&zoneId, *buffer, *length);
+ zone->next = GetPointerForNavigationZoneIndex(zoneId);
} \ No newline at end of file