mirror of https://github.com/OpenTTD/OpenTTD
(svn r11127) -Fix: truncate the result of 8 bits callbacks.
parent
7f721d31c2
commit
262836a24f
|
@ -13,6 +13,9 @@
|
||||||
* bit is set in the callback flags/trigger for a vehicle, house,
|
* bit is set in the callback flags/trigger for a vehicle, house,
|
||||||
* industry, etc.
|
* industry, etc.
|
||||||
* Names are formatted as CBID_<CLASS>_<CALLBACK>
|
* Names are formatted as CBID_<CLASS>_<CALLBACK>
|
||||||
|
*
|
||||||
|
* @note Do not forget to add 15 bits callbacks to the switch in
|
||||||
|
* newgrf_spritegroup.cpp (search for "15 bits callback").
|
||||||
*/
|
*/
|
||||||
enum CallbackID {
|
enum CallbackID {
|
||||||
/** Set when using the callback resolve system, but not to resolve a callback. */
|
/** Set when using the callback resolve system, but not to resolve a callback. */
|
||||||
|
|
|
@ -192,7 +192,25 @@ static inline const SpriteGroup *ResolveVariable(const SpriteGroup *group, Resol
|
||||||
if (group->g.determ.num_ranges == 0) {
|
if (group->g.determ.num_ranges == 0) {
|
||||||
/* nvar == 0 is a special case -- we turn our value into a callback result */
|
/* nvar == 0 is a special case -- we turn our value into a callback result */
|
||||||
nvarzero.type = SGT_CALLBACK;
|
nvarzero.type = SGT_CALLBACK;
|
||||||
|
switch (object->callback) {
|
||||||
|
/* All these functions are 15 bit callbacks */
|
||||||
|
case CBID_VEHICLE_REFIT_CAPACITY:
|
||||||
|
case CBID_BUILDING_COLOUR:
|
||||||
|
case CBID_HOUSE_CARGO_ACCEPTANCE:
|
||||||
|
case CBID_INDUSTRY_LOCATION:
|
||||||
|
case CBID_INDTILE_CARGO_ACCEPTANCE:
|
||||||
|
case CBID_VEHICLE_COLOUR_MAPPING:
|
||||||
|
case CBID_HOUSE_PRODUCE_CARGO:
|
||||||
|
case CBID_VEHICLE_SOUND_EFFECT:
|
||||||
|
case CBID_SOUNDS_AMBIENT_EFFECT:
|
||||||
nvarzero.g.callback.result = GB(value, 0, 15);
|
nvarzero.g.callback.result = GB(value, 0, 15);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* The rest is a 8 bit callback, which should be truncated properly */
|
||||||
|
default:
|
||||||
|
nvarzero.g.callback.result = GB(value, 0, 8);
|
||||||
|
break;
|
||||||
|
}
|
||||||
return &nvarzero;
|
return &nvarzero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue