Index: src/economy.cpp =================================================================== --- src/economy.cpp (revision 14286) +++ src/economy.cpp (working copy) @@ -472,6 +472,7 @@ _current_player = old; + UpdateNobodysStations(); MarkWholeScreenDirty(); } Index: src/openttd.cpp =================================================================== --- src/openttd.cpp (revision 14286) +++ src/openttd.cpp (working copy) @@ -820,6 +820,7 @@ _current_player = _local_player; DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE); + UpdateNobodysStations(); MarkWholeScreenDirty(); } @@ -934,6 +935,7 @@ } #endif /* ENABLE_NETWORK */ } + UpdateNobodysStations(); break; } @@ -950,6 +952,7 @@ SetLocalPlayer(OWNER_NONE); GenerateWorld(GW_HEIGHTMAP, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y); + UpdateNobodysStations(); MarkWholeScreenDirty(); break; @@ -962,6 +965,7 @@ SetDParamStr(1, GetSaveLoadErrorString()); ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); } + UpdateNobodysStations(); break; } Index: src/station_func.h =================================================================== --- src/station_func.h (revision 14286) +++ src/station_func.h (working copy) @@ -49,4 +49,6 @@ void UpdateAirportsNoise(); +void UpdateNobodysStations(); + #endif /* STATION_FUNC_H */ Index: src/station.cpp =================================================================== --- src/station.cpp (revision 14286) +++ src/station.cpp (working copy) @@ -508,3 +508,56 @@ return NULL; } + +/** + * Update the nobody owned airports (oilfields), + * and set them as free if they are not being used. + */ +void UpdateNobodysStations() +{ + Vehicle *v; + Station *st; + TileIndex *occupied_tiles = MallocT(1); + int i, count = 0; + bool is_used; + + /* Loop through all the landed airplanes and keep their + * positions in mind */ + FOR_ALL_VEHICLES(v) + { + if (v->type == VEH_AIRCRAFT && v->tile != 0) + { + occupied_tiles = ReallocT(occupied_tiles, ++count); + occupied_tiles[count - 1] = v->tile; + } + } + + /* Loop through airports of nobody owned stations (typically oilfields), + * and find ones where aren't any aircrafts landed */ + FOR_ALL_STATIONS(st) + { + if (st->owner == OWNER_NONE && st->airport_tile != 0) + { + is_used = false; + for (i=0; iairport_tile) + { + is_used = true; + break; + } + } + + if (!is_used) + { + st->airport_flags = NOTHING_block; + } + } + } + + free(v); + free(st); + free(occupied_tiles); + + return; +}