diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2017-05-31 07:24:00 +0200 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2017-05-31 07:24:00 +0200 |
| commit | 92c65ff3b240678ab864e4eb574e02f6151bdbe4 (patch) | |
| tree | 2ed5dc6c355e658fbe2de92c207bede986876587 /Source | |
| parent | f5d1b4415c3bc8f145a84b8fd00d04629eb6e218 (diff) | |
| download | airport-92c65ff3b240678ab864e4eb574e02f6151bdbe4.tar.gz | |
* Used runway is now freed if state == STATE_APPROACH.
TODO: Free runway on state == STATE_READY_TAKEOFF or STATE_ENTERING_RWY.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Aircraft.c | 9 | ||||
| -rw-r--r-- | Source/Aircraft.h | 1 | ||||
| -rw-r--r-- | Source/Game.c | 83 | ||||
| -rw-r--r-- | Source/Game.h | 2 | ||||
| -rw-r--r-- | Source/Menu.c | 2 |
5 files changed, 68 insertions, 29 deletions
diff --git a/Source/Aircraft.c b/Source/Aircraft.c index 14b1ea2..c2932c5 100644 --- a/Source/Aircraft.c +++ b/Source/Aircraft.c @@ -420,7 +420,7 @@ void AircraftDirection(TYPE_AIRCRAFT_DATA* ptrAircraft) if(GameInsideLevelFromIsoPos(&ptrAircraft->IsoPos) == true)
{
- GameRemoveFlight(ptrAircraft->FlightDataIdx);
+ GameRemoveFlight(ptrAircraft->FlightDataIdx, true);
}
}
}
@@ -553,6 +553,13 @@ uint16_t* AircraftGetTargets(uint8_t index) return ptrAircraft->Target;
}
+uint8_t AircraftGetTargetIdx(uint8_t index)
+{
+ TYPE_AIRCRAFT_DATA* ptrAircraft = AircraftFromFlightDataIndex(index);
+
+ return ptrAircraft->TargetIdx;
+}
+
bool AircraftMoving(uint8_t index)
{
TYPE_AIRCRAFT_DATA* ptrAircraft = AircraftFromFlightDataIndex(index);
diff --git a/Source/Aircraft.h b/Source/Aircraft.h index d681479..8a7f75c 100644 --- a/Source/Aircraft.h +++ b/Source/Aircraft.h @@ -25,6 +25,7 @@ uint16_t AircraftGetTileFromFlightDataIndex(uint8_t index); bool AircraftRemove(uint8_t aircraftIdx);
uint16_t* AircraftGetTargets(uint8_t index);
bool AircraftMoving(uint8_t index);
+uint8_t AircraftGetTargetIdx(uint8_t index);
AIRCRAFT_DIRECTION AircraftGetDirection(TYPE_AIRCRAFT_DATA* ptrAircraft);
bool AircraftAddNew( TYPE_FLIGHT_DATA * ptrFlightData,
uint8_t FlightDataIndex,
diff --git a/Source/Game.c b/Source/Game.c index 6c59674..19db3b6 100644 --- a/Source/Game.c +++ b/Source/Game.c @@ -803,7 +803,7 @@ void GameAircraftState(void) target[0] = FlightData.Parking[i]; - dprintf("Target assigned = %d", target[0]); + dprintf("Target assigned = %d\n", target[0]); if(AircraftAddNew(&FlightData, i, target) == false) { @@ -824,18 +824,8 @@ void GameAircraftState(void) && (FlightData.RemainingTime[i] == 0) ) { - uint8_t j; - // Player(s) lost a flight! - FlightData.State[i] = STATE_IDLE; - GameScore = (GameScore < LOST_FLIGHT_PENALTY)? 0 : (GameScore - LOST_FLIGHT_PENALTY); - - for(j = 0; j < MAX_PLAYERS; j++) - { - TYPE_PLAYER* ptrPlayer = &PlayerData[j]; - - GameActiveAircraftList(ptrPlayer, &FlightData); - } + GameRemoveFlight(i, false); } } } @@ -1012,9 +1002,31 @@ void GameRenderLevel(TYPE_PLAYER* ptrPlayer) || (GameLevelBuffer[i] == TILE_RWY_HOLDING_POINT_2) ) ) { - ptrTileset->r = NORMAL_LUMINANCE >> 2; - ptrTileset->g = rwy_sine; - ptrTileset->b = NORMAL_LUMINANCE >> 2; + uint16_t aircraftTile; + bool bHoldingRwyBusy = false; + + for(j = 0; j < GAME_MAX_AIRCRAFT; j++) + { + aircraftTile = AircraftGetTileFromFlightDataIndex(j); + + if(i == aircraftTile) + { + bHoldingRwyBusy = true; + } + } + + if(bHoldingRwyBusy == true) + { + ptrTileset->r = rwy_sine; + ptrTileset->g = NORMAL_LUMINANCE >> 2; + ptrTileset->b = NORMAL_LUMINANCE >> 2; + } + else + { + ptrTileset->r = NORMAL_LUMINANCE >> 2; + ptrTileset->g = rwy_sine; + ptrTileset->b = NORMAL_LUMINANCE >> 2; + } } else if( (ptrPlayer->SelectTaxiwayParking == true) && @@ -2211,7 +2223,7 @@ void GameStateUnboarding(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData else { // Flight has finished. Remove aircraft and set finished flag - GameRemoveFlight(ptrPlayer->FlightDataSelectedAircraft); + GameRemoveFlight(ptrPlayer->FlightDataSelectedAircraft, true); } ptrPlayer->UnboardingSequenceIdx = 0; @@ -2414,19 +2426,20 @@ bool GameInsideLevelFromIsoPos(TYPE_ISOMETRIC_FIX16_POS* ptrIsoPos) return false; } -void GameRemoveFlight(uint8_t idx) +void GameRemoveFlight(uint8_t idx, bool successful) { - TYPE_PLAYER* ptrPlayer; uint8_t i; - uint8_t j; - for(i = 0; i < MAX_PLAYERS; i++) + for(i = PLAYER_ONE; i < MAX_PLAYERS; i++) { - ptrPlayer = &PlayerData[i]; + TYPE_PLAYER* ptrPlayer = &PlayerData[i]; + uint8_t j; for(j = 0; j < ptrPlayer->ActiveAircraft; j++) { - if(FlightData.State[ptrPlayer->FlightDataSelectedAircraft] != STATE_IDLE) + uint8_t k; + + if(FlightData.State[ptrPlayer->ActiveAircraftList[j]] != STATE_IDLE) { if(ptrPlayer->ActiveAircraftList[j] == idx) { @@ -2447,9 +2460,20 @@ void GameRemoveFlight(uint8_t idx) DEBUG_PRINT_VAR(&PlayerData[PLAYER_ONE]); DEBUG_PRINT_VAR(&PlayerData[PLAYER_TWO]);*/ - FlightData.Passengers[ptrPlayer->FlightDataSelectedAircraft] = 0; - FlightData.State[ptrPlayer->FlightDataSelectedAircraft] = STATE_IDLE; - FlightData.Finished[ptrPlayer->FlightDataSelectedAircraft] = true; + FlightData.Passengers[ptrPlayer->ActiveAircraftList[j]] = 0; + FlightData.State[ptrPlayer->ActiveAircraftList[j]] = STATE_IDLE; + FlightData.Finished[ptrPlayer->ActiveAircraftList[j]] = true; + + for(k = 0; k < GAME_MAX_RUNWAYS; k++) + { + uint16_t* targets = AircraftGetTargets(ptrPlayer->ActiveAircraftList[j]); + uint8_t targetIdx = AircraftGetTargetIdx(ptrPlayer->ActiveAircraftList[j]); + + if(SystemContains_u16(GameUsedRwy[k], targets, targetIdx) == true) + { + GameUsedRwy[k] = 0; + } + } if(AircraftRemove(idx) == false) { @@ -2459,7 +2483,14 @@ void GameRemoveFlight(uint8_t idx) ptrPlayer->LockTarget = false; ptrPlayer->LockedAircraft = 0; - GameScore += SCORE_REWARD_FINISH_FLIGHT; + if(successful == true) + { + GameScore += SCORE_REWARD_FINISH_FLIGHT; + } + else + { + GameScore = (GameScore < LOST_FLIGHT_PENALTY)? 0 : (GameScore - LOST_FLIGHT_PENALTY); + } return; } diff --git a/Source/Game.h b/Source/Game.h index c5ff605..094b99a 100644 --- a/Source/Game.h +++ b/Source/Game.h @@ -51,5 +51,5 @@ uint16_t GameGetTileFromIsoPosition(TYPE_ISOMETRIC_POS * IsoPos); FL_STATE GameGetFlightDataStateFromIdx(uint8_t FlightDataIdx); uint32_t GameGetScore(void); bool GameInsideLevelFromIsoPos(TYPE_ISOMETRIC_FIX16_POS* ptrIsoPos); -void GameRemoveFlight(uint8_t idx); +void GameRemoveFlight(uint8_t idx, bool successful); #endif //__GAME_HEADER__ diff --git a/Source/Menu.c b/Source/Menu.c index b2dde33..168ef00 100644 --- a/Source/Menu.c +++ b/Source/Menu.c @@ -283,7 +283,7 @@ void MainMenu(void) case ONE_TWO_PLAYERS_LEVEL: - GsSortCls(0,0,40); + GsSortCls(0,0,40); MainMenuDrawButton(&MainMenuBtn[ONE_PLAYER_BUTTON_INDEX]); MainMenuDrawButton(&MainMenuBtn[TWO_PLAYER_BUTTON_INDEX]); |
