From 9c11b051ee4c0941c5ab671b52bc54eb0342691f Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 6 Jan 2017 12:03:15 +0000 Subject: [PATCH] Add some max constants for RCT1 --- src/openrct2/rct1.h | 7 +++++-- src/openrct2/rct1/S4Importer.cpp | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/openrct2/rct1.h b/src/openrct2/rct1.h index 89eaf43166..2b0d850e02 100644 --- a/src/openrct2/rct1.h +++ b/src/openrct2/rct1.h @@ -26,6 +26,9 @@ #include "world/map.h" #include "world/sprite.h" +#define RCT1_MAX_MAP_ELEMENTS 0xC000 +#define RCT1_MAX_SPRITES 5000 + #pragma pack(push, 1) typedef struct rct1_entrance { uint16 x; @@ -414,9 +417,9 @@ typedef struct rct1_s4 { uint32 ticks; uint32 random_a; uint32 random_b; - rct_map_element map_elements[0xC000]; + rct_map_element map_elements[RCT1_MAX_MAP_ELEMENTS]; uint32 unk_counter; - rct1_sprite sprites[5000]; + rct1_sprite sprites[RCT1_MAX_SPRITES]; uint16 next_sprite_index; uint16 first_vehicle_sprite_index; uint16 first_peep_sprite_index; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 03b1513d4d..f9ef72febd 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -789,7 +789,7 @@ private: void ImportPeeps() { - for (int i = 0; i < 5000; i++) + for (int i = 0; i < RCT1_MAX_SPRITES; i++) { if (_s4.sprites[i].unknown.sprite_identifier == SPRITE_IDENTIFIER_PEEP) { @@ -941,7 +941,7 @@ private: void ImportLitter() { - for (int i = 0; i < 5000; i++) + for (int i = 0; i < RCT1_MAX_SPRITES; i++) { if (_s4.sprites[i].unknown.sprite_identifier == SPRITE_IDENTIFIER_LITTER) { rct_litter *srcLitter = &_s4.sprites[i].litter; @@ -1076,7 +1076,7 @@ private: void ImportMapElements() { - memcpy(gMapElements, _s4.map_elements, 0xC000 * sizeof(rct_map_element)); + memcpy(gMapElements, _s4.map_elements, RCT1_MAX_MAP_ELEMENTS * sizeof(rct_map_element)); ClearExtraTileEntries(); FixColours(); FixZ();