summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_waypoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api/ai_waypoint.cpp')
-rw-r--r--src/ai/api/ai_waypoint.cpp34
1 files changed, 3 insertions, 31 deletions
diff --git a/src/ai/api/ai_waypoint.cpp b/src/ai/api/ai_waypoint.cpp
index d0286c429..c32df4ee8 100644
--- a/src/ai/api/ai_waypoint.cpp
+++ b/src/ai/api/ai_waypoint.cpp
@@ -12,43 +12,15 @@
#include "../../core/alloc_func.hpp"
#include "table/strings.h"
-/* static */ bool AIWaypoint::IsValidWaypoint(WaypointID waypoint_id)
+/* static */ bool AIWaypoint::IsValidWaypoint(StationID waypoint_id)
{
const Waypoint *wp = ::Waypoint::GetIfValid(waypoint_id);
return wp != NULL && wp->owner == _current_company;
}
-/* static */ WaypointID AIWaypoint::GetWaypointID(TileIndex tile)
+/* static */ StationID AIWaypoint::GetWaypointID(TileIndex tile)
{
- if (!AIRail::IsRailWaypointTile(tile)) return WAYPOINT_INVALID;
+ if (!AIRail::IsRailWaypointTile(tile)) return STATION_INVALID;
return ::GetStationIndex(tile);
}
-
-/* static */ char *AIWaypoint::GetName(WaypointID waypoint_id)
-{
- if (!IsValidWaypoint(waypoint_id)) return NULL;
-
- static const int len = 64;
- char *waypoint_name = MallocT<char>(len);
-
- ::SetDParam(0, waypoint_id);
- ::GetString(waypoint_name, STR_WAYPOINT_NAME, &waypoint_name[len - 1]);
- return waypoint_name;
-}
-
-/* static */ bool AIWaypoint::SetName(WaypointID waypoint_id, const char *name)
-{
- EnforcePrecondition(false, IsValidWaypoint(waypoint_id));
- EnforcePrecondition(false, !::StrEmpty(name));
- 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);
-}
-
-/* static */ TileIndex AIWaypoint::GetLocation(WaypointID waypoint_id)
-{
- if (!IsValidWaypoint(waypoint_id)) return INVALID_TILE;
-
- return ::Waypoint::Get(waypoint_id)->xy;
-}