author | rubidium |
Sun, 25 May 2008 19:17:03 +0000 | |
changeset 9354 | 845e07db4549 |
parent 9129 | a7b713cb0422 |
child 9949 | 392998225bdd |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8962
diff
changeset
|
3 |
/** @file waypoint.h Base of waypoints. */ |
6432
226650eb2ef3
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6247
diff
changeset
|
4 |
|
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
5 |
#ifndef WAYPOINT_H |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
6 |
#define WAYPOINT_H |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
7 |
|
8775
fd5e36ec9f6c
(svn r12474) -Codechange: split type related stuff from waypoints from waypoint.h (and openttd.h) to waypoint_type.h.
rubidium
parents:
8769
diff
changeset
|
8 |
#include "waypoint_type.h" |
5216
8bd14ee39af2
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
4984
diff
changeset
|
9 |
#include "oldpool.h" |
3239
9b1030ac7d83
(svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents:
2817
diff
changeset
|
10 |
#include "rail_map.h" |
8237
6f925c9cf836
(svn r11801) -Codechange: remove some unneeded includes from some header files.
rubidium
parents:
7496
diff
changeset
|
11 |
#include "command_type.h" |
8769
b554c4996eb1
(svn r12468) -Codechange: move some type related stuff from station.h (and openttd.h) to station_type.h.
rubidium
parents:
8579
diff
changeset
|
12 |
#include "station_type.h" |
8962
1b263c69799d
(svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents:
8775
diff
changeset
|
13 |
#include "town_type.h" |
9129
a7b713cb0422
(svn r12989) -Codechange: move ViewportSign to viewport_type.h.
rubidium
parents:
9111
diff
changeset
|
14 |
#include "viewport_type.h" |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
15 |
|
7381
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
16 |
DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000) |
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
17 |
|
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
18 |
struct Waypoint : PoolItem<Waypoint, WaypointID, &_Waypoint_pool> { |
2670
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
19 |
TileIndex xy; ///< Tile of waypoint |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
20 |
|
3346
a0d4def7d934
(svn r4130) - CodeChange: Add proper semantics for TownID for such variables instead of using the general uint16-type. We probably need to change GetTown() and IsTownIndex() as well to use TownID.
Darkvater
parents:
3239
diff
changeset
|
21 |
TownID town_index; ///< Town associated with the waypoint |
8579
db463f9c0256
(svn r12160) -Fix [FS#1744]: remove the arbitrary limit of 64 waypoints per town, so weird things won't happen anymore
smatz
parents:
8258
diff
changeset
|
22 |
uint16 town_cn; ///< The Nth waypoint for this town (consecutive number) |
8258
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8237
diff
changeset
|
23 |
StringID string; ///< C000-C03F have special meaning in old games |
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8237
diff
changeset
|
24 |
char *name; ///< Custom name. If not set, town + town_cn is used for naming |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
25 |
|
2670
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
26 |
ViewportSign sign; ///< Dimensions of sign (not saved) |
4289
8981ce44336d
(svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents:
4044
diff
changeset
|
27 |
Date build_date; ///< Date of construction |
2670
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
28 |
|
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
29 |
byte stat_id; ///< ID of waypoint within the waypoint class (not saved) |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
30 |
uint32 grfid; ///< ID of GRF file |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
31 |
byte localidx; ///< Index of station within GRF file |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
32 |
|
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
33 |
byte deleted; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted. |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
34 |
|
7381
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
35 |
Waypoint(TileIndex tile = 0); |
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
36 |
~Waypoint(); |
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
37 |
|
7496
49cec492627b
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7413
diff
changeset
|
38 |
inline bool IsValid() const { return this->xy != 0; } |
7381
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
39 |
}; |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4289
diff
changeset
|
40 |
|
4389
18d6ccfb5335
(svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore)
truelight
parents:
4352
diff
changeset
|
41 |
static inline bool IsValidWaypointID(WaypointID index) |
4352
6703cd8d39e0
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4346
diff
changeset
|
42 |
{ |
7381
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
43 |
return index < GetWaypointPoolSize() && GetWaypoint(index)->IsValid(); |
4352
6703cd8d39e0
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4346
diff
changeset
|
44 |
} |
6703cd8d39e0
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4346
diff
changeset
|
45 |
|
4390
c7adc07e4301
(svn r6143) -Codechange: DeleteWaypoint removes a waypoint from the pool
truelight
parents:
4389
diff
changeset
|
46 |
static inline void DeleteWaypoint(Waypoint *wp) |
c7adc07e4301
(svn r6143) -Codechange: DeleteWaypoint removes a waypoint from the pool
truelight
parents:
4389
diff
changeset
|
47 |
{ |
7381
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
48 |
wp->~Waypoint(); |
4390
c7adc07e4301
(svn r6143) -Codechange: DeleteWaypoint removes a waypoint from the pool
truelight
parents:
4389
diff
changeset
|
49 |
} |
c7adc07e4301
(svn r6143) -Codechange: DeleteWaypoint removes a waypoint from the pool
truelight
parents:
4389
diff
changeset
|
50 |
|
7381
d7991ec3f19d
(svn r10750) -Codechange: make the waypoint struct use the new poolitem class as super class.
rubidium
parents:
7318
diff
changeset
|
51 |
#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1U) : NULL) if (wp->IsValid()) |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
52 |
#define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0) |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
53 |
|
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
54 |
|
2670
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
55 |
/** |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
56 |
* Fetch a waypoint by tile |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
57 |
* @param tile Tile of waypoint |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
58 |
* @return Waypoint |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
59 |
*/ |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
60 |
static inline Waypoint *GetWaypointByTile(TileIndex tile) |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
61 |
{ |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
62 |
assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile)); |
6182
7337aca829f1
(svn r8954) -Codechange: remove direct map accesses from non-map-accessor headers.
rubidium
parents:
5475
diff
changeset
|
63 |
return GetWaypoint(GetWaypointIndex(tile)); |
2670
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
64 |
} |
f2d6a8424e3e
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
65 |
|
6943
1914f26aee04
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
6432
diff
changeset
|
66 |
CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove); |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1718
diff
changeset
|
67 |
Station *ComposeWaypointStation(TileIndex tile); |
2116 | 68 |
void ShowRenameWaypointWindow(const Waypoint *cp); |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6943
diff
changeset
|
69 |
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype); |
6247 | 70 |
void FixOldWaypoints(); |
71 |
void UpdateAllWaypointSigns(); |
|
72 |
void AfterLoadWaypoints(); |
|
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
73 |
|
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
diff
changeset
|
74 |
#endif /* WAYPOINT_H */ |