aboutsummaryrefslogtreecommitdiff
path: root/Source/Game.c
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2017-09-16 03:21:15 +0200
committerXaviDCR92 <xavi.dcr@gmail.com>2017-09-16 03:21:15 +0200
commit6629a61c3bde7a79c7ac32d6bffbc72e31e91fc3 (patch)
tree7a23885577374b5a5760ae4514099feadae312cf /Source/Game.c
parent0d7af34486f15d8f31f8474f17cad698923cadcb (diff)
downloadairport-6629a61c3bde7a79c7ac32d6bffbc72e31e91fc3.tar.gz
* Removed unneeded -g flag from Makefile.
* Aircraft now prevents collision against other aircraft if state == STATE_TAXIING. * Game: new event handlers for new Aircraft collision prevention algorithm. * Font: although not compulsory, _blend_effect_lum should be volatile. * Other minor changes.
Diffstat (limited to 'Source/Game.c')
-rw-r--r--Source/Game.c71
1 files changed, 63 insertions, 8 deletions
diff --git a/Source/Game.c b/Source/Game.c
index 2fc14ad..614905d 100644
--- a/Source/Game.c
+++ b/Source/Game.c
@@ -2344,21 +2344,20 @@ void GameSelectAircraftFromList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFli
break;
}
}
-
- Serial_printf("aircraftState = %d\n", aircraftState);
- Serial_printf("AircraftIdx = %d\n", AircraftIdx);
}
else if (ptrPlayer->PadKeySinglePress_Callback(PAD_L1) == true)
{
- FL_STATE* AircraftState = &FlightData.State[ptrPlayer->FlightDataSelectedAircraft];
+ FL_STATE* ptrAircraftState = &FlightData.State[ptrPlayer->FlightDataSelectedAircraft];
- if (*AircraftState == STATE_TAXIING)
+ if (*ptrAircraftState == STATE_TAXIING)
{
- *AircraftState = STATE_STOPPED;
+ *ptrAircraftState = STATE_USER_STOPPED;
}
- else if (*AircraftState == STATE_STOPPED)
+ else if ( (*ptrAircraftState == STATE_USER_STOPPED)
+ ||
+ (*ptrAircraftState == STATE_AUTO_STOPPED) )
{
- *AircraftState = STATE_TAXIING;
+ *ptrAircraftState = STATE_TAXIING;
}
}
}
@@ -3948,3 +3947,59 @@ void GameAircraftCollision(uint8_t AircraftIdx)
GameAircraftCollisionFlag = true;
GameAircraftCollisionIdx = AircraftIdx;
}
+
+/* *******************************************************************************************
+ *
+ * @name: void GameAircraftCollision(uint8_t AircraftIdx)
+ *
+ * @author: Xavier Del Campo
+ *
+ * @param:
+ *
+ * uint8_t AircraftIdx:
+ * Index from FlightData.
+ *
+ * @brief:
+ * Event triggered by Aircraft when aircraft A is getting close to non-moving aircraft B
+ * and a security stop must be done in order to avoid collision.
+ *
+ * *******************************************************************************************/
+
+void GameStopFlight(uint8_t AircraftIdx)
+{
+ FL_STATE* ptrState = &FlightData.State[AircraftIdx];
+
+ if (*ptrState == STATE_TAXIING)
+ {
+ // Only allow auto stop under taxi
+ *ptrState = STATE_AUTO_STOPPED;
+ }
+}
+
+/* *******************************************************************************************
+ *
+ * @name: void GameAircraftCollision(uint8_t AircraftIdx)
+ *
+ * @author: Xavier Del Campo
+ *
+ * @param:
+ *
+ * uint8_t AircraftIdx:
+ * Index from FlightData.
+ *
+ * @brief:
+ * Event triggered by Aircraft when aircraft A is no longer getting close to aircraft B, so
+ * that taxiing can be resumed.
+ *
+ * *******************************************************************************************/
+
+void GameResumeFlightFromAutoStop(uint8_t AircraftIdx)
+{
+ FL_STATE* ptrState = &FlightData.State[AircraftIdx];
+
+ if (*ptrState == STATE_AUTO_STOPPED)
+ {
+ // Only recovery to STATE_TAXIING is allowed.
+ *ptrState = STATE_TAXIING;
+ }
+}