diff options
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 934acc223b0..c96861d9ef4 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -17346,49 +17346,56 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) // NOW player must have valid map // load the player's map here if it's not already loaded Map* map = sMapMgr->CreateMap(mapId, this); - + AreaTrigger const* areaTrigger = NULL; + bool check = false; + if (!map) { - instanceId = 0; - AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(mapId); - if (at) + areaTrigger = sObjectMgr->GetGoBackTrigger(mapId); + check = true; + } + else if (map->IsDungeon()) // if map is dungeon... + { + if (!((InstanceMap*)map)->CanEnter(this)) // ... and can't enter map, then look for entry point. { - TC_LOG_ERROR("entities.player", "Player (guidlow %d) is teleported to gobacktrigger (Map: %u X: %f Y: %f Z: %f O: %f).", guid, mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - Relocate(at->target_X, at->target_Y, at->target_Z, GetOrientation()); - mapId = at->target_mapId; + areaTrigger = sObjectMgr->GetGoBackTrigger(mapId); + check = true; } - else + else if (instanceId && !sInstanceSaveMgr->GetInstanceSave(instanceId)) // ... and instance is reseted then look for entrance. { - TC_LOG_ERROR("entities.player", "Player (guidlow %d) is teleported to home (Map: %u X: %f Y: %f Z: %f O: %f).", guid, mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - RelocateToHomebind(); + areaTrigger = sObjectMgr->GetMapEntranceTrigger(mapId); + check = true; } - - map = sMapMgr->CreateMap(mapId, this); - if (!map) + } + + if (check) // in case of special event when creating map... + { + if (areaTrigger) // ... if we have an areatrigger, then relocate to new map/coordinates. { - PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); - mapId = info->mapId; - Relocate(info->positionX, info->positionY, info->positionZ, 0.0f); - TC_LOG_ERROR("entities.player", "Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", guid, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - map = sMapMgr->CreateMap(mapId, this); - if (!map) + Relocate(areaTrigger->target_X, areaTrigger->target_Y, areaTrigger->target_Z, GetOrientation()); + if (mapId != areaTrigger->target_mapId) { - TC_LOG_ERROR("entities.player", "Player (guidlow %d) has invalid default map coordinates (X: %f Y: %f Z: %f O: %f). or instance couldn't be created", guid, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - return false; + mapId = areaTrigger->target_mapId; + map = sMapMgr->CreateMap(mapId, this); } } + else + { + TC_LOG_ERROR("entities.player", "Player %s (guid: %d) Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.", m_name, guid, mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + map = NULL; + } } - - // if the player is in an instance and it has been reset in the meantime teleport him to the entrance - if (instanceId && !sInstanceSaveMgr->GetInstanceSave(instanceId) && !map->IsBattlegroundOrArena()) + + if (!map) { - AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(mapId); - if (at) - Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation); - else + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); + mapId = info->mapId; + Relocate(info->positionX, info->positionY, info->positionZ, 0.0f); + map = sMapMgr->CreateMap(mapId, this); + if (!map) { - TC_LOG_ERROR("entities.player", "Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no area-trigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName().c_str(), GetGUIDLow(), mapId); - RelocateToHomebind(); + TC_LOG_ERROR("entities.player", "Player %s (guid: %d) Map: %u, X: %f, Y: %f, Z: %f, O: %f. Invalid default map coordinates or instance couldn't be created.", m_name, guid, mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + return false; } } |