mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-20 19:02:41 +01:00
Codechange: Get/pass engine by reference instead of pointer.
This commit is contained in:
committed by
Peter Nelson
parent
7ff0c67f77
commit
55098a2f2e
@@ -97,8 +97,8 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||
/* static */ HSQOBJECT ScriptController::Import(const std::string &library, const std::string &class_name, int version)
|
||||
{
|
||||
ScriptController &controller = ScriptObject::GetActiveInstance().GetController();
|
||||
Squirrel *engine = ScriptObject::GetActiveInstance().engine;
|
||||
HSQUIRRELVM vm = engine->GetVM();
|
||||
Squirrel &engine = *ScriptObject::GetActiveInstance().engine;
|
||||
HSQUIRRELVM vm = engine.GetVM();
|
||||
|
||||
ScriptInfo *lib = ScriptObject::GetActiveInstance().FindLibrary(library, version);
|
||||
if (lib == nullptr) {
|
||||
@@ -128,7 +128,7 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||
sq_pushstring(vm, fake_class);
|
||||
sq_newclass(vm, SQFalse);
|
||||
/* Load the library */
|
||||
if (!engine->LoadScript(vm, lib->GetMainScript(), false)) {
|
||||
if (!engine.LoadScript(vm, lib->GetMainScript(), false)) {
|
||||
throw sq_throwerror(vm, fmt::format("there was a compile error when importing '{}' version {}", library, version));
|
||||
}
|
||||
/* Create the fake class */
|
||||
|
||||
@@ -310,8 +310,8 @@ ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
||||
IncreaseDoCommandCosts(res.GetCost());
|
||||
if (!_generating_world) {
|
||||
/* Charge a nominal fee for asynchronously executed commands */
|
||||
Squirrel *engine = ScriptObject::GetActiveInstance().engine;
|
||||
Squirrel::DecreaseOps(engine->GetVM(), 100);
|
||||
Squirrel &engine = *ScriptObject::GetActiveInstance().engine;
|
||||
Squirrel::DecreaseOps(engine.GetVM(), 100);
|
||||
}
|
||||
if (callback != nullptr) {
|
||||
/* Insert return value into to stack and throw a control code that
|
||||
|
||||
Reference in New Issue
Block a user