Update to 14.0-beta1
This commit is contained in:
211
src/road_cmd.cpp
211
src/road_cmd.cpp
@@ -12,6 +12,7 @@
|
||||
#include "road_internal.h"
|
||||
#include "viewport_func.h"
|
||||
#include "command_func.h"
|
||||
#include "company_func.h"
|
||||
#include "pathfinder/yapf/yapf_cache.h"
|
||||
#include "depot_base.h"
|
||||
#include "newgrf.h"
|
||||
@@ -30,10 +31,11 @@
|
||||
#include "town.h"
|
||||
#include "company_base.h"
|
||||
#include "core/random_func.hpp"
|
||||
#include "core/container_func.hpp"
|
||||
#include "newgrf_debug.h"
|
||||
#include "newgrf_railtype.h"
|
||||
#include "newgrf_roadtype.h"
|
||||
#include "date_func.h"
|
||||
#include "timer/timer_game_calendar.h"
|
||||
#include "genworld.h"
|
||||
#include "company_gui.h"
|
||||
#include "road_func.h"
|
||||
@@ -66,17 +68,8 @@ void ResetRoadTypes()
|
||||
{
|
||||
static_assert(lengthof(_original_roadtypes) <= lengthof(_roadtypes));
|
||||
|
||||
uint i = 0;
|
||||
for (; i < lengthof(_original_roadtypes); i++) _roadtypes[i] = _original_roadtypes[i];
|
||||
|
||||
static const RoadTypeInfo empty_roadtype = {
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, {}, {}, 0, {}, {} },
|
||||
ROADTYPES_NONE, ROTFB_NONE, 0, 0, 0, 0,
|
||||
RoadTypeLabelList(), 0, 0, ROADTYPES_NONE, ROADTYPES_NONE, 0,
|
||||
{}, {} };
|
||||
for (; i < lengthof(_roadtypes); i++) _roadtypes[i] = empty_roadtype;
|
||||
auto insert = std::copy(std::begin(_original_roadtypes), std::end(_original_roadtypes), std::begin(_roadtypes));
|
||||
std::fill(insert, std::end(_roadtypes), RoadTypeInfo{});
|
||||
|
||||
_roadtypes_hidden_mask = ROADTYPES_NONE;
|
||||
_roadtypes_type = ROADTYPES_TRAM;
|
||||
@@ -149,7 +142,7 @@ RoadType AllocateRoadType(RoadTypeLabel label, RoadTramType rtt)
|
||||
rti->label = label;
|
||||
rti->alternate_labels.clear();
|
||||
rti->flags = ROTFB_NONE;
|
||||
rti->introduction_date = INVALID_DATE;
|
||||
rti->introduction_date = CalendarTime::INVALID_DATE;
|
||||
|
||||
/* Make us compatible with ourself. */
|
||||
rti->powered_roadtypes = (RoadTypes)(1ULL << rt);
|
||||
@@ -327,10 +320,9 @@ CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, R
|
||||
* @param flags operation to perform
|
||||
* @param pieces roadbits to remove
|
||||
* @param rt roadtype to remove
|
||||
* @param crossing_check should we check if there is a tram track when we are removing road from crossing?
|
||||
* @param town_check should we check if the town allows removal?
|
||||
*/
|
||||
static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits pieces, RoadTramType rtt, bool crossing_check, bool town_check = true)
|
||||
static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits pieces, RoadTramType rtt, bool town_check)
|
||||
{
|
||||
assert(pieces != ROAD_NONE);
|
||||
|
||||
@@ -476,6 +468,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
|
||||
const Town *town = CalcClosestTownFromTile(tile);
|
||||
SetTownIndex(tile, town == nullptr ? INVALID_TOWN : town->index);
|
||||
}
|
||||
if (rtt == RTT_ROAD) SetDisallowedRoadDirections(tile, DRD_NONE);
|
||||
SetRoadBits(tile, ROAD_NONE, rtt);
|
||||
SetRoadType(tile, rtt, INVALID_ROADTYPE);
|
||||
MarkTileDirtyByTile(tile);
|
||||
@@ -736,6 +729,11 @@ CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, R
|
||||
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||
}
|
||||
|
||||
if (!_settings_game.construction.crossing_with_competitor && company != OWNER_TOWN && company != OWNER_DEITY) {
|
||||
CommandCost ret = CheckTileOwnership(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
if (GetRailTileType(tile) != RAIL_TILE_NORMAL) goto do_clear;
|
||||
|
||||
if (RoadNoLevelCrossing(rt)) {
|
||||
@@ -866,7 +864,7 @@ do_clear:;
|
||||
if (HasPowerOnRoad(rt, existing_rt)) {
|
||||
rt = existing_rt;
|
||||
} else if (HasPowerOnRoad(existing_rt, rt)) {
|
||||
CommandCost ret = Command<CMD_CONVERT_ROAD>::Do(flags, tile, tile, rt);
|
||||
ret = Command<CMD_CONVERT_ROAD>::Do(flags, tile, tile, rt);
|
||||
if (ret.Failed()) return ret;
|
||||
cost.AddCost(ret);
|
||||
} else {
|
||||
@@ -980,7 +978,7 @@ static bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir)
|
||||
*/
|
||||
CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
|
||||
{
|
||||
if (start_tile >= MapSize()) return CMD_ERROR;
|
||||
if (start_tile >= Map::Size()) return CMD_ERROR;
|
||||
|
||||
if (!ValParamRoadType(rt) || !IsValidAxis(axis) || !IsValidDisallowedRoadDirections(drd)) return CMD_ERROR;
|
||||
|
||||
@@ -1009,49 +1007,55 @@ CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex
|
||||
bool had_bridge = false;
|
||||
bool had_tunnel = false;
|
||||
bool had_success = false;
|
||||
bool under_tunnelbridge = false;
|
||||
|
||||
/* Start tile is the first tile clicked by the user. */
|
||||
for (;;) {
|
||||
RoadBits bits = AxisToRoadBits(axis);
|
||||
/* Don't try to place road between tunnelbridge ends */
|
||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||
under_tunnelbridge = !under_tunnelbridge;
|
||||
} else if (!under_tunnelbridge) {
|
||||
RoadBits bits = AxisToRoadBits(axis);
|
||||
|
||||
/* Determine which road parts should be built. */
|
||||
if (!is_ai && start_tile != end_tile) {
|
||||
/* Only build the first and last roadbit if they can connect to something. */
|
||||
if (tile == end_tile && !CanConnectToRoad(tile, rt, dir)) {
|
||||
bits = DiagDirToRoadBits(ReverseDiagDir(dir));
|
||||
} else if (tile == start_tile && !CanConnectToRoad(tile, rt, ReverseDiagDir(dir))) {
|
||||
bits = DiagDirToRoadBits(dir);
|
||||
}
|
||||
} else {
|
||||
/* Road parts only have to be built at the start tile or at the end tile. */
|
||||
if (tile == end_tile && !end_half) bits &= DiagDirToRoadBits(ReverseDiagDir(dir));
|
||||
if (tile == start_tile && start_half) bits &= DiagDirToRoadBits(dir);
|
||||
}
|
||||
|
||||
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(flags, tile, bits, rt, drd, 0);
|
||||
if (ret.Failed()) {
|
||||
last_error = ret;
|
||||
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) {
|
||||
if (is_ai) return last_error;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
had_success = true;
|
||||
/* Only pay for the upgrade on one side of the bridges and tunnels */
|
||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||
if (IsBridge(tile)) {
|
||||
if (!had_bridge || GetTunnelBridgeDirection(tile) == dir) {
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
had_bridge = true;
|
||||
} else { // IsTunnel(tile)
|
||||
if (!had_tunnel || GetTunnelBridgeDirection(tile) == dir) {
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
had_tunnel = true;
|
||||
/* Determine which road parts should be built. */
|
||||
if (!is_ai && start_tile != end_tile) {
|
||||
/* Only build the first and last roadbit if they can connect to something. */
|
||||
if (tile == end_tile && !CanConnectToRoad(tile, rt, dir)) {
|
||||
bits = DiagDirToRoadBits(ReverseDiagDir(dir));
|
||||
} else if (tile == start_tile && !CanConnectToRoad(tile, rt, ReverseDiagDir(dir))) {
|
||||
bits = DiagDirToRoadBits(dir);
|
||||
}
|
||||
} else {
|
||||
cost.AddCost(ret);
|
||||
/* Road parts only have to be built at the start tile or at the end tile. */
|
||||
if (tile == end_tile && !end_half) bits &= DiagDirToRoadBits(ReverseDiagDir(dir));
|
||||
if (tile == start_tile && start_half) bits &= DiagDirToRoadBits(dir);
|
||||
}
|
||||
|
||||
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(flags, tile, bits, rt, drd, 0);
|
||||
if (ret.Failed()) {
|
||||
last_error = ret;
|
||||
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) {
|
||||
if (is_ai) return last_error;
|
||||
if (had_success) break; // Keep going if we haven't constructed any road yet, skipping the start of the drag
|
||||
}
|
||||
} else {
|
||||
had_success = true;
|
||||
/* Only pay for the upgrade on one side of the bridges and tunnels */
|
||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||
if (IsBridge(tile)) {
|
||||
if (!had_bridge || GetTunnelBridgeDirection(tile) == dir) {
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
had_bridge = true;
|
||||
} else { // IsTunnel(tile)
|
||||
if (!had_tunnel || GetTunnelBridgeDirection(tile) == dir) {
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
had_tunnel = true;
|
||||
}
|
||||
} else {
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1078,7 +1082,7 @@ std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
if (start_tile >= MapSize()) return { CMD_ERROR, 0 };
|
||||
if (start_tile >= Map::Size()) return { CMD_ERROR, 0 };
|
||||
if (!ValParamRoadType(rt) || !IsValidAxis(axis)) return { CMD_ERROR, 0 };
|
||||
|
||||
/* Only drag in X or Y direction dictated by the direction variable */
|
||||
@@ -1113,7 +1117,7 @@ std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex
|
||||
if (money_spent > 0 && money_spent > money_available) {
|
||||
return { cost, std::get<0>(Command<CMD_REMOVE_LONG_ROAD>::Do(flags & ~DC_EXEC, end_tile, start_tile, rt, axis, start_half, end_half)).GetCost() };
|
||||
}
|
||||
RemoveRoad(tile, flags, bits, rtt, true, false);
|
||||
RemoveRoad(tile, flags, bits, rtt, false);
|
||||
}
|
||||
cost.AddCost(ret);
|
||||
had_success = true;
|
||||
@@ -1162,24 +1166,46 @@ CommandCost CmdBuildRoadDepot(DoCommandFlag flags, TileIndex tile, RoadType rt,
|
||||
cost.AddCost(_price[PR_BUILD_FOUNDATION]);
|
||||
}
|
||||
|
||||
cost.AddCost(Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile));
|
||||
if (cost.Failed()) return cost;
|
||||
/* Allow the user to rotate the depot instead of having to destroy it and build it again */
|
||||
bool rotate_existing_depot = false;
|
||||
if (IsRoadDepotTile(tile) && (HasRoadTypeTram(tile) ? rt == GetRoadTypeTram(tile) : rt == GetRoadTypeRoad(tile)))
|
||||
{
|
||||
CommandCost ret = CheckTileOwnership(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
if (dir == GetRoadDepotDirection(tile)) return_cmd_error(STR_ERROR_ALREADY_BUILT);
|
||||
|
||||
if (!Depot::CanAllocateItem()) return CMD_ERROR;
|
||||
ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
rotate_existing_depot = true;
|
||||
}
|
||||
|
||||
if (!rotate_existing_depot) {
|
||||
cost.AddCost(Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile));
|
||||
if (cost.Failed()) return cost;
|
||||
|
||||
if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
|
||||
if (!Depot::CanAllocateItem()) return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
Depot *dep = new Depot(tile);
|
||||
dep->build_date = _date;
|
||||
if (rotate_existing_depot) {
|
||||
SetRoadDepotExitDirection(tile, dir);
|
||||
} else {
|
||||
Depot *dep = new Depot(tile);
|
||||
dep->build_date = TimerGameCalendar::date;
|
||||
MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
|
||||
MakeDefaultName(dep);
|
||||
|
||||
/* A road depot has two road bits. */
|
||||
UpdateCompanyRoadInfrastructure(rt, _current_company, ROAD_DEPOT_TRACKBIT_FACTOR);
|
||||
/* A road depot has two road bits. */
|
||||
UpdateCompanyRoadInfrastructure(rt, _current_company, ROAD_DEPOT_TRACKBIT_FACTOR);
|
||||
}
|
||||
|
||||
MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
|
||||
MarkTileDirtyByTile(tile);
|
||||
MakeDefaultName(dep);
|
||||
}
|
||||
|
||||
cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]);
|
||||
return cost;
|
||||
}
|
||||
@@ -1242,7 +1268,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags)
|
||||
for (RoadTramType rtt : { RTT_TRAM, RTT_ROAD }) {
|
||||
if (!MayHaveRoad(tile) || GetRoadType(tile, rtt) == INVALID_ROADTYPE) continue;
|
||||
|
||||
CommandCost tmp_ret = RemoveRoad(tile, flags, GetCrossingRoadBits(tile), rtt, false);
|
||||
CommandCost tmp_ret = RemoveRoad(tile, flags, GetCrossingRoadBits(tile), rtt, true);
|
||||
if (tmp_ret.Failed()) return tmp_ret;
|
||||
ret.AddCost(tmp_ret);
|
||||
}
|
||||
@@ -1264,7 +1290,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags)
|
||||
|
||||
|
||||
struct DrawRoadTileStruct {
|
||||
uint16 image;
|
||||
uint16_t image;
|
||||
byte subcoord_x;
|
||||
byte subcoord_y;
|
||||
};
|
||||
@@ -1386,7 +1412,7 @@ void DrawRoadTypeCatenary(const TileInfo *ti, RoadType rt, RoadBits rb)
|
||||
if (CountBits(rb_new) >= 2) rb = rb_new;
|
||||
}
|
||||
|
||||
const RoadTypeInfo* rti = GetRoadTypeInfo(rt);
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
||||
SpriteID front = GetCustomRoadSprite(rti, ti->tile, ROTSG_CATENARY_FRONT);
|
||||
SpriteID back = GetCustomRoadSprite(rti, ti->tile, ROTSG_CATENARY_BACK);
|
||||
|
||||
@@ -1646,8 +1672,18 @@ static void DrawRoadBits(TileInfo *ti)
|
||||
/* If there are no road bits, return, as there is nothing left to do */
|
||||
if (HasAtMostOneBit(road)) return;
|
||||
|
||||
/* Do not draw details when invisible. */
|
||||
if (roadside == ROADSIDE_TREES && IsInvisibilitySet(TO_TREES)) return;
|
||||
bool is_transparent = roadside == ROADSIDE_TREES && IsTransparencySet(TO_TREES);
|
||||
if (roadside == ROADSIDE_STREET_LIGHTS && IsInvisibilitySet(TO_HOUSES)) return;
|
||||
|
||||
/* Check whether details should be transparent. */
|
||||
bool is_transparent = false;
|
||||
if (roadside == ROADSIDE_TREES && IsTransparencySet(TO_TREES)) {
|
||||
is_transparent = true;
|
||||
}
|
||||
if (roadside == ROADSIDE_STREET_LIGHTS && IsTransparencySet(TO_HOUSES)) {
|
||||
is_transparent = true;
|
||||
}
|
||||
|
||||
/* Draw extra details. */
|
||||
for (const DrawRoadTileStruct *drts = _road_display_table[roadside][road | tram]; drts->image != 0; drts++) {
|
||||
@@ -1668,7 +1704,7 @@ static void DrawTile_Road(TileInfo *ti)
|
||||
|
||||
Axis axis = GetCrossingRailAxis(ti->tile);
|
||||
|
||||
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
|
||||
const RailTypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
|
||||
|
||||
RoadType road_rt = GetRoadTypeRoad(ti->tile);
|
||||
RoadType tram_rt = GetRoadTypeTram(ti->tile);
|
||||
@@ -1716,7 +1752,7 @@ static void DrawTile_Road(TileInfo *ti)
|
||||
/* Draw rail/PBS overlay */
|
||||
bool draw_pbs = _game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile);
|
||||
if (rti->UsesOverlay()) {
|
||||
PaletteID pal = draw_pbs ? PALETTE_CRASH : PAL_NONE;
|
||||
pal = draw_pbs ? PALETTE_CRASH : PAL_NONE;
|
||||
SpriteID rail = GetCustomRailSprite(rti, ti->tile, RTSG_CROSSING) + axis;
|
||||
DrawGroundSprite(rail, pal);
|
||||
|
||||
@@ -1726,7 +1762,7 @@ static void DrawTile_Road(TileInfo *ti)
|
||||
uint adjacent_diagdirs = 0;
|
||||
for (DiagDirection dir : { dir1, dir2 }) {
|
||||
const TileIndex t = TileAddByDiagDir(ti->tile, dir);
|
||||
if (t < MapSize() && IsLevelCrossingTile(t) && GetCrossingRoadAxis(t) == road_axis) {
|
||||
if (t < Map::Size() && IsLevelCrossingTile(t) && GetCrossingRoadAxis(t) == road_axis) {
|
||||
SetBit(adjacent_diagdirs, dir);
|
||||
}
|
||||
}
|
||||
@@ -1758,7 +1794,7 @@ static void DrawTile_Road(TileInfo *ti)
|
||||
}
|
||||
} else if (draw_pbs || tram_rti != nullptr || road_rti->UsesOverlay()) {
|
||||
/* Add another rail overlay, unless there is only the base road sprite. */
|
||||
PaletteID pal = draw_pbs ? PALETTE_CRASH : PAL_NONE;
|
||||
pal = draw_pbs ? PALETTE_CRASH : PAL_NONE;
|
||||
SpriteID rail = GetCrossingRoadAxis(ti->tile) == AXIS_Y ? GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_x : GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_y;
|
||||
DrawGroundSprite(rail, pal);
|
||||
}
|
||||
@@ -1831,7 +1867,7 @@ void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
|
||||
{
|
||||
PaletteID palette = COMPANY_SPRITE_COLOUR(_local_company);
|
||||
|
||||
const RoadTypeInfo* rti = GetRoadTypeInfo(rt);
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
||||
int relocation = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_DEPOT);
|
||||
bool default_gfx = relocation == 0;
|
||||
if (default_gfx) {
|
||||
@@ -1874,7 +1910,7 @@ void UpdateNearestTownForRoadTiles(bool invalidate)
|
||||
{
|
||||
assert(!invalidate || _generating_world);
|
||||
|
||||
for (TileIndex t = 0; t < MapSize(); t++) {
|
||||
for (TileIndex t = 0; t < Map::Size(); t++) {
|
||||
if (IsTileType(t, MP_ROAD) && !IsRoadDepot(t) && !HasTownOwnedRoad(t)) {
|
||||
TownID tid = INVALID_TOWN;
|
||||
if (!invalidate) {
|
||||
@@ -1886,7 +1922,7 @@ void UpdateNearestTownForRoadTiles(bool invalidate)
|
||||
}
|
||||
}
|
||||
|
||||
static int GetSlopePixelZ_Road(TileIndex tile, uint x, uint y)
|
||||
static int GetSlopePixelZ_Road(TileIndex tile, uint x, uint y, bool)
|
||||
{
|
||||
|
||||
if (IsNormalRoad(tile)) {
|
||||
@@ -1919,6 +1955,8 @@ static const Roadside _town_road_types[][2] = {
|
||||
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
|
||||
};
|
||||
|
||||
static_assert(lengthof(_town_road_types) == HZB_END);
|
||||
|
||||
static const Roadside _town_road_types_2[][2] = {
|
||||
{ ROADSIDE_GRASS, ROADSIDE_GRASS },
|
||||
{ ROADSIDE_PAVED, ROADSIDE_PAVED },
|
||||
@@ -1927,6 +1965,8 @@ static const Roadside _town_road_types_2[][2] = {
|
||||
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
|
||||
};
|
||||
|
||||
static_assert(lengthof(_town_road_types_2) == HZB_END);
|
||||
|
||||
|
||||
static void TileLoop_Road(TileIndex tile)
|
||||
{
|
||||
@@ -2016,7 +2056,7 @@ static void TileLoop_Road(TileIndex tile)
|
||||
|
||||
/* Possibly change road type */
|
||||
if (GetRoadOwner(tile, RTT_ROAD) == OWNER_TOWN) {
|
||||
RoadType rt = GetTownRoadType(t);
|
||||
RoadType rt = GetTownRoadType();
|
||||
if (rt != GetRoadTypeRoad(tile)) {
|
||||
SetRoadType(tile, RTT_ROAD, rt);
|
||||
}
|
||||
@@ -2155,7 +2195,7 @@ static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
|
||||
td->str = STR_LAI_ROAD_DESCRIPTION_ROAD_RAIL_LEVEL_CROSSING;
|
||||
rail_owner = GetTileOwner(tile);
|
||||
|
||||
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
|
||||
const RailTypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
|
||||
td->railtype = rti->strings.name;
|
||||
td->rail_speed = rti->max_speed;
|
||||
|
||||
@@ -2203,7 +2243,7 @@ static const byte _roadveh_enter_depot_dir[4] = {
|
||||
TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE
|
||||
};
|
||||
|
||||
static VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
|
||||
static VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int, int)
|
||||
{
|
||||
switch (GetRoadTileType(tile)) {
|
||||
case ROAD_TILE_DEPOT: {
|
||||
@@ -2394,7 +2434,7 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
||||
TileIndex area_end = tile;
|
||||
|
||||
if (!ValParamRoadType(to_type)) return CMD_ERROR;
|
||||
if (area_start >= MapSize()) return CMD_ERROR;
|
||||
if (area_start >= Map::Size()) return CMD_ERROR;
|
||||
|
||||
RoadVehicleList affected_rvs;
|
||||
RoadTramType rtt = GetRoadTramType(to_type);
|
||||
@@ -2403,7 +2443,7 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
||||
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)
|
||||
|
||||
TileIterator *iter = new OrthogonalTileIterator(area_start, area_end);
|
||||
std::unique_ptr<TileIterator> iter = std::make_unique<OrthogonalTileIterator>(area_start, area_end);
|
||||
for (; (tile = *iter) != INVALID_TILE; ++(*iter)) {
|
||||
/* Is road present on tile? */
|
||||
if (!MayHaveRoad(tile)) continue;
|
||||
@@ -2462,14 +2502,14 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
||||
}
|
||||
|
||||
if (rtt == RTT_ROAD && owner == OWNER_TOWN) {
|
||||
SetDParamsForOwnedBy(OWNER_TOWN, tile);
|
||||
error.MakeError(STR_ERROR_OWNED_BY);
|
||||
GetNameOfOwner(OWNER_TOWN, tile);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
uint num_pieces = CountBits(GetAnyRoadBits(tile, rtt));
|
||||
if (tt == MP_STATION && IsStandardRoadStopTile(tile)) {
|
||||
if (tt == MP_STATION && IsBayRoadStopTile(tile)) {
|
||||
num_pieces *= ROAD_STOP_TRACKBIT_FACTOR;
|
||||
} else if (tt == MP_ROAD && IsRoadDepot(tile)) {
|
||||
num_pieces *= ROAD_DEPOT_TRACKBIT_FACTOR;
|
||||
@@ -2515,8 +2555,8 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
||||
}
|
||||
|
||||
if (rtt == RTT_ROAD && owner == OWNER_TOWN) {
|
||||
SetDParamsForOwnedBy(OWNER_TOWN, tile);
|
||||
error.MakeError(STR_ERROR_OWNED_BY);
|
||||
GetNameOfOwner(OWNER_TOWN, tile);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -2559,7 +2599,6 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
||||
}
|
||||
}
|
||||
|
||||
delete iter;
|
||||
return found_convertible_road ? cost : error;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user