(svn r6143) -Codechange: DeleteWaypoint removes a waypoint from the pool
authortruelight
Sat, 26 Aug 2006 16:46:32 +0000
changeset 4390 c7adc07e4301
parent 4389 18d6ccfb5335
child 4391 40c1c7dd05f3
(svn r6143) -Codechange: DeleteWaypoint removes a waypoint from the pool
-Codechange: DestroyWaypoint is called by DeleteWaypoint to remove all things where a waypoint depends on.
Last 2 changes to prepare for new pool system. Not pretty now, will be soon.
waypoint.c
waypoint.h
--- a/waypoint.c	Sat Aug 26 16:34:03 2006 +0000
+++ b/waypoint.c	Sat Aug 26 16:46:32 2006 +0000
@@ -95,6 +95,16 @@
 	}
 }
 
+/* Internal handler to delete a waypoint */
+void DestroyWaypoint(Waypoint *wp)
+{
+	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, (DestinationID)wp->index);
+
+	if (wp->string != STR_NULL) DeleteName(wp->string);
+
+	RedrawWaypointSign(wp);
+}
+
 /* Set the default name for a waypoint */
 static void MakeDefaultWaypointName(Waypoint* wp)
 {
@@ -244,18 +254,6 @@
 	return _price.build_train_depot;
 }
 
-/* Internal handler to delete a waypoint */
-static void DoDeleteWaypoint(Waypoint *wp)
-{
-	wp->xy = 0;
-
-	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, (DestinationID)wp->index);
-
-	if (wp->string != STR_NULL) DeleteName(wp->string);
-
-	RedrawWaypointSign(wp);
-}
-
 /* Daily loop for waypoints */
 void WaypointsDailyLoop(void)
 {
@@ -263,7 +261,7 @@
 
 	/* Check if we need to delete a waypoint */
 	FOR_ALL_WAYPOINTS(wp) {
-		if (wp->deleted != 0 && --wp->deleted == 0) DoDeleteWaypoint(wp);
+		if (wp->deleted != 0 && --wp->deleted == 0) DestroyWaypoint(wp);
 	}
 }
 
--- a/waypoint.h	Sat Aug 26 16:34:03 2006 +0000
+++ b/waypoint.h	Sat Aug 26 16:46:32 2006 +0000
@@ -55,6 +55,14 @@
 	return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index));
 }
 
+void DestroyWaypoint(Waypoint *wp);
+
+static inline void DeleteWaypoint(Waypoint *wp)
+{
+	DestroyWaypoint(wp);
+	wp->xy = 0;
+}
+
 #define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1 < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1) : NULL) if (IsValidWaypoint(wp))
 #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)