mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-27 01:00:13 +00:00
refactor: extract toHexString utility, more color constants, final cast cleanup
Add core::toHexString() utility in logger.hpp to replace 11 duplicate hex-dump loops across world_packets, world_socket, and game_handler. Add kColorBrightGreen/kColorDarkGray constants in game_screen.cpp replacing 26 inline literals. Replace remaining ~37 C-style casts in 16 files. Normalize keybinding_manager.hpp to #pragma once.
This commit is contained in:
parent
ba99d505dd
commit
eea205ffc9
5 changed files with 63 additions and 96 deletions
|
|
@ -7,6 +7,8 @@
|
|||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <atomic>
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
|
||||
namespace wowee {
|
||||
namespace core {
|
||||
|
|
@ -144,6 +146,17 @@ private:
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
inline std::string toHexString(const uint8_t* data, size_t len, bool spaces = false) {
|
||||
std::string s;
|
||||
s.reserve(len * (spaces ? 3 : 2));
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
char buf[4];
|
||||
std::snprintf(buf, sizeof(buf), spaces ? "%02x " : "%02x", data[i]);
|
||||
s += buf;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace wowee
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue