mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[9353] Some fixes to guild/arenateam events.
This commit is contained in:
parent
1aa6c8eac9
commit
0bd88dd55a
12 changed files with 317 additions and 347 deletions
|
|
@ -281,10 +281,10 @@ bool Guild::LoadRanksFromDB(QueryResult *guildRanksResult)
|
|||
Field *fields;
|
||||
bool broken_ranks = false;
|
||||
|
||||
//GUILD RANKS are sequence starting from 0 = GUILD_MASTER (ALL PRIVILEGES) to max 9 (lowest privileges)
|
||||
//the lower rank id is considered higher rank - so promotion does rank-- and demotion does rank++
|
||||
//between ranks in sequence cannot be gaps - so 0,1,2,4 cannot be
|
||||
//min ranks count is 5 and max is 10.
|
||||
// GUILD RANKS are sequence starting from 0 = GUILD_MASTER (ALL PRIVILEGES) to max 9 (lowest privileges)
|
||||
// the lower rank id is considered higher rank - so promotion does rank-- and demotion does rank++
|
||||
// between ranks in sequence cannot be gaps - so 0,1,2,4 cannot be
|
||||
// min ranks count is 5 and max is 10.
|
||||
|
||||
do
|
||||
{
|
||||
|
|
@ -354,26 +354,26 @@ bool Guild::LoadMembersFromDB(QueryResult *guildMembersResult)
|
|||
do
|
||||
{
|
||||
Field *fields = guildMembersResult->Fetch();
|
||||
//this condition will be true when all rows in QueryResult are processed and new guild without members is going to be loaded - prevent crash
|
||||
// this condition will be true when all rows in QueryResult are processed and new guild without members is going to be loaded - prevent crash
|
||||
if (!fields)
|
||||
break;
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
if (guildId < m_Id)
|
||||
{
|
||||
//there is in table guild_member record which doesn't have guildid in guild table, report error
|
||||
// there is in table guild_member record which doesn't have guildid in guild table, report error
|
||||
sLog.outErrorDb("Guild %u does not exist but it has a record in guild_member table, deleting it!", guildId);
|
||||
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guildid = '%u'", guildId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (guildId > m_Id)
|
||||
//we loaded all members for this guild already, break cycle
|
||||
// we loaded all members for this guild already, break cycle
|
||||
break;
|
||||
|
||||
MemberSlot newmember;
|
||||
uint64 guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
newmember.RankId = fields[2].GetUInt32();
|
||||
//don't allow member to have not existing rank!
|
||||
// don't allow member to have not existing rank!
|
||||
if (newmember.RankId >= m_Ranks.size())
|
||||
newmember.RankId = GetLowestRank();
|
||||
|
||||
|
|
@ -393,7 +393,7 @@ bool Guild::LoadMembersFromDB(QueryResult *guildMembersResult)
|
|||
newmember.ZoneId = fields[22].GetUInt32();
|
||||
newmember.LogoutTime = fields[23].GetUInt64();
|
||||
|
||||
//this code will remove unexisting character guids from guild
|
||||
// this code will remove not existing character guids from guild
|
||||
if (newmember.Level < 1 || newmember.Level > STRONG_MAX_LEVEL) // can be at broken `data` field
|
||||
{
|
||||
sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`data`, deleting him from guild!",GUID_LOPART(guid));
|
||||
|
|
@ -449,8 +449,8 @@ void Guild::SetLeader(uint64 guid)
|
|||
|
||||
void Guild::DelMember(uint64 guid, bool isDisbanding)
|
||||
{
|
||||
//guild master can be deleted when loading guild and guid doesn't exist in characters table
|
||||
//or when he is removed from guild by gm command
|
||||
// guild master can be deleted when loading guild and guid doesn't exist in characters table
|
||||
// or when he is removed from guild by gm command
|
||||
if (m_LeaderGuid == guid && !isDisbanding)
|
||||
{
|
||||
MemberSlot* oldLeader = NULL;
|
||||
|
|
@ -485,21 +485,10 @@ void Guild::DelMember(uint64 guid, bool isDisbanding)
|
|||
// when leader non-exist (at guild load with deleted leader only) not send broadcasts
|
||||
if (oldLeader)
|
||||
{
|
||||
WorldPacket data(SMSG_GUILD_EVENT, (1+1+(oldLeader->Name).size()+1+(best->Name).size()+1));
|
||||
data << (uint8)GE_LEADER_CHANGED;
|
||||
data << (uint8)2;
|
||||
data << oldLeader->Name;
|
||||
data << best->Name;
|
||||
BroadcastPacket(&data);
|
||||
BroadcastEvent(GE_LEADER_CHANGED, 0, 2, oldLeader->Name, best->Name, "");
|
||||
|
||||
data.Initialize(SMSG_GUILD_EVENT, (1+1+(oldLeader->Name).size()+1));
|
||||
data << (uint8)GE_LEFT;
|
||||
data << (uint8)1;
|
||||
data << oldLeader->Name;
|
||||
BroadcastPacket(&data);
|
||||
BroadcastEvent(GE_LEFT, guid, 1, oldLeader->Name, "", "");
|
||||
}
|
||||
|
||||
sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" );
|
||||
}
|
||||
|
||||
members.erase(GUID_LOPART(guid));
|
||||
|
|
@ -620,11 +609,11 @@ void Guild::CreateRank(std::string name_,uint32 rights)
|
|||
|
||||
AddRank(name_, rights, 0);
|
||||
|
||||
//existing records in db should be deleted before calling this procedure and m_PurchasedTabs must be loaded already
|
||||
// existing records in db should be deleted before calling this procedure and m_PurchasedTabs must be loaded already
|
||||
|
||||
for (uint32 i = 0; i < m_PurchasedTabs; ++i)
|
||||
{
|
||||
//create bank rights with 0
|
||||
// create bank rights with 0
|
||||
CharacterDatabase.PExecute("INSERT INTO guild_bank_right (guildid,TabId,rid) VALUES ('%u','%u','%u')", m_Id, i, new_rank_id);
|
||||
}
|
||||
// name now can be used for encoding to DB
|
||||
|
|
@ -700,9 +689,7 @@ int32 Guild::GetRank(uint32 LowGuid)
|
|||
|
||||
void Guild::Disband()
|
||||
{
|
||||
WorldPacket data(SMSG_GUILD_EVENT, 1);
|
||||
data << (uint8)GE_DISBANDED;
|
||||
BroadcastPacket(&data);
|
||||
BroadcastEvent(GE_DISBANDED, 0, 0, "", "", "");
|
||||
|
||||
while (!members.empty())
|
||||
{
|
||||
|
|
@ -727,11 +714,11 @@ void Guild::Roster(WorldSession *session /*= NULL*/)
|
|||
{
|
||||
// we can only guess size
|
||||
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));
|
||||
data << (uint32)members.size();
|
||||
data << uint32(members.size());
|
||||
data << MOTD;
|
||||
data << GINFO;
|
||||
|
||||
data << (uint32)m_Ranks.size();
|
||||
data << uint32(m_Ranks.size());
|
||||
for (RankList::const_iterator ritr = m_Ranks.begin(); ritr != m_Ranks.end(); ++ritr)
|
||||
{
|
||||
data << uint32(ritr->Rights);
|
||||
|
|
@ -783,7 +770,7 @@ void Guild::Query(WorldSession *session)
|
|||
{
|
||||
WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (8*32+200));// we can only guess size
|
||||
|
||||
data << m_Id;
|
||||
data << uint32(m_Id);
|
||||
data << m_Name;
|
||||
|
||||
for (size_t i = 0 ; i < GUILD_RANKS_MAX_COUNT; ++i) // show always 10 ranks
|
||||
|
|
@ -791,7 +778,7 @@ void Guild::Query(WorldSession *session)
|
|||
if (i < m_Ranks.size())
|
||||
data << m_Ranks[i].Name;
|
||||
else
|
||||
data << (uint8)0; // null string
|
||||
data << uint8(0); // null string
|
||||
}
|
||||
|
||||
data << uint32(m_EmblemStyle);
|
||||
|
|
@ -799,7 +786,7 @@ void Guild::Query(WorldSession *session)
|
|||
data << uint32(m_BorderStyle);
|
||||
data << uint32(m_BorderColor);
|
||||
data << uint32(m_BackgroundColor);
|
||||
data << uint32(0); // something new in WotLK
|
||||
data << uint32(0); // probably real ranks count
|
||||
|
||||
session->SendPacket( &data );
|
||||
sLog.outDebug( "WORLD: Sent (SMSG_GUILD_QUERY_RESPONSE)" );
|
||||
|
|
@ -981,7 +968,7 @@ void Guild::DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2)
|
|||
data << uint8(2); // item count
|
||||
|
||||
if (slot1 > slot2)
|
||||
std::swap(slot1,slot2);
|
||||
std::swap(slot1, slot2);
|
||||
|
||||
AppendDisplayGuildBankSlot(data, tab, slot1);
|
||||
AppendDisplayGuildBankSlot(data, tab, slot2);
|
||||
|
|
@ -996,7 +983,7 @@ void Guild::DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2)
|
|||
if (!IsMemberHaveRights(itr->first,TabId,GUILD_BANK_RIGHT_VIEW_TAB))
|
||||
continue;
|
||||
|
||||
data.put<uint32>(rempos,uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId)));
|
||||
data.put<uint32>(rempos, uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId)));
|
||||
|
||||
player->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
|
@ -1264,7 +1251,7 @@ bool Guild::IsMemberHaveRights(uint32 LowGuid, uint8 TabId, uint32 rights) const
|
|||
if (itr->second.RankId == GR_GUILDMASTER)
|
||||
return true;
|
||||
|
||||
return (GetBankRights(itr->second.RankId,TabId) & rights) == rights;
|
||||
return (GetBankRights(itr->second.RankId, TabId) & rights) == rights;
|
||||
}
|
||||
|
||||
uint32 Guild::GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId)
|
||||
|
|
@ -1335,7 +1322,7 @@ void Guild::SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint
|
|||
TabId >= GUILD_BANK_MAX_TABS ||
|
||||
TabId >= m_PurchasedTabs)
|
||||
{
|
||||
//TODO remove next line, It is there just to repair existing bug in deleting guild rank
|
||||
// TODO remove next line, It is there just to repair existing bug in deleting guild rank
|
||||
CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid='%u' AND rid='%u' AND TabId='%u'", m_Id, rankId, TabId);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1394,20 +1381,20 @@ bool Guild::LoadBankRightsFromDB(QueryResult *guildBankTabRightsResult)
|
|||
do
|
||||
{
|
||||
Field *fields = guildBankTabRightsResult->Fetch();
|
||||
//prevent crash when all rights in result are already processed
|
||||
// prevent crash when all rights in result are already processed
|
||||
if (!fields)
|
||||
break;
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
if (guildId < m_Id)
|
||||
{
|
||||
//there is in table guild_bank_right record which doesn't have guildid in guild table, report error
|
||||
// there is in table guild_bank_right record which doesn't have guildid in guild table, report error
|
||||
sLog.outErrorDb("Guild %u does not exist but it has a record in guild_bank_right table, deleting it!", guildId);
|
||||
CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u'", guildId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (guildId > m_Id)
|
||||
//we loaded all ranks for this guild bank already, break cycle
|
||||
// we loaded all ranks for this guild bank already, break cycle
|
||||
break;
|
||||
uint8 TabId = fields[1].GetUInt8();
|
||||
uint32 rankId = fields[2].GetUInt32();
|
||||
|
|
@ -1428,8 +1415,8 @@ void Guild::LoadGuildBankEventLogFromDB()
|
|||
{
|
||||
// Money log is in TabId = GUILD_BANK_MONEY_LOGS_TAB
|
||||
|
||||
//uint32 configCount = sWorld.getConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT);
|
||||
//cycle through all purchased guild bank item tabs
|
||||
// uint32 configCount = sWorld.getConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT);
|
||||
// cycle through all purchased guild bank item tabs
|
||||
for (uint32 tabId = 0; tabId < m_PurchasedTabs; ++tabId)
|
||||
{
|
||||
// 0 1 2 3 4 5 6
|
||||
|
|
@ -1450,7 +1437,7 @@ void Guild::LoadGuildBankEventLogFromDB()
|
|||
NewEvent.DestTabId = fields[5].GetUInt8();
|
||||
NewEvent.TimeStamp = fields[6].GetUInt64();
|
||||
|
||||
//if newEvent is moneyEvent, move it to moneyEventTab in DB and report error
|
||||
// if newEvent is moneyEvent, move it to moneyEventTab in DB and report error
|
||||
if (NewEvent.isMoneyEvent())
|
||||
{
|
||||
uint32 logGuid = fields[0].GetUInt32();
|
||||
|
|
@ -1459,21 +1446,21 @@ void Guild::LoadGuildBankEventLogFromDB()
|
|||
continue;
|
||||
}
|
||||
else
|
||||
//add event to list
|
||||
//events are ordered from oldest (in beginning) to latest (in the end)
|
||||
// add event to list
|
||||
// events are ordered from oldest (in beginning) to latest (in the end)
|
||||
m_GuildBankEventLog_Item[tabId].push_front(NewEvent);
|
||||
|
||||
if (!isNextLogGuidSet)
|
||||
{
|
||||
m_GuildBankEventLogNextGuid_Item[tabId] = fields[0].GetUInt32();
|
||||
//we don't have to do m_GuildBankEventLogNextGuid_Item[tabId] %= configCount; - it will be done when creating new record
|
||||
// we don't have to do m_GuildBankEventLogNextGuid_Item[tabId] %= configCount; - it will be done when creating new record
|
||||
isNextLogGuidSet = true;
|
||||
}
|
||||
} while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
|
||||
//special handle for guild bank money log
|
||||
// special handle for guild bank money log
|
||||
// 0 1 2 3 4 5 6
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog WHERE guildid='%u' AND TabId='%u' ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, GUILD_BANK_MONEY_LOGS_TAB, GUILD_BANK_MAX_LOGS);
|
||||
if (!result)
|
||||
|
|
@ -1486,7 +1473,7 @@ void Guild::LoadGuildBankEventLogFromDB()
|
|||
if (!isNextMoneyLogGuidSet)
|
||||
{
|
||||
m_GuildBankEventLogNextGuid_Money = fields[0].GetUInt32();
|
||||
//we don't have to do m_GuildBankEventLogNextGuid_Money %= configCount; - it will be done when creating new record
|
||||
// we don't have to do m_GuildBankEventLogNextGuid_Money %= configCount; - it will be done when creating new record
|
||||
isNextMoneyLogGuidSet = true;
|
||||
}
|
||||
GuildBankEventLogEntry NewEvent;
|
||||
|
|
@ -1498,12 +1485,12 @@ void Guild::LoadGuildBankEventLogFromDB()
|
|||
NewEvent.DestTabId = fields[5].GetUInt8();
|
||||
NewEvent.TimeStamp = fields[6].GetUInt64();
|
||||
|
||||
//if newEvent is not moneyEvent, then report error
|
||||
// if newEvent is not moneyEvent, then report error
|
||||
if (!NewEvent.isMoneyEvent())
|
||||
sLog.outError("GuildBankEventLog ERROR: MoneyEvent LogGuid %u for Guild %u is not MoneyEvent - ignoring...", fields[0].GetUInt32(), m_Id);
|
||||
else
|
||||
//add event to list
|
||||
//events are ordered from oldest (in beginning) to latest (in the end)
|
||||
// add event to list
|
||||
// events are ordered from oldest (in beginning) to latest (in the end)
|
||||
m_GuildBankEventLog_Money.push_front(NewEvent);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
|
@ -1579,7 +1566,7 @@ void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId)
|
|||
|
||||
void Guild::LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount, uint8 DestTabId)
|
||||
{
|
||||
//create Event
|
||||
// create Event
|
||||
GuildBankEventLogEntry NewEvent;
|
||||
NewEvent.EventType = EventType;
|
||||
NewEvent.PlayerGuid = PlayerGuidLow;
|
||||
|
|
@ -1588,7 +1575,7 @@ void Guild::LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uin
|
|||
NewEvent.DestTabId = DestTabId;
|
||||
NewEvent.TimeStamp = uint32(time(NULL));
|
||||
|
||||
//add new event to the end of event list
|
||||
// add new event to the end of event list
|
||||
uint32 currentTabId = TabId;
|
||||
uint32 currentLogGuid = 0;
|
||||
if (NewEvent.isMoneyEvent())
|
||||
|
|
@ -1611,7 +1598,7 @@ void Guild::LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uin
|
|||
m_GuildBankEventLog_Item[TabId].push_back(NewEvent);
|
||||
}
|
||||
|
||||
//save event to database
|
||||
// save event to database
|
||||
CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u' AND TabId='%u'", m_Id, currentLogGuid, currentTabId);
|
||||
|
||||
CharacterDatabase.PExecute("INSERT INTO guild_bank_eventlog (guildid,LogGuid,TabId,EventType,PlayerGuid,ItemOrMoney,ItemStackCount,DestTabId,TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','%u','%u','" UI64FMTD "')",
|
||||
|
|
@ -2307,8 +2294,8 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
|
|||
// logging item move to bank
|
||||
if (pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
{
|
||||
sLog.outCommand(pl->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
pl->GetName(),pl->GetSession()->GetAccountId(),
|
||||
sLog.outCommand(pl->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
pl->GetName(), pl->GetSession()->GetAccountId(),
|
||||
pItemChar->GetProto()->Name1, pItemChar->GetEntry(), pItemChar->GetCount(),
|
||||
m_Id);
|
||||
}
|
||||
|
|
@ -2336,6 +2323,38 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
|
|||
}
|
||||
}
|
||||
|
||||
void Guild::BroadcastEvent(GuildEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3)
|
||||
{
|
||||
WorldPacket data(SMSG_GUILD_EVENT, 1+1+(guid ? 8 : 0));
|
||||
data << uint8(event);
|
||||
data << uint8(strCount);
|
||||
|
||||
switch(strCount)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
data << str1;
|
||||
break;
|
||||
case 2:
|
||||
data << str1 << str2;
|
||||
break;
|
||||
case 3:
|
||||
data << str1 << str2 << str3;
|
||||
break;
|
||||
default:
|
||||
sLog.outError("Guild::BroadcastEvent: incorrect strings count %u!", strCount);
|
||||
break;
|
||||
}
|
||||
|
||||
if(guid)
|
||||
data << uint64(guid);
|
||||
|
||||
BroadcastPacket(&data);
|
||||
|
||||
sLog.outDebug("WORLD: Sent SMSG_GUILD_EVENT");
|
||||
}
|
||||
|
||||
bool GuildItemPosCount::isContainedIn(GuildItemPosCountVec const &vec) const
|
||||
{
|
||||
for(GuildItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end(); ++itr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue