Index: src/road_cmd.cpp =================================================================== --- src/road_cmd.cpp (revisi¢n: 18520) +++ src/road_cmd.cpp (copia de trabajo) @@ -697,9 +697,9 @@ } /** Build a long piece of road. - * @param end_tile end tile of drag + * @param end_tile start tile of drag * @param flags operation to perform - * @param p1 start tile of drag + * @param p1 end tile of drag * @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) @@ -709,19 +709,20 @@ * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildLongRoad(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - CommandCost cost(EXPENSES_CONSTRUCTION); + CommandCost ret, cost(EXPENSES_CONSTRUCTION); bool had_bridge = false; bool had_tunnel = false; bool had_success = false; + bool inverted = false; DisallowedRoadDirections drd = DRD_NORTHBOUND; _error_message = INVALID_STRING_ID; if (p1 >= MapSize()) return CMD_ERROR; - TileIndex start_tile = p1; + TileIndex end_tile = p1; RoadType rt = (RoadType)GB(p2, 3, 2); if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR; @@ -729,11 +730,9 @@ if (!HasBit(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis if (HasBit(p2, 2) && TileX(start_tile) != TileX(end_tile)) return CMD_ERROR; // y-axis - /* Swap start and ending tile, also the half-tile drag var (bit 0 and 1) */ + /* Swap the half-tile drag var (bit 0 and 1) */ if (start_tile > end_tile || (start_tile == end_tile && HasBit(p2, 0))) { - TileIndex t = start_tile; - start_tile = end_tile; - end_tile = t; + inverted = true; p2 ^= IsInsideMM(p2 & 3, 1, 3) ? 3 : 0; drd = DRD_SOUTHBOUND; } @@ -750,13 +749,18 @@ for (;;) { RoadBits bits = HasBit(p2, 2) ? ROAD_Y : ROAD_X; - if (tile == end_tile && !HasBit(p2, 1)) bits &= ROAD_NW | ROAD_NE; - if (tile == start_tile && HasBit(p2, 0)) bits &= ROAD_SE | ROAD_SW; + if (inverted) { + if (tile == start_tile && !HasBit(p2, 1)) bits &= ROAD_NW | ROAD_NE; + if (tile == end_tile && HasBit(p2, 0)) bits &= ROAD_SE | ROAD_SW; + } else { + if (tile == end_tile && !HasBit(p2, 1)) bits &= ROAD_NW | ROAD_NE; + if (tile == start_tile && HasBit(p2, 0)) bits &= ROAD_SE | ROAD_SW; + } _error_message = INVALID_STRING_ID; - CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD); + ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD); if (CmdFailed(ret)) { - if (_error_message != STR_ERROR_ALREADY_BUILT) return CMD_ERROR; + if (_error_message != STR_ERROR_ALREADY_BUILT) break; } else { had_success = true; /* Only pay for the upgrade on one side of the bridges and tunnels */ @@ -779,7 +783,11 @@ if (tile == end_tile) break; - tile += HasBit(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); + if (inverted) { + tile += HasBit(p2, 2) ? TileDiffXY(0, -1) : TileDiffXY(-1, 0); + } else { + tile += HasBit(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); + } } return !had_success ? CMD_ERROR : cost; Index: src/road_gui.cpp =================================================================== --- src/road_gui.cpp (revisi¢n: 18520) +++ src/road_gui.cpp (copia de trabajo) @@ -605,7 +605,7 @@ * not the 3rd bit set) */ _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3)); - DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), + DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), _remove_button_clicked ? CMD_REMOVE_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) : CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound1D);