mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
This commit is contained in:
parent
7c9165827e
commit
3254155930
|
@ -534,9 +534,12 @@ static void DrawTile_Clear(TileInfo *ti)
|
||||||
DrawClearLandFence(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)
|
static Slope GetSlopeTileh_Clear(TileIndex tile, Slope tileh)
|
||||||
|
|
|
@ -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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
static Slope GetSlopeTileh_Industry(TileIndex tile, Slope tileh)
|
||||||
|
|
|
@ -174,11 +174,9 @@ uint GetPartialZ(int x, int y, Slope corners)
|
||||||
|
|
||||||
uint GetSlopeZ(int x, int y)
|
uint GetSlopeZ(int x, int y)
|
||||||
{
|
{
|
||||||
TileInfo ti;
|
TileIndex tile = TileVirtXY(x, y);
|
||||||
|
|
||||||
FindLandscapeHeight(&ti, x, y);
|
return _tile_type_procs[GetTileType(tile)]->get_slope_z_proc(tile, x, y);
|
||||||
|
|
||||||
return _tile_type_procs[ti.type]->get_slope_z_proc(&ti);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,7 @@ typedef struct {
|
||||||
|
|
||||||
|
|
||||||
typedef void DrawTileProc(TileInfo *ti);
|
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 int32 ClearTileProc(TileIndex tile, byte flags);
|
||||||
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
|
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
|
||||||
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
|
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
|
||||||
|
|
12
rail_cmd.c
12
rail_cmd.c
|
@ -1692,20 +1692,20 @@ void SetSignalsOnBothDir(TileIndex tile, byte track)
|
||||||
UpdateSignalsOnSegment(tile, _search_dir_2[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;
|
||||||
uint z = ti->z;
|
Slope tileh = GetTileSlope(tile, &z);
|
||||||
|
|
||||||
if (tileh == SLOPE_FLAT) return z;
|
if (tileh == SLOPE_FLAT) return z;
|
||||||
if (IsPlainRailTile(ti->tile)) {
|
if (IsPlainRailTile(tile)) {
|
||||||
uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile));
|
uint f = GetRailFoundation(tileh, GetTrackBits(tile));
|
||||||
|
|
||||||
if (f != 0) {
|
if (f != 0) {
|
||||||
if (f < 15) return z + TILE_HEIGHT; // leveled foundation
|
if (f < 15) return z + TILE_HEIGHT; // leveled foundation
|
||||||
tileh = _inclined_tileh[f - 15]; // inclined 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 {
|
} else {
|
||||||
return z + TILE_HEIGHT;
|
return z + TILE_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
12
road_cmd.c
12
road_cmd.c
|
@ -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;
|
||||||
uint z = ti->z;
|
Slope tileh = GetTileSlope(tile, &z);
|
||||||
|
|
||||||
if (tileh == SLOPE_FLAT) return z;
|
if (tileh == SLOPE_FLAT) return z;
|
||||||
if (GetRoadTileType(ti->tile) == ROAD_TILE_NORMAL) {
|
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
|
||||||
uint f = GetRoadFoundation(tileh, GetRoadBits(ti->tile));
|
uint f = GetRoadFoundation(tileh, GetRoadBits(tile));
|
||||||
|
|
||||||
if (f != 0) {
|
if (f != 0) {
|
||||||
if (f < 15) return z + TILE_HEIGHT; // leveled foundation
|
if (f < 15) return z + TILE_HEIGHT; // leveled foundation
|
||||||
tileh = _inclined_tileh[f - 15]; // inclined 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 {
|
} else {
|
||||||
return z + TILE_HEIGHT;
|
return z + TILE_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
static Slope GetSlopeTileh_Station(TileIndex tile, Slope tileh)
|
||||||
|
|
|
@ -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)
|
static Slope GetSlopeTileh_Town(TileIndex tile, Slope tileh)
|
||||||
|
|
|
@ -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)
|
static Slope GetSlopeTileh_Trees(TileIndex tile, Slope tileh)
|
||||||
|
|
|
@ -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;
|
||||||
uint z = ti->z;
|
Slope tileh = GetTileSlope(tile, &z);
|
||||||
uint x = ti->x & 0xF;
|
|
||||||
uint y = ti->y & 0xF;
|
x &= 0xF;
|
||||||
Slope tileh = ti->tileh;
|
y &= 0xF;
|
||||||
|
|
||||||
if (IsTunnel(tile)) {
|
if (IsTunnel(tile)) {
|
||||||
uint pos = (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? y : x);
|
uint pos = (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? y : x);
|
||||||
|
|
|
@ -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)) {
|
if (IsOwnedLand(tile)) {
|
||||||
return ti->z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh);
|
uint z;
|
||||||
|
uint tileh = GetTileSlope(tile, &z);
|
||||||
|
|
||||||
|
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
|
||||||
} else {
|
} else {
|
||||||
return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
|
return GetTileMaxZ(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
viewport.c
20
viewport.c
|
@ -294,7 +294,6 @@ ViewPort *IsPtInWindowViewport(const Window *w, int x, int y)
|
||||||
|
|
||||||
static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
|
static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
int z;
|
|
||||||
Point pt;
|
Point pt;
|
||||||
int a,b;
|
int a,b;
|
||||||
|
|
||||||
|
@ -314,16 +313,19 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
|
||||||
a = x+y;
|
a = x+y;
|
||||||
b = x-y;
|
b = x-y;
|
||||||
#endif
|
#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;
|
if ((uint)a < MapMaxX() * TILE_SIZE && (uint)b < MapMaxY() * TILE_SIZE) {
|
||||||
pt.y = b+z;
|
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;
|
pt.x = pt.y = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
static Slope GetSlopeTileh_Water(TileIndex tile, Slope tileh)
|
||||||
|
|
Loading…
Reference in New Issue