From a0f5f1243f4c984946e59cf53f2a777fca3f4d45 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 1 Sep 2017 13:01:15 +0100 Subject: [PATCH] Remove more map element paint globals --- src/openrct2/paint/map_element/map_element.c | 17 +++++------------ src/openrct2/paint/map_element/map_element.h | 12 ------------ src/openrct2/paint/map_element/path.c | 8 ++++---- src/openrct2/paint/map_element/surface.c | 8 ++++---- src/openrct2/paint/paint.h | 8 ++++++++ src/openrct2/paint/supports.c | 18 +++++++++--------- src/openrct2/ride/gentle/mini_golf.c | 4 ++-- src/openrct2/ride/track_paint.c | 2 +- 8 files changed, 33 insertions(+), 44 deletions(-) diff --git a/src/openrct2/paint/map_element/map_element.c b/src/openrct2/paint/map_element/map_element.c index 823308b7b3..089d72c665 100644 --- a/src/openrct2/paint/map_element/map_element.c +++ b/src/openrct2/paint/map_element/map_element.c @@ -32,13 +32,6 @@ #include "../../game.h" #include "../supports.h" -#ifdef NO_RCT2 -uint8 g141E9DB; -uint16 gUnk141E9DC; -bool gDidPassSurface; -rct_map_element * gSurfaceElement; -#endif - #ifdef __TESTPAINT__ uint16 testPaintVerticalTunnelHeight; #endif @@ -62,8 +55,8 @@ void map_element_paint_setup(sint32 x, sint32 y) ) { paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_force_set_general_support_height(-1, 0); - g141E9DB = 0; - gUnk141E9DC = 0xFFFF; + gPaintSession.Unk141E9DB = 0; + gPaintSession.Unk141E9DC = 0xFFFF; sub_68B3FB(x, y); } else { @@ -85,8 +78,8 @@ void sub_68B2B7(sint32 x, sint32 y) ) { paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_force_set_general_support_height(-1, 0); - gUnk141E9DC = 0xFFFF; - g141E9DB = G141E9DB_FLAG_2; + gPaintSession.Unk141E9DC = 0xFFFF; + gPaintSession.Unk141E9DB = G141E9DB_FLAG_2; sub_68B3FB(x, y); } else { @@ -240,7 +233,7 @@ static void sub_68B3FB(sint32 x, sint32 y) gPaintSession.SpritePosition.x = x; gPaintSession.SpritePosition.y = y; - gDidPassSurface = false; + gPaintSession.DidPassSurface = false; do { // Only paint map_elements below the clip height. if ((gCurrentViewportFlags & VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT) && (map_element->base_height > gClipHeight)) break; diff --git a/src/openrct2/paint/map_element/map_element.h b/src/openrct2/paint/map_element/map_element.h index d169c70185..ccf1c5cf83 100644 --- a/src/openrct2/paint/map_element/map_element.h +++ b/src/openrct2/paint/map_element/map_element.h @@ -75,18 +75,6 @@ enum G141E9DB_FLAG_2 = 2, }; -#ifdef NO_RCT2 -extern uint8 g141E9DB; -extern uint16 gUnk141E9DC; -extern bool gDidPassSurface; -extern rct_map_element * gSurfaceElement; -#else -#define g141E9DB RCT2_GLOBAL(0x0141E9DB, uint8) -#define gUnk141E9DC RCT2_GLOBAL(0x0141E9DC, uint16) -#define gDidPassSurface RCT2_GLOBAL(0x009DE57C, bool) -#define gSurfaceElement RCT2_GLOBAL(0x009E3250, rct_map_element *) -#endif - #ifdef __TESTPAINT__ extern uint16 testPaintVerticalTunnelHeight; #endif diff --git a/src/openrct2/paint/map_element/path.c b/src/openrct2/paint/map_element/path.c index 1a804d201f..761aedd340 100644 --- a/src/openrct2/paint/map_element/path.c +++ b/src/openrct2/paint/map_element/path.c @@ -826,14 +826,14 @@ void path_paint_pole_support(rct_map_element * mapElement, sint32 height, rct_fo imageId += 51; } - if (!gDidPassSurface) { + if (!gPaintSession.DidPassSurface) { boundBoxOffset.x = 3; boundBoxOffset.y = 3; boundBoxSize.x = 26; boundBoxSize.y = 26; } - if (!hasFences || !gDidPassSurface) { + if (!hasFences || !gPaintSession.DidPassSurface) { sub_98197C(imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); } else { uint32 image_id; @@ -940,14 +940,14 @@ void path_paint_box_support(rct_map_element* mapElement, sint16 height, rct_foot } // Below Surface - if (!gDidPassSurface) { + if (!gPaintSession.DidPassSurface) { boundBoxOffset.x = 3; boundBoxOffset.y = 3; boundBoxSize.x = 26; boundBoxSize.y = 26; } - if (!hasFences || !gDidPassSurface) { + if (!hasFences || !gPaintSession.DidPassSurface) { sub_98197C(imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); } else { diff --git a/src/openrct2/paint/map_element/surface.c b/src/openrct2/paint/map_element/surface.c index 98c0d2e3de..ab937b862b 100644 --- a/src/openrct2/paint/map_element/surface.c +++ b/src/openrct2/paint/map_element/surface.c @@ -992,8 +992,8 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) { rct_drawpixelinfo * dpi = gPaintSession.Unk140E9A8; gPaintSession.InteractionType = VIEWPORT_INTERACTION_ITEM_TERRAIN; - gDidPassSurface = true; - gSurfaceElement = mapElement; + gPaintSession.DidPassSurface = true; + gPaintSession.SurfaceElement = mapElement; uint16 zoomLevel = dpi->zoom_level; @@ -1379,7 +1379,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) uint16 waterHeight = map_get_water_height(mapElement) * 16; if (!gTrackDesignSaveMode) { - gUnk141E9DC = waterHeight; + gPaintSession.Unk141E9DC = waterHeight; sint32 image_offset = 0; if (waterHeight <= localHeight) { @@ -1531,7 +1531,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) } gPaintSession.InteractionType = VIEWPORT_INTERACTION_ITEM_TERRAIN; - g141E9DB |= G141E9DB_FLAG_1; + gPaintSession.Unk141E9DB |= G141E9DB_FLAG_1; switch (surfaceShape) { default: diff --git a/src/openrct2/paint/paint.h b/src/openrct2/paint/paint.h index b881ae0281..141f6a688e 100644 --- a/src/openrct2/paint/paint.h +++ b/src/openrct2/paint/paint.h @@ -164,6 +164,10 @@ typedef struct paint_session tunnel_entry RightTunnels[TUNNEL_MAX_COUNT]; uint8 RightTunnelCount; uint8 VerticalTunnelHeight; + rct_map_element * SurfaceElement; + bool DidPassSurface; + uint8 Unk141E9DB; + uint16 Unk141E9DC; } paint_session; extern paint_session gPaintSession; @@ -183,6 +187,10 @@ extern paint_session gPaintSession; #define gRightTunnels RCT2_ADDRESS(0x009E30B6, tunnel_entry) #define gRightTunnelCount RCT2_GLOBAL(0x0141F56B, uint8) #define gVerticalTunnelHeight RCT2_GLOBAL(0x009E323C, uint8) +#define gSurfaceElement RCT2_GLOBAL(0x009E3250, rct_map_element *) +#define gDidPassSurface RCT2_GLOBAL(0x009DE57C, bool) +#define g141E9DB RCT2_GLOBAL(0x0141E9DB, uint8) +#define gUnk141E9DC RCT2_GLOBAL(0x0141E9DC, uint16) #endif /** rct2: 0x00993CC4 */ diff --git a/src/openrct2/paint/supports.c b/src/openrct2/paint/supports.c index 31fefd477c..4ec8dc1725 100644 --- a/src/openrct2/paint/supports.c +++ b/src/openrct2/paint/supports.c @@ -351,7 +351,7 @@ bool wooden_a_supports_paint_setup(sint32 supportType, sint32 special, sint32 he return false; } - if (!(g141E9DB & G141E9DB_FLAG_1)) { + if (!(gPaintSession.Unk141E9DB & G141E9DB_FLAG_1)) { return false; } @@ -429,7 +429,7 @@ bool wooden_a_supports_paint_setup(sint32 supportType, sint32 special, sint32 he // Draw repeated supports for left over space while (height != 0) { - if ((z & 16) == 0 && height >= 2 && z + 16 != gUnk141E9DC) { + if ((z & 16) == 0 && height >= 2 && z + 16 != gPaintSession.Unk141E9DC) { // Full support sint32 imageId = WoodenSupportImageIds[supportType].full | imageColourFlags; uint8 ah = height == 2 ? 23 : 28; @@ -505,7 +505,7 @@ bool wooden_b_supports_paint_setup(sint32 supportType, sint32 special, sint32 he return false; } - if (!(g141E9DB & G141E9DB_FLAG_1)) { + if (!(gPaintSession.Unk141E9DB & G141E9DB_FLAG_1)) { if (underground != NULL) *underground = false; // AND return false; } @@ -606,7 +606,7 @@ bool wooden_b_supports_paint_setup(sint32 supportType, sint32 special, sint32 he if (!skipTo663004) { while (heightSteps > 0) { - if (baseHeight & 0x10 || heightSteps == 1 || baseHeight + 16 == gUnk141E9DC) { + if (baseHeight & 0x10 || heightSteps == 1 || baseHeight + 16 == gPaintSession.Unk141E9DC) { sub_98196C( WoodenSupportImageIds[supportType].half | imageColourFlags, 0, 0, @@ -691,7 +691,7 @@ bool metal_a_supports_paint_setup(uint8 supportType, uint8 segment, sint32 speci return false; } - if (!(g141E9DB & G141E9DB_FLAG_1)) { + if (!(gPaintSession.Unk141E9DB & G141E9DB_FLAG_1)) { return false; } @@ -891,7 +891,7 @@ bool metal_b_supports_paint_setup(uint8 supportType, uint8 segment, sint32 speci return false; // AND } - if (!(g141E9DB & G141E9DB_FLAG_1)) { + if (!(gPaintSession.Unk141E9DB & G141E9DB_FLAG_1)) { return false; // AND } @@ -1082,7 +1082,7 @@ bool path_a_supports_paint_setup(sint32 supportType, sint32 special, sint32 heig return false; } - if (!(g141E9DB & G141E9DB_FLAG_1)) { + if (!(gPaintSession.Unk141E9DB & G141E9DB_FLAG_1)) { return false; } @@ -1161,7 +1161,7 @@ bool path_a_supports_paint_setup(sint32 supportType, sint32 special, sint32 heig } while (heightSteps > 0) { - if (baseHeight & 0x10 || heightSteps == 1 || baseHeight + 16 == gUnk141E9DC) { + if (baseHeight & 0x10 || heightSteps == 1 || baseHeight + 16 == gPaintSession.Unk141E9DC) { uint32 imageId = (supportType * 24) + pathEntry->bridge_image + 23; @@ -1260,7 +1260,7 @@ bool path_b_supports_paint_setup(sint32 segment, sint32 special, sint32 height, return false; // AND } - if (!(g141E9DB & G141E9DB_FLAG_1)) { + if (!(gPaintSession.Unk141E9DB & G141E9DB_FLAG_1)) { return false; // AND } diff --git a/src/openrct2/ride/gentle/mini_golf.c b/src/openrct2/ride/gentle/mini_golf.c index 3f768e0260..4ec503bf0b 100644 --- a/src/openrct2/ride/gentle/mini_golf.c +++ b/src/openrct2/ride/gentle/mini_golf.c @@ -443,12 +443,12 @@ static paint_struct * mini_golf_paint_util_7c( static bool mini_golf_paint_util_should_draw_fence(rct_map_element * mapElement) { - if (!gDidPassSurface) { + if (!gPaintSession.DidPassSurface) { // Should be above ground (have passed surface rendering) return false; } - rct_map_element * surfaceElement = gSurfaceElement; + rct_map_element * surfaceElement = gPaintSession.SurfaceElement; if (surfaceElement->base_height != mapElement->base_height) { return true; } diff --git a/src/openrct2/ride/track_paint.c b/src/openrct2/ride/track_paint.c index a3ec101ff5..6ccb6c8b76 100644 --- a/src/openrct2/ride/track_paint.c +++ b/src/openrct2/ride/track_paint.c @@ -577,7 +577,7 @@ bool track_paint_util_draw_station_covers(enum edge_t edge, bool hasFence, const bool track_paint_util_draw_station_covers_2(enum edge_t edge, bool hasFence, const rct_ride_entrance_definition * entranceStyle, uint8 direction, uint16 height, uint8 stationVariant) { - if (!(g141E9DB & (G141E9DB_FLAG_1 | G141E9DB_FLAG_2))) { + if (!(gPaintSession.Unk141E9DB & (G141E9DB_FLAG_1 | G141E9DB_FLAG_2))) { return false; }