Added the player list to the 1.8 protocol.
This commit is contained in:
parent
6fb0a76b1e
commit
f94df06b66
@ -1 +1 @@
|
||||
Subproject commit 203c2fb68bbf871eaf4ca98756a113d74d620dea
|
||||
Subproject commit 27b9d111818af3b05bcf4153bb6e380fe1dd6816
|
@ -127,7 +127,7 @@ cClientHandle::~cClientHandle()
|
||||
if (!m_Username.empty() && (World != NULL))
|
||||
{
|
||||
// Send the Offline PlayerList packet:
|
||||
World->BroadcastPlayerListItem(*m_Player, false, this);
|
||||
World->BroadcastPlayerListItem(*m_Player, 4, this);
|
||||
}
|
||||
if (World != NULL)
|
||||
{
|
||||
@ -366,6 +366,10 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID,
|
||||
m_Player->Initialize(*World);
|
||||
m_State = csAuthenticated;
|
||||
|
||||
// Send player list items
|
||||
SendPlayerListItem(*m_Player, 0);
|
||||
World->SendPlayerList(m_Player);
|
||||
|
||||
// Query player team
|
||||
m_Player->UpdateTeam();
|
||||
|
||||
@ -2378,9 +2382,9 @@ void cClientHandle::SendPlayerAbilities()
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
|
||||
void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, char a_Action)
|
||||
{
|
||||
m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
|
||||
m_Protocol->SendPlayerListItem(a_Player, a_Action);
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
void SendEntityAnimation (const cEntity & a_Entity, char a_Animation); // tolua_export
|
||||
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);
|
||||
void SendPlayerAbilities (void);
|
||||
void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline);
|
||||
void SendPlayerListItem (const cPlayer & a_Player, char a_Action);
|
||||
void SendPlayerMaxSpeed (void); ///< Informs the client of the maximum player speed (1.6.1+)
|
||||
void SendPlayerMoveLook (void);
|
||||
void SendPlayerPosition (void);
|
||||
|
@ -135,7 +135,7 @@ const char * cEntity::GetParentClass(void) const
|
||||
|
||||
bool cEntity::Initialize(cWorld & a_World)
|
||||
{
|
||||
if (cPluginManager::Get()->CallHookSpawningEntity(a_World, *this))
|
||||
if (cPluginManager::Get()->CallHookSpawningEntity(a_World, *this) && !IsPlayer())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
cTimer t1;
|
||||
if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= t1.GetNowTime())
|
||||
{
|
||||
m_World->SendPlayerList(this);
|
||||
m_World->BroadcastPlayerListItem(*this, 2);
|
||||
m_LastPlayerListTime = t1.GetNowTime();
|
||||
}
|
||||
|
||||
@ -1172,6 +1172,8 @@ void cPlayer::SetGameMode(eGameMode a_GameMode)
|
||||
SetFlying(false);
|
||||
SetCanFly(false);
|
||||
}
|
||||
|
||||
m_World->BroadcastPlayerListItem(*this, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -2147,7 +2147,7 @@ void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, float a_Src
|
||||
|
||||
|
||||
|
||||
void cWorld::BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude)
|
||||
void cWorld::BroadcastPlayerListItem(const cPlayer & a_Player, char a_Action, const cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSPlayers);
|
||||
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
@ -2157,7 +2157,7 @@ void cWorld::BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ch->SendPlayerListItem(a_Player, a_IsOnline);
|
||||
ch->SendPlayerListItem(a_Player, a_Action);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2680,7 +2680,7 @@ void cWorld::SendPlayerList(cPlayer * a_DestPlayer)
|
||||
cClientHandle * ch = (*itr)->GetClientHandle();
|
||||
if ((ch != NULL) && !ch->IsDestroyed())
|
||||
{
|
||||
a_DestPlayer->GetClientHandle()->SendPlayerListItem(*(*itr), true);
|
||||
a_DestPlayer->GetClientHandle()->SendPlayerListItem(*(*itr), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ public:
|
||||
void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override; // tolua_export
|
||||
void BroadcastParticleEffect (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, cClientHandle * a_Exclude = NULL); // tolua_export
|
||||
void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastPlayerListItem (const cPlayer & a_Player, char a_Action, 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);
|
||||
|
Loading…
Reference in New Issue
Block a user