diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2018-11-23 14:44:21 +0100 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2018-11-23 14:44:21 +0100 |
| commit | ca6e4a13aa1b0d696b375fbd1ad43933174d34b9 (patch) | |
| tree | 62f1fdd641c614e9bb1ac05d7a8efad17fcb6a30 /Source/Game.c | |
| parent | 3b80f74ce10cfd7e55199dcb9a8c4b80598227d2 (diff) | |
| download | airport-ca6e4a13aa1b0d696b375fbd1ad43933174d34b9.tar.gz | |
Fixed critical bug that provoked an accidental access to a NULL pointer.
Diffstat (limited to 'Source/Game.c')
| -rw-r--r-- | Source/Game.c | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/Source/Game.c b/Source/Game.c index beb4b89..f582e47 100644 --- a/Source/Game.c +++ b/Source/Game.c @@ -438,21 +438,18 @@ void GameInit(const TYPE_GAME_CONFIGURATION* const pGameCfg) { uint8_t i; uint32_t track; - static bool firstLoad = true; + static bool loaded; GameStartupFlag = true; // Has to be initialized before loading *.PLT files inside LoadMenu(). MessageInit(); - if (firstLoad) + if (loaded == false) { - firstLoad = false; + loaded = true; - LoadMenu( GameFileList, - GameFileDest, - sizeof (GameFileList) / sizeof (char*), - sizeof (GameFileDest) /sizeof (void*) ); + LOAD_FILES(GameFileList, GameFileDest); } LoadMenu( &pGameCfg->PLTPath, @@ -3618,65 +3615,70 @@ void GameGenerateUnboardingSequence(TYPE_PLAYER* const ptrPlayer) void GameCreateTakeoffWaypoints(TYPE_PLAYER* const ptrPlayer, TYPE_FLIGHT_DATA* const ptrFlightData, uint8_t aircraftIdx) { - // Look for aircraft direction by searching TILE_RWY_EXIT - //uint16_t currentTile = AircraftGetTileFromFlightDataIndex(aircraftIdx); - //uint8_t targetsIdx = 0; - DIRECTION aircraftDir = AircraftGetDirection(AircraftFromFlightDataIndex(aircraftIdx)); - int8_t rwyStep = 0; - uint16_t currentTile = 0; - uint16_t targets[AIRCRAFT_MAX_TARGETS] = {0}; - uint8_t i; + TYPE_AIRCRAFT_DATA* const ptrAircraft = AircraftFromFlightDataIndex(aircraftIdx); - switch(aircraftDir) + if (ptrAircraft != NULL) { - case DIR_EAST: - rwyStep = 1; - break; + // Look for aircraft direction by searching TILE_RWY_EXIT + //uint16_t currentTile = AircraftGetTileFromFlightDataIndex(aircraftIdx); + //uint8_t targetsIdx = 0; + DIRECTION aircraftDir = AircraftGetDirection(ptrAircraft); + int8_t rwyStep = 0; + uint16_t currentTile = 0; + uint16_t targets[AIRCRAFT_MAX_TARGETS] = {0}; + uint8_t i; + + switch(aircraftDir) + { + case DIR_EAST: + rwyStep = 1; + break; - case DIR_WEST: - rwyStep = -1; - break; + case DIR_WEST: + rwyStep = -1; + break; - case DIR_NORTH: - rwyStep = -GameLevelColumns; - break; + case DIR_NORTH: + rwyStep = -GameLevelColumns; + break; - case DIR_SOUTH: - rwyStep = GameLevelColumns; - break; + case DIR_SOUTH: + rwyStep = GameLevelColumns; + break; - default: - return; - } + default: + return; + } - for (currentTile = (AircraftGetTileFromFlightDataIndex(aircraftIdx) + rwyStep); - ((levelBuffer[currentTile] & ~(TILE_MIRROR_FLAG)) != TILE_RWY_START_1) - && - ((levelBuffer[currentTile] & ~(TILE_MIRROR_FLAG)) != TILE_RWY_START_2); - currentTile -= rwyStep ) - { - // Calculate new currentTile value until conditions are invalid. - } + for (currentTile = (AircraftGetTileFromFlightDataIndex(aircraftIdx) + rwyStep); + ((levelBuffer[currentTile] & ~(TILE_MIRROR_FLAG)) != TILE_RWY_START_1) + && + ((levelBuffer[currentTile] & ~(TILE_MIRROR_FLAG)) != TILE_RWY_START_2); + currentTile -= rwyStep ) + { + // Calculate new currentTile value until conditions are invalid. + } - for (i = 0; i < GAME_MAX_RUNWAYS; i++) - { - if (GameUsedRwy[i] == currentTile) + for (i = 0; i < GAME_MAX_RUNWAYS; i++) { - GameUsedRwy[i] = 0; - break; + if (GameUsedRwy[i] == currentTile) + { + GameUsedRwy[i] = 0; + break; + } } - } - for ( currentTile = (AircraftGetTileFromFlightDataIndex(aircraftIdx) + rwyStep); - (levelBuffer[currentTile] & ~(TILE_MIRROR_FLAG)) != TILE_RWY_EXIT; - currentTile += rwyStep ) - { + for ( currentTile = (AircraftGetTileFromFlightDataIndex(aircraftIdx) + rwyStep); + (levelBuffer[currentTile] & ~(TILE_MIRROR_FLAG)) != TILE_RWY_EXIT; + currentTile += rwyStep ) + { - } + } - targets[0] = currentTile; + targets[0] = currentTile; - AircraftAddTargets(AircraftFromFlightDataIndex(aircraftIdx), targets); + AircraftAddTargets(AircraftFromFlightDataIndex(aircraftIdx), targets); + } } /* ******************************************************************************************* |
