(svn r5317) s/RGT_/ROADSIDE_/ and some minor changes

This commit is contained in:
tron 2006-06-19 20:13:50 +00:00
parent 10e00914f7
commit 9b6fce70a2
3 changed files with 58 additions and 55 deletions

2
npf.c
View File

@ -228,7 +228,7 @@ static void NPFMarkTile(TileIndex tile)
case MP_STREET: case MP_STREET:
if (!IsTileDepotType(tile, TRANSPORT_ROAD)) { if (!IsTileDepotType(tile, TRANSPORT_ROAD)) {
SetGroundType(tile, RGT_BARREN); SetRoadside(tile, ROADSIDE_BARREN);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }
break; break;

View File

@ -700,6 +700,7 @@ static void DrawRoadBits(TileInfo* ti, RoadBits road)
{ {
const DrawRoadTileStruct *drts; const DrawRoadTileStruct *drts;
PalSpriteID image = 0; PalSpriteID image = 0;
Roadside roadside;
if (ti->tileh != SLOPE_FLAT) { if (ti->tileh != SLOPE_FLAT) {
int foundation = GetRoadFoundation(ti->tileh, road); 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 (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)) { if (IsOnSnow(ti->tile)) {
image += 19; image += 19;
} else if (HasPavement(ti->tile)) { } else {
// Pavement tiles. switch (roadside) {
image -= 19; 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); DrawGroundSprite(image);
@ -734,7 +739,7 @@ static void DrawRoadBits(TileInfo* ti, RoadBits road)
} }
// Draw extra details. // 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 x = ti->x | drts->subcoord_x;
int y = ti->y | drts->subcoord_y; int y = ti->y | drts->subcoord_y;
byte z = ti->z; byte z = ti->z;
@ -763,8 +768,11 @@ static void DrawTile_Road(TileInfo *ti)
if (IsOnSnow(ti->tile)) { if (IsOnSnow(ti->tile)) {
image += 8; image += 8;
} else { } else {
if (GetGroundType(ti->tile) == RGT_BARREN) image |= PALETTE_TO_BARE_LAND; switch (GetRoadside(ti->tile)) {
if (HasPavement(ti->tile)) image += 4; case ROADSIDE_BARREN: image |= PALETTE_TO_BARE_LAND; break;
case ROADSIDE_GRASS: break;
default: image += 4; break; // Paved
}
} }
DrawGroundSprite(image); DrawGroundSprite(image);
@ -866,20 +874,21 @@ static void AnimateTile_Road(TileIndex tile)
if (IsLevelCrossing(tile)) MarkTileDirtyByTile(tile); if (IsLevelCrossing(tile)) MarkTileDirtyByTile(tile);
} }
static const RoadGroundType _town_road_types[5][2] = {
{RGT_GRASS,RGT_GRASS}, static const Roadside _town_road_types[][2] = {
{RGT_PAVED,RGT_PAVED}, { ROADSIDE_GRASS, ROADSIDE_GRASS },
{RGT_PAVED,RGT_PAVED}, { ROADSIDE_PAVED, ROADSIDE_PAVED },
{RGT_ALLEY,RGT_ALLEY}, { ROADSIDE_PAVED, ROADSIDE_PAVED },
{RGT_LIGHT,RGT_PAVED}, { ROADSIDE_TREES, ROADSIDE_TREES },
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
}; };
static const RoadGroundType _town_road_types_2[5][2] = { static const Roadside _town_road_types_2[][2] = {
{RGT_GRASS,RGT_GRASS}, { ROADSIDE_GRASS, ROADSIDE_GRASS },
{RGT_PAVED,RGT_PAVED}, { ROADSIDE_PAVED, ROADSIDE_PAVED },
{RGT_LIGHT,RGT_PAVED}, { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED },
{RGT_LIGHT,RGT_PAVED}, { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED },
{RGT_LIGHT,RGT_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) */ /* 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]; const Roadside* new_rs = (_opt.landscape == LT_CANDY) ? _town_road_types_2[grp] : _town_road_types[grp];
RoadGroundType rgt = GetGroundType(tile); Roadside cur_rs = GetRoadside(tile);
/* We have our desired type, do nothing */ /* 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 */ /* We have the pre-type of the desired type, switch to the desired type */
if (rgt == target_rgt[1]) { if (cur_rs == new_rs[1]) {
rgt = target_rgt[0]; cur_rs = new_rs[0];
/* We have barren land, install the pre-type */ /* We have barren land, install the pre-type */
} else if (rgt == RGT_BARREN) { } else if (cur_rs == ROADSIDE_BARREN) {
rgt = target_rgt[1]; cur_rs = new_rs[1];
/* We're totally off limits, remove any installation and make barren land */ /* We're totally off limits, remove any installation and make barren land */
} else { } else {
rgt = RGT_BARREN; cur_rs = ROADSIDE_BARREN;
} }
SetGroundType(tile, rgt); SetRoadside(tile, cur_rs);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }
} else if (IncreaseRoadWorksCounter(tile)) { } else if (IncreaseRoadWorksCounter(tile)) {
@ -1018,7 +1027,7 @@ static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
switch (GetRoadTileType(tile)) { switch (GetRoadTileType(tile)) {
case ROAD_TILE_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break; 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; 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;
} }
} }

View File

@ -104,32 +104,30 @@ static inline void ToggleSnow(TileIndex t)
TOGGLEBIT(_m[t].m4, 7); 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 typedef enum Roadside {
} RoadGroundType; 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) 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) static inline bool IncreaseRoadWorksCounter(TileIndex t)
@ -143,25 +141,21 @@ static inline void StartRoadWorks(TileIndex t)
{ {
assert(!HasRoadWorks(t)); assert(!HasRoadWorks(t));
/* Remove any trees or lamps in case or roadwork */ /* Remove any trees or lamps in case or roadwork */
switch (GetGroundType(t)) { switch (GetRoadside(t)) {
case RGT_BARREN: case ROADSIDE_BARREN:
case RGT_GRASS: SetGroundType(t, RGT_ROADWORK_GRASS); break; case ROADSIDE_GRASS: SetRoadside(t, ROADSIDE_GRASS_ROAD_WORKS); break;
default: SetGroundType(t, RGT_ROADWORK_PAVED); break; default: SetRoadside(t, ROADSIDE_PAVED_ROAD_WORKS); break;
} }
} }
static inline void TerminateRoadWorks(TileIndex t) static inline void TerminateRoadWorks(TileIndex t)
{ {
assert(HasRoadWorks(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 */ /* Stop the counter */
SB(_m[t].m4, 0, 4, 0); 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) static inline DiagDirection GetRoadDepotDirection(TileIndex t)
{ {