Skip to content

Commit 0e96931

Browse files
committed
feat: update node engine to v22.12.0
fix: fix some warnings
1 parent de21675 commit 0e96931

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

src/legacy/api/BlockAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ Local<Value> BlockClass::destroyBlock(const Arguments& args) {
319319

320320
Local<Value> BlockClass::getNbt(const Arguments&) {
321321
try {
322-
return NbtCompoundClass::pack(std::move(block->getSerializationId().clone()));
322+
return NbtCompoundClass::pack(block->getSerializationId().clone());
323323
}
324324
CATCH("Fail in getNbt!");
325325
}

src/legacy/api/FileSystemAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ Local<Value> FileClass::writeLine(const Arguments& args) {
388388
if (args.size() >= 2) CHECK_ARG_TYPE(args[1], ValueKind::kFunction);
389389

390390
try {
391-
std::string data{std::move(args[0].asString().toString())};
391+
std::string data{args[0].asString().toString()};
392392

393393
script::Global<Function> callbackFunc;
394394
if (args.size() >= 2) callbackFunc = args[1].asFunction();

src/legacy/api/ItemAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ Local<Value> ItemClass::setDamage(const Arguments& args) {
401401

402402
Local<Value> ItemClass::getNbt(const Arguments&) {
403403
try {
404-
return NbtCompoundClass::pack(std::move(get()->save(*SaveContextFactory::createCloneSaveContext())));
404+
return NbtCompoundClass::pack(get()->save(*SaveContextFactory::createCloneSaveContext()));
405405
}
406406
CATCH("Fail in getNbt!");
407407
}

src/legacy/api/StructureAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Local<Value> McClass::getStructure(const Arguments& args) {
4848
ignoreEntities
4949
);
5050

51-
return NbtCompoundClass::pack(std::move(structure->save()));
51+
return NbtCompoundClass::pack(structure->save());
5252
}
5353
CATCH("Fail in getStructure!");
5454
}

src/legacy/main/NodeJsHelper.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,16 @@ bool initNodeJs() {
4747
auto path = ll::string_utils::wstr2str(buf) + "\\bedrock_server_mod.exe";
4848
char* cPath = (char*)path.c_str();
4949
uv_setup_args(1, &cPath);
50-
args = {path};
51-
std::vector<std::string> errors;
52-
auto exitCode = node::InitializeNodeWithArgs(&args, &exec_args, &errors);
53-
if (exitCode != 0) {
50+
args = {path};
51+
auto result = node::InitializeOncePerProcess(
52+
args,
53+
node::ProcessInitializationFlags::Flags(
54+
node::ProcessInitializationFlags::kNoInitializeV8
55+
| node::ProcessInitializationFlags::kNoInitializeNodeV8Platform
56+
)
57+
);
58+
exec_args = result->exec_args();
59+
if (result->exit_code() != 0) {
5460
lse::getSelfModInstance().getLogger().error("Failed to initialize node! NodeJs plugins won't be loaded");
5561
return false;
5662
}
@@ -67,7 +73,7 @@ bool initNodeJs() {
6773

6874
void shutdownNodeJs() {
6975
v8::V8::Dispose();
70-
v8::V8::ShutdownPlatform();
76+
v8::V8::DisposePlatform();
7177
}
7278

7379
script::ScriptEngine* newEngine() {
@@ -132,8 +138,7 @@ bool loadPluginCode(script::ScriptEngine* engine, std::string entryScriptPath, s
132138
auto it = setups->find(engine);
133139
if (it == setups->end()) return false;
134140

135-
auto isolate = it->second->isolate();
136-
auto env = it->second->env();
141+
auto env = it->second->env();
137142

138143
try {
139144
using namespace v8;

xmake.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ target("legacy-script-engine")
133133

134134
elseif is_config("backend", "nodejs") then
135135
add_defines(
136-
"LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS"
136+
"LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS",
137+
"USING_V8_PLATFORM_SHARED"
137138
)
138139
set_basename("legacy-script-engine-nodejs")
139140
after_build(function(target)

0 commit comments

Comments
 (0)