From e308c348f0f1dad5d18349aba5c19a2a4b372df3 Mon Sep 17 00:00:00 2001 From: smatz Date: Fri, 21 Jan 2011 16:20:55 +0000 Subject: (svn r21879) -Codechange: reset vehicle's GOINGUP/DOWN bits when it crashes --- src/ground_vehicle.hpp | 15 +++++++++++++++ src/roadveh_cmd.cpp | 2 +- src/train_cmd.cpp | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp index 503cddf13..7e2894f5b 100644 --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -86,6 +86,21 @@ struct GroundVehicle : public SpecializedVehicle { 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. diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index d084d37a8..59d979273 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -460,7 +460,7 @@ static Vehicle *EnumCheckRoadVehCrashTrain(Vehicle *v, void *data) uint RoadVehicle::Crash(bool flooded) { - uint pass = Vehicle::Crash(flooded); + uint pass = this->GroundVehicleBase::Crash(flooded); if (this->IsFrontEngine()) { pass += 1; // driver diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 4d058396d..6f1cc9003 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2780,7 +2780,7 @@ uint Train::Crash(bool flooded) 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; -- cgit v1.2.3-70-g09d2