~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/station_gui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Kooijman, Matthijs Kooijman
  • Date: 2009-10-01 22:52:59 UTC
  • mfrom: (1.1.8 upstream) (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091001225259-5kpkp4sthbszpyif
[ Matthijs Kooijman ]
* New upstream release
* Use printf instead of echo -en in openttd-wrapper to make it POSIX
  compatible (Closes: #547758).
* Remove three patches that are now included in upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: station_gui.cpp 16060 2009-04-14 21:13:07Z rubidium $ */
 
1
/* $Id: station_gui.cpp 16741 2009-07-04 17:20:48Z rubidium $ */
2
2
 
3
3
/** @file station_gui.cpp The GUI for stations. */
4
4
 
1000
1000
        AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
1001
1001
}
1002
1002
 
 
1003
/** Struct containing TileIndex and StationID */
 
1004
struct TileAndStation {
 
1005
        TileIndex tile;    ///< TileIndex
 
1006
        StationID station; ///< StationID
 
1007
};
 
1008
 
 
1009
static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
1003
1010
static SmallVector<StationID, 8> _stations_nearby_list;
1004
 
static SmallMap<TileIndex, StationID, 8> _deleted_stations_nearby;
1005
1011
 
1006
1012
/** Context for FindStationsNearby */
1007
1013
struct FindNearbyStationContext {
1020
1026
{
1021
1027
        FindNearbyStationContext *ctx = (FindNearbyStationContext *)user_data;
1022
1028
 
1023
 
        /* First check if there was a deleted station here */
1024
 
        SmallPair<TileIndex, StationID> *dst = _deleted_stations_nearby.Find(tile);
1025
 
        if (dst != _deleted_stations_nearby.End()) {
1026
 
                _stations_nearby_list.Include(dst->second);
1027
 
                return false;
 
1029
        /* First check if there were deleted stations here */
 
1030
        for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
 
1031
                TileAndStation *ts = _deleted_stations_nearby.Get(i);
 
1032
                if (ts->tile == tile) {
 
1033
                        *_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
 
1034
                        _deleted_stations_nearby.Erase(ts);
 
1035
                        i--;
 
1036
                }
1028
1037
        }
1029
1038
 
1030
1039
        /* Check if own station and if we stay within station spread */
1072
1081
                if (st->facilities == 0 && st->owner == _local_company) {
1073
1082
                        /* Include only within station spread (yes, it is strictly less than) */
1074
1083
                        if (max(DistanceMax(tile, st->xy), DistanceMax(TILE_ADDXY(tile, w - 1, h - 1), st->xy)) < _settings_game.station.station_spread) {
1075
 
                                _deleted_stations_nearby.Insert(st->xy, st->index);
 
1084
                                TileAndStation *ts = _deleted_stations_nearby.Append();
 
1085
                                ts->tile = st->xy;
 
1086
                                ts->station = st->index;
1076
1087
 
1077
1088
                                /* Add the station when it's within where we're going to build */
1078
1089
                                if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) &&