Skip to content

Commit 40a52c8

Browse files
NyeriahCopilot
andauthored
feat(Core/Scripts): Add ChatLog.Enable config to chat_log.cpp (azerothcore#25795)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 9259122 commit 40a52c8

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/server/apps/worldserver/worldserver.conf.dist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,15 @@ Allow.IP.Based.Action.Logging = 0
621621

622622
LogSpamReports = 1
623623

624+
#
625+
# ChatLog.Enable
626+
# Description: Enable or disable chat logging (chat_log.cpp).
627+
# Default: 0 - (Disabled)
628+
# 1 - (Enabled)
629+
#
630+
631+
ChatLog.Enable = 0
632+
624633
#
625634
# Appender config values: Given an appender "name"
626635
# Appender.name

src/server/game/World/WorldConfig.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,8 @@ void WorldConfig::BuildConfigCache()
604604

605605
SetConfigValue<bool>(CONFIG_LOGSPAMREPORTS, "LogSpamReports", true);
606606

607+
SetConfigValue<bool>(CONFIG_CHATLOG_ENABLED, "ChatLog.Enable", false);
608+
607609
// Whether to use LoS from game objects
608610
SetConfigValue<bool>(CONFIG_CHECK_GOBJECT_LOS, "CheckGameObjectLoS", true);
609611

src/server/game/World/WorldConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ enum ServerConfigs
492492
CONFIG_NEW_CHAR_STRING,
493493
CONFIG_VALIDATE_SKILL_LEARNED_BY_SPELLS,
494494
CONFIG_ACHIEVEMENT_REALM_FIRST_KILL_WINDOW,
495+
CONFIG_CHATLOG_ENABLED,
495496

496497
MAX_NUM_SERVER_CONFIGS
497498
};

src/server/scripts/World/chat_log.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "Guild.h"
2121
#include "Log.h"
2222
#include "PlayerScript.h"
23+
#include "World.h"
2324

2425
class ChatLogScript : public PlayerScript
2526
{
@@ -38,6 +39,9 @@ class ChatLogScript : public PlayerScript
3839

3940
bool OnPlayerCanUseChat(Player* player, uint32 type, uint32 lang, std::string& msg) override
4041
{
42+
if (!sWorld->getBoolConfig(CONFIG_CHATLOG_ENABLED))
43+
return true;
44+
4145
std::string logType = "";
4246
std::string chatType = "";
4347

@@ -67,6 +71,9 @@ class ChatLogScript : public PlayerScript
6771

6872
bool OnPlayerCanUseChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver) override
6973
{
74+
if (!sWorld->getBoolConfig(CONFIG_CHATLOG_ENABLED))
75+
return true;
76+
7077
//! NOTE:
7178
//! LANG_ADDON can only be sent by client in "PARTY", "RAID", "GUILD", "BATTLEGROUND", "WHISPER"
7279
std::string logType = (lang != LANG_ADDON) ? "chat." : "chat.addon.";
@@ -80,6 +87,9 @@ class ChatLogScript : public PlayerScript
8087

8188
bool OnPlayerCanUseChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) override
8289
{
90+
if (!sWorld->getBoolConfig(CONFIG_CHATLOG_ENABLED))
91+
return true;
92+
8393
//! NOTE:
8494
//! LANG_ADDON can only be sent by client in "PARTY", "RAID", "GUILD", "BATTLEGROUND", "WHISPER"
8595
std::string logType = (lang != LANG_ADDON) ? "chat." : "chat.addon.";
@@ -116,6 +126,9 @@ class ChatLogScript : public PlayerScript
116126

117127
bool OnPlayerCanUseChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild) override
118128
{
129+
if (!sWorld->getBoolConfig(CONFIG_CHATLOG_ENABLED))
130+
return true;
131+
119132
//! NOTE:
120133
//! LANG_ADDON can only be sent by client in "PARTY", "RAID", "GUILD", "BATTLEGROUND", "WHISPER"
121134
std::string logType = (lang != LANG_ADDON) ? "chat." : "chat.addon.";
@@ -141,6 +154,9 @@ class ChatLogScript : public PlayerScript
141154

142155
bool OnPlayerCanUseChat(Player* player, uint32 /*type*/, uint32 /*lang*/, std::string& msg, Channel* channel) override
143156
{
157+
if (!sWorld->getBoolConfig(CONFIG_CHATLOG_ENABLED))
158+
return true;
159+
144160
bool isSystem = channel &&
145161
(channel->HasFlag(CHANNEL_FLAG_TRADE) ||
146162
channel->HasFlag(CHANNEL_FLAG_GENERAL) ||

0 commit comments

Comments
 (0)