author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6488 | b6c42e91bb35 |
child 6653 | b20fcfed0847 |
permissions | -rw-r--r-- |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
1 |
/* $Id$ */ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
2 |
|
6121
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
6117
diff
changeset
|
3 |
/** @file station.cpp */ |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
4 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
6 |
#include "openttd.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
7 |
#include "bridge_map.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
8 |
#include "debug.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
9 |
#include "functions.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
10 |
#include "station_map.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
11 |
#include "table/sprites.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
12 |
#include "table/strings.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
13 |
#include "map.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
14 |
#include "tile.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
15 |
#include "station.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
16 |
#include "gfx.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
17 |
#include "window.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
18 |
#include "viewport.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
19 |
#include "command.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
20 |
#include "town.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
21 |
#include "vehicle.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
22 |
#include "news.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
23 |
#include "saveload.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
24 |
#include "economy.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
25 |
#include "player.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
26 |
#include "airport.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
27 |
#include "sprite.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
28 |
#include "depot.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
29 |
#include "train.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
30 |
#include "water_map.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
31 |
#include "industry_map.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
32 |
#include "newgrf_callbacks.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
33 |
#include "newgrf_station.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
34 |
#include "yapf/yapf.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
35 |
#include "date.h" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
36 |
#include "helpers.hpp" |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
37 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
38 |
Station::Station(TileIndex tile) |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
39 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
40 |
DEBUG(station, cDebugCtorLevel, "I+%3d", index); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
41 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
42 |
xy = tile; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
43 |
airport_tile = dock_tile = train_tile = 0; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
44 |
bus_stops = truck_stops = NULL; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
45 |
had_vehicle_of_type = 0; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
46 |
time_since_load = 255; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
47 |
time_since_unload = 255; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
48 |
delete_ctr = 0; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
49 |
facilities = 0; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
50 |
|
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6247
diff
changeset
|
51 |
last_vehicle_type = VEH_INVALID; |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
52 |
|
5721
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
53 |
random_bits = 0; // Random() must be called when station is really built (DC_EXEC) |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
54 |
waiting_triggers = 0; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
55 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
56 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
57 |
/** |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6259
diff
changeset
|
58 |
* Clean up a station by clearing vehicle orders and invalidating windows. |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6259
diff
changeset
|
59 |
* Aircraft-Hangar orders need special treatment here, as the hangars are |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6259
diff
changeset
|
60 |
* actually part of a station (tiletype is STATION), but the order type |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6259
diff
changeset
|
61 |
* is OT_GOTO_DEPOT. |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6259
diff
changeset
|
62 |
*/ |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
63 |
Station::~Station() |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
64 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
65 |
DEBUG(station, cDebugCtorLevel, "I-%3d", index); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
66 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
67 |
DeleteName(string_id); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
68 |
MarkDirty(); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
69 |
RebuildStationLists(); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
70 |
InvalidateWindowClasses(WC_STATION_LIST); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
71 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
72 |
DeleteWindowById(WC_STATION_VIEW, index); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
73 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
74 |
/* Now delete all orders that go to the station */ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
75 |
RemoveOrderFromAllVehicles(OT_GOTO_STATION, index); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
76 |
|
5678 | 77 |
/* Subsidies need removal as well */ |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
78 |
DeleteSubsidyWithStation(index); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
79 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
80 |
free(speclist); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
81 |
xy = 0; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
82 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
83 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
84 |
void* Station::operator new(size_t size) |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
85 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
86 |
Station *st = AllocateRaw(); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
87 |
return st; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
88 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
89 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
90 |
void* Station::operator new(size_t size, int st_idx) |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
91 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
92 |
if (!AddBlockIfNeeded(&_Station_pool, st_idx)) |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
93 |
error("Stations: failed loading savegame: too many stations"); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
94 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
95 |
Station *st = GetStation(st_idx); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
96 |
return st; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
97 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
98 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
99 |
void Station::operator delete(void *p) |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
100 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
101 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
102 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
103 |
void Station::operator delete(void *p, int st_idx) |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
104 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
105 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
106 |
|
5721
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
107 |
/** Called when new facility is built on the station. If it is the first facility |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6259
diff
changeset
|
108 |
* it initializes also 'xy' and 'random_bits' members */ |
5721
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
109 |
void Station::AddFacility(byte new_facility_bit, TileIndex facil_xy) |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
110 |
{ |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
111 |
if (facilities == 0) { |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
112 |
xy = facil_xy; |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
113 |
random_bits = Random(); |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
114 |
} |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
115 |
facilities |= new_facility_bit; |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
116 |
owner = _current_player; |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
117 |
build_date = _date; |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
118 |
} |
fa4e587f59f5
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents:
5718
diff
changeset
|
119 |
|
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
120 |
void Station::MarkDirty() const |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
121 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
122 |
if (sign.width_1 != 0) { |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
123 |
InvalidateWindowWidget(WC_STATION_VIEW, index, 1); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
124 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
125 |
MarkAllViewportsDirty( |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
126 |
sign.left - 6, |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
127 |
sign.top, |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
128 |
sign.left + (sign.width_1 << 2) + 12, |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
129 |
sign.top + 48); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
130 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
131 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
132 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
133 |
void Station::MarkTilesDirty() const |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
134 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
135 |
TileIndex tile = train_tile; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
136 |
int w, h; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
137 |
|
5678 | 138 |
/* XXX No station is recorded as 0, not INVALID_TILE... */ |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
139 |
if (tile == 0) return; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
140 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
141 |
for (h = 0; h < trainst_h; h++) { |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
142 |
for (w = 0; w < trainst_w; w++) { |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
143 |
if (TileBelongsToRailStation(tile)) { |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
144 |
MarkTileDirtyByTile(tile); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
145 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
146 |
tile += TileDiffXY(1, 0); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
147 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
148 |
tile += TileDiffXY(-w, 1); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
149 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
150 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
151 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
152 |
bool Station::TileBelongsToRailStation(TileIndex tile) const |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
153 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
154 |
return IsTileType(tile, MP_STATION) && GetStationIndex(tile) == index && IsRailwayStation(tile); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
155 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
156 |
|
6247 | 157 |
/*static*/ Station *Station::AllocateRaw() |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
158 |
{ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
159 |
Station *st = NULL; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
160 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
161 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
162 |
* TODO - This is just a temporary stage, this will be removed. */ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
163 |
for (st = GetStation(0); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) { |
5996
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
164 |
if (!st->IsValid()) { |
5665
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
165 |
StationID index = st->index; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
166 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
167 |
memset(st, 0, sizeof(Station)); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
168 |
st->index = index; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
169 |
return st; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
170 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
171 |
} |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
172 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
173 |
/* Check if we can add a block to the pool */ |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
174 |
if (AddBlockToPool(&_Station_pool)) return AllocateRaw(); |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
175 |
|
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
176 |
_error_message = STR_3008_TOO_MANY_STATIONS_LOADING; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
177 |
return NULL; |
d6b5c720ad67
(svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents:
diff
changeset
|
178 |
} |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
179 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
180 |
|
5998
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
181 |
/** Obtain the length of a platform |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
182 |
* @pre tile must be a railway station tile |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
183 |
* @param tile A tile that contains the platform in question |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6259
diff
changeset
|
184 |
* @return The length of the platform |
5998
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
185 |
*/ |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
186 |
uint Station::GetPlatformLength(TileIndex tile) const |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
187 |
{ |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
188 |
TileIndex t; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
189 |
TileIndexDiff delta; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
190 |
uint len = 0; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
191 |
assert(TileBelongsToRailStation(tile)); |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
192 |
|
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
193 |
delta = (GetRailStationAxis(tile) == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
194 |
|
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
195 |
t = tile; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
196 |
do { |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
197 |
t -= delta; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
198 |
len++; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
199 |
} while (IsCompatibleTrainStationTile(t, tile)); |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
200 |
|
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
201 |
t = tile; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
202 |
do { |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
203 |
t += delta; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
204 |
len++; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
205 |
} while (IsCompatibleTrainStationTile(t, tile)); |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
206 |
|
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
207 |
return len - 1; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
208 |
} |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
209 |
|
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
210 |
/** Determines the REMAINING length of a platform, starting at (and including) |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
211 |
* the given tile. |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
212 |
* @param tile the tile from which to start searching. Must be a railway station tile |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
213 |
* @param dir The direction in which to search. |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
214 |
* @return The platform length |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
215 |
*/ |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
216 |
uint Station::GetPlatformLength(TileIndex tile, DiagDirection dir) const |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
217 |
{ |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
218 |
TileIndex start_tile = tile; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
219 |
uint length = 0; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
220 |
assert(IsRailwayStationTile(tile)); |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
221 |
assert(dir < DIAGDIR_END); |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
222 |
|
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
223 |
do { |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
224 |
length ++; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
225 |
tile += TileOffsByDiagDir(dir); |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
226 |
} while (IsCompatibleTrainStationTile(tile, start_tile)); |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
227 |
|
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
228 |
return length; |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
229 |
} |
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5997
diff
changeset
|
230 |
|
5896
a9f7bdd841d4
(svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents:
5867
diff
changeset
|
231 |
/** Determines whether a station is a buoy only. |
a9f7bdd841d4
(svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents:
5867
diff
changeset
|
232 |
* @todo Ditch this encoding of buoys |
a9f7bdd841d4
(svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents:
5867
diff
changeset
|
233 |
*/ |
a9f7bdd841d4
(svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents:
5867
diff
changeset
|
234 |
bool Station::IsBuoy() const |
a9f7bdd841d4
(svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents:
5867
diff
changeset
|
235 |
{ |
5997
e6d057d90fce
(svn r8708) -Codechange(r8514): No need to use "this->" in methods
celestar
parents:
5996
diff
changeset
|
236 |
return (had_vehicle_of_type & HVOT_BUOY) != 0; |
5896
a9f7bdd841d4
(svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents:
5867
diff
changeset
|
237 |
} |
a9f7bdd841d4
(svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents:
5867
diff
changeset
|
238 |
|
5996
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
239 |
/** Determines whether a station exists |
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
240 |
* @todo replace 0 by INVALID_TILE |
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
241 |
*/ |
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
242 |
bool Station::IsValid() const |
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
243 |
{ |
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
244 |
return xy != 0; |
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
245 |
} |
4bcab9c286d8
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
5990
diff
changeset
|
246 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
247 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
248 |
/************************************************************************/ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
249 |
/* StationRect implementation */ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
250 |
/************************************************************************/ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
251 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
252 |
StationRect::StationRect() |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
253 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
254 |
MakeEmpty(); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
255 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
256 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
257 |
void StationRect::MakeEmpty() |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
258 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
259 |
left = top = right = bottom = 0; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
260 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
261 |
|
5910
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
262 |
/** |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
263 |
* Determines whether a given point (x, y) is within a certain distance of |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
264 |
* the station rectangle. |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
265 |
* @note x and y are in Tile coordinates |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
266 |
* @param x X coordinate |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
267 |
* @param y Y coordinate |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
268 |
* @param distance The maxmium distance a point may have (L1 norm) |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
269 |
* @return true if the point is within distance tiles of the station rectangle |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
270 |
*/ |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
271 |
bool StationRect::PtInExtendedRect(int x, int y, int distance) const |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
272 |
{ |
5910
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
273 |
return (left - distance <= x && x <= right + distance && top - distance <= y && y <= bottom + distance); |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
274 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
275 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
276 |
bool StationRect::IsEmpty() const |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
277 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
278 |
return (left == 0 || left > right || top > bottom); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
279 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
280 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
281 |
bool StationRect::BeforeAddTile(TileIndex tile, StationRectMode mode) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
282 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
283 |
int x = TileX(tile); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
284 |
int y = TileY(tile); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
285 |
if (IsEmpty()) { |
5678 | 286 |
/* we are adding the first station tile */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
287 |
left = right = x; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
288 |
top = bottom = y; |
5678 | 289 |
|
5910
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
290 |
} else if (!PtInExtendedRect(x, y)) { |
5678 | 291 |
/* current rect is not empty and new point is outside this rect */ |
292 |
/* make new spread-out rectangle */ |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
293 |
Rect new_rect = {min(x, left), min(y, top), max(x, right), max(y, bottom)}; |
5678 | 294 |
|
295 |
/* check new rect dimensions against preset max */ |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
296 |
int w = new_rect.right - new_rect.left + 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
297 |
int h = new_rect.bottom - new_rect.top + 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
298 |
if (mode != ADD_FORCE && (w > _patches.station_spread || h > _patches.station_spread)) { |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
299 |
assert(mode != ADD_TRY); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
300 |
_error_message = STR_306C_STATION_TOO_SPREAD_OUT; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
301 |
return false; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
302 |
} |
5678 | 303 |
|
304 |
/* spread-out ok, return true */ |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
305 |
if (mode != ADD_TEST) { |
5678 | 306 |
/* we should update the station rect */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
307 |
*this = new_rect; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
308 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
309 |
} else { |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
310 |
; // new point is inside the rect, we don't need to do anything |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
311 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
312 |
return true; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
313 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
314 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
315 |
bool StationRect::BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
316 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
317 |
return BeforeAddTile(tile, mode) && BeforeAddTile(TILE_ADDXY(tile, w - 1, h - 1), mode); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
318 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
319 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
320 |
/*static*/ bool StationRect::ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
321 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
322 |
TileIndex top_left = TileXY(left_a, top_a); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
323 |
int width = right_a - left_a + 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
324 |
int height = bottom_a - top_a + 1; |
5678 | 325 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
326 |
BEGIN_TILE_LOOP(tile, width, height, top_left) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
327 |
if (IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st_id) return true; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
328 |
END_TILE_LOOP(tile, width, height, top_left); |
5678 | 329 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
330 |
return false; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
331 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
332 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
333 |
bool StationRect::AfterRemoveTile(Station *st, TileIndex tile) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
334 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
335 |
int x = TileX(tile); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
336 |
int y = TileY(tile); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
337 |
|
5678 | 338 |
/* look if removed tile was on the bounding rect edge |
339 |
* and try to reduce the rect by this edge |
|
340 |
* do it until we have empty rect or nothing to do */ |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
341 |
for (;;) { |
5678 | 342 |
/* check if removed tile is on rect edge */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
343 |
bool left_edge = (x == left); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
344 |
bool right_edge = (x == right); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
345 |
bool top_edge = (y == top); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
346 |
bool bottom_edge = (y == bottom); |
5678 | 347 |
|
348 |
/* can we reduce the rect in either direction? */ |
|
349 |
bool reduce_x = ((left_edge || right_edge) && !ScanForStationTiles(st->index, x, top, x, bottom)); |
|
350 |
bool reduce_y = ((top_edge || bottom_edge) && !ScanForStationTiles(st->index, left, y, right, y)); |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
351 |
if (!(reduce_x || reduce_y)) break; // nothing to do (can't reduce) |
5678 | 352 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
353 |
if (reduce_x) { |
5678 | 354 |
/* reduce horizontally */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
355 |
if (left_edge) { |
5678 | 356 |
/* move left edge right */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
357 |
left = x = x + 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
358 |
} else { |
5678 | 359 |
/* move right edge left */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
360 |
right = x = x - 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
361 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
362 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
363 |
if (reduce_y) { |
5678 | 364 |
/* reduce vertically */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
365 |
if (top_edge) { |
5678 | 366 |
/* move top edge down */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
367 |
top = y = y + 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
368 |
} else { |
5678 | 369 |
/* move bottom edge up */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
370 |
bottom = y = y - 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
371 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
372 |
} |
5678 | 373 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
374 |
if (left > right || top > bottom) { |
5678 | 375 |
/* can't continue, if the remaining rectangle is empty */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
376 |
MakeEmpty(); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
377 |
return true; // empty remaining rect |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
378 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
379 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
380 |
return false; // non-empty remaining rect |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
381 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
382 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
383 |
bool StationRect::AfterRemoveRect(Station *st, TileIndex tile, int w, int h) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
384 |
{ |
5910
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
385 |
assert(PtInExtendedRect(TileX(tile), TileY(tile))); |
f1409c7e8a87
(svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents:
5896
diff
changeset
|
386 |
assert(PtInExtendedRect(TileX(tile) + w - 1, TileY(tile) + h - 1)); |
5678 | 387 |
|
388 |
bool empty = AfterRemoveTile(st, tile); |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
389 |
if (w != 1 || h != 1) empty = empty || AfterRemoveTile(st, TILE_ADDXY(tile, w - 1, h - 1)); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
390 |
return empty; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
391 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
392 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
393 |
StationRect& StationRect::operator = (Rect src) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
394 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
395 |
left = src.left; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
396 |
top = src.top; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
397 |
right = src.right; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
398 |
bottom = src.bottom; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
399 |
return *this; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
400 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
401 |
|
5708
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
402 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
403 |
/************************************************************************/ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
404 |
/* RoadStop implementation */ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
405 |
/************************************************************************/ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
406 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
407 |
/** Allocates a new RoadStop onto the pool, or recycles an unsed one |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
408 |
* @return a pointer to the new roadstop |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
409 |
*/ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
410 |
void *RoadStop::operator new(size_t size) |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
411 |
{ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
412 |
RoadStop *rs = AllocateRaw(); |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
413 |
return rs; |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
414 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
415 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
416 |
/** Gets a RoadStop with a given index and allocates it when needed |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
417 |
* @return a pointer to the roadstop |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
418 |
*/ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
419 |
void *RoadStop::operator new(size_t size, int index) |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
420 |
{ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
421 |
if (!AddBlockIfNeeded(&_RoadStop_pool, index)) { |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
422 |
error("RoadStops: failed loading savegame: too many RoadStops"); |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
423 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
424 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
425 |
RoadStop *rs = GetRoadStop(index); |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
426 |
return rs; |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
427 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
428 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
429 |
void RoadStop::operator delete(void *p) |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
430 |
{ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
431 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
432 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
433 |
void RoadStop::operator delete(void *p, int index) |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
434 |
{ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
435 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
436 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
437 |
/** Initializes a RoadStop */ |
5716 | 438 |
RoadStop::RoadStop(TileIndex tile) : |
5713 | 439 |
xy(tile), |
440 |
status(3), // stop is free |
|
441 |
num_vehicles(0), |
|
5867 | 442 |
next(NULL) |
5708
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
443 |
{ |
5716 | 444 |
DEBUG(ms, cDebugCtorLevel, "I+ at %d[0x%x]", tile, tile); |
5708
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
445 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
446 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
447 |
/** De-Initializes a RoadStops. This includes clearing all slots that vehicles might |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
448 |
* have and unlinks it from the linked list of road stops at the given station |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
449 |
*/ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
450 |
RoadStop::~RoadStop() |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
451 |
{ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
452 |
/* Clear the slot assignment of all vehicles heading for this road stop */ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
453 |
if (num_vehicles != 0) { |
5713 | 454 |
Vehicle *v; |
455 |
||
5708
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
456 |
FOR_ALL_VEHICLES(v) { |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6247
diff
changeset
|
457 |
if (v->type == VEH_ROAD && v->u.road.slot == this) ClearSlot(v); |
5708
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
458 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
459 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
460 |
assert(num_vehicles == 0); |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
461 |
|
5716 | 462 |
DEBUG(ms, cDebugCtorLevel , "I- at %d[0x%x]", xy, xy); |
5708
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
463 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
464 |
xy = INVALID_TILE; |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
465 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
466 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
467 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
468 |
/** Low-level function for allocating a RoadStop on the pool */ |
6247 | 469 |
RoadStop *RoadStop::AllocateRaw() |
5708
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
470 |
{ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
471 |
RoadStop *rs; |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
472 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
473 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
474 |
* TODO - This is just a temporary stage, this will be removed. */ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
475 |
for (rs = GetRoadStop(0); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) { |
5835
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
476 |
if (!rs->IsValid()) { |
5708
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
477 |
RoadStopID index = rs->index; |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
478 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
479 |
memset(rs, 0, sizeof(*rs)); |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
480 |
rs->index = index; |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
481 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
482 |
return rs; |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
483 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
484 |
} |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
485 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
486 |
/* Check if we can add a block to the pool */ |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
487 |
if (AddBlockToPool(&_RoadStop_pool)) return AllocateRaw(); |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
488 |
|
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
489 |
return NULL; |
4c4c5ec2bed6
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents:
5678
diff
changeset
|
490 |
} |
5835
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
491 |
|
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
492 |
/** Determines whether a RoadStop is a valid (i.e. existing) one */ |
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
493 |
bool RoadStop::IsValid() const |
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
494 |
{ |
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
495 |
return xy != INVALID_TILE; |
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
496 |
} |
5990
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
497 |
|
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
498 |
/** Checks whether there is a free bay in this road stop */ |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
499 |
bool RoadStop::HasFreeBay() const |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
500 |
{ |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
501 |
return GB(status, 0, MAX_BAY_COUNT) != 0; |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
502 |
} |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
503 |
|
6012
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
504 |
/** Checks whether the given bay is free in this road stop */ |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
505 |
bool RoadStop::IsFreeBay(uint nr) const |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
506 |
{ |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
507 |
assert(nr < MAX_BAY_COUNT); |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
508 |
return HASBIT(status, nr); |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
509 |
} |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
510 |
|
5990
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
511 |
/** |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
512 |
* Allocates a bay |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
513 |
* @return the allocated bay number |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
514 |
* @pre this->HasFreeBay() |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
515 |
*/ |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
516 |
uint RoadStop::AllocateBay() |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
517 |
{ |
6005
f9ddc290e8b0
(svn r8726) -Codechange: bools are 1 or 0 according to the C++ standard and refactor RoadStop::AllocateBay to remove a loop condition. Suggestions by Tron.
rubidium
parents:
5998
diff
changeset
|
518 |
assert(HasFreeBay()); |
f9ddc290e8b0
(svn r8726) -Codechange: bools are 1 or 0 according to the C++ standard and refactor RoadStop::AllocateBay to remove a loop condition. Suggestions by Tron.
rubidium
parents:
5998
diff
changeset
|
519 |
|
5990
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
520 |
/* Find the first free bay. If the bit is set, the bay is free. */ |
6005
f9ddc290e8b0
(svn r8726) -Codechange: bools are 1 or 0 according to the C++ standard and refactor RoadStop::AllocateBay to remove a loop condition. Suggestions by Tron.
rubidium
parents:
5998
diff
changeset
|
521 |
uint bay_nr = 0; |
f9ddc290e8b0
(svn r8726) -Codechange: bools are 1 or 0 according to the C++ standard and refactor RoadStop::AllocateBay to remove a loop condition. Suggestions by Tron.
rubidium
parents:
5998
diff
changeset
|
522 |
while (!HASBIT(status, bay_nr)) bay_nr++; |
5990
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
523 |
|
6005
f9ddc290e8b0
(svn r8726) -Codechange: bools are 1 or 0 according to the C++ standard and refactor RoadStop::AllocateBay to remove a loop condition. Suggestions by Tron.
rubidium
parents:
5998
diff
changeset
|
524 |
CLRBIT(status, bay_nr); |
f9ddc290e8b0
(svn r8726) -Codechange: bools are 1 or 0 according to the C++ standard and refactor RoadStop::AllocateBay to remove a loop condition. Suggestions by Tron.
rubidium
parents:
5998
diff
changeset
|
525 |
return bay_nr; |
5990
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
526 |
} |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
527 |
|
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
528 |
/** |
6012
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
529 |
* Allocates a bay in a drive-through road stop |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
530 |
* @param nr the number of the bay to allocate |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
531 |
*/ |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
532 |
void RoadStop::AllocateDriveThroughBay(uint nr) |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
533 |
{ |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
534 |
assert(nr < MAX_BAY_COUNT); |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
535 |
CLRBIT(status, nr); |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
536 |
} |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
537 |
|
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6005
diff
changeset
|
538 |
/** |
5990
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
539 |
* Frees the given bay |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
540 |
* @param nr the number of the bay to free |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
541 |
*/ |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
542 |
void RoadStop::FreeBay(uint nr) |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
543 |
{ |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
544 |
assert(nr < MAX_BAY_COUNT); |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
545 |
SETBIT(status, nr); |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
546 |
} |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
547 |
|
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
548 |
|
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
549 |
/** Checks whether the entrance of the road stop is occupied by a vehicle */ |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
550 |
bool RoadStop::IsEntranceBusy() const |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
551 |
{ |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
552 |
return HASBIT(status, 7); |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
553 |
} |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
554 |
|
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
555 |
/** Makes an entrance occupied or free */ |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
556 |
void RoadStop::SetEntranceBusy(bool busy) |
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
557 |
{ |
6005
f9ddc290e8b0
(svn r8726) -Codechange: bools are 1 or 0 according to the C++ standard and refactor RoadStop::AllocateBay to remove a loop condition. Suggestions by Tron.
rubidium
parents:
5998
diff
changeset
|
558 |
SB(status, 7, 1, busy); |
5990
280fbef32d44
(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
rubidium
parents:
5910
diff
changeset
|
559 |
} |