mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-25 16:30:15 +00:00
Refactor instance loading: extract initializeRenderers, fix deferred state transition
- Extract initializeRenderers() from loadTestTerrain() so WMO-only maps (dungeons/raids) initialize renderers directly without a dummy ADT path - Defer setState(IN_GAME) until after processing any pending deferred world entry, preventing brief IN_GAME flicker on the wrong map - Remove verbose area trigger debug logging (every-second position spam)
This commit is contained in:
parent
48eb0b70a3
commit
3c55b09a3f
4 changed files with 80 additions and 88 deletions
|
|
@ -3430,19 +3430,14 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
|||
// Initialize renderers if they don't exist yet (first login to a WMO-only map).
|
||||
// On map change, renderers already exist from the previous map.
|
||||
if (!renderer->getWMORenderer() || !renderer->getTerrainManager()) {
|
||||
auto [tileX, tileY] = core::coords::canonicalToTile(spawnCanonical.x, spawnCanonical.y);
|
||||
std::string dummyAdtPath = "World\\Maps\\" + mapName + "\\" + mapName + "_" +
|
||||
std::to_string(tileX) + "_" + std::to_string(tileY) + ".adt";
|
||||
LOG_WARNING("WMO-only: calling loadTestTerrain to create renderers");
|
||||
renderer->loadTestTerrain(assetManager.get(), dummyAdtPath);
|
||||
renderer->initializeRenderers(assetManager.get(), mapName);
|
||||
}
|
||||
|
||||
// Set map name on WMO and terrain renderers
|
||||
// Set map name on WMO renderer and disable terrain streaming (no ADT tiles for instances)
|
||||
if (renderer->getWMORenderer()) {
|
||||
renderer->getWMORenderer()->setMapName(mapName);
|
||||
}
|
||||
if (renderer->getTerrainManager()) {
|
||||
renderer->getTerrainManager()->setMapName(mapName);
|
||||
renderer->getTerrainManager()->setStreamingEnabled(false);
|
||||
}
|
||||
|
||||
|
|
@ -3635,14 +3630,10 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
|||
LOG_INFO("Online world terrain loading initiated");
|
||||
}
|
||||
|
||||
// Set map name on the newly-created WMO/terrain renderers
|
||||
// (loadTestTerrain creates them, so the earlier setMapName at line ~3296 was a no-op)
|
||||
// Set map name on WMO renderer (initializeRenderers handles terrain/minimap/worldMap)
|
||||
if (renderer->getWMORenderer()) {
|
||||
renderer->getWMORenderer()->setMapName(mapName);
|
||||
}
|
||||
if (renderer->getTerrainManager()) {
|
||||
renderer->getTerrainManager()->setMapName(mapName);
|
||||
}
|
||||
|
||||
// Character renderer is created inside loadTestTerrain(), so spawn the
|
||||
// player model now that the renderer actually exists.
|
||||
|
|
@ -3873,9 +3864,6 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
|||
// Track which map we actually loaded (used by same-map teleport check).
|
||||
loadedMapId_ = mapId;
|
||||
|
||||
// Set game state
|
||||
setState(AppState::IN_GAME);
|
||||
|
||||
// Clear loading flag and process any deferred world entry.
|
||||
// A deferred entry occurs when SMSG_NEW_WORLD arrived during our warmup
|
||||
// (e.g., an area trigger in a dungeon immediately teleporting the player out).
|
||||
|
|
@ -3887,9 +3875,13 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
|||
worldEntryMovementGraceTimer_ = 2.0f;
|
||||
taxiLandingClampTimer_ = 0.0f;
|
||||
lastTaxiFlight_ = false;
|
||||
// Recursive call — sets loadedMapId_ to entry.mapId inside.
|
||||
// Recursive call — sets loadedMapId_ and IN_GAME state for the final map.
|
||||
loadOnlineWorldTerrain(entry.mapId, entry.x, entry.y, entry.z);
|
||||
return; // The recursive call handles setState(IN_GAME).
|
||||
}
|
||||
|
||||
// Only enter IN_GAME when this is the final map (no deferred entry pending).
|
||||
setState(AppState::IN_GAME);
|
||||
}
|
||||
|
||||
void Application::buildCreatureDisplayLookups() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue