Codechange: use StringParameters for remapping the NewGRF string control codes

This commit is contained in:
Rubidium
2023-06-13 15:55:46 +02:00
committed by rubidium42
parent 1146904d45
commit aba0d27a28
5 changed files with 38 additions and 24 deletions

View File

@@ -129,6 +129,20 @@ public:
return &this->data[this->offset];
}
/**
* Get a new instance of StringParameters that is a "range" into the
* parameters existing parameters. Upon destruction the offset in the parent
* is not updated. However, calls to SetDParam do update the parameters.
*
* The returned StringParameters must not outlive this StringParameters.
* @return A "range" of the string parameters.
*/
StringParameters GetRemainingParameters()
{
return StringParameters(&this->data[this->offset], GetDataLeft(),
this->type == nullptr ? nullptr : &this->type[this->offset]);
}
/** Return the amount of elements which can still be read. */
uint GetDataLeft() const
{