Changeset - r420:d99a908fcdb7
[Not reviewed]
master
0 2 0
darkvater - 20 years ago 2004-11-14 23:36:19
darkvater@openttd.org
(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)
2 files changed with 27 insertions and 15 deletions:
0 comments (0 inline, 0 general)
grfspecial.c
Show inline comments
 
@@ -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);
train_gui.c
Show inline comments
 
@@ -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
 
					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, i
 
			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 *
 

	
 
				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);
0 comments (0 inline, 0 general)