From e473e69ba4d59df7f9cdd9a5010cf54a66fd5b90 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 28 Jul 2009 21:06:38 +0000 Subject: [PATCH] (svn r16976) -Codechange: remove WaypointID and MAX_LENGTH constants in favour of their Station variants --- src/ai/api/ai_waypoint.cpp | 2 +- src/order_base.h | 3 +-- src/order_cmd.cpp | 3 +-- src/rail_map.h | 1 - src/station_type.h | 1 + src/vehicle_gui.h | 1 - src/waypoint_base.h | 1 - src/waypoint_cmd.cpp | 6 +++--- src/waypoint_func.h | 2 +- src/waypoint_gui.cpp | 2 +- src/waypoint_type.h | 16 ---------------- 11 files changed, 9 insertions(+), 29 deletions(-) delete mode 100644 src/waypoint_type.h diff --git a/src/ai/api/ai_waypoint.cpp b/src/ai/api/ai_waypoint.cpp index e2a7c38611..d0286c429e 100644 --- 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); } diff --git a/src/order_base.h b/src/order_base.h index 4b1aba9b41..1d3753beca 100644 --- 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 OrderPool; typedef Pool OrderListPool; @@ -92,7 +91,7 @@ public: * 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. diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 3d43c50687..06a9ef5acd 100644 --- 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 @@ void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderN this->SetRefit(cargo, subtype); } -void Order::MakeGoToWaypoint(WaypointID destination) +void Order::MakeGoToWaypoint(StationID destination) { this->type = OT_GOTO_WAYPOINT; this->flags = 0; diff --git a/src/rail_map.h b/src/rail_map.h index 332ee46fd1..957a2a222e 100644 --- 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 */ diff --git a/src/station_type.h b/src/station_type.h index 4af075f201..7a5f1c2f7b 100644 --- a/src/station_type.h +++ b/src/station_type.h @@ -15,6 +15,7 @@ struct BaseStation; struct Station; struct RoadStop; struct StationSpec; +struct Waypoint; static const StationID NEW_STATION = 0xFFFE; static const StationID INVALID_STATION = 0xFFFF; diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index b205db17e4..20f01808af 100644 --- 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); diff --git a/src/waypoint_base.h b/src/waypoint_base.h index 9525032604..ae7ed5f61a 100644 --- 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 { diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp index 30f23ac9ea..bb18b9c14c 100644 --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -44,7 +44,7 @@ void MakeDefaultWaypointName(Waypoint *wp) { 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 @@ void MakeDefaultWaypointName(Waypoint *wp) * 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 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui 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); } diff --git a/src/waypoint_func.h b/src/waypoint_func.h index 0709eee49c..f55af4429f 100644 --- 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); diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 46478505c0..03f6fcc468 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -82,7 +82,7 @@ public: 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 diff --git a/src/waypoint_type.h b/src/waypoint_type.h deleted file mode 100644 index 404ba7c680..0000000000 --- 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 */