diff options
author | darkvater <darkvater@openttd.org> | 2004-11-14 23:36:19 +0000 |
---|---|---|
committer | darkvater <darkvater@openttd.org> | 2004-11-14 23:36:19 +0000 |
commit | 485247434373200909ba90baf426ff3b55b1f80f (patch) | |
tree | 227d6114aa8ca2334868ba6b8a164900f434af00 | |
parent | afca207cf085599ce543ca0d68cfd2ba5e5453ae (diff) | |
download | openttd-485247434373200909ba90baf426ff3b55b1f80f.tar.xz |
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
-rw-r--r-- | grfspecial.c | 33 | ||||
-rw-r--r-- | train_gui.c | 9 |
2 files changed, 27 insertions, 15 deletions
diff --git a/grfspecial.c b/grfspecial.c index 6e0f723d2..1fbef4e0b 100644 --- a/grfspecial.c +++ b/grfspecial.c @@ -21,6 +21,7 @@ extern int _skip_sprites; extern int _replace_sprites_count[16]; extern int _replace_sprites_offset[16]; +extern int _traininfo_vehicle_pitch; struct GRFFile { char *filename; @@ -1548,8 +1549,10 @@ static void SkipIf(byte *buf, int len) case 0x8D: /* TTD Version, 00=DOS, 01=Windows */ param_val = 1; break; + case 0x8E: + param_val = _traininfo_vehicle_pitch; + break; /* TODO */ - case 0x8E: /* How many pixels to displace sprites in train info windows */ case 0x8F: /* Track type cost multipliers */ default: if (param >= 0x80) { @@ -1739,6 +1742,7 @@ static void ParamSet(byte *buf, int len) uint16 src1; uint16 src2; uint16 data = 0; + int32 *dest; check_length(len, 5, "ParamSet"); buf++; @@ -1790,37 +1794,42 @@ static void ParamSet(byte *buf, int len) * from action 7, but at the moment the only variable that is valid to * write is 8E. */ - if (_param_max < target) - _param_max = target; + if (target == 0x8E) { + dest = &_traininfo_vehicle_pitch; + } else { + if (_param_max < target) + _param_max = target; + dest = &_paramlist[target]; + } /* FIXME: No checking for overflows. */ switch (oper) { case 0x00: - _paramlist[target] = src1; + *dest = src1; break; case 0x01: - _paramlist[target] = src1 + src2; + *dest = src1 + src2; break; case 0x02: - _paramlist[target] = src1 - src2; + *dest = src1 - src2; break; case 0x03: - _paramlist[target] = ((uint32) src1) * ((uint32) src2); + *dest = ((uint32) src1) * ((uint32) src2); break; case 0x04: - _paramlist[target] = ((int32) src1) * ((int32) src2); + *dest = ((int32) src1) * ((int32) src2); break; case 0x05: if (src2 & 0x8000) /* src2 is "negative" */ - _paramlist[target] = src1 >> -((int16) src2); + *dest = src1 >> -((int16) src2); else - _paramlist[target] = src1 << src2; + *dest = src1 << src2; break; case 0x06: if (src2 & 0x8000) /* src2 is "negative" */ - _paramlist[target] = ((int16) src1) >> -((int16) src2); + *dest = ((int16) src1) >> -((int16) src2); else - _paramlist[target] = ((int16) src1) << src2; + *dest = ((int16) src1) << src2; break; default: grfmsg(GMS_ERROR, "ParamSet: Unknown operation %d, skipping.", oper); diff --git a/train_gui.c b/train_gui.c index 6f0e26d48..2a2e0ae62 100644 --- a/train_gui.c +++ b/train_gui.c @@ -11,6 +11,9 @@ #include "player.h" #include "engine.h" + +int _traininfo_vehicle_pitch = 0; + static Engine * const _rail_engines[3] = { &_engines[0], &_engines[NUM_NORMAL_RAIL_ENGINES], @@ -109,7 +112,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e) if (sel==0) selected_id = engine_id; if (IS_INT_INSIDE(--pos, -8, 0)) { DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); - DrawTrainEngine(x+29, y+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); + DrawTrainEngine(x+29, y+6+_traininfo_vehicle_pitch, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); y += 14; } sel--; @@ -253,7 +256,7 @@ static void DrawTrainImage(Vehicle *v, int x, int y, int count, int skip, Vehicl int image = GetTrainImage(v, 6); uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); if (v->vehstatus & VS_CRASHED) ormod = 0x3248000; - DrawSprite(image | ormod, x+14, y+6); + DrawSprite(image | ormod, x+14, y+6+_traininfo_vehicle_pitch); if (v->index == selection) DrawFrameRect(x-1, y-1, x+28, y+12, 15, 0x10); x += 29; count--; @@ -1271,7 +1274,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e) assert(v->type == VEH_Train && v->subtype == 0 && v->owner == window_number); - DrawTrainImage(v, x + 21, y + 6, 10, 0, INVALID_VEHICLE); + DrawTrainImage(v, x + 21, y + 6 + _traininfo_vehicle_pitch, 10, 0, INVALID_VEHICLE); DrawVehicleProfitButton(v, x, y+13); SET_DPARAM16(0, v->unitnumber); |