|
@@ -687,12 +687,13 @@ do_clear:;
|
|
|
* @param p2 various bitstuffed elements
|
|
|
* - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1)
|
|
|
* - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
|
|
|
* - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
|
|
|
* - p2 = (bit 3 + 4) - road type
|
|
|
* - p2 = (bit 5) - set road direction
|
|
|
* - p2 = (bit 6) - 0 = build up to an obstacle, 1 = fail if an obstacle is found (used for AIs).
|
|
|
* @param text unused
|
|
|
* @return the cost of this operation or an error
|
|
|
*/
|
|
|
CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
{
|
|
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
|
@@ -739,13 +740,16 @@ CommandCost CmdBuildLongRoad(TileIndex s
|
|
|
if (tile == end_tile && !HasBit(p2, 1)) bits &= DiagDirToRoadBits(ReverseDiagDir(dir));
|
|
|
if (tile == start_tile && HasBit(p2, 0)) bits &= DiagDirToRoadBits(dir);
|
|
|
|
|
|
_error_message = INVALID_STRING_ID;
|
|
|
CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD);
|
|
|
if (ret.Failed()) {
|
|
|
if (_error_message != STR_ERROR_ALREADY_BUILT) break;
|
|
|
if (_error_message != STR_ERROR_ALREADY_BUILT) {
|
|
|
if (HasBit(p2, 6)) return CMD_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)) {
|