From c77311a113a21160534d8649dbd6287a2d3f1113 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 8 May 2016 23:16:25 +0100 Subject: [PATCH] small fix and refactor of S6Importer / Exporter --- src/addresses.h | 3 ++- src/interface/viewport.h | 4 ++-- src/rct2/S6Exporter.cpp | 9 +++++---- src/rct2/S6Importer.cpp | 10 ++++++---- src/scenario.h | 3 ++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 4636f4614f..9a1e366171 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -378,7 +378,8 @@ #define RCT2_ADDRESS_SAVED_AGE 0x01388698 #define RCT2_ADDRESS_SAVED_VIEW_X 0x0138869A #define RCT2_ADDRESS_SAVED_VIEW_Y 0x0138869C -#define RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION 0x0138869E +#define RCT2_ADDRESS_SAVED_VIEW_ZOOM 0x0138869E +#define RCT2_ADDRESS_SAVED_VIEW_ROTATION 0x0138869F #define RCT2_ADDRESS_SCENARIO_COMPLETED_BY 0x013587D8 #define RCT2_ADDRESS_RIDE_MEASUREMENTS 0x0138B60C diff --git a/src/interface/viewport.h b/src/interface/viewport.h index d890ec9175..69344a4b8d 100644 --- a/src/interface/viewport.h +++ b/src/interface/viewport.h @@ -88,8 +88,8 @@ typedef struct { #define gSavedViewX RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16) #define gSavedViewY RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16) -#define gSavedViewZoom RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, uint8) -#define gSavedViewRotation RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION + 1, uint8) +#define gSavedViewZoom RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM, uint8) +#define gSavedViewRotation RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ROTATION, uint8) #define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) #define gCurrentViewportFlags RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint16) diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index 6356104e70..e4729d46ed 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -398,10 +398,11 @@ void S6Exporter::Export() _s6.game_ticks_1 = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32); memcpy(_s6.rides, RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride*), sizeof(_s6.rides)); _s6.saved_age = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_AGE, uint16); - _s6.saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, uint16); - _s6.saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, uint16); - _s6.saved_view_zoom_and_rotation = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, uint16); - memcpy(_s6.map_animations, RCT2_ADDRESS(gAnimatedObjects, rct_map_animation), sizeof(_s6.map_animations)); + _s6.saved_view_x = gSavedViewX; + _s6.saved_view_y = gSavedViewY; + _s6.saved_view_zoom = gSavedViewZoom; + _s6.saved_view_rotation = gSavedViewRotation; + memcpy(_s6.map_animations, gAnimatedObjects, sizeof(_s6.map_animations)); // rct1_map_animations _s6.num_map_animations = RCT2_GLOBAL(0x0138B580, uint16); // pad_0138B582 diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 5e223284dc..637931da95 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -22,6 +22,7 @@ extern "C" { #include "../config.h" #include "../game.h" + #include "../interface/viewport.h" #include "../localisation/date.h" #include "../localisation/localisation.h" #include "../management/finance.h" @@ -329,10 +330,11 @@ void S6Importer::Import() RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) = _s6.game_ticks_1; memcpy(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride*), _s6.rides, sizeof(_s6.rides)); RCT2_GLOBAL(RCT2_ADDRESS_SAVED_AGE, uint16) = _s6.saved_age; - RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, uint16) = _s6.saved_view_x; - RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, uint16) = _s6.saved_view_y; - RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, uint16) = _s6.saved_view_zoom_and_rotation; - memcpy(RCT2_ADDRESS(gAnimatedObjects, rct_map_animation), _s6.map_animations, sizeof(_s6.map_animations)); + gSavedViewX = _s6.saved_view_x; + gSavedViewY = _s6.saved_view_y; + gSavedViewZoom = _s6.saved_view_zoom; + gSavedViewRotation = _s6.saved_view_rotation; + memcpy(gAnimatedObjects, _s6.map_animations, sizeof(_s6.map_animations)); // rct1_map_animations RCT2_GLOBAL(0x0138B580, uint16) = _s6.num_map_animations; // pad_0138B582 diff --git a/src/scenario.h b/src/scenario.h index ae2aa4de67..d404d95eb2 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -298,7 +298,8 @@ typedef struct { uint16 saved_age; uint16 saved_view_x; uint16 saved_view_y; - uint16 saved_view_zoom_and_rotation; + uint8 saved_view_zoom; + uint8 saved_view_rotation; rct_map_animation map_animations[1000]; rct_map_animation rct1_map_animations[1000]; uint16 num_map_animations;