mirror of https://github.com/OpenTTD/OpenTTD
Codechange: remove now unused functions related to old CopyOutDParm
parent
fcc3365b1f
commit
0574fd767c
|
@ -168,24 +168,6 @@ void CopyInDParam(const std::span<const StringParameterBackup> 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<StringParameterBackup> &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<StringParameterBackup> &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<StringParameterBackup> &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);
|
||||
|
|
|
@ -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<const StringParameterBackup> backup);
|
||||
void CopyOutDParam(std::vector<StringParameterBackup> &backup, size_t num);
|
||||
void CopyOutDParam(std::vector<StringParameterBackup> &backup, class StringParameters &¶ms);
|
||||
bool HaveDParamChanged(const std::vector<StringParameterBackup> &backup);
|
||||
|
||||
uint64_t GetDParam(size_t n);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @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<StringParameterBackup> 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);
|
||||
|
||||
}
|
Loading…
Reference in New Issue