Mercurial > hg > openttd
changeset 16099:084184db4653 draft
(svn r20792) -Fix (r8973): [NewGRF] vehicle vars 0x98 and 0xB4 (max speed and current speed) used the wrong unit for aircraft (Hirundo)
author | yexo <yexo@openttd.org> |
---|---|
date | Sun, 12 Sep 2010 19:54:25 +0000 |
parents | 69fa0c82f849 |
children | 08e65ca04e76 |
files | src/newgrf_engine.cpp |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -713,8 +713,12 @@ case 0x15: return GB(v->service_interval, 8, 8); case 0x16: return v->last_station_visited; case 0x17: return v->tick_counter; - case 0x18: return v->max_speed; - case 0x19: return GB(v->max_speed, 8, 8); + case 0x18: + case 0x19: { + uint max_speed = v->type == VEH_TRAIN ? Train::From(v)->tcache.cached_max_speed : v->max_speed; + if (v->type == VEH_AIRCRAFT) max_speed = max_speed * 10 / 128; + return (variable - 0x80) == 0x18 ? max_speed : GB(max_speed, 8, 8); + } case 0x1A: return v->x_pos; case 0x1B: return GB(v->x_pos, 8, 8); case 0x1C: return v->y_pos; @@ -725,8 +729,8 @@ case 0x29: return GB(v->cur_image, 8, 8); case 0x32: return v->vehstatus; case 0x33: return 0; // non-existent high byte of vehstatus - case 0x34: return v->cur_speed; - case 0x35: return GB(v->cur_speed, 8, 8); + case 0x34: return v->type == VEH_AIRCRAFT ? (v->cur_speed * 10) / 128 : v->cur_speed; + case 0x35: return GB(v->type == VEH_AIRCRAFT ? (v->cur_speed * 10) / 128 : v->cur_speed, 8, 8); case 0x36: return v->subspeed; case 0x37: return v->acceleration; case 0x39: return v->cargo_type;