Merge commit '4fe144de352434ff6e98a4269777b82e8b03f4d0' into pullstream
This commit is contained in:
commit
cbe7385a3b
@ -27,6 +27,7 @@ FakeTruth (founder)
|
||||
feyokorenhof
|
||||
Gareth Nelson
|
||||
GefaketHD
|
||||
Griezn (Seppe Degryse)
|
||||
HaoTNN
|
||||
havel06 (Michal Havlíček)
|
||||
hle0
|
||||
|
@ -56,4 +56,16 @@ bool ParseString(const AString & a_JsonStr, Json::Value & a_Root, AString * a_Er
|
||||
return Reader->parse(Doc, Doc + a_JsonStr.size(), &a_Root, a_ErrorMsg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AString SerializeSingleValueJsonObject(
|
||||
const AString & a_Key, const AString & a_Value)
|
||||
{
|
||||
Json::Value root;
|
||||
root[a_Key] = a_Value;
|
||||
return JsonUtils::WriteFastString(root);
|
||||
}
|
||||
|
||||
} // namespace JsonUtils
|
||||
|
@ -30,4 +30,7 @@ AString WriteStyledString(const Json::Value & a_Root);
|
||||
|
||||
bool ParseString(const AString & a_JsonStr, Json::Value & a_Root, AString * a_ErrorMsg = nullptr);
|
||||
|
||||
/** Creates a Json string representing an object with the specified single value. */
|
||||
extern AString SerializeSingleValueJsonObject(const AString & a_Key, const AString & a_Value);
|
||||
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ void cMultiVersionProtocol::SendDisconnect(cClientHandle & a_Client, const AStri
|
||||
return;
|
||||
}
|
||||
|
||||
const AString Message = fmt::format(FMT_STRING("{{\"text\":\"{}\"}}"), EscapeString(a_Reason));
|
||||
const AString Message = JsonUtils::SerializeSingleValueJsonObject("text", a_Reason);
|
||||
const auto PacketID = GetPacketID(cProtocol::ePacketType::pktDisconnectDuringLogin);
|
||||
cByteBuffer Out(
|
||||
cByteBuffer::GetVarIntSize(PacketID) +
|
||||
|
@ -25,6 +25,7 @@ Implements the 1.14 protocol classes:
|
||||
#include "Globals.h"
|
||||
#include "Protocol_1_14.h"
|
||||
#include "Packetizer.h"
|
||||
#include "JsonUtils.h"
|
||||
#include "../Root.h"
|
||||
#include "../Server.h"
|
||||
#include "../World.h"
|
||||
@ -456,7 +457,7 @@ void cProtocol_1_14::SendWindowOpen(const cWindow & a_Window)
|
||||
}
|
||||
}
|
||||
|
||||
Pkt.WriteString(fmt::format(FMT_STRING("{{\"text\":\"{}\"}}"), a_Window.GetWindowTitle()));
|
||||
Pkt.WriteString(JsonUtils::SerializeSingleValueJsonObject("text", a_Window.GetWindowTitle()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ void cProtocol_1_8_0::SendChat(const AString & a_Message, eChatType a_Type)
|
||||
{
|
||||
ASSERT(m_State == 3); // In game mode?
|
||||
|
||||
SendChatRaw(fmt::format(FMT_STRING("{{\"text\":\"{}\"}}"), EscapeString(a_Message)), a_Type);
|
||||
SendChatRaw(JsonUtils::SerializeSingleValueJsonObject("text", a_Message), a_Type);
|
||||
}
|
||||
|
||||
|
||||
@ -449,13 +449,13 @@ void cProtocol_1_8_0::SendDisconnect(const AString & a_Reason)
|
||||
case State::Login:
|
||||
{
|
||||
cPacketizer Pkt(*this, pktDisconnectDuringLogin);
|
||||
Pkt.WriteString(fmt::format(FMT_STRING("{{\"text\":\"{}\"}}"), EscapeString(a_Reason)));
|
||||
Pkt.WriteString(JsonUtils::SerializeSingleValueJsonObject("text", a_Reason));
|
||||
break;
|
||||
}
|
||||
case State::Game:
|
||||
{
|
||||
cPacketizer Pkt(*this, pktDisconnectDuringGame);
|
||||
Pkt.WriteString(fmt::format(FMT_STRING("{{\"text\":\"{}\"}}"), EscapeString(a_Reason)));
|
||||
Pkt.WriteString(JsonUtils::SerializeSingleValueJsonObject("text", a_Reason));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1119,7 +1119,7 @@ void cProtocol_1_8_0::SendPlayerListUpdateDisplayName(const cPlayer & a_Player,
|
||||
else
|
||||
{
|
||||
Pkt.WriteBool(true);
|
||||
Pkt.WriteString(fmt::format(FMT_STRING("{{\"text\":\"{}\"}}"), a_CustomName));
|
||||
Pkt.WriteString(JsonUtils::SerializeSingleValueJsonObject("text", a_CustomName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1675,9 +1675,7 @@ void cProtocol_1_8_0::SendUpdateSign(Vector3i a_BlockPos, const AString & a_Line
|
||||
AString Lines[] = { a_Line1, a_Line2, a_Line3, a_Line4 };
|
||||
for (size_t i = 0; i < ARRAYCOUNT(Lines); i++)
|
||||
{
|
||||
Json::Value RootValue;
|
||||
RootValue["text"] = Lines[i];
|
||||
Pkt.WriteString(JsonUtils::WriteFastString(RootValue));
|
||||
Pkt.WriteString(JsonUtils::SerializeSingleValueJsonObject("text", Lines[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1766,7 +1764,7 @@ void cProtocol_1_8_0::SendWindowOpen(const cWindow & a_Window)
|
||||
cPacketizer Pkt(*this, pktWindowOpen);
|
||||
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Window.GetWindowID()));
|
||||
Pkt.WriteString(a_Window.GetWindowTypeName());
|
||||
Pkt.WriteString(fmt::format(FMT_STRING("{{\"text\":\"{}\"}}"), a_Window.GetWindowTitle()));
|
||||
Pkt.WriteString(JsonUtils::SerializeSingleValueJsonObject("text", a_Window.GetWindowTitle()));
|
||||
|
||||
switch (a_Window.GetWindowType())
|
||||
{
|
||||
@ -3154,7 +3152,7 @@ void cProtocol_1_8_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEn
|
||||
a_Writer.AddString("CustomName", "@");
|
||||
if (!CommandBlockEntity.GetLastOutput().empty())
|
||||
{
|
||||
a_Writer.AddString("LastOutput", fmt::format(FMT_STRING("{{\"text\":\"{}\"}}"), CommandBlockEntity.GetLastOutput()));
|
||||
a_Writer.AddString("LastOutput", JsonUtils::SerializeSingleValueJsonObject("text", CommandBlockEntity.GetLastOutput()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user