mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
converted all tabs to 4 spaces
This commit is contained in:
@@ -34,7 +34,7 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId,
|
||||
_teamId(teamId),
|
||||
_ownerGUID(0),
|
||||
_name(name),
|
||||
_channelDBId(channelDBId),
|
||||
_channelDBId(channelDBId),
|
||||
_password("")
|
||||
{
|
||||
// set special flags if built-in channel
|
||||
@@ -73,20 +73,20 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId,
|
||||
|
||||
_IsSaved = true;
|
||||
|
||||
// Xinef: loading
|
||||
if (channelDBId > 0)
|
||||
return;
|
||||
// Xinef: loading
|
||||
if (channelDBId > 0)
|
||||
return;
|
||||
|
||||
// If storing custom channels in the db is enabled either load or save the channel
|
||||
if (sWorld->getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS))
|
||||
{
|
||||
_channelDBId = ++ChannelMgr::_channelIdMax;
|
||||
_channelDBId = ++ChannelMgr::_channelIdMax;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setString(1, name);
|
||||
stmt->setUInt32(2, _teamId);
|
||||
stmt->setUInt8(3, _announce);
|
||||
stmt->setUInt8(3, _announce);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
@@ -94,8 +94,8 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId,
|
||||
|
||||
bool Channel::IsBanned(uint64 guid) const
|
||||
{
|
||||
BannedContainer::const_iterator itr = bannedStore.find(GUID_LOPART(guid));
|
||||
return itr != bannedStore.end() && itr->second > time(NULL);
|
||||
BannedContainer::const_iterator itr = bannedStore.find(GUID_LOPART(guid));
|
||||
return itr != bannedStore.end() && itr->second > time(NULL);
|
||||
}
|
||||
|
||||
void Channel::UpdateChannelInDB() const
|
||||
@@ -105,7 +105,7 @@ void Channel::UpdateChannelInDB() const
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL);
|
||||
stmt->setBool(0, _announce);
|
||||
stmt->setString(1, _password);
|
||||
stmt->setUInt32(2, _channelDBId);
|
||||
stmt->setUInt32(2, _channelDBId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
;//sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) updated in database", _name.c_str());
|
||||
@@ -115,24 +115,24 @@ void Channel::UpdateChannelInDB() const
|
||||
void Channel::UpdateChannelUseageInDB() const
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_USAGE);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void Channel::AddChannelBanToDB(uint32 guid, uint32 time) const
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL_BAN);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setUInt32(1, guid);
|
||||
stmt->setUInt32(2, time);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setUInt32(1, guid);
|
||||
stmt->setUInt32(2, time);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void Channel::RemoveChannelBanFromDB(uint32 guid) const
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHANNEL_BAN);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setUInt32(1, guid);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setUInt32(1, guid);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -140,16 +140,16 @@ void Channel::CleanOldChannelsInDB()
|
||||
{
|
||||
if (sWorld->getIntConfig(CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION) > 0)
|
||||
{
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_CHANNELS);
|
||||
stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION) * DAY);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_CHANNELS_BANS);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_CHANNELS_BANS);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,176 +289,176 @@ void Channel::LeaveChannel(Player* player, bool send)
|
||||
// If the channel owner left and there are still playersStore inside, pick a new owner
|
||||
if (changeowner && _ownership)
|
||||
{
|
||||
if (!playersStore.empty())
|
||||
{
|
||||
uint64 newowner = 0;
|
||||
for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
|
||||
{
|
||||
newowner = itr->second.player;
|
||||
if (!itr->second.plrPtr->GetSession()->GetSecurity())
|
||||
break;
|
||||
}
|
||||
SetOwner(newowner);
|
||||
}
|
||||
else
|
||||
SetOwner(0);
|
||||
if (!playersStore.empty())
|
||||
{
|
||||
uint64 newowner = 0;
|
||||
for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
|
||||
{
|
||||
newowner = itr->second.player;
|
||||
if (!itr->second.plrPtr->GetSession()->GetSecurity())
|
||||
break;
|
||||
}
|
||||
SetOwner(newowner);
|
||||
}
|
||||
else
|
||||
SetOwner(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban)
|
||||
{
|
||||
AccountTypes sec = player->GetSession()->GetSecurity();
|
||||
uint64 good = player->GetGUID();
|
||||
AccountTypes sec = player->GetSession()->GetSecurity();
|
||||
uint64 good = player->GetGUID();
|
||||
|
||||
if (!IsOn(good))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotMember(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
if (!IsOn(good))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotMember(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
|
||||
bool banOffline = false; // pussywizard
|
||||
bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
|
||||
bool banOffline = false; // pussywizard
|
||||
bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
|
||||
|
||||
uint64 victim = 0;
|
||||
uint32 badAccId = 0;
|
||||
uint32 badSecurity = 0;
|
||||
Player* bad = ObjectAccessor::FindPlayerByName(badname, false);
|
||||
if (bad)
|
||||
{
|
||||
victim = bad->GetGUID();
|
||||
badAccId = bad->GetSession()->GetAccountId();
|
||||
badSecurity = bad->GetSession()->GetSecurity();
|
||||
}
|
||||
uint64 victim = 0;
|
||||
uint32 badAccId = 0;
|
||||
uint32 badSecurity = 0;
|
||||
Player* bad = ObjectAccessor::FindPlayerByName(badname, false);
|
||||
if (bad)
|
||||
{
|
||||
victim = bad->GetGUID();
|
||||
badAccId = bad->GetSession()->GetAccountId();
|
||||
badSecurity = bad->GetSession()->GetSecurity();
|
||||
}
|
||||
|
||||
bool isOnChannel = victim && IsOn(victim);
|
||||
if (!isOnChannel)
|
||||
{
|
||||
if (ban && (AccountMgr::IsGMAccount(sec) || isGoodConstantModerator))
|
||||
{
|
||||
if (uint32 lowGuid = sWorld->GetGlobalPlayerGUID(badname))
|
||||
if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(lowGuid))
|
||||
{
|
||||
if (Player::TeamIdForRace(gpd->race) == Player::TeamIdForRace(player->getRace()))
|
||||
{
|
||||
banOffline = true;
|
||||
victim = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);
|
||||
badAccId = gpd->accountId;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatHandler(player->GetSession()).PSendSysMessage("Character %s has other faction!", badname.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
bool isOnChannel = victim && IsOn(victim);
|
||||
if (!isOnChannel)
|
||||
{
|
||||
if (ban && (AccountMgr::IsGMAccount(sec) || isGoodConstantModerator))
|
||||
{
|
||||
if (uint32 lowGuid = sWorld->GetGlobalPlayerGUID(badname))
|
||||
if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(lowGuid))
|
||||
{
|
||||
if (Player::TeamIdForRace(gpd->race) == Player::TeamIdForRace(player->getRace()))
|
||||
{
|
||||
banOffline = true;
|
||||
victim = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);
|
||||
badAccId = gpd->accountId;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatHandler(player->GetSession()).PSendSysMessage("Character %s has other faction!", badname.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!banOffline)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerNotFound(&data, badname);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerNotFound(&data, badname);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!banOffline)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerNotFound(&data, badname);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerNotFound(&data, badname);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool changeowner = _ownerGUID == victim;
|
||||
bool isBadConstantModerator = _channelRights.moderators.find(badAccId) != _channelRights.moderators.end();
|
||||
bool changeowner = _ownerGUID == victim;
|
||||
bool isBadConstantModerator = _channelRights.moderators.find(badAccId) != _channelRights.moderators.end();
|
||||
|
||||
if (!AccountMgr::IsGMAccount(sec) && !isGoodConstantModerator)
|
||||
{
|
||||
if (changeowner && good != _ownerGUID)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotOwner(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
if (!AccountMgr::IsGMAccount(sec) && !isGoodConstantModerator)
|
||||
{
|
||||
if (changeowner && good != _ownerGUID)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotOwner(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ban && (_channelRights.flags & CHANNEL_RIGHT_CANT_BAN) || !ban && (_channelRights.flags & CHANNEL_RIGHT_CANT_KICK))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
if (ban && (_channelRights.flags & CHANNEL_RIGHT_CANT_BAN) || !ban && (_channelRights.flags & CHANNEL_RIGHT_CANT_KICK))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBadConstantModerator || AccountMgr::IsGMAccount(badSecurity))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isBadConstantModerator || AccountMgr::IsGMAccount(badSecurity))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
SendToOne(&data, good);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
|
||||
bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
|
||||
|
||||
if (ban)
|
||||
{
|
||||
if (!IsBanned(victim))
|
||||
{
|
||||
bannedStore[GUID_LOPART(victim)] = time(NULL) + CHANNEL_BAN_DURATION;
|
||||
AddChannelBanToDB(GUID_LOPART(victim), time(NULL) + CHANNEL_BAN_DURATION);
|
||||
if (ban)
|
||||
{
|
||||
if (!IsBanned(victim))
|
||||
{
|
||||
bannedStore[GUID_LOPART(victim)] = time(NULL) + CHANNEL_BAN_DURATION;
|
||||
AddChannelBanToDB(GUID_LOPART(victim), time(NULL) + CHANNEL_BAN_DURATION);
|
||||
|
||||
if (notify)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerBanned(&data, victim, good);
|
||||
SendToAll(&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (notify)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerKicked(&data, victim, good);
|
||||
SendToAll(&data);
|
||||
}
|
||||
if (notify)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerBanned(&data, victim, good);
|
||||
SendToAll(&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (notify)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerKicked(&data, victim, good);
|
||||
SendToAll(&data);
|
||||
}
|
||||
|
||||
if (isOnChannel)
|
||||
{
|
||||
playersStore.erase(victim);
|
||||
bad->LeftChannel(this);
|
||||
RemoveWatching(bad);
|
||||
LeaveNotify(bad);
|
||||
}
|
||||
if (isOnChannel)
|
||||
{
|
||||
playersStore.erase(victim);
|
||||
bad->LeftChannel(this);
|
||||
RemoveWatching(bad);
|
||||
LeaveNotify(bad);
|
||||
}
|
||||
|
||||
if (changeowner && _ownership)
|
||||
{
|
||||
if (good != victim)
|
||||
SetOwner(good);
|
||||
else if (!playersStore.empty())
|
||||
{
|
||||
uint64 newowner = 0;
|
||||
for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
|
||||
{
|
||||
newowner = itr->second.player;
|
||||
if (!itr->second.plrPtr->GetSession()->GetSecurity())
|
||||
break;
|
||||
}
|
||||
SetOwner(newowner);
|
||||
}
|
||||
else
|
||||
SetOwner(0);
|
||||
}
|
||||
if (changeowner && _ownership)
|
||||
{
|
||||
if (good != victim)
|
||||
SetOwner(good);
|
||||
else if (!playersStore.empty())
|
||||
{
|
||||
uint64 newowner = 0;
|
||||
for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
|
||||
{
|
||||
newowner = itr->second.player;
|
||||
if (!itr->second.plrPtr->GetSession()->GetSecurity())
|
||||
break;
|
||||
}
|
||||
SetOwner(newowner);
|
||||
}
|
||||
else
|
||||
SetOwner(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::UnBan(Player const* player, std::string const& badname)
|
||||
@@ -482,9 +482,9 @@ void Channel::UnBan(Player const* player, std::string const& badname)
|
||||
return;
|
||||
}
|
||||
|
||||
uint64 victim = 0;
|
||||
if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(badname))
|
||||
victim = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
|
||||
uint64 victim = 0;
|
||||
if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(badname))
|
||||
victim = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
|
||||
|
||||
if (!victim || !IsBanned(victim))
|
||||
{
|
||||
@@ -510,7 +510,7 @@ void Channel::UnBan(Player const* player, std::string const& badname)
|
||||
sLog->outCommand(player->GetSession()->GetAccountId(), "Command: /unban %s %s (Moderator %s [guid: %u, account: %u] unbanned %s [guid: %u])", GetName().c_str(), badname.c_str(), player->GetName().c_str(), player->GetGUIDLow(), player->GetSession()->GetAccountId(), badname.c_str(), GUID_LOPART(victim));
|
||||
|
||||
bannedStore.erase(GUID_LOPART(victim));
|
||||
RemoveChannelBanFromDB(GUID_LOPART(victim));
|
||||
RemoveChannelBanFromDB(GUID_LOPART(victim));
|
||||
|
||||
WorldPacket data;
|
||||
MakePlayerUnbanned(&data, victim, good);
|
||||
@@ -522,7 +522,7 @@ void Channel::UnBan(uint64 guid)
|
||||
if (!IsBanned(guid))
|
||||
return;
|
||||
bannedStore.erase(GUID_LOPART(guid));
|
||||
RemoveChannelBanFromDB(GUID_LOPART(guid));
|
||||
RemoveChannelBanFromDB(GUID_LOPART(guid));
|
||||
}
|
||||
|
||||
void Channel::Password(Player const* player, std::string const& pass)
|
||||
@@ -595,7 +595,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
|
||||
// allow make moderator from another team only if both is GMs
|
||||
// at this moment this only way to show channel post for GM from another team
|
||||
((!AccountMgr::IsGMAccount(sec) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) && player->GetTeamId() != newp->GetTeamId() &&
|
||||
!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)))
|
||||
!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerNotFound(&data, p2n);
|
||||
@@ -660,8 +660,8 @@ void Channel::SetOwner(Player const* player, std::string const& newname)
|
||||
Player* newp = ObjectAccessor::FindPlayerByName(newname, false);
|
||||
uint64 victim = newp ? newp->GetGUID() : 0;
|
||||
|
||||
if (!victim || !IsOn(victim) || newp->GetTeamId() != player->GetTeamId() &&
|
||||
!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
|
||||
if (!victim || !IsOn(victim) || newp->GetTeamId() != player->GetTeamId() &&
|
||||
!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerNotFound(&data, newname);
|
||||
@@ -706,14 +706,14 @@ void Channel::List(Player const* player)
|
||||
data << uint32(0); // size of list, placeholder
|
||||
|
||||
uint32 count = 0;
|
||||
if (!(_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK))
|
||||
for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
|
||||
if (AccountMgr::IsPlayerAccount(i->second.plrPtr->GetSession()->GetSecurity()))
|
||||
{
|
||||
data << uint64(i->first);
|
||||
data << uint8(i->second.flags); // flags seems to be changed...
|
||||
++count;
|
||||
}
|
||||
if (!(_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK))
|
||||
for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
|
||||
if (AccountMgr::IsPlayerAccount(i->second.plrPtr->GetSession()->GetSecurity()))
|
||||
{
|
||||
data << uint64(i->first);
|
||||
data << uint8(i->second.flags); // flags seems to be changed...
|
||||
++count;
|
||||
}
|
||||
|
||||
data.put<uint32>(pos, count);
|
||||
|
||||
@@ -766,8 +766,8 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
|
||||
if (what.empty())
|
||||
return;
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
|
||||
lang = LANG_UNIVERSAL;
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
|
||||
lang = LANG_UNIVERSAL;
|
||||
|
||||
if (!IsOn(guid))
|
||||
{
|
||||
@@ -790,22 +790,22 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
|
||||
Player* player = pinfo.plrPtr;
|
||||
|
||||
if (player && !player->GetSession()->GetSecurity()) // pussywizard: prevent spam on populated channels
|
||||
{
|
||||
uint32 speakDelay = 0;
|
||||
if (_channelRights.speakDelay > 0)
|
||||
speakDelay = _channelRights.speakDelay;
|
||||
else if (playersStore.size() >= 10)
|
||||
speakDelay = 5;
|
||||
{
|
||||
uint32 speakDelay = 0;
|
||||
if (_channelRights.speakDelay > 0)
|
||||
speakDelay = _channelRights.speakDelay;
|
||||
else if (playersStore.size() >= 10)
|
||||
speakDelay = 5;
|
||||
|
||||
if (!pinfo.IsAllowedToSpeak(speakDelay))
|
||||
if (!pinfo.IsAllowedToSpeak(speakDelay))
|
||||
{
|
||||
std::string timeStr = secsToTimeString(pinfo.lastSpeakTime + speakDelay - sWorld->GetGameTime());
|
||||
if (_channelRights.speakMessage.length() > 0)
|
||||
player->GetSession()->SendNotification(_channelRights.speakMessage.c_str());
|
||||
player->GetSession()->SendNotification("You must wait %s before speaking again.", timeStr.c_str());
|
||||
std::string timeStr = secsToTimeString(pinfo.lastSpeakTime + speakDelay - sWorld->GetGameTime());
|
||||
if (_channelRights.speakMessage.length() > 0)
|
||||
player->GetSession()->SendNotification(_channelRights.speakMessage.c_str());
|
||||
player->GetSession()->SendNotification("You must wait %s before speaking again.", timeStr.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WorldPacket data;
|
||||
if (player)
|
||||
@@ -818,28 +818,28 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
|
||||
|
||||
void Channel::EveryoneSayToSelf(const char *what)
|
||||
{
|
||||
if (!what)
|
||||
return;
|
||||
if (!what)
|
||||
return;
|
||||
|
||||
uint32 messageLength = strlen(what) + 1;
|
||||
uint32 messageLength = strlen(what) + 1;
|
||||
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 1+4+8+4+_name.size()+1+8+4+messageLength+1);
|
||||
data << (uint8)CHAT_MSG_CHANNEL;
|
||||
data << (uint32)LANG_UNIVERSAL;
|
||||
data << uint64(0); // put player guid here
|
||||
data << uint32(0);
|
||||
data << _name;
|
||||
data << uint64(0); // put player guid here
|
||||
data << messageLength;
|
||||
data << what;
|
||||
data << uint8(0);
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 1+4+8+4+_name.size()+1+8+4+messageLength+1);
|
||||
data << (uint8)CHAT_MSG_CHANNEL;
|
||||
data << (uint32)LANG_UNIVERSAL;
|
||||
data << uint64(0); // put player guid here
|
||||
data << uint32(0);
|
||||
data << _name;
|
||||
data << uint64(0); // put player guid here
|
||||
data << messageLength;
|
||||
data << what;
|
||||
data << uint8(0);
|
||||
|
||||
for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
|
||||
{
|
||||
data.put(5, i->first);
|
||||
data.put(17+_name.size()+1, i->first);
|
||||
i->second.plrPtr->GetSession()->SendPacket(&data);
|
||||
}
|
||||
for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
|
||||
{
|
||||
data.put(5, i->first);
|
||||
data.put(17+_name.size()+1, i->first);
|
||||
i->second.plrPtr->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::Invite(Player const* player, std::string const& newname)
|
||||
@@ -1185,10 +1185,10 @@ void Channel::MakeVoiceOff(WorldPacket* data, uint64 guid)
|
||||
|
||||
void Channel::JoinNotify(Player* p)
|
||||
{
|
||||
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
||||
return;
|
||||
if (!AccountMgr::IsPlayerAccount(p->GetSession()->GetSecurity()))
|
||||
return;
|
||||
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
||||
return;
|
||||
if (!AccountMgr::IsPlayerAccount(p->GetSession()->GetSecurity()))
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_USERLIST_ADD, 8 + 1 + 1 + 4 + GetName().size());
|
||||
data << uint64(p->GetGUID());
|
||||
@@ -1202,10 +1202,10 @@ void Channel::JoinNotify(Player* p)
|
||||
|
||||
void Channel::LeaveNotify(Player* p)
|
||||
{
|
||||
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
||||
return;
|
||||
if (!AccountMgr::IsPlayerAccount(p->GetSession()->GetSecurity()))
|
||||
return;
|
||||
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
||||
return;
|
||||
if (!AccountMgr::IsPlayerAccount(p->GetSession()->GetSecurity()))
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size());
|
||||
data << uint64(p->GetGUID());
|
||||
@@ -1218,10 +1218,10 @@ void Channel::LeaveNotify(Player* p)
|
||||
|
||||
void Channel::FlagsNotify(Player* p)
|
||||
{
|
||||
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
||||
return;
|
||||
if (!AccountMgr::IsPlayerAccount(p->GetSession()->GetSecurity()))
|
||||
return;
|
||||
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
||||
return;
|
||||
if (!AccountMgr::IsPlayerAccount(p->GetSession()->GetSecurity()))
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size());
|
||||
data << uint64(p->GetGUID());
|
||||
@@ -1235,14 +1235,14 @@ void Channel::FlagsNotify(Player* p)
|
||||
|
||||
void Channel::AddWatching(Player* p)
|
||||
{
|
||||
if (!IsOn(p->GetGUID()))
|
||||
return;
|
||||
playersWatchingStore.insert(p);
|
||||
if (!IsOn(p->GetGUID()))
|
||||
return;
|
||||
playersWatchingStore.insert(p);
|
||||
}
|
||||
|
||||
void Channel::RemoveWatching(Player* p)
|
||||
{
|
||||
PlayersWatchingContainer::iterator itr = playersWatchingStore.find(p);
|
||||
if (itr != playersWatchingStore.end())
|
||||
playersWatchingStore.erase(itr);
|
||||
PlayersWatchingContainer::iterator itr = playersWatchingStore.find(p);
|
||||
if (itr != playersWatchingStore.end())
|
||||
playersWatchingStore.erase(itr);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
class Player;
|
||||
|
||||
#define CHANNEL_BAN_DURATION DAY*60
|
||||
#define CHANNEL_BAN_DURATION DAY*60
|
||||
|
||||
enum ChatNotify
|
||||
{
|
||||
@@ -123,26 +123,26 @@ enum ChannelMemberFlags
|
||||
class ChannelRights
|
||||
{
|
||||
public:
|
||||
ChannelRights() : flags(0), speakDelay(0) {}
|
||||
ChannelRights(const uint32& f, const uint32& d, const std::string& jm, const std::string& sm, const std::set<uint32>& ml) : flags(f), speakDelay(d), joinMessage(jm), speakMessage(sm), moderators(ml) {}
|
||||
uint32 flags;
|
||||
uint32 speakDelay;
|
||||
std::string joinMessage;
|
||||
std::string speakMessage;
|
||||
std::set<uint32> moderators;
|
||||
ChannelRights() : flags(0), speakDelay(0) {}
|
||||
ChannelRights(const uint32& f, const uint32& d, const std::string& jm, const std::string& sm, const std::set<uint32>& ml) : flags(f), speakDelay(d), joinMessage(jm), speakMessage(sm), moderators(ml) {}
|
||||
uint32 flags;
|
||||
uint32 speakDelay;
|
||||
std::string joinMessage;
|
||||
std::string speakMessage;
|
||||
std::set<uint32> moderators;
|
||||
};
|
||||
|
||||
enum eChannelRights
|
||||
{
|
||||
CHANNEL_RIGHT_FORCE_NO_ANNOUNCEMENTS = 0x001,
|
||||
CHANNEL_RIGHT_FORCE_ANNOUNCEMENTS = 0x002,
|
||||
CHANNEL_RIGHT_NO_OWNERSHIP = 0x004,
|
||||
CHANNEL_RIGHT_CANT_SPEAK = 0x008,
|
||||
CHANNEL_RIGHT_CANT_BAN = 0x010,
|
||||
CHANNEL_RIGHT_CANT_KICK = 0x020,
|
||||
CHANNEL_RIGHT_CANT_MUTE = 0x040,
|
||||
CHANNEL_RIGHT_CANT_CHANGE_PASSWORD = 0x080,
|
||||
CHANNEL_RIGHT_DONT_PRESERVE = 0x100,
|
||||
CHANNEL_RIGHT_FORCE_NO_ANNOUNCEMENTS = 0x001,
|
||||
CHANNEL_RIGHT_FORCE_ANNOUNCEMENTS = 0x002,
|
||||
CHANNEL_RIGHT_NO_OWNERSHIP = 0x004,
|
||||
CHANNEL_RIGHT_CANT_SPEAK = 0x008,
|
||||
CHANNEL_RIGHT_CANT_BAN = 0x010,
|
||||
CHANNEL_RIGHT_CANT_KICK = 0x020,
|
||||
CHANNEL_RIGHT_CANT_MUTE = 0x040,
|
||||
CHANNEL_RIGHT_CANT_CHANGE_PASSWORD = 0x080,
|
||||
CHANNEL_RIGHT_DONT_PRESERVE = 0x100,
|
||||
};
|
||||
|
||||
class Channel
|
||||
@@ -204,7 +204,7 @@ class Channel
|
||||
void KickOrBan(Player const* player, std::string const& badname, bool ban);
|
||||
void Kick(Player const* player, std::string const& badname) { KickOrBan(player, badname, false); }
|
||||
void Ban(Player const* player, std::string const& badname) { KickOrBan(player, badname, true); }
|
||||
void AddBan(uint32 guid, uint32 time) { bannedStore[guid] = time; }
|
||||
void AddBan(uint32 guid, uint32 time) { bannedStore[guid] = time; }
|
||||
void UnBan(Player const* player, std::string const& badname);
|
||||
void UnBan(uint64 guid);
|
||||
void Password(Player const* player, std::string const& pass);
|
||||
@@ -219,7 +219,7 @@ class Channel
|
||||
void List(Player const* player);
|
||||
void Announce(Player const* player);
|
||||
void Say(uint64 guid, std::string const& what, uint32 lang);
|
||||
void EveryoneSayToSelf(const char *what);
|
||||
void EveryoneSayToSelf(const char *what);
|
||||
void Invite(Player const* player, std::string const& newp);
|
||||
void Voice(uint64 guid1, uint64 guid2);
|
||||
void DeVoice(uint64 guid1, uint64 guid2);
|
||||
@@ -228,9 +228,9 @@ class Channel
|
||||
void FlagsNotify(Player* p);
|
||||
static void CleanOldChannelsInDB();
|
||||
|
||||
// pussywizard:
|
||||
void AddWatching(Player* p);
|
||||
void RemoveWatching(Player* p);
|
||||
// pussywizard:
|
||||
void AddWatching(Player* p);
|
||||
void RemoveWatching(Player* p);
|
||||
|
||||
private:
|
||||
// initial packet data (notify type and channel name)
|
||||
@@ -281,8 +281,8 @@ class Channel
|
||||
|
||||
void UpdateChannelInDB() const;
|
||||
void UpdateChannelUseageInDB() const;
|
||||
void AddChannelBanToDB(uint32 guid, uint32 time) const;
|
||||
void RemoveChannelBanFromDB(uint32 guid) const;
|
||||
void AddChannelBanToDB(uint32 guid, uint32 time) const;
|
||||
void RemoveChannelBanFromDB(uint32 guid) const;
|
||||
|
||||
uint8 GetPlayerFlags(uint64 guid) const
|
||||
{
|
||||
@@ -329,7 +329,7 @@ class Channel
|
||||
bool _IsSaved;
|
||||
uint8 _flags;
|
||||
uint32 _channelId;
|
||||
uint32 _channelDBId;
|
||||
uint32 _channelDBId;
|
||||
TeamId _teamId;
|
||||
uint64 _ownerGUID;
|
||||
std::string _name;
|
||||
|
||||
@@ -30,8 +30,8 @@ ChannelMgr::~ChannelMgr()
|
||||
|
||||
ChannelMgr* ChannelMgr::forTeam(TeamId teamId)
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
|
||||
return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance(); // cross-faction
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
|
||||
return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance(); // cross-faction
|
||||
|
||||
if (teamId == TEAM_ALLIANCE)
|
||||
return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance();
|
||||
@@ -45,13 +45,13 @@ ChannelMgr* ChannelMgr::forTeam(TeamId teamId)
|
||||
|
||||
void ChannelMgr::LoadChannels()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
uint32 count = 0;
|
||||
uint32 oldMSTime = getMSTime();
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT channelId, name, team, announce, password FROM channels WHERE team = %u ORDER BY channelId ASC", _teamId);
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT channelId, name, team, announce, password FROM channels WHERE team = %u ORDER BY channelId ASC", _teamId);
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 channels for %s", _teamId == TEAM_ALLIANCE ? "Alliance" : "Horde");
|
||||
sLog->outString(">> Loaded 0 channels for %s", _teamId == TEAM_ALLIANCE ? "Alliance" : "Horde");
|
||||
sLog->outString();
|
||||
return;
|
||||
}
|
||||
@@ -62,31 +62,31 @@ void ChannelMgr::LoadChannels()
|
||||
if (!fields)
|
||||
break;
|
||||
|
||||
uint32 channelDBId = fields[0].GetUInt32();
|
||||
std::string channelName = fields[1].GetString();
|
||||
std::string password = fields[4].GetString();
|
||||
std::wstring channelWName;
|
||||
Utf8toWStr(channelName, channelWName);
|
||||
uint32 channelDBId = fields[0].GetUInt32();
|
||||
std::string channelName = fields[1].GetString();
|
||||
std::string password = fields[4].GetString();
|
||||
std::wstring channelWName;
|
||||
Utf8toWStr(channelName, channelWName);
|
||||
|
||||
Channel* newChannel = new Channel(channelName, 0, channelDBId, TeamId(fields[2].GetUInt32()), fields[3].GetUInt8());
|
||||
newChannel->SetPassword(password);
|
||||
Channel* newChannel = new Channel(channelName, 0, channelDBId, TeamId(fields[2].GetUInt32()), fields[3].GetUInt8());
|
||||
newChannel->SetPassword(password);
|
||||
channels[channelWName] = newChannel;
|
||||
|
||||
if (QueryResult banResult = CharacterDatabase.PQuery("SELECT playerGUID, banTime FROM channels_bans WHERE channelId = %u", channelDBId))
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* banFields = banResult->Fetch();
|
||||
if (!banFields)
|
||||
break;
|
||||
newChannel->AddBan(banFields[0].GetUInt32(), banFields[1].GetUInt32());
|
||||
}
|
||||
while (banResult->NextRow());
|
||||
}
|
||||
if (QueryResult banResult = CharacterDatabase.PQuery("SELECT playerGUID, banTime FROM channels_bans WHERE channelId = %u", channelDBId))
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* banFields = banResult->Fetch();
|
||||
if (!banFields)
|
||||
break;
|
||||
newChannel->AddBan(banFields[0].GetUInt32(), banFields[1].GetUInt32());
|
||||
}
|
||||
while (banResult->NextRow());
|
||||
}
|
||||
|
||||
if (channelDBId > ChannelMgr::_channelIdMax)
|
||||
ChannelMgr::_channelIdMax = channelDBId;
|
||||
++count;
|
||||
if (channelDBId > ChannelMgr::_channelIdMax)
|
||||
ChannelMgr::_channelIdMax = channelDBId;
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
@@ -144,58 +144,58 @@ ChannelRights ChannelMgr::channelRightsEmpty;
|
||||
|
||||
void ChannelMgr::LoadChannelRights()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
channels_rights.clear();
|
||||
uint32 oldMSTime = getMSTime();
|
||||
channels_rights.clear();
|
||||
|
||||
QueryResult result = CharacterDatabase.Query("SELECT name, flags, speakdelay, joinmessage, delaymessage, moderators FROM channels_rights");
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString();
|
||||
sLog->outString(">> Loaded 0 Channel Rights!");
|
||||
return;
|
||||
}
|
||||
QueryResult result = CharacterDatabase.Query("SELECT name, flags, speakdelay, joinmessage, delaymessage, moderators FROM channels_rights");
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString();
|
||||
sLog->outString(">> Loaded 0 Channel Rights!");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
std::set<uint32> moderators;
|
||||
const char* moderatorList = fields[5].GetCString();
|
||||
if (moderatorList)
|
||||
{
|
||||
Tokenizer tokens(moderatorList, ' ');
|
||||
for (Tokenizer::const_iterator i = tokens.begin(); i != tokens.end(); ++i)
|
||||
{
|
||||
uint64 moderator_acc = atol(*i);
|
||||
if (moderator_acc && ((uint32)moderator_acc) == moderator_acc)
|
||||
moderators.insert((uint32)moderator_acc);
|
||||
}
|
||||
}
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
std::set<uint32> moderators;
|
||||
const char* moderatorList = fields[5].GetCString();
|
||||
if (moderatorList)
|
||||
{
|
||||
Tokenizer tokens(moderatorList, ' ');
|
||||
for (Tokenizer::const_iterator i = tokens.begin(); i != tokens.end(); ++i)
|
||||
{
|
||||
uint64 moderator_acc = atol(*i);
|
||||
if (moderator_acc && ((uint32)moderator_acc) == moderator_acc)
|
||||
moderators.insert((uint32)moderator_acc);
|
||||
}
|
||||
}
|
||||
|
||||
SetChannelRightsFor(fields[0].GetString(), fields[1].GetUInt32(), fields[2].GetUInt32(), fields[3].GetString(), fields[4].GetString(), moderators);
|
||||
SetChannelRightsFor(fields[0].GetString(), fields[1].GetUInt32(), fields[2].GetUInt32(), fields[3].GetString(), fields[4].GetString(), moderators);
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %d Channel Rights in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
sLog->outString(">> Loaded %d Channel Rights in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
const ChannelRights& ChannelMgr::GetChannelRightsFor(const std::string& name)
|
||||
{
|
||||
std::string nameStr = name;
|
||||
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
|
||||
ChannelRightsMap::const_iterator itr = channels_rights.find(nameStr);
|
||||
if (itr != channels_rights.end())
|
||||
return itr->second;
|
||||
return channelRightsEmpty;
|
||||
std::string nameStr = name;
|
||||
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
|
||||
ChannelRightsMap::const_iterator itr = channels_rights.find(nameStr);
|
||||
if (itr != channels_rights.end())
|
||||
return itr->second;
|
||||
return channelRightsEmpty;
|
||||
}
|
||||
|
||||
void ChannelMgr::SetChannelRightsFor(const std::string& name, const uint32& flags, const uint32& speakDelay, const std::string& joinmessage, const std::string& speakmessage, const std::set<uint32>& moderators)
|
||||
{
|
||||
std::string nameStr = name;
|
||||
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
|
||||
channels_rights[nameStr] = ChannelRights(flags, speakDelay, joinmessage, speakmessage, moderators);
|
||||
std::string nameStr = name;
|
||||
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
|
||||
channels_rights[nameStr] = ChannelRights(flags, speakDelay, joinmessage, speakmessage, moderators);
|
||||
}
|
||||
|
||||
void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string const& name)
|
||||
|
||||
@@ -44,12 +44,12 @@ class ChannelMgr
|
||||
|
||||
Channel* GetJoinChannel(std::string const& name, uint32 channel_id);
|
||||
Channel* GetChannel(std::string const& name, Player* p, bool pkt = true);
|
||||
void LoadChannels();
|
||||
void LoadChannels();
|
||||
|
||||
static void LoadChannelRights();
|
||||
static const ChannelRights& GetChannelRightsFor(const std::string& name);
|
||||
static void SetChannelRightsFor(const std::string& name, const uint32& flags, const uint32& speakDelay, const std::string& joinmessage, const std::string& speakmessage, const std::set<uint32>& moderators);
|
||||
static uint32 _channelIdMax;
|
||||
static uint32 _channelIdMax;
|
||||
|
||||
private:
|
||||
ChannelMap channels;
|
||||
|
||||
Reference in New Issue
Block a user