Codechange: Use std::array for GRF(File|Config) parameters.

This simplifies comparison, copying and assignment operations.
This commit is contained in:
Peter Nelson
2023-05-18 19:56:24 +01:00
committed by PeterN
parent c23aae96a2
commit 6b87fe6540
7 changed files with 18 additions and 23 deletions

View File

@@ -121,7 +121,7 @@ struct GRFFile : ZeroedMemoryAllocator {
std::vector<std::unique_ptr<struct AirportTileSpec>> airtspec;
std::vector<std::unique_ptr<struct RoadStopSpec>> roadstops;
uint32 param[0x80];
std::array<uint32_t, 0x80> param;
uint param_end; ///< one more than the highest set parameter
std::vector<GRFLabel> labels; ///< List of labels
@@ -154,9 +154,9 @@ struct GRFFile : ZeroedMemoryAllocator {
/** Get GRF Parameter with range checking */
uint32 GetParam(uint number) const
{
/* Note: We implicitly test for number < lengthof(this->param) and return 0 for invalid parameters.
/* Note: We implicitly test for number < this->param.size() and return 0 for invalid parameters.
* In fact this is the more important test, as param is zeroed anyway. */
assert(this->param_end <= lengthof(this->param));
assert(this->param_end <= this->param.size());
return (number < this->param_end) ? this->param[number] : 0;
}
};