summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-22 16:56:36 +0000
committerrubidium <rubidium@openttd.org>2009-07-22 16:56:36 +0000
commit3bcfa7c52ad592ccfaf58ad499e78fd89aea6722 (patch)
tree93679153f8b75af75846228e5cd2c1a1a1ed0296
parent13a7c550ad86f94bdf0dca83cd402cfd1ca6e8ba (diff)
downloadopenttd-3bcfa7c52ad592ccfaf58ad499e78fd89aea6722.tar.xz
(svn r16917) -Codechange: fix some GCC 4.5 'case X is not in enum Y' warnings
-rw-r--r--src/ai/api/ai_road.cpp20
-rw-r--r--src/rail_gui.cpp8
-rw-r--r--src/rail_type.h6
-rw-r--r--src/road_type.h6
-rw-r--r--src/saveload/oldloader_sl.cpp14
5 files changed, 33 insertions, 21 deletions
diff --git a/src/ai/api/ai_road.cpp b/src/ai/api/ai_road.cpp
index fd3ec11d9..f5489348f 100644
--- a/src/ai/api/ai_road.cpp
+++ b/src/ai/api/ai_road.cpp
@@ -266,14 +266,14 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, Array *existing, int32 start
case SLOPE_W:
/* A slope similar to a SLOPE_W. */
switch (new_roadbits) {
- case 6: // ROAD_SE | ROAD_SW:
- case 9: // ROAD_NE | ROAD_NW:
- case 12: // ROAD_NE | ROAD_SE:
+ case ROAD_N:
+ case ROAD_E:
+ case ROAD_S:
/* Cannot build anything with a turn from the low side. */
return 0;
- case 5: // ROAD_SE | ROAD_NW:
- case 10: // ROAD_NE | ROAD_SW:
+ case ROAD_X:
+ case ROAD_Y:
/* A 'sloped' tile is going to be build. */
if ((existing_roadbits | new_roadbits) != new_roadbits) {
/* There is already a foundation on the tile, or at least
@@ -282,25 +282,25 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, Array *existing, int32 start
}
/* If the start is in the low part, it is automatically
* building the second part too. */
- return ((start_roadbits & (ROAD_NE | ROAD_SE)) && !(existing_roadbits & (ROAD_SW | ROAD_NW))) ? 2 : 1;
+ return ((start_roadbits & ROAD_E) && !(existing_roadbits & ROAD_W)) ? 2 : 1;
default:
/* Roadbits causing a foundation are going to be build.
* When the existing roadbits are slopes (the lower bits
* are used), this cannot be done. */
if ((existing_roadbits | new_roadbits) == new_roadbits) return 1;
- return (existing_roadbits & (ROAD_NE | ROAD_SE)) ? 0 : 1;
+ return (existing_roadbits & ROAD_E) ? 0 : 1;
}
case SLOPE_SW:
/* A slope similar to a SLOPE_SW. */
switch (new_roadbits) {
- case 9: // ROAD_NE | ROAD_NW:
- case 12: // ROAD_NE | ROAD_SE:
+ case ROAD_N:
+ case ROAD_E:
/* Cannot build anything with a turn from the low side. */
return 0;
- case 10: // ROAD_NE | ROAD_SW:
+ case ROAD_X:
/* A 'sloped' tile is going to be build. */
if ((existing_roadbits | new_roadbits) != new_roadbits) {
/* There is already a foundation on the tile, or at least
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index ccb77c41a..adfd3dc46 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1824,7 +1824,7 @@ static void SetDefaultRailGui()
extern RailType _last_built_railtype;
RailType rt = (RailType)_settings_client.gui.default_rail_type;
if (rt >= RAILTYPE_END) {
- if (rt == RAILTYPE_END + 2) {
+ if (rt == DEF_RAILTYPE_MOST_USED) {
/* Find the most used rail type */
RailType count[RAILTYPE_END];
memset(count, 0, sizeof(count));
@@ -1841,15 +1841,15 @@ static void SetDefaultRailGui()
}
/* No rail, just get the first available one */
- if (count[rt] == 0) rt = RAILTYPE_END;
+ if (count[rt] == 0) rt = DEF_RAILTYPE_FIRST;
}
switch (rt) {
- case RAILTYPE_END + 0:
+ case DEF_RAILTYPE_FIRST:
rt = RAILTYPE_RAIL;
while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_company, rt)) rt++;
break;
- case RAILTYPE_END + 1:
+ case DEF_RAILTYPE_LAST:
rt = GetBestRailtype(_local_company);
break;
diff --git a/src/rail_type.h b/src/rail_type.h
index e8c452492..331b85783 100644
--- a/src/rail_type.h
+++ b/src/rail_type.h
@@ -21,7 +21,11 @@ enum RailType {
RAILTYPE_MONO = 2, ///< Monorail
RAILTYPE_MAGLEV = 3, ///< Maglev
RAILTYPE_END, ///< Used for iterations
- INVALID_RAILTYPE = 0xFF ///< Flag for invalid railtype
+ INVALID_RAILTYPE = 0xFF, ///< Flag for invalid railtype
+
+ DEF_RAILTYPE_FIRST = RAILTYPE_END, ///< Default railtype: first available
+ DEF_RAILTYPE_LAST, ///< Default railtype: last available
+ DEF_RAILTYPE_MOST_USED, ///< Default railtype: most used
};
/** Allow incrementing of Track variables */
diff --git a/src/road_type.h b/src/road_type.h
index a50f91c7c..e681b83ad 100644
--- a/src/road_type.h
+++ b/src/road_type.h
@@ -51,6 +51,12 @@ enum RoadBits {
ROAD_NE = 8U, ///< North-east part
ROAD_X = ROAD_SW | ROAD_NE, ///< Full road along the x-axis (south-west + north-east)
ROAD_Y = ROAD_NW | ROAD_SE, ///< Full road along the y-axis (north-west + south-east)
+
+ ROAD_N = ROAD_NE | ROAD_NW, ///< Road at the two northern edges
+ ROAD_E = ROAD_NE | ROAD_SE, ///< Road at the two eastern edges
+ ROAD_S = ROAD_SE | ROAD_SW, ///< Road at the two southern edges
+ ROAD_W = ROAD_NW | ROAD_SW, ///< Road at the two western edges
+
ROAD_ALL = ROAD_X | ROAD_Y ///< Full 4-way crossing
};
DECLARE_ENUM_AS_BIT_SET(RoadBits);
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index fceb86df0..0702a170e 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -204,18 +204,20 @@ static bool FixTTOMapArray()
{
for (TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
TileType tt = GetTileType(t);
+ if (tt == 11) {
+ /* TTO has a different way of storing monorail.
+ * Instead of using bits in m3 it uses a different tile type. */
+ _m[t].m3 = 1; // rail type = monorail (in TTD)
+ SetTileType(t, MP_RAILWAY);
+ _m[t].m2 = 1; // set monorail ground to RAIL_GROUND_GRASS
+ tt = MP_RAILWAY;
+ }
switch (tt) {
case MP_CLEAR:
break;
case MP_RAILWAY:
- case 11: // monorail
- if (tt == 11) {
- _m[t].m3 = 1; // rail type = monorail
- _m[t].type_height &= 0x1F; // -> MP_RAILWAY
- _m[t].m2 = 1; // set monorail ground to RAIL_GROUND_GRASS
- }
switch (GB(_m[t].m5, 6, 2)) {
case 0: // RAIL_TILE_NORMAL
break;