summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ClientHandle.cpp4
-rw-r--r--src/ClientHandle.h2
-rw-r--r--src/Entities/Player.cpp7
-rw-r--r--src/Protocol/Protocol.h2
-rw-r--r--src/Protocol/Protocol125.cpp22
-rw-r--r--src/Protocol/Protocol125.h2
-rw-r--r--src/Protocol/Protocol17x.cpp20
-rw-r--r--src/Protocol/Protocol17x.h2
-rw-r--r--src/Protocol/Protocol18x.cpp21
-rw-r--r--src/Protocol/Protocol18x.h2
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp4
-rw-r--r--src/Protocol/ProtocolRecognizer.h2
-rw-r--r--src/World.cpp4
-rw-r--r--src/World.h2
-rw-r--r--src/WorldStorage/MapSerializer.cpp18
-rw-r--r--src/WorldStorage/MapSerializer.h4
16 files changed, 41 insertions, 77 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 1e2f4ffad..878d309c9 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2453,9 +2453,9 @@ void cClientHandle::SendPlayerListUpdatePing(const cPlayer & a_Player)
-void cClientHandle::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName)
+void cClientHandle::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName)
{
- m_Protocol->SendPlayerListUpdateDisplayName(a_Player, a_OldListName);
+ m_Protocol->SendPlayerListUpdateDisplayName(a_Player, a_CustomName);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index b91c3722c..0a936a2ca 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -172,7 +172,7 @@ public:
void SendPlayerListRemovePlayer (const cPlayer & a_Player);
void SendPlayerListUpdateGameMode (const cPlayer & a_Player);
void SendPlayerListUpdatePing (const cPlayer & a_Player);
- void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName);
+ void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName);
void SendPlayerMaxSpeed (void); ///< Informs the client of the maximum player speed (1.6.1+)
void SendPlayerMoveLook (void);
void SendPlayerPosition (void);
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index a8a4061a6..66da14c0c 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -816,7 +816,8 @@ void cPlayer::SetCustomName(const AString & a_CustomName)
{
return;
}
- AString OldCustomName = m_CustomName;
+
+ m_World->BroadcastPlayerListRemovePlayer(*this);
m_CustomName = a_CustomName;
if (m_CustomName.length() > 16)
@@ -824,8 +825,8 @@ void cPlayer::SetCustomName(const AString & a_CustomName)
m_CustomName = m_CustomName.substr(0, 16);
}
- m_World->BroadcastPlayerListUpdateDisplayName(*this, m_CustomName);
- m_World->BroadcastSpawnEntity(*this, m_ClientHandle);
+ m_World->BroadcastPlayerListAddPlayer(*this);
+ m_World->BroadcastSpawnEntity(*this, GetClientHandle());
}
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index f351ee4b9..b2ee92918 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -98,7 +98,7 @@ public:
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) = 0;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) = 0;
virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) = 0;
- virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) = 0;
+ virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) = 0;
virtual void SendPlayerMaxSpeed (void) = 0; ///< Informs the client of the maximum player speed (1.6.1+)
virtual void SendPlayerMoveLook (void) = 0;
virtual void SendPlayerPosition (void) = 0;
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index 385e6a623..369a35e18 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -767,25 +767,11 @@ void cProtocol125::SendPlayerListUpdatePing(const cPlayer & a_Player)
-void cProtocol125::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName)
+void cProtocol125::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName)
{
- if (a_OldListName == a_Player.GetPlayerListName())
- {
- return;
- }
-
- cCSLock Lock(m_CSPacket);
-
- // Remove the old name from the tablist:
- {
- WriteByte (PACKET_PLAYER_LIST_ITEM);
- WriteString(a_OldListName);
- WriteBool (false);
- WriteShort (0);
- Flush();
- }
-
- SendPlayerListAddPlayer(a_Player);
+ // Not implemented in this protocol version
+ UNUSED(a_Player);
+ UNUSED(a_CustomName);
}
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 4241c1fd4..3ea116c3b 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -69,7 +69,7 @@ public:
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) override;
+ virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) override;
virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 36a808afe..ac58ef28b 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -838,23 +838,11 @@ void cProtocol172::SendPlayerListUpdatePing(const cPlayer & a_Player)
-void cProtocol172::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName)
+void cProtocol172::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName)
{
- ASSERT(m_State == 3); // In game mode?
- if (a_OldListName == a_Player.GetPlayerListName())
- {
- return;
- }
-
- // Remove the old name from the tablist:
- {
- cPacketizer Pkt(*this, 0x38);
- Pkt.WriteString(a_OldListName);
- Pkt.WriteBool(false);
- Pkt.WriteShort(0);
- }
-
- SendPlayerListAddPlayer(a_Player);
+ // Not implemented in this protocol version
+ UNUSED(a_Player);
+ UNUSED(a_CustomName);
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 7ec7d0fce..8f537f5d7 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -105,7 +105,7 @@ public:
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) override;
+ virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) override;
virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index 9f7569ff2..a2dbb7a1f 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -802,7 +802,7 @@ void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player)
Pkt.WriteVarInt(0);
Pkt.WriteVarInt(1);
Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteString(a_Player.GetName());
+ Pkt.WriteString(a_Player.GetPlayerListName());
const Json::Value & Properties = a_Player.GetClientHandle()->GetProperties();
Pkt.WriteVarInt(Properties.size());
@@ -824,17 +824,7 @@ void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player)
Pkt.WriteVarInt((UInt32)a_Player.GetGameMode());
Pkt.WriteVarInt((UInt32)a_Player.GetClientHandle()->GetPing());
-
- 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);
- }
+ Pkt.WriteBool(false);
}
@@ -885,7 +875,7 @@ void cProtocol180::SendPlayerListUpdatePing(const cPlayer & a_Player)
-void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName)
+void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName)
{
ASSERT(m_State == 3); // In game mode?
@@ -894,15 +884,14 @@ void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, con
Pkt.WriteVarInt(1);
Pkt.WriteUUID(a_Player.GetUUID());
- AString CustomName = a_Player.GetPlayerListName();
- if (CustomName == a_Player.GetName())
+ if (a_CustomName.empty())
{
Pkt.WriteBool(false);
}
else
{
Pkt.WriteBool(true);
- Pkt.WriteString(Printf("{\"text\":\"%s\"}", CustomName.c_str()));
+ Pkt.WriteString(Printf("{\"text\":\"%s\"}", a_CustomName.c_str()));
}
}
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index df188b70f..554edecc8 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -101,7 +101,7 @@ public:
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) override;
+ virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) override;
virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index a5b745c2f..fe53aede1 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -529,10 +529,10 @@ void cProtocolRecognizer::SendPlayerListUpdatePing(const cPlayer & a_Player)
-void cProtocolRecognizer::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName)
+void cProtocolRecognizer::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerListUpdateDisplayName(a_Player, a_OldListName);
+ m_Protocol->SendPlayerListUpdateDisplayName(a_Player, a_CustomName);
}
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 55348a758..e4419f6ae 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -105,7 +105,7 @@ public:
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) override;
+ virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) override;
virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
diff --git a/src/World.cpp b/src/World.cpp
index cd23ff191..61c061867 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2236,7 +2236,7 @@ void cWorld::BroadcastPlayerListUpdatePing(const cPlayer & a_Player, const cClie
-void cWorld::BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName, const cClientHandle * a_Exclude)
+void cWorld::BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -2246,7 +2246,7 @@ void cWorld::BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, cons
{
continue;
}
- ch->SendPlayerListUpdateDisplayName(a_Player, a_OldListName);
+ ch->SendPlayerListUpdateDisplayName(a_Player, a_CustomName);
}
}
diff --git a/src/World.h b/src/World.h
index c3ceb5e7c..90dada259 100644
--- a/src/World.h
+++ b/src/World.h
@@ -245,7 +245,7 @@ public:
void BroadcastPlayerListRemovePlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastPlayerListUpdateGameMode (const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastPlayerListUpdatePing (const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
- void BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName, const cClientHandle * a_Exclude = NULL);
+ void BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName, const cClientHandle * a_Exclude = NULL);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode);
void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode);
diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp
index 012fc52f3..4a913c81a 100644
--- a/src/WorldStorage/MapSerializer.cpp
+++ b/src/WorldStorage/MapSerializer.cpp
@@ -130,14 +130,14 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
}
int CurrLine = a_NBT.FindChildByName(Data, "scale");
- if (CurrLine >= 0)
+ if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Byte))
{
- unsigned int Scale = a_NBT.GetByte(CurrLine);
+ unsigned int Scale = (unsigned int)a_NBT.GetByte(CurrLine);
m_Map->SetScale(Scale);
}
CurrLine = a_NBT.FindChildByName(Data, "dimension");
- if (CurrLine >= 0)
+ if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Byte))
{
eDimension Dimension = (eDimension) a_NBT.GetByte(CurrLine);
@@ -149,9 +149,9 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
}
CurrLine = a_NBT.FindChildByName(Data, "width");
- if (CurrLine >= 0)
+ if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Short))
{
- unsigned int Width = a_NBT.GetShort(CurrLine);
+ unsigned int Width = (unsigned int)a_NBT.GetShort(CurrLine);
if (Width != 128)
{
return false;
@@ -160,9 +160,9 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
}
CurrLine = a_NBT.FindChildByName(Data, "height");
- if (CurrLine >= 0)
+ if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Short))
{
- unsigned int Height = a_NBT.GetShort(CurrLine);
+ unsigned int Height = (unsigned int)a_NBT.GetShort(CurrLine);
if (Height >= 256)
{
return false;
@@ -171,14 +171,14 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
}
CurrLine = a_NBT.FindChildByName(Data, "xCenter");
- if (CurrLine >= 0)
+ if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Int))
{
int CenterX = a_NBT.GetInt(CurrLine);
m_Map->m_CenterX = CenterX;
}
CurrLine = a_NBT.FindChildByName(Data, "zCenter");
- if (CurrLine >= 0)
+ if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Int))
{
int CenterZ = a_NBT.GetInt(CurrLine);
m_Map->m_CenterZ = CenterZ;
diff --git a/src/WorldStorage/MapSerializer.h b/src/WorldStorage/MapSerializer.h
index 4fa40f6f9..e13a75c8f 100644
--- a/src/WorldStorage/MapSerializer.h
+++ b/src/WorldStorage/MapSerializer.h
@@ -28,10 +28,10 @@ public:
cMapSerializer(const AString& a_WorldName, cMap * a_Map);
- /** Try to load the scoreboard */
+ /** Try to load the map */
bool Load(void);
- /** Try to save the scoreboard */
+ /** Try to save the map */
bool Save(void);