author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 10445 | 2dd7d9d0a957 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9265
diff
changeset
|
3 |
/** @file station_base.h Base classes/functions for stations. */ |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6890
diff
changeset
|
4 |
|
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9265
diff
changeset
|
5 |
#ifndef STATION_BASE_H |
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9265
diff
changeset
|
6 |
#define STATION_BASE_H |
0 | 7 |
|
9265
3988d0156a49
(svn r12468) -Codechange: move some type related stuff from station.h (and openttd.h) to station_type.h.
rubidium
parents:
9069
diff
changeset
|
8 |
#include "station_type.h" |
6358 | 9 |
#include "airport.h" |
5216
d581e4db95b6
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
4981
diff
changeset
|
10 |
#include "oldpool.h" |
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7449
diff
changeset
|
11 |
#include "cargopacket.h" |
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8605
diff
changeset
|
12 |
#include "cargo_type.h" |
8709
4187ad809fe7
(svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium
parents:
8617
diff
changeset
|
13 |
#include "town_type.h" |
9283
624272490f5a
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
9281
diff
changeset
|
14 |
#include "strings_type.h" |
624272490f5a
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
9281
diff
changeset
|
15 |
#include "date_type.h" |
624272490f5a
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
9281
diff
changeset
|
16 |
#include "vehicle_type.h" |
624272490f5a
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
9281
diff
changeset
|
17 |
#include "player_type.h" |
624272490f5a
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
9281
diff
changeset
|
18 |
#include "core/geometry_type.hpp" |
10445
2dd7d9d0a957
(svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents:
10266
diff
changeset
|
19 |
#include "viewport_type.h" |
6996
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6916
diff
changeset
|
20 |
#include <list> |
0 | 21 |
|
7873
b3bccdcf85ef
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium
parents:
7872
diff
changeset
|
22 |
DECLARE_OLD_POOL(Station, Station, 6, 1000) |
b3bccdcf85ef
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium
parents:
7872
diff
changeset
|
23 |
DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000) |
b3bccdcf85ef
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium
parents:
7872
diff
changeset
|
24 |
|
6587
bc0bd6259485
(svn r9070) -Fix [FS#404]: if bribe failed and you didn't pick up cargo yet, you wouldn't ever be able to do so for a given station
truelight
parents:
6574
diff
changeset
|
25 |
static const byte INITIAL_STATION_RATING = 175; |
5921
51fa3124c16a
(svn r8130) Provide struct GoodsEntry with a constructor
tron
parents:
5916
diff
changeset
|
26 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
27 |
struct GoodsEntry { |
7970
204ece3a05d5
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium
parents:
7965
diff
changeset
|
28 |
enum AcceptancePickup { |
204ece3a05d5
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium
parents:
7965
diff
changeset
|
29 |
ACCEPTANCE, |
204ece3a05d5
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium
parents:
7965
diff
changeset
|
30 |
PICKUP |
204ece3a05d5
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium
parents:
7965
diff
changeset
|
31 |
}; |
204ece3a05d5
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium
parents:
7965
diff
changeset
|
32 |
|
5921
51fa3124c16a
(svn r8130) Provide struct GoodsEntry with a constructor
tron
parents:
5916
diff
changeset
|
33 |
GoodsEntry() : |
7970
204ece3a05d5
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium
parents:
7965
diff
changeset
|
34 |
acceptance_pickup(0), |
7509
5adc45aa7c3c
(svn r10269) -Fix [FS#912]: station ratings were shown for all cargos instead of only the cargos that have been transported.
rubidium
parents:
7506
diff
changeset
|
35 |
days_since_pickup(255), |
6587
bc0bd6259485
(svn r9070) -Fix [FS#404]: if bribe failed and you didn't pick up cargo yet, you wouldn't ever be able to do so for a given station
truelight
parents:
6574
diff
changeset
|
36 |
rating(INITIAL_STATION_RATING), |
5921
51fa3124c16a
(svn r8130) Provide struct GoodsEntry with a constructor
tron
parents:
5916
diff
changeset
|
37 |
last_speed(0), |
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7449
diff
changeset
|
38 |
last_age(255) |
5921
51fa3124c16a
(svn r8130) Provide struct GoodsEntry with a constructor
tron
parents:
5916
diff
changeset
|
39 |
{} |
51fa3124c16a
(svn r8130) Provide struct GoodsEntry with a constructor
tron
parents:
5916
diff
changeset
|
40 |
|
7970
204ece3a05d5
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium
parents:
7965
diff
changeset
|
41 |
byte acceptance_pickup; |
0 | 42 |
byte days_since_pickup; |
43 |
byte rating; |
|
44 |
byte last_speed; |
|
45 |
byte last_age; |
|
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7449
diff
changeset
|
46 |
CargoList cargo; ///< The cargo packets of cargo waiting in this station |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
47 |
}; |
0 | 48 |
|
6087
b56c54f79335
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents:
6086
diff
changeset
|
49 |
/** A Stop for a Road Vehicle */ |
7873
b3bccdcf85ef
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium
parents:
7872
diff
changeset
|
50 |
struct RoadStop : PoolItem<RoadStop, RoadStopID, &_RoadStop_pool> { |
7900
b88064d431b5
(svn r10777) -Fix: don't put the ctor debug on lvl3, it is more a lvl5 debug
truelight
parents:
7873
diff
changeset
|
51 |
static const int cDebugCtorLevel = 5; ///< Debug level on which Contructor / Destructor messages are printed |
6088
c11f7acc18bd
(svn r8403) -Fix (r8402): Forgot to remove an enum
celestar
parents:
6087
diff
changeset
|
52 |
static const uint LIMIT = 16; ///< The maximum amount of roadstops that are allowed at a single station |
6316
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
53 |
static const uint MAX_BAY_COUNT = 2; ///< The maximum number of loading bays |
6087
b56c54f79335
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents:
6086
diff
changeset
|
54 |
|
b56c54f79335
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents:
6086
diff
changeset
|
55 |
TileIndex xy; ///< Position on the map |
6316
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
56 |
byte status; ///< Current status of the Stop. Like which spot is taken. Access using *Bay and *Busy functions. |
6087
b56c54f79335
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents:
6086
diff
changeset
|
57 |
byte num_vehicles; ///< Number of vehicles currently slotted to this stop |
b56c54f79335
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents:
6086
diff
changeset
|
58 |
struct RoadStop *next; ///< Next stop of the given type at this station |
5959
6a4c261987c3
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5934
diff
changeset
|
59 |
|
7873
b3bccdcf85ef
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium
parents:
7872
diff
changeset
|
60 |
RoadStop(TileIndex tile = 0); |
b3bccdcf85ef
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium
parents:
7872
diff
changeset
|
61 |
virtual ~RoadStop(); |
5959
6a4c261987c3
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5934
diff
changeset
|
62 |
|
7992
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
63 |
/** |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
64 |
* Determines whether a road stop exists |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
65 |
* @return true if and only is the road stop exists |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
66 |
*/ |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
67 |
inline bool IsValid() const { return this->xy != 0; } |
6316
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
68 |
|
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
69 |
/* For accessing status */ |
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
70 |
bool HasFreeBay() const; |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6324
diff
changeset
|
71 |
bool IsFreeBay(uint nr) const; |
6316
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
72 |
uint AllocateBay(); |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6324
diff
changeset
|
73 |
void AllocateDriveThroughBay(uint nr); |
6316
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
74 |
void FreeBay(uint nr); |
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
75 |
bool IsEntranceBusy() const; |
6ba1efc2b7fc
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
6187
diff
changeset
|
76 |
void SetEntranceBusy(bool busy); |
7965
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
77 |
|
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
78 |
RoadStop *GetNextRoadStop(const Vehicle *v) const; |
6087
b56c54f79335
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents:
6086
diff
changeset
|
79 |
}; |
1217
ab9f02a224ab
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
80 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
81 |
struct StationSpecList { |
3587 | 82 |
const StationSpec *spec; |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6890
diff
changeset
|
83 |
uint32 grfid; ///< GRF ID of this custom station |
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6890
diff
changeset
|
84 |
uint8 localidx; ///< Station ID within GRF of station |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
85 |
}; |
3587 | 86 |
|
5927
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
87 |
/** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */ |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
88 |
struct StationRect : public Rect { |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
89 |
enum StationRectMode |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
90 |
{ |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
91 |
ADD_TEST = 0, |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
92 |
ADD_TRY, |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
93 |
ADD_FORCE |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
94 |
}; |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
95 |
|
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
96 |
StationRect(); |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
97 |
void MakeEmpty(); |
6161
754debc55207
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
6147
diff
changeset
|
98 |
bool PtInExtendedRect(int x, int y, int distance = 0) const; |
5927
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
99 |
bool IsEmpty() const; |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
100 |
bool BeforeAddTile(TileIndex tile, StationRectMode mode); |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
101 |
bool BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode); |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
102 |
bool AfterRemoveTile(Station *st, TileIndex tile); |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
103 |
bool AfterRemoveRect(Station *st, TileIndex tile, int w, int h); |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
104 |
|
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
105 |
static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a); |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
106 |
|
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
107 |
StationRect& operator = (Rect src); |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
108 |
}; |
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
109 |
|
7873
b3bccdcf85ef
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium
parents:
7872
diff
changeset
|
110 |
struct Station : PoolItem<Station, StationID, &_Station_pool> { |
7965
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
111 |
public: |
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9265
diff
changeset
|
112 |
RoadStop *GetPrimaryRoadStop(RoadStopType type) const |
7965
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
113 |
{ |
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9265
diff
changeset
|
114 |
return type == ROADSTOP_BUS ? bus_stops : truck_stops; |
7965
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
115 |
} |
6127 | 116 |
|
7965
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
117 |
RoadStop *GetPrimaryRoadStop(const Vehicle *v) const; |
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
118 |
|
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
119 |
const AirportFTAClass *Airport() const |
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
120 |
{ |
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
121 |
if (airport_tile == 0) return GetAirport(AT_DUMMY); |
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
122 |
return GetAirport(airport_type); |
c1a170885a60
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium
parents:
7909
diff
changeset
|
123 |
} |
6358 | 124 |
|
0 | 125 |
TileIndex xy; |
1217
ab9f02a224ab
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
126 |
RoadStop *bus_stops; |
ab9f02a224ab
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
127 |
RoadStop *truck_stops; |
0 | 128 |
TileIndex train_tile; |
129 |
TileIndex airport_tile; |
|
130 |
TileIndex dock_tile; |
|
131 |
Town *town; |
|
8754
5dae65402806
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8733
diff
changeset
|
132 |
StringID string_id; ///< Default name (town area) of station |
5dae65402806
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8733
diff
changeset
|
133 |
char *name; ///< Custom name |
0 | 134 |
|
135 |
ViewportSign sign; |
|
136 |
||
137 |
uint16 had_vehicle_of_type; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
123
diff
changeset
|
138 |
|
0 | 139 |
byte time_since_load; |
140 |
byte time_since_unload; |
|
141 |
byte delete_ctr; |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
142 |
PlayerByte owner; |
0 | 143 |
byte facilities; |
144 |
byte airport_type; |
|
145 |
||
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6890
diff
changeset
|
146 |
/* trainstation width/height */ |
0 | 147 |
byte trainst_w, trainst_h; |
148 |
||
3587 | 149 |
/** List of custom stations (StationSpecs) allocated to the station */ |
3786
73784d02aa69
(svn r4782) - Newstations: fix issue with saving/loading games with newstations on big endian architectures.
peter1138
parents:
3765
diff
changeset
|
150 |
uint8 num_specs; |
3587 | 151 |
StationSpecList *speclist; |
152 |
||
4289
ff1b2b915cab
(svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents:
4268
diff
changeset
|
153 |
Date build_date; |
0 | 154 |
|
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6890
diff
changeset
|
155 |
uint64 airport_flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32 |
0 | 156 |
|
3580
607e4245d024
(svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents:
3574
diff
changeset
|
157 |
byte last_vehicle_type; |
6996
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6916
diff
changeset
|
158 |
std::list<Vehicle *> loading_vehicles; |
0 | 159 |
GoodsEntry goods[NUM_CARGO]; |
1217
ab9f02a224ab
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
160 |
|
3687
109ec5cdb932
(svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents:
3587
diff
changeset
|
161 |
uint16 random_bits; |
109ec5cdb932
(svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents:
3587
diff
changeset
|
162 |
byte waiting_triggers; |
10266
435142fa43dc
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
9283
diff
changeset
|
163 |
uint8 cached_anim_triggers; ///< Combined animation trigger bitmask, used to determine if trigger processing should happen. |
3687
109ec5cdb932
(svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents:
3587
diff
changeset
|
164 |
|
5927
d740cab19ca0
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5921
diff
changeset
|
165 |
StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions |
5916
75c6d5cf1600
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
5852
diff
changeset
|
166 |
|
7900
b88064d431b5
(svn r10777) -Fix: don't put the ctor debug on lvl3, it is more a lvl5 debug
truelight
parents:
7873
diff
changeset
|
167 |
static const int cDebugCtorLevel = 5; |
5916
75c6d5cf1600
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
5852
diff
changeset
|
168 |
|
75c6d5cf1600
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
5852
diff
changeset
|
169 |
Station(TileIndex tile = 0); |
7873
b3bccdcf85ef
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium
parents:
7872
diff
changeset
|
170 |
virtual ~Station(); |
7872
a0646ade9d4a
(svn r10745) -Codechange: generalize the pool cleanup/initialize functions for stations (in such a manner that they can be used for other pools too).
rubidium
parents:
7768
diff
changeset
|
171 |
|
5972
564f98b055d1
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5969
diff
changeset
|
172 |
void AddFacility(byte new_facility_bit, TileIndex facil_xy); |
8041
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
173 |
|
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
174 |
/** |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
175 |
* Mark the sign of a station dirty for repaint. |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
176 |
* |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
177 |
* @ingroup dirty |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
178 |
*/ |
5916
75c6d5cf1600
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
5852
diff
changeset
|
179 |
void MarkDirty() const; |
8041
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
180 |
|
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
181 |
/** |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
182 |
* Marks the tiles of the station as dirty. |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
183 |
* |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
184 |
* @ingroup dirty |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7994
diff
changeset
|
185 |
*/ |
7319
f884be171f04
(svn r10062) -Codechange: Don't redraw all station tiles when cargo is added or removed if the station has no custom graphics.
peter1138
parents:
7173
diff
changeset
|
186 |
void MarkTilesDirty(bool cargo_change) const; |
5916
75c6d5cf1600
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
5852
diff
changeset
|
187 |
bool TileBelongsToRailStation(TileIndex tile) const; |
6324
ebf3649bd88f
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
6322
diff
changeset
|
188 |
uint GetPlatformLength(TileIndex tile, DiagDirection dir) const; |
ebf3649bd88f
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
6322
diff
changeset
|
189 |
uint GetPlatformLength(TileIndex tile) const; |
6147
2345f00d2a33
(svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents:
6135
diff
changeset
|
190 |
bool IsBuoy() const; |
7992
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
191 |
|
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
192 |
/** |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
193 |
* Determines whether a station exists |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
194 |
* @return true if and only is the station exists |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
195 |
*/ |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7970
diff
changeset
|
196 |
inline bool IsValid() const { return this->xy != 0; } |
0 | 197 |
}; |
198 |
||
6573 | 199 |
static inline StationID GetMaxStationIndex() |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
200 |
{ |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
201 |
/* TODO - This isn't the real content of the function, but |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
202 |
* with the new pool-system this will be replaced with one that |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5220
diff
changeset
|
203 |
* _really_ returns the highest index. Now it just returns |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
204 |
* the next safe value we are sure about everything is below. |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
205 |
*/ |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5220
diff
changeset
|
206 |
return GetStationPoolSize() - 1; |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5220
diff
changeset
|
207 |
} |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5220
diff
changeset
|
208 |
|
6573 | 209 |
static inline uint GetNumStations() |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5220
diff
changeset
|
210 |
{ |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
211 |
return GetStationPoolSize(); |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
212 |
} |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
213 |
|
6322
3d191e6e89bc
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
6321
diff
changeset
|
214 |
static inline bool IsValidStationID(StationID index) |
4346
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
215 |
{ |
6322
3d191e6e89bc
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
6321
diff
changeset
|
216 |
return index < GetStationPoolSize() && GetStation(index)->IsValid(); |
4346
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
217 |
} |
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
218 |
|
6322
3d191e6e89bc
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
6321
diff
changeset
|
219 |
#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) if (st->IsValid()) |
1272
d3e09adb7736
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
220 |
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0) |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
221 |
|
1284
06a52178bf46
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
222 |
|
06a52178bf46
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
223 |
/* Stuff for ROADSTOPS */ |
06a52178bf46
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
224 |
|
6086
61742a8471f5
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5972
diff
changeset
|
225 |
#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) if (rs->IsValid()) |
1284
06a52178bf46
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
226 |
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0) |
06a52178bf46
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
227 |
|
06a52178bf46
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
228 |
/* End of stuff for ROADSTOPS */ |
06a52178bf46
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
229 |
|
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9265
diff
changeset
|
230 |
#endif /* STATION_BASE_H */ |