mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
game: fix NPCs not spawning on reconnect to same map
On disconnect/reconnect to the same map, entityManager was not cleared and creatureInstances_ still held old entries from the previous session. When the server re-sent CREATE_OBJECT for the same GUIDs, the spawn callback's early-return guard (creatureInstances_.count(guid)) silently dropped every NPC re-spawn, leaving the world empty. Fixes: - disconnect() now calls entityManager.clear() to purge stale entities - WorldEntryCallback gains a bool isInitialEntry parameter (true on first login or reconnect, false on in-world teleport/flight landing) - Same-map optimization path skipped when isInitialEntry=true, so loadOnlineWorldTerrain runs its full cleanup and properly despawns old creature/player instances before the server refreshes them
This commit is contained in:
parent
baab997da8
commit
54246345bb
3 changed files with 13 additions and 8 deletions
|
|
@ -499,6 +499,8 @@ void GameHandler::disconnect() {
|
|||
wardenModuleSize_ = 0;
|
||||
wardenModuleData_.clear();
|
||||
wardenLoadedModule_.reset();
|
||||
// Clear entity state so reconnect sees fresh CREATE_OBJECT for all visible objects.
|
||||
entityManager.clear();
|
||||
setState(WorldState::DISCONNECTED);
|
||||
LOG_INFO("Disconnected from world server");
|
||||
}
|
||||
|
|
@ -6074,7 +6076,7 @@ void GameHandler::handleLoginVerifyWorld(network::Packet& packet) {
|
|||
|
||||
// Notify application to load terrain for this map/position (online mode)
|
||||
if (worldEntryCallback_) {
|
||||
worldEntryCallback_(data.mapId, data.x, data.y, data.z);
|
||||
worldEntryCallback_(data.mapId, data.x, data.y, data.z, initialWorldEntry);
|
||||
}
|
||||
|
||||
// Auto-join default chat channels
|
||||
|
|
@ -15582,7 +15584,7 @@ void GameHandler::handleTeleportAck(network::Packet& packet) {
|
|||
// Notify application of teleport — the callback decides whether to do
|
||||
// a full world reload (map change) or just update position (same map).
|
||||
if (worldEntryCallback_) {
|
||||
worldEntryCallback_(currentMapId_, serverX, serverY, serverZ);
|
||||
worldEntryCallback_(currentMapId_, serverX, serverY, serverZ, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -15689,7 +15691,7 @@ void GameHandler::handleNewWorld(network::Packet& packet) {
|
|||
|
||||
// Reload terrain at new position
|
||||
if (worldEntryCallback_) {
|
||||
worldEntryCallback_(mapId, serverX, serverY, serverZ);
|
||||
worldEntryCallback_(mapId, serverX, serverY, serverZ, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue