summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-01-02 16:47:32 +0000
committeryexo <yexo@openttd.org>2010-01-02 16:47:32 +0000
commitd8bcda3b94840a7b3d274ff33e855911ce517e3f (patch)
treef3e3e4f633fa879a97a06a690ee8a35d0b4a86fe /src
parent43a5a4bee8b2121c713782b8f5f1136cbf5e5b53 (diff)
downloadopenttd-d8bcda3b94840a7b3d274ff33e855911ce517e3f.tar.xz
(svn r18691) -Change [NoAI]: cleanup some errors messages and add a few to AIWaypoint
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_changelog.hpp2
-rw-r--r--src/ai/api/ai_error.hpp1
-rw-r--r--src/ai/api/ai_error.hpp.sq1
-rw-r--r--src/ai/api/ai_station.hpp5
-rw-r--r--src/ai/api/ai_station.hpp.sq16
-rw-r--r--src/ai/api/ai_waypoint.hpp14
-rw-r--r--src/ai/api/ai_waypoint.hpp.sq14
7 files changed, 40 insertions, 13 deletions
diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp
index af82a18e5..fa35e559e 100644
--- a/src/ai/api/ai_changelog.hpp
+++ b/src/ai/api/ai_changelog.hpp
@@ -34,12 +34,14 @@
* \li AISubsidy::GetDestinationIndex
* \li AITown::GetLastMonthTransportedPercentage
* \li AIVehicleList_Depot
+ * \li Some error messages to AIWaypoint
*
* API removals:
* \li AIOrder::ChangeOrder, use AIOrder::SetOrderFlags instead
* \li AIRail::RemoveRailStationTileRect, use AIRail::RemoveRailStationTileRectangle instead
* \li AIRail::RemoveRailWaypoint, use AIRail::RemoveRailWaypointTileRectangle instead
* \li AISign::GetMaxSignID, use AISignList instead
+ * \li AIStation::ERR_STATION_TOO_LARGE, use AIError::ERR_STATION_TOO_SPREAD_OUT instead
* \li AISubsidy::SourceIsTown, use AISubsidy::GetSourceType instead
* \li AISubsidy::GetSource, use AISubsidy::GetSourceIndex instead
* \li AISubsidy::DestinationIsTown, use AISubsidy::GetDestinationType instead
diff --git a/src/ai/api/ai_error.hpp b/src/ai/api/ai_error.hpp
index 6ca08c1cf..44e36405f 100644
--- a/src/ai/api/ai_error.hpp
+++ b/src/ai/api/ai_error.hpp
@@ -61,6 +61,7 @@ public:
ERR_CAT_ROAD, //!< Error messages related to building / maintaining roads.
ERR_CAT_ORDER, //!< Error messages related to managing orders.
ERR_CAT_MARINE, //!< Error messages related to building / removing ships, docks and channels.
+ ERR_CAT_WAYPOINT, //!< Error messages related to building / maintaining waypoints.
/**
* DO NOT USE! The error bitsize determines how many errors can be stored in
diff --git a/src/ai/api/ai_error.hpp.sq b/src/ai/api/ai_error.hpp.sq
index 0a5337cfb..e8d3aa643 100644
--- a/src/ai/api/ai_error.hpp.sq
+++ b/src/ai/api/ai_error.hpp.sq
@@ -44,6 +44,7 @@ void SQAIError_Register(Squirrel *engine)
SQAIError.DefSQConst(engine, AIError::ERR_CAT_ROAD, "ERR_CAT_ROAD");
SQAIError.DefSQConst(engine, AIError::ERR_CAT_ORDER, "ERR_CAT_ORDER");
SQAIError.DefSQConst(engine, AIError::ERR_CAT_MARINE, "ERR_CAT_MARINE");
+ SQAIError.DefSQConst(engine, AIError::ERR_CAT_WAYPOINT, "ERR_CAT_WAYPOINT");
SQAIError.DefSQConst(engine, AIError::ERR_CAT_BIT_SIZE, "ERR_CAT_BIT_SIZE");
SQAIError.DefSQConst(engine, AIError::ERR_NONE, "ERR_NONE");
SQAIError.DefSQConst(engine, AIError::ERR_UNKNOWN, "ERR_UNKNOWN");
diff --git a/src/ai/api/ai_station.hpp b/src/ai/api/ai_station.hpp
index a88a8ce35..7a996490f 100644
--- a/src/ai/api/ai_station.hpp
+++ b/src/ai/api/ai_station.hpp
@@ -31,9 +31,6 @@ public:
/** Base for station related errors */
ERR_STATION_BASE = AIError::ERR_CAT_STATION << AIError::ERR_CAT_BIT_SIZE,
- /** The station size exceeds the station spread */
- ERR_STATION_TOO_LARGE, // [STR_ERROR_STATION_TOO_SPREAD_OUT]
-
/** The station is build too close to another station, airport or dock */
ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION, // [STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT, STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION, STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK]
@@ -41,7 +38,7 @@ public:
ERR_STATION_TOO_MANY_STATIONS, // [STR_ERROR_TOO_MANY_STATIONS_LOADING, STR_ERROR_TOO_MANY_TRUCK_STOPS, STR_ERROR_TOO_MANY_BUS_STOPS]
/** There are too many stations, airports of docks in a town */
- ERR_STATION_TOO_MANY_STATIONS_IN_TOWN, // []
+ ERR_STATION_TOO_MANY_STATIONS_IN_TOWN, // [STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT]
};
/**
diff --git a/src/ai/api/ai_station.hpp.sq b/src/ai/api/ai_station.hpp.sq
index 5bd1a3a58..c968a3352 100644
--- a/src/ai/api/ai_station.hpp.sq
+++ b/src/ai/api/ai_station.hpp.sq
@@ -33,7 +33,6 @@ void SQAIStation_Register(Squirrel *engine)
SQAIStation.AddConstructor<void (AIStation::*)(), 1>(engine, "x");
SQAIStation.DefSQConst(engine, AIStation::ERR_STATION_BASE, "ERR_STATION_BASE");
- SQAIStation.DefSQConst(engine, AIStation::ERR_STATION_TOO_LARGE, "ERR_STATION_TOO_LARGE");
SQAIStation.DefSQConst(engine, AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION, "ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION");
SQAIStation.DefSQConst(engine, AIStation::ERR_STATION_TOO_MANY_STATIONS, "ERR_STATION_TOO_MANY_STATIONS");
SQAIStation.DefSQConst(engine, AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN, "ERR_STATION_TOO_MANY_STATIONS_IN_TOWN");
@@ -44,15 +43,14 @@ void SQAIStation_Register(Squirrel *engine)
SQAIStation.DefSQConst(engine, AIStation::STATION_DOCK, "STATION_DOCK");
SQAIStation.DefSQConst(engine, AIStation::STATION_ANY, "STATION_ANY");
- AIError::RegisterErrorMap(STR_ERROR_STATION_TOO_SPREAD_OUT, AIStation::ERR_STATION_TOO_LARGE);
- AIError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT, AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION);
- AIError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION, AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION);
- AIError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK, AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION);
- AIError::RegisterErrorMap(STR_ERROR_TOO_MANY_STATIONS_LOADING, AIStation::ERR_STATION_TOO_MANY_STATIONS);
- AIError::RegisterErrorMap(STR_ERROR_TOO_MANY_TRUCK_STOPS, AIStation::ERR_STATION_TOO_MANY_STATIONS);
- AIError::RegisterErrorMap(STR_ERROR_TOO_MANY_BUS_STOPS, AIStation::ERR_STATION_TOO_MANY_STATIONS);
+ AIError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT, AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION);
+ AIError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION, AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION);
+ AIError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK, AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION);
+ AIError::RegisterErrorMap(STR_ERROR_TOO_MANY_STATIONS_LOADING, AIStation::ERR_STATION_TOO_MANY_STATIONS);
+ AIError::RegisterErrorMap(STR_ERROR_TOO_MANY_TRUCK_STOPS, AIStation::ERR_STATION_TOO_MANY_STATIONS);
+ AIError::RegisterErrorMap(STR_ERROR_TOO_MANY_BUS_STOPS, AIStation::ERR_STATION_TOO_MANY_STATIONS);
+ AIError::RegisterErrorMap(STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT, AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN);
- AIError::RegisterErrorMapString(AIStation::ERR_STATION_TOO_LARGE, "ERR_STATION_TOO_LARGE");
AIError::RegisterErrorMapString(AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION, "ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION");
AIError::RegisterErrorMapString(AIStation::ERR_STATION_TOO_MANY_STATIONS, "ERR_STATION_TOO_MANY_STATIONS");
AIError::RegisterErrorMapString(AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN, "ERR_STATION_TOO_MANY_STATIONS_IN_TOWN");
diff --git a/src/ai/api/ai_waypoint.hpp b/src/ai/api/ai_waypoint.hpp
index 73677df24..a781a0ba9 100644
--- a/src/ai/api/ai_waypoint.hpp
+++ b/src/ai/api/ai_waypoint.hpp
@@ -24,6 +24,20 @@ public:
static const char *GetClassName() { return "AIWaypoint"; }
/**
+ * All waypoint related error messages.
+ */
+ enum ErrorMessages {
+ /** Base for waypoint related errors */
+ ERR_WAYPOINT_BASE = AIError::ERR_CAT_WAYPOINT << AIError::ERR_CAT_BIT_SIZE,
+
+ /** The waypoint is build too close to another waypoint */
+ ERR_WAYPOINT_TOO_CLOSE_TO_ANOTHER_WAYPOINT, // [STR_ERROR_TOO_CLOSE_TO_ANOTHER_WAYPOINT]
+
+ /** The waypoint would join more then one existing waypoint together. */
+ ERR_WAYPOINT_ADJOINS_MULTIPLE_WAYPOINTS, // [STR_ERROR_WAYPOINT_ADJOINS_MORE_THAN_ONE_EXISTING]
+ };
+
+ /**
* Checks whether the given waypoint is valid and owned by you.
* @param waypoint_id The waypoint to check.
* @return True if and only if the waypoint is valid.
diff --git a/src/ai/api/ai_waypoint.hpp.sq b/src/ai/api/ai_waypoint.hpp.sq
index 815c104c5..bdecda56b 100644
--- a/src/ai/api/ai_waypoint.hpp.sq
+++ b/src/ai/api/ai_waypoint.hpp.sq
@@ -12,6 +12,10 @@
#include "ai_waypoint.hpp"
namespace SQConvert {
+ /* Allow enums to be used as Squirrel parameters */
+ template <> AIWaypoint::ErrorMessages GetParam(ForceType<AIWaypoint::ErrorMessages>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIWaypoint::ErrorMessages)tmp; }
+ template <> int Return<AIWaypoint::ErrorMessages>(HSQUIRRELVM vm, AIWaypoint::ErrorMessages res) { sq_pushinteger(vm, (int32)res); return 1; }
+
/* Allow AIWaypoint to be used as Squirrel parameter */
template <> AIWaypoint *GetParam(ForceType<AIWaypoint *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIWaypoint *)instance; }
template <> AIWaypoint &GetParam(ForceType<AIWaypoint &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIWaypoint *)instance; }
@@ -26,6 +30,16 @@ void SQAIWaypoint_Register(Squirrel *engine)
SQAIWaypoint.PreRegister(engine, "AIBaseStation");
SQAIWaypoint.AddConstructor<void (AIWaypoint::*)(), 1>(engine, "x");
+ SQAIWaypoint.DefSQConst(engine, AIWaypoint::ERR_WAYPOINT_BASE, "ERR_WAYPOINT_BASE");
+ SQAIWaypoint.DefSQConst(engine, AIWaypoint::ERR_WAYPOINT_TOO_CLOSE_TO_ANOTHER_WAYPOINT, "ERR_WAYPOINT_TOO_CLOSE_TO_ANOTHER_WAYPOINT");
+ SQAIWaypoint.DefSQConst(engine, AIWaypoint::ERR_WAYPOINT_ADJOINS_MULTIPLE_WAYPOINTS, "ERR_WAYPOINT_ADJOINS_MULTIPLE_WAYPOINTS");
+
+ AIError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_ANOTHER_WAYPOINT, AIWaypoint::ERR_WAYPOINT_TOO_CLOSE_TO_ANOTHER_WAYPOINT);
+ AIError::RegisterErrorMap(STR_ERROR_WAYPOINT_ADJOINS_MORE_THAN_ONE_EXISTING, AIWaypoint::ERR_WAYPOINT_ADJOINS_MULTIPLE_WAYPOINTS);
+
+ AIError::RegisterErrorMapString(AIWaypoint::ERR_WAYPOINT_TOO_CLOSE_TO_ANOTHER_WAYPOINT, "ERR_WAYPOINT_TOO_CLOSE_TO_ANOTHER_WAYPOINT");
+ AIError::RegisterErrorMapString(AIWaypoint::ERR_WAYPOINT_ADJOINS_MULTIPLE_WAYPOINTS, "ERR_WAYPOINT_ADJOINS_MULTIPLE_WAYPOINTS");
+
SQAIWaypoint.DefSQStaticMethod(engine, &AIWaypoint::IsValidWaypoint, "IsValidWaypoint", 2, ".i");
SQAIWaypoint.DefSQStaticMethod(engine, &AIWaypoint::GetWaypointID, "GetWaypointID", 2, ".i");