1
0
Fork 0

Codechange: remove need for GetDParamX

pull/11003/head
Rubidium 2023-06-11 21:59:58 +02:00 committed by rubidium42
parent 82b434b589
commit 613ad80581
2 changed files with 6 additions and 16 deletions

View File

@ -131,6 +131,12 @@ ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg,
*/ */
void ErrorMessageData::CopyOutDParams() void ErrorMessageData::CopyOutDParams()
{ {
if (this->detailed_msg == STR_ERROR_OWNED_BY) {
/* The parameters are set by SetDParamsForOwnedBy. */
CompanyID company = (CompanyID)GetDParam(OWNED_BY_OWNER_IN_PARAMETERS_OFFSET);
if (company < MAX_COMPANIES) face = company;
}
/* Reset parameters */ /* Reset parameters */
for (size_t i = 0; i < lengthof(this->strings); i++) free(this->strings[i]); for (size_t i = 0; i < lengthof(this->strings); i++) free(this->strings[i]);
memset(this->decode_params, 0, sizeof(this->decode_params)); memset(this->decode_params, 0, sizeof(this->decode_params));
@ -140,11 +146,6 @@ void ErrorMessageData::CopyOutDParams()
if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack); if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack);
CopyOutDParam(this->decode_params, this->strings, this->detailed_msg == INVALID_STRING_ID ? this->summary_msg : this->detailed_msg, lengthof(this->decode_params)); CopyOutDParam(this->decode_params, this->strings, this->detailed_msg == INVALID_STRING_ID ? this->summary_msg : this->detailed_msg, lengthof(this->decode_params));
if (this->textref_stack_size > 0) StopTextRefStackUsage(); if (this->textref_stack_size > 0) StopTextRefStackUsage();
if (this->detailed_msg == STR_ERROR_OWNED_BY) {
CompanyID company = (CompanyID)GetDParamX(this->decode_params, OWNED_BY_OWNER_IN_PARAMETERS_OFFSET);
if (company < MAX_COMPANIES) face = company;
}
} }
/** /**

View File

@ -211,17 +211,6 @@ void CopyInDParam(const uint64 *src, int num);
void CopyOutDParam(uint64 *dst, int num); void CopyOutDParam(uint64 *dst, int num);
void CopyOutDParam(uint64 *dst, const char **strings, StringID string, int num); void CopyOutDParam(uint64 *dst, const char **strings, StringID string, int num);
/**
* Get the current string parameter at index \a n from parameter array \a s.
* @param s Array of string parameters.
* @param n Index of the string parameter.
* @return Value of the requested string parameter.
*/
static inline uint64 GetDParamX(const uint64 *s, uint n)
{
return s[n];
}
/** /**
* Get the current string parameter at index \a n from the global string parameter array. * Get the current string parameter at index \a n from the global string parameter array.
* @param n Index of the string parameter. * @param n Index of the string parameter.