Skip to content

Commit

Permalink
feat: finish todos
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Nov 9, 2024
1 parent d844740 commit 4b74748
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
21 changes: 10 additions & 11 deletions src/ll/core/tweak/ModifyInfomation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,28 @@ 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 {
bool success = false;
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);

Expand Down
5 changes: 2 additions & 3 deletions src/mc/nbt/detail/SnbtErrorCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<struct snbt_category>();
static constexpr struct snbt_category ins;
return ins;
}
ll::Unexpected makeSnbtError(SnbtErrorCode code) {
return makeErrorCodeError(std::error_code{fmt::underlying(code), snbt_category()});
Expand Down

0 comments on commit 4b74748

Please sign in to comment.