From 7449deeffe36cfdb696616e59f038561e5581a1c Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 16 Aug 2015 15:31:59 +0200 Subject: [PATCH] Add console option to reset all user strings --- src/interface/console.c | 12 +++++++++++- src/localisation/user.c | 10 +++++++++- src/localisation/user.h | 21 +++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/localisation/user.h diff --git a/src/interface/console.c b/src/interface/console.c index 30107c5762..4c6529ef03 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -4,6 +4,7 @@ #include "../addresses.h" #include "../drawing/drawing.h" #include "../localisation/localisation.h" +#include "../localisation/user.h" #include "../platform/platform.h" #include "../world/park.h" #include "../util/sawyercoding.h" @@ -816,6 +817,7 @@ static int cc_load_object(const utf8 **argv, int argc) { return 0; } + static int cc_object_count(const utf8 **argv, int argc) { const utf8* object_type_names[] = { "Rides", "Small scenery", "Large scenery", "Walls", "Banners", "Paths", "Path Additions", "Scenery groups", "Park entrances", "Water" }; for (int i = 0; i < 10; i++) { @@ -831,6 +833,13 @@ static int cc_object_count(const utf8 **argv, int argc) { return 0; } + +static int cc_reset_user_strings(const utf8 **argv, int argc) +{ + reset_user_strings(); + return 0; +} + static int cc_open(const utf8 **argv, int argc) { if (argc > 0) { bool title = (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) != 0; @@ -920,7 +929,8 @@ console_command console_command_table[] = { "This is a safer method opposed to \"open object_selection\".", "load_object " }, { "object_count", cc_object_count, "Shows the number of objects of each type in the scenario.", "object_count" }, - { "twitch", cc_twitch, "Twitch API" } + { "twitch", cc_twitch, "Twitch API" }, + { "reset_user_strings", cc_reset_user_strings, "Resets all user-defined strings, to fix incorrectly occurring 'Chosen name in use already' errors.", "reset_user_strings" } }; static int cc_windows(const utf8 **argv, int argc) { diff --git a/src/localisation/user.c b/src/localisation/user.c index e481edf0d1..08f9ac474f 100644 --- a/src/localisation/user.c +++ b/src/localisation/user.c @@ -89,4 +89,12 @@ static bool user_string_exists(const utf8 *text) bool is_user_string_id(rct_string_id stringId) { return stringId >= 0x8000 && stringId < 0x9000; -} \ No newline at end of file +} + +void reset_user_strings() +{ + char *userString = gUserStrings; + for (int i = 0; i < MAX_USER_STRINGS; i++, userString += USER_STRING_MAX_LENGTH) { + userString[0] = 0; + } +} diff --git a/src/localisation/user.h b/src/localisation/user.h new file mode 100644 index 0000000000..879c09ad49 --- /dev/null +++ b/src/localisation/user.h @@ -0,0 +1,21 @@ +/***************************************************************************** + * Copyright (c) 2015 Michael Steenbeek + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +void reset_user_strings();