Changeset - r39:c8e54423ac24
[Not reviewed]
master
0 13 0
dominik - 20 years ago 2004-08-13 18:27:33
dominik@openttd.org
(svn r40) Final slope graphics fix
13 files changed with 120 insertions and 8 deletions:
0 comments (0 inline, 0 general)
clear_cmd.c
Show inline comments
 
@@ -511,12 +511,17 @@ static void DrawTile_Clear(TileInfo *ti)
 
	
 
	DrawClearLandFence(ti, _map3_hi[ti->tile] >> 2);
 
}
 

	
 
uint GetSlopeZ_Clear(TileInfo *ti) { return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z; }
 

	
 
uint GetSlopeTileh_Clear(TileInfo *ti)
 
{
 
	return ti->tileh;
 
}
 

	
 
static void GetAcceptedCargo_Clear(uint tile, AcceptedCargo *ac)
 
{
 
	/* unused */	
 
}
 

	
 
static void AnimateTile_Clear(uint tile)
 
@@ -800,7 +805,8 @@ const TileTypeProcs _tile_type_clear_pro
 
	AnimateTile_Clear,				/* animate_tile_proc */
 
	TileLoop_Clear,						/* tile_loop_clear */
 
	ChangeTileOwner_Clear,		/* change_tile_owner_clear */
 
	NULL,											/* get_produced_cargo_proc */
 
	NULL,											/* vehicle_enter_tile_proc */
 
	NULL,											/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Clear,			/* get_slope_tileh_proc */
 
};
dummy_land.c
Show inline comments
 
@@ -10,12 +10,16 @@ static void DrawTile_Dummy(TileInfo *ti)
 

	
 

	
 
static uint GetSlopeZ_Dummy(TileInfo *ti) {
 
	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 
}
 

	
 
static uint GetSlopeZ_Dummy(TileInfo *ti) {
 
	return ti->tileh;
 
}
 

	
 
static int32 ClearTile_Dummy(uint tile, byte flags) {
 
	return_cmd_error(STR_0001_OFF_EDGE_OF_MAP);
 
}
 

	
 

	
 
static void GetAcceptedCargo_Dummy(uint tile, AcceptedCargo *ac)
 
@@ -65,8 +69,9 @@ const TileTypeProcs _tile_type_dummy_pro
 
	AnimateTile_Dummy,				/* animate_tile_proc */
 
	TileLoop_Dummy,						/* tile_loop_clear */
 
	ChangeTileOwner_Dummy,		/* change_tile_owner_clear */
 
	NULL,											/* get_produced_cargo_proc */
 
	NULL,											/* vehicle_enter_tile_proc */
 
	NULL,											/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Dummy,			/* get_slope_tileh_proc */
 
};
 

	
industry_cmd.c
Show inline comments
 
@@ -331,12 +331,16 @@ static void DrawTile_Industry(TileInfo *
 

	
 

	
 
static uint GetSlopeZ_Industry(TileInfo *ti) {
 
	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 
}
 

	
 
static uint GetSlopeTileh_Industry(TileInfo *ti) {
 
	return 0;
 
}
 

	
 
static void GetAcceptedCargo_Industry(uint tile, AcceptedCargo *ac)
 
{
 
	int m5 = _map5[tile];
 
	int a;
 

	
 
	a = _industry_map5_accepts_1[m5];
 
@@ -1816,12 +1820,13 @@ const TileTypeProcs _tile_type_industry_
 
	AnimateTile_Industry,				/* animate_tile_proc */
 
	TileLoop_Industry,					/* tile_loop_proc */
 
	ChangeTileOwner_Industry,		/* change_tile_owner_proc */
 
	GetProducedCargo_Industry,  /* get_produced_cargo_proc */
 
	NULL,												/* vehicle_enter_tile_proc */
 
	NULL,												/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Industry,			/* get_slope_tileh_proc */
 
};
 

	
 
static const byte _industry_desc[] = {
 
	SLE_VAR(Industry,xy,							SLE_UINT16),
 
	SLE_VAR(Industry,width,						SLE_UINT8),
 
	SLE_VAR(Industry,height,					SLE_UINT8),
landscape.c
Show inline comments
 
@@ -234,28 +234,40 @@ uint GetSlopeZ(int x,  int y)
 
	x &= 0xF;
 
	y &= 0xF;
 

	
 

	
 
	assert(z < 256);
 
*/
 

	
 
	return _tile_type_procs[ti.type]->get_slope_z_proc(&ti);
 
}
 

	
 
/* TODO: add check if this tile has a foundation or not. Since this can't be done easily with the
 
	current landscape arrays, we might have to add a new TileTypeProc. */ 
 
bool hasFoundation(uint tile)
 
// direction=true:  check for foundation in east and south corner
 
// direction=false: check for foundation in west and south corner
 
bool hasFoundation(TileInfo *ti, bool direction)
 
{
 
	return true;
 
	bool south, other; // southern corner and east/west corner
 
	uint slope = _tile_type_procs[ti->type]->get_slope_tileh_proc(ti);
 
	south = ((ti->tileh) & 2) != (slope & 2);
 

	
 
	if(direction)
 
		other = ((ti->tileh) & 4) != (slope & 4);
 
	else
 
		other = ((ti->tileh) & 1) != (slope & 1);
 

	
 
	return south || other;
 
}
 

	
 
void DrawFoundation(TileInfo *ti, uint f)
 
{
 
	uint32 sprite_base = SPR_SLOPES_BASE-14;
 
	if(hasFoundation( TILE_FROM_XY(ti->x, ti->y-1) )) sprite_base += 22;		// foundation in NW direction
 
	if(hasFoundation( TILE_FROM_XY(ti->x-1, ti->y) )) sprite_base += 22*2;	// foundation in NE direction
 

	
 
	TileInfo ti2;
 
	FindLandscapeHeight(&ti2, ti->x, ti->y-1);
 
	if(hasFoundation( &ti2, true )) sprite_base += 22;		// foundation in NW direction
 
	FindLandscapeHeight(&ti2, ti->x-1, ti->y);
 
	if(hasFoundation( &ti2, false )) sprite_base += 22*2;	// foundation in NE direction
 

	
 
	if (f < 15) {
 
		// leveled foundation	
 
		if( sprite_base < SPR_SLOPES_BASE ) sprite_base = 990; // use original slope sprites
 

	
 
		AddSortableSpriteToDraw(f-1 + sprite_base, ti->x, ti->y, 16, 16, 7, ti->z);
rail_cmd.c
Show inline comments
 
@@ -1691,12 +1691,34 @@ uint GetSlopeZ_Track(TileInfo *ti)
 
		}
 
		return GetPartialZ(ti->x&0xF, ti->y&0xF, th) + z;
 
	}
 
	return z;
 
}
 

	
 
uint GetSlopeTileh_Track(TileInfo *ti) 
 
{
 
	// check if it's a foundation
 
	if (ti->tileh != 0) {
 
		if ((ti->map5 & 0x80) == 0) {
 
			uint f = GetRailFoundation(ti->tileh, ti->map5 & 0x3F);
 
			if (f != 0) {
 
				if (f < 15) {
 
					// leveled foundation
 
					return 0;
 
				}
 
				// inclined foundation
 
				return _inclined_tileh[f - 15];
 
			}
 
		} else if ((ti->map5 & 0xC0) == 0xC0) {
 
			// depot or checkpoint
 
			return 0;
 
		}
 
	}
 
	return ti->tileh;
 
}
 

	
 
static void GetAcceptedCargo_Track(uint tile, AcceptedCargo *ac)
 
{
 
	/* not used */
 
}
 

	
 
static void AnimateTile_Track(uint tile)
 
@@ -1946,7 +1968,8 @@ const TileTypeProcs _tile_type_rail_proc
 
	AnimateTile_Track,				/* animate_tile_proc */
 
	TileLoop_Track,						/* tile_loop_clear */
 
	ChangeTileOwner_Track,		/* change_tile_owner_clear */
 
	NULL,											/* get_produced_cargo_proc */
 
	VehicleEnter_Track,				/* vehicle_enter_tile_proc */
 
	NULL,											/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Track,			/* get_slope_tileh_proc */
 
};
road_cmd.c
Show inline comments
 
@@ -872,13 +872,35 @@ uint GetSlopeZ_Road(TileInfo *ti)
 
		} else if ((ti->map5 & 0xF0) == 0x20) {
 
			// depot
 
			return z + 8;
 
		}
 
		return GetPartialZ(ti->x&0xF, ti->y&0xF, th) + z;
 
	}
 
	return z;
 
	return z; // normal Z if no slope
 
}
 

	
 
uint GetSlopeTileh_Road(TileInfo *ti)
 
{
 
	// check if it's a foundation
 
	if (ti->tileh != 0) {
 
		if ((ti->map5 & 0xE0) == 0) { /* road or crossing */
 
			uint f = GetRoadFoundation(ti->tileh, ti->map5 & 0x3F);
 
			if (f != 0) {
 
				if (f < 15) {
 
					// leveled foundation
 
					return 0;
 
				}
 
				// inclined foundation
 
				return _inclined_tileh[f - 15];
 
			}
 
		} else if ((ti->map5 & 0xF0) == 0x20) {
 
			// depot
 
			return 0;
 
		}
 
	}
 
	return ti->tileh;
 
}
 

	
 
static void GetAcceptedCargo_Road(uint tile, AcceptedCargo *ac)
 
