Changeset - r17328:c2138f8c095c
[Not reviewed]
master
0 1 0
rubidium - 13 years ago 2011-02-14 19:18:12
rubidium@openttd.org
(svn r22078) -Fix [FS#4499]: maximum train length interfered with wagon replacement when wagon removal was turned on
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -494,7 +494,10 @@ static CommandCost ReplaceChain(Vehicle 
 
						/* Insert wagon after 'last_engine' */
 
						CommandCost res = CmdMoveVehicle(append, last_engine, DC_EXEC, false);
 

	
 
						if (res.Succeeded() && wagon_removal && new_head->gcache.cached_total_length > old_total_length) {
 
						/* When we allow removal of wagons, either the move failing due
 
						 * to the train becoming too long, or the train becoming longer
 
						 * would move the vehicle to the empty vehicle chain. */
 
						if (wagon_removal && (res.Failed() ? res.GetErrorMessage() == STR_ERROR_TRAIN_TOO_LONG : new_head->gcache.cached_total_length > old_total_length)) {
 
							CmdMoveVehicle(append, NULL, DC_EXEC | DC_AUTOREPLACE, false);
 
							break;
 
						}
 
@@ -511,6 +514,7 @@ static CommandCost ReplaceChain(Vehicle 
 

	
 
			/* Sell superfluous new vehicles that could not be inserted. */
 
			if (cost.Succeeded() && wagon_removal) {
 
				assert(new_head->gcache.cached_total_length <= _settings_game.vehicle.max_train_length * TILE_SIZE);
 
				for (int i = 1; i < num_units; i++) {
 
					Vehicle *wagon = new_vehs[i];
 
					if (wagon == NULL) continue;
0 comments (0 inline, 0 general)