Skip to content

Commit 3e9c5f3

Browse files
committed
fix: start support levilamina 0.7.x
1 parent 205e387 commit 3e9c5f3

File tree

17 files changed

+46
-49
lines changed

17 files changed

+46
-49
lines changed

src/legacy/api/APIHelp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Local<Value> JsonToValue(std::string jsonStr) {
355355
} catch (const ordered_json::exception& e) {
356356
lse::getSelfPluginInstance().getLogger().warn(
357357
"{}{}",
358-
tr("llse.apiHelp.parseJson.fail"),
358+
"llse.apiHelp.parseJson.fail"_tr(),
359359
ll::string_utils::tou8str(e.what())
360360
);
361361
return String::newString(jsonStr);

src/legacy/api/BaseAPI.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ Local<Value> FloatPos::getDim() {
128128
string name;
129129
switch (dim) {
130130
case 0:
131-
name = tr("base.getDimName.0");
131+
name = "base.getDimName.0"_tr();
132132
break;
133133
case 1:
134-
name = tr("base.getDimName.1");
134+
name = "base.getDimName.1"_tr();
135135
break;
136136
case 2:
137-
name = tr("base.getDimName.2");
137+
name = "base.getDimName.2"_tr();
138138
break;
139139
default:
140-
name = tr("base.getDimName.unknown");
140+
name = "base.getDimName.unknown"_tr();
141141
break;
142142
}
143143
return String::newString(name);

src/legacy/api/EntityAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ Local<Value> EntityClass::quickEvalMolangScript(const Arguments& args) {
14471447
try {
14481448
Actor* actor = get();
14491449
if (!actor) return Local<Value>();
1450-
return Number::newNumber(actor->quickEvalMolangScript(args[0].toStr()));
1450+
return Number::newNumber(actor->evalMolang(args[0].toStr()));
14511451
}
14521452
CATCH("Fail in quickEvalMolangScript!");
14531453
}

src/legacy/api/InternationalAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "api/InternationalAPI.h"
33

44
#include <FMT/args.h>
5-
#include <ll/api/i18n/I18nAPI.h>
5+
#include <ll/api/i18n/I18n.h>
66

77
void FormatHelper(
88
std::vector<Local<Value>>& args,

src/legacy/api/PlayerAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,7 @@ Local<Value> PlayerClass::quickEvalMolangScript(const Arguments& args) {
30263026
try {
30273027
Player* actor = get();
30283028
if (!actor) return Local<Value>();
3029-
return Number::newNumber(actor->quickEvalMolangScript(args[0].toStr()));
3029+
return Number::newNumber(actor->evalMolang(args[0].toStr()));
30303030
}
30313031
CATCH("Fail in quickEvalMolangScript!");
30323032
}

src/legacy/engine/EngineOwnData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "dyncall/dyncall.h"
44
#include "ll/api/Logger.h"
5-
#include "ll/api/i18n/I18nAPI.h"
5+
#include "ll/api/i18n/I18n.h"
66
#include "main/Configs.h"
77
#include "utils/UsingScriptX.h"
88

src/legacy/engine/GlobalShareData.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ void InitGlobalShareData() {
2424
(LLSE_GLOBAL_DATA_NAME + std::to_wstring(GetCurrentProcessId())).c_str()
2525
);
2626
if (hGlobalData == NULL) {
27-
lse::getSelfPluginInstance().getLogger().error(tr("init.fileMapping.fail"));
27+
lse::getSelfPluginInstance().getLogger().error("init.fileMapping.fail"_tr());
2828
localShareData->isFirstInstance = true;
2929
return;
3030
}
3131

3232
LPVOID address = MapViewOfFile(hGlobalData, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
3333
if (address == NULL) {
34-
lse::getSelfPluginInstance().getLogger().error(tr("init.mapFile.fail"));
34+
lse::getSelfPluginInstance().getLogger().error("init.mapFile.fail"_tr());
3535
localShareData->isFirstInstance = true;
3636
return;
3737
}

src/legacy/legacyapi/command/DynamicCommand.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "fmt/core.h"
44
#include "ll/api/Logger.h"
5+
#include "ll/api/command/CommandRegistrar.h"
56
#include "ll/api/memory/Closure.h"
67
#include "ll/api/memory/Memory.h"
78
#include "ll/api/utils/ErrorUtils.h"
@@ -34,6 +35,7 @@
3435
#include <algorithm>
3536
#include <cstddef>
3637
#include <cstdint>
38+
#include <ll/api/command/CommandRegistrar.h>
3739
#include <memory>
3840
#include <sstream>
3941
#include <stdexcept>
@@ -453,30 +455,24 @@ DynamicCommand::preSetup(CommandRegistry& registry, std::unique_ptr<class Dynami
453455
if (param.type == ParameterType::Enum) {
454456
// clone BDS's enum
455457
if (commandInstance->enumRanges.count(param.description) == 0) {
456-
auto namesInBds = registry.getEnumNames();
457-
auto iter = std::find(namesInBds.begin(), namesInBds.end(), param.description);
458-
if (iter == namesInBds.end())
459-
throw std::runtime_error(
460-
"Enum " + std::string(param.description) + "not found in command and BDS"
461-
);
462-
commandInstance->setEnum(*iter, registry.getEnumValues(*iter));
458+
if (!ll::command::CommandRegistrar::getInstance().hasEnum(param.description))
459+
throw std::runtime_error("Enum " + param.description + "not found in command and BDS");
460+
commandInstance->setEnum(param.description, registry.getEnumValues(*iter));
463461
}
464462
} else if (param.type == ParameterType::SoftEnum) {
465463
// add empty Soft Enum if not found in command and BDS
466464
if (commandInstance->softEnums.count(param.description) == 0) {
467-
auto namesInBds = registry.getSoftEnumNames();
468-
auto iter = std::find(namesInBds.begin(), namesInBds.end(), param.description);
469-
if (iter == namesInBds.end()) commandInstance->setSoftEnum(param.description, {});
465+
if (!ll::command::CommandRegistrar::getInstance().hasSoftEnum(param.description))
466+
commandInstance->setSoftEnum(param.description, {});
470467
}
471468
}
472469
}
473470

474471
// fix enum name with prefix '_...' if Enum name is exists in BDS
475-
auto namesInBds = registry.getEnumNames();
476472
std::unordered_map<std::string_view, std::pair<size_t, size_t>> convertedEnumRanges;
477473
for (auto& [desc, range] : commandInstance->enumRanges) {
478474
std::string fixedName = desc.data();
479-
while (std::find(namesInBds.begin(), namesInBds.end(), fixedName) != namesInBds.end()) {
475+
while (!ll::command::CommandRegistrar::getInstance().hasEnum(fixedName)) {
480476
fixedName.append("_");
481477
}
482478
std::string_view fixedView = desc;
@@ -881,8 +877,7 @@ std::string DynamicCommandInstance::setSoftEnum(std::string const& name, std::ve
881877
if (!hasRegistered()) {
882878
softEnums.emplace(name, values);
883879
} else {
884-
auto names = registry.getSoftEnumNames();
885-
if (std::find(names.begin(), names.end(), name) == names.end()) {
880+
if (!ll::command::CommandRegistrar::getInstance().hasSoftEnum(name)) {
886881
registry.addSoftEnum(name, values);
887882
return name;
888883
}
@@ -900,8 +895,7 @@ bool DynamicCommandInstance::addSoftEnumValues(std::string const& name, std::vec
900895
setSoftEnum(name, values);
901896
}
902897
} else {
903-
auto names = registry.getSoftEnumNames();
904-
if (std::find(names.begin(), names.end(), name) == names.end()) {
898+
if (!ll::command::CommandRegistrar::getInstance().hasSoftEnum(name)) {
905899
registry.addSoftEnum(name, values);
906900
return true;
907901
}

src/legacy/legacyapi/command/DynamicCommand.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include <utility>
4444
#include <vector>
4545

46-
4746
namespace ll::memory {
4847
template <class Ret, class... Args>
4948
class NativeClosure;
@@ -276,7 +275,7 @@ class DynamicCommand : public Command {
276275
std::string toDebugString() const;
277276
DynamicCommandInstance const* getInstance() const;
278277

279-
template <ll::concepts::ConceptFor<valid_type> T>
278+
template <ll::concepts::Require<valid_type> T>
280279
T const& getRaw() const {
281280

282281
if (type == ParameterType::Enum) {
@@ -295,7 +294,7 @@ class DynamicCommand : public Command {
295294
));
296295
}
297296

298-
template <ll::concepts::ConceptFor<valid_type> T>
297+
template <ll::concepts::Require<valid_type> T>
299298
T const& value_or(T const& defaultValue) {
300299
if (isSet) return getRaw<T>();
301300
return defaultValue;

src/legacy/legacyapi/db/Session.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "legacyapi/db/impl/mysql/Session.h"
44
#include "legacyapi/db/impl/sqlite/Session.h"
5+
#include "ll/api/utils/StringUtils.h"
56

67
namespace DB {
78

0 commit comments

Comments
 (0)