mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[6955] Introduce new function Player::LeaveAllArenaTeams and use it on player delete.
Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
parent
c92d146391
commit
b17b4c9fd8
4 changed files with 37 additions and 47 deletions
|
|
@ -171,7 +171,7 @@ void WorldSession::HandleArenaTeamInviteAcceptOpcode(WorldPacket & /*recv_data*/
|
|||
if(!at)
|
||||
return;
|
||||
|
||||
if(_player->GetArenaTeamIdFromDB(_player->GetGUIDLow(), at->GetType()))
|
||||
if(_player->GetArenaTeamId(at->GetType()))
|
||||
{
|
||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,"","",ERR_ALREADY_IN_ARENA_TEAM); // already in arena team that size
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -3521,27 +3521,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
|||
}
|
||||
|
||||
// remove from arena teams
|
||||
uint32 at_id = GetArenaTeamIdFromDB(playerguid,ARENA_TEAM_2v2);
|
||||
if(at_id != 0)
|
||||
{
|
||||
ArenaTeam * at = objmgr.GetArenaTeamById(at_id);
|
||||
if(at)
|
||||
at->DelMember(playerguid);
|
||||
}
|
||||
at_id = GetArenaTeamIdFromDB(playerguid,ARENA_TEAM_3v3);
|
||||
if(at_id != 0)
|
||||
{
|
||||
ArenaTeam * at = objmgr.GetArenaTeamById(at_id);
|
||||
if(at)
|
||||
at->DelMember(playerguid);
|
||||
}
|
||||
at_id = GetArenaTeamIdFromDB(playerguid,ARENA_TEAM_5v5);
|
||||
if(at_id != 0)
|
||||
{
|
||||
ArenaTeam * at = objmgr.GetArenaTeamById(at_id);
|
||||
if(at)
|
||||
at->DelMember(playerguid);
|
||||
}
|
||||
LeaveAllArenaTeams(playerguid);
|
||||
|
||||
// the player was uninvited already on logout so just remove from group
|
||||
QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", guid);
|
||||
|
|
@ -6144,24 +6124,18 @@ void Player::ModifyArenaPoints( int32 value )
|
|||
|
||||
uint32 Player::GetGuildIdFromDB(uint64 guid)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss<<"SELECT guildid FROM guild_member WHERE guid='"<<guid<<"'";
|
||||
QueryResult *result = CharacterDatabase.Query( ss.str().c_str() );
|
||||
if( result )
|
||||
{
|
||||
uint32 v = result->Fetch()[0].GetUInt32();
|
||||
delete result;
|
||||
return v;
|
||||
}
|
||||
else
|
||||
QueryResult* result = CharacterDatabase.PQuery("SELECT guildid FROM guild_member WHERE guid='%u'", GUID_LOPART(guid));
|
||||
if(!result)
|
||||
return 0;
|
||||
|
||||
uint32 id = result->Fetch()[0].GetUInt32();
|
||||
delete result;
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32 Player::GetRankFromDB(uint64 guid)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss<<"SELECT rank FROM guild_member WHERE guid='"<<guid<<"'";
|
||||
QueryResult *result = CharacterDatabase.Query( ss.str().c_str() );
|
||||
QueryResult *result = CharacterDatabase.PQuery( "SELECT rank FROM guild_member WHERE guid='%u'", GUID_LOPART(guid) );
|
||||
if( result )
|
||||
{
|
||||
uint32 v = result->Fetch()[0].GetUInt32();
|
||||
|
|
@ -6185,10 +6159,8 @@ uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type)
|
|||
|
||||
uint32 Player::GetZoneIdFromDB(uint64 guid)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss<<"SELECT zone FROM characters WHERE guid='"<<GUID_LOPART(guid)<<"'";
|
||||
QueryResult *result = CharacterDatabase.Query( ss.str().c_str() );
|
||||
uint32 guidLow = GUID_LOPART(guid);
|
||||
QueryResult *result = CharacterDatabase.PQuery( "SELECT zone FROM characters WHERE guid='%u'", guidLow );
|
||||
if (!result)
|
||||
return 0;
|
||||
Field* fields = result->Fetch();
|
||||
|
|
@ -6198,22 +6170,18 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
|
|||
if (!zone)
|
||||
{
|
||||
// stored zone is zero, use generic and slow zone detection
|
||||
ss.str("");
|
||||
ss<<"SELECT map,position_x,position_y FROM characters WHERE guid='"<<GUID_LOPART(guid)<<"'";
|
||||
result = CharacterDatabase.Query(ss.str().c_str());
|
||||
result = CharacterDatabase.PQuery("SELECT map,position_x,position_y FROM characters WHERE guid='%u'", guidLow);
|
||||
if( !result )
|
||||
return 0;
|
||||
fields = result->Fetch();
|
||||
uint32 map = fields[0].GetUInt32();
|
||||
uint32 map = fields[0].GetUInt32();
|
||||
float posx = fields[1].GetFloat();
|
||||
float posy = fields[2].GetFloat();
|
||||
delete result;
|
||||
|
||||
zone = MapManager::Instance().GetZoneId(map,posx,posy);
|
||||
|
||||
ss.str("");
|
||||
ss << "UPDATE characters SET zone='"<<zone<<"' WHERE guid='"<<GUID_LOPART(guid)<<"'";
|
||||
CharacterDatabase.Execute(ss.str().c_str());
|
||||
CharacterDatabase.PExecute("UPDATE characters SET zone='%u' WHERE guid='%u'", zone, guidLow);
|
||||
}
|
||||
|
||||
return zone;
|
||||
|
|
@ -16628,6 +16596,27 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type)
|
|||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
void LeaveAllArenaTeams(uint64 guid)
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u'", GUID_LOPART(guid));
|
||||
if(!result)
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
uint32 at_id = fields[0].GetUInt32();
|
||||
if(at_id != 0)
|
||||
{
|
||||
ArenaTeam * at = objmgr.GetArenaTeamById(at_id);
|
||||
if(at)
|
||||
at->DelMember(guid);
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::SetRestBonus (float rest_bonus_new)
|
||||
{
|
||||
// Prevent resting on max level
|
||||
|
|
|
|||
|
|
@ -1598,6 +1598,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
|
||||
void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
|
||||
uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
|
||||
static void LeaveAllArenaTeams(uint64 guid);
|
||||
|
||||
void SetDifficulty(uint32 dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; }
|
||||
uint8 GetDifficulty() { return m_dungeonDifficulty; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "6954"
|
||||
#define REVISION_NR "6955"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue