diff options
author | michi_cc <michi_cc@openttd.org> | 2010-07-02 16:34:11 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2010-07-02 16:34:11 +0000 |
commit | 34f32cbbf47b2cb332b51342c429da93856281d7 (patch) | |
tree | cfeca95505173e09a25326035c3d643de143b587 /src | |
parent | a75583bbb6d600d51f76edc396279aa0fe6f4c32 (diff) | |
download | openttd-34f32cbbf47b2cb332b51342c429da93856281d7.tar.xz |
(svn r20049) -Feature: [NewGRF] Add a railtype flag to disallow level crossings per railtype.
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/api/ai_changelog.hpp | 1 | ||||
-rw-r--r-- | src/ai/api/ai_rail.hpp | 3 | ||||
-rw-r--r-- | src/ai/api/ai_rail.hpp.sq | 3 | ||||
-rw-r--r-- | src/lang/english.txt | 1 | ||||
-rw-r--r-- | src/rail.h | 18 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 2 | ||||
-rw-r--r-- | src/road_cmd.cpp | 4 |
7 files changed, 29 insertions, 3 deletions
diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp index c748066cd..e907ce007 100644 --- a/src/ai/api/ai_changelog.hpp +++ b/src/ai/api/ai_changelog.hpp @@ -22,6 +22,7 @@ * \li IsEnd for all lists. * \li AIIndustry::GetIndustryID * \li AIRail::GetMaxSpeed + * \li AIRail::ERR_RAILTYPE_DISALLOWS_CROSSING * * API removals: * \li HasNext for all lists. diff --git a/src/ai/api/ai_rail.hpp b/src/ai/api/ai_rail.hpp index 807248243..26d649aa4 100644 --- a/src/ai/api/ai_rail.hpp +++ b/src/ai/api/ai_rail.hpp @@ -38,6 +38,9 @@ public: /** Non-uniform stations is diabled */ ERR_NONUNIFORM_STATIONS_DISABLED, // [STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED] + + /** This railtype cannot have crossings */ + ERR_RAILTYPE_DISALLOWS_CROSSING, // [STR_ERROR_CROSSING_DISALLOWED] }; /** diff --git a/src/ai/api/ai_rail.hpp.sq b/src/ai/api/ai_rail.hpp.sq index 30c875c4e..04ddfb1a0 100644 --- a/src/ai/api/ai_rail.hpp.sq +++ b/src/ai/api/ai_rail.hpp.sq @@ -42,6 +42,7 @@ void SQAIRail_Register(Squirrel *engine) SQAIRail.DefSQConst(engine, AIRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD"); SQAIRail.DefSQConst(engine, AIRail::ERR_UNSUITABLE_TRACK, "ERR_UNSUITABLE_TRACK"); SQAIRail.DefSQConst(engine, AIRail::ERR_NONUNIFORM_STATIONS_DISABLED, "ERR_NONUNIFORM_STATIONS_DISABLED"); + SQAIRail.DefSQConst(engine, AIRail::ERR_RAILTYPE_DISALLOWS_CROSSING, "ERR_RAILTYPE_DISALLOWS_CROSSING"); SQAIRail.DefSQConst(engine, AIRail::RAILTYPE_INVALID, "RAILTYPE_INVALID"); SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_NE_SW, "RAILTRACK_NE_SW"); SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_NW_SE, "RAILTRACK_NW_SE"); @@ -71,10 +72,12 @@ void SQAIRail_Register(Squirrel *engine) AIError::RegisterErrorMap(STR_ERROR_CROSSING_ON_ONEWAY_ROAD, AIRail::ERR_CROSSING_ON_ONEWAY_ROAD); AIError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, AIRail::ERR_UNSUITABLE_TRACK); AIError::RegisterErrorMap(STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED, AIRail::ERR_NONUNIFORM_STATIONS_DISABLED); + AIError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED, AIRail::ERR_RAILTYPE_DISALLOWS_CROSSING); AIError::RegisterErrorMapString(AIRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD"); AIError::RegisterErrorMapString(AIRail::ERR_UNSUITABLE_TRACK, "ERR_UNSUITABLE_TRACK"); AIError::RegisterErrorMapString(AIRail::ERR_NONUNIFORM_STATIONS_DISABLED, "ERR_NONUNIFORM_STATIONS_DISABLED"); + AIError::RegisterErrorMapString(AIRail::ERR_RAILTYPE_DISALLOWS_CROSSING, "ERR_RAILTYPE_DISALLOWS_CROSSING"); SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTile, "IsRailTile", 2, ".i"); SQAIRail.DefSQStaticMethod(engine, &AIRail::IsLevelCrossingTile, "IsLevelCrossingTile", 2, ".i"); diff --git a/src/lang/english.txt b/src/lang/english.txt index f5bdda74a..ea84f1dfd 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3543,6 +3543,7 @@ STR_ERROR_MUST_REMOVE_SIGNALS_FIRST :{WHITE}Must rem STR_ERROR_NO_SUITABLE_RAILROAD_TRACK :{WHITE}No suitable railway track STR_ERROR_MUST_REMOVE_RAILROAD_TRACK :{WHITE}Must remove railway track first STR_ERROR_CROSSING_ON_ONEWAY_ROAD :{WHITE}Road is one way or blocked +STR_ERROR_CROSSING_DISALLOWED :{WHITE}Level crossings not allowed for this rail type STR_ERROR_CAN_T_BUILD_SIGNALS_HERE :{WHITE}Can't build signals here... STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK :{WHITE}Can't build railway track here... STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK :{WHITE}Can't remove railway track from here... diff --git a/src/rail.h b/src/rail.h index 01af4f369..7a05eda73 100644 --- a/src/rail.h +++ b/src/rail.h @@ -22,10 +22,12 @@ /** Railtype flags. */ enum RailTypeFlags { - RTF_CATENARY = 0, ///< Bit number for drawing a catenary. + RTF_CATENARY = 0, ///< Bit number for drawing a catenary. + RTF_NO_LEVEL_CROSSING = 1, ///< Bit number for disallowing level crossings. - RTFB_NONE = 0, ///< All flags cleared. - RTFB_CATENARY = 1 << RTF_CATENARY, ///< Value for drawing a catenary. + RTFB_NONE = 0, ///< All flags cleared. + RTFB_CATENARY = 1 << RTF_CATENARY, ///< Value for drawing a catenary. + RTFB_NO_LEVEL_CROSSING = 1 << RTF_NO_LEVEL_CROSSING, ///< Value for disallowing level crossings. }; DECLARE_ENUM_AS_BIT_SET(RailTypeFlags) @@ -259,6 +261,16 @@ static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype) } /** + * Test if a RailType disallows build of level crossings. + * @param rt The RailType to check. + * @return Whether level crossings are not allowed. + */ +static inline bool RailNoLevelCrossings(RailType rt) +{ + return HasBit(GetRailTypeInfo(rt)->flags, RTF_NO_LEVEL_CROSSING); +} + +/** * Returns the cost of building the specified railtype. * @param railtype The railtype being built. * @return The cost multiplier. diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 86eaa5ca2..c61503fe6 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -423,6 +423,8 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u if (GetDisallowedRoadDirections(tile) != DRD_NONE) return_cmd_error(STR_ERROR_CROSSING_ON_ONEWAY_ROAD); + if (RailNoLevelCrossings(railtype)) return_cmd_error(STR_ERROR_CROSSING_DISALLOWED); + RoadTypes roadtypes = GetRoadTypes(tile); RoadBits road = GetRoadBits(tile, ROADTYPE_ROAD); RoadBits tram = GetRoadBits(tile, ROADTYPE_TRAM); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 772887e90..515237f38 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -546,6 +546,10 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (GetRailTileType(tile) != RAIL_TILE_NORMAL) goto do_clear; + if (RailNoLevelCrossings(GetRailType(tile))) { + return_cmd_error(STR_ERROR_CROSSING_DISALLOWED); + } + Axis roaddir; switch (GetTrackBits(tile)) { case TRACK_BIT_X: |