diff --git a/src/strings.cpp b/src/strings.cpp index 6a1205d541..a88099fb73 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -168,24 +168,6 @@ void CopyInDParam(const std::span backup) } } -/** - * Copy \a num string parameters from the global string parameter array to the \a backup. - * @param backup The backup to write to. - * @param num Number of string parameters to copy. - */ -void CopyOutDParam(std::vector &backup, size_t num) -{ - backup.resize(num); - for (size_t i = 0; i < backup.size(); i++) { - const char *str = _global_string_params.GetParamStr(i); - if (str != nullptr) { - backup[i] = str; - } else { - backup[i] = _global_string_params.GetParam(i); - } - } -} - /** * Copy parameters into StringParameterBackup for long-term storage. * @param backup The backup to write to. @@ -207,26 +189,6 @@ void CopyOutDParam(std::vector &backup, StringParameters } } -/** - * Checks whether the global string parameters have changed compared to the given backup. - * @param backup The backup to check against. - * @return True when the parameters have changed, otherwise false. - */ -bool HaveDParamChanged(const std::vector &backup) -{ - bool changed = false; - for (size_t i = 0; !changed && i < backup.size(); i++) { - bool global_has_string = _global_string_params.GetParamStr(i) != nullptr; - if (global_has_string != backup[i].string.has_value()) return true; - - if (global_has_string) { - changed = backup[i].string.value() != _global_string_params.GetParamStr(i); - } else { - changed = backup[i].data != _global_string_params.GetParam(i); - } - } - return changed; -} static void StationGetSpecialString(StringBuilder &builder, StationFacility x); static void GetSpecialTownNameString(StringBuilder &builder, int ind, uint32_t seed); diff --git a/src/strings_func.h b/src/strings_func.h index 4cc208b991..4a495112a2 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -99,9 +99,7 @@ void SetDParamStr(size_t n, const std::string &str); void SetDParamStr(size_t n, std::string &&str); void CopyInDParam(const std::span backup); -void CopyOutDParam(std::vector &backup, size_t num); void CopyOutDParam(std::vector &backup, class StringParameters &¶ms); -bool HaveDParamChanged(const std::vector &backup); uint64_t GetDParam(size_t n); diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 53884be7d7..55b71946b9 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -7,7 +7,6 @@ add_test_files( mock_spritecache.cpp mock_spritecache.h string_func.cpp - strings_func.cpp test_main.cpp test_script_admin.cpp test_window_desc.cpp diff --git a/src/tests/strings_func.cpp b/src/tests/strings_func.cpp deleted file mode 100644 index dd70b0a365..0000000000 --- a/src/tests/strings_func.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of OpenTTD. - * OpenTTD 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, version 2. - * OpenTTD 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 OpenTTD. If not, see . - */ - -/** @file strings_func.cpp Test functionality from strings_func. */ - -#include "../stdafx.h" - -#include "../3rdparty/catch2/catch.hpp" - -#include "../strings_func.h" - -TEST_CASE("HaveDParamChanged") -{ - SetDParam(0, 0); - SetDParamStr(1, "some string"); - - std::vector backup; - CopyOutDParam(backup, 2); - - CHECK(HaveDParamChanged(backup) == false); - - /* A different parameter 0 (both string and numeric). */ - SetDParam(0, 1); - CHECK(HaveDParamChanged(backup) == true); - - SetDParamStr(0, "some other string"); - CHECK(HaveDParamChanged(backup) == true); - - /* Back to the original state, nothing should have changed. */ - SetDParam(0, 0); - CHECK(HaveDParamChanged(backup) == false); - - /* A different parameter 1 (both string and numeric). */ - SetDParamStr(1, "some other string"); - CHECK(HaveDParamChanged(backup) == true); - - SetDParam(1, 0); - CHECK(HaveDParamChanged(backup) == true); - - /* Back to the original state, nothing should have changed. */ - SetDParamStr(1, "some string"); - CHECK(HaveDParamChanged(backup) == false); - - /* Changing paramter 2 should not have any effect, as the backup is only 2 long. */ - SetDParam(2, 3); - CHECK(HaveDParamChanged(backup) == false); - -}