Skip to content

Commit 40d49f6

Browse files
committed
refactor: clean some wrong code
1 parent 5b3e40d commit 40d49f6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/legacy/api/SystemAPI.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "engine/EngineManager.h"
55
#include "engine/TimeTaskSystem.h"
66
#include "ll/api/chrono/GameChrono.h"
7+
#include "ll/api/schedule/Scheduler.h"
78
#include "ll/api/schedule/Task.h"
89
#include "ll/api/service/ServerInfo.h"
910
#include "ll/api/utils/ErrorUtils.h"
@@ -26,6 +27,7 @@ ClassDefine<void> SystemClassBuilder = defineClass("system")
2627
.function("newProcess", &SystemClass::newProcess)
2728
.build();
2829

30+
ll::schedule::Scheduler<ll::chrono::GameTickClock> systemScheduler;
2931
// From LiteLoaderBDSv2 llapi/utils/WinHelper.cpp
3032
bool NewProcess(
3133
const std::string& process,
@@ -115,7 +117,7 @@ Local<Value> SystemClass::cmd(const Arguments& args) {
115117
return Boolean::newBoolean(NewProcess(
116118
"cmd /c" + cmd,
117119
[callback{std::move(callbackFunc)}, engine{EngineScope::currentEngine()}](int exitCode, string output) {
118-
ll::schedule::DelayTask<ll::chrono::GameTickClock>(
120+
systemScheduler.add<ll::schedule::DelayTask>(
119121
ll::chrono::ticks(1),
120122
[engine, callback = std::move(callback), exitCode, output = std::move(output)]() {
121123
if ((ll::getServerStatus() != ll::ServerStatus::Running)) return;
@@ -150,7 +152,7 @@ Local<Value> SystemClass::newProcess(const Arguments& args) {
150152
return Boolean::newBoolean(NewProcess(
151153
process,
152154
[callback{std::move(callbackFunc)}, engine{EngineScope::currentEngine()}](int exitCode, string output) {
153-
ll::schedule::DelayTask<ll::chrono::GameTickClock>(
155+
systemScheduler.add<ll::schedule::DelayTask>(
154156
ll::chrono::ticks(1),
155157
[engine, callback = std::move(callback), exitCode, output = std::move(output)]() {
156158
if ((ll::getServerStatus() != ll::ServerStatus::Running)) return;
@@ -162,7 +164,7 @@ Local<Value> SystemClass::newProcess(const Arguments& args) {
162164
}
163165
CATCH_IN_CALLBACK("newProcess")
164166
}
165-
).call();
167+
);
166168
},
167169
args.size() >= 3 ? args[2].toInt() : -1
168170
));

0 commit comments

Comments
 (0)