Changeset - r26426:f1212f018b73
[Not reviewed]
master
0 6 0
Tyler Trahan - 2 years ago 2022-05-12 00:52:38
tyler@tylertrahan.com
Fix #9883: Show cost/income float over end tile of rail or road construction
6 files changed with 17 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -922,8 +922,8 @@ static CommandCost CmdRailTrackHelper(Do
 
 * Build rail on a stretch of track.
 
 * Stub for the unified rail builder/remover
 
 * @param flags operation to perform
 
 * @param tile start tile of drag
 
 * @param end_tile end tile of drag
 
 * @param start_tile start tile of drag
 
 * @param railtype railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
 
 * @param track track-orientation
 
 * @param auto_remove_signals false = build up to an obstacle, true = fail if an obstacle is found (used for AIs).
 
@@ -931,9 +931,9 @@ static CommandCost CmdRailTrackHelper(Do
 

	
 
 * @see CmdRailTrackHelper
 
 */
 
CommandCost CmdBuildRailroadTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle)
 
CommandCost CmdBuildRailroadTrack(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle)
 
{
 
	return CmdRailTrackHelper(flags, tile, end_tile, railtype, track, false, auto_remove_signals, fail_on_obstacle);
 
	return CmdRailTrackHelper(flags, start_tile, end_tile, railtype, track, false, auto_remove_signals, fail_on_obstacle);
 
}
 

	
 
/**
src/rail_gui.cpp
Show inline comments
 
@@ -355,10 +355,10 @@ static void DoRailroadTrack(Track track)
 
{
 
	if (_remove_button_clicked) {
 
		Command<CMD_REMOVE_RAILROAD_TRACK>::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
 
				TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track);
 
				TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), track);
 
	} else {
 
		Command<CMD_BUILD_RAILROAD_TRACK>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
 
				TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype, track, _settings_client.gui.auto_remove_signals, false);
 
				TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y),  _cur_railtype, track, _settings_client.gui.auto_remove_signals, false);
 
	}
 
}
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -962,8 +962,8 @@ static bool CanConnectToRoad(TileIndex t
 
/**
 
 * Build a long piece of road.
 
 * @param flags operation to perform
 
 * @param start_tile start tile of drag (the building cost will appear over this tile)
 
 * @param end_tile end tile of drag
 
 * @param start_tile start tile of drag
 
 * @param rt road type
 
 * @param axis direction
 
 * @param drd set road direction
 
@@ -974,7 +974,7 @@ static bool CanConnectToRoad(TileIndex t
 
 *      - 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 start_tile, TileIndex end_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
 
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;
 

	
 
@@ -1062,15 +1062,15 @@ CommandCost CmdBuildLongRoad(DoCommandFl
 
/**
 
 * Remove a long piece of road.
 
 * @param flags operation to perform
 
 * @param end_tile end tile of drag
 
 * @param start_tile start tile of drag
 
 * @param end_tile end tile of drag
 
 * @param rt road type
 
 * @param axis direction
 
 * @param start_half start tile starts in the 2nd half of tile
 
 * @param end_half end tile starts in the 2nd half of tile (p2 & 2)
 
 * @return the cost of this operation or an error
 
 */
 
std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex start_tile, TileIndex end_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
 
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);
 

	
 
@@ -1107,7 +1107,7 @@ std::tuple<CommandCost, Money> CmdRemove
 
				if (flags & DC_EXEC) {
 
					money_spent += ret.GetCost();
 
					if (money_spent > 0 && money_spent > money_available) {
 
						return { cost, std::get<0>(Command<CMD_REMOVE_LONG_ROAD>::Do(flags & ~DC_EXEC, start_tile, end_tile, rt, axis, start_half, end_half)).GetCost() };
 
						return { cost, std::get<0>(Command<CMD_REMOVE_LONG_ROAD>::Do(flags & ~DC_EXEC, end_tile, start_tile, rt, axis, start_half, end_half)).GetCost() };
 
					}
 
					RemoveRoad(tile, flags, bits, rtt, true, false);
 
				}
