* Set the value of the given user-changeable parameter. * @param info The grf parameter info to set the value for. * @param value The new value. */
| 178 | * @param value The new value. |
| 179 | */ |
| 180 | void GRFConfig::SetValue(const GRFParameterInfo &info, uint32_t value) |
| 181 | { |
| 182 | value = Clamp(value, info.min_value, info.max_value); |
| 183 | |
| 184 | /* Allocate the new parameter if it's not already present. */ |
| 185 | if (info.param_nr >= std::size(this->param)) this->param.resize(info.param_nr + 1); |
| 186 | |
| 187 | /* SB doesn't work correctly with nbits == 32, so handle that case here. */ |
| 188 | if (info.num_bit == 32) { |
| 189 | this->param[info.param_nr] = value; |
| 190 | } else { |
| 191 | SB(this->param[info.param_nr], info.first_bit, info.num_bit, value); |
| 192 | } |
| 193 | |
| 194 | SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Finalize Action 14 info after file scan is finished. |
no test coverage detected