1
0
Fork 0

(svn r19816) -Codechange: use static const uint for the unnamed 'tile consts' enum as well

release/1.1
rubidium 2010-05-13 11:19:30 +00:00
parent 28d25cadfc
commit 548dd91ef0
6 changed files with 31 additions and 33 deletions

View File

@ -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; delete v;
return false; return false;
} }
@ -291,7 +291,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
/* Fly around randomly */ /* Fly around randomly */
int x = TileX(v->dest_tile) * TILE_SIZE; int x = TileX(v->dest_tile) * TILE_SIZE;
int y = TileY(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); v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePosResult gp = GetNewVehiclePos(v); GetNewVehiclePosResult gp = GetNewVehiclePos(v);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); 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); GetNewVehiclePosResult gp = GetNewVehiclePos(v);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); 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; delete v;
return false; return false;
} }
@ -505,7 +505,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
Vehicle *target; Vehicle *target;
FOR_ALL_VEHICLES(target) { FOR_ALL_VEHICLES(target) {
if (target->type == VEH_TRAIN || target->type == VEH_ROAD) { 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_ctr = 5;
target->breakdown_delay = 0xF0; target->breakdown_delay = 0xF0;
} }
@ -536,7 +536,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
} else if (v->current_order.GetDestination() == 0) { } else if (v->current_order.GetDestination() == 0) {
int x = TileX(v->dest_tile) * TILE_SIZE; int x = TileX(v->dest_tile) * TILE_SIZE;
int y = TileY(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); v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePosResult gp = GetNewVehiclePos(v); GetNewVehiclePosResult gp = GetNewVehiclePos(v);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); 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); GetNewVehiclePosResult gp = GetNewVehiclePos(v);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); 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; delete v;
return false; return false;
} }
if (v->current_order.GetDestination() == 0) { if (v->current_order.GetDestination() == 0) {
Vehicle *u = Vehicle::Get(v->big_ufo_destroyer_target); 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); v->current_order.SetDestination(1);
CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE); CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);

View File

@ -1304,7 +1304,7 @@ public:
sx = -hv.x; sx = -hv.x;
sub = 0; sub = 0;
} }
if (sx > (int)MapMaxX() * TILE_SIZE - hv.x) { if (sx > (int)(MapMaxX() * TILE_SIZE) - hv.x) {
sx = MapMaxX() * TILE_SIZE - hv.x; sx = MapMaxX() * TILE_SIZE - hv.x;
sub = 0; sub = 0;
} }
@ -1312,7 +1312,7 @@ public:
sy = -hv.y; sy = -hv.y;
sub = 0; sub = 0;
} }
if (sy > (int)MapMaxY() * TILE_SIZE - hv.y) { if (sy > (int)(MapMaxY() * TILE_SIZE) - hv.y) {
sy = MapMaxY() * TILE_SIZE - hv.y; sy = MapMaxY() * TILE_SIZE - hv.y;
sub = 0; sub = 0;
} }

View File

@ -156,7 +156,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int
/* Check range of destination height */ /* Check range of destination height */
if (height < 0) return_cmd_error(STR_ERROR_ALREADY_AT_SEA_LEVEL); 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. * Check if the terraforming has any effect.

View File

@ -12,18 +12,16 @@
#ifndef TILE_TYPE_H #ifndef TILE_TYPE_H
#define 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 { static const uint MAX_TILE_HEIGHT = 15; ///< Maximum allowed tile height
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)
MAX_TILE_HEIGHT = 15, ///< Maximum allowed tile height static const uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snowline height
MIN_SNOWLINE_HEIGHT = 2, ///< Minimum snowline height static const uint DEF_SNOWLINE_HEIGHT = 7; ///< Default snowline height
DEF_SNOWLINE_HEIGHT = 7, ///< Default snowline height static const uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum allowed snowline height
MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2), ///< Maximum allowed snowline height
};
/** /**

View File

@ -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 */ /* 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); AddSortableSpriteToDraw(image, psid->pal, x_back, y_back, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5);
} }
} }

View File

@ -1017,8 +1017,8 @@ static void ViewportAddLandscape()
do { do {
int width_cur = width; int width_cur = width;
int x_cur = x; uint x_cur = x;
int y_cur = y; uint y_cur = y;
do { do {
TileType tt = MP_VOID; TileType tt = MP_VOID;
@ -1031,8 +1031,8 @@ static void ViewportAddLandscape()
ti.tileh = SLOPE_FLAT; ti.tileh = SLOPE_FLAT;
ti.tile = INVALID_TILE; ti.tile = INVALID_TILE;
if (0 <= x_cur && x_cur < (int)MapMaxX() * TILE_SIZE && if (x_cur < MapMaxX() * TILE_SIZE &&
0 <= y_cur && y_cur < (int)MapMaxY() * TILE_SIZE) { y_cur < MapMaxY() * TILE_SIZE) {
TileIndex tile = TileVirtXY(x_cur, y_cur); TileIndex tile = TileVirtXY(x_cur, y_cur);
if (!_settings_game.construction.freeform_edges || (TileX(tile) != 0 && TileY(tile) != 0)) { 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 { } else {
/* We are not on a straight line. Determine the rail to build /* We are not on a straight line. Determine the rail to build
* based on whether we are above or below it. */ * 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 /* Calculate where a horizontal line through the start point and
* a vertical line from the selected end point intersect 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 */ /* 'Build' the last half rail tile if needed */
if ((offset & TILE_UNIT_MASK) > (TILE_SIZE / 2)) { 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; x += (dx + dy < 0) ? TILE_SIZE : -TILE_SIZE;
} else { } else {
y += (dx + dy < 0) ? TILE_SIZE : -TILE_SIZE; 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); CheckUnderflow(y, x, 1);
CheckOverflow(x, y, (MapMaxX() - 1) * TILE_SIZE, 1); CheckOverflow(x, y, (MapMaxX() - 1) * TILE_SIZE, 1);
CheckOverflow(y, x, (MapMaxY() - 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; break;
@ -2376,7 +2376,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
CheckUnderflow(y, x, -1); CheckUnderflow(y, x, -1);
CheckOverflow(x, y, (MapMaxX() - 1) * TILE_SIZE, -1); CheckOverflow(x, y, (MapMaxX() - 1) * TILE_SIZE, -1);
CheckOverflow(y, x, (MapMaxY() - 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; break;
@ -2390,18 +2390,18 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
b = HT_RECT; b = HT_RECT;
} }
} else if (h == TILE_SIZE) { // Is this in X direction? } 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; b = (Check2x1AutoRail(3)) | HT_LINE;
} else if (dx == -TILE_SIZE) { } else if (dx == -(int)TILE_SIZE) {
b = (Check2x1AutoRail(2)) | HT_LINE; b = (Check2x1AutoRail(2)) | HT_LINE;
} else { } else {
b = HT_LINE | HT_DIR_X; b = HT_LINE | HT_DIR_X;
} }
y = thd->selstart.y; y = thd->selstart.y;
} else if (w == TILE_SIZE) { // Or Y direction? } 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; 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; b = (Check2x1AutoRail(0)) | HT_LINE;
} else { } else {
b = HT_LINE | HT_DIR_Y; b = HT_LINE | HT_DIR_Y;