From edd3e9bb916688b13d8a8fb8adcd1dceef20d22b Mon Sep 17 00:00:00 2001 From: MacroModel Date: Tue, 11 Apr 2023 22:32:07 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=96=B0=E8=87=AA=E5=8A=A8=E8=A1=A5?= =?UTF-8?q?=E5=85=A8=EF=BC=88=E5=BC=80=E5=8F=91=E4=B8=AD=EF=BC=8C=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=BC=96=E8=AF=91=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- China/HeliumClient/Commands/ICommand.h | 197 ++++++++++++++++++++++++- 1 file changed, 192 insertions(+), 5 deletions(-) diff --git a/China/HeliumClient/Commands/ICommand.h b/China/HeliumClient/Commands/ICommand.h index 4780ba5..61335f3 100644 --- a/China/HeliumClient/Commands/ICommand.h +++ b/China/HeliumClient/Commands/ICommand.h @@ -1,6 +1,7 @@ #pragma once //#include +#include #include #include #include @@ -10,11 +11,197 @@ #include "../Setting/SettingManager.h" //#include "CommandsManager.h" -struct aliasList_struct { - std::u8string_view name{}; - void* next{}; // nullptr or fast_io::vector* +namespace details { + +template +concept has_next_objects = requires(T a) { + next_objects(a, nullptr, 0); + }; + +struct auto_completion_base_impl { + virtual constexpr ~auto_completion_base_impl() = default; + virtual constexpr fast_io::vector* next_objects_impl(fast_io::vector* cmdlist, size_t order) const noexcept = 0; + virtual constexpr auto_completion_base_impl* clone() const = 0; +}; + +template +struct auto_completion_derv_impl : auto_completion_base_impl { + T t; + auto_completion_derv_impl(std::in_place_t, T&& tt) : t{std::forward(tt)} {} + virtual constexpr fast_io::vector* next_objects_impl(fast_io::vector* cmdlist, size_t order) const noexcept override { + return next_objects(t, cmdlist, order); + } + virtual constexpr auto_completion_base_impl* clone() const override { + return new auto_completion_derv_impl(*this); + } +}; + +} // namespace details + +class aliasList_struct { +public: + ::details::auto_completion_base_impl* ptr{}; + constexpr aliasList_struct() noexcept = default; + template + explicit constexpr aliasList_struct(std::in_place_t, T&& tt) noexcept : ptr{new ::details::shape_derv_impl(std::in_place, std::forward(tt))} { + } + constexpr aliasList_struct(aliasList_struct const& other) : ptr{other.ptr->clone()} {} + constexpr aliasList_struct& operator=(aliasList_struct const& other) { + auto temp{other.ptr->clone()}; + delete this->ptr; + this->ptr = other.ptr; + return *this; + } + constexpr aliasList_struct(aliasList_struct&& other) noexcept : ptr{other.ptr} { + other.ptr = nullptr; + } + constexpr aliasList_struct& operator=(aliasList_struct&& other) noexcept { + delete this->ptr; + this->ptr = other.ptr; + other.ptr = nullptr; + return *this; + } + ~aliasList_struct() { + delete ptr; + } +}; + +inline constexpr fast_io::vector* next_objects(aliasList_struct const& p, fast_io::vector* cmdlist, size_t order) noexcept { + return p.ptr->next_objects_impl(cmdlist, order); +} + +struct Empty_Object { + fast_io::vector* next{}; +}; + +inline constexpr fast_io::vector* next_objects(Empty_Object p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + return p.next; +} + +struct stringview_Object { + std::u8string_view str{}; + fast_io::vector* next{}; }; +inline constexpr fast_io::vector* next_objects(stringview_Object p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + if (cmdlist->operator[](order) == p.str) + return p.next; + else + return nullptr; +} + +struct string_Object { + std::u8string str{}; + fast_io::vector* next{}; +}; + +inline constexpr fast_io::vector* next_objects(stringview_Object p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + if (cmdlist->operator[](order) == p.str) + return p.next; + else + return nullptr; +} + +template +struct integral_Object { // or equal to + _Ty min{}; + _Ty max{}; + fast_io::vector* next{}; +}; + +template +inline constexpr fast_io::vector* next_objects(integral_Object<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + _Ty num{}; + try { + num = fast_io::u8to<_Ty>(cmdlist->operator[](order)); + } catch (const fast_io::error&) { + return nullptr; + } + + if (num >= p.min && num <= p.max) + return next; + else + return nullptr; +} + +template +struct floating_point_Object { // or equal to + _Ty min{}; + bool equaltomin{}; + _Ty max{}; + bool equaltomax{}; + fast_io::vector* next{}; +}; + +template +inline constexpr fast_io::vector* next_objects(floating_point_Object<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + std::u8string& str{cmdlist->operator[](order)}; + + _Ty num{}; + try { + if constexpr (std::is_same_v<_Ty, float>) { + num = std::stof(*reinterpret_cast(&str)); + } else if constexpr (std::is_same_v<_Ty, double>) { + num = std::stod(*reinterpret_cast(&str)); + } else if constexpr (std::is_same_v<_Ty, long double>) { + num = std::stold(*reinterpret_cast(&str)); + } else { + static_cast(false, "floating_point must be float, double, long double"); + } + } catch (const std::exception&) { + return nullptr; + } + + if (p.equaltomin) { + if (num < p.min) + return nullptr; + } else { + if (num <= p.min) + return nullptr; + } + + if (p.equaltomax) { + if (num > p.max) + return nullptr; + } else { + if (num >= p.max) + return nullptr; + } + + return next; +} + +// i command class ICommand { public: std::u8string_view _command{}; @@ -24,8 +211,8 @@ public: std::shared_mutex iCommandLook{}; public: - void (*init)(ICommand*) = nullptr; - bool (*onExecute)(const fast_io::vector& args) = nullptr; + void (*init)(ICommand*){nullptr}; + bool (*onExecute)(const fast_io::vector& args){nullptr}; protected: static float assertFloat(std::u8string_view string); -- Gitee From bf0d0db0f851dca884aafce6de869c17f66346e7 Mon Sep 17 00:00:00 2001 From: MacroModel Date: Tue, 11 Apr 2023 22:55:23 +0800 Subject: [PATCH 2/8] update --- .../Commands/Commands/BindCommand.cpp | 2 +- .../Commands/Commands/ConfigCommand.cpp | 30 ++-- China/HeliumClient/Commands/ICommand.h | 153 ++++++++++++++++++ 3 files changed, 169 insertions(+), 16 deletions(-) diff --git a/China/HeliumClient/Commands/Commands/BindCommand.cpp b/China/HeliumClient/Commands/Commands/BindCommand.cpp index e04c5d5..e253d8d 100644 --- a/China/HeliumClient/Commands/Commands/BindCommand.cpp +++ b/China/HeliumClient/Commands/Commands/BindCommand.cpp @@ -5,7 +5,7 @@ void BindCommand_onInit(ICommand* _this) { _this->aliasList.reserve(ModuleManager::NameTable.size()); for (auto& i : ModuleManager::NameTable) - _this->aliasList.push_back_unchecked(aliasList_struct{std::u8string_view{i.first}, nullptr}); + _this->aliasList.emplace_back_unchecked(std::in_place, stringview_Object{std::u8string_view{i.first}, nullptr}); } diff --git a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp index 3e9ed67..daca52b 100644 --- a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp +++ b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp @@ -8,13 +8,12 @@ fast_io::vector configs_ConfigCommand{}; void listCommand_ConfigCommand() { - static fast_io::vector configsString{}; - configsString = ConfigManager::list(); + fast_io::vector configsString{ConfigManager::list()}; configs_ConfigCommand.clear(); configs_ConfigCommand.reserve(configsString.size()); for (auto& i : configsString) - configs_ConfigCommand.push_back_unchecked(aliasList_struct{std::u8string_view{i}, nullptr}); + configs_ConfigCommand.emplace_back_unchecked(std::in_place, string_Object{i, nullptr}); } bool ConfigCommand_onExecute(const fast_io::vector& args) { @@ -23,7 +22,8 @@ bool ConfigCommand_onExecute(const fast_io::vector& args) { return false; else if (args.size() == 2) { if (args[1] == u8"list"sv) { - listCommand_ConfigCommand(); + + fast_io::vector configsString{ConfigManager::list()}; C_GuiData::displayClientMessageC(Utils::TextColor::GRAY, u8"========================"); switch (SettingManager::languageget) { @@ -55,8 +55,8 @@ bool ConfigCommand_onExecute(const fast_io::vector& args) { std::unreachable(); } - for (auto& i : configs_ConfigCommand) - C_GuiData::displayClientMessageC(Utils::TextColor::GRAY, i.name); + for (auto& i : configsString) + C_GuiData::displayClientMessageC(Utils::TextColor::GRAY, i); return true; } else if (args[1] == u8"save"sv) { if (configMgr.saveConfig()) { @@ -265,8 +265,8 @@ bool ConfigCommand_onExecute(const fast_io::vector& args) { } return true; } else if (args[1] == u8"create"sv) { - listCommand_ConfigCommand(); - if (args[2] == configMgr.currentConfig || std::ranges::any_of(configs_ConfigCommand, [&args](aliasList_struct& al) { return args[2] == al.name; })) { + fast_io::vector configsString{ConfigManager::list()}; + if (args[2] == configMgr.currentConfig || std::ranges::any_of(configsString, [&args](std::u8string& al) { return args[2] == al; })) { switch (SettingManager::languageget) { case 0: default: @@ -414,8 +414,8 @@ bool ConfigCommand_onExecute(const fast_io::vector& args) { } return true; } - listCommand_ConfigCommand(); - if (std::ranges::any_of(configs_ConfigCommand, [&args](aliasList_struct& al) { return args[2] == al.name; }) && configMgr.deleteConfig(args[2])) { + fast_io::vector configsString{ConfigManager::list()}; + if (std::ranges::any_of(configsString, [&args](std::u8string& al) { return args[2] == al; }) && configMgr.deleteConfig(args[2])) { switch (SettingManager::languageget) { case 0: default: @@ -504,11 +504,11 @@ ICommand ConfigCommand{ {u8"Load, Create, Save, Delete or List Configuration", u8"加载, 创建, 保存, 删除或列出配置", u8"加載, 創建, 保存, 刪除或列出配置", u8"構成の読み込み、 作成、 保存、 削除、 一覧表示"}, {}, { - {u8"load", (void*)&configs_ConfigCommand}, - {u8"create", nullptr}, - {u8"save", nullptr}, - {u8"delete", (void*)&configs_ConfigCommand /*Place and delete by mistake, please enter manually*/}, - {u8"list", nullptr}, + aliasList_struct{std::in_place, stringview_Object{u8"load", &configs_ConfigCommand}}, + aliasList_struct{std::in_place, stringview_Object{u8"create", nullptr}}, + aliasList_struct{std::in_place, stringview_Object{u8"save", nullptr}}, + aliasList_struct{std::in_place, stringview_Object{u8"delete", &configs_ConfigCommand /*Place and delete by mistake, please enter manually*/}}, + aliasList_struct{std::in_place, stringview_Object{u8"list", nullptr}}, }, nullptr, &ConfigCommand_onExecute}; diff --git a/China/HeliumClient/Commands/ICommand.h b/China/HeliumClient/Commands/ICommand.h index 61335f3..2f1ba3a 100644 --- a/China/HeliumClient/Commands/ICommand.h +++ b/China/HeliumClient/Commands/ICommand.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "../../Utils/Utils.h" @@ -201,6 +202,158 @@ inline constexpr fast_io::vector* next_objects(floating_point_ return next; } +// Judge +struct Empty_Judge { + fast_io::vector* next{}; + bool (*judge)(fast_io::vector* cmdlist){}; +}; + +inline constexpr fast_io::vector* next_objects(Empty_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + if (p.judge(cmdlist)) + return p.next; + else + return nullptr; +} + +struct stringview_Judge { + std::u8string_view str{}; + fast_io::vector* next{}; + bool (*judge)(fast_io::vector* cmdlist){}; +}; + +inline constexpr fast_io::vector* next_objects(stringview_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + if (cmdlist->operator[](order) == p.str) { + if (p.judge(cmdlist)) + return p.next; + else + return nullptr; + } else + return nullptr; +} + +struct string_Judge { + std::u8string str{}; + fast_io::vector* next{}; + bool (*judge)(fast_io::vector* cmdlist){}; +}; + +inline constexpr fast_io::vector* next_objects(string_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + if (cmdlist->operator[](order) == p.str) { + if (p.judge(cmdlist)) + return p.next; + else + return nullptr; + } else + return nullptr; +} + +template +struct integral_Judge { // or equal to + _Ty min{}; + _Ty max{}; + fast_io::vector* next{}; + bool (*judge)(fast_io::vector* cmdlist){}; +}; + +template +inline constexpr fast_io::vector* next_objects(integral_Judge<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + _Ty num{}; + try { + num = fast_io::u8to<_Ty>(cmdlist->operator[](order)); + } catch (const fast_io::error&) { + return nullptr; + } + + if (num >= p.min && num <= p.max) { + if (p.judge(cmdlist)) + return p.next; + else + return nullptr; + } else + return nullptr; +} + +template +struct floating_point_Judge { // or equal to + _Ty min{}; + bool equaltomin{}; + _Ty max{}; + bool equaltomax{}; + fast_io::vector* next{}; + bool (*judge)(fast_io::vector* cmdlist){}; +}; + +template +inline constexpr fast_io::vector* next_objects(floating_point_Judge<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { + if (cmdlist == nullptr) [[unlikely]] + return nullptr; + + if (order >= cmdlist->size()) [[unlikely]] + return nullptr; + + std::u8string& str{cmdlist->operator[](order)}; + + _Ty num{}; + try { + if constexpr (std::is_same_v<_Ty, float>) { + num = std::stof(*reinterpret_cast(&str)); + } else if constexpr (std::is_same_v<_Ty, double>) { + num = std::stod(*reinterpret_cast(&str)); + } else if constexpr (std::is_same_v<_Ty, long double>) { + num = std::stold(*reinterpret_cast(&str)); + } else { + static_cast(false, "floating_point must be float, double, long double"); + } + } catch (const std::exception&) { + return nullptr; + } + + if (p.equaltomin) { + if (num < p.min) + return nullptr; + } else { + if (num <= p.min) + return nullptr; + } + + if (p.equaltomax) { + if (num > p.max) + return nullptr; + } else { + if (num >= p.max) + return nullptr; + } + + if (p.judge(cmdlist)) + return p.next; + else + return nullptr; +} + // i command class ICommand { public: -- Gitee From 4795d731d41e7bd852468f4857ea7a31c8a7247e Mon Sep 17 00:00:00 2001 From: MacroModel Date: Tue, 11 Apr 2023 23:14:25 +0800 Subject: [PATCH 3/8] fix --- .../Commands/Commands/ConfigCommand.cpp | 33 ++--- .../Commands/Commands/ConfigCommand.h | 2 - .../Commands/Commands/EjectCommand.cpp | 2 +- .../Commands/Commands/FriendCommand.cpp | 17 ++- .../Commands/Commands/SetLanguageCommand.cpp | 22 +-- .../Commands/Commands/ToggleCommand.cpp | 2 +- .../Commands/Commands/TranslateCommand.cpp | 128 +++++++++--------- China/HeliumClient/Commands/ICommand.h | 10 +- 8 files changed, 113 insertions(+), 103 deletions(-) diff --git a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp index daca52b..d87a7ce 100644 --- a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp +++ b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp @@ -5,17 +5,6 @@ #include "../../../Memory/GameData.h" #include "../../Config/ConfigManager.h" -fast_io::vector configs_ConfigCommand{}; - -void listCommand_ConfigCommand() { - fast_io::vector configsString{ConfigManager::list()}; - - configs_ConfigCommand.clear(); - configs_ConfigCommand.reserve(configsString.size()); - for (auto& i : configsString) - configs_ConfigCommand.emplace_back_unchecked(std::in_place, string_Object{i, nullptr}); -} - bool ConfigCommand_onExecute(const fast_io::vector& args) { using std::operator""sv; if (args.size() > 3 || args.size() < 2) @@ -498,17 +487,29 @@ bool ConfigCommand_onExecute(const fast_io::vector& args) { return false; } +fast_io::vector configs_ConfigCommand{}; + +bool listCommand_ConfigCommand(fast_io::vector*) { + fast_io::vector configsString{ConfigManager::list()}; + + configs_ConfigCommand.clear(); + configs_ConfigCommand.reserve(configsString.size()); + for (auto& i : configsString) + configs_ConfigCommand.emplace_back_unchecked(std::in_place, string_Object{i, nullptr}); + return true; +} + ICommand ConfigCommand{ u8"config", u8".config [load , create , save, delete , list]", {u8"Load, Create, Save, Delete or List Configuration", u8"加载, 创建, 保存, 删除或列出配置", u8"加載, 創建, 保存, 刪除或列出配置", u8"構成の読み込み、 作成、 保存、 削除、 一覧表示"}, {}, { - aliasList_struct{std::in_place, stringview_Object{u8"load", &configs_ConfigCommand}}, - aliasList_struct{std::in_place, stringview_Object{u8"create", nullptr}}, - aliasList_struct{std::in_place, stringview_Object{u8"save", nullptr}}, - aliasList_struct{std::in_place, stringview_Object{u8"delete", &configs_ConfigCommand /*Place and delete by mistake, please enter manually*/}}, - aliasList_struct{std::in_place, stringview_Object{u8"list", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"load", &configs_ConfigCommand, &listCommand_ConfigCommand}}, + aliasList_struct{std::in_place, stringview_Judge{u8"create", nullptr, &listCommand_ConfigCommand}}, + aliasList_struct{std::in_place, stringview_Judge{u8"save", nullptr, &listCommand_ConfigCommand}}, + aliasList_struct{std::in_place, stringview_Judge{u8"delete", &configs_ConfigCommand, &listCommand_ConfigCommand}}, + aliasList_struct{std::in_place, stringview_Judge{u8"list", nullptr, &listCommand_ConfigCommand}}, }, nullptr, &ConfigCommand_onExecute}; diff --git a/China/HeliumClient/Commands/Commands/ConfigCommand.h b/China/HeliumClient/Commands/Commands/ConfigCommand.h index bcd5174..9517079 100644 --- a/China/HeliumClient/Commands/Commands/ConfigCommand.h +++ b/China/HeliumClient/Commands/Commands/ConfigCommand.h @@ -2,6 +2,4 @@ #include "../ICommand.h" -extern fast_io::vector configs_ConfigCommand; -extern void listCommand_ConfigCommand(); extern ICommand ConfigCommand; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/EjectCommand.cpp b/China/HeliumClient/Commands/Commands/EjectCommand.cpp index 0e27cdb..de1b1dd 100644 --- a/China/HeliumClient/Commands/Commands/EjectCommand.cpp +++ b/China/HeliumClient/Commands/Commands/EjectCommand.cpp @@ -23,6 +23,6 @@ ICommand EjectCommand{u8"eject", u8".eject [advance]", {u8"eject Helium from the game.", u8"从游戏中卸载Helium。", u8"從遊戲中卸載Helium。", u8"ゲームから Helium をアンインストールします。"}, {u8"uninject"}, - {{u8"advance", nullptr}}, // If empty must use fast_io::vector{} + {aliasList_struct{std::in_place, stringview_Object{u8"advance", nullptr}}}, // If empty must use fast_io::vector{} nullptr, &EjectCommand_onExecute}; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/FriendCommand.cpp b/China/HeliumClient/Commands/Commands/FriendCommand.cpp index 4352da7..7a08e7c 100644 --- a/China/HeliumClient/Commands/Commands/FriendCommand.cpp +++ b/China/HeliumClient/Commands/Commands/FriendCommand.cpp @@ -194,14 +194,25 @@ bool FriendCommand_onExecute(const fast_io::vector& args) { return true; } +bool listPlayer_FriendCommand(fast_io::vector*) { + Friend_playerList.clear(); + g_Data.forEachEntity([](C_Entity* ent) { + if (ent != g_Data.getLocalPlayer() && ent->isPlayer()) + if (auto name = ent->getNameTag()->getString(); !name.empty()) [[likely]] + Friend_playerList.emplace_back(std::in_place, string_Object{std::u8string{name}, nullptr}); + }); + + return true; +} + ICommand FriendCommand{u8"friend", u8".friend [add/ remove] , list", {u8"Add or remove friendly players", u8"添加或删除友好玩家", u8"添加或刪除友好玩家", u8"味方プレイヤーの追加または削除"}, {}, { - {u8"add", (void*)&Friend_playerList}, - {u8"remove", (void*)&Friend_friendList}, - {u8"list", nullptr}, + aliasList_struct{std::in_place, stringview_Judge{u8"add", &Friend_playerList, &listPlayer_FriendCommand}}, + aliasList_struct{std::in_place, stringview_Judge{u8"remove", &Friend_friendList, &listPlayer_FriendCommand}}, + aliasList_struct{std::in_place, stringview_Judge{u8"list", nullptr, &listPlayer_FriendCommand}}, }, // If empty must use fast_io::vector{} nullptr, &FriendCommand_onExecute}; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp b/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp index f24de80..7fb78cf 100644 --- a/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp +++ b/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp @@ -42,17 +42,17 @@ ICommand SetLanguageCommand{u8"setlanguage", {u8"Set Language", u8"设置语言", u8"設置語言", u8"言語を設定する"}, {}, { - {u8"en_US", nullptr}, - {u8"zh_CN", nullptr}, - {u8"zh_HK", nullptr}, - {u8"zh_SG", nullptr}, - {u8"zh_TW", nullptr}, - {u8"zh_ZA", nullptr}, - {u8"ja_JP", nullptr}, - {u8"0", nullptr}, - {u8"1", nullptr}, - {u8"2", nullptr}, - {u8"3", nullptr}, + aliasList_struct{std::in_place, stringview_Judge{u8"en_US", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"zh_CN", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"zh_HK", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"zh_SG", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"zh_TW", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"zh_ZA", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"ja_JP", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"0", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"1", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"2", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"3", nullptr}}, }, // If empty must use fast_io::vector{} nullptr, &SetLanguageCommand_onExecute}; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/ToggleCommand.cpp b/China/HeliumClient/Commands/Commands/ToggleCommand.cpp index 41a2f25..434e582 100644 --- a/China/HeliumClient/Commands/Commands/ToggleCommand.cpp +++ b/China/HeliumClient/Commands/Commands/ToggleCommand.cpp @@ -5,7 +5,7 @@ void ToggleCommand_onInit(ICommand* toggleCMD) { toggleCMD->aliasList.reserve(ModuleManager::NameTable.size()); for (auto& i : ModuleManager::NameTable) - toggleCMD->aliasList.push_back_unchecked(aliasList_struct{i.first, nullptr}); + toggleCMD->aliasList.emplace_back_unchecked(std::in_place, stringview_Judge{i.first, nullptr}); // NameTable已经初始化完毕,string指针不会变动 } bool ToggleCommand_onExecute(const fast_io::vector& args) { diff --git a/China/HeliumClient/Commands/Commands/TranslateCommand.cpp b/China/HeliumClient/Commands/Commands/TranslateCommand.cpp index 24a16ee..4070829 100644 --- a/China/HeliumClient/Commands/Commands/TranslateCommand.cpp +++ b/China/HeliumClient/Commands/Commands/TranslateCommand.cpp @@ -377,80 +377,80 @@ bool TranslateCommand_onExecute(const fast_io::vector& args) { } fast_io::vector languageto{ - {u8"yue", nullptr}, - {u8"kor", nullptr}, - {u8"th", nullptr}, - {u8"pt", nullptr}, - {u8"el", nullptr}, - {u8"bul", nullptr}, - {u8"fin", nullptr}, - {u8"slo", nullptr}, - {u8"cht", nullptr}, - {u8"zh", nullptr}, - {u8"wyw", nullptr}, - {u8"fra", nullptr}, - {u8"ara", nullptr}, - {u8"de", nullptr}, - {u8"nl", nullptr}, - {u8"est", nullptr}, - {u8"cs", nullptr}, - {u8"swe", nullptr}, - {u8"vie", nullptr}, - {u8"en", nullptr}, - {u8"jp", nullptr}, - {u8"spa", nullptr}, - {u8"ru", nullptr}, - {u8"it", nullptr}, - {u8"pl", nullptr}, - {u8"dan", nullptr}, - {u8"rom", nullptr}, - {u8"hu", nullptr}}; + aliasList_struct{std::in_place, stringview_Judge{u8"yue", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"kor", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"th", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"pt", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"el", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"bul", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"fin", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"slo", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"cht", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"zh", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"wyw", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"fra", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"ara", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"de", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"nl", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"est", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"cs", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"swe", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"vie", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"en", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"jp", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"spa", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"ru", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"it", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"pl", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"dan", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"rom", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"hu", nullptr}}}; fast_io::vector languagefrom{ - {u8"auto", &languageto}, - {u8"yue", &languageto}, - {u8"kor", &languageto}, - {u8"th", &languageto}, - {u8"pt", &languageto}, - {u8"el", &languageto}, - {u8"bul", &languageto}, - {u8"fin", &languageto}, - {u8"slo", &languageto}, - {u8"cht", &languageto}, - {u8"zh", &languageto}, - {u8"wyw", &languageto}, - {u8"fra", &languageto}, - {u8"ara", &languageto}, - {u8"de", &languageto}, - {u8"nl", &languageto}, - {u8"est", &languageto}, - {u8"cs", &languageto}, - {u8"swe", &languageto}, - {u8"vie", &languageto}, - {u8"en", &languageto}, - {u8"jp", &languageto}, - {u8"spa", &languageto}, - {u8"ru", &languageto}, - {u8"it", &languageto}, - {u8"pl", &languageto}, - {u8"dan", &languageto}, - {u8"rom", &languageto}, - {u8"hu", &languageto}}; + aliasList_struct{std::in_place, stringview_Judge{u8"auto", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"yue", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"kor", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"th", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"pt", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"el", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"bul", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"fin", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"slo", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"cht", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"zh", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"wyw", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"fra", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"ara", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"de", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"nl", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"est", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"cs", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"swe", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"vie", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"en", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"jp", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"spa", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"ru", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"it", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"pl", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"dan", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"rom", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"hu", nullptr}}}; fast_io::vector com{ - {u8"appid", nullptr}, - {u8"key", nullptr}, - {u8"local", &languagefrom}, - {u8"server", &languagefrom}}; + aliasList_struct{std::in_place, stringview_Judge{u8"appid", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"key", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"local", &languagefrom}}, + aliasList_struct{std::in_place, stringview_Judge{u8"server", &languagefrom}}}; ICommand TranslateCommand{ u8"translate", u8".translate or .transl [set [[loacl, server] , appid , key ], send , display ]", {u8"Translate with Baidu Translator", u8"使用百度翻译器翻译", u8"使用百度翻譯器翻譯", u8"Baidu Translator で翻訳する"}, {u8"transl"}, - {{u8"set", &com}, - {u8"send", nullptr}, - {u8"display", nullptr}}, // If empty must use fast_io::vector{} + {aliasList_struct{std::in_place, stringview_Judge{u8"set", &com}}, + aliasList_struct{std::in_place, stringview_Judge{u8"send", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"display", nullptr}}}, // If empty must use fast_io::vector{} nullptr, &TranslateCommand_onExecute}; diff --git a/China/HeliumClient/Commands/ICommand.h b/China/HeliumClient/Commands/ICommand.h index 2f1ba3a..494da26 100644 --- a/China/HeliumClient/Commands/ICommand.h +++ b/China/HeliumClient/Commands/ICommand.h @@ -209,7 +209,7 @@ struct Empty_Judge { }; inline constexpr fast_io::vector* next_objects(Empty_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { - if (cmdlist == nullptr) [[unlikely]] + if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; if (order >= cmdlist->size()) [[unlikely]] @@ -228,7 +228,7 @@ struct stringview_Judge { }; inline constexpr fast_io::vector* next_objects(stringview_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { - if (cmdlist == nullptr) [[unlikely]] + if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; if (order >= cmdlist->size()) [[unlikely]] @@ -250,7 +250,7 @@ struct string_Judge { }; inline constexpr fast_io::vector* next_objects(string_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { - if (cmdlist == nullptr) [[unlikely]] + if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; if (order >= cmdlist->size()) [[unlikely]] @@ -275,7 +275,7 @@ struct integral_Judge { // or equal to template inline constexpr fast_io::vector* next_objects(integral_Judge<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { - if (cmdlist == nullptr) [[unlikely]] + if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; if (order >= cmdlist->size()) [[unlikely]] @@ -309,7 +309,7 @@ struct floating_point_Judge { // or equal to template inline constexpr fast_io::vector* next_objects(floating_point_Judge<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { - if (cmdlist == nullptr) [[unlikely]] + if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; if (order >= cmdlist->size()) [[unlikely]] -- Gitee From 38c7b714bd79ac83ca76d4a537695966d5f94129 Mon Sep 17 00:00:00 2001 From: MacroModel Date: Tue, 11 Apr 2023 23:51:58 +0800 Subject: [PATCH 4/8] ememmmmm --- .../Commands/Commands/ConfigCommand.cpp | 2 +- .../Commands/Commands/EjectCommand.cpp | 2 +- .../Commands/Commands/FriendCommand.cpp | 2 +- .../Commands/Commands/SetLanguageCommand.cpp | 2 +- .../Commands/Commands/TranslateCommand.cpp | 6 +- China/HeliumClient/Commands/ICommand.h | 119 +++++++++++++----- China/Memory/Hook.cpp | 56 ++------- 7 files changed, 106 insertions(+), 83 deletions(-) diff --git a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp index d87a7ce..5b8edd4 100644 --- a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp +++ b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp @@ -504,7 +504,7 @@ ICommand ConfigCommand{ u8".config [load , create , save, delete , list]", {u8"Load, Create, Save, Delete or List Configuration", u8"加载, 创建, 保存, 删除或列出配置", u8"加載, 創建, 保存, 刪除或列出配置", u8"構成の読み込み、 作成、 保存、 削除、 一覧表示"}, {}, - { + fast_io::vector{ aliasList_struct{std::in_place, stringview_Judge{u8"load", &configs_ConfigCommand, &listCommand_ConfigCommand}}, aliasList_struct{std::in_place, stringview_Judge{u8"create", nullptr, &listCommand_ConfigCommand}}, aliasList_struct{std::in_place, stringview_Judge{u8"save", nullptr, &listCommand_ConfigCommand}}, diff --git a/China/HeliumClient/Commands/Commands/EjectCommand.cpp b/China/HeliumClient/Commands/Commands/EjectCommand.cpp index de1b1dd..72195df 100644 --- a/China/HeliumClient/Commands/Commands/EjectCommand.cpp +++ b/China/HeliumClient/Commands/Commands/EjectCommand.cpp @@ -23,6 +23,6 @@ ICommand EjectCommand{u8"eject", u8".eject [advance]", {u8"eject Helium from the game.", u8"从游戏中卸载Helium。", u8"從遊戲中卸載Helium。", u8"ゲームから Helium をアンインストールします。"}, {u8"uninject"}, - {aliasList_struct{std::in_place, stringview_Object{u8"advance", nullptr}}}, // If empty must use fast_io::vector{} + fast_io::vector{aliasList_struct{std::in_place, stringview_Object{u8"advance", nullptr}}}, // If empty must use fast_io::vector{} nullptr, &EjectCommand_onExecute}; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/FriendCommand.cpp b/China/HeliumClient/Commands/Commands/FriendCommand.cpp index 7a08e7c..f948275 100644 --- a/China/HeliumClient/Commands/Commands/FriendCommand.cpp +++ b/China/HeliumClient/Commands/Commands/FriendCommand.cpp @@ -209,7 +209,7 @@ ICommand FriendCommand{u8"friend", u8".friend [add/ remove] , list", {u8"Add or remove friendly players", u8"添加或删除友好玩家", u8"添加或刪除友好玩家", u8"味方プレイヤーの追加または削除"}, {}, - { + fast_io::vector{ aliasList_struct{std::in_place, stringview_Judge{u8"add", &Friend_playerList, &listPlayer_FriendCommand}}, aliasList_struct{std::in_place, stringview_Judge{u8"remove", &Friend_friendList, &listPlayer_FriendCommand}}, aliasList_struct{std::in_place, stringview_Judge{u8"list", nullptr, &listPlayer_FriendCommand}}, diff --git a/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp b/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp index 7fb78cf..e427b7f 100644 --- a/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp +++ b/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp @@ -41,7 +41,7 @@ ICommand SetLanguageCommand{u8"setlanguage", u8".setlanguage [, ]", {u8"Set Language", u8"设置语言", u8"設置語言", u8"言語を設定する"}, {}, - { + fast_io::vector{ aliasList_struct{std::in_place, stringview_Judge{u8"en_US", nullptr}}, aliasList_struct{std::in_place, stringview_Judge{u8"zh_CN", nullptr}}, aliasList_struct{std::in_place, stringview_Judge{u8"zh_HK", nullptr}}, diff --git a/China/HeliumClient/Commands/Commands/TranslateCommand.cpp b/China/HeliumClient/Commands/Commands/TranslateCommand.cpp index 4070829..400fead 100644 --- a/China/HeliumClient/Commands/Commands/TranslateCommand.cpp +++ b/China/HeliumClient/Commands/Commands/TranslateCommand.cpp @@ -448,9 +448,9 @@ ICommand TranslateCommand{ u8".translate or .transl [set [[loacl, server] , appid , key ], send , display ]", {u8"Translate with Baidu Translator", u8"使用百度翻译器翻译", u8"使用百度翻譯器翻譯", u8"Baidu Translator で翻訳する"}, {u8"transl"}, - {aliasList_struct{std::in_place, stringview_Judge{u8"set", &com}}, - aliasList_struct{std::in_place, stringview_Judge{u8"send", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"display", nullptr}}}, // If empty must use fast_io::vector{} + fast_io::vector{aliasList_struct{std::in_place, stringview_Judge{u8"set", &com}}, + aliasList_struct{std::in_place, stringview_Judge{u8"send", nullptr}}, + aliasList_struct{std::in_place, stringview_Judge{u8"display", nullptr}}}, // If empty must use fast_io::vector{} nullptr, &TranslateCommand_onExecute}; diff --git a/China/HeliumClient/Commands/ICommand.h b/China/HeliumClient/Commands/ICommand.h index 494da26..5b05f14 100644 --- a/China/HeliumClient/Commands/ICommand.h +++ b/China/HeliumClient/Commands/ICommand.h @@ -17,11 +17,13 @@ namespace details { template concept has_next_objects = requires(T a) { next_objects(a, nullptr, 0); + next_complete(a); }; struct auto_completion_base_impl { virtual constexpr ~auto_completion_base_impl() = default; - virtual constexpr fast_io::vector* next_objects_impl(fast_io::vector* cmdlist, size_t order) const noexcept = 0; + virtual constexpr void* next_objects_impl(fast_io::vector* cmdlist, size_t order) const noexcept = 0; + virtual constexpr std::u8string_view next_complete_impl() const noexcept = 0; virtual constexpr auto_completion_base_impl* clone() const = 0; }; @@ -29,9 +31,12 @@ template struct auto_completion_derv_impl : auto_completion_base_impl { T t; auto_completion_derv_impl(std::in_place_t, T&& tt) : t{std::forward(tt)} {} - virtual constexpr fast_io::vector* next_objects_impl(fast_io::vector* cmdlist, size_t order) const noexcept override { + virtual constexpr void* next_objects_impl(fast_io::vector* cmdlist, size_t order) const noexcept override { return next_objects(t, cmdlist, order); } + virtual constexpr std::u8string_view next_complete_impl() const noexcept override{ + return next_complete(t); + } virtual constexpr auto_completion_base_impl* clone() const override { return new auto_completion_derv_impl(*this); } @@ -44,7 +49,7 @@ public: ::details::auto_completion_base_impl* ptr{}; constexpr aliasList_struct() noexcept = default; template - explicit constexpr aliasList_struct(std::in_place_t, T&& tt) noexcept : ptr{new ::details::shape_derv_impl(std::in_place, std::forward(tt))} { + explicit constexpr aliasList_struct(std::in_place_t, T&& tt) noexcept : ptr{new ::details::auto_completion_derv_impl(std::in_place, std::forward(tt))} { } constexpr aliasList_struct(aliasList_struct const& other) : ptr{other.ptr->clone()} {} constexpr aliasList_struct& operator=(aliasList_struct const& other) { @@ -67,15 +72,19 @@ public: } }; -inline constexpr fast_io::vector* next_objects(aliasList_struct const& p, fast_io::vector* cmdlist, size_t order) noexcept { +inline constexpr void* next_objects(aliasList_struct const& p, fast_io::vector* cmdlist, size_t order) noexcept { return p.ptr->next_objects_impl(cmdlist, order); } +inline constexpr std::u8string_view next_complete(aliasList_struct const& p) noexcept { + return p.ptr->next_complete_impl(); +} + struct Empty_Object { fast_io::vector* next{}; }; -inline constexpr fast_io::vector* next_objects(Empty_Object p, fast_io::vector* cmdlist, size_t order) noexcept { +inline constexpr void* next_objects(Empty_Object p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr) [[unlikely]] return nullptr; @@ -85,12 +94,16 @@ inline constexpr fast_io::vector* next_objects(Empty_Object p, return p.next; } +inline constexpr std::u8string_view next_complete(Empty_Object p) noexcept { + return std::u8string_view{}; +} + struct stringview_Object { std::u8string_view str{}; fast_io::vector* next{}; }; -inline constexpr fast_io::vector* next_objects(stringview_Object p, fast_io::vector* cmdlist, size_t order) noexcept { +inline constexpr void* next_objects(stringview_Object p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr) [[unlikely]] return nullptr; @@ -103,12 +116,16 @@ inline constexpr fast_io::vector* next_objects(stringview_Obje return nullptr; } +inline constexpr std::u8string_view next_complete(stringview_Object p) noexcept { + return p.str; +} + struct string_Object { std::u8string str{}; fast_io::vector* next{}; }; -inline constexpr fast_io::vector* next_objects(stringview_Object p, fast_io::vector* cmdlist, size_t order) noexcept { +inline constexpr void* next_objects(string_Object p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr) [[unlikely]] return nullptr; @@ -121,15 +138,19 @@ inline constexpr fast_io::vector* next_objects(stringview_Obje return nullptr; } -template -struct integral_Object { // or equal to +inline constexpr std::u8string_view next_complete(string_Object p) noexcept { + return p.str; +} + +template +struct integral_Object { // or equal to _Ty min{}; _Ty max{}; fast_io::vector* next{}; }; -template -inline constexpr fast_io::vector* next_objects(integral_Object<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { +template +inline constexpr void* next_objects(integral_Object<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr) [[unlikely]] return nullptr; @@ -144,12 +165,17 @@ inline constexpr fast_io::vector* next_objects(integral_Object } if (num >= p.min && num <= p.max) - return next; + return p.next; else return nullptr; } -template +template +inline constexpr std::u8string_view next_complete(integral_Object<_Ty> p) noexcept { + return fast_io::u8concat(p); +} + +template struct floating_point_Object { // or equal to _Ty min{}; bool equaltomin{}; @@ -158,8 +184,8 @@ struct floating_point_Object { // or equal to fast_io::vector* next{}; }; -template -inline constexpr fast_io::vector* next_objects(floating_point_Object<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { +template +inline constexpr void* next_objects(floating_point_Object<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr) [[unlikely]] return nullptr; @@ -171,13 +197,13 @@ inline constexpr fast_io::vector* next_objects(floating_point_ _Ty num{}; try { if constexpr (std::is_same_v<_Ty, float>) { - num = std::stof(*reinterpret_cast(&str)); + num = std::stof(*reinterpret_cast(&str)); } else if constexpr (std::is_same_v<_Ty, double>) { - num = std::stod(*reinterpret_cast(&str)); + num = std::stod(*reinterpret_cast(&str)); } else if constexpr (std::is_same_v<_Ty, long double>) { - num = std::stold(*reinterpret_cast(&str)); + num = std::stold(*reinterpret_cast(&str)); } else { - static_cast(false, "floating_point must be float, double, long double"); + fast_io::fast_terminate(); } } catch (const std::exception&) { return nullptr; @@ -199,7 +225,12 @@ inline constexpr fast_io::vector* next_objects(floating_point_ return nullptr; } - return next; + return p.next; +} + +template +inline constexpr std::u8string_view next_complete(floating_point_Object<_Ty> p) noexcept { + return fast_io::u8concat(p); } // Judge @@ -208,7 +239,7 @@ struct Empty_Judge { bool (*judge)(fast_io::vector* cmdlist){}; }; -inline constexpr fast_io::vector* next_objects(Empty_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { +inline constexpr void* next_objects(Empty_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; @@ -221,13 +252,17 @@ inline constexpr fast_io::vector* next_objects(Empty_Judge p, return nullptr; } +inline constexpr std::u8string_view next_complete(Empty_Judge p) noexcept { + return std::u8string_view{}; +} + struct stringview_Judge { std::u8string_view str{}; fast_io::vector* next{}; bool (*judge)(fast_io::vector* cmdlist){}; }; -inline constexpr fast_io::vector* next_objects(stringview_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { +inline constexpr void* next_objects(stringview_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; @@ -243,13 +278,17 @@ inline constexpr fast_io::vector* next_objects(stringview_Judg return nullptr; } +inline constexpr std::u8string_view next_complete(stringview_Judge p) noexcept { + return p.str; +} + struct string_Judge { std::u8string str{}; fast_io::vector* next{}; bool (*judge)(fast_io::vector* cmdlist){}; }; -inline constexpr fast_io::vector* next_objects(string_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { +inline constexpr void* next_objects(string_Judge p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; @@ -265,7 +304,11 @@ inline constexpr fast_io::vector* next_objects(string_Judge p, return nullptr; } -template +inline constexpr std::u8string_view next_complete(string_Judge p) noexcept { + return p.str; +} + +template struct integral_Judge { // or equal to _Ty min{}; _Ty max{}; @@ -273,8 +316,8 @@ struct integral_Judge { // or equal to bool (*judge)(fast_io::vector* cmdlist){}; }; -template -inline constexpr fast_io::vector* next_objects(integral_Judge<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { +template +inline constexpr void* next_objects(integral_Judge<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; @@ -297,7 +340,12 @@ inline constexpr fast_io::vector* next_objects(integral_Judge< return nullptr; } -template +template +inline constexpr std::u8string_view next_complete(integral_Judge<_Ty> p) noexcept { + return fast_io::concat(p); +} + +template struct floating_point_Judge { // or equal to _Ty min{}; bool equaltomin{}; @@ -307,8 +355,8 @@ struct floating_point_Judge { // or equal to bool (*judge)(fast_io::vector* cmdlist){}; }; -template -inline constexpr fast_io::vector* next_objects(floating_point_Judge<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { +template +inline constexpr void* next_objects(floating_point_Judge<_Ty> p, fast_io::vector* cmdlist, size_t order) noexcept { if (cmdlist == nullptr || p.judge == nullptr) [[unlikely]] return nullptr; @@ -320,13 +368,13 @@ inline constexpr fast_io::vector* next_objects(floating_point_ _Ty num{}; try { if constexpr (std::is_same_v<_Ty, float>) { - num = std::stof(*reinterpret_cast(&str)); + num = std::stof(*reinterpret_cast(&str)); } else if constexpr (std::is_same_v<_Ty, double>) { - num = std::stod(*reinterpret_cast(&str)); + num = std::stod(*reinterpret_cast(&str)); } else if constexpr (std::is_same_v<_Ty, long double>) { - num = std::stold(*reinterpret_cast(&str)); + num = std::stold(*reinterpret_cast(&str)); } else { - static_cast(false, "floating_point must be float, double, long double"); + fast_io::fast_terminate(); } } catch (const std::exception&) { return nullptr; @@ -354,6 +402,11 @@ inline constexpr fast_io::vector* next_objects(floating_point_ return nullptr; } +template +inline constexpr std::u8string_view next_complete(std::is_floating_point<_Ty> p) noexcept { + return fast_io::concat(p); +} + // i command class ICommand { public: diff --git a/China/Memory/Hook.cpp b/China/Memory/Hook.cpp index a98e5c0..6f2f696 100644 --- a/China/Memory/Hook.cpp +++ b/China/Memory/Hook.cpp @@ -766,26 +766,11 @@ void Hooks::PleaseAutoComplete(__int64 _this, __int64 a2, TextHolder* text, int for (size_t j = 1; j < cmdlist.size(); j++) { for (size_t i = 0; i < next->size(); i++) { - if (cmdlist[j] == next->operator[](i).name) { - next = reinterpret_cast*>(next->operator[](i).next); - if (next == nullptr) { - concat.clear(); - return oFunc(_this, a2, text, a4); - } else if (next == &configs_ConfigCommand) { // config command !!! - listCommand_ConfigCommand(); - } else if (next == &Friend_friendList) { - Friend_friendList.clear(); - Friend_friendList.reserve(FriendList.size()); - for (auto &i : FriendList) - Friend_friendList.push_back_unchecked(aliasList_struct{i, nullptr}); - } else if (next == &Friend_playerList) { - Friend_playerList.clear(); - g_Data.forEachEntity([](C_Entity* ent) { - if (ent != g_Data.getLocalPlayer() && ent->isPlayer()) - if (auto name = ent->getNameTag()->getString(); !name.empty()) [[likely]] - Friend_playerList.push_back(aliasList_struct{name, nullptr}); - }); - } + next = reinterpret_cast*>(next_objects(next->operator[](i), &cmdlist, j)); + if (next == nullptr) { + concat.clear(); + return oFunc(_this, a2, text, a4); + } else { concat.append(fast_io::u8concat(cmdlist[j], fast_io::mnp::chvw(u8' '))); break; } @@ -800,8 +785,8 @@ void Hooks::PleaseAutoComplete(__int64 _this, __int64 a2, TextHolder* text, int completeList.reserve(next->size()); for (auto& al : *next) { - C_GuiData::displayClientMessageC(fast_io::mnp::chvw(CommandMgr::prefix), Utils::TextColor::DARK_GRAY, cmd->first, fast_io::mnp::chvw(u8' '), concat, Utils::TextColor::GRAY, al.name); - completeList.emplace_back_unchecked(std::u8string{al.name}, 0, 0ui8); + C_GuiData::displayClientMessageC(fast_io::mnp::chvw(CommandMgr::prefix), Utils::TextColor::DARK_GRAY, cmd->first, fast_io::mnp::chvw(u8' '), concat, Utils::TextColor::GRAY, next_complete(al)); + completeList.emplace_back_unchecked(std::u8string{next_complete(al)}, 0, 0ui8); } std::u8string complete = fast_io::u8concat(fast_io::mnp::chvw(CommandMgr::prefix), cmd->first, fast_io::mnp::chvw(u8' '), concat, completeList.front().cmd); setTextAndReturn(complete); @@ -883,26 +868,11 @@ void Hooks::PleaseAutoComplete(__int64 _this, __int64 a2, TextHolder* text, int for (size_t j = 1; j < cmdlist.size(); j++) { if (j != cmdlist.size() - 1) { for (size_t i = 0; i < next->size(); i++) { - if (cmdlist[j] == next->operator[](i).name) { - next = reinterpret_cast*>(next->operator[](i).next); - if (next == nullptr) { - concat.clear(); - return oFunc(_this, a2, text, a4); - } else if (next == &configs_ConfigCommand) { // config command !!! - listCommand_ConfigCommand(); - } else if (next == &Friend_friendList) { - Friend_friendList.clear(); - Friend_friendList.reserve(FriendList.size()); - for (auto& i : FriendList) - Friend_friendList.push_back_unchecked(aliasList_struct{i, nullptr}); - } else if (next == &Friend_playerList) { - Friend_playerList.clear(); - g_Data.forEachEntity([](C_Entity* ent) { - if (ent != g_Data.getLocalPlayer() && ent->isPlayer()) - if (auto name = ent->getNameTag()->getString(); !name.empty()) [[likely]] - Friend_playerList.push_back(aliasList_struct{name, nullptr}); - }); - } + next = reinterpret_cast*>(next_objects(next->operator[](i), &cmdlist, j)); + if (next == nullptr) { + concat.clear(); + return oFunc(_this, a2, text, a4); + } else { concat.append(fast_io::u8concat(cmdlist[j], fast_io::mnp::chvw(u8' '))); break; } @@ -913,7 +883,7 @@ void Hooks::PleaseAutoComplete(__int64 _this, __int64 a2, TextHolder* text, int } } else { for (auto& i : *next) { - auto res = Analyze(cmdlist[j], i.name); + auto res = Analyze(cmdlist[j], next_complete(i)); if (res.type != 4) { completeList.emplace_back(std::move(res)); } -- Gitee From 3600a40540848e2b7ad84687998f95c86a834629 Mon Sep 17 00:00:00 2001 From: MacroModel Date: Wed, 12 Apr 2023 22:49:56 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=96=B0=E8=87=AA=E5=8A=A8=E8=A1=A5?= =?UTF-8?q?=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/Commands/BindCommand.cpp | 2 +- .../Commands/Commands/ConfigCommand.cpp | 12 +- .../Commands/Commands/EjectCommand.cpp | 2 +- .../Commands/Commands/FriendCommand.cpp | 8 +- .../Commands/Commands/SetLanguageCommand.cpp | 22 +-- .../Commands/Commands/ToggleCommand.cpp | 2 +- .../Commands/Commands/TranslateCommand.cpp | 128 +++++++++--------- China/HeliumClient/Commands/ICommand.h | 38 +++--- China/Memory/Hook.cpp | 2 +- .../fast_io/fast_io_dsal/impl/vector.h | 2 +- 10 files changed, 109 insertions(+), 109 deletions(-) diff --git a/China/HeliumClient/Commands/Commands/BindCommand.cpp b/China/HeliumClient/Commands/Commands/BindCommand.cpp index e253d8d..08b0b91 100644 --- a/China/HeliumClient/Commands/Commands/BindCommand.cpp +++ b/China/HeliumClient/Commands/Commands/BindCommand.cpp @@ -5,7 +5,7 @@ void BindCommand_onInit(ICommand* _this) { _this->aliasList.reserve(ModuleManager::NameTable.size()); for (auto& i : ModuleManager::NameTable) - _this->aliasList.emplace_back_unchecked(std::in_place, stringview_Object{std::u8string_view{i.first}, nullptr}); + _this->aliasList.emplace_back_unchecked(stringview_Object{std::u8string_view{i.first}, nullptr}); } diff --git a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp index 5b8edd4..1fc1d66 100644 --- a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp +++ b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp @@ -495,7 +495,7 @@ bool listCommand_ConfigCommand(fast_io::vector*) { configs_ConfigCommand.clear(); configs_ConfigCommand.reserve(configsString.size()); for (auto& i : configsString) - configs_ConfigCommand.emplace_back_unchecked(std::in_place, string_Object{i, nullptr}); + configs_ConfigCommand.emplace_back_unchecked(string_Object{i, nullptr}); return true; } @@ -505,11 +505,11 @@ ICommand ConfigCommand{ {u8"Load, Create, Save, Delete or List Configuration", u8"加载, 创建, 保存, 删除或列出配置", u8"加載, 創建, 保存, 刪除或列出配置", u8"構成の読み込み、 作成、 保存、 削除、 一覧表示"}, {}, fast_io::vector{ - aliasList_struct{std::in_place, stringview_Judge{u8"load", &configs_ConfigCommand, &listCommand_ConfigCommand}}, - aliasList_struct{std::in_place, stringview_Judge{u8"create", nullptr, &listCommand_ConfigCommand}}, - aliasList_struct{std::in_place, stringview_Judge{u8"save", nullptr, &listCommand_ConfigCommand}}, - aliasList_struct{std::in_place, stringview_Judge{u8"delete", &configs_ConfigCommand, &listCommand_ConfigCommand}}, - aliasList_struct{std::in_place, stringview_Judge{u8"list", nullptr, &listCommand_ConfigCommand}}, + aliasList_struct{stringview_Judge{u8"load", &configs_ConfigCommand, &listCommand_ConfigCommand}}, + aliasList_struct{stringview_Judge{u8"create", nullptr, &listCommand_ConfigCommand}}, + aliasList_struct{stringview_Judge{u8"save", nullptr, &listCommand_ConfigCommand}}, + aliasList_struct{stringview_Judge{u8"delete", &configs_ConfigCommand, &listCommand_ConfigCommand}}, + aliasList_struct{stringview_Judge{u8"list", nullptr, &listCommand_ConfigCommand}}, }, nullptr, &ConfigCommand_onExecute}; diff --git a/China/HeliumClient/Commands/Commands/EjectCommand.cpp b/China/HeliumClient/Commands/Commands/EjectCommand.cpp index 72195df..33ef221 100644 --- a/China/HeliumClient/Commands/Commands/EjectCommand.cpp +++ b/China/HeliumClient/Commands/Commands/EjectCommand.cpp @@ -23,6 +23,6 @@ ICommand EjectCommand{u8"eject", u8".eject [advance]", {u8"eject Helium from the game.", u8"从游戏中卸载Helium。", u8"從遊戲中卸載Helium。", u8"ゲームから Helium をアンインストールします。"}, {u8"uninject"}, - fast_io::vector{aliasList_struct{std::in_place, stringview_Object{u8"advance", nullptr}}}, // If empty must use fast_io::vector{} + fast_io::vector{aliasList_struct{stringview_Object{u8"advance", nullptr}}}, // If empty must use fast_io::vector{} nullptr, &EjectCommand_onExecute}; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/FriendCommand.cpp b/China/HeliumClient/Commands/Commands/FriendCommand.cpp index f948275..a87d3e3 100644 --- a/China/HeliumClient/Commands/Commands/FriendCommand.cpp +++ b/China/HeliumClient/Commands/Commands/FriendCommand.cpp @@ -199,7 +199,7 @@ bool listPlayer_FriendCommand(fast_io::vector*) { g_Data.forEachEntity([](C_Entity* ent) { if (ent != g_Data.getLocalPlayer() && ent->isPlayer()) if (auto name = ent->getNameTag()->getString(); !name.empty()) [[likely]] - Friend_playerList.emplace_back(std::in_place, string_Object{std::u8string{name}, nullptr}); + Friend_playerList.emplace_back(string_Object{std::u8string{name}, nullptr}); }); return true; @@ -210,9 +210,9 @@ ICommand FriendCommand{u8"friend", {u8"Add or remove friendly players", u8"添加或删除友好玩家", u8"添加或刪除友好玩家", u8"味方プレイヤーの追加または削除"}, {}, fast_io::vector{ - aliasList_struct{std::in_place, stringview_Judge{u8"add", &Friend_playerList, &listPlayer_FriendCommand}}, - aliasList_struct{std::in_place, stringview_Judge{u8"remove", &Friend_friendList, &listPlayer_FriendCommand}}, - aliasList_struct{std::in_place, stringview_Judge{u8"list", nullptr, &listPlayer_FriendCommand}}, + aliasList_struct{stringview_Judge{u8"add", &Friend_playerList, &listPlayer_FriendCommand}}, + aliasList_struct{stringview_Judge{u8"remove", &Friend_friendList, &listPlayer_FriendCommand}}, + aliasList_struct{stringview_Judge{u8"list", nullptr, &listPlayer_FriendCommand}}, }, // If empty must use fast_io::vector{} nullptr, &FriendCommand_onExecute}; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp b/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp index e427b7f..04657db 100644 --- a/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp +++ b/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp @@ -42,17 +42,17 @@ ICommand SetLanguageCommand{u8"setlanguage", {u8"Set Language", u8"设置语言", u8"設置語言", u8"言語を設定する"}, {}, fast_io::vector{ - aliasList_struct{std::in_place, stringview_Judge{u8"en_US", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"zh_CN", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"zh_HK", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"zh_SG", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"zh_TW", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"zh_ZA", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"ja_JP", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"0", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"1", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"2", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"3", nullptr}}, + aliasList_struct{stringview_Judge{u8"en_US", nullptr}}, + aliasList_struct{stringview_Judge{u8"zh_CN", nullptr}}, + aliasList_struct{stringview_Judge{u8"zh_HK", nullptr}}, + aliasList_struct{stringview_Judge{u8"zh_SG", nullptr}}, + aliasList_struct{stringview_Judge{u8"zh_TW", nullptr}}, + aliasList_struct{stringview_Judge{u8"zh_ZA", nullptr}}, + aliasList_struct{stringview_Judge{u8"ja_JP", nullptr}}, + aliasList_struct{stringview_Judge{u8"0", nullptr}}, + aliasList_struct{stringview_Judge{u8"1", nullptr}}, + aliasList_struct{stringview_Judge{u8"2", nullptr}}, + aliasList_struct{stringview_Judge{u8"3", nullptr}}, }, // If empty must use fast_io::vector{} nullptr, &SetLanguageCommand_onExecute}; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/ToggleCommand.cpp b/China/HeliumClient/Commands/Commands/ToggleCommand.cpp index 434e582..e4a75ec 100644 --- a/China/HeliumClient/Commands/Commands/ToggleCommand.cpp +++ b/China/HeliumClient/Commands/Commands/ToggleCommand.cpp @@ -5,7 +5,7 @@ void ToggleCommand_onInit(ICommand* toggleCMD) { toggleCMD->aliasList.reserve(ModuleManager::NameTable.size()); for (auto& i : ModuleManager::NameTable) - toggleCMD->aliasList.emplace_back_unchecked(std::in_place, stringview_Judge{i.first, nullptr}); // NameTable已经初始化完毕,string指针不会变动 + toggleCMD->aliasList.emplace_back_unchecked(stringview_Judge{i.first, nullptr}); // NameTable已经初始化完毕,string指针不会变动 } bool ToggleCommand_onExecute(const fast_io::vector& args) { diff --git a/China/HeliumClient/Commands/Commands/TranslateCommand.cpp b/China/HeliumClient/Commands/Commands/TranslateCommand.cpp index 400fead..895f205 100644 --- a/China/HeliumClient/Commands/Commands/TranslateCommand.cpp +++ b/China/HeliumClient/Commands/Commands/TranslateCommand.cpp @@ -377,80 +377,80 @@ bool TranslateCommand_onExecute(const fast_io::vector& args) { } fast_io::vector languageto{ - aliasList_struct{std::in_place, stringview_Judge{u8"yue", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"kor", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"th", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"pt", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"el", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"bul", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"fin", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"slo", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"cht", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"zh", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"wyw", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"fra", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"ara", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"de", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"nl", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"est", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"cs", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"swe", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"vie", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"en", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"jp", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"spa", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"ru", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"it", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"pl", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"dan", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"rom", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"hu", nullptr}}}; + aliasList_struct{stringview_Judge{u8"yue", nullptr}}, + aliasList_struct{stringview_Judge{u8"kor", nullptr}}, + aliasList_struct{stringview_Judge{u8"th", nullptr}}, + aliasList_struct{stringview_Judge{u8"pt", nullptr}}, + aliasList_struct{stringview_Judge{u8"el", nullptr}}, + aliasList_struct{stringview_Judge{u8"bul", nullptr}}, + aliasList_struct{stringview_Judge{u8"fin", nullptr}}, + aliasList_struct{stringview_Judge{u8"slo", nullptr}}, + aliasList_struct{stringview_Judge{u8"cht", nullptr}}, + aliasList_struct{stringview_Judge{u8"zh", nullptr}}, + aliasList_struct{stringview_Judge{u8"wyw", nullptr}}, + aliasList_struct{stringview_Judge{u8"fra", nullptr}}, + aliasList_struct{stringview_Judge{u8"ara", nullptr}}, + aliasList_struct{stringview_Judge{u8"de", nullptr}}, + aliasList_struct{stringview_Judge{u8"nl", nullptr}}, + aliasList_struct{stringview_Judge{u8"est", nullptr}}, + aliasList_struct{stringview_Judge{u8"cs", nullptr}}, + aliasList_struct{stringview_Judge{u8"swe", nullptr}}, + aliasList_struct{stringview_Judge{u8"vie", nullptr}}, + aliasList_struct{stringview_Judge{u8"en", nullptr}}, + aliasList_struct{stringview_Judge{u8"jp", nullptr}}, + aliasList_struct{stringview_Judge{u8"spa", nullptr}}, + aliasList_struct{stringview_Judge{u8"ru", nullptr}}, + aliasList_struct{stringview_Judge{u8"it", nullptr}}, + aliasList_struct{stringview_Judge{u8"pl", nullptr}}, + aliasList_struct{stringview_Judge{u8"dan", nullptr}}, + aliasList_struct{stringview_Judge{u8"rom", nullptr}}, + aliasList_struct{stringview_Judge{u8"hu", nullptr}}}; fast_io::vector languagefrom{ - aliasList_struct{std::in_place, stringview_Judge{u8"auto", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"yue", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"kor", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"th", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"pt", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"el", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"bul", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"fin", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"slo", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"cht", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"zh", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"wyw", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"fra", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"ara", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"de", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"nl", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"est", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"cs", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"swe", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"vie", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"en", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"jp", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"spa", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"ru", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"it", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"pl", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"dan", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"rom", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"hu", nullptr}}}; + aliasList_struct{stringview_Judge{u8"auto", nullptr}}, + aliasList_struct{stringview_Judge{u8"yue", nullptr}}, + aliasList_struct{stringview_Judge{u8"kor", nullptr}}, + aliasList_struct{stringview_Judge{u8"th", nullptr}}, + aliasList_struct{stringview_Judge{u8"pt", nullptr}}, + aliasList_struct{stringview_Judge{u8"el", nullptr}}, + aliasList_struct{stringview_Judge{u8"bul", nullptr}}, + aliasList_struct{stringview_Judge{u8"fin", nullptr}}, + aliasList_struct{stringview_Judge{u8"slo", nullptr}}, + aliasList_struct{stringview_Judge{u8"cht", nullptr}}, + aliasList_struct{stringview_Judge{u8"zh", nullptr}}, + aliasList_struct{stringview_Judge{u8"wyw", nullptr}}, + aliasList_struct{stringview_Judge{u8"fra", nullptr}}, + aliasList_struct{stringview_Judge{u8"ara", nullptr}}, + aliasList_struct{stringview_Judge{u8"de", nullptr}}, + aliasList_struct{stringview_Judge{u8"nl", nullptr}}, + aliasList_struct{stringview_Judge{u8"est", nullptr}}, + aliasList_struct{stringview_Judge{u8"cs", nullptr}}, + aliasList_struct{stringview_Judge{u8"swe", nullptr}}, + aliasList_struct{stringview_Judge{u8"vie", nullptr}}, + aliasList_struct{stringview_Judge{u8"en", nullptr}}, + aliasList_struct{stringview_Judge{u8"jp", nullptr}}, + aliasList_struct{stringview_Judge{u8"spa", nullptr}}, + aliasList_struct{stringview_Judge{u8"ru", nullptr}}, + aliasList_struct{stringview_Judge{u8"it", nullptr}}, + aliasList_struct{stringview_Judge{u8"pl", nullptr}}, + aliasList_struct{stringview_Judge{u8"dan", nullptr}}, + aliasList_struct{stringview_Judge{u8"rom", nullptr}}, + aliasList_struct{stringview_Judge{u8"hu", nullptr}}}; fast_io::vector com{ - aliasList_struct{std::in_place, stringview_Judge{u8"appid", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"key", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"local", &languagefrom}}, - aliasList_struct{std::in_place, stringview_Judge{u8"server", &languagefrom}}}; + aliasList_struct{stringview_Judge{u8"appid", nullptr}}, + aliasList_struct{stringview_Judge{u8"key", nullptr}}, + aliasList_struct{stringview_Judge{u8"local", &languagefrom}}, + aliasList_struct{stringview_Judge{u8"server", &languagefrom}}}; ICommand TranslateCommand{ u8"translate", u8".translate or .transl [set [[loacl, server] , appid , key ], send , display ]", {u8"Translate with Baidu Translator", u8"使用百度翻译器翻译", u8"使用百度翻譯器翻譯", u8"Baidu Translator で翻訳する"}, {u8"transl"}, - fast_io::vector{aliasList_struct{std::in_place, stringview_Judge{u8"set", &com}}, - aliasList_struct{std::in_place, stringview_Judge{u8"send", nullptr}}, - aliasList_struct{std::in_place, stringview_Judge{u8"display", nullptr}}}, // If empty must use fast_io::vector{} + fast_io::vector{aliasList_struct{stringview_Judge{u8"set", &com}}, + aliasList_struct{stringview_Judge{u8"send", nullptr}}, + aliasList_struct{stringview_Judge{u8"display", nullptr}}}, // If empty must use fast_io::vector{} nullptr, &TranslateCommand_onExecute}; diff --git a/China/HeliumClient/Commands/ICommand.h b/China/HeliumClient/Commands/ICommand.h index 5b05f14..329bdc8 100644 --- a/China/HeliumClient/Commands/ICommand.h +++ b/China/HeliumClient/Commands/ICommand.h @@ -23,18 +23,18 @@ concept has_next_objects = requires(T a) { struct auto_completion_base_impl { virtual constexpr ~auto_completion_base_impl() = default; virtual constexpr void* next_objects_impl(fast_io::vector* cmdlist, size_t order) const noexcept = 0; - virtual constexpr std::u8string_view next_complete_impl() const noexcept = 0; + virtual constexpr std::u8string next_complete_impl() const noexcept = 0; virtual constexpr auto_completion_base_impl* clone() const = 0; }; template struct auto_completion_derv_impl : auto_completion_base_impl { T t; - auto_completion_derv_impl(std::in_place_t, T&& tt) : t{std::forward(tt)} {} + auto_completion_derv_impl(T&& tt) : t{std::forward(tt)} {} virtual constexpr void* next_objects_impl(fast_io::vector* cmdlist, size_t order) const noexcept override { return next_objects(t, cmdlist, order); } - virtual constexpr std::u8string_view next_complete_impl() const noexcept override{ + virtual constexpr std::u8string next_complete_impl() const noexcept override{ return next_complete(t); } virtual constexpr auto_completion_base_impl* clone() const override { @@ -49,7 +49,7 @@ public: ::details::auto_completion_base_impl* ptr{}; constexpr aliasList_struct() noexcept = default; template - explicit constexpr aliasList_struct(std::in_place_t, T&& tt) noexcept : ptr{new ::details::auto_completion_derv_impl(std::in_place, std::forward(tt))} { + explicit constexpr aliasList_struct(T&& tt) noexcept : ptr{new ::details::auto_completion_derv_impl(std::forward(tt))} { } constexpr aliasList_struct(aliasList_struct const& other) : ptr{other.ptr->clone()} {} constexpr aliasList_struct& operator=(aliasList_struct const& other) { @@ -76,7 +76,7 @@ inline constexpr void* next_objects(aliasList_struct const& p, fast_io::vectornext_objects_impl(cmdlist, order); } -inline constexpr std::u8string_view next_complete(aliasList_struct const& p) noexcept { +inline constexpr std::u8string next_complete(aliasList_struct const& p) noexcept { return p.ptr->next_complete_impl(); } @@ -94,8 +94,8 @@ inline constexpr void* next_objects(Empty_Object p, fast_io::vector p, fast_io::vector -inline constexpr std::u8string_view next_complete(integral_Object<_Ty> p) noexcept { +inline constexpr std::u8string next_complete(integral_Object<_Ty> p) noexcept { return fast_io::u8concat(p); } @@ -229,7 +229,7 @@ inline constexpr void* next_objects(floating_point_Object<_Ty> p, fast_io::vecto } template -inline constexpr std::u8string_view next_complete(floating_point_Object<_Ty> p) noexcept { +inline constexpr std::u8string next_complete(floating_point_Object<_Ty> p) noexcept { return fast_io::u8concat(p); } @@ -252,8 +252,8 @@ inline constexpr void* next_objects(Empty_Judge p, fast_io::vector p, fast_io::vector -inline constexpr std::u8string_view next_complete(integral_Judge<_Ty> p) noexcept { +inline constexpr std::u8string next_complete(integral_Judge<_Ty> p) noexcept { return fast_io::concat(p); } @@ -403,7 +403,7 @@ inline constexpr void* next_objects(floating_point_Judge<_Ty> p, fast_io::vector } template -inline constexpr std::u8string_view next_complete(std::is_floating_point<_Ty> p) noexcept { +inline constexpr std::u8string next_complete(std::is_floating_point<_Ty> p) noexcept { return fast_io::concat(p); } diff --git a/China/Memory/Hook.cpp b/China/Memory/Hook.cpp index 6f2f696..1359dad 100644 --- a/China/Memory/Hook.cpp +++ b/China/Memory/Hook.cpp @@ -786,7 +786,7 @@ void Hooks::PleaseAutoComplete(__int64 _this, __int64 a2, TextHolder* text, int completeList.reserve(next->size()); for (auto& al : *next) { C_GuiData::displayClientMessageC(fast_io::mnp::chvw(CommandMgr::prefix), Utils::TextColor::DARK_GRAY, cmd->first, fast_io::mnp::chvw(u8' '), concat, Utils::TextColor::GRAY, next_complete(al)); - completeList.emplace_back_unchecked(std::u8string{next_complete(al)}, 0, 0ui8); + completeList.emplace_back_unchecked(next_complete(al), 0, 0ui8); } std::u8string complete = fast_io::u8concat(fast_io::mnp::chvw(CommandMgr::prefix), cmd->first, fast_io::mnp::chvw(u8' '), concat, completeList.front().cmd); setTextAndReturn(complete); diff --git a/China/include/fast_io/fast_io_dsal/impl/vector.h b/China/include/fast_io/fast_io_dsal/impl/vector.h index 6b20e35..fa5a330 100644 --- a/China/include/fast_io/fast_io_dsal/impl/vector.h +++ b/China/include/fast_io/fast_io_dsal/impl/vector.h @@ -531,7 +531,7 @@ public: else { auto const size{ ilist.size() }; - imp.curr_ptr = imp.begin_ptr = typed_allocator_type::allocator(size); + imp.curr_ptr = imp.begin_ptr = typed_allocator_type::allocate(size); auto e = imp.end_ptr = imp.begin_ptr + size; run_destroy des{ this }; assign_common_impl(ilist.begin(), ilist.end()); -- Gitee From a240a49873f57edacdcabda4a37cbebe36805c2c Mon Sep 17 00:00:00 2001 From: MacroModel Date: Wed, 12 Apr 2023 23:15:33 +0800 Subject: [PATCH 6/8] fix crash --- .../Commands/Commands/ConfigCommand.cpp | 4 +-- China/Memory/Hook.cpp | 26 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp index 1fc1d66..293670e 100644 --- a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp +++ b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp @@ -506,8 +506,8 @@ ICommand ConfigCommand{ {}, fast_io::vector{ aliasList_struct{stringview_Judge{u8"load", &configs_ConfigCommand, &listCommand_ConfigCommand}}, - aliasList_struct{stringview_Judge{u8"create", nullptr, &listCommand_ConfigCommand}}, - aliasList_struct{stringview_Judge{u8"save", nullptr, &listCommand_ConfigCommand}}, + aliasList_struct{stringview_Object{u8"create", nullptr}}, + aliasList_struct{stringview_Object{u8"save", nullptr}}, aliasList_struct{stringview_Judge{u8"delete", &configs_ConfigCommand, &listCommand_ConfigCommand}}, aliasList_struct{stringview_Judge{u8"list", nullptr, &listCommand_ConfigCommand}}, }, diff --git a/China/Memory/Hook.cpp b/China/Memory/Hook.cpp index 1359dad..15bc503 100644 --- a/China/Memory/Hook.cpp +++ b/China/Memory/Hook.cpp @@ -765,16 +765,15 @@ void Hooks::PleaseAutoComplete(__int64 _this, __int64 a2, TextHolder* text, int fast_io::vector* next = &cmd->second->aliasList; // Resolved for the first time for (size_t j = 1; j < cmdlist.size(); j++) { - for (size_t i = 0; i < next->size(); i++) { - next = reinterpret_cast*>(next_objects(next->operator[](i), &cmdlist, j)); - if (next == nullptr) { - concat.clear(); - return oFunc(_this, a2, text, a4); - } else { + const auto nextsize = next->size(); + for (size_t i = 0; i < nextsize; i++) { + auto newnext{reinterpret_cast*>(next_objects(next->operator[](i), &cmdlist, j))}; + if (newnext != nullptr) { + next = newnext; concat.append(fast_io::u8concat(cmdlist[j], fast_io::mnp::chvw(u8' '))); break; } - if (i == next->size() - 1) [[unlikely]] { // not found + if (i == nextsize - 1) [[unlikely]] { // not found concat.clear(); return oFunc(_this, a2, text, a4); // next = nullptr (return) } @@ -867,16 +866,15 @@ void Hooks::PleaseAutoComplete(__int64 _this, __int64 a2, TextHolder* text, int for (size_t j = 1; j < cmdlist.size(); j++) { if (j != cmdlist.size() - 1) { - for (size_t i = 0; i < next->size(); i++) { - next = reinterpret_cast*>(next_objects(next->operator[](i), &cmdlist, j)); - if (next == nullptr) { - concat.clear(); - return oFunc(_this, a2, text, a4); - } else { + const auto nextsize = next->size(); + for (size_t i = 0; i < nextsize; i++) { + auto newnext{reinterpret_cast*>(next_objects(next->operator[](i), &cmdlist, j))}; + if (newnext != nullptr) { + next = newnext; concat.append(fast_io::u8concat(cmdlist[j], fast_io::mnp::chvw(u8' '))); break; } - if (i == next->size() - 1) [[unlikely]] { // not found + if (i == nextsize - 1) [[unlikely]] { // not found concat.clear(); return oFunc(_this, a2, text, a4); // next = nullptr (return) } -- Gitee From 0144ed4abaec01a0086cd772429ff4f737fa9054 Mon Sep 17 00:00:00 2001 From: MacroModel Date: Wed, 12 Apr 2023 23:30:09 +0800 Subject: [PATCH 7/8] list friend --- .../Commands/Commands/FriendCommand.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/China/HeliumClient/Commands/Commands/FriendCommand.cpp b/China/HeliumClient/Commands/Commands/FriendCommand.cpp index a87d3e3..6be90d7 100644 --- a/China/HeliumClient/Commands/Commands/FriendCommand.cpp +++ b/China/HeliumClient/Commands/Commands/FriendCommand.cpp @@ -205,14 +205,23 @@ bool listPlayer_FriendCommand(fast_io::vector*) { return true; } +bool listFriend_FriendCommand(fast_io::vector*) { + Friend_friendList.clear(); + Friend_friendList.reserve(FriendList.size()); + for (auto& i : FriendList) + Friend_friendList.emplace_back(stringview_Object{i, nullptr}); + + return true; +} + ICommand FriendCommand{u8"friend", u8".friend [add/ remove] , list", {u8"Add or remove friendly players", u8"添加或删除友好玩家", u8"添加或刪除友好玩家", u8"味方プレイヤーの追加または削除"}, {}, fast_io::vector{ aliasList_struct{stringview_Judge{u8"add", &Friend_playerList, &listPlayer_FriendCommand}}, - aliasList_struct{stringview_Judge{u8"remove", &Friend_friendList, &listPlayer_FriendCommand}}, - aliasList_struct{stringview_Judge{u8"list", nullptr, &listPlayer_FriendCommand}}, + aliasList_struct{stringview_Judge{u8"remove", &Friend_friendList, &listFriend_FriendCommand}}, + aliasList_struct{stringview_Judge{u8"list", nullptr, &listFriend_FriendCommand}}, }, // If empty must use fast_io::vector{} nullptr, &FriendCommand_onExecute}; \ No newline at end of file -- Gitee From 96cc79a659b4759068af64a9e1163812edd9f7db Mon Sep 17 00:00:00 2001 From: MacroModel Date: Wed, 12 Apr 2023 23:44:37 +0800 Subject: [PATCH 8/8] fix --- .../Commands/Commands/ConfigCommand.cpp | 2 +- .../Commands/Commands/FriendCommand.cpp | 28 ++-- .../Commands/Commands/SetLanguageCommand.cpp | 22 +-- .../Commands/Commands/TranslateCommand.cpp | 128 +++++++++--------- 4 files changed, 96 insertions(+), 84 deletions(-) diff --git a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp index 293670e..04acdb1 100644 --- a/China/HeliumClient/Commands/Commands/ConfigCommand.cpp +++ b/China/HeliumClient/Commands/Commands/ConfigCommand.cpp @@ -495,7 +495,7 @@ bool listCommand_ConfigCommand(fast_io::vector*) { configs_ConfigCommand.clear(); configs_ConfigCommand.reserve(configsString.size()); for (auto& i : configsString) - configs_ConfigCommand.emplace_back_unchecked(string_Object{i, nullptr}); + configs_ConfigCommand.emplace_back_unchecked(string_Object{std::move(i), nullptr}); // MOVE!!! return true; } diff --git a/China/HeliumClient/Commands/Commands/FriendCommand.cpp b/China/HeliumClient/Commands/Commands/FriendCommand.cpp index 6be90d7..15b2288 100644 --- a/China/HeliumClient/Commands/Commands/FriendCommand.cpp +++ b/China/HeliumClient/Commands/Commands/FriendCommand.cpp @@ -8,6 +8,26 @@ fast_io::vector Friend_playerList{}; fast_io::vector Friend_friendList{}; bool FriendCommand_onExecute(const fast_io::vector& args) { + if (args.size() == 2) { + if (args[1] == u8"list") { + if (FriendList.empty()) { + C_GuiData::displayClientMessageC(Utils::TextColor::LIGHT_PURPLE, + u8"[Helium] ", + Utils::TextColor::RED, + u8"No Players in Friend List"); + } else { + C_GuiData::displayClientMessageC(Utils::TextColor::LIGHT_PURPLE, + u8"[Helium] ", + Utils::TextColor::YELLOW, + u8"Friend List:"); + for (auto& i : FriendList) + C_GuiData::displayClientMessageC(Utils::TextColor::GRAY, i); + } + return true; + } else + return false; + } + if (args.size() < 3) return false; @@ -180,14 +200,6 @@ bool FriendCommand_onExecute(const fast_io::vector& args) { std::unreachable(); } } - } else if (args[1] == u8"list") { - C_GuiData::displayClientMessageC(Utils::TextColor::LIGHT_PURPLE, - u8"[Helium] ", - Utils::TextColor::YELLOW, - u8"Friend List:"); - for (auto& i : FriendList) - C_GuiData::displayClientMessageC(Utils::TextColor::GRAY, i); - } else return false; diff --git a/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp b/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp index 04657db..5bd3e31 100644 --- a/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp +++ b/China/HeliumClient/Commands/Commands/SetLanguageCommand.cpp @@ -42,17 +42,17 @@ ICommand SetLanguageCommand{u8"setlanguage", {u8"Set Language", u8"设置语言", u8"設置語言", u8"言語を設定する"}, {}, fast_io::vector{ - aliasList_struct{stringview_Judge{u8"en_US", nullptr}}, - aliasList_struct{stringview_Judge{u8"zh_CN", nullptr}}, - aliasList_struct{stringview_Judge{u8"zh_HK", nullptr}}, - aliasList_struct{stringview_Judge{u8"zh_SG", nullptr}}, - aliasList_struct{stringview_Judge{u8"zh_TW", nullptr}}, - aliasList_struct{stringview_Judge{u8"zh_ZA", nullptr}}, - aliasList_struct{stringview_Judge{u8"ja_JP", nullptr}}, - aliasList_struct{stringview_Judge{u8"0", nullptr}}, - aliasList_struct{stringview_Judge{u8"1", nullptr}}, - aliasList_struct{stringview_Judge{u8"2", nullptr}}, - aliasList_struct{stringview_Judge{u8"3", nullptr}}, + aliasList_struct{stringview_Object{u8"en_US", nullptr}}, + aliasList_struct{stringview_Object{u8"zh_CN", nullptr}}, + aliasList_struct{stringview_Object{u8"zh_HK", nullptr}}, + aliasList_struct{stringview_Object{u8"zh_SG", nullptr}}, + aliasList_struct{stringview_Object{u8"zh_TW", nullptr}}, + aliasList_struct{stringview_Object{u8"zh_ZA", nullptr}}, + aliasList_struct{stringview_Object{u8"ja_JP", nullptr}}, + aliasList_struct{stringview_Object{u8"0", nullptr}}, + aliasList_struct{stringview_Object{u8"1", nullptr}}, + aliasList_struct{stringview_Object{u8"2", nullptr}}, + aliasList_struct{stringview_Object{u8"3", nullptr}}, }, // If empty must use fast_io::vector{} nullptr, &SetLanguageCommand_onExecute}; \ No newline at end of file diff --git a/China/HeliumClient/Commands/Commands/TranslateCommand.cpp b/China/HeliumClient/Commands/Commands/TranslateCommand.cpp index 895f205..2378d23 100644 --- a/China/HeliumClient/Commands/Commands/TranslateCommand.cpp +++ b/China/HeliumClient/Commands/Commands/TranslateCommand.cpp @@ -377,80 +377,80 @@ bool TranslateCommand_onExecute(const fast_io::vector& args) { } fast_io::vector languageto{ - aliasList_struct{stringview_Judge{u8"yue", nullptr}}, - aliasList_struct{stringview_Judge{u8"kor", nullptr}}, - aliasList_struct{stringview_Judge{u8"th", nullptr}}, - aliasList_struct{stringview_Judge{u8"pt", nullptr}}, - aliasList_struct{stringview_Judge{u8"el", nullptr}}, - aliasList_struct{stringview_Judge{u8"bul", nullptr}}, - aliasList_struct{stringview_Judge{u8"fin", nullptr}}, - aliasList_struct{stringview_Judge{u8"slo", nullptr}}, - aliasList_struct{stringview_Judge{u8"cht", nullptr}}, - aliasList_struct{stringview_Judge{u8"zh", nullptr}}, - aliasList_struct{stringview_Judge{u8"wyw", nullptr}}, - aliasList_struct{stringview_Judge{u8"fra", nullptr}}, - aliasList_struct{stringview_Judge{u8"ara", nullptr}}, - aliasList_struct{stringview_Judge{u8"de", nullptr}}, - aliasList_struct{stringview_Judge{u8"nl", nullptr}}, - aliasList_struct{stringview_Judge{u8"est", nullptr}}, - aliasList_struct{stringview_Judge{u8"cs", nullptr}}, - aliasList_struct{stringview_Judge{u8"swe", nullptr}}, - aliasList_struct{stringview_Judge{u8"vie", nullptr}}, - aliasList_struct{stringview_Judge{u8"en", nullptr}}, - aliasList_struct{stringview_Judge{u8"jp", nullptr}}, - aliasList_struct{stringview_Judge{u8"spa", nullptr}}, - aliasList_struct{stringview_Judge{u8"ru", nullptr}}, - aliasList_struct{stringview_Judge{u8"it", nullptr}}, - aliasList_struct{stringview_Judge{u8"pl", nullptr}}, - aliasList_struct{stringview_Judge{u8"dan", nullptr}}, - aliasList_struct{stringview_Judge{u8"rom", nullptr}}, - aliasList_struct{stringview_Judge{u8"hu", nullptr}}}; + aliasList_struct{stringview_Object{u8"yue", nullptr}}, + aliasList_struct{stringview_Object{u8"kor", nullptr}}, + aliasList_struct{stringview_Object{u8"th", nullptr}}, + aliasList_struct{stringview_Object{u8"pt", nullptr}}, + aliasList_struct{stringview_Object{u8"el", nullptr}}, + aliasList_struct{stringview_Object{u8"bul", nullptr}}, + aliasList_struct{stringview_Object{u8"fin", nullptr}}, + aliasList_struct{stringview_Object{u8"slo", nullptr}}, + aliasList_struct{stringview_Object{u8"cht", nullptr}}, + aliasList_struct{stringview_Object{u8"zh", nullptr}}, + aliasList_struct{stringview_Object{u8"wyw", nullptr}}, + aliasList_struct{stringview_Object{u8"fra", nullptr}}, + aliasList_struct{stringview_Object{u8"ara", nullptr}}, + aliasList_struct{stringview_Object{u8"de", nullptr}}, + aliasList_struct{stringview_Object{u8"nl", nullptr}}, + aliasList_struct{stringview_Object{u8"est", nullptr}}, + aliasList_struct{stringview_Object{u8"cs", nullptr}}, + aliasList_struct{stringview_Object{u8"swe", nullptr}}, + aliasList_struct{stringview_Object{u8"vie", nullptr}}, + aliasList_struct{stringview_Object{u8"en", nullptr}}, + aliasList_struct{stringview_Object{u8"jp", nullptr}}, + aliasList_struct{stringview_Object{u8"spa", nullptr}}, + aliasList_struct{stringview_Object{u8"ru", nullptr}}, + aliasList_struct{stringview_Object{u8"it", nullptr}}, + aliasList_struct{stringview_Object{u8"pl", nullptr}}, + aliasList_struct{stringview_Object{u8"dan", nullptr}}, + aliasList_struct{stringview_Object{u8"rom", nullptr}}, + aliasList_struct{stringview_Object{u8"hu", nullptr}}}; fast_io::vector languagefrom{ - aliasList_struct{stringview_Judge{u8"auto", nullptr}}, - aliasList_struct{stringview_Judge{u8"yue", nullptr}}, - aliasList_struct{stringview_Judge{u8"kor", nullptr}}, - aliasList_struct{stringview_Judge{u8"th", nullptr}}, - aliasList_struct{stringview_Judge{u8"pt", nullptr}}, - aliasList_struct{stringview_Judge{u8"el", nullptr}}, - aliasList_struct{stringview_Judge{u8"bul", nullptr}}, - aliasList_struct{stringview_Judge{u8"fin", nullptr}}, - aliasList_struct{stringview_Judge{u8"slo", nullptr}}, - aliasList_struct{stringview_Judge{u8"cht", nullptr}}, - aliasList_struct{stringview_Judge{u8"zh", nullptr}}, - aliasList_struct{stringview_Judge{u8"wyw", nullptr}}, - aliasList_struct{stringview_Judge{u8"fra", nullptr}}, - aliasList_struct{stringview_Judge{u8"ara", nullptr}}, - aliasList_struct{stringview_Judge{u8"de", nullptr}}, - aliasList_struct{stringview_Judge{u8"nl", nullptr}}, - aliasList_struct{stringview_Judge{u8"est", nullptr}}, - aliasList_struct{stringview_Judge{u8"cs", nullptr}}, - aliasList_struct{stringview_Judge{u8"swe", nullptr}}, - aliasList_struct{stringview_Judge{u8"vie", nullptr}}, - aliasList_struct{stringview_Judge{u8"en", nullptr}}, - aliasList_struct{stringview_Judge{u8"jp", nullptr}}, - aliasList_struct{stringview_Judge{u8"spa", nullptr}}, - aliasList_struct{stringview_Judge{u8"ru", nullptr}}, - aliasList_struct{stringview_Judge{u8"it", nullptr}}, - aliasList_struct{stringview_Judge{u8"pl", nullptr}}, - aliasList_struct{stringview_Judge{u8"dan", nullptr}}, - aliasList_struct{stringview_Judge{u8"rom", nullptr}}, - aliasList_struct{stringview_Judge{u8"hu", nullptr}}}; + aliasList_struct{stringview_Object{u8"auto", &languageto}}, + aliasList_struct{stringview_Object{u8"yue", &languageto}}, + aliasList_struct{stringview_Object{u8"kor", &languageto}}, + aliasList_struct{stringview_Object{u8"th", &languageto}}, + aliasList_struct{stringview_Object{u8"pt", &languageto}}, + aliasList_struct{stringview_Object{u8"el", &languageto}}, + aliasList_struct{stringview_Object{u8"bul", &languageto}}, + aliasList_struct{stringview_Object{u8"fin", &languageto}}, + aliasList_struct{stringview_Object{u8"slo", &languageto}}, + aliasList_struct{stringview_Object{u8"cht", &languageto}}, + aliasList_struct{stringview_Object{u8"zh", &languageto}}, + aliasList_struct{stringview_Object{u8"wyw", &languageto}}, + aliasList_struct{stringview_Object{u8"fra", &languageto}}, + aliasList_struct{stringview_Object{u8"ara", &languageto}}, + aliasList_struct{stringview_Object{u8"de", &languageto}}, + aliasList_struct{stringview_Object{u8"nl", &languageto}}, + aliasList_struct{stringview_Object{u8"est", &languageto}}, + aliasList_struct{stringview_Object{u8"cs", &languageto}}, + aliasList_struct{stringview_Object{u8"swe", &languageto}}, + aliasList_struct{stringview_Object{u8"vie", &languageto}}, + aliasList_struct{stringview_Object{u8"en", &languageto}}, + aliasList_struct{stringview_Object{u8"jp", &languageto}}, + aliasList_struct{stringview_Object{u8"spa", &languageto}}, + aliasList_struct{stringview_Object{u8"ru", &languageto}}, + aliasList_struct{stringview_Object{u8"it", &languageto}}, + aliasList_struct{stringview_Object{u8"pl", &languageto}}, + aliasList_struct{stringview_Object{u8"dan", &languageto}}, + aliasList_struct{stringview_Object{u8"rom", &languageto}}, + aliasList_struct{stringview_Object{u8"hu", &languageto}}}; fast_io::vector com{ - aliasList_struct{stringview_Judge{u8"appid", nullptr}}, - aliasList_struct{stringview_Judge{u8"key", nullptr}}, - aliasList_struct{stringview_Judge{u8"local", &languagefrom}}, - aliasList_struct{stringview_Judge{u8"server", &languagefrom}}}; + aliasList_struct{stringview_Object{u8"appid", nullptr}}, + aliasList_struct{stringview_Object{u8"key", nullptr}}, + aliasList_struct{stringview_Object{u8"local", &languagefrom}}, + aliasList_struct{stringview_Object{u8"server", &languagefrom}}}; ICommand TranslateCommand{ u8"translate", u8".translate or .transl [set [[loacl, server] , appid , key ], send , display ]", {u8"Translate with Baidu Translator", u8"使用百度翻译器翻译", u8"使用百度翻譯器翻譯", u8"Baidu Translator で翻訳する"}, {u8"transl"}, - fast_io::vector{aliasList_struct{stringview_Judge{u8"set", &com}}, - aliasList_struct{stringview_Judge{u8"send", nullptr}}, - aliasList_struct{stringview_Judge{u8"display", nullptr}}}, // If empty must use fast_io::vector{} + fast_io::vector{aliasList_struct{stringview_Object{u8"set", &com}}, + aliasList_struct{stringview_Object{u8"send", nullptr}}, + aliasList_struct{stringview_Object{u8"display", nullptr}}}, // If empty must use fast_io::vector{} nullptr, &TranslateCommand_onExecute}; -- Gitee