MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Initialize

Method Initialize

src/script/squirrel.cpp:516–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516void Squirrel::Initialize()
517{
518 ScriptAllocatorScope alloc_scope(this);
519
520 this->global_pointer = nullptr;
521 this->print_func = nullptr;
522 this->crashed = false;
523 this->overdrawn_ops = 0;
524 this->vm = sq_open(1024);
525
526 /* Handle compile-errors ourself, so we can display it nicely */
527 sq_setcompilererrorhandler(this->vm, &Squirrel::CompileError);
528 sq_notifyallexceptions(this->vm, _debug_script_level > 5);
529 /* Set a good print-function */
530 sq_setprintfunc(this->vm, &Squirrel::PrintFunc);
531 /* Handle runtime-errors ourself, so we can display it nicely */
532 sq_newclosure(this->vm, &Squirrel::_RunError, 0);
533 sq_seterrorhandler(this->vm);
534
535 /* Set the foreign pointer, so we can always find this instance from within the VM */
536 sq_setforeignptr(this->vm, this);
537
538 sq_pushroottable(this->vm);
539 squirrel_register_global_std(*this);
540
541 /* Set consts table as delegate of root table, so consts/enums defined via require() are accessible */
542 sq_pushconsttable(this->vm);
543 sq_setdelegate(this->vm, -2);
544}
545
546class SQFile {
547private:

Callers 3

SquirrelMethod · 0.95
ResetMethod · 0.95
AfterLoadVehiclesPhase1Function · 0.45

Calls 11

sq_openFunction · 0.85
sq_notifyallexceptionsFunction · 0.85
sq_setprintfuncFunction · 0.85
sq_newclosureFunction · 0.85
sq_seterrorhandlerFunction · 0.85
sq_setforeignptrFunction · 0.85
sq_pushroottableFunction · 0.85
sq_pushconsttableFunction · 0.85
sq_setdelegateFunction · 0.85

Tested by

no test coverage detected