Skip to content

Commit

Permalink
simplesquirrel: Store Squirrel thread object handlers in main ssq::VM
Browse files Browse the repository at this point in the history
  • Loading branch information
Vankata453 committed Jan 11, 2025
1 parent 8b5bc3c commit 6b5506c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion external/simplesquirrel
5 changes: 0 additions & 5 deletions src/squirrel/squirrel_environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ SquirrelEnvironment::SquirrelEnvironment(ssq::VM& vm, const std::string& name) :
m_scripts(),
m_scheduler(std::make_unique<SquirrelScheduler>(m_vm))
{
// Garbage collector has to be invoked manually!
sq_collectgarbage(m_vm.getHandle());

// Set the root table as delegate.
m_table.setDelegate(m_vm);
}
Expand All @@ -44,8 +41,6 @@ SquirrelEnvironment::~SquirrelEnvironment()
{
m_scripts.clear();
m_table.reset();

sq_collectgarbage(m_vm.getHandle());
}

void
Expand Down
8 changes: 5 additions & 3 deletions src/squirrel/supertux_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ static bool check_cutscene()
static SQInteger wait(HSQUIRRELVM vm, float seconds, bool forced = false)
{
ssq::VM* ssq_vm = ssq::VM::get(vm);
if (ssq_vm && !ssq_vm->isThread()) return 0;
assert(ssq_vm);
if (!ssq_vm->isThread()) return 0;

if (!forced)
{
Expand Down Expand Up @@ -310,10 +311,11 @@ static void load_level(const std::string& filename)
*/
static void import(HSQUIRRELVM vm, const std::string& filename)
{
ssq::VM ssq_vm(vm);
ssq::VM* ssq_vm = ssq::VM::get(vm);
assert(ssq_vm);

IFileStream in(filename);
ssq_vm.run(ssq_vm.compileSource(in, filename.c_str()));
ssq_vm->run(ssq_vm->compileSource(in, filename.c_str()));
}

/**
Expand Down

0 comments on commit 6b5506c

Please sign in to comment.