From 142c54852d968dbcfa66ce02586e79c4cc3941a4 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Tue, 3 May 2016 23:36:29 +0200 Subject: [PATCH] Clean up some residual usages of old config (#3484) --- src/config.c | 17 +++-------------- src/interface/paint_surface.c | 4 ++-- src/interface/viewport.c | 18 ++++++++++++++++-- src/interface/viewport.h | 1 + src/windows/banner.c | 4 ++-- src/windows/game_bottom_toolbar.c | 2 +- src/windows/options.c | 10 +++------- src/windows/park.c | 2 +- src/windows/sign.c | 6 +++--- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/config.c b/src/config.c index fd065eb692..a85fabf582 100644 --- a/src/config.c +++ b/src/config.c @@ -23,6 +23,7 @@ #include "interface/keyboard_shortcut.h" #include "interface/themes.h" #include "interface/title_sequences.h" +#include "interface/viewport.h" #include "localisation/language.h" #include "localisation/localisation.h" #include "network/network.h" @@ -942,20 +943,8 @@ void config_apply_to_old_addresses() RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = gConfigGeneral.measurement_format; RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, sint8) = gConfigGeneral.temperature_format; RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER, uint8) = gConfigGeneral.construction_marker_colour; - if (gConfigGeneral.show_height_as_units) { - RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = 0; - } else { - switch (gConfigGeneral.measurement_format) { - default: - case MEASUREMENT_FORMAT_IMPERIAL: - RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = 1 * 256; - break; - case MEASUREMENT_FORMAT_METRIC: - case MEASUREMENT_FORMAT_SI: - RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = 2 * 256; - break; - } - } + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = get_height_marker_offset(); + int configFlags = 0; if (gConfigGeneral.always_show_gridlines) configFlags |= CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES; diff --git a/src/interface/paint_surface.c b/src/interface/paint_surface.c index 4c2ff56fe1..61df32e670 100644 --- a/src/interface/paint_surface.c +++ b/src/interface/paint_surface.c @@ -1054,7 +1054,7 @@ void viewport_surface_paint_setup(uint8 direction, uint16 height, rct_map_elemen dx += 3; int image_id = (SPR_HEIGHT_MARKER_BASE + dx / 16) | 0x20780000; - image_id += RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16); + image_id += get_height_marker_offset(); image_id -= RCT2_GLOBAL(0x01359208, uint16); sub_98196C(image_id, 16, 16, 1, 1, 0, height, get_current_rotation()); @@ -1312,7 +1312,7 @@ void viewport_surface_paint_setup(uint8 direction, uint16 height, rct_map_elemen && has_surface && !(gCurrentViewportFlags & VIEWPORT_FLAG_UNDERGROUND_INSIDE) && !(gCurrentViewportFlags & VIEWPORT_FLAG_HIDE_BASE) - && !(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE)) { + && gConfigGeneral.landscape_smoothing) { viewport_surface_smoothen_edge(EDGE_TOPLEFT, tileDescriptors[0], tileDescriptors[3]); viewport_surface_smoothen_edge(EDGE_TOPRIGHT, tileDescriptors[0], tileDescriptors[4]); viewport_surface_smoothen_edge(EDGE_BOTTOMLEFT, tileDescriptors[0], tileDescriptors[1]); diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 2db685084a..16c2b11970 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -1813,7 +1813,7 @@ void viewport_track_paint_setup(uint8 direction, int height, rct_map_element *ma if (RCT2_ADDRESS(0x00999694, uint32)[trackType] & (1 << trackSequence)) { uint16 ax = RideData5[ride->type].z_offset; uint32 ebx = 0x20381689 + (height + 8) / 16; - ebx += RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16); + ebx += get_height_marker_offset(); ebx -= RCT2_GLOBAL(0x01359208, uint16); sub_98197C(ebx, 16, 16, 1, 1, 0, height + ax + 3, 1000, 1000, 2047, get_current_rotation()); } @@ -1909,7 +1909,7 @@ void viewport_entrance_paint_setup(uint8 direction, int height, rct_map_element* int z = map_element->base_height * 8 + 3; uint32 image_id = z / 16 + - RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS,sint16) + + get_height_marker_offset() + 0x20101689; image_id -= RCT2_GLOBAL(0x01359208, sint16); @@ -3505,3 +3505,17 @@ uint8 get_current_rotation() #endif // DEBUG_LEVEL_1 return rotation_masked; } + +sint16 get_height_marker_offset() +{ + // Height labels in units + if (gConfigGeneral.show_height_as_units) + return 0; + + // Height labels in feet + if (gConfigGeneral.measurement_format == MEASUREMENT_FORMAT_IMPERIAL) + return 1 * 256; + + // Height labels in metres + return 2 * 256; +} diff --git a/src/interface/viewport.h b/src/interface/viewport.h index 0a008c6712..7cef3db387 100644 --- a/src/interface/viewport.h +++ b/src/interface/viewport.h @@ -193,5 +193,6 @@ void screen_get_map_xy_side(sint16 screenX, sint16 screenY, sint16 *mapX, sint16 void screen_get_map_xy_side_with_z(sint16 screenX, sint16 screenY, sint16 z, sint16 *mapX, sint16 *mapY, uint8 *side); uint8 get_current_rotation(); +sint16 get_height_marker_offset(); #endif diff --git a/src/windows/banner.c b/src/windows/banner.c index 74fca235c6..0266117e0d 100644 --- a/src/windows/banner.c +++ b/src/windows/banner.c @@ -168,7 +168,7 @@ void window_banner_open(rct_windownumber number) -1 ); - w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0; + w->viewport->flags = gConfigGeneral.always_show_gridlines ? VIEWPORT_FLAG_GRIDLINES : 0; window_invalidate(w); } @@ -363,6 +363,6 @@ static void window_banner_unknown_14(rct_window *w) -1 ); - w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0; + w->viewport->flags = gConfigGeneral.always_show_gridlines ? VIEWPORT_FLAG_GRIDLINES : 0; window_invalidate(w); } diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index 7cd6e65385..f7e6b13b60 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -475,7 +475,7 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, temperature = gClimateCurrentTemperature; format = STR_CELSIUS_VALUE; - if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8)) { + if (gConfigGeneral.temperature_format == TEMPERATURE_FORMAT_F) { temperature = climate_celsius_to_fahrenheit(temperature); format = STR_FAHRENHEIT_VALUE; } diff --git a/src/windows/options.c b/src/windows/options.c index 9f6b05a865..f8d97d5656 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -1157,14 +1157,12 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown switch (widgetIndex) { case WIDX_HEIGHT_LABELS_DROPDOWN: // reset flag and set it to 1 if height as units is selected - RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= ~CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS; gConfigGeneral.show_height_as_units = 0; if (dropdownIndex == 0) { - RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS; gConfigGeneral.show_height_as_units = 1; } - + config_save_default(); window_options_update_height_markers(); break; case WIDX_CURRENCY_DROPDOWN: @@ -1371,8 +1369,8 @@ static void window_options_invalidate(rct_window *w) break; case WINDOW_OPTIONS_PAGE_RENDERING: - widget_set_checkbox_value(w, WIDX_TILE_SMOOTHING_CHECKBOX, (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE) == 0); - widget_set_checkbox_value(w, WIDX_GRIDLINES_CHECKBOX, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES); + widget_set_checkbox_value(w, WIDX_TILE_SMOOTHING_CHECKBOX, gConfigGeneral.landscape_smoothing); + widget_set_checkbox_value(w, WIDX_GRIDLINES_CHECKBOX, gConfigGeneral.always_show_gridlines); widget_set_checkbox_value(w, WIDX_DAY_NIGHT_CHECKBOX, gConfigGeneral.day_night_cycle); widget_set_checkbox_value(w, WIDX_UPPER_CASE_BANNERS_CHECKBOX, gConfigGeneral.upper_case_banners); widget_set_checkbox_value(w, WIDX_DISABLE_LIGHTNING_EFFECT_CHECKBOX, gConfigGeneral.disable_lightning_effect); @@ -1743,8 +1741,6 @@ static void window_options_show_dropdown(rct_window *w, rct_widget *widget, int static void window_options_update_height_markers() { - RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16) = gConfigGeneral.show_height_as_units ? - 0 : (gConfigGeneral.measurement_format + 1) * 256; config_save_default(); gfx_invalidate_screen(); } diff --git a/src/windows/park.c b/src/windows/park.c index ea3bd885d4..c5b82acf94 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -1075,7 +1075,7 @@ static void window_park_init_viewport(rct_window *w) } if (w->viewport == NULL) { - viewportFlags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0; + viewportFlags = gConfigGeneral.always_show_gridlines ? VIEWPORT_FLAG_GRIDLINES : 0; } else { // if (w->var_482 == x && w->var_484 == y && w->var_486 == z && (uint16)w->var_488 >> 8 == r) // return; diff --git a/src/windows/sign.c b/src/windows/sign.c index 78cee54d0f..05618f2ed6 100644 --- a/src/windows/sign.c +++ b/src/windows/sign.c @@ -210,7 +210,7 @@ void window_sign_open(rct_windownumber number) -1 ); - w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0; + w->viewport->flags = gConfigGeneral.always_show_gridlines ? VIEWPORT_FLAG_GRIDLINES : 0; window_invalidate(w); } @@ -398,7 +398,7 @@ static void window_sign_unknown_14(rct_window *w) -1 ); - w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0; + w->viewport->flags = gConfigGeneral.always_show_gridlines ? VIEWPORT_FLAG_GRIDLINES : 0; window_invalidate(w); } @@ -475,7 +475,7 @@ void window_sign_small_open(rct_windownumber number){ -1 ); - w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0; + w->viewport->flags = gConfigGeneral.always_show_gridlines ? VIEWPORT_FLAG_GRIDLINES : 0; w->flags |= WF_NO_SCROLLING; window_invalidate(w); }