diff options
author | truebrain <truebrain@openttd.org> | 2011-12-19 21:00:32 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-12-19 21:00:32 +0000 |
commit | 3a535690d4e9aaa896a062e7b5b5454b1b07ac47 (patch) | |
tree | 600859d25db8391542b9cc0da9e063c7bdc6f4fc /src/script/api/script_event_types.hpp | |
parent | 77b7366c2947a3f2545d5542021be1cc203a74e8 (diff) | |
download | openttd-3a535690d4e9aaa896a062e7b5b5454b1b07ac47.tar.xz |
(svn r23623) -Add: allow bi-directional communication with the AdminPort and GameScript
Diffstat (limited to 'src/script/api/script_event_types.hpp')
-rw-r--r-- | src/script/api/script_event_types.hpp | 56 |
1 files changed, 56 insertions, 0 deletions
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 */ |