Mercurial > hg > openttd
annotate src/roadstop.cpp @ 13859:e6ee12f4541d draft
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 02 Dec 2009 23:53:15 +0000 |
parents | 8c8d1ebf7ae1 |
children | 99221d89bb23 |
rev | line source |
---|---|
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12305
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12305
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12305
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12305
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12305
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12305
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12305
diff
changeset
|
9 |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
10 /** @file roadstop.cpp Implementation of the roadstop base class. */ |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
11 |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
12 #include "stdafx.h" |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
13 #include "roadveh.h" |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
14 #include "core/pool_func.hpp" |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
15 #include "roadstop_base.h" |
12247
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
16 #include "station_base.h" |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
17 |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
18 RoadStopPool _roadstop_pool("RoadStop"); |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
19 INSTANTIATE_POOL_METHODS(RoadStop) |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
20 |
13194
4b124fd22c06
(svn r17701) -Codechange: don't start line with a space if it's not inside comment
smatz <smatz@openttd.org>
parents:
13186
diff
changeset
|
21 /** |
13856
8c8d1ebf7ae1
(svn r18385) -Cleanup: remove the now unneeded multistop slot management code
rubidium <rubidium@openttd.org>
parents:
13194
diff
changeset
|
22 * De-Initializes RoadStops. |
13194
4b124fd22c06
(svn r17701) -Codechange: don't start line with a space if it's not inside comment
smatz <smatz@openttd.org>
parents:
13186
diff
changeset
|
23 */ |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
24 RoadStop::~RoadStop() |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
25 { |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
26 if (CleaningPool()) return; |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
27 } |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
28 |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
29 /** |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
30 * Get the next road stop accessible by this vehicle. |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
31 * @param v the vehicle to get the next road stop for. |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
32 * @return the next road stop accessible. |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
33 */ |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
34 RoadStop *RoadStop::GetNextRoadStop(const RoadVehicle *v) const |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
35 { |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
36 for (RoadStop *rs = this->next; rs != NULL; rs = rs->next) { |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
37 /* The vehicle cannot go to this roadstop (different roadtype) */ |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
38 if ((GetRoadTypes(rs->xy) & v->compatible_roadtypes) == ROADTYPES_NONE) continue; |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
39 /* The vehicle is articulated and can therefor not go the a standard road stop */ |
12305
217431f4bc67
(svn r16722) -Codechange: unify the naming of the Is/Set/HasArticulatedPart functions
rubidium <rubidium@openttd.org>
parents:
12304
diff
changeset
|
40 if (IsStandardRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue; |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
41 |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
42 /* The vehicle can actually go to this road stop. So, return it! */ |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
43 return rs; |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
44 } |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
45 |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
46 return NULL; |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
47 } |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
48 |
12247
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
49 /** |
13859
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
50 * Leave the road stop |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
51 * @param rv the vehicle that leaves the stop |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
52 */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
53 void RoadStop::Leave(RoadVehicle *rv) |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
54 { |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
55 /* Vehicle is leaving a road stop tile, mark bay as free |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
56 * For drive-through stops, only do it if the vehicle stopped here */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
57 if (IsStandardRoadStopTile(rv->tile) || HasBit(rv->state, RVS_IS_STOPPING)) { |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
58 this->FreeBay(HasBit(rv->state, RVS_USING_SECOND_BAY)); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
59 ClrBit(rv->state, RVS_IS_STOPPING); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
60 } |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
61 if (IsStandardRoadStopTile(rv->tile)) this->SetEntranceBusy(false); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
62 } |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
63 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
64 /** |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
65 * Enter the road stop |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
66 * @param rv the vehicle that enters the stop |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
67 * @return whether the road stop could actually be entered |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
68 */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
69 bool RoadStop::Enter(RoadVehicle *rv) |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
70 { |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
71 if (IsStandardRoadStopTile(this->xy)) { |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
72 /* For normal (non drive-through) road stops |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
73 * Check if station is busy or if there are no free bays or whether it is a articulated vehicle. */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
74 if (this->IsEntranceBusy() || !this->HasFreeBay() || rv->HasArticulatedPart()) return false; |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
75 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
76 SetBit(rv->state, RVS_IN_ROAD_STOP); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
77 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
78 /* Allocate a bay and update the road state */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
79 uint bay_nr = this->AllocateBay(); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
80 SB(rv->state, RVS_USING_SECOND_BAY, 1, bay_nr); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
81 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
82 /* Mark the station entrace as busy */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
83 this->SetEntranceBusy(true); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
84 return true; |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
85 } |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
86 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
87 /* Vehicles entering a drive-through stop from the 'normal' side use first bay (bay 0). */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
88 byte side = ((DirToDiagDir(rv->direction) == ReverseDiagDir(GetRoadStopDir(this->xy))) == (rv->overtaking == 0)) ? 0 : 1; |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
89 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
90 if (!this->IsFreeBay(side)) return false; |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
91 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
92 /* Check if the vehicle is stopping at this road stop */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
93 if (GetRoadStopType(this->xy) == (rv->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK) && |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
94 rv->current_order.ShouldStopAtStation(rv, GetStationIndex(this->xy))) { |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
95 SetBit(rv->state, RVS_IS_STOPPING); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
96 this->AllocateDriveThroughBay(side); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
97 } |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
98 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
99 /* Indicate if vehicle is using second bay. */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
100 if (side == 1) SetBit(rv->state, RVS_USING_SECOND_BAY); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
101 /* Indicate a drive-through stop */ |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
102 SetBit(rv->state, RVS_IN_DT_ROAD_STOP); |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
103 return true; |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
104 } |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
105 |
e6ee12f4541d
(svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents:
13856
diff
changeset
|
106 /** |
12247
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
107 * Find a roadstop at given tile |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
108 * @param tile tile with roadstop |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
109 * @param type roadstop type |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
110 * @return pointer to RoadStop |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
111 * @pre there has to be roadstop of given type there! |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
112 */ |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
113 /* static */ RoadStop *RoadStop::GetByTile(TileIndex tile, RoadStopType type) |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
114 { |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
115 const Station *st = Station::GetByTile(tile); |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
116 |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
117 for (RoadStop *rs = st->GetPrimaryRoadStop(type);; rs = rs->next) { |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
118 if (rs->xy == tile) return rs; |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
119 assert(rs->next != NULL); |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
120 } |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
121 } |
184079fb309d
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
122 |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
123 void InitializeRoadStops() |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
124 { |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
125 _roadstop_pool.CleanPool(); |
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
126 } |