Skip to content

Commit 06c1757

Browse files
committed
refactor: remove more macro
1 parent cc7aaff commit 06c1757

File tree

6 files changed

+17
-28
lines changed

6 files changed

+17
-28
lines changed

src/legacy/engine/MessageSystem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ModuleMessageResult ModuleMessage::broadcastLocal(MessageType type, string data,
9898
for (auto& engine : engines) {
9999
try {
100100
engine->messageQueue()->postMessage(
101-
PackEngineMessage(LLSE_MODULE_TYPE, type, data, &msgId),
101+
PackEngineMessage(LLSE_BACKEND_TYPE, type, data, &msgId),
102102
std::chrono::milliseconds(delay)
103103
);
104104
engineList.push_back(engine);
@@ -184,7 +184,7 @@ ModuleMessageResult ModuleMessage::broadcastTo(std::string toModuleType, Message
184184

185185
ModuleMessageResult ModuleMessage::sendTo(ScriptEngine* engine, MessageType type, std::string data, int64_t delay) {
186186
int msgId = -1;
187-
string toModuleType = LLSE_MODULE_TYPE;
187+
string toModuleType = LLSE_BACKEND_TYPE;
188188

189189
try {
190190
engine->messageQueue()->postMessage(
@@ -342,14 +342,14 @@ void MessageSystemLoopOnce() {
342342
}
343343
}
344344
// messageLoopLock.unlock();
345-
// lse::getSelfPluginInstance().getLogger().debug("Engine-{} Message Loop.", LLSE_MODULE_TYPE);
345+
// lse::getSelfPluginInstance().getLogger().debug("Engine-{} Message Loop.", LLSE_BACKEND_TYPE);
346346
}
347347

348348
void InitMessageSystem() {
349349
#ifdef NDEBUG
350350
ll::error_utils::initExceptionTranslator();
351351
#endif
352-
globalShareData->messageSystemHandlers[LLSE_MODULE_TYPE] = {ModuleMessage::handle, ModuleMessage::cleanup};
352+
globalShareData->messageSystemHandlers[LLSE_BACKEND_TYPE] = {ModuleMessage::handle, ModuleMessage::cleanup};
353353

354354
ll::event::EventBus::getInstance().emplaceListener<ll::event::ServerStoppingEvent>(
355355
[](ll::event::ServerStoppingEvent&) { EndMessageSystemLoop(); }

src/legacy/engine/MessageSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ModuleMessage {
5353
MessageHeader() {
5454
id = getNextMessageId();
5555
fromEngine = EngineScope::currentEngine();
56-
fromEngineModuleType = LLSE_MODULE_TYPE;
56+
fromEngineModuleType = LLSE_BACKEND_TYPE;
5757
}
5858
int id;
5959
ScriptEngine* fromEngine;

src/legacy/engine/RemoteCall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void inline StringTrim(string& str) {
2121

2222
void RemoteSyncCallRequest(ModuleMessage& msg) {
2323
// lse::getSelfPluginInstance().getLogger().debug("*** Remote call request received.");
24-
// lse::getSelfPluginInstance().getLogger().debug("*** Current Module:{}", LLSE_MODULE_TYPE);
24+
// lse::getSelfPluginInstance().getLogger().debug("*** Current Module:{}", LLSE_BACKEND_TYPE);
2525

2626
std::istringstream sin(msg.getData());
2727

@@ -119,7 +119,7 @@ bool LLSEExportFunc(ScriptEngine *engine, const Local<Function> &func, const str
119119
return false;
120120
funcData->engine = engine;
121121
funcData->func = script::Global<Function>(func);
122-
funcData->fromEngineType = LLSE_MODULE_TYPE;
122+
funcData->fromEngineType = LLSE_BACKEND_TYPE;
123123
funcData->callback = [exportName](std::vector<std::string> params) -> std::string {
124124
auto data = globalShareData->exportedFuncs.find(exportName);
125125
if (data == globalShareData->exportedFuncs.end())

src/legacy/legacyapi/command/DynamicCommand.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "magic_enum.hpp"
99
#include "mc/deps/core/utility/typeid_t.h"
1010
#include "mc/nbt/CompoundTag.h"
11-
#include "mc/network/packet/AvailableCommandsPacket.h"
1211
#include "mc/server/commands/BlockStateCommandParam.h"
1312
#include "mc/server/commands/Command.h"
1413
#include "mc/server/commands/CommandBlockName.h"
@@ -31,11 +30,8 @@
3130
#include "mc/world/item/ItemInstance.h"
3231
#include "mc/world/level/Level.h"
3332

34-
#include <algorithm>
35-
#include <cstddef>
3633
#include <cstdint>
3734
#include <ll/api/command/CommandRegistrar.h>
38-
#include <ll/api/io/Logger.h>
3935
#include <memory>
4036
#include <sstream>
4137
#include <stdexcept>
@@ -54,8 +50,6 @@ bool CommandRegistry::parse<std::pair<
5450
return true;
5551
}
5652

57-
#define logger lse::getSelfPluginInstance().getLogger()
58-
5953
#define ForEachParameterType(func) \
6054
func(Bool); \
6155
func(Int); \
@@ -133,9 +127,9 @@ auto const ParameterSizeMap = std::unordered_map<ParameterType, size_t>{
133127
};
134128

135129
inline void OutputError(const std::string& command, const std::string& func = __builtin_FUNCTION()) {
136-
ll::error_utils::printCurrentException(logger);
137-
logger.error("In Function ({})", func);
138-
logger.error("In Command <{}>", command);
130+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
131+
lse::getSelfPluginInstance().getLogger().error("In Function ({})", func);
132+
lse::getSelfPluginInstance().getLogger().error("In Command <{}>", command);
139133
}
140134

141135
} // namespace
@@ -426,7 +420,7 @@ std::string DynamicCommand::Result::toDebugString() const {
426420
isSet ? getRaw<std::unique_ptr<Command>>()->getCommandName() : "Null"
427421
);
428422
default:
429-
logger.error("Unknown Parameter Type {}, name: {}", typeName, name);
423+
lse::getSelfPluginInstance().getLogger().error("Unknown Parameter Type {}, name: {}", typeName, name);
430424
return "";
431425
}
432426
}
@@ -446,7 +440,7 @@ DynamicCommandInstance*
446440
DynamicCommand::preSetup(CommandRegistry& registry, std::unique_ptr<class DynamicCommandInstance> commandInstance) {
447441
std::string name = commandInstance->getCommandName();
448442
#if defined(LEGACYSCRIPTENGINE_DEBUG)
449-
logger.debug("Setting up command \"{}\"", name);
443+
lse::getSelfPluginInstance().getLogger().debug("Setting up command \"{}\"", name);
450444
#endif
451445
// Check if there is another command with the same name
452446
auto signature = registry.findCommand(name);
@@ -556,7 +550,10 @@ DynamicCommand::~DynamicCommand() {
556550
std::string commandName = getCommandName();
557551
auto iter = dynamicCommandInstances.find(commandName);
558552
if (iter == dynamicCommandInstances.end()) {
559-
logger.error("Error in DynamicCommand::~DynamicCommand(), command \"{}\" not found", commandName);
553+
lse::getSelfPluginInstance().getLogger().error(
554+
"Error in DynamicCommand::~DynamicCommand(), command \"{}\" not found",
555+
commandName
556+
);
560557
return;
561558
}
562559
auto& commandIns = *iter->second;
@@ -604,7 +601,7 @@ DynamicCommandInstance const*
604601
DynamicCommand::setup(CommandRegistry& registry, std::unique_ptr<class DynamicCommandInstance> commandInstance) {
605602
auto name = commandInstance->getCommandName();
606603
auto ptr = preSetup(registry, std::move(commandInstance));
607-
if (!ptr) logger.warn("Registering command \"{}\" failed", name);
604+
if (!ptr) lse::getSelfPluginInstance().getLogger().warn("Registering command \"{}\" failed", name);
608605
updateAvailableCommands(registry);
609606
return ptr;
610607
}

src/legacy/main/Configs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#endif
2121

2222
// All backends information
23-
#define LLSE_MODULE_TYPE LLSE_BACKEND_TYPE
2423
#define LLSE_VALID_BACKENDS_COUNT 4
2524

2625
// Debug engine information

src/legacy/main/Global.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
#pragma once
22

3-
#ifndef WIN32_LEAN_AND_MEAN
4-
#define WIN32_LEAN_AND_MEAN
5-
#endif
6-
#ifndef CPPHTTPLIB_OPENSSL_SUPPORT
7-
#define CPPHTTPLIB_OPENSSL_SUPPORT
8-
#endif
9-
103
#include "mc/deps/core/math/Vec3.h"
114
#include "mc/world/level/BlockPos.h"
125

0 commit comments

Comments
 (0)