Changeset - r14420:5d77bf502c4e
[Not reviewed]
master
0 3 0
terkhen - 15 years ago 2010-02-02 22:27:03
terkhen@openttd.org
(svn r18987) -Fix: [NoAI] Make building long rails fail for AIs if there is an obstacle in the way.
3 files changed with 7 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_rail.cpp
Show inline comments
 
@@ -332,7 +332,7 @@ static uint32 SimulateDrag(TileIndex fro
 
			(::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) ||
 
			(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
 

	
 
	uint32 p2 = SimulateDrag(from, tile, &to);
 
	uint32 p2 = SimulateDrag(from, tile, &to) | 1 << 8;
 
	return AIObject::DoCommand(tile, to, p2, CMD_BUILD_RAILROAD_TRACK);
 
}
 

	
src/ai/api/ai_rail.hpp
Show inline comments
 
@@ -380,6 +380,7 @@ public:
 
	 * @exception AIRail::ERR_CROSSING_ON_ONEWAY_ROAD
 
	 * @exception AIRoad::ERR_ROAD_WORKS_IN_PROGRESS
 
	 * @exception AIError::ERR_ALREADY_BUILT
 
	 * @note Construction will fail if an obstacle is found between the start and end tiles.
 
	 * @return Whether the rail has been/can be build or not.
 
	 */
 
	static bool BuildRail(TileIndex from, TileIndex tile, TileIndex to);
src/rail_cmd.cpp
Show inline comments
 
@@ -698,6 +698,7 @@ static CommandCost ValidateAutoDrag(Trac
 
 * - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
 
 * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
 
 * - p2 = (bit 7)   - 0 = build, 1 = remove tracks
 
 * - p2 = (bit 8)   - 0 = build up to an obstacle, 1 = fail if an obstacle is found (used for AIs).
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
@@ -721,7 +722,10 @@ static CommandCost CmdRailTrackHelper(Ti
 
		ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, remove ? CMD_REMOVE_SINGLE_RAIL : CMD_BUILD_SINGLE_RAIL);
 

	
 
		if (ret.Failed()) {
 
			if (_error_message != STR_ERROR_ALREADY_BUILT && !remove) break;
 
			if (_error_message != STR_ERROR_ALREADY_BUILT && !remove) {
 
				if (HasBit(p2, 8)) return CMD_ERROR;
 
				break;
 
			}
 
			_error_message = INVALID_STRING_ID;
 
		} else {
 
			total_cost.AddCost(ret);
0 comments (0 inline, 0 general)