mirror of https://github.com/OpenTTD/OpenTTD
(svn r23106) -Codechange: pass int* to GetTileSlope and friends
parent
643c54d288
commit
19eabdba2c
|
@ -170,7 +170,7 @@
|
|||
{
|
||||
if (!::IsValidTile(tile) || !::IsValidCorner((::Corner)corner)) return -1;
|
||||
|
||||
uint z;
|
||||
int z;
|
||||
::Slope slope = ::GetTileSlope(tile, &z);
|
||||
return (z + ::GetSlopeZInCorner(slope, (::Corner)corner));
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
/* If it's a tunnel already, take the easy way out! */
|
||||
if (IsTunnelTile(tile)) return ::GetOtherTunnelEnd(tile);
|
||||
|
||||
uint start_z;
|
||||
int start_z;
|
||||
Slope start_tileh = ::GetTileSlope(tile, &start_z);
|
||||
DiagDirection direction = ::GetInclinedSlopeDirection(start_tileh);
|
||||
if (direction == INVALID_DIAGDIR) return INVALID_TILE;
|
||||
|
||||
TileIndexDiff delta = ::TileOffsByDiagDir(direction);
|
||||
uint end_z;
|
||||
int end_z;
|
||||
do {
|
||||
tile += delta;
|
||||
if (!::IsValidTile(tile)) return INVALID_TILE;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* @param entrance Entrance edge.
|
||||
* @return true iff terraforming is allowed.
|
||||
*/
|
||||
static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance)
|
||||
static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
|
||||
{
|
||||
if (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new)) return false;
|
||||
return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
|
||||
|
|
|
@ -67,9 +67,9 @@ TileIndex GetOtherBridgeEnd(TileIndex tile)
|
|||
* @param tile the bridge ramp tile to get the bridge height from
|
||||
* @return the height of the bridge.
|
||||
*/
|
||||
uint GetBridgeHeight(TileIndex t)
|
||||
int GetBridgeHeight(TileIndex t)
|
||||
{
|
||||
uint h;
|
||||
int h;
|
||||
Slope tileh = GetTileSlope(t, &h);
|
||||
Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
|
||||
|
||||
|
|
|
@ -89,13 +89,13 @@ TileIndex GetNorthernBridgeEnd(TileIndex t);
|
|||
TileIndex GetSouthernBridgeEnd(TileIndex t);
|
||||
TileIndex GetOtherBridgeEnd(TileIndex t);
|
||||
|
||||
uint GetBridgeHeight(TileIndex tile);
|
||||
int GetBridgeHeight(TileIndex tile);
|
||||
/**
|
||||
* Get the height ('z') of a bridge in pixels.
|
||||
* @param tile the bridge ramp tile to get the bridge height from
|
||||
* @return the height of the bridge in pixels
|
||||
*/
|
||||
static inline uint GetBridgePixelHeight(TileIndex tile)
|
||||
static inline int GetBridgePixelHeight(TileIndex tile)
|
||||
{
|
||||
return GetBridgeHeight(tile) * TILE_HEIGHT;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ static void DrawTile_Clear(TileInfo *ti)
|
|||
|
||||
static uint GetSlopePixelZ_Clear(TileIndex tile, uint x, uint y)
|
||||
{
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
|
||||
return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
|
||||
|
@ -230,7 +230,7 @@ static void TileLoop_Clear(TileIndex tile)
|
|||
{
|
||||
/* If the tile is at any edge flood it to prevent maps without water. */
|
||||
if (_settings_game.construction.freeform_edges && DistanceFromEdge(tile) == 1) {
|
||||
uint z;
|
||||
int z;
|
||||
Slope slope = GetTileSlope(tile, &z);
|
||||
if (z == 0 && slope == SLOPE_FLAT) {
|
||||
DoFloodTile(tile);
|
||||
|
|
|
@ -59,7 +59,7 @@ void CcBuildCanal(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p
|
|||
*/
|
||||
static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to = NULL)
|
||||
{
|
||||
uint z;
|
||||
int z;
|
||||
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, &z));
|
||||
|
||||
/* If the direction isn't right, just return the next tile so the command
|
||||
|
|
|
@ -401,7 +401,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
|||
|
||||
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) {
|
||||
Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y;
|
||||
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
|
||||
if ((height <= GetTileMaxZ(ti->tile) + 1) &&
|
||||
(i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) {
|
||||
|
@ -438,7 +438,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
|||
|
||||
/* Don't draw a wire under a low bridge */
|
||||
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
|
||||
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
|
||||
if (height <= GetTileMaxZ(ti->tile) + 1) return;
|
||||
}
|
||||
|
|
|
@ -1165,7 +1165,7 @@ static CommandCost CheckNewIndustry_NULL(TileIndex tile)
|
|||
static CommandCost CheckNewIndustry_Forest(TileIndex tile)
|
||||
{
|
||||
if (_settings_game.game_creation.landscape == LT_ARCTIC) {
|
||||
if (GetTileZ(tile) < HighestSnowLine() + 2U) {
|
||||
if (GetTileZ(tile) < HighestSnowLine() + 2) {
|
||||
return_cmd_error(STR_ERROR_FOREST_CAN_ONLY_BE_PLANTED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
|
|||
* @param z returns the z of the foundation slope. (Can be NULL, if not needed)
|
||||
* @return The slope on top of the foundation.
|
||||
*/
|
||||
Slope GetFoundationSlope(TileIndex tile, uint *z)
|
||||
Slope GetFoundationSlope(TileIndex tile, int *z)
|
||||
{
|
||||
Slope tileh = GetTileSlope(tile, z);
|
||||
Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh);
|
||||
|
@ -349,7 +349,7 @@ Slope GetFoundationSlope(TileIndex tile, uint *z)
|
|||
|
||||
bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here)
|
||||
{
|
||||
uint z;
|
||||
int z;
|
||||
|
||||
int z_W_here = z_here;
|
||||
int z_N_here = z_here;
|
||||
|
@ -366,7 +366,7 @@ bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here)
|
|||
|
||||
bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here)
|
||||
{
|
||||
uint z;
|
||||
int z;
|
||||
|
||||
int z_E_here = z_here;
|
||||
int z_N_here = z_here;
|
||||
|
@ -393,7 +393,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
|
|||
assert(f != FOUNDATION_STEEP_BOTH);
|
||||
|
||||
uint sprite_block = 0;
|
||||
uint z;
|
||||
int z;
|
||||
Slope slope = GetFoundationPixelSlope(ti->tile, &z);
|
||||
|
||||
/* Select the needed block of foundations sprites
|
||||
|
@ -926,7 +926,7 @@ static void CreateDesertOrRainForest()
|
|||
*/
|
||||
static bool FindSpring(TileIndex tile, void *user_data)
|
||||
{
|
||||
uint referenceHeight;
|
||||
int referenceHeight;
|
||||
Slope s = GetTileSlope(tile, &referenceHeight);
|
||||
if (s != SLOPE_FLAT || IsWaterTile(tile)) return false;
|
||||
|
||||
|
@ -988,8 +988,8 @@ static bool FlowsDown(TileIndex begin, TileIndex end)
|
|||
{
|
||||
assert(DistanceManhattan(begin, end) == 1);
|
||||
|
||||
uint heightBegin;
|
||||
uint heightEnd;
|
||||
int heightBegin;
|
||||
int heightEnd;
|
||||
Slope slopeBegin = GetTileSlope(begin, &heightBegin);
|
||||
Slope slopeEnd = GetTileSlope(end, &heightEnd);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ byte LowestSnowLine();
|
|||
void ClearSnowLine();
|
||||
|
||||
int GetSlopeZInCorner(Slope tileh, Corner corner);
|
||||
Slope GetFoundationSlope(TileIndex tile, uint *z = NULL);
|
||||
Slope GetFoundationSlope(TileIndex tile, int *z = NULL);
|
||||
|
||||
uint GetPartialPixelZ(int x, int y, Slope corners);
|
||||
int GetSlopePixelZ(int x, int y);
|
||||
|
@ -64,7 +64,7 @@ static inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
|
|||
* @param z returns the z of the foundation slope. (Can be NULL, if not needed)
|
||||
* @return The slope on top of the foundation.
|
||||
*/
|
||||
static inline Slope GetFoundationPixelSlope(TileIndex tile, uint *z)
|
||||
static inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
|
||||
{
|
||||
assert(z != NULL);
|
||||
Slope s = GetFoundationSlope(tile, z);
|
||||
|
|
|
@ -447,7 +447,7 @@ uint32 GetNearbyTileInformation(TileIndex tile)
|
|||
/* Fake tile type for trees on shore */
|
||||
if (IsTileType(tile, MP_TREES) && GetTreeGround(tile) == TREE_GROUND_SHORE) tile_type = MP_WATER;
|
||||
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
/* Return 0 if the tile is a land tile */
|
||||
byte terrain_type = (HasTileWaterClass(tile) ? (GetWaterClass(tile) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
|
||||
|
|
|
@ -230,7 +230,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||
|
||||
/* So, now the surface is checked... check the slope of said surface. */
|
||||
int allowed_z;
|
||||
if (GetTileSlope(tile, (uint*)&allowed_z) != SLOPE_FLAT) allowed_z++;
|
||||
if (GetTileSlope(tile, &allowed_z) != SLOPE_FLAT) allowed_z++;
|
||||
|
||||
TILE_AREA_LOOP(t, ta) {
|
||||
uint16 callback = CALLBACK_FAILED;
|
||||
|
@ -384,7 +384,7 @@ static void DrawTile_Object(TileInfo *ti)
|
|||
static uint GetSlopePixelZ_Object(TileIndex tile, uint x, uint y)
|
||||
{
|
||||
if (IsOwnedLand(tile)) {
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
|
||||
return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
|
||||
|
@ -642,7 +642,7 @@ void GenerateObjects()
|
|||
for (uint i = ScaleByMapSize(1000); i != 0 && Object::CanAllocateItem(); i--) {
|
||||
TileIndex tile = RandomTile();
|
||||
|
||||
uint h;
|
||||
int h;
|
||||
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= 4 && !IsBridgeAbove(tile)) {
|
||||
TileIndex t = tile;
|
||||
if (CircularTileSearch(&t, 9, HasTransmitter, NULL)) continue;
|
||||
|
@ -679,7 +679,7 @@ void GenerateObjects()
|
|||
if (!IsTileType(tile, MP_WATER)) continue;
|
||||
|
||||
for (int j = 0; j < 19; j++) {
|
||||
uint h;
|
||||
int h;
|
||||
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h <= 2 && !IsBridgeAbove(tile)) {
|
||||
BuildObject(OBJECT_LIGHTHOUSE, tile);
|
||||
IncreaseGeneratingWorldProgress(GWP_OBJECT);
|
||||
|
|
|
@ -2338,7 +2338,7 @@ void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype)
|
|||
static uint GetSlopePixelZ_Track(TileIndex tile, uint x, uint y)
|
||||
{
|
||||
if (IsPlainRail(tile)) {
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
if (tileh == SLOPE_FLAT) return z;
|
||||
|
||||
|
@ -2366,7 +2366,7 @@ static void TileLoop_Track(TileIndex tile)
|
|||
|
||||
switch (_settings_game.game_creation.landscape) {
|
||||
case LT_ARCTIC: {
|
||||
uint z;
|
||||
int z;
|
||||
Slope slope = GetTileSlope(tile, &z);
|
||||
bool half = false;
|
||||
|
||||
|
@ -2828,7 +2828,7 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_ol
|
|||
|
||||
static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
|
||||
{
|
||||
uint z_old;
|
||||
int z_old;
|
||||
Slope tileh_old = GetTileSlope(tile, &z_old);
|
||||
if (IsPlainRail(tile)) {
|
||||
TrackBits rail_bits = GetTrackBits(tile);
|
||||
|
|
|
@ -1080,7 +1080,7 @@ void DrawTramCatenary(const TileInfo *ti, RoadBits tram)
|
|||
|
||||
/* Don't draw the catenary under a low bridge */
|
||||
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
|
||||
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
|
||||
if (height <= GetTileMaxZ(ti->tile) + 1) return;
|
||||
}
|
||||
|
@ -1187,8 +1187,8 @@ static void DrawRoadBits(TileInfo *ti)
|
|||
|
||||
/* Do not draw details (street lights, trees) under low bridge */
|
||||
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && (roadside == ROADSIDE_TREES || roadside == ROADSIDE_STREET_LIGHTS)) {
|
||||
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
uint minz = GetTileMaxZ(ti->tile) + 2;
|
||||
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
int minz = GetTileMaxZ(ti->tile) + 2;
|
||||
|
||||
if (roadside == ROADSIDE_TREES) minz++;
|
||||
|
||||
|
@ -1341,7 +1341,7 @@ static uint GetSlopePixelZ_Road(TileIndex tile, uint x, uint y)
|
|||
{
|
||||
|
||||
if (IsNormalRoad(tile)) {
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
if (tileh == SLOPE_FLAT) return z;
|
||||
|
||||
|
@ -1696,7 +1696,7 @@ static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlag flags, uint
|
|||
if (CheckRoadSlope(tileh_new, &bits_copy, ROAD_NONE, ROAD_NONE).Succeeded()) {
|
||||
/* CheckRoadSlope() sometimes changes the road_bits, if it does not agree with them. */
|
||||
if (bits == bits_copy) {
|
||||
uint z_old;
|
||||
int z_old;
|
||||
Slope tileh_old = GetTileSlope(tile, &z_old);
|
||||
|
||||
/* Get the slope on top of the foundation */
|
||||
|
|
|
@ -159,7 +159,7 @@ static inline Corner GetHalftileSlopeCorner(Slope s)
|
|||
* @param s The #Slope.
|
||||
* @return Relative height of highest corner.
|
||||
*/
|
||||
static inline uint GetSlopeMaxZ(Slope s)
|
||||
static inline int GetSlopeMaxZ(Slope s)
|
||||
{
|
||||
if (s == SLOPE_FLAT) return 0;
|
||||
if (IsSteepSlope(s)) return 2;
|
||||
|
@ -172,7 +172,7 @@ static inline uint GetSlopeMaxZ(Slope s)
|
|||
* @param s The #Slope.
|
||||
* @return Relative height of highest corner.
|
||||
*/
|
||||
static inline uint GetSlopeMaxPixelZ(Slope s)
|
||||
static inline int GetSlopeMaxPixelZ(Slope s)
|
||||
{
|
||||
return GetSlopeMaxZ(s) * TILE_HEIGHT;
|
||||
}
|
||||
|
|
|
@ -664,7 +664,7 @@ CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z
|
|||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTileSlope(tile, &z);
|
||||
|
||||
/* Prohibit building if
|
||||
|
@ -2584,7 +2584,7 @@ static void DrawTile_Station(TileInfo *ti)
|
|||
/* Station has custom foundations.
|
||||
* Check whether the foundation continues beyond the tile's upper sides. */
|
||||
uint edge_info = 0;
|
||||
uint z;
|
||||
int z;
|
||||
Slope slope = GetFoundationPixelSlope(ti->tile, &z);
|
||||
if (!HasFoundationNW(ti->tile, slope, z)) SetBit(edge_info, 0);
|
||||
if (!HasFoundationNE(ti->tile, slope, z)) SetBit(edge_info, 1);
|
||||
|
|
|
@ -292,14 +292,14 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||
if (IsTileType(tile, MP_VOID)) continue;
|
||||
|
||||
/* Find new heights of tile corners */
|
||||
uint z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
|
||||
uint z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
|
||||
uint z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
|
||||
uint z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
|
||||
int z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
|
||||
int z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
|
||||
int z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
|
||||
int z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
|
||||
|
||||
/* Find min and max height of tile */
|
||||
uint z_min = min(min(z_N, z_W), min(z_S, z_E));
|
||||
uint z_max = max(max(z_N, z_W), max(z_S, z_E));
|
||||
int z_min = min(min(z_N, z_W), min(z_S, z_E));
|
||||
int z_max = max(max(z_N, z_W), max(z_S, z_E));
|
||||
|
||||
/* Compute tile slope */
|
||||
Slope tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT);
|
||||
|
|
|
@ -46,7 +46,7 @@ struct TileInfo {
|
|||
uint y; ///< Y position of the tile in unit coordinates
|
||||
Slope tileh; ///< Slope of the tile
|
||||
TileIndex tile; ///< Tile index
|
||||
uint z; ///< Height
|
||||
int z; ///< Height
|
||||
};
|
||||
|
||||
/** Tile description for the 'land area information' tool */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* @param h If not \c NULL, pointer to storage of z height
|
||||
* @return Slope of the tile, except for the HALFTILE part
|
||||
*/
|
||||
Slope GetTileSlope(TileIndex tile, uint *h)
|
||||
Slope GetTileSlope(TileIndex tile, int *h)
|
||||
{
|
||||
assert(tile < MapSize());
|
||||
|
||||
|
@ -28,13 +28,13 @@ Slope GetTileSlope(TileIndex tile, uint *h)
|
|||
return SLOPE_FLAT;
|
||||
}
|
||||
|
||||
uint a = TileHeight(tile); // Height of the N corner
|
||||
uint min = a; // Minimal height of all corners examined so far
|
||||
uint b = TileHeight(tile + TileDiffXY(1, 0)); // Height of the W corner
|
||||
int a = TileHeight(tile); // Height of the N corner
|
||||
int min = a; // Minimal height of all corners examined so far
|
||||
int b = TileHeight(tile + TileDiffXY(1, 0)); // Height of the W corner
|
||||
if (min > b) min = b;
|
||||
uint c = TileHeight(tile + TileDiffXY(0, 1)); // Height of the E corner
|
||||
int c = TileHeight(tile + TileDiffXY(0, 1)); // Height of the E corner
|
||||
if (min > c) min = c;
|
||||
uint d = TileHeight(tile + TileDiffXY(1, 1)); // Height of the S corner
|
||||
int d = TileHeight(tile + TileDiffXY(1, 1)); // Height of the S corner
|
||||
if (min > d) min = d;
|
||||
|
||||
/* Due to the fact that tiles must connect with each other without leaving gaps, the
|
||||
|
@ -64,11 +64,11 @@ Slope GetTileSlope(TileIndex tile, uint *h)
|
|||
* @param tile Tile to compute height of
|
||||
* @return Minimum height of the tile
|
||||
*/
|
||||
uint GetTileZ(TileIndex tile)
|
||||
int GetTileZ(TileIndex tile)
|
||||
{
|
||||
if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return 0;
|
||||
|
||||
uint h = TileHeight(tile); // N corner
|
||||
int h = TileHeight(tile); // N corner
|
||||
h = min(h, TileHeight(tile + TileDiffXY(1, 0))); // W corner
|
||||
h = min(h, TileHeight(tile + TileDiffXY(0, 1))); // E corner
|
||||
h = min(h, TileHeight(tile + TileDiffXY(1, 1))); // S corner
|
||||
|
@ -81,14 +81,14 @@ uint GetTileZ(TileIndex tile)
|
|||
* @param t Tile to compute height of
|
||||
* @return Maximum height of the tile
|
||||
*/
|
||||
uint GetTileMaxZ(TileIndex t)
|
||||
int GetTileMaxZ(TileIndex t)
|
||||
{
|
||||
if (TileX(t) == MapMaxX() || TileY(t) == MapMaxY()) return 0;
|
||||
|
||||
uint h = TileHeight(t); // N corner
|
||||
h = max(h, TileHeight(t + TileDiffXY(1, 0))); // W corner
|
||||
h = max(h, TileHeight(t + TileDiffXY(0, 1))); // E corner
|
||||
h = max(h, TileHeight(t + TileDiffXY(1, 1))); // S corner
|
||||
int h = TileHeight(t); // N corner
|
||||
h = max<int>(h, TileHeight(t + TileDiffXY(1, 0))); // W corner
|
||||
h = max<int>(h, TileHeight(t + TileDiffXY(0, 1))); // E corner
|
||||
h = max<int>(h, TileHeight(t + TileDiffXY(1, 1))); // S corner
|
||||
|
||||
return h;
|
||||
}
|
||||
|
|
|
@ -226,9 +226,9 @@ static inline void SetAnimationFrame(TileIndex t, byte frame)
|
|||
_me[t].m7 = frame;
|
||||
}
|
||||
|
||||
Slope GetTileSlope(TileIndex tile, uint *h = NULL);
|
||||
uint GetTileZ(TileIndex tile);
|
||||
uint GetTileMaxZ(TileIndex tile);
|
||||
Slope GetTileSlope(TileIndex tile, int *h = NULL);
|
||||
int GetTileZ(TileIndex tile);
|
||||
int GetTileMaxZ(TileIndex tile);
|
||||
|
||||
/**
|
||||
* Return the slope of a given tile
|
||||
|
@ -236,7 +236,7 @@ uint GetTileMaxZ(TileIndex tile);
|
|||
* @param h If not \c NULL, pointer to storage of z height
|
||||
* @return Slope of the tile, except for the HALFTILE part
|
||||
*/
|
||||
static inline Slope GetTilePixelSlope(TileIndex tile, uint *h)
|
||||
static inline Slope GetTilePixelSlope(TileIndex tile, int *h)
|
||||
{
|
||||
Slope s = GetTileSlope(tile, h);
|
||||
if (h != NULL) *h *= TILE_HEIGHT;
|
||||
|
@ -248,7 +248,7 @@ static inline Slope GetTilePixelSlope(TileIndex tile, uint *h)
|
|||
* @param tile Tile to compute height of
|
||||
* @return Minimum height of the tile
|
||||
*/
|
||||
static inline uint GetTilePixelZ(TileIndex tile)
|
||||
static inline int GetTilePixelZ(TileIndex tile)
|
||||
{
|
||||
return GetTileZ(tile) * TILE_HEIGHT;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ static inline uint GetTilePixelZ(TileIndex tile)
|
|||
* @param t Tile to compute height of
|
||||
* @return Maximum height of the tile
|
||||
*/
|
||||
static inline uint GetTileMaxPixelZ(TileIndex tile)
|
||||
static inline int GetTileMaxPixelZ(TileIndex tile)
|
||||
{
|
||||
return GetTileMaxZ(tile) * TILE_HEIGHT;
|
||||
}
|
||||
|
|
|
@ -2095,7 +2095,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
|||
/* no house allowed at all, bail out */
|
||||
if (!CanBuildHouseHere(tile, t->index, false)) return false;
|
||||
|
||||
uint z;
|
||||
int z;
|
||||
Slope slope = GetTileSlope(tile, &z);
|
||||
|
||||
/* Get the town zone type of the current tile, as well as the climate.
|
||||
|
|
|
@ -216,7 +216,7 @@ static void PlaceTreeGroups(uint num_groups)
|
|||
* @param tile The base tile to add a new tree somewhere around
|
||||
* @param height The height (like the one from the tile)
|
||||
*/
|
||||
static void PlaceTreeAtSameHeight(TileIndex tile, uint height)
|
||||
static void PlaceTreeAtSameHeight(TileIndex tile, int height)
|
||||
{
|
||||
for (uint i = 0; i < DEFAULT_TREE_STEPS; i++) {
|
||||
uint32 r = Random();
|
||||
|
@ -247,7 +247,7 @@ static void PlaceTreeAtSameHeight(TileIndex tile, uint height)
|
|||
*/
|
||||
void PlaceTreesRandomly()
|
||||
{
|
||||
uint i, j, ht;
|
||||
int i, j, ht;
|
||||
|
||||
i = ScaleByMapSize(DEFAULT_TREE_STEPS);
|
||||
if (_game_mode == GM_EDITOR) i /= EDITOR_TREE_DIV;
|
||||
|
@ -518,7 +518,7 @@ static void DrawTile_Trees(TileInfo *ti)
|
|||
|
||||
static uint GetSlopePixelZ_Trees(TileIndex tile, uint x, uint y)
|
||||
{
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
|
||||
return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
|
||||
|
|
|
@ -23,7 +23,7 @@ TileIndex GetOtherTunnelEnd(TileIndex tile)
|
|||
{
|
||||
DiagDirection dir = GetTunnelBridgeDirection(tile);
|
||||
TileIndexDiff delta = TileOffsByDiagDir(dir);
|
||||
uint z = GetTileZ(tile);
|
||||
int z = GetTileZ(tile);
|
||||
|
||||
dir = ReverseDiagDir(dir);
|
||||
do {
|
||||
|
|
|
@ -138,7 +138,7 @@ static inline const PalSpriteID *GetBridgeSpriteTable(int index, BridgePieces ta
|
|||
* @param z TileZ corresponding to tileh, gets modified as well
|
||||
* @return Error or cost for bridge foundation
|
||||
*/
|
||||
static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope *tileh, uint *z)
|
||||
static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope *tileh, int *z)
|
||||
{
|
||||
Foundation f = GetBridgeFoundation(*tileh, axis);
|
||||
*z += ApplyFoundationToSlope(f, tileh);
|
||||
|
@ -159,7 +159,7 @@ static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope *tileh, uint *z)
|
|||
* @param z TileZ corresponding to tileh, gets modified as well
|
||||
* @return Error or cost for bridge foundation
|
||||
*/
|
||||
static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z)
|
||||
static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, int *z)
|
||||
{
|
||||
Foundation f = GetBridgeFoundation(*tileh, axis);
|
||||
*z += ApplyFoundationToSlope(f, tileh);
|
||||
|
@ -267,8 +267,8 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
|||
if (bridge_len > _settings_game.construction.max_bridge_length) return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
|
||||
}
|
||||
|
||||
uint z_start;
|
||||
uint z_end;
|
||||
int z_start;
|
||||
int z_end;
|
||||
Slope tileh_start = GetTileSlope(tile_start, &z_start);
|
||||
Slope tileh_end = GetTileSlope(tile_end, &z_end);
|
||||
bool pbs_reservation = false;
|
||||
|
@ -525,8 +525,8 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
|
|||
default: return CMD_ERROR;
|
||||
}
|
||||
|
||||
uint start_z;
|
||||
uint end_z;
|
||||
int start_z;
|
||||
int end_z;
|
||||
Slope start_tileh = GetTileSlope(start_tile, &start_z);
|
||||
DiagDirection direction = GetInclinedSlopeDirection(start_tileh);
|
||||
if (direction == INVALID_DIAGDIR) return_cmd_error(STR_ERROR_SITE_UNSUITABLE_FOR_TUNNEL);
|
||||
|
@ -1361,7 +1361,7 @@ void DrawBridgeMiddle(const TileInfo *ti)
|
|||
|
||||
static uint GetSlopePixelZ_TunnelBridge(TileIndex tile, uint x, uint y)
|
||||
{
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
|
||||
x &= 0xF;
|
||||
|
@ -1380,7 +1380,7 @@ static uint GetSlopePixelZ_TunnelBridge(TileIndex tile, uint x, uint y)
|
|||
|
||||
/* On the bridge ramp? */
|
||||
if (5 <= pos && pos <= 10) {
|
||||
uint delta;
|
||||
int delta;
|
||||
|
||||
if (tileh != SLOPE_FLAT) return z + TILE_HEIGHT;
|
||||
|
||||
|
@ -1679,16 +1679,16 @@ static CommandCost TerraformTile_TunnelBridge(TileIndex tile, DoCommandFlag flag
|
|||
DiagDirection direction = GetTunnelBridgeDirection(tile);
|
||||
Axis axis = DiagDirToAxis(direction);
|
||||
CommandCost res;
|
||||
uint z_old;
|
||||
int z_old;
|
||||
Slope tileh_old = GetTileSlope(tile, &z_old);
|
||||
|
||||
/* Check if new slope is valid for bridges in general (so we can safely call GetBridgeFoundation()) */
|
||||
if ((direction == DIAGDIR_NW) || (direction == DIAGDIR_NE)) {
|
||||
CheckBridgeSlopeSouth(axis, &tileh_old, &z_old);
|
||||
res = CheckBridgeSlopeSouth(axis, &tileh_new, &z_new);
|
||||
res = CheckBridgeSlopeSouth(axis, &tileh_new, (int*)&z_new);
|
||||
} else {
|
||||
CheckBridgeSlopeNorth(axis, &tileh_old, &z_old);
|
||||
res = CheckBridgeSlopeNorth(axis, &tileh_new, &z_new);
|
||||
res = CheckBridgeSlopeNorth(axis, &tileh_new, (int*)&z_new);
|
||||
}
|
||||
|
||||
/* Surface slope is valid and remains unchanged? */
|
||||
|
|
|
@ -149,7 +149,7 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
|
|||
WaterClass wc = GetWaterClass(tile);
|
||||
|
||||
/* Autoslope might turn an originally canal or river tile into land */
|
||||
uint z;
|
||||
int z;
|
||||
if (GetTileSlope(tile, &z) != SLOPE_FLAT) wc = WATER_CLASS_INVALID;
|
||||
|
||||
if (wc == WATER_CLASS_SEA && z > 0) wc = WATER_CLASS_CANAL;
|
||||
|
@ -796,7 +796,7 @@ void DrawShipDepotSprite(int x, int y, Axis axis, DepotPart part)
|
|||
|
||||
static uint GetSlopePixelZ_Water(TileIndex tile, uint x, uint y)
|
||||
{
|
||||
uint z;
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
|
||||
return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
|
||||
|
@ -1079,7 +1079,7 @@ void TileLoop_Water(TileIndex tile)
|
|||
/* do not try to flood water tiles - increases performance a lot */
|
||||
if (IsTileType(dest, MP_WATER)) continue;
|
||||
|
||||
uint z_dest;
|
||||
int z_dest;
|
||||
Slope slope_dest = GetFoundationSlope(dest, &z_dest) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP;
|
||||
if (z_dest > 0) continue;
|
||||
|
||||
|
@ -1109,7 +1109,7 @@ void TileLoop_Water(TileIndex tile)
|
|||
|
||||
void ConvertGroundTilesIntoWaterTiles()
|
||||
{
|
||||
uint z;
|
||||
int z;
|
||||
|
||||
for (TileIndex tile = 0; tile < MapSize(); ++tile) {
|
||||
Slope slope = GetTileSlope(tile, &z);
|
||||
|
|
Loading…
Reference in New Issue