changeset 12538:6e39a114ed49 draft

(svn r16976) -Codechange: remove WaypointID and MAX_LENGTH constants in favour of their Station variants
author rubidium <rubidium@openttd.org>
date Tue, 28 Jul 2009 21:06:38 +0000
parents c8f92c5ca668
children b8c81bc9cb33
files src/ai/api/ai_waypoint.cpp src/order_base.h src/order_cmd.cpp src/rail_map.h src/station_type.h src/vehicle_gui.h src/waypoint_base.h src/waypoint_cmd.cpp src/waypoint_func.h src/waypoint_gui.cpp src/waypoint_type.h
diffstat 11 files changed, 9 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/api/ai_waypoint.cpp
+++ b/src/ai/api/ai_waypoint.cpp
@@ -41,7 +41,7 @@
 {
 	EnforcePrecondition(false, IsValidWaypoint(waypoint_id));
 	EnforcePrecondition(false, !::StrEmpty(name));
-	EnforcePreconditionCustomError(false, ::strlen(name) < MAX_LENGTH_WAYPOINT_NAME_BYTES, AIError::ERR_PRECONDITION_STRING_TOO_LONG);
+	EnforcePreconditionCustomError(false, ::strlen(name) < MAX_LENGTH_STATION_NAME_BYTES, AIError::ERR_PRECONDITION_STRING_TOO_LONG);
 
 	return AIObject::DoCommand(0, waypoint_id, 0, CMD_RENAME_WAYPOINT, name);
 }
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -12,7 +12,6 @@
 #include "depot_type.h"
 #include "station_type.h"
 #include "vehicle_type.h"
-#include "waypoint_type.h"
 
 typedef Pool<Order, OrderID, 256, 64000> OrderPool;
 typedef Pool<OrderList, OrderListID, 128, 64000> OrderListPool;
@@ -92,7 +91,7 @@
 	 * Makes this order a Go To Waypoint order.
 	 * @param destination the waypoint to go to.
 	 */
-	void MakeGoToWaypoint(WaypointID destination);
+	void MakeGoToWaypoint(StationID destination);
 
 	/**
 	 * Makes this order a Loading order.
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -32,7 +32,6 @@
  * be any of them
  */
 assert_compile(sizeof(DestinationID) >= sizeof(DepotID));
-assert_compile(sizeof(DestinationID) >= sizeof(WaypointID));
 assert_compile(sizeof(DestinationID) >= sizeof(StationID));
 
 TileIndex _backup_orders_tile;
@@ -68,7 +67,7 @@
 	this->SetRefit(cargo, subtype);
 }
 
-void Order::MakeGoToWaypoint(WaypointID destination)
+void Order::MakeGoToWaypoint(StationID destination)
 {
 	this->type = OT_GOTO_WAYPOINT;
 	this->flags = 0;
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -11,7 +11,6 @@
 #include "track_func.h"
 #include "tile_map.h"
 #include "signal_type.h"
-#include "waypoint_type.h"
 
 
 /** Different types of Rail-related tiles */
--- a/src/station_type.h
+++ b/src/station_type.h
@@ -15,6 +15,7 @@
 struct Station;
 struct RoadStop;
 struct StationSpec;
+struct Waypoint;
 
 static const StationID NEW_STATION = 0xFFFE;
 static const StationID INVALID_STATION = 0xFFFF;
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -10,7 +10,6 @@
 #include "order_type.h"
 #include "station_type.h"
 #include "engine_type.h"
-#include "waypoint_type.h"
 #include "tile_type.h"
 
 void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
--- a/src/waypoint_base.h
+++ b/src/waypoint_base.h
@@ -5,7 +5,6 @@
 #ifndef WAYPOINT_H
 #define WAYPOINT_H
 
-#include "waypoint_type.h"
 #include "base_station_base.h"
 
 struct Waypoint : SpecializedStation<Waypoint, true> {
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -44,7 +44,7 @@
 {
 	uint32 used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base
 	uint32 next = 0; // first waypoint number in the bitmap
-	WaypointID idx = 0; // index where we will stop
+	StationID idx = 0; // index where we will stop
 
 	wp->town = ClosestTownFromTile(wp->xy, UINT_MAX);
 
@@ -58,7 +58,7 @@
 	 * If it wasn't using 'used' and 'idx', it would just search for increasing 'next',
 	 * but this way it is faster */
 
-	WaypointID cid = 0; // current index, goes to Waypoint::GetPoolSize()-1, then wraps to 0
+	StationID cid = 0; // current index, goes to Waypoint::GetPoolSize()-1, then wraps to 0
 	do {
 		Waypoint *lwp = Waypoint::GetIfValid(cid);
 
@@ -386,7 +386,7 @@
 	bool reset = StrEmpty(text);
 
 	if (!reset) {
-		if (strlen(text) >= MAX_LENGTH_WAYPOINT_NAME_BYTES) return CMD_ERROR;
+		if (strlen(text) >= MAX_LENGTH_STATION_NAME_BYTES) return CMD_ERROR;
 		if (!IsUniqueWaypointName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
 	}
 
--- a/src/waypoint_func.h
+++ b/src/waypoint_func.h
@@ -7,7 +7,7 @@
 
 #include "rail_type.h"
 #include "command_type.h"
-#include "waypoint_type.h"
+#include "station_type.h"
 
 CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justremove);
 CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags);
--- a/src/waypoint_gui.cpp
+++ b/src/waypoint_gui.cpp
@@ -82,7 +82,7 @@
 
 			case WAYPVW_RENAME: // rename
 				SetDParam(0, this->wp->index);
-				ShowQueryString(STR_WAYPOINT_NAME, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_WAYPOINT_NAME_BYTES, MAX_LENGTH_WAYPOINT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
+				ShowQueryString(STR_WAYPOINT_NAME, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_STATION_NAME_BYTES, MAX_LENGTH_STATION_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 				break;
 
 			case WAYPVW_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders
deleted file mode 100644
--- a/src/waypoint_type.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* $Id$ */
-
-/** @file waypoint_type.h Types related to waypoints. */
-
-#ifndef WAYPOINT_TYPE_H
-#define WAYPOINT_TYPE_H
-
-typedef uint16 WaypointID;
-struct Waypoint;
-
-enum {
-	MAX_LENGTH_WAYPOINT_NAME_BYTES  =  31, ///< The maximum length of a waypoint name in bytes including '\0'
-	MAX_LENGTH_WAYPOINT_NAME_PIXELS = 180, ///< The maximum length of a waypoint name in pixels
-};
-
-#endif /* WAYPOINT_TYPE_H */