mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[7254] Cleanups and batter checking in homebind/bgEntryPoint code.
* Load homebind data early in Player::LoadFromDB and use instead initital race points in cases need some safe point if current coordinate broken by some reason. * Store BG entry point in to WorldLocation and simplify calls. * Set bg entry point at GM teleports to battleground for correct auto-recall position at battleground end.
This commit is contained in:
parent
e97c7ad9c5
commit
8af53064eb
8 changed files with 58 additions and 65 deletions
|
|
@ -14101,16 +14101,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
|
||||
m_class = fields[5].GetUInt8();
|
||||
|
||||
PlayerInfo const *info = objmgr.GetPlayerInfo(m_race, m_class);
|
||||
if(!info)
|
||||
{
|
||||
sLog.outError("Player have incorrect race/class pair. Can't be loaded.");
|
||||
delete result;
|
||||
// load home bind and check in same time class/race pair, it used later for restore broken positions
|
||||
if(!_LoadHomeBind(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND)))
|
||||
return false;
|
||||
}
|
||||
|
||||
InitPrimaryProffesions(); // to max set before any spell loaded
|
||||
|
||||
// init saved position, and fix it later if problematic
|
||||
uint32 transGUID = fields[24].GetUInt32();
|
||||
Relocate(fields[6].GetFloat(),fields[7].GetFloat(),fields[8].GetFloat(),fields[10].GetFloat());
|
||||
SetMapId(fields[9].GetUInt32());
|
||||
|
|
@ -14147,9 +14144,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
if(!IsPositionValid())
|
||||
{
|
||||
sLog.outError("ERROR: 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());
|
||||
|
||||
SetMapId(info->mapId);
|
||||
Relocate(info->positionX,info->positionY,info->positionZ,0.0f);
|
||||
RelocateToHomebind();
|
||||
|
||||
transGUID = 0;
|
||||
|
||||
|
|
@ -14159,24 +14154,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
m_movementInfo.t_o = 0.0f;
|
||||
}
|
||||
|
||||
// load the player's map here if it's not already loaded
|
||||
Map *map = GetMap();
|
||||
// since the player may not be bound to the map yet, make sure subsequent
|
||||
// getmap calls won't create new maps
|
||||
SetInstanceId(map->GetInstanceId());
|
||||
|
||||
// if the player is in an instance and it has been reset in the meantime teleport him to the entrance
|
||||
if(GetInstanceId() && !sInstanceSaveManager.GetInstanceSave(GetInstanceId()))
|
||||
{
|
||||
AreaTrigger const* at = objmgr.GetMapEntranceTrigger(GetMapId());
|
||||
if(at)
|
||||
Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
|
||||
else
|
||||
sLog.outError("Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no aretrigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), GetMapId());
|
||||
}
|
||||
|
||||
SaveRecallPosition();
|
||||
|
||||
if (transGUID != 0)
|
||||
{
|
||||
m_movementInfo.t_x = fields[20].GetFloat();
|
||||
|
|
@ -14194,8 +14171,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
guid,GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y,
|
||||
GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o);
|
||||
|
||||
SetMapId(info->mapId);
|
||||
Relocate(info->positionX,info->positionY,info->positionZ,0.0f);
|
||||
RelocateToHomebind();
|
||||
|
||||
m_movementInfo.t_x = 0.0f;
|
||||
m_movementInfo.t_y = 0.0f;
|
||||
|
|
@ -14224,8 +14200,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
sLog.outError("ERROR: Player (guidlow %d) have invalid transport guid (%u). Teleport to default race/class locations.",
|
||||
guid,transGUID);
|
||||
|
||||
SetMapId(info->mapId);
|
||||
Relocate(info->positionX,info->positionY,info->positionZ,0.0f);
|
||||
RelocateToHomebind();
|
||||
|
||||
m_movementInfo.t_x = 0.0f;
|
||||
m_movementInfo.t_y = 0.0f;
|
||||
|
|
@ -14236,6 +14211,26 @@ 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 = GetMap();
|
||||
|
||||
// since the player may not be bound to the map yet, make sure subsequent
|
||||
// getmap calls won't create new maps
|
||||
SetInstanceId(map->GetInstanceId());
|
||||
|
||||
// if the player is in an instance and it has been reset in the meantime teleport him to the entrance
|
||||
if(GetInstanceId() && !sInstanceSaveManager.GetInstanceSave(GetInstanceId()))
|
||||
{
|
||||
AreaTrigger const* at = objmgr.GetMapEntranceTrigger(GetMapId());
|
||||
if(at)
|
||||
Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
|
||||
else
|
||||
sLog.outError("Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no aretrigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), GetMapId());
|
||||
}
|
||||
|
||||
SaveRecallPosition();
|
||||
|
||||
time_t now = time(NULL);
|
||||
time_t logoutTime = time_t(fields[16].GetUInt64());
|
||||
|
||||
|
|
@ -14382,9 +14377,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
|
||||
m_social = sSocialMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSOCIALLIST), GetGUIDLow());
|
||||
|
||||
if(!_LoadHomeBind(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND)))
|
||||
return false;
|
||||
|
||||
// check PLAYER_CHOSEN_TITLE compatibility with PLAYER__FIELD_KNOWN_TITLES
|
||||
// note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded
|
||||
if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE))
|
||||
|
|
@ -14404,8 +14396,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
if(!nodeEntry) // don't know taxi start node, to homebind
|
||||
{
|
||||
sLog.outError("Character %u have wrong data in taxi destination list, teleport to homebind.",GetGUIDLow());
|
||||
SetMapId(m_homebindMapId);
|
||||
Relocate( m_homebindX, m_homebindY, m_homebindZ,0.0f);
|
||||
RelocateToHomebind();
|
||||
SaveRecallPosition(); // save as recall also to prevent recall and fall from sky
|
||||
}
|
||||
else // have start node, to it
|
||||
|
|
@ -15432,6 +15423,13 @@ void Player::ConvertInstancesToGroup(Player *player, Group *group, uint64 player
|
|||
|
||||
bool Player::_LoadHomeBind(QueryResult *result)
|
||||
{
|
||||
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass());
|
||||
if(!info)
|
||||
{
|
||||
sLog.outError("Player have incorrect race/class pair. Can't be loaded.");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(playerGuid));
|
||||
if (result)
|
||||
|
|
@ -15456,9 +15454,6 @@ bool Player::_LoadHomeBind(QueryResult *result)
|
|||
|
||||
if(!ok)
|
||||
{
|
||||
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass());
|
||||
if(!info) return false;
|
||||
|
||||
m_homebindMapId = info->mapId;
|
||||
m_homebindZoneId = info->zoneId;
|
||||
m_homebindX = info->positionX;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue