Loading

Paste #pbzxkqdp8

  1. diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
  2. index 797ead1..d02aeee 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. +bool _bridge_catenary_flag = true;
  10. +
  11.  /**
  12.   * Carriage for the data we need if we want to build a bridge
  13.   */
  14. @@ -117,7 +119,7 @@ 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. +       DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index | (_bridge_catenary_flag << 17),
  20.                     CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge);
  21.     }
  22.  
  23. @@ -358,10 +360,12 @@ static WindowDesc _build_bridge_desc(
  24.   * @param transport_type The transport type
  25.   * @param road_rail_type The road/rail type
  26.   */
  27. -void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
  28. +void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type, bool catenary_flag)
  29.  {
  30.     DeleteWindowByClass(WC_BUILD_BRIDGE);
  31.  
  32. +    _bridge_catenary_flag = catenary_flag;
  33. +
  34.     /* Data type for the bridge.
  35.      * Bit 16,15 = transport type,
  36.      *     14..8 = road/rail types,
  37. diff --git a/src/bridge_map.h b/src/bridge_map.h
  38. index 74c6974..426bafa 100644
  39. --- a/src/bridge_map.h
  40. +++ b/src/bridge_map.h
  41. @@ -116,6 +116,19 @@ static inline void SetBridgeMiddle(TileIndex t, Axis a)
  42.     SetBit(_m[t].type, 2 + a);
  43.  }
  44.  
  45. +
  46. +static inline void SetBridgeRoadTramCatenary(TileIndex t, bool b)
  47. +{
  48. +   assert(IsTileType(t, MP_TUNNELBRIDGE));
  49. +   SB(_m[t].m1, 7, 1, b ? 1 : 0);
  50. +}
  51. +
  52. +static inline bool HasBridgeRoadTramCatenary(TileIndex t)
  53. +{
  54. +   return GB(_m[t].m1, 7, 1);
  55. +}
  56. +
  57. +
  58.  /**
  59.   * Generic part to make a bridge ramp for both roads and rails.
  60.   * @param t          the tile to make a bridge ramp
  61. @@ -148,12 +161,13 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, D
  62.   * @param d          the direction this ramp must be facing
  63.   * @param r          the road type of the bridge
  64.   */
  65. -static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadTypes r)
  66. +static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadTypes r, bool catenary_flag = false)
  67.  {
  68.     MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, 0);
  69.     SetRoadOwner(t, ROADTYPE_ROAD, owner_road);
  70.     if (owner_tram != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, owner_tram);
  71.     SetRoadTypes(t, r);
  72. +    SetBridgeRoadTramCatenary(t, catenary_flag);
  73.  }
  74.  
  75.  /**
  76. diff --git a/src/gui.h b/src/gui.h
  77. index 39f1ea6..eb2961d 100644
  78. --- a/src/gui.h
  79. +++ b/src/gui.h
  80. @@ -61,7 +61,7 @@ void ShowExtraViewPortWindow(TileIndex tile = INVALID_TILE);
  81.  void ShowExtraViewPortWindowForTileUnderCursor();
  82.  
  83.  /* bridge_gui.cpp */
  84. -void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type);
  85. +void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type, bool catenary_flag = false);
  86.  
  87.  void ShowBuildIndustryWindow();
  88.  void ShowFoundTownWindow();
  89. diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
  90. index 2010f9b..e5bf3ac 100644
  91. --- a/src/rail_cmd.cpp
  92. +++ b/src/rail_cmd.cpp
  93. @@ -636,7 +636,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
  94.                 owner = GetTileOwner(tile);
  95.                 Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR;
  96.                 DirtyCompanyInfrastructureWindows(owner);
  97. -               MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM));
  98. +               MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), HasCatenary(tile));
  99.                 DeleteNewGRFInspectWindow(GSF_RAILTYPES, tile);
  100.             }
  101.             break;
  102. diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
  103. index aa445eb..1c84dbb 100644
  104. --- a/src/road_cmd.cpp
  105. +++ b/src/road_cmd.cpp
  106. @@ -477,6 +477,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi
  107.   * @param p1 bit 0..3 road pieces to build (RoadBits)
  108.   *           bit 4..5 road type
  109.   *           bit 6..7 disallowed directions to toggle
  110. + *           bit 8 catenary
  111.   * @param p2 the town that is building the road (0 if not applicable)
  112.   * @param text unused
  113.   * @return the cost of this operation or an error
  114. @@ -515,6 +516,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
  115.     if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR;
  116.  
  117.     DisallowedRoadDirections toggle_drd = Extract<DisallowedRoadDirections, 6, 2>(p1);
  118. +    bool _catenary_flag = HasBit(p1, 8);
  119.  
  120.     Slope tileh = GetTileSlope(tile);
  121.  
  122. @@ -749,6 +751,7 @@ do_clear:;
  123.                     if (rt == ROADTYPE_ROAD) SetTownIndex(tile, p2);
  124.                 }
  125.                 if (rtt != ROAD_TILE_CROSSING) SetRoadBits(tile, existing | pieces, rt);
  126. +                SetCatenary(tile, _catenary_flag);
  127.                 break;
  128.             }
  129.  
  130. @@ -777,7 +780,7 @@ do_clear:;
  131.                 break;
  132.  
  133.             default:
  134. -               MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, company, company);
  135. +               MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, company, company, _catenary_flag);
  136.                 break;
  137.         }
  138.  
  139. @@ -794,7 +797,6 @@ do_clear:;
  140.             SetDisallowedRoadDirections(tile, IsStraightRoad(existing) ?
  141.                     GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE);
  142.         }
  143. -
  144.         MarkTileDirtyByTile(tile);
  145.     }
  146.     return cost;
  147. @@ -827,6 +829,7 @@ static bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir)
  148.   * - p2 = (bit 6) - defines two different behaviors for this command:
  149.   *      - 0 = Build up to an obstacle. Do not build the first and last roadbits unless they can be connected to something, or if we are building a single tile
  150.   *      - 1 = Fail if an obstacle is found. Always take into account bit 0 and 1. This behavior is used for scripts
  151. + * - p2 = (bit 7) - catenary
  152.   * @param text unused
  153.   * @return the cost of this operation or an error
  154.   */
  155. @@ -886,8 +889,8 @@ CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p
  156.             if (tile == end_tile && !HasBit(p2, 1)) bits &= DiagDirToRoadBits(ReverseDiagDir(dir));
  157.             if (tile == start_tile && HasBit(p2, 0)) bits &= DiagDirToRoadBits(dir);
  158.         }
  159. -
  160. -       CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD);
  161. +       bool _has_catenary = HasBit(p2, 7);
  162. +       CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits | _has_catenary << 8 , 0, flags, CMD_BUILD_ROAD);
  163.         if (ret.Failed()) {
  164.             last_error = ret;
  165.             if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) {
  166. @@ -1298,7 +1301,7 @@ static void DrawRoadBits(TileInfo *ti)
  167.         return;
  168.     }
  169.  
  170. -   if (tram != ROAD_NONE) DrawTramCatenary(ti, tram);
  171. +   if (HasCatenary(ti->tile)) DrawTramCatenary(ti, tram);
  172.  
  173.     /* Return if full detail is disabled, or we are zoomed fully out. */
  174.     if (!HasBit(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZOOM_LVL_DETAIL) return;
  175. @@ -1388,7 +1391,7 @@ static void DrawTile_Road(TileInfo *ti)
  176.  
  177.             if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) {
  178.                 DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal);
  179. -               DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
  180. +               if (HasCatenary(ti->tile)) DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
  181.             }
  182.             if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
  183.             break;
  184. diff --git a/src/road_gui.cpp b/src/road_gui.cpp
  185. index 92c660e..7dc8dc8 100644
  186. --- a/src/road_gui.cpp
  187. +++ b/src/road_gui.cpp
  188. @@ -60,6 +60,7 @@ DECLARE_ENUM_AS_BIT_SET(RoadFlags)
  189.  static RoadFlags _place_road_flag;
  190.  
  191.  static RoadType _cur_roadtype;
  192. +bool _catenary_flag;
  193.  
  194.  static DiagDirection _road_depot_orientation;
  195.  static DiagDirection _road_station_picker_orientation;
  196. @@ -231,6 +232,7 @@ static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, u
  197.         ddir -= DIAGDIR_END; // Adjust picker result to actual direction.
  198.     }
  199.     p2 |= ddir << 6; // Set the DiagDirecion into p2 bits 6 and 7.
  200. +    SB(p2, 9, 1, _catenary_flag); // set _catenary_flag into p2 bit 9.
  201.  
  202.     TileArea ta(start_tile, end_tile);
  203.     CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop, "" };
  204. @@ -610,7 +612,7 @@ struct BuildRoadToolbarWindow : Window {
  205.                 default: NOT_REACHED();
  206.                 case DDSP_BUILD_BRIDGE:
  207.                     if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
  208. -                   ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
  209. +                   ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype), _catenary_flag);
  210.                     break;
  211.  
  212.                 case DDSP_DEMOLISH_AREA:
  213. @@ -626,7 +628,7 @@ struct BuildRoadToolbarWindow : Window {
  214.                      * not the 3rd bit set) */
  215.                     _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
  216.  
  217. -                   DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5),
  218. +                   DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5) | (_catenary_flag << 7),
  219.                             _remove_button_clicked ?
  220.                             CMD_REMOVE_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
  221.                             CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound1D);
  222. @@ -802,10 +804,11 @@ static WindowDesc _build_tramway_desc(
  223.   *
  224.   * @return newly opened road toolbar, or NULL if the toolbar could not be opened.
  225.   */
  226. -Window *ShowBuildRoadToolbar(RoadType roadtype)
  227. +Window *ShowBuildRoadToolbar(RoadType roadtype, bool catenary_flag)
  228.  {
  229.     if (!Company::IsValidID(_local_company)) return NULL;
  230.     _cur_roadtype = roadtype;
  231. +    _catenary_flag = catenary_flag;
  232.  
  233.     DeleteWindowByClass(WC_BUILD_TOOLBAR);
  234.     return AllocateWindowDescFront<BuildRoadToolbarWindow>(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
  235. diff --git a/src/road_gui.h b/src/road_gui.h
  236. index c56443c..dd61ce9 100644
  237. --- a/src/road_gui.h
  238. +++ b/src/road_gui.h
  239. @@ -16,7 +16,7 @@
  240.  #include "tile_type.h"
  241.  #include "direction_type.h"
  242.  
  243. -struct Window *ShowBuildRoadToolbar(RoadType roadtype);
  244. +struct Window *ShowBuildRoadToolbar(RoadType roadtype, bool catenary_flag = false);
  245.  struct Window *ShowBuildRoadScenToolbar();
  246.  void ConnectRoadToStructure(TileIndex tile, DiagDirection direction);
  247.  
  248. diff --git a/src/road_map.h b/src/road_map.h
  249. index 6937302..a847568 100644
  250. --- a/src/road_map.h
  251. +++ b/src/road_map.h
  252. @@ -251,6 +251,11 @@ static inline bool HasTownOwnedRoad(TileIndex t)
  253.     return HasTileRoadType(t, ROADTYPE_ROAD) && IsRoadOwner(t, ROADTYPE_ROAD, OWNER_TOWN);
  254.  }
  255.  
  256. +static inline bool HasCatenary(TileIndex t)
  257. +{
  258. +   return GB(_m[t].m1, 7, 1);
  259. +}
  260. +
  261.  /** Which directions are disallowed ? */
  262.  enum DisallowedRoadDirections {
  263.     DRD_NONE,       ///< None of the directions are disallowed
  264. @@ -286,6 +291,12 @@ static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirect
  265.     SB(_m[t].m5, 4, 2, drd);
  266.  }
  267.  
  268. +static inline void SetCatenary(TileIndex t, bool b)
  269. +{
  270. +   assert(IsNormalRoad(t));
  271. +   SB(_m[t].m1, 7, 1, b ? 1 : 0);
  272. +}
  273. +
  274.  /**
  275.   * Get the road axis of a level crossing.
  276.   * @param t The tile to query.
  277. @@ -550,7 +561,7 @@ RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge
  278.   * @param road New owner of road.
  279.   * @param tram New owner of tram tracks.
  280.   */
  281. -static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram)
  282. +static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram, bool catenary_flag = false)
  283.  {
  284.     SetTileType(t, MP_ROAD);
  285.     SetTileOwner(t, road);
  286. @@ -561,6 +572,7 @@ static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, Tow
  287.     SB(_me[t].m6, 2, 4, 0);
  288.     _me[t].m7 = rot << 6;
  289.     SetRoadOwner(t, ROADTYPE_TRAM, tram);
  290. +   SetCatenary(t, catenary_flag);
  291.  }
  292.  
  293.  /**
  294. diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
  295. index eb90c29..b5ca448 100644
  296. --- a/src/station_cmd.cpp
  297. +++ b/src/station_cmd.cpp
  298. @@ -1759,6 +1759,11 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
  299.     bool reuse = (station_to_join != NEW_STATION);
  300.     if (!reuse) station_to_join = INVALID_STATION;
  301.     bool distant_join = (station_to_join != INVALID_STATION);
  302. +    bool catenary_flag = HasBit(p2, 9); // the setting from the selected roadtype
  303. +    bool cur_tile_catenary_flag = catenary_flag; // used to set catenary flag on any given tile
  304. +   printf("CmdBuildRoadStop called %d ", tile);
  305. +   printf("catenary_flag %d ", catenary_flag);
  306. +   printf("\n");
  307.  
  308.     uint8 width = (uint8)GB(p1, 0, 8);
  309.     uint8 lenght = (uint8)GB(p1, 8, 8);
  310. @@ -1815,6 +1820,12 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
  311.         /* Check every tile in the area. */
  312.         TILE_AREA_LOOP(cur_tile, roadstop_area) {
  313.             RoadTypes cur_rts = GetRoadTypes(cur_tile);
  314. +           // don't remove existing catenary if present
  315. +           if (HasCatenary(cur_tile)) {
  316. +               cur_tile_catenary_flag = true;
  317. +           } else {
  318. +               cur_tile_catenary_flag = catenary_flag;
  319. +           }
  320.             Owner road_owner = HasBit(cur_rts, ROADTYPE_ROAD) ? GetRoadOwner(cur_tile, ROADTYPE_ROAD) : _current_company;
  321.             Owner tram_owner = HasBit(cur_rts, ROADTYPE_TRAM) ? GetRoadOwner(cur_tile, ROADTYPE_TRAM) : _current_company;
  322.  
  323. @@ -1851,7 +1862,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
  324.                     }
  325.                 }
  326.  
  327. -               MakeDriveThroughRoadStop(cur_tile, st->owner, road_owner, tram_owner, st->index, rs_type, rts | cur_rts, axis);
  328. +               MakeDriveThroughRoadStop(cur_tile, st->owner, road_owner, tram_owner, st->index, rs_type, rts | cur_rts, axis, cur_tile_catenary_flag);
  329.                 road_stop->MakeDriveThrough();
  330.             } else {
  331.                 /* Non-drive-through stop never overbuild and always count as two road bits. */
  332. @@ -2013,6 +2024,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
  333.     uint8 width = (uint8)GB(p1, 0, 8);
  334.     uint8 height = (uint8)GB(p1, 8, 8);
  335.     bool keep_drive_through_roads = !HasBit(p2, 1);
  336. +   bool keep_catenary = false;
  337.  
  338.     /* Check for incorrect width / height. */
  339.     if (width == 0 || height == 0) return CMD_ERROR;
  340. @@ -2030,6 +2042,11 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
  341.     TILE_AREA_LOOP(cur_tile, roadstop_area) {
  342.         /* Make sure the specified tile is a road stop of the correct type */
  343.         if (!IsTileType(cur_tile, MP_STATION) || !IsRoadStop(cur_tile) || (uint32)GetRoadStopType(cur_tile) != GB(p2, 0, 1)) continue;
  344. +        if (HasCatenary(cur_tile)) {
  345. +            keep_catenary = true;
  346. +        } else {
  347. +            keep_catenary = false;
  348. +        }
  349.  
  350.         /* Save information on to-be-restored roads before the stop is removed. */
  351.         RoadTypes rts = ROADTYPES_NONE;
  352. @@ -2057,7 +2074,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
  353.         /* Restore roads. */
  354.         if ((flags & DC_EXEC) && rts != ROADTYPES_NONE) {
  355.             MakeRoadNormal(cur_tile, road_bits, rts, ClosestTownFromTile(cur_tile, UINT_MAX)->index,
  356. -                   road_owner[ROADTYPE_ROAD], road_owner[ROADTYPE_TRAM]);
  357. +                   road_owner[ROADTYPE_ROAD], road_owner[ROADTYPE_TRAM], keep_catenary);
  358.  
  359.             /* Update company infrastructure counts. */
  360.             RoadType rt;
  361. @@ -2902,7 +2919,7 @@ draw_default_foundation:
  362.     if (HasBit(roadtypes, ROADTYPE_TRAM)) {
  363.         Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
  364.         DrawGroundSprite((HasBit(roadtypes, ROADTYPE_ROAD) ? SPR_TRAMWAY_OVERLAY : SPR_TRAMWAY_TRAM) + (axis ^ 1), PAL_NONE);
  365. -       DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
  366. +       if (HasRoadTramCatenary(ti->tile)) DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
  367.     }
  368.  
  369.     if (IsRailWaypoint(ti->tile)) {
  370. diff --git a/src/station_map.h b/src/station_map.h
  371. index 7ca9bd7..8a101ad 100644
  372. --- a/src/station_map.h
  373. +++ b/src/station_map.h
  374. @@ -521,6 +521,17 @@ static inline byte GetStationTileRandomBits(TileIndex t)
  375.     return GB(_m[t].m3, 4, 4);
  376.  }
  377.  
  378. +static inline void SetRoadTramCatenary(TileIndex t, bool b)
  379. +{
  380. +   assert(IsTileType(t, MP_STATION));
  381. +   SB(_m[t].m1, 7, 1, b ? 1 : 0);
  382. +}
  383. +
  384. +static inline bool HasRoadTramCatenary(TileIndex t)
  385. +{
  386. +   return GB(_m[t].m1, 7, 1);
  387. +}
  388. +
  389.  /**
  390.   * Make the given tile a station tile.
  391.   * @param t the tile to make a station tile
  392. @@ -604,12 +615,13 @@ static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopTyp
  393.   * @param rt the roadtypes on this tile
  394.   * @param a the direction of the roadstop
  395.   */
  396. -static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadTypes rt, Axis a)
  397. +static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadTypes rt, Axis a, bool catenary_flag)
  398.  {
  399.     MakeStation(t, station, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
  400.     SetRoadTypes(t, rt);
  401.     SetRoadOwner(t, ROADTYPE_ROAD, road);
  402.     SetRoadOwner(t, ROADTYPE_TRAM, tram);
  403. +   SetRoadTramCatenary(t, catenary_flag);
  404.  }
  405.  
  406.  /**
  407. diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
  408. index 45d751d..0f28fbd 100644
  409. --- a/src/toolbar_gui.cpp
  410. +++ b/src/toolbar_gui.cpp
  411. @@ -891,7 +891,8 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w)
  412.     DropDownList *list = new DropDownList();
  413.  
  414.     /* Road is always visible and available. */
  415. -   *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION, ROADTYPE_ROAD, false);
  416. +   *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION, 0, false);
  417. +   *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION, 1, false);
  418.  
  419.     /* Tram is only visible when there will be a tram, and available when that has been introduced. */
  420.     Engine *e;
  421. @@ -899,7 +900,8 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w)
  422.         if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
  423.         if (!HasBit(e->info.misc_flags, EF_ROAD_TRAM)) continue;
  424.  
  425. -       *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION, ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
  426. +       *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION, 2, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
  427. +       *list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION, 3, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
  428.         break;
  429.     }
  430.     ShowDropDownList(w, list, _last_built_roadtype, WID_TN_ROADS, 140, true, true);
  431. @@ -915,8 +917,19 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w)
  432.   */
  433.  static CallBackFunction MenuClickBuildRoad(int index)
  434.  {
  435. -   _last_built_roadtype = (RoadType)index;
  436. -   ShowBuildRoadToolbar(_last_built_roadtype);
  437. +    bool _catenary_flag = false;
  438. +    if (index == 0) {
  439. +       _last_built_roadtype = (RoadType)ROADTYPE_ROAD;
  440. +    } else if (index == 1) {
  441. +       _last_built_roadtype = (RoadType)ROADTYPE_ROAD;
  442. +       _catenary_flag = true;
  443. +    } else if (index == 2) {
  444. +       _last_built_roadtype = (RoadType)ROADTYPE_TRAM;
  445. +    } else if (index == 3) {
  446. +       _last_built_roadtype = (RoadType)ROADTYPE_TRAM;
  447. +       _catenary_flag = true;
  448. +   }
  449. +   ShowBuildRoadToolbar(_last_built_roadtype, _catenary_flag);
  450.     return CBF_NONE;
  451.  }
  452.  
  453. diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
  454. index 5f2534b..a93fa1a 100644
  455. --- a/src/tunnelbridge_cmd.cpp
  456. +++ b/src/tunnelbridge_cmd.cpp
  457. @@ -515,8 +515,9 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
  458.                 }
  459.                 Owner owner_road = HasBit(prev_roadtypes, ROADTYPE_ROAD) ? GetRoadOwner(tile_start, ROADTYPE_ROAD) : company;
  460.                 Owner owner_tram = HasBit(prev_roadtypes, ROADTYPE_TRAM) ? GetRoadOwner(tile_start, ROADTYPE_TRAM) : company;
  461. -               MakeRoadBridgeRamp(tile_start, owner, owner_road, owner_tram, bridge_type, dir,                 roadtypes);
  462. -               MakeRoadBridgeRamp(tile_end,   owner, owner_road, owner_tram, bridge_type, ReverseDiagDir(dir), roadtypes);
  463. +               bool catenary_flag = HasBit(p2, 17); // the setting from the selected roadtype
  464. +               MakeRoadBridgeRamp(tile_start, owner, owner_road, owner_tram, bridge_type, dir,                 roadtypes, catenary_flag);
  465. +               MakeRoadBridgeRamp(tile_end,   owner, owner_road, owner_tram, bridge_type, ReverseDiagDir(dir), roadtypes, catenary_flag);
  466.                 break;
  467.             }
  468.  
  469. @@ -1087,7 +1088,7 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis
  470.   * @param overlay do we want to still see the road?
  471.   * @param head    are we drawing bridge head?
  472.   */
  473. -static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bool head)
  474. +static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bool head, bool has_catenary)
  475.  {
  476.     static const SpriteID tram_offsets[2][6] = { { 107, 108, 109, 110, 111, 112 }, { 4, 5, 15, 16, 17, 18 } };
  477.     static const SpriteID back_offsets[6]    =   {  95,  96,  99, 102, 100, 101 };
  478. @@ -1107,7 +1108,7 @@ static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bo
  479.     }
  480.  
  481.     /* Do not draw catenary if it is set invisible */
  482. -   if (!IsInvisibilitySet(TO_CATENARY)) {
  483. +   if (has_catenary && !IsInvisibilitySet(TO_CATENARY)) {
  484.         AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE,
  485.             x, y, size_x[offset], size_y[offset], 0x28, z,
  486.             IsTransparencySet(TO_CATENARY));
  487. @@ -1118,7 +1119,7 @@ static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bo
  488.     StartSpriteCombine();
  489.  
  490.     /* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
  491. -   if (!IsInvisibilitySet(TO_CATENARY)) {
  492. +   if (has_catenary && !IsInvisibilitySet(TO_CATENARY)) {
  493.         AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE,
  494.             x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z,
  495.             IsTransparencySet(TO_CATENARY), front_bb_offset_x[offset], front_bb_offset_y[offset]);
  496. @@ -1193,7 +1194,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
  497.                 DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][tunnelbridge_direction], PAL_NONE);
  498.  
  499.                 /* Do not draw wires if they are invisible */
  500. -               if (!IsInvisibilitySet(TO_CATENARY)) {
  501. +               if (HasTunnelBridgeRoadTramCatenary(ti->tile) && !IsInvisibilitySet(TO_CATENARY)) {
  502.                     catenary = true;
  503.                     StartSpriteCombine();
  504.                     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);
  505. @@ -1303,7 +1304,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
  506.                     offset += 2;
  507.                 }
  508.                 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */
  509. -               DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true);
  510. +               DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true, HasBridgeRoadTramCatenary(ti->tile));
  511.             }
  512.             EndSpriteCombine();
  513.         } else if (transport_type == TRANSPORT_RAIL) {
  514. @@ -1466,7 +1467,7 @@ void DrawBridgeMiddle(const TileInfo *ti)
  515.  
  516.         if (HasBit(rts, ROADTYPE_TRAM)) {
  517.             /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */
  518. -           DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD), false);
  519. +           DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD), false, HasBridgeRoadTramCatenary(ti->tile));
  520.         } else {
  521.             EndSpriteCombine();
  522.             StartSpriteCombine();
  523. diff --git a/src/tunnelbridge_map.h b/src/tunnelbridge_map.h
  524. index 0f7f17b..199033e 100644
  525. --- a/src/tunnelbridge_map.h
  526. +++ b/src/tunnelbridge_map.h
  527. @@ -121,4 +121,16 @@ static inline TrackBits GetTunnelBridgeReservationTrackBits(TileIndex t)
  528.     return HasTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE;
  529.  }
  530.  
  531. +
  532. +static inline void SetTunnelBridgeRoadTramCatenary(TileIndex t, bool b)
  533. +{
  534. +   assert(IsTileType(t, MP_TUNNELBRIDGE));
  535. +   SB(_m[t].m1, 7, 1, b ? 1 : 0);
  536. +}
  537. +
  538. +static inline bool HasTunnelBridgeRoadTramCatenary(TileIndex t)
  539. +{
  540. +   return GB(_m[t].m1, 7, 1);
  541. +}
  542. +
  543.  #endif /* TUNNELBRIDGE_MAP_H */

Comments