(svn r2261) - Fix: When crashed vehicles try to find a depot for servicing, openttd asserts.
Crashed vehicles shouldn't find depots anyway...
This commit is contained in:
		@@ -353,6 +353,9 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 | 
				
			|||||||
	if (v->type != VEH_Road || !CheckOwnership(v->owner))
 | 
						if (v->type != VEH_Road || !CheckOwnership(v->owner))
 | 
				
			||||||
		return CMD_ERROR;
 | 
							return CMD_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (v->vehstatus & VS_CRASHED)
 | 
				
			||||||
 | 
							return CMD_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (v->current_order.type == OT_GOTO_DEPOT) {
 | 
						if (v->current_order.type == OT_GOTO_DEPOT) {
 | 
				
			||||||
		if (flags & DC_EXEC) {
 | 
							if (flags & DC_EXEC) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1002,6 +1002,9 @@ int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 | 
				
			|||||||
	if (v->type != VEH_Ship || !CheckOwnership(v->owner))
 | 
						if (v->type != VEH_Ship || !CheckOwnership(v->owner))
 | 
				
			||||||
		return CMD_ERROR;
 | 
							return CMD_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (v->vehstatus & VS_CRASHED)
 | 
				
			||||||
 | 
							return CMD_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (v->current_order.type == OT_GOTO_DEPOT) {
 | 
						if (v->current_order.type == OT_GOTO_DEPOT) {
 | 
				
			||||||
		if (flags & DC_EXEC) {
 | 
							if (flags & DC_EXEC) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1298,7 +1298,8 @@ static bool TrainFindDepotEnumProc(uint tile, TrainFindDepotData *tfdd, int trac
 | 
				
			|||||||
	return length >= tfdd->best_length;
 | 
						return length >= tfdd->best_length;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// returns the tile of a depot to goto to.
 | 
					// returns the tile of a depot to goto to. The given vehicle must be on track,
 | 
				
			||||||
 | 
					// so not crashed, in a depot, etc.
 | 
				
			||||||
static TrainFindDepotData FindClosestTrainDepot(Vehicle *v)
 | 
					static TrainFindDepotData FindClosestTrainDepot(Vehicle *v)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
@@ -1362,6 +1363,9 @@ int32 CmdTrainGotoDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 | 
				
			|||||||
	if (v->type != VEH_Train || !CheckOwnership(v->owner))
 | 
						if (v->type != VEH_Train || !CheckOwnership(v->owner))
 | 
				
			||||||
		return CMD_ERROR;
 | 
							return CMD_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (v->vehstatus & VS_CRASHED)
 | 
				
			||||||
 | 
							return CMD_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (v->current_order.type == OT_GOTO_DEPOT) {
 | 
						if (v->current_order.type == OT_GOTO_DEPOT) {
 | 
				
			||||||
		if (flags & DC_EXEC) {
 | 
							if (flags & DC_EXEC) {
 | 
				
			||||||
			if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) {
 | 
								if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,6 +55,9 @@ bool VehicleNeedsService(const Vehicle *v)
 | 
				
			|||||||
	if (_patches.no_servicing_if_no_breakdowns && _opt.diff.vehicle_breakdowns == 0)
 | 
						if (_patches.no_servicing_if_no_breakdowns && _opt.diff.vehicle_breakdowns == 0)
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (v->vehstatus & VS_CRASHED)
 | 
				
			||||||
 | 
							return false; /* Crashed vehicles don't need service anymore */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return _patches.servint_ispercent ?
 | 
						return _patches.servint_ispercent ?
 | 
				
			||||||
		(v->reliability < _engines[v->engine_type].reliability * (100 - v->service_interval) / 100) :
 | 
							(v->reliability < _engines[v->engine_type].reliability * (100 - v->service_interval) / 100) :
 | 
				
			||||||
		(v->date_of_last_service + v->service_interval < _date);
 | 
							(v->date_of_last_service + v->service_interval < _date);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user