From 3a535690d4e9aaa896a062e7b5b5454b1b07ac47 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 21:00:32 +0000 Subject: (svn r23623) -Add: allow bi-directional communication with the AdminPort and GameScript --- src/script/api/script_event_types.hpp | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src/script/api/script_event_types.hpp') diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index cffa4a797..d6552aad1 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -829,4 +829,60 @@ private: VehicleID vehicle_id; ///< The vehicle aircraft whose destination is too far away. }; +/** + * Event Admin Port, indicating the admin port is sending you information. + * @api game + */ +class ScriptEventAdminPort : public ScriptEvent { +public: + /** + * @param json The JSON string which got sent. + */ + ScriptEventAdminPort(const char *json) : + ScriptEvent(ET_ADMIN_PORT), + json(strdup(json)) + {} + + ~ScriptEventAdminPort() + { + free(this->json); + } + + /** + * Convert an ScriptEvent to the real instance. + * @param instance The instance to convert. + * @return The converted instance. + */ + static ScriptEventAdminPort *Convert(ScriptEvent *instance) { return (ScriptEventAdminPort *)instance; } + + /** + * Get the information that was sent to you back as Squirrel object. + */ + SQInteger GetObject(HSQUIRRELVM vm); + +private: + char *json; ///< The JSON string. + + /** + * Read a table from a JSON string. + * @param vm The VM used. + * @param p The (part of the) JSON string reading. + */ + char *ReadTable(HSQUIRRELVM vm, char *p); + + /** + * Read a value from a JSON string. + * @param vm The VM used. + * @param p The (part of the) JSON string reading. + */ + char *ReadValue(HSQUIRRELVM vm, char *p); + + /** + * Read a string from a JSON string. + * @param vm The VM used. + * @param p The (part of the) JSON string reading. + */ + char *ReadString(HSQUIRRELVM vm, char *p); +}; + #endif /* SCRIPT_EVENT_TYPES_HPP */ -- cgit v1.2.3-54-g00ecf