Changeset - r15312:e63ca178d21b
[Not reviewed]
master
0 1 0
terkhen - 14 years ago 2010-06-11 20:30:12
terkhen@openttd.org
(svn r19963) -Add: Stop a vehicle after it crashes or is destroyed.
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -160,24 +160,26 @@ bool Vehicle::NeedsAutomaticServicing() 
 
	if (_settings_game.order.gotodepot && VehicleHasDepotOrders(this)) return false;
 
	if (this->current_order.IsType(OT_LOADING))            return false;
 
	if (this->current_order.IsType(OT_GOTO_DEPOT) && this->current_order.GetDepotOrderType() != ODTFB_SERVICE) return false;
 
	return NeedsServicing();
 
}
 

	
 
uint Vehicle::Crash(bool flooded)
 
{
 
	assert((this->vehstatus & VS_CRASHED) == 0);
 
	assert(this->Previous() == NULL); // IsPrimaryVehicle fails for free-wagon-chains
 

	
 
	uint pass = 0;
 
	/* Stop the vehicle. */
 
	if (this->IsPrimaryVehicle()) this->vehstatus |= VS_STOPPED;
 
	/* crash all wagons, and count passengers */
 
	for (Vehicle *v = this; v != NULL; v = v->Next()) {
 
		if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo.Count();
 
		v->vehstatus |= VS_CRASHED;
 
		MarkSingleVehicleDirty(v);
 
	}
 

	
 
	/* Dirty some windows */
 
	InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
	SetWindowDirty(WC_VEHICLE_DEPOT, this->tile);
0 comments (0 inline, 0 general)