Changeset - r27682:ba707ea68c11
[Not reviewed]
master
0 2 0
Rubidium - 12 months ago 2023-06-21 05:05:15
rubidium@openttd.org
Cleanup: remove old backup/restore of string parameters
2 files changed with 0 insertions and 48 deletions:
0 comments (0 inline, 0 general)
src/strings.cpp
Show inline comments
 
@@ -154,50 +154,6 @@ void SetDParamMaxDigits(size_t n, uint c
 
}
 

	
 
/**
 
 * Copy \a num string parameters from array \a src into the global string parameter array.
 
 * @param src  Source array of string parameters.
 
 * @param num  Number of string parameters to copy.
 
 */
 
void CopyInDParam(const uint64 *src, int num)
 
{
 
	for (int i = 0; i < num; i++) SetDParam(i, src[i]);
 
}
 

	
 
/**
 
 * Copy \a num string parameters from the global string parameter array to the \a dst array.
 
 * @param dst  Destination array of string parameters.
 
 * @param num  Number of string parameters to copy.
 
 */
 
void CopyOutDParam(uint64 *dst, int num)
 
{
 
	for (int i = 0; i < num; i++) dst[i] = GetDParam(i);
 
}
 

	
 
/**
 
 * Copy \a num string parameters from the global string parameter array to the \a dst array.
 
 * Furthermore clone raw string parameters into \a strings and amend the data in \a dst.
 
 * @param dst     Destination array of string parameters.
 
 * @param strings Destination array for clone of the raw strings. Must be of same length as dst. Deallocation left to the caller.
 
 * @param string  The string used to determine where raw strings are and where there are no raw strings.
 
 * @param num     Number of string parameters to copy.
 
 */
 
void CopyOutDParam(uint64 *dst, const char **strings, StringID string, int num)
 
{
 
	/* Just get the string to extract the type information. */
 
	GetString(string);
 

	
 
	for (int i = 0; i < num; i++) {
 
		if (_global_string_params.GetTypeAtOffset(i) == SCC_RAW_STRING_POINTER) {
 
			strings[i] = stredup((const char *)(size_t)_global_string_params.GetParam(i));
 
			dst[i] = (size_t)strings[i];
 
		} else {
 
			strings[i] = nullptr;
 
			dst[i] = _global_string_params.GetParam(i);
 
		}
 
	}
 
}
 

	
 
/**
 
 * Copy the parameters from the backup into the global string parameter array.
 
 * @param backup The backup to copy from.
 
 */
src/strings_func.h
Show inline comments
 
@@ -86,10 +86,6 @@ void SetDParamStr(size_t n, const char *
 
void SetDParamStr(size_t n, const std::string &str);
 
void SetDParamStr(size_t n, std::string &&str) = delete; // block passing temporaries to SetDParamStr
 

	
 
void CopyInDParam(const uint64 *src, int num);
 
void CopyOutDParam(uint64 *dst, int num);
 
void CopyOutDParam(uint64 *dst, const char **strings, StringID string, int num);
 

	
 
void CopyInDParam(const span<const StringParameterBackup> backup);
 
void CopyOutDParam(std::vector<StringParameterBackup> &backup, size_t num);
 
void CopyOutDParam(std::vector<StringParameterBackup> &backup, size_t num, StringID string);
0 comments (0 inline, 0 general)