mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
Reduce number of DB queries in guild related code.
This commit is contained in:
parent
90828fa699
commit
9d8a7aea79
3 changed files with 102 additions and 113 deletions
|
|
@ -104,8 +104,17 @@ bool Guild::create(uint64 lGuid, std::string gname)
|
|||
|
||||
bool Guild::AddMember(uint64 plGuid, uint32 plRank)
|
||||
{
|
||||
if(Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild
|
||||
return false;
|
||||
Player* pl = objmgr.GetPlayer(plGuid);
|
||||
if(pl)
|
||||
{
|
||||
if(pl->GetGuildId() != 0)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove all player signs from another petitions
|
||||
// this will be prevent attempt joining player to many guilds and corrupt guild data integrity
|
||||
|
|
@ -134,7 +143,6 @@ bool Guild::AddMember(uint64 plGuid, uint32 plRank)
|
|||
CharacterDatabase.PExecute("INSERT INTO guild_member (guildid,guid,rank,pnote,offnote) VALUES ('%u', '%u', '%u','%s','%s')",
|
||||
Id, GUID_LOPART(plGuid), newmember.RankId, dbPnote.c_str(), dbOFFnote.c_str());
|
||||
|
||||
Player* pl = objmgr.GetPlayer(plGuid);
|
||||
if(pl)
|
||||
{
|
||||
pl->SetInGuild(Id);
|
||||
|
|
@ -650,6 +658,15 @@ void Guild::SetRankRights(uint32 rankId, uint32 rights)
|
|||
CharacterDatabase.PExecute("UPDATE guild_rank SET rights='%u' WHERE rid='%u' AND guildid='%u'", rights, (rankId+1), Id);
|
||||
}
|
||||
|
||||
int32 Guild::GetRank(uint32 LowGuid)
|
||||
{
|
||||
MemberList::iterator itr = members.find(LowGuid);
|
||||
if (itr==members.end())
|
||||
return -1;
|
||||
|
||||
return itr->second.RankId;
|
||||
}
|
||||
|
||||
void Guild::Disband()
|
||||
{
|
||||
WorldPacket data(SMSG_GUILD_EVENT, 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue