From 3bff25ab22c48f74ba7e7e2fb780481b33b6dc97 Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 25 Jul 2019 22:31:49 +0100 Subject: [PATCH] Use TileCoordsXY --- src/openrct2-ui/windows/Banner.cpp | 12 +++++------ src/openrct2-ui/windows/Sign.cpp | 20 +++++++++---------- src/openrct2/actions/BannerPlaceAction.hpp | 4 ++-- src/openrct2/actions/BannerSetStyleAction.hpp | 12 +++++------ .../actions/LargeSceneryPlaceAction.hpp | 4 ++-- src/openrct2/actions/SignSetNameAction.hpp | 4 ++-- src/openrct2/actions/SignSetStyleAction.hpp | 4 ++-- src/openrct2/actions/WallPlaceAction.hpp | 4 ++-- src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/rct2/S6Exporter.cpp | 4 ++-- src/openrct2/rct2/S6Importer.cpp | 4 ++-- src/openrct2/world/Banner.cpp | 7 +++---- src/openrct2/world/Banner.h | 3 +-- src/openrct2/world/TileInspector.cpp | 3 +-- 14 files changed, 43 insertions(+), 46 deletions(-) diff --git a/src/openrct2-ui/windows/Banner.cpp b/src/openrct2-ui/windows/Banner.cpp index d79ad31582..a059147c89 100644 --- a/src/openrct2-ui/windows/Banner.cpp +++ b/src/openrct2-ui/windows/Banner.cpp @@ -133,8 +133,8 @@ rct_window* window_banner_open(rct_windownumber number) window_init_scroll_widgets(w); auto banner = get_banner(w->number); - int32_t view_x = banner->x << 5; - int32_t view_y = banner->y << 5; + int32_t view_x = banner->position.x << 5; + int32_t view_y = banner->position.y << 5; TileElement* tile_element = map_get_first_element_at(view_x / 32, view_y / 32); while (1) @@ -172,8 +172,8 @@ rct_window* window_banner_open(rct_windownumber number) static void window_banner_mouseup(rct_window* w, rct_widgetindex widgetIndex) { auto banner = get_banner(w->number); - int32_t x = banner->x << 5; - int32_t y = banner->y << 5; + int32_t x = banner->position.x << 5; + int32_t y = banner->position.y << 5; TileElement* tile_element = map_get_first_element_at(x / 32, y / 32); @@ -343,8 +343,8 @@ static void window_banner_viewport_rotate(rct_window* w) auto banner = get_banner(w->number); - int32_t view_x = (banner->x << 5) + 16; - int32_t view_y = (banner->y << 5) + 16; + int32_t view_x = (banner->position.x << 5) + 16; + int32_t view_y = (banner->position.y << 5) + 16; int32_t view_z = w->frame_no; // Create viewport diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index b594f8fbb0..6bc1811b17 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -154,8 +154,8 @@ rct_window* window_sign_open(rct_windownumber number) window_init_scroll_widgets(w); auto banner = get_banner(w->number); - int32_t view_x = banner->x << 5; - int32_t view_y = banner->y << 5; + int32_t view_x = banner->position.x << 5; + int32_t view_y = banner->position.y << 5; TileElement* tile_element = map_get_first_element_at(view_x / 32, view_y / 32); @@ -204,8 +204,8 @@ rct_window* window_sign_open(rct_windownumber number) static void window_sign_mouseup(rct_window* w, rct_widgetindex widgetIndex) { auto banner = get_banner(w->number); - int32_t x = banner->x << 5; - int32_t y = banner->y << 5; + int32_t x = banner->position.x << 5; + int32_t y = banner->position.y << 5; auto tile_element = map_get_first_element_at(x / 32, y / 32); switch (widgetIndex) @@ -370,8 +370,8 @@ static void window_sign_viewport_rotate(rct_window* w) auto banner = get_banner(w->number); - int32_t view_x = (banner->x << 5) + 16; - int32_t view_y = (banner->y << 5) + 16; + int32_t view_x = (banner->position.x << 5) + 16; + int32_t view_y = (banner->position.y << 5) + 16; int32_t view_z = w->frame_no; // Create viewport @@ -410,8 +410,8 @@ rct_window* window_sign_small_open(rct_windownumber number) w->colours[2] = COLOUR_DARK_BROWN; auto banner = get_banner(w->number); - int32_t view_x = banner->x << 5; - int32_t view_y = banner->y << 5; + int32_t view_x = banner->position.x << 5; + int32_t view_y = banner->position.y << 5; TileElement* tile_element = map_get_first_element_at(view_x / 32, view_y / 32); @@ -459,8 +459,8 @@ rct_window* window_sign_small_open(rct_windownumber number) static void window_sign_small_mouseup(rct_window* w, rct_widgetindex widgetIndex) { auto banner = get_banner(w->number); - int32_t x = banner->x << 5; - int32_t y = banner->y << 5; + int32_t x = banner->position.x << 5; + int32_t y = banner->position.y << 5; auto tile_element = map_get_first_element_at(x / 32, y / 32); switch (widgetIndex) diff --git a/src/openrct2/actions/BannerPlaceAction.hpp b/src/openrct2/actions/BannerPlaceAction.hpp index 0d5a54be74..2845ac445f 100644 --- a/src/openrct2/actions/BannerPlaceAction.hpp +++ b/src/openrct2/actions/BannerPlaceAction.hpp @@ -145,8 +145,8 @@ public: banner->text_colour = 2; banner->type = _bannerType; banner->colour = _primaryColour; - banner->x = _loc.x / 32; - banner->y = _loc.y / 32; + banner->position.x = _loc.x / 32; + banner->position.y = _loc.y / 32; newTileElement->SetType(TILE_ELEMENT_TYPE_BANNER); BannerElement* bannerElement = newTileElement->AsBanner(); bannerElement->clearance_height = newTileElement->base_height + 2; diff --git a/src/openrct2/actions/BannerSetStyleAction.hpp b/src/openrct2/actions/BannerSetStyleAction.hpp index 58d5ae00d3..46eee091ca 100644 --- a/src/openrct2/actions/BannerSetStyleAction.hpp +++ b/src/openrct2/actions/BannerSetStyleAction.hpp @@ -66,9 +66,9 @@ public: auto banner = get_banner(_bannerIndex); res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - res->Position.x = banner->x * 32 + 16; - res->Position.y = banner->y * 32 + 16; - res->Position.z = tile_element_height(banner->x, banner->y); + res->Position.x = banner->position.x * 32 + 16; + res->Position.y = banner->position.y * 32 + 16; + res->Position.z = tile_element_height(banner->position.x, banner->position.y); TileElement* tileElement = banner_get_tile_element(_bannerIndex); @@ -116,9 +116,9 @@ public: auto banner = get_banner(_bannerIndex); res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - res->Position.x = banner->x * 32 + 16; - res->Position.y = banner->y * 32 + 16; - res->Position.z = tile_element_height(banner->x, banner->y); + res->Position.x = banner->position.x * 32 + 16; + res->Position.y = banner->position.y * 32 + 16; + res->Position.z = tile_element_height(banner->position.x, banner->position.y); TileElement* tileElement = banner_get_tile_element(_bannerIndex); diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.hpp b/src/openrct2/actions/LargeSceneryPlaceAction.hpp index da178be266..33e7b507f8 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.hpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.hpp @@ -265,8 +265,8 @@ public: banner->text_colour = 2; banner->flags = BANNER_FLAG_IS_LARGE_SCENERY; banner->type = 0; - banner->x = _loc.x / 32; - banner->y = _loc.y / 32; + banner->position.x = _loc.x / 32; + banner->position.y = _loc.y / 32; ride_id_t rideIndex = banner_get_closest_ride_index(_loc.x, _loc.y, maxHeight); if (rideIndex != RIDE_ID_NULL) diff --git a/src/openrct2/actions/SignSetNameAction.hpp b/src/openrct2/actions/SignSetNameAction.hpp index eab015d9da..e2245e946c 100644 --- a/src/openrct2/actions/SignSetNameAction.hpp +++ b/src/openrct2/actions/SignSetNameAction.hpp @@ -72,8 +72,8 @@ public: { auto banner = get_banner(_bannerIndex); - int32_t x = banner->x << 5; - int32_t y = banner->y << 5; + int32_t x = banner->position.x << 5; + int32_t y = banner->position.y << 5; if (_name.empty() == false) { diff --git a/src/openrct2/actions/SignSetStyleAction.hpp b/src/openrct2/actions/SignSetStyleAction.hpp index 0ee580e6c8..b4304be8f9 100644 --- a/src/openrct2/actions/SignSetStyleAction.hpp +++ b/src/openrct2/actions/SignSetStyleAction.hpp @@ -59,7 +59,7 @@ public: auto banner = get_banner(_bannerIndex); - CoordsXY coords{ banner->x * 32, banner->y * 32 }; + CoordsXY coords{ banner->position.x * 32, banner->position.y * 32 }; if (_isLarge) { @@ -93,7 +93,7 @@ public: { auto banner = get_banner(_bannerIndex); - CoordsXY coords{ banner->x * 32, banner->y * 32 }; + CoordsXY coords{ banner->position.x * 32, banner->position.y * 32 }; if (_isLarge) { diff --git a/src/openrct2/actions/WallPlaceAction.hpp b/src/openrct2/actions/WallPlaceAction.hpp index ffc3641d22..a1f1865b96 100644 --- a/src/openrct2/actions/WallPlaceAction.hpp +++ b/src/openrct2/actions/WallPlaceAction.hpp @@ -361,8 +361,8 @@ public: banner->text_colour = 2; banner->flags = BANNER_FLAG_IS_WALL; banner->type = 0; - banner->x = _loc.x / 32; - banner->y = _loc.y / 32; + banner->position.x = _loc.x / 32; + banner->position.y = _loc.y / 32; ride_id_t rideIndex = banner_get_closest_ride_index(_loc.x, _loc.y, targetHeight); if (rideIndex != RIDE_ID_NULL) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 1ec2edc235..5e524b7e2c 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2860,8 +2860,8 @@ private: dst->colour = RCT1::GetColour(src->colour); dst->text_colour = src->text_colour; - dst->x = src->x; - dst->y = src->y; + dst->position.x = src->x; + dst->position.y = src->y; } void FixEntrancePositions() diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 7576002e13..0124f8d7aa 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1197,8 +1197,8 @@ void S6Exporter::ExportBanner(RCT12Banner& dst, const Banner& src) dst.colour = src.colour; } dst.text_colour = src.text_colour; - dst.x = src.x; - dst.y = src.y; + dst.x = src.position.x; + dst.y = src.position.y; } enum : uint32_t diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index e223e7741f..d4152ca79b 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -853,8 +853,8 @@ public: } dst->text_colour = src->text_colour; - dst->x = src->x; - dst->y = src->y; + dst->position.x = src->x; + dst->position.y = src->y; } void Initialise() diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index 0f2d2b916c..43fda837ec 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -119,7 +119,7 @@ TileElement* banner_get_tile_element(BannerIndex bannerIndex) auto banner = get_banner(bannerIndex); if (banner != nullptr) { - auto tileElement = map_get_first_element_at(banner->x, banner->y); + auto tileElement = map_get_first_element_at(banner->position.x, banner->position.y); if (tileElement != nullptr) { do @@ -140,7 +140,7 @@ WallElement* banner_get_scrolling_wall_tile_element(BannerIndex bannerIndex) if (banner == nullptr) return nullptr; - auto tileElement = map_get_first_element_at(banner->x, banner->y); + auto tileElement = map_get_first_element_at(banner->position.x, banner->position.y); if (tileElement == nullptr) return nullptr; @@ -256,8 +256,7 @@ void fix_duplicated_banners() // Copy over the original banner, but update the location auto& newBanner = *get_banner(newBannerIndex); newBanner = *get_banner(bannerIndex); - newBanner.x = x; - newBanner.y = y; + newBanner.position = { x, y }; // Duplicate user string too rct_string_id stringIdx = newBanner.string_idx; diff --git a/src/openrct2/world/Banner.h b/src/openrct2/world/Banner.h index 298b48b97d..17b5162421 100644 --- a/src/openrct2/world/Banner.h +++ b/src/openrct2/world/Banner.h @@ -26,8 +26,7 @@ struct Banner uint8_t colour; uint8_t ride_index; uint8_t text_colour; - uint8_t x; - uint8_t y; + TileCoordsXY position; }; enum BANNER_FLAGS diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 35068247c1..4b7ba1d3f3 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -309,8 +309,7 @@ GameActionResult::Ptr tile_inspector_paste_element_at(CoordsXY loc, TileElement } auto& newBanner = *get_banner(newBannerIndex); newBanner = *get_banner(bannerIndex); - newBanner.x = loc.x / 32; - newBanner.y = loc.y / 32; + newBanner.position = TileCoordsXY(loc); // Use the new banner index tile_element_set_banner_index(&element, newBannerIndex);