[8339] Improved storing/restoring BG entry point

* Introduced new table character_battleground_data
    * Entry point is now stored on BG enter event not join event
    * Entry point for dungeons is now correctly set to nearest graveyard
      (this prevent well known assert in GetInstance because of porting to already destroyed instance)
    * Teleporting from BG correctly restore mount state
    * Teleporting from BG correctly restore taxi flight
      (in multipath flight you will end up in nearest transition point on the route)

    Signed-off-by: ApoC <[email protected]>

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-12 20:27:00 -05:00
parent ed637fbf1f
commit 4f4775a31b
8 changed files with 344 additions and 196 deletions
+1 -1
View File
@@ -1071,7 +1071,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
plr->SetBGTeam(0);
if (Transport)
plr->TeleportTo(plr->GetBattleGroundEntryPoint());
plr->TeleportToBGEntryPoint();
sLog.outDetail("BATTLEGROUND: Removed player %s from BattleGround.", plr->GetName());
}
+3 -11
View File
@@ -164,9 +164,6 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId); // add to queue
// store entry point coords
member->SetBattleGroundEntryPoint(member->GetMapId(),member->GetPositionX(),member->GetPositionY(),member->GetPositionZ(),member->GetOrientation());
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType);
@@ -182,8 +179,6 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
{
// already checked if queueSlot is valid, now just get it
uint32 queueSlot = _player->AddBattleGroundQueueId(bgQueueTypeId);
// store entry point coords
_player->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
WorldPacket data;
// send status packet (in queue)
@@ -438,6 +433,9 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
case 1: // port to battleground
if (!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId))
return; // cheating?
_player->SetBattleGroundEntryPoint();
// resurrect the player
if (!_player->isAlive())
{
@@ -758,9 +756,6 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);// add to queue
// store entry point coords (same as leader entry point)
member->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
@@ -778,9 +773,6 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
{
uint32 queueSlot = _player->AddBattleGroundQueueId(bgQueueTypeId);
// store entry point coords
_player->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
+3 -49
View File
@@ -64,7 +64,7 @@ bool LoginQueryHolder::Initialize()
// NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure.
// !!! NOTE: including unused `zone`,`online`
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,instance_id,bgteam,bgmap,bgx,bgy,bgz,bgo FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,instance_id FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2 ,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
@@ -87,6 +87,7 @@ bool LoginQueryHolder::Initialize()
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS, "SELECT achievement, date FROM character_achievement WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS,"SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBGDATA, "SELECT instance_id, team, join_x, join_y, join_z, join_o, join_map, taxi_start, taxi_end, mount_spell FROM character_battleground_data WHERE guid = '%u'", GUID_LOPART(m_guid));
return res;
}
@@ -763,54 +764,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
pCurrChar->SetMovement(MOVE_WATER_WALK);
}
if(uint32 sourceNode = pCurrChar->m_taxi.GetTaxiSource())
{
sLog.outDebug( "WORLD: Restart character %u taxi flight", pCurrChar->GetGUIDLow() );
uint32 mountDisplayId = objmgr.GetTaxiMountDisplayId(sourceNode, pCurrChar->GetTeam(),true);
uint32 path = pCurrChar->m_taxi.GetCurrentTaxiPath();
// search appropriate start path node
uint32 startNode = 0;
TaxiPathNodeList const& nodeList = sTaxiPathNodesByPath[path];
float distPrev = MAP_SIZE*MAP_SIZE;
float distNext =
(nodeList[0].x-pCurrChar->GetPositionX())*(nodeList[0].x-pCurrChar->GetPositionX())+
(nodeList[0].y-pCurrChar->GetPositionY())*(nodeList[0].y-pCurrChar->GetPositionY())+
(nodeList[0].z-pCurrChar->GetPositionZ())*(nodeList[0].z-pCurrChar->GetPositionZ());
for(uint32 i = 1; i < nodeList.size(); ++i)
{
TaxiPathNode const& node = nodeList[i];
TaxiPathNode const& prevNode = nodeList[i-1];
// skip nodes at another map
if(node.mapid != pCurrChar->GetMapId())
continue;
distPrev = distNext;
distNext =
(node.x-pCurrChar->GetPositionX())*(node.x-pCurrChar->GetPositionX())+
(node.y-pCurrChar->GetPositionY())*(node.y-pCurrChar->GetPositionY())+
(node.z-pCurrChar->GetPositionZ())*(node.z-pCurrChar->GetPositionZ());
float distNodes =
(node.x-prevNode.x)*(node.x-prevNode.x)+
(node.y-prevNode.y)*(node.y-prevNode.y)+
(node.z-prevNode.z)*(node.z-prevNode.z);
if(distNext + distPrev < distNodes)
{
startNode = i;
break;
}
}
SendDoFlight( mountDisplayId, path, startNode );
}
pCurrChar->ContinueTaxiFlight();
// reset for all pets before pet loading
if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
+2 -2
View File
@@ -822,7 +822,7 @@ bool ChatHandler::HandleNamegoCommand(const char* args)
// when porting out from the bg, it will be reset to 0
target->SetBattleGroundId(m_session->GetPlayer()->GetBattleGroundId(), m_session->GetPlayer()->GetBattleGroundTypeId());
// remember current position as entry point for return at bg end teleportation
target->SetBattleGroundEntryPoint(target->GetMapId(),target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),target->GetOrientation());
target->SetBattleGroundEntryPoint();
}
else if (pMap->IsDungeon())
{
@@ -936,7 +936,7 @@ bool ChatHandler::HandleGonameCommand(const char* args)
// when porting out from the bg, it will be reset to 0
_player->SetBattleGroundId(target->GetBattleGroundId(), target->GetBattleGroundTypeId());
// remember current position as entry point for return at bg end teleportation
_player->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
_player->SetBattleGroundEntryPoint();
}
else if(cMap->IsDungeon())
{
+221 -94
View File
@@ -369,14 +369,11 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
m_DetectInvTimer = 1*IN_MILISECONDS;
m_bgBattleGroundID = 0;
m_bgTypeID = BATTLEGROUND_TYPE_NONE;
for (int j=0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; j++)
for (int j=0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; ++j)
{
m_bgBattleGroundQueueID[j].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
m_bgBattleGroundQueueID[j].invitedToInstance = 0;
}
m_bgTeam = 0;
m_logintime = time(NULL);
m_Last_tick = m_logintime;
@@ -459,7 +456,6 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
m_mover = this;
m_seer = this;
m_bgAfkReportedTimer = 0;
m_contestedPvPTimer = 0;
m_declinedname = NULL;
@@ -1879,6 +1875,13 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
return true;
}
bool Player::TeleportToBGEntryPoint()
{
ScheduleDelayedOperation(DELAYED_BG_MOUNT_RESTORE);
ScheduleDelayedOperation(DELAYED_BG_TAXI_RESTORE);
return TeleportTo(m_bgData.joinPos);
}
void Player::ProcessDelayedOperations()
{
if(m_DelayedOperations == 0)
@@ -1914,18 +1917,31 @@ void Player::ProcessDelayedOperations()
CastSpell(this, SPELL_ID_DESERTER, true); // Deserter
}
if (m_DelayedOperations & DELAYED_BG_MOUNT_RESTORE)
{
if (m_bgData.mountSpell)
{
CastSpell(this, m_bgData.mountSpell, true);
m_bgData.mountSpell = 0;
}
}
if (m_DelayedOperations & DELAYED_BG_TAXI_RESTORE)
{
if (m_bgData.HasTaxiPath())
{
m_taxi.AddTaxiDestination(m_bgData.taxiPath[0]);
m_taxi.AddTaxiDestination(m_bgData.taxiPath[1]);
m_bgData.ClearTaxiPath();
ContinueTaxiFlight();
}
}
//we have executed ALL delayed ops, so clear the flag
m_DelayedOperations = 0;
}
void Player::ScheduleDelayedOperation(uint32 operation)
{
if(operation >= DELAYED_END)
return;
m_DelayedOperations |= operation;
}
void Player::AddToWorld()
{
///- Do not add/remove the player from the object storage
@@ -14395,6 +14411,28 @@ void Player::_LoadEquipmentSets(QueryResult *result)
delete result;
}
void Player::_LoadBGData(QueryResult* result)
{
if (!result)
return;
// Expecting only one row
Field *fields = result->Fetch();
/* bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */
m_bgData.bgInstanceID = fields[0].GetUInt32();
m_bgData.bgTeam = fields[1].GetUInt32();
m_bgData.joinPos = WorldLocation(fields[6].GetUInt32(), // Map
fields[2].GetFloat(), // X
fields[3].GetFloat(), // Y
fields[4].GetFloat(), // Z
fields[5].GetFloat()); // Orientation
m_bgData.taxiPath[0] = fields[7].GetUInt32();
m_bgData.taxiPath[1] = fields[8].GetUInt32();
m_bgData.mountSpell = fields[9].GetUInt32();
delete result;
}
bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid)
{
QueryResult *result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'",GUID_LOPART(guid));
@@ -14497,8 +14535,8 @@ float Player::GetFloatValueFromDB(uint16 index, uint64 guid)
bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
{
//// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
//QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,bgid,bgteam,bgmap,bgx,bgy,bgz,bgo FROM characters WHERE guid = '%u'", guid);
//// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
//QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points FROM characters WHERE guid = '%u'", guid);
QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM);
if(!result)
@@ -14593,7 +14631,15 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
InitPrimaryProfessions(); // to max set before any spell loaded
// init saved position, and fix it later if problematic
uint32 transGUID = fields[31].GetUInt32();
Relocate(fields[13].GetFloat(),fields[14].GetFloat(),fields[15].GetFloat(),fields[17].GetFloat());
uint32 mapId = fields[16].GetUInt32();
uint32 instanceId = fields[41].GetFloat();
SetDifficulty(fields[39].GetUInt32()); // may be changed in _LoadGroup
std::string taxi_nodes = fields[38].GetCppString();
#define RelocateToHomebind() mapId = m_homebindMapId; instanceId = 0; Relocate(m_homebindX, m_homebindY, m_homebindZ)
_LoadGroup(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGROUP));
@@ -14622,52 +14668,31 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
}
_LoadBoundInstances(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES));
// load player map related values
uint32 transGUID = fields[31].GetUInt32();
Relocate(fields[13].GetFloat(),fields[14].GetFloat(),fields[15].GetFloat(),fields[17].GetFloat());
uint32 mapId = fields[16].GetUInt32();
uint32 instanceId = fields[41].GetFloat();
std::string taxi_nodes = fields[38].GetCppString();
_LoadBGData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBGDATA));
MapEntry const * mapEntry = sMapStore.LookupEntry(mapId);
if(!IsPositionValid())
{
sLog.outError("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());
RelocateToHomebind(mapId);
transGUID = 0;
instanceId = 0;
m_movementInfo.t_x = 0.0f;
m_movementInfo.t_y = 0.0f;
m_movementInfo.t_z = 0.0f;
m_movementInfo.t_o = 0.0f;
RelocateToHomebind();
}
// Player was saved in Arena or Bg
else if (mapEntry && mapEntry->IsBattleGroundOrArena())
{
// Get Entry Point(bg master) or Homebind
SetBattleGroundEntryPoint(fields[43].GetUInt32(),fields[44].GetFloat(),fields[45].GetFloat(),fields[46].GetFloat(),fields[47].GetFloat());
BattleGround *currentBg = NULL;
if(m_bgData.bgInstanceID) //saved in BattleGround
currentBg = sBattleGroundMgr.GetBattleGround(m_bgData.bgInstanceID, BATTLEGROUND_TYPE_NONE);
MapEntry const* bgEntry = sMapStore.LookupEntry(m_bgEntryPoint.mapid);
if(!bgEntry || bgEntry->Instanceable() || !MapManager::IsValidMapCoord(m_bgEntryPoint))
SetBattleGroundEntryPoint(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ,0.0f);
// Bg still exists - join it!
BattleGround *currentBg = sBattleGroundMgr.GetBattleGround(instanceId, BATTLEGROUND_TYPE_NONE);
if(currentBg && currentBg->IsPlayerInBattleGround(GetGUID()))
{
uint32 bgteam = fields[42].GetUInt32();
BattleGroundQueueTypeId bgQueueTypeId = sBattleGroundMgr.BGQueueTypeId(currentBg->GetTypeID(), currentBg->GetArenaType());
AddBattleGroundQueueId(bgQueueTypeId);
SetBattleGroundId(currentBg->GetInstanceID(), currentBg->GetTypeID());
SetBGTeam(bgteam);
m_bgData.bgTypeID = currentBg->GetTypeID();
//join player to battleground group
currentBg->EventPlayerLoggedIn(this, GetGUID());
currentBg->AddOrSetPlayerToCorrectBgGroup(this, GetGUID(), bgteam);
currentBg->AddOrSetPlayerToCorrectBgGroup(this, GetGUID(), m_bgData.bgTeam);
SetInviteForBattleGroundQueueType(bgQueueTypeId,currentBg->GetInstanceID());
}
@@ -14675,13 +14700,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
else
{
// Do not look for instance if bg not found
instanceId = 0;
const WorldLocation& _loc = GetBattleGroundEntryPoint();
mapId = _loc.mapid;
mapId = _loc.mapid; instanceId = 0;
Relocate(_loc.coord_x, _loc.coord_y, _loc.coord_z, _loc.orientation);
}
}
else if (transGUID != 0)
// currently we do not support transport in bg
else if (transGUID)
{
// There are no transports on instances
instanceId = 0;
@@ -14691,7 +14716,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
m_movementInfo.t_z = fields[29].GetFloat();
m_movementInfo.t_o = fields[30].GetFloat();
if( !Trinity::IsValidMapCoord(
if( !MaNGOS::IsValidMapCoord(
GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y,
GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o) ||
// transport size limited
@@ -14701,14 +14726,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);
RelocateToHomebind(mapId);
m_movementInfo.t_x = 0.0f;
m_movementInfo.t_y = 0.0f;
m_movementInfo.t_z = 0.0f;
m_movementInfo.t_o = 0.0f;
transGUID = 0;
RelocateToHomebind();
}
else
{
@@ -14727,23 +14745,22 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
sLog.outError("Player (guidlow %d) have problems with transport guid (%u). Teleport to default race/class locations.",
guid,transGUID);
RelocateToHomebind(mapId);
m_movementInfo.t_x = 0.0f;
m_movementInfo.t_y = 0.0f;
m_movementInfo.t_z = 0.0f;
m_movementInfo.t_o = 0.0f;
transGUID = 0;
RelocateToHomebind();
}
}
}
else if (!taxi_nodes.empty()) // Taxi Flight path loaded from db
// currently we do not support taxi in instance
else if (!taxi_nodes.empty())
{
// There are no flightpaths in instances
instanceId = 0;
if(!m_taxi.LoadTaxiDestinationsFromString(taxi_nodes,GetTeam()))
// Not finish taxi flight path
if(m_bgData.HasTaxiPath())
{
for (int i = 0; i < 2; ++i)
m_taxi.AddTaxiDestination(m_bgData.taxiPath[i]);
}
else if(!m_taxi.LoadTaxiDestinationsFromString(taxi_nodes,GetTeam()))
{
// problems with taxi path loading
TaxiNodesEntry const* nodeEntry = NULL;
@@ -14753,7 +14770,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());
RelocateToHomebind(mapId);
RelocateToHomebind();
}
else // have start node, to it
{
@@ -14761,26 +14778,28 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
mapId = nodeEntry->map_id;
Relocate(nodeEntry->x, nodeEntry->y, nodeEntry->z,0.0f);
}
m_taxi.ClearTaxiDestinations();
}
// Taxi path loading succesfull
else if(uint32 node_id = m_taxi.GetTaxiSource())
if(uint32 node_id = m_taxi.GetTaxiSource())
{
// save source node as recall coord to prevent recall and fall from sky
TaxiNodesEntry const* nodeEntry = sTaxiNodesStore.LookupEntry(node_id);
assert(nodeEntry); // checked in m_taxi.LoadTaxiDestinationsFromString
Relocate(nodeEntry->x,nodeEntry->y,nodeEntry->z,0);
mapId = nodeEntry->map_id;
Relocate(nodeEntry->x, nodeEntry->y, nodeEntry->z,0.0f);
// flight will started later
}
}
// Map could be changed before
mapEntry = sMapStore.LookupEntry(mapId);
// client without expansion support
if(GetSession()->Expansion() < mapEntry->Expansion())
{
sLog.outDebug("Player %s using client without required expansion tried login at non accessible map %u", GetName(), mapId);
RelocateToHomebind(mapId);
instanceId = 0;
RelocateToHomebind();
}
// fix crash (because of if(Map *map = _FindMap(instanceId)) in MapInstanced::CreateInstance)
@@ -14806,7 +14825,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
else
{
sLog.outError("Player (guidlow %d) is teleported to home (Map: %u X: %f Y: %f Z: %f O: %f).",guid,mapId,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation());
RelocateToHomebind(mapId);
RelocateToHomebind();
}
map = MapManager::Instance().CreateMap(mapId, this, 0);
@@ -14835,8 +14854,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
else
{
sLog.outError("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(), GetGUIDLow(), mapId);
RelocateToHomebind(mapId);
instanceId = 0;
RelocateToHomebind();
}
}
@@ -16116,7 +16134,7 @@ void Player::SaveToDB()
"taximask, online, cinematic, "
"totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, "
"trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, "
"death_expire_time, taxi_path, arena_pending_points, latency, bgid, bgteam, bgmap, bgx, bgy, bgz, bgo) VALUES ("
"death_expire_time, taxi_path, arena_pending_points, latency) VALUES ("
<< GetGUIDLow() << ", "
<< GetSession()->GetAccountId() << ", '"
<< sql_name << "', "
@@ -16198,14 +16216,7 @@ void Player::SaveToDB()
ss << m_taxi.SaveTaxiDestinationsToString() << "', ";
ss << "'0', "; // arena_pending_points
ss << GetSession()->GetLatency() << ", ";
ss << GetBattleGroundId() << ", ";
ss << GetBGTeam() << ", ";
ss << m_bgEntryPoint.mapid << ", "
<< finiteAlways(m_bgEntryPoint.coord_x) << ", "
<< finiteAlways(m_bgEntryPoint.coord_y) << ", "
<< finiteAlways(m_bgEntryPoint.coord_z) << ", "
<< finiteAlways(m_bgEntryPoint.orientation);
ss << GetSession()->GetLatency();
ss << ")";
CharacterDatabase.Execute( ss.str().c_str() );
@@ -16213,6 +16224,7 @@ void Player::SaveToDB()
if(m_mailsUpdated) //save mails only when needed
_SaveMail();
_SaveBGData();
_SaveInventory();
_SaveQuestStatus();
_SaveDailyQuestStatus();
@@ -16779,10 +16791,10 @@ void Player::SendResetInstanceFailed(uint32 reason, uint32 MapId)
///checks the 15 afk reports per 5 minutes limit
void Player::UpdateAfkReport(time_t currTime)
{
if(m_bgAfkReportedTimer <= currTime)
if(m_bgData.bgAfkReportedTimer <= currTime)
{
m_bgAfkReportedCount = 0;
m_bgAfkReportedTimer = currTime+5*MINUTE;
m_bgData.bgAfkReportedCount = 0;
m_bgData.bgAfkReportedTimer = currTime+5*MINUTE;
}
}
@@ -17768,6 +17780,59 @@ void Player::CleanupAfterTaxiFlight()
getHostilRefManager().setOnlineOfflineState(true);
}
void Player::ContinueTaxiFlight()
{
uint32 sourceNode = m_taxi.GetTaxiSource();
if (!sourceNode)
return;
sLog.outDebug( "WORLD: Restart character %u taxi flight", GetGUIDLow() );
uint32 mountDisplayId = objmgr.GetTaxiMountDisplayId(sourceNode, GetTeam(),true);
uint32 path = m_taxi.GetCurrentTaxiPath();
// search appropriate start path node
uint32 startNode = 0;
TaxiPathNodeList const& nodeList = sTaxiPathNodesByPath[path];
float distPrev = MAP_SIZE*MAP_SIZE;
float distNext =
(nodeList[0].x-GetPositionX())*(nodeList[0].x-GetPositionX())+
(nodeList[0].y-GetPositionY())*(nodeList[0].y-GetPositionY())+
(nodeList[0].z-GetPositionZ())*(nodeList[0].z-GetPositionZ());
for(uint32 i = 1; i < nodeList.size(); ++i)
{
TaxiPathNode const& node = nodeList[i];
TaxiPathNode const& prevNode = nodeList[i-1];
// skip nodes at another map
if(node.mapid != GetMapId())
continue;
distPrev = distNext;
distNext =
(node.x-GetPositionX())*(node.x-GetPositionX())+
(node.y-GetPositionY())*(node.y-GetPositionY())+
(node.z-GetPositionZ())*(node.z-GetPositionZ());
float distNodes =
(node.x-prevNode.x)*(node.x-prevNode.x)+
(node.y-prevNode.y)*(node.y-prevNode.y)+
(node.z-prevNode.z)*(node.z-prevNode.z);
if(distNext + distPrev < distNodes)
{
startNode = i;
break;
}
}
GetSession()->SendDoFlight(mountDisplayId, path, startNode);
}
void Player::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs )
{
// last check 2.0.10
@@ -18492,6 +18557,56 @@ void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply)
}
}
void Player::SetBattleGroundEntryPoint()
{
// Taxi path store
if (!m_taxi.empty())
{
m_bgData.mountSpell = 0;
m_bgData.taxiPath[0] = m_taxi.GetTaxiSource();
m_bgData.taxiPath[1] = m_taxi.GetTaxiDestination();
// On taxi we don't need check for dungeon
m_bgData.joinPos = WorldLocation(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
return;
}
else
{
m_bgData.ClearTaxiPath();
// Mount spell id storing
if (IsMounted())
{
AuraEffectList const& auras = GetAurasByType(SPELL_AURA_MOUNTED);
if (!auras.empty())
m_bgData.mountSpell = (*auras.begin())->GetId();
}
else
m_bgData.mountSpell = 0;
// If map is dungeon find linked graveyard
if(GetMap()->IsDungeon())
{
if (const WorldSafeLocsEntry* entry = objmgr.GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam()))
{
m_bgData.joinPos = WorldLocation(entry->map_id, entry->x, entry->y, entry->z, 0.0f);
return;
}
else
sLog.outError("SetBattleGroundEntryPoint: Dungeon map %u has no linked graveyard, setting home location as entry point.", GetMapId());
}
// If new entry point is not BG or arena set it
else if (!GetMap()->IsBattleGroundOrArena())
{
m_bgData.joinPos = WorldLocation(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
return;
}
}
// In error cases use homebind position
m_bgData.joinPos = WorldLocation(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, 0.0f);
}
void Player::LeaveBattleground(bool teleportToEntryPoint)
{
if(BattleGround *bg = GetBattleGround())
@@ -18528,9 +18643,9 @@ bool Player::CanJoinToBattleground() const
bool Player::CanReportAfkDueToLimit()
{
// a player can complain about 15 people per 5 minutes
if(m_bgAfkReportedCount >= 15)
if(m_bgData.bgAfkReportedCount++ >= 15)
return false;
++m_bgAfkReportedCount;
return true;
}
@@ -18542,15 +18657,15 @@ void Player::ReportedAfkBy(Player* reporter)
return;
// check if player has 'Idle' or 'Inactive' debuff
if(m_bgAfkReporter.find(reporter->GetGUIDLow())==m_bgAfkReporter.end() && !HasAura(43680) && !HasAura(43681) && reporter->CanReportAfkDueToLimit())
if(m_bgData.bgAfkReporter.find(reporter->GetGUIDLow())==m_bgData.bgAfkReporter.end() && !HasAura(43680) && !HasAura(43681) && reporter->CanReportAfkDueToLimit())
{
m_bgAfkReporter.insert(reporter->GetGUIDLow());
m_bgData.bgAfkReporter.insert(reporter->GetGUIDLow());
// 3 players have to complain to apply debuff
if(m_bgAfkReporter.size() >= 3)
if(m_bgData.bgAfkReporter.size() >= 3)
{
// cast 'Idle' spell
CastSpell(this, 43680, true);
m_bgAfkReporter.clear();
m_bgData.bgAfkReporter.clear();
}
}
}
@@ -19308,7 +19423,7 @@ BattleGround* Player::GetBattleGround() const
if(GetBattleGroundId()==0)
return NULL;
return sBattleGroundMgr.GetBattleGround(GetBattleGroundId(), m_bgTypeID);
return sBattleGroundMgr.GetBattleGround(GetBattleGroundId(), m_bgData.bgTypeID);
}
bool Player::InArena() const
@@ -21334,6 +21449,18 @@ void Player::_SaveEquipmentSets()
}
}
void Player::_SaveBGData()
{
CharacterDatabase.PExecute("DELETE FROM character_battleground_data WHERE guid='%u'", GetGUIDLow());
if (m_bgData.bgInstanceID)
{
/* guid, bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */
CharacterDatabase.PExecute("INSERT INTO character_battleground_data VALUES ('%u', '%u', '%u', '%f', '%f', '%f', '%f', '%u', '%u', '%u', '%u')",
GetGUIDLow(), m_bgData.bgInstanceID, m_bgData.bgTeam, m_bgData.joinPos.coord_x, m_bgData.joinPos.coord_y, m_bgData.joinPos.coord_z,
m_bgData.joinPos.orientation, m_bgData.joinPos.mapid, m_bgData.taxiPath[0], m_bgData.taxiPath[1], m_bgData.mountSpell);
}
}
void Player::DeleteEquipmentSet(uint64 setGuid)
{
for(EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr)
+61 -31
View File
@@ -789,14 +789,17 @@ enum PlayerLoginQueryIndex
PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS = 18,
PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS = 19,
PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS = 20,
MAX_PLAYER_LOGIN_QUERY = 21
PLAYER_LOGIN_QUERY_LOADBGDATA = 21,
MAX_PLAYER_LOGIN_QUERY = 22
};
enum PlayerDelayedOperations
{
DELAYED_SAVE_PLAYER = 1,
DELAYED_RESURRECT_PLAYER = 2,
DELAYED_SPELL_CAST_DESERTER = 4,
DELAYED_SAVE_PLAYER = 0x01,
DELAYED_RESURRECT_PLAYER = 0x02,
DELAYED_SPELL_CAST_DESERTER = 0x04,
DELAYED_BG_MOUNT_RESTORE = 0x08, ///< Flag to restore mount state after teleport from BG
DELAYED_BG_TAXI_RESTORE = 0x10, ///< Flag to restore taxi state after teleport from BG
DELAYED_END
};
@@ -882,7 +885,36 @@ class TRINITY_DLL_SPEC PlayerTaxi
std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
class TRINITY_DLL_SPEC Player : public Unit
class Player;
/// Holder for BattleGround data
struct BGData
{
BGData() : bgInstanceID(0), bgTypeID(BATTLEGROUND_TYPE_NONE), bgAfkReportedCount(0), bgAfkReportedTimer(0),
bgTeam(0), mountSpell(0) { ClearTaxiPath(); }
uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID,
/// when player is teleported to BG - (it is battleground's GUID)
BattleGroundTypeId bgTypeID;
std::set<uint32> bgAfkReporter;
uint8 bgAfkReportedCount;
time_t bgAfkReportedTimer;
uint32 bgTeam; ///< What side the player will be added to
uint32 mountSpell;
uint32 taxiPath[2];
WorldLocation joinPos; ///< From where player entered BG
void ClearTaxiPath() { taxiPath[0] = taxiPath[1] = 0; }
bool HasTaxiPath() const { return taxiPath[0] && taxiPath[1]; }
};
class MANGOS_DLL_SPEC Player : public Unit
{
friend class WorldSession;
friend void Item::AddToUpdateQueueOf(Player *player);
@@ -907,6 +939,8 @@ class TRINITY_DLL_SPEC Player : public Unit
return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation, options);
}
bool TeleportToBGEntryPoint();
void SetSummonPoint(uint32 mapid, float x, float y, float z)
{
m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
@@ -954,6 +988,7 @@ class TRINITY_DLL_SPEC Player : public Unit
bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = NULL, uint32 spellid = 0);
bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0);
void CleanupAfterTaxiFlight();
void ContinueTaxiFlight();
// mount_id can be used in scripting calls
bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
@@ -1855,10 +1890,10 @@ class TRINITY_DLL_SPEC Player : public Unit
/*** BATTLEGROUND SYSTEM ***/
/*********************************************************/
bool InBattleGround() const { return m_bgBattleGroundID != 0; }
bool InBattleGround() const { return m_bgData.bgInstanceID != 0; }
bool InArena() const;
uint32 GetBattleGroundId() const { return m_bgBattleGroundID; }
BattleGroundTypeId GetBattleGroundTypeId() const { return m_bgTypeID; }
uint32 GetBattleGroundId() const { return m_bgData.bgInstanceID; }
BattleGroundTypeId GetBattleGroundTypeId() const { return m_bgData.bgTypeID; }
BattleGround* GetBattleGround() const;
@@ -1894,8 +1929,8 @@ class TRINITY_DLL_SPEC Player : public Unit
void SetBattleGroundId(uint32 val, BattleGroundTypeId bgTypeId)
{
m_bgBattleGroundID = val;
m_bgTypeID = bgTypeId;
m_bgData.bgInstanceID = val;
m_bgData.bgTypeID = bgTypeId;
}
uint32 AddBattleGroundQueueId(BattleGroundQueueTypeId val)
{
@@ -1942,20 +1977,17 @@ class TRINITY_DLL_SPEC Player : public Unit
return true;
return false;
}
WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgEntryPoint; }
void SetBattleGroundEntryPoint(uint32 Map, float PosX, float PosY, float PosZ, float PosO )
{
m_bgEntryPoint = WorldLocation(Map,PosX,PosY,PosZ,PosO);
}
WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; }
void SetBattleGroundEntryPoint();
void SetBGTeam(uint32 team) { m_bgTeam = team; }
uint32 GetBGTeam() const { return m_bgTeam ? m_bgTeam : GetTeam(); }
void SetBGTeam(uint32 team) { m_bgData.bgTeam = team; }
uint32 GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); }
void LeaveBattleground(bool teleportToEntryPoint = true);
bool CanJoinToBattleground() const;
bool CanReportAfkDueToLimit();
void ReportedAfkBy(Player* reporter);
void ClearAfkReports() { m_bgAfkReporter.clear(); }
void ClearAfkReports() { m_bgData.bgAfkReporter.clear(); }
bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const;
bool isTotalImmunity();
@@ -2035,7 +2067,6 @@ class TRINITY_DLL_SPEC Player : public Unit
float m_homebindX;
float m_homebindY;
float m_homebindZ;
void RelocateToHomebind(uint32 & newMap) { newMap = m_homebindMapId; Relocate(m_homebindX,m_homebindY,m_homebindZ); }
// currently visible objects at player client
typedef std::set<uint64> ClientGUIDs;
@@ -2158,13 +2189,12 @@ class TRINITY_DLL_SPEC Player : public Unit
bool canSeeSpellClickOn(Creature const* creature) const;
protected:
uint32 m_contestedPvPTimer;
/*********************************************************/
/*** BATTLEGROUND SYSTEM ***/
/*********************************************************/
/* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
uint32 m_bgBattleGroundID;
BattleGroundTypeId m_bgTypeID;
/*
this is an array of BG queues (BgTypeIDs) in which is player
*/
@@ -2173,15 +2203,9 @@ class TRINITY_DLL_SPEC Player : public Unit
BattleGroundQueueTypeId bgQueueTypeId;
uint32 invitedToInstance;
};
BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES];
WorldLocation m_bgEntryPoint;
std::set<uint32> m_bgAfkReporter;
uint8 m_bgAfkReportedCount;
time_t m_bgAfkReportedTimer;
uint32 m_contestedPvPTimer;
uint32 m_bgTeam; // what side the player will be added to
BGData m_bgData;
/*********************************************************/
/*** QUEST SYSTEM ***/
@@ -2214,6 +2238,7 @@ class TRINITY_DLL_SPEC Player : public Unit
void _LoadDeclinedNames(QueryResult *result);
void _LoadArenaTeamInfo(QueryResult *result);
void _LoadEquipmentSets(QueryResult *result);
void _LoadBGData(QueryResult* result);
/*********************************************************/
/*** SAVE SYSTEM ***/
@@ -2227,6 +2252,7 @@ class TRINITY_DLL_SPEC Player : public Unit
void _SaveDailyQuestStatus();
void _SaveSpells();
void _SaveEquipmentSets();
void _SaveBGData();
void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
@@ -2389,7 +2415,11 @@ class TRINITY_DLL_SPEC Player : public Unit
bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; }
void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; }
void ScheduleDelayedOperation(uint32 operation);
void ScheduleDelayedOperation(uint32 operation)
{
if(operation < DELAYED_END)
m_DelayedOperations |= operation;
}
GridReference<Player> m_gridRef;
MapReference m_mapRef;