src/road_gui.cpp
Show inline comments
 
@@ -642,10 +642,10 @@ struct BuildRoadToolbarWindow : Window {
 

	
 
					if (_remove_button_clicked) {
 
						Command<CMD_REMOVE_LONG_ROAD>::Post(this->rti->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER,
 
								start_tile, end_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
 
								end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
 
					} else {
 
						Command<CMD_BUILD_LONG_ROAD>::Post(this->rti->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER,
 
								start_tile, end_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false);
 
								end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false);
 
					}
 
					break;
 
				}
src/script/api/script_rail.cpp
Show inline comments
 
@@ -365,7 +365,7 @@ static Track SimulateDrag(TileIndex from
 
			(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
 

	
 
	Track track = SimulateDrag(from, tile, &to);
 
	return ScriptObject::Command<CMD_BUILD_RAILROAD_TRACK>::Do(tile, to, (::RailType)ScriptRail::GetCurrentRailType(), track, false, true);
 
	return ScriptObject::Command<CMD_BUILD_RAILROAD_TRACK>::Do(to, tile, (::RailType)ScriptRail::GetCurrentRailType(), track, false, true);
 
}
 

	
 
/* static */ bool ScriptRail::RemoveRail(TileIndex from, TileIndex tile, TileIndex to)
 
@@ -382,7 +382,7 @@ static Track SimulateDrag(TileIndex from
 
			(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
 

	
 
	Track track = SimulateDrag(from, tile, &to);
 
	return ScriptObject::Command<CMD_REMOVE_RAILROAD_TRACK>::Do(tile, to, track);
 
	return ScriptObject::Command<CMD_REMOVE_RAILROAD_TRACK>::Do(to, tile, track);
 
}
 

	
 
/**
src/script/api/script_road.cpp
Show inline comments
 
@@ -496,7 +496,7 @@ static bool NeighbourHasReachableRoad(::
 
	EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType()));
 

	
 
	Axis axis = ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X;
 
	return ScriptObject::Command<CMD_BUILD_LONG_ROAD>::Do(start, end, ScriptObject::GetRoadType(), axis, one_way ? DRD_NORTHBOUND : DRD_NONE, (start < end) == !full, (start < end) != !full, true);
 
	return ScriptObject::Command<CMD_BUILD_LONG_ROAD>::Do(end, start, ScriptObject::GetRoadType(), axis, one_way ? DRD_NORTHBOUND : DRD_NONE, (start < end) == !full, (start < end) != !full, true);
 
}
 

	
 
/* static */ bool ScriptRoad::BuildRoad(TileIndex start, TileIndex end)
 
@@ -571,7 +571,7 @@ static bool NeighbourHasReachableRoad(::
 
	EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end));
 
	EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType()));
 

	
 
	return ScriptObject::Command<CMD_REMOVE_LONG_ROAD>::Do(start, end, ScriptObject::GetRoadType(), ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X, start < end, start >= end);
 
	return ScriptObject::Command<CMD_REMOVE_LONG_ROAD>::Do(end, start, ScriptObject::GetRoadType(), ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X, start < end, start >= end);
 
}
 

	
 
/* static */ bool ScriptRoad::RemoveRoadFull(TileIndex start, TileIndex end)
 
@@ -583,7 +583,7 @@ static bool NeighbourHasReachableRoad(::
 
	EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end));
 
	EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType()));
 

	
 
	return ScriptObject::Command<CMD_REMOVE_LONG_ROAD>::Do(start, end, ScriptObject::GetRoadType(), ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X, start >= end, start < end);
 
	return ScriptObject::Command<CMD_REMOVE_LONG_ROAD>::Do(end, start, ScriptObject::GetRoadType(), ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X, start >= end, start < end);
 
}
 

	
 
/* static */ bool ScriptRoad::RemoveRoadDepot(TileIndex tile)
0 comments (0 inline, 0 general)