diff options
-rw-r--r-- | src/ClientHandle.cpp | 18 | ||||
-rw-r--r-- | src/Protocol/Protocol.h | 10 | ||||
-rw-r--r-- | src/Protocol/Protocol17x.cpp | 67 | ||||
-rw-r--r-- | src/Protocol/Protocol17x.h | 10 | ||||
-rw-r--r-- | src/Protocol/Protocol18x.cpp | 66 | ||||
-rw-r--r-- | src/Protocol/Protocol18x.h | 10 | ||||
-rw-r--r-- | src/Protocol/ProtocolRecognizer.cpp | 68 | ||||
-rw-r--r-- | src/Protocol/ProtocolRecognizer.h | 10 |
8 files changed, 32 insertions, 227 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 679dd6a46..6c9e6a781 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2086,8 +2086,9 @@ void cClientHandle::SendChat(const AString & a_Message, eMessageType a_ChatPrefi } } - AString Message = FormatMessageType(World->ShouldUseChatPrefixes(), a_ChatPrefix, a_AdditionalData); - m_Protocol->SendChat(Message.append(a_Message)); + bool ShouldUsePrefixes = World->ShouldUseChatPrefixes(); + AString Message = FormatMessageType(ShouldUsePrefixes, a_ChatPrefix, a_AdditionalData); + m_Protocol->SendChat(Message.append(a_Message), ctChatBox, ShouldUsePrefixes); } @@ -2096,7 +2097,7 @@ void cClientHandle::SendChat(const AString & a_Message, eMessageType a_ChatPrefi void cClientHandle::SendChat(const cCompositeChat & a_Message) { - m_Protocol->SendChat(a_Message); + m_Protocol->SendChat(a_Message, ctChatBox, GetPlayer()->GetWorld()->ShouldUseChatPrefixes()); } @@ -2116,7 +2117,7 @@ void cClientHandle::SendChatAboveActionBar(const AString & a_Message, eMessageTy } AString Message = FormatMessageType(World->ShouldUseChatPrefixes(), a_ChatPrefix, a_AdditionalData); - m_Protocol->SendChatAboveActionBar(Message.append(a_Message)); + m_Protocol->SendChat(Message.append(a_Message), ctAboveActionBar); } @@ -2125,7 +2126,7 @@ void cClientHandle::SendChatAboveActionBar(const AString & a_Message, eMessageTy void cClientHandle::SendChatAboveActionBar(const cCompositeChat & a_Message) { - m_Protocol->SendChatAboveActionBar(a_Message); + m_Protocol->SendChat(a_Message, ctAboveActionBar, GetPlayer()->GetWorld()->ShouldUseChatPrefixes()); } @@ -2144,8 +2145,9 @@ void cClientHandle::SendChatSystem(const AString & a_Message, eMessageType a_Cha } } - AString Message = FormatMessageType(World->ShouldUseChatPrefixes(), a_ChatPrefix, a_AdditionalData); - m_Protocol->SendChatSystem(Message.append(a_Message)); + auto ShouldUsePrefixes = World->ShouldUseChatPrefixes(); + AString Message = FormatMessageType(ShouldUsePrefixes, a_ChatPrefix, a_AdditionalData); + m_Protocol->SendChat(Message.append(a_Message), ctSystem, ShouldUsePrefixes); } @@ -2154,7 +2156,7 @@ void cClientHandle::SendChatSystem(const AString & a_Message, eMessageType a_Cha void cClientHandle::SendChatSystem(const cCompositeChat & a_Message) { - m_Protocol->SendChatSystem(a_Message); + m_Protocol->SendChat(a_Message, ctSystem, GetPlayer()->GetWorld()->ShouldUseChatPrefixes()); } diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 9153ec8ae..4581da6a9 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -68,14 +68,8 @@ public: virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) = 0; virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) = 0; - virtual void SendChat (const AString & a_Message) = 0; - virtual void SendChat (const cCompositeChat & a_Message) = 0; - virtual void SendChatAboveActionBar (const AString & a_Message) = 0; - virtual void SendChatAboveActionBar (const cCompositeChat & a_Message) = 0; - virtual void SendChatSystem (const AString & a_Message) = 0; - virtual void SendChatSystem (const cCompositeChat & a_Message) = 0; - virtual void SendChatType (const AString & a_Message, eChatType type) = 0; - virtual void SendChatType (const cCompositeChat & a_Message, eChatType type) = 0; + virtual void SendChat (const AString & a_Message, eChatType a_Type) = 0; + virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) = 0; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) = 0; virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) = 0; virtual void SendDestroyEntity (const cEntity & a_Entity) = 0; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 3ac656d47..ad76480b3 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -245,65 +245,11 @@ void cProtocol172::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV -void cProtocol172::SendChat(const AString & a_Message) -{ - this->SendChatType(a_Message, ctChatBox); -} - - - - - -void cProtocol172::SendChat(const cCompositeChat & a_Message) -{ - this->SendChatType(a_Message, ctChatBox); -} - - - - - -void cProtocol172::SendChatSystem(const AString & a_Message) -{ - this->SendChatType(a_Message, ctSystem); -} - - - - - -void cProtocol172::SendChatSystem(const cCompositeChat & a_Message) -{ - this->SendChatType(a_Message, ctSystem); -} - - - - - -void cProtocol172::SendChatAboveActionBar(const AString & a_Message) -{ - this->SendChatType(a_Message, ctAboveActionBar); -} - - - - - -void cProtocol172::SendChatAboveActionBar(const cCompositeChat & a_Message) -{ - this->SendChatType(a_Message, ctAboveActionBar); -} - - - - - -void cProtocol172::SendChatType(const AString & a_Message, eChatType type) +void cProtocol172::SendChat(const AString & a_Message, eChatType a_Type) { ASSERT(m_State == 3); // In game mode? - if (type != ctChatBox) // 1.7.2 doesn't support anything else + if (a_Type != ctChatBox) // 1.7.2 doesn't support anything else { return; } @@ -316,21 +262,18 @@ void cProtocol172::SendChatType(const AString & a_Message, eChatType type) -void cProtocol172::SendChatType(const cCompositeChat & a_Message, eChatType type) +void cProtocol172::SendChat(const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) { ASSERT(m_State == 3); // In game mode? - if (type != ctChatBox) // 1.7.2 doesn't support anything else + if (a_Type != ctChatBox) // 1.7.2 doesn't support anything else { return; } - cWorld * World = m_Client->GetPlayer()->GetWorld(); - bool ShouldUseChatPrefixes = (World == nullptr) ? false : World->ShouldUseChatPrefixes(); - // Send the message to the client: cPacketizer Pkt(*this, 0x02); - Pkt.WriteString(a_Message.CreateJsonString(ShouldUseChatPrefixes)); + Pkt.WriteString(a_Message.CreateJsonString(a_ShouldUseChatPrefixes)); } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 9d2d108dc..cc201f840 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -66,14 +66,8 @@ public: virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override; virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override; - virtual void SendChat (const AString & a_Message) override; - virtual void SendChat (const cCompositeChat & a_Message) override; - virtual void SendChatAboveActionBar (const AString & a_Message) override; - virtual void SendChatAboveActionBar (const cCompositeChat & a_Message) override; - virtual void SendChatSystem (const AString & a_Message) override; - virtual void SendChatSystem (const cCompositeChat & a_Message) override; - virtual void SendChatType (const AString & a_Message, eChatType type) override; - virtual void SendChatType (const cCompositeChat & a_Message, eChatType type) override; + virtual void SendChat (const AString & a_Message, eChatType a_Type) override; + virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override; virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override; virtual void SendDestroyEntity (const cEntity & a_Entity) override; diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index 115028fa9..ed1d3bfc1 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -232,84 +232,28 @@ void cProtocol180::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV -void cProtocol180::SendChat(const AString & a_Message) -{ - this->SendChatType(a_Message, ctChatBox); -} - - - - - -void cProtocol180::SendChat(const cCompositeChat & a_Message) -{ - this->SendChatType(a_Message, ctChatBox); -} - - - - - -void cProtocol180::SendChatSystem(const AString & a_Message) -{ - this->SendChatType(a_Message, ctSystem); -} - - - - - -void cProtocol180::SendChatSystem(const cCompositeChat & a_Message) -{ - this->SendChatType(a_Message, ctSystem); -} - - - - - -void cProtocol180::SendChatAboveActionBar(const AString & a_Message) -{ - this->SendChatType(a_Message, ctAboveActionBar); -} - - - - - -void cProtocol180::SendChatAboveActionBar(const cCompositeChat & a_Message) -{ - this->SendChatType(a_Message, ctAboveActionBar); -} - - - - - -void cProtocol180::SendChatType(const AString & a_Message, eChatType type) +void cProtocol180::SendChat(const AString & a_Message, eChatType a_Type) { ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x02); // Chat Message packet Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Message).c_str())); - Pkt.WriteBEInt8(type); + Pkt.WriteBEInt8(a_Type); } -void cProtocol180::SendChatType(const cCompositeChat & a_Message, eChatType type) +void cProtocol180::SendChat(const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) { ASSERT(m_State == 3); // In game mode? - cWorld * World = m_Client->GetPlayer()->GetWorld(); - bool ShouldUseChatPrefixes = (World == nullptr) ? false : World->ShouldUseChatPrefixes(); // Send the message to the client: cPacketizer Pkt(*this, 0x02); - Pkt.WriteString(a_Message.CreateJsonString(ShouldUseChatPrefixes)); - Pkt.WriteBEInt8(type); + Pkt.WriteString(a_Message.CreateJsonString(a_ShouldUseChatPrefixes)); + Pkt.WriteBEInt8(a_Type); } diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h index 02add5528..aa73a4a6a 100644 --- a/src/Protocol/Protocol18x.h +++ b/src/Protocol/Protocol18x.h @@ -65,14 +65,8 @@ public: virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override; virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override; - virtual void SendChat (const AString & a_Message) override; - virtual void SendChat (const cCompositeChat & a_Message) override; - virtual void SendChatAboveActionBar (const AString & a_Message) override; - virtual void SendChatAboveActionBar (const cCompositeChat & a_Message) override; - virtual void SendChatSystem (const AString & a_Message) override; - virtual void SendChatSystem (const cCompositeChat & a_Message) override; - virtual void SendChatType (const AString & a_Message, eChatType type) override; - virtual void SendChatType (const cCompositeChat & a_Message, eChatType type) override; + virtual void SendChat (const AString & a_Message, eChatType a_Type) override; + virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override; virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override; virtual void SendDestroyEntity (const cEntity & a_Entity) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 42c2eee0a..0d16262f9 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -138,80 +138,20 @@ void cProtocolRecognizer::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSe -void cProtocolRecognizer::SendChat(const AString & a_Message) +void cProtocolRecognizer::SendChat(const AString & a_Message, eChatType a_Type) { ASSERT(m_Protocol != nullptr); - m_Protocol->SendChat(a_Message); + m_Protocol->SendChat(a_Message, a_Type); } -void cProtocolRecognizer::SendChat(const cCompositeChat & a_Message) +void cProtocolRecognizer::SendChat(const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) { ASSERT(m_Protocol != nullptr); - m_Protocol->SendChat(a_Message); -} - - - - - -void cProtocolRecognizer::SendChatAboveActionBar(const AString & a_Message) -{ - ASSERT(m_Protocol != nullptr); - m_Protocol->SendChatAboveActionBar(a_Message); -} - - - - - -void cProtocolRecognizer::SendChatAboveActionBar(const cCompositeChat & a_Message) -{ - ASSERT(m_Protocol != nullptr); - m_Protocol->SendChatAboveActionBar(a_Message); -} - - - - - -void cProtocolRecognizer::SendChatSystem(const AString & a_Message) -{ - ASSERT(m_Protocol != nullptr); - m_Protocol->SendChatSystem(a_Message); -} - - - - - -void cProtocolRecognizer::SendChatSystem(const cCompositeChat & a_Message) -{ - ASSERT(m_Protocol != nullptr); - m_Protocol->SendChatSystem(a_Message); -} - - - - - -void cProtocolRecognizer::SendChatType(const AString & a_Message, eChatType type) -{ - ASSERT(m_Protocol != nullptr); - m_Protocol->SendChatType(a_Message, type); -} - - - - - -void cProtocolRecognizer::SendChatType(const cCompositeChat & a_Message, eChatType type) -{ - ASSERT(m_Protocol != nullptr); - m_Protocol->SendChatType(a_Message, type); + m_Protocol->SendChat(a_Message, a_Type, a_ShouldUseChatPrefixes); } diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index d3cfd9bf7..7b5952bea 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -53,14 +53,8 @@ public: virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override; virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override; - virtual void SendChat (const AString & a_Message) override; - virtual void SendChat (const cCompositeChat & a_Message) override; - virtual void SendChatAboveActionBar (const AString & a_Message) override; - virtual void SendChatAboveActionBar (const cCompositeChat & a_Message) override; - virtual void SendChatSystem (const AString & a_Message) override; - virtual void SendChatSystem (const cCompositeChat & a_Message) override; - virtual void SendChatType (const AString & a_Message, eChatType type) override; - virtual void SendChatType (const cCompositeChat & a_Message, eChatType type) override; + virtual void SendChat (const AString & a_Message, eChatType a_Type) override; + virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override; virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override; virtual void SendDestroyEntity (const cEntity & a_Entity) override; |