From 17198cfdb23bb829ad63b5997f4bf0039ecec2ab Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 10 Sep 2016 18:03:25 +0100 Subject: [PATCH] Integrate gTrackDesignSaveMode --- src/drawing/Rain.cpp | 2 +- src/interface/viewport.c | 2 +- src/paint/map_element/banner.c | 2 +- src/paint/map_element/entrance.c | 6 +++--- src/paint/map_element/fence.c | 2 +- src/paint/map_element/path.c | 6 +++--- src/paint/map_element/scenery.c | 2 +- src/paint/map_element/scenery_multiple.c | 2 +- src/paint/map_element/surface.c | 7 ++++--- src/paint/sprite/sprite.c | 2 +- src/ride/track_design.h | 3 +++ src/ride/track_design_save.c | 5 ++++- src/ride/track_paint.c | 2 +- src/windows/ride.c | 15 ++++++++------- src/world/map.c | 2 +- 15 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/drawing/Rain.cpp b/src/drawing/Rain.cpp index 92384c76e4..49d9589b87 100644 --- a/src/drawing/Rain.cpp +++ b/src/drawing/Rain.cpp @@ -174,7 +174,7 @@ void DrawRain(rct_drawpixelinfo * dpi, IRainDrawer * rainDrawer) { // Get rain draw function and draw rain uint32 rainType = gClimateCurrentRainLevel; - if (rainType > 0 && !(RCT2_GLOBAL(0x009DEA6F, uint8) & 1)) + if (rainType > 0 && !gTrackDesignSaveMode) { DrawRainAnimation(dpi, rainDrawer, rainType); } diff --git a/src/interface/viewport.c b/src/interface/viewport.c index fbb774b79c..096a08ce42 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -776,7 +776,7 @@ void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, int left, in paint_quadrant_ps(); int weather_colour = WeatherColours[gClimateCurrentWeatherGloom]; - if ((weather_colour != -1) && (!(gCurrentViewportFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES)) && (!(RCT2_GLOBAL(0x9DEA6F, uint8) & 1))){ + if ((weather_colour != -1) && (!(gCurrentViewportFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES)) && !gTrackDesignSaveMode) { gfx_fill_rect(dpi2, dpi2->x, dpi2->y, dpi2->width + dpi2->x - 1, dpi2->height + dpi2->y - 1, weather_colour); } viewport_draw_money_effects(); diff --git a/src/paint/map_element/banner.c b/src/paint/map_element/banner.c index 79130ab754..bed3c6af6f 100644 --- a/src/paint/map_element/banner.c +++ b/src/paint/map_element/banner.c @@ -35,7 +35,7 @@ void banner_paint(uint8 direction, int height, rct_map_element* map_element) gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_BANNER; - if (dpi->zoom_level > 1 || RCT2_GLOBAL(0x9DEA6F, uint8_t) & 1) return; + if (dpi->zoom_level > 1 || gTrackDesignSaveMode) return; height -= 16; diff --git a/src/paint/map_element/entrance.c b/src/paint/map_element/entrance.c index cae9b3d870..c0ebf20648 100644 --- a/src/paint/map_element/entrance.c +++ b/src/paint/map_element/entrance.c @@ -34,8 +34,8 @@ static void ride_entrance_exit_paint(uint8 direction, int height, rct_map_elemen { uint8 is_exit = map_element->properties.entrance.type == ENTRANCE_TYPE_RIDE_EXIT; - if (RCT2_GLOBAL(0x9DEA6F, uint8_t) & 1){ - if (map_element->properties.entrance.ride_index != RCT2_GLOBAL(0x00F64DE8, uint8)) + if (gTrackDesignSaveMode) { + if (map_element->properties.entrance.ride_index != gTrackDesignSaveRideIndex) return; } @@ -160,7 +160,7 @@ static void ride_entrance_exit_paint(uint8 direction, int height, rct_map_elemen * rct2: 0x006658ED */ static void park_entrance_paint(uint8 direction, int height, rct_map_element* map_element){ - if (RCT2_GLOBAL(0x9DEA6F, uint8_t) & 1) + if (gTrackDesignSaveMode) return; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_PARK; diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index f0bddf6146..3280b12488 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -161,7 +161,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) paint_util_set_general_support_height(height, 0x20); uint32 dword_141F710 = 0; - if (RCT2_GLOBAL(0x9DEA6F, uint8) & 1) { + if (gTrackDesignSaveMode) { if (!track_design_save_contains_map_element(map_element)) { dword_141F710 = 0x21700000; } diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index d6b98d807a..c6373fcee7 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -590,7 +590,7 @@ static void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_drawpixelinfo * dpi = unk_140E9A8; if (dpi->zoom_level <= 1) { - if (!(RCT2_GLOBAL(0x9DEA6F, uint8) & 1)) { + if (!gTrackDesignSaveMode) { uint8 additions = map_element->properties.path.additions & 0xF; if (additions != 0) { gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM; @@ -680,9 +680,9 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) uint32 sceneryImageFlags = 0; uint32 imageFlags = 0; - if (RCT2_GLOBAL(0x9DEA6F, uint8) & 1) { + if (gTrackDesignSaveMode) { if (map_element->type & 1) { - if (map_element->properties.path.ride_index != RCT2_GLOBAL(0x00F64DE8, uint8)) { + if (map_element->properties.path.ride_index != gTrackDesignSaveRideIndex) { return; } } diff --git a/src/paint/map_element/scenery.c b/src/paint/map_element/scenery.c index 45808c33c0..6c217e8f81 100644 --- a/src/paint/map_element/scenery.c +++ b/src/paint/map_element/scenery.c @@ -52,7 +52,7 @@ void scenery_paint(uint8 direction, int height, rct_map_element* mapElement) { boxoffset.y = 0; boxoffset.z = height; int baseImageid = 0; - if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1) { + if (gTrackDesignSaveMode) { if (!track_design_save_contains_map_element(mapElement)) { baseImageid = 0x21700000; } diff --git a/src/paint/map_element/scenery_multiple.c b/src/paint/map_element/scenery_multiple.c index 151a6e80cb..03ecd11d61 100644 --- a/src/paint/map_element/scenery_multiple.c +++ b/src/paint/map_element/scenery_multiple.c @@ -194,7 +194,7 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map image_id |= ((mapElement->properties.scenerymultiple.colour[0] & 0x1F) << 19) | ((mapElement->properties.scenerymultiple.colour[1] & 0x1F) << 24) | 0xA0000000; rct_xyz16 boxlength; rct_xyz16 boxoffset; - if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1) { + if (gTrackDesignSaveMode) { if (!track_design_save_contains_map_element(mapElement)) { ebp = 0x21700000; image_id &= 0x7FFFF; diff --git a/src/paint/map_element/surface.c b/src/paint/map_element/surface.c index 318c650e62..cfd4b9eed3 100644 --- a/src/paint/map_element/surface.c +++ b/src/paint/map_element/surface.c @@ -1354,7 +1354,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) uint16 waterHeight = (mapElement->properties.surface.terrain & 0x1F) * 16; RCT2_GLOBAL(0x009E3298, uint16) = waterHeight; - if ((RCT2_GLOBAL(0x9DEA6F, uint8_t) & 1) == 0) { + if (!gTrackDesignSaveMode) { RCT2_GLOBAL(0x0141E9DC, uint16) = waterHeight; int image_offset = 0; @@ -1382,8 +1382,9 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) } } - if (mapElement->properties.surface.ownership & 0x0F - && !(RCT2_GLOBAL(0x009DEA6F, uint8) & 1)) { + if ((mapElement->properties.surface.ownership & 0x0F) && + !gTrackDesignSaveMode + ) { // Owned land boundary fences gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_PARK; diff --git a/src/paint/sprite/sprite.c b/src/paint/sprite/sprite.c index b701bf4573..04cfd90a25 100644 --- a/src/paint/sprite/sprite.c +++ b/src/paint/sprite/sprite.c @@ -35,7 +35,7 @@ void sprite_paint_setup(const uint16 eax, const uint16 ecx) { uint16 sprite_idx = sprite_get_first_in_quadrant(eax, ecx); if (sprite_idx == SPRITE_INDEX_NULL) return; - if (RCT2_GLOBAL(0x9DEA6F, uint8) & 1) return; + if (gTrackDesignSaveMode) return; if (gCurrentViewportFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES) return; diff --git a/src/ride/track_design.h b/src/ride/track_design.h index 638c118afc..41409a627b 100644 --- a/src/ride/track_design.h +++ b/src/ride/track_design.h @@ -195,6 +195,9 @@ extern rct_xyz16 gTrackPreviewOrigin; extern uint8 byte_F4414E; extern uint8 byte_9D8150; +extern bool gTrackDesignSaveMode; +extern uint8 gTrackDesignSaveRideIndex; + rct_track_td6 *track_design_open(const utf8 *path); void track_design_dispose(rct_track_td6 *td6); diff --git a/src/ride/track_design_save.c b/src/ride/track_design_save.c index 04d6ce0e0e..3118cc23df 100644 --- a/src/ride/track_design_save.c +++ b/src/ride/track_design_save.c @@ -32,6 +32,9 @@ #define TRACK_MAX_SAVED_MAP_ELEMENTS 1500 +bool gTrackDesignSaveMode = false; +uint8 gTrackDesignSaveRideIndex = 255; + static size_t _trackSavedMapElementsCount; #ifdef NO_RCT2 static rct_map_element *_trackSavedMapElements[TRACK_MAX_SAVED_MAP_ELEMENTS]; @@ -160,7 +163,7 @@ bool track_design_save(uint8 rideIndex) return false; } - if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1) { + if (gTrackDesignSaveMode) { if (!track_design_save_copy_scenery_to_td6(_trackDesign)) { free(_trackDesign->track_elements); free(_trackDesign->entrance_elements); diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 13a8e9edc0..ffa82afcae 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -1281,7 +1281,7 @@ void track_paint(uint8 direction, int height, rct_map_element *mapElement) ride->entrance_style = RIDE_ENTRANCE_STYLE_PLAIN; } - if (!(RCT2_GLOBAL(0x009DEA6F, uint8) & 1) || rideIndex == RCT2_GLOBAL(0x00F64DE8, uint8)) { + if (!gTrackDesignSaveMode || rideIndex == gTrackDesignSaveRideIndex) { trackType = mapElement->properties.track.type; trackSequence = mapElement->properties.track.sequence & 0x0F; trackColourScheme = mapElement->properties.track.colour & 3; diff --git a/src/windows/ride.c b/src/windows/ride.c index 482804d1bb..8903d007d2 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -4982,7 +4982,7 @@ static void window_ride_music_paint(rct_window *w, rct_drawpixelinfo *dpi) when al == 0*/ static void cancel_scenery_selection(){ gGamePaused &= ~GAME_PAUSED_SAVING_TRACK; - RCT2_GLOBAL(0x9DEA6F, uint8) &= ~(1 << 0); + gTrackDesignSaveMode = false; audio_unpause_sounds(); rct_window* main_w = window_get_main(); @@ -5001,17 +5001,17 @@ static void cancel_scenery_selection(){ */ static void setup_scenery_selection(rct_window* w) { - if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1){ + if (gTrackDesignSaveMode){ cancel_scenery_selection(); } while (tool_set(w, 0, 12)); - RCT2_GLOBAL(0x00F64DE8, uint8) = (uint8)w->number; + gTrackDesignSaveRideIndex = (uint8)w->number; track_design_save_init(); gGamePaused |= GAME_PAUSED_SAVING_TRACK; - RCT2_GLOBAL(0x009DEA6F, uint8) |= 1; + gTrackDesignSaveMode = true; audio_pause_sounds(); @@ -5039,7 +5039,7 @@ static void window_ride_measurements_design_reset() */ static void window_ride_measurements_design_select_nearby_scenery() { - track_design_save_select_nearby_scenery(RCT2_GLOBAL(0x00F64DE8, uint8)); + track_design_save_select_nearby_scenery(gTrackDesignSaveRideIndex); } /** @@ -5048,8 +5048,9 @@ static void window_ride_measurements_design_select_nearby_scenery() */ void window_ride_measurements_design_cancel() { - if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1) + if (gTrackDesignSaveMode) { cancel_scenery_selection(); + } } /** @@ -5224,7 +5225,7 @@ static void window_ride_measurements_invalidate(rct_window *w) window_ride_measurements_widgets[WIDX_SAVE_TRACK_DESIGN].tooltip = STR_SAVE_TRACK_DESIGN_NOT_POSSIBLE; window_ride_measurements_widgets[WIDX_SAVE_TRACK_DESIGN].type = WWT_EMPTY; - if ((RCT2_GLOBAL(0x009DEA6F, uint8) & 1) && RCT2_GLOBAL(0x00F64DE8, uint8) == w->number) { + if (gTrackDesignSaveMode && gTrackDesignSaveRideIndex == w->number) { window_ride_measurements_widgets[WIDX_SELECT_NEARBY_SCENERY].type = WWT_DROPDOWN_BUTTON; window_ride_measurements_widgets[WIDX_RESET_SELECTION].type = WWT_DROPDOWN_BUTTON; window_ride_measurements_widgets[WIDX_SAVE_DESIGN].type = WWT_DROPDOWN_BUTTON; diff --git a/src/world/map.c b/src/world/map.c index 7e5e71fedb..a4240a5d2c 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -565,7 +565,7 @@ void sub_68B089() int i; rct_map_element *mapElementFirst, *mapElement; - if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1) + if (gTrackDesignSaveMode) return; i = RCT2_GLOBAL(0x0010E63B8, uint32);