OregonCore  revision fb2a440-git
Your Favourite TBC server
Guild.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #include "Database/DatabaseEnv.h"
18 #include "WorldPacket.h"
19 #include "WorldSession.h"
20 #include "Player.h"
21 #include "Opcodes.h"
22 #include "ObjectMgr.h"
23 #include "Guild.h"
24 #include "Chat.h"
25 #include "SocialMgr.h"
26 #include "Utilities/Util.h"
27 #include "Language.h"
28 
30 {
31  m_Id = 0;
32  m_Name = "";
33  m_LeaderGuid = 0;
34  GINFO = MOTD = "";
35  m_EmblemStyle = 0;
36  m_EmblemColor = 0;
37  m_BorderStyle = 0;
38  m_BorderColor = 0;
40  m_accountsNumber = 0;
41 
42  m_CreatedYear = 0;
43  m_CreatedMonth = 0;
44  m_CreatedDay = 0;
45 
46  m_GuildBankMoney = 0;
47  m_PurchasedTabs = 0;
48 
51 
52  for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
54 }
55 
57 {
58 
59 }
60 
61 bool Guild::Create(Player* leader, std::string gname)
62 {
63  if (sObjectMgr.GetGuildByName(gname))
64  return false;
65 
66  WorldSession* lSession = leader->GetSession();
67  if (!lSession)
68  return false;
69 
70  m_LeaderGuid = leader->GetGUID();
71  m_Name = gname;
72  GINFO = "";
73  MOTD = "No message set.";
74  m_GuildBankMoney = 0;
75  m_PurchasedTabs = 0;
76  m_Id = sObjectMgr.GenerateGuildId();
77 
78  // creating data
79  time_t now = time(0);
80  tm local = *(localtime(&now)); // dereference and assign
81  m_CreatedDay = local.tm_mday;
82  m_CreatedMonth = local.tm_mon + 1;
83  m_CreatedYear = local.tm_year + 1900;
84 
85  sLog.outDebug("GUILD: creating guild %s to leader: %u", gname.c_str(), GUID_LOPART(m_LeaderGuid));
86 
87  // gname already assigned to Guild::name, use it to encode string for DB
89 
90  std::string dbGINFO = GINFO;
91  std::string dbMOTD = MOTD;
94 
96  // CharacterDatabase.PExecute("DELETE FROM guild WHERE guildid='%u'", m_Id); - MAX(guildid)+1 not exist
97  CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", m_Id);
98  CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guildid='%u'", m_Id);
99  CharacterDatabase.PExecute("INSERT INTO guild (guildid,name,leaderguid,info,motd,createdate,EmblemStyle,EmblemColor,BorderStyle,BorderColor,BackgroundColor,BankMoney) "
100  "VALUES('%u','%s','%u', '%s', '%s', NOW(),'%u','%u','%u','%u','%u','" UI64FMTD "')",
103 
105 
107 }
108 
109 void Guild::CreateDefaultGuildRanks(int locale_idx)
110 {
111  CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", m_Id);
112  CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u'", m_Id);
113 
114  CreateRank(sObjectMgr.GetOregonString(LANG_GUILD_MASTER, locale_idx), GR_RIGHT_ALL);
115  CreateRank(sObjectMgr.GetOregonString(LANG_GUILD_OFFICER, locale_idx), GR_RIGHT_ALL);
119 }
120 
121 bool Guild::AddMember(uint64 plGuid, uint32 plRank)
122 {
123  Player* pl = sObjectMgr.GetPlayer(plGuid);
124  if (pl)
125  {
126  if (pl->GetGuildId() != 0)
127  return false;
128  }
129  else
130  {
131  if (Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild
132  return false;
133  }
134 
135  // remove all player signs from another petitions
136  // this will be prevent attempt joining player to many guilds and corrupt guild data integrity
138 
139  // fill player data
140  MemberSlot newmember;
141 
142  if (!FillPlayerData(plGuid, &newmember)) // problems with player data collection
143  return false;
144 
145  newmember.RankId = plRank;
146  newmember.OFFnote = (std::string)"";
147  newmember.Pnote = (std::string)"";
148  newmember.LogoutTime = time(NULL);
149  newmember.BankResetTimeMoney = 0; // this will force update at first query
150  for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
151  newmember.BankResetTimeTab[i] = 0;
152  members[GUID_LOPART(plGuid)] = newmember;
153 
154  std::string dbPnote = newmember.Pnote;
155  std::string dbOFFnote = newmember.OFFnote;
157  CharacterDatabase.escape_string(dbOFFnote);
158 
159  CharacterDatabase.PExecute("INSERT INTO guild_member (guildid,guid,rank,pnote,offnote) VALUES ('%u', '%u', '%u','%s','%s')",
160  m_Id, GUID_LOPART(plGuid), newmember.RankId, dbPnote.c_str(), dbOFFnote.c_str());
161 
162  // If player not in game data in data field will be loaded from guild tables, no need to update it!!
163  if (pl)
164  {
165  pl->SetInGuild(m_Id);
166  pl->SetRank(newmember.RankId);
167  pl->SetGuildIdInvited(0);
168  }
169 
171 
172  return true;
173 }
174 
175 void Guild::SetMOTD(std::string motd)
176 {
177  MOTD = motd;
178 
179  // motd now can be used for encoding to DB
181  CharacterDatabase.PExecute("UPDATE guild SET motd='%s' WHERE guildid='%u'", motd.c_str(), m_Id);
182 }
183 
184 void Guild::SetGINFO(std::string ginfo)
185 {
186  GINFO = ginfo;
187 
188  // ginfo now can be used for encoding to DB
190  CharacterDatabase.PExecute("UPDATE guild SET info='%s' WHERE guildid='%u'", ginfo.c_str(), m_Id);
191 }
192 
194 {
195  if (!guildDataResult)
196  return false;
197 
198  Field* fields = guildDataResult->Fetch();
199 
200  m_Id = fields[0].GetUInt32();
201  m_Name = fields[1].GetCppString();
202  m_LeaderGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER);
203  m_EmblemStyle = fields[3].GetUInt32();
204  m_EmblemColor = fields[4].GetUInt32();
205  m_BorderStyle = fields[5].GetUInt32();
206  m_BorderColor = fields[6].GetUInt32();
207  m_BackgroundColor = fields[7].GetUInt32();
208  GINFO = fields[8].GetCppString();
209  MOTD = fields[9].GetCppString();
210  time_t time = time_t(fields[10].GetUInt64());
211  m_GuildBankMoney = fields[11].GetUInt64();
212  m_PurchasedTabs = fields[12].GetUInt32();
213 
216 
217  if (time > 0)
218  {
219  tm local = *(localtime(&time)); // dereference and assign
220  m_CreatedDay = local.tm_mday;
221  m_CreatedMonth = local.tm_mon + 1;
222  m_CreatedYear = local.tm_year + 1900;
223  }
224 
225  return true;
226 }
227 
229 {
230  // If the leader does not exist attempt to promote another member
231  if (!sObjectMgr.GetPlayerAccountIdByGUID(m_LeaderGuid))
232  {
234  // check no members case (disbanded)
235  if (members.empty())
236  return false;
237  }
238 
239  m_bankloaded = false;
240  m_eventlogloaded = false;
241  m_onlinemembers = 0;
242  RenumBankLogs();
244  return true;
245 }
246 
248 {
249  if (!guildRanksResult)
250  {
251  sLog.outError("Guild %u has broken `guild_rank` data, creating new...", m_Id);
253  return true;
254  }
255 
256  Field* fields;
257  bool broken_ranks = false;
258 
259  do
260  {
261  fields = guildRanksResult->Fetch();
262  // condition that would be true when all ranks in QueryResult will be processed and guild without ranks is being processed
263  if (!fields)
264  break;
265 
266  uint32 guildId = fields[0].GetUInt32();
267  if (guildId < m_Id)
268  {
269  // there is in table guild_rank record which doesn't have guildid in guild table, report error
270  sLog.outErrorDb("Guild %u does not exist but it has a record in guild_rank table, deleting it!", guildId);
271  CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid = '%u'", guildId);
272  continue;
273  }
274 
275  if (guildId > m_Id)
276  // we loaded all ranks for this guild already, break cycle
277  break;
278  uint32 rankID = fields[1].GetUInt32();
279  std::string rankName = fields[2].GetCppString();
280  uint32 rankRights = fields[3].GetUInt32();
281  uint32 rankMoney = fields[4].GetUInt32();
282 
283  if (rankID != m_Ranks.size() + 1) // ranks start at 1
284  broken_ranks = true;
285 
286  // first rank is guildmaster, prevent loss leader rights
287  if (m_Ranks.empty())
288  rankRights |= GR_RIGHT_ALL;
289 
290  AddRank(rankName, rankRights, rankMoney);
291  }
292  while (guildRanksResult->NextRow());
293 
294  if (m_Ranks.size() < GUILD_RANKS_MIN_COUNT) // if too few ranks, renew them
295  {
296  m_Ranks.clear();
297  sLog.outError("Guild %u has broken `guild_rank` data, creating new...", m_Id);
298  CreateDefaultGuildRanks(0); // 0 is default locale_idx
299  broken_ranks = false;
300  }
301  // guild_rank have wrong numbered ranks, repair
302  if (broken_ranks)
303  {
304  sLog.outError("Guild %u has broken `guild_rank` data, repairing...", m_Id);
306  CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", m_Id);
307  for (size_t i = 0; i < m_Ranks.size(); ++i)
308  {
309  std::string name = m_Ranks[i].Name;
310  uint32 rights = m_Ranks[i].Rights;
312  CharacterDatabase.PExecute("INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", m_Id, uint32(i), name.c_str(), rights);
313  }
315  }
316 
317  return true;
318 }
319 
321 {
322  if (!guildMembersResult)
323  return false;
324 
325  do
326  {
327  Field* fields = guildMembersResult->Fetch();
328  // this condition will be true when all rows in QueryResult are processed and new guild without members is going to be loaded - prevent crash
329  if (!fields)
330  break;
331 
332  uint32 guildId = fields[0].GetUInt32();
333  if (guildId < m_Id)
334  {
335  // there is in table guild_member record which doesn't have guildid in guild table, report error
336  sLog.outErrorDb("Guild %u does not exist but it has a record in guild_member table, deleting it!", guildId);
337  CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guildid = '%u'", guildId);
338  continue;
339  }
340 
341  if (guildId > m_Id)
342  // we loaded all members for this guild already, break cycle
343  break;
344  MemberSlot newmember;
345  uint64 guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
346  newmember.RankId = fields[2].GetUInt32();
347  // don't allow member to have not existing rank!
348  if (newmember.RankId >= m_Ranks.size())
349  newmember.RankId = GetLowestRank();
350 
351  newmember.Pnote = fields[3].GetCppString();
352  newmember.OFFnote = fields[4].GetCppString();
353  newmember.BankResetTimeMoney = fields[5].GetUInt32();
354  newmember.BankRemMoney = fields[6].GetUInt32();
355  for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
356  {
357  newmember.BankResetTimeTab[i] = fields[7 + (2 * i)].GetUInt32();
358  newmember.BankRemSlotsTab[i] = fields[8 + (2 * i)].GetUInt32();
359  }
360  newmember.Name = fields[19].GetCppString();
361  newmember.Level = fields[20].GetUInt8();
362  newmember.Class = fields[21].GetUInt8();
363  newmember.ZoneId = fields[22].GetUInt32();
364  newmember.LogoutTime = fields[23].GetUInt64();
365  newmember.accountId = fields[24].GetUInt32();
366 
367  //this code will remove unexisting character guids from guild
368  if (newmember.Level < 1) // can be at broken `data` field
369  {
370  sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`data`, deleting him from guild!", GUID_LOPART(guid));
371  CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid));
372  continue;
373  }
374  if (!newmember.ZoneId)
375  {
376  sLog.outError("Player (GUID: %u) has broken zone-data", GUID_LOPART(guid));
377  // here it will also try the same, to get the zone from characters-table, but additional it tries to find
378  // the zone through xy coords .. this is a bit redundant, but shouldn't be called often
379  newmember.ZoneId = Player::GetZoneIdFromDB(guid);
380  }
381  if (newmember.Class < CLASS_WARRIOR || newmember.Class >= MAX_CLASSES) // can be at broken `class` field
382  {
383  sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`class`, deleting him from guild!", GUID_LOPART(guid));
384  CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid));
385  continue;
386  }
387 
388  members[GUID_LOPART(guid)] = newmember;
389 
390  }
391  while (guildMembersResult->NextRow());
392 
393  if (members.empty())
394  return false;
395 
397 
398  return true;
399 }
400 
402 {
403  int32 accountId;
404  std::string plName;
405  uint32 plLevel;
406  uint32 plClass;
407  uint32 plZone;
408 
409  Player* pl = sObjectMgr.GetPlayer(guid);
410  if (pl)
411  {
412  accountId = pl->GetSession()->GetAccountId();
413  plName = pl->GetName();
414  plLevel = pl->getLevel();
415  plClass = pl->getClass();
416  plZone = pl->GetZoneId();
417  }
418  else
419  {
420  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT name,level,zone,class,account FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
421  if (!result)
422  return false; // player doesn't exist
423 
424  Field* fields = result->Fetch();
425 
426  plName = fields[0].GetCppString();
427  plLevel = fields[1].GetUInt32();
428  plZone = fields[2].GetUInt32();
429  plClass = fields[3].GetUInt32();
430  accountId = fields[4].GetUInt32();
431 
432  if (plLevel < 1 || plLevel > STRONG_MAX_LEVEL) // can be at broken `data` field
433  {
434  sLog.outError("Player (GUID: %u) has a broken data in field characters.data.", GUID_LOPART(guid));
435  return false;
436  }
437 
438  if (!plZone)
439  {
440  sLog.outError("Player (GUID: %u) has broken zone-data", GUID_LOPART(guid));
441  // here it will also try the same, to get the zone from characters-table, but additional it tries to find
442  // the zone through xy coords .. this is a bit redundant, but shouldn't be called often
443  plZone = Player::GetZoneIdFromDB(guid);
444  }
445 
446  if (plClass < CLASS_WARRIOR || plClass >= MAX_CLASSES) // can be at broken `class` field
447  {
448  sLog.outError("Player (GUID: %u) has a broken data in field characters.class.", GUID_LOPART(guid));
449  return false;
450  }
451  }
452 
453  memslot->accountId = accountId;
454  memslot->Name = plName;
455  memslot->Level = plLevel;
456  memslot->Class = plClass;
457  memslot->ZoneId = plZone;
458 
459  return true;
460 }
461 
463 {
464  MemberList::iterator itr = members.find(GUID_LOPART(guid));
465  if (itr == members.end())
466  return;
467 
469  if (!pl)
470  return;
471  itr->second.Name = pl->GetName();
472  itr->second.Level = pl->getLevel();
473  itr->second.Class = pl->getClass();
474 }
475 
477 {
478  m_LeaderGuid = guid;
479  ChangeRank(guid, GR_GUILDMASTER);
480 
481  CharacterDatabase.PExecute("UPDATE guild SET leaderguid='%u' WHERE guildid='%u'", GUID_LOPART(guid), m_Id);
482 }
483 
484 void Guild::DelMember(uint64 guid, bool isDisbanding)
485 {
486  if (m_LeaderGuid == guid && !isDisbanding)
487  {
488  MemberSlot* oldLeader = NULL;
489  MemberSlot* best = NULL;
490  uint64 newLeaderGUID = 0;
491  for (Guild::MemberList::iterator i = members.begin(); i != members.end(); ++i)
492  {
493  if (i->first == GUID_LOPART(guid))
494  {
495  oldLeader = &(i->second);
496  continue;
497  }
498 
499  if (!best || best->RankId > i->second.RankId)
500  {
501  best = &(i->second);
502  newLeaderGUID = i->first;
503  }
504  }
505  if (!best)
506  {
507  Disband();
508  delete this;
509  return;
510  }
511 
512  SetLeader(newLeaderGUID);
513 
514  // If player not online data in data field will be loaded from guild tabs no need to update it !!
515  if (Player* newLeader = sObjectMgr.GetPlayer(newLeaderGUID))
516  newLeader->SetRank(GR_GUILDMASTER);
517 
518  // when leader non-exist (at guild load with deleted leader only) not send broadcasts
519  if (oldLeader)
520  {
521  BroadcastEvent(GE_LEADER_CHANGED, oldLeader->Name.c_str(), best->Name.c_str());
522  BroadcastEvent(GE_LEFT, guid, oldLeader->Name.c_str());
523  }
524  }
525 
526  members.erase(GUID_LOPART(guid));
527 
528  Player* player = sObjectMgr.GetPlayer(guid);
529  // If player not online data in data field will be loaded from guild tabs no need to update it !!
530  if (player)
531  {
532  player->SetInGuild(0);
533  player->SetRank(0);
534  }
535 
536  CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid));
537 }
538 
539 void Guild::ChangeRank(uint64 guid, uint32 newRank)
540 {
541  MemberList::iterator itr = members.find(GUID_LOPART(guid));
542  if (itr != members.end())
543  itr->second.RankId = newRank;
544 
545  Player* player = sObjectMgr.GetPlayer(guid);
546  // If player not online data in data field will be loaded from guild tabs no need to update it !!
547  if (player)
548  player->SetRank(newRank);
549 
550  CharacterDatabase.PExecute("UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, GUID_LOPART(guid));
551 }
552 
553 void Guild::SetPNOTE(uint64 guid, std::string pnote)
554 {
555  MemberList::iterator itr = members.find(GUID_LOPART(guid));
556  if (itr == members.end())
557  return;
558 
559  itr->second.Pnote = pnote;
560 
561  // pnote now can be used for encoding to DB
563  CharacterDatabase.PExecute("UPDATE guild_member SET pnote = '%s' WHERE guid = '%u'", pnote.c_str(), itr->first);
564 }
565 
566 void Guild::SetOFFNOTE(uint64 guid, std::string offnote)
567 {
568  MemberList::iterator itr = members.find(GUID_LOPART(guid));
569  if (itr == members.end())
570  return;
571  itr->second.OFFnote = offnote;
572  // offnote now can be used for encoding to DB
574  CharacterDatabase.PExecute("UPDATE guild_member SET offnote = '%s' WHERE guid = '%u'", offnote.c_str(), itr->first);
575 }
576 
577 void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language)
578 {
579  if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_GCHATSPEAK))
580  {
581  WorldPacket data;
582  ChatHandler(session).FillMessageData(&data, CHAT_MSG_GUILD, language, 0, msg.c_str());
583 
584  for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
585  {
587 
588  if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow()))
589  pl->GetSession()->SendPacket(&data);
590  }
591  }
592 }
593 
594 void Guild::BroadcastToOfficers(WorldSession* session, const std::string& msg, uint32 language)
595 {
596  if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_OFFCHATSPEAK))
597  {
598  for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
599  {
600  WorldPacket data;
601  ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, NULL, 0, msg.c_str(), NULL);
602 
603  Player* pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER), true);
604 
605  if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_OFFCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow()))
606  pl->GetSession()->SendPacket(&data);
607  }
608  }
609 }
610 
612 {
613  for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
614  {
615  Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER), true);
616  if (player)
617  player->GetSession()->SendPacket(packet);
618  }
619 }
620 
622 {
623  for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
624  {
625  if (itr->second.RankId == rankId)
626  {
627  Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER), true);
628  if (player)
629  player->GetSession()->SendPacket(packet);
630  }
631  }
632 }
633 
634 void Guild::CreateRank(std::string name_, uint32 rights)
635 {
636  if (m_Ranks.size() >= GUILD_MAX_RANKS)
637  return;
638 
639  AddRank(name_, rights, 0);
640 
641  for (uint8 i = 0; i < m_PurchasedTabs; ++i)
642  CreateBankRightForTab(m_Ranks.size() - 1, uint8(i));
643 
644  // guild_rank.rid always store rank+1 value
645 
646  // m_Name now can be used for encoding to DB
648  CharacterDatabase.PExecute("INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%lu', '%s', '%u')", m_Id, m_Ranks.size(), name_.c_str(), rights);
649 }
650 
651 void Guild::AddRank(const std::string& name_, uint32 rights, uint32 money)
652 {
653  m_Ranks.push_back(RankInfo(name_, rights, money));
654 }
655 
657 {
658  if (m_Ranks.empty())
659  return;
660 
661  // guild_rank.rid always store rank+1 value
662  uint32 rank = m_Ranks.size() - 1;
663  CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE rid>='%u' AND guildid='%u'", (rank + 1), m_Id);
664  CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE rid>='%u' AND guildid='%u'", rank, m_Id);
665 
666  m_Ranks.pop_back();
667 }
668 
669 std::string Guild::GetRankName(uint32 rankId)
670 {
671  if (rankId >= m_Ranks.size())
672  return "<unknown>";
673 
674  return m_Ranks[rankId].Name;
675 }
676 
678 {
679  if (rankId >= m_Ranks.size())
680  return 0;
681 
682  return m_Ranks[rankId].Rights;
683 }
684 
685 void Guild::SetRankName(uint32 rankId, std::string name_)
686 {
687  if (rankId >= m_Ranks.size())
688  return;
689 
690  m_Ranks[rankId].Name = name_;
691 
692  // name now can be used for encoding to DB
694  CharacterDatabase.PExecute("UPDATE guild_rank SET rname='%s' WHERE rid='%u' AND guildid='%u'", name_.c_str(), (rankId + 1), m_Id);
695 }
696 
697 void Guild::SetRankRights(uint32 rankId, uint32 rights)
698 {
699  if (rankId >= m_Ranks.size())
700  return;
701 
702  m_Ranks[rankId].Rights = rights;
703 
704  CharacterDatabase.PExecute("UPDATE guild_rank SET rights='%u' WHERE rid='%u' AND guildid='%u'", rights, (rankId + 1), m_Id);
705 }
706 
708 {
709  MemberList::iterator itr = members.find(LowGuid);
710  if (itr == members.end())
711  return -1;
712 
713  return itr->second.RankId;
714 }
715 
717 {
719 
720  while (!members.empty())
721  {
722  MemberList::iterator itr = members.begin();
723  DelMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER), true);
724  }
725 
727  CharacterDatabase.PExecute("DELETE FROM guild WHERE guildid = '%u'", m_Id);
728  CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid = '%u'", m_Id);
729  CharacterDatabase.PExecute("DELETE FROM guild_bank_tab WHERE guildid = '%u'", m_Id);
730  CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid = '%u'", m_Id);
731  CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u'", m_Id);
732  CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid = '%u'", m_Id);
733  CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid = '%u'", m_Id);
735  sObjectMgr.RemoveGuild(m_Id);
736 }
737 
738 void Guild::Roster(WorldSession* session /*= NULL*/)
739 {
740  // we can only guess size
741  WorldPacket data(SMSG_GUILD_ROSTER, (4 + MOTD.length() + 1 + GINFO.length() + 1 + 4 + m_Ranks.size() * (4 + 4 + GUILD_BANK_MAX_TABS * (4 + 4)) + members.size() * 50));
742  data << uint32(members.size());
743  data << MOTD;
744  data << GINFO;
745 
746  data << uint32(m_Ranks.size());
747  for (RankList::const_iterator ritr = m_Ranks.begin(); ritr != m_Ranks.end(); ++ritr)
748  {
749  data << uint32(ritr->Rights);
750  data << uint32(ritr->BankMoneyPerDay); // count of: withdraw gold(gold/day) Note: in game set gold, in packet set bronze.
751  for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i)
752  {
753  data << uint32(ritr->TabRight[i]); // for TAB_i rights: view tabs = 0x01, deposit items =0x02
754  data << uint32(ritr->TabSlotPerDay[i]); // for TAB_i count of: withdraw items(stack/day)
755  }
756  }
757  for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
758  {
760  {
761  data << uint64(pl->GetGUID());
762  data << uint8(1);
763  data << pl->GetName();
764  data << uint32(itr->second.RankId);
765  data << uint8(pl->getLevel());
766  data << uint8(pl->getClass());
767  data << uint8(0); // new 2.4.0
768  data << uint32(pl->GetZoneId());
769  data << itr->second.Pnote;
770  data << itr->second.OFFnote;
771  }
772  else
773  {
774  data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
775  data << uint8(0);
776  data << itr->second.Name;
777  data << uint32(itr->second.RankId);
778  data << uint8(itr->second.Level);
779  data << uint8(itr->second.Class);
780  data << uint8(0); // new 2.4.0
781  data << uint32(itr->second.ZoneId);
782  data << float(float(time(NULL) - itr->second.LogoutTime) / DAY);
783  data << itr->second.Pnote;
784  data << itr->second.OFFnote;
785  }
786  }
787  if (session)
788  session->SendPacket(&data);
789  else
790  BroadcastPacket(&data);
791  sLog.outDebug("WORLD: Sent (SMSG_GUILD_ROSTER)");
792 }
793 
795 {
796  WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (8 * 32 + 200)); // we can only guess size
797 
798  data << uint32(m_Id);
799  data << m_Name;
800 
801  for (size_t i = 0 ; i < 10; ++i) // show always 10 ranks
802  {
803  if (i < m_Ranks.size())
804  data << m_Ranks[i].Name;
805  else
806  data << uint8(0); // null string
807  }
808 
809  data << uint32(m_EmblemStyle);
810  data << uint32(m_EmblemColor);
811  data << uint32(m_BorderStyle);
812  data << uint32(m_BorderColor);
813  data << uint32(m_BackgroundColor);
814 
815  session->SendPacket(&data);
816  sLog.outDebug("WORLD: Sent (SMSG_GUILD_QUERY_RESPONSE)");
817 }
818 
819 void Guild::SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor)
820 {
821  m_EmblemStyle = emblemStyle;
822  m_EmblemColor = emblemColor;
823  m_BorderStyle = borderStyle;
824  m_BorderColor = borderColor;
825  m_BackgroundColor = backgroundColor;
826 
827  CharacterDatabase.PExecute("UPDATE guild SET EmblemStyle=%u, EmblemColor=%u, BorderStyle=%u, BorderColor=%u, BackgroundColor=%u WHERE guildid = %u", m_EmblemStyle, m_EmblemColor, m_BorderStyle, m_BorderColor, m_BackgroundColor, m_Id);
828 }
829 
831 {
832  MemberList::iterator itr = members.find(GUID_LOPART(guid));
833  if (itr == members.end())
834  return;
835 
836  itr->second.LogoutTime = time(NULL);
837 
838  if (m_onlinemembers > 0)
839  --m_onlinemembers;
840  else
841  {
842  UnloadGuildBank();
844  }
845 }
846 
852 {
853  // We use a set to be sure each element will be unique
854  std::set<uint32> accountsIdSet;
855  for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
856  accountsIdSet.insert(itr->second.accountId);
857 
858  m_accountsNumber = accountsIdSet.size();
859 }
860 
861 // *************************************************
862 // Guild Eventlog part
863 // *************************************************
864 // Display guild eventlog
866 {
867  // Load guild eventlog, if not already done
868  if (!m_eventlogloaded)
870 
871  // Sending result
873  // count, max count == 100
874  data << uint8(m_GuildEventlog.size());
875  for (GuildEventlog::const_iterator itr = m_GuildEventlog.begin(); itr != m_GuildEventlog.end(); ++itr)
876  {
877  // Event type
878  data << uint8(itr->EventType);
879  // Player 1
880  data << uint64(itr->PlayerGuid1);
881  // Player 2 not for left/join guild events
882  if (itr->EventType != GUILD_EVENT_LOG_JOIN_GUILD && itr->EventType != GUILD_EVENT_LOG_LEAVE_GUILD)
883  data << uint64(itr->PlayerGuid2);
884  // New Rank - only for promote/demote guild events
885  if (itr->EventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || itr->EventType == GUILD_EVENT_LOG_DEMOTE_PLAYER)
886  data << uint8(itr->NewRank);
887  // Event timestamp
888  data << uint32(time(NULL) - itr->TimeStamp);
889  }
890  session->SendPacket(&data);
891  sLog.outDebug("WORLD: Sent (MSG_GUILD_EVENT_LOG_QUERY)");
892 }
893 
894 // Load guild eventlog from DB
896 {
897  // Return if already loaded
898  if (m_eventlogloaded)
899  return;
900 
901  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY LogGuid DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_ENTRIES);
902  if (!result)
903  return;
904  do
905  {
906  Field* fields = result->Fetch();
907  GuildEventlogEntry NewEvent;
908  // Fill entry
909  NewEvent.LogGuid = fields[0].GetUInt32();
910  NewEvent.EventType = fields[1].GetUInt8();
911  NewEvent.PlayerGuid1 = fields[2].GetUInt32();
912  NewEvent.PlayerGuid2 = fields[3].GetUInt32();
913  NewEvent.NewRank = fields[4].GetUInt8();
914  NewEvent.TimeStamp = fields[5].GetUInt64();
915  // Add entry to map
916  m_GuildEventlog.push_front(NewEvent);
917 
918  }
919  while (result->NextRow());
920 
921  // Check lists size in case to many event entries in db
922  // This cases can happen only if a crash occured somewhere and table has too many log entries
923  if (!m_GuildEventlog.empty())
924  CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid=%u AND LogGuid < %u", m_Id, m_GuildEventlog.front().LogGuid);
925 
926  m_eventlogloaded = true;
927 }
928 
929 // Unload guild eventlog
931 {
932  if (!m_eventlogloaded)
933  return;
934 
935  m_GuildEventlog.clear();
936  m_eventlogloaded = false;
937 }
938 
939 // This will renum guids used at load to prevent always going up until infinit
941 {
942  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT Min(LogGuid), Max(LogGuid) FROM guild_eventlog WHERE guildid = %u", m_Id);
943  if (!result)
944  return;
945 
946  Field* fields = result->Fetch();
947  CharacterDatabase.PExecute("UPDATE guild_eventlog SET LogGuid=LogGuid-%u+1 WHERE guildid=%u ORDER BY LogGuid %s", fields[0].GetUInt32(), m_Id, fields[0].GetUInt32() ? "ASC" : "DESC");
948  GuildEventlogMaxGuid = fields[1].GetUInt32() + 1;
949 }
950 
951 // Add entry to guild eventlog
952 void Guild::LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank)
953 {
954  GuildEventlogEntry NewEvent;
955  // Create event
956  NewEvent.LogGuid = GuildEventlogMaxGuid++;
957  NewEvent.EventType = EventType;
958  NewEvent.PlayerGuid1 = PlayerGuid1;
959  NewEvent.PlayerGuid2 = PlayerGuid2;
960  NewEvent.NewRank = NewRank;
961  NewEvent.TimeStamp = uint32(time(NULL));
962  // Check max records limit
964  {
965  CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid='%u' AND LogGuid='%u'", m_Id, m_GuildEventlog.front().LogGuid);
966  m_GuildEventlog.pop_front();
967  }
968  // Add event to list
969  m_GuildEventlog.push_back(NewEvent);
970  // Save event to DB
971  CharacterDatabase.PExecute("INSERT INTO guild_eventlog (guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','" UI64FMTD "')",
972  m_Id, NewEvent.LogGuid, uint32(NewEvent.EventType), NewEvent.PlayerGuid1, NewEvent.PlayerGuid2, uint32(NewEvent.NewRank), NewEvent.TimeStamp);
973 }
974 
975 // *************************************************
976 // Guild Bank part
977 // *************************************************
978 // Bank content related
980 {
981  WorldPacket data(SMSG_GUILD_BANK_LIST, 1200);
982 
983  GuildBankTab const* tab = GetBankTab(TabId);
984  if (!tab)
985  return;
986 
988  return;
989 
990  data << uint64(GetGuildBankMoney());
991  data << uint8(TabId);
992  // remaining slots for today
993  data << uint32(GetMemberSlotWithdrawRem(session->GetPlayer()->GetGUIDLow(), TabId));
994  data << uint8(0); // Tell client that there's no tab info in this packet
995 
996  data << uint8(GUILD_BANK_MAX_SLOTS);
997 
998  for (uint8 i = 0; i < GUILD_BANK_MAX_SLOTS; ++i)
999  AppendDisplayGuildBankSlot(data, tab, i);
1000 
1001  session->SendPacket(&data);
1002 
1003  sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)");
1004 }
1005 
1007 {
1008  WorldPacket data(SMSG_GUILD_BANK_LIST, 8 + 1 + 4 + 1 + 1);
1009 
1010  data << uint64(GetGuildBankMoney());
1011  data << uint8(0); // TabId, default 0
1012  data << uint32(0); // Slot withdrow, default 0
1013  data << uint8(0); // Tell that there's no tab info in this packet
1014  data << uint8(0); // not send items
1015  BroadcastPacket(&data);
1016 
1017  sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)");
1018 }
1019 
1021 {
1022  GuildBankTab const* tab = GetBankTab(TabId);
1023  if (!tab)
1024  return;
1025 
1026  WorldPacket data(SMSG_GUILD_BANK_LIST, 1200);
1027 
1028  data << uint64(GetGuildBankMoney());
1029  data << uint8(TabId);
1030 
1031  size_t rempos = data.wpos();
1032  data << uint32(0); // item withdraw amount, will be filled later
1033  data << uint8(0); // Tell client that there's no tab info in this packet
1034 
1035  if (slot2 == -1) // single item in slot1
1036  {
1037  data << uint8(1); // item count
1038 
1039  AppendDisplayGuildBankSlot(data, tab, slot1);
1040  }
1041  else // 2 items (in slot1 and slot2)
1042  {
1043  data << uint8(2); // item count
1044 
1045  if (slot1 > slot2)
1046  std::swap(slot1, slot2);
1047 
1048  AppendDisplayGuildBankSlot(data, tab, slot1);
1049  AppendDisplayGuildBankSlot(data, tab, slot2);
1050  }
1051 
1052  for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
1053  {
1055  if (!player)
1056  continue;
1057 
1058  if (!IsMemberHaveRights(itr->first, TabId, GUILD_BANK_RIGHT_VIEW_TAB))
1059  continue;
1060 
1061  data.put<uint32>(rempos, uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId)));
1062 
1063  player->GetSession()->SendPacket(&data);
1064  }
1065 
1066  sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)");
1067 }
1068 
1070 {
1071  GuildBankTab const* tab = GetBankTab(TabId);
1072  if (!tab)
1073  return;
1074 
1075  WorldPacket data(SMSG_GUILD_BANK_LIST, 1200);
1076 
1077  data << uint64(GetGuildBankMoney());
1078  data << uint8(TabId);
1079 
1080  size_t rempos = data.wpos();
1081  data << uint32(0); // item withdraw amount, will be filled later
1082  data << uint8(0); // Tell client that there's no tab info in this packet
1083 
1084  data << uint8(slots.size()); // updates count
1085 
1086  for (GuildItemPosCountVec::const_iterator itr = slots.begin(); itr != slots.end(); ++itr)
1087  AppendDisplayGuildBankSlot(data, tab, itr->Slot);
1088 
1089  for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
1090  {
1092  if (!player)
1093  continue;
1094 
1095  if (!IsMemberHaveRights(itr->first, TabId, GUILD_BANK_RIGHT_VIEW_TAB))
1096  continue;
1097 
1098  data.put<uint32>(rempos, uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId)));
1099 
1100  player->GetSession()->SendPacket(&data);
1101  }
1102 
1103  sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)");
1104 }
1105 
1107 {
1108  if (TabId >= m_TabListMap.size() || SlotId >= GUILD_BANK_MAX_SLOTS)
1109  return NULL;
1110  return m_TabListMap[TabId]->Slots[SlotId];
1111 }
1112 
1113 // *************************************************
1114 // Tab related
1115 
1117 {
1118  // Time to load bank if not already done
1119  if (!m_bankloaded)
1121 
1122  WorldPacket data(SMSG_GUILD_BANK_LIST, 500);
1123 
1124  data << uint64(GetGuildBankMoney());
1125  data << uint8(0); // TabInfo packet must be for TabId 0
1126  data << uint32(0xFFFFFFFF); // bit 9 must be set for this packet to work
1127  data << uint8(1); // Tell client that this packet includes tab info
1128 
1129  data << uint8(m_PurchasedTabs); // here is the number of tabs
1130 
1131  for (uint8 i = 0; i < m_PurchasedTabs; ++i)
1132  {
1133  data << m_TabListMap[i]->Name.c_str();
1134  data << m_TabListMap[i]->Icon.c_str();
1135  }
1136  data << uint8(0); // Do not send tab content
1137  session->SendPacket(&data);
1138 
1139  sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)");
1140 }
1141 
1143 {
1145  return;
1146 
1147  ++m_PurchasedTabs;
1148 
1149  GuildBankTab* AnotherTab = new GuildBankTab;
1150  memset(AnotherTab->Slots, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*));
1151  m_TabListMap.resize(m_PurchasedTabs);
1152  m_TabListMap[m_PurchasedTabs - 1] = AnotherTab;
1153 
1155  CharacterDatabase.PExecute("DELETE FROM guild_bank_tab WHERE guildid='%u' AND TabId='%u'", m_Id, uint32(m_PurchasedTabs - 1));
1156  CharacterDatabase.PExecute("INSERT INTO guild_bank_tab (guildid,TabId) VALUES ('%u','%u')", m_Id, uint32(m_PurchasedTabs - 1));
1158 }
1159 
1160 void Guild::SetGuildBankTabInfo(uint8 TabId, std::string Name, std::string Icon)
1161 {
1162  if (TabId >= GUILD_BANK_MAX_TABS)
1163  return;
1164  if (TabId >= m_TabListMap.size())
1165  return;
1166 
1167  if (!m_TabListMap[TabId])
1168  return;
1169 
1170  if (m_TabListMap[TabId]->Name == Name && m_TabListMap[TabId]->Icon == Icon)
1171  return;
1172 
1173  m_TabListMap[TabId]->Name = Name;
1174  m_TabListMap[TabId]->Icon = Icon;
1175 
1178  CharacterDatabase.PExecute("UPDATE guild_bank_tab SET TabName='%s',TabIcon='%s' WHERE guildid='%u' AND TabId='%u'", Name.c_str(), Icon.c_str(), m_Id, uint32(TabId));
1179 }
1180 
1182 {
1183  sLog.outDebug("CreateBankRightForTab. rank: %u, TabId: %u", rankId, uint32(TabId));
1184  if (rankId >= m_Ranks.size() || TabId >= GUILD_BANK_MAX_TABS)
1185  return;
1186 
1187  m_Ranks[rankId].TabRight[TabId] = 0;
1188  m_Ranks[rankId].TabSlotPerDay[TabId] = 0;
1190  CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u' AND TabId = '%u' AND rid = '%u'", m_Id, uint32(TabId), rankId);
1191  CharacterDatabase.PExecute("INSERT INTO guild_bank_right (guildid,TabId,rid) VALUES ('%u','%u','%u')", m_Id, uint32(TabId), rankId);
1193 }
1194 
1196 {
1197  if (rankId >= m_Ranks.size() || TabId >= GUILD_BANK_MAX_TABS)
1198  return 0;
1199 
1200  return m_Ranks[rankId].TabRight[TabId];
1201 }
1202 
1203 // *************************************************
1204 // Guild bank loading/unloading related
1205 
1206 // This load should be called when the bank is first accessed by a guild member
1208 {
1209  if (m_bankloaded)
1210  return;
1211 
1212  m_bankloaded = true;
1214 
1215  // 0 1 2 3
1216  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT TabId, TabName, TabIcon, TabText FROM guild_bank_tab WHERE guildid='%u' ORDER BY TabId", m_Id);
1217  if (!result)
1218  {
1219  m_PurchasedTabs = 0;
1220  return;
1221  }
1222 
1223  m_TabListMap.resize(m_PurchasedTabs);
1224  do
1225  {
1226  Field* fields = result->Fetch();
1227  uint8 TabId = fields[0].GetUInt8();
1228 
1229  GuildBankTab* NewTab = new GuildBankTab;
1230  memset(NewTab->Slots, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*));
1231 
1232  NewTab->Name = fields[1].GetCppString();
1233  NewTab->Icon = fields[2].GetCppString();
1234  NewTab->Text = fields[3].GetCppString();
1235 
1236  m_TabListMap[TabId] = NewTab;
1237  }
1238  while (result->NextRow());
1239 
1240  // data needs to be at first place for Item::LoadFromDB
1241  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1242  result = CharacterDatabase.PQuery("SELECT itemEntry, creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, itemTextId, TabId, SlotId, item_guid, item_entry FROM guild_bank_item JOIN item_instance ON item_guid = guid WHERE guildid='%u' ORDER BY TabId", m_Id);
1243  if (!result)
1244  return;
1245 
1246  do
1247  {
1248  Field* fields = result->Fetch();
1249  uint8 TabId = fields[11].GetUInt8();
1250  uint8 SlotId = fields[12].GetUInt8();
1251  uint32 ItemGuid = fields[13].GetUInt32();
1252  uint32 ItemEntry = fields[14].GetUInt32();
1253 
1254  if (TabId >= m_PurchasedTabs || TabId >= GUILD_BANK_MAX_TABS)
1255  {
1256  sLog.outError("Guild::LoadGuildBankFromDB: Invalid tab for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemEntry);
1257  continue;
1258  }
1259 
1260  if (SlotId >= GUILD_BANK_MAX_SLOTS)
1261  {
1262  sLog.outError("Guild::LoadGuildBankFromDB: Invalid slot for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemEntry);
1263  continue;
1264  }
1265 
1266  ItemTemplate const* proto = sObjectMgr.GetItemTemplate(ItemEntry);
1267 
1268  if (!proto)
1269  {
1270  sLog.outError("Guild::LoadGuildBankFromDB: Unknown item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemEntry);
1271  continue;
1272  }
1273 
1274  Item* pItem = NewItemOrBag(proto);
1275  if (!pItem->LoadFromDB(ItemGuid, 0, fields))
1276  {
1277  CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'", m_Id, uint32(TabId), uint32(SlotId));
1278  sLog.outError("Item GUID %u not found in item_instance, deleting from Guild Bank!", ItemGuid);
1279  delete pItem;
1280  continue;
1281  }
1282 
1283  pItem->AddToWorld();
1284  m_TabListMap[TabId]->Slots[SlotId] = pItem;
1285  }
1286  while (result->NextRow());
1287 }
1288 
1289 // This unload should be called when the last member of the guild gets offline
1291 {
1292  if (!m_bankloaded)
1293  return;
1294  for (uint8 i = 0 ; i < m_PurchasedTabs ; ++i)
1295  {
1296  for (uint8 j = 0 ; j < GUILD_BANK_MAX_SLOTS ; ++j)
1297  {
1298  if (m_TabListMap[i]->Slots[j])
1299  {
1300  m_TabListMap[i]->Slots[j]->RemoveFromWorld();
1301  delete m_TabListMap[i]->Slots[j];
1302  }
1303  }
1304  delete m_TabListMap[i];
1305  }
1306  m_TabListMap.clear();
1307 
1309  m_bankloaded = false;
1310 }
1311 
1312 // *************************************************
1313 // Money deposit/withdraw related
1314 
1316 {
1318  data << uint32(GetMemberMoneyWithdrawRem(LowGuid));
1319  session->SendPacket(&data);
1320  sLog.outDebug("WORLD: Sent MSG_GUILD_BANK_MONEY_WITHDRAWN");
1321 }
1322 
1324 {
1325  uint32 MoneyWithDrawRight = GetMemberMoneyWithdrawRem(LowGuid);
1326 
1327  if (MoneyWithDrawRight < amount || GetGuildBankMoney() < amount)
1328  return false;
1329 
1330  SetBankMoney(GetGuildBankMoney() - amount);
1331 
1332  if (MoneyWithDrawRight < uint32(WITHDRAW_MONEY_UNLIMITED))
1333  {
1334  MemberList::iterator itr = members.find(LowGuid);
1335  if (itr == members.end())
1336  return false;
1337  itr->second.BankRemMoney -= amount;
1338  CharacterDatabase.PExecute("UPDATE guild_member SET BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'",
1339  itr->second.BankRemMoney, m_Id, LowGuid);
1340  }
1341  return true;
1342 }
1343 
1345 {
1346  if (money < 0) // I don't know how this happens, it does!!
1347  money = 0;
1348  m_GuildBankMoney = money;
1349 
1350  CharacterDatabase.PExecute("UPDATE guild SET BankMoney='" UI64FMTD "' WHERE guildid='%u'", money, m_Id);
1351 }
1352 
1353 // *************************************************
1354 // Item per day and money per day related
1355 
1357 {
1358  uint32 SlotsWithDrawRight = GetMemberSlotWithdrawRem(LowGuid, TabId);
1359 
1360  if (SlotsWithDrawRight == 0)
1361  return false;
1362 
1363  if (SlotsWithDrawRight < uint32(WITHDRAW_SLOT_UNLIMITED))
1364  {
1365  MemberList::iterator itr = members.find(LowGuid);
1366  if (itr == members.end())
1367  return false;
1368  --itr->second.BankRemSlotsTab[TabId];
1369  CharacterDatabase.PExecute("UPDATE guild_member SET BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'",
1370  uint32(TabId), itr->second.BankRemSlotsTab[TabId], m_Id, LowGuid);
1371  }
1372  return true;
1373 }
1374 
1375 bool Guild::IsMemberHaveRights(uint32 LowGuid, uint8 TabId, uint32 rights) const
1376 {
1377  MemberList::const_iterator itr = members.find(LowGuid);
1378  if (itr == members.end())
1379  return false;
1380 
1381  if (itr->second.RankId == GR_GUILDMASTER)
1382  return true;
1383 
1384  return (GetBankRights(itr->second.RankId, TabId) & rights) == rights;
1385 }
1386 
1388 {
1389  MemberList::iterator itr = members.find(LowGuid);
1390  if (itr == members.end())
1391  return 0;
1392 
1393  if (itr->second.RankId == GR_GUILDMASTER)
1394  return WITHDRAW_SLOT_UNLIMITED;
1395 
1396  if ((GetBankRights(itr->second.RankId, TabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GUILD_BANK_RIGHT_VIEW_TAB)
1397  return 0;
1398 
1399  uint32 curTime = uint32(time(NULL) / MINUTE);
1400  if (curTime - itr->second.BankResetTimeTab[TabId] >= 24 * HOUR / MINUTE)
1401  {
1402  itr->second.BankResetTimeTab[TabId] = curTime;
1403  itr->second.BankRemSlotsTab[TabId] = GetBankSlotPerDay(itr->second.RankId, TabId);
1404  CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='%u', BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'",
1405  uint32(TabId), itr->second.BankResetTimeTab[TabId], uint32(TabId), itr->second.BankRemSlotsTab[TabId], m_Id, LowGuid);
1406  }
1407  return itr->second.BankRemSlotsTab[TabId];
1408 }
1409 
1411 {
1412  MemberList::iterator itr = members.find(LowGuid);
1413  if (itr == members.end())
1414  return 0;
1415 
1416  if (itr->second.RankId == GR_GUILDMASTER)
1417  return WITHDRAW_MONEY_UNLIMITED;
1418 
1419  uint32 curTime = uint32(time(NULL) / MINUTE); // minutes
1420  // 24 hours
1421  if (curTime > itr->second.BankResetTimeMoney + 24 * HOUR / MINUTE)
1422  {
1423  itr->second.BankResetTimeMoney = curTime;
1424  itr->second.BankRemMoney = GetBankMoneyPerDay(itr->second.RankId);
1425  CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='%u',BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'",
1426  itr->second.BankResetTimeMoney, itr->second.BankRemMoney, m_Id, LowGuid);
1427  }
1428  return itr->second.BankRemMoney;
1429 }
1430 
1432 {
1433  if (rankId >= m_Ranks.size())
1434  return;
1435 
1436  if (rankId == GR_GUILDMASTER)
1437  money = WITHDRAW_MONEY_UNLIMITED;
1438 
1439  m_Ranks[rankId].BankMoneyPerDay = money;
1440 
1441  for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
1442  if (itr->second.RankId == rankId)
1443  itr->second.BankResetTimeMoney = 0;
1444 
1445  CharacterDatabase.PExecute("UPDATE guild_rank SET BankMoneyPerDay='%u' WHERE rid='%u' AND guildid='%u'", money, (rankId + 1), m_Id);
1446  CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='0' WHERE guildid='%u' AND rank='%u'", m_Id, rankId);
1447 }
1448 
1449 void Guild::SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint32 nbSlots, bool db)
1450 {
1451  if (rankId >= m_Ranks.size() ||
1452  TabId >= GUILD_BANK_MAX_TABS ||
1453  TabId >= m_PurchasedTabs)
1454  {
1455  // TODO remove next line, It is there just to repair existing bug in deleting guild rank
1456  CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid='%u' AND rid='%u' AND TabId='%u'", m_Id, rankId, TabId);
1457  return;
1458  }
1459 
1460  if (rankId == GR_GUILDMASTER)
1461  {
1462  nbSlots = WITHDRAW_SLOT_UNLIMITED;
1463  right = GUILD_BANK_RIGHT_FULL;
1464  }
1465 
1466  m_Ranks[rankId].TabSlotPerDay[TabId] = nbSlots;
1467  m_Ranks[rankId].TabRight[TabId] = right;
1468 
1469  if (db)
1470  {
1471  for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
1472  if (itr->second.RankId == rankId)
1473  for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
1474  itr->second.BankResetTimeTab[i] = 0;
1475 
1476  CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid='%u' AND TabId='%u' AND rid='%u'", m_Id, uint32(TabId), rankId);
1477  CharacterDatabase.PExecute("INSERT INTO guild_bank_right (guildid,TabId,rid,gbright,SlotPerDay) VALUES "
1478  "('%u','%u','%u','%u','%u')", m_Id, uint32(TabId), rankId, m_Ranks[rankId].TabRight[TabId], m_Ranks[rankId].TabSlotPerDay[TabId]);
1479  CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='0' WHERE guildid='%u' AND rank='%u'", uint32(TabId), m_Id, rankId);
1480  }
1481 }
1482 
1484 {
1485  if (rankId >= m_Ranks.size())
1486  return 0;
1487 
1488  if (rankId == GR_GUILDMASTER)
1489  return WITHDRAW_MONEY_UNLIMITED;
1490  return m_Ranks[rankId].BankMoneyPerDay;
1491 }
1492 
1494 {
1495  if (rankId >= m_Ranks.size() || TabId >= GUILD_BANK_MAX_TABS)
1496  return 0;
1497 
1498  if (rankId == GR_GUILDMASTER)
1499  return WITHDRAW_SLOT_UNLIMITED;
1500  return m_Ranks[rankId].TabSlotPerDay[TabId];
1501 }
1502 
1503 // *************************************************
1504 // Rights per day related
1505 
1506 bool Guild::LoadBankRightsFromDB(QueryResult_AutoPtr guildBankTabRightsResult)
1507 {
1508  if (!guildBankTabRightsResult)
1509  return true;
1510 
1511  do
1512  {
1513  Field* fields = guildBankTabRightsResult->Fetch();
1514  // prevent crash when all rights in result are already processed
1515  if (!fields)
1516  break;
1517  uint32 guildId = fields[0].GetUInt32();
1518  if (guildId < m_Id)
1519  {
1520  // there is in table guild_bank_right record which doesn't have guildid in guild table, report error
1521  sLog.outErrorDb("Guild %u does not exist but it has a record in guild_bank_right table, deleting it!", guildId);
1522  CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u'", guildId);
1523  continue;
1524  }
1525 
1526  if (guildId > m_Id)
1527  // we loaded all ranks for this guild bank already, break cycle
1528  break;
1529  uint8 TabId = fields[1].GetUInt8();
1530  uint32 rankId = fields[2].GetUInt32();
1531  uint16 right = fields[3].GetUInt16();
1532  uint16 SlotPerDay = fields[4].GetUInt16();
1533 
1534  SetBankRightsAndSlots(rankId, TabId, right, SlotPerDay, false);
1535 
1536  }
1537  while (guildBankTabRightsResult->NextRow());
1538 
1539  return true;
1540 }
1541 
1542 // *************************************************
1543 // Bank log related
1544 
1546 {
1547  // We can't add a limit as in Guild::LoadGuildEventLogFromDB since we fetch both money and bank log and know nothing about the composition
1548  // 0 1 2 3 4 5 6 7
1549  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT LogGuid, LogEntry, TabId, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog WHERE guildid='%u' ORDER BY TimeStamp DESC", m_Id);
1550  if (!result)
1551  return;
1552 
1553  do
1554  {
1555  Field* fields = result->Fetch();
1556  GuildBankEvent NewEvent;
1557 
1558  NewEvent.LogGuid = fields[0].GetUInt32();
1559  NewEvent.LogEntry = fields[1].GetUInt8();
1560  uint8 TabId = fields[2].GetUInt8();
1561  NewEvent.PlayerGuid = fields[3].GetUInt32();
1562  NewEvent.ItemOrMoney = fields[4].GetUInt32();
1563  NewEvent.ItemStackCount = fields[5].GetUInt8();
1564  NewEvent.DestTabId = fields[6].GetUInt8();
1565  NewEvent.TimeStamp = fields[7].GetUInt64();
1566 
1567  if (TabId >= GUILD_BANK_MAX_TABS)
1568  {
1569  sLog.outError("Guild::LoadGuildBankEventLogFromDB: Invalid tabid '%u' for guild bank log entry (guild: '%s', LogGuid: %u), skipped.", TabId, GetName().c_str(), NewEvent.LogGuid);
1570  continue;
1571  }
1572 
1573  if ((NewEvent.isMoneyEvent() && m_GuildBankEventLog_Money.size() >= GUILD_BANK_MAX_LOGS) ||
1574  (m_GuildBankEventLog_Item[TabId].size() >= GUILD_BANK_MAX_LOGS))
1575  continue;
1576 
1577  if (NewEvent.isMoneyEvent())
1578  m_GuildBankEventLog_Money.push_front(NewEvent);
1579  else
1580  m_GuildBankEventLog_Item[TabId].push_front(NewEvent);
1581 
1582  }
1583  while (result->NextRow());
1584 
1585  // Check lists size in case to many event entries in db for a tab or for money
1586  // This cases can happen only if a crash occured somewhere and table has too many log entries
1587  if (!m_GuildBankEventLog_Money.empty())
1588  {
1589  CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid=%u AND LogGuid < %u",
1590  m_Id, m_GuildBankEventLog_Money.front().LogGuid);
1591  }
1592  for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
1593  {
1594  if (!m_GuildBankEventLog_Item[i].empty())
1595  {
1596  CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid=%u AND LogGuid < %u",
1597  m_Id, m_GuildBankEventLog_Item[i].front().LogGuid);
1598  }
1599  }
1600 }
1601 
1603 {
1604  m_GuildBankEventLog_Money.clear();
1605 
1606  for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i)
1607  m_GuildBankEventLog_Item[i].clear();
1608 }
1609 
1611 {
1612  if (TabId > GUILD_BANK_MAX_TABS)
1613  return;
1614 
1615  if (TabId == GUILD_BANK_MAX_TABS)
1616  {
1617  // Here we display money logs
1618  WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Money.size() * (4 * 4 + 1) + 1 + 1);
1619  data << uint8(TabId); // Here GUILD_BANK_MAX_TABS
1620  data << uint8(m_GuildBankEventLog_Money.size()); // number of log entries
1621  for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Money.begin(); itr != m_GuildBankEventLog_Money.end(); ++itr)
1622  {
1623  data << uint8(itr->LogEntry);
1624  data << uint64(MAKE_NEW_GUID(itr->PlayerGuid, 0, HIGHGUID_PLAYER));
1625  data << uint32(itr->ItemOrMoney);
1626  data << uint32(time(NULL) - itr->TimeStamp);
1627  }
1628  session->SendPacket(&data);
1629  }
1630  else
1631  {
1632  // here we display current tab logs
1633  WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Item[TabId].size() * (4 * 4 + 1 + 1) + 1 + 1);
1634  data << uint8(TabId); // Here a real Tab Id
1635  // number of log entries
1636  data << uint8(m_GuildBankEventLog_Item[TabId].size());
1637  for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Item[TabId].begin(); itr != m_GuildBankEventLog_Item[TabId].end(); ++itr)
1638  {
1639  data << uint8(itr->LogEntry);
1640  data << uint64(MAKE_NEW_GUID(itr->PlayerGuid, 0, HIGHGUID_PLAYER));
1641  data << uint32(itr->ItemOrMoney);
1642  data << uint8(itr->ItemStackCount);
1643  if (itr->LogEntry == GUILD_BANK_LOG_MOVE_ITEM || itr->LogEntry == GUILD_BANK_LOG_MOVE_ITEM2)
1644  data << uint8(itr->DestTabId); // moved tab
1645  data << uint32(time(NULL) - itr->TimeStamp);
1646  }
1647  session->SendPacket(&data);
1648  }
1649  sLog.outDebug("WORLD: Sent (MSG_GUILD_BANK_LOG_QUERY)");
1650 }
1651 
1652 void Guild::LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount, uint8 DestTabId)
1653 {
1654  GuildBankEvent NewEvent;
1655 
1656  NewEvent.LogGuid = LogMaxGuid++;
1657  NewEvent.LogEntry = LogEntry;
1658  NewEvent.PlayerGuid = PlayerGuidLow;
1659  NewEvent.ItemOrMoney = ItemOrMoney;
1660  NewEvent.ItemStackCount = ItemStackCount;
1661  NewEvent.DestTabId = DestTabId;
1662  NewEvent.TimeStamp = uint32(time(NULL));
1663 
1664  if (NewEvent.isMoneyEvent())
1665  {
1667  {
1668  CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", m_Id, m_GuildBankEventLog_Money.front().LogGuid);
1669  m_GuildBankEventLog_Money.pop_front();
1670  }
1671  m_GuildBankEventLog_Money.push_back(NewEvent);
1672  }
1673  else
1674  {
1675  if (m_GuildBankEventLog_Item[TabId].size() > GUILD_BANK_MAX_LOGS)
1676  {
1677  CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", m_Id, m_GuildBankEventLog_Item[TabId].front().LogGuid);
1678  m_GuildBankEventLog_Item[TabId].pop_front();
1679  }
1680  m_GuildBankEventLog_Item[TabId].push_back(NewEvent);
1681  }
1682  CharacterDatabase.PExecute("INSERT INTO guild_bank_eventlog (guildid,LogGuid,LogEntry,TabId,PlayerGuid,ItemOrMoney,ItemStackCount,DestTabId,TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','%u','%u','" UI64FMTD "')",
1683  m_Id, NewEvent.LogGuid, uint32(NewEvent.LogEntry), uint32(TabId), NewEvent.PlayerGuid, NewEvent.ItemOrMoney, uint32(NewEvent.ItemStackCount), uint32(NewEvent.DestTabId), NewEvent.TimeStamp);
1684 }
1685 
1686 // This will renum guids used at load to prevent always going up until infinit
1688 {
1689  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT Min(LogGuid), Max(LogGuid) FROM guild_bank_eventlog WHERE guildid = %u", m_Id);
1690  if (!result)
1691  return;
1692 
1693  Field* fields = result->Fetch();
1694  CharacterDatabase.PExecute("UPDATE guild_bank_eventlog SET LogGuid=LogGuid-%u+1 WHERE guildid=%u ORDER BY LogGuid %s", fields[0].GetUInt32(), m_Id, fields[0].GetUInt32() ? "ASC" : "DESC");
1695  LogMaxGuid = fields[1].GetUInt32() + 1;
1696 }
1697 
1698 bool Guild::AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry)
1699 {
1700  CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid = '%u' AND TabId = '%u'AND SlotId = '%u'", GuildId, BankTab, BankTabSlot);
1701  CharacterDatabase.PExecute("INSERT INTO guild_bank_item (guildid,TabId,SlotId,item_guid,item_entry) "
1702  "VALUES ('%u', '%u', '%u', '%u', '%u')", GuildId, BankTab, BankTabSlot, GUIDLow, Entry);
1703  return true;
1704 }
1705 
1707 {
1708  Item* pItem = tab->Slots[slot];
1709  uint32 entry = pItem ? pItem->GetEntry() : 0;
1710 
1711  data << uint8(slot);
1712  data << uint32(entry);
1713  if (entry)
1714  {
1715  data << uint32(pItem->GetItemRandomPropertyId()); // random item property id + 8
1716 
1717  if (pItem->GetItemRandomPropertyId())
1718  data << uint32(pItem->GetItemSuffixFactor()); // SuffixFactor + 4
1719  data << uint8(pItem->GetCount()); // +12 // ITEM_FIELD_STACK_COUNT
1720  data << uint32(0); // +16 // Unknown value
1721  data << uint8(abs(pItem->GetSpellCharges())); // Charges
1722  if (uint32 Enchant0 = pItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT))
1723  {
1724  data << uint8(1); // number of enchantments (max 3) why max 3?
1725  data << uint8(PERM_ENCHANTMENT_SLOT); // enchantment Slot (range: 0:2)
1726  data << uint32(Enchant0); // enchantment m_Id
1727  }
1728  else
1729  data << uint8(0); // no enchantments (0)
1730  }
1731 }
1732 
1734 {
1735  if (!pItem)
1736  return NULL;
1737 
1738  Item* lastItem = pItem;
1739 
1740  for (GuildItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end();)
1741  {
1742  uint8 slot = itr->Slot;
1743  uint32 count = itr->Count;
1744 
1745  ++itr;
1746 
1747  if (itr == dest.end())
1748  {
1749  lastItem = _StoreItem(tabId, slot, pItem, count, false);
1750  break;
1751  }
1752 
1753  lastItem = _StoreItem(tabId, slot, pItem, count, true);
1754  }
1755 
1756  return lastItem;
1757 }
1758 
1759 // Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case.
1760 Item* Guild::_StoreItem(uint8 tab, uint8 slot, Item* pItem, uint32 count, bool clone)
1761 {
1762  if (!pItem)
1763  return NULL;
1764 
1765  sLog.outDebug("GUILD STORAGE: StoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count);
1766 
1767  Item* pItem2 = m_TabListMap[tab]->Slots[slot];
1768 
1769  if (!pItem2)
1770  {
1771  if (clone)
1772  pItem = pItem->CloneItem(count);
1773  else
1774  pItem->SetCount(count);
1775 
1776  if (!pItem)
1777  return NULL;
1778 
1779  m_TabListMap[tab]->Slots[slot] = pItem;
1780 
1782  pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0);
1783  AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry());
1784  pItem->FSetState(ITEM_NEW);
1785  pItem->SaveToDB(); // not in inventory and can be save standalone
1786 
1787  return pItem;
1788  }
1789  else
1790  {
1791  pItem2->SetCount(pItem2->GetCount() + count);
1792  pItem2->FSetState(ITEM_CHANGED);
1793  pItem2->SaveToDB(); // not in inventory and can be save standalone
1794 
1795  if (!clone)
1796  {
1797  pItem->RemoveFromWorld();
1798  pItem->DeleteFromDB();
1799  delete pItem;
1800  }
1801 
1802  return pItem2;
1803  }
1804 }
1805 
1807 {
1808  m_TabListMap[tab]->Slots[slot] = NULL;
1809  CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'",
1810  GetId(), uint32(tab), uint32(slot));
1811 }
1812 
1813 uint8 Guild::_CanStoreItem_InSpecificSlot(uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item* pSrcItem) const
1814 {
1815  Item* pItem2 = m_TabListMap[tab]->Slots[slot];
1816 
1817  // ignore move item (this slot will be empty at move)
1818  if (pItem2 == pSrcItem)
1819  pItem2 = NULL;
1820 
1821  uint32 need_space;
1822 
1823  // empty specific slot - check item fit to slot
1824  if (!pItem2 || swap)
1825  {
1826  // non empty stack with space
1827  need_space = pSrcItem->GetMaxStackCount();
1828  }
1829  // non empty slot, check item type
1830  else
1831  {
1832  // check item type
1833  if (pItem2->GetEntry() != pSrcItem->GetEntry())
1835 
1836  // check free space
1837  if (pItem2->GetCount() >= pSrcItem->GetMaxStackCount())
1839 
1840  need_space = pSrcItem->GetMaxStackCount() - pItem2->GetCount();
1841  }
1842 
1843  if (need_space > count)
1844  need_space = count;
1845 
1846  GuildItemPosCount newPosition = GuildItemPosCount(slot, need_space);
1847  if (!newPosition.isContainedIn(dest))
1848  {
1849  dest.push_back(newPosition);
1850  count -= need_space;
1851  }
1852 
1853  return EQUIP_ERR_OK;
1854 }
1855 
1856 uint8 Guild::_CanStoreItem_InTab(uint8 tab, GuildItemPosCountVec& dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot) const
1857 {
1858  for (uint32 j = 0; j < GUILD_BANK_MAX_SLOTS; ++j)
1859  {
1860  // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot
1861  if (j == skip_slot)
1862  continue;
1863 
1864  Item* pItem2 = m_TabListMap[tab]->Slots[j];
1865 
1866  // ignore move item (this slot will be empty at move)
1867  if (pItem2 == pSrcItem)
1868  pItem2 = NULL;
1869 
1870  // if merge skip empty, if !merge skip non-empty
1871  if ((pItem2 != NULL) != merge)
1872  continue;
1873 
1874  if (pItem2)
1875  {
1876  if (pItem2->GetEntry() == pSrcItem->GetEntry() && pItem2->GetCount() < pSrcItem->GetMaxStackCount())
1877  {
1878  uint32 need_space = pSrcItem->GetMaxStackCount() - pItem2->GetCount();
1879  if (need_space > count)
1880  need_space = count;
1881 
1882  GuildItemPosCount newPosition = GuildItemPosCount(j, need_space);
1883  if (!newPosition.isContainedIn(dest))
1884  {
1885  dest.push_back(newPosition);
1886  count -= need_space;
1887 
1888  if (count == 0)
1889  return EQUIP_ERR_OK;
1890  }
1891  }
1892  }
1893  else
1894  {
1895  uint32 need_space = pSrcItem->GetMaxStackCount();
1896  if (need_space > count)
1897  need_space = count;
1898 
1899  GuildItemPosCount newPosition = GuildItemPosCount(j, need_space);
1900  if (!newPosition.isContainedIn(dest))
1901  {
1902  dest.push_back(newPosition);
1903  count -= need_space;
1904 
1905  if (count == 0)
1906  return EQUIP_ERR_OK;
1907  }
1908  }
1909  }
1910  return EQUIP_ERR_OK;
1911 }
1912 
1913 uint8 Guild::CanStoreItem(uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item* pItem, bool swap) const
1914 {
1915  sLog.outDebug("GUILD STORAGE: CanStoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count);
1916 
1917  if (count > pItem->GetCount())
1919 
1920  if (pItem->IsSoulBound())
1922 
1923  // in specific slot
1924  if (slot != NULL_SLOT)
1925  {
1926  uint8 res = _CanStoreItem_InSpecificSlot(tab, slot, dest, count, swap, pItem);
1927  if (res != EQUIP_ERR_OK)
1928  return res;
1929 
1930  if (count == 0)
1931  return EQUIP_ERR_OK;
1932  }
1933 
1934  // not specific slot or have space for partly store only in specific slot
1935 
1936  // search stack in tab for merge to
1937  if (pItem->GetMaxStackCount() > 1)
1938  {
1939  uint8 res = _CanStoreItem_InTab(tab, dest, count, true, pItem, slot);
1940  if (res != EQUIP_ERR_OK)
1941  return res;
1942 
1943  if (count == 0)
1944  return EQUIP_ERR_OK;
1945  }
1946 
1947  // search free slot in bag for place to
1948  uint8 res = _CanStoreItem_InTab(tab, dest, count, false, pItem, slot);
1949  if (res != EQUIP_ERR_OK)
1950  return res;
1951 
1952  if (count == 0)
1953  return EQUIP_ERR_OK;
1954 
1955  return EQUIP_ERR_BANK_FULL;
1956 }
1957 
1958 void Guild::SetGuildBankTabText(uint8 TabId, std::string text)
1959 {
1960  if (TabId >= GUILD_BANK_MAX_TABS)
1961  return;
1962  if (TabId >= m_TabListMap.size())
1963  return;
1964  if (!m_TabListMap[TabId])
1965  return;
1966 
1967  if (m_TabListMap[TabId]->Text == text)
1968  return;
1969 
1970  utf8truncate(text, 500); // DB and client size limitation
1971 
1972  m_TabListMap[TabId]->Text = text;
1973 
1975  CharacterDatabase.PExecute("UPDATE guild_bank_tab SET TabText='%s' WHERE guildid='%u' AND TabId='%u'", text.c_str(), m_Id, uint32(TabId));
1976 
1977  // announce
1978  SendGuildBankTabText(NULL, TabId);
1979 }
1980 
1982 {
1983  if (TabId > GUILD_BANK_MAX_TABS)
1984  return;
1985 
1986  GuildBankTab const* tab = GetBankTab(TabId);
1987  if (!tab)
1988  return;
1989 
1990  WorldPacket data(MSG_QUERY_GUILD_BANK_TEXT, 1 + tab->Text.size() + 1);
1991  data << uint8(TabId);
1992  data << tab->Text;
1993 
1994  if (session)
1995  session->SendPacket(&data);
1996  else
1997  BroadcastPacket(&data);
1998 }
1999 
2000 void Guild::BroadcastEvent(GuildEvents event, uint64 guid, char const* str1 /*=NULL*/, char const* str2 /*=NULL*/, char const* str3 /*=NULL*/)
2001 {
2002  uint8 strCount = !str1 ? 0 : (!str2 ? 1 : (!str3 ? 2 : 3));
2003 
2004  WorldPacket data(SMSG_GUILD_EVENT, 1 + 1 + 1 * strCount + (!guid ? 0 : 8));
2005  data << uint8(event);
2006  data << uint8(strCount);
2007 
2008  if (str3)
2009  {
2010  data << str1;
2011  data << str2;
2012  data << str3;
2013  }
2014  else if (str2)
2015  {
2016  data << str1;
2017  data << str2;
2018  }
2019  else if (str1)
2020  data << str1;
2021 
2022  if (guid)
2023  data << guid;
2024 
2025  BroadcastPacket(&data);
2026 
2027  DEBUG_LOG("WORLD: Sent SMSG_GUILD_EVENT");
2028 }
2029 
2031 {
2032  for (GuildItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end(); ++itr)
2033  if (itr->Slot == this->Slot)
2034  return true;
2035 
2036  return false;
2037 }
2038 
bool LoadBankRightsFromDB(QueryResult_AutoPtr guildBankTabRightsResult)
Definition: Guild.cpp:1506
void LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank)
Definition: Guild.cpp:952
uint8 EventType
Definition: Guild.h:175
void SendMoneyInfo(WorldSession *session, uint32 LowGuid)
Definition: Guild.cpp:1315
uint32 GetCount() const
Definition: Item.h:251
void AddRank(const std::string &name, uint32 rights, uint32 money)
Definition: Guild.cpp:651
uint32 BankRemSlotsTab[GUILD_BANK_MAX_TABS]
Definition: Guild.h:244
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:330
#define GUILD_BANK_MAX_SLOTS
uint32 PlayerGuid1
Definition: Guild.h:176
void AppendDisplayGuildBankSlot(WorldPacket &data, GuildBankTab const *tab, int32 slot)
Definition: Guild.cpp:1706
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
void SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint32 SlotPerDay, bool db)
Definition: Guild.cpp:1449
void CreateRank(std::string m_Name, uint32 rights)
Definition: Guild.cpp:634
uint32 LogMaxGuid
Definition: Guild.h:528
TabListMap m_TabListMap
Definition: Guild.h:509
uint32 ZoneId
Definition: Guild.h:237
int32 GetRank(uint32 LowGuid)
Definition: Guild.cpp:707
bool isContainedIn(std::vector< GuildItemPosCount > const &vec) const
Definition: Guild.cpp:2030
std::string Icon
Definition: Guild.h:215
uint32 GetLowestRank() const
Definition: Guild.h:337
uint32 m_GuildEventLogNextGuid
Definition: Guild.h:518
void SetInGuild(uint32 GuildId)
Definition: Player.h:1811
GuildBankEventLog m_GuildBankEventLog_Item[GUILD_BANK_MAX_TABS]
Definition: Guild.h:516
void SetGuildBankTabInfo(uint8 TabId, std::string m_Name, std::string icon)
Definition: Guild.cpp:1160
uint32 GetItemSuffixFactor() const
Definition: Item.h:302
bool BeginTransaction()
Definition: Database.cpp:533
void LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0)
Definition: Guild.cpp:1652
#define GUILD_BANK_MAX_LOGS
void DelMember(uint64 guid, bool isDisbanding=false)
Definition: Guild.cpp:484
bool LoadMembersFromDB(QueryResult_AutoPtr guildMembersResult)
Definition: Guild.cpp:320
bool IsSoulBound() const
Definition: Item.h:219
virtual void DeleteFromDB()
Definition: Item.cpp:450
uint32 GetMaxStackCount() const
Definition: Item.h:259
QueryResult_AutoPtr PQuery(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:400
void BroadcastEvent(GuildEvents event, uint64 guid, char const *str1=NULL, char const *str2=NULL, char const *str3=NULL)
Definition: Guild.cpp:2000
Item * CloneItem(uint32 count, Player const *player=NULL) const
Definition: Item.cpp:963
uint32 RankId
Definition: Guild.h:234
uint32 m_Id
Definition: Guild.h:488
uint32 BankRemMoney
Definition: Guild.h:242
uint8 ItemStackCount
Definition: Guild.h:199
void FSetState(ItemUpdateState state)
Definition: Item.h:358
Definition: Field.h:24
void utf8truncate(std::string &utf8str, size_t len)
Definition: Util.cpp:234
#define WITHDRAW_MONEY_UNLIMITED
Definition: Guild.h:21
void SetBankMoneyPerDay(uint32 rankId, uint32 money)
Definition: Guild.cpp:1431
virtual void SaveToDB()
Definition: Item.cpp:286
bool HasIgnore(uint32 ignore_guid)
Definition: SocialMgr.cpp:162
uint32 m_GuildBankEventLogNextGuid_Item[GUILD_BANK_MAX_TABS]
Definition: Guild.h:520
uint64 m_LeaderGuid
Definition: Guild.h:490
uint32 m_BackgroundColor
Definition: Guild.h:501
std::string Text
Definition: Guild.h:216
std::string MOTD
Definition: Guild.h:491
uint32 GetZoneId() const
Definition: Object.cpp:1179
uint32 m_accountsNumber
Definition: Guild.h:502
uint32 GetBankRights(uint32 rankId, uint8 TabId) const
Definition: Guild.cpp:1195
void DisplayGuildBankLogs(WorldSession *session, uint8 TabId)
Definition: Guild.cpp:1610
std::string GINFO
Definition: Guild.h:492
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 m_BorderStyle
Definition: Guild.h:499
MemberList members
Definition: Guild.h:506
void SetEmblem(uint32 m_EmblemStyle, uint32 m_EmblemColor, uint32 m_BorderStyle, uint32 m_BorderColor, uint32 m_BackgroundColor)
Definition: Guild.cpp:819
ACE_INT32 int32
Definition: Define.h:67
uint64 GetGuildBankMoney()
Definition: Guild.h:462
unsigned long escape_string(char *to, const char *from, unsigned long length)
Definition: Database.cpp:212
void BroadcastPacketToRank(WorldPacket *packet, uint32 rankId)
Definition: Guild.cpp:621
std::string const & GetName() const
Definition: Guild.h:286
bool LoadGuildFromDB(QueryResult_AutoPtr guildDataResult)
Definition: Guild.cpp:193
GuildBankEventLog m_GuildBankEventLog_Money
Definition: Guild.h:515
uint8 m_PurchasedTabs
Definition: Guild.h:526
void UpdateAccountsNumber()
Definition: Guild.cpp:851
void LoadGuildBankEventLogFromDB()
Definition: Guild.cpp:1545
uint32 ItemOrMoney
Definition: Guild.h:198
void SetLeader(uint64 guid)
Definition: Guild.cpp:476
static uint32 GetZoneIdFromDB(uint64 guid)
Definition: Player.cpp:6219
~Guild()
Definition: Guild.cpp:56
bool isMoneyEvent() const
Definition: Guild.h:203
void UnloadGuildEventlog()
Definition: Guild.cpp:930
uint32 GetAccountId() const
Definition: WorldSession.h:100
void SetCount(uint32 value)
Definition: Item.h:255
Player * GetPlayer() const
Definition: WorldSession.h:104
uint32 GetGUIDLow() const
Definition: Object.h:166
uint8 DestTabId
Definition: Guild.h:200
void UpdateLogoutTime(uint64 guid)
Definition: Guild.cpp:830
std::string m_Name
Definition: Guild.h:489
#define GUILD_RANKS_MIN_COUNT
Definition: Guild.h:28
void LoadGuildBankFromDB()
Definition: Guild.cpp:1207
uint32 m_CreatedDay
Definition: Guild.h:495
uint32 LogGuid
Definition: Guild.h:194
int32 GetItemRandomPropertyId() const
Definition: Item.h:298
uint64 TimeStamp
Definition: Guild.h:179
static void RemovePetitionsAndSigns(uint64 guid, uint32 type)
Definition: Player.cpp:17662
#define sObjectMgr
Definition: ObjectMgr.h:1285
int32 accountId
Definition: Guild.h:232
void SendPacket(WorldPacket const *packet)
Item * Slots[GUILD_BANK_MAX_SLOTS]
Definition: Guild.h:213
bool CommitTransaction()
Definition: Database.cpp:551
bool LoadRanksFromDB(QueryResult_AutoPtr guildRanksResult)
Definition: Guild.cpp:247
#define GUILD_MAX_RANKS
void DisplayGuildBankContent(WorldSession *session, uint8 TabId)
Definition: Guild.cpp:979
void Disband()
Definition: Guild.cpp:716
void SetGuildBankTabText(uint8 TabId, std::string text)
Definition: Guild.cpp:1958
void BroadcastToGuild(WorldSession *session, const std::string &msg, uint32 language=LANG_UNIVERSAL)
Definition: Guild.cpp:577
Definition: Common.h:181
std::string Pnote
Definition: Guild.h:239
uint8 getLevel() const
Definition: Unit.h:1057
virtual void RemoveFromWorld()
Definition: Object.h:151
void SetRank(uint32 rankId)
Definition: Player.h:1815
uint32 PlayerGuid2
Definition: Guild.h:177
Definition: Common.h:179
std::vector< GuildItemPosCount > GuildItemPosCountVec
Definition: Guild.h:228
void SetRankRights(uint32 rankId, uint32 rights)
Definition: Guild.cpp:697
uint8 _CanStoreItem_InTab(uint8 tab, GuildItemPosCountVec &dest, uint32 &count, bool merge, Item *pSrcItem, uint8 skip_slot) const
Definition: Guild.cpp:1856
size_t wpos() const
Definition: ByteBuffer.h:264
uint64 LogoutTime
Definition: Guild.h:238
uint32 m_GuildBankEventLogNextGuid_Money
Definition: Guild.h:519
void SetGuildIdInvited(uint32 GuildId)
Definition: Player.h:1819
ACE_UINT8 uint8
Definition: Define.h:73
#define UI64FMTD
Definition: Common.h:149
PlayerSocial * GetSocial()
Definition: Player.h:985
std::string GetCppString() const
Definition: Field.h:52
uint32 GetMemberMoneyWithdrawRem(uint32 LowGuid)
Definition: Guild.cpp:1410
Item * NewItemOrBag(ItemTemplate const *proto)
Definition: Bag.h:70
void SetRankName(uint32 rankId, std::string name)
Definition: Guild.cpp:685
std::string Name
Definition: Guild.h:233
Definition: adtfile.h:38
uint64 TimeStamp
Definition: Guild.h:201
uint8 Level
Definition: Guild.h:235
void put(size_t pos, T value)
Definition: ByteBuffer.h:79
uint32 m_EmblemColor
Definition: Guild.h:498
#define MAKE_NEW_GUID(l, e, h)
Definition: ObjectGuid.h:80
uint32 BankResetTimeMoney
Definition: Guild.h:241
Definition: Item.h:196
static Player * FindPlayer(uint64, bool force=false)
void BroadcastPacket(WorldPacket *packet)
Definition: Guild.cpp:611
void LoadGuildEventLogFromDB()
Definition: Guild.cpp:895
uint32 GetRank()
Definition: Player.h:1828
static uint32 GetGuildIdFromDB(uint64 guid)
Definition: Player.cpp:6181
uint32 GetRankRights(uint32 rankId)
Definition: Guild.cpp:677
void CreateNewBankTab()
Definition: Guild.cpp:1142
#define DEBUG_LOG(...)
Definition: Log.h:194
bool MemberMoneyWithdraw(uint32 amount, uint32 LowGuid)
Definition: Guild.cpp:1323
bool CheckGuildStructure()
Definition: Guild.cpp:228
void SetPNOTE(uint64 guid, std::string pnote)
Definition: Guild.cpp:553
std::string OFFnote
Definition: Guild.h:240
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
std::string Name
Definition: Guild.h:214
#define WITHDRAW_SLOT_UNLIMITED
Definition: Guild.h:22
void SetUInt64Value(uint16 index, const uint64 &value)
Definition: Object.cpp:798
void SetMOTD(std::string motd)
Definition: Guild.cpp:175
void DelRank()
Definition: Guild.cpp:656
uint32 GetGuildId()
Definition: Player.h:1823
void RenumGuildEventlog()
Definition: Guild.cpp:940
#define MAX_CLASSES
Definition: SharedDefines.h:91
void SetOFFNOTE(uint64 guid, std::string offnote)
Definition: Guild.cpp:566
const char * GetName() const
Definition: Object.h:704
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field *fields)
Definition: Item.cpp:369
Item * _StoreItem(uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone)
Definition: Guild.cpp:1760
ACE_UINT64 uint64
Definition: Define.h:70
void UnloadGuildBank()
Definition: Guild.cpp:1290
uint32 m_onlinemembers
Definition: Guild.h:524
uint32 GetBankMoneyPerDay(uint32 rankId)
Definition: Guild.cpp:1483
uint64 m_GuildBankMoney
Definition: Guild.h:525
bool FillPlayerData(uint64 guid, MemberSlot *memslot)
Definition: Guild.cpp:401
void Roster(WorldSession *session=NULL)
Definition: Guild.cpp:738
uint32 m_BorderColor
Definition: Guild.h:500
virtual void AddToWorld()
Definition: Object.h:139
GuildEventlog m_GuildEventlog
Definition: Guild.h:514
uint8 LogEntry
Definition: Guild.h:195
uint32 m_CreatedYear
Definition: Guild.h:493
uint8 Class
Definition: Guild.h:236
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
int GetSessionDbLocaleIndex() const
Definition: WorldSession.h:237
bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId, uint32 rights) const
Definition: Guild.cpp:1375
Definition: Common.h:180
ACE_INT64 int64
Definition: Define.h:66
void LoadPlayerStatsByGuid(uint64 guid)
Definition: Guild.cpp:462
Guild()
Definition: Guild.cpp:29
uint32 BankResetTimeTab[GUILD_BANK_MAX_TABS]
Definition: Guild.h:243
std::string GetRankName(uint32 rankId)
Definition: Guild.cpp:669
uint32 GetId()
Definition: Guild.h:278
void RenumBankLogs()
Definition: Guild.cpp:1687
void DisplayGuildBankMoneyUpdate()
Definition: Guild.cpp:1006
void SetGINFO(std::string ginfo)
Definition: Guild.cpp:184
void SendGuildBankTabText(WorldSession *session, uint8 TabId)
Definition: Guild.cpp:1981
uint8 CanStoreItem(uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32 count, Item *pItem, bool swap=false) const
Definition: Guild.cpp:1913
uint32 GetBankSlotPerDay(uint32 rankId, uint8 TabId)
Definition: Guild.cpp:1493
uint8 getClass() const
Definition: Unit.h:1062
uint32 GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId)
Definition: Guild.cpp:1387
bool AddMember(uint64 plGuid, uint32 plRank)
Definition: Guild.cpp:121
void BroadcastToOfficers(WorldSession *session, const std::string &msg, uint32 language=LANG_UNIVERSAL)
Definition: Guild.cpp:594
void CreateBankRightForTab(uint32 rankid, uint8 TabId)
Definition: Guild.cpp:1181
Item * StoreItem(uint8 tab, GuildItemPosCountVec const &pos, Item *pItem)
Definition: Guild.cpp:1733
bool HasRankRight(uint32 rankId, uint32 right)
Definition: Guild.h:387
uint8 _CanStoreItem_InSpecificSlot(uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32 &count, bool swap, Item *pSrcItem) const
Definition: Guild.cpp:1813
#define GUILD_EVENTLOG_MAX_ENTRIES
uint32 GuildEventlogMaxGuid
Definition: Guild.h:529
Item * GetItem(uint8 TabId, uint8 SlotId)
Definition: Guild.cpp:1106
void CreateDefaultGuildRanks(int locale_idx)
Definition: Guild.cpp:109
void SetBankMoney(int64 money)
Definition: Guild.cpp:1344
bool m_bankloaded
Definition: Guild.h:522
uint32 GetEntry() const
Definition: Object.h:192
WorldSession * GetSession() const
Definition: Player.h:1944
void UnloadGuildBankEventLog()
Definition: Guild.cpp:1602
uint32 m_EmblemStyle
Definition: Guild.h:497
RankList m_Ranks
Definition: Guild.h:504
Definition: Item.h:188
void DisplayGuildEventlog(WorldSession *session)
Definition: Guild.cpp:865
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
ACE_UINT16 uint16
Definition: Define.h:72
bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab, uint32 BankTabSlot, uint32 GUIDLow, uint32 Entry)
Definition: Guild.cpp:1698
uint32 m_CreatedMonth
Definition: Guild.h:494
void DisplayGuildBankTabsInfo(WorldSession *session)
Definition: Guild.cpp:1116
const GuildBankTab * GetBankTab(uint8 index)
Definition: Guild.h:444
ACE_UINT32 uint32
Definition: Define.h:71
void Query(WorldSession *session)
Definition: Guild.cpp:794
Definition: Player.h:922
Definition: Guild.h:107
bool Create(Player *leader, std::string gname)
Definition: Guild.cpp:61
GuildEvents
Definition: Guild.h:101
void RemoveItem(uint8 tab, uint8 slot)
Definition: Guild.cpp:1806
void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2=-1)
Definition: Guild.cpp:1020
void ChangeRank(uint64 guid, uint32 newRank)
Definition: Guild.cpp:539
uint32 PlayerGuid
Definition: Guild.h:197
#define STRONG_MAX_LEVEL
Definition: DBCEnums.h:32
#define GUILD_BANK_MAX_TABS
static void FillMessageData(WorldPacket *data, WorldSession *session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker)
Definition: Chat.cpp:1518
bool m_eventlogloaded
Definition: Guild.h:523
uint32 LogGuid
Definition: Guild.h:174
bool MemberItemWithdraw(uint8 TabId, uint32 LowGuid)
Definition: Guild.cpp:1356
const uint64 & GetGUID() const
Definition: Object.h:162
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:313