mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 07:48:02 +00:00
feat(Core/Chat): delete delay for channels (#10365)
* feat(Core/Chat): delete delay for channels * 1
This commit is contained in:
@@ -35,7 +35,6 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId,
|
|||||||
_channelId(channelId),
|
_channelId(channelId),
|
||||||
_channelDBId(channelDBId),
|
_channelDBId(channelDBId),
|
||||||
_teamId(teamId),
|
_teamId(teamId),
|
||||||
_lastSpeakTime(0),
|
|
||||||
_name(name),
|
_name(name),
|
||||||
_password("")
|
_password("")
|
||||||
{
|
{
|
||||||
@@ -803,45 +802,20 @@ void Channel::Say(ObjectGuid guid, std::string const& what, uint32 lang)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player* player = pinfo.plrPtr;
|
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;
|
WorldPacket data;
|
||||||
|
|
||||||
if (player)
|
if (player)
|
||||||
|
{
|
||||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _name);
|
ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _name);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name);
|
ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name);
|
||||||
|
}
|
||||||
|
|
||||||
SendToAll(&data, pinfo.IsModerator() ? ObjectGuid::Empty : guid);
|
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)
|
void Channel::Invite(Player const* player, std::string const& newname)
|
||||||
{
|
{
|
||||||
ObjectGuid guid = player->GetGUID();
|
ObjectGuid guid = player->GetGUID();
|
||||||
|
|||||||
@@ -223,7 +223,6 @@ public:
|
|||||||
// pussywizard:
|
// pussywizard:
|
||||||
void AddWatching(Player* p);
|
void AddWatching(Player* p);
|
||||||
void RemoveWatching(Player* p);
|
void RemoveWatching(Player* p);
|
||||||
bool IsAllowedToSpeak(uint32 speakDelay); // pussywizard
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// initial packet data (notify type and channel name)
|
// initial packet data (notify type and channel name)
|
||||||
@@ -329,7 +328,6 @@ private:
|
|||||||
uint32 _channelDBId;
|
uint32 _channelDBId;
|
||||||
TeamId _teamId;
|
TeamId _teamId;
|
||||||
ObjectGuid _ownerGUID;
|
ObjectGuid _ownerGUID;
|
||||||
uint32 _lastSpeakTime;
|
|
||||||
std::string _name;
|
std::string _name;
|
||||||
std::string _password;
|
std::string _password;
|
||||||
ChannelRights _channelRights;
|
ChannelRights _channelRights;
|
||||||
|
|||||||
Reference in New Issue
Block a user