From 14b5cdfc26bc56d8037c7edee63435b29b17f354 Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Sun, 29 Mar 2020 22:32:56 +0000 Subject: games/openrct2: update to 0.2.5 --- games/openrct2/Makefile | 12 +- games/openrct2/distinfo | 14 +- games/openrct2/files/patch-bigendian | 707 ----------------------------------- 3 files changed, 16 insertions(+), 717 deletions(-) delete mode 100644 games/openrct2/files/patch-bigendian (limited to 'games/openrct2') diff --git a/games/openrct2/Makefile b/games/openrct2/Makefile index 6d313fd799ea..2226439e4fa4 100644 --- a/games/openrct2/Makefile +++ b/games/openrct2/Makefile @@ -3,10 +3,13 @@ PORTNAME= openrct2 DISTVERSIONPREFIX= v -DISTVERSION= 0.2.4 -PORTREVISION= 1 +DISTVERSION= 0.2.5 CATEGORIES= games +PATCH_SITES= https://github.com/${PORTNAME}/${PORTNAME}/commit/ +PATCHFILES= 920150b06d1888919488502021717209d08433b1.patch:-p1 \ + c8f9324e4176d57d521897565df00c33fcac0c07.patch:-p1 + MAINTAINER= pkubaj@FreeBSD.org COMMENT= Open source re-implementation of RollerCoaster Tycoon 2 @@ -23,11 +26,11 @@ LIB_DEPENDS= libpng.so:graphics/png \ libicuuc.so:devel/icu USES= cmake compiler:c++17-lang desktop-file-utils gnome gl iconv \ - localbase:ldflags pkgconfig sdl shared-mime-info ssl xorg + localbase:ldflags pkgconfig sdl shared-mime-info ssl USE_GITHUB= yes GH_ACCOUNT= OpenRCT2 GH_PROJECT= OpenRCT2 -GH_TUPLE= OpenRCT2:objects:v1.0.12:objects \ +GH_TUPLE= OpenRCT2:objects:v1.0.13:objects \ OpenRCT2:title-sequences:v0.1.2c:title_sequences USE_GL= gl USE_LDCONFIG= yes @@ -36,7 +39,6 @@ USE_SDL= sdl2 CMAKE_ON= BUILD_SHARED_LIBS CMAKE_OFF= DOWNLOAD_TITLE_SEQUENCES \ DOWNLOAD_OBJECTS -CXXFLAGS+= -D_GNU_SOURCE PORTDATA= * PORTDOCS= changelog.txt contributors.md licence.txt readme.txt diff --git a/games/openrct2/distinfo b/games/openrct2/distinfo index 815f02aa48ba..15554c024117 100644 --- a/games/openrct2/distinfo +++ b/games/openrct2/distinfo @@ -1,7 +1,11 @@ -TIMESTAMP = 1572386957 -SHA256 (OpenRCT2-OpenRCT2-v0.2.4_GH0.tar.gz) = 5662ecdc2dc22903e81eb54b3ae0e320600216b4d109c32fb3a76b68584f79bb -SIZE (OpenRCT2-OpenRCT2-v0.2.4_GH0.tar.gz) = 6805976 -SHA256 (OpenRCT2-objects-v1.0.12_GH0.tar.gz) = 12f3d9ce9c2141d18585a92a7570daf5b73edf1738ba36a356dfd3deec6d5218 -SIZE (OpenRCT2-objects-v1.0.12_GH0.tar.gz) = 637667 +TIMESTAMP = 1585520552 +SHA256 (OpenRCT2-OpenRCT2-v0.2.5_GH0.tar.gz) = 5d492320e6010fe8ba10f633ebc9846837c48f3513af0ae08c842a3c89b17ce9 +SIZE (OpenRCT2-OpenRCT2-v0.2.5_GH0.tar.gz) = 11076466 +SHA256 (OpenRCT2-objects-v1.0.13_GH0.tar.gz) = f70f7f0d9abfae295c031184aaf0476222b16db9e1369b7adde07449546f0597 +SIZE (OpenRCT2-objects-v1.0.13_GH0.tar.gz) = 697676 SHA256 (OpenRCT2-title-sequences-v0.1.2c_GH0.tar.gz) = 2f5734061ed859f9eeca821f3d483d9c95f773a40656eda74e9b65b298f19c7b SIZE (OpenRCT2-title-sequences-v0.1.2c_GH0.tar.gz) = 20478990 +SHA256 (920150b06d1888919488502021717209d08433b1.patch) = f9f9bb02f4586bf1d46759a9754a7b9cf6303ce31a7cd23de9fb591dda673751 +SIZE (920150b06d1888919488502021717209d08433b1.patch) = 1162 +SHA256 (c8f9324e4176d57d521897565df00c33fcac0c07.patch) = 9f2a079ca0d648d9b0663a5f27357a56bf707d00ec6b6508ba9c86a12875a790 +SIZE (c8f9324e4176d57d521897565df00c33fcac0c07.patch) = 995 diff --git a/games/openrct2/files/patch-bigendian b/games/openrct2/files/patch-bigendian deleted file mode 100644 index 5c30fdef22cc..000000000000 --- a/games/openrct2/files/patch-bigendian +++ /dev/null @@ -1,707 +0,0 @@ ---- src/openrct2-ui/input/KeyboardShortcuts.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2-ui/input/KeyboardShortcuts.cpp -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - - using namespace OpenRCT2; - using namespace OpenRCT2::Input; -@@ -55,14 +56,14 @@ bool KeyboardShortcuts::Load() - if (File::Exists(path)) - { - auto fs = FileStream(path, FILE_MODE_OPEN); -- uint16_t version = fs.ReadValue(); -+ uint16_t version = ORCT_SwapLEu16(fs.ReadValue()); - if (version == KeyboardShortcuts::CURRENT_FILE_VERSION) - { - int32_t numShortcutsInFile = (fs.GetLength() - sizeof(uint16_t)) / sizeof(uint16_t); - int32_t numShortcutsToRead = std::min(SHORTCUT_COUNT, numShortcutsInFile); - for (int32_t i = 0; i < numShortcutsToRead; i++) - { -- _keys[i] = fs.ReadValue(); -+ _keys[i] = ORCT_SwapLEu16(fs.ReadValue()); - } - result = true; - } ---- src/openrct2/audio/Audio.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/audio/Audio.cpp -@@ -23,6 +23,7 @@ - #include "../peep/Peep.h" - #include "../ride/Ride.h" - #include "../ui/UiContext.h" -+#include "../util/Endian.h" - #include "../util/Util.h" - #include "AudioContext.h" - #include "AudioMixer.h" -@@ -344,7 +345,7 @@ void audio_init_ride_sounds_and_info() - try - { - auto fs = FileStream(path, FILE_MODE_OPEN); -- uint32_t head = fs.ReadValue(); -+ uint32_t head = ORCT_SwapLEu32(fs.ReadValue()); - if (head == 0x78787878) - { - rideMusicInfo.length = 0; ---- src/openrct2/common.h.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/common.h -@@ -71,6 +71,10 @@ const constexpr auto ror64 = ror; - # define RCT2_ENDIANESS __ORDER_LITTLE_ENDIAN__ - # define LOBYTE(w) ((uint8_t)(w)) - # define HIBYTE(w) ((uint8_t)(((uint16_t)(w) >> 8) & 0xFF)) -+# else -+# define RCT2_ENDIANESS __ORDER_BIG_ENDIAN__ -+# define HIBYTE(w) ((uint8_t)(w)) -+# define LOBYTE(w) ((uint8_t)(((uint16_t)(w) >> 8) & 0xFF)) - # endif // __BYTE_ORDER__ - - # ifndef RCT2_ENDIANESS ---- src/openrct2/core/FileIndex.hpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/core/FileIndex.hpp -@@ -10,6 +10,7 @@ - #pragma once - - #include "../common.h" -+#include "../util/Endian.h" - #include "Console.hpp" - #include "File.h" - #include "FileScanner.h" -@@ -265,6 +266,14 @@ template class FileIndex (private) - - // Read header, check if we need to re-scan - auto header = fs.ReadValue(); -+ header.HeaderSize = ORCT_SwapLEu32(header.HeaderSize); -+ header.MagicNumber = ORCT_SwapLEu32(header.MagicNumber); -+ header.LanguageId = ORCT_SwapLEu16(header.LanguageId); -+ header.NumItems = ORCT_SwapLEu32(header.NumItems); -+ header.Stats.TotalFiles = ORCT_SwapLEu32(header.Stats.TotalFiles); -+ header.Stats.TotalFileSize = ORCT_SwapLEu64(header.Stats.TotalFileSize); -+ header.Stats.FileDateModifiedChecksum = ORCT_SwapLEu32(header.Stats.FileDateModifiedChecksum); -+ header.Stats.PathChecksum = ORCT_SwapLEu32(header.Stats.PathChecksum); - if (header.HeaderSize == sizeof(FileIndexHeader) && header.MagicNumber == _magicNumber - && header.VersionA == FILE_INDEX_VERSION && header.VersionB == _version && header.LanguageId == language - && header.Stats.TotalFiles == stats.TotalFiles && header.Stats.TotalFileSize == stats.TotalFileSize ---- src/openrct2/drawing/Drawing.Sprite.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/drawing/Drawing.Sprite.cpp -@@ -16,6 +16,7 @@ - #include "../platform/platform.h" - #include "../sprites.h" - #include "../ui/UiContext.h" -+#include "../util/Endian.h" - #include "../util/Util.h" - #include "Drawing.h" - -@@ -238,6 +239,8 @@ bool gfx_load_g1(const IPlatformEnvironment& env) - auto path = Path::Combine(env.GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA), "g1.dat"); - auto fs = FileStream(path, FILE_MODE_OPEN); - _g1.header = fs.ReadValue(); -+ _g1.header.num_entries = ORCT_SwapLEu32(_g1.header.num_entries); -+ _g1.header.total_size = ORCT_SwapLEu32(_g1.header.total_size); - - log_verbose("g1.dat, number of entries: %u", _g1.header.num_entries); - -@@ -310,6 +313,8 @@ bool gfx_load_g2() - { - auto fs = FileStream(path, FILE_MODE_OPEN); - _g2.header = fs.ReadValue(); -+ _g2.header.num_entries = ORCT_SwapLEu32(_g2.header.num_entries); -+ _g2.header.total_size = ORCT_SwapLEu32(_g2.header.total_size); - - // Read element headers - _g2.elements.resize(_g2.header.num_entries); ---- src/openrct2/object/BannerObject.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/BannerObject.cpp -@@ -14,6 +14,7 @@ - #include "../localisation/Language.h" - #include "../object/Object.h" - #include "../object/ObjectRepository.h" -+#include "../util/Endian.h" - #include "ObjectJsonHelpers.h" - #include "ObjectList.h" - -@@ -22,13 +23,14 @@ void BannerObject::ReadLegacy(IReadObjectContext* cont - stream->Seek(6, STREAM_SEEK_CURRENT); - _legacyType.banner.scrolling_mode = stream->ReadValue(); - _legacyType.banner.flags = stream->ReadValue(); -- _legacyType.banner.price = stream->ReadValue(); -+ _legacyType.banner.price = ORCT_SwapLEi16(stream->ReadValue()); - _legacyType.banner.scenery_tab_id = stream->ReadValue(); - stream->Seek(1, STREAM_SEEK_CURRENT); - - GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); - - rct_object_entry sgEntry = stream->ReadValue(); -+ sgEntry.flags = ORCT_SwapLEu32(sgEntry.flags); - SetPrimarySceneryGroup(&sgEntry); - - GetImageTable().Read(context, stream); ---- src/openrct2/object/FootpathItemObject.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/FootpathItemObject.cpp -@@ -15,6 +15,7 @@ - #include "../localisation/Localisation.h" - #include "../object/Object.h" - #include "../object/ObjectRepository.h" -+#include "../util/Endian.h" - #include "ObjectJsonHelpers.h" - #include "ObjectList.h" - -@@ -23,16 +24,17 @@ - void FootpathItemObject::ReadLegacy(IReadObjectContext* context, IStream* stream) - { - stream->Seek(6, STREAM_SEEK_CURRENT); -- _legacyType.path_bit.flags = stream->ReadValue(); -+ _legacyType.path_bit.flags = ORCT_SwapLEu16(stream->ReadValue()); - _legacyType.path_bit.draw_type = stream->ReadValue(); - _legacyType.path_bit.tool_id = stream->ReadValue(); -- _legacyType.path_bit.price = stream->ReadValue(); -+ _legacyType.path_bit.price = ORCT_SwapLEi16(stream->ReadValue()); - _legacyType.path_bit.scenery_tab_id = stream->ReadValue(); - stream->Seek(1, STREAM_SEEK_CURRENT); - - GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); - - rct_object_entry sgEntry = stream->ReadValue(); -+ sgEntry.flags = ORCT_SwapLEu32(sgEntry.flags); - SetPrimarySceneryGroup(&sgEntry); - - GetImageTable().Read(context, stream); ---- src/openrct2/object/ImageTable.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/ImageTable.cpp -@@ -11,6 +11,7 @@ - - #include "../OpenRCT2.h" - #include "../core/IStream.hpp" -+#include "../util/Endian.h" - #include "Object.h" - - #include -@@ -37,8 +38,8 @@ void ImageTable::Read(IReadObjectContext* context, ISt - - try - { -- uint32_t numImages = stream->ReadValue(); -- uint32_t imageDataSize = stream->ReadValue(); -+ uint32_t numImages = ORCT_SwapLEu32(stream->ReadValue()); -+ uint32_t imageDataSize = ORCT_SwapLEu32(stream->ReadValue()); - - uint64_t headerTableSize = numImages * 16; - uint64_t remainingBytes = stream->GetLength() - stream->GetPosition() - headerTableSize; -@@ -63,15 +64,15 @@ void ImageTable::Read(IReadObjectContext* context, ISt - { - rct_g1_element g1Element; - -- uintptr_t imageDataOffset = (uintptr_t)stream->ReadValue(); -+ uintptr_t imageDataOffset = ORCT_SwapLEu32((uintptr_t)stream->ReadValue()); - g1Element.offset = (uint8_t*)(imageDataBase + imageDataOffset); - -- g1Element.width = stream->ReadValue(); -- g1Element.height = stream->ReadValue(); -- g1Element.x_offset = stream->ReadValue(); -- g1Element.y_offset = stream->ReadValue(); -- g1Element.flags = stream->ReadValue(); -- g1Element.zoomed_offset = stream->ReadValue(); -+ g1Element.width = ORCT_SwapLEi16(stream->ReadValue()); -+ g1Element.height = ORCT_SwapLEi16(stream->ReadValue()); -+ g1Element.x_offset = ORCT_SwapLEi16(stream->ReadValue()); -+ g1Element.y_offset = ORCT_SwapLEi16(stream->ReadValue()); -+ g1Element.flags = ORCT_SwapLEu16(stream->ReadValue()); -+ g1Element.zoomed_offset = ORCT_SwapLEu16(stream->ReadValue()); - - newEntries.push_back(g1Element); - } ---- src/openrct2/object/LargeSceneryObject.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/LargeSceneryObject.cpp -@@ -16,6 +16,7 @@ - #include "../drawing/Drawing.h" - #include "../interface/Cursors.h" - #include "../localisation/Language.h" -+#include "../util/Endian.h" - #include "../world/Banner.h" - #include "../world/Location.hpp" - #include "ObjectJsonHelpers.h" -@@ -28,8 +29,8 @@ void LargeSceneryObject::ReadLegacy(IReadObjectContext - stream->Seek(6, STREAM_SEEK_CURRENT); - _legacyType.large_scenery.tool_id = stream->ReadValue(); - _legacyType.large_scenery.flags = stream->ReadValue(); -- _legacyType.large_scenery.price = stream->ReadValue(); -- _legacyType.large_scenery.removal_price = stream->ReadValue(); -+ _legacyType.large_scenery.price = ORCT_SwapLEi16(stream->ReadValue()); -+ _legacyType.large_scenery.removal_price = ORCT_SwapLEi16(stream->ReadValue()); - stream->Seek(5, STREAM_SEEK_CURRENT); - _legacyType.large_scenery.scenery_tab_id = 0xFF; - _legacyType.large_scenery.scrolling_mode = stream->ReadValue(); -@@ -38,6 +39,7 @@ void LargeSceneryObject::ReadLegacy(IReadObjectContext - GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); - - rct_object_entry sgEntry = stream->ReadValue(); -+ sgEntry.flags = ORCT_SwapLEu32(sgEntry.flags); - SetPrimarySceneryGroup(&sgEntry); - - if (_legacyType.large_scenery.flags & LARGE_SCENERY_FLAG_3D_TEXT) -@@ -112,10 +114,17 @@ void LargeSceneryObject::DrawPreview(rct_drawpixelinfo - std::vector LargeSceneryObject::ReadTiles(IStream* stream) - { - auto tiles = std::vector(); -+ // Note: no need to swap the value here... - while (stream->ReadValue() != 0xFFFF) - { - stream->Seek(-2, STREAM_SEEK_CURRENT); -+ - auto tile = stream->ReadValue(); -+ tile.x_offset = ORCT_SwapLEi16(tile.x_offset); -+ tile.y_offset = ORCT_SwapLEi16(tile.y_offset); -+ tile.z_offset = ORCT_SwapLEi16(tile.z_offset); -+ tile.z_clearance = ORCT_SwapLEi16(tile.z_clearance); -+ tile.flags = ORCT_SwapLEi16(tile.flags); - tiles.push_back(tile); - } - tiles.push_back({ -1, -1, -1, 255, 0xFFFF }); ---- src/openrct2/object/ObjectFactory.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/ObjectFactory.cpp -@@ -20,6 +20,7 @@ - #include "../core/String.hpp" - #include "../core/Zip.h" - #include "../rct12/SawyerChunkReader.h" -+#include "../util/Endian.h" - #include "BannerObject.h" - #include "EntranceObject.h" - #include "FootpathItemObject.h" ---- src/openrct2/object/ObjectRepository.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/ObjectRepository.cpp -@@ -29,6 +29,7 @@ - #include "../rct12/SawyerChunkReader.h" - #include "../rct12/SawyerChunkWriter.h" - #include "../scenario/ScenarioRepository.h" -+#include "../util/Endian.h" - #include "../util/SawyerCoding.h" - #include "../util/Util.h" - #include "Object.h" -@@ -161,6 +162,7 @@ class ObjectFileIndex final : public FileIndexReadValue(); -+ item.ObjectEntry.flags = ORCT_SwapLEu32(item.ObjectEntry.flags); - item.Path = stream->ReadStdString(); - item.Name = stream->ReadStdString(); - auto sourceLength = stream->ReadValue(); -@@ -186,11 +188,12 @@ class ObjectFileIndex final : public FileIndexReadValue(); -+ auto numEntries = ORCT_SwapLEu16(stream->ReadValue()); - item.SceneryGroupInfo.Entries = std::vector(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - item.SceneryGroupInfo.Entries[i] = stream->ReadValue(); -+ item.SceneryGroupInfo.Entries[i].flags = ORCT_SwapLEu32(item.SceneryGroupInfo.Entries[i].flags); - } - break; - } -@@ -363,6 +366,7 @@ class ObjectRepository final : public IObjectRepositor - - // Check if we already have this object - rct_object_entry entry = stream->ReadValue(); -+ entry.flags = ORCT_SwapLEu32(entry.flags); - if (FindObject(&entry) != nullptr) - { - chunkReader.SkipChunk(); -@@ -622,6 +626,7 @@ class ObjectRepository final : public IObjectRepositor - // Read object data from file - auto fs = FileStream(item->Path, FILE_MODE_OPEN); - auto fileEntry = fs.ReadValue(); -+ fileEntry.flags = ORCT_SwapLEu32(fileEntry.flags); - if (!object_entry_compare(entry, &fileEntry)) - { - throw std::runtime_error("Header found in object file does not match object to pack."); ---- src/openrct2/object/RideObject.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/RideObject.cpp -@@ -23,6 +23,7 @@ - #include "../ride/RideGroupManager.h" - #include "../ride/ShopItem.h" - #include "../ride/Track.h" -+#include "../util/Endian.h" - #include "ObjectJsonHelpers.h" - #include "ObjectRepository.h" - -@@ -35,7 +36,7 @@ using namespace OpenRCT2; - void RideObject::ReadLegacy(IReadObjectContext* context, IStream* stream) - { - stream->Seek(8, STREAM_SEEK_CURRENT); -- _legacyType.flags = stream->ReadValue(); -+ _legacyType.flags = ORCT_SwapLEu32(stream->ReadValue()); - for (auto& rideType : _legacyType.ride_type) - { - rideType = stream->ReadValue(); -@@ -60,7 +61,7 @@ void RideObject::ReadLegacy(IReadObjectContext* contex - _legacyType.intensity_multiplier = stream->ReadValue(); - _legacyType.nausea_multiplier = stream->ReadValue(); - _legacyType.max_height = stream->ReadValue(); -- _legacyType.enabledTrackPieces = stream->ReadValue(); -+ _legacyType.enabledTrackPieces = ORCT_SwapLEu64(stream->ReadValue()); - _legacyType.category[0] = stream->ReadValue(); - _legacyType.category[1] = stream->ReadValue(); - _legacyType.shop_item = stream->ReadValue(); -@@ -108,7 +109,7 @@ void RideObject::ReadLegacy(IReadObjectContext* contex - uint16_t numPeepLoadingPositions = stream->ReadValue(); - if (numPeepLoadingPositions == 255) - { -- numPeepLoadingPositions = stream->ReadValue(); -+ numPeepLoadingPositions = ORCT_SwapLEu16(stream->ReadValue()); - } - - if (_legacyType.vehicles[i].flags & VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS) -@@ -130,7 +131,7 @@ void RideObject::ReadLegacy(IReadObjectContext* contex - entry[1].y = stream->ReadValue(); - entry[2].x = stream->ReadValue(); - entry[2].y = stream->ReadValue(); -- stream->ReadValue(); // Skip blanks -+ stream->ReadValue(); // Skip blanks, no need to swap endianess - - _peepLoadingWaypoints[i].push_back(entry); - } -@@ -426,19 +427,19 @@ void RideObject::SetRepositoryItem(ObjectRepositoryIte - void RideObject::ReadLegacyVehicle( - [[maybe_unused]] IReadObjectContext* context, IStream* stream, rct_ride_entry_vehicle* vehicle) - { -- vehicle->rotation_frame_mask = stream->ReadValue(); -+ vehicle->rotation_frame_mask = ORCT_SwapLEu16(stream->ReadValue()); - stream->Seek(2 * 1, STREAM_SEEK_CURRENT); -- vehicle->spacing = stream->ReadValue(); -- vehicle->car_mass = stream->ReadValue(); -+ vehicle->spacing = ORCT_SwapLEu32(stream->ReadValue()); -+ vehicle->car_mass = ORCT_SwapLEu16(stream->ReadValue()); - vehicle->tab_height = stream->ReadValue(); - vehicle->num_seats = stream->ReadValue(); -- vehicle->sprite_flags = stream->ReadValue(); -+ vehicle->sprite_flags = ORCT_SwapLEu16(stream->ReadValue()); - vehicle->sprite_width = stream->ReadValue(); - vehicle->sprite_height_negative = stream->ReadValue(); - vehicle->sprite_height_positive = stream->ReadValue(); - vehicle->animation = stream->ReadValue(); -- vehicle->flags = stream->ReadValue(); -- vehicle->base_num_frames = stream->ReadValue(); -+ vehicle->flags = ORCT_SwapLEu32(stream->ReadValue()); -+ vehicle->base_num_frames = ORCT_SwapLEu16(stream->ReadValue()); - stream->Seek(15 * 4, STREAM_SEEK_CURRENT); - vehicle->no_seating_rows = stream->ReadValue(); - vehicle->spinning_inertia = stream->ReadValue(); ---- src/openrct2/object/SceneryGroupObject.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/SceneryGroupObject.cpp -@@ -18,6 +18,7 @@ - #include "../drawing/Drawing.h" - #include "../localisation/Language.h" - #include "../peep/Staff.h" -+#include "../util/Endian.h" - #include "ObjectJsonHelpers.h" - #include "ObjectManager.h" - #include "ObjectRepository.h" -@@ -34,7 +35,7 @@ void SceneryGroupObject::ReadLegacy(IReadObjectContext - _legacyType.pad_107 = stream->ReadValue(); - _legacyType.priority = stream->ReadValue(); - _legacyType.pad_109 = stream->ReadValue(); -- _legacyType.entertainer_costumes = stream->ReadValue(); -+ _legacyType.entertainer_costumes = ORCT_SwapLEu32(stream->ReadValue()); - - GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); - _items = ReadItems(stream); -@@ -126,6 +127,7 @@ std::vector SceneryGroupObject::Read - { - stream->Seek(-1, STREAM_SEEK_CURRENT); - auto entry = stream->ReadValue(); -+ entry.flags = ORCT_SwapLEu32(entry.flags); - items.push_back(entry); - } - return items; ---- src/openrct2/object/SmallSceneryObject.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/SmallSceneryObject.cpp -@@ -17,6 +17,7 @@ - #include "../drawing/Drawing.h" - #include "../interface/Cursors.h" - #include "../localisation/Language.h" -+#include "../util/Endian.h" - #include "../world/Scenery.h" - #include "../world/SmallScenery.h" - #include "ObjectJsonHelpers.h" -@@ -26,20 +27,21 @@ - void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream) - { - stream->Seek(6, STREAM_SEEK_CURRENT); -- _legacyType.small_scenery.flags = stream->ReadValue(); -+ _legacyType.small_scenery.flags = ORCT_SwapLEu32(stream->ReadValue()); - _legacyType.small_scenery.height = stream->ReadValue(); - _legacyType.small_scenery.tool_id = stream->ReadValue(); -- _legacyType.small_scenery.price = stream->ReadValue(); -- _legacyType.small_scenery.removal_price = stream->ReadValue(); -+ _legacyType.small_scenery.price = ORCT_SwapLEu16(stream->ReadValue()); -+ _legacyType.small_scenery.removal_price = ORCT_SwapLEu16(stream->ReadValue()); - stream->Seek(4, STREAM_SEEK_CURRENT); -- _legacyType.small_scenery.animation_delay = stream->ReadValue(); -- _legacyType.small_scenery.animation_mask = stream->ReadValue(); -- _legacyType.small_scenery.num_frames = stream->ReadValue(); -+ _legacyType.small_scenery.animation_delay = ORCT_SwapLEu16(stream->ReadValue()); -+ _legacyType.small_scenery.animation_mask = ORCT_SwapLEu16(stream->ReadValue()); -+ _legacyType.small_scenery.num_frames = ORCT_SwapLEu16(stream->ReadValue()); - _legacyType.small_scenery.scenery_tab_id = 0xFF; - - GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); - - rct_object_entry sgEntry = stream->ReadValue(); -+ sgEntry.flags = ORCT_SwapLEu32(sgEntry.flags); - SetPrimarySceneryGroup(&sgEntry); - - if (scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS)) ---- src/openrct2/object/WallObject.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/WallObject.cpp -@@ -14,6 +14,7 @@ - #include "../drawing/Drawing.h" - #include "../interface/Cursors.h" - #include "../localisation/Language.h" -+#include "../util/Endian.h" - #include "../world/Banner.h" - #include "ObjectJsonHelpers.h" - -@@ -24,13 +25,14 @@ void WallObject::ReadLegacy(IReadObjectContext* contex - _legacyType.wall.flags = stream->ReadValue(); - _legacyType.wall.height = stream->ReadValue(); - _legacyType.wall.flags2 = stream->ReadValue(); -- _legacyType.wall.price = stream->ReadValue(); -+ _legacyType.wall.price = ORCT_SwapLEu16(stream->ReadValue()); - _legacyType.wall.scenery_tab_id = stream->ReadValue(); - _legacyType.wall.scrolling_mode = stream->ReadValue(); - - GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); - - rct_object_entry sgEntry = stream->ReadValue(); -+ sgEntry.flags = ORCT_SwapLEu16(sgEntry.flags); - SetPrimarySceneryGroup(&sgEntry); - - GetImageTable().Read(context, stream); ---- src/openrct2/object/WaterObject.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/object/WaterObject.cpp -@@ -15,6 +15,7 @@ - #include "../core/IStream.hpp" - #include "../localisation/Language.h" - #include "../localisation/StringIds.h" -+#include "../util/Endian.h" - #include "ObjectJsonHelpers.h" - - #include -@@ -22,7 +23,7 @@ - void WaterObject::ReadLegacy(IReadObjectContext* context, IStream* stream) - { - stream->Seek(14, STREAM_SEEK_CURRENT); -- _legacyType.flags = stream->ReadValue(); -+ _legacyType.flags = ORCT_SwapLEu16(stream->ReadValue()); - - GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); - GetImageTable().Read(context, stream); ---- src/openrct2/rct12/SawyerChunkReader.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/rct12/SawyerChunkReader.cpp -@@ -10,6 +10,7 @@ - #include "SawyerChunkReader.h" - - #include "../core/IStream.hpp" -+#include "../util/Endian.h" - - // malloc is very slow for large allocations in MSVC debug builds as it allocates - // memory on a special debug heap and then initialises all the memory to 0xCC. -@@ -52,6 +53,7 @@ void SawyerChunkReader::SkipChunk() - try - { - auto header = _stream->ReadValue(); -+ header.length = ORCT_SwapLEu32(header.length); - _stream->Seek(header.length, STREAM_SEEK_CURRENT); - } - catch (const std::exception&) -@@ -68,6 +70,7 @@ std::shared_ptr SawyerChunkReader::ReadCh - try - { - auto header = _stream->ReadValue(); -+ header.length = ORCT_SwapLEu32(header.length); - if (header.length >= MAX_UNCOMPRESSED_CHUNK_SIZE) - throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_CHUNK_SIZE); - ---- src/openrct2/rct12/SawyerEncoding.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/rct12/SawyerEncoding.cpp -@@ -10,6 +10,7 @@ - #include "SawyerEncoding.h" - - #include "../core/IStream.hpp" -+#include "../util/Endian.h" - #include "RCT12.h" - - #include -@@ -45,7 +46,7 @@ namespace SawyerEncoding - } while (dataSize != 0); - - // Read file checksum -- uint32_t fileChecksum = stream->ReadValue(); -+ uint32_t fileChecksum = ORCT_SwapLEu32(stream->ReadValue()); - - // Rewind back to original position - stream->SetPosition(initialPosition); ---- src/openrct2/ride/TrackDesignRepository.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/ride/TrackDesignRepository.cpp -@@ -22,6 +22,7 @@ - #include "../localisation/LocalisationService.h" - #include "../object/ObjectRepository.h" - #include "../object/RideObject.h" -+#include "../util/Endian.h" - #include "RideGroupManager.h" - #include "TrackDesign.h" - -@@ -113,7 +114,7 @@ class TrackDesignFileIndex final : public FileIndexReadStdString(); - item.RideType = stream->ReadValue(); - item.ObjectEntry = stream->ReadStdString(); -- item.Flags = stream->ReadValue(); -+ item.Flags = ORCT_SwapLEu32(stream->ReadValue()); - return item; - } - ---- src/openrct2/scenario/ScenarioRepository.cpp.orig 2019-10-28 20:18:47 UTC -+++ src/openrct2/scenario/ScenarioRepository.cpp -@@ -25,6 +25,7 @@ - #include "../localisation/LocalisationService.h" - #include "../platform/platform.h" - #include "../rct12/SawyerChunkReader.h" -+#include "../util/Endian.h" - #include "Scenario.h" - #include "ScenarioSources.h" - -@@ -182,17 +183,17 @@ class ScenarioFileIndex final : public FileIndexRead(item.path, sizeof(item.path)); -- item.timestamp = stream->ReadValue(); -+ item.timestamp = ORCT_SwapLEu64(stream->ReadValue()); - - item.category = stream->ReadValue(); - item.source_game = stream->ReadValue(); -- item.source_index = stream->ReadValue(); -- item.sc_id = stream->ReadValue(); -+ item.source_index = ORCT_SwapLEi16(stream->ReadValue()); -+ item.sc_id = ORCT_SwapLEu16(stream->ReadValue()); - - item.objective_type = stream->ReadValue(); - item.objective_arg_1 = stream->ReadValue(); -- item.objective_arg_2 = stream->ReadValue(); -- item.objective_arg_3 = stream->ReadValue(); -+ item.objective_arg_2 = ORCT_SwapLEi32(stream->ReadValue()); -+ item.objective_arg_3 = ORCT_SwapLEi16(stream->ReadValue()); - item.highscore = nullptr; - - stream->Read(item.internal_name, sizeof(item.internal_name)); -@@ -587,7 +588,7 @@ class ScenarioRepository final : public IScenarioRepos - try - { - auto fs = FileStream(path, FILE_MODE_OPEN); -- uint32_t fileVersion = fs.ReadValue(); -+ uint32_t fileVersion = ORCT_SwapLEu32(fs.ReadValue()); - if (fileVersion != 1) - { - Console::Error::WriteLine("Invalid or incompatible highscores file."); -@@ -596,14 +597,14 @@ class ScenarioRepository final : public IScenarioRepos - - ClearHighscores(); - -- uint32_t numHighscores = fs.ReadValue(); -+ uint32_t numHighscores = ORCT_SwapLEu32(fs.ReadValue()); - for (uint32_t i = 0; i < numHighscores; i++) - { - scenario_highscore_entry* highscore = InsertHighscore(); - highscore->fileName = fs.ReadString(); - highscore->name = fs.ReadString(); -- highscore->company_value = fs.ReadValue(); -- highscore->timestamp = fs.ReadValue(); -+ highscore->company_value = ORCT_SwapLEi32(fs.ReadValue()); -+ highscore->timestamp = ORCT_SwapLEu64(fs.ReadValue()); - } - } - catch (const std::exception&) -@@ -647,6 +648,10 @@ class ScenarioRepository final : public IScenarioRepos - { - // Read legacy entry - auto scBasic = fs.ReadValue(); -+ scBasic.objectiveArg2 = ORCT_SwapLEi32(scBasic.objectiveArg2); -+ scBasic.objectiveArg3 = ORCT_SwapLEi16(scBasic.objectiveArg3); -+ scBasic.Flags = ORCT_SwapLEi32(scBasic.Flags); -+ scBasic.CompanyValue = ORCT_SwapLEi32(scBasic.CompanyValue); - - // Ignore non-completed scenarios - if (scBasic.Flags & SCENARIO_FLAGS_COMPLETED) ---- src/openrct2/util/Endian.h.orig 2019-10-29 22:14:34 UTC -+++ src/openrct2/util/Endian.h -@@ -0,0 +1,70 @@ -+#include -+ -+#pragma once -+ -+// Based on SDL2 -+ -+#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ -+ -+static inline uint16_t ORCT_Swapu16(uint16_t x) -+{ -+ return static_cast((x << 8) | (x >> 8)); -+} -+ -+static inline uint32_t ORCT_Swapu32(uint32_t x) -+{ -+ return static_cast(((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x >> 24))); -+} -+ -+static inline uint64_t ORCT_Swapu64(uint64_t x) -+{ -+ uint32_t hi, lo; -+ -+ /* Separate into high and low 32-bit values and swap them */ -+ lo = static_cast(x & 0xFFFFFFFF); -+ x >>= 32; -+ hi = static_cast(x & 0xFFFFFFFF); -+ x = ORCT_Swapu32(lo); -+ x <<= 32; -+ x |= ORCT_Swapu32(hi); -+ return (x); -+} -+ -+static inline int16_t ORCT_Swapi16(int16_t x) -+{ -+ return static_cast((x << 8) | (x >> 8)); -+} -+ -+static inline int32_t ORCT_Swapi32(int32_t x) -+{ -+ return static_cast(((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x >> 24))); -+} -+ -+static inline int64_t ORCT_Swapi64(int64_t x) -+{ -+ uint32_t hi, lo; -+ -+ /* Separate into high and low 32-bit values and swap them */ -+ lo = static_cast(x & 0xFFFFFFFF); -+ x >>= 32; -+ hi = static_cast(x & 0xFFFFFFFF); -+ x = ORCT_Swapu32(lo); -+ x <<= 32; -+ x |= ORCT_Swapu32(hi); -+ return (x); -+} -+ -+# define ORCT_SwapLEi16(X) ORCT_Swapi16(X) -+# define ORCT_SwapLEi32(X) ORCT_Swapi32(X) -+# define ORCT_SwapLEi64(X) ORCT_Swapi64(X) -+# define ORCT_SwapLEu16(X) ORCT_Swapu16(X) -+# define ORCT_SwapLEu32(X) ORCT_Swapu32(X) -+# define ORCT_SwapLEu64(X) ORCT_Swapu64(X) -+#else -+# define ORCT_SwapLEi16(X) (X) -+# define ORCT_SwapLEi32(X) (X) -+# define ORCT_SwapLEi64(X) (X) -+# define ORCT_SwapLEu16(X) (X) -+# define ORCT_SwapLEu32(X) (X) -+# define ORCT_SwapLEu64(X) (X) -+#endif -- cgit v1.2.3