(svn r12886) [NewGRF_ports] -Change: Added test for IsInFlight to detect if an aircraft is flying between airports, or is in the main body of the FSM. NewGRF_ports
authorrichk
Fri, 25 Apr 2008 01:39:33 +0000
branchNewGRF_ports
changeset 10345 14c21d416900
parent 10337 3d5a7bddcea6
child 10346 a1e9f8871c05
(svn r12886) [NewGRF_ports] -Change: Added test for IsInFlight to detect if an aircraft is flying between airports, or is in the main body of the FSM.
src/aircraft.h
--- a/src/aircraft.h	Thu Apr 24 21:53:20 2008 +0000
+++ b/src/aircraft.h	Fri Apr 25 01:39:33 2008 +0000
@@ -54,6 +54,17 @@
 	}
 }
 
+/** Check if the aircraft is in flight between airports
+ * @param v vehicle to check
+ * @return Returns true if the aircraft is in flight
+ * false if it is any other state) */
+static inline bool IsInFlight(const Vehicle *v)
+{
+	assert(v->type == VEH_AIRCRAFT);
+	return ((v->u.air.pos == v->u.air.previous_pos) && v->u.air.state == FLYING);
+}
+
+
 /** Checks if an aircraft can use the station in question
  * @param engine The engine to test
  * @param st The station