Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
chat_log.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
ScriptMgr.h
"
7
#include "
Channel.h
"
8
#include "
Guild.h
"
9
#include "
Group.h
"
10
11
class
ChatLogScript
:
public
PlayerScript
12
{
13
public
:
14
ChatLogScript
() :
PlayerScript
(
"ChatLogScript"
) { }
15
16
void
OnChat
(
Player
* player,
ChatMsg
type,
Language
lang, std::string& msg)
17
{
18
switch
(type)
19
{
20
case
ChatMsg::CHAT_MSG_ADDON
:
21
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_ADDON
))
22
SF_LOG_DEBUG
(
"chat.log"
,
"[ADDON] Player %s sends: %s"
,
23
player->
GetName
().c_str(), msg.c_str());
24
break
;
25
26
case
ChatMsg::CHAT_MSG_SAY
:
27
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_PUBLIC
))
28
SF_LOG_DEBUG
(
"chat.log"
,
"[SAY] Player %s says (language %u): %s"
,
29
player->
GetName
().c_str(),
uint8
(lang), msg.c_str());
30
break
;
31
32
case
ChatMsg::CHAT_MSG_EMOTE
:
33
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_PUBLIC
))
34
SF_LOG_DEBUG
(
"chat.log"
,
"[TEXTEMOTE] Player %s emotes: %s"
,
35
player->
GetName
().c_str(), msg.c_str());
36
break
;
37
38
case
ChatMsg::CHAT_MSG_YELL
:
39
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_PUBLIC
))
40
SF_LOG_DEBUG
(
"chat.log"
,
"[YELL] Player %s yells (language %u): %s"
,
41
player->
GetName
().c_str(),
uint8
(lang), msg.c_str());
42
break
;
43
default
:
44
break
;
45
}
46
}
47
48
void
OnChat
(
Player
* player,
ChatMsg
/*type*/
,
Language
lang, std::string& msg,
Player
* receiver)
49
{
50
if
(lang !=
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_WHISPER
))
51
SF_LOG_DEBUG
(
"chat.log"
,
"[WHISPER] Player %s tells %s: %s"
,
52
player->
GetName
().c_str(), receiver ? receiver->
GetName
().c_str() :
"<unknown>"
, msg.c_str());
53
else
if
(lang ==
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_ADDON
))
54
SF_LOG_DEBUG
(
"chat.log"
,
"[ADDON] Player %s tells %s: %s"
,
55
player->
GetName
().c_str(), receiver ? receiver->
GetName
().c_str() :
"<unknown>"
, msg.c_str());
56
}
57
58
void
OnChat
(
Player
* player,
ChatMsg
type,
Language
lang, std::string& msg,
Group
* group)
59
{
62
switch
(type)
63
{
64
case
ChatMsg::CHAT_MSG_PARTY
:
65
if
(lang !=
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_PARTY
))
66
SF_LOG_DEBUG
(
"chat.log"
,
"[PARTY] Player %s tells group with leader %s: %s"
,
67
player->
GetName
().c_str(), group ? group->
GetLeaderName
() :
"<unknown>"
, msg.c_str());
68
else
if
(lang ==
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_ADDON
))
69
SF_LOG_DEBUG
(
"chat.log"
,
"[ADDON] Player %s tells group with leader %s: %s"
,
70
player->
GetName
().c_str(), group ? group->
GetLeaderName
() :
"<unknown>"
, msg.c_str());
71
break
;
72
73
case
ChatMsg::CHAT_MSG_PARTY_LEADER
:
74
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_PARTY
))
75
SF_LOG_DEBUG
(
"chat.log"
,
"[PARTY] Leader %s tells group: %s"
,
76
player->
GetName
().c_str(), msg.c_str());
77
break
;
78
79
case
ChatMsg::CHAT_MSG_RAID
:
80
if
(lang !=
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_RAID
))
81
SF_LOG_DEBUG
(
"chat.log"
,
"[RAID] Player %s tells raid with leader %s: %s"
,
82
player->
GetName
().c_str(), group ? group->
GetLeaderName
() :
"<unknown>"
, msg.c_str());
83
else
if
(lang ==
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_ADDON
))
84
SF_LOG_DEBUG
(
"chat.log"
,
"[ADDON] Player %s tells raid with leader %s: %s"
,
85
player->
GetName
().c_str(), group ? group->
GetLeaderName
() :
"<unknown>"
, msg.c_str());
86
break
;
87
88
case
ChatMsg::CHAT_MSG_RAID_LEADER
:
89
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_RAID
))
90
SF_LOG_DEBUG
(
"chat.log"
,
"[RAID] Leader player %s tells raid: %s"
,
91
player->
GetName
().c_str(), msg.c_str());
92
break
;
93
94
case
ChatMsg::CHAT_MSG_RAID_WARNING
:
95
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_RAID
))
96
SF_LOG_DEBUG
(
"chat.log"
,
"[RAID] Leader player %s warns raid with: %s"
,
97
player->
GetName
().c_str(), msg.c_str());
98
break
;
99
100
case
ChatMsg::CHAT_MSG_INSTANCE
:
101
if
(lang !=
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_BGROUND
))
102
SF_LOG_DEBUG
(
"chat.log"
,
"[BATTLEGROUND] Player %s tells battleground with leader %s: %s"
,
103
player->
GetName
().c_str(), group ? group->
GetLeaderName
() :
"<unknown>"
, msg.c_str());
104
else
if
(lang ==
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_ADDON
))
105
SF_LOG_DEBUG
(
"chat.log"
,
"[ADDON] Player %s tells battleground with leader %s: %s"
,
106
player->
GetName
().c_str(), group ? group->
GetLeaderName
() :
"<unknown>"
, msg.c_str());
107
break
;
108
109
case
ChatMsg::CHAT_MSG_INSTANCE_LEADER
:
110
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_BGROUND
))
111
SF_LOG_DEBUG
(
"chat.log"
,
"[BATTLEGROUND] Leader player %s tells battleground: %s"
,
112
player->
GetName
().c_str(), msg.c_str());
113
break
;
114
default
:
115
break
;
116
}
117
}
118
119
void
OnChat
(
Player
* player,
ChatMsg
type,
Language
lang, std::string& msg,
Guild
* guild)
120
{
121
switch
(type)
122
{
123
case
ChatMsg::CHAT_MSG_GUILD
:
124
if
(lang !=
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_GUILD
))
125
SF_LOG_DEBUG
(
"chat.log"
,
"[GUILD] Player %s tells guild %s: %s"
,
126
player->
GetName
().c_str(), guild ? guild->
GetName
().c_str() :
"<unknown>"
, msg.c_str());
127
else
if
(lang ==
Language::LANG_ADDON
&&
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_ADDON
))
128
SF_LOG_DEBUG
(
"chat.log"
,
"[ADDON] Player %s sends to guild %s: %s"
,
129
player->
GetName
().c_str(), guild ? guild->
GetName
().c_str() :
"<unknown>"
, msg.c_str());
130
break
;
131
132
case
ChatMsg::CHAT_MSG_OFFICER
:
133
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_GUILD
))
134
SF_LOG_DEBUG
(
"chat.log"
,
"[OFFICER] Player %s tells guild %s officers: %s"
,
135
player->
GetName
().c_str(), guild ? guild->
GetName
().c_str() :
"<unknown>"
, msg.c_str());
136
break
;
137
default
:
138
break
;
139
}
140
}
141
142
void
OnChat
(
Player
* player,
ChatMsg
/*type*/
,
Language
/*lang*/
, std::string& msg,
Channel
* channel)
143
{
144
bool
isSystem = channel &&
145
(channel->
HasFlag
(
CHANNEL_FLAG_TRADE
) ||
146
channel->
HasFlag
(
CHANNEL_FLAG_GENERAL
) ||
147
channel->
HasFlag
(
CHANNEL_FLAG_CITY
) ||
148
channel->
HasFlag
(
CHANNEL_FLAG_LFG
));
149
150
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_SYSCHAN
) && isSystem)
151
SF_LOG_DEBUG
(
"chat.log"
,
"[SYSCHAN] Player %s tells channel %s: %s"
,
152
player->
GetName
().c_str(), channel->
GetName
().c_str(), msg.c_str());
153
else
if
(
sWorld
->GetBoolConfig(
WorldBoolConfigs::CONFIG_CHATLOG_CHANNEL
))
154
SF_LOG_DEBUG
(
"chat.log"
,
"[CHANNEL] Player %s tells channel %s: %s"
,
155
player->
GetName
().c_str(), channel ? channel->
GetName
().c_str() :
"<unknown>"
, msg.c_str());
156
}
157
};
158
159
void
AddSC_chat_log
()
160
{
161
new
ChatLogScript
();
162
}
Channel.h
CHANNEL_FLAG_TRADE
@ CHANNEL_FLAG_TRADE
Definition
Channel.h:65
CHANNEL_FLAG_GENERAL
@ CHANNEL_FLAG_GENERAL
Definition
Channel.h:67
CHANNEL_FLAG_LFG
@ CHANNEL_FLAG_LFG
Definition
Channel.h:69
CHANNEL_FLAG_CITY
@ CHANNEL_FLAG_CITY
Definition
Channel.h:68
uint8
std::uint8_t uint8
Definition
Define.h:79
Group.h
Guild.h
SF_LOG_DEBUG
#define SF_LOG_DEBUG(filterType__,...)
Definition
Log.h:134
ScriptMgr.h
ChatMsg
ChatMsg
Definition
SharedDefines.h:3662
ChatMsg::CHAT_MSG_PARTY
@ CHAT_MSG_PARTY
Definition
SharedDefines.h:3666
ChatMsg::CHAT_MSG_GUILD
@ CHAT_MSG_GUILD
Definition
SharedDefines.h:3668
ChatMsg::CHAT_MSG_SAY
@ CHAT_MSG_SAY
Definition
SharedDefines.h:3665
ChatMsg::CHAT_MSG_RAID_LEADER
@ CHAT_MSG_RAID_LEADER
Definition
SharedDefines.h:3703
ChatMsg::CHAT_MSG_INSTANCE_LEADER
@ CHAT_MSG_INSTANCE_LEADER
Definition
SharedDefines.h:3731
ChatMsg::CHAT_MSG_OFFICER
@ CHAT_MSG_OFFICER
Definition
SharedDefines.h:3669
ChatMsg::CHAT_MSG_PARTY_LEADER
@ CHAT_MSG_PARTY_LEADER
Definition
SharedDefines.h:3713
ChatMsg::CHAT_MSG_RAID
@ CHAT_MSG_RAID
Definition
SharedDefines.h:3667
ChatMsg::CHAT_MSG_EMOTE
@ CHAT_MSG_EMOTE
Definition
SharedDefines.h:3674
ChatMsg::CHAT_MSG_ADDON
@ CHAT_MSG_ADDON
Definition
SharedDefines.h:3663
ChatMsg::CHAT_MSG_YELL
@ CHAT_MSG_YELL
Definition
SharedDefines.h:3670
ChatMsg::CHAT_MSG_RAID_WARNING
@ CHAT_MSG_RAID_WARNING
Definition
SharedDefines.h:3704
ChatMsg::CHAT_MSG_INSTANCE
@ CHAT_MSG_INSTANCE
Definition
SharedDefines.h:3730
Language
Language
Definition
SharedDefines.h:837
Language::LANG_ADDON
@ LANG_ADDON
Definition
SharedDefines.h:838
AddSC_chat_log
void AddSC_chat_log()
Definition
chat_log.cpp:159
Channel
Definition
Channel.h:107
Channel::HasFlag
bool HasFlag(uint8 flag) const
Definition
Channel.h:148
Channel::GetName
std::string const & GetName() const
Definition
Channel.h:138
ChatLogScript
Definition
chat_log.cpp:12
ChatLogScript::OnChat
void OnChat(Player *player, ChatMsg type, Language lang, std::string &msg)
Definition
chat_log.cpp:16
ChatLogScript::OnChat
void OnChat(Player *player, ChatMsg type, Language lang, std::string &msg, Guild *guild)
Definition
chat_log.cpp:119
ChatLogScript::OnChat
void OnChat(Player *player, ChatMsg type, Language lang, std::string &msg, Group *group)
Definition
chat_log.cpp:58
ChatLogScript::OnChat
void OnChat(Player *player, ChatMsg, Language lang, std::string &msg, Player *receiver)
Definition
chat_log.cpp:48
ChatLogScript::OnChat
void OnChat(Player *player, ChatMsg, Language, std::string &msg, Channel *channel)
Definition
chat_log.cpp:142
ChatLogScript::ChatLogScript
ChatLogScript()
Definition
chat_log.cpp:14
Group
Definition
Group.h:147
Group::GetLeaderName
const char * GetLeaderName() const
Definition
Group.cpp:2583
Guild
Definition
Guild.h:324
Guild::GetName
std::string const & GetName() const
Definition
Guild.h:760
Player
Definition
Player.h:1289
PlayerScript::PlayerScript
PlayerScript(const char *name)
Definition
ScriptMgr.cpp:1514
WorldObject::GetName
std::string const & GetName() const
Definition
Object.h:664
sWorld
#define sWorld
Definition
World.h:910
WorldBoolConfigs::CONFIG_CHATLOG_CHANNEL
@ CONFIG_CHATLOG_CHANNEL
Definition
World.h:142
WorldBoolConfigs::CONFIG_CHATLOG_GUILD
@ CONFIG_CHATLOG_GUILD
Definition
World.h:147
WorldBoolConfigs::CONFIG_CHATLOG_ADDON
@ CONFIG_CHATLOG_ADDON
Definition
World.h:149
WorldBoolConfigs::CONFIG_CHATLOG_BGROUND
@ CONFIG_CHATLOG_BGROUND
Definition
World.h:150
WorldBoolConfigs::CONFIG_CHATLOG_WHISPER
@ CONFIG_CHATLOG_WHISPER
Definition
World.h:143
WorldBoolConfigs::CONFIG_CHATLOG_RAID
@ CONFIG_CHATLOG_RAID
Definition
World.h:146
WorldBoolConfigs::CONFIG_CHATLOG_PUBLIC
@ CONFIG_CHATLOG_PUBLIC
Definition
World.h:148
WorldBoolConfigs::CONFIG_CHATLOG_SYSCHAN
@ CONFIG_CHATLOG_SYSCHAN
Definition
World.h:144
WorldBoolConfigs::CONFIG_CHATLOG_PARTY
@ CONFIG_CHATLOG_PARTY
Definition
World.h:145
src
server
scripts
World
chat_log.cpp
Generated on
for Project SkyFire Core by
1.17.0