mirror of https://github.com/OpenTTD/OpenTTD
parent
319a657454
commit
a93087ec5c
|
@ -857,7 +857,7 @@ do_clear:;
|
||||||
if (HasPowerOnRoad(rt, existing_rt)) {
|
if (HasPowerOnRoad(rt, existing_rt)) {
|
||||||
rt = existing_rt;
|
rt = existing_rt;
|
||||||
} else if (HasPowerOnRoad(existing_rt, rt)) {
|
} else if (HasPowerOnRoad(existing_rt, rt)) {
|
||||||
ret = Command<CMD_CONVERT_ROAD>::Do(flags, tile, tile, rt);
|
ret = Command<CMD_CONVERT_ROAD>::Do(flags, tile, tile, rt, false);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
cost.AddCost(ret.GetCost());
|
cost.AddCost(ret.GetCost());
|
||||||
} else {
|
} else {
|
||||||
|
@ -2435,7 +2435,7 @@ static void ConvertRoadTypeOwner(TileIndex tile, uint num_pieces, Owner owner, R
|
||||||
* @param to_type new roadtype to convert to.
|
* @param to_type new roadtype to convert to.
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type)
|
CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type, bool diagonal)
|
||||||
{
|
{
|
||||||
TileIndex area_end = tile;
|
TileIndex area_end = tile;
|
||||||
|
|
||||||
|
@ -2449,7 +2449,7 @@ CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_
|
||||||
CommandCost error = CommandCost((rtt == RTT_TRAM) ? STR_ERROR_NO_SUITABLE_TRAMWAY : STR_ERROR_NO_SUITABLE_ROAD); // by default, there is no road to convert.
|
CommandCost error = CommandCost((rtt == RTT_TRAM) ? STR_ERROR_NO_SUITABLE_TRAMWAY : STR_ERROR_NO_SUITABLE_ROAD); // by default, there is no road to convert.
|
||||||
bool found_convertible_road = false; // whether we actually did convert any road/tram (see bug #7633)
|
bool found_convertible_road = false; // whether we actually did convert any road/tram (see bug #7633)
|
||||||
|
|
||||||
std::unique_ptr<TileIterator> iter = std::make_unique<OrthogonalTileIterator>(area_start, area_end);
|
std::unique_ptr<TileIterator> iter = TileIterator::Create(area_start, area_end, diagonal);
|
||||||
for (; (tile = *iter) != INVALID_TILE; ++(*iter)) {
|
for (; (tile = *iter) != INVALID_TILE; ++(*iter)) {
|
||||||
/* Is road present on tile? */
|
/* Is road present on tile? */
|
||||||
if (!MayHaveRoad(tile)) continue;
|
if (!MayHaveRoad(tile)) continue;
|
||||||
|
@ -2552,7 +2552,11 @@ CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_
|
||||||
/* If both ends of tunnel/bridge are in the range, do not try to convert twice -
|
/* If both ends of tunnel/bridge are in the range, do not try to convert twice -
|
||||||
* it would cause assert because of different test and exec runs */
|
* it would cause assert because of different test and exec runs */
|
||||||
if (endtile < tile) {
|
if (endtile < tile) {
|
||||||
if (OrthogonalTileArea(area_start, area_end).Contains(endtile)) continue;
|
if (diagonal) {
|
||||||
|
if (DiagonalTileArea(area_start, area_end).Contains(endtile)) continue;
|
||||||
|
} else {
|
||||||
|
if (OrthogonalTileArea(area_start, area_end).Contains(endtile)) continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When not converting rail <-> el. rail, any vehicle cannot be in tunnel/bridge */
|
/* When not converting rail <-> el. rail, any vehicle cannot be in tunnel/bridge */
|
||||||
|
|
|
@ -23,7 +23,7 @@ CommandCost CmdBuildLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex
|
||||||
std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half);
|
std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half);
|
||||||
CommandCost CmdBuildRoad(DoCommandFlags flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id);
|
CommandCost CmdBuildRoad(DoCommandFlags flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id);
|
||||||
CommandCost CmdBuildRoadDepot(DoCommandFlags flags, TileIndex tile, RoadType rt, DiagDirection dir);
|
CommandCost CmdBuildRoadDepot(DoCommandFlags flags, TileIndex tile, RoadType rt, DiagDirection dir);
|
||||||
CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type);
|
CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type, bool diagonal);
|
||||||
|
|
||||||
DEF_CMD_TRAIT(CMD_BUILD_LONG_ROAD, CmdBuildLongRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater, CommandFlag::Deity}), CMDT_LANDSCAPE_CONSTRUCTION)
|
DEF_CMD_TRAIT(CMD_BUILD_LONG_ROAD, CmdBuildLongRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater, CommandFlag::Deity}), CMDT_LANDSCAPE_CONSTRUCTION)
|
||||||
DEF_CMD_TRAIT(CMD_REMOVE_LONG_ROAD, CmdRemoveLongRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoTest}), CMDT_LANDSCAPE_CONSTRUCTION) // towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
|
DEF_CMD_TRAIT(CMD_REMOVE_LONG_ROAD, CmdRemoveLongRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoTest}), CMDT_LANDSCAPE_CONSTRUCTION) // towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
|
||||||
|
|
|
@ -586,7 +586,7 @@ struct BuildRoadToolbarWindow : Window {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_ROT_CONVERT_ROAD:
|
case WID_ROT_CONVERT_ROAD:
|
||||||
HandlePlacePushButton(this, WID_ROT_CONVERT_ROAD, GetRoadTypeInfo(this->roadtype)->cursor.convert_road, HT_RECT);
|
HandlePlacePushButton(this, WID_ROT_CONVERT_ROAD, GetRoadTypeInfo(this->roadtype)->cursor.convert_road, HT_RECT | HT_DIAGONAL);
|
||||||
this->last_started_action = widget;
|
this->last_started_action = widget;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -805,7 +805,7 @@ struct BuildRoadToolbarWindow : Window {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DDSP_CONVERT_ROAD:
|
case DDSP_CONVERT_ROAD:
|
||||||
Command<CMD_CONVERT_ROAD>::Post(GetRoadTypeInfo(this->roadtype)->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype);
|
Command<CMD_CONVERT_ROAD>::Post(GetRoadTypeInfo(this->roadtype)->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype, _ctrl_pressed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@
|
||||||
EnforcePrecondition(false, ::IsValidTile(end_tile));
|
EnforcePrecondition(false, ::IsValidTile(end_tile));
|
||||||
EnforcePrecondition(false, IsRoadTypeAvailable(road_type));
|
EnforcePrecondition(false, IsRoadTypeAvailable(road_type));
|
||||||
|
|
||||||
return ScriptObject::Command<CMD_CONVERT_ROAD>::Do(start_tile, end_tile, (::RoadType)road_type);
|
return ScriptObject::Command<CMD_CONVERT_ROAD>::Do(start_tile, end_tile, (::RoadType)road_type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper functions for ScriptRoad::CanBuildConnectedRoadParts(). */
|
/* Helper functions for ScriptRoad::CanBuildConnectedRoadParts(). */
|
||||||
|
|
Loading…
Reference in New Issue