summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-06-19 20:13:50 +0000
committertron <tron@openttd.org>2006-06-19 20:13:50 +0000
commite6b7fbd949e4e5465aff3816d7b4b559e00e62a2 (patch)
tree68851fcced56843f2bd0017f7f7dfef0bac22517
parent3723f3f300fa2dbfefbe5d576f8e775d2ae6e5ed (diff)
downloadopenttd-e6b7fbd949e4e5465aff3816d7b4b559e00e62a2.tar.xz
(svn r5317) s/RGT_/ROADSIDE_/ and some minor changes
-rw-r--r--npf.c2
-rw-r--r--road_cmd.c67
-rw-r--r--road_map.h44
3 files changed, 58 insertions, 55 deletions
diff --git a/npf.c b/npf.c
index a0d2fb0d7..9812c8782 100644
--- a/npf.c
+++ b/npf.c
@@ -228,7 +228,7 @@ static void NPFMarkTile(TileIndex tile)
case MP_STREET:
if (!IsTileDepotType(tile, TRANSPORT_ROAD)) {
- SetGroundType(tile, RGT_BARREN);
+ SetRoadside(tile, ROADSIDE_BARREN);
MarkTileDirtyByTile(tile);
}
break;
diff --git a/road_cmd.c b/road_cmd.c
index 7f99d6d0a..0bf2ded25 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -700,6 +700,7 @@ static void DrawRoadBits(TileInfo* ti, RoadBits road)
{
const DrawRoadTileStruct *drts;
PalSpriteID image = 0;
+ Roadside roadside;
if (ti->tileh != SLOPE_FLAT) {
int foundation = GetRoadFoundation(ti->tileh, road);
@@ -713,13 +714,17 @@ static void DrawRoadBits(TileInfo* ti, RoadBits road)
if (image == 0) image = _road_tile_sprites_1[road];
- if (GetGroundType(ti->tile) == RGT_BARREN) image |= PALETTE_TO_BARE_LAND;
+ roadside = GetRoadside(ti->tile);
if (IsOnSnow(ti->tile)) {
image += 19;
- } else if (HasPavement(ti->tile)) {
- // Pavement tiles.
- image -= 19;
+ } else {
+ switch (roadside) {
+ case ROADSIDE_BARREN: image |= PALETTE_TO_BARE_LAND; break;
+ case ROADSIDE_GRASS: break;
+ case ROADSIDE_GRASS_ROAD_WORKS: break;
+ default: image -= 19; break; // Paved
+ }
}
DrawGroundSprite(image);
@@ -734,7 +739,7 @@ static void DrawRoadBits(TileInfo* ti, RoadBits road)
}
// Draw extra details.
- for (drts = _road_display_table[GetGroundType(ti->tile)][road]; drts->image != 0; drts++) {
+ for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) {
int x = ti->x | drts->subcoord_x;
int y = ti->y | drts->subcoord_y;
byte z = ti->z;
@@ -763,8 +768,11 @@ static void DrawTile_Road(TileInfo *ti)
if (IsOnSnow(ti->tile)) {
image += 8;
} else {
- if (GetGroundType(ti->tile) == RGT_BARREN) image |= PALETTE_TO_BARE_LAND;
- if (HasPavement(ti->tile)) image += 4;
+ switch (GetRoadside(ti->tile)) {
+ case ROADSIDE_BARREN: image |= PALETTE_TO_BARE_LAND; break;
+ case ROADSIDE_GRASS: break;
+ default: image += 4; break; // Paved
+ }
}
DrawGroundSprite(image);
@@ -866,20 +874,21 @@ static void AnimateTile_Road(TileIndex tile)
if (IsLevelCrossing(tile)) MarkTileDirtyByTile(tile);
}
-static const RoadGroundType _town_road_types[5][2] = {
- {RGT_GRASS,RGT_GRASS},
- {RGT_PAVED,RGT_PAVED},
- {RGT_PAVED,RGT_PAVED},
- {RGT_ALLEY,RGT_ALLEY},
- {RGT_LIGHT,RGT_PAVED},
+
+static const Roadside _town_road_types[][2] = {
+ { ROADSIDE_GRASS, ROADSIDE_GRASS },
+ { ROADSIDE_PAVED, ROADSIDE_PAVED },
+ { ROADSIDE_PAVED, ROADSIDE_PAVED },
+ { ROADSIDE_TREES, ROADSIDE_TREES },
+ { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
};
-static const RoadGroundType _town_road_types_2[5][2] = {
- {RGT_GRASS,RGT_GRASS},
- {RGT_PAVED,RGT_PAVED},
- {RGT_LIGHT,RGT_PAVED},
- {RGT_LIGHT,RGT_PAVED},
- {RGT_LIGHT,RGT_PAVED},
+static const Roadside _town_road_types_2[][2] = {
+ { ROADSIDE_GRASS, ROADSIDE_GRASS },
+ { ROADSIDE_PAVED, ROADSIDE_PAVED },
+ { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED },
+ { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED },
+ { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
};
@@ -934,23 +943,23 @@ static void TileLoop_Road(TileIndex tile)
{
/* Adjust road ground type depending on 'grp' (grp is the distance to the center) */
- const RoadGroundType *target_rgt = (_opt.landscape == LT_CANDY) ? _town_road_types_2[grp] : _town_road_types[grp];
- RoadGroundType rgt = GetGroundType(tile);
+ const Roadside* new_rs = (_opt.landscape == LT_CANDY) ? _town_road_types_2[grp] : _town_road_types[grp];
+ Roadside cur_rs = GetRoadside(tile);
/* We have our desired type, do nothing */
- if (rgt == target_rgt[0]) return;
+ if (cur_rs == new_rs[0]) return;
/* We have the pre-type of the desired type, switch to the desired type */
- if (rgt == target_rgt[1]) {
- rgt = target_rgt[0];
+ if (cur_rs == new_rs[1]) {
+ cur_rs = new_rs[0];
/* We have barren land, install the pre-type */
- } else if (rgt == RGT_BARREN) {
- rgt = target_rgt[1];
+ } else if (cur_rs == ROADSIDE_BARREN) {
+ cur_rs = new_rs[1];
/* We're totally off limits, remove any installation and make barren land */
} else {
- rgt = RGT_BARREN;
+ cur_rs = ROADSIDE_BARREN;
}
- SetGroundType(tile, rgt);
+ SetRoadside(tile, cur_rs);
MarkTileDirtyByTile(tile);
}
} else if (IncreaseRoadWorksCounter(tile)) {
@@ -1018,7 +1027,7 @@ static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
switch (GetRoadTileType(tile)) {
case ROAD_TILE_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break;
case ROAD_TILE_DEPOT: td->str = STR_1817_ROAD_VEHICLE_DEPOT; break;
- default: td->str = _road_tile_strings[GetGroundType(tile)]; break;
+ default: td->str = _road_tile_strings[GetRoadside(tile)]; break;
}
}
diff --git a/road_map.h b/road_map.h
index 73d386cb1..754c6d026 100644
--- a/road_map.h
+++ b/road_map.h
@@ -104,32 +104,30 @@ static inline void ToggleSnow(TileIndex t)
TOGGLEBIT(_m[t].m4, 7);
}
-typedef enum RoadGroundType {
- RGT_BARREN,
- RGT_GRASS,
- RGT_PAVED,
- RGT_LIGHT,
- RGT_NOT_IN_USE, /* Has something to do with fund buildings */
- RGT_ALLEY,
- RGT_ROADWORK_GRASS,
- RGT_ROADWORK_PAVED,
- RGT_ROADWORK_OFFSET = RGT_ROADWORK_GRASS - RGT_GRASS
-} RoadGroundType;
+typedef enum Roadside {
+ ROADSIDE_BARREN = 0,
+ ROADSIDE_GRASS = 1,
+ ROADSIDE_PAVED = 2,
+ ROADSIDE_STREET_LIGHTS = 3,
+ ROADSIDE_TREES = 5,
+ ROADSIDE_GRASS_ROAD_WORKS = 6,
+ ROADSIDE_PAVED_ROAD_WORKS = 7
+} Roadside;
-static inline RoadGroundType GetGroundType(TileIndex t)
+static inline Roadside GetRoadside(TileIndex tile)
{
- return (RoadGroundType)GB(_m[t].m4, 4, 3);
+ return (Roadside)GB(_m[tile].m4, 4, 3);
}
-static inline void SetGroundType(TileIndex t, RoadGroundType rgt)
+static inline void SetRoadside(TileIndex tile, Roadside s)
{
- SB(_m[t].m4, 4, 3, rgt);
+ SB(_m[tile].m4, 4, 3, s);
}
static inline bool HasRoadWorks(TileIndex t)
{
- return GetGroundType(t) >= RGT_ROADWORK_GRASS;
+ return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS;
}
static inline bool IncreaseRoadWorksCounter(TileIndex t)
@@ -143,25 +141,21 @@ static inline void StartRoadWorks(TileIndex t)
{
assert(!HasRoadWorks(t));
/* Remove any trees or lamps in case or roadwork */
- switch (GetGroundType(t)) {
- case RGT_BARREN:
- case RGT_GRASS: SetGroundType(t, RGT_ROADWORK_GRASS); break;
- default: SetGroundType(t, RGT_ROADWORK_PAVED); break;
+ switch (GetRoadside(t)) {
+ case ROADSIDE_BARREN:
+ case ROADSIDE_GRASS: SetRoadside(t, ROADSIDE_GRASS_ROAD_WORKS); break;
+ default: SetRoadside(t, ROADSIDE_PAVED_ROAD_WORKS); break;
}
}
static inline void TerminateRoadWorks(TileIndex t)
{
assert(HasRoadWorks(t));
- SetGroundType(t, (RoadGroundType)(GetGroundType(t) - RGT_ROADWORK_OFFSET));
+ SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS));
/* Stop the counter */
SB(_m[t].m4, 0, 4, 0);
}
-static inline bool HasPavement(TileIndex t)
-{
- return GetGroundType(t) >= RGT_PAVED && GetGroundType(t) != RGT_ROADWORK_GRASS;
-}
static inline DiagDirection GetRoadDepotDirection(TileIndex t)
{