Loading

Paste #pu9wsloj2

  1. diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
  2. index 797ead1..67e8329 100644
  3. --- a/src/bridge_gui.cpp
  4. +++ b/src/bridge_gui.cpp
  5. @@ -36,6 +36,8 @@ static BridgeType _last_railbridge_type = 0;
  6.  /** The type of the last built road bridge */
  7.  static BridgeType _last_roadbridge_type = 0;
  8.  
  9. +uint8 _bridge_cur_road_subtype = 0;
  10. +
  11.  /**
  12.   * Carriage for the data we need if we want to build a bridge
  13.   */
  14. @@ -117,7 +119,10 @@ private:
  15.             case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->Get(i)->index; break;
  16.             default: break;
  17.         }
  18. -       DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index,
  19. +       // Alberth: It's hacky, but it ensures your bits are preserved (shifting 17 times in a value with width 8 is undefined behavior)
  20. +       uint32 w = _bridge_cur_road_subtype;
  21. +       w <<= 17;
  22. +       DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index | w,
  23.                     CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge);
  24.     }
  25.  
  26. @@ -358,10 +363,12 @@ static WindowDesc _build_bridge_desc(
  27.   * @param transport_type The transport type
  28.   * @param road_rail_type The road/rail type
  29.   */
  30. -void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
  31. +void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type, uint8 cur_road_subtype)
  32.  {
  33.     DeleteWindowByClass(WC_BUILD_BRIDGE);
  34.  
  35. +    _bridge_cur_road_subtype = cur_road_subtype;
  36. +
  37.     /* Data type for the bridge.
  38.      * Bit 16,15 = transport type,
  39.      *     14..8 = road/rail types,
  40. diff --git a/src/bridge_map.h b/src/bridge_map.h
  41. index 74c6974..4e7984e 100644
  42. --- a/src/bridge_map.h
  43. +++ b/src/bridge_map.h
  44. @@ -148,12 +148,16 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, D
  45.   * @param d          the direction this ramp must be facing
  46.   * @param r          the road type of the bridge
  47.   */
  48. -static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadTypes r)
  49. +static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadTypes r, uint8 cur_road_subtype)
  50.  {
  51.     MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, 0);
  52.     SetRoadOwner(t, ROADTYPE_ROAD, owner_road);
  53.     if (owner_tram != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, owner_tram);
  54.     SetRoadTypes(t, r);
  55. +   printf("!! Unfinished split between road and tram subtypes in MakeRoadBridgeRamp !! \n");
  56. +   // !! should split before calling this, and pass appropriate road and tram subtypes based on existing / new subtypes for the tile
  57. +   SetRoadSubtype(t, cur_road_subtype);
  58. +   SetTramSubtype(t, cur_road_subtype);
  59.  }
  60.  
  61.  /**
  62. diff --git a/src/gui.h b/src/gui.h
  63. index 39f1ea6..97ee592 100644
  64. --- a/src/gui.h
  65. +++ b/src/gui.h
  66. @@ -61,7 +61,7 @@ void ShowExtraViewPortWindow(TileIndex tile = INVALID_TILE);
  67.  void ShowExtraViewPortWindowForTileUnderCursor();
  68.  
  69.  /* bridge_gui.cpp */
  70. -void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type);
  71. +void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type, uint8 cur_road_subtype = 0);
  72.  
  73.  void ShowBuildIndustryWindow();
  74.  void ShowFoundTownWindow();
  75. diff --git a/src/lang/english.txt b/src/lang/english.txt
  76. index 0bd430b..b02e251 100644
  77. --- a/src/lang/english.txt
  78. +++ b/src/lang/english.txt
  79. @@ -439,8 +439,13 @@ STR_RAIL_MENU_MAGLEV_CONSTRUCTION                               :Maglev construc
  80.  ############ range ends here
  81.  
  82.  ############ range for road construction menu starts
  83. -STR_ROAD_MENU_ROAD_CONSTRUCTION                                 :Road construction
  84. -STR_ROAD_MENU_TRAM_CONSTRUCTION                                 :Tramway construction
  85. +STR_ROAD_MENU_ROAD_CONSTRUCTION                                 :(Deprecated)
  86. +STR_ROAD_MENU_TRAM_CONSTRUCTION                                 :(Deprecated)
  87. +STR_ROAD_MENU_ROAD_CONSTRUCTION_0                               :Road construction 0
  88. +STR_ROAD_MENU_ROAD_CONSTRUCTION_1                               :Road construction 1
  89. +STR_ROAD_MENU_TRAM_CONSTRUCTION_0                               :Tramway construction 0
  90. +STR_ROAD_MENU_TRAM_CONSTRUCTION_1                               :Tramway construction 1
  91. +STR_ROAD_MENU_TRAM_CONSTRUCTION_2                               :Tramway construction 2
  92.  ############ range ends here
  93.  
  94.  ############ range for waterways construction menu starts
  95. diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp
  96. index 9f19b02..59c7777 100644
  97. --- a/src/pathfinder/follow_track.hpp
  98. +++ b/src/pathfinder/follow_track.hpp
  99. @@ -102,6 +102,7 @@ struct CFollowTrackT
  100.         assert(IsTram()); // this function shouldn't be called in other cases
  101.  
  102.         if (IsNormalRoadTile(tile)) {
  103. +            return INVALID_DIAGDIR;
  104.             RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM);
  105.             switch (rb) {
  106.                 case ROAD_NW: return DIAGDIR_NW;
  107. diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
  108. index 2010f9b..68fd2de 100644
  109. --- a/src/rail_cmd.cpp
  110. +++ b/src/rail_cmd.cpp
  111. @@ -33,6 +33,7 @@
  112.  #include "strings_func.h"
  113.  #include "company_gui.h"
  114.  #include "object_map.h"
  115. +#include "road_type.h"
  116.  
  117.  #include "table/strings.h"
  118.  #include "table/railtypes.h"
  119. @@ -636,6 +637,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
  120.                 owner = GetTileOwner(tile);
  121.                 Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR;
  122.                 DirtyCompanyInfrastructureWindows(owner);
  123. +               // !! needs subtype detection for crossings
  124.                 MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM));
  125.                 DeleteNewGRFInspectWindow(GSF_RAILTYPES, tile);
  126.             }
  127. diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
  128. index aa445eb..b566d44 100644
  129. --- a/src/road_cmd.cpp
  130. +++ b/src/road_cmd.cpp
  131. @@ -326,7 +326,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
  132.  
  133.                 if (present == ROAD_NONE) {
  134.                     RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
  135. -                   if (rts == ROADTYPES_NONE) {
  136. +                   if (!HasRoadType(rt) && !HasTramType(rt)) {
  137.                         /* Includes MarkTileDirtyByTile() */
  138.                         DoClearSquare(tile);
  139.                     } else {
  140. @@ -374,7 +374,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
  141.                 }
  142.  
  143.                 Track railtrack = GetCrossingRailTrack(tile);
  144. -               RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
  145. +               //RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
  146.                 if (rts == ROADTYPES_NONE) {
  147.                     TrackBits tracks = GetCrossingRailBits(tile);
  148.                     bool reserved = HasCrossingReservation(tile);
  149. @@ -515,6 +515,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
  150.     if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR;
  151.  
  152.     DisallowedRoadDirections toggle_drd = Extract<DisallowedRoadDirections, 6, 2>(p1);
  153. +    uint8 cur_road_subtype = GB(p1, 8, 8);
  154.  
  155.     Slope tileh = GetTileSlope(tile);
  156.  
  157. @@ -749,6 +750,8 @@ do_clear:;
  158.                     if (rt == ROADTYPE_ROAD) SetTownIndex(tile, p2);
  159.                 }
  160.                 if (rtt != ROAD_TILE_CROSSING) SetRoadBits(tile, existing | pieces, rt);
  161. +                SetRoadSubtype(tile, cur_road_subtype);
  162. +                SetTramSubtype(tile, cur_road_subtype);
  163.                 break;
  164.             }
  165.  
  166. @@ -759,6 +762,8 @@ do_clear:;
  167.                 SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
  168.                 SetRoadOwner(other_end, rt, company);
  169.                 SetRoadOwner(tile, rt, company);
  170. +               //SetBridgeRoadTramCatenary(other_end, _catenary_flag);
  171. +               //SetBridgeRoadTramCatenary(tile, _catenary_flag);
  172.  
  173.                 /* Mark tiles dirty that have been repaved */
  174.                 if (IsBridge(tile)) {
  175. @@ -777,7 +782,15 @@ do_clear:;
  176.                 break;
  177.  
  178.             default:
  179. -               MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, company, company);
  180. +               uint8 road_subtype = 0;
  181. +               uint8 tram_subtype = 0;
  182. +               if (rt == ROADTYPE_ROAD) {
  183. +                   road_subtype = cur_road_subtype;
  184. +               }
  185. +               if (rt == ROADTYPE_TRAM) {
  186. +                   tram_subtype = cur_road_subtype;
  187. +               }
  188. +               MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, company, company, road_subtype, tram_subtype);
  189.                 break;
  190.         }
  191.  
  192. @@ -794,7 +807,6 @@ do_clear:;
  193.             SetDisallowedRoadDirections(tile, IsStraightRoad(existing) ?
  194.                     GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE);
  195.         }
  196. -
  197.         MarkTileDirtyByTile(tile);
  198.     }
  199.     return cost;
  200. @@ -886,8 +898,8 @@ CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p
  201.             if (tile == end_tile && !HasBit(p2, 1)) bits &= DiagDirToRoadBits(ReverseDiagDir(dir));
  202.             if (tile == start_tile && HasBit(p2, 0)) bits &= DiagDirToRoadBits(dir);
  203.         }
  204. -
  205. -       CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD);
  206. +       uint8 _cur_road_subtype = GB(p2, 7, 8);
  207. +       CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits | _cur_road_subtype << 8 , 0, flags, CMD_BUILD_ROAD);
  208.         if (ret.Failed()) {
  209.             last_error = ret;
  210.             if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) {
  211. @@ -1298,7 +1310,7 @@ static void DrawRoadBits(TileInfo *ti)
  212.         return;
  213.     }
  214.  
  215. -   if (tram != ROAD_NONE) DrawTramCatenary(ti, tram);
  216. +   if (RoadTileHasCatenary(ti->tile)) DrawTramCatenary(ti, tram);
  217.  
  218.     /* Return if full detail is disabled, or we are zoomed fully out. */
  219.     if (!HasBit(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZOOM_LVL_DETAIL) return;
  220. @@ -1388,7 +1400,7 @@ static void DrawTile_Road(TileInfo *ti)
  221.  
  222.             if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) {
  223.                 DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal);
  224. -               DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
  225. +               if (RoadTileHasCatenary(ti->tile)) DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
  226.             }
  227.             if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
  228.             break;
  229. @@ -1623,6 +1635,21 @@ static TrackStatus GetTileTrackStatus_Road(TileIndex tile, TransportType mode, u
  230.                     RoadType rt = (RoadType)FindFirstBit(sub_mode);
  231.                     RoadBits bits = GetRoadBits(tile, rt);
  232.  
  233. +                   // subtype not sub_mode
  234. +                   uint8 road_subtype = GetRoadSubtype(tile);
  235. +                   uint8 tram_subtype = GetTramSubtype(tile);
  236. +                   // !! ROADTYPES is a bitmask afaict, testing '==' with it is a bad solution?
  237. +                   if (sub_mode == ROADTYPES_ROAD) {
  238. +                       // road
  239. +                        printf("GetTileTrackStatus_Road: road_subtype = %d \n", road_subtype);
  240. +                       if (road_subtype != 0) break;
  241. +                   }
  242. +                   if (sub_mode == ROADTYPES_TRAM) {
  243. +                       // tram
  244. +                        printf("GetTileTrackStatus_Road: tram_subtype = %d \n", tram_subtype);
  245. +                       if (tram_subtype != 0) break;
  246. +                    }
  247. +
  248.                     /* no roadbit at this side of tile, return 0 */
  249.                     if (side != INVALID_DIAGDIR && (DiagDirToRoadBits(side) & bits) == 0) break;
  250.  
  251. @@ -1757,6 +1784,7 @@ static VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int
  252.  
  253.         default: break;
  254.     }
  255. +
  256.     return VETSB_CONTINUE;
  257.  }
  258.  
  259. diff --git a/src/road_gui.cpp b/src/road_gui.cpp
  260. index 92c660e..d989048 100644
  261. --- a/src/road_gui.cpp
  262. +++ b/src/road_gui.cpp
  263. @@ -60,6 +60,7 @@ DECLARE_ENUM_AS_BIT_SET(RoadFlags)
  264.  static RoadFlags _place_road_flag;
  265.  
  266.  static RoadType _cur_roadtype;
  267. +uint8 _cur_road_subtype;
  268.  
  269.  static DiagDirection _road_depot_orientation;
  270.  static DiagDirection _road_station_picker_orientation;
  271. @@ -231,6 +232,7 @@ static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, u
  272.         ddir -= DIAGDIR_END; // Adjust picker result to actual direction.
  273.     }
  274.     p2 |= ddir << 6; // Set the DiagDirecion into p2 bits 6 and 7.
  275. +    SB(p2, 9, 1, _cur_road_subtype); // !! set _cur_road_subtype into p2 bit 9, only works whilst valid subtype values are 0-1
  276.  
  277.     TileArea ta(start_tile, end_tile);
  278.     CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop, "" };
  279. @@ -535,7 +537,7 @@ struct BuildRoadToolbarWindow : Window {
  280.                 break;
  281.  
  282.             case WID_ROT_BUILD_TUNNEL:
  283. -               DoCommandP(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0,
  284. +               DoCommandP(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), _cur_road_subtype,
  285.                         CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel);
  286.                 break;
  287.  
  288. @@ -610,7 +612,8 @@ struct BuildRoadToolbarWindow : Window {
  289.                 default: NOT_REACHED();
  290.                 case DDSP_BUILD_BRIDGE:
  291.                     if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
  292. -                   ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
  293. +                   printf("OnPlaceMouseUp: _cur_road_subtype: %d \n", _cur_road_subtype);
  294. +                   ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype), _cur_road_subtype);
  295.                     break;
  296.  
  297.                 case DDSP_DEMOLISH_AREA:
  298. @@ -626,7 +629,7 @@ struct BuildRoadToolbarWindow : Window {
  299.                      * not the 3rd bit set) */
  300.                     _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
  301.  
  302. -                   DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5),
  303. +                   DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5) | (_cur_road_subtype << 7),
  304.                             _remove_button_clicked ?
  305.                             CMD_REMOVE_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
  306.                             CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound1D);
  307. @@ -657,7 +660,7 @@ struct BuildRoadToolbarWindow : Window {
  308.  
  309.     virtual void OnPlacePresize(Point pt, TileIndex tile)
  310.     {
  311. -       DoCommand(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL);
  312. +       DoCommand(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), _cur_road_subtype, DC_AUTO, CMD_BUILD_TUNNEL);
  313.         VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
  314.     }
  315.  
  316. @@ -802,10 +805,11 @@ static WindowDesc _build_tramway_desc(
  317.   *
  318.   * @return newly opened road toolbar, or NULL if the toolbar could not be opened.
  319.   */
  320. -Window *ShowBuildRoadToolbar(RoadType roadtype)
  321. +Window *ShowBuildRoadToolbar(RoadType roadtype, uint8 road_subtype)
  322.  {
  323.     if (!Company::IsValidID(_local_company)) return NULL;
  324.     _cur_roadtype = roadtype;
  325. +   _cur_road_subtype = road_subtype;
  326.  
  327.     DeleteWindowByClass(WC_BUILD_TOOLBAR);
  328.     return AllocateWindowDescFront<BuildRoadToolbarWindow>(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
  329. diff --git a/src/road_gui.h b/src/road_gui.h
  330. index c56443c..1802e11 100644
  331. --- a/src/road_gui.h
  332. +++ b/src/road_gui.h
  333. @@ -16,7 +16,7 @@
  334.  #include "tile_type.h"
  335.  #include "direction_type.h"
  336.  
  337. -struct Window *ShowBuildRoadToolbar(RoadType roadtype);
  338. +struct Window *ShowBuildRoadToolbar(RoadType roadtype, uint8 road_subtype = 0);
  339.  struct Window *ShowBuildRoadScenToolbar();
  340.  void ConnectRoadToStructure(TileIndex tile, DiagDirection direction);
  341.  
  342. diff --git a/src/road_internal.h b/src/road_internal.h
  343. index c8cae84..0b7532b 100644
  344. --- a/src/road_internal.h
  345. +++ b/src/road_internal.h
  346. @@ -13,6 +13,7 @@
  347.  #define ROAD_INTERNAL_H
  348.  
  349.  #include "tile_cmd.h"
  350. +#include "road_map.h"
  351.  #include "road_type.h"
  352.  
  353.  RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb);
  354. @@ -21,4 +22,11 @@ CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, R
  355.  
  356.  void DrawTramCatenary(const TileInfo *ti, RoadBits tram);
  357.  
  358. +static inline bool RoadTileHasCatenary(const TileIndex tile) {
  359. +    uint8 road_subtype = GetRoadSubtype(tile);
  360. +    uint8 tram_subtype = GetTramSubtype(tile);
  361. +    return (RoadSubtypeHasCatenary(road_subtype) || TramSubtypeHasCatenary(tram_subtype));
  362. +}
  363. +
  364. +
  365.  #endif /* ROAD_INTERNAL_H */
  366. diff --git a/src/road_map.h b/src/road_map.h
  367. index 6937302..663517a 100644
  368. --- a/src/road_map.h
  369. +++ b/src/road_map.h
  370. @@ -286,6 +286,30 @@ static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirect
  371.     SB(_m[t].m5, 4, 2, drd);
  372.  }
  373.  
  374. +static inline void SetRoadSubtype(TileIndex t, uint8 subtype)
  375. +{
  376. +   assert(IsTileType(t, MP_ROAD) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
  377. +   //assert(subtype <= 3); // we're only using 2 bits here, only 4 subtypes permitted
  378. +   SB(_m[t].m4, 4, 4, subtype);
  379. +}
  380. +
  381. +static inline void SetTramSubtype(TileIndex t, uint8 subtype)
  382. +{
  383. +   assert(IsTileType(t, MP_ROAD) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
  384. +   //assert(subtype <= 3); // we're only using 2 bits here, only 4 subtypes permitted
  385. +   SB(_m[t].m4, 0, 4, subtype);
  386. +}
  387. +
  388. +static inline uint8 GetRoadSubtype(TileIndex t)
  389. +{
  390. +   return GB(_m[t].m4, 4, 4);
  391. +}
  392. +
  393. +static inline uint8 GetTramSubtype(TileIndex t)
  394. +{
  395. +   return GB(_m[t].m4, 0, 4);
  396. +}
  397. +
  398.  /**
  399.   * Get the road axis of a level crossing.
  400.   * @param t The tile to query.
  401. @@ -550,7 +574,7 @@ RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge
  402.   * @param road New owner of road.
  403.   * @param tram New owner of tram tracks.
  404.   */
  405. -static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram)
  406. +static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram, uint8 road_subtype = 0, uint8 tram_subtype = 0)
  407.  {
  408.     SetTileType(t, MP_ROAD);
  409.     SetTileOwner(t, road);
  410. @@ -561,6 +585,8 @@ static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, Tow
  411.     SB(_me[t].m6, 2, 4, 0);
  412.     _me[t].m7 = rot << 6;
  413.     SetRoadOwner(t, ROADTYPE_TRAM, tram);
  414. +   SetRoadSubtype(t, road_subtype);
  415. +   SetTramSubtype(t, tram_subtype);
  416.  }
  417.  
  418.  /**
  419. diff --git a/src/road_type.h b/src/road_type.h
  420. index 5251a53..40b961e 100644
  421. --- a/src/road_type.h
  422. +++ b/src/road_type.h
  423. @@ -29,22 +29,42 @@ enum RoadType {
  424.  DECLARE_POSTFIX_INCREMENT(RoadType)
  425.  template <> struct EnumPropsT<RoadType> : MakeEnumPropsT<RoadType, byte, ROADTYPE_BEGIN, ROADTYPE_END, INVALID_ROADTYPE, 2> {};
  426.  
  427. -/**
  428. - * The different roadtypes we support, but then a bitmask of them
  429. - * @note currently only roadtypes with ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
  430. - */
  431. +// RoadTypes, with ability to get road type, tram type, or look up roadtype given subtype
  432.  enum RoadTypes {
  433. -   ROADTYPES_NONE     = 0,                                ///< No roadtypes
  434. -   ROADTYPES_ROAD     = 1 << ROADTYPE_ROAD,               ///< Road
  435. -   ROADTYPES_TRAM     = 1 << ROADTYPE_TRAM,               ///< Trams
  436. -   ROADTYPES_ALL      = ROADTYPES_ROAD | ROADTYPES_TRAM,  ///< Road + trams
  437. -   ROADTYPES_END,                                         ///< Used for iterations?
  438. -   INVALID_ROADTYPES  = 0xFF,                             ///< Invalid roadtypes
  439. +   ROADTYPES_ROAD_BASE = 0,
  440. +   ROADTYPES_ROAD_LENGTH = 4,    ///< Number of bit
  441. +   ROADTYPES_INVALID_ROAD = 0x7, ///< Road-type denoting 'no road'.
  442. +
  443. +   ROADTYPES_TRAM_BASE = 4,      ///< Start bit of the tram types.
  444. +   ROADTYPES_TRAM_LENGTH = 4,    ///< Number of bits for the tram types.
  445. +   ROADTYPES_INVALID_TRAM = 0x7, ///< Tram-type denoting 'no tram'.
  446.  };
  447. -DECLARE_ENUM_AS_BIT_SET(RoadTypes)
  448. -template <> struct EnumPropsT<RoadTypes> : MakeEnumPropsT<RoadTypes, byte, ROADTYPES_NONE, ROADTYPES_END, INVALID_ROADTYPES, 2> {};
  449. -typedef SimpleTinyEnumT<RoadTypes, byte> RoadTypesByte;
  450.  
  451. +static inline uint8 GetRoadType(RoadTypes rt) {
  452. +   return GB(rt, ROADTYPES_ROAD_BASE, ROADTYPES_ROAD_LENGTH);
  453. +}
  454. +
  455. +static inline uint8 GetTramType(RoadTypes rt) {
  456. +   return GB(rt, ROADTYPES_TRAM_BASE, ROADTYPES_TRAM_LENGTH);
  457. +}
  458. +
  459. +static inline RoadTypes SetRoadType(RoadTypes rt, uint8 road_type) {
  460. +   assert((road_type & ((1 << ROADTYPES_ROAD_LENGTH) - 1)) == road_type);
  461. +   return (RoadTypes)SB(rt, ROADTYPES_ROAD_BASE, ROADTYPES_ROAD_LENGTH, road_type);
  462. +}
  463. +
  464. +static inline RoadTypes SetTramType(RoadTypes rt, uint8 tram_type) {
  465. +   assert((tram_type & ((1 << ROADTYPES_TRAM_LENGTH) - 1)) == tram_type);
  466. +   return (RoadTypes)SB(rt, ROADTYPES_TRAM_BASE, ROADTYPES_TRAM_LENGTH, tram_type);
  467. +}
  468. +
  469. +static inline bool HasRoadType(rt) {
  470. +    return GetRoadType(rt) != ROADTYPES_ROAD_INVALID;
  471. +}
  472. +
  473. +static inline bool HasTramType(rt) {
  474. +    return GetTramType(rt) != ROADTYPES_TRAM_INVALID;
  475. +}
  476.  
  477.  /**
  478.   * Enumeration for the road parts on a tile.
  479. @@ -73,4 +93,19 @@ enum RoadBits {
  480.  DECLARE_ENUM_AS_BIT_SET(RoadBits)
  481.  template <> struct EnumPropsT<RoadBits> : MakeEnumPropsT<RoadBits, byte, ROAD_NONE, ROAD_END, ROAD_NONE, 4> {};
  482.  
  483. +static inline bool RoadSubtypeHasCatenary(uint8 subtype) {
  484. +    if (subtype == 1) {
  485. +        return true;
  486. +    } else {
  487. +        return false;
  488. +    }
  489. +}
  490. +static inline bool TramSubtypeHasCatenary(uint8 subtype) {
  491. +    if (subtype == 1) {
  492. +        return true;
  493. +    } else {
  494. +        return false;
  495. +    }
  496. +}
  497. +
  498.  #endif /* ROAD_TYPE_H */
  499. diff --git a/src/roadveh.h b/src/roadveh.h
  500. index 5b265f0..ed2f409 100644
  501. --- a/src/roadveh.h
  502. +++ b/src/roadveh.h
  503. @@ -95,7 +95,8 @@ struct RoadVehicle FINAL : public GroundVehicle<RoadVehicle, VEH_ROAD> {
  504.     byte reverse_ctr;
  505.  
  506.     RoadType roadtype;
  507. -   RoadTypes compatible_roadtypes;
  508. +   uint8 subtype;
  509. +   uint16 compatible_roadtypes; // first 8 bits are RoadTypes, next bits are subtype
  510.  
  511.     /** We don't want GCC to zero our struct! It already is zeroed and has an index! */
  512.     RoadVehicle() : GroundVehicleBase() {}
  513. diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
  514. index 35c671d..7149bd5 100644
  515. --- a/src/roadveh_cmd.cpp
  516. +++ b/src/roadveh_cmd.cpp
  517. @@ -1208,7 +1208,7 @@ again:
  518.                 }
  519.                 if ((v->Previous() != NULL && v->Previous()->tile == tile) ||
  520.                         (v->IsFrontEngine() && IsNormalRoadTile(tile) && !HasRoadWorks(tile) &&
  521. -                           (needed & GetRoadBits(tile, ROADTYPE_TRAM)) != ROAD_NONE)) {
  522. +                           (needed & GetRoadBits(tile, ROADTYPE_TRAM)) != ROAD_NONE)  && (GetTramSubtype(tile) == 0)) {
  523.                     /*
  524.                      * Taking the 'big' corner for trams only happens when:
  525.                      * - The previous vehicle in this (articulated) tram chain is
  526. diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
  527. index eb90c29..1109193 100644
  528. --- a/src/station_cmd.cpp
  529. +++ b/src/station_cmd.cpp
  530. @@ -1759,6 +1759,11 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
  531.     bool reuse = (station_to_join != NEW_STATION);
  532.     if (!reuse) station_to_join = INVALID_STATION;
  533.     bool distant_join = (station_to_join != INVALID_STATION);
  534. +    bool catenary_flag = HasBit(p2, 9); // the setting from the selected roadtype
  535. +    bool cur_tile_catenary_flag = catenary_flag; // used to set catenary flag on any given tile
  536. +   printf("CmdBuildRoadStop called %d ", tile);
  537. +   printf("catenary_flag %d ", catenary_flag);
  538. +   printf("\n");
  539.  
  540.     uint8 width = (uint8)GB(p1, 0, 8);
  541.     uint8 lenght = (uint8)GB(p1, 8, 8);
  542. @@ -1815,6 +1820,12 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
  543.         /* Check every tile in the area. */
  544.         TILE_AREA_LOOP(cur_tile, roadstop_area) {
  545.             RoadTypes cur_rts = GetRoadTypes(cur_tile);
  546. +           // don't remove existing catenary if present
  547. +           if (RoadTileHasCatenary(cur_tile)) {
  548. +               cur_tile_catenary_flag = true;
  549. +           } else {
  550. +               cur_tile_catenary_flag = catenary_flag;
  551. +           }
  552.             Owner road_owner = HasBit(cur_rts, ROADTYPE_ROAD) ? GetRoadOwner(cur_tile, ROADTYPE_ROAD) : _current_company;
  553.             Owner tram_owner = HasBit(cur_rts, ROADTYPE_TRAM) ? GetRoadOwner(cur_tile, ROADTYPE_TRAM) : _current_company;
  554.  
  555. @@ -1851,7 +1862,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
  556.                     }
  557.                 }
  558.  
  559. -               MakeDriveThroughRoadStop(cur_tile, st->owner, road_owner, tram_owner, st->index, rs_type, rts | cur_rts, axis);
  560. +               MakeDriveThroughRoadStop(cur_tile, st->owner, road_owner, tram_owner, st->index, rs_type, rts | cur_rts, axis, cur_tile_catenary_flag);
  561.                 road_stop->MakeDriveThrough();
  562.             } else {
  563.                 /* Non-drive-through stop never overbuild and always count as two road bits. */
  564. @@ -2013,6 +2024,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
  565.     uint8 width = (uint8)GB(p1, 0, 8);
  566.     uint8 height = (uint8)GB(p1, 8, 8);
  567.     bool keep_drive_through_roads = !HasBit(p2, 1);
  568. +   bool keep_catenary = false;
  569.  
  570.     /* Check for incorrect width / height. */
  571.     if (width == 0 || height == 0) return CMD_ERROR;
  572. @@ -2030,6 +2042,11 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
  573.     TILE_AREA_LOOP(cur_tile, roadstop_area) {
  574.         /* Make sure the specified tile is a road stop of the correct type */
  575.         if (!IsTileType(cur_tile, MP_STATION) || !IsRoadStop(cur_tile) || (uint32)GetRoadStopType(cur_tile) != GB(p2, 0, 1)) continue;
  576. +        if (RoadTileHasCatenary(cur_tile)) {
  577. +            keep_catenary = true;
  578. +        } else {
  579. +            keep_catenary = false;
  580. +        }
  581.  
  582.         /* Save information on to-be-restored roads before the stop is removed. */
  583.         RoadTypes rts = ROADTYPES_NONE;
  584. @@ -2057,7 +2074,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
  585.         /* Restore roads. */
  586.         if ((flags & DC_EXEC) && rts != ROADTYPES_NONE) {
  587.             MakeRoadNormal(cur_tile, road_bits, rts, ClosestTownFromTile(cur_tile, UINT_MAX)->index,
  588. -                   road_owner[ROADTYPE_ROAD], road_owner[ROADTYPE_TRAM]);
  589. +                   road_owner[ROADTYPE_ROAD], road_owner[ROADTYPE_TRAM], keep_catenary);
  590.  
  591.             /* Update company infrastructure counts. */
  592.             RoadType rt;
  593. @@ -2902,7 +2919,7 @@ draw_default_foundation:
  594.     if (HasBit(roadtypes, ROADTYPE_TRAM)) {
  595.         Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
  596.         DrawGroundSprite((HasBit(roadtypes, ROADTYPE_ROAD) ? SPR_TRAMWAY_OVERLAY : SPR_TRAMWAY_TRAM) + (axis ^ 1), PAL_NONE);
  597. -       DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
  598. +       if (HasRoadTramCatenary(ti->tile)) DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
  599.     }
  600.  
  601.     if (IsRailWaypoint(ti->tile)) {
  602. diff --git a/src/station_map.h b/src/station_map.h
  603. index 7ca9bd7..8a101ad 100644
  604. --- a/src/station_map.h
  605. +++ b/src/station_map.h
  606. @@ -521,6 +521,17 @@ static inline byte GetStationTileRandomBits(TileIndex t)
  607.     return GB(_m[t].m3, 4, 4);
  608.  }
  609.  
  610. +static inline void SetRoadTramCatenary(TileIndex t, bool b)
  611. +{
  612. +   assert(IsTileType(t, MP_STATION));
  613. +   SB(_m[t].m1, 7, 1, b ? 1 : 0);
  614. +}
  615. +
  616. +static inline bool HasRoadTramCatenary(TileIndex t)
  617. +{
  618. +   return GB(_m[t].m1, 7, 1);
  619. +}
  620. +
  621.  /**
  622.   * Make the given tile a station tile.
  623.   * @param t the tile to make a station tile
  624. @@ -604,12 +615,13 @@ static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopTyp
  625.   * @param rt the roadtypes on this tile
  626.   * @param a the direction of the roadstop
  627.   */
  628. -static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadTypes rt, Axis a)
  629. +static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadTypes rt, Axis a, bool catenary_flag)
  630.  {
  631.     MakeStation(t, station, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
  632.     SetRoadTypes(t, rt);
  633.     SetRoadOwner(t, ROADTYPE_ROAD, road);
  634.     SetRoadOwner(t, ROADTYPE_TRAM, tram);
  635. +   SetRoadTramCatenary(t, catenary_flag);
  636.  }
  637.  
  638.  /**
  639. diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
  640. index 45d751d..c62c395 100644
  641. --- a/src/toolbar_gui.cpp
  642. +++ b/src/toolbar_gui.cpp
  643. @@ -891,7 +891,8 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w)
  644.     DropDownList *list = new DropDownList();
  645.  
  646.     /* Road is always visible and available. */
  647. -   *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION, ROADTYPE_ROAD, false);
  648. +   *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION_0, 0, false);
  649. +   *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION_1, 1, false);
  650.  
  651.     /* Tram is only visible when there will be a tram, and available when that has been introduced. */
  652.     Engine *e;
  653. @@ -899,7 +900,9 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w)
  654.         if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
  655.         if (!HasBit(e->info.misc_flags, EF_ROAD_TRAM)) continue;
  656.  
  657. -       *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION, ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
  658. +       *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION_0, 2, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
  659. +       *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION_1, 3, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
  660. +       *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION_2, 4, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
  661.         break;
  662.     }
  663.     ShowDropDownList(w, list, _last_built_roadtype, WID_TN_ROADS, 140, true, true);
  664. @@ -915,8 +918,24 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w)
  665.   */
  666.  static CallBackFunction MenuClickBuildRoad(int index)
  667.  {
  668. -   _last_built_roadtype = (RoadType)index;
  669. -   ShowBuildRoadToolbar(_last_built_roadtype);
  670. +    uint8 _last_built_road_subtype = 0;
  671. +    if (index == 0) {
  672. +       _last_built_roadtype = (RoadType)ROADTYPE_ROAD;
  673. +       _last_built_road_subtype = 0;
  674. +    } else if (index == 1) {
  675. +       _last_built_roadtype = (RoadType)ROADTYPE_ROAD;
  676. +       _last_built_road_subtype = 1;
  677. +    } else if (index == 2) {
  678. +       _last_built_roadtype = (RoadType)ROADTYPE_TRAM;
  679. +       _last_built_road_subtype = 0;
  680. +    } else if (index == 3) {
  681. +       _last_built_roadtype = (RoadType)ROADTYPE_TRAM;
  682. +       _last_built_road_subtype = 1;
  683. +    } else if (index == 4) {
  684. +       _last_built_roadtype = (RoadType)ROADTYPE_TRAM;
  685. +       _last_built_road_subtype = 2;
  686. +   }
  687. +   ShowBuildRoadToolbar(_last_built_roadtype, _last_built_road_subtype);
  688.     return CBF_NONE;
  689.  }
  690.  
  691. diff --git a/src/tunnel_map.h b/src/tunnel_map.h
  692. index e200a12..d9c24dd 100644
  693. --- a/src/tunnel_map.h
  694. +++ b/src/tunnel_map.h
  695. @@ -48,7 +48,7 @@ bool IsTunnelInWayDir(TileIndex tile, int z, DiagDirection dir);
  696.   * @param d the direction facing out of the tunnel
  697.   * @param r the road type used in the tunnel
  698.   */
  699. -static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
  700. +static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r, uint8 cur_road_subtype)
  701.  {
  702.     SetTileType(t, MP_TUNNELBRIDGE);
  703.     SetTileOwner(t, o);
  704. @@ -61,6 +61,10 @@ static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTyp
  705.     SetRoadOwner(t, ROADTYPE_ROAD, o);
  706.     if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o);
  707.     SetRoadTypes(t, r);
  708. +   printf("!! Unfinished split between road and tram subtypes in MakeRoadTunnel !! \n");
  709. +   // !! should split before calling this, and pass appropriate road and tram subtypes based on existing / new subtypes for the tile
  710. +   SetRoadSubtype(t, cur_road_subtype);
  711. +   SetTramSubtype(t, cur_road_subtype);
  712.  }
  713.  
  714.  /**
  715. diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
  716. index 5f2534b..4160cb5 100644
  717. --- a/src/tunnelbridge_cmd.cpp
  718. +++ b/src/tunnelbridge_cmd.cpp
  719. @@ -40,6 +40,7 @@
  720.  #include "object_base.h"
  721.  #include "water.h"
  722.  #include "company_gui.h"
  723. +#include "road_internal.h"
  724.  
  725.  #include "table/strings.h"
  726.  #include "table/bridge_land.h"
  727. @@ -515,8 +516,9 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
  728.                 }
  729.                 Owner owner_road = HasBit(prev_roadtypes, ROADTYPE_ROAD) ? GetRoadOwner(tile_start, ROADTYPE_ROAD) : company;
  730.                 Owner owner_tram = HasBit(prev_roadtypes, ROADTYPE_TRAM) ? GetRoadOwner(tile_start, ROADTYPE_TRAM) : company;
  731. -               MakeRoadBridgeRamp(tile_start, owner, owner_road, owner_tram, bridge_type, dir,                 roadtypes);
  732. -               MakeRoadBridgeRamp(tile_end,   owner, owner_road, owner_tram, bridge_type, ReverseDiagDir(dir), roadtypes);
  733. +               uint8 cur_road_subtype = GB(p2, 17, 8);
  734. +               MakeRoadBridgeRamp(tile_start, owner, owner_road, owner_tram, bridge_type, dir,                 roadtypes, cur_road_subtype);
  735. +               MakeRoadBridgeRamp(tile_end,   owner, owner_road, owner_tram, bridge_type, ReverseDiagDir(dir), roadtypes, cur_road_subtype);
  736.                 break;
  737.             }
  738.  
  739. @@ -589,6 +591,8 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
  740.     RailType railtype = INVALID_RAILTYPE;
  741.     RoadTypes rts = ROADTYPES_NONE;
  742.     _build_tunnel_endtile = 0;
  743. +    uint8 _build_tunnel_cur_road_subtype = GB(p2, 0, 8);
  744. +
  745.     switch (transport_type) {
  746.         case TRANSPORT_RAIL:
  747.             railtype = Extract<RailType, 0, 4>(p1);
  748. @@ -731,8 +735,8 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
  749.                     c->infrastructure.road[rt] += num_pieces * 2; // A full diagonal road has two road bits.
  750.                 }
  751.             }
  752. -           MakeRoadTunnel(start_tile, company, direction,                 rts);
  753. -           MakeRoadTunnel(end_tile,   company, ReverseDiagDir(direction), rts);
  754. +           MakeRoadTunnel(start_tile, company, direction,                 rts, _build_tunnel_cur_road_subtype);
  755. +           MakeRoadTunnel(end_tile,   company, ReverseDiagDir(direction), rts, _build_tunnel_cur_road_subtype);
  756.         }
  757.         DirtyCompanyInfrastructureWindows(company);
  758.     }
  759. @@ -1087,7 +1091,7 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis
  760.   * @param overlay do we want to still see the road?
  761.   * @param head    are we drawing bridge head?
  762.   */
  763. -static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bool head)
  764. +static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bool head, bool has_catenary)
  765.  {
  766.     static const SpriteID tram_offsets[2][6] = { { 107, 108, 109, 110, 111, 112 }, { 4, 5, 15, 16, 17, 18 } };
  767.     static const SpriteID back_offsets[6]    =   {  95,  96,  99, 102, 100, 101 };
  768. @@ -1107,7 +1111,7 @@ static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bo
  769.     }
  770.  
  771.     /* Do not draw catenary if it is set invisible */
  772. -   if (!IsInvisibilitySet(TO_CATENARY)) {
  773. +   if (has_catenary && !IsInvisibilitySet(TO_CATENARY)) {
  774.         AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE,
  775.             x, y, size_x[offset], size_y[offset], 0x28, z,
  776.             IsTransparencySet(TO_CATENARY));
  777. @@ -1118,7 +1122,7 @@ static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bo
  778.     StartSpriteCombine();
  779.  
  780.     /* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
  781. -   if (!IsInvisibilitySet(TO_CATENARY)) {
  782. +   if (has_catenary && !IsInvisibilitySet(TO_CATENARY)) {
  783.         AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE,
  784.             x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z,
  785.             IsTransparencySet(TO_CATENARY), front_bb_offset_x[offset], front_bb_offset_y[offset]);
  786. @@ -1193,7 +1197,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
  787.                 DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][tunnelbridge_direction], PAL_NONE);
  788.  
  789.                 /* Do not draw wires if they are invisible */
  790. -               if (!IsInvisibilitySet(TO_CATENARY)) {
  791. +               if (RoadTileHasCatenary(ti->tile) && !IsInvisibilitySet(TO_CATENARY)) {
  792.                     catenary = true;
  793.                     StartSpriteCombine();
  794.                     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);
  795. @@ -1303,7 +1307,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
  796.                     offset += 2;
  797.                 }
  798.                 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */
  799. -               DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true);
  800. +               DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true, RoadTileHasCatenary(ti->tile));
  801.             }
  802.             EndSpriteCombine();
  803.         } else if (transport_type == TRANSPORT_RAIL) {
  804. @@ -1466,7 +1470,7 @@ void DrawBridgeMiddle(const TileInfo *ti)
  805.  
  806.         if (HasBit(rts, ROADTYPE_TRAM)) {
  807.             /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */
  808. -           DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD), false);
  809. +           DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD), false, RoadTileHasCatenary(ti->tile));
  810.         } else {
  811.             EndSpriteCombine();
  812.             StartSpriteCombine();

Comments