diff --git a/include/game/movement_handler.hpp b/include/game/movement_handler.hpp index b53ba6b4..3a4649c2 100644 --- a/include/game/movement_handler.hpp +++ b/include/game/movement_handler.hpp @@ -122,8 +122,11 @@ public: }; const std::unordered_map& getTaxiNodes() const { return taxiNodes_; } + // WotLK 3.3.5a TaxiNodes.dbc has 384 entries; the known-taxi bitmask + // is 12 × uint32 = 384 bits. Node IDs outside this range are invalid. + static constexpr uint32_t kMaxTaxiNodeId = 384; bool isKnownTaxiNode(uint32_t nodeId) const { - if (nodeId == 0 || nodeId > 384) return false; + if (nodeId == 0 || nodeId > kMaxTaxiNodeId) return false; uint32_t idx = nodeId - 1; return (knownTaxiMask_[idx / 32] & (1u << (idx % 32))) != 0; } diff --git a/src/core/memory_monitor.cpp b/src/core/memory_monitor.cpp index 080a1ef6..75ee47e3 100644 --- a/src/core/memory_monitor.cpp +++ b/src/core/memory_monitor.cpp @@ -23,9 +23,10 @@ size_t readMemAvailableBytesFromProc() { std::string line; while (std::getline(meminfo, line)) { - // Format: "MemAvailable: 123456789 kB" + // /proc/meminfo format: "MemAvailable: 123456789 kB" + static constexpr size_t kFieldPrefixLen = 13; // strlen("MemAvailable:") if (line.rfind("MemAvailable:", 0) != 0) continue; - std::istringstream iss(line.substr(13)); + std::istringstream iss(line.substr(kFieldPrefixLen)); size_t kb = 0; iss >> kb; if (kb > 0) return kb * 1024ull; @@ -42,13 +43,18 @@ MemoryMonitor& MemoryMonitor::getInstance() { } void MemoryMonitor::initialize() { + constexpr size_t kOneGB = 1024ull * 1024 * 1024; + // Fallback if OS API unavailable — 16 GB is a safe conservative estimate + // that prevents over-aggressive asset caching on unknown hardware. + constexpr size_t kFallbackRAM = 16 * kOneGB; + #ifdef _WIN32 ULONGLONG totalKB = 0; if (GetPhysicallyInstalledSystemMemory(&totalKB)) { totalRAM_ = static_cast(totalKB) * 1024ull; - LOG_INFO("System RAM detected: ", totalRAM_ / (1024 * 1024 * 1024), " GB"); + LOG_INFO("System RAM detected: ", totalRAM_ / kOneGB, " GB"); } else { - totalRAM_ = 16ull * 1024 * 1024 * 1024; + totalRAM_ = kFallbackRAM; LOG_WARNING("Could not detect system RAM, assuming 16GB"); } #elif defined(__APPLE__) @@ -56,19 +62,18 @@ void MemoryMonitor::initialize() { size_t len = sizeof(physmem); if (sysctlbyname("hw.memsize", &physmem, &len, nullptr, 0) == 0) { totalRAM_ = static_cast(physmem); - LOG_INFO("System RAM detected: ", totalRAM_ / (1024 * 1024 * 1024), " GB"); + LOG_INFO("System RAM detected: ", totalRAM_ / kOneGB, " GB"); } else { - totalRAM_ = 16ull * 1024 * 1024 * 1024; + totalRAM_ = kFallbackRAM; LOG_WARNING("Could not detect system RAM, assuming 16GB"); } #else struct sysinfo info; if (sysinfo(&info) == 0) { totalRAM_ = static_cast(info.totalram) * info.mem_unit; - LOG_INFO("System RAM detected: ", totalRAM_ / (1024 * 1024 * 1024), " GB"); + LOG_INFO("System RAM detected: ", totalRAM_ / kOneGB, " GB"); } else { - // Fallback: assume 16GB - totalRAM_ = 16ull * 1024 * 1024 * 1024; + totalRAM_ = kFallbackRAM; LOG_WARNING("Could not detect system RAM, assuming 16GB"); } #endif diff --git a/src/rendering/camera.cpp b/src/rendering/camera.cpp index bd1ebe0a..a169d9fc 100644 --- a/src/rendering/camera.cpp +++ b/src/rendering/camera.cpp @@ -48,7 +48,10 @@ glm::vec3 Camera::getUp() const { } void Camera::setJitter(float jx, float jy) { - // Remove old jitter, apply new + // Sub-pixel jitter for temporal anti-aliasing (TAA / FSR2). + // Column 2 of the projection matrix holds the NDC x/y offset — modifying + // [2][0] and [2][1] shifts the entire rendered image by a sub-pixel amount + // each frame, giving the upscaler different sample positions to reconstruct. projectionMatrix[2][0] -= jitterOffset.x; projectionMatrix[2][1] -= jitterOffset.y; jitterOffset = glm::vec2(jx, jy);