From 341a6f6e959c75b4b6246579dc316e8c43c138f9 Mon Sep 17 00:00:00 2001 From: frosch Date: Mon, 6 May 2013 13:59:11 +0000 Subject: (svn r25223) -Change: [NewGRF] Unify the behaviour of Aircraft::tick_counter with other vehicle types and increment it once per tick. (instead of twice like before, or six times like in r0) --- src/aircraft_cmd.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 71d8d3bb2..18d284dbb 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1066,7 +1066,12 @@ static bool HandleCrashedAircraft(Aircraft *v) } -static void HandleAircraftSmoke(Aircraft *v) +/** + * Handle smoke of broken aircraft. + * @param v Aircraft + * @param mode Is this the non-first call for this vehicle in this tick? + */ +static void HandleAircraftSmoke(Aircraft *v, bool mode) { static const struct { int8 x; @@ -1084,13 +1089,15 @@ static void HandleAircraftSmoke(Aircraft *v) if (!(v->vehstatus & VS_AIRCRAFT_BROKEN)) return; + /* Stop smoking when landed */ if (v->cur_speed < 10) { v->vehstatus &= ~VS_AIRCRAFT_BROKEN; v->breakdown_ctr = 0; return; } - if ((v->tick_counter & 0x1F) == 0) { + /* Spawn effect et most once per Tick, i.e. !mode */ + if (!mode && (v->tick_counter & 0x0F) == 0) { CreateEffectVehicleRel(v, smoke_pos[v->direction].x, smoke_pos[v->direction].y, @@ -1893,8 +1900,6 @@ static void AircraftHandleDestTooFar(Aircraft *v, bool too_far) static bool AircraftEventHandler(Aircraft *v, int loop) { - v->tick_counter++; - if (v->vehstatus & VS_CRASHED) { return HandleCrashedAircraft(v); } @@ -1903,7 +1908,7 @@ static bool AircraftEventHandler(Aircraft *v, int loop) v->HandleBreakdown(); - HandleAircraftSmoke(v); + HandleAircraftSmoke(v, loop != 0); ProcessOrders(v); v->HandleLoading(loop != 0); @@ -1933,6 +1938,8 @@ bool Aircraft::Tick() { if (!this->IsNormalAircraft()) return true; + this->tick_counter++; + if (!(this->vehstatus & VS_STOPPED)) this->running_ticks++; if (this->subtype == AIR_HELICOPTER) HelicopterTickHandler(this); -- cgit v1.2.3-54-g00ecf