Changeset - r17550:1c1132cf940b
[Not reviewed]
master
0 1 0
frosch - 13 years ago 2011-04-15 19:03:55
frosch@openttd.org
(svn r22324) -Fix: Vehicles skipped orders when inserting automatic orders failed.
1 file changed with 7 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -1898,48 +1898,55 @@ void Vehicle::LeaveStation()
 

	
 
		SetBit(Train::From(this)->flags, VRF_LEAVING_STATION);
 
	}
 
}
 

	
 

	
 
/**
 
 * Handle the loading of the vehicle; when not it skips through dummy
 
 * orders and does nothing in all other cases.
 
 * @param mode is the non-first call for this vehicle in this tick?
 
 */
 
void Vehicle::HandleLoading(bool mode)
 
{
 
	switch (this->current_order.GetType()) {
 
		case OT_LOADING: {
 
			uint wait_time = max(this->current_order.wait_time - this->lateness_counter, 0);
 

	
 
			/* Not the first call for this tick, or still loading */
 
			if (mode || !HasBit(this->vehicle_flags, VF_LOADING_FINISHED) || this->current_order_time < wait_time) return;
 

	
 
			this->PlayLeaveStationSound();
 

	
 
			this->LeaveStation();
 

	
 
			/* Only advance to next order if we just loaded at the current one */
 
			const Order *order = this->GetOrder(this->cur_auto_order_index);
 
			if (order == NULL ||
 
					(!order->IsType(OT_AUTOMATIC) && !order->IsType(OT_GOTO_STATION)) ||
 
					order->GetDestination() != this->last_station_visited) {
 
				return;
 
			}
 
			break;
 
		}
 

	
 
		case OT_DUMMY: break;
 

	
 
		default: return;
 
	}
 

	
 
	this->IncrementAutoOrderIndex();
 
}
 

	
 
/**
 
 * Send this vehicle to the depot using the given command(s).
 
 * @param flags   the command flags (like execute and such).
 
 * @param command the command to execute.
 
 * @return the cost of the depot action.
 
 */
 
CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
 
{
 
	CommandCost ret = CheckOwnership(this->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	if (this->vehstatus & VS_CRASHED) return CMD_ERROR;
 
	if (this->IsStoppedInDepot()) return CMD_ERROR;
0 comments (0 inline, 0 general)