| 769 | } |
| 770 | |
| 771 | bool ScriptInstance::CallLoad() |
| 772 | { |
| 773 | HSQUIRRELVM vm = this->engine->GetVM(); |
| 774 | /* Is there save data that we should load? */ |
| 775 | if (!this->is_save_data_on_stack) return true; |
| 776 | /* Whatever happens, after CallLoad the savegame data is removed from the stack. */ |
| 777 | this->is_save_data_on_stack = false; |
| 778 | |
| 779 | if (!this->engine->MethodExists(*this->instance, "Load")) { |
| 780 | ScriptLog::Warning("Loading failed: there was data for the script to load, but the script does not have a Load() function."); |
| 781 | |
| 782 | /* Pop the savegame data and version. */ |
| 783 | sq_pop(vm, 2); |
| 784 | return true; |
| 785 | } |
| 786 | |
| 787 | /* Go to the instance-root */ |
| 788 | sq_pushobject(vm, *this->instance); |
| 789 | /* Find the function-name inside the script */ |
| 790 | sq_pushstring(vm, "Load"); |
| 791 | /* Change the "Load" string in a function pointer */ |
| 792 | sq_get(vm, -2); |
| 793 | /* Push the main instance as "this" object */ |
| 794 | sq_pushobject(vm, *this->instance); |
| 795 | /* Push the version data and savegame data as arguments */ |
| 796 | sq_push(vm, -5); |
| 797 | sq_push(vm, -5); |
| 798 | |
| 799 | /* Call the script load function. sq_call removes the arguments (but not the |
| 800 | * function pointer) from the stack. */ |
| 801 | if (SQ_FAILED(sq_call(vm, 3, SQFalse, SQTrue, MAX_SL_OPS))) return false; |
| 802 | |
| 803 | /* Pop 1) The version, 2) the savegame data, 3) the object instance, 4) the function pointer. */ |
| 804 | sq_pop(vm, 4); |
| 805 | return true; |
| 806 | } |
| 807 | |
| 808 | SQInteger ScriptInstance::GetOpsTillSuspend() |
| 809 | { |
no test coverage detected