summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Protocol/Protocol.h2
-rw-r--r--src/Protocol/Protocol125.cpp12
-rw-r--r--src/Protocol/Protocol125.h2
-rw-r--r--src/Protocol/Protocol17x.cpp13
-rw-r--r--src/Protocol/Protocol17x.h2
-rw-r--r--src/Protocol/Protocol18x.cpp74
-rw-r--r--src/Protocol/Protocol18x.h2
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp4
-rw-r--r--src/Protocol/ProtocolRecognizer.h2
9 files changed, 92 insertions, 21 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 5811e5bff..902c72675 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -94,7 +94,7 @@ public:
virtual void SendPlayerAbilities (void) = 0;
virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) = 0;
virtual void SendParticleEffect (const AString & a_SoundName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount) = 0;
- virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) = 0;
+ virtual void SendPlayerListItem (const cPlayer & a_Player, char a_Action) = 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 77939d933..8c4534ff7 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -720,9 +720,15 @@ void cProtocol125::SendPaintingSpawn(const cPainting & a_Painting)
-void cProtocol125::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+void cProtocol125::SendPlayerListItem(const cPlayer & a_Player, char a_Action)
{
cCSLock Lock(m_CSPacket);
+ if (a_Action == 1)
+ {
+ // Ignore gamemode update
+ return;
+ }
+
AString PlayerName(a_Player.GetColor());
PlayerName.append(a_Player.GetName());
if (PlayerName.length() > 14)
@@ -733,8 +739,8 @@ void cProtocol125::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
WriteByte ((unsigned char)PACKET_PLAYER_LIST_ITEM);
WriteString(PlayerName);
- WriteBool (a_IsOnline);
- WriteShort (a_IsOnline ? a_Player.GetClientHandle()->GetPing() : 0);
+ WriteBool (a_Action != 4);
+ WriteShort ((a_Action == 4) ? 0 : a_Player.GetClientHandle()->GetPing());
Flush();
}
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 1063777a2..029845b8b 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -65,7 +65,7 @@ public:
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAbilities (void) override {} // This protocol doesn't support such message
virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) override;
- virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
+ virtual void SendPlayerListItem (const cPlayer & a_Player, char a_Action) 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 162d4da30..b4f96bd88 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -867,14 +867,19 @@ void cProtocol172::SendParticleEffect(const AString & a_ParticleName, float a_Sr
-void cProtocol172::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+void cProtocol172::SendPlayerListItem(const cPlayer & a_Player, char a_Action)
{
ASSERT(m_State == 3); // In game mode?
-
+ if (a_Action == 1)
+ {
+ // Ignore gamemode update
+ return;
+ }
+
cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
Pkt.WriteString(a_Player.GetName());
- Pkt.WriteBool(a_IsOnline);
- Pkt.WriteShort(a_IsOnline ? a_Player.GetClientHandle()->GetPing() : 0);
+ Pkt.WriteBool(a_Action != 4);
+ Pkt.WriteShort((a_Action == 4) ? 0 : a_Player.GetClientHandle()->GetPing());
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 24fe1cb20..6bb5873d3 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -101,7 +101,7 @@ public:
virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount) override;
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAbilities (void) override;
- virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
+ virtual void SendPlayerListItem (const cPlayer & a_Player, char a_Action) 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 e336dcbec..5f1f97a4a 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -659,7 +659,7 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
Pkt.WriteChar((char)a_World.GetDimension());
Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60));
+ Pkt.WriteByte(Server->GetMaxPlayers());
Pkt.WriteString("default"); // Level type - wtf?
Pkt.WriteBool(false); // Reduced Debug Info - wtf?
}
@@ -868,14 +868,74 @@ void cProtocol180::SendParticleEffect(const AString & a_ParticleName, float a_Sr
-void cProtocol180::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+void cProtocol180::SendPlayerListItem(const cPlayer & a_Player, char a_Action)
{
ASSERT(m_State == 3); // In game mode?
-
- /*cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
- Pkt.WriteString(a_Player.GetName());
- Pkt.WriteBool(a_IsOnline);
- Pkt.WriteShort(a_IsOnline ? a_Player.GetClientHandle()->GetPing() : 0);*/
+
+ cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
+ Pkt.WriteVarInt(a_Action);
+ Pkt.WriteVarInt(1);
+ Pkt.WriteUUID(a_Player.GetUUID());
+
+ switch (a_Action)
+ {
+ case 0:
+ {
+ // Add Player
+ Pkt.WriteString(a_Player.GetName());
+
+ const Json::Value & Properties = a_Player.GetClientHandle()->GetProperties();
+ Pkt.WriteVarInt(Properties.size());
+ for (Json::Value::iterator itr = Properties.begin(), end = Properties.end(); itr != end; ++itr)
+ {
+ Pkt.WriteString(((Json::Value)*itr).get("name", "").asString());
+ Pkt.WriteString(((Json::Value)*itr).get("value", "").asString());
+ AString Signature = ((Json::Value)*itr).get("signature", "").asString();
+ if (Signature.empty())
+ {
+ Pkt.WriteBool(false);
+ }
+ else
+ {
+ Pkt.WriteBool(true);
+ Pkt.WriteString(Signature);
+ }
+ }
+
+ Pkt.WriteVarInt((UInt32)a_Player.GetGameMode());
+ Pkt.WriteVarInt((UInt32)a_Player.GetClientHandle()->GetPing());
+ Pkt.WriteBool(false);
+ break;
+ }
+ case 1:
+ {
+ // Update GameMode
+ Pkt.WriteVarInt((UInt32)a_Player.GetGameMode());
+ break;
+ }
+ case 2:
+ {
+ // Update Ping
+ Pkt.WriteVarInt((UInt32)a_Player.GetClientHandle()->GetPing());
+ break;
+ }
+ case 3:
+ {
+ // Update DisplayName
+ Pkt.WriteBool(false);
+ break;
+ }
+ case 4:
+ {
+ // Remove player
+ break;
+ }
+ default:
+ {
+ ASSERT(!"Unhandled player list item action!");
+ return;
+ }
+ }
}
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index 207af0b44..8e8570b68 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -97,7 +97,7 @@ public:
virtual void SendPlayerAbilities (void) override;
virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) override;
virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount) override;
- virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
+ virtual void SendPlayerListItem (const cPlayer & a_Player, char a_Action) 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 c535390cc..56e5b43f3 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -489,10 +489,10 @@ void cProtocolRecognizer::SendEntityAnimation(const cEntity & a_Entity, char a_A
-void cProtocolRecognizer::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+void cProtocolRecognizer::SendPlayerListItem(const cPlayer & a_Player, char a_Action)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
+ m_Protocol->SendPlayerListItem(a_Player, a_Action);
}
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 2e8976a9f..4d2bceb68 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -101,7 +101,7 @@ public:
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAbilities (void) override;
virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) override;
- virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
+ virtual void SendPlayerListItem (const cPlayer & a_Player, char a_Action) override;
virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;