annotate src/roadstop.cpp @ 20729:ea20edff1862 draft default tip master

(svn r25643) -Fix (r25480): [OSX] Define version constants before they're used
author planetmaker <planetmaker@openttd.org>
date Wed, 31 Jul 2013 18:50:01 +0000
parents 0dba7f49118c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
17 #include "vehicle_func.h"
12225
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
18
17635
41ea7460de25 (svn r22406) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17370
diff changeset
19 /** The pool of roadstops. */
12225
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
20 RoadStopPool _roadstop_pool("RoadStop");
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
21 INSTANTIATE_POOL_METHODS(RoadStop)
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
22
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 /**
13856
8c8d1ebf7ae1 (svn r18385) -Cleanup: remove the now unneeded multistop slot management code
rubidium <rubidium@openttd.org>
parents: 13194
diff changeset
24 * 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
25 */
12225
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
26 RoadStop::~RoadStop()
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
27 {
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
28 /* When we are the head we need to free the entries */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
29 if (HasBit(this->status, RSSFB_BASE_ENTRY)) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
30 delete this->east;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
31 delete this->west;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
32 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
33
12225
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
34 if (CleaningPool()) return;
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
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
37 /**
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
38 * 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
39 * @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
40 * @return the next road stop accessible.
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 RoadStop *RoadStop::GetNextRoadStop(const RoadVehicle *v) const
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
43 {
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
44 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
45 /* 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
46 if ((GetRoadTypes(rs->xy) & v->compatible_roadtypes) == ROADTYPES_NONE) continue;
19843
9a8968c733ba (svn r24776) -Doc: Typo fixes, additions, and additional dots collected from various sources (including Eagle_rainbow, MinchinWeb)
alberth <alberth@openttd.org>
parents: 17635
diff changeset
47 /* The vehicle is articulated and can therefore not go to 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
48 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
49
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
50 /* 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
51 return rs;
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
52 }
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
53
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
54 return NULL;
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
55 }
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
56
12247
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
57 /**
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
58 * Join this road stop to another 'base' road stop if possible;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
59 * fill all necessary data to become an actual drive through road stop.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
60 * Also update the length etc.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
61 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
62 void RoadStop::MakeDriveThrough()
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
63 {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
64 assert(this->east == NULL && this->west == NULL);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
65
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
66 RoadStopType rst = GetRoadStopType(this->xy);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
67 DiagDirection dir = GetRoadStopDir(this->xy);
19968
0dba7f49118c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents: 19843
diff changeset
68 /* Use absolute so we always go towards the northern tile */
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
69 TileIndexDiff offset = abs(TileOffsByDiagDir(dir));
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
70
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
71 /* Information about the tile north of us */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
72 TileIndex north_tile = this->xy - offset;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
73 bool north = IsDriveThroughRoadStopContinuation(this->xy, north_tile);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
74 RoadStop *rs_north = north ? RoadStop::GetByTile(north_tile, rst) : NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
75
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
76 /* Information about the tile south of us */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
77 TileIndex south_tile = this->xy + offset;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
78 bool south = IsDriveThroughRoadStopContinuation(this->xy, south_tile);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
79 RoadStop *rs_south = south ? RoadStop::GetByTile(south_tile, rst) : NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
80
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
81 /* Amount of road stops that will be added to the 'northern' head */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
82 int added = 1;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
83 if (north && rs_north->east != NULL) { // (east != NULL) == (west != NULL)
19968
0dba7f49118c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents: 19843
diff changeset
84 /* There is a more northern one, so this can join them */
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
85 this->east = rs_north->east;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
86 this->west = rs_north->west;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
87
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
88 if (south && rs_south->east != NULL) { // (east != NULL) == (west != NULL)
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
89 /* There more southern tiles too, they must 'join' us too */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
90 ClrBit(rs_south->status, RSSFB_BASE_ENTRY);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
91 this->east->occupied += rs_south->east->occupied;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
92 this->west->occupied += rs_south->west->occupied;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
93
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
94 /* Free the now unneeded entry structs */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
95 delete rs_south->east;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
96 delete rs_south->west;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
97
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
98 /* Make all 'children' of the southern tile take the new master */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
99 for (; IsDriveThroughRoadStopContinuation(this->xy, south_tile); south_tile += offset) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
100 rs_south = RoadStop::GetByTile(south_tile, rst);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
101 if (rs_south->east == NULL) break;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
102 rs_south->east = rs_north->east;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
103 rs_south->west = rs_north->west;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
104 added++;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
105 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
106 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
107 } else if (south && rs_south->east != NULL) { // (east != NULL) == (west != NULL)
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
108 /* There is one to the south, but not to the north... so we become 'parent' */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
109 this->east = rs_south->east;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
110 this->west = rs_south->west;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
111 SetBit(this->status, RSSFB_BASE_ENTRY);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
112 ClrBit(rs_south->status, RSSFB_BASE_ENTRY);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
113 } else {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
114 /* We are the only... so we are automatically the master */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
115 this->east = new Entry();
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
116 this->west = new Entry();
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
117 SetBit(this->status, RSSFB_BASE_ENTRY);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
118 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
119
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
120 /* Now update the lengths */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
121 added *= TILE_SIZE;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
122 this->east->length += added;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
123 this->west->length += added;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
124 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
125
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
126 /**
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
127 * Prepare for removal of this stop; update other neighbouring stops
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
128 * if needed. Also update the length etc.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
129 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
130 void RoadStop::ClearDriveThrough()
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
131 {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
132 assert(this->east != NULL && this->west != NULL);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
133
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
134 RoadStopType rst = GetRoadStopType(this->xy);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
135 DiagDirection dir = GetRoadStopDir(this->xy);
19968
0dba7f49118c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents: 19843
diff changeset
136 /* Use absolute so we always go towards the northern tile */
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
137 TileIndexDiff offset = abs(TileOffsByDiagDir(dir));
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
138
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
139 /* Information about the tile north of us */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
140 TileIndex north_tile = this->xy - offset;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
141 bool north = IsDriveThroughRoadStopContinuation(this->xy, north_tile);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
142 RoadStop *rs_north = north ? RoadStop::GetByTile(north_tile, rst) : NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
143
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
144 /* Information about the tile south of us */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
145 TileIndex south_tile = this->xy + offset;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
146 bool south = IsDriveThroughRoadStopContinuation(this->xy, south_tile);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
147 RoadStop *rs_south = south ? RoadStop::GetByTile(south_tile, rst) : NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
148
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
149 /* Must only be cleared after we determined which neighbours are
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
150 * part of our little entry 'queue' */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
151 DoClearSquare(this->xy);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
152
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
153 if (north) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
154 /* There is a tile to the north, so we can't clear ourselves. */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
155 if (south) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
156 /* There are more southern tiles too, they must be split;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
157 * first make the new southern 'base' */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
158 SetBit(rs_south->status, RSSFB_BASE_ENTRY);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
159 rs_south->east = new Entry();
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
160 rs_south->west = new Entry();
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
161
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
162 /* Keep track of the base because we need it later on */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
163 RoadStop *rs_south_base = rs_south;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
164 TileIndex base_tile = south_tile;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
165
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
166 /* Make all (even more) southern stops part of the new entry queue */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
167 for (south_tile += offset; IsDriveThroughRoadStopContinuation(base_tile, south_tile); south_tile += offset) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
168 rs_south = RoadStop::GetByTile(south_tile, rst);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
169 rs_south->east = rs_south_base->east;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
170 rs_south->west = rs_south_base->west;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
171 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
172
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
173 /* Find the other end; the northern most tile */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
174 for (; IsDriveThroughRoadStopContinuation(base_tile, north_tile); north_tile -= offset) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
175 rs_north = RoadStop::GetByTile(north_tile, rst);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
176 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
177
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
178 /* We have to rebuild the entries because we cannot easily determine
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
179 * how full each part is. So instead of keeping and maintaining a list
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
180 * of vehicles and using that to 'rebuild' the occupied state we just
19968
0dba7f49118c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents: 19843
diff changeset
181 * rebuild it from scratch as that removes lots of maintenance code
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
182 * for the vehicle list and it's faster in real games as long as you
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
183 * do not keep split and merge road stop every tick by the millions. */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
184 rs_south_base->east->Rebuild(rs_south_base);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
185 rs_south_base->west->Rebuild(rs_south_base);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
186
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
187 assert(HasBit(rs_north->status, RSSFB_BASE_ENTRY));
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
188 rs_north->east->Rebuild(rs_north);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
189 rs_north->west->Rebuild(rs_north);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
190 } else {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
191 /* Only we left, so simple update the length. */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
192 rs_north->east->length -= TILE_SIZE;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
193 rs_north->west->length -= TILE_SIZE;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
194 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
195 } else if (south) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
196 /* There is only something to the south. Hand over the base entry */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
197 SetBit(rs_south->status, RSSFB_BASE_ENTRY);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
198 rs_south->east->length -= TILE_SIZE;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
199 rs_south->west->length -= TILE_SIZE;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
200 } else {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
201 /* We were the last */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
202 delete this->east;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
203 delete this->west;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
204 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
205
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
206 /* Make sure we don't get used for something 'incorrect' */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
207 ClrBit(this->status, RSSFB_BASE_ENTRY);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
208 this->east = NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
209 this->west = NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
210 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
211
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
212 /**
13859
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
213 * 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
214 * @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
215 */
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
216 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
217 {
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
218 if (IsStandardRoadStopTile(rv->tile)) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
219 /* Vehicle is leaving a road stop tile, mark bay as free */
13859
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
220 this->FreeBay(HasBit(rv->state, RVS_USING_SECOND_BAY));
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
221 this->SetEntranceBusy(false);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
222 } else {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
223 /* Otherwise just leave the drive through's entry cache. */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
224 this->GetEntry(DirToDiagDir(rv->direction))->Leave(rv);
13859
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
225 }
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
226 }
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
227
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
228 /**
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
229 * 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
230 * @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
231 * @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
232 */
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
233 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
234 {
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
235 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
236 /* For normal (non drive-through) road stops
13860
99221d89bb23 (svn r18389) -Fix: some minor documentation alignment issues
rubidium <rubidium@openttd.org>
parents: 13859
diff changeset
237 * Check if station is busy or if there are no free bays or whether it is a articulated vehicle. */
13859
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
238 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
239
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
240 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
241
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
242 /* 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
243 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
244 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
245
19968
0dba7f49118c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents: 19843
diff changeset
246 /* Mark the station entrance as busy */
13859
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
247 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
248 return true;
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
249 }
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
250
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
251 /* Vehicles entering a drive-through stop from the 'normal' side use first bay (bay 0). */
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
252 this->GetEntry(DirToDiagDir(rv->direction))->Enter(rv);
13859
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
253
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
254 /* 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
255 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
256 return true;
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
257 }
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
258
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
259 /**
12247
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
260 * Find a roadstop at given tile
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
261 * @param tile tile with roadstop
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
262 * @param type roadstop type
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
263 * @return pointer to RoadStop
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
264 * @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
265 */
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
266 /* 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
267 {
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
268 const Station *st = Station::GetByTile(tile);
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
269
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
270 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
271 if (rs->xy == tile) return rs;
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
272 assert(rs->next != NULL);
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
273 }
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
274 }
184079fb309d (svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
smatz <smatz@openttd.org>
parents: 12225
diff changeset
275
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
276 /**
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
277 * Leave the road stop
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
278 * @param rv the vehicle that leaves the stop
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
279 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
280 void RoadStop::Entry::Leave(const RoadVehicle *rv)
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
281 {
16788
efb0333e5aad (svn r21521) -Codechange: Unify some cached values that were present in both road vehicles and trains.
terkhen <terkhen@openttd.org>
parents: 15944
diff changeset
282 this->occupied -= rv->gcache.cached_total_length;
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
283 assert(this->occupied >= 0);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
284 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
285
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
286 /**
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
287 * Enter the road stop
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
288 * @param rv the vehicle that enters the stop
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
289 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
290 void RoadStop::Entry::Enter(const RoadVehicle *rv)
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
291 {
13899
72c67db52eb2 (svn r18429) -Fix [FS#3360]: when road vehicles are, because of the 'jam protection' running through eachother more vehicles could be in a road stop than there could be under normal circumstances. As such an assert when the road stop's limits are reached isn't good.
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
292 /* we cannot assert on this->occupied < this->length because of the
19968
0dba7f49118c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents: 19843
diff changeset
293 * remote possibility that RVs are running through each other when
13899
72c67db52eb2 (svn r18429) -Fix [FS#3360]: when road vehicles are, because of the 'jam protection' running through eachother more vehicles could be in a road stop than there could be under normal circumstances. As such an assert when the road stop's limits are reached isn't good.
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
294 * trying to prevention an infinite jam. */
16788
efb0333e5aad (svn r21521) -Codechange: Unify some cached values that were present in both road vehicles and trains.
terkhen <terkhen@openttd.org>
parents: 15944
diff changeset
295 this->occupied += rv->gcache.cached_total_length;
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
296 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
297
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
298 /**
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
299 * Checks whether the 'next' tile is still part of the road same drive through
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
300 * stop 'rs' in the same direction for the same vehicle.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
301 * @param rs the road stop tile to check against
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
302 * @param next the 'next' tile to check
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
303 * @return true if the 'next' tile is part of the road stop at 'next'.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
304 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
305 /* static */ bool RoadStop::IsDriveThroughRoadStopContinuation(TileIndex rs, TileIndex next)
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
306 {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
307 return IsTileType(next, MP_STATION) &&
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
308 GetStationIndex(next) == GetStationIndex(rs) &&
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
309 GetStationType(next) == GetStationType(rs) &&
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
310 GetRoadStopDir(next) == GetRoadStopDir(rs) &&
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
311 IsDriveThroughStopTile(next);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
312 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
313
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
314 typedef std::list<const RoadVehicle *> RVList; ///< A list of road vehicles
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
315
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
316 /** Helper for finding RVs in a road stop. */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
317 struct RoadStopEntryRebuilderHelper {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
318 RVList vehicles; ///< The list of vehicles to possibly add to.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
319 DiagDirection dir; ///< The direction the vehicle has to face to be added.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
320 };
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
321
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
322 /**
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
323 * Add road vehicles to the station's list if needed.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
324 * @param v the found vehicle
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
325 * @param data the extra data used to make our decision
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
326 * @return always NULL
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
327 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
328 Vehicle *FindVehiclesInRoadStop(Vehicle *v, void *data)
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
329 {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
330 RoadStopEntryRebuilderHelper *rserh = (RoadStopEntryRebuilderHelper*)data;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
331 /* Not a RV or not in the right direction or crashed :( */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
332 if (v->type != VEH_ROAD || DirToDiagDir(v->direction) != rserh->dir || !v->IsPrimaryVehicle() || (v->vehstatus & VS_CRASHED) != 0) return NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
333
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
334 RoadVehicle *rv = RoadVehicle::From(v);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
335 /* Don't add ones not in a road stop */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
336 if (rv->state < RVSB_IN_ROAD_STOP) return NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
337
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
338 /* Do not add duplicates! */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
339 for (RVList::iterator it = rserh->vehicles.begin(); it != rserh->vehicles.end(); it++) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
340 if (rv == *it) return NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
341 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
342
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
343 rserh->vehicles.push_back(rv);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
344 return NULL;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
345 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
346
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
347 /**
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
348 * Rebuild, from scratch, the vehicles and other metadata on this stop.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
349 * @param rs the roadstop this entry is part of
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
350 * @param side the side of the road stop to look at
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
351 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
352 void RoadStop::Entry::Rebuild(const RoadStop *rs, int side)
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
353 {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
354 assert(HasBit(rs->status, RSSFB_BASE_ENTRY));
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
355
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
356 DiagDirection dir = GetRoadStopDir(rs->xy);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
357 if (side == -1) side = (rs->east == this);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
358
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
359 RoadStopEntryRebuilderHelper rserh;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
360 rserh.dir = side ? dir : ReverseDiagDir(dir);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
361
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
362 this->length = 0;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
363 TileIndexDiff offset = abs(TileOffsByDiagDir(dir));
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
364 for (TileIndex tile = rs->xy; IsDriveThroughRoadStopContinuation(rs->xy, tile); tile += offset) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
365 this->length += TILE_SIZE;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
366 FindVehicleOnPos(tile, &rserh, FindVehiclesInRoadStop);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
367 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
368
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
369 this->occupied = 0;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
370 for (RVList::iterator it = rserh.vehicles.begin(); it != rserh.vehicles.end(); it++) {
16788
efb0333e5aad (svn r21521) -Codechange: Unify some cached values that were present in both road vehicles and trains.
terkhen <terkhen@openttd.org>
parents: 15944
diff changeset
371 this->occupied += (*it)->gcache.cached_total_length;
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
372 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
373 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
374
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
375
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
376 /**
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
377 * Check the integrity of the data in this struct.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
378 * @param rs the roadstop this entry is part of
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
379 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
380 void RoadStop::Entry::CheckIntegrity(const RoadStop *rs) const
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
381 {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
382 if (!HasBit(rs->status, RSSFB_BASE_ENTRY)) return;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
383
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
384 /* The tile 'before' the road stop must not be part of this 'line' */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
385 assert(!IsDriveThroughRoadStopContinuation(rs->xy, rs->xy - abs(TileOffsByDiagDir(GetRoadStopDir(rs->xy)))));
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
386
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
387 Entry temp;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
388 temp.Rebuild(rs, rs->east == this);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
389 if (temp.length != this->length || temp.occupied != this->occupied) NOT_REACHED();
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13860
diff changeset
390 }