Changeset - r14134:cdf3a9d02f8d
[Not reviewed]
master
0 7 0
yexo - 14 years ago 2010-01-02 16:47:32
yexo@openttd.org
(svn r18691) -Change [NoAI]: cleanup some errors messages and add a few to AIWaypoint
7 files changed with 40 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_changelog.hpp
Show inline comments
 
@@ -31,18 +31,20 @@
 
 * \li AISubsidy::GetSourceType
 
 * \li AISubsidy::GetSourceIndex
 
 * \li AISubsidy::GetDestinationType
 
 * \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
 
 * \li AISubsidy::GetDestination, use AISubsidy::GetDestinationIndex instead
 
 * \li AITile::GetHeight, use AITile::GetMinHeight/GetMaxHeight/GetCornerHeight instead
 
 * \li AITown::GetMaxProduction, use AITown::GetLastMonthProduction instead
src/ai/api/ai_error.hpp
Show inline comments
 
@@ -58,12 +58,13 @@ public:
 
		ERR_CAT_TILE,     //!< Error messages related to raising / lowering and demolishing tiles.
 
		ERR_CAT_SIGN,     //!< Error messages related to building / removing signs.
 
		ERR_CAT_RAIL,     //!< Error messages related to building / maintaining rails.
 
		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
 
		 *  a category and what the offsets are of all categories.
 
		 */
 
		ERR_CAT_BIT_SIZE = 8,
src/ai/api/ai_error.hpp.sq
Show inline comments
 
@@ -41,12 +41,13 @@ void SQAIError_Register(Squirrel *engine
 
	SQAIError.DefSQConst(engine, AIError::ERR_CAT_TILE,                     "ERR_CAT_TILE");
 
	SQAIError.DefSQConst(engine, AIError::ERR_CAT_SIGN,                     "ERR_CAT_SIGN");
 
	SQAIError.DefSQConst(engine, AIError::ERR_CAT_RAIL,                     "ERR_CAT_RAIL");
 
	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");
 
	SQAIError.DefSQConst(engine, AIError::ERR_PRECONDITION_FAILED,          "ERR_PRECONDITION_FAILED");
 
	SQAIError.DefSQConst(engine, AIError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
 
	SQAIError.DefSQConst(engine, AIError::ERR_NEWGRF_SUPPLIED_ERROR,        "ERR_NEWGRF_SUPPLIED_ERROR");
src/ai/api/ai_station.hpp
Show inline comments
 
@@ -28,23 +28,20 @@ public:
 
	 * All station related error messages.
 
	 */
 
	enum ErrorMessages {
 
		/** 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]
 

	
 
		/** There are too many stations, airports and docks in the game */
 
		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]
 
	};
 

	
 
	/**
 
	 * Type of stations known in the game.
 
	 */
 
	enum StationType {
src/ai/api/ai_station.hpp.sq
Show inline comments
 
@@ -30,32 +30,30 @@ void SQAIStation_Register(Squirrel *engi
 
{
 
	DefSQClass <AIStation> SQAIStation("AIStation");
 
	SQAIStation.PreRegister(engine, "AIBaseStation");
 
	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");
 
	SQAIStation.DefSQConst(engine, AIStation::STATION_TRAIN,                            "STATION_TRAIN");
 
	SQAIStation.DefSQConst(engine, AIStation::STATION_TRUCK_STOP,                       "STATION_TRUCK_STOP");
 
	SQAIStation.DefSQConst(engine, AIStation::STATION_BUS_STOP,                         "STATION_BUS_STOP");
 
	SQAIStation.DefSQConst(engine, AIStation::STATION_AIRPORT,                          "STATION_AIRPORT");
 
	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");
 

	
 
	SQAIStation.DefSQStaticMethod(engine, &AIStation::IsValidStation,             "IsValidStation",             2, ".i");
 
	SQAIStation.DefSQStaticMethod(engine, &AIStation::GetStationID,               "GetStationID",               2, ".i");
src/ai/api/ai_waypoint.hpp
Show inline comments
 
@@ -21,12 +21,26 @@
 
 */
 
class AIWaypoint : public AIBaseStation {
 
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.
 
	 */
 
	static bool IsValidWaypoint(StationID waypoint_id);
 

	
src/ai/api/ai_waypoint.hpp.sq
Show inline comments
 
@@ -9,12 +9,16 @@
 

	
 
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
 

	
 
#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; }
 
	template <> const AIWaypoint *GetParam(ForceType<const AIWaypoint *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIWaypoint *)instance; }
 
	template <> const AIWaypoint &GetParam(ForceType<const AIWaypoint &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIWaypoint *)instance; }
 
	template <> int Return<AIWaypoint *>(HSQUIRRELVM vm, AIWaypoint *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIWaypoint", res, NULL, DefSQDestructorCallback<AIWaypoint>); return 1; }
 
@@ -23,11 +27,21 @@ namespace SQConvert {
 
void SQAIWaypoint_Register(Squirrel *engine)
 
{
 
	DefSQClass <AIWaypoint> SQAIWaypoint("AIWaypoint");
 
	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");
 

	
 
	SQAIWaypoint.PostRegister(engine);
 
}
0 comments (0 inline, 0 general)