mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r5317) s/RGT_/ROADSIDE_/ and some minor changes
This commit is contained in:
parent
10e00914f7
commit
9b6fce70a2
2
npf.c
2
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;
|
||||
|
67
road_cmd.c
67
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
44
road_map.h
44
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user