(svn r9804) -Fix (r9761): Update aircraft cached information when its 'pos' changes, as well as 'state'. (Thanks to bulb)
authorpeter1138
Sun, 06 May 2007 21:10:49 +0000
changeset 7086 466f738d31c7
parent 7085 bb5d226fc24a
child 7087 b65f7298f106
(svn r9804) -Fix (r9761): Update aircraft cached information when its 'pos' changes, as well as 'state'. (Thanks to bulb)
src/aircraft_cmd.cpp
--- a/src/aircraft_cmd.cpp	Sun May 06 20:05:10 2007 +0000
+++ b/src/aircraft_cmd.cpp	Sun May 06 21:10:49 2007 +0000
@@ -1091,6 +1091,7 @@
 				 * helicopter will circle until sign disappears, then go to next order
 				 * what to do when it is the only order left, right now it just stays in 1 place */
 				v->u.air.state = FLYING;
+				UpdateAircraftCache(v);
 				AircraftNextAirportPos_and_Order(v);
 				return false;
 			}
@@ -1205,6 +1206,7 @@
 			if (st->airport_tile == 0) {
 				/* Airport has been removed, abort the landing procedure */
 				v->u.air.state = FLYING;
+				UpdateAircraftCache(v);
 				AircraftNextAirportPos_and_Order(v);
 				/* get aircraft back on running altitude */
 				SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlyingAltitude(v));
@@ -1879,7 +1881,7 @@
 		byte prev_state = v->u.air.state;
 		_aircraft_state_handlers[v->u.air.state](v, apc);
 		if (v->u.air.state != FLYING) v->u.air.previous_pos = prev_pos;
-		if (v->u.air.state != prev_state) UpdateAircraftCache(v);
+		if (v->u.air.state != prev_state || v->u.air.pos != prev_pos) UpdateAircraftCache(v);
 		return true;
 	}
 
@@ -1889,6 +1891,7 @@
 	if (current->next == NULL) {
 		if (AirportSetBlocks(v, current, apc)) {
 			v->u.air.pos = current->next_position;
+			UpdateAircraftCache(v);
 		} // move to next position
 		return false;
 	}
@@ -1899,6 +1902,7 @@
 		if (v->u.air.state == current->heading || current->heading == TO_ALL) {
 			if (AirportSetBlocks(v, current, apc)) {
 				v->u.air.pos = current->next_position;
+				UpdateAircraftCache(v);
 			} // move to next position
 			return false;
 		}
@@ -2203,6 +2207,7 @@
 				if (v->u.air.state >= FLYING) { // circle around
 					v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, ap);
 					v->u.air.state = FLYING;
+					UpdateAircraftCache(v);
 					/* landing plane needs to be reset to flying height (only if in pause mode upgrade,
 					 * in normal mode, plane is reset in AircraftController. It doesn't hurt for FLYING */
 					GetNewVehiclePosResult gp = GetNewVehiclePos(v);
@@ -2216,6 +2221,7 @@
 					for (uint cnt = 0; cnt < ap->nofelements; cnt++) {
 						if (ap->layout[cnt].heading == takeofftype) {
 							v->u.air.pos = ap->layout[cnt].position;
+							UpdateAircraftCache(v);
 							break;
 						}
 					}