mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r13016) -Codechange: unify the detection if rail catenary should be drawn
This commit is contained in:
parent
4a11ebe76f
commit
386a3f1d20
@ -967,6 +967,10 @@
|
|||||||
RelativePath=".\..\src\effectvehicle_base.h"
|
RelativePath=".\..\src\effectvehicle_base.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\elrail_func.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\core\endian_func.hpp"
|
RelativePath=".\..\src\core\endian_func.hpp"
|
||||||
>
|
>
|
||||||
|
@ -964,6 +964,10 @@
|
|||||||
RelativePath=".\..\src\effectvehicle_base.h"
|
RelativePath=".\..\src\effectvehicle_base.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\elrail_func.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\core\endian_func.hpp"
|
RelativePath=".\..\src\core\endian_func.hpp"
|
||||||
>
|
>
|
||||||
|
@ -167,6 +167,7 @@ economy_func.h
|
|||||||
economy_type.h
|
economy_type.h
|
||||||
effectvehicle_func.h
|
effectvehicle_func.h
|
||||||
effectvehicle_base.h
|
effectvehicle_base.h
|
||||||
|
elrail_func.h
|
||||||
core/endian_func.hpp
|
core/endian_func.hpp
|
||||||
engine_base.h
|
engine_base.h
|
||||||
engine_func.h
|
engine_func.h
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
#include "player_base.h"
|
#include "player_base.h"
|
||||||
#include "tunnelbridge.h"
|
#include "tunnelbridge.h"
|
||||||
#include "engine_func.h"
|
#include "engine_func.h"
|
||||||
|
#include "elrail_func.h"
|
||||||
#include "engine_base.h"
|
#include "engine_base.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
@ -182,8 +183,6 @@ void DrawCatenaryOnTunnel(const TileInfo *ti)
|
|||||||
{ 1, 0, 15, 16 }, // NW
|
{ 1, 0, 15, 16 }, // NW
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!HasCatenary(GetRailType(ti->tile)) || _patches.disable_elrails) return;
|
|
||||||
|
|
||||||
DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
|
DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
|
||||||
|
|
||||||
const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[dir];
|
const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[dir];
|
||||||
@ -382,11 +381,6 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
|||||||
|
|
||||||
void DrawCatenaryOnBridge(const TileInfo *ti)
|
void DrawCatenaryOnBridge(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
if (_patches.disable_elrails) return;
|
|
||||||
|
|
||||||
/* Do not draw catenary if it is invisible */
|
|
||||||
if (IsInvisibilitySet(TO_CATENARY)) return;
|
|
||||||
|
|
||||||
TileIndex end = GetSouthernBridgeEnd(ti->tile);
|
TileIndex end = GetSouthernBridgeEnd(ti->tile);
|
||||||
TileIndex start = GetOtherBridgeEnd(end);
|
TileIndex start = GetOtherBridgeEnd(end);
|
||||||
|
|
||||||
@ -440,11 +434,6 @@ void DrawCatenaryOnBridge(const TileInfo *ti)
|
|||||||
|
|
||||||
void DrawCatenary(const TileInfo *ti)
|
void DrawCatenary(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
if (_patches.disable_elrails) return;
|
|
||||||
|
|
||||||
/* Do not draw catenary if it is invisible */
|
|
||||||
if (IsInvisibilitySet(TO_CATENARY)) return;
|
|
||||||
|
|
||||||
switch (GetTileType(ti->tile)) {
|
switch (GetTileType(ti->tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (IsRailDepot(ti->tile)) {
|
if (IsRailDepot(ti->tile)) {
|
||||||
|
42
src/elrail_func.h
Normal file
42
src/elrail_func.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file elrail_func.h header file for electrified rail specific functions */
|
||||||
|
|
||||||
|
#ifndef ELRAIL_FUNC_H
|
||||||
|
#define ELRAIL_FUNC_H
|
||||||
|
|
||||||
|
#include "rail.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
#include "tile_cmd.h"
|
||||||
|
#include "settings_type.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if a rail type has catenary
|
||||||
|
* @param rt Rail type to test
|
||||||
|
*/
|
||||||
|
static inline bool HasCatenary(RailType rt)
|
||||||
|
{
|
||||||
|
return HasBit(GetRailTypeInfo(rt)->flags, RTF_CATENARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if we should draw rail catenary
|
||||||
|
* @param rt Rail type to test
|
||||||
|
*/
|
||||||
|
static inline bool HasCatenaryDrawn(RailType rt)
|
||||||
|
{
|
||||||
|
return HasCatenary(rt) && !IsInvisibilitySet(TO_CATENARY) && !_patches.disable_elrails;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws overhead wires and pylons for electric railways.
|
||||||
|
* @param ti The TileInfo struct of the tile being drawn
|
||||||
|
* @see DrawCatenaryRailway
|
||||||
|
*/
|
||||||
|
void DrawCatenary(const TileInfo *ti);
|
||||||
|
void DrawCatenaryOnTunnel(const TileInfo *ti);
|
||||||
|
void DrawCatenaryOnBridge(const TileInfo *ti);
|
||||||
|
|
||||||
|
int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
|
||||||
|
|
||||||
|
#endif /* ELRAIL_FUNC_H */
|
@ -5,6 +5,7 @@
|
|||||||
#include "../stdafx.h"
|
#include "../stdafx.h"
|
||||||
#include "../openttd.h"
|
#include "../openttd.h"
|
||||||
#include "../direction_type.h"
|
#include "../direction_type.h"
|
||||||
|
#include "../strings_type.h"
|
||||||
#include "../rail.h"
|
#include "../rail.h"
|
||||||
#include "../rail_map.h"
|
#include "../rail_map.h"
|
||||||
#include "dbg_helpers.h"
|
#include "dbg_helpers.h"
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#include "cheat_func.h"
|
#include "cheat_func.h"
|
||||||
#include "animated_tile_func.h"
|
#include "animated_tile_func.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
#include "elrail_func.h"
|
||||||
#include "rev.h"
|
#include "rev.h"
|
||||||
|
|
||||||
#include "newgrf.h"
|
#include "newgrf.h"
|
||||||
|
23
src/rail.h
23
src/rail.h
@ -11,7 +11,7 @@
|
|||||||
#include "gfx_type.h"
|
#include "gfx_type.h"
|
||||||
#include "core/bitmath_func.hpp"
|
#include "core/bitmath_func.hpp"
|
||||||
#include "economy_func.h"
|
#include "economy_func.h"
|
||||||
#include "tile_cmd.h"
|
#include "slope_type.h"
|
||||||
|
|
||||||
enum RailTypeFlag {
|
enum RailTypeFlag {
|
||||||
RTF_CATENARY = 0, ///< Set if the rail type should have catenary drawn
|
RTF_CATENARY = 0, ///< Set if the rail type should have catenary drawn
|
||||||
@ -198,29 +198,8 @@ void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
|
|||||||
void *EnsureNoTrainOnTrackProc(Vehicle *v, void *data);
|
void *EnsureNoTrainOnTrackProc(Vehicle *v, void *data);
|
||||||
int TicksToLeaveDepot(const Vehicle *v);
|
int TicksToLeaveDepot(const Vehicle *v);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if a rail type has catenary
|
|
||||||
* @param rt Rail type to test
|
|
||||||
*/
|
|
||||||
static inline bool HasCatenary(RailType rt)
|
|
||||||
{
|
|
||||||
return HasBit(GetRailTypeInfo(rt)->flags, RTF_CATENARY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draws overhead wires and pylons for electric railways.
|
|
||||||
* @param ti The TileInfo struct of the tile being drawn
|
|
||||||
* @see DrawCatenaryRailway
|
|
||||||
*/
|
|
||||||
void DrawCatenary(const TileInfo *ti);
|
|
||||||
void DrawCatenaryOnTunnel(const TileInfo *ti);
|
|
||||||
void DrawCatenaryOnBridge(const TileInfo *ti);
|
|
||||||
|
|
||||||
Foundation GetRailFoundation(Slope tileh, TrackBits bits);
|
Foundation GetRailFoundation(Slope tileh, TrackBits bits);
|
||||||
|
|
||||||
int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds out if a Player has a certain railtype available
|
* Finds out if a Player has a certain railtype available
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include "station_map.h"
|
#include "station_map.h"
|
||||||
#include "water_map.h"
|
#include "water_map.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
#include "elrail_func.h"
|
||||||
#include "oldpool_func.h"
|
#include "oldpool_func.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
@ -1762,7 +1763,7 @@ static void DrawTile_Track(TileInfo *ti)
|
|||||||
|
|
||||||
if (HasBit(_display_opt, DO_FULL_DETAIL)) DrawTrackDetails(ti);
|
if (HasBit(_display_opt, DO_FULL_DETAIL)) DrawTrackDetails(ti);
|
||||||
|
|
||||||
if (HasCatenary(GetRailType(ti->tile))) DrawCatenary(ti);
|
if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
|
||||||
|
|
||||||
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails);
|
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails);
|
||||||
} else {
|
} else {
|
||||||
@ -1841,7 +1842,7 @@ default_waypoint:
|
|||||||
|
|
||||||
DrawGroundSprite(image, PAL_NONE);
|
DrawGroundSprite(image, PAL_NONE);
|
||||||
|
|
||||||
if (HasCatenary(GetRailType(ti->tile))) DrawCatenary(ti);
|
if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
|
||||||
|
|
||||||
/* End now if buildings are invisible */
|
/* End now if buildings are invisible */
|
||||||
if (IsInvisibilitySet(TO_BUILDINGS)) return;
|
if (IsInvisibilitySet(TO_BUILDINGS)) return;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "cheat_func.h"
|
#include "cheat_func.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "effectvehicle_func.h"
|
#include "effectvehicle_func.h"
|
||||||
|
#include "elrail_func.h"
|
||||||
#include "oldpool_func.h"
|
#include "oldpool_func.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
@ -1139,7 +1140,7 @@ static void DrawTile_Road(TileInfo *ti)
|
|||||||
DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal);
|
DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal);
|
||||||
DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
|
DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
|
||||||
}
|
}
|
||||||
if (HasCatenary(GetRailType(ti->tile))) DrawCatenary(ti);
|
if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "textbuf_gui.h"
|
#include "textbuf_gui.h"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
#include "rail_gui.h"
|
#include "rail_gui.h"
|
||||||
|
#include "elrail_func.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "town.h"
|
#include "town.h"
|
||||||
#include "video/video_driver.hpp"
|
#include "video/video_driver.hpp"
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "signal_func.h"
|
#include "signal_func.h"
|
||||||
#include "oldpool_func.h"
|
#include "oldpool_func.h"
|
||||||
#include "animated_tile_func.h"
|
#include "animated_tile_func.h"
|
||||||
|
#include "elrail_func.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
@ -2106,7 +2107,7 @@ static void DrawTile_Station(TileInfo *ti)
|
|||||||
DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE);
|
DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsRailwayStation(ti->tile) && HasCatenary(GetRailType(ti->tile)) && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
|
if (IsRailwayStation(ti->tile) && HasCatenaryDrawn(GetRailType(ti->tile)) && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
|
||||||
|
|
||||||
if (HasBit(roadtypes, ROADTYPE_TRAM)) {
|
if (HasBit(roadtypes, ROADTYPE_TRAM)) {
|
||||||
Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
|
Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "economy_func.h"
|
#include "economy_func.h"
|
||||||
#include "rail.h"
|
#include "rail.h"
|
||||||
#include "cheat_func.h"
|
#include "cheat_func.h"
|
||||||
|
#include "elrail_func.h"
|
||||||
#include "landscape_type.h"
|
#include "landscape_type.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
@ -887,7 +888,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
|||||||
AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
|
AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!IsInvisibilitySet(TO_CATENARY) && HasCatenary(GetRailType(ti->tile))) {
|
} else if (HasCatenaryDrawn(GetRailType(ti->tile))) {
|
||||||
catenary = true;
|
catenary = true;
|
||||||
StartSpriteCombine();
|
StartSpriteCombine();
|
||||||
DrawCatenaryOnTunnel(ti);
|
DrawCatenaryOnTunnel(ti);
|
||||||
@ -960,7 +961,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
|||||||
DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true);
|
DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true);
|
||||||
}
|
}
|
||||||
EndSpriteCombine();
|
EndSpriteCombine();
|
||||||
} else if (HasCatenary(GetRailType(ti->tile))) {
|
} else if (HasCatenaryDrawn(GetRailType(ti->tile))) {
|
||||||
DrawCatenary(ti);
|
DrawCatenary(ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1088,7 +1089,7 @@ void DrawBridgeMiddle(const TileInfo* ti)
|
|||||||
EndSpriteCombine();
|
EndSpriteCombine();
|
||||||
StartSpriteCombine();
|
StartSpriteCombine();
|
||||||
}
|
}
|
||||||
} else if (HasCatenary(GetRailType(rampsouth))) {
|
} else if (HasCatenaryDrawn(GetRailType(rampsouth))) {
|
||||||
DrawCatenaryOnBridge(ti);
|
DrawCatenaryOnBridge(ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user