mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r3889) Change a part of the bridge drawing code to make it more comprehensible and add the needed accessors
This commit is contained in:
parent
dcf6c85bf2
commit
f262ae6c8b
17
bridge_map.h
17
bridge_map.h
@ -28,6 +28,23 @@ static inline DiagDirection GetBridgeRampDirection(TileIndex t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool IsClearUnderBridge(TileIndex t)
|
||||||
|
{
|
||||||
|
return GB(_m[t].m5, 3, 3) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool IsTransportUnderBridge(TileIndex t)
|
||||||
|
{
|
||||||
|
return HASBIT(_m[t].m5, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline TransportType GetTransportTypeUnderBridge(TileIndex t)
|
||||||
|
{
|
||||||
|
return (TransportType)GB(_m[t].m5, 3, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starting at one bridge end finds the other bridge end
|
* Starting at one bridge end finds the other bridge end
|
||||||
*/
|
*/
|
||||||
|
@ -26,10 +26,6 @@
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const SpriteID _bridge_land_below[] = {
|
|
||||||
SPR_FLAT_GRASS_TILE, SPR_FLAT_WATER_TILE, SPR_FLAT_SNOWY_TILE, SPR_FLAT_WATER_TILE
|
|
||||||
};
|
|
||||||
|
|
||||||
static const PalSpriteID _bridge_sprite_table_2_0[] = {
|
static const PalSpriteID _bridge_sprite_table_2_0[] = {
|
||||||
0x9C3, 0x9C7, 0x9C9, 0x0, 0x9C4, 0x9C8, 0x9CA, 0x0,
|
0x9C3, 0x9C7, 0x9C9, 0x0, 0x9C4, 0x9C8, 0x9CA, 0x0,
|
||||||
0x9C5, 0x9C7, 0x9C9, 0x0, 0x9C6, 0x9C8, 0x9CA, 0x0,
|
0x9C5, 0x9C7, 0x9C9, 0x0, 0x9C6, 0x9C8, 0x9CA, 0x0,
|
||||||
|
@ -1033,23 +1033,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
|||||||
uint z;
|
uint z;
|
||||||
int x,y;
|
int x,y;
|
||||||
|
|
||||||
image = GB(ti->map5, 3, 2); // type of stuff under bridge (only defined for 0,1)
|
if (IsTransportUnderBridge(ti->tile)) {
|
||||||
/** @todo So why do we even WASTE that one bit?! (map5, bit 4) */
|
|
||||||
assert(image <= 1);
|
|
||||||
|
|
||||||
if (!(ti->map5 & 0x20)) {
|
|
||||||
// draw land under bridge
|
|
||||||
if (ice) image += 2;
|
|
||||||
|
|
||||||
if (image != 1 || ti->tileh == 0) {
|
|
||||||
DrawGroundSprite(_bridge_land_below[image] + _tileh_to_sprite[ti->tileh]);
|
|
||||||
} else {
|
|
||||||
DrawGroundSprite(_water_shore_sprites[ti->tileh]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw canal water?
|
|
||||||
if (ti->map5 & 8 && ti->z != 0) DrawCanalWater(ti->tile);
|
|
||||||
} else {
|
|
||||||
// draw transport route under bridge
|
// draw transport route under bridge
|
||||||
|
|
||||||
// draw foundation?
|
// draw foundation?
|
||||||
@ -1058,9 +1042,9 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
|||||||
if (f) DrawFoundation(ti, f);
|
if (f) DrawFoundation(ti, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(image&1)) {
|
if (GetTransportTypeUnderBridge(ti->tile) == TRANSPORT_RAIL) {
|
||||||
const RailtypeInfo *rti = GetRailTypeInfo(GB(_m[ti->tile].m3, 0, 4));
|
const RailtypeInfo *rti = GetRailTypeInfo(GB(_m[ti->tile].m3, 0, 4));
|
||||||
// railway
|
|
||||||
image = SPR_RAIL_TRACK_Y + (ti->map5 & 1);
|
image = SPR_RAIL_TRACK_Y + (ti->map5 & 1);
|
||||||
if (ti->tileh != 0) image = SPR_RAIL_TRACK_Y + _track_sloped_sprites[ti->tileh - 1];
|
if (ti->tileh != 0) image = SPR_RAIL_TRACK_Y + _track_sloped_sprites[ti->tileh - 1];
|
||||||
image += rti->total_offset;
|
image += rti->total_offset;
|
||||||
@ -1072,6 +1056,18 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
|||||||
if (ice) image += 19;
|
if (ice) image += 19;
|
||||||
}
|
}
|
||||||
DrawGroundSprite(image);
|
DrawGroundSprite(image);
|
||||||
|
} else {
|
||||||
|
if (IsClearUnderBridge(ti->tile)) {
|
||||||
|
image = (ice ? SPR_FLAT_SNOWY_TILE : SPR_FLAT_GRASS_TILE);
|
||||||
|
DrawGroundSprite(image + _tileh_to_sprite[ti->tileh]);
|
||||||
|
} else {
|
||||||
|
if (ti->tileh == 0) {
|
||||||
|
DrawGroundSprite(SPR_FLAT_WATER_TILE);
|
||||||
|
if (ti->z != 0) DrawCanalWater(ti->tile);
|
||||||
|
} else {
|
||||||
|
DrawGroundSprite(_water_shore_sprites[ti->tileh]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cope for the direction of the bridge */
|
/* Cope for the direction of the bridge */
|
||||||
|
Loading…
Reference in New Issue
Block a user