diff options
author | Lumi Kalt <99078103+lumikalt@users.noreply.github.com> | 2024-02-14 19:32:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-14 19:32:09 +0000 |
commit | f96664b29af6d12a92e309e4be558e45e24015df (patch) | |
tree | 2c1166a7175afb2b72983256e7a7e9747f47f8c1 | |
parent | 1641c466201e7d8df51b97f0527da58814f04b2d (diff) | |
parent | eb9564c3dedca186f9292bc43a7c1b74990c8d02 (diff) |
Merge pull request #17 from yzh5606/main
seems fix the memory issue
-rw-r--r-- | source/game/scripting/StarLuaRoot.cpp | 6 | ||||
-rw-r--r-- | source/utility/world_benchmark.cpp | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/source/game/scripting/StarLuaRoot.cpp b/source/game/scripting/StarLuaRoot.cpp index c538df1..d79e8f4 100644 --- a/source/game/scripting/StarLuaRoot.cpp +++ b/source/game/scripting/StarLuaRoot.cpp @@ -106,9 +106,11 @@ LuaContext LuaRoot::createContext(StringList const& scriptPaths) { } }); - newContext.set("loadstring", m_luaEngine->createFunction([newContext](String const& source, Maybe<String> const& name, Maybe<LuaValue> const& env) -> LuaFunction { + auto handleIndex = newContext.handleIndex(); + auto engine = m_luaEngine.get(); + newContext.set("loadstring", m_luaEngine->createFunction([engine,handleIndex](String const& source, Maybe<String> const& name, Maybe<LuaValue> const& env) -> LuaFunction { String functionName = name ? strf("loadstring: {}", *name) : "loadstring"; - return newContext.engine().createFunctionFromSource(newContext.handleIndex(), source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr()); + return engine->createFunctionFromSource(handleIndex, source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr()); })); auto assets = Root::singleton().assets(); diff --git a/source/utility/world_benchmark.cpp b/source/utility/world_benchmark.cpp index 40476a1..90524f5 100644 --- a/source/utility/world_benchmark.cpp +++ b/source/utility/world_benchmark.cpp @@ -81,7 +81,7 @@ int main(int argc, char** argv) { lastReport = Time::monotonicTime(); coutf("[{}] {}s | FPS: {} | Entities: {}\n", j, Time::monotonicTime() - start, fps, entityCount); } - worldServer.update(); + worldServer.update(ServerGlobalTimestep * GlobalTimescale); } double totalTime = Time::monotonicTime() - start; coutf("Finished run of running dungeon world '{}' with seed {} for {} steps in {} seconds, average FPS: {}\n", |