(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo

This commit is contained in:
tron 2006-08-06 16:32:49 +00:00
parent 7c9165827e
commit 3254155930
14 changed files with 61 additions and 49 deletions

View File

@ -534,9 +534,12 @@ static void DrawTile_Clear(TileInfo *ti)
DrawClearLandFence(ti);
}
static uint GetSlopeZ_Clear(const TileInfo* ti)
static uint GetSlopeZ_Clear(TileIndex tile, uint x, uint y)
{
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
uint z;
uint tileh = GetTileSlope(tile, &z);
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
}
static Slope GetSlopeTileh_Clear(TileIndex tile, Slope tileh)

View File

@ -14,7 +14,7 @@ static void DrawTile_Dummy(TileInfo *ti)
}
static uint GetSlopeZ_Dummy(const TileInfo* ti)
static uint GetSlopeZ_Dummy(TileIndex tile, uint x, uint y)
{
return 0;
}

View File

@ -267,9 +267,9 @@ static void DrawTile_Industry(TileInfo *ti)
}
}
static uint GetSlopeZ_Industry(const TileInfo *ti)
static uint GetSlopeZ_Industry(TileIndex tile, uint x, uint y)
{
return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
return GetTileMaxZ(tile);
}
static Slope GetSlopeTileh_Industry(TileIndex tile, Slope tileh)

View File

@ -174,11 +174,9 @@ uint GetPartialZ(int x, int y, Slope corners)
uint GetSlopeZ(int x, int y)
{
TileInfo ti;
TileIndex tile = TileVirtXY(x, y);
FindLandscapeHeight(&ti, x, y);
return _tile_type_procs[ti.type]->get_slope_z_proc(&ti);
return _tile_type_procs[GetTileType(tile)]->get_slope_z_proc(tile, x, y);
}

View File

@ -298,7 +298,7 @@ typedef struct {
typedef void DrawTileProc(TileInfo *ti);
typedef uint GetSlopeZProc(const TileInfo* ti);
typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
typedef int32 ClearTileProc(TileIndex tile, byte flags);
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);

View File

@ -1692,20 +1692,20 @@ void SetSignalsOnBothDir(TileIndex tile, byte track)
UpdateSignalsOnSegment(tile, _search_dir_2[track]);
}
static uint GetSlopeZ_Track(const TileInfo* ti)
static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y)
{
Slope tileh = ti->tileh;
uint z = ti->z;
uint z;
Slope tileh = GetTileSlope(tile, &z);
if (tileh == SLOPE_FLAT) return z;
if (IsPlainRailTile(ti->tile)) {
uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile));
if (IsPlainRailTile(tile)) {
uint f = GetRailFoundation(tileh, GetTrackBits(tile));
if (f != 0) {
if (f < 15) return z + TILE_HEIGHT; // leveled foundation
tileh = _inclined_tileh[f - 15]; // inclined foundation
}
return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh);
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
} else {
return z + TILE_HEIGHT;
}

View File

@ -833,20 +833,20 @@ void DrawRoadDepotSprite(int x, int y, DiagDirection dir)
}
}
static uint GetSlopeZ_Road(const TileInfo* ti)
static uint GetSlopeZ_Road(TileIndex tile, uint x, uint y)
{
Slope tileh = ti->tileh;
uint z = ti->z;
uint z;
Slope tileh = GetTileSlope(tile, &z);
if (tileh == SLOPE_FLAT) return z;
if (GetRoadTileType(ti->tile) == ROAD_TILE_NORMAL) {
uint f = GetRoadFoundation(tileh, GetRoadBits(ti->tile));
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
uint f = GetRoadFoundation(tileh, GetRoadBits(tile));
if (f != 0) {
if (f < 15) return z + TILE_HEIGHT; // leveled foundation
tileh = _inclined_tileh[f - 15]; // inclined foundation
}
return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh);
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
} else {
return z + TILE_HEIGHT;
}

View File

