Changeset - r17131:8e7f5d0ba4e4
[Not reviewed]
master
0 3 0
smatz - 13 years ago 2011-01-21 16:20:55
smatz@openttd.org
(svn r21879) -Codechange: reset vehicle's GOINGUP/DOWN bits when it crashes
3 files changed with 17 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/ground_vehicle.hpp
Show inline comments
 
@@ -84,12 +84,27 @@ struct GroundVehicle : public Specialize
 

	
 
	void PowerChanged();
 
	void CargoChanged();
 
	int GetAcceleration() const;
 

	
 
	/**
 
	 * Common code executed for crashed ground vehicles
 
	 * @param flooded was this vehicle flooded?
 
	 * @return number of victims
 
	 */
 
	/* virtual */ uint Crash(bool flooded)
 
	{
 
		/* Crashed vehicles aren't going up or down */
 
		for (T *v = T::From(this); v != NULL; v = v->Next()) {
 
			ClrBit(v->gv_flags, GVF_GOINGUP_BIT);
 
			ClrBit(v->gv_flags, GVF_GOINGDOWN_BIT);
 
		}
 
		return this->Vehicle::Crash(flooded);
 
	}
 

	
 
	/**
 
	 * Calculates the total slope resistance for this vehicle.
 
	 * @return Slope resistance.
 
	 */
 
	FORCEINLINE int32 GetSlopeResistance() const
 
	{
 
		int32 incl = 0;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -457,13 +457,13 @@ static Vehicle *EnumCheckRoadVehCrashTra
 
			abs(v->x_pos - u->x_pos) <= 4 &&
 
			abs(v->y_pos - u->y_pos) <= 4) ? v : NULL;
 
}
 

	
 
uint RoadVehicle::Crash(bool flooded)
 
{
 
	uint pass = Vehicle::Crash(flooded);
 
	uint pass = this->GroundVehicleBase::Crash(flooded);
 
	if (this->IsFrontEngine()) {
 
		pass += 1; // driver
 

	
 
		/* If we're in a drive through road stop we ought to leave it */
 
		if (IsInsideMM(this->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END)) {
 
			RoadStop::GetByTile(this->tile, GetRoadStopType(this->tile))->Leave(this);
src/train_cmd.cpp
Show inline comments
 
@@ -2777,13 +2777,13 @@ uint Train::Crash(bool flooded)
 
		if (crossing != INVALID_TILE) UpdateLevelCrossing(crossing);
 

	
 
		/* Remove the loading indicators (if any) */
 
		HideFillingPercent(&this->fill_percent_te_id);
 
	}
 

	
 
	pass += Vehicle::Crash(flooded);
 
	pass += this->GroundVehicleBase::Crash(flooded);
 

	
 
	this->crash_anim_pos = flooded ? 4000 : 1; // max 4440, disappear pretty fast when flooded
 
	return pass;
 
}
 

	
 
/**
0 comments (0 inline, 0 general)