Changeset - r15441:95dabb8cf50d
[Not reviewed]
master
0 1 0
terkhen - 14 years ago 2010-07-09 16:43:00
terkhen@openttd.org
(svn r20100) -Fix: Give priority to ownership errors while removing rails.
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -761,24 +761,27 @@ static CommandCost CmdRailTrackHelper(Ti
 

	
 
	bool had_success = false;
 
	CommandCost last_error = CMD_ERROR;
 
	for (;;) {
 
		CommandCost ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, remove ? CMD_REMOVE_SINGLE_RAIL : CMD_BUILD_SINGLE_RAIL);
 

	
 
		if (ret.Failed()) {
 
			last_error = ret;
 
			if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
 
				if (HasBit(p2, 8)) return last_error;
 
				break;
 
			}
 

	
 
			/* Ownership errors are more important. */
 
			if (last_error.GetErrorMessage() == STR_ERROR_OWNED_BY && remove) break;
 
		} else {
 
			had_success = true;
 
			total_cost.AddCost(ret);
 
		}
 

	
 
		if (tile == end_tile) break;
 

	
 
		tile += ToTileIndexDiff(_trackdelta[trackdir]);
 

	
 
		/* toggle railbit for the non-diagonal tracks */
 
		if (!IsDiagonalTrackdir(trackdir)) ToggleBit(trackdir, 0);
 
	}
0 comments (0 inline, 0 general)