summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-05-06 13:59:11 +0000
committerfrosch <frosch@openttd.org>2013-05-06 13:59:11 +0000
commit341a6f6e959c75b4b6246579dc316e8c43c138f9 (patch)
tree41a727daf03380df41b7e5317a523d772c91d318
parent65855af0842ab9585612d7c02348c1ddccce2167 (diff)
downloadopenttd-341a6f6e959c75b4b6246579dc316e8c43c138f9.tar.xz
(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)
-rw-r--r--src/aircraft_cmd.cpp17
1 files 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);