MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / Start

Method Start

src/openrct2/scripting/Plugin.cpp:78–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void Plugin::Start()
79{
80 if (!_hasLoaded)
81 {
82 throw std::runtime_error("Plugin has not been loaded.");
83 }
84
85 const JSValue mainFunc = _metadata.Main.callback;
86 if (!JS_IsFunction(_context, mainFunc))
87 {
88 throw std::runtime_error("No main function specified.");
89 }
90
91 _hasStarted = true;
92
93 const JSValue res = JS_Call(_context, mainFunc, JS_UNDEFINED, 0, nullptr);
94 if (JS_IsException(res))
95 {
96 JSValue exceptionVal = JS_GetException(_context);
97 std::string details = Stringify(_context, exceptionVal);
98 JS_FreeValue(_context, exceptionVal);
99 JS_FreeValue(_context, res);
100 throw std::runtime_error("[" + _metadata.Name + "]\n" + details);
101 }
102 JS_FreeValue(_context, res);
103}
104
105void Plugin::StopBegin()
106{

Callers 2

LaunchMethod · 0.45
StartPluginMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected