(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
authortron
Sun, 02 Apr 2006 12:49:18 +0000
changeset 3418 a592d40a4d04
parent 3417 c867f87873ae
child 3419 47f71d6e9a09
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
clear_cmd.c
dummy_land.c
industry_cmd.c
landscape.c
openttd.h
rail_cmd.c
road_cmd.c
station_cmd.c
town_cmd.c
tree_cmd.c
tunnelbridge_cmd.c
unmovable_cmd.c
water_cmd.c
--- a/clear_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/clear_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -518,9 +518,9 @@
 	return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Clear(const TileInfo *ti)
+static uint GetSlopeTileh_Clear(TileIndex tile, uint tileh)
 {
-	return ti->tileh;
+	return tileh;
 }
 
 static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac)
--- a/dummy_land.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/dummy_land.c	Sun Apr 02 12:49:18 2006 +0000
@@ -19,7 +19,7 @@
 	return 0;
 }
 
-static uint GetSlopeTileh_Dummy(const TileInfo* ti)
+static uint GetSlopeTileh_Dummy(TileIndex tile, uint tileh)
 {
 	return 0;
 }
--- a/industry_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/industry_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -404,7 +404,7 @@
 	return ti->z + (ti->tileh == 0 ? 0 : 8);
 }
 
-static uint GetSlopeTileh_Industry(const TileInfo* ti)
+static uint GetSlopeTileh_Industry(TileIndex tile, uint tileh)
 {
 	return 0;
 }
--- a/landscape.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/landscape.c	Sun Apr 02 12:49:18 2006 +0000
@@ -183,11 +183,11 @@
 
 // direction=true:  check for foundation in east and south corner
 // direction=false: check for foundation in west and south corner
-static bool hasFoundation(const TileInfo* ti, bool direction)
+static bool HasFoundation(TileIndex tile, bool direction)
 {
 	bool south, other; // southern corner and east/west corner
-	uint slope = _tile_type_procs[ti->type]->get_slope_tileh_proc(ti);
-	uint tileh = ti->tileh;
+	uint tileh = GetTileSlope(tile, NULL);
+	uint slope = _tile_type_procs[GetTileType(tile)]->get_slope_tileh_proc(tile, tileh);
 
 	if (slope == 0 && slope != tileh) tileh = 15;
 	south = (tileh & 2) != (slope & 2);
@@ -204,11 +204,8 @@
 {
 	uint32 sprite_base = SPR_SLOPES_BASE-14;
 
-	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 (HasFoundation(TILE_ADDXY(ti->tile, 0, -1), true)) sprite_base += 22; // foundation in NW direction
+	if (HasFoundation(TILE_ADDXY(ti->tile, -1, 0), false)) sprite_base += 44; // foundation in NE direction
 
 	if (f < 15) {
 		// leveled foundation
--- a/openttd.h	Sun Apr 02 12:41:01 2006 +0000
+++ b/openttd.h	Sun Apr 02 12:49:18 2006 +0000
@@ -333,7 +333,7 @@
  * other bits that can be set? */
 typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
 typedef void VehicleLeaveTileProc(Vehicle *v, TileIndex tile, int x, int y);
-typedef uint GetSlopeTilehProc(const TileInfo *ti);
+typedef uint GetSlopeTilehProc(TileIndex, uint tileh);
 
 typedef struct {
 	DrawTileProc *draw_tile_proc;
--- a/rail_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/rail_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -1770,15 +1770,15 @@
 	}
 }
 
-static uint GetSlopeTileh_Track(const TileInfo *ti)
+static uint GetSlopeTileh_Track(TileIndex tile, uint tileh)
 {
-	if (ti->tileh == 0) return ti->tileh;
-	if (GetRailTileType(ti->tile) == RAIL_TYPE_DEPOT_WAYPOINT) {
+	if (tileh == 0) return 0;
+	if (GetRailTileType(tile) == RAIL_TYPE_DEPOT_WAYPOINT) {
 		return 0;
 	} else {
-		uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile));
+		uint f = GetRailFoundation(tileh, GetTrackBits(tile));
 
-		if (f == 0) return ti->tileh;
+		if (f == 0) return tileh;
 		if (f < 15) return 0; // leveled foundation
 		return _inclined_tileh[f - 15]; // inclined foundation
 	}
--- a/road_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/road_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -863,13 +863,13 @@
 	}
 }
 
-static uint GetSlopeTileh_Road(const TileInfo *ti)
+static uint GetSlopeTileh_Road(TileIndex tile, uint tileh)
 {
-	if (ti->tileh == 0) return ti->tileh;
-	if (GetRoadType(ti->tile) == ROAD_NORMAL) {
-		uint f = GetRoadFoundation(ti->tileh, GetRoadBits(ti->tile));
+	if (tileh == 0) return 0;
+	if (GetRoadType(tile) == ROAD_NORMAL) {
+		uint f = GetRoadFoundation(tileh, GetRoadBits(tile));
 
-		if (f == 0) return ti->tileh;
+		if (f == 0) return tileh;
 		if (f < 15) return 0; // leveled foundation
 		return _inclined_tileh[f - 15]; // inclined foundation
 	} else {
--- a/station_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/station_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -1999,7 +1999,7 @@
 	return ti->z + (ti->tileh == 0 ? 0 : 8);
 }
 
-static uint GetSlopeTileh_Station(const TileInfo *ti)
+static uint GetSlopeTileh_Station(TileIndex tile, uint tileh)
 {
 	return 0;
 }
--- a/town_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/town_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -150,7 +150,7 @@
 	return ti->z + (ti->tileh == 0 ? 0 : 8);
 }
 
-static uint GetSlopeTileh_Town(const TileInfo *ti)
+static uint GetSlopeTileh_Town(TileIndex tile, uint tileh)
 {
 	return 0;
 }
--- a/tree_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/tree_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -326,9 +326,9 @@
 	return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Trees(const TileInfo* ti)
+static uint GetSlopeTileh_Trees(TileIndex tile, uint tileh)
 {
-	return ti->tileh;
+	return tileh;
 }
 
 static int32 ClearTile_Trees(TileIndex tile, byte flags)
--- a/tunnelbridge_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/tunnelbridge_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -1143,7 +1143,7 @@
 	return GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_TunnelBridge(const TileInfo* ti)
+static uint GetSlopeTileh_TunnelBridge(TileIndex tile, uint tileh)
 {
 	// not accurate, but good enough for slope graphics drawing
 	return 0;
--- a/unmovable_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/unmovable_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -212,9 +212,9 @@
 	}
 }
 
-static uint GetSlopeTileh_Unmovable(const TileInfo *ti)
+static uint GetSlopeTileh_Unmovable(TileIndex tile, uint tileh)
 {
-	return IsOwnedLand(ti->tile) ? ti->tileh : 0;
+	return IsOwnedLand(tile) ? tileh : 0;
 }
 
 static int32 ClearTile_Unmovable(TileIndex tile, byte flags)
--- a/water_cmd.c	Sun Apr 02 12:41:01 2006 +0000
+++ b/water_cmd.c	Sun Apr 02 12:49:18 2006 +0000
@@ -446,9 +446,9 @@
 	return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Water(const TileInfo *ti)
+static uint GetSlopeTileh_Water(TileIndex tile, uint tileh)
 {
-	return ti->tileh;
+	return tileh;
 }
 
 static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac)