Skip to content

Commit

Permalink
Cleanup: remove old backup/restore of string parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
rubidium42 committed Jun 21, 2023
1 parent 3d1aadc commit b3571db
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 deletions.
44 changes: 0 additions & 44 deletions src/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,50 +151,6 @@ void SetDParamMaxDigits(size_t n, uint count, FontSize size)
SetDParam(n, val);
}

/**
* 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.
Expand Down
4 changes: 0 additions & 4 deletions src/strings_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ void SetDParamStr(size_t n, const char *str);
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);
Expand Down

0 comments on commit b3571db

Please sign in to comment.