mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-21 19:32:54 +01:00
(svn r16121) [0.7] -Backport from trunk:
- Add: [NoAI] UseAsRandomAI as function in info.nut. When an AI returns false, it will never be chosen as random AI (r16113) - Fix: [NoAI] Make sure AIOrder::GetDestination always returns a tile belonging to the station (16109) - Fix: [NoAI] When giving an aircraft a goto-hangar order do not let it be a normal goto-station order (r16108) - Add: [NoAI] AIOF_STOP_IN_DEPOT to the orderflags in AIOrder to allow stop-in-depot orders (r16107) - Fix: [NoAI] AIOrder::SetOrderFlags always removed "Service if needed" from goto-depot orders (r16106) - Add: [NoAI] GetURL() as possible function to info.nut. If AIs implement it, that url is shown when the AI crashes and also in the AI selection window [FS#2808] (r16093) - Change: [NoAI] Reverse the order of the lines in the AI debug window [FS#2778] (r16091) - Fix: [NoAI] AIDebug window profiled the blitters by invalidating itself unconditionally on repaint. OTOH it was not invalidated in other cases when needed (r16094) - Fix: [NoAI] MOF_COND_DESTINATION was not accepted by CmdModifyOrder() (r16063)
This commit is contained in:
@@ -234,6 +234,15 @@ bool Squirrel::CallIntegerMethod(HSQOBJECT instance, const char *method_name, in
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Squirrel::CallBoolMethod(HSQOBJECT instance, const char *method_name, bool *res, int suspend)
|
||||
{
|
||||
HSQOBJECT ret;
|
||||
if (!this->CallMethod(instance, method_name, &ret, suspend)) return false;
|
||||
if (ret._type != OT_BOOL) return false;
|
||||
*res = ObjectToBool(&ret);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool Squirrel::CreateClassInstanceVM(HSQUIRRELVM vm, const char *class_name, void *real_instance, HSQOBJECT *instance, SQRELEASEHOOK release_hook)
|
||||
{
|
||||
int oldtop = sq_gettop(vm);
|
||||
|
||||
@@ -116,6 +116,7 @@ public:
|
||||
bool CallMethod(HSQOBJECT instance, const char *method_name, int suspend = -1) { return this->CallMethod(instance, method_name, NULL, suspend); }
|
||||
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);
|
||||
bool CallBoolMethod(HSQOBJECT instance, const char *method_name, bool *res, int suspend = -1);
|
||||
|
||||
/**
|
||||
* Check if a method exists in an instance.
|
||||
@@ -161,6 +162,11 @@ public:
|
||||
*/
|
||||
static int ObjectToInteger(HSQOBJECT *ptr) { return sq_objtointeger(ptr); }
|
||||
|
||||
/**
|
||||
* Convert a Squirrel-object to a bool.
|
||||
*/
|
||||
static bool ObjectToBool(HSQOBJECT *ptr) { return sq_objtobool(ptr) == 1; }
|
||||
|
||||
/**
|
||||
* Sets a pointer in the VM that is reachable from where ever you are in SQ.
|
||||
* Useful to keep track of the main instance.
|
||||
|
||||
Reference in New Issue
Block a user