fix: hearthstone from action bar, far teleport loading screen

Action bar hearthstone: the slot was type SPELL (spell 8690) not ITEM.
castSpell sends CMSG_CAST_SPELL which the server rejects for item-use
spells. Now detects item-use spells via getItemIdForSpell() and routes
through useItemById() instead, sending CMSG_USE_ITEM correctly.

Far same-map teleport: hearthstone on the same continent (e.g., Westfall
→ Stormwind on Azeroth) skipped the loading screen, so the player fell
through unloaded terrain. Now triggers a full world reload with loading
screen for teleports > 500 units, with the warmup ground check ensuring
WMO floors are loaded before spawning.
This commit is contained in:
Kelsi 2026-03-28 14:55:58 -07:00
parent 4e709692f1
commit 11571c582b
4 changed files with 54 additions and 6 deletions

View file

@ -8556,6 +8556,34 @@ void GameHandler::useItemById(uint32_t itemId) {
if (inventoryHandler_) inventoryHandler_->useItemById(itemId);
}
uint32_t GameHandler::getItemIdForSpell(uint32_t spellId) const {
if (spellId == 0) return 0;
// Search backpack and bags for an item whose on-use spell matches
for (int i = 0; i < inventory.getBackpackSize(); i++) {
const auto& slot = inventory.getBackpackSlot(i);
if (slot.empty()) continue;
auto* info = getItemInfo(slot.item.itemId);
if (!info || !info->valid) continue;
for (const auto& sp : info->spells) {
if (sp.spellId == spellId && (sp.spellTrigger == 0 || sp.spellTrigger == 5))
return slot.item.itemId;
}
}
for (int bag = 0; bag < inventory.NUM_BAG_SLOTS; bag++) {
for (int s = 0; s < inventory.getBagSize(bag); s++) {
const auto& slot = inventory.getBagSlot(bag, s);
if (slot.empty()) continue;
auto* info = getItemInfo(slot.item.itemId);
if (!info || !info->valid) continue;
for (const auto& sp : info->spells) {
if (sp.spellId == spellId && (sp.spellTrigger == 0 || sp.spellTrigger == 5))
return slot.item.itemId;
}
}
}
return 0;
}
void GameHandler::unstuck() {
if (unstuckCallback_) {
unstuckCallback_();