mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r18974) -Fix [FS#3578]: CMD_BUILD_ROAD missed CMD_AUTO. Also do not access tiles anymore after clearing them; that fails either in test or exec run.
This commit is contained in:
parent
8e6096931a
commit
cbbe311cea
|
@ -221,7 +221,7 @@ static const Command _command_proc_table[] = {
|
||||||
{CmdRemoveRoadStop, 0}, // CMD_REMOVE_ROAD_STOP
|
{CmdRemoveRoadStop, 0}, // CMD_REMOVE_ROAD_STOP
|
||||||
{CmdBuildLongRoad, CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_LONG_ROAD
|
{CmdBuildLongRoad, CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_LONG_ROAD
|
||||||
{CmdRemoveLongRoad, CMD_NO_TEST | CMD_AUTO}, // CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
|
{CmdRemoveLongRoad, CMD_NO_TEST | CMD_AUTO}, // CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
|
||||||
{CmdBuildRoad, 0}, // CMD_BUILD_ROAD
|
{CmdBuildRoad, CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_ROAD
|
||||||
{CmdRemoveRoad, 0}, // CMD_REMOVE_ROAD
|
{CmdRemoveRoad, 0}, // CMD_REMOVE_ROAD
|
||||||
{CmdBuildRoadDepot, CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_ROAD_DEPOT
|
{CmdBuildRoadDepot, CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_ROAD_DEPOT
|
||||||
|
|
||||||
|
|
|
@ -483,6 +483,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
|
|
||||||
Slope tileh = GetTileSlope(tile, NULL);
|
Slope tileh = GetTileSlope(tile, NULL);
|
||||||
|
|
||||||
|
bool tile_cleared = false; // Used to remember that the tile was cleared during test run
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_ROAD:
|
case MP_ROAD:
|
||||||
switch (GetRoadTileType(tile)) {
|
switch (GetRoadTileType(tile)) {
|
||||||
|
@ -601,6 +602,7 @@ do_clear:;
|
||||||
CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
cost.AddCost(ret);
|
cost.AddCost(ret);
|
||||||
|
tile_cleared = true;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +617,7 @@ do_clear:;
|
||||||
cost.AddCost(ret);
|
cost.AddCost(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsTileType(tile, MP_ROAD)) {
|
if (!tile_cleared && IsTileType(tile, MP_ROAD)) {
|
||||||
/* Don't put the pieces that already exist */
|
/* Don't put the pieces that already exist */
|
||||||
pieces &= ComplementRoadBits(existing);
|
pieces &= ComplementRoadBits(existing);
|
||||||
|
|
||||||
|
@ -637,10 +639,10 @@ do_clear:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
if (!tile_cleared && !EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
cost.AddCost(CountBits(pieces) * _price[PR_BUILD_ROAD]);
|
cost.AddCost(CountBits(pieces) * _price[PR_BUILD_ROAD]);
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
if (!tile_cleared && IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
/* Pay for *every* tile of the bridge or tunnel */
|
/* Pay for *every* tile of the bridge or tunnel */
|
||||||
cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2);
|
cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue