Mercurial > hg > openttd
annotate src/station_cmd.cpp @ 8144:d18c8a0bb638 draft
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 27 Dec 2007 13:35:39 +0000 |
parents | fb8a05d579da |
children | e2bea11667fd |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
6117
6def6ecb1bf7
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas <belugas@openttd.org>
parents:
6116
diff
changeset
|
3 /** @file station_cmd.cpp */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
4 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
5 #include "stdafx.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
6 #include "openttd.h" |
8106
47b1794a7eca
(svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium <rubidium@openttd.org>
parents:
8105
diff
changeset
|
7 #include "string.h" |
6087 | 8 #include "aircraft.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
9 #include "bridge_map.h" |
6134 | 10 #include "cmd_helper.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
11 #include "debug.h" |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
12 #include "tile_cmd.h" |
6453
666fc3ef3174
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros <maedhros@openttd.org>
parents:
6427
diff
changeset
|
13 #include "landscape.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
14 #include "station_map.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
15 #include "table/sprites.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
16 #include "table/strings.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
17 #include "station.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
18 #include "viewport.h" |
8116
9cc845deddfe
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents:
8114
diff
changeset
|
19 #include "command_func.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
20 #include "town.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
21 #include "news.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
22 #include "saveload.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
23 #include "player.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
24 #include "airport.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
25 #include "sprite.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
26 #include "depot.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
27 #include "train.h" |
6857
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6823
diff
changeset
|
28 #include "roadveh.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
29 #include "water_map.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
30 #include "industry_map.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
31 #include "newgrf_callbacks.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
32 #include "newgrf_station.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
33 #include "yapf/yapf.h" |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
34 #include "misc/autoptr.hpp" |
8102
afb4c7da91df
(svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents:
8098
diff
changeset
|
35 #include "road_type.h" |
afb4c7da91df
(svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents:
8098
diff
changeset
|
36 #include "road_internal.h" /* For drawing catenary/checking road removal */ |
6091
17ebeb5a2c37
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents:
6087
diff
changeset
|
37 #include "cargotype.h" |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
38 #include "autoslope.h" |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7826
diff
changeset
|
39 #include "transparency.h" |
7948
4044e2de8086
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium <rubidium@openttd.org>
parents:
7931
diff
changeset
|
40 #include "water.h" |
8016
f60addd19e1a
(svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents:
8015
diff
changeset
|
41 #include "station_gui.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8109
diff
changeset
|
42 #include "strings_func.h" |
8131
e300ac8001ae
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
43 #include "functions.h" |
e300ac8001ae
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
44 #include "window_func.h" |
8140
fb8a05d579da
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents:
8139
diff
changeset
|
45 #include "date_func.h" |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
8140
diff
changeset
|
46 #include "vehicle_func.h" |
5666
1cf4c9bc5bb1
(svn r8126) -Fix (r8125): missing #include fixes compilation error on g++ (still some warnings, working on it)
KUDr <KUDr@openttd.org>
parents:
5665
diff
changeset
|
47 |
7376
b8662c8a1b78
(svn r10745) -Codechange: generalize the pool cleanup/initialize functions for stations (in such a manner that they can be used for other pools too).
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
48 DEFINE_OLD_POOL_GENERIC(Station, Station) |
b8662c8a1b78
(svn r10745) -Codechange: generalize the pool cleanup/initialize functions for stations (in such a manner that they can be used for other pools too).
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
49 DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
50 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
51 |
7320
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
52 /** |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
53 * Check whether the given tile is a hangar. |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
54 * @param t the tile to of whether it is a hangar. |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
55 * @pre IsTileType(t, MP_STATION) |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
56 * @return true if and only if the tile is a hangar. |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
57 */ |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
58 bool IsHangar(TileIndex t) |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
59 { |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
60 assert(IsTileType(t, MP_STATION)); |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
61 |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
62 const Station *st = GetStationByTile(t); |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
63 const AirportFTAClass *apc = st->Airport(); |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
64 |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
65 for (uint i = 0; i < apc->nof_depots; i++) { |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
66 if (st->airport_tile + ToTileIndexDiff(apc->airport_depots[i]) == t) return true; |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
67 } |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
68 |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
69 return false; |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
70 } |
e69c6734f97c
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium <rubidium@openttd.org>
parents:
7319
diff
changeset
|
71 |
5836
0b68d5a508a2
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar <celestar@openttd.org>
parents:
5834
diff
changeset
|
72 RoadStop* GetRoadStopByTile(TileIndex tile, RoadStop::Type type) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
73 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
74 const Station* st = GetStationByTile(tile); |
6069 | 75 |
76 for (RoadStop *rs = st->GetPrimaryRoadStop(type);; rs = rs->next) { | |
77 if (rs->xy == tile) return rs; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
78 assert(rs->next != NULL); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
79 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
80 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
81 |
5913 | 82 |
83 static uint GetNumRoadStopsInStation(const Station* st, RoadStop::Type type) | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
84 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
85 uint num = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
86 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
87 assert(st != NULL); |
6069 | 88 for (const RoadStop *rs = st->GetPrimaryRoadStop(type); rs != NULL; rs = rs->next) { |
89 num++; | |
90 } | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
91 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
92 return num; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
93 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
94 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
95 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
96 /** Calculate the radius of the station. Basicly it is the biggest |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
97 * radius that is available within the station |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
98 * @param st Station to query |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
99 * @return the so calculated radius |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
100 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
101 static uint FindCatchmentRadius(const Station* st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
102 { |
6041 | 103 uint ret = CA_NONE; |
104 | |
105 if (st->bus_stops != NULL) ret = max<uint>(ret, CA_BUS); | |
106 if (st->truck_stops != NULL) ret = max<uint>(ret, CA_TRUCK); | |
107 if (st->train_tile != 0) ret = max<uint>(ret, CA_TRAIN); | |
108 if (st->dock_tile != 0) ret = max<uint>(ret, CA_DOCK); | |
109 if (st->airport_tile) ret = max<uint>(ret, st->Airport()->catchment); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
110 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
111 return ret; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
112 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
113 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
114 #define CHECK_STATIONS_ERR ((Station*)-1) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
115 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
116 static Station* GetStationAround(TileIndex tile, int w, int h, StationID closest_station) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
117 { |
6420
080aae477331
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas <belugas@openttd.org>
parents:
6402
diff
changeset
|
118 /* check around to see if there's any stations there */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
119 BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
120 if (IsTileType(tile_cur, MP_STATION)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
121 StationID t = GetStationIndex(tile_cur); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
122 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
123 if (closest_station == INVALID_STATION) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
124 closest_station = t; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
125 } else if (closest_station != t) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
126 _error_message = STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
127 return CHECK_STATIONS_ERR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
128 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
129 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
130 END_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
131 return (closest_station == INVALID_STATION) ? NULL : GetStation(closest_station); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
132 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
133 |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
134 /** |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
135 * Function to check whether the given tile matches some criterion. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
136 * @param tile the tile to check |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
137 * @return true if it matches, false otherwise |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
138 */ |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
139 typedef bool (*CMSAMatcher)(TileIndex tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
140 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
141 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
142 * Counts the numbers of tiles matching a specific type in the area around |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
143 * @param tile the center tile of the 'count area' |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
144 * @param type the type of tile searched for |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
145 * @param industry when type == MP_INDUSTRY, the type of the industry, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
146 * in all other cases this parameter is ignored |
6201
3b141366478a
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents:
6198
diff
changeset
|
147 * @return the result the noumber of matching tiles around |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
148 */ |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
149 static int CountMapSquareAround(TileIndex tile, CMSAMatcher cmp) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
151 int num = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
152 |
6069 | 153 for (int dx = -3; dx <= 3; dx++) { |
154 for (int dy = -3; dy <= 3; dy++) { | |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
155 if (cmp(TILE_MASK(tile + TileDiffXY(dx, dy)))) num++; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
156 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
157 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
158 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
159 return num; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
160 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
161 |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
162 /** |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
163 * Check whether the tile is a mine. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
164 * @param tile the tile to investigate. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
165 * @return true if and only if the tile is a mine |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
166 */ |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
167 static bool CMSAMine(TileIndex tile) |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
168 { |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
169 /* No industry */ |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
170 if (!IsTileType(tile, MP_INDUSTRY)) return false; |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
171 |
7645
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
172 const Industry *ind = GetIndustryByTile(tile); |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
173 |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
174 /* No extractive industry */ |
7645
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
175 if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_EXTRACTIVE) == 0) return false; |
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
176 |
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
177 for (uint i = 0; i < lengthof(ind->produced_cargo); i++) { |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
178 /* The industry extracts something non-liquid, i.e. no oil or plastic, so it is a mine */ |
7645
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
179 if (ind->produced_cargo[i] != CT_INVALID && (GetCargo(ind->produced_cargo[i])->classes & CC_LIQUID) == 0) return true; |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
180 } |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
181 |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
182 return false; |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
183 } |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
184 |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
185 /** |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
186 * Check whether the tile is water. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
187 * @param tile the tile to investigate. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
188 * @return true if and only if the tile is a mine |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
189 */ |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
190 static bool CMSAWater(TileIndex tile) |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
191 { |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
192 return IsTileType(tile, MP_WATER) && IsWater(tile); |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
193 } |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
194 |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
195 /** |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
196 * Check whether the tile is a tree. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
197 * @param tile the tile to investigate. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
198 * @return true if and only if the tile is a mine |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
199 */ |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
200 static bool CMSATree(TileIndex tile) |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
201 { |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
202 return IsTileType(tile, MP_TREES); |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
203 } |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
204 |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
205 /** |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
206 * Check whether the tile is a forest. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
207 * @param tile the tile to investigate. |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
208 * @return true if and only if the tile is a mine |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
209 */ |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
210 static bool CMSAForest(TileIndex tile) |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
211 { |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
212 /* No industry */ |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
213 if (!IsTileType(tile, MP_INDUSTRY)) return false; |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
214 |
7645
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
215 const Industry *ind = GetIndustryByTile(tile); |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
216 |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
217 /* No extractive industry */ |
7645
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
218 if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_ORGANIC) == 0) return false; |
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
219 |
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
220 for (uint i = 0; i < lengthof(ind->produced_cargo); i++) { |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
221 /* The industry produces wood. */ |
7645
5178857fa331
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents:
7642
diff
changeset
|
222 if (ind->produced_cargo[i] != CT_INVALID && GetCargo(ind->produced_cargo[i])->label == 'WOOD') return true; |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
223 } |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
224 |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
225 return false; |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
226 } |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
227 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
228 #define M(x) ((x) - STR_SV_STNAME) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
229 |
7814
91405b7333f9
(svn r11364) -Fix (r11363): compilation broken
glx <glx@openttd.org>
parents:
7813
diff
changeset
|
230 enum StationNaming { |
7813
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
231 STATIONNAMING_RAIL = 0, |
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
232 STATIONNAMING_ROAD = 0, |
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
233 STATIONNAMING_AIRPORT, |
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
234 STATIONNAMING_OILRIG, |
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
235 STATIONNAMING_DOCK, |
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
236 STATIONNAMING_BUOY, |
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
237 STATIONNAMING_HELIPORT, |
7814
91405b7333f9
(svn r11364) -Fix (r11363): compilation broken
glx <glx@openttd.org>
parents:
7813
diff
changeset
|
238 }; |
7813
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
239 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
240 static bool GenerateStationName(Station *st, TileIndex tile, int flag) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
241 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
242 static const uint32 _gen_station_name_bits[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
243 0, /* 0 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
244 1 << M(STR_SV_STNAME_AIRPORT), /* 1 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
245 1 << M(STR_SV_STNAME_OILFIELD), /* 2 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
246 1 << M(STR_SV_STNAME_DOCKS), /* 3 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
247 0x1FF << M(STR_SV_STNAME_BUOY_1), /* 4 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
248 1 << M(STR_SV_STNAME_HELIPORT), /* 5 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
249 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
250 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
251 Town *t = st->town; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
252 uint32 free_names = (uint32)-1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
253 int found; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
254 unsigned long tmp; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
255 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
256 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
257 Station *s; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
258 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
259 FOR_ALL_STATIONS(s) { |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
260 if (s != st && s->town == t) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
261 uint str = M(s->string_id); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
262 if (str <= 0x20) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
263 if (str == M(STR_SV_STNAME_FOREST)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
264 str = M(STR_SV_STNAME_WOODS); |
7929
4d13dbed828c
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
265 ClrBit(free_names, str); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
266 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
267 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
268 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
269 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
270 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
271 /* check default names */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
272 tmp = free_names & _gen_station_name_bits[flag]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
273 if (tmp != 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
274 found = FindFirstBit(tmp); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
275 goto done; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
276 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
277 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
278 /* check mine? */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
279 if (HasBit(free_names, M(STR_SV_STNAME_MINES))) { |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
280 if (CountMapSquareAround(tile, CMSAMine) >= 2) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
281 found = M(STR_SV_STNAME_MINES); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
282 goto done; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
283 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
284 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
285 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 /* check close enough to town to get central as name? */ |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
287 if (DistanceMax(tile, t->xy) < 8) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
288 found = M(STR_SV_STNAME); |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
289 if (HasBit(free_names, M(STR_SV_STNAME))) goto done; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
290 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
291 found = M(STR_SV_STNAME_CENTRAL); |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
292 if (HasBit(free_names, M(STR_SV_STNAME_CENTRAL))) goto done; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
293 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
294 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
295 /* Check lakeside */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
296 if (HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
297 DistanceFromEdge(tile) < 20 && |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
298 CountMapSquareAround(tile, CMSAWater) >= 5) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
299 found = M(STR_SV_STNAME_LAKESIDE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
300 goto done; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
301 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
302 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
303 /* Check woods */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
304 if (HasBit(free_names, M(STR_SV_STNAME_WOODS)) && ( |
7319
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
305 CountMapSquareAround(tile, CMSATree) >= 8 || |
d2b2514b2a5f
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
rubidium <rubidium@openttd.org>
parents:
7298
diff
changeset
|
306 CountMapSquareAround(tile, CMSAForest) >= 2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
307 ) { |
6357
96b1652c6011
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas <belugas@openttd.org>
parents:
6350
diff
changeset
|
308 found = _opt.landscape == LT_TROPIC ? |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
309 M(STR_SV_STNAME_FOREST) : M(STR_SV_STNAME_WOODS); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
310 goto done; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
311 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
312 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
313 /* check elevation compared to town */ |
6069 | 314 { |
315 uint z = GetTileZ(tile); | |
316 uint z2 = GetTileZ(t->xy); | |
317 if (z < z2) { | |
318 found = M(STR_SV_STNAME_VALLEY); | |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
319 if (HasBit(free_names, M(STR_SV_STNAME_VALLEY))) goto done; |
6069 | 320 } else if (z > z2) { |
321 found = M(STR_SV_STNAME_HEIGHTS); | |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
322 if (HasBit(free_names, M(STR_SV_STNAME_HEIGHTS))) goto done; |
6069 | 323 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
324 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
325 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
326 /* check direction compared to town */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
327 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
328 static const int8 _direction_and_table[] = { |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
329 ~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ), |
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
330 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ), |
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
331 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ), |
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
332 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ), |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
333 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
334 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
335 free_names &= _direction_and_table[ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
336 (TileX(tile) < TileX(t->xy)) + |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
337 (TileY(tile) < TileY(t->xy)) * 2]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
338 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
339 |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
340 tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30)); |
7055
1511234872f5
(svn r10320) -Fix [FS#278]: one could only build a limited number of stations before one had to rename them.
rubidium <rubidium@openttd.org>
parents:
7013
diff
changeset
|
341 found = (tmp == 0) ? M(STR_SV_STNAME_FALLBACK) : FindFirstBit(tmp); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
342 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
343 done: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
344 st->string_id = found + STR_SV_STNAME; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
345 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
346 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
347 #undef M |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
348 |
6052 | 349 static Station* GetClosestStationFromTile(TileIndex tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
350 { |
6052 | 351 uint threshold = 8; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
352 Station* best_station = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
353 Station* st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
354 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
355 FOR_ALL_STATIONS(st) { |
6052 | 356 if (st->facilities == 0 && st->owner == _current_player) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
357 uint cur_dist = DistanceManhattan(tile, st->xy); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
358 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
359 if (cur_dist < threshold) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
360 threshold = cur_dist; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
361 best_station = st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
362 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
363 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
364 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
365 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
366 return best_station; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
367 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
368 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
369 /** Update the virtual coords needed to draw the station sign. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
370 * @param st Station to update for. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
371 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
372 static void UpdateStationVirtCoord(Station *st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
373 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
374 Point pt = RemapCoords2(TileX(st->xy) * TILE_SIZE, TileY(st->xy) * TILE_SIZE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
375 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
376 pt.y -= 32; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
377 if (st->facilities & FACIL_AIRPORT && st->airport_type == AT_OILRIG) pt.y -= 16; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
378 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
379 SetDParam(0, st->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
380 SetDParam(1, st->facilities); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
381 UpdateViewportSignPos(&st->sign, pt.x, pt.y, STR_305C_0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
382 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
383 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
384 /** Update the virtual coords needed to draw the station sign for all stations. */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
385 void UpdateAllStationVirtCoord() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
386 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
387 Station* st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
388 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
389 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
390 UpdateStationVirtCoord(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
391 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
392 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
393 |
7545
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
394 /** |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
395 * Update the station virt coords while making the modified parts dirty. |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
396 * |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
397 * This function updates the virt coords and mark the modified parts as dirty |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
398 * |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
399 * @param st The station to update the virt coords |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
400 * @ingroup dirty |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
401 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
402 static void UpdateStationVirtCoordDirty(Station *st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
403 { |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
404 st->MarkDirty(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
405 UpdateStationVirtCoord(st); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
406 st->MarkDirty(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
407 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
408 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
409 /** Get a mask of the cargo types that the station accepts. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
410 * @param st Station to query |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
411 * @return the expected mask |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
412 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
413 static uint GetAcceptanceMask(const Station *st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
414 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
415 uint mask = 0; |
6069 | 416 |
6350
8132258640be
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents:
6329
diff
changeset
|
417 for (CargoID i = 0; i < NUM_CARGO; i++) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
418 if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE)) mask |= 1 << i; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
419 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
420 return mask; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
421 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
422 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
423 /** Items contains the two cargo names that are to be accepted or rejected. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
424 * msg is the string id of the message to display. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
425 */ |
5690
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
426 static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *cargo, StringID msg) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
427 { |
5690
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
428 for (uint i = 0; i < num_items; i++) { |
6091
17ebeb5a2c37
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents:
6087
diff
changeset
|
429 SetDParam(i + 1, GetCargo(cargo[i])->name); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
430 } |
5690
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
431 |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
432 SetDParam(0, st->index); |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
433 AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
434 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
435 |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
436 /** |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
437 * Get a list of the cargo types being produced around the tile (in a rectangle). |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
438 * @param produced: Destination array of produced cargo |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
439 * @param tile: Center of the search area |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
440 * @param w: Width of the center |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
441 * @param h: Height of the center |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
442 * @param rad: Radius of the search area |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
443 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
444 void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
445 int w, int h, int rad) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
446 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
447 memset(produced, 0, sizeof(AcceptedCargo)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
448 |
6069 | 449 int x = TileX(tile); |
450 int y = TileY(tile); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
451 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
452 /* expand the region by rad tiles on each side |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
453 * while making sure that we remain inside the board. */ |
6069 | 454 int x2 = min(x + w + rad, MapSizeX()); |
455 int x1 = max(x - rad, 0); | |
456 | |
457 int y2 = min(y + h + rad, MapSizeY()); | |
458 int y1 = max(y - rad, 0); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
459 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
460 assert(x1 < x2); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
461 assert(y1 < y2); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
462 assert(w > 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
463 assert(h > 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
464 |
6069 | 465 for (int yc = y1; yc != y2; yc++) { |
466 for (int xc = x1; xc != x2; xc++) { | |
7954
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7948
diff
changeset
|
467 if (!(IsInsideBS(xc, x, w) && IsInsideBS(yc, y, h))) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
468 TileIndex tile = TileXY(xc, yc); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
469 |
6069 | 470 GetProducedCargoProc *gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
471 if (gpc != NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
472 CargoID cargos[2] = { CT_INVALID, CT_INVALID }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
473 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
474 gpc(tile, cargos); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
475 if (cargos[0] != CT_INVALID) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
476 produced[cargos[0]]++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
477 if (cargos[1] != CT_INVALID) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
478 produced[cargos[1]]++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
479 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
480 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
481 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
482 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
483 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
484 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
485 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
486 |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
487 /** |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
488 * Get a list of the cargo types that are accepted around the tile. |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
489 * @param accepts: Destination array of accepted cargo |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
490 * @param tile: Center of the search area |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
491 * @param w: Width of the center |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
492 * @param h: Height of the center |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
493 * @param rad: Radius of the rectangular search area |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
494 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
495 void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
496 int w, int h, int rad) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
497 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
498 memset(accepts, 0, sizeof(AcceptedCargo)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
499 |
6069 | 500 int x = TileX(tile); |
501 int y = TileY(tile); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
502 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
503 /* expand the region by rad tiles on each side |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
504 * while making sure that we remain inside the board. */ |
6069 | 505 int x2 = min(x + w + rad, MapSizeX()); |
506 int y2 = min(y + h + rad, MapSizeY()); | |
507 int x1 = max(x - rad, 0); | |
508 int y1 = max(y - rad, 0); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
509 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
510 assert(x1 < x2); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
511 assert(y1 < y2); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
512 assert(w > 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
513 assert(h > 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
514 |
6069 | 515 for (int yc = y1; yc != y2; yc++) { |
516 for (int xc = x1; xc != x2; xc++) { | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
517 TileIndex tile = TileXY(xc, yc); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
518 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
519 if (!IsTileType(tile, MP_STATION)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
520 AcceptedCargo ac; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
521 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
522 GetAcceptedCargo(tile, ac); |
6069 | 523 for (uint i = 0; i < lengthof(ac); ++i) accepts[i] += ac[i]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
524 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
525 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
526 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
527 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
528 |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
529 struct ottd_Rectangle { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
530 uint min_x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
531 uint min_y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
532 uint max_x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
533 uint max_y; |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
534 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
535 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
536 static inline void MergePoint(ottd_Rectangle* rect, TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
537 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
538 uint x = TileX(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
539 uint y = TileY(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
540 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
541 if (rect->min_x > x) rect->min_x = x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
542 if (rect->min_y > y) rect->min_y = y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
543 if (rect->max_x < x) rect->max_x = x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
544 if (rect->max_y < y) rect->max_y = y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
545 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
546 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
547 /** Update the acceptance for a station. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
548 * @param st Station to update |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
549 * @param show_msg controls whether to display a message that acceptance was changed. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
550 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
551 static void UpdateStationAcceptance(Station *st, bool show_msg) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
552 { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
553 /* Don't update acceptance for a buoy */ |
6069 | 554 if (st->IsBuoy()) return; |
555 | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
556 ottd_Rectangle rect; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
557 rect.min_x = MapSizeX(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
558 rect.min_y = MapSizeY(); |
6069 | 559 rect.max_x = 0; |
560 rect.max_y = 0; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
561 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
562 /* old accepted goods types */ |
6069 | 563 uint old_acc = GetAcceptanceMask(st); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
564 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
565 /* Put all the tiles that span an area in the table. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
566 if (st->train_tile != 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
567 MergePoint(&rect, st->train_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
568 MergePoint(&rect, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
569 st->train_tile + TileDiffXY(st->trainst_w - 1, st->trainst_h - 1) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
570 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
571 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
572 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
573 if (st->airport_tile != 0) { |
6032 | 574 const AirportFTAClass* afc = st->Airport(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
575 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
576 MergePoint(&rect, st->airport_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
577 MergePoint(&rect, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
578 st->airport_tile + TileDiffXY(afc->size_x - 1, afc->size_y - 1) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
579 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
580 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
581 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
582 if (st->dock_tile != 0) MergePoint(&rect, st->dock_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
583 |
6069 | 584 for (const RoadStop *rs = st->bus_stops; rs != NULL; rs = rs->next) { |
585 MergePoint(&rect, rs->xy); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
586 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
587 |
6069 | 588 for (const RoadStop *rs = st->truck_stops; rs != NULL; rs = rs->next) { |
589 MergePoint(&rect, rs->xy); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
590 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
591 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
592 /* And retrieve the acceptance. */ |
6069 | 593 AcceptedCargo accepts; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
594 if (rect.max_x >= rect.min_x) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
595 GetAcceptanceAroundTiles( |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
596 accepts, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
597 TileXY(rect.min_x, rect.min_y), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
598 rect.max_x - rect.min_x + 1, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
599 rect.max_y - rect.min_y + 1, |
6069 | 600 _patches.modified_catchment ? FindCatchmentRadius(st) : 4 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
601 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
602 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
603 memset(accepts, 0, sizeof(accepts)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
604 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
605 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
606 /* Adjust in case our station only accepts fewer kinds of goods */ |
6350
8132258640be
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents:
6329
diff
changeset
|
607 for (CargoID i = 0; i < NUM_CARGO; i++) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
608 uint amt = min(accepts[i], 15); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
609 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
610 /* Make sure the station can accept the goods type. */ |
6329
34db8eef99ef
(svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138 <peter1138@openttd.org>
parents:
6306
diff
changeset
|
611 bool is_passengers = IsCargoInClass(i, CC_PASSENGERS); |
34db8eef99ef
(svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138 <peter1138@openttd.org>
parents:
6306
diff
changeset
|
612 if ((!is_passengers && !(st->facilities & (byte)~FACIL_BUS_STOP)) || |
34db8eef99ef
(svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138 <peter1138@openttd.org>
parents:
6306
diff
changeset
|
613 (is_passengers && !(st->facilities & (byte)~FACIL_TRUCK_STOP))) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
614 amt = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
615 |
7474
7b35fd1cc99d
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium <rubidium@openttd.org>
parents:
7469
diff
changeset
|
616 SB(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, amt >= 8); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
617 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
618 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
619 /* Only show a message in case the acceptance was actually changed. */ |
6069 | 620 uint new_acc = GetAcceptanceMask(st); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
621 if (old_acc == new_acc) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
622 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
623 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
624 /* show a message to report that the acceptance was changed? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
625 if (show_msg && st->owner == _local_player && st->facilities) { |
5690
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
626 /* List of accept and reject strings for different number of |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
627 * cargo types */ |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
628 static const StringID accept_msg[] = { |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
629 STR_3040_NOW_ACCEPTS, |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
630 STR_3041_NOW_ACCEPTS_AND, |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
631 }; |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
632 static const StringID reject_msg[] = { |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
633 STR_303E_NO_LONGER_ACCEPTS, |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
634 STR_303F_NO_LONGER_ACCEPTS_OR, |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
635 }; |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
636 |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
637 /* Array of accepted and rejected cargo types */ |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
638 CargoID accepts[2] = { CT_INVALID, CT_INVALID }; |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
639 CargoID rejects[2] = { CT_INVALID, CT_INVALID }; |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
640 uint num_acc = 0; |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
641 uint num_rej = 0; |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
642 |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
643 /* Test each cargo type to see if its acceptange has changed */ |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
644 for (CargoID i = 0; i < NUM_CARGO; i++) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
645 if (HasBit(new_acc, i)) { |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
646 if (!HasBit(old_acc, i) && num_acc < lengthof(accepts)) { |
5690
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
647 /* New cargo is accepted */ |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
648 accepts[num_acc++] = i; |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
649 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
650 } else { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
651 if (HasBit(old_acc, i) && num_rej < lengthof(rejects)) { |
5690
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
652 /* Old cargo is no longer accepted */ |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
653 rejects[num_rej++] = i; |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
654 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
655 } |
5690
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
656 } |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
657 |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
658 /* Show news message if there are any changes */ |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
659 if (num_acc > 0) ShowRejectOrAcceptNews(st, num_acc, accepts, accept_msg[num_acc - 1]); |
532db432b390
(svn r8153) -Codechange: Change UpdateStationAcceptance() and ShowRejectOrAcceptNews() to work with cargo IDs instead of cargo names, and explicitly list the different strings to use.
peter1138 <peter1138@openttd.org>
parents:
5683
diff
changeset
|
660 if (num_rej > 0) ShowRejectOrAcceptNews(st, num_rej, rejects, reject_msg[num_rej - 1]); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
661 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
662 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
663 /* redraw the station view since acceptance changed */ |
8016
f60addd19e1a
(svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents:
8015
diff
changeset
|
664 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ACCEPTLIST); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
665 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
666 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
667 static void UpdateStationSignCoord(Station *st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
668 { |
6069 | 669 const StationRect *r = &st->rect; |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
670 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
671 if (r->IsEmpty()) return; /* no tiles belong to this station */ |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
672 |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
673 /* clamp sign coord to be inside the station rect */ |
7922
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7891
diff
changeset
|
674 st->xy = TileXY(ClampU(TileX(st->xy), r->left, r->right), ClampU(TileY(st->xy), r->top, r->bottom)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
675 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
676 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
677 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
678 /** This is called right after a station was deleted. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
679 * It checks if the whole station is free of substations, and if so, the station will be |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
680 * deleted after a little while. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
681 * @param st Station |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
682 */ |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
683 static void DeleteStationIfEmpty(Station *st) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
684 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
685 if (st->facilities == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
686 st->delete_ctr = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
687 RebuildStationLists(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
688 InvalidateWindow(WC_STATION_LIST, st->owner); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
689 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
690 /* station remains but it probably lost some parts - station sign should stay in the station boundaries */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
691 UpdateStationSignCoord(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
692 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
693 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
694 static CommandCost ClearTile_Station(TileIndex tile, byte flags); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
695 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
696 /** Tries to clear the given area. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
697 * @param tile TileIndex to start check |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
698 * @param w width of search area |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
699 * @param h height of search area |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
700 * @param flags operation to perform |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
701 * @param invalid_dirs prohibited directions |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
702 * @param station StationID to be queried and returned if available |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
703 * @param check_clear if clearing tile should be performed (in wich case, cost will be added) |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
704 * @return the cost in case of success, or an error code if it failed. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
705 */ |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
706 CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID *station, bool check_clear = true) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
707 { |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
708 CommandCost cost; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
709 int allowed_z = -1; |
6069 | 710 |
711 BEGIN_TILE_LOOP(tile_cur, w, h, tile) { | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
712 if (MayHaveBridgeAbove(tile_cur) && IsBridgeAbove(tile_cur)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
713 return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
714 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
715 |
6915
0c8df34ca222
(svn r10168) -Fix [FS#879]: cannot build airport when an aircraft is flying over it.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
716 if (!EnsureNoVehicleOnGround(tile_cur)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
717 |
6069 | 718 uint z; |
719 Slope tileh = GetTileSlope(tile_cur, &z); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
720 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
721 /* Prohibit building if |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
722 * 1) The tile is "steep" (i.e. stretches two height levels) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
723 * -OR- |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
724 * 2) The tile is non-flat if |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
725 * a) the player building is an "old-school" AI |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
726 * -OR- |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
727 * b) the build_on_slopes switch is disabled |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
728 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
729 if (IsSteepSlope(tileh) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
730 ((_is_old_ai_player || !_patches.build_on_slopes) && tileh != SLOPE_FLAT)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
731 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
732 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
733 |
6069 | 734 int flat_z = z; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
735 if (tileh != SLOPE_FLAT) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
736 /* need to check so the entrance to the station is not pointing at a slope. */ |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
737 if ((invalid_dirs & 1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) || |
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
738 (invalid_dirs & 2 && !(tileh & SLOPE_SE) && h_cur == 1) || |
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
739 (invalid_dirs & 4 && !(tileh & SLOPE_SW) && w_cur == 1) || |
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
740 (invalid_dirs & 8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
741 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
742 } |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
743 cost.AddCost(_price.terraform); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
744 flat_z += TILE_HEIGHT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
745 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
746 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
747 /* get corresponding flat level and make sure that all parts of the station have the same level. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
748 if (allowed_z == -1) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
749 /* first tile */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
750 allowed_z = flat_z; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
751 } else if (allowed_z != flat_z) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
752 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
753 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
754 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
755 /* if station is set, then we have special handling to allow building on top of already existing stations. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
756 * so station points to INVALID_STATION if we can build on any station. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
757 * Or it points to a station if we're only allowed to build on exactly that station. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
758 if (station != NULL && IsTileType(tile_cur, MP_STATION)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
759 if (!IsRailwayStation(tile_cur)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
760 return ClearTile_Station(tile_cur, DC_AUTO); // get error message |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
761 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
762 StationID st = GetStationIndex(tile_cur); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
763 if (*station == INVALID_STATION) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
764 *station = st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
765 } else if (*station != st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
766 return_cmd_error(STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
767 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
768 } |
6720
8fa32d4cf5ab
(svn r9952) -Fix r9951: it was not possible to build a drive-through station over a road/tram
glx <glx@openttd.org>
parents:
6719
diff
changeset
|
769 } else if (check_clear) { |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
770 CommandCost ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
771 if (CmdFailed(ret)) return ret; |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
772 cost.AddCost(ret); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
773 } |
6069 | 774 } END_TILE_LOOP(tile_cur, w, h, tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
775 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
776 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
777 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
778 |
6069 | 779 static bool CanExpandRailroadStation(const Station* st, uint* fin, Axis axis) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
780 { |
6069 | 781 uint curw = st->trainst_w; |
782 uint curh = st->trainst_h; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
783 TileIndex tile = fin[0]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
784 uint w = fin[1]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
785 uint h = fin[2]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
786 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
787 if (_patches.nonuniform_stations) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
788 /* determine new size of train station region.. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
789 int x = min(TileX(st->train_tile), TileX(tile)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
790 int y = min(TileY(st->train_tile), TileY(tile)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
791 curw = max(TileX(st->train_tile) + curw, TileX(tile) + w) - x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
792 curh = max(TileY(st->train_tile) + curh, TileY(tile) + h) - y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
793 tile = TileXY(x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
794 } else { |
8098
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
795 /* do not allow modifying non-uniform stations, |
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
796 * the uniform-stations code wouldn't handle it well */ |
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
797 BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile) |
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
798 if (!st->TileBelongsToRailStation(t)) { // there may be adjoined station |
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
799 _error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED; |
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
800 return false; |
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
801 } |
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
802 END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile) |
2f4ef2db2161
(svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled
smatz <smatz@openttd.org>
parents:
8096
diff
changeset
|
803 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
804 /* check so the orientation is the same */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
805 if (GetRailStationAxis(st->train_tile) != axis) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
806 _error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
807 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
808 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
809 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
810 /* check if the new station adjoins the old station in either direction */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
811 if (curw == w && st->train_tile == tile + TileDiffXY(0, h)) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
812 /* above */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
813 curh += h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
814 } else if (curw == w && st->train_tile == tile - TileDiffXY(0, curh)) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
815 /* below */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
816 tile -= TileDiffXY(0, curh); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
817 curh += h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
818 } else if (curh == h && st->train_tile == tile + TileDiffXY(w, 0)) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
819 /* to the left */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
820 curw += w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
821 } else if (curh == h && st->train_tile == tile - TileDiffXY(curw, 0)) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
822 /* to the right */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
823 tile -= TileDiffXY(curw, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
824 curw += w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
825 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
826 _error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
827 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
828 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
829 } |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
830 /* make sure the final size is not too big. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
831 if (curw > _patches.station_spread || curh > _patches.station_spread) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
832 _error_message = STR_306C_STATION_TOO_SPREAD_OUT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
833 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
834 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
835 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
836 /* now tile contains the new value for st->train_tile |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
837 * curw, curh contain the new value for width and height */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
838 fin[0] = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
839 fin[1] = curw; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
840 fin[2] = curh; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
841 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
842 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
843 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
844 static inline byte *CreateSingle(byte *layout, int n) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
845 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
846 int i = n; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
847 do *layout++ = 0; while (--i); |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
848 layout[((n - 1) >> 1) - n] = 2; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
849 return layout; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
850 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
851 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
852 static inline byte *CreateMulti(byte *layout, int n, byte b) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
853 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
854 int i = n; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
855 do *layout++ = b; while (--i); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
856 if (n > 4) { |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
857 layout[0 - n] = 0; |
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
858 layout[n - 1 - n] = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
859 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
860 return layout; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
861 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
862 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
863 static void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *statspec) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
864 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
865 if (statspec != NULL && statspec->lengths >= plat_len && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
866 statspec->platforms[plat_len - 1] >= numtracks && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
867 statspec->layouts[plat_len - 1][numtracks - 1]) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
868 /* Custom layout defined, follow it. */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
869 memcpy(layout, statspec->layouts[plat_len - 1][numtracks - 1], |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
870 plat_len * numtracks); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
871 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
872 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
873 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
874 if (plat_len == 1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
875 CreateSingle(layout, numtracks); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
876 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
877 if (numtracks & 1) layout = CreateSingle(layout, plat_len); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
878 numtracks >>= 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
879 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
880 while (--numtracks >= 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
881 layout = CreateMulti(layout, plat_len, 4); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
882 layout = CreateMulti(layout, plat_len, 6); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
883 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
884 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
885 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
886 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
887 /** Build railroad station |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
888 * @param tile_org starting position of station dragging/placement |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6463
diff
changeset
|
889 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
890 * @param p1 various bitstuffed elements |
6134 | 891 * - p1 = (bit 0) - orientation (Axis) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
892 * - p1 = (bit 8-15) - number of tracks |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
893 * - p1 = (bit 16-23) - platform length |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
894 * - p1 = (bit 24) - allow stations directly adjacent to other stations. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
895 * @param p2 various bitstuffed elements |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
896 * - p2 = (bit 0- 3) - railtype (p2 & 0xF) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
897 * - p2 = (bit 8-15) - custom station class |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
898 * - p2 = (bit 16-23) - custom station id |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
899 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
900 CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
901 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
902 int w_org, h_org; |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
903 CommandCost ret; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
904 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
905 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
906 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
907 /* Does the authority allow this? */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
908 if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
909 if (!ValParamRailtype(p2 & 0xF)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
910 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
911 /* unpack parameters */ |
6134 | 912 Axis axis = Extract<Axis, 0>(p1); |
6069 | 913 uint numtracks = GB(p1, 8, 8); |
914 uint plat_len = GB(p1, 16, 8); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
915 if (axis == AXIS_X) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
916 w_org = plat_len; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
917 h_org = numtracks; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
918 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
919 h_org = plat_len; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
920 w_org = numtracks; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
921 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
922 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
923 if (h_org > _patches.station_spread || w_org > _patches.station_spread) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
924 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
925 /* these values are those that will be stored in train_tile and station_platforms */ |
6069 | 926 uint finalvalues[3]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
927 finalvalues[0] = tile_org; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
928 finalvalues[1] = w_org; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
929 finalvalues[2] = h_org; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
930 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
931 /* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */ |
6069 | 932 StationID est = INVALID_STATION; |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
933 /* If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
934 * for detail info, see: |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
935 * https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
936 ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
937 if (CmdFailed(ret)) return ret; |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
938 CommandCost cost(ret.GetCost() + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
939 |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
940 Station *st = NULL; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
941 bool check_surrounding = true; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
942 |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
943 if (_patches.adjacent_stations) { |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
944 if (est != INVALID_STATION) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
945 if (HasBit(p1, 24)) { |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
946 /* You can't build an adjacent station over the top of one that |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
947 * already exists. */ |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
948 return_cmd_error(STR_MUST_REMOVE_RAILWAY_STATION_FIRST); |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
949 } else { |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
950 /* Extend the current station, and don't check whether it will |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
951 * be near any other stations. */ |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
952 st = GetStation(est); |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
953 check_surrounding = false; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
954 } |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
955 } else { |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
956 /* There's no station here. Don't check the tiles surrounding this |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
957 * one if the player wanted to build an adjacent station. */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
958 if (HasBit(p1, 24)) check_surrounding = false; |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
959 } |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
960 } |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
961 |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
962 if (check_surrounding) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
963 /* Make sure there are no similar stations around us. */ |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
964 st = GetStationAround(tile_org, w_org, h_org, est); |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
965 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
966 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
967 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
968 /* See if there is a deleted station close to us. */ |
6052 | 969 if (st == NULL) st = GetClosestStationFromTile(tile_org); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
970 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
971 /* In case of new station if DC_EXEC is NOT set we still need to create the station |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
972 * to test if everything is OK. In this case we need to delete it before return. */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
973 AutoPtrT<Station> st_auto_delete; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
974 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
975 if (st != NULL) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
976 /* Reuse an existing station. */ |
6064 | 977 if (st->owner != _current_player) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
978 return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
979 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
980 if (st->train_tile != 0) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
981 /* check if we want to expanding an already existing station? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
982 if (_is_old_ai_player || !_patches.join_stations) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
983 return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
984 if (!CanExpandRailroadStation(st, finalvalues, axis)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
985 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
986 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
987 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
988 /* XXX can't we pack this in the "else" part of the if above? */ |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
989 if (!st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TEST)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
990 } else { |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
991 /* allocate and initialize new station */ |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
992 st = new Station(tile_org); |
7377
b450ba96bf70
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium <rubidium@openttd.org>
parents:
7376
diff
changeset
|
993 if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
994 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
995 /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
996 st_auto_delete = st; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
997 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
998 st->town = ClosestTownFromTile(tile_org, (uint)-1); |
7813
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
999 if (!GenerateStationName(st, tile_org, STATIONNAMING_RAIL)) return CMD_ERROR; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1000 |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1001 if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
1002 SetBit(st->town->have_ratings, _current_player); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1003 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1004 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1005 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1006 /* Check if the given station class is valid */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1007 if (GB(p2, 8, 8) >= STAT_CLASS_MAX) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1008 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1009 /* Check if we can allocate a custom stationspec to this station */ |
6069 | 1010 const StationSpec *statspec = GetCustomStationSpec((StationClassID)GB(p2, 8, 8), GB(p2, 16, 8)); |
1011 int specindex = AllocateSpecToStation(statspec, st, flags & DC_EXEC); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1012 if (specindex == -1) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1013 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1014 if (statspec != NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1015 /* Perform NewStation checks */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1016 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1017 /* Check if the station size is permitted */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1018 if (HasBit(statspec->disallowed_platforms, numtracks - 1) || HasBit(statspec->disallowed_lengths, plat_len - 1)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1019 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1020 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1021 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1022 /* Check if the station is buildable */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1023 if (HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1024 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1025 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1026 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1027 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1028 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1029 TileIndexDiff tile_delta; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1030 byte *layout_ptr; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1031 byte numtracks_orig; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1032 Track track; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1033 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1034 /* Now really clear the land below the station |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1035 * It should never return CMD_ERROR.. but you never know ;) |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1036 * (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags) */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1037 ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _patches.nonuniform_stations ? &est : NULL); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1038 if (CmdFailed(ret)) return ret; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1039 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1040 st->train_tile = finalvalues[0]; |
5721
06a31b083e84
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr <KUDr@openttd.org>
parents:
5718
diff
changeset
|
1041 st->AddFacility(FACIL_TRAIN, finalvalues[0]); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1042 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1043 st->trainst_w = finalvalues[1]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1044 st->trainst_h = finalvalues[2]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1045 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1046 st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1047 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1048 tile_delta = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1049 track = AxisToTrack(axis); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1050 |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
1051 layout_ptr = (byte*)alloca(numtracks * plat_len); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1052 GetStationLayout(layout_ptr, numtracks, plat_len, statspec); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1053 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1054 numtracks_orig = numtracks; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1055 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1056 do { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1057 TileIndex tile = tile_org; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1058 int w = plat_len; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1059 do { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1060 byte layout = *layout_ptr++; |
6556
aac89a493707
(svn r9758) -Fix (FS#756): Ignore bit 1 (axis) of station tile layouts
peter1138 <peter1138@openttd.org>
parents:
6500
diff
changeset
|
1061 MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p2, 0, 4)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1062 SetCustomStationSpecIndex(tile, specindex); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1063 SetStationTileRandomBits(tile, GB(Random(), 0, 4)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1064 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1065 if (statspec != NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1066 /* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1067 uint32 platinfo = GetPlatformInfo(AXIS_X, 0, plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false); |
7864
dee7f1c1a1e2
(svn r11414) -Fix [FS#1387]: when building a station, even though we already 'know' it in memory, it should still be unknown in the realm of callbacks.
rubidium <rubidium@openttd.org>
parents:
7857
diff
changeset
|
1068 |
dee7f1c1a1e2
(svn r11414) -Fix [FS#1387]: when building a station, even though we already 'know' it in memory, it should still be unknown in the realm of callbacks.
rubidium <rubidium@openttd.org>
parents:
7857
diff
changeset
|
1069 /* As the station is not yet completely finished, the station does not yet exist. */ |
dee7f1c1a1e2
(svn r11414) -Fix [FS#1387]: when building a station, even though we already 'know' it in memory, it should still be unknown in the realm of callbacks.
rubidium <rubidium@openttd.org>
parents:
7857
diff
changeset
|
1070 uint16 callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, NULL, tile); |
6556
aac89a493707
(svn r9758) -Fix (FS#756): Ignore bit 1 (axis) of station tile layouts
peter1138 <peter1138@openttd.org>
parents:
6500
diff
changeset
|
1071 if (callback != CALLBACK_FAILED && callback < 8) SetStationGfx(tile, (callback & ~1) + axis); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1072 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1073 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1074 tile += tile_delta; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1075 } while (--w); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1076 SetSignalsOnBothDir(tile_org, track); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1077 YapfNotifyTrackLayoutChange(tile_org, track); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1078 tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1079 } while (--numtracks); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1080 |
6823
afa9c0a81fda
(svn r10062) -Codechange: Don't redraw all station tiles when cargo is added or removed if the station has no custom graphics.
peter1138 <peter1138@openttd.org>
parents:
6761
diff
changeset
|
1081 st->MarkTilesDirty(false); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1082 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1083 UpdateStationAcceptance(st, false); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1084 RebuildStationLists(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1085 InvalidateWindow(WC_STATION_LIST, st->owner); |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1086 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1087 /* success, so don't delete the new station */ |
7298
b30b64f784db
(svn r10646) -Cleanup: AutoPtrT<>::Release() renamed to Detach()
KUDr <KUDr@openttd.org>
parents:
7272
diff
changeset
|
1088 st_auto_delete.Detach(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1089 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1090 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1091 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1092 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1093 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1094 static void MakeRailwayStationAreaSmaller(Station *st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1095 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1096 uint w = st->trainst_w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1097 uint h = st->trainst_h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1098 TileIndex tile = st->train_tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1099 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1100 restart: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1101 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1102 /* too small? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1103 if (w != 0 && h != 0) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1104 /* check the left side, x = constant, y changes */ |
6069 | 1105 for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(0, i));) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1106 /* the left side is unused? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1107 if (++i == h) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1108 tile += TileDiffXY(1, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1109 w--; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1110 goto restart; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1111 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1112 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1113 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1114 /* check the right side, x = constant, y changes */ |
6069 | 1115 for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(w - 1, i));) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1116 /* the right side is unused? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1117 if (++i == h) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1118 w--; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1119 goto restart; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1120 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1121 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1122 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1123 /* check the upper side, y = constant, x changes */ |
6069 | 1124 for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(i, 0));) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1125 /* the left side is unused? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1126 if (++i == w) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1127 tile += TileDiffXY(0, 1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1128 h--; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1129 goto restart; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1130 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1131 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1132 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1133 /* check the lower side, y = constant, x changes */ |
6069 | 1134 for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(i, h - 1));) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1135 /* the left side is unused? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1136 if (++i == w) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1137 h--; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1138 goto restart; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1139 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1140 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1141 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1142 tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1143 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1144 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1145 st->trainst_w = w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1146 st->trainst_h = h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1147 st->train_tile = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1148 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1149 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1150 /** Remove a single tile from a railroad station. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1151 * This allows for custom-built station with holes and weird layouts |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1152 * @param tile tile of station piece to remove |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6463
diff
changeset
|
1153 * @param flags operation to perform |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1154 * @param p1 start_tile |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1155 * @param p2 unused |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1156 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1157 CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1158 { |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1159 TileIndex start = p1 == 0 ? tile : p1; |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1160 |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1161 /* Count of the number of tiles removed */ |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1162 int quantity = 0; |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1163 |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1164 if (tile >= MapSize() || start >= MapSize()) return CMD_ERROR; |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1165 |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1166 /* make sure sx,sy are smaller than ex,ey */ |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1167 int ex = TileX(tile); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1168 int ey = TileY(tile); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1169 int sx = TileX(start); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1170 int sy = TileY(start); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1171 if (ex < sx) Swap(ex, sx); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1172 if (ey < sy) Swap(ey, sy); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1173 tile = TileXY(sx, sy); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1174 |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1175 int size_x = ex - sx + 1; |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1176 int size_y = ey - sy + 1; |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1177 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1178 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1179 |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1180 /* Do the action for every tile into the area */ |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1181 BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) { |
8010
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1182 /* Make sure the specified tile is a railroad station */ |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1183 if (!IsTileType(tile2, MP_STATION) || !IsRailwayStation(tile2)) { |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1184 continue; |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1185 } |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1186 |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1187 /* If there is a vehicle on ground, do not allow to remove (flood) the tile */ |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1188 if (!EnsureNoVehicleOnGround(tile2)) { |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1189 continue; |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1190 } |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1191 |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1192 /* Check ownership of station */ |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1193 Station *st = GetStationByTile(tile2); |
8010
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1194 if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) { |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1195 continue; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1196 } |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1197 |
8010
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1198 /* Do not allow removing from stations if non-uniform stations are not enabled |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1199 * The check must be here to give correct error message |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1200 */ |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1201 if (!_patches.nonuniform_stations) return_cmd_error(STR_306D_NONUNIFORM_STATIONS_DISALLOWED); |
32a26aa50015
(svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON)
smatz <smatz@openttd.org>
parents:
7954
diff
changeset
|
1202 |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1203 /* If we reached here, the tile is valid so increase the quantity of tiles we will remove */ |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1204 quantity++; |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1205 |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1206 if (flags & DC_EXEC) { |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1207 uint specindex = GetCustomStationSpecIndex(tile2); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1208 Track track = GetRailStationTrack(tile2); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1209 DoClearSquare(tile2); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1210 st->rect.AfterRemoveTile(st, tile2); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1211 SetSignalsOnBothDir(tile2, track); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1212 YapfNotifyTrackLayoutChange(tile2, track); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1213 |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1214 DeallocateSpecFromStation(st, specindex); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1215 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1216 /* now we need to make the "spanned" area of the railway station smaller |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1217 * if we deleted something at the edges. |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1218 * we also need to adjust train_tile. */ |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1219 MakeRailwayStationAreaSmaller(st); |
6823
afa9c0a81fda
(svn r10062) -Codechange: Don't redraw all station tiles when cargo is added or removed if the station has no custom graphics.
peter1138 <peter1138@openttd.org>
parents:
6761
diff
changeset
|
1220 st->MarkTilesDirty(false); |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1221 UpdateStationSignCoord(st); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1222 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1223 /* if we deleted the whole station, delete the train facility. */ |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1224 if (st->train_tile == 0) { |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1225 st->facilities &= ~FACIL_TRAIN; |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1226 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS); |
6596
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1227 UpdateStationVirtCoordDirty(st); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1228 DeleteStationIfEmpty(st); |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1229 } |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1230 } |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1231 } END_TILE_LOOP(tile2, size_x, size_y, tile) |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1232 |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1233 /* If we've not removed any tiles, give an error */ |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1234 if (quantity == 0) return CMD_ERROR; |
25eb42436c22
(svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents:
6556
diff
changeset
|
1235 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1236 return CommandCost(_price.remove_rail_station * quantity); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1237 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1238 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1239 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1240 static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1241 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1242 /* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1243 if (_current_player == OWNER_WATER && _patches.nonuniform_stations) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1244 return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1245 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1246 /* Current player owns the station? */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1247 if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1248 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1249 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1250 /* determine width and height of platforms */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1251 tile = st->train_tile; |
6069 | 1252 int w = st->trainst_w; |
1253 int h = st->trainst_h; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1254 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1255 assert(w != 0 && h != 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1256 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1257 CommandCost cost; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1258 /* clear all areas of the station */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1259 do { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1260 int w_bak = w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1261 do { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1262 // for nonuniform stations, only remove tiles that are actually train station tiles |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1263 if (st->TileBelongsToRailStation(tile)) { |
7758
013f54f32e5e
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium <rubidium@openttd.org>
parents:
7739
diff
changeset
|
1264 if (!EnsureNoVehicleOnGround(tile)) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1265 return CMD_ERROR; |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1266 cost.AddCost(_price.remove_rail_station); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1267 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1268 Track track = GetRailStationTrack(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1269 DoClearSquare(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1270 SetSignalsOnBothDir(tile, track); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1271 YapfNotifyTrackLayoutChange(tile, track); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1272 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1273 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1274 tile += TileDiffXY(1, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1275 } while (--w); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1276 w = w_bak; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1277 tile += TileDiffXY(-w, 1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1278 } while (--h); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1279 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1280 if (flags & DC_EXEC) { |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1281 st->rect.AfterRemoveRect(st, st->train_tile, st->trainst_w, st->trainst_h); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1282 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1283 st->train_tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1284 st->trainst_w = st->trainst_h = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1285 st->facilities &= ~FACIL_TRAIN; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1286 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1287 free(st->speclist); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1288 st->num_specs = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1289 st->speclist = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1290 |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1291 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1292 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1293 DeleteStationIfEmpty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1294 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1295 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1296 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1297 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1298 |
6368
4e4f7827e7ed
(svn r9425) -Codechange/Fix (FS#689): Housekeeping in the convert rail functions: Changed the order of error checks to generate more meaningful error messages, added some doxygen comments and replaced bitshifting by proper mathematical operations
celestar <celestar@openttd.org>
parents:
6357
diff
changeset
|
1299 /** |
6488
5f4bfd9f649d
(svn r9669) -Documentation: some more doxygen fixes
belugas <belugas@openttd.org>
parents:
6484
diff
changeset
|
1300 * @param truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK |
5f4bfd9f649d
(svn r9669) -Documentation: some more doxygen fixes
belugas <belugas@openttd.org>
parents:
6484
diff
changeset
|
1301 * @param st The Station to do the whole procedure for |
5906 | 1302 * @return a pointer to where to link a new RoadStop* |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1303 */ |
5906 | 1304 static RoadStop **FindRoadStopSpot(bool truck_station, Station* st) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1305 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1306 RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1307 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1308 if (*primary_stop == NULL) { |
6488
5f4bfd9f649d
(svn r9669) -Documentation: some more doxygen fixes
belugas <belugas@openttd.org>
parents:
6484
diff
changeset
|
1309 /* we have no roadstop of the type yet, so write a "primary stop" */ |
5906 | 1310 return primary_stop; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1311 } else { |
6488
5f4bfd9f649d
(svn r9669) -Documentation: some more doxygen fixes
belugas <belugas@openttd.org>
parents:
6484
diff
changeset
|
1312 /* there are stops already, so append to the end of the list */ |
5906 | 1313 RoadStop *stop = *primary_stop; |
1314 while (stop->next != NULL) stop = stop->next; | |
1315 return &stop->next; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1316 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1317 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1318 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1319 /** Build a bus or truck stop |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1320 * @param tile tile to build the stop at |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6463
diff
changeset
|
1321 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1322 * @param p1 entrance direction (DiagDirection) |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1323 * @param p2 bit 0: 0 for Bus stops, 1 for truck stops |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1324 * bit 1: 0 for normal, 1 for drive-through |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1325 * bit 2..4: the roadtypes |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1326 * bit 5: allow stations directly adjacent to other stations. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1327 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1328 CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1329 { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1330 bool type = HasBit(p2, 0); |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1331 bool is_drive_through = HasBit(p2, 1); |
7370
fba35a9abf79
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents:
7335
diff
changeset
|
1332 bool build_over_road = is_drive_through && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL; |
6067
0158909ce445
(svn r8797) -Fix (8741): the 'drive through station built on town owned road' bit was not set.
rubidium <rubidium@openttd.org>
parents:
6066
diff
changeset
|
1333 bool town_owned_road = build_over_road && IsTileOwner(tile, OWNER_TOWN); |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1334 RoadTypes rts = (RoadTypes)GB(p2, 2, 3); |
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1335 |
7857
707c26c48f4e
(svn r11407) -Fix: do not allow building of tram-tracks when they are not available (SmatZ)
truelight <truelight@openttd.org>
parents:
7849
diff
changeset
|
1336 if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1337 |
6677
8451c7d3a664
(svn r9908) -Codechange: prepare the station picker for more road types.
rubidium <rubidium@openttd.org>
parents:
6674
diff
changeset
|
1338 /* Trams only have drive through stops */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1339 if (!is_drive_through && HasBit(rts, ROADTYPE_TRAM)) return CMD_ERROR; |
6677
8451c7d3a664
(svn r9908) -Codechange: prepare the station picker for more road types.
rubidium <rubidium@openttd.org>
parents:
6674
diff
changeset
|
1340 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1341 /* Saveguard the parameters */ |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
1342 if (!IsValidDiagDirection((DiagDirection)p1)) return CMD_ERROR; |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1343 /* If it is a drive-through stop check for valid axis */ |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1344 if (is_drive_through && !IsValidAxis((Axis)p1)) return CMD_ERROR; |
6018
0b8944c960b5
(svn r8741) -Fix (r8735): make the saveguards of CmdBuildRoadStop more robust and add roadstops.grf to the list of required grfs.
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
1345 /* Road bits in the wrong direction */ |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1346 if (build_over_road && (GetAllRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_DRIVE_THROUGH_ERROR_DIRECTION); |
6703
9db57e7e8526
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1347 |
9db57e7e8526
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1348 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
9db57e7e8526
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1349 |
9db57e7e8526
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1350 if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR; |
9db57e7e8526
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1351 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1352 CommandCost cost; |
6703
9db57e7e8526
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1353 |
6018
0b8944c960b5
(svn r8741) -Fix (r8735): make the saveguards of CmdBuildRoadStop more robust and add roadstops.grf to the list of required grfs.
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
1354 /* Not allowed to build over this road */ |
6402
b0b11d9fe257
(svn r9532) -Fix (r8741) [FS#708]: Make errors when building drive through road stops more descriptive.
maedhros <maedhros@openttd.org>
parents:
6394
diff
changeset
|
1355 if (build_over_road) { |
b0b11d9fe257
(svn r9532) -Fix (r8741) [FS#708]: Make errors when building drive through road stops more descriptive.
maedhros <maedhros@openttd.org>
parents:
6394
diff
changeset
|
1356 if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD); |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1357 if (GetRoadTileType(tile) != ROAD_TILE_NORMAL) return CMD_ERROR; |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1358 |
6761
f75a2f332873
(svn r9996) -Fix: be more strict when building/upgrading roads and/or road stops.
rubidium <rubidium@openttd.org>
parents:
6733
diff
changeset
|
1359 /* Don't allow building the roadstop when vehicles are already driving on it */ |
f75a2f332873
(svn r9996) -Fix: be more strict when building/upgrading roads and/or road stops.
rubidium <rubidium@openttd.org>
parents:
6733
diff
changeset
|
1360 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
f75a2f332873
(svn r9996) -Fix: be more strict when building/upgrading roads and/or road stops.
rubidium <rubidium@openttd.org>
parents:
6733
diff
changeset
|
1361 |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1362 RoadTypes cur_rts = GetRoadTypes(tile); |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1363 if (GetRoadOwner(tile, ROADTYPE_ROAD) != OWNER_TOWN && HasBit(cur_rts, ROADTYPE_ROAD) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_ROAD))) return CMD_ERROR; |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1364 if (HasBit(cur_rts, ROADTYPE_TRAM) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_TRAM))) return CMD_ERROR; |
6703
9db57e7e8526
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1365 |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1366 /* Do not remove roadtypes! */ |
6703
9db57e7e8526
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1367 rts |= cur_rts; |
6402
b0b11d9fe257
(svn r9532) -Fix (r8741) [FS#708]: Make errors when building drive through road stops more descriptive.
maedhros <maedhros@openttd.org>
parents:
6394
diff
changeset
|
1368 } |
6720
8fa32d4cf5ab
(svn r9952) -Fix r9951: it was not possible to build a drive-through station over a road/tram
glx <glx@openttd.org>
parents:
6719
diff
changeset
|
1369 cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road); |
6719
e745bb9e9727
(svn r9951) -Fix: slope check was incomplete when building road over tram track (and vice-versa)
glx <glx@openttd.org>
parents:
6703
diff
changeset
|
1370 if (CmdFailed(cost)) return cost; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1371 |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1372 Station *st = NULL; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1373 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1374 if (!_patches.adjacent_stations || !HasBit(p2, 5)) { |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1375 st = GetStationAround(tile, 1, 1, INVALID_STATION); |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1376 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1377 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1378 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1379 /* Find a station close to us */ |
6052 | 1380 if (st == NULL) st = GetClosestStationFromTile(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1381 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1382 /* give us a road stop in the list, and check if something went wrong */ |
6069 | 1383 RoadStop *road_stop = new RoadStop(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1384 if (road_stop == NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1385 return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1386 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1387 |
5833
bcd4b73b9fd2
(svn r8399) -Fix (r8185): a new road stop was always created in CmdBuildRoadStop(), but it was not deleted if DC_EXEC flag was not set or if the station creation failed
glx <glx@openttd.org>
parents:
5721
diff
changeset
|
1388 /* ensure that in case of error (or no DC_EXEC) the new road stop gets deleted upon return */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
1389 AutoPtrT<RoadStop> rs_auto_delete(road_stop); |
5833
bcd4b73b9fd2
(svn r8399) -Fix (r8185): a new road stop was always created in CmdBuildRoadStop(), but it was not deleted if DC_EXEC flag was not set or if the station creation failed
glx <glx@openttd.org>
parents:
5721
diff
changeset
|
1390 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1391 if (st != NULL && |
5837
e18480817d2c
(svn r8403) -Fix (r8402): Forgot to remove an enum
celestar <celestar@openttd.org>
parents:
5836
diff
changeset
|
1392 GetNumRoadStopsInStation(st, RoadStop::BUS) + GetNumRoadStopsInStation(st, RoadStop::TRUCK) >= RoadStop::LIMIT) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1393 return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1394 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1395 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1396 /* In case of new station if DC_EXEC is NOT set we still need to create the station |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1397 * to test if everything is OK. In this case we need to delete it before return. */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
1398 AutoPtrT<Station> st_auto_delete; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1399 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1400 if (st != NULL) { |
6064 | 1401 if (st->owner != _current_player) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1402 return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1403 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1404 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1405 if (!st->rect.BeforeAddTile(tile, StationRect::ADD_TEST)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1406 } else { |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1407 /* allocate and initialize new station */ |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1408 st = new Station(tile); |
7377
b450ba96bf70
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium <rubidium@openttd.org>
parents:
7376
diff
changeset
|
1409 if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1410 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1411 /* ensure that in case of error (or no DC_EXEC) the new station gets deleted upon return */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
1412 st_auto_delete = st; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1413 |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1414 |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1415 Town *t = st->town = ClosestTownFromTile(tile, (uint)-1); |
7813
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
1416 if (!GenerateStationName(st, tile, STATIONNAMING_ROAD)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1417 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1418 if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
1419 SetBit(t->have_ratings, _current_player); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1420 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1421 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1422 st->sign.width_1 = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1423 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1424 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1425 cost.AddCost((type) ? _price.build_truck_station : _price.build_bus_station); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1426 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1427 if (flags & DC_EXEC) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1428 /* Insert into linked list of RoadStops */ |
5906 | 1429 RoadStop **currstop = FindRoadStopSpot(type, st); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1430 *currstop = road_stop; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1431 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1432 /*initialize an empty station */ |
5721
06a31b083e84
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr <KUDr@openttd.org>
parents:
5718
diff
changeset
|
1433 st->AddFacility((type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP, tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1434 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1435 st->rect.BeforeAddTile(tile, StationRect::ADD_TRY); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1436 |
6098 | 1437 RoadStop::Type rs_type = type ? RoadStop::TRUCK : RoadStop::BUS; |
1438 if (is_drive_through) { | |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1439 MakeDriveThroughRoadStop(tile, st->owner, st->index, rs_type, rts, (Axis)p1, town_owned_road); |
6098 | 1440 } else { |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1441 MakeRoadStop(tile, st->owner, st->index, rs_type, rts, (DiagDirection)p1); |
6098 | 1442 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1443 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1444 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1445 UpdateStationAcceptance(st, false); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1446 RebuildStationLists(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1447 InvalidateWindow(WC_STATION_LIST, st->owner); |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1448 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS); |
5833
bcd4b73b9fd2
(svn r8399) -Fix (r8185): a new road stop was always created in CmdBuildRoadStop(), but it was not deleted if DC_EXEC flag was not set or if the station creation failed
glx <glx@openttd.org>
parents:
5721
diff
changeset
|
1449 /* success, so don't delete the new station and the new road stop */ |
7298
b30b64f784db
(svn r10646) -Cleanup: AutoPtrT<>::Release() renamed to Detach()
KUDr <KUDr@openttd.org>
parents:
7272
diff
changeset
|
1450 st_auto_delete.Detach(); |
b30b64f784db
(svn r10646) -Cleanup: AutoPtrT<>::Release() renamed to Detach()
KUDr <KUDr@openttd.org>
parents:
7272
diff
changeset
|
1451 rs_auto_delete.Detach(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1452 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1453 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1454 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1455 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1456 /** Remove a bus station |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1457 * @param st Station to remove |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1458 * @param flags operation to perform |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1459 * @param tile TileIndex been queried |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1460 * @return cost or failure of operation |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1461 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1462 static CommandCost RemoveRoadStop(Station *st, uint32 flags, TileIndex tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1463 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1464 if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1465 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1466 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1467 |
6069 | 1468 bool is_truck = IsTruckStop(tile); |
1469 | |
1470 RoadStop **primary_stop; | |
1471 RoadStop *cur_stop; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1472 if (is_truck) { // truck stop |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1473 primary_stop = &st->truck_stops; |
5836
0b68d5a508a2
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar <celestar@openttd.org>
parents:
5834
diff
changeset
|
1474 cur_stop = GetRoadStopByTile(tile, RoadStop::TRUCK); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1475 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1476 primary_stop = &st->bus_stops; |
5836
0b68d5a508a2
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar <celestar@openttd.org>
parents:
5834
diff
changeset
|
1477 cur_stop = GetRoadStopByTile(tile, RoadStop::BUS); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1478 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1479 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1480 assert(cur_stop != NULL); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1481 |
7758
013f54f32e5e
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium <rubidium@openttd.org>
parents:
7739
diff
changeset
|
1482 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1483 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1484 if (flags & DC_EXEC) { |
5867 | 1485 if (*primary_stop == cur_stop) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1486 /* removed the first stop in the list */ |
5867 | 1487 *primary_stop = cur_stop->next; |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1488 /* removed the only stop? */ |
5867 | 1489 if (*primary_stop == NULL) { |
1490 st->facilities &= (is_truck ? ~FACIL_TRUCK_STOP : ~FACIL_BUS_STOP); | |
1491 } | |
1492 } else { | |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1493 /* tell the predecessor in the list to skip this stop */ |
5867 | 1494 RoadStop *pred = *primary_stop; |
1495 while (pred->next != cur_stop) pred = pred->next; | |
1496 pred->next = cur_stop->next; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1497 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1498 |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1499 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS); |
5708
3dc3a5375999
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar <celestar@openttd.org>
parents:
5697
diff
changeset
|
1500 delete cur_stop; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1501 DoClearSquare(tile); |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1502 st->rect.AfterRemoveTile(st, tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1503 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1504 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1505 DeleteStationIfEmpty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1506 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1507 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1508 return CommandCost((is_truck) ? _price.remove_truck_station : _price.remove_bus_station); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1509 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1510 |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1511 /** Remove a bus or truck stop |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1512 * @param tile tile to remove the stop from |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6463
diff
changeset
|
1513 * @param flags operation to perform |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1514 * @param p1 not used |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1515 * @param p2 bit 0: 0 for Bus stops, 1 for truck stops |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1516 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1517 CommandCost CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1518 { |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1519 /* Make sure the specified tile is a road stop of the correct type */ |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1520 if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile) || (uint32)GetRoadStopType(tile) != p2) return CMD_ERROR; |
6069 | 1521 Station *st = GetStationByTile(tile); |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1522 /* Save the stop info before it is removed */ |
6069 | 1523 bool is_drive_through = IsDriveThroughStopTile(tile); |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
1524 RoadTypes rts = GetRoadTypes(tile); |
6664
d6b2f3c0cd3b
(svn r9895) -Fix: assertion when removing roadstop.
rubidium <rubidium@openttd.org>
parents:
6662
diff
changeset
|
1525 RoadBits road_bits = IsDriveThroughStopTile(tile) ? |
d6b2f3c0cd3b
(svn r9895) -Fix: assertion when removing roadstop.
rubidium <rubidium@openttd.org>
parents:
6662
diff
changeset
|
1526 ((GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y) : |
d6b2f3c0cd3b
(svn r9895) -Fix: assertion when removing roadstop.
rubidium <rubidium@openttd.org>
parents:
6662
diff
changeset
|
1527 DiagDirToRoadBits(GetRoadStopDir(tile)); |
6069 | 1528 bool is_towns_road = is_drive_through && GetStopBuiltOnTownRoad(tile); |
1529 | |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1530 CommandCost ret = RemoveRoadStop(st, flags, tile); |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1531 |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1532 /* If the stop was a drive-through stop replace the road */ |
6946
803e29b0584e
(svn r10200) -Codechange: add "shortcut" for !CmdFailed (CmdSucceeded).
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
1533 if ((flags & DC_EXEC) && CmdSucceeded(ret) && is_drive_through) { |
6733
84f67d7e1b86
(svn r9965) -Fix: the ownership of drive through road stops on town owned roads wasn't properly reset when the road stop was removed.
rubidium <rubidium@openttd.org>
parents:
6720
diff
changeset
|
1534 /* Rebuild the drive throuhg road stop. As a road stop can only be |
84f67d7e1b86
(svn r9965) -Fix: the ownership of drive through road stops on town owned roads wasn't properly reset when the road stop was removed.
rubidium <rubidium@openttd.org>
parents:
6720
diff
changeset
|
1535 * removed by the owner of the roadstop, _current_player is the |
84f67d7e1b86
(svn r9965) -Fix: the ownership of drive through road stops on town owned roads wasn't properly reset when the road stop was removed.
rubidium <rubidium@openttd.org>
parents:
6720
diff
changeset
|
1536 * owner of the road stop. */ |
84f67d7e1b86
(svn r9965) -Fix: the ownership of drive through road stops on town owned roads wasn't properly reset when the road stop was removed.
rubidium <rubidium@openttd.org>
parents:
6720
diff
changeset
|
1537 MakeRoadNormal(tile, road_bits, rts, is_towns_road ? ClosestTownFromTile(tile, (uint)-1)->index : 0, |
84f67d7e1b86
(svn r9965) -Fix: the ownership of drive through road stops on town owned roads wasn't properly reset when the road stop was removed.
rubidium <rubidium@openttd.org>
parents:
6720
diff
changeset
|
1538 is_towns_road ? OWNER_TOWN : _current_player, _current_player, _current_player); |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1539 } |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1540 |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1541 return ret; |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
1542 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1543 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1544 /* FIXME -- need to move to its corresponding Airport variable*/ |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1545 |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1546 /* Country Airfield (small) */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1547 static const byte _airport_sections_country[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1548 54, 53, 52, 65, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1549 58, 57, 56, 55, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1550 64, 63, 63, 62 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1551 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1552 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1553 /* City Airport (large) */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1554 static const byte _airport_sections_town[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1555 31, 9, 33, 9, 9, 32, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1556 27, 36, 29, 34, 8, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1557 30, 11, 35, 13, 20, 21, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1558 51, 12, 14, 17, 19, 28, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1559 38, 13, 15, 16, 18, 39, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1560 26, 22, 23, 24, 25, 26 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1561 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1562 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1563 /* Metropolitain Airport (large) - 2 runways */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1564 static const byte _airport_sections_metropolitan[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1565 31, 9, 33, 9, 9, 32, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1566 27, 36, 29, 34, 8, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1567 30, 11, 35, 13, 20, 21, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1568 102, 8, 8, 8, 8, 28, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1569 83, 84, 84, 84, 84, 83, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1570 26, 23, 23, 23, 23, 26 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1571 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1572 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1573 /* International Airport (large) - 2 runways */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1574 static const byte _airport_sections_international[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1575 88, 89, 89, 89, 89, 89, 88, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1576 51, 8, 8, 8, 8, 8, 32, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1577 30, 8, 11, 27, 11, 8, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1578 32, 8, 11, 27, 11, 8, 114, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1579 87, 8, 11, 85, 11, 8, 114, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1580 87, 8, 8, 8, 8, 8, 90, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1581 26, 23, 23, 23, 23, 23, 26 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1582 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1583 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1584 /* Intercontinental Airport (vlarge) - 4 runways */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1585 static const byte _airport_sections_intercontinental[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1586 102, 120, 89, 89, 89, 89, 89, 89, 118, |
6267
aa94b177ca9a
(svn r9076) -Fix [FS#529]: the intercontinental airport used 'T-junction' runway sprites when there is no exit in the middle of the runway as in the city airport (skidd13).
rubidium <rubidium@openttd.org>
parents:
6261
diff
changeset
|
1587 120, 23, 23, 23, 23, 23, 23, 119, 117, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1588 87, 54, 87, 8, 8, 8, 8, 51, 117, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1589 87, 162, 87, 85, 116, 116, 8, 9, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1590 87, 8, 8, 11, 31, 11, 8, 160, 32, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1591 32, 160, 8, 11, 27, 11, 8, 8, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1592 87, 8, 8, 11, 30, 11, 8, 8, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1593 87, 142, 8, 11, 29, 11, 10, 163, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1594 87, 164, 87, 8, 8, 8, 10, 37, 117, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1595 87, 120, 89, 89, 89, 89, 89, 89, 119, |
6267
aa94b177ca9a
(svn r9076) -Fix [FS#529]: the intercontinental airport used 'T-junction' runway sprites when there is no exit in the middle of the runway as in the city airport (skidd13).
rubidium <rubidium@openttd.org>
parents:
6261
diff
changeset
|
1596 121, 23, 23, 23, 23, 23, 23, 119, 37 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1597 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1598 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1599 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1600 /* Commuter Airfield (small) */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1601 static const byte _airport_sections_commuter[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1602 85, 30, 115, 115, 32, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1603 87, 8, 8, 8, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1604 87, 11, 11, 11, 10, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1605 26, 23, 23, 23, 26 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1606 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1607 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1608 /* Heliport */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1609 static const byte _airport_sections_heliport[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1610 66, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1611 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1612 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1613 /* Helidepot */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1614 static const byte _airport_sections_helidepot[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1615 124, 32, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1616 122, 123 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1617 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1618 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1619 /* Helistation */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1620 static const byte _airport_sections_helistation[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1621 32, 134, 159, 158, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1622 161, 142, 142, 157 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1623 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1624 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1625 static const byte * const _airport_sections[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1626 _airport_sections_country, // Country Airfield (small) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1627 _airport_sections_town, // City Airport (large) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1628 _airport_sections_heliport, // Heliport |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1629 _airport_sections_metropolitan, // Metropolitain Airport (large) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1630 _airport_sections_international, // International Airport (xlarge) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1631 _airport_sections_commuter, // Commuter Airport (small) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1632 _airport_sections_helidepot, // Helidepot |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1633 _airport_sections_intercontinental, // Intercontinental Airport (xxlarge) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1634 _airport_sections_helistation // Helistation |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1635 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1636 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1637 /** Place an Airport. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1638 * @param tile tile where airport will be built |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6463
diff
changeset
|
1639 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1640 * @param p1 airport type, @see airport.h |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1641 * @param p2 (bit 0) - allow airports directly adjacent to other airports. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1642 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1643 CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1644 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1645 bool airport_upgrade = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1646 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1647 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1648 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1649 /* Check if a valid, buildable airport was chosen for construction */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1650 if (p1 > lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1651 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1652 if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1653 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1654 |
6069 | 1655 Town *t = ClosestTownFromTile(tile, (uint)-1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1656 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1657 /* Check if local auth refuses a new airport */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1658 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1659 uint num = 0; |
6069 | 1660 const Station *st; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1661 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1662 if (st->town == t && st->facilities&FACIL_AIRPORT && st->airport_type != AT_OILRIG) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1663 num++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1664 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1665 if (num >= 2) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1666 SetDParam(0, t->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1667 return_cmd_error(STR_2035_LOCAL_AUTHORITY_REFUSES); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1668 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1669 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1670 |
6069 | 1671 const AirportFTAClass *afc = GetAirport(p1); |
1672 int w = afc->size_x; | |
1673 int h = afc->size_y; | |
1674 | |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1675 CommandCost ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1676 if (CmdFailed(ret)) return ret; |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1677 CommandCost cost(ret.GetCost()); |
6069 | 1678 |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1679 Station *st = NULL; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1680 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1681 if (!_patches.adjacent_stations || !HasBit(p2, 0)) { |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1682 st = GetStationAround(tile, w, h, INVALID_STATION); |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1683 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1684 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1685 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1686 /* Find a station close to us */ |
6052 | 1687 if (st == NULL) st = GetClosestStationFromTile(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1688 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1689 if (w > _patches.station_spread || h > _patches.station_spread) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1690 _error_message = STR_306C_STATION_TOO_SPREAD_OUT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1691 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1692 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1693 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1694 /* In case of new station if DC_EXEC is NOT set we still need to create the station |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1695 * to test if everything is OK. In this case we need to delete it before return. */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
1696 AutoPtrT<Station> st_auto_delete; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1697 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1698 if (st != NULL) { |
6064 | 1699 if (st->owner != _current_player) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1700 return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1701 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1702 if (!st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TEST)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1703 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1704 if (st->airport_tile != 0) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1705 return_cmd_error(STR_300D_TOO_CLOSE_TO_ANOTHER_AIRPORT); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1706 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1707 airport_upgrade = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1708 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1709 /* allocate and initialize new station */ |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1710 st = new Station(tile); |
7377
b450ba96bf70
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium <rubidium@openttd.org>
parents:
7376
diff
changeset
|
1711 if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1712 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1713 /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
1714 st_auto_delete = st; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1715 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1716 st->town = t; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1717 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1718 if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
1719 SetBit(t->have_ratings, _current_player); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1720 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1721 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1722 st->sign.width_1 = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1723 |
6049 | 1724 /* If only helicopters may use the airport generate a helicopter related (5) |
1725 * station name, otherwise generate a normal airport name (1) */ | |
7813
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
1726 if (!GenerateStationName(st, tile, !(afc->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_HELIPORT : STATIONNAMING_AIRPORT)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1727 return CMD_ERROR; |
6049 | 1728 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1729 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1730 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1731 cost.AddCost(_price.build_airport * w * h); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1732 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1733 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1734 st->airport_tile = tile; |
5721
06a31b083e84
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr <KUDr@openttd.org>
parents:
5718
diff
changeset
|
1735 st->AddFacility(FACIL_AIRPORT, tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1736 st->airport_type = (byte)p1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1737 st->airport_flags = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1738 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1739 st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1740 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1741 /* if airport was demolished while planes were en-route to it, the |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1742 * positions can no longer be the same (v->u.air.pos), since different |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1743 * airports have different indexes. So update all planes en-route to this |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1744 * airport. Only update if |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1745 * 1. airport is upgraded |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1746 * 2. airport is added to existing station (unfortunately unavoideable) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1747 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1748 if (airport_upgrade) UpdateAirplanesOnNewStation(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1749 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1750 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1751 const byte *b = _airport_sections[p1]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1752 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1753 BEGIN_TILE_LOOP(tile_cur, w, h, tile) { |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
1754 MakeAirport(tile_cur, st->owner, st->index, *b - ((*b < 67) ? 8 : 24)); |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
1755 b++; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1756 } END_TILE_LOOP(tile_cur, w, h, tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1757 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1758 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1759 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1760 UpdateStationAcceptance(st, false); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1761 RebuildStationLists(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1762 InvalidateWindow(WC_STATION_LIST, st->owner); |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1763 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1764 /* success, so don't delete the new station */ |
7298
b30b64f784db
(svn r10646) -Cleanup: AutoPtrT<>::Release() renamed to Detach()
KUDr <KUDr@openttd.org>
parents:
7272
diff
changeset
|
1765 st_auto_delete.Detach(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1766 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1767 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1768 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1769 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1770 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1771 static CommandCost RemoveAirport(Station *st, uint32 flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1772 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1773 if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1774 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1775 |
6069 | 1776 TileIndex tile = st->airport_tile; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1777 |
6032 | 1778 const AirportFTAClass *afc = st->Airport(); |
6069 | 1779 int w = afc->size_x; |
1780 int h = afc->size_y; | |
1781 | |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1782 CommandCost cost(w * h * _price.remove_airport); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1783 |
6394
d1cf5ac55918
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar <celestar@openttd.org>
parents:
6368
diff
changeset
|
1784 Vehicle *v; |
d1cf5ac55918
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar <celestar@openttd.org>
parents:
6368
diff
changeset
|
1785 FOR_ALL_VEHICLES(v) { |
d1cf5ac55918
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar <celestar@openttd.org>
parents:
6368
diff
changeset
|
1786 if (!(v->type == VEH_AIRCRAFT && IsNormalAircraft(v))) continue; |
d1cf5ac55918
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar <celestar@openttd.org>
parents:
6368
diff
changeset
|
1787 |
d1cf5ac55918
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar <celestar@openttd.org>
parents:
6368
diff
changeset
|
1788 if (v->u.air.targetairport == st->index && v->u.air.state != FLYING) return CMD_ERROR; |
d1cf5ac55918
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar <celestar@openttd.org>
parents:
6368
diff
changeset
|
1789 } |
d1cf5ac55918
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar <celestar@openttd.org>
parents:
6368
diff
changeset
|
1790 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1791 BEGIN_TILE_LOOP(tile_cur, w, h, tile) { |
7652
58283aa94bde
(svn r11183) -Fix [FS#1249]: airports do not need to care about overflying aircraf when removing them, because if they were not in the "flying" state it can't be removed anyway.
rubidium <rubidium@openttd.org>
parents:
7645
diff
changeset
|
1792 if (!EnsureNoVehicleOnGround(tile_cur)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1793 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1794 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1795 DeleteAnimatedTile(tile_cur); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1796 DoClearSquare(tile_cur); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1797 } |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6488
diff
changeset
|
1798 } END_TILE_LOOP(tile_cur, w, h, tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1799 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1800 if (flags & DC_EXEC) { |
6069 | 1801 for (uint i = 0; i < afc->nof_depots; ++i) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1802 DeleteWindowById( |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1803 WC_VEHICLE_DEPOT, tile + ToTileIndexDiff(afc->airport_depots[i]) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1804 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1805 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1806 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1807 st->rect.AfterRemoveRect(st, tile, w, h); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1808 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1809 st->airport_tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1810 st->facilities &= ~FACIL_AIRPORT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1811 |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1812 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1813 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1814 DeleteStationIfEmpty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1815 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1816 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1817 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1818 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1819 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1820 /** Build a buoy. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1821 * @param tile tile where to place the bouy |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6463
diff
changeset
|
1822 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1823 * @param p1 unused |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1824 * @param p2 unused |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1825 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1826 CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1827 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1828 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1829 |
7739
3387a53e113f
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents:
7730
diff
changeset
|
1830 if (!IsWaterTile(tile) || tile == 0) return_cmd_error(STR_304B_SITE_UNSUITABLE); |
6306
0e06c28cf44e
(svn r9178) -Fix (r7573) [FS#679]: Don't allow building docks or buoys under bridges.
maedhros <maedhros@openttd.org>
parents:
6304
diff
changeset
|
1831 if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1832 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1833 /* allocate and initialize new station */ |
6069 | 1834 Station *st = new Station(tile); |
7377
b450ba96bf70
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium <rubidium@openttd.org>
parents:
7376
diff
changeset
|
1835 if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1836 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1837 /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
1838 AutoPtrT<Station> st_auto_delete(st); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1839 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1840 st->town = ClosestTownFromTile(tile, (uint)-1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1841 st->sign.width_1 = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1842 |
7813
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
1843 if (!GenerateStationName(st, tile, STATIONNAMING_BUOY)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1844 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1845 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1846 st->dock_tile = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1847 st->facilities |= FACIL_DOCK; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1848 /* Buoys are marked in the Station struct by this flag. Yes, it is this |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1849 * braindead.. */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1850 st->had_vehicle_of_type |= HVOT_BUOY; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1851 st->owner = OWNER_NONE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1852 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1853 st->build_date = _date; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1854 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1855 MakeBuoy(tile, st->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1856 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1857 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1858 UpdateStationAcceptance(st, false); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1859 RebuildStationLists(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1860 InvalidateWindow(WC_STATION_LIST, st->owner); |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1861 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1862 /* success, so don't delete the new station */ |
7298
b30b64f784db
(svn r10646) -Cleanup: AutoPtrT<>::Release() renamed to Detach()
KUDr <KUDr@openttd.org>
parents:
7272
diff
changeset
|
1863 st_auto_delete.Detach(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1864 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1865 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1866 return CommandCost(_price.build_dock); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1867 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1868 |
8109
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1869 /** |
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1870 * Tests whether the player's vehicles have this station in orders |
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1871 * When player == INVALID_PLAYER, then check all vehicles |
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1872 * @param station station ID |
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1873 * @param player player ID, INVALID_PLAYER to disable the check |
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1874 */ |
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1875 bool HasStationInUse(StationID station, PlayerID player) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1876 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1877 const Vehicle *v; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1878 FOR_ALL_VEHICLES(v) { |
8109
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1879 if (player == INVALID_PLAYER || v->owner == player) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1880 const Order *order; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1881 FOR_VEHICLE_ORDERS(v, order) { |
8109
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1882 if (order->type == OT_GOTO_STATION && order->dest == station) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1883 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1884 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1885 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1886 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1887 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1888 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1889 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1890 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1891 static CommandCost RemoveBuoy(Station *st, uint32 flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1892 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1893 /* XXX: strange stuff */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1894 if (!IsValidPlayer(_current_player)) return_cmd_error(INVALID_STRING_ID); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1895 |
6069 | 1896 TileIndex tile = st->dock_tile; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1897 |
8109
eaab22131e32
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents:
8108
diff
changeset
|
1898 if (HasStationInUse(st->index, INVALID_PLAYER)) return_cmd_error(STR_BUOY_IS_IN_USE); |
7758
013f54f32e5e
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium <rubidium@openttd.org>
parents:
7739
diff
changeset
|
1899 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1900 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1901 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1902 st->dock_tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1903 /* Buoys are marked in the Station struct by this flag. Yes, it is this |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1904 * braindead.. */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1905 st->facilities &= ~FACIL_DOCK; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1906 st->had_vehicle_of_type &= ~HVOT_BUOY; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1907 |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1908 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS); |
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
1909 |
5953
81aac4ab6860
(svn r8619) -Fix: store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. This solves the issue of removing ownership from canal tiles thus making is possible for other players to remove the canal tile.
rubidium <rubidium@openttd.org>
parents:
5914
diff
changeset
|
1910 /* We have to set the water tile's state to the same state as before the |
81aac4ab6860
(svn r8619) -Fix: store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. This solves the issue of removing ownership from canal tiles thus making is possible for other players to remove the canal tile.
rubidium <rubidium@openttd.org>
parents:
5914
diff
changeset
|
1911 * buoy was placed. Otherwise one could plant a buoy on a canal edge, |
81aac4ab6860
(svn r8619) -Fix: store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. This solves the issue of removing ownership from canal tiles thus making is possible for other players to remove the canal tile.
rubidium <rubidium@openttd.org>
parents:
5914
diff
changeset
|
1912 * remove it and flood the land (if the canal edge is at level 0) */ |
8105
f1453e6bb1d8
(svn r11666) -Fix (r11504): when removing buoys, return to water or canal depending on their owner
glx <glx@openttd.org>
parents:
8102
diff
changeset
|
1913 MakeWaterOrCanalDependingOnOwner(tile, GetTileOwner(tile)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1914 MarkTileDirtyByTile(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1915 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1916 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1917 DeleteStationIfEmpty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1918 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1919 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
1920 return CommandCost(_price.remove_truck_station); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1921 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1922 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1923 static const TileIndexDiffC _dock_tileoffs_chkaround[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1924 {-1, 0}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1925 { 0, 0}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1926 { 0, 0}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1927 { 0, -1} |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1928 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1929 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1930 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1931 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1932 /** Build a dock/haven. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1933 * @param tile tile where dock will be built |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6463
diff
changeset
|
1934 * @param flags operation to perform |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1935 * @param p1 (bit 0) - allow docks directly adjacent to other docks. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1936 * @param p2 unused |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1937 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1938 CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1939 { |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
1940 CommandCost cost; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1941 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1942 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1943 |
6069 | 1944 DiagDirection direction; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1945 switch (GetTileSlope(tile, NULL)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1946 case SLOPE_SW: direction = DIAGDIR_NE; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1947 case SLOPE_SE: direction = DIAGDIR_NW; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1948 case SLOPE_NW: direction = DIAGDIR_SE; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1949 case SLOPE_NE: direction = DIAGDIR_SW; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1950 default: return_cmd_error(STR_304B_SITE_UNSUITABLE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1951 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1952 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1953 if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1954 |
6306
0e06c28cf44e
(svn r9178) -Fix (r7573) [FS#679]: Don't allow building docks or buoys under bridges.
maedhros <maedhros@openttd.org>
parents:
6304
diff
changeset
|
1955 if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
0e06c28cf44e
(svn r9178) -Fix (r7573) [FS#679]: Don't allow building docks or buoys under bridges.
maedhros <maedhros@openttd.org>
parents:
6304
diff
changeset
|
1956 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1957 cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1958 if (CmdFailed(cost)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1959 |
6069 | 1960 TileIndex tile_cur = tile + TileOffsByDiagDir(direction); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1961 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1962 if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != SLOPE_FLAT) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1963 return_cmd_error(STR_304B_SITE_UNSUITABLE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1964 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1965 |
6306
0e06c28cf44e
(svn r9178) -Fix (r7573) [FS#679]: Don't allow building docks or buoys under bridges.
maedhros <maedhros@openttd.org>
parents:
6304
diff
changeset
|
1966 if (MayHaveBridgeAbove(tile_cur) && IsBridgeAbove(tile_cur)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
0e06c28cf44e
(svn r9178) -Fix (r7573) [FS#679]: Don't allow building docks or buoys under bridges.
maedhros <maedhros@openttd.org>
parents:
6304
diff
changeset
|
1967 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1968 cost = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1969 if (CmdFailed(cost)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1970 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1971 tile_cur += TileOffsByDiagDir(direction); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1972 if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != SLOPE_FLAT) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1973 return_cmd_error(STR_304B_SITE_UNSUITABLE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1974 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1975 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1976 /* middle */ |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1977 Station *st = NULL; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1978 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1979 if (!_patches.adjacent_stations || !HasBit(p1, 0)) { |
6674
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1980 st = GetStationAround( |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1981 tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]), |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1982 _dock_w_chk[direction], _dock_h_chk[direction], INVALID_STATION); |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1983 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
2a72960b1ec6
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros <maedhros@openttd.org>
parents:
6664
diff
changeset
|
1984 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1985 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1986 /* Find a station close to us */ |
6052 | 1987 if (st == NULL) st = GetClosestStationFromTile(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1988 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1989 /* In case of new station if DC_EXEC is NOT set we still need to create the station |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
1990 * to test if everything is OK. In this case we need to delete it before return. */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
1991 AutoPtrT<Station> st_auto_delete; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
1992 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1993 if (st != NULL) { |
6064 | 1994 if (st->owner != _current_player) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1995 return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1996 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
1997 if (!st->rect.BeforeAddRect(tile, _dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TEST)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1998 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1999 if (st->dock_tile != 0) return_cmd_error(STR_304C_TOO_CLOSE_TO_ANOTHER_DOCK); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2000 } else { |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2001 /* allocate and initialize new station */ |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2002 st = new Station(tile); |
7377
b450ba96bf70
(svn r10746) -Codechange: add a generic superclass for almost all pool items so we do not have to duplicate code for each of the pool item classes and use it for the station and roadstop classes.
rubidium <rubidium@openttd.org>
parents:
7376
diff
changeset
|
2003 if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2004 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2005 /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */ |
5844
a4805866f6fc
(svn r8414) -Codechange: Use own AutoPtrT instead of std::auto_ptr.
KUDr <KUDr@openttd.org>
parents:
5837
diff
changeset
|
2006 st_auto_delete = st; |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2007 |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2008 Town *t = st->town = ClosestTownFromTile(tile, (uint)-1); |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2009 |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2010 if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
2011 SetBit(t->have_ratings, _current_player); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2012 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2013 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2014 st->sign.width_1 = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2015 |
7813
abee2c8e51ed
(svn r11363) -Codechange: Remove some magical numbers
belugas <belugas@openttd.org>
parents:
7795
diff
changeset
|
2016 if (!GenerateStationName(st, tile, STATIONNAMING_DOCK)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2017 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2018 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2019 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2020 st->dock_tile = tile; |
5721
06a31b083e84
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr <KUDr@openttd.org>
parents:
5718
diff
changeset
|
2021 st->AddFacility(FACIL_DOCK, tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2022 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
2023 st->rect.BeforeAddRect(tile, _dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TRY); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2024 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2025 MakeDock(tile, st->owner, st->index, direction); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2026 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2027 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2028 UpdateStationAcceptance(st, false); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2029 RebuildStationLists(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2030 InvalidateWindow(WC_STATION_LIST, st->owner); |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
2031 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2032 /* success, so don't delete the new station */ |
7298
b30b64f784db
(svn r10646) -Cleanup: AutoPtrT<>::Release() renamed to Detach()
KUDr <KUDr@openttd.org>
parents:
7272
diff
changeset
|
2033 st_auto_delete.Detach(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2034 } |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
2035 return CommandCost(_price.build_dock); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2036 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2037 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
2038 static CommandCost RemoveDock(Station *st, uint32 flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2039 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2040 if (!CheckOwnership(st->owner)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2041 |
6069 | 2042 TileIndex tile1 = st->dock_tile; |
2043 TileIndex tile2 = tile1 + TileOffsByDiagDir(GetDockDirection(tile1)); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2044 |
7758
013f54f32e5e
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium <rubidium@openttd.org>
parents:
7739
diff
changeset
|
2045 if (!EnsureNoVehicleOnGround(tile1)) return CMD_ERROR; |
013f54f32e5e
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium <rubidium@openttd.org>
parents:
7739
diff
changeset
|
2046 if (!EnsureNoVehicleOnGround(tile2)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2047 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2048 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2049 DoClearSquare(tile1); |
7948
4044e2de8086
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium <rubidium@openttd.org>
parents:
7931
diff
changeset
|
2050 MakeWaterOrCanalDependingOnSurroundings(tile2, st->owner); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2051 |
5676
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
2052 st->rect.AfterRemoveTile(st, tile1); |
c9994ba3a762
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr <KUDr@openttd.org>
parents:
5668
diff
changeset
|
2053 st->rect.AfterRemoveTile(st, tile2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2054 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2055 MarkTileDirtyByTile(tile2); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2056 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2057 st->dock_tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2058 st->facilities &= ~FACIL_DOCK; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2059 |
8017
67fa2241acb1
(svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed
smatz <smatz@openttd.org>
parents:
8016
diff
changeset
|
2060 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2061 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2062 DeleteStationIfEmpty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2063 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2064 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
2065 return CommandCost(_price.remove_dock); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2066 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2067 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2068 #include "table/station_land.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2069 |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2070 const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2071 { |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2072 return &_station_display_datas[st][gfx]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2073 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2074 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2075 static void DrawTile_Station(TileInfo *ti) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2076 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2077 const DrawTileSprites *t = NULL; |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2078 RailType railtype; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2079 RoadTypes roadtypes; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2080 if (IsRailwayStation(ti->tile)) { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2081 railtype = GetRailType(ti->tile); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2082 roadtypes = ROADTYPES_NONE; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2083 } else { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2084 roadtypes = GetRoadTypes(ti->tile); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2085 railtype = RAILTYPE_BEGIN; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2086 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2087 const RailtypeInfo *rti = GetRailTypeInfo(railtype); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2088 uint32 relocation = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2089 const Station *st = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2090 const StationSpec *statspec = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2091 PlayerID owner = GetTileOwner(ti->tile); |
6069 | 2092 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5667
diff
changeset
|
2093 SpriteID palette; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2094 if (IsValidPlayer(owner)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2095 palette = PLAYER_SPRITE_COLOR(owner); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2096 } else { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2097 /* Some stations are not owner by a player, namely oil rigs */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2098 palette = PALETTE_TO_GREY; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2099 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2100 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2101 /* don't show foundation for docks */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2102 if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile)) |
7335
0090d1c6b978
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7333
diff
changeset
|
2103 DrawFoundation(ti, FOUNDATION_LEVELED); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2104 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2105 if (IsCustomStationSpecIndex(ti->tile)) { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2106 /* look for customization */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2107 st = GetStationByTile(ti->tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2108 statspec = st->speclist[GetCustomStationSpecIndex(ti->tile)].spec; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2109 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2110 //debug("Cust-o-mized %p", statspec); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2111 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2112 if (statspec != NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2113 uint tile = GetStationGfx(ti->tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2114 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2115 relocation = GetCustomStationRelocation(statspec, st, ti->tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2116 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2117 if (HasBit(statspec->callbackmask, CBM_STATION_SPRITE_LAYOUT)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2118 uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2119 if (callback != CALLBACK_FAILED) tile = (callback & ~1) + GetRailStationAxis(ti->tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2120 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2121 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2122 /* Ensure the chosen tile layout is valid for this custom station */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2123 if (statspec->renderdata != NULL) { |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
2124 t = &statspec->renderdata[tile < statspec->tiles ? tile : (uint)GetRailStationAxis(ti->tile)]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2125 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2126 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2127 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2128 |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2129 if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationType(ti->tile)][GetStationGfx(ti->tile)]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2130 |
6069 | 2131 SpriteID image = t->ground_sprite; |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2132 if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2133 image += GetCustomStationGroundRelocation(statspec, st, ti->tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2134 image += rti->custom_ground_offset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2135 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2136 image += rti->total_offset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2137 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2138 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2139 /* station_land array has been increased from 82 elements to 114 |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2140 * but this is something else. If AI builds station with 114 it looks all weird */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2141 DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2142 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2143 if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2144 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2145 if (HasBit(roadtypes, ROADTYPE_TRAM)) { |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2146 Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y; |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2147 DrawGroundSprite((HasBit(roadtypes, ROADTYPE_ROAD) ? SPR_TRAMWAY_OVERLAY : SPR_TRAMWAY_TRAM) + (axis ^ 1), PAL_NONE); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2148 DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2149 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2150 |
7739
3387a53e113f
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents:
7730
diff
changeset
|
2151 if (IsCanalBuoyTile(ti->tile)) DrawCanalWater(ti->tile); |
5963
9d9c1c80f583
(svn r8635) -Fix: draw canal edges under buoys that are in a canal.
rubidium <rubidium@openttd.org>
parents:
5953
diff
changeset
|
2152 |
6069 | 2153 const DrawTileSeqStruct *dtss; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2154 foreach_draw_tile_seq(dtss, t->seq) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2155 image = dtss->image; |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2156 if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2157 image += rti->total_offset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2158 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2159 image += relocation; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2160 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2161 |
6069 | 2162 SpriteID pal; |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2163 if (!IsTransparencySet(TO_BUILDINGS) && HasBit(image, PALETTE_MODIFIER_COLOR)) { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5667
diff
changeset
|
2164 pal = palette; |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5667
diff
changeset
|
2165 } else { |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5667
diff
changeset
|
2166 pal = dtss->pal; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2167 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2168 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2169 if ((byte)dtss->delta_z != 0x80) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2170 AddSortableSpriteToDraw( |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5667
diff
changeset
|
2171 image, pal, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2172 ti->x + dtss->delta_x, ti->y + dtss->delta_y, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2173 dtss->size_x, dtss->size_y, |
7333
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7320
diff
changeset
|
2174 dtss->size_z, ti->z + dtss->delta_z, |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7826
diff
changeset
|
2175 IsTransparencySet(TO_BUILDINGS) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2176 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2177 } else { |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7826
diff
changeset
|
2178 AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, IsTransparencySet(TO_BUILDINGS)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2179 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2180 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2181 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2182 |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2183 void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2184 { |
6069 | 2185 const RailtypeInfo *rti = GetRailTypeInfo(railtype); |
2186 SpriteID pal = PLAYER_SPRITE_COLOR(_local_player); | |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2187 const DrawTileSprites *t = &_station_display_datas[st][image]; |
6069 | 2188 |
2189 SpriteID img = t->ground_sprite; | |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2190 DrawSprite(img + rti->total_offset, HasBit(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y); |
6069 | 2191 |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2192 if (roadtype == ROADTYPE_TRAM) { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2193 DrawSprite(SPR_TRAMWAY_TRAM + (t->ground_sprite == SPR_ROAD_PAVED_STRAIGHT_X ? 1 : 0), PAL_NONE, x, y); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2194 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
2195 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2196 const DrawTileSeqStruct *dtss; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2197 foreach_draw_tile_seq(dtss, t->seq) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2198 Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5667
diff
changeset
|
2199 DrawSprite(dtss->image + rti->total_offset, pal, x + pt.x, y + pt.y); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2200 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2201 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2202 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2203 static uint GetSlopeZ_Station(TileIndex tile, uint x, uint y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2204 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2205 return GetTileMaxZ(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2206 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2207 |
7335
0090d1c6b978
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7333
diff
changeset
|
2208 static Foundation GetFoundation_Station(TileIndex tile, Slope tileh) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2209 { |
7335
0090d1c6b978
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7333
diff
changeset
|
2210 return FlatteningFoundation(tileh); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2211 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2212 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2213 static void GetAcceptedCargo_Station(TileIndex tile, AcceptedCargo ac) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2214 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2215 /* not used */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2216 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2217 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2218 static void GetTileDesc_Station(TileIndex tile, TileDesc *td) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2219 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2220 td->owner = GetTileOwner(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2221 td->build_date = GetStationByTile(tile)->build_date; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2222 |
6069 | 2223 StringID str; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2224 switch (GetStationType(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2225 default: NOT_REACHED(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2226 case STATION_RAIL: str = STR_305E_RAILROAD_STATION; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2227 case STATION_AIRPORT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2228 str = (IsHangar(tile) ? STR_305F_AIRCRAFT_HANGAR : STR_3060_AIRPORT); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2229 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2230 case STATION_TRUCK: str = STR_3061_TRUCK_LOADING_AREA; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2231 case STATION_BUS: str = STR_3062_BUS_STATION; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2232 case STATION_OILRIG: str = STR_4807_OIL_RIG; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2233 case STATION_DOCK: str = STR_3063_SHIP_DOCK; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2234 case STATION_BUOY: str = STR_3069_BUOY; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2235 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2236 td->str = str; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2237 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2238 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2239 |
6683
6984c0dbbb07
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium <rubidium@openttd.org>
parents:
6677
diff
changeset
|
2240 static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode, uint sub_mode) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2241 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2242 switch (mode) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2243 case TRANSPORT_RAIL: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2244 if (IsRailwayStation(tile) && !IsStationTileBlocked(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2245 return TrackToTrackBits(GetRailStationTrack(tile)) * 0x101; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2246 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2247 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2248 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2249 case TRANSPORT_WATER: |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2250 /* buoy is coded as a station, it is always on open water */ |
5914
cfb5c65a5119
(svn r8540) -Fix[YAPF]: Assert when buoy is placed on NE or NW map edge (Dan)
KUDr <KUDr@openttd.org>
parents:
5913
diff
changeset
|
2251 if (IsBuoy(tile)) { |
cfb5c65a5119
(svn r8540) -Fix[YAPF]: Assert when buoy is placed on NE or NW map edge (Dan)
KUDr <KUDr@openttd.org>
parents:
5913
diff
changeset
|
2252 TrackBits ts = TRACK_BIT_ALL; |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2253 /* remove tracks that connect NE map edge */ |
5914
cfb5c65a5119
(svn r8540) -Fix[YAPF]: Assert when buoy is placed on NE or NW map edge (Dan)
KUDr <KUDr@openttd.org>
parents:
5913
diff
changeset
|
2254 if (TileX(tile) == 0) ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT); |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2255 /* remove tracks that connect NW map edge */ |
5914
cfb5c65a5119
(svn r8540) -Fix[YAPF]: Assert when buoy is placed on NE or NW map edge (Dan)
KUDr <KUDr@openttd.org>
parents:
5913
diff
changeset
|
2256 if (TileY(tile) == 0) ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER); |
cfb5c65a5119
(svn r8540) -Fix[YAPF]: Assert when buoy is placed on NE or NW map edge (Dan)
KUDr <KUDr@openttd.org>
parents:
5913
diff
changeset
|
2257 return uint32(ts) * 0x101; |
cfb5c65a5119
(svn r8540) -Fix[YAPF]: Assert when buoy is placed on NE or NW map edge (Dan)
KUDr <KUDr@openttd.org>
parents:
5913
diff
changeset
|
2258 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2259 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2260 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2261 case TRANSPORT_ROAD: |
6683
6984c0dbbb07
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium <rubidium@openttd.org>
parents:
6677
diff
changeset
|
2262 if ((GetRoadTypes(tile) & sub_mode) != 0 && IsRoadStopTile(tile)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2263 return AxisToTrackBits(DiagDirToAxis(GetRoadStopDir(tile))) * 0x101; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2264 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2265 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2266 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2267 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2268 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2269 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2270 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2271 return 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2272 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2273 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2274 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2275 static void TileLoop_Station(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2276 { |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2277 /* FIXME -- GetTileTrackStatus_Station -> animated stationtiles |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2278 * hardcoded.....not good */ |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2279 switch (GetStationType(tile)) { |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2280 case STATION_AIRPORT: |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2281 switch (GetStationGfx(tile)) { |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2282 case GFX_RADAR_LARGE_FIRST: |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2283 case GFX_WINDSACK_FIRST : // for small airport |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2284 case GFX_RADAR_INTERNATIONAL_FIRST: |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2285 case GFX_RADAR_METROPOLITAN_FIRST: |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2286 case GFX_RADAR_DISTRICTWE_FIRST: // radar district W-E airport |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2287 case GFX_WINDSACK_INTERCON_FIRST : // for intercontinental airport |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2288 AddAnimatedTile(tile); |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2289 break; |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2290 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2291 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2292 |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2293 case STATION_OILRIG: //(station part) |
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7252
diff
changeset
|
2294 case STATION_BUOY: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2295 TileLoop_Water(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2296 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2297 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2298 default: break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2299 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2300 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2301 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2302 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2303 static void AnimateTile_Station(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2304 { |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
2305 struct AnimData { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2306 StationGfx from; // first sprite |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2307 StationGfx to; // last sprite |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2308 byte delay; |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
2309 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2310 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2311 static const AnimData data[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2312 { GFX_RADAR_LARGE_FIRST, GFX_RADAR_LARGE_LAST, 3 }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2313 { GFX_WINDSACK_FIRST, GFX_WINDSACK_LAST, 1 }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2314 { GFX_RADAR_INTERNATIONAL_FIRST, GFX_RADAR_INTERNATIONAL_LAST, 3 }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2315 { GFX_RADAR_METROPOLITAN_FIRST, GFX_RADAR_METROPOLITAN_LAST, 3 }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2316 { GFX_RADAR_DISTRICTWE_FIRST, GFX_RADAR_DISTRICTWE_LAST, 3 }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2317 { GFX_WINDSACK_INTERCON_FIRST, GFX_WINDSACK_INTERCON_LAST, 1 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2318 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2319 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2320 StationGfx gfx = GetStationGfx(tile); |
6069 | 2321 |
2322 for (const AnimData *i = data; i != endof(data); i++) { | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2323 if (i->from <= gfx && gfx <= i->to) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2324 if ((_tick_counter & i->delay) == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2325 SetStationGfx(tile, gfx < i->to ? gfx + 1 : i->from); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2326 MarkTileDirtyByTile(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2327 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2328 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2329 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2330 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2331 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2332 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2333 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2334 static void ClickTile_Station(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2335 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2336 if (IsHangar(tile)) { |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6248
diff
changeset
|
2337 ShowDepotWindow(tile, VEH_AIRCRAFT); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2338 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2339 ShowStationViewWindow(GetStationIndex(tile)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2340 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2341 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2342 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2343 static const byte _enter_station_speedtable[12] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2344 215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2345 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2346 |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
2347 static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2348 { |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6248
diff
changeset
|
2349 if (v->type == VEH_TRAIN) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2350 if (IsRailwayStation(tile) && IsFrontEngine(v) && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2351 !IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2352 StationID station_id = GetStationIndex(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2353 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2354 if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2355 (v->current_order.type == OT_GOTO_STATION && v->current_order.dest == station_id)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2356 if (!(_patches.new_nonstop && v->current_order.flags & OF_NON_STOP) && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2357 v->current_order.type != OT_LEAVESTATION && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2358 v->last_station_visited != station_id) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2359 DiagDirection dir = DirToDiagDir(v->direction); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2360 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2361 x &= 0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2362 y &= 0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2363 |
6106 | 2364 if (DiagDirToAxis(dir) != AXIS_X) Swap(x, y); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2365 if (y == TILE_SIZE / 2) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2366 if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x; |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
2367 if (x == 12) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); /* enter station */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2368 if (x < 12) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2369 uint16 spd; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2370 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2371 v->vehstatus |= VS_TRAIN_SLOWING; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2372 spd = _enter_station_speedtable[x]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2373 if (spd < v->cur_speed) v->cur_speed = spd; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2374 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2375 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2376 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2377 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2378 } |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6248
diff
changeset
|
2379 } else if (v->type == VEH_ROAD) { |
6076
0540ac4a12e6
(svn r8809) -Fix (r8715): accidentally removed a part of an expression.
rubidium <rubidium@openttd.org>
parents:
6070
diff
changeset
|
2380 if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) { |
6857
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6823
diff
changeset
|
2381 if (IsRoadStop(tile) && IsRoadVehFront(v)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2382 /* Attempt to allocate a parking bay in a road stop */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2383 RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2384 |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2385 if (IsDriveThroughStopTile(tile)) { |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2386 /* Vehicles entering a drive-through stop from the 'normal' side use first bay (bay 0). */ |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2387 byte side = ((DirToDiagDir(v->direction) == ReverseDiagDir(GetRoadStopDir(tile))) == (v->u.road.overtaking == 0)) ? 0 : 1; |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2388 |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2389 if (!rs->IsFreeBay(side)) return VETSB_CANNOT_ENTER; |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2390 |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2391 /* Check if the vehicle is stopping at this road stop */ |
6329
34db8eef99ef
(svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138 <peter1138@openttd.org>
parents:
6306
diff
changeset
|
2392 if (GetRoadStopType(tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK) && |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2393 v->current_order.dest == GetStationIndex(tile)) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
2394 SetBit(v->u.road.state, RVS_IS_STOPPING); |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2395 rs->AllocateDriveThroughBay(side); |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2396 } |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2397 |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2398 /* Indicate if vehicle is using second bay. */ |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
2399 if (side == 1) SetBit(v->u.road.state, RVS_USING_SECOND_BAY); |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2400 /* Indicate a drive-through stop */ |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
2401 SetBit(v->u.road.state, RVS_IN_DT_ROAD_STOP); |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2402 return VETSB_CONTINUE; |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2403 } |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2404 |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2405 /* For normal (non drive-through) road stops */ |
7469
8dba8e21984f
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium <rubidium@openttd.org>
parents:
7379
diff
changeset
|
2406 /* Check if station is busy or if there are no free bays or whether it is a articulated vehicle. */ |
8dba8e21984f
(svn r10974) -Fix [FS#1144, FS#1155]: road vehicles that could not (properly) use a road stop still tried to go to that road stop.
rubidium <rubidium@openttd.org>
parents:
7379
diff
changeset
|
2407 if (rs->IsEntranceBusy() || !rs->HasFreeBay() || RoadVehHasArticPart(v)) return VETSB_CANNOT_ENTER; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2408 |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
2409 SetBit(v->u.road.state, RVS_IN_ROAD_STOP); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2410 |
5990
3ccf6528ac1f
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium <rubidium@openttd.org>
parents:
5963
diff
changeset
|
2411 /* Allocate a bay and update the road state */ |
3ccf6528ac1f
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium <rubidium@openttd.org>
parents:
5963
diff
changeset
|
2412 uint bay_nr = rs->AllocateBay(); |
6000
2f43f0d4d589
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium <rubidium@openttd.org>
parents:
5998
diff
changeset
|
2413 SB(v->u.road.state, RVS_USING_SECOND_BAY, 1, bay_nr); |
5990
3ccf6528ac1f
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium <rubidium@openttd.org>
parents:
5963
diff
changeset
|
2414 |
3ccf6528ac1f
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium <rubidium@openttd.org>
parents:
5963
diff
changeset
|
2415 /* Mark the station entrace as busy */ |
3ccf6528ac1f
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium <rubidium@openttd.org>
parents:
5963
diff
changeset
|
2416 rs->SetEntranceBusy(true); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2417 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2418 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2419 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2420 |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5990
diff
changeset
|
2421 return VETSB_CONTINUE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2422 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2423 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2424 /* this function is called for one station each tick */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2425 static void StationHandleBigTick(Station *st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2426 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2427 UpdateStationAcceptance(st, true); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2428 |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2429 if (st->facilities == 0 && ++st->delete_ctr >= 8) delete st; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2430 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2431 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2432 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2433 static inline void byte_inc_sat(byte *p) { byte b = *p + 1; if (b != 0) *p = b; } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2434 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2435 static void UpdateStationRating(Station *st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2436 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2437 bool waiting_changed = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2438 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2439 byte_inc_sat(&st->time_since_load); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2440 byte_inc_sat(&st->time_since_unload); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2441 |
6069 | 2442 GoodsEntry *ge = st->goods; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2443 do { |
6261
a2ab35efe1ab
(svn r9070) -Fix [FS#404]: if bribe failed and you didn't pick up cargo yet, you wouldn't ever be able to do so for a given station
truelight <truelight@openttd.org>
parents:
6259
diff
changeset
|
2444 /* Slowly increase the rating back to his original level in the case we |
a2ab35efe1ab
(svn r9070) -Fix [FS#404]: if bribe failed and you didn't pick up cargo yet, you wouldn't ever be able to do so for a given station
truelight <truelight@openttd.org>
parents:
6259
diff
changeset
|
2445 * didn't deliver cargo yet to this station. This happens when a bribe |
a2ab35efe1ab
(svn r9070) -Fix [FS#404]: if bribe failed and you didn't pick up cargo yet, you wouldn't ever be able to do so for a given station
truelight <truelight@openttd.org>
parents:
6259
diff
changeset
|
2446 * failed while you didn't moved that cargo yet to a station. */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2447 if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP) && ge->rating < INITIAL_STATION_RATING) { |
6261
a2ab35efe1ab
(svn r9070) -Fix [FS#404]: if bribe failed and you didn't pick up cargo yet, you wouldn't ever be able to do so for a given station
truelight <truelight@openttd.org>
parents:
6259
diff
changeset
|
2448 ge->rating++; |
7474
7b35fd1cc99d
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium <rubidium@openttd.org>
parents:
7469
diff
changeset
|
2449 } |
7b35fd1cc99d
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium <rubidium@openttd.org>
parents:
7469
diff
changeset
|
2450 |
6261
a2ab35efe1ab
(svn r9070) -Fix [FS#404]: if bribe failed and you didn't pick up cargo yet, you wouldn't ever be able to do so for a given station
truelight <truelight@openttd.org>
parents:
6259
diff
changeset
|
2451 /* Only change the rating if we are moving this cargo */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2452 if (HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2453 byte_inc_sat(&ge->days_since_pickup); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2454 |
6069 | 2455 int rating = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2456 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2457 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2458 int b = ge->last_speed; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2459 if ((b-=85) >= 0) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2460 rating += b >> 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2461 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2462 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2463 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2464 byte age = ge->last_age; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2465 (age >= 3) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2466 (rating += 10, age >= 2) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2467 (rating += 10, age >= 1) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2468 (rating += 13, true); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2469 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2470 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2471 if (IsValidPlayer(st->owner) && HasBit(st->town->statues, st->owner)) rating += 26; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2472 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2473 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2474 byte days = ge->days_since_pickup; |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2475 if (st->last_vehicle_type == VEH_SHIP) days >>= 2; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2476 (days > 21) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2477 (rating += 25, days > 12) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2478 (rating += 25, days > 6) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2479 (rating += 45, days > 3) || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2480 (rating += 35, true); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2481 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2482 |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2483 uint waiting = ge->cargo.Count(); |
6069 | 2484 (rating -= 90, waiting > 1500) || |
2485 (rating += 55, waiting > 1000) || | |
2486 (rating += 35, waiting > 600) || | |
2487 (rating += 10, waiting > 300) || | |
2488 (rating += 20, waiting > 100) || | |
2489 (rating += 10, true); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2490 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2491 { |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
2492 int or_ = ge->rating; // old rating |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2493 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2494 /* only modify rating in steps of -2, -1, 0, 1 or 2 */ |
7922
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7891
diff
changeset
|
2495 ge->rating = rating = or_ + Clamp(Clamp(rating, 0, 255) - or_, -2, 2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2496 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2497 /* if rating is <= 64 and more than 200 items waiting, |
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2498 * remove some random amount of goods from the station */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2499 if (rating <= 64 && waiting >= 200) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2500 int dec = Random() & 0x1F; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2501 if (waiting < 400) dec &= 7; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2502 waiting -= dec + 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2503 waiting_changed = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2504 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2505 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
2506 /* if rating is <= 127 and there are any items waiting, maybe remove some goods. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2507 if (rating <= 127 && waiting != 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2508 uint32 r = Random(); |
5660
8ba2b1e4ef83
(svn r8120) -Fix (r8055): Station cargo waiting value clamp should be signed not unsigned. This resulted in cargo magically appearing...
peter1138 <peter1138@openttd.org>
parents:
5609
diff
changeset
|
2509 if (rating <= (int)GB(r, 0, 7)) { |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2510 /* Need to have int, otherwise it will just overflow etc. */ |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2511 waiting = max((int)waiting - (int)GB(r, 8, 2) - 1, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2512 waiting_changed = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2513 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2514 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2515 |
7252
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2516 /* At some point we really must cap the cargo. Previously this |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2517 * was a strict 4095, but now we'll have a less strict, but |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2518 * increasingly agressive truncation of the amount of cargo. */ |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2519 static const uint WAITING_CARGO_THRESHOLD = 1 << 12; |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2520 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6; |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2521 static const uint MAX_WAITING_CARGO = 1 << 15; |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2522 |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2523 if (waiting > WAITING_CARGO_THRESHOLD) { |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2524 uint difference = waiting - WAITING_CARGO_THRESHOLD; |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2525 waiting -= (difference / WAITING_CARGO_CUT_FACTOR); |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2526 |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2527 waiting = min(waiting, MAX_WAITING_CARGO); |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2528 waiting_changed = true; |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2529 } |
feb4100735d9
(svn r10555) -Codechange/Fix: add a soft limit of 4096 "entities" in a station's waiting queue and a hard limit of 32768 so (malicious) people cannot cause a "denial of service" attack by filling cargo lists.
rubidium <rubidium@openttd.org>
parents:
7097
diff
changeset
|
2530 |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2531 if (waiting_changed) ge->cargo.Truncate(waiting); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2532 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2533 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2534 } while (++ge != endof(st->goods)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2535 |
6069 | 2536 StationID index = st->index; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2537 if (waiting_changed) { |
8016
f60addd19e1a
(svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents:
8015
diff
changeset
|
2538 InvalidateWindow(WC_STATION_VIEW, index); // update whole window |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2539 } else { |
8016
f60addd19e1a
(svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents:
8015
diff
changeset
|
2540 InvalidateWindowWidget(WC_STATION_VIEW, index, SVW_RATINGLIST); // update only ratings list |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2541 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2542 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2543 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2544 /* called for every station each tick */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2545 static void StationHandleSmallTick(Station *st) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2546 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2547 if (st->facilities == 0) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2548 |
6069 | 2549 byte b = st->delete_ctr + 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2550 if (b >= 185) b = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2551 st->delete_ctr = b; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2552 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2553 if (b == 0) UpdateStationRating(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2554 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2555 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
2556 void OnTick_Station() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2557 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2558 if (_game_mode == GM_EDITOR) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2559 |
6069 | 2560 uint i = _station_tick_ctr; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2561 if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2562 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2563 if (IsValidStationID(i)) StationHandleBigTick(GetStation(i)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2564 |
6069 | 2565 Station *st; |
2566 FOR_ALL_STATIONS(st) StationHandleSmallTick(st); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2567 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2568 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
2569 void StationMonthlyLoop() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2570 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2571 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2572 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2573 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2574 void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2575 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2576 Station *st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2577 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2578 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2579 if (st->owner == owner && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2580 DistanceManhattan(tile, st->xy) <= radius) { |
6350
8132258640be
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents:
6329
diff
changeset
|
2581 for (CargoID i = 0; i < NUM_CARGO; i++) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2582 GoodsEntry* ge = &st->goods[i]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2583 |
7474
7b35fd1cc99d
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium <rubidium@openttd.org>
parents:
7469
diff
changeset
|
2584 if (ge->acceptance_pickup != 0) { |
7922
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7891
diff
changeset
|
2585 ge->rating = Clamp(ge->rating + amount, 0, 255); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2586 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2587 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2588 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2589 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2590 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2591 |
6350
8132258640be
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents:
6329
diff
changeset
|
2592 static void UpdateStationWaiting(Station *st, CargoID type, uint amount) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2593 { |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2594 st->goods[type].cargo.Append(new CargoPacket(st->index, amount)); |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
2595 SetBit(st->goods[type].acceptance_pickup, GoodsEntry::PICKUP); |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2596 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2597 InvalidateWindow(WC_STATION_VIEW, st->index); |
6823
afa9c0a81fda
(svn r10062) -Codechange: Don't redraw all station tiles when cargo is added or removed if the station has no custom graphics.
peter1138 <peter1138@openttd.org>
parents:
6761
diff
changeset
|
2598 st->MarkTilesDirty(true); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2599 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2600 |
7097
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2601 static bool IsUniqueStationName(const char *name) |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2602 { |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2603 const Station *st; |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2604 char buf[512]; |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2605 |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2606 FOR_ALL_STATIONS(st) { |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2607 SetDParam(0, st->index); |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2608 GetString(buf, STR_STATION, lastof(buf)); |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2609 if (strcmp(buf, name) == 0) return false; |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2610 } |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2611 |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2612 return true; |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2613 } |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2614 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2615 /** Rename a station |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2616 * @param tile unused |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6463
diff
changeset
|
2617 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2618 * @param p1 station ID that is to be renamed |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2619 * @param p2 unused |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2620 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
2621 CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2622 { |
7097
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2623 if (!IsValidStationID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR; |
6069 | 2624 Station *st = GetStation(p1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2625 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2626 if (!CheckOwnership(st->owner)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2627 |
7097
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2628 if (!IsUniqueStationName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2629 |
5c2889ace3ac
(svn r10364) -Fix [FS#706]: checking for duplicate custom names was inconsistent, and tested all 'namespaces'. now only check names of the same type.
peter1138 <peter1138@openttd.org>
parents:
7067
diff
changeset
|
2630 StringID str = AllocateName(_cmd_text, 6); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2631 if (str == 0) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2632 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2633 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2634 StringID old_str = st->string_id; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2635 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2636 st->string_id = str; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2637 UpdateStationVirtCoord(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2638 DeleteName(old_str); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2639 ResortStationLists(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2640 MarkWholeScreenDirty(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2641 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2642 DeleteName(str); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2643 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2644 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
2645 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2646 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2647 |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2648 /** |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2649 * Find all (non-buoy) stations around an industry tile |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2650 * |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2651 * @param tile: Center tile to search from |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2652 * @param w: Width of the center |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2653 * @param h: Height of the center |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2654 * |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2655 * @return: Set of found stations |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2656 */ |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2657 StationSet FindStationsAroundIndustryTile(TileIndex tile, int w, int h) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2658 { |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2659 StationSet station_set; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2660 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2661 int w_prod; // width and height of the "producer" of the cargo |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2662 int h_prod; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2663 int max_rad; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2664 if (_patches.modified_catchment) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2665 w_prod = w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2666 h_prod = h; |
7498
1381772864e1
(svn r11013) -Fix [FS#1171]: MoveGoodsToStation's search area is too small as it assumed a lower maximum catchment area than the real maximum catchment area. Based on a patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents:
7494
diff
changeset
|
2667 w += 2 * MAX_CATCHMENT; |
1381772864e1
(svn r11013) -Fix [FS#1171]: MoveGoodsToStation's search area is too small as it assumed a lower maximum catchment area than the real maximum catchment area. Based on a patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents:
7494
diff
changeset
|
2668 h += 2 * MAX_CATCHMENT; |
1381772864e1
(svn r11013) -Fix [FS#1171]: MoveGoodsToStation's search area is too small as it assumed a lower maximum catchment area than the real maximum catchment area. Based on a patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents:
7494
diff
changeset
|
2669 max_rad = MAX_CATCHMENT; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2670 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2671 w_prod = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2672 h_prod = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2673 w += 8; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2674 h += 8; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2675 max_rad = 4; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2676 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2677 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2678 BEGIN_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2679 cur_tile = TILE_MASK(cur_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2680 if (!IsTileType(cur_tile, MP_STATION)) continue; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2681 |
6069 | 2682 Station *st = GetStationByTile(cur_tile); |
2683 | |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2684 if (st->IsBuoy()) continue; // bouys don't accept cargo |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2685 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2686 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2687 if (_patches.modified_catchment) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2688 /* min and max coordinates of the producer relative */ |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2689 const int x_min_prod = max_rad + 1; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2690 const int x_max_prod = max_rad + w_prod; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2691 const int y_min_prod = max_rad + 1; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2692 const int y_max_prod = max_rad + h_prod; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2693 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2694 int rad = FindCatchmentRadius(st); |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2695 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2696 int x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur); |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2697 if (w_cur < x_min_prod) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2698 x_dist = x_min_prod - w_cur; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2699 } else if (w_cur > x_max_prod) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2700 x_dist = w_cur - x_max_prod; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2701 } |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2702 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2703 if (x_dist > rad) continue; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2704 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2705 int y_dist = min(h_cur - y_min_prod, y_max_prod - h_cur); |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2706 if (h_cur < y_min_prod) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2707 y_dist = y_min_prod - h_cur; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2708 } else if (h_cur > y_max_prod) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2709 y_dist = h_cur - y_max_prod; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2710 } |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2711 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2712 if (y_dist > rad) continue; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2713 } |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2714 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2715 /* Insert the station in the set. This will fail if it has |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2716 * already been added. |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2717 */ |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2718 station_set.insert(st); |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2719 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2720 END_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2721 |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2722 return station_set; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2723 } |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2724 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2725 uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount) |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2726 { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2727 Station *st1 = NULL; // Station with best rating |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2728 Station *st2 = NULL; // Second best station |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2729 uint best_rating1 = 0; // rating of st1 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2730 uint best_rating2 = 0; // rating of st2 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2731 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2732 StationSet all_stations = FindStationsAroundIndustryTile(tile, w, h); |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2733 for (StationSet::iterator st_iter = all_stations.begin(); st_iter != all_stations.end(); ++st_iter) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2734 Station *st = *st_iter; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2735 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2736 /* Is the station reserved exclusively for somebody else? */ |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2737 if (st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2738 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2739 if (st->goods[type].rating == 0) continue; // Lowest possible rating, better not to give cargo anymore |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2740 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2741 if (_patches.selectgoods && st->goods[type].last_speed == 0) continue; // Selectively servicing stations, and not this one |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2742 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2743 if (IsCargoInClass(type, CC_PASSENGERS)) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2744 if (st->facilities == FACIL_TRUCK_STOP) continue; // passengers are never served by just a truck stop |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2745 } else { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2746 if (st->facilities == FACIL_BUS_STOP) continue; // non-passengers are never served by just a bus stop |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2747 } |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2748 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2749 /* This station can be used, add it to st1/st2 */ |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2750 if (st1 == NULL || st->goods[type].rating >= best_rating1) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2751 st2 = st1; best_rating2 = best_rating1; st1 = st; best_rating1 = st->goods[type].rating; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2752 } else if (st2 == NULL || st->goods[type].rating >= best_rating2) { |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2753 st2 = st; best_rating2 = st->goods[type].rating; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2754 } |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2755 } |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2756 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2757 /* no stations around at all? */ |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2758 if (st1 == NULL) return 0; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2759 |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2760 if (st2 == NULL) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2761 /* only one station around */ |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2762 uint moved = amount * best_rating1 / 256 + 1; |
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2763 UpdateStationWaiting(st1, type, moved); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2764 return moved; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2765 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2766 |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2767 /* several stations around, the best two (highest rating) are in st1 and st2 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2768 assert(st1 != NULL); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2769 assert(st2 != NULL); |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2770 assert(best_rating1 != 0 || best_rating2 != 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2771 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2772 /* the 2nd highest one gets a penalty */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2773 best_rating2 >>= 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2774 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2775 /* amount given to station 1 */ |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2776 uint t = (best_rating1 * (amount + 1)) / (best_rating1 + best_rating2); |
6069 | 2777 |
2778 uint moved = 0; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2779 if (t != 0) { |
7891
202a48f69a30
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
7864
diff
changeset
|
2780 moved = t * best_rating1 / 256 + 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2781 amount -= t; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2782 UpdateStationWaiting(st1, type, moved); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2783 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2784 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2785 if (amount != 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2786 amount = amount * best_rating2 / 256 + 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2787 moved += amount; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2788 UpdateStationWaiting(st2, type, amount); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2789 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2790 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2791 return moved; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2792 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2793 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2794 void BuildOilRig(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2795 { |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2796 Station *st = new Station(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2797 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2798 if (st == NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2799 DEBUG(misc, 0, "Can't allocate station for oilrig at 0x%X, reverting to oilrig only", tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2800 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2801 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2802 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2803 st->town = ClosestTownFromTile(tile, (uint)-1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2804 st->sign.width_1 = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2805 |
7826
4ea8c684b2d1
(svn r11376) -Fix: fill the town a oil rig is associated with before creating the name, otherwise every oil rig will become "<TOWN> Oilrig" which effectively means that there can be several oil rigs with exactly the same name.
rubidium <rubidium@openttd.org>
parents:
7814
diff
changeset
|
2806 if (!GenerateStationName(st, tile, STATIONNAMING_OILRIG)) { |
4ea8c684b2d1
(svn r11376) -Fix: fill the town a oil rig is associated with before creating the name, otherwise every oil rig will become "<TOWN> Oilrig" which effectively means that there can be several oil rigs with exactly the same name.
rubidium <rubidium@openttd.org>
parents:
7814
diff
changeset
|
2807 DEBUG(misc, 0, "Can't allocate station-name for oilrig at 0x%X, reverting to oilrig only", tile); |
4ea8c684b2d1
(svn r11376) -Fix: fill the town a oil rig is associated with before creating the name, otherwise every oil rig will become "<TOWN> Oilrig" which effectively means that there can be several oil rigs with exactly the same name.
rubidium <rubidium@openttd.org>
parents:
7814
diff
changeset
|
2808 delete st; |
4ea8c684b2d1
(svn r11376) -Fix: fill the town a oil rig is associated with before creating the name, otherwise every oil rig will become "<TOWN> Oilrig" which effectively means that there can be several oil rigs with exactly the same name.
rubidium <rubidium@openttd.org>
parents:
7814
diff
changeset
|
2809 return; |
4ea8c684b2d1
(svn r11376) -Fix: fill the town a oil rig is associated with before creating the name, otherwise every oil rig will become "<TOWN> Oilrig" which effectively means that there can be several oil rigs with exactly the same name.
rubidium <rubidium@openttd.org>
parents:
7814
diff
changeset
|
2810 } |
4ea8c684b2d1
(svn r11376) -Fix: fill the town a oil rig is associated with before creating the name, otherwise every oil rig will become "<TOWN> Oilrig" which effectively means that there can be several oil rigs with exactly the same name.
rubidium <rubidium@openttd.org>
parents:
7814
diff
changeset
|
2811 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2812 MakeOilrig(tile, st->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2813 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2814 st->owner = OWNER_NONE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2815 st->airport_flags = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2816 st->airport_type = AT_OILRIG; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2817 st->xy = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2818 st->bus_stops = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2819 st->truck_stops = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2820 st->airport_tile = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2821 st->dock_tile = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2822 st->train_tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2823 st->had_vehicle_of_type = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2824 st->time_since_load = 255; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2825 st->time_since_unload = 255; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2826 st->delete_ctr = 0; |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6248
diff
changeset
|
2827 st->last_vehicle_type = VEH_INVALID; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2828 st->facilities = FACIL_AIRPORT | FACIL_DOCK; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2829 st->build_date = _date; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2830 |
6350
8132258640be
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents:
6329
diff
changeset
|
2831 for (CargoID j = 0; j < NUM_CARGO; j++) { |
7474
7b35fd1cc99d
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium <rubidium@openttd.org>
parents:
7469
diff
changeset
|
2832 st->goods[j].acceptance_pickup = 0; |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2833 st->goods[j].days_since_pickup = 255; |
6261
a2ab35efe1ab
(svn r9070) -Fix [FS#404]: if bribe failed and you didn't pick up cargo yet, you wouldn't ever be able to do so for a given station
truelight <truelight@openttd.org>
parents:
6259
diff
changeset
|
2834 st->goods[j].rating = INITIAL_STATION_RATING; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2835 st->goods[j].last_speed = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2836 st->goods[j].last_age = 255; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2837 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2838 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2839 UpdateStationVirtCoordDirty(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2840 UpdateStationAcceptance(st, false); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2841 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2842 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2843 void DeleteOilRig(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2844 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2845 Station* st = GetStationByTile(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2846 |
5887 | 2847 MakeWater(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2848 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2849 st->dock_tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2850 st->airport_tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2851 st->facilities &= ~(FACIL_AIRPORT | FACIL_DOCK); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2852 st->airport_flags = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2853 UpdateStationVirtCoordDirty(st); |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
2854 if (st->facilities == 0) delete st; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2855 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2856 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2857 static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerID new_player) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2858 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2859 if (!IsTileOwner(tile, old_player)) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2860 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2861 if (new_player != PLAYER_SPECTATOR) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2862 Station* st = GetStationByTile(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2863 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2864 SetTileOwner(tile, new_player); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2865 st->owner = new_player; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2866 RebuildStationLists(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2867 InvalidateWindowClasses(WC_STATION_LIST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2868 } else { |
6116
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2869 if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) { |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2870 /* For a drive-through stop on a town-owned road remove the stop and replace the road */ |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2871 DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC, CMD_REMOVE_ROAD_STOP); |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2872 } else { |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2873 DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2874 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2875 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2876 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2877 |
6116
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2878 /** |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2879 * Check if a drive-through road stop tile can be cleared. |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2880 * Road stops built on town-owned roads check the conditions |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2881 * that would allow clearing of the original road. |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2882 * @param tile road stop tile to check |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2883 * @return true if the road can be cleared |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2884 */ |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2885 static bool CanRemoveRoadWithStop(TileIndex tile) |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2886 { |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2887 /* The road can always be cleared if it was not a town-owned road */ |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2888 if (!GetStopBuiltOnTownRoad(tile)) return true; |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2889 |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2890 bool edge_road; |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
2891 return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, &edge_road, ROADTYPE_ROAD) && |
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6596
diff
changeset
|
2892 CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_TRAM), OWNER_TOWN, &edge_road, ROADTYPE_TRAM); |
6116
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2893 } |
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2894 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6915
diff
changeset
|
2895 static CommandCost ClearTile_Station(TileIndex tile, byte flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2896 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2897 if (flags & DC_AUTO) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2898 switch (GetStationType(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2899 case STATION_RAIL: return_cmd_error(STR_300B_MUST_DEMOLISH_RAILROAD); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2900 case STATION_AIRPORT: return_cmd_error(STR_300E_MUST_DEMOLISH_AIRPORT_FIRST); |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2901 case STATION_TRUCK: return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_3047_MUST_DEMOLISH_CARGO_TRAM_STATION : STR_3047_MUST_DEMOLISH_TRUCK_STATION); |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2902 case STATION_BUS: return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_3046_MUST_DEMOLISH_PASSENGER_TRAM_STATION : STR_3046_MUST_DEMOLISH_BUS_STATION); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2903 case STATION_BUOY: return_cmd_error(STR_306A_BUOY_IN_THE_WAY); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2904 case STATION_DOCK: return_cmd_error(STR_304D_MUST_DEMOLISH_DOCK_FIRST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2905 case STATION_OILRIG: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2906 SetDParam(0, STR_4807_OIL_RIG); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2907 return_cmd_error(STR_4800_IN_THE_WAY); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2908 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2909 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2910 |
6069 | 2911 Station *st = GetStationByTile(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2912 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2913 switch (GetStationType(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2914 case STATION_RAIL: return RemoveRailroadStation(st, tile, flags); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2915 case STATION_AIRPORT: return RemoveAirport(st, flags); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2916 case STATION_TRUCK: |
6116
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2917 if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile)) |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2918 return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION); |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2919 return RemoveRoadStop(st, flags, tile); |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2920 case STATION_BUS: |
6116
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
6115
diff
changeset
|
2921 if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile)) |
6012
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2922 return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION); |
542153c1c803
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium <rubidium@openttd.org>
parents:
6000
diff
changeset
|
2923 return RemoveRoadStop(st, flags, tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2924 case STATION_BUOY: return RemoveBuoy(st, flags); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2925 case STATION_DOCK: return RemoveDock(st, flags); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2926 default: break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2927 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2928 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2929 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2930 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2931 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
2932 void InitializeStations() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2933 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2934 /* Clean the station pool and create 1 block in it */ |
7379
711b78f7dd89
(svn r10748) -Codechange: call the pool cleanup functions for stations directly instead of using the wrapper functions.
rubidium <rubidium@openttd.org>
parents:
7377
diff
changeset
|
2935 _Station_pool.CleanPool(); |
711b78f7dd89
(svn r10748) -Codechange: call the pool cleanup functions for stations directly instead of using the wrapper functions.
rubidium <rubidium@openttd.org>
parents:
7377
diff
changeset
|
2936 _Station_pool.AddBlockToPool(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2937 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2938 /* Clean the roadstop pool and create 1 block in it */ |
7379
711b78f7dd89
(svn r10748) -Codechange: call the pool cleanup functions for stations directly instead of using the wrapper functions.
rubidium <rubidium@openttd.org>
parents:
7377
diff
changeset
|
2939 _RoadStop_pool.CleanPool(); |
711b78f7dd89
(svn r10748) -Codechange: call the pool cleanup functions for stations directly instead of using the wrapper functions.
rubidium <rubidium@openttd.org>
parents:
7377
diff
changeset
|
2940 _RoadStop_pool.AddBlockToPool(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2941 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2942 _station_tick_ctr = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2943 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2944 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2945 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2946 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
2947 void AfterLoadStations() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2948 { |
6069 | 2949 /* Update the speclists of all stations to point to the currently loaded custom stations. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2950 Station *st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2951 FOR_ALL_STATIONS(st) { |
6069 | 2952 for (uint i = 0; i < st->num_specs; i++) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2953 if (st->speclist[i].grfid == 0) continue; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2954 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2955 st->speclist[i].spec = GetCustomStationSpecByGrf(st->speclist[i].grfid, st->speclist[i].localidx); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2956 } |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2957 |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
2958 for (CargoID c = 0; c < NUM_CARGO; c++) st->goods[c].cargo.InvalidateCache(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2959 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2960 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2961 |
7494
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7491
diff
changeset
|
2962 static CommandCost TerraformTile_Station(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7491
diff
changeset
|
2963 { |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2964 if (_patches.build_on_slopes && AutoslopeEnabled()) { |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2965 /* TODO: If you implement newgrf callback 149 'land slope check', you have to decide what to do with it here. |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2966 * TTDP does not call it. |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2967 */ |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2968 if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) { |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2969 switch (GetStationType(tile)) { |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2970 case STATION_RAIL: { |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2971 DiagDirection direction = AxisToDiagDir(GetRailStationAxis(tile)); |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2972 if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break; |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2973 if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break; |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2974 return _price.terraform; |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2975 } |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2976 |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2977 case STATION_AIRPORT: |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2978 return _price.terraform; |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2979 |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2980 case STATION_TRUCK: |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2981 case STATION_BUS: { |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2982 DiagDirection direction = GetRoadStopDir(tile); |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2983 if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break; |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2984 if (IsDriveThroughStopTile(tile)) { |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2985 if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break; |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2986 } |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2987 return _price.terraform; |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2988 } |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2989 |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2990 default: break; |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2991 } |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2992 } |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7545
diff
changeset
|
2993 } |
7494
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7491
diff
changeset
|
2994 return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7491
diff
changeset
|
2995 } |
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7491
diff
changeset
|
2996 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2997 |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
2998 extern const TileTypeProcs _tile_type_station_procs = { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2999 DrawTile_Station, /* draw_tile_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3000 GetSlopeZ_Station, /* get_slope_z_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3001 ClearTile_Station, /* clear_tile_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3002 GetAcceptedCargo_Station, /* get_accepted_cargo_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3003 GetTileDesc_Station, /* get_tile_desc_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3004 GetTileTrackStatus_Station, /* get_tile_track_status_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3005 ClickTile_Station, /* click_tile_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3006 AnimateTile_Station, /* animate_tile_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3007 TileLoop_Station, /* tile_loop_clear */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3008 ChangeTileOwner_Station, /* change_tile_owner_clear */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3009 NULL, /* get_produced_cargo_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3010 VehicleEnter_Station, /* vehicle_enter_tile_proc */ |
7335
0090d1c6b978
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7333
diff
changeset
|
3011 GetFoundation_Station, /* get_foundation_proc */ |
7494
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7491
diff
changeset
|
3012 TerraformTile_Station, /* terraform_tile_proc */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3013 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3014 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3015 static const SaveLoad _roadstop_desc[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3016 SLE_VAR(RoadStop,xy, SLE_UINT32), |
5718 | 3017 SLE_CONDNULL(1, 0, 44), |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3018 SLE_VAR(RoadStop,status, SLE_UINT8), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3019 /* Index was saved in some versions, but this is not needed */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3020 SLE_CONDNULL(4, 0, 8), |
5716 | 3021 SLE_CONDNULL(2, 0, 44), |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3022 SLE_CONDNULL(1, 0, 25), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3023 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3024 SLE_REF(RoadStop,next, REF_ROADSTOPS), |
5867 | 3025 SLE_CONDNULL(2, 0, 44), |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3026 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3027 SLE_CONDNULL(4, 0, 24), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3028 SLE_CONDNULL(1, 25, 25), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3029 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3030 SLE_END() |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3031 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3032 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3033 static const SaveLoad _station_desc[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3034 SLE_CONDVAR(Station, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3035 SLE_CONDVAR(Station, xy, SLE_UINT32, 6, SL_MAX_VERSION), |
5879 | 3036 SLE_CONDNULL(4, 0, 5), // bus/lorry tile |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3037 SLE_CONDVAR(Station, train_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3038 SLE_CONDVAR(Station, train_tile, SLE_UINT32, 6, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3039 SLE_CONDVAR(Station, airport_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3040 SLE_CONDVAR(Station, airport_tile, SLE_UINT32, 6, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3041 SLE_CONDVAR(Station, dock_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3042 SLE_CONDVAR(Station, dock_tile, SLE_UINT32, 6, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3043 SLE_REF(Station, town, REF_TOWN), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3044 SLE_VAR(Station, trainst_w, SLE_UINT8), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3045 SLE_CONDVAR(Station, trainst_h, SLE_UINT8, 2, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3046 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
3047 /* alpha_order was stored here in savegame format 0 - 3 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3048 SLE_CONDNULL(1, 0, 3), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3049 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3050 SLE_VAR(Station, string_id, SLE_STRINGID), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3051 SLE_VAR(Station, had_vehicle_of_type, SLE_UINT16), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3052 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3053 SLE_VAR(Station, time_since_load, SLE_UINT8), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3054 SLE_VAR(Station, time_since_unload, SLE_UINT8), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3055 SLE_VAR(Station, delete_ctr, SLE_UINT8), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3056 SLE_VAR(Station, owner, SLE_UINT8), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3057 SLE_VAR(Station, facilities, SLE_UINT8), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3058 SLE_VAR(Station, airport_type, SLE_UINT8), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3059 |
5878 | 3060 SLE_CONDNULL(2, 0, 5), // Truck/bus stop status |
5877 | 3061 SLE_CONDNULL(1, 0, 4), // Blocked months |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3062 |
5995
c72b07427c7f
(svn r8705) -Codechange: Increased the number of airport blocks to 64. This involves changing the enum of airport blocks to a static const uint64 as SOME platforms do not support 64-bit enums
celestar <celestar@openttd.org>
parents:
5991
diff
changeset
|
3063 SLE_CONDVAR(Station, airport_flags, SLE_VAR_U64 | SLE_FILE_U16, 0, 2), |
c72b07427c7f
(svn r8705) -Codechange: Increased the number of airport blocks to 64. This involves changing the enum of airport blocks to a static const uint64 as SOME platforms do not support 64-bit enums
celestar <celestar@openttd.org>
parents:
5991
diff
changeset
|
3064 SLE_CONDVAR(Station, airport_flags, SLE_VAR_U64 | SLE_FILE_U32, 3, 45), |
c72b07427c7f
(svn r8705) -Codechange: Increased the number of airport blocks to 64. This involves changing the enum of airport blocks to a static const uint64 as SOME platforms do not support 64-bit enums
celestar <celestar@openttd.org>
parents:
5991
diff
changeset
|
3065 SLE_CONDVAR(Station, airport_flags, SLE_UINT64, 46, SL_MAX_VERSION), |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3066 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3067 SLE_CONDNULL(2, 0, 25), /* Ex last-vehicle */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3068 SLE_CONDVAR(Station, last_vehicle_type, SLE_UINT8, 26, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3069 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
3070 /* Was custom station class and id */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3071 SLE_CONDNULL(2, 3, 25), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3072 SLE_CONDVAR(Station, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3073 SLE_CONDVAR(Station, build_date, SLE_INT32, 31, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3074 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3075 SLE_CONDREF(Station, bus_stops, REF_ROADSTOPS, 6, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3076 SLE_CONDREF(Station, truck_stops, REF_ROADSTOPS, 6, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3077 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3078 /* Used by newstations for graphic variations */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3079 SLE_CONDVAR(Station, random_bits, SLE_UINT16, 27, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3080 SLE_CONDVAR(Station, waiting_triggers, SLE_UINT8, 27, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3081 SLE_CONDVAR(Station, num_specs, SLE_UINT8, 27, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3082 |
6500
ad8ea1f30c99
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents:
6491
diff
changeset
|
3083 SLE_CONDLST(Station, loading_vehicles, REF_VEHICLE, 57, SL_MAX_VERSION), |
ad8ea1f30c99
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents:
6491
diff
changeset
|
3084 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
3085 /* reserve extra space in savegame here. (currently 32 bytes) */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3086 SLE_CONDNULL(32, 2, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3087 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3088 SLE_END() |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3089 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3090 |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3091 static uint16 _waiting_acceptance; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3092 static uint16 _cargo_source; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3093 static uint32 _cargo_source_xy; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3094 static uint16 _cargo_days; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3095 static Money _cargo_feeder_share; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3096 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3097 static const SaveLoad _station_speclist_desc[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3098 SLE_CONDVAR(StationSpecList, grfid, SLE_UINT32, 27, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3099 SLE_CONDVAR(StationSpecList, localidx, SLE_UINT8, 27, SL_MAX_VERSION), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3100 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3101 SLE_END() |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3102 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3103 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3104 |
7491
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3105 void SaveLoad_STNS(Station *st) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3106 { |
7491
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3107 static const SaveLoad _goods_desc[] = { |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3108 SLEG_CONDVAR( _waiting_acceptance, SLE_UINT16, 0, 67), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3109 SLE_CONDVAR(GoodsEntry, acceptance_pickup, SLE_UINT8, 68, SL_MAX_VERSION), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3110 SLE_CONDNULL(2, 51, 67), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3111 SLE_VAR(GoodsEntry, days_since_pickup, SLE_UINT8), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3112 SLE_VAR(GoodsEntry, rating, SLE_UINT8), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3113 SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, 0, 6), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3114 SLEG_CONDVAR( _cargo_source, SLE_UINT16, 7, 67), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3115 SLEG_CONDVAR( _cargo_source_xy, SLE_UINT32, 44, 67), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3116 SLEG_CONDVAR( _cargo_days, SLE_UINT8, 0, 67), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3117 SLE_VAR(GoodsEntry, last_speed, SLE_UINT8), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3118 SLE_VAR(GoodsEntry, last_age, SLE_UINT8), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3119 SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, 14, 64), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3120 SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, 65, 67), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3121 SLE_CONDLST(GoodsEntry, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION), |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3122 |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3123 SLE_END() |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3124 }; |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3125 |
4c057868119e
(svn r11002) -Codechange: unhackify the cargo packet list saving (a little).
rubidium <rubidium@openttd.org>
parents:
7474
diff
changeset
|
3126 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3127 SlObject(st, _station_desc); |
6463
0315af802158
(svn r9638) -Feature: Increase cargo types from 12 to 32 and enable newcargo flag in NewGRF loader.
peter1138 <peter1138@openttd.org>
parents:
6453
diff
changeset
|
3128 |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3129 _waiting_acceptance = 0; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3130 |
6463
0315af802158
(svn r9638) -Feature: Increase cargo types from 12 to 32 and enable newcargo flag in NewGRF loader.
peter1138 <peter1138@openttd.org>
parents:
6453
diff
changeset
|
3131 uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO; |
0315af802158
(svn r9638) -Feature: Increase cargo types from 12 to 32 and enable newcargo flag in NewGRF loader.
peter1138 <peter1138@openttd.org>
parents:
6453
diff
changeset
|
3132 for (CargoID i = 0; i < num_cargo; i++) { |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3133 GoodsEntry *ge = &st->goods[i]; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3134 SlObject(ge, _goods_desc); |
7013
4b344122f60d
(svn r10269) -Fix [FS#912]: station ratings were shown for all cargos instead of only the cargos that have been transported.
rubidium <rubidium@openttd.org>
parents:
7010
diff
changeset
|
3135 if (CheckSavegameVersion(68)) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
3136 SB(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15)); |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3137 if (GB(_waiting_acceptance, 0, 12) != 0) { |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3138 /* Don't construct the packet with station here, because that'll fail with old savegames */ |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3139 CargoPacket *cp = new CargoPacket(); |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3140 /* In old versions, enroute_from used 0xFF as INVALID_STATION */ |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3141 cp->source = (CheckSavegameVersion(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3142 cp->count = GB(_waiting_acceptance, 0, 12); |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3143 cp->days_in_transit = _cargo_days; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3144 cp->feeder_share = _cargo_feeder_share; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3145 cp->source_xy = _cargo_source_xy; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3146 cp->days_in_transit = _cargo_days; |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3147 cp->feeder_share = _cargo_feeder_share; |
7474
7b35fd1cc99d
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium <rubidium@openttd.org>
parents:
7469
diff
changeset
|
3148 SB(ge->acceptance_pickup, GoodsEntry::PICKUP, 1, 1); |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3149 ge->cargo.Append(cp); |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3150 } |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6955
diff
changeset
|
3151 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3152 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3153 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3154 if (st->num_specs != 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3155 /* Allocate speclist memory when loading a game */ |
5609
358c07fb3212
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr <KUDr@openttd.org>
parents:
5601
diff
changeset
|
3156 if (st->speclist == NULL) st->speclist = CallocT<StationSpecList>(st->num_specs); |
6069 | 3157 for (uint i = 0; i < st->num_specs; i++) { |
3158 SlObject(&st->speclist[i], _station_speclist_desc); | |
3159 } | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3160 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3161 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3162 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
3163 static void Save_STNS() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3164 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3165 Station *st; |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
3166 /* Write the stations */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3167 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3168 SlSetArrayIndex(st->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3169 SlAutolength((AutolengthProc*)SaveLoad_STNS, st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3170 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3171 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3172 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
3173 static void Load_STNS() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3174 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3175 int index; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3176 while ((index = SlIterateArray()) != -1) { |
5665
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
3177 Station *st = new (index) Station(); |
3cc382938839
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr <KUDr@openttd.org>
parents:
5660
diff
changeset
|
3178 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3179 SaveLoad_STNS(st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3180 |
7795
f49ffccacf58
(svn r11345) -Cleanup: a bit of comment style fixing
belugas <belugas@openttd.org>
parents:
7758
diff
changeset
|
3181 /* this means it's an oldstyle savegame without support for nonuniform stations */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3182 if (st->train_tile != 0 && st->trainst_h == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3183 uint w = GB(st->trainst_w, 4, 4); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3184 uint h = GB(st->trainst_w, 0, 4); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3185 |
6106 | 3186 if (GetRailStationAxis(st->train_tile) != AXIS_X) Swap(w, h); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3187 st->trainst_w = w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3188 st->trainst_h = h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3189 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3190 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3191 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3192 /* This is to ensure all pointers are within the limits of _stations_size */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3193 if (_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3194 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3195 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
3196 static void Save_ROADSTOP() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3197 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3198 RoadStop *rs; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3199 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3200 FOR_ALL_ROADSTOPS(rs) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3201 SlSetArrayIndex(rs->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3202 SlObject(rs, _roadstop_desc); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3203 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3204 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3205 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6201
diff
changeset
|
3206 static void Load_ROADSTOP() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3207 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3208 int index; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3209 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3210 while ((index = SlIterateArray()) != -1) { |
5716 | 3211 RoadStop *rs = new (index) RoadStop(INVALID_TILE); |
5708
3dc3a5375999
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar <celestar@openttd.org>
parents:
5697
diff
changeset
|
3212 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3213 SlObject(rs, _roadstop_desc); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3214 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3215 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3216 |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
3217 extern const ChunkHandler _station_chunk_handlers[] = { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3218 { 'STNS', Save_STNS, Load_STNS, CH_ARRAY }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3219 { 'ROAD', Save_ROADSTOP, Load_ROADSTOP, CH_ARRAY | CH_LAST}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
3220 }; |