mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r19491) -Codechange: Keep track of last error in CmdRemoveLongRoad().
This commit is contained in:
parent
467803a7c0
commit
b714160fcc
@ -848,6 +848,8 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32
|
|||||||
|
|
||||||
Money money = GetAvailableMoneyForCommand();
|
Money money = GetAvailableMoneyForCommand();
|
||||||
TileIndex tile = start_tile;
|
TileIndex tile = start_tile;
|
||||||
|
CommandCost last_error = CMD_ERROR;
|
||||||
|
bool had_success = false;
|
||||||
/* Start tile is the small number. */
|
/* Start tile is the small number. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
RoadBits bits = AxisToRoadBits(axis);
|
RoadBits bits = AxisToRoadBits(axis);
|
||||||
@ -868,6 +870,9 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32
|
|||||||
RemoveRoad(tile, flags, bits, rt, true, false);
|
RemoveRoad(tile, flags, bits, rt, true, false);
|
||||||
}
|
}
|
||||||
cost.AddCost(ret);
|
cost.AddCost(ret);
|
||||||
|
had_success = true;
|
||||||
|
} else {
|
||||||
|
last_error = ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -876,7 +881,7 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32
|
|||||||
tile += (axis == AXIS_Y) ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
tile += (axis == AXIS_Y) ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (cost.GetCost() == 0) ? CMD_ERROR : cost;
|
return had_success ? cost : last_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Build a road depot.
|
/** Build a road depot.
|
||||||
|
Loading…
Reference in New Issue
Block a user