diff options
author | yexo <yexo@openttd.org> | 2009-02-13 17:17:34 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-02-13 17:17:34 +0000 |
commit | 8e14d77d0509e3b2d2162d16c2f9696680b0b1a0 (patch) | |
tree | 569a356b10c209708942b4184b1d6f9b100e228b /src/script/squirrel.hpp | |
parent | 15b9366f0687182d635bb3e4bdce9451534a82ad (diff) | |
download | openttd-8e14d77d0509e3b2d2162d16c2f9696680b0b1a0.tar.xz |
(svn r15467) -Fix [NoAI]: AIs with an error in their info.nut are no longer available in-game.
Diffstat (limited to 'src/script/squirrel.hpp')
-rw-r--r-- | src/script/squirrel.hpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp index b5b352bd0..5ce8675ed 100644 --- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -12,6 +12,7 @@ private: HSQUIRRELVM vm; ///< The VirtualMachine instnace for squirrel void *global_pointer; ///< Can be set by who ever initializes Squirrel SQPrintFunc *print_func; ///< Points to either NULL, or a custom print handler + bool crashed; ///< True if the squirrel script made an error. /** * The internal RunError handler. It looks up the real error and calls RunError with it. @@ -111,11 +112,12 @@ public: /** * Call a method of an instance, in various flavors. + * @return False if the script crashed or returned a wrong type. */ bool CallMethod(HSQOBJECT instance, const char *method_name, HSQOBJECT *ret, int suspend = -1); bool CallMethod(HSQOBJECT instance, const char *method_name, int suspend = -1) { return this->CallMethod(instance, method_name, NULL, suspend); } - const char *CallStringMethodStrdup(HSQOBJECT instance, const char *method_name, int suspend = -1) { HSQOBJECT ret; this->CallMethod(instance, method_name, &ret, suspend); return strdup(ObjectToString(&ret)); } - int CallIntegerMethod(HSQOBJECT instance, const char *method_name, int suspend = -1) { HSQOBJECT ret; this->CallMethod(instance, method_name, &ret, suspend); return ObjectToInteger(&ret); } + bool CallStringMethodStrdup(HSQOBJECT instance, const char *method_name, const char **res, int suspend = -1); + bool CallIntegerMethod(HSQOBJECT instance, const char *method_name, int *res, int suspend = -1); /** * Check if a method exists in an instance. @@ -191,6 +193,22 @@ public: * Tell the VM to remove \c amount ops from the number of ops till suspend. */ static void DecreaseOps(HSQUIRRELVM vm, int amount); + + /** + * Did the squirrel code suspend or return normally. + * @return True if the function suspended. + */ + bool IsSuspended(); + + /** + * Find out if the squirrel script made an error before. + */ + bool HasScriptCrashed(); + + /** + * Reset the crashed status. + */ + void ResetCrashed(); }; #endif /* SQUIRREL_HPP */ |