mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 01:23:51 +00:00
fix(render): code quality cleanup
Magic number elimination: - Create protocol_constants.hpp, warden_constants.hpp, render_constants.hpp, ui_constants.hpp - Replace ~55 magic numbers across game_handler, warden_handler, m2_renderer_render Reduce nesting depth: - Extract 5 parseEffect* methods from handleSpellLogExecute (max indent 52 → 16 cols) - Extract resolveSpellSchool/playSpellCastSound/playSpellImpactSound from 3× duplicate audio blocks in handleSpellGo - Flatten SMSG_INVENTORY_CHANGE_FAILURE with early-return guards - Extract drawScreenEdgeVignette() for 3 duplicate vignette blocks DRY extract patterns: - Replace 12 compound expansion checks with isPreWotlk() across movement_handler (9), chat_handler (1), social_handler (1) const to constexpr: - Promote 23+ static const arrays/scalars to static constexpr across 12 source files Error handling: - Convert PIN auth from exceptions to std::optional<PinProof> - Add [[nodiscard]] to 15+ initialize/parse methods - Wrap ~20 unchecked initialize() calls with LOG_WARNING/LOG_ERROR Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
This commit is contained in:
parent
2e8856bacd
commit
97106bd6ae
41 changed files with 849 additions and 424 deletions
|
|
@ -40,7 +40,7 @@ public:
|
|||
~AuthHandler();
|
||||
|
||||
// Connection
|
||||
bool connect(const std::string& host, uint16_t port = 3724);
|
||||
[[nodiscard]] bool connect(const std::string& host, uint16_t port = 3724);
|
||||
void disconnect();
|
||||
bool isConnected() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ struct LogonChallengeResponse {
|
|||
// LOGON_CHALLENGE response parser
|
||||
class LogonChallengeResponseParser {
|
||||
public:
|
||||
static bool parse(network::Packet& packet, LogonChallengeResponse& response);
|
||||
[[nodiscard]] static bool parse(network::Packet& packet, LogonChallengeResponse& response);
|
||||
};
|
||||
|
||||
// LOGON_PROOF packet builder
|
||||
|
|
@ -92,7 +92,7 @@ struct LogonProofResponse {
|
|||
// LOGON_PROOF response parser
|
||||
class LogonProofResponseParser {
|
||||
public:
|
||||
static bool parse(network::Packet& packet, LogonProofResponse& response);
|
||||
[[nodiscard]] static bool parse(network::Packet& packet, LogonProofResponse& response);
|
||||
};
|
||||
|
||||
// Realm data structure
|
||||
|
|
@ -131,7 +131,7 @@ struct RealmListResponse {
|
|||
class RealmListResponseParser {
|
||||
public:
|
||||
// protocolVersion: 3 = vanilla (uint8 realmCount, uint32 icon), 8 = WotLK (uint16 realmCount, uint8 icon)
|
||||
static bool parse(network::Packet& packet, RealmListResponse& response, uint8_t protocolVersion = 8);
|
||||
[[nodiscard]] static bool parse(network::Packet& packet, RealmListResponse& response, uint8_t protocolVersion = 8);
|
||||
};
|
||||
|
||||
} // namespace auth
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace wowee {
|
||||
|
|
@ -19,9 +20,11 @@ struct PinProof {
|
|||
// - Compute: pin_hash = SHA1(client_salt || SHA1(server_salt || randomized_pin_ascii))
|
||||
//
|
||||
// PIN must be 4-10 ASCII digits.
|
||||
PinProof computePinProof(const std::string& pinDigits,
|
||||
uint32_t pinGridSeed,
|
||||
const std::array<uint8_t, 16>& serverSalt);
|
||||
// Returns std::nullopt on invalid input (bad length, non-digit chars, or grid corruption).
|
||||
[[nodiscard]] std::optional<PinProof> computePinProof(
|
||||
const std::string& pinDigits,
|
||||
uint32_t pinGridSeed,
|
||||
const std::array<uint8_t, 16>& serverSalt);
|
||||
|
||||
} // namespace auth
|
||||
} // namespace wowee
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue