From 180b78d106717b47bb331306bdab08e249b3a751 Mon Sep 17 00:00:00 2001 From: kelsi davis Date: Sat, 7 Feb 2026 00:00:06 -0800 Subject: [PATCH] Fix compilation errors from single-player removal - Fixed corrupted header (removed orphaned code fragment) - Restored NPC callbacks needed for online animations - NpcDeathCallback, NpcRespawnCallback, NpcSwingCallback - These were incorrectly removed as "SP-only" but are used for animations in online mode - Removed calls to deleted methods: - getItemTemplateName, getItemTemplateQuality (used fallback in loot window) - notifyInventoryChanged, notifyEquipmentChanged (SP persistence markers) - Removed hearthstone single-player handling (now uses server) All online features preserved. Code should now compile. --- include/game/game_handler.hpp | 19 ++++++++++++++++--- src/game/game_handler.cpp | 9 +-------- src/ui/game_screen.cpp | 14 +------------- src/ui/inventory_screen.cpp | 3 --- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index 755378db..3d0a689d 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -236,13 +236,23 @@ public: const std::vector& getPlayerAuras() const { return playerAuras; } const std::vector& getTargetAuras() const { return targetAuras; } + // NPC death callback (for animations) + using NpcDeathCallback = std::function; + void setNpcDeathCallback(NpcDeathCallback cb) { npcDeathCallback_ = std::move(cb); } + + // NPC respawn callback (health 0 → >0, resets animation to idle) + using NpcRespawnCallback = std::function; + void setNpcRespawnCallback(NpcRespawnCallback cb) { npcRespawnCallback_ = std::move(cb); } + // Melee swing callback (for driving animation/SFX) using MeleeSwingCallback = std::function; void setMeleeSwingCallback(MeleeSwingCallback cb) { meleeSwingCallback_ = std::move(cb); } - playerXp_ = 0; - } - // XP tracking (works in both single-player and server modes) + // NPC swing callback (plays attack animation on NPC) + using NpcSwingCallback = std::function; + void setNpcSwingCallback(NpcSwingCallback cb) { npcSwingCallback_ = std::move(cb); } + + // XP tracking uint32_t getPlayerXp() const { return playerXp_; } uint32_t getPlayerNextLevelXp() const { return playerNextLevelXp_; } uint32_t getPlayerLevel() const { return serverPlayerLevel_; } @@ -671,7 +681,10 @@ private: uint32_t serverPlayerLevel_ = 1; static uint32_t xpForLevel(uint32_t level); + NpcDeathCallback npcDeathCallback_; + NpcRespawnCallback npcRespawnCallback_; MeleeSwingCallback meleeSwingCallback_; + NpcSwingCallback npcSwingCallback_; bool playerDead_ = false; }; diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 75dce835..26401ff5 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -2051,14 +2051,7 @@ void GameHandler::handleSpellHealLog(network::Packet& packet) { // ============================================================ void GameHandler::castSpell(uint32_t spellId, uint64_t targetGuid) { - // Hearthstone (8690) — handle locally when no server connection (single-player) - if (spellId == 8690 && hearthstoneCallback) { - LOG_INFO("Hearthstone: teleporting home"); - hearthstoneCallback(); - return; - } - - // Attack (6603) routes to auto-attack instead of cast (works without server) + // Attack (6603) routes to auto-attack instead of cast if (spellId == 6603) { uint64_t target = targetGuid != 0 ? targetGuid : this->targetGuid; if (target != 0) { diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index e686b79f..13012c9e 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -154,15 +154,10 @@ void GameScreen::render(game::GameHandler& gameHandler) { // Character screen (C key toggle handled inside render()) inventoryScreen.renderCharacterScreen(gameHandler); - if (inventoryScreen.consumeInventoryDirty()) { - gameHandler.notifyInventoryChanged(); - } - if (inventoryScreen.consumeEquipmentDirty() || gameHandler.consumeOnlineEquipmentDirty()) { updateCharacterGeosets(gameHandler.getInventory()); updateCharacterTextures(gameHandler.getInventory()); core::Application::getInstance().loadEquippedWeapons(); - gameHandler.notifyEquipmentChanged(); inventoryScreen.markPreviewDirty(); // Update renderer weapon type for animation selection auto* r = core::Application::getInstance().getRenderer(); @@ -2017,14 +2012,7 @@ void GameScreen::renderLootWindow(game::GameHandler& gameHandler) { itemName = info->name; quality = static_cast(info->quality); } else { - // Fallback: look up name from item template DB (single-player) - auto tplName = gameHandler.getItemTemplateName(item.itemId); - if (!tplName.empty()) { - itemName = tplName; - quality = gameHandler.getItemTemplateQuality(item.itemId); - } else { - itemName = "Item #" + std::to_string(item.itemId); - } + itemName = "Item #" + std::to_string(item.itemId); } ImVec4 qColor = InventoryScreen::getQualityColor(quality); diff --git a/src/ui/inventory_screen.cpp b/src/ui/inventory_screen.cpp index b147eeb7..4beb8c64 100644 --- a/src/ui/inventory_screen.cpp +++ b/src/ui/inventory_screen.cpp @@ -628,9 +628,6 @@ void InventoryScreen::render(game::Inventory& inventory, uint64_t moneyCopper) { heldItem = game::ItemDef{}; heldSource = HeldSource::NONE; inventoryDirty = true; - if (gameHandler_) { - gameHandler_->notifyInventoryChanged(); - } dropItemName_.clear(); ImGui::CloseCurrentPopup(); }