{
 
	/* not used */
 
}
 
@@ -1126,7 +1148,8 @@ const TileTypeProcs _tile_type_road_proc
 
	AnimateTile_Road,					/* animate_tile_proc */
 
	TileLoop_Road,						/* tile_loop_clear */
 
	ChangeTileOwner_Road,			/* change_tile_owner_clear */
 
	NULL,											/* get_produced_cargo_proc */
 
	VehicleEnter_Road,				/* vehicle_enter_tile_proc */
 
	VehicleLeave_Road,				/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Road,				/* get_slope_tileh_proc */
 
};
station_cmd.c
Show inline comments
 
@@ -1775,12 +1775,17 @@ static uint GetSlopeZ_Station(TileInfo *
 
	uint z = ti->z;
 
	if (ti->tileh != 0)
 
		z += 8;
 
	return z;
 
}
 

	
 
static uint GetSlopeTileh_Station(TileInfo *ti)
 
{
 
	return 0;
 
}
 

	
 
static void GetAcceptedCargo_Station(uint tile, AcceptedCargo *ac)
 
{
 
	/* not used */
 
}
 

	
 
static void GetTileDesc_Station(uint tile, TileDesc *td)
 
@@ -2448,12 +2453,13 @@ const TileTypeProcs _tile_type_station_p
 
	AnimateTile_Station,				/* animate_tile_proc */
 
	TileLoop_Station,						/* tile_loop_clear */
 
	ChangeTileOwner_Station,		/* change_tile_owner_clear */
 
	NULL,												/* get_produced_cargo_proc */
 
	VehicleEnter_Station,				/* vehicle_enter_tile_proc */
 
	NULL,												/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Station,			/* get_slope_tileh_proc */
 
};
 

	
 

	
 
static const byte _station_desc[] = {
 
	SLE_VAR(Station,xy,							SLE_UINT16),
 
	SLE_VAR(Station,bus_tile,				SLE_UINT16),
town_cmd.c
Show inline comments
 
@@ -100,12 +100,17 @@ static uint GetSlopeZ_Town(TileInfo *ti)
 
{
 
	uint z = GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 
	if (ti->tileh != 0) z = (z & ~7) + 4;
 
	return (uint16) z;	
 
}
 

	
 
static uint GetSlopeTileh_Town(TileInfo *ti)
 
{
 
	return ti->tileh;
 
}
 

	
 
static void AnimateTile_Town(uint tile)
 
{
 
	int old;
 
	int i;
 
	int a,b;
 

	
 
@@ -1769,12 +1774,13 @@ const TileTypeProcs _tile_type_town_proc
 
	AnimateTile_Town,					/* animate_tile_proc */
 
	TileLoop_Town,						/* tile_loop_clear */
 
	ChangeTileOwner_Town,			/* change_tile_owner_clear */
 
	NULL,											/* get_produced_cargo_proc */
 
	NULL,											/* vehicle_enter_tile_proc */
 
	NULL,											/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Town,				/* get_slope_tileh_proc */
 
};
 

	
 

	
 
// Save and load of towns.
 
static const byte _town_desc[] = {
 
	SLE_VAR(Town,xy,					SLE_UINT16),
tree_cmd.c
Show inline comments
 
@@ -329,12 +329,16 @@ static void DrawTile_Trees(TileInfo *ti)
 

	
 

	
 
static uint GetSlopeZ_Trees(TileInfo *ti) {
 
	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 
}
 

	
 
static uint GetSlopeTileh_Trees(TileInfo *ti) {
 
	return ti->tileh;
 
}
 

	
 
static int32 ClearTile_Trees(uint tile, byte flags) {
 
	int num;
 

	
 
	if (flags & DC_EXEC && _current_player < MAX_PLAYERS) {
 
		Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
 
		if (t != NULL) 
 
@@ -641,7 +645,8 @@ const TileTypeProcs _tile_type_trees_pro
 
	AnimateTile_Trees,				/* animate_tile_proc */
 
	TileLoop_Trees,						/* tile_loop_clear */
 
	ChangeTileOwner_Trees,		/* change_tile_owner_clear */
 
	NULL,											/* get_produced_cargo_proc */
 
	NULL,											/* vehicle_enter_tile_proc */
 
	NULL,											/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Trees,			/* get_slope_tileh_proc */
 
};
ttd.h
Show inline comments
 
@@ -239,12 +239,13 @@ typedef void ChangeTileOwnerProc(uint ti
 
/* Return value has bit 0x2 set, when the vehicle enters a station. Then,
 
 * result << 8 contains the id of the station entered. If the return value has
 
 * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
 
 * other bits that can be set? */
 
typedef uint32 VehicleEnterTileProc(Vehicle *v, uint tile, int x, int y);
 
typedef void VehicleLeaveTileProc(Vehicle *v, uint tile, int x, int y);
 
typedef uint GetSlopeTilehProc(TileInfo *ti);
 

	
 
typedef struct {
 
	DrawTileProc *draw_tile_proc;
 
	GetSlopeZProc *get_slope_z_proc;
 
	ClearTileProc *clear_tile_proc;
 
	GetAcceptedCargoProc *get_accepted_cargo_proc;
 
@@ -254,12 +255,13 @@ typedef struct {
 
	AnimateTileProc *animate_tile_proc;
 
	TileLoopProc *tile_loop_proc;
 
	ChangeTileOwnerProc *change_tile_owner_proc;
 
	GetProducedCargoProc *get_produced_cargo_proc;
 
	VehicleEnterTileProc *vehicle_enter_tile_proc;
 
	VehicleLeaveTileProc *vehicle_leave_tile_proc;
 
	GetSlopeTilehProc *get_slope_tileh_proc;
 
} TileTypeProcs;
 

	
 

	
 

	
 
#define MP_SETTYPE(x) ((x+1) << 8)
 

	
tunnelbridge_cmd.c
Show inline comments
 
@@ -1195,12 +1195,18 @@ static uint GetSlopeZ_TunnelBridge(TileI
 

	
 
	// default case
 
	z = ti->z;
 
	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + z;
 
}
 

	
 
static uint GetSlopeTileh_TunnelBridge(TileInfo *ti) {
 
	// not accurate, but good enough for slope graphics drawing
 
	return 0;
 
}
 

	
 

	
 
static void GetAcceptedCargo_TunnelBridge(uint tile, AcceptedCargo *ac)
 
{
 
	/* not used */
 
}
 

	
 
static const StringID _bridge_tile_str[(MAX_BRIDGES + 3) + (MAX_BRIDGES + 3)] = {
 
@@ -1475,7 +1481,8 @@ const TileTypeProcs _tile_type_tunnelbri
 
	AnimateTile_TunnelBridge,				/* animate_tile_proc */
 
	TileLoop_TunnelBridge,					/* tile_loop_clear */
 
	ChangeTileOwner_TunnelBridge,		/* change_tile_owner_clear */
 
	NULL,														/* get_produced_cargo_proc */
 
	VehicleEnter_TunnelBridge,			/* vehicle_enter_tile_proc */
 
	NULL,														/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_TunnelBridge,			/* get_slope_tileh_proc */
 
};
unmovable_cmd.c
Show inline comments
 
@@ -103,12 +103,17 @@ static void DrawTile_Unmovable(TileInfo 
 

	
 
static uint GetSlopeZ_Unmovable(TileInfo *ti) 
 
{
 
	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 
}
 

	
 
static uint GetSlopeTileh_Unmovable(TileInfo *ti) 
 
{
 
	return 0;
 
}
 

	
 
static int32 ClearTile_Unmovable(uint tile, byte flags)
 
{
 
	byte m5 = _map5[tile];
 
	//Town *t;
 
		
 
	if (m5 & 0x80)
 
@@ -383,7 +388,8 @@ const TileTypeProcs _tile_type_unmovable
 
	AnimateTile_Unmovable,				/* animate_tile_proc */
 
	TileLoop_Unmovable,						/* tile_loop_clear */
 
	ChangeTileOwner_Unmovable,		/* change_tile_owner_clear */
 
	NULL,													/* get_produced_cargo_proc */
 
	NULL,													/* vehicle_enter_tile_proc */
 
	NULL,													/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Unmovable,			/* get_slope_tileh_proc */
 
};
water_cmd.c
Show inline comments
 
@@ -438,12 +438,17 @@ void DrawShipDepotSprite(int x, int y, i
 

	
 
uint GetSlopeZ_Water(TileInfo *ti)
 
{ 
 
	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 
}
 

	
 
uint GetSlopeTileh_Water(TileInfo *ti)
 
{ 
 
	return ti->tileh;
 
}
 

	
 
static void GetAcceptedCargo_Water(uint tile, AcceptedCargo *ac)
 
{
 
	/* not used */
 
}
 

	
 
static void GetTileDesc_Water(uint tile, TileDesc *td)
 
@@ -605,8 +610,9 @@ const TileTypeProcs _tile_type_water_pro
 
	AnimateTile_Water,				/* animate_tile_proc */
 
	TileLoop_Water,						/* tile_loop_clear */
 
	ChangeTileOwner_Water,		/* change_tile_owner_clear */
 
	NULL,											/* get_produced_cargo_proc */
 
	VehicleEnter_Water,				/* vehicle_enter_tile_proc */
 
	NULL,											/* vehicle_leave_tile_proc */
 
	GetSlopeTileh_Water,			/* get_slope_tileh_proc */
 
};
 

	
0 comments (0 inline, 0 general)