Mercurial > hg > openttd
changeset 12571:a01708f7f21f draft
(svn r17011) -Change [NoAI]: Add AIBaseStation as a parentclass for AIStation and AIWaypoint, and move GetName, SetName and GetLocation to AIBaseStation
Remove (nearly) all references to WaypointID and replace them with StationID
author | yexo <yexo@openttd.org> |
---|---|
date | Fri, 31 Jul 2009 22:30:54 +0000 |
parents | 79d0f650f0f1 |
children | 52a8fb91191b |
files | projects/openttd_vs80.vcproj projects/openttd_vs90.vcproj source.list src/ai/ai_instance.cpp src/ai/api/ai_basestation.cpp src/ai/api/ai_basestation.hpp src/ai/api/ai_basestation.hpp.sq src/ai/api/ai_station.cpp src/ai/api/ai_station.hpp src/ai/api/ai_station.hpp.sq src/ai/api/ai_types.hpp src/ai/api/ai_waypoint.cpp src/ai/api/ai_waypoint.hpp src/ai/api/ai_waypoint.hpp.sq |
diffstat | 14 files changed, 183 insertions(+), 164 deletions(-) [+] |
line wrap: on
line diff
--- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -2620,6 +2620,10 @@ > </File> <File + RelativePath=".\..\src\ai\api\ai_basestation.hpp" + > + </File> + <File RelativePath=".\..\src\ai\api\ai_bridge.hpp" > </File> @@ -2832,6 +2836,10 @@ > </File> <File + RelativePath=".\..\src\ai\api\ai_basestation.cpp" + > + </File> + <File RelativePath=".\..\src\ai\api\ai_bridge.cpp" > </File>
--- a/projects/openttd_vs90.vcproj +++ b/projects/openttd_vs90.vcproj @@ -2617,6 +2617,10 @@ > </File> <File + RelativePath=".\..\src\ai\api\ai_basestation.hpp" + > + </File> + <File RelativePath=".\..\src\ai\api\ai_bridge.hpp" > </File> @@ -2829,6 +2833,10 @@ > </File> <File + RelativePath=".\..\src\ai\api\ai_basestation.cpp" + > + </File> + <File RelativePath=".\..\src\ai\api\ai_bridge.cpp" > </File>
--- a/source.list +++ b/source.list @@ -608,6 +608,7 @@ ai/api/ai_accounting.hpp ai/api/ai_airport.hpp ai/api/ai_base.hpp +ai/api/ai_basestation.hpp ai/api/ai_bridge.hpp ai/api/ai_bridgelist.hpp ai/api/ai_buoylist.hpp @@ -662,6 +663,7 @@ ai/api/ai_accounting.cpp ai/api/ai_airport.cpp ai/api/ai_base.cpp +ai/api/ai_basestation.cpp ai/api/ai_bridge.cpp ai/api/ai_bridgelist.cpp ai/api/ai_buoylist.cpp
--- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -30,6 +30,7 @@ #include "api/ai_accounting.hpp.sq" #include "api/ai_airport.hpp.sq" #include "api/ai_base.hpp.sq" +#include "api/ai_basestation.hpp.sq" #include "api/ai_bridge.hpp.sq" #include "api/ai_bridgelist.hpp.sq" #include "api/ai_buoylist.hpp.sq" @@ -158,6 +159,7 @@ SQAIAccounting_Register(this->engine); SQAIAirport_Register(this->engine); SQAIBase_Register(this->engine); + SQAIBaseStation_Register(this->engine); SQAIBridge_Register(this->engine); SQAIBridgeList_Register(this->engine); SQAIBridgeList_Length_Register(this->engine);
new file mode 100644 --- /dev/null +++ b/src/ai/api/ai_basestation.cpp @@ -0,0 +1,47 @@ +/* $Id$ */ + +/** @file ai_basestation.cpp Implementation of AIBaseStation. */ + +#include "ai_basestation.hpp" +#include "../../base_station_base.h" +#include "../../station_base.h" +#include "../../command_func.h" +#include "../../string_func.h" +#include "../../strings_func.h" +#include "../../company_func.h" +#include "../../core/alloc_func.hpp" +#include "table/strings.h" + +/* static */ bool AIBaseStation::IsValidBaseStation(StationID station_id) +{ + const BaseStation *st = ::BaseStation::GetIfValid(station_id); + return st != NULL && st->owner == _current_company; +} + +/* static */ char *AIBaseStation::GetName(StationID station_id) +{ + if (!IsValidBaseStation(station_id)) return NULL; + + static const int len = 64; + char *name = MallocT<char>(len); + + ::SetDParam(0, station_id); + ::GetString(name, ::Station::IsValidID(station_id) ? STR_STATION_NAME : STR_WAYPOINT_NAME, &name[len - 1]); + return name; +} + +/* static */ bool AIBaseStation::SetName(StationID station_id, const char *name) +{ + EnforcePrecondition(false, IsValidBaseStation(station_id)); + EnforcePrecondition(false, !::StrEmpty(name)); + EnforcePreconditionCustomError(false, ::strlen(name) < MAX_LENGTH_STATION_NAME_BYTES, AIError::ERR_PRECONDITION_STRING_TOO_LONG); + + return AIObject::DoCommand(0, station_id, 0, ::Station::IsValidID(station_id) ? CMD_RENAME_STATION : CMD_RENAME_WAYPOINT, name); +} + +/* static */ TileIndex AIBaseStation::GetLocation(StationID station_id) +{ + if (!IsValidBaseStation(station_id)) return INVALID_TILE; + + return ::BaseStation::Get(station_id)->xy; +}
new file mode 100644 --- /dev/null +++ b/src/ai/api/ai_basestation.hpp @@ -0,0 +1,66 @@ +/* $Id$ */ + +/** @file ai_waypoint.hpp Everything to query and build waypoints. */ + +#ifndef AI_BASESTATION_HPP +#define AI_BASESTATION_HPP + +#include "ai_object.hpp" +#include "ai_error.hpp" + +/** + * Base class for stations and waypoints. + */ +class AIBaseStation : public AIObject { +public: + static const char *GetClassName() { return "AIBaseStation"; } + + /** + * Special station IDs for building adjacent/new stations when + * the adjacent/distant join features are enabled. + */ + enum SpecialStationIDs { + STATION_NEW = 0xFFFD, //!< Build a new station + STATION_JOIN_ADJACENT = 0xFFFE, //!< Join an neighbouring station if one exists + STATION_INVALID = 0xFFFF, //!< Invalid station id. + WAYPOINT_INVALID = 0xFFFF, //!< @deprecated Use STATION_INVALID instead. + }; + + /** + * Checks whether the given basestation is valid and owned by you. + * @param station_id The station to check. + * @return True if and only if the basestation is valid. + * @note IsValidBaseStation == (IsValidStation || IsValidWaypoint). + */ + static bool IsValidBaseStation(StationID station_id); + + /** + * Get the name of a basestation. + * @param station_id The basestation to get the name of. + * @pre IsValidBaseStation(station_id). + * @return The name of the station. + */ + static char *GetName(StationID station_id); + + /** + * Set the name this basestation. + * @param station_id The basestation to set the name of. + * @param name The new name of the station. + * @pre IsValidBaseStation(station_id). + * @pre 'name' must have at least one character. + * @pre 'name' must have at most 30 characters. + * @exception AIError::ERR_NAME_IS_NOT_UNIQUE + * @return True if the name was changed. + */ + static bool SetName(StationID station_id, const char *name); + + /** + * Get the current location of a basestation. + * @param station_id The basestation to get the location of. + * @pre IsValidBaseStation(station_id). + * @return The tile the basestation is currently on. + */ + static TileIndex GetLocation(StationID station_id); +}; + +#endif /* AI_BASESTATION_HPP */
new file mode 100644 --- /dev/null +++ b/src/ai/api/ai_basestation.hpp.sq @@ -0,0 +1,35 @@ +/* $Id$ */ +/* 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 <> AIBaseStation::SpecialStationIDs GetParam(ForceType<AIBaseStation::SpecialStationIDs>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIBaseStation::SpecialStationIDs)tmp; } + template <> int Return<AIBaseStation::SpecialStationIDs>(HSQUIRRELVM vm, AIBaseStation::SpecialStationIDs res) { sq_pushinteger(vm, (int32)res); return 1; } + + /* Allow AIBaseStation to be used as Squirrel parameter */ + template <> AIBaseStation *GetParam(ForceType<AIBaseStation *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIBaseStation *)instance; } + template <> AIBaseStation &GetParam(ForceType<AIBaseStation &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBaseStation *)instance; } + template <> const AIBaseStation *GetParam(ForceType<const AIBaseStation *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIBaseStation *)instance; } + template <> const AIBaseStation &GetParam(ForceType<const AIBaseStation &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBaseStation *)instance; } + template <> int Return<AIBaseStation *>(HSQUIRRELVM vm, AIBaseStation *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBaseStation", res, NULL, DefSQDestructorCallback<AIBaseStation>); return 1; } +}; // namespace SQConvert + +void SQAIBaseStation_Register(Squirrel *engine) { + DefSQClass <AIBaseStation> SQAIBaseStation("AIBaseStation"); + SQAIBaseStation.PreRegister(engine); + SQAIBaseStation.AddConstructor<void (AIBaseStation::*)(), 1>(engine, "x"); + + SQAIBaseStation.DefSQConst(engine, AIBaseStation::STATION_NEW, "STATION_NEW"); + SQAIBaseStation.DefSQConst(engine, AIBaseStation::STATION_JOIN_ADJACENT, "STATION_JOIN_ADJACENT"); + SQAIBaseStation.DefSQConst(engine, AIBaseStation::STATION_INVALID, "STATION_INVALID"); + SQAIBaseStation.DefSQConst(engine, AIBaseStation::WAYPOINT_INVALID, "WAYPOINT_INVALID"); + + SQAIBaseStation.DefSQStaticMethod(engine, &AIBaseStation::IsValidBaseStation, "IsValidBaseStation", 2, ".i"); + SQAIBaseStation.DefSQStaticMethod(engine, &AIBaseStation::GetName, "GetName", 2, ".i"); + SQAIBaseStation.DefSQStaticMethod(engine, &AIBaseStation::SetName, "SetName", 3, ".is"); + SQAIBaseStation.DefSQStaticMethod(engine, &AIBaseStation::GetLocation, "GetLocation", 2, ".i"); + + SQAIBaseStation.PostRegister(engine); +}
--- a/src/ai/api/ai_station.cpp +++ b/src/ai/api/ai_station.cpp @@ -28,34 +28,6 @@ return ::GetStationIndex(tile); } -/* static */ char *AIStation::GetName(StationID station_id) -{ - if (!IsValidStation(station_id)) return NULL; - - static const int len = 64; - char *station_name = MallocT<char>(len); - - ::SetDParam(0, Station::Get(station_id)->index); - ::GetString(station_name, STR_STATION_NAME, &station_name[len - 1]); - return station_name; -} - -/* static */ bool AIStation::SetName(StationID station_id, const char *name) -{ - EnforcePrecondition(false, IsValidStation(station_id)); - EnforcePrecondition(false, !::StrEmpty(name)); - EnforcePreconditionCustomError(false, ::strlen(name) < MAX_LENGTH_STATION_NAME_BYTES, AIError::ERR_PRECONDITION_STRING_TOO_LONG); - - return AIObject::DoCommand(0, station_id, 0, CMD_RENAME_STATION, name); -} - -/* static */ TileIndex AIStation::GetLocation(StationID station_id) -{ - if (!IsValidStation(station_id)) return INVALID_TILE; - - return ::Station::Get(station_id)->xy; -} - /* static */ int32 AIStation::GetCargoWaiting(StationID station_id, CargoID cargo_id) { if (!IsValidStation(station_id)) return -1;
--- a/src/ai/api/ai_station.hpp +++ b/src/ai/api/ai_station.hpp @@ -8,11 +8,12 @@ #include "ai_object.hpp" #include "ai_error.hpp" #include "ai_road.hpp" +#include "ai_basestation.hpp" /** * Class that handles all station related functions. */ -class AIStation : public AIObject { +class AIStation : public AIBaseStation { public: static const char *GetClassName() { return "AIStation"; } @@ -50,16 +51,6 @@ }; /** - * Special station IDs for building adjacent/new stations when - * the adjacent/distant join features are enabled. - */ - enum SpecialStationIDs { - STATION_NEW = 0xFFFD, //!< Build a new station - STATION_JOIN_ADJACENT = 0xFFFE, //!< Join an neighbouring station if one exists - STATION_INVALID = 0xFFFF, //!< Invalid station id. - }; - - /** * Checks whether the given station is valid and owned by you. * @param station_id The station to check. * @return True if and only if the station is valid. @@ -75,34 +66,6 @@ static StationID GetStationID(TileIndex tile); /** - * Get the name of a station. - * @param station_id The station to get the name of. - * @pre IsValidStation(station_id). - * @return The name of the station. - */ - static char *GetName(StationID station_id); - - /** - * Set the name this station. - * @param station_id The station to set the name of. - * @param name The new name of the station. - * @pre IsValidStation(station_id). - * @pre 'name' must have at least one character. - * @pre 'name' must have at most 30 characters. - * @exception AIError::ERR_NAME_IS_NOT_UNIQUE - * @return True if the name was changed. - */ - static bool SetName(StationID station_id, const char *name); - - /** - * Get the current location of a station. - * @param station_id The station to get the location of. - * @pre IsValidStation(station_id). - * @return The tile the station is currently on. - */ - static TileIndex GetLocation(StationID station_id); - - /** * See how much cargo there is waiting on a station. * @param station_id The station to get the cargo-waiting of. * @param cargo_id The cargo to get the cargo-waiting of.
--- a/src/ai/api/ai_station.hpp.sq +++ b/src/ai/api/ai_station.hpp.sq @@ -9,8 +9,6 @@ template <> int Return<AIStation::ErrorMessages>(HSQUIRRELVM vm, AIStation::ErrorMessages res) { sq_pushinteger(vm, (int32)res); return 1; } template <> AIStation::StationType GetParam(ForceType<AIStation::StationType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIStation::StationType)tmp; } template <> int Return<AIStation::StationType>(HSQUIRRELVM vm, AIStation::StationType res) { sq_pushinteger(vm, (int32)res); return 1; } - template <> AIStation::SpecialStationIDs GetParam(ForceType<AIStation::SpecialStationIDs>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIStation::SpecialStationIDs)tmp; } - template <> int Return<AIStation::SpecialStationIDs>(HSQUIRRELVM vm, AIStation::SpecialStationIDs res) { sq_pushinteger(vm, (int32)res); return 1; } /* Allow AIStation to be used as Squirrel parameter */ template <> AIStation *GetParam(ForceType<AIStation *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIStation *)instance; } @@ -22,7 +20,7 @@ void SQAIStation_Register(Squirrel *engine) { DefSQClass <AIStation> SQAIStation("AIStation"); - SQAIStation.PreRegister(engine); + SQAIStation.PreRegister(engine, "AIBaseStation"); SQAIStation.AddConstructor<void (AIStation::*)(), 1>(engine, "x"); SQAIStation.DefSQConst(engine, AIStation::ERR_STATION_BASE, "ERR_STATION_BASE"); @@ -36,9 +34,6 @@ SQAIStation.DefSQConst(engine, AIStation::STATION_AIRPORT, "STATION_AIRPORT"); SQAIStation.DefSQConst(engine, AIStation::STATION_DOCK, "STATION_DOCK"); SQAIStation.DefSQConst(engine, AIStation::STATION_ANY, "STATION_ANY"); - SQAIStation.DefSQConst(engine, AIStation::STATION_NEW, "STATION_NEW"); - SQAIStation.DefSQConst(engine, AIStation::STATION_JOIN_ADJACENT, "STATION_JOIN_ADJACENT"); - SQAIStation.DefSQConst(engine, AIStation::STATION_INVALID, "STATION_INVALID"); 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); @@ -55,9 +50,6 @@ SQAIStation.DefSQStaticMethod(engine, &AIStation::IsValidStation, "IsValidStation", 2, ".i"); SQAIStation.DefSQStaticMethod(engine, &AIStation::GetStationID, "GetStationID", 2, ".i"); - SQAIStation.DefSQStaticMethod(engine, &AIStation::GetName, "GetName", 2, ".i"); - SQAIStation.DefSQStaticMethod(engine, &AIStation::SetName, "SetName", 3, ".is"); - SQAIStation.DefSQStaticMethod(engine, &AIStation::GetLocation, "GetLocation", 2, ".i"); SQAIStation.DefSQStaticMethod(engine, &AIStation::GetCargoWaiting, "GetCargoWaiting", 3, ".ii"); SQAIStation.DefSQStaticMethod(engine, &AIStation::GetCargoRating, "GetCargoRating", 3, ".ii"); SQAIStation.DefSQStaticMethod(engine, &AIStation::GetCoverageRadius, "GetCoverageRadius", 2, ".i");
--- a/src/ai/api/ai_types.hpp +++ b/src/ai/api/ai_types.hpp @@ -60,10 +60,6 @@ * <td> construction, autorenew, autoreplace </td> * <td> destruction, autorenew, autoreplace </td> * <td> yes </td></tr> - * <tr><td>#WaypointID </td><td> waypoint </td> - * <td> construction </td> - * <td> destruction </td> - * <td> yes </td></tr> * </table> * * @remarks @@ -94,7 +90,6 @@ typedef uint32 TileIndex; //!< The ID of a tile (just named differently). typedef uint16 TownID; //!< The ID of a town. typedef uint16 VehicleID; //!< The ID of a vehicle. -typedef uint16 WaypointID; //!< The ID of a waypoint. /* Types we defined ourself, as the OpenTTD core doesn't have them (yet) */ typedef uint AIErrorType; //!< The types of errors inside the NoAI framework.
--- 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; -}
--- a/src/ai/api/ai_waypoint.hpp +++ b/src/ai/api/ai_waypoint.hpp @@ -7,63 +7,29 @@ #include "ai_object.hpp" #include "ai_error.hpp" +#include "ai_basestation.hpp" /** * Class that handles all waypoint related functions. */ -class AIWaypoint : public AIObject { +class AIWaypoint : public AIBaseStation { public: static const char *GetClassName() { return "AIWaypoint"; } /** - * Special waypoint IDs signalling different kinds of waypoints. - */ - enum SpecialWaypointIDs { - WAYPOINT_INVALID = 0xFFFF, //!< An invalid WaypointID. - }; - - /** * 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(WaypointID waypoint_id); - - /** - * Get the WaypointID of a tile. - * @param tile The tile to find the WaypointID of. - * @pre AIRail::IsRailWaypointTile(tile). - * @return WaypointID of the waypoint. - */ - static WaypointID GetWaypointID(TileIndex tile); - - /** - * Get the name of a waypoint. - * @param waypoint_id The waypoint to get the name of. - * @pre IsValidWaypoint(waypoint_id). - * @return The name of the waypoint. - */ - static char *GetName(WaypointID waypoint_id); + static bool IsValidWaypoint(StationID waypoint_id); /** - * Set the name this waypoint. - * @param waypoint_id The waypoint to set the name of. - * @param name The new name of the waypoint. - * @pre IsValidWaypointwaypoint_id). - * @pre 'name' must have at least one character. - * @pre 'name' must have at most 30 characters. - * @exception AIError::ERR_NAME_IS_NOT_UNIQUE - * @return True if the name was changed. + * Get the StationID of a tile. + * @param tile The tile to find the StationID of. + * @pre AIRail::IsRailWaypointTile(tile). + * @return StationID of the waypoint. */ - static bool SetName(WaypointID waypoint_id, const char *name); - - /** - * Get the current location of a waypoint. - * @param waypoint_id The waypoint to get the location of. - * @pre IsValidWaypoint(waypoint_id). - * @return The tile the waypoint is currently on. - */ - static TileIndex GetLocation(WaypointID waypoint_id); + static StationID GetWaypointID(TileIndex tile); }; #endif /* AI_WAYPOINT_HPP */
--- a/src/ai/api/ai_waypoint.hpp.sq +++ b/src/ai/api/ai_waypoint.hpp.sq @@ -4,10 +4,6 @@ #include "ai_waypoint.hpp" namespace SQConvert { - /* Allow enums to be used as Squirrel parameters */ - template <> AIWaypoint::SpecialWaypointIDs GetParam(ForceType<AIWaypoint::SpecialWaypointIDs>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIWaypoint::SpecialWaypointIDs)tmp; } - template <> int Return<AIWaypoint::SpecialWaypointIDs>(HSQUIRRELVM vm, AIWaypoint::SpecialWaypointIDs 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; } @@ -18,16 +14,11 @@ void SQAIWaypoint_Register(Squirrel *engine) { DefSQClass <AIWaypoint> SQAIWaypoint("AIWaypoint"); - SQAIWaypoint.PreRegister(engine); + SQAIWaypoint.PreRegister(engine, "AIBaseStation"); SQAIWaypoint.AddConstructor<void (AIWaypoint::*)(), 1>(engine, "x"); - SQAIWaypoint.DefSQConst(engine, AIWaypoint::WAYPOINT_INVALID, "WAYPOINT_INVALID"); - SQAIWaypoint.DefSQStaticMethod(engine, &AIWaypoint::IsValidWaypoint, "IsValidWaypoint", 2, ".i"); SQAIWaypoint.DefSQStaticMethod(engine, &AIWaypoint::GetWaypointID, "GetWaypointID", 2, ".i"); - SQAIWaypoint.DefSQStaticMethod(engine, &AIWaypoint::GetName, "GetName", 2, ".i"); - SQAIWaypoint.DefSQStaticMethod(engine, &AIWaypoint::SetName, "SetName", 3, ".is"); - SQAIWaypoint.DefSQStaticMethod(engine, &AIWaypoint::GetLocation, "GetLocation", 2, ".i"); SQAIWaypoint.PostRegister(engine); }