summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-05-19 22:16:29 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-05-19 22:16:29 +0200
commit3a9543178abb7500aff65e09f054c28200ca6cac (patch)
tree098503b8bce507fcffb87e9b4ed3e2cc44aa4d86
parentAdded client translation to achievements (diff)
downloadcuberite-3a9543178abb7500aff65e09f054c28200ca6cac.tar
cuberite-3a9543178abb7500aff65e09f054c28200ca6cac.tar.gz
cuberite-3a9543178abb7500aff65e09f054c28200ca6cac.tar.bz2
cuberite-3a9543178abb7500aff65e09f054c28200ca6cac.tar.lz
cuberite-3a9543178abb7500aff65e09f054c28200ca6cac.tar.xz
cuberite-3a9543178abb7500aff65e09f054c28200ca6cac.tar.zst
cuberite-3a9543178abb7500aff65e09f054c28200ca6cac.zip
-rw-r--r--src/ClientHandle.h4
-rw-r--r--src/CompositeChat.cpp3
-rw-r--r--src/CompositeChat.h9
-rw-r--r--src/Protocol/Protocol17x.cpp2
4 files changed, 13 insertions, 5 deletions
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 9f1245be5..659c67658 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -80,9 +80,9 @@ public:
static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export
/** Formats the type of message with the proper color and prefix for sending to the client. **/
- AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData);
+ static AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData);
- AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
+ static AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
void Kick(const AString & a_Reason); // tolua_export
void Authenticate(const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator when the user passes authentication
diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp
index d3b7595b7..a3612983a 100644
--- a/src/CompositeChat.cpp
+++ b/src/CompositeChat.cpp
@@ -299,9 +299,10 @@ void cCompositeChat::ParseText(const AString & a_ParseText)
-void cCompositeChat::SetMessageType(eMessageType a_MessageType)
+void cCompositeChat::SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeData)
{
m_MessageType = a_MessageType;
+ m_AdditionalMessageTypeData = a_AdditionalMessageTypeData;
}
diff --git a/src/CompositeChat.h b/src/CompositeChat.h
index a0264d864..209d9d925 100644
--- a/src/CompositeChat.h
+++ b/src/CompositeChat.h
@@ -47,6 +47,7 @@ public:
ePartType m_PartType;
AString m_Text;
AString m_Style;
+ AString m_AdditionalStyleData;
cBasePart(ePartType a_PartType, const AString & a_Text, const AString & a_Style = "");
@@ -169,7 +170,7 @@ public:
void ParseText(const AString & a_ParseText);
/** Sets the message type, which is indicated by prefixes added to the message when serializing. */
- void SetMessageType(eMessageType a_MessageType);
+ void SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeata = "");
/** Adds the "underline" style to each part that is an URL. */
void UnderlineUrls(void);
@@ -178,6 +179,9 @@ public:
/** Returns the message type set previously by SetMessageType(). */
eMessageType GetMessageType(void) const { return m_MessageType; }
+
+ /** Returns additional data pertaining to message type, for example, the name of a mtPrivateMsg sender */
+ AString GetAdditionalMessageTypeData(void) const { return m_AdditionalMessageTypeData; }
/** Returns the text from the parts that comprises the human-readable data.
Used for older protocols that don't support composite chat
@@ -199,6 +203,9 @@ protected:
/** The message type, as indicated by prefixes. */
eMessageType m_MessageType;
+ /** Additional data pertaining to message type, for example, the name of a mtPrivateMsg sender */
+ AString m_AdditionalMessageTypeData;
+
/** Adds a_AddStyle to a_Style; overwrites the existing style if appropriate.
If the style already contains something that a_AddStyle overrides, it is erased first. */
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 3061d132b..7c526d103 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -234,7 +234,7 @@ void cProtocol172::SendChat(const cCompositeChat & a_Message)
// Compose the complete Json string to send:
Json::Value msg;
- msg["text"] = ""; // The client crashes without this
+ msg["text"] = cClientHandle::FormatMessageType(m_Client->GetPlayer()->GetWorld()->ShouldUseChatPrefixes(), a_Message.GetMessageType(), a_Message.GetAdditionalMessageTypeData()); // The client crashes without this field being present
const cCompositeChat::cParts & Parts = a_Message.GetParts();
for (cCompositeChat::cParts::const_iterator itr = Parts.begin(), end = Parts.end(); itr != end; ++itr)
{