terrain: pre-load bind point tiles during Hearthstone cast

When the player starts casting Hearthstone (spell IDs 6948/8690),
trigger background terrain loading at the bind point so tiles are
ready when the teleport fires.

- Add HearthstonePreloadCallback to GameHandler, called from
  handleSpellStart when a Hearthstone cast begins.
- Application callback enqueues a 5×5 tile grid around the bind
  point via precacheTiles() (same-map) or starts a file-cache warm
  via startWorldPreload() (cross-map) during the ~10 s cast time.
- On same-map teleport arrival, call processAllReadyTiles() to
  GPU-upload any tiles that finished parsing during the cast before
  the first frame at the new position.

Fixes: player landing in unloaded terrain and falling after Hearthstone.
This commit is contained in:
Kelsi 2026-03-09 21:57:42 -07:00
parent 0a6f88e8ad
commit 8f0d2cc4ab
3 changed files with 64 additions and 0 deletions

View file

@ -610,6 +610,12 @@ public:
using BindPointCallback = std::function<void(uint32_t mapId, float x, float y, float z)>;
void setBindPointCallback(BindPointCallback cb) { bindPointCallback_ = std::move(cb); }
// Called when the player starts casting Hearthstone so terrain at the bind
// point can be pre-loaded during the cast time.
// Parameters: mapId and canonical (x, y, z) of the bind location.
using HearthstonePreloadCallback = std::function<void(uint32_t mapId, float x, float y, float z)>;
void setHearthstonePreloadCallback(HearthstonePreloadCallback cb) { hearthstonePreloadCallback_ = std::move(cb); }
// Creature spawn callback (online mode - triggered when creature enters view)
// Parameters: guid, displayId, x, y, z (canonical), orientation
using CreatureSpawnCallback = std::function<void(uint64_t guid, uint32_t displayId, float x, float y, float z, float orientation)>;
@ -1683,6 +1689,7 @@ private:
UnstuckCallback unstuckGyCallback_;
UnstuckCallback unstuckHearthCallback_;
BindPointCallback bindPointCallback_;
HearthstonePreloadCallback hearthstonePreloadCallback_;
CreatureSpawnCallback creatureSpawnCallback_;
CreatureDespawnCallback creatureDespawnCallback_;
PlayerSpawnCallback playerSpawnCallback_;