summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--projects/openttd_vs80.vcproj4
-rw-r--r--projects/openttd_vs90.vcproj4
-rw-r--r--source.list1
-rw-r--r--src/elrail.cpp13
-rw-r--r--src/elrail_func.h42
-rw-r--r--src/misc/dbg_helpers.cpp1
-rw-r--r--src/openttd.cpp1
-rw-r--r--src/rail.h23
-rw-r--r--src/rail_cmd.cpp5
-rw-r--r--src/road_cmd.cpp3
-rw-r--r--src/settings.cpp1
-rw-r--r--src/station_cmd.cpp3
-rw-r--r--src/tunnelbridge_cmd.cpp7
13 files changed, 67 insertions, 41 deletions
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 6f71224f7..caec08917 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -968,6 +968,10 @@
>
</File>
<File
+ RelativePath=".\..\src\elrail_func.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\core\endian_func.hpp"
>
</File>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index a89a3a3fb..b84ebdc71 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -965,6 +965,10 @@
>
</File>
<File
+ RelativePath=".\..\src\elrail_func.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\core\endian_func.hpp"
>
</File>
diff --git a/source.list b/source.list
index 1a9448717..12da54bde 100644
--- a/source.list
+++ b/source.list
@@ -167,6 +167,7 @@ economy_func.h
economy_type.h
effectvehicle_func.h
effectvehicle_base.h
+elrail_func.h
core/endian_func.hpp
engine_base.h
engine_func.h
diff --git a/src/elrail.cpp b/src/elrail.cpp
index 1db2471a7..81ddb3dea 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -67,6 +67,7 @@
#include "player_base.h"
#include "tunnelbridge.h"
#include "engine_func.h"
+#include "elrail_func.h"
#include "engine_base.h"
#include "table/sprites.h"
@@ -182,8 +183,6 @@ void DrawCatenaryOnTunnel(const TileInfo *ti)
{ 1, 0, 15, 16 }, // NW
};
- if (!HasCatenary(GetRailType(ti->tile)) || _patches.disable_elrails) return;
-
DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[dir];
@@ -382,11 +381,6 @@ static void DrawCatenaryRailway(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 start = GetOtherBridgeEnd(end);
@@ -440,11 +434,6 @@ void DrawCatenaryOnBridge(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)) {
case MP_RAILWAY:
if (IsRailDepot(ti->tile)) {
diff --git a/src/elrail_func.h b/src/elrail_func.h
new file mode 100644
index 000000000..c65be6fa5
--- /dev/null
+++ b/src/elrail_func.h
@@ -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 */
diff --git a/src/misc/dbg_helpers.cpp b/src/misc/dbg_helpers.cpp
index c019ce5de..6db02e8ef 100644
--- a/src/misc/dbg_helpers.cpp
+++ b/src/misc/dbg_helpers.cpp
@@ -5,6 +5,7 @@
#include "../stdafx.h"
#include "../openttd.h"
#include "../direction_type.h"
+#include "../strings_type.h"
#include "../rail.h"
#include "../rail_map.h"
#include "dbg_helpers.h"
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 577a2945a..dd3448543 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -60,6 +60,7 @@
#include "cheat_func.h"
#include "animated_tile_func.h"
#include "functions.h"
+#include "elrail_func.h"
#include "rev.h"
#include "newgrf.h"
diff --git a/src/rail.h b/src/rail.h
index 07ccb5204..331674f30 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -11,7 +11,7 @@
#include "gfx_type.h"
#include "core/bitmath_func.hpp"
#include "economy_func.h"
-#include "tile_cmd.h"
+#include "slope_type.h"
enum RailTypeFlag {
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);
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);
-int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
/**
* Finds out if a Player has a certain railtype available
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 991751e9c..012085a2f 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -44,6 +44,7 @@
#include "station_map.h"
#include "water_map.h"
#include "functions.h"
+#include "elrail_func.h"
#include "oldpool_func.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 (HasCatenary(GetRailType(ti->tile))) DrawCatenary(ti);
+ if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails);
} else {
@@ -1841,7 +1842,7 @@ default_waypoint:
DrawGroundSprite(image, PAL_NONE);
- if (HasCatenary(GetRailType(ti->tile))) DrawCatenary(ti);
+ if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
/* End now if buildings are invisible */
if (IsInvisibilitySet(TO_BUILDINGS)) return;
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 01b414661..19758274c 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -37,6 +37,7 @@
#include "cheat_func.h"
#include "functions.h"
#include "effectvehicle_func.h"
+#include "elrail_func.h"
#include "oldpool_func.h"
#include "table/sprites.h"
@@ -1139,7 +1140,7 @@ static void DrawTile_Road(TileInfo *ti)
DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal);
DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
}
- if (HasCatenary(GetRailType(ti->tile))) DrawCatenary(ti);
+ if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
break;
}
diff --git a/src/settings.cpp b/src/settings.cpp
index 8d5e46bba..d109e1a1e 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -53,6 +53,7 @@
#include "textbuf_gui.h"
#include "string_func.h"
#include "rail_gui.h"
+#include "elrail_func.h"
#include "gui.h"
#include "town.h"
#include "video/video_driver.hpp"
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index a2bd618d2..f97ac5d2b 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -42,6 +42,7 @@
#include "signal_func.h"
#include "oldpool_func.h"
#include "animated_tile_func.h"
+#include "elrail_func.h"
#include "table/sprites.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);
}
- 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)) {
Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index a95c3bfbc..96c57833c 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -39,6 +39,7 @@
#include "economy_func.h"
#include "rail.h"
#include "cheat_func.h"
+#include "elrail_func.h"
#include "landscape_type.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);
}
}
- } else if (!IsInvisibilitySet(TO_CATENARY) && HasCatenary(GetRailType(ti->tile))) {
+ } else if (HasCatenaryDrawn(GetRailType(ti->tile))) {
catenary = true;
StartSpriteCombine();
DrawCatenaryOnTunnel(ti);
@@ -960,7 +961,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true);
}
EndSpriteCombine();
- } else if (HasCatenary(GetRailType(ti->tile))) {
+ } else if (HasCatenaryDrawn(GetRailType(ti->tile))) {
DrawCatenary(ti);
}
@@ -1088,7 +1089,7 @@ void DrawBridgeMiddle(const TileInfo* ti)
EndSpriteCombine();
StartSpriteCombine();
}
- } else if (HasCatenary(GetRailType(rampsouth))) {
+ } else if (HasCatenaryDrawn(GetRailType(rampsouth))) {
DrawCatenaryOnBridge(ti);
}