@ -2152,9 +2152,9 @@ void StationPickerDrawSprite(int x, int y, RailType railtype, int image)
}
}
static uint GetSlopeZ_Station(const TileInfo* ti)
static uint GetSlopeZ_Station(TileIndex tile, uint x, uint y)
{
return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
return GetTileMaxZ(tile);
}
static Slope GetSlopeTileh_Station(TileIndex tile, Slope tileh)

View File

@ -110,9 +110,9 @@ static void DrawTile_Town(TileInfo *ti)
}
}
static uint GetSlopeZ_Town(const TileInfo* ti)
static uint GetSlopeZ_Town(TileIndex tile, uint x, uint y)
{
return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
return GetTileMaxZ(tile);
}
static Slope GetSlopeTileh_Town(TileIndex tile, Slope tileh)

View File

@ -323,9 +323,12 @@ static void DrawTile_Trees(TileInfo *ti)
}
static uint GetSlopeZ_Trees(const TileInfo* ti)
static uint GetSlopeZ_Trees(TileIndex tile, uint x, uint y)
{
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
uint z;
uint tileh = GetTileSlope(tile, &z);
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
}
static Slope GetSlopeTileh_Trees(TileIndex tile, Slope tileh)

View File

@ -1089,13 +1089,13 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
}
}
static uint GetSlopeZ_TunnelBridge(const TileInfo* ti)
static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y)
{
TileIndex tile = ti->tile;
uint z = ti->z;
uint x = ti->x & 0xF;
uint y = ti->y & 0xF;
Slope tileh = ti->tileh;
uint z;
Slope tileh = GetTileSlope(tile, &z);
x &= 0xF;
y &= 0xF;
if (IsTunnel(tile)) {
uint pos = (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? y : x);

View File

@ -176,12 +176,15 @@ static void DrawTile_Unmovable(TileInfo *ti)
}
}
static uint GetSlopeZ_Unmovable(const TileInfo* ti)
static uint GetSlopeZ_Unmovable(TileIndex tile, uint x, uint y)
{
if (IsOwnedLand(ti->tile)) {
return ti->z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh);
if (IsOwnedLand(tile)) {
uint z;
uint tileh = GetTileSlope(tile, &z);
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
} else {
return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
return GetTileMaxZ(tile);
}
}

View File

@ -294,7 +294,6 @@ ViewPort *IsPtInWindowViewport(const Window *w, int x, int y)
static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
{
int z;
Point pt;
int a,b;
@ -314,16 +313,19 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
a = x+y;
b = x-y;
#endif
z = GetSlopeZ(a, b) >> 1;
z = GetSlopeZ(a+z, b+z) >> 1;
z = GetSlopeZ(a+z, b+z) >> 1;
z = GetSlopeZ(a+z, b+z) >> 1;
z = GetSlopeZ(a+z, b+z) >> 1;
pt.x = a+z;
pt.y = b+z;
if ((uint)a < MapMaxX() * TILE_SIZE && (uint)b < MapMaxY() * TILE_SIZE) {
uint z;
if ((uint)pt.x >= MapMaxX() * TILE_SIZE || (uint)pt.y >= MapMaxY() * TILE_SIZE) {
z = GetSlopeZ(a, b ) / 2;
z = GetSlopeZ(a + z, b + z) / 2;
z = GetSlopeZ(a + z, b + z) / 2;
z = GetSlopeZ(a + z, b + z) / 2;
z = GetSlopeZ(a + z, b + z) / 2;
pt.x = a + z;
pt.y = b + z;
} else {
pt.x = pt.y = -1;
}

View File

@ -479,9 +479,12 @@ void DrawShipDepotSprite(int x, int y, int image)
}
static uint GetSlopeZ_Water(const TileInfo *ti)
static uint GetSlopeZ_Water(TileIndex tile, uint x, uint y)
{
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
uint z;
uint tileh = GetTileSlope(tile, &z);
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
}
static Slope GetSlopeTileh_Water(TileIndex tile, Slope tileh)