summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-03-18 00:18:02 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-03-19 12:23:30 +0100
commit55ba39ca0e2d4aed9c0c1b3e030727728ea0a02f (patch)
tree4ec40239f2f1e2225b14faba1b4e5aa110e1a471 /src/Protocol
parentDeduplicate WriteBlockEntity (diff)
downloadcuberite-55ba39ca0e2d4aed9c0c1b3e030727728ea0a02f.tar
cuberite-55ba39ca0e2d4aed9c0c1b3e030727728ea0a02f.tar.gz
cuberite-55ba39ca0e2d4aed9c0c1b3e030727728ea0a02f.tar.bz2
cuberite-55ba39ca0e2d4aed9c0c1b3e030727728ea0a02f.tar.lz
cuberite-55ba39ca0e2d4aed9c0c1b3e030727728ea0a02f.tar.xz
cuberite-55ba39ca0e2d4aed9c0c1b3e030727728ea0a02f.tar.zst
cuberite-55ba39ca0e2d4aed9c0c1b3e030727728ea0a02f.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol.h2
-rw-r--r--src/Protocol/Protocol_1_8.cpp14
-rw-r--r--src/Protocol/Protocol_1_8.h2
3 files changed, 12 insertions, 6 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 743a73aba..3c70cdb55 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -410,7 +410,7 @@ public:
virtual void SendPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) = 0;
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 SendPlayerListUpdatePing () = 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;
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index 654146e14..79f75fcc5 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -1111,15 +1111,21 @@ void cProtocol_1_8_0::SendPlayerListUpdateGameMode(const cPlayer & a_Player)
-void cProtocol_1_8_0::SendPlayerListUpdatePing(const cPlayer & a_Player)
+void cProtocol_1_8_0::SendPlayerListUpdatePing()
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktPlayerList);
Pkt.WriteVarInt32(2);
- Pkt.WriteVarInt32(1);
- Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetClientHandle()->GetPing()));
+
+ const auto World = m_Client->GetPlayer()->GetWorld();
+ Pkt.WriteVarInt32(static_cast<UInt32>(World->GetPlayerCount()));
+ World->ForEachPlayer([&Pkt](cPlayer & a_Player)
+ {
+ Pkt.WriteUUID(a_Player.GetUUID());
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetClientHandle()->GetPing()));
+ return false;
+ });
}
diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h
index 9a849e82e..ae6d09417 100644
--- a/src/Protocol/Protocol_1_8.h
+++ b/src/Protocol/Protocol_1_8.h
@@ -94,7 +94,7 @@ public:
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) override;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) override;
+ virtual void SendPlayerListUpdatePing () override;
virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;