mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-02 15:53: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
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
/// Initialize the audio engine and all managers.
|
||||
/// @return true if audio is available (engine initialized successfully)
|
||||
bool initialize();
|
||||
[[nodiscard]] bool initialize();
|
||||
|
||||
/// Initialize managers that need AssetManager (music lookups, sound banks).
|
||||
void initializeWithAssets(pipeline::AssetManager* assetManager);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public:
|
|||
~AudioEngine();
|
||||
|
||||
// Initialization
|
||||
bool initialize();
|
||||
[[nodiscard]] bool initialize();
|
||||
void shutdown();
|
||||
bool isInitialized() const { return initialized_; }
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
126
include/game/protocol_constants.hpp
Normal file
126
include/game/protocol_constants.hpp
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// WoW 3.3.5a (12340) protocol constants.
|
||||
// Centralised so every handler references a single source of truth.
|
||||
|
||||
namespace wowee {
|
||||
namespace game {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Currency
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t COPPER_PER_GOLD = 10000;
|
||||
constexpr uint32_t COPPER_PER_SILVER = 100;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Unit flags (UNIT_FIELD_FLAGS — offset 46 in UnitFields)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t UNIT_FLAG_TAXI_FLIGHT = 0x00000100;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// NPC flags (UNIT_NPC_FLAGS — offset 147 in UnitFields, 3.3.5a)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t NPC_FLAG_SPIRIT_GUIDE = 0x00004000;
|
||||
constexpr uint32_t NPC_FLAG_SPIRIT_HEALER = 0x00008000;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Default action-bar spell IDs
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t SPELL_ID_ATTACK = 6603;
|
||||
constexpr uint32_t SPELL_ID_HEARTHSTONE = 8690;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Class IDs
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t CLASS_WARRIOR = 1;
|
||||
constexpr uint32_t CLASS_PALADIN = 2;
|
||||
constexpr uint32_t CLASS_HUNTER = 3;
|
||||
constexpr uint32_t CLASS_ROGUE = 4;
|
||||
constexpr uint32_t CLASS_PRIEST = 5;
|
||||
constexpr uint32_t CLASS_DK = 6;
|
||||
constexpr uint32_t CLASS_SHAMAN = 7;
|
||||
constexpr uint32_t CLASS_MAGE = 8;
|
||||
constexpr uint32_t CLASS_WARLOCK = 9;
|
||||
constexpr uint32_t CLASS_DRUID = 11;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Class-specific stance / form / presence spell IDs
|
||||
// ---------------------------------------------------------------------------
|
||||
// Warrior stances
|
||||
constexpr uint32_t SPELL_BATTLE_STANCE = 2457;
|
||||
constexpr uint32_t SPELL_DEFENSIVE_STANCE = 71;
|
||||
constexpr uint32_t SPELL_BERSERKER_STANCE = 2458;
|
||||
|
||||
// Death Knight presences
|
||||
constexpr uint32_t SPELL_BLOOD_PRESENCE = 48266;
|
||||
constexpr uint32_t SPELL_FROST_PRESENCE = 48263;
|
||||
constexpr uint32_t SPELL_UNHOLY_PRESENCE = 48265;
|
||||
|
||||
// Druid forms
|
||||
constexpr uint32_t SPELL_BEAR_FORM = 5487;
|
||||
constexpr uint32_t SPELL_DIRE_BEAR_FORM = 9634;
|
||||
constexpr uint32_t SPELL_CAT_FORM = 768;
|
||||
constexpr uint32_t SPELL_AQUATIC_FORM = 1066;
|
||||
constexpr uint32_t SPELL_TRAVEL_FORM = 783;
|
||||
constexpr uint32_t SPELL_MOONKIN_FORM = 24858;
|
||||
constexpr uint32_t SPELL_FLIGHT_FORM = 33943;
|
||||
constexpr uint32_t SPELL_SWIFT_FLIGHT = 40120;
|
||||
constexpr uint32_t SPELL_TREE_OF_LIFE = 33891;
|
||||
|
||||
// Rogue
|
||||
constexpr uint32_t SPELL_STEALTH = 1784;
|
||||
|
||||
// Priest
|
||||
constexpr uint32_t SPELL_SHADOWFORM = 15473;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Session / network timing
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t SESSION_KEY_HEX_LENGTH = 40;
|
||||
constexpr uint32_t RX_SILENCE_WARNING_MS = 10000; // 10 s
|
||||
constexpr uint32_t RX_SILENCE_CRITICAL_MS = 15000; // 15 s
|
||||
constexpr float WARDEN_GATE_LOG_INTERVAL_SEC = 30.0f;
|
||||
constexpr float CLASSIC_PING_INTERVAL_SEC = 10.0f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Heartbeat / area-trigger intervals (seconds)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float HEARTBEAT_INTERVAL_TAXI = 0.25f;
|
||||
constexpr float HEARTBEAT_INTERVAL_STATIONARY_COMBAT = 0.75f;
|
||||
constexpr float HEARTBEAT_INTERVAL_MOVING_COMBAT = 0.20f;
|
||||
constexpr float AREA_TRIGGER_CHECK_INTERVAL = 0.25f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Gameplay distance thresholds
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float ENTITY_UPDATE_RADIUS = 150.0f;
|
||||
constexpr float NPC_INTERACT_MAX_DISTANCE = 15.0f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Skill categories (from SkillLine DBC)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t SKILL_CATEGORY_PROFESSION = 11;
|
||||
constexpr uint32_t SKILL_CATEGORY_SECONDARY = 9;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DBC field-index sentinel (field lookup failure)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t DBC_FIELD_INVALID = 0xFFFFFFFF;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Appearance byte packing
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t APPEARANCE_SKIN_MASK = 0xFF;
|
||||
constexpr uint32_t APPEARANCE_FACE_SHIFT = 8;
|
||||
constexpr uint32_t APPEARANCE_HAIRSTYLE_SHIFT = 16;
|
||||
constexpr uint32_t APPEARANCE_HAIRCOLOR_SHIFT = 24;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Critter detection
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t CRITTER_MAX_HEALTH_THRESHOLD = 100;
|
||||
|
||||
} // namespace game
|
||||
} // namespace wowee
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
#include "game/opcode_table.hpp"
|
||||
#include "game/spell_defines.hpp"
|
||||
#include "game/handler_types.hpp"
|
||||
#include "audio/spell_sound_manager.hpp"
|
||||
#include "network/packet.hpp"
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
|
|
@ -273,6 +274,30 @@ private:
|
|||
void handleChannelUpdate(network::Packet& packet);
|
||||
|
||||
// --- Internal helpers ---
|
||||
|
||||
// Resolve the magic school for a spell (for audio playback).
|
||||
// Returns MagicSchool from the spell name cache, defaulting to ARCANE.
|
||||
audio::SpellSoundManager::MagicSchool resolveSpellSchool(uint32_t spellId);
|
||||
|
||||
// Play a spell cast or impact sound via audioCoordinator, if available.
|
||||
void playSpellCastSound(uint32_t spellId);
|
||||
void playSpellImpactSound(uint32_t spellId);
|
||||
|
||||
// --- handleSpellLogExecute per-effect parsers (extracted to reduce nesting) ---
|
||||
void parseEffectPowerDrain(network::Packet& packet, uint32_t effectLogCount,
|
||||
uint64_t caster, uint32_t spellId, bool isPlayerCaster,
|
||||
bool usesFullGuid);
|
||||
void parseEffectHealthLeech(network::Packet& packet, uint32_t effectLogCount,
|
||||
uint64_t caster, uint32_t spellId, bool isPlayerCaster,
|
||||
bool usesFullGuid);
|
||||
void parseEffectCreateItem(network::Packet& packet, uint32_t effectLogCount,
|
||||
uint64_t caster, uint32_t spellId, bool isPlayerCaster);
|
||||
void parseEffectInterruptCast(network::Packet& packet, uint32_t effectLogCount,
|
||||
uint64_t caster, uint32_t spellId, bool isPlayerCaster,
|
||||
bool usesFullGuid);
|
||||
void parseEffectFeedPet(network::Packet& packet, uint32_t effectLogCount,
|
||||
uint64_t caster, uint32_t spellId, bool isPlayerCaster);
|
||||
|
||||
// Find the on-use spell for an item (trigger=0 Use or trigger=5 NoDelay).
|
||||
// CMSG_USE_ITEM requires a valid spellId or the server silently ignores it.
|
||||
uint32_t findOnUseSpellId(uint32_t itemId) const;
|
||||
|
|
|
|||
65
include/game/warden_constants.hpp
Normal file
65
include/game/warden_constants.hpp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// Warden anti-cheat protocol constants for WoW 3.3.5a (12340).
|
||||
// Server-to-Client (SMSG) and Client-to-Server (CMSG) sub-opcodes,
|
||||
// memory region boundaries, check sizes, and result codes.
|
||||
|
||||
namespace wowee {
|
||||
namespace game {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Warden sub-opcodes (inside SMSG_WARDEN_DATA / CMSG_WARDEN_DATA)
|
||||
// ---------------------------------------------------------------------------
|
||||
// Server → Client
|
||||
constexpr uint8_t WARDEN_SMSG_MODULE_USE = 0x00;
|
||||
constexpr uint8_t WARDEN_SMSG_MODULE_CACHE = 0x01;
|
||||
constexpr uint8_t WARDEN_SMSG_CHEAT_CHECKS_REQUEST = 0x02;
|
||||
constexpr uint8_t WARDEN_SMSG_MODULE_INITIALIZE = 0x03;
|
||||
constexpr uint8_t WARDEN_SMSG_HASH_REQUEST = 0x05;
|
||||
|
||||
// Client → Server
|
||||
constexpr uint8_t WARDEN_CMSG_MODULE_MISSING = 0x00;
|
||||
constexpr uint8_t WARDEN_CMSG_MODULE_OK = 0x01;
|
||||
constexpr uint8_t WARDEN_CMSG_CHEAT_CHECKS_RESULT = 0x02;
|
||||
constexpr uint8_t WARDEN_CMSG_HASH_RESULT = 0x04;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// PE section boundaries (Wow.exe 3.3.5a 12340, default base 0x400000)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t PE_TEXT_SECTION_BASE = 0x400000;
|
||||
constexpr uint32_t PE_TEXT_SECTION_END = 0x800000;
|
||||
constexpr uint32_t PE_RDATA_SECTION_BASE = 0x7FF000;
|
||||
constexpr uint32_t PE_DATA_RAW_SECTION_BASE = 0x827000;
|
||||
constexpr uint32_t PE_BSS_SECTION_BASE = 0x883000;
|
||||
constexpr uint32_t PE_BSS_SECTION_END = 0xD06000;
|
||||
|
||||
// Windows KUSER_SHARED_DATA page (read-only, always mapped)
|
||||
constexpr uint32_t KUSER_SHARED_DATA_BASE = 0x7FFE0000;
|
||||
constexpr uint32_t KUSER_SHARED_DATA_END = 0x7FFF0000;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Well-known memory addresses
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t WARDEN_TICKCOUNT_ADDRESS = 0x00CF0BC8;
|
||||
constexpr uint32_t WARDEN_WIN_VERSION_ADDRESS = 0x7FFE026C;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Check sizes (bytes)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t WARDEN_CR_HEADER_SIZE = 17;
|
||||
constexpr uint32_t WARDEN_CR_ENTRY_SIZE = 68;
|
||||
constexpr uint32_t WARDEN_PAGE_CHECK_SIZE = 29;
|
||||
constexpr uint32_t WARDEN_PAGE_A_SHORT_SIZE = 24;
|
||||
constexpr uint32_t WARDEN_KNOWN_CODE_SCAN_OFFSET = 13856;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Memory-check result codes
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint8_t WARDEN_MEM_CHECK_SUCCESS = 0x00;
|
||||
constexpr uint8_t WARDEN_MEM_CHECK_UNMAPPED = 0xE9;
|
||||
constexpr uint8_t WARDEN_PAGE_CHECK_FOUND = 0x4A;
|
||||
|
||||
} // namespace game
|
||||
} // namespace wowee
|
||||
|
|
@ -49,7 +49,7 @@ public:
|
|||
CharacterRenderer();
|
||||
~CharacterRenderer();
|
||||
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout, pipeline::AssetManager* am,
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout, pipeline::AssetManager* am,
|
||||
VkRenderPass renderPassOverride = VK_NULL_HANDLE,
|
||||
VkSampleCountFlagBits msaaSamples = VK_SAMPLE_COUNT_1_BIT);
|
||||
void shutdown();
|
||||
|
|
@ -71,7 +71,7 @@ public:
|
|||
void prepareRender(uint32_t frameIndex);
|
||||
void render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const Camera& camera);
|
||||
void recreatePipelines();
|
||||
bool initializeShadow(VkRenderPass shadowRenderPass);
|
||||
[[nodiscard]] bool initializeShadow(VkRenderPass shadowRenderPass);
|
||||
void renderShadow(VkCommandBuffer cmd, const glm::mat4& lightSpaceMatrix,
|
||||
const glm::vec3& shadowCenter = glm::vec3(0), float shadowRadius = 1e9f);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public:
|
|||
ChargeEffect();
|
||||
~ChargeEffect();
|
||||
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
void shutdown();
|
||||
void recreatePipelines();
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public:
|
|||
Lightning();
|
||||
~Lightning();
|
||||
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
void shutdown();
|
||||
void recreatePipelines();
|
||||
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ public:
|
|||
M2Renderer();
|
||||
~M2Renderer();
|
||||
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout,
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout,
|
||||
pipeline::AssetManager* assets);
|
||||
void shutdown();
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ public:
|
|||
/**
|
||||
* Initialize shadow pipeline (Phase 7)
|
||||
*/
|
||||
bool initializeShadow(VkRenderPass shadowRenderPass);
|
||||
[[nodiscard]] bool initializeShadow(VkRenderPass shadowRenderPass);
|
||||
bool hasShadowPipeline() const { return shadowPipeline_ != VK_NULL_HANDLE; }
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public:
|
|||
MountDust();
|
||||
~MountDust();
|
||||
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
void shutdown();
|
||||
void recreatePipelines();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public:
|
|||
QuestMarkerRenderer();
|
||||
~QuestMarkerRenderer();
|
||||
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout, pipeline::AssetManager* assetManager);
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout, pipeline::AssetManager* assetManager);
|
||||
void shutdown();
|
||||
void recreatePipelines();
|
||||
|
||||
|
|
|
|||
74
include/rendering/render_constants.hpp
Normal file
74
include/rendering/render_constants.hpp
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// Rendering-domain constants: distances, LOD thresholds, particle tuning.
|
||||
|
||||
namespace wowee {
|
||||
namespace rendering {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// M2 instance-count → render-distance mapping
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr uint32_t M2_HIGH_DENSITY_INSTANCE_THRESHOLD = 2000;
|
||||
constexpr float M2_MAX_RENDER_DISTANCE_HIGH_DENSITY = 800.0f;
|
||||
constexpr float M2_MAX_RENDER_DISTANCE_LOW_DENSITY = 2800.0f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// M2 LOD / bone-update distance thresholds (world units)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float M2_LOD3_DISTANCE = 150.0f; // Beyond this: no bone updates
|
||||
constexpr float M2_BONE_SKIP_DIST_FAR = 100.0f; // Beyond this: every 4th frame
|
||||
constexpr float M2_BONE_SKIP_DIST_MID = 50.0f; // Beyond this: every 2nd frame
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// M2 culling geometry
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float M2_CULL_RADIUS_SCALE_DIVISOR = 12.0f;
|
||||
constexpr float M2_PADDED_RADIUS_SCALE = 1.5f;
|
||||
constexpr float M2_PADDED_RADIUS_MIN_MARGIN = 3.0f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// M2 variation / idle animation timing (milliseconds)
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float M2_VARIATION_TIMER_MIN_MS = 3000.0f;
|
||||
constexpr float M2_VARIATION_TIMER_MAX_MS = 11000.0f;
|
||||
constexpr float M2_LOOP_VARIATION_TIMER_MIN_MS = 4000.0f;
|
||||
constexpr float M2_LOOP_VARIATION_TIMER_MAX_MS = 10000.0f;
|
||||
constexpr float M2_IDLE_VARIATION_TIMER_MIN_MS = 2000.0f;
|
||||
constexpr float M2_IDLE_VARIATION_TIMER_MAX_MS = 6000.0f;
|
||||
constexpr float M2_DEFAULT_PARTICLE_ANIM_MS = 3333.0f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// HiZ occlusion culling
|
||||
// ---------------------------------------------------------------------------
|
||||
// VP matrix diff threshold — below this HiZ is considered safe.
|
||||
// Typical tracking camera (following a walking character) produces 0.05–0.25.
|
||||
constexpr float HIZ_VP_DIFF_THRESHOLD = 0.5f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Smoke / spark particle tuning
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float SMOKE_OFFSET_XY_MIN = -0.4f;
|
||||
constexpr float SMOKE_OFFSET_XY_MAX = 0.4f;
|
||||
constexpr float SMOKE_VEL_Z_MIN = 3.0f;
|
||||
constexpr float SMOKE_VEL_Z_MAX = 5.0f;
|
||||
constexpr float SMOKE_LIFETIME_MIN = 4.0f;
|
||||
constexpr float SMOKE_LIFETIME_MAX = 7.0f;
|
||||
constexpr float SMOKE_Z_VEL_DAMPING = 0.98f;
|
||||
constexpr float SMOKE_SIZE_START = 1.0f;
|
||||
constexpr float SMOKE_SIZE_GROWTH = 2.5f;
|
||||
|
||||
constexpr int SPARK_PROBABILITY_DENOM = 8; // 1-in-8 chance per frame
|
||||
constexpr float SPARK_LIFE_BASE = 0.8f;
|
||||
constexpr float SPARK_LIFE_RANGE = 1.2f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Character rendering
|
||||
// ---------------------------------------------------------------------------
|
||||
// Default frustum-cull radius when model bounds are unavailable (world units).
|
||||
// 4.0 covers Tauren, mounted characters, and most creature models.
|
||||
constexpr float DEFAULT_CHARACTER_CULL_RADIUS = 4.0f;
|
||||
|
||||
} // namespace rendering
|
||||
} // namespace wowee
|
||||
|
|
@ -19,7 +19,7 @@ public:
|
|||
SwimEffects();
|
||||
~SwimEffects();
|
||||
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
void shutdown();
|
||||
void recreatePipelines();
|
||||
void update(const Camera& camera, const CameraController& cc,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public:
|
|||
* @param perFrameLayout Descriptor set layout for the per-frame UBO (set 0)
|
||||
* @return true if initialization succeeded
|
||||
*/
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
||||
void recreatePipelines();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public:
|
|||
* @param perFrameLayout Descriptor set layout for set 0 (per-frame UBO)
|
||||
* @param assetManager Asset manager for loading textures (optional)
|
||||
*/
|
||||
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout,
|
||||
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout,
|
||||
pipeline::AssetManager* assetManager = nullptr);
|
||||
|
||||
/**
|
||||
|
|
@ -163,7 +163,7 @@ public:
|
|||
/**
|
||||
* Initialize shadow pipeline (Phase 7)
|
||||
*/
|
||||
bool initializeShadow(VkRenderPass shadowRenderPass);
|
||||
[[nodiscard]] bool initializeShadow(VkRenderPass shadowRenderPass);
|
||||
|
||||
/**
|
||||
* Render depth-only for shadow casting
|
||||
|
|
|
|||
68
include/ui/ui_constants.hpp
Normal file
68
include/ui/ui_constants.hpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// UI-layer constants: colors, layout sizes, effect timing.
|
||||
|
||||
namespace wowee {
|
||||
namespace ui {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Target selection-circle difficulty colours (WoW-canonical)
|
||||
// ---------------------------------------------------------------------------
|
||||
// Stored as {R, G, B} in [0,1]. Alpha is set by the caller.
|
||||
struct Colour3f { float r, g, b; };
|
||||
|
||||
constexpr Colour3f SEL_COLOR_DEFAULT_YELLOW = {1.0f, 1.0f, 0.3f};
|
||||
constexpr Colour3f SEL_COLOR_RED = {1.0f, 0.1f, 0.1f};
|
||||
constexpr Colour3f SEL_COLOR_ORANGE = {1.0f, 0.5f, 0.1f};
|
||||
constexpr Colour3f SEL_COLOR_YELLOW = {1.0f, 1.0f, 0.1f};
|
||||
constexpr Colour3f SEL_COLOR_GREEN = {0.3f, 1.0f, 0.3f};
|
||||
constexpr Colour3f SEL_COLOR_GREY = {0.6f, 0.6f, 0.6f};
|
||||
constexpr Colour3f SEL_COLOR_DEAD = {0.5f, 0.5f, 0.5f};
|
||||
|
||||
// Level-diff thresholds that select colours above.
|
||||
constexpr int MOB_LEVEL_DIFF_RED = 10; // ≥ 10 levels above player → red
|
||||
constexpr int MOB_LEVEL_DIFF_ORANGE = 5; // ≥ 5 → orange
|
||||
constexpr int MOB_LEVEL_DIFF_YELLOW_FLOOR = -2; // ≥ -2 → yellow, else green
|
||||
|
||||
// Selection circle world-unit bounds
|
||||
constexpr float SEL_CIRCLE_MIN_RADIUS = 0.8f;
|
||||
constexpr float SEL_CIRCLE_MAX_RADIUS = 8.0f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Damage flash / vignette effect
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float DAMAGE_FLASH_FADE_SPEED = 2.0f; // alpha units/sec
|
||||
constexpr float DAMAGE_FLASH_ALPHA_SCALE = 100.0f; // multiplier
|
||||
constexpr uint8_t DAMAGE_FLASH_RED_CHANNEL = 200; // IM_COL32 R channel
|
||||
constexpr float DAMAGE_VIGNETTE_THICKNESS = 0.12f; // fraction of screen
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Low-health pulsing vignette
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float LOW_HEALTH_THRESHOLD_PCT = 0.20f; // start at 20% HP
|
||||
constexpr float LOW_HEALTH_PULSE_FREQUENCY = 9.4f; // angular speed (~1.5 Hz)
|
||||
constexpr float LOW_HEALTH_MAX_ALPHA = 90.0f;
|
||||
constexpr float LOW_HEALTH_VIGNETTE_THICKNESS = 0.15f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Level-up flash overlay
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float LEVELUP_FLASH_FADE_SPEED = 1.0f; // alpha units/sec
|
||||
constexpr float LEVELUP_FLASH_ALPHA_SCALE = 160.0f;
|
||||
constexpr float LEVELUP_VIGNETTE_THICKNESS = 0.18f;
|
||||
constexpr float LEVELUP_TEXT_FONT_SIZE = 28.0f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Ghost / death state
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float GHOST_OPACITY = 0.5f;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Click / interaction thresholds
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr float CLICK_THRESHOLD_PX = 5.0f;
|
||||
|
||||
} // namespace ui
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue