feat(Core/Chat): delete delay for channels (#10365)

* feat(Core/Chat): delete delay for channels

* 1
This commit is contained in:
Kargatum
2022-01-27 17:58:59 +07:00
committed by GitHub
parent 1ddf5d8d1f
commit 3d6724e448
2 changed files with 5 additions and 33 deletions

View File

@@ -35,7 +35,6 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId,
_channelId(channelId),
_channelDBId(channelDBId),
_teamId(teamId),
_lastSpeakTime(0),
_name(name),
_password("")
{
@@ -803,45 +802,20 @@ void Channel::Say(ObjectGuid guid, std::string const& what, uint32 lang)
}
Player* player = pinfo.plrPtr;
if (player && player->GetSession()->GetSecurity() == AccountTypes::SEC_PLAYER) // pussywizard: prevent spam on populated channels
{
uint32 speakDelay = 0;
if (_channelRights.speakDelay > 0)
speakDelay = _channelRights.speakDelay;
else if (playersStore.size() >= 10)
speakDelay = 5;
if (!IsAllowedToSpeak(speakDelay))
{
std::string timeStr = secsToTimeString(_lastSpeakTime + speakDelay - GameTime::GetGameTime().count());
if (_channelRights.speakMessage.length() > 0)
player->GetSession()->SendNotification("%s", _channelRights.speakMessage.c_str());
player->GetSession()->SendNotification("You must wait %s before speaking again.", timeStr.c_str());
return;
}
}
WorldPacket data;
if (player)
{
ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _name);
}
else
{
ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name);
}
SendToAll(&data, pinfo.IsModerator() ? ObjectGuid::Empty : guid);
}
bool Channel::IsAllowedToSpeak(uint32 speakDelay)
{
if (_lastSpeakTime + speakDelay <= GameTime::GetGameTime().count())
{
_lastSpeakTime = GameTime::GetGameTime().count();
return true;
}
return false;
}
void Channel::Invite(Player const* player, std::string const& newname)
{
ObjectGuid guid = player->GetGUID();

View File

@@ -223,7 +223,6 @@ public:
// pussywizard:
void AddWatching(Player* p);
void RemoveWatching(Player* p);
bool IsAllowedToSpeak(uint32 speakDelay); // pussywizard
private:
// initial packet data (notify type and channel name)
@@ -329,7 +328,6 @@ private:
uint32 _channelDBId;
TeamId _teamId;
ObjectGuid _ownerGUID;
uint32 _lastSpeakTime;
std::string _name;
std::string _password;
ChannelRights _channelRights;