1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 17:02:37 +01:00

Codechange: Preprocess text ref stack parameters. (#13642)

NewGRF text ref stack is now processed in advance, creating parameters as necessary, and then encoding this into an EncodedString.
This commit is contained in:
Peter Nelson
2025-02-22 22:03:38 +00:00
committed by GitHub
parent 4ac81656ee
commit b28dca2222
12 changed files with 168 additions and 354 deletions

View File

@@ -407,32 +407,8 @@ void CommandCost::AddCost(const CommandCost &ret)
}
}
/**
* Values to put on the #TextRefStack for the error message.
* There is only one static instance of the array, just like there is only one
* instance of normal DParams.
*/
/* static */ uint32_t CommandCost::textref_stack[16];
/* static */ EncodedString CommandCost::encoded_message;
/**
* Activate usage of the NewGRF #TextRefStack for the error message.
* @param grffile NewGRF that provides the #TextRefStack
* @param num_registers number of entries to copy from the temporary NewGRF registers
*/
void CommandCost::UseTextRefStack(const GRFFile *grffile, uint num_registers)
{
extern TemporaryStorageArray<int32_t, 0x110> _temp_store;
assert(num_registers < lengthof(textref_stack));
this->textref_stack_grffile = grffile;
this->textref_stack_size = num_registers;
for (uint i = 0; i < num_registers; i++) {
textref_stack[i] = _temp_store.GetValue(0x100 + i);
}
}
/**
* Return an error status, with string and parameter.
* @param str StringID of error.