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

« back to all changes in this revision

Viewing changes to src/station_map.h

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: station_map.h 12042 2008-02-02 09:28:43Z peter1138 $ */
 
1
/* $Id: station_map.h 15643 2009-03-08 16:10:39Z smatz $ */
2
2
 
3
 
/** @file station_map.h */
 
3
/** @file station_map.h Maps accessors for stations. */
4
4
 
5
5
#ifndef STATION_MAP_H
6
6
#define STATION_MAP_H
8
8
#include "rail_map.h"
9
9
#include "road_map.h"
10
10
#include "water_map.h"
11
 
#include "station.h"
 
11
#include "station_func.h"
 
12
#include "station_base.h"
12
13
#include "rail.h"
13
14
 
14
15
typedef byte StationGfx;
15
16
 
 
17
/** Get Station ID from a tile
 
18
 * @pre Tile \t must be part of the station
 
19
 * @param t Tile to query station ID from
 
20
 * @return Station ID of the station at \a t */
16
21
static inline StationID GetStationIndex(TileIndex t)
17
22
{
18
23
        assert(IsTileType(t, MP_STATION));
49
54
        return (StationType)GB(_m[t].m6, 3, 3);
50
55
}
51
56
 
52
 
static inline RoadStop::Type GetRoadStopType(TileIndex t)
 
57
static inline RoadStopType GetRoadStopType(TileIndex t)
53
58
{
54
59
        assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
55
 
        return GetStationType(t) == STATION_TRUCK ? RoadStop::TRUCK : RoadStop::BUS;
 
60
        return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
56
61
}
57
62
 
58
63
static inline StationGfx GetStationGfx(TileIndex t)
67
72
        _m[t].m5 = gfx;
68
73
}
69
74
 
 
75
static inline uint8 GetStationAnimationFrame(TileIndex t)
 
76
{
 
77
        assert(IsTileType(t, MP_STATION));
 
78
        return _me[t].m7;
 
79
}
 
80
 
 
81
static inline void SetStationAnimationFrame(TileIndex t, uint8 frame)
 
82
{
 
83
        assert(IsTileType(t, MP_STATION));
 
84
        _me[t].m7 = frame;
 
85
}
 
86
 
70
87
static inline bool IsRailwayStation(TileIndex t)
71
88
{
72
89
        return GetStationType(t) == STATION_RAIL;
84
101
 
85
102
bool IsHangar(TileIndex t);
86
103
 
 
104
/**
 
105
 * Is the station at \a t a truck stop?
 
106
 * @param t Tile to check
 
107
 * @return \c true if station is a truck stop, \c false otherwise */
87
108
static inline bool IsTruckStop(TileIndex t)
88
109
{
89
110
        return GetStationType(t) == STATION_TRUCK;
90
111
}
91
112
 
 
113
/**
 
114
 * Is the station at \a t a bus stop?
 
115
 * @param t Tile to check
 
116
 * @return \c true if station is a bus stop, \c false otherwise */
92
117
static inline bool IsBusStop(TileIndex t)
93
118
{
94
119
        return GetStationType(t) == STATION_BUS;
95
120
}
96
121
 
 
122
/**
 
123
 * Is the station at \a t a road station?
 
124
 * @pre Tile at \a t is a station tile
 
125
 * @param t Tile to check
 
126
 * @return \c true if station at the tile is a bus top or a truck stop, \c false otherwise */
97
127
static inline bool IsRoadStop(TileIndex t)
98
128
{
99
129
        assert(IsTileType(t, MP_STATION));
115
145
        return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
116
146
}
117
147
 
118
 
static inline bool GetStopBuiltOnTownRoad(TileIndex t)
119
 
{
120
 
        assert(IsDriveThroughStopTile(t));
121
 
        return HasBit(_m[t].m6, 2);
122
 
}
123
 
 
124
 
 
125
148
/**
126
149
 * Gets the direction the road stop entrance points towards.
127
150
 */
146
169
        return GetStationType(t) == STATION_DOCK;
147
170
}
148
171
 
 
172
static inline bool IsDockTile(TileIndex t)
 
173
{
 
174
        return IsTileType(t, MP_STATION) && GetStationType(t) == STATION_DOCK;
 
175
}
 
176
 
149
177
static inline bool IsBuoy(TileIndex t)
150
178
{
151
179
        return GetStationType(t) == STATION_BUOY;
185
213
                !IsStationTileBlocked(t1);
186
214
}
187
215
 
 
216
/**
 
217
 * Get the reservation state of the rail station
 
218
 * @pre IsRailwayStationTile(t)
 
219
 * @param t the station tile
 
220
 * @return reservation state
 
221
 */
 
222
static inline bool GetRailwayStationReservation(TileIndex t)
 
223
{
 
224
        assert(IsRailwayStationTile(t));
 
225
        return HasBit(_m[t].m6, 2);
 
226
}
 
227
 
 
228
/**
 
229
 * Set the reservation state of the rail station
 
230
 * @pre IsRailwayStationTile(t)
 
231
 * @param t the station tile
 
232
 * @param b the reservation state
 
233
 */
 
234
static inline void SetRailwayStationReservation(TileIndex t, bool b)
 
235
{
 
236
        assert(IsRailwayStationTile(t));
 
237
        SB(_m[t].m6, 2, 1, b ? 1 : 0);
 
238
}
 
239
 
 
240
/**
 
241
 * Get the reserved track bits for a waypoint
 
242
 * @pre IsRailwayStationTile(t)
 
243
 * @param t the tile
 
244
 * @return reserved track bits
 
245
 */
 
246
static inline TrackBits GetRailStationReservation(TileIndex t)
 
247
{
 
248
        return GetRailwayStationReservation(t) ? AxisToTrackBits(GetRailStationAxis(t)) : TRACK_BIT_NONE;
 
249
}
 
250
 
188
251
 
189
252
static inline DiagDirection GetDockDirection(TileIndex t)
190
253
{
251
314
        _m[t].m3 = 0;
252
315
        _m[t].m4 = 0;
253
316
        _m[t].m5 = section;
 
317
        SB(_m[t].m6, 2, 1, 0);
254
318
        SB(_m[t].m6, 3, 3, st);
 
319
        _me[t].m7 = 0;
255
320
}
256
321
 
257
322
static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
258
323
{
259
324
        MakeStation(t, o, sid, STATION_RAIL, section + a);
260
325
        SetRailType(t, rt);
261
 
}
262
 
 
263
 
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, DiagDirection d)
264
 
{
265
 
        MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), d);
266
 
        SetRoadTypes(t, rt);
267
 
}
268
 
 
269
 
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, Axis a, bool on_town_road)
270
 
{
271
 
        MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
272
 
        SB(_m[t].m6, 2, 1, on_town_road);
273
 
        SetRoadTypes(t, rt);
 
326
        SetRailwayStationReservation(t, false);
 
327
}
 
328
 
 
329
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)
 
330
{
 
331
        MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);
 
332
        SetRoadTypes(t, rt);
 
333
        SetRoadOwner(t, ROADTYPE_ROAD, o);
 
334
        SetRoadOwner(t, ROADTYPE_TRAM, o);
 
335
}
 
336
 
 
337
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadTypes rt, Axis a)
 
338
{
 
339
        MakeStation(t, station, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
 
340
        SetRoadTypes(t, rt);
 
341
        SetRoadOwner(t, ROADTYPE_ROAD, road);
 
342
        SetRoadOwner(t, ROADTYPE_TRAM, tram);
274
343
}
275
344
 
276
345
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
294
363
        SetWaterClass(t + TileOffsByDiagDir(d), wc);
295
364
}
296
365
 
297
 
static inline void MakeOilrig(TileIndex t, StationID sid)
 
366
static inline void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
298
367
{
299
368
        MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0);
 
369
        SetWaterClass(t, wc);
300
370
}
301
371
 
302
372
#endif /* STATION_MAP_H */