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:
Pavel Okhlopkov 2026-04-06 22:43:13 +03:00
parent 2e8856bacd
commit 97106bd6ae
41 changed files with 849 additions and 424 deletions

View file

@ -137,7 +137,8 @@ bool Application::initialize() {
// Create and initialize audio coordinator (owns all audio managers)
audioCoordinator_ = std::make_unique<audio::AudioCoordinator>();
audioCoordinator_->initialize();
if (!audioCoordinator_->initialize())
LOG_WARNING("Audio coordinator initialization failed — game will run without audio");
renderer->setAudioCoordinator(audioCoordinator_.get());
// Create UI manager
@ -2549,7 +2550,8 @@ void Application::loadQuestMarkerModels() {
if (auto* vkCtx = renderer->getVkContext()) {
VkDescriptorSetLayout pfl = renderer->getPerFrameSetLayout();
if (pfl != VK_NULL_HANDLE) {
qmr->initialize(vkCtx, pfl, assetManager.get());
if (!qmr->initialize(vkCtx, pfl, assetManager.get()))
LOG_WARNING("Quest marker renderer re-init failed (non-fatal)");
}
}
}