diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/disaster_cmd.cpp | 14 | ||||
-rw-r--r-- | src/smallmap_gui.cpp | 4 | ||||
-rw-r--r-- | src/terraform_cmd.cpp | 2 | ||||
-rw-r--r-- | src/tile_type.h | 18 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 2 | ||||
-rw-r--r-- | src/viewport.cpp | 24 |
6 files changed, 31 insertions, 33 deletions
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index c4b00e458..adbc118b8 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -221,7 +221,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v) } } - if (v->y_pos >= ((int)MapSizeY() + 9) * TILE_SIZE - 1) { + if (v->y_pos >= (int)((MapSizeY() + 9) * TILE_SIZE - 1)) { delete v; return false; } @@ -291,7 +291,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v) /* Fly around randomly */ int x = TileX(v->dest_tile) * TILE_SIZE; int y = TileY(v->dest_tile) * TILE_SIZE; - if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) { + if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) { v->direction = GetDirectionTowards(v, x, y); GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); @@ -389,7 +389,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); - if ((leave_at_top && gp.x < (-10 * TILE_SIZE)) || (!leave_at_top && gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1)) { + if ((leave_at_top && gp.x < (-10 * (int)TILE_SIZE)) || (!leave_at_top && gp.x > (int)(MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1)) { delete v; return false; } @@ -505,7 +505,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v) Vehicle *target; FOR_ALL_VEHICLES(target) { if (target->type == VEH_TRAIN || target->type == VEH_ROAD) { - if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * TILE_SIZE) { + if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * (int)TILE_SIZE) { target->breakdown_ctr = 5; target->breakdown_delay = 0xF0; } @@ -536,7 +536,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v) } else if (v->current_order.GetDestination() == 0) { int x = TileX(v->dest_tile) * TILE_SIZE; int y = TileY(v->dest_tile) * TILE_SIZE; - if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) { + if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) { v->direction = GetDirectionTowards(v, x, y); GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); @@ -576,14 +576,14 @@ static bool DisasterTick_Big_Ufo_Destroyer(DisasterVehicle *v) GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); - if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) { + if (gp.x > (int)(MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1) { delete v; return false; } if (v->current_order.GetDestination() == 0) { Vehicle *u = Vehicle::Get(v->big_ufo_destroyer_target); - if (Delta(v->x_pos, u->x_pos) > TILE_SIZE) return true; + if (Delta(v->x_pos, u->x_pos) > (int)TILE_SIZE) return true; v->current_order.SetDestination(1); CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE); diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 68a9a056c..16ce51369 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1304,7 +1304,7 @@ public: sx = -hv.x; sub = 0; } - if (sx > (int)MapMaxX() * TILE_SIZE - hv.x) { + if (sx > (int)(MapMaxX() * TILE_SIZE) - hv.x) { sx = MapMaxX() * TILE_SIZE - hv.x; sub = 0; } @@ -1312,7 +1312,7 @@ public: sy = -hv.y; sub = 0; } - if (sy > (int)MapMaxY() * TILE_SIZE - hv.y) { + if (sy > (int)(MapMaxY() * TILE_SIZE) - hv.y) { sy = MapMaxY() * TILE_SIZE - hv.y; sub = 0; } diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index 2c45bcc45..424aa9f37 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -156,7 +156,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int /* Check range of destination height */ if (height < 0) return_cmd_error(STR_ERROR_ALREADY_AT_SEA_LEVEL); - if (height > MAX_TILE_HEIGHT) return_cmd_error(STR_ERROR_TOO_HIGH); + if (height > (int)MAX_TILE_HEIGHT) return_cmd_error(STR_ERROR_TOO_HIGH); /* * Check if the terraforming has any effect. diff --git a/src/tile_type.h b/src/tile_type.h index 82e4146e0..26b0fa1f0 100644 --- a/src/tile_type.h +++ b/src/tile_type.h @@ -12,18 +12,16 @@ #ifndef TILE_TYPE_H #define TILE_TYPE_H +static const uint TILE_SIZE = 16; ///< Tiles are 16x16 "units" in size +static const uint TILE_UNIT_MASK = TILE_SIZE - 1; ///< for masking in/out the inner-tile units. +static const uint TILE_PIXELS = 32; ///< a tile is 32x32 pixels +static const uint TILE_HEIGHT = 8; ///< The standard height-difference between tiles on two levels is 8 (z-diff 8) -enum { - TILE_SIZE = 16, ///< Tiles are 16x16 "units" in size - TILE_UNIT_MASK = TILE_SIZE - 1, ///< for masking in/out the inner-tile units. - TILE_PIXELS = 32, ///< a tile is 32x32 pixels - TILE_HEIGHT = 8, ///< The standard height-difference between tiles on two levels is 8 (z-diff 8) +static const uint MAX_TILE_HEIGHT = 15; ///< Maximum allowed tile height - MAX_TILE_HEIGHT = 15, ///< Maximum allowed tile height - MIN_SNOWLINE_HEIGHT = 2, ///< Minimum snowline height - DEF_SNOWLINE_HEIGHT = 7, ///< Default snowline height - MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2), ///< Maximum allowed snowline height -}; +static const uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snowline height +static const uint DEF_SNOWLINE_HEIGHT = 7; ///< Default snowline height +static const uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum allowed snowline height /** diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 5823ff679..a08410eb5 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -861,7 +861,7 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis } /* Draw back facing pillar, but not the highest part directly under the bridge-floor */ - if (drawfarpillar && cur_z >= back_height && cur_z < z_bridge - TILE_HEIGHT) { + if (drawfarpillar && cur_z >= back_height && cur_z < z_bridge - (int)TILE_HEIGHT) { AddSortableSpriteToDraw(image, psid->pal, x_back, y_back, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5); } } diff --git a/src/viewport.cpp b/src/viewport.cpp index 00ef9f6cc..87023c958 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1017,8 +1017,8 @@ static void ViewportAddLandscape() do { int width_cur = width; - int x_cur = x; - int y_cur = y; + uint x_cur = x; + uint y_cur = y; do { TileType tt = MP_VOID; @@ -1031,8 +1031,8 @@ static void ViewportAddLandscape() ti.tileh = SLOPE_FLAT; ti.tile = INVALID_TILE; - if (0 <= x_cur && x_cur < (int)MapMaxX() * TILE_SIZE && - 0 <= y_cur && y_cur < (int)MapMaxY() * TILE_SIZE) { + if (x_cur < MapMaxX() * TILE_SIZE && + y_cur < MapMaxY() * TILE_SIZE) { TileIndex tile = TileVirtXY(x_cur, y_cur); if (!_settings_game.construction.freeform_edges || (TileX(tile) != 0 && TileY(tile) != 0)) { @@ -2318,7 +2318,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth } else { /* We are not on a straight line. Determine the rail to build * based on whether we are above or below it. */ - b = dx + dy >= TILE_SIZE ? HT_LINE | HT_DIR_HU : HT_LINE | HT_DIR_HL; + b = dx + dy >= (int)TILE_SIZE ? HT_LINE | HT_DIR_HU : HT_LINE | HT_DIR_HL; /* Calculate where a horizontal line through the start point and * a vertical line from the selected end point intersect and @@ -2329,7 +2329,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth /* 'Build' the last half rail tile if needed */ if ((offset & TILE_UNIT_MASK) > (TILE_SIZE / 2)) { - if (dx + dy >= TILE_SIZE) { + if (dx + dy >= (int)TILE_SIZE) { x += (dx + dy < 0) ? TILE_SIZE : -TILE_SIZE; } else { y += (dx + dy < 0) ? TILE_SIZE : -TILE_SIZE; @@ -2341,7 +2341,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth CheckUnderflow(y, x, 1); CheckOverflow(x, y, (MapMaxX() - 1) * TILE_SIZE, 1); CheckOverflow(y, x, (MapMaxY() - 1) * TILE_SIZE, 1); - assert(x >= 0 && y >= 0 && x <= (int)MapMaxX() * TILE_SIZE && y <= (int)MapMaxY() * TILE_SIZE); + assert(x >= 0 && y >= 0 && x <= (int)(MapMaxX() * TILE_SIZE) && y <= (int)(MapMaxY() * TILE_SIZE)); } break; @@ -2376,7 +2376,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth CheckUnderflow(y, x, -1); CheckOverflow(x, y, (MapMaxX() - 1) * TILE_SIZE, -1); CheckOverflow(y, x, (MapMaxY() - 1) * TILE_SIZE, -1); - assert(x >= 0 && y >= 0 && x <= (int)MapMaxX() * TILE_SIZE && y <= (int)MapMaxY() * TILE_SIZE); + assert(x >= 0 && y >= 0 && x <= (int)(MapMaxX() * TILE_SIZE) && y <= (int)(MapMaxY() * TILE_SIZE)); } break; @@ -2390,18 +2390,18 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth b = HT_RECT; } } else if (h == TILE_SIZE) { // Is this in X direction? - if (dx == TILE_SIZE) { // 2x1 special handling + if (dx == (int)TILE_SIZE) { // 2x1 special handling b = (Check2x1AutoRail(3)) | HT_LINE; - } else if (dx == -TILE_SIZE) { + } else if (dx == -(int)TILE_SIZE) { b = (Check2x1AutoRail(2)) | HT_LINE; } else { b = HT_LINE | HT_DIR_X; } y = thd->selstart.y; } else if (w == TILE_SIZE) { // Or Y direction? - if (dy == TILE_SIZE) { // 2x1 special handling + if (dy == (int)TILE_SIZE) { // 2x1 special handling b = (Check2x1AutoRail(1)) | HT_LINE; - } else if (dy == -TILE_SIZE) { // 2x1 other direction + } else if (dy == -(int)TILE_SIZE) { // 2x1 other direction b = (Check2x1AutoRail(0)) | HT_LINE; } else { b = HT_LINE | HT_DIR_Y; |