Codechange: Use std::array for GRF(File|Config) parameters.
This simplifies comparison, copying and assignment operations.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user