Changeset - r14660:861ca27274d0
[Not reviewed]
master
0 2 0
smatz - 15 years ago 2010-02-25 14:09:58
smatz@openttd.org
(svn r19249) -Fix [FS#3642](r18803): start and end tiles were swapped in CMD_REMOVE_LONG_ROAD
2 files changed with 7 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_road.cpp
Show inline comments
 
@@ -547,23 +547,23 @@ static bool NeighbourHasReachableRoad(::
 
{
 
	EnforcePrecondition(false, ::IsValidTile(start));
 
	EnforcePrecondition(false, ::IsValidTile(end));
 
	EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end));
 
	EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType()));
 

	
 
	return AIObject::DoCommand(end, start, (::TileY(start) != ::TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (AIObject::GetRoadType() << 3), CMD_REMOVE_LONG_ROAD);
 
	return AIObject::DoCommand(start, end, (::TileY(start) != ::TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (AIObject::GetRoadType() << 3), CMD_REMOVE_LONG_ROAD);
 
}
 

	
 
/* static */ bool AIRoad::RemoveRoadFull(TileIndex start, TileIndex end)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(start));
 
	EnforcePrecondition(false, ::IsValidTile(end));
 
	EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end));
 
	EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType()));
 

	
 
	return AIObject::DoCommand(end, start, (::TileY(start) != ::TileY(end) ? 4 : 0) | (start < end ? 2 : 1) | (AIObject::GetRoadType() << 3), CMD_REMOVE_LONG_ROAD);
 
	return AIObject::DoCommand(start, end, (::TileY(start) != ::TileY(end) ? 4 : 0) | (start < end ? 2 : 1) | (AIObject::GetRoadType() << 3), CMD_REMOVE_LONG_ROAD);
 
}
 

	
 
/* static */ bool AIRoad::RemoveRoadDepot(TileIndex tile)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, IsTileType(tile, MP_ROAD))
src/road_cmd.cpp
Show inline comments
 
@@ -776,30 +776,30 @@ CommandCost CmdBuildLongRoad(TileIndex s
 
	}
 

	
 
	return !had_success ? CMD_ERROR : cost;
 
}
 

	
 
/** Remove a long piece of road.
 
 * @param end_tile end tile of drag
 
 * @param start_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)
 
 * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
 
 * - p2 = (bit 3 + 4) - road type
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveLongRoad(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 

	
 
	if (p1 >= MapSize()) return CMD_ERROR;
 

	
 
	TileIndex start_tile = p1;
 
	TileIndex end_tile = p1;
 
	RoadType rt = (RoadType)GB(p2, 3, 2);
 
	if (!IsValidRoadType(rt)) return CMD_ERROR;
 

	
 
	Axis axis = Extract<Axis, 2>(p2);
 
	/* Only drag in X or Y direction dictated by the direction variable */
 
	if (axis == AXIS_X && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis
 
@@ -826,13 +826,13 @@ CommandCost CmdRemoveLongRoad(TileIndex 
 
		if (bits != 0) {
 
			CommandCost ret = RemoveRoad(tile, flags & ~DC_EXEC, bits, rt, true);
 
			if (ret.Succeeded()) {
 
				if (flags & DC_EXEC) {
 
					money -= ret.GetCost();
 
					if (money < 0) {
 
						_additional_cash_required = DoCommand(end_tile, start_tile, p2, flags & ~DC_EXEC, CMD_REMOVE_LONG_ROAD).GetCost();
 
						_additional_cash_required = DoCommand(start_tile, end_tile, p2, flags & ~DC_EXEC, CMD_REMOVE_LONG_ROAD).GetCost();
 
						return cost;
 
					}
 
					RemoveRoad(tile, flags, bits, rt, true, false);
 
				}
 
				cost.AddCost(ret);
 
			}
0 comments (0 inline, 0 general)