Changeset - r26448:bfdeddc5c3d4
[Not reviewed]
master
0 2 0
Michael Lutz - 2 years ago 2022-10-16 16:01:43
michi@icosahedron.de
Fix db98cedb: Swap the tile parameter validation around as only the first TileIndex is automatically validated.
2 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -877,13 +877,13 @@ static CommandCost ValidateAutoDrag(Trac
 
 */
 
static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, RailType railtype, Track track, bool remove, bool auto_remove_signals, bool fail_on_obstacle)
 
{
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 

	
 
	if ((!remove && !ValParamRailtype(railtype)) || !ValParamTrackOrientation(track)) return CMD_ERROR;
 
	if (end_tile >= MapSize()) return CMD_ERROR;
 
	if (end_tile >= MapSize() || tile >= MapSize()) return CMD_ERROR;
 

	
 
	Trackdir trackdir = TrackToTrackdir(track);
 

	
 
	CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
 
	if (ret.Failed()) return ret;
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -973,13 +973,13 @@ static bool CanConnectToRoad(TileIndex t
 
 *      - false = Build up to an obstacle. Do not build the first and last roadbits unless they can be connected to something, or if we are building a single tile
 
 *      - true = Fail if an obstacle is found. Always take into account start_half and end_half. This behavior is used for scripts
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
 
{
 
	if (end_tile >= MapSize()) return CMD_ERROR;
 
	if (start_tile >= MapSize()) return CMD_ERROR;
 

	
 
	if (!ValParamRoadType(rt) || !IsValidAxis(axis) || !IsValidDisallowedRoadDirections(drd)) return CMD_ERROR;
 

	
 
	/* 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
 
	if (axis == AXIS_Y && TileX(start_tile) != TileX(end_tile)) return CMD_ERROR; // y-axis
 
@@ -1071,13 +1071,13 @@ CommandCost CmdBuildLongRoad(DoCommandFl
 
 * @return the cost of this operation or an error
 
 */
 
std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
 
{
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 

	
 
	if (end_tile >= MapSize()) return { CMD_ERROR, 0 };
 
	if (start_tile >= MapSize()) return { CMD_ERROR, 0 };
 
	if (!ValParamRoadType(rt) || !IsValidAxis(axis)) return { CMD_ERROR, 0 };
 

	
 
	/* 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, 0 }; // x-axis
 
	if (axis == AXIS_Y && TileX(start_tile) != TileX(end_tile)) return { CMD_ERROR, 0 }; // y-axis
 

	
0 comments (0 inline, 0 general)