MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetValue

Method SetValue

src/newgrf_config.cpp:180–195  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

178 * @param value The new value.
179 */
180void 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.

Callers 1

SetParameterDefaultsMethod · 0.95

Calls 5

ClampFunction · 0.85
SBFunction · 0.85
SetWindowDirtyFunction · 0.85
resizeMethod · 0.80
sizeFunction · 0.50

Tested by

no test coverage detected