From 4b7474800de8a39f9592ec7524e77cdb4eae8b15 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sat, 9 Nov 2024 17:53:41 +0800 Subject: [PATCH] feat: finish todos --- src/ll/core/tweak/ModifyInfomation.cpp | 21 ++++++++++----------- src/mc/nbt/detail/SnbtErrorCode.cpp | 5 ++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/ll/core/tweak/ModifyInfomation.cpp b/src/ll/core/tweak/ModifyInfomation.cpp index 54aebd9923..e4f6b25a3e 100644 --- a/src/ll/core/tweak/ModifyInfomation.cpp +++ b/src/ll/core/tweak/ModifyInfomation.cpp @@ -42,15 +42,14 @@ LL_STATIC_HOOK( auto serverLogger = io::LoggerRegistry::getInstance().getOrCreate("Server"); -// int _vscprintf(const char* format, va_list pargs) { // TODO: move to predefine -// int retval; -// va_list argcopy; -// va_copy(argcopy, pargs); -// retval = vsnprintf(nullptr, 0, format, argcopy); -// va_end(argcopy); -// return retval; -// } -// vsnprintf(buffer.data(), buffer.size(), pszFormat, va); +int printfbufc(const char* format, va_list const& pargs) { + int retval; + va_list argcopy; + va_copy(argcopy, pargs); + retval = vsnprintf(nullptr, 0, format, argcopy); + va_end(argcopy); + return retval; +} LL_STATIC_HOOK(BedrockLogOutHook, HookPriority::Normal, BedrockLogOut, void, uint priority, char const* pszFormat, ...) try { @@ -58,13 +57,13 @@ try { std::string buffer; va_list va; va_start(va, pszFormat); - auto bufferCount = _vscprintf(pszFormat, va); + auto bufferCount = printfbufc(pszFormat, va); if (bufferCount >= 0) { success = true; } if (success && bufferCount > 0) { buffer = std::string(bufferCount, '\0'); - vsprintf_s(buffer.data(), buffer.size() + 1, pszFormat, va); + vsnprintf(buffer.data(), buffer.size() + 1, pszFormat, va); } va_end(va); diff --git a/src/mc/nbt/detail/SnbtErrorCode.cpp b/src/mc/nbt/detail/SnbtErrorCode.cpp index 509b8d4d9a..f503e9588d 100644 --- a/src/mc/nbt/detail/SnbtErrorCode.cpp +++ b/src/mc/nbt/detail/SnbtErrorCode.cpp @@ -50,10 +50,9 @@ struct snbt_category : public std::error_category { [[nodiscard]] char const* name() const noexcept override { return "snbt"; } }; -// TODO: move to predefine [[_Clang::__require_constant_initialization__]] - inline std::error_category const& snbt_category() noexcept { - return std::_Immortalize_memcpy_image(); + static constexpr struct snbt_category ins; + return ins; } ll::Unexpected makeSnbtError(SnbtErrorCode code) { return makeErrorCodeError(std::error_code{fmt::underlying(code), snbt_category()});