aboutsummaryrefslogtreecommitdiff
path: root/games/openrct2/files/patch-bigendian
blob: 378bfc3d59749b650c0eb34e11b671787c307f0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
--- src/openrct2-ui/input/KeyboardShortcuts.cpp.orig	2019-03-13 20:51:10 UTC
+++ src/openrct2-ui/input/KeyboardShortcuts.cpp
@@ -19,6 +19,7 @@
 #include <openrct2/core/Path.hpp>
 #include <openrct2/core/String.hpp>
 #include <openrct2/localisation/Localisation.h>
+#include <openrct2/util/Endian.h>
 
 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>();
+            uint16_t version = ORCT_SwapLEu16(fs.ReadValue<uint16_t>());
             if (version == KeyboardShortcuts::CURRENT_FILE_VERSION)
             {
                 int32_t numShortcutsInFile = (fs.GetLength() - sizeof(uint16_t)) / sizeof(uint16_t);
                 int32_t numShortcutsToRead = std::min<int32_t>(SHORTCUT_COUNT, numShortcutsInFile);
                 for (int32_t i = 0; i < numShortcutsToRead; i++)
                 {
-                    _keys[i] = fs.ReadValue<uint16_t>();
+                    _keys[i] = ORCT_SwapLEu16(fs.ReadValue<uint16_t>());
                 }
                 result = true;
             }
--- src/openrct2/audio/Audio.cpp.orig	2019-03-13 20:51:10 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"
@@ -350,7 +351,7 @@ void audio_init_ride_sounds_and_info()
             try
             {
                 auto fs = FileStream(path, FILE_MODE_OPEN);
-                uint32_t head = fs.ReadValue<uint32_t>();
+                uint32_t head = ORCT_SwapLEu32(fs.ReadValue<uint32_t>());
                 if (head == 0x78787878)
                 {
                     rideMusicInfo.length = 0;
--- src/openrct2/common.h.orig	2019-03-13 20:51:10 UTC
+++ src/openrct2/common.h
@@ -75,6 +75,10 @@ const constexpr auto ror64 = ror<uint64_
 #        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-03-13 20:51:10 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 @@ private:
 
                 // Read header, check if we need to re-scan
                 auto header = fs.ReadValue<FileIndexHeader>();
+                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-03-13 20:51:10 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"
 
@@ -237,6 +238,8 @@ bool gfx_load_g1(const IPlatformEnvironm
         auto path = Path::Combine(env.GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA), "g1.dat");
         auto fs = FileStream(path, FILE_MODE_OPEN);
         _g1.header = fs.ReadValue<rct_g1_header>();
+        _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);
 
@@ -309,6 +312,8 @@ bool gfx_load_g2()
     {
         auto fs = FileStream(path, FILE_MODE_OPEN);
         _g2.header = fs.ReadValue<rct_g1_header>();
+        _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-03-13 20:51:10 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(IReadObjec
     stream->Seek(6, STREAM_SEEK_CURRENT);
     _legacyType.banner.scrolling_mode = stream->ReadValue<uint8_t>();
     _legacyType.banner.flags = stream->ReadValue<uint8_t>();
-    _legacyType.banner.price = stream->ReadValue<int16_t>();
+    _legacyType.banner.price = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
     _legacyType.banner.scenery_tab_id = stream->ReadValue<uint8_t>();
     stream->Seek(1, STREAM_SEEK_CURRENT);
 
     GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME);
 
     rct_object_entry sgEntry = stream->ReadValue<rct_object_entry>();
+    sgEntry.flags = ORCT_SwapLEu32(sgEntry.flags);
     SetPrimarySceneryGroup(&sgEntry);
 
     GetImageTable().Read(context, stream);
--- src/openrct2/object/FootpathItemObject.cpp.orig	2019-03-13 20:51:10 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<uint16_t>();
+    _legacyType.path_bit.flags = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
     _legacyType.path_bit.draw_type = stream->ReadValue<uint8_t>();
     _legacyType.path_bit.tool_id = stream->ReadValue<uint8_t>();
-    _legacyType.path_bit.price = stream->ReadValue<int16_t>();
+    _legacyType.path_bit.price = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
     _legacyType.path_bit.scenery_tab_id = stream->ReadValue<uint8_t>();
     stream->Seek(1, STREAM_SEEK_CURRENT);
 
     GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME);
 
     rct_object_entry sgEntry = stream->ReadValue<rct_object_entry>();
+    sgEntry.flags = ORCT_SwapLEu32(sgEntry.flags);
     SetPrimarySceneryGroup(&sgEntry);
 
     GetImageTable().Read(context, stream);
--- src/openrct2/object/ImageTable.cpp.orig	2019-03-13 20:51:10 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 <algorithm>
@@ -37,8 +38,8 @@ void ImageTable::Read(IReadObjectContext
 
     try
     {
-        uint32_t numImages = stream->ReadValue<uint32_t>();
-        uint32_t imageDataSize = stream->ReadValue<uint32_t>();
+        uint32_t numImages = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
+        uint32_t imageDataSize = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
 
         uint64_t headerTableSize = numImages * 16;
         uint64_t remainingBytes = stream->GetLength() - stream->GetPosition() - headerTableSize;
@@ -63,15 +64,15 @@ void ImageTable::Read(IReadObjectContext
         {
             rct_g1_element g1Element;
 
-            uintptr_t imageDataOffset = (uintptr_t)stream->ReadValue<uint32_t>();
+            uintptr_t imageDataOffset = ORCT_SwapLEu32((uintptr_t)stream->ReadValue<uint32_t>());
             g1Element.offset = (uint8_t*)(imageDataBase + imageDataOffset);
 
-            g1Element.width = stream->ReadValue<int16_t>();
-            g1Element.height = stream->ReadValue<int16_t>();
-            g1Element.x_offset = stream->ReadValue<int16_t>();
-            g1Element.y_offset = stream->ReadValue<int16_t>();
-            g1Element.flags = stream->ReadValue<uint16_t>();
-            g1Element.zoomed_offset = stream->ReadValue<uint16_t>();
+            g1Element.width = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
+            g1Element.height = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
+            g1Element.x_offset = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
+            g1Element.y_offset = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
+            g1Element.flags = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
+            g1Element.zoomed_offset = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
 
             newEntries.push_back(g1Element);
         }
--- src/openrct2/object/LargeSceneryObject.cpp.orig	2019-03-13 20:51:10 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(IRea
     stream->Seek(6, STREAM_SEEK_CURRENT);
     _legacyType.large_scenery.tool_id = stream->ReadValue<uint8_t>();
     _legacyType.large_scenery.flags = stream->ReadValue<uint8_t>();
-    _legacyType.large_scenery.price = stream->ReadValue<int16_t>();
-    _legacyType.large_scenery.removal_price = stream->ReadValue<int16_t>();
+    _legacyType.large_scenery.price = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
+    _legacyType.large_scenery.removal_price = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
     stream->Seek(5, STREAM_SEEK_CURRENT);
     _legacyType.large_scenery.scenery_tab_id = 0xFF;
     _legacyType.large_scenery.scrolling_mode = stream->ReadValue<uint8_t>();
@@ -38,6 +39,7 @@ void LargeSceneryObject::ReadLegacy(IRea
     GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME);
 
     rct_object_entry sgEntry = stream->ReadValue<rct_object_entry>();
+    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
 std::vector<rct_large_scenery_tile> LargeSceneryObject::ReadTiles(IStream* stream)
 {
     auto tiles = std::vector<rct_large_scenery_tile>();
+    // Note: no need to swap the value here...
     while (stream->ReadValue<uint16_t>() != 0xFFFF)
     {
         stream->Seek(-2, STREAM_SEEK_CURRENT);
+
         auto tile = stream->ReadValue<rct_large_scenery_tile>();
+        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-03-13 20:51:10 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-03-13 20:51:10 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 @@ protected:
         ObjectRepositoryItem item;
 
         item.ObjectEntry = stream->ReadValue<rct_object_entry>();
+        item.ObjectEntry.flags = ORCT_SwapLEu32(item.ObjectEntry.flags);
         item.Path = stream->ReadStdString();
         item.Name = stream->ReadStdString();
         auto sourceLength = stream->ReadValue<uint8_t>();
@@ -186,11 +188,12 @@ protected:
                 break;
             case OBJECT_TYPE_SCENERY_GROUP:
             {
-                auto numEntries = stream->ReadValue<uint16_t>();
+                auto numEntries = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
                 item.SceneryGroupInfo.Entries = std::vector<rct_object_entry>(numEntries);
                 for (size_t i = 0; i < numEntries; i++)
                 {
                     item.SceneryGroupInfo.Entries[i] = stream->ReadValue<rct_object_entry>();
+                    item.SceneryGroupInfo.Entries[i].flags = ORCT_SwapLEu32(item.SceneryGroupInfo.Entries[i].flags);
                 }
                 break;
             }
@@ -363,6 +366,7 @@ public:
 
         // Check if we already have this object
         rct_object_entry entry = stream->ReadValue<rct_object_entry>();
+        entry.flags = ORCT_SwapLEu32(entry.flags);
         if (FindObject(&entry) != nullptr)
         {
             chunkReader.SkipChunk();
@@ -622,6 +626,7 @@ private:
         // Read object data from file
         auto fs = FileStream(item->Path, FILE_MODE_OPEN);
         auto fileEntry = fs.ReadValue<rct_object_entry>();
+        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-03-13 20:51:10 UTC
+++ src/openrct2/object/RideObject.cpp
@@ -22,6 +22,7 @@
 #include "../ride/RideGroupManager.h"
 #include "../ride/ShopItem.h"
 #include "../ride/Track.h"
+#include "../util/Endian.h"
 #include "ObjectJsonHelpers.h"
 #include "ObjectRepository.h"
 
@@ -34,7 +35,7 @@ using namespace OpenRCT2;
 void RideObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
 {
     stream->Seek(8, STREAM_SEEK_CURRENT);
-    _legacyType.flags = stream->ReadValue<uint32_t>();
+    _legacyType.flags = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
     for (auto& rideType : _legacyType.ride_type)
     {
         rideType = stream->ReadValue<uint8_t>();
@@ -59,7 +60,7 @@ void RideObject::ReadLegacy(IReadObjectC
     _legacyType.intensity_multiplier = stream->ReadValue<int8_t>();
     _legacyType.nausea_multiplier = stream->ReadValue<int8_t>();
     _legacyType.max_height = stream->ReadValue<uint8_t>();
-    _legacyType.enabledTrackPieces = stream->ReadValue<uint64_t>();
+    _legacyType.enabledTrackPieces = ORCT_SwapLEu64(stream->ReadValue<uint64_t>());
     _legacyType.category[0] = stream->ReadValue<uint8_t>();
     _legacyType.category[1] = stream->ReadValue<uint8_t>();
     _legacyType.shop_item = stream->ReadValue<uint8_t>();
@@ -94,7 +95,7 @@ void RideObject::ReadLegacy(IReadObjectC
         uint16_t numPeepLoadingPositions = stream->ReadValue<uint8_t>();
         if (numPeepLoadingPositions == 255)
         {
-            numPeepLoadingPositions = stream->ReadValue<uint16_t>();
+            numPeepLoadingPositions = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
         }
 
         if (_legacyType.vehicles[i].flags & VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS)
@@ -116,7 +117,7 @@ void RideObject::ReadLegacy(IReadObjectC
                 entry[1].y = stream->ReadValue<int8_t>();
                 entry[2].x = stream->ReadValue<int8_t>();
                 entry[2].y = stream->ReadValue<int8_t>();
-                stream->ReadValue<uint16_t>(); // Skip blanks
+                stream->ReadValue<uint16_t>(); // Skip blanks, no need to swap endianess
 
                 _peepLoadingWaypoints[i].push_back(entry);
             }
@@ -412,19 +413,19 @@ void RideObject::SetRepositoryItem(Objec
 void RideObject::ReadLegacyVehicle(
     [[maybe_unused]] IReadObjectContext* context, IStream* stream, rct_ride_entry_vehicle* vehicle)
 {
-    vehicle->rotation_frame_mask = stream->ReadValue<uint16_t>();
+    vehicle->rotation_frame_mask = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
     stream->Seek(2 * 1, STREAM_SEEK_CURRENT);
-    vehicle->spacing = stream->ReadValue<uint32_t>();
-    vehicle->car_mass = stream->ReadValue<uint16_t>();
+    vehicle->spacing = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
+    vehicle->car_mass = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
     vehicle->tab_height = stream->ReadValue<int8_t>();
     vehicle->num_seats = stream->ReadValue<uint8_t>();
-    vehicle->sprite_flags = stream->ReadValue<uint16_t>();
+    vehicle->sprite_flags = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
     vehicle->sprite_width = stream->ReadValue<uint8_t>();
     vehicle->sprite_height_negative = stream->ReadValue<uint8_t>();
     vehicle->sprite_height_positive = stream->ReadValue<uint8_t>();
     vehicle->animation = stream->ReadValue<uint8_t>();
-    vehicle->flags = stream->ReadValue<uint32_t>();
-    vehicle->base_num_frames = stream->ReadValue<uint16_t>();
+    vehicle->flags = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
+    vehicle->base_num_frames = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
     stream->Seek(15 * 4, STREAM_SEEK_CURRENT);
     vehicle->no_seating_rows = stream->ReadValue<uint8_t>();
     vehicle->spinning_inertia = stream->ReadValue<uint8_t>();
--- src/openrct2/object/SceneryGroupObject.cpp.orig	2019-03-13 20:51:10 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(IRea
     _legacyType.pad_107 = stream->ReadValue<uint8_t>();
     _legacyType.priority = stream->ReadValue<uint8_t>();
     _legacyType.pad_109 = stream->ReadValue<uint8_t>();
-    _legacyType.entertainer_costumes = stream->ReadValue<uint32_t>();
+    _legacyType.entertainer_costumes = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
 
     GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME);
     _items = ReadItems(stream);
@@ -126,6 +127,7 @@ std::vector<rct_object_entry> SceneryGro
     {
         stream->Seek(-1, STREAM_SEEK_CURRENT);
         auto entry = stream->ReadValue<rct_object_entry>();
+        entry.flags = ORCT_SwapLEu32(entry.flags);
         items.push_back(entry);
     }
     return items;
--- src/openrct2/object/SmallSceneryObject.cpp.orig	2019-03-13 20:51:10 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<uint32_t>();
+    _legacyType.small_scenery.flags = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
     _legacyType.small_scenery.height = stream->ReadValue<uint8_t>();
     _legacyType.small_scenery.tool_id = stream->ReadValue<uint8_t>();
-    _legacyType.small_scenery.price = stream->ReadValue<int16_t>();
-    _legacyType.small_scenery.removal_price = stream->ReadValue<int16_t>();
+    _legacyType.small_scenery.price = ORCT_SwapLEu16(stream->ReadValue<int16_t>());
+    _legacyType.small_scenery.removal_price = ORCT_SwapLEu16(stream->ReadValue<int16_t>());
     stream->Seek(4, STREAM_SEEK_CURRENT);
-    _legacyType.small_scenery.animation_delay = stream->ReadValue<uint16_t>();
-    _legacyType.small_scenery.animation_mask = stream->ReadValue<uint16_t>();
-    _legacyType.small_scenery.num_frames = stream->ReadValue<uint16_t>();
+    _legacyType.small_scenery.animation_delay = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
+    _legacyType.small_scenery.animation_mask = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
+    _legacyType.small_scenery.num_frames = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
     _legacyType.small_scenery.scenery_tab_id = 0xFF;
 
     GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME);
 
     rct_object_entry sgEntry = stream->ReadValue<rct_object_entry>();
+    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-03-13 20:51:10 UTC
+++ src/openrct2/object/WallObject.cpp
@@ -13,6 +13,7 @@
 #include "../drawing/Drawing.h"
 #include "../interface/Cursors.h"
 #include "../localisation/Language.h"
+#include "../util/Endian.h"
 #include "../world/Banner.h"
 #include "ObjectJsonHelpers.h"
 
@@ -23,13 +24,14 @@ void WallObject::ReadLegacy(IReadObjectC
     _legacyType.wall.flags = stream->ReadValue<uint8_t>();
     _legacyType.wall.height = stream->ReadValue<uint8_t>();
     _legacyType.wall.flags2 = stream->ReadValue<uint8_t>();
-    _legacyType.wall.price = stream->ReadValue<uint16_t>();
+    _legacyType.wall.price = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
     _legacyType.wall.scenery_tab_id = stream->ReadValue<uint8_t>();
     _legacyType.wall.scrolling_mode = stream->ReadValue<uint8_t>();
 
     GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME);
 
     rct_object_entry sgEntry = stream->ReadValue<rct_object_entry>();
+    sgEntry.flags = ORCT_SwapLEu16(sgEntry.flags);
     SetPrimarySceneryGroup(&sgEntry);
 
     GetImageTable().Read(context, stream);
--- src/openrct2/object/WaterObject.cpp.orig	2019-03-13 20:51:10 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 <memory>
@@ -22,7 +23,7 @@
 void WaterObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
 {
     stream->Seek(14, STREAM_SEEK_CURRENT);
-    _legacyType.flags = stream->ReadValue<uint16_t>();
+    _legacyType.flags = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
 
     GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME);
     GetImageTable().Read(context, stream);
--- src/openrct2/rct12/SawyerChunkReader.cpp.orig	2019-03-13 20:51:10 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<sawyercoding_chunk_header>();
+        header.length = ORCT_SwapLEu32(header.length);
         _stream->Seek(header.length, STREAM_SEEK_CURRENT);
     }
     catch (const std::exception&)
@@ -68,6 +70,7 @@ std::shared_ptr<SawyerChunk> SawyerChunk
     try
     {
         auto header = _stream->ReadValue<sawyercoding_chunk_header>();
+        header.length = ORCT_SwapLEu32(header.length);
         switch (header.encoding)
         {
             case CHUNK_ENCODING_NONE:
--- src/openrct2/rct12/SawyerEncoding.cpp.orig	2019-03-13 20:51:10 UTC
+++ src/openrct2/rct12/SawyerEncoding.cpp
@@ -10,6 +10,7 @@
 #include "SawyerEncoding.h"
 
 #include "../core/IStream.hpp"
+#include "../util/Endian.h"
 
 #include <algorithm>
 
@@ -44,7 +45,7 @@ namespace SawyerEncoding
             } while (dataSize != 0);
 
             // Read file checksum
-            uint32_t fileChecksum = stream->ReadValue<uint32_t>();
+            uint32_t fileChecksum = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
 
             // Rewind back to original position
             stream->SetPosition(initialPosition);
--- src/openrct2/ride/TrackDesignRepository.cpp.orig	2019-03-13 20:51:10 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"
 
@@ -114,7 +115,7 @@ protected:
         item.Path = stream->ReadStdString();
         item.RideType = stream->ReadValue<uint8_t>();
         item.ObjectEntry = stream->ReadStdString();
-        item.Flags = stream->ReadValue<uint32_t>();
+        item.Flags = ORCT_SwapLEu32(stream->ReadValue<uint32_t>());
         return item;
     }
 
--- src/openrct2/scenario/ScenarioRepository.cpp.orig	2019-03-13 20:51:10 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 @@ protected:
         scenario_index_entry item;
 
         stream->Read(item.path, sizeof(item.path));
-        item.timestamp = stream->ReadValue<uint64_t>();
+        item.timestamp = ORCT_SwapLEu64(stream->ReadValue<uint64_t>());
 
         item.category = stream->ReadValue<uint8_t>();
         item.source_game = stream->ReadValue<uint8_t>();
-        item.source_index = stream->ReadValue<int16_t>();
-        item.sc_id = stream->ReadValue<uint16_t>();
+        item.source_index = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
+        item.sc_id = ORCT_SwapLEu16(stream->ReadValue<uint16_t>());
 
         item.objective_type = stream->ReadValue<uint8_t>();
         item.objective_arg_1 = stream->ReadValue<uint8_t>();
-        item.objective_arg_2 = stream->ReadValue<int32_t>();
-        item.objective_arg_3 = stream->ReadValue<int16_t>();
+        item.objective_arg_2 = ORCT_SwapLEi32(stream->ReadValue<int32_t>());
+        item.objective_arg_3 = ORCT_SwapLEi16(stream->ReadValue<int16_t>());
         item.highscore = nullptr;
 
         stream->Read(item.internal_name, sizeof(item.internal_name));
@@ -587,7 +588,7 @@ private:
         try
         {
             auto fs = FileStream(path, FILE_MODE_OPEN);
-            uint32_t fileVersion = fs.ReadValue<uint32_t>();
+            uint32_t fileVersion = ORCT_SwapLEu32(fs.ReadValue<uint32_t>());
             if (fileVersion != 1)
             {
                 Console::Error::WriteLine("Invalid or incompatible highscores file.");
@@ -596,14 +597,14 @@ private:
 
             ClearHighscores();
 
-            uint32_t numHighscores = fs.ReadValue<uint32_t>();
+            uint32_t numHighscores = ORCT_SwapLEu32(fs.ReadValue<uint32_t>());
             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<money32>();
-                highscore->timestamp = fs.ReadValue<datetime64>();
+                highscore->company_value = ORCT_SwapLEi32(fs.ReadValue<money32>());
+                highscore->timestamp = ORCT_SwapLEu64(fs.ReadValue<datetime64>());
             }
         }
         catch (const std::exception&)
@@ -647,6 +648,10 @@ private:
             {
                 // Read legacy entry
                 auto scBasic = fs.ReadValue<rct_scores_entry>();
+                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-04-04 08:21:55 UTC
+++ src/openrct2/util/Endian.h
@@ -0,0 +1,70 @@
+#include <cstdint>
+
+#pragma once
+
+// Based on SDL2
+
+#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
+
+static inline uint16_t ORCT_Swapu16(uint16_t x)
+{
+    return static_cast<uint16_t>((x << 8) | (x >> 8));
+}
+
+static inline uint32_t ORCT_Swapu32(uint32_t x)
+{
+    return static_cast<uint32_t>(((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<uint32_t>(x & 0xFFFFFFFF);
+    x >>= 32;
+    hi = static_cast<uint32_t>(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<uint16_t>((x << 8) | (x >> 8));
+}
+
+static inline int32_t ORCT_Swapi32(int32_t x)
+{
+    return static_cast<uint32_t>(((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<uint32_t>(x & 0xFFFFFFFF);
+    x >>= 32;
+    hi = static_cast<uint32_t>(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