From f6dee8c58df8cec24b01eaf4a4e88013f50ef49d Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 16 Jan 2017 18:41:16 +0000 Subject: [PATCH] Unify rct1_award and rct2_award --- src/openrct2/libopenrct2.vcxproj | 1 + src/openrct2/rct1.h | 12 ++--------- src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/rct12.h | 34 ++++++++++++++++++++++++++++++++ src/openrct2/rct2.h | 8 -------- src/openrct2/rct2/S6Exporter.cpp | 4 ++-- src/openrct2/rct2/S6Importer.cpp | 4 ++-- src/openrct2/scenario/scenario.h | 5 ++--- 8 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 src/openrct2/rct12.h diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 4691d1c7f9..b111546c3b 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -411,6 +411,7 @@ + diff --git a/src/openrct2/rct1.h b/src/openrct2/rct1.h index 582eed4b0d..b26b117b4e 100644 --- a/src/openrct2/rct1.h +++ b/src/openrct2/rct1.h @@ -20,6 +20,7 @@ #include "management/award.h" #include "management/news_item.h" #include "management/research.h" +#include "rct12.h" #include "rct2.h" #include "ride/ride.h" #include "world/banner.h" @@ -28,7 +29,6 @@ #define RCT1_MAX_MAP_ELEMENTS 0xC000 #define RCT1_MAX_SPRITES 5000 -#define RCT1_MAX_AWARDS 4 #pragma pack(push, 1) typedef struct rct1_entrance { @@ -426,14 +426,6 @@ typedef struct rct1_research_item { } rct1_research_item; assert_struct_size(rct1_research_item, 5); -#pragma pack(push, 1) -typedef struct rct1_award { - uint16 time; - uint16 type; -} rct1_award; -assert_struct_size(rct1_award, 4); -#pragma pack(pop) - /** * RCT1,AA,LL scenario / saved game structure. * size: 0x1F850C @@ -529,7 +521,7 @@ typedef struct rct1_s4 { money32 admission_total_income; money32 company_value; uint8 thought_timer[16]; - rct1_award awards[RCT1_MAX_AWARDS]; + rct12_award awards[RCT12_MAX_AWARDS]; money16 land_price; money16 construction_rights_price; uint16 unk_199BCC; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index ac2153a710..89b36e73df 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1439,9 +1439,9 @@ private: // Awards award_reset(); - for (sint32 i = 0; i < RCT1_MAX_AWARDS; i++) + for (sint32 i = 0; i < RCT12_MAX_AWARDS; i++) { - rct1_award * src = &_s4.awards[i]; + rct12_award * src = &_s4.awards[i]; Award * dst = &gCurrentAwards[i]; dst->Time = src->time; dst->Type = src->type; diff --git a/src/openrct2/rct12.h b/src/openrct2/rct12.h new file mode 100644 index 0000000000..b6abdac398 --- /dev/null +++ b/src/openrct2/rct12.h @@ -0,0 +1,34 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#pragma once + +// Structures shared between both RCT1 and RCT2. + +#include "common.h" + +#define RCT12_MAX_AWARDS 4 + +#pragma pack(push, 1) + +typedef struct rct12_award +{ + uint16 time; + uint16 type; +} rct12_award; +assert_struct_size(rct12_award, 4); + +#pragma pack(pop) diff --git a/src/openrct2/rct2.h b/src/openrct2/rct2.h index 816d5f4f43..5a64ab48e4 100644 --- a/src/openrct2/rct2.h +++ b/src/openrct2/rct2.h @@ -29,14 +29,6 @@ typedef struct rct2_install_info { uint32 activeExpansionPacks; //0xB10 } rct2_install_info; -#pragma pack(push, 1) -typedef struct rct2_award { - uint16 time; - uint16 type; -} rct2_award; -assert_struct_size(rct2_award, 4); -#pragma pack(pop) - enum { // Although this is labeled a flag it actually means when // zero the screen is in playing mode. diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index d515f57e9d..05c005854c 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -351,10 +351,10 @@ void S6Exporter::Export() memcpy(_s6.peep_warning_throttle, gPeepWarningThrottle, sizeof(_s6.peep_warning_throttle)); // Awards - for (int i = 0; i < RCT2_MAX_AWARDS; i++) + for (sint32 i = 0; i < RCT12_MAX_AWARDS; i++) { Award * src = &gCurrentAwards[i]; - rct2_award * dst = &_s6.awards[i]; + rct12_award * dst = &_s6.awards[i]; dst->time = src->Time; dst->type = src->Type; } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 5d13acdf93..1815ad1d62 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -268,9 +268,9 @@ void S6Importer::Import() // Awards award_reset(); - for (int i = 0; i < RCT2_MAX_AWARDS; i++) + for (sint32 i = 0; i < RCT12_MAX_AWARDS; i++) { - rct2_award * src = &_s6.awards[i]; + rct12_award * src = &_s6.awards[i]; Award * dst = &gCurrentAwards[i]; dst->Time = src->time; dst->Type = src->type; diff --git a/src/openrct2/scenario/scenario.h b/src/openrct2/scenario/scenario.h index 4ebc94325e..2ca44f6d37 100644 --- a/src/openrct2/scenario/scenario.h +++ b/src/openrct2/scenario/scenario.h @@ -23,6 +23,7 @@ #include "../management/research.h" #include "../object.h" #include "../platform/platform.h" +#include "../rct12.h" #include "../rct2.h" #include "../rct2/addresses.h" #include "../ride/ride.h" @@ -32,8 +33,6 @@ #include "../world/map_animation.h" #include "../world/sprite.h" -#define RCT2_MAX_AWARDS 4 - #pragma pack(push, 1) /** * SV6/SC6 header chunk @@ -247,7 +246,7 @@ typedef struct rct_s6_data { money32 income_from_admissions; money32 company_value; uint8 peep_warning_throttle[16]; - rct2_award awards[RCT2_MAX_AWARDS]; + rct12_award awards[RCT12_MAX_AWARDS]; money16 land_price; money16 construction_rights_price; uint16 word_01358774;