author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5867 | b7aa408ce6f3 |
child 5896 | a9f7bdd841d4 |
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 |
|
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
|
3 |
/** @file station_cmd.c */ |
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 |
|
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
|
51 |
last_vehicle_type = VEH_Invalid; |
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 |
/** |
5678 | 58 |
* Clean up a station by clearing vehicle orders and invalidating windows. |
59 |
* Aircraft-Hangar orders need special treatment here, as the hangars are |
|
60 |
* actually part of a station (tiletype is STATION), but the order type |
|
61 |
* is OT_GOTO_DEPOT. |
|
62 |
* @param st Station to be deleted |
|
63 |
*/ |
|
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
|
64 |
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
|
65 |
{ |
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 |
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
|
67 |
|
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 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
|
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 |
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
|
74 |
|
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 |
/* 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
|
76 |
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
|
77 |
|
5678 | 78 |
/* 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
|
79 |
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
|
80 |
|
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 |
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
|
82 |
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
|
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 |
|
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 |
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
|
86 |
{ |
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 |
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
|
88 |
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
|
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 |
|
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 |
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
|
92 |
{ |
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 |
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
|
94 |
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
|
95 |
|
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 |
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
|
97 |
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
|
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 |
|
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 |
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
|
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 |
|
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 |
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
|
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 |
} |
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
|
107 |
|
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
|
108 |
/** Called when new facility is built on the station. If it is the first facility |
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 |
* it initializes also 'xy' and 'random_bits' members */ |
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 |
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
|
111 |
{ |
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 |
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
|
113 |
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
|
114 |
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
|
115 |
} |
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 |
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
|
117 |
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
|
118 |
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
|
119 |
} |
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
|
120 |
|
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
|
121 |
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
|
122 |
{ |
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 |
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
|
124 |
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
|
125 |
|
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 |
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
|
127 |
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
|
128 |
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
|
129 |
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
|
130 |
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
|
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 |
|
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 |
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
|
135 |
{ |
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 |
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
|
137 |
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
|
138 |
|
5678 | 139 |
/* 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
|
140 |
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
|
141 |
|
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 (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
|
143 |
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
|
144 |
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
|
145 |
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
|
146 |
} |
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 |
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
|
148 |
} |
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 |
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
|
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 |
|
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 |
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
|
154 |
{ |
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 |
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
|
156 |
} |
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
|
157 |
|
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 |
/*static*/ Station *Station::AllocateRaw(void) |
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 |
{ |
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 |
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
|
161 |
|
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 |
/* 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
|
163 |
* 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
|
164 |
for (st = GetStation(0); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : 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
|
165 |
if (!IsValidStation(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
|
166 |
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
|
167 |
|
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 |
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
|
169 |
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
|
170 |
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
|
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 |
|
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 |
/* 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
|
175 |
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
|
176 |
|
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 |
_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
|
178 |
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
|
179 |
} |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
180 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
181 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
182 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
183 |
/************************************************************************/ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
184 |
/* StationRect implementation */ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
185 |
/************************************************************************/ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
186 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
187 |
StationRect::StationRect() |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
188 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
189 |
MakeEmpty(); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
190 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
191 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
192 |
void StationRect::MakeEmpty() |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
193 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
194 |
left = top = right = bottom = 0; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
195 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
196 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
197 |
bool StationRect::PtInRectXY(int x, int y) const |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
198 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
199 |
return (left <= x && x <= right && top <= y && y <= bottom); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
200 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
201 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
202 |
bool StationRect::IsEmpty() const |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
203 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
204 |
return (left == 0 || left > right || top > bottom); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
205 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
206 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
207 |
bool StationRect::BeforeAddTile(TileIndex tile, StationRectMode mode) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
208 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
209 |
int x = TileX(tile); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
210 |
int y = TileY(tile); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
211 |
if (IsEmpty()) { |
5678 | 212 |
/* 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
|
213 |
left = right = x; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
214 |
top = bottom = y; |
5678 | 215 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
216 |
} else if (!PtInRectXY(x, y)) { |
5678 | 217 |
/* current rect is not empty and new point is outside this rect */ |
218 |
/* make new spread-out rectangle */ |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
219 |
Rect new_rect = {min(x, left), min(y, top), max(x, right), max(y, bottom)}; |
5678 | 220 |
|
221 |
/* 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
|
222 |
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
|
223 |
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
|
224 |
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
|
225 |
assert(mode != ADD_TRY); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
226 |
_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
|
227 |
return false; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
228 |
} |
5678 | 229 |
|
230 |
/* spread-out ok, return true */ |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
231 |
if (mode != ADD_TEST) { |
5678 | 232 |
/* we should update the station rect */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
233 |
*this = new_rect; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
234 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
235 |
} else { |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
236 |
; // 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
|
237 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
238 |
return true; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
239 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
240 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
241 |
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
|
242 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
243 |
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
|
244 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
245 |
|
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
246 |
/*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
|
247 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
248 |
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
|
249 |
int width = right_a - left_a + 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
250 |
int height = bottom_a - top_a + 1; |
5678 | 251 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
252 |
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
|
253 |
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
|
254 |
END_TILE_LOOP(tile, width, height, top_left); |
5678 | 255 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
256 |
return false; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
257 |
} |
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 |
bool StationRect::AfterRemoveTile(Station *st, TileIndex tile) |
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 |
int x = TileX(tile); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
262 |
int y = TileY(tile); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
263 |
|
5678 | 264 |
/* look if removed tile was on the bounding rect edge |
265 |
* and try to reduce the rect by this edge |
|
266 |
* 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
|
267 |
for (;;) { |
5678 | 268 |
/* 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
|
269 |
bool left_edge = (x == left); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
270 |
bool right_edge = (x == right); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
271 |
bool top_edge = (y == top); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
272 |
bool bottom_edge = (y == bottom); |
5678 | 273 |
|
274 |
/* can we reduce the rect in either direction? */ |
|
275 |
bool reduce_x = ((left_edge || right_edge) && !ScanForStationTiles(st->index, x, top, x, bottom)); |
|
276 |
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
|
277 |
if (!(reduce_x || reduce_y)) break; // nothing to do (can't reduce) |
5678 | 278 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
279 |
if (reduce_x) { |
5678 | 280 |
/* reduce horizontally */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
281 |
if (left_edge) { |
5678 | 282 |
/* move left edge right */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
283 |
left = x = x + 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
284 |
} else { |
5678 | 285 |
/* move right edge left */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
286 |
right = x = x - 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
287 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
288 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
289 |
if (reduce_y) { |
5678 | 290 |
/* reduce vertically */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
291 |
if (top_edge) { |
5678 | 292 |
/* move top edge down */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
293 |
top = y = y + 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
294 |
} else { |
5678 | 295 |
/* move bottom edge up */ |
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
296 |
bottom = y = y - 1; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
297 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
298 |
} |
5678 | 299 |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
300 |
if (left > right || top > bottom) { |
5678 | 301 |
/* 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
|
302 |
MakeEmpty(); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
303 |
return true; // empty remaining rect |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
304 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
305 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
306 |
return false; // non-empty remaining rect |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
307 |
} |
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 |
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
|
310 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
311 |
assert(PtInRectXY(TileX(tile), TileY(tile))); |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
312 |
assert(PtInRectXY(TileX(tile) + w - 1, TileY(tile) + h - 1)); |
5678 | 313 |
|
314 |
bool empty = AfterRemoveTile(st, tile); |
|
5676
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
315 |
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
|
316 |
return empty; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
317 |
} |
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 |
StationRect& StationRect::operator = (Rect src) |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
320 |
{ |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
321 |
left = src.left; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
322 |
top = src.top; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
323 |
right = src.right; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
324 |
bottom = src.bottom; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
325 |
return *this; |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
326 |
} |
7a641ebbc080
(svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents:
5670
diff
changeset
|
327 |
|
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
|
328 |
|
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
|
329 |
/************************************************************************/ |
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
|
330 |
/* 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
|
331 |
/************************************************************************/ |
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
|
332 |
|
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
|
333 |
/** 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
|
334 |
* @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
|
335 |
*/ |
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
|
336 |
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
|
337 |
{ |
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
|
338 |
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
|
339 |
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
|
340 |
} |
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
|
341 |
|
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
|
342 |
/** 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
|
343 |
* @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
|
344 |
*/ |
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
|
345 |
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
|
346 |
{ |
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
|
347 |
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
|
348 |
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
|
349 |
} |
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
|
350 |
|
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
|
351 |
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
|
352 |
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
|
353 |
} |
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
|
354 |
|
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
|
355 |
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
|
356 |
{ |
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
|
357 |
} |
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
|
358 |
|
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
|
359 |
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
|
360 |
{ |
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
|
361 |
} |
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
|
362 |
|
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
|
363 |
/** Initializes a RoadStop */ |
5716 | 364 |
RoadStop::RoadStop(TileIndex tile) : |
5713 | 365 |
xy(tile), |
366 |
status(3), // stop is free |
|
367 |
num_vehicles(0), |
|
5867 | 368 |
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
|
369 |
{ |
5716 | 370 |
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
|
371 |
} |
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
|
372 |
|
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
|
373 |
/** 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
|
374 |
* 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
|
375 |
*/ |
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
|
376 |
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
|
377 |
{ |
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
|
378 |
/* 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
|
379 |
if (num_vehicles != 0) { |
5713 | 380 |
Vehicle *v; |
381 |
||
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
|
382 |
FOR_ALL_VEHICLES(v) { |
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
|
383 |
if (v->type == VEH_Road && v->u.road.slot == this) ClearSlot(v); |
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
|
384 |
} |
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
|
385 |
} |
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
|
386 |
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
|
387 |
|
5716 | 388 |
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
|
389 |
|
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
|
390 |
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
|
391 |
} |
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
|
392 |
|
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
|
393 |
|
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
|
394 |
/** Low-level function for allocating a RoadStop on 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
|
395 |
RoadStop *RoadStop::AllocateRaw( void ) |
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
|
396 |
{ |
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
|
397 |
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
|
398 |
|
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
|
399 |
/* 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
|
400 |
* 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
|
401 |
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
|
402 |
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
|
403 |
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
|
404 |
|
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 |
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
|
406 |
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
|
407 |
|
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 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
|
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 |
} |
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 |
/* 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
|
413 |
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
|
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 |
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
|
416 |
} |
5835
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
417 |
|
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
418 |
/** 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
|
419 |
bool RoadStop::IsValid() const |
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
420 |
{ |
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
421 |
return xy != INVALID_TILE; |
7ef65a4a70ef
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents:
5721
diff
changeset
|
422 |
} |