Skip to content

Commit a5839a8

Browse files
committed
fix: fix debug engine logger
1 parent 5ceb498 commit a5839a8

File tree

4 files changed

+40
-39
lines changed

4 files changed

+40
-39
lines changed

src/legacy/engine/EngineOwnData.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ struct SimpleCallbackData
3535
};
3636
*/
3737

38-
class Player;
39-
38+
// It is similar to ll::mod::Mod, it stores data of an engine(usually a plugin).
4039
struct EngineOwnData {
4140
// 基础信息
4241
std::string pluginName = "";

src/legacy/main/Global.cpp

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,4 @@
11
#include "main/Global.h"
22

33
// 全局变量
4-
bool isCmdRegisterEnabled = false;
5-
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS)
6-
// QuickJs
7-
const std::string LLSE_BACKEND_TYPE = "Js";
8-
9-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
10-
// Lua
11-
const std::string LLSE_BACKEND_TYPE = "Lua";
12-
13-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
14-
// NodeJs
15-
const std::string LLSE_BACKEND_TYPE = "NodeJs";
16-
17-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
18-
// Python
19-
const std::string LLSE_BACKEND_TYPE = "Python";
20-
#endif
21-
22-
const int LLSE_VALID_BACKENDS_COUNT = 4;
23-
24-
// Debug engine information
25-
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
26-
const std::string LLSE_DEBUG_CMD = "nodejsdebug";
27-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS)
28-
const std::string LLSE_DEBUG_CMD = "jsdebug";
29-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
30-
const std::string LLSE_DEBUG_CMD = "luadebug";
31-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
32-
const std::string LLSE_DEBUG_CMD = "pydebug";
33-
#endif
34-
35-
const wchar_t* LLSE_GLOBAL_DATA_NAME = L"LLSE_GLOBAL_DATA_SECTION";
4+
bool isCmdRegisterEnabled = false;

src/legacy/main/Global.h

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,36 @@ inline std::string DimId2Name(int dimid) {
5959
}
6060

6161
// 全局变量
62-
extern bool isCmdRegisterEnabled;
63-
extern const std::string LLSE_BACKEND_TYPE;
64-
extern const int LLSE_VALID_BACKENDS_COUNT;
65-
extern const std::string LLSE_DEBUG_CMD;
66-
extern const wchar_t* LLSE_GLOBAL_DATA_NAME;
62+
extern bool isCmdRegisterEnabled;
63+
64+
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS)
65+
// QuickJs
66+
constexpr std::string LLSE_BACKEND_TYPE = "Js";
67+
68+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
69+
// Lua
70+
constexpr std::string LLSE_BACKEND_TYPE = "Lua";
71+
72+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
73+
// NodeJs
74+
const std::string LLSE_BACKEND_TYPE = "NodeJs";
75+
76+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
77+
// Python
78+
const std::string LLSE_BACKEND_TYPE = "Python";
79+
#endif
80+
81+
const int LLSE_VALID_BACKENDS_COUNT = 4;
82+
83+
// Debug engine information
84+
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
85+
constexpr std::string LLSE_DEBUG_CMD = "nodejsdebug";
86+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS)
87+
constexpr std::string LLSE_DEBUG_CMD = "jsdebug";
88+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
89+
constexpr std::string LLSE_DEBUG_CMD = "luadebug";
90+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
91+
constexpr std::string LLSE_DEBUG_CMD = "pydebug";
92+
#endif
93+
94+
constexpr wchar_t LLSE_GLOBAL_DATA_NAME[] = L"LLSE_GLOBAL_DATA_SECTION";

src/lse/Entry.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "legacy/engine/EngineManager.h"
66
#include "legacy/main/EconomicSystem.h"
77
#include "lse/api/MoreGlobal.h"
8+
#include "legacy/engine/EngineOwnData.h"
89

910
#include <ScriptX/ScriptX.h>
1011
#include <exception>
@@ -149,6 +150,10 @@ void loadDebugEngine(const ll::mod::NativeMod& self) {
149150

150151
script::EngineScope engineScope(scriptEngine);
151152

153+
ll::mod::Manifest manifest;
154+
manifest.name = "DebugEngine";
155+
getEngineOwnData()->plugin = std::make_shared<lse::Plugin>(manifest);
156+
152157
BindAPIs(&scriptEngine);
153158

154159
// Load BaseLib.

0 commit comments

Comments
 (0)