Fix various uint/size_t mismatches in string functions

This commit is contained in:
Jonathan G Rennison
2023-11-09 20:27:56 +00:00
parent c31a8971f2
commit a2d5c4354d
2 changed files with 12 additions and 12 deletions

View File

@@ -106,7 +106,7 @@ StringParameter *StringParameters::GetNextParameterPointer()
* @param min_count Minimum number of digits independent of \a max. * @param min_count Minimum number of digits independent of \a max.
* @param size Font of the number * @param size Font of the number
*/ */
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size) void SetDParamMaxValue(size_t n, uint64 max_value, uint min_count, FontSize size)
{ {
uint num_digits = 1; uint num_digits = 1;
while (max_value >= 10) { while (max_value >= 10) {
@@ -122,7 +122,7 @@ void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
* @param count Number of digits which shall be displayable. * @param count Number of digits which shall be displayable.
* @param size Font of the number * @param size Font of the number
*/ */
void SetDParamMaxDigits(uint n, uint count, FontSize size) void SetDParamMaxDigits(size_t n, uint count, FontSize size)
{ {
SetDParam(n, GetBroadestDigitsValue(count, size)); SetDParam(n, GetBroadestDigitsValue(count, size));
} }
@@ -311,7 +311,7 @@ std::string GetString(StringID string)
* @param n slot of the string * @param n slot of the string
* @param str string to bind * @param str string to bind
*/ */
void SetDParamStr(uint n, const char *str) void SetDParamStr(size_t n, const char *str)
{ {
_global_string_params.SetParam(n, str); _global_string_params.SetParam(n, str);
} }
@@ -323,7 +323,7 @@ void SetDParamStr(uint n, const char *str)
* @param n slot of the string * @param n slot of the string
* @param str string to bind * @param str string to bind
*/ */
void SetDParamStr(uint n, std::string str) void SetDParamStr(size_t n, std::string str)
{ {
_global_string_params.SetParam(n, std::move(str)); _global_string_params.SetParam(n, std::move(str));
} }
@@ -1218,7 +1218,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters &arg
case SCC_GENDER_LIST: { // {G 0 Der Die Das} case SCC_GENDER_LIST: { // {G 0 Der Die Das}
/* First read the meta data from the language file. */ /* First read the meta data from the language file. */
uint offset = orig_offset + (byte)*str++; size_t offset = orig_offset + (byte)*str++;
int gender = 0; int gender = 0;
if (!dry_run && args.GetTypeAtOffset(offset) != 0) { if (!dry_run && args.GetTypeAtOffset(offset) != 0) {
/* Now we need to figure out what text to resolve, i.e. /* Now we need to figure out what text to resolve, i.e.
@@ -1260,7 +1260,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters &arg
case SCC_PLURAL_LIST: { // {P} case SCC_PLURAL_LIST: { // {P}
int plural_form = *str++; // contains the plural form for this string int plural_form = *str++; // contains the plural form for this string
uint offset = orig_offset + (byte)*str++; size_t offset = orig_offset + (byte)*str++;
int64 v = args.GetParam(offset); // contains the number that determines plural int64 v = args.GetParam(offset); // contains the number that determines plural
str = ParseStringChoice(str, DeterminePluralForm(v, plural_form), &buff, last); str = ParseStringChoice(str, DeterminePluralForm(v, plural_form), &buff, last);
break; break;

View File

@@ -94,16 +94,16 @@ WChar GetDecimalSeparatorChar();
* @param n Index of the string parameter. * @param n Index of the string parameter.
* @param v Value of the string parameter. * @param v Value of the string parameter.
*/ */
static inline void SetDParam(uint n, uint64 v) static inline void SetDParam(size_t n, uint64 v)
{ {
_global_string_params.SetParam(n, v); _global_string_params.SetParam(n, v);
} }
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count = 0, FontSize size = FS_NORMAL); void SetDParamMaxValue(size_t n, uint64 max_value, uint min_count = 0, FontSize size = FS_NORMAL);
void SetDParamMaxDigits(uint n, uint count, FontSize size = FS_NORMAL); void SetDParamMaxDigits(size_t n, uint count, FontSize size = FS_NORMAL);
void SetDParamStr(uint n, const char *str); void SetDParamStr(size_t n, const char *str);
void SetDParamStr(uint n, std::string str); void SetDParamStr(size_t n, std::string str);
void CopyInDParam(const span<const StringParameterBackup> backup, uint offset = 0); void CopyInDParam(const span<const StringParameterBackup> backup, uint offset = 0);
void CopyOutDParam(std::vector<StringParameterBackup> &backup, size_t num); void CopyOutDParam(std::vector<StringParameterBackup> &backup, size_t num);
@@ -114,7 +114,7 @@ bool HaveDParamChanged(const std::vector<StringParameterBackup> &backup);
* @param n Index of the string parameter. * @param n Index of the string parameter.
* @return Value of the requested string parameter. * @return Value of the requested string parameter.
*/ */
static inline uint64 GetDParam(uint n) static inline uint64 GetDParam(size_t n)
{ {
return _global_string_params.GetParam(n); return _global_string_params.GetParam(n);
} }