From 8e14d77d0509e3b2d2162d16c2f9696680b0b1a0 Mon Sep 17 00:00:00 2001 From: yexo Date: Fri, 13 Feb 2009 17:17:34 +0000 Subject: (svn r15467) -Fix [NoAI]: AIs with an error in their info.nut are no longer available in-game. --- src/script/squirrel.hpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/script/squirrel.hpp') 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 */ -- cgit v1.2.3-54-g00ecf