From 43a5cc92cc189bcf3a2a1a9b6897d7c8be8fd47e Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 7 Jan 2016 22:14:53 +0000 Subject: [PATCH] define STR_NONE as a rct_string_id --- src/interface/window.c | 2 +- src/localisation/language.cpp | 10 +++++----- src/localisation/localisation.c | 2 +- src/localisation/string_ids.h | 6 ++++-- src/object_list.c | 2 +- src/scenario.c | 6 +++--- src/scenario_list.c | 4 ++-- src/windows/error.c | 4 ++-- src/windows/map_tooltip.c | 2 +- src/windows/text_input.c | 2 +- src/windows/title_scenarioselect.c | 2 +- src/windows/tooltip.c | 2 +- 12 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/interface/window.c b/src/interface/window.c index bb38986147..3eaf7df19c 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -2443,7 +2443,7 @@ void window_start_textbox(rct_window *call_w, int call_widget, rct_string_id exi // Enter in the the text input buffer any existing // text. - if (existing_text != (rct_string_id)STR_NONE) + if (existing_text != STR_NONE) format_string(gTextBoxInput, existing_text, &existing_args); // In order to prevent strings that exceed the maxLength diff --git a/src/localisation/language.cpp b/src/localisation/language.cpp index dc70f285cd..92f4780269 100644 --- a/src/localisation/language.cpp +++ b/src/localisation/language.cpp @@ -135,7 +135,7 @@ const char *language_get_string(rct_string_id id) { const char *openrctString = nullptr; - if (id == (rct_string_id)STR_NONE) + if (id == STR_NONE) return nullptr; if (_languageCurrent != nullptr) @@ -356,7 +356,7 @@ rct_string_id object_get_localised_text(uint8_t** pStringTable/*ebp*/, int type/ name[8] = 0; rct_string_id stringId = _languageCurrent->GetObjectOverrideStringId(name, tableindex); - if (stringId != (rct_string_id)STR_NONE) { + if (stringId != STR_NONE) { return stringId; } @@ -423,9 +423,9 @@ bool language_get_localised_scenario_strings(const utf8 *scenarioFilename, rct_s outStringIds[1] = _languageCurrent->GetScenarioOverrideStringId(scenarioFilename, 1); outStringIds[2] = _languageCurrent->GetScenarioOverrideStringId(scenarioFilename, 2); return - outStringIds[0] != (rct_string_id)STR_NONE || - outStringIds[1] != (rct_string_id)STR_NONE || - outStringIds[2] != (rct_string_id)STR_NONE; + outStringIds[0] != STR_NONE || + outStringIds[1] != STR_NONE || + outStringIds[2] != STR_NONE; } } diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c index 697178f29f..01bd0101e8 100644 --- a/src/localisation/localisation.c +++ b/src/localisation/localisation.c @@ -760,7 +760,7 @@ void format_string_part_from_raw(utf8 **dest, const utf8 *src, char **args) void format_string_part(utf8 **dest, rct_string_id format, char **args) { - if (format == (rct_string_id)STR_NONE) { + if (format == STR_NONE) { **dest = 0; } else if (format < 0x8000) { // Language string diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 9e24822c28..d08d0a9c4a 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -21,9 +21,11 @@ #ifndef _STRING_IDS_H_ #define _STRING_IDS_H_ -enum { - STR_NONE = -1, +#include "../common.h" +#define STR_NONE ((rct_string_id)-1) + +enum { STR_GUEST = 767, STR_DATE_DAY_1 = 779, diff --git a/src/object_list.c b/src/object_list.c index 7b865c66d5..5702007235 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -773,7 +773,7 @@ static uint32 install_object_entry(rct_object_entry* entry, rct_object_entry* in // Always extract only the vehicle type, since the track type is always displayed in the left column, to prevent duplicate track names. rct_string_id nameStringId = object_get_name_string_id(entry, chunk); - if (nameStringId == (rct_string_id)STR_NONE) { + if (nameStringId == STR_NONE) { nameStringId = (rct_string_id)RCT2_GLOBAL(RCT2_ADDRESS_CURR_OBJECT_BASE_STRING_ID, uint32); } diff --git a/src/scenario.c b/src/scenario.c index c7bcdcafb0..9c6563137b 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -285,13 +285,13 @@ void scenario_begin() rct_string_id localisedStringIds[3]; if (language_get_localised_scenario_strings(normalisedName, localisedStringIds)) { - if (localisedStringIds[0] != (rct_string_id)STR_NONE) { + if (localisedStringIds[0] != STR_NONE) { safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, language_get_string(localisedStringIds[0]), 32); } - if (localisedStringIds[1] != (rct_string_id)STR_NONE) { + if (localisedStringIds[1] != STR_NONE) { park_set_name(language_get_string(localisedStringIds[1])); } - if (localisedStringIds[2] != (rct_string_id)STR_NONE) { + if (localisedStringIds[2] != STR_NONE) { safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, language_get_string(localisedStringIds[2]), 256); } } else { diff --git a/src/scenario_list.c b/src/scenario_list.c index d62c906946..5d5efc86a6 100644 --- a/src/scenario_list.c +++ b/src/scenario_list.c @@ -190,10 +190,10 @@ static void scenario_translate(scenario_index_entry *scenarioEntry, const rct_ob { rct_string_id localisedStringIds[3]; if (language_get_localised_scenario_strings(scenarioEntry->name, localisedStringIds)) { - if (localisedStringIds[0] != (rct_string_id)STR_NONE) { + if (localisedStringIds[0] != STR_NONE) { safe_strncpy(scenarioEntry->name, language_get_string(localisedStringIds[0]), 64); } - if (localisedStringIds[2] != (rct_string_id)STR_NONE) { + if (localisedStringIds[2] != STR_NONE) { safe_strncpy(scenarioEntry->details, language_get_string(localisedStringIds[2]), 256); } } else { diff --git a/src/windows/error.c b/src/windows/error.c index 10d2d4e9af..6900e7ec74 100644 --- a/src/windows/error.c +++ b/src/windows/error.c @@ -91,13 +91,13 @@ void window_error_open(rct_string_id title, rct_string_id message) // Format the title dst = utf8_write_codepoint(dst, FORMAT_BLACK); - if (title != (rct_string_id)STR_NONE) { + if (title != STR_NONE) { format_string(dst, title, args); dst = get_string_end(dst); } // Format the message - if (message != (rct_string_id)STR_NONE) { + if (message != STR_NONE) { dst = utf8_write_codepoint(dst, FORMAT_NEWLINE); format_string(dst, message, args); dst = get_string_end(dst); diff --git a/src/windows/map_tooltip.c b/src/windows/map_tooltip.c index 87c65aa5bc..d09f2df031 100644 --- a/src/windows/map_tooltip.c +++ b/src/windows/map_tooltip.c @@ -148,7 +148,7 @@ static void window_map_tooltip_update(rct_window *w) */ static void window_map_tooltip_paint(rct_window *w, rct_drawpixelinfo *dpi) { - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, rct_string_id) == (rct_string_id)STR_NONE) + if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, rct_string_id) == STR_NONE) return; gfx_draw_string_centred_wrapped(dpi, (void*)RCT2_ADDRESS_MAP_TOOLTIP_ARGS, w->x + (w->width / 2), w->y + (w->height / 2), w->width, 1162, 0); diff --git a/src/windows/text_input.c b/src/windows/text_input.c index 48cbef83d6..9fa7d5ebe6 100644 --- a/src/windows/text_input.c +++ b/src/windows/text_input.c @@ -111,7 +111,7 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t // Enter in the the text input buffer any existing // text. - if (existing_text != (rct_string_id)STR_NONE) + if (existing_text != STR_NONE) format_string(text_input, existing_text, &existing_args); // In order to prevent strings that exceed the maxLength diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index 20e358ceed..96b1b20992 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -556,7 +556,7 @@ static void initialise_list_items(rct_window *w) } } } - if (headingStringId != (rct_string_id)STR_NONE) { + if (headingStringId != STR_NONE) { // Ensure list capacity if (length == capacity) { capacity += 32; diff --git a/src/windows/tooltip.c b/src/windows/tooltip.c index 8ba29917ef..0e77880917 100644 --- a/src/windows/tooltip.c +++ b/src/windows/tooltip.c @@ -158,7 +158,7 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y gTooltipWidget.window_number = widgetWindow->number; gTooltipWidget.widget_index = widgetIndex; - if (window_event_tooltip_call(widgetWindow, widgetIndex) == (rct_string_id)STR_NONE) + if (window_event_tooltip_call(widgetWindow, widgetIndex) == STR_NONE) return; window_tooltip_show(widget->tooltip, x, y);