1
0
Fork 0

(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)

release/0.4.5
darkvater 2004-11-14 23:36:19 +00:00
parent afca207cf0
commit 4852474343
2 changed files with 27 additions and 15 deletions

View File

@ -21,6 +21,7 @@
extern int _skip_sprites; extern int _skip_sprites;
extern int _replace_sprites_count[16]; extern int _replace_sprites_count[16];
extern int _replace_sprites_offset[16]; extern int _replace_sprites_offset[16];
extern int _traininfo_vehicle_pitch;
struct GRFFile { struct GRFFile {
char *filename; char *filename;
@ -1548,8 +1549,10 @@ static void SkipIf(byte *buf, int len)
case 0x8D: /* TTD Version, 00=DOS, 01=Windows */ case 0x8D: /* TTD Version, 00=DOS, 01=Windows */
param_val = 1; param_val = 1;
break; break;
case 0x8E:
param_val = _traininfo_vehicle_pitch;
break;
/* TODO */ /* TODO */
case 0x8E: /* How many pixels to displace sprites in train info windows */
case 0x8F: /* Track type cost multipliers */ case 0x8F: /* Track type cost multipliers */
default: default:
if (param >= 0x80) { if (param >= 0x80) {
@ -1739,6 +1742,7 @@ static void ParamSet(byte *buf, int len)
uint16 src1; uint16 src1;
uint16 src2; uint16 src2;
uint16 data = 0; uint16 data = 0;
int32 *dest;
check_length(len, 5, "ParamSet"); check_length(len, 5, "ParamSet");
buf++; 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 * from action 7, but at the moment the only variable that is valid to
* write is 8E. */ * write is 8E. */
if (_param_max < target) if (target == 0x8E) {
_param_max = target; dest = &_traininfo_vehicle_pitch;
} else {
if (_param_max < target)
_param_max = target;
dest = &_paramlist[target];
}
/* FIXME: No checking for overflows. */ /* FIXME: No checking for overflows. */
switch (oper) { switch (oper) {
case 0x00: case 0x00:
_paramlist[target] = src1; *dest = src1;
break; break;
case 0x01: case 0x01:
_paramlist[target] = src1 + src2; *dest = src1 + src2;
break; break;
case 0x02: case 0x02:
_paramlist[target] = src1 - src2; *dest = src1 - src2;
break; break;
case 0x03: case 0x03:
_paramlist[target] = ((uint32) src1) * ((uint32) src2); *dest = ((uint32) src1) * ((uint32) src2);
break; break;
case 0x04: case 0x04:
_paramlist[target] = ((int32) src1) * ((int32) src2); *dest = ((int32) src1) * ((int32) src2);
break; break;
case 0x05: case 0x05:
if (src2 & 0x8000) /* src2 is "negative" */ if (src2 & 0x8000) /* src2 is "negative" */
_paramlist[target] = src1 >> -((int16) src2); *dest = src1 >> -((int16) src2);
else else
_paramlist[target] = src1 << src2; *dest = src1 << src2;
break; break;
case 0x06: case 0x06:
if (src2 & 0x8000) /* src2 is "negative" */ if (src2 & 0x8000) /* src2 is "negative" */
_paramlist[target] = ((int16) src1) >> -((int16) src2); *dest = ((int16) src1) >> -((int16) src2);
else else
_paramlist[target] = ((int16) src1) << src2; *dest = ((int16) src1) << src2;
break; break;
default: default:
grfmsg(GMS_ERROR, "ParamSet: Unknown operation %d, skipping.", oper); grfmsg(GMS_ERROR, "ParamSet: Unknown operation %d, skipping.", oper);

View File

@ -11,6 +11,9 @@
#include "player.h" #include "player.h"
#include "engine.h" #include "engine.h"
int _traininfo_vehicle_pitch = 0;
static Engine * const _rail_engines[3] = { static Engine * const _rail_engines[3] = {
&_engines[0], &_engines[0],
&_engines[NUM_NORMAL_RAIL_ENGINES], &_engines[NUM_NORMAL_RAIL_ENGINES],
@ -109,7 +112,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
if (sel==0) selected_id = engine_id; if (sel==0) selected_id = engine_id;
if (IS_INT_INSIDE(--pos, -8, 0)) { if (IS_INT_INSIDE(--pos, -8, 0)) {
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); 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; y += 14;
} }
sel--; sel--;
@ -253,7 +256,7 @@ static void DrawTrainImage(Vehicle *v, int x, int y, int count, int skip, Vehicl
int image = GetTrainImage(v, 6); int image = GetTrainImage(v, 6);
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
if (v->vehstatus & VS_CRASHED) ormod = 0x3248000; 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); if (v->index == selection) DrawFrameRect(x-1, y-1, x+28, y+12, 15, 0x10);
x += 29; x += 29;
count--; count--;
@ -1271,7 +1274,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
assert(v->type == VEH_Train && v->subtype == 0 && v->owner == window_number); 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); DrawVehicleProfitButton(v, x, y+13);
SET_DPARAM16(0, v->unitnumber); SET_DPARAM16(0, v->unitnumber);