summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Defines.h91
-rw-r--r--src/Entities/Player.h4
-rw-r--r--src/Root.h14
3 files changed, 62 insertions, 47 deletions
diff --git a/src/Defines.h b/src/Defines.h
index 17885394e..f766d4d04 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -465,51 +465,54 @@ inline AString AppendChatEpithet(const AString & a_ChatMessage, ChatPrefixCodes
{
switch (a_ChatPrefix)
{
- case mtCustom: return a_ChatMessage;
- case mtFailure:
- {
- AString Message(Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
- Message.append(a_ChatMessage);
- return Message;
- }
- case mtInformation:
- {
- AString Message(Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str()));
- Message.append(a_ChatMessage);
- return Message;
- }
- case mtSuccess:
- {
- AString Message(Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str()));
- Message.append(a_ChatMessage);
- return Message;
- }
- case mtWarning:
- {
- AString Message(Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
- Message.append(a_ChatMessage);
- return Message;
- }
- case mtFatal:
- {
- AString Message(Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str()));
- Message.append(a_ChatMessage);
- return Message;
- }
- case mtDeath:
- {
- AString Message(Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str()));
- Message.append(a_ChatMessage);
- return Message;
- }
- case mtPrivateMessage:
- {
- AString Message(Printf("%s[MSG] %s%s", cChatColor::LightBlue.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()));
- Message.append(a_ChatMessage);
- return Message;
- }
+ case mtCustom: return a_ChatMessage;
+ case mtFailure:
+ {
+ AString Message(Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtInformation:
+ {
+ AString Message(Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtSuccess:
+ {
+ AString Message(Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtWarning:
+ {
+ AString Message(Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtFatal:
+ {
+ AString Message(Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtDeath:
+ {
+ AString Message(Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtPrivateMessage:
+ {
+ AString Message(Printf("%s[MSG] %s%s", cChatColor::LightBlue.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ default: ASSERT(!"Unhandled chat prefix type!"); return "";
}
-}// tolua_begin
+}
+
+// tolua_begin
/// Normalizes an angle in degrees to the [-180, +180) range:
inline double NormalizeAngleDegrees(const double a_Degrees)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 764b47ae0..784aac327 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -199,6 +199,10 @@ public:
void SendMessageInfo(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtInformation)); }
void SendMessageFailure(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); }
void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); }
+ void SendMessageWarning(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtWarning)); }
+ void SendMessageFatal(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); }
+ void SendMessageDeath(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtDeath)); }
+ void SendMessagePrivateMsg(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtPrivateMessage)); }
const AString & GetName(void) const { return m_PlayerName; }
void SetName(const AString & a_Name) { m_PlayerName = a_Name; }
diff --git a/src/Root.h b/src/Root.h
index c59afc810..fa52c21a1 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -3,6 +3,7 @@
#include "Authenticator.h"
#include "HTTPServer/HTTPServer.h"
+#include "Defines.h"
@@ -98,9 +99,6 @@ public:
/// Saves all chunks in all worlds
void SaveAllChunks(void); // tolua_export
- /// Sends a chat message to all connected clients (in all worlds)
- void BroadcastChat(const AString & a_Message); // tolua_export
-
/// Calls the callback for each player in all worlds
bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
@@ -109,6 +107,16 @@ public:
// tolua_begin
+ /// Sends a chat message to all connected clients (in all worlds)
+ void BroadcastChat(const AString & a_Message);
+ void BroadcastChatInfo(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtInformation)); }
+ void BroadcastChatFailure(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtFailure)); }
+ void BroadcastChatSuccess(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtSuccess)); }
+ void BroadcastChatWarning(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtWarning)); }
+ void BroadcastChatFatal(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtFailure)); }
+ void BroadcastChatDeath(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtDeath)); }
+ void BroadcastChatPrivateMsg(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtPrivateMessage)); }
+
/// Returns the textual description of the protocol version: 49 -> "1.4.4". Provided specifically for Lua API
static AString GetProtocolVersionTextFromInt(int a_ProtocolVersionNum);