mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
Improve some arena team related DB access.
Reduce number of queries for adding a new arena team member. Merge two queries in Player::GetArenaTeamIdFromDB() into one.
This commit is contained in:
parent
166007525e
commit
2cdd7dcfce
2 changed files with 34 additions and 50 deletions
|
|
@ -6012,32 +6012,11 @@ uint32 Player::GetRankFromDB(uint64 guid)
|
|||
|
||||
uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type)
|
||||
{
|
||||
// need fix it!
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT arenateamid FROM arena_team_member WHERE guid='%u'", GUID_LOPART(guid));
|
||||
if(result)
|
||||
{
|
||||
// init id to 0, check the arena type before assigning a value to id
|
||||
uint32 id = 0;
|
||||
do
|
||||
{
|
||||
QueryResult *result2 = CharacterDatabase.PQuery("SELECT type FROM arena_team WHERE arenateamid='%u'", id);
|
||||
if(result2)
|
||||
{
|
||||
uint8 dbtype = (*result2)[0].GetUInt32();
|
||||
delete result2;
|
||||
if(dbtype == type)
|
||||
{
|
||||
// if the type matches, we've found the id
|
||||
id = (*result)[0].GetUInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while(result->NextRow());
|
||||
delete result;
|
||||
return id;
|
||||
}
|
||||
// no arenateam for the specified guid, return 0
|
||||
return 0;
|
||||
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' AND type='%u' LIMIT 1", GUID_LOPART(guid), type);
|
||||
if(!result)
|
||||
return 0;
|
||||
|
||||
return (*result)[0].GetUInt32();
|
||||
}
|
||||
|
||||
uint32 Player::GetZoneIdFromDB(uint64 guid)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue