diff options
author | Franz Reiter <franzi.moos@googlemail.com> | 2014-09-23 15:54:07 +0200 |
---|---|---|
committer | Franz Reiter <franzi.moos@googlemail.com> | 2014-09-23 15:54:07 +0200 |
commit | 33f8091d5f550a91b1fbe24f07a397aa5a336093 (patch) | |
tree | 4fe1be83dd4212e010fed749cd444c4deecc64e6 /src/Protocol | |
parent | QtBiomeVisualiser: Fixed confusion about Globals.h. (diff) | |
parent | Fixed SQLiteCpp downgrade (diff) | |
download | cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.gz cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.bz2 cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.lz cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.xz cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.zst cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.zip |
Diffstat (limited to 'src/Protocol')
-rw-r--r-- | src/Protocol/Protocol125.cpp | 15 | ||||
-rw-r--r-- | src/Protocol/Protocol132.cpp | 9 | ||||
-rw-r--r-- | src/Protocol/Protocol17x.cpp | 35 | ||||
-rw-r--r-- | src/Protocol/Protocol18x.cpp | 19 |
4 files changed, 62 insertions, 16 deletions
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 4378ef466..ba4cfa7ef 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -723,7 +723,7 @@ void cProtocol125::SendPlayerListAddPlayer(const cPlayer & a_Player) { cCSLock Lock(m_CSPacket); WriteByte (PACKET_PLAYER_LIST_ITEM); - WriteString(a_Player.GetName()); + WriteString(a_Player.GetPlayerListName()); WriteBool (true); WriteShort (a_Player.GetClientHandle()->GetPing()); Flush(); @@ -737,7 +737,7 @@ void cProtocol125::SendPlayerListRemovePlayer(const cPlayer & a_Player) { cCSLock Lock(m_CSPacket); WriteByte (PACKET_PLAYER_LIST_ITEM); - WriteString(a_Player.GetName()); + WriteString(a_Player.GetPlayerListName()); WriteBool (false); WriteShort (0); Flush(); @@ -769,7 +769,7 @@ void cProtocol125::SendPlayerListUpdatePing(const cPlayer & a_Player) void cProtocol125::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) { - if (a_OldListName == a_Player.GetName()) + if (a_OldListName == a_Player.GetPlayerListName()) { return; } @@ -843,7 +843,14 @@ void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player) cCSLock Lock(m_CSPacket); WriteByte (PACKET_PLAYER_SPAWN); WriteInt (a_Player.GetUniqueID()); - WriteString(a_Player.GetName()); + if (a_Player.HasCustomName()) + { + WriteString(a_Player.GetCustomName()); + } + else + { + WriteString(a_Player.GetName()); + } WriteInt ((int)(a_Player.GetPosX() * 32)); WriteInt ((int)(a_Player.GetPosY() * 32)); WriteInt ((int)(a_Player.GetPosZ() * 32)); diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 5fd2655b8..63a15c082 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -260,7 +260,14 @@ void cProtocol132::SendPlayerSpawn(const cPlayer & a_Player) cCSLock Lock(m_CSPacket); WriteByte (PACKET_PLAYER_SPAWN); WriteInt (a_Player.GetUniqueID()); - WriteString(a_Player.GetName()); + if (a_Player.HasCustomName()) + { + WriteString(a_Player.GetCustomName()); + } + else + { + WriteString(a_Player.GetName()); + } WriteInt ((int)(a_Player.GetPosX() * 32)); WriteInt ((int)(a_Player.GetPosY() * 32)); WriteInt ((int)(a_Player.GetPosZ() * 32)); diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 2fbc58541..67a4c47a7 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -795,7 +795,7 @@ void cProtocol172::SendPlayerListAddPlayer(const cPlayer & a_Player) ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x38); // Playerlist Item packet - Pkt.WriteString(a_Player.GetName()); + Pkt.WriteString(a_Player.GetPlayerListName()); Pkt.WriteBool(true); Pkt.WriteShort(a_Player.GetClientHandle()->GetPing()); } @@ -809,7 +809,7 @@ void cProtocol172::SendPlayerListRemovePlayer(const cPlayer & a_Player) ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x38); - Pkt.WriteString(a_Player.GetName()); + Pkt.WriteString(a_Player.GetPlayerListName()); Pkt.WriteBool(false); Pkt.WriteShort(0); } @@ -841,7 +841,7 @@ void cProtocol172::SendPlayerListUpdatePing(const cPlayer & a_Player) void cProtocol172::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) { ASSERT(m_State == 3); // In game mode? - if (a_OldListName == a_Player.GetName()) + if (a_OldListName == a_Player.GetPlayerListName()) { return; } @@ -928,9 +928,16 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player) // Called to spawn another player for the client cPacketizer Pkt(*this, 0x0c); // Spawn Player packet - Pkt.WriteVarInt(a_Player.GetUniqueID()); + Pkt.WriteVarInt((UInt32) a_Player.GetUniqueID()); Pkt.WriteString(cMojangAPI::MakeUUIDDashed(a_Player.GetClientHandle()->GetUUID())); - Pkt.WriteString(a_Player.GetName()); + if (a_Player.HasCustomName()) + { + Pkt.WriteString(a_Player.GetCustomName()); + } + else + { + Pkt.WriteString(a_Player.GetName()); + } Pkt.WriteFPInt(a_Player.GetPosX()); Pkt.WriteFPInt(a_Player.GetPosY()); Pkt.WriteFPInt(a_Player.GetPosZ()); @@ -2928,6 +2935,15 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob) break; } } // switch (a_Mob.GetType()) + + // Custom name: + if (a_Mob.HasCustomName()) + { + WriteByte(0x8a); + WriteString(a_Mob.GetCustomName()); + WriteByte(0x0b); + WriteByte(a_Mob.IsCustomNameAlwaysVisible() ? 1 : 0); + } } @@ -2972,7 +2988,14 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player) cPacketizer Pkt(*this, 0x0c); // Spawn Player packet Pkt.WriteVarInt(a_Player.GetUniqueID()); Pkt.WriteString(cMojangAPI::MakeUUIDDashed(a_Player.GetClientHandle()->GetUUID())); - Pkt.WriteString(a_Player.GetName()); + if (a_Player.HasCustomName()) + { + Pkt.WriteString(a_Player.GetCustomName()); + } + else + { + Pkt.WriteString(a_Player.GetName()); + } const Json::Value & Properties = a_Player.GetClientHandle()->GetProperties(); Pkt.WriteVarInt(Properties.size()); diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index a7ab3abb1..e2ea6701a 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -824,7 +824,17 @@ void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player) Pkt.WriteVarInt((UInt32)a_Player.GetGameMode()); Pkt.WriteVarInt((UInt32)a_Player.GetClientHandle()->GetPing()); - Pkt.WriteBool(false); + + AString CustomName = a_Player.GetPlayerListName(); + if (CustomName != a_Player.GetName()) + { + Pkt.WriteBool(true); + Pkt.WriteString(Printf("{\"text\":\"%s\"}", CustomName.c_str())); + } + else + { + Pkt.WriteBool(false); + } } @@ -877,7 +887,6 @@ void cProtocol180::SendPlayerListUpdatePing(const cPlayer & a_Player) void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) { - UNUSED(a_OldListName); ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x38); // Playerlist Item packet @@ -885,15 +894,15 @@ void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, con Pkt.WriteVarInt(1); Pkt.WriteUUID(a_Player.GetUUID()); - // TODO: Replace this with GetPlayerListName() (It's already done in other pull request) - if (a_Player.GetName().empty()) + AString CustomName = a_Player.GetPlayerListName(); + if (CustomName == a_Player.GetName()) { Pkt.WriteBool(false); } else { Pkt.WriteBool(true); - Pkt.WriteString(Printf("{\"text\":\"%s\"}", a_Player.GetName().c_str())); + Pkt.WriteString(Printf("{\"text\":\"%s\"}", CustomName.c_str())); } } |