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
commitd1e158d6f723b6fcb2f1edf1ffac29b81ed307e7 (patch)
tree45d160ba77950eea4f380bd7ff3bbcf6644f651a /waypoint.h
parent625d041e99b5ddd75a8f4cd3a1e11d9923d219f9 (diff)
downloadopenttd-d1e158d6f723b6fcb2f1edf1ffac29b81ed307e7.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 */