summaryrefslogtreecommitdiff
path: root/waypoint.h
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-03-24 17:03:37 +0000
committertruelight <truelight@openttd.org>2005-03-24 17:03:37 +0000
commit83637d164e8be15166aeb39134170ecbe02173d3 (patch)
tree45d160ba77950eea4f380bd7ff3bbcf6644f651a /waypoint.h
parentf86318407ca89cecce23128f34c61f9fa4f078b7 (diff)
downloadopenttd-83637d164e8be15166aeb39134170ecbe02173d3.tar.xz
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
-Codechange: rewrote some functions while moving waypoint-stuff -Add: added support for 64k waypoints -Fix: made the waypoint struct a bit more logic (no bit-fucking)
Diffstat (limited to 'waypoint.h')
-rw-r--r--waypoint.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/waypoint.h b/waypoint.h
new file mode 100644
index 000000000..186b8c154
--- /dev/null
+++ b/waypoint.h
@@ -0,0 +1,60 @@
+#ifndef WAYPOINT_H
+#define WAYPOINT_H
+
+#include "pool.h"
+
+struct Waypoint {
+ TileIndex xy;
+ uint16 index;
+
+ uint16 town_index;
+ byte town_cn; // The Nth waypoint for this town (consecutive number)
+ StringID string; // If this is zero, town + town_cn is used for naming
+
+ ViewportSign sign;
+ uint16 build_date;
+ byte stat_id;
+ byte deleted; // this is a delete counter. when it reaches 0, the waypoint struct is deleted.
+};
+
+enum {
+ RAIL_TYPE_WAYPOINT = 0xC4,
+ RAIL_WAYPOINT_TRACK_MASK = 1,
+};
+
+extern MemoryPool _waypoint_pool;
+
+/**
+ * Get the pointer to the waypoint with index 'index'
+ */
+static inline Waypoint *GetWaypoint(uint index)
+{
+ return (Waypoint*)GetItemFromPool(&_waypoint_pool, index);
+}
+
+/**
+ * Get the current size of the WaypointPool
+ */
+static inline uint16 GetWaypointPoolSize(void)
+{
+ return _waypoint_pool.total_items;
+}
+
+#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1 < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1) : NULL)
+#define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
+
+static inline bool IsRailWaypoint(byte m5)
+{
+ return (m5 & 0xFC) == 0xC4;
+}
+
+int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove);
+Station *ComposeWaypointStation(uint tile);
+Waypoint *GetWaypointByTile(TileIndex tile);
+void ShowRenameWaypointWindow(Waypoint *cp);
+void DrawWaypointSprite(int x, int y, int image, int railtype);
+void UpdateWaypointSign(Waypoint *cp);
+void FixOldWaypoints(void);
+void UpdateAllWaypointSigns(void);
+
+#endif /* WAYPOINT_H */