summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-04-22 13:34:32 +0200
committerMattes D <github@xoft.cz>2014-04-22 13:34:32 +0200
commit6492aa000b322877aecda32573cc55b57abfc5ed (patch)
treef9f0f9211b42aa72729f8d6d444e4f48556e5fb9 /src/Protocol
parentAdded prefab hitboxes. (diff)
parentreverted the revert of the minecart collision detection fix. (diff)
downloadcuberite-6492aa000b322877aecda32573cc55b57abfc5ed.tar
cuberite-6492aa000b322877aecda32573cc55b57abfc5ed.tar.gz
cuberite-6492aa000b322877aecda32573cc55b57abfc5ed.tar.bz2
cuberite-6492aa000b322877aecda32573cc55b57abfc5ed.tar.lz
cuberite-6492aa000b322877aecda32573cc55b57abfc5ed.tar.xz
cuberite-6492aa000b322877aecda32573cc55b57abfc5ed.tar.zst
cuberite-6492aa000b322877aecda32573cc55b57abfc5ed.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Authenticator.cpp7
-rw-r--r--src/Protocol/Protocol125.cpp32
-rw-r--r--src/Protocol/Protocol132.cpp18
-rw-r--r--src/Protocol/Protocol14x.cpp12
-rw-r--r--src/Protocol/Protocol16x.cpp17
-rw-r--r--src/Protocol/Protocol17x.cpp85
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp13
7 files changed, 104 insertions, 80 deletions
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index a30131b36..e0fcc0007 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -119,9 +119,10 @@ void cAuthenticator::Execute(void)
}
ASSERT(!m_Queue.empty());
- int ClientID = m_Queue.front().m_ClientID;
- AString UserName = m_Queue.front().m_Name;
- AString ServerID = m_Queue.front().m_ServerID;
+ cAuthenticator::cUser & User = m_Queue.front();
+ int ClientID = User.m_ClientID;
+ AString UserName = User.m_Name;
+ AString ServerID = User.m_ServerID;
m_Queue.pop_front();
Lock.Unlock();
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index 9b8db0b7b..3282a827f 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -538,9 +538,10 @@ void cProtocol125::SendHealth(void)
{
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_UPDATE_HEALTH);
- WriteShort((short)m_Client->GetPlayer()->GetHealth());
- WriteShort((short)m_Client->GetPlayer()->GetFoodLevel());
- WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
+ cPlayer * Player = m_Client->GetPlayer();
+ WriteShort((short)Player->GetHealth());
+ WriteShort((short)Player->GetFoodLevel());
+ WriteFloat((float)Player->GetFoodSaturationLevel());
Flush();
}
@@ -668,13 +669,14 @@ void cProtocol125::SendPickupSpawn(const cPickup & a_Pickup)
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_PICKUP_SPAWN);
WriteInt (a_Pickup.GetUniqueID());
- WriteShort (a_Pickup.GetItem().m_ItemType);
- WriteChar (a_Pickup.GetItem().m_ItemCount);
- WriteShort (a_Pickup.GetItem().m_ItemDamage);
+ const cItem & Item = a_Pickup.GetItem();
+ WriteShort (Item.m_ItemType);
+ WriteChar (Item.m_ItemCount);
+ WriteShort (Item.m_ItemDamage);
WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
- WriteByte ((char)(a_Pickup.GetSpeed().x * 8));
- WriteByte ((char)(a_Pickup.GetSpeed().y * 8));
- WriteByte ((char)(a_Pickup.GetSpeed().z * 8));
+ WriteByte ((char)(a_Pickup.GetSpeedX() * 8));
+ WriteByte ((char)(a_Pickup.GetSpeedY() * 8));
+ WriteByte ((char)(a_Pickup.GetSpeedZ() * 8));
Flush();
}
@@ -831,10 +833,11 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
void cProtocol125::SendRespawn(void)
{
cCSLock Lock(m_CSPacket);
+ cPlayer * Player = m_Client->GetPlayer();
WriteByte (PACKET_RESPAWN);
- WriteInt ((int)(m_Client->GetPlayer()->GetWorld()->GetDimension()));
+ WriteInt ((int)(Player->GetWorld()->GetDimension()));
WriteByte (2); // TODO: Difficulty; 2 = Normal
- WriteChar ((char)m_Client->GetPlayer()->GetGameMode());
+ WriteChar ((char)Player->GetGameMode());
WriteShort (256); // Current world height
WriteString("default");
}
@@ -846,10 +849,11 @@ void cProtocol125::SendRespawn(void)
void cProtocol125::SendExperience(void)
{
cCSLock Lock(m_CSPacket);
+ cPlayer * Player = m_Client->GetPlayer();
WriteByte (PACKET_EXPERIENCE);
- WriteFloat (m_Client->GetPlayer()->GetXpPercentage());
- WriteShort (m_Client->GetPlayer()->GetXpLevel());
- WriteShort (m_Client->GetPlayer()->GetCurrentXp());
+ WriteFloat (Player->GetXpPercentage());
+ WriteShort (Player->GetXpLevel());
+ WriteShort (Player->GetCurrentXp());
Flush();
}
diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp
index ce5942a5c..53d8c1561 100644
--- a/src/Protocol/Protocol132.cpp
+++ b/src/Protocol/Protocol132.cpp
@@ -408,7 +408,8 @@ void cProtocol132::SendWholeInventory(const cWindow & a_Window)
super::SendWholeInventory(a_Window);
// Send the player inventory and hotbar:
- const cInventory & Inventory = m_Client->GetPlayer()->GetInventory();
+ cPlayer * Player = m_Client->GetPlayer();
+ const cInventory & Inventory = Player->GetInventory();
int BaseOffset = a_Window.GetNumSlots() - (cInventory::invNumSlots - cInventory::invInventoryOffset); // Number of non-inventory slots
char WindowID = a_Window.GetWindowID();
for (short i = 0; i < cInventory::invInventoryCount; i++)
@@ -422,7 +423,7 @@ void cProtocol132::SendWholeInventory(const cWindow & a_Window)
} // for i - Hotbar[]
// Send even the item being dragged:
- SendInventorySlot(-1, -1, m_Client->GetPlayer()->GetDraggingItem());
+ SendInventorySlot(-1, -1, Player->GetDraggingItem());
}
@@ -800,10 +801,12 @@ void cProtocol132::SendCompass(const cWorld & a_World)
void cProtocol132::SendEncryptionKeyRequest(void)
{
cCSLock Lock(m_CSPacket);
+ cServer * Server = cRoot::Get()->GetServer();
WriteByte(0xfd);
- WriteString(cRoot::Get()->GetServer()->GetServerID());
- WriteShort((short)(cRoot::Get()->GetServer()->GetPublicKeyDER().size()));
- SendData(cRoot::Get()->GetServer()->GetPublicKeyDER().data(), cRoot::Get()->GetServer()->GetPublicKeyDER().size());
+ WriteString(Server->GetServerID());
+ const AString & PublicKeyDER = Server->GetPublicKeyDER();
+ WriteShort((short)(PublicKeyDER.size()));
+ SendData(PublicKeyDER.data(), PublicKeyDER.size());
WriteShort(4);
WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
Flush();
@@ -874,10 +877,11 @@ void cProtocol132::StartEncryption(const Byte * a_Key)
// Prepare the m_AuthServerID:
cSHA1Checksum Checksum;
- AString ServerID = cRoot::Get()->GetServer()->GetServerID();
+ cServer * Server = cRoot::Get()->GetServer();
+ AString ServerID = Server->GetServerID();
Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length());
Checksum.Update(a_Key, 16);
- Checksum.Update((const Byte *)cRoot::Get()->GetServer()->GetPublicKeyDER().data(), cRoot::Get()->GetServer()->GetPublicKeyDER().size());
+ Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size());
Byte Digest[20];
Checksum.Finalize(Digest);
cSHA1Checksum::DigestToJava(Digest, m_AuthServerID);
diff --git a/src/Protocol/Protocol14x.cpp b/src/Protocol/Protocol14x.cpp
index f694af1eb..f60e756fd 100644
--- a/src/Protocol/Protocol14x.cpp
+++ b/src/Protocol/Protocol14x.cpp
@@ -103,9 +103,9 @@ void cProtocol142::SendPickupSpawn(const cPickup & a_Pickup)
WriteInt (a_Pickup.GetUniqueID());
WriteItem (a_Pickup.GetItem());
WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
- WriteChar ((char)(a_Pickup.GetSpeed().x * 8));
- WriteChar ((char)(a_Pickup.GetSpeed().y * 8));
- WriteChar ((char)(a_Pickup.GetSpeed().z * 8));
+ WriteChar((char)(a_Pickup.GetSpeedX() * 8));
+ WriteChar((char)(a_Pickup.GetSpeedY() * 8));
+ WriteChar((char)(a_Pickup.GetSpeedZ() * 8));
Flush();
}
@@ -170,9 +170,9 @@ void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
WriteInt ((int)(a_Pickup.GetPosY() * 32));
WriteInt ((int)(a_Pickup.GetPosZ() * 32));
WriteInt (1);
- WriteShort((short)(a_Pickup.GetSpeed().x * 32));
- WriteShort((short)(a_Pickup.GetSpeed().y * 32));
- WriteShort((short)(a_Pickup.GetSpeed().z * 32));
+ WriteShort((short)(a_Pickup.GetSpeedX() * 32));
+ WriteShort((short)(a_Pickup.GetSpeedY() * 32));
+ WriteShort((short)(a_Pickup.GetSpeedZ() * 32));
WriteByte(0);
WriteByte(0);
diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp
index 8d79213af..714bf5e46 100644
--- a/src/Protocol/Protocol16x.cpp
+++ b/src/Protocol/Protocol16x.cpp
@@ -131,9 +131,10 @@ void cProtocol161::SendHealth(void)
{
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_UPDATE_HEALTH);
- WriteFloat((float)m_Client->GetPlayer()->GetHealth());
- WriteShort((short)m_Client->GetPlayer()->GetFoodLevel());
- WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
+ cPlayer * Player = m_Client->GetPlayer();
+ WriteFloat((float)Player->GetHealth());
+ WriteShort((short)Player->GetFoodLevel());
+ WriteFloat((float)Player->GetFoodSaturationLevel());
Flush();
}
@@ -144,11 +145,12 @@ void cProtocol161::SendHealth(void)
void cProtocol161::SendPlayerMaxSpeed(void)
{
cCSLock Lock(m_CSPacket);
+ cPlayer * Player = m_Client->GetPlayer();
WriteByte(PACKET_ENTITY_PROPERTIES);
- WriteInt(m_Client->GetPlayer()->GetUniqueID());
+ WriteInt(Player->GetUniqueID());
WriteInt(1);
WriteString("generic.movementSpeed");
- WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed());
+ WriteDouble(0.1 * Player->GetMaxSpeed());
Flush();
}
@@ -295,11 +297,12 @@ cProtocol162::cProtocol162(cClientHandle * a_Client) :
void cProtocol162::SendPlayerMaxSpeed(void)
{
cCSLock Lock(m_CSPacket);
+ cPlayer * Player = m_Client->GetPlayer();
WriteByte(PACKET_ENTITY_PROPERTIES);
- WriteInt(m_Client->GetPlayer()->GetUniqueID());
+ WriteInt(Player->GetUniqueID());
WriteInt(1);
WriteString("generic.movementSpeed");
- WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed());
+ WriteDouble(0.1 * Player->GetMaxSpeed());
WriteShort(0);
Flush();
}
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 36f770df7..e57b551cb 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -563,9 +563,10 @@ void cProtocol172::SendHealth(void)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x06); // Update Health packet
- Pkt.WriteFloat((float)m_Client->GetPlayer()->GetHealth());
- Pkt.WriteShort(m_Client->GetPlayer()->GetFoodLevel());
- Pkt.WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
+ cPlayer * Player = m_Client->GetPlayer();
+ Pkt.WriteFloat((float)Player->GetHealth());
+ Pkt.WriteShort(Player->GetFoodLevel());
+ Pkt.WriteFloat((float)Player->GetFoodSaturationLevel());
}
@@ -607,12 +608,13 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
{
// Send the Join Game packet:
{
+ cServer * Server = cRoot::Get()->GetServer();
cPacketizer Pkt(*this, 0x01); // Join Game packet
Pkt.WriteInt(a_Player.GetUniqueID());
- Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (cRoot::Get()->GetServer()->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
+ 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(cRoot::Get()->GetServer()->GetMaxPlayers(), 60));
+ Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60));
Pkt.WriteString("default"); // Level type - wtf?
}
@@ -758,22 +760,23 @@ void cProtocol172::SendPlayerAbilities(void)
cPacketizer Pkt(*this, 0x39); // Player Abilities packet
Byte Flags = 0;
- if (m_Client->GetPlayer()->IsGameModeCreative())
+ cPlayer * Player = m_Client->GetPlayer();
+ if (Player->IsGameModeCreative())
{
Flags |= 0x01;
Flags |= 0x08; // Godmode, used for creative
}
- if (m_Client->GetPlayer()->IsFlying())
+ if (Player->IsFlying())
{
Flags |= 0x02;
}
- if (m_Client->GetPlayer()->CanFly())
+ if (Player->CanFly())
{
Flags |= 0x04;
}
Pkt.WriteByte(Flags);
- Pkt.WriteFloat((float)(0.05 * m_Client->GetPlayer()->GetFlyingMaxSpeed()));
- Pkt.WriteFloat((float)(0.1 * m_Client->GetPlayer()->GetMaxSpeed()));
+ Pkt.WriteFloat((float)(0.05 * Player->GetFlyingMaxSpeed()));
+ Pkt.WriteFloat((float)(0.1 * Player->GetMaxSpeed()));
}
@@ -832,17 +835,18 @@ void cProtocol172::SendPlayerMaxSpeed(void)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x20); // Entity Properties
- Pkt.WriteInt(m_Client->GetPlayer()->GetUniqueID());
+ cPlayer * Player = m_Client->GetPlayer();
+ Pkt.WriteInt(Player->GetUniqueID());
Pkt.WriteInt(1); // Count
Pkt.WriteString("generic.movementSpeed");
// The default game speed is 0.1, multiply that value by the relative speed:
- Pkt.WriteDouble(0.1 * m_Client->GetPlayer()->GetNormalMaxSpeed());
- if (m_Client->GetPlayer()->IsSprinting())
+ Pkt.WriteDouble(0.1 * Player->GetNormalMaxSpeed());
+ if (Player->IsSprinting())
{
Pkt.WriteShort(1); // Modifier count
Pkt.WriteInt64(0x662a6b8dda3e4c1c);
Pkt.WriteInt64(0x881396ea6097278d); // UUID of the modifier
- Pkt.WriteDouble(m_Client->GetPlayer()->GetSprintingMaxSpeed() - m_Client->GetPlayer()->GetNormalMaxSpeed());
+ Pkt.WriteDouble(Player->GetSprintingMaxSpeed() - Player->GetNormalMaxSpeed());
Pkt.WriteByte(2);
}
else
@@ -860,16 +864,17 @@ void cProtocol172::SendPlayerMoveLook(void)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x08); // Player Position And Look packet
- Pkt.WriteDouble(m_Client->GetPlayer()->GetPosX());
+ cPlayer * Player = m_Client->GetPlayer();
+ Pkt.WriteDouble(Player->GetPosX());
// Protocol docs say this is PosY, but #323 says this is eye-pos
// Moreover, the "+ 0.001" is there because otherwise the player falls through the block they were standing on.
- Pkt.WriteDouble(m_Client->GetPlayer()->GetStance() + 0.001);
+ Pkt.WriteDouble(Player->GetStance() + 0.001);
- Pkt.WriteDouble(m_Client->GetPlayer()->GetPosZ());
- Pkt.WriteFloat((float)m_Client->GetPlayer()->GetYaw());
- Pkt.WriteFloat((float)m_Client->GetPlayer()->GetPitch());
- Pkt.WriteBool(m_Client->GetPlayer()->IsOnGround());
+ Pkt.WriteDouble(Player->GetPosZ());
+ Pkt.WriteFloat((float)Player->GetYaw());
+ Pkt.WriteFloat((float)Player->GetPitch());
+ Pkt.WriteBool(Player->IsOnGround());
}
@@ -941,9 +946,10 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
void cProtocol172::SendRespawn(void)
{
cPacketizer Pkt(*this, 0x07); // Respawn packet
- Pkt.WriteInt(m_Client->GetPlayer()->GetWorld()->GetDimension());
+ cPlayer * Player = m_Client->GetPlayer();
+ Pkt.WriteInt(Player->GetWorld()->GetDimension());
Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteByte((Byte)m_Client->GetPlayer()->GetEffectiveGameMode());
+ Pkt.WriteByte((Byte)Player->GetEffectiveGameMode());
Pkt.WriteString("default");
}
@@ -956,9 +962,10 @@ void cProtocol172::SendExperience (void)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x1f); // Experience Packet
- Pkt.WriteFloat(m_Client->GetPlayer()->GetXpPercentage());
- Pkt.WriteShort(m_Client->GetPlayer()->GetXpLevel());
- Pkt.WriteShort(m_Client->GetPlayer()->GetCurrentXp());
+ cPlayer * Player = m_Client->GetPlayer();
+ Pkt.WriteFloat(Player->GetXpPercentage());
+ Pkt.WriteShort(Player->GetXpLevel());
+ Pkt.WriteShort(Player->GetCurrentXp());
}
@@ -1635,15 +1642,16 @@ void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
{
// Send the response:
AString Response = "{\"version\":{\"name\":\"1.7.2\",\"protocol\":4},\"players\":{";
+ cServer * Server = cRoot::Get()->GetServer();
AppendPrintf(Response, "\"max\":%u,\"online\":%u,\"sample\":[]},",
- cRoot::Get()->GetServer()->GetMaxPlayers(),
- cRoot::Get()->GetServer()->GetNumPlayers()
+ Server->GetMaxPlayers(),
+ Server->GetNumPlayers()
);
AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},",
- cRoot::Get()->GetServer()->GetDescription().c_str()
+ Server->GetDescription().c_str()
);
AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"",
- cRoot::Get()->GetServer()->GetFaviconData().c_str()
+ Server->GetFaviconData().c_str()
);
Response.append("}");
@@ -1723,12 +1731,13 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
return;
}
+ cServer * Server = cRoot::Get()->GetServer();
// If auth is required, then send the encryption request:
- if (cRoot::Get()->GetServer()->ShouldAuthenticate())
+ if (Server->ShouldAuthenticate())
{
cPacketizer Pkt(*this, 0x01);
- Pkt.WriteString(cRoot::Get()->GetServer()->GetServerID());
- const AString & PubKeyDer = cRoot::Get()->GetServer()->GetPublicKeyDER();
+ Pkt.WriteString(Server->GetServerID());
+ const AString & PubKeyDer = Server->GetPublicKeyDER();
Pkt.WriteShort(PubKeyDer.size());
Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size());
Pkt.WriteShort(4);
@@ -2281,10 +2290,11 @@ void cProtocol172::StartEncryption(const Byte * a_Key)
// Prepare the m_AuthServerID:
cSHA1Checksum Checksum;
- const AString & ServerID = cRoot::Get()->GetServer()->GetServerID();
+ cServer * Server = cRoot::Get()->GetServer();
+ const AString & ServerID = Server->GetServerID();
Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length());
Checksum.Update(a_Key, 16);
- Checksum.Update((const Byte *)cRoot::Get()->GetServer()->GetPublicKeyDER().data(), cRoot::Get()->GetServer()->GetPublicKeyDER().size());
+ Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size());
Byte Digest[20];
Checksum.Finalize(Digest);
cSHA1Checksum::DigestToJava(Digest, m_AuthServerID);
@@ -2626,11 +2636,12 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity)
if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpNone)
{
cRideableMinecart & RideableMinecart = ((cRideableMinecart &)a_Entity);
- if (!RideableMinecart.GetContent().IsEmpty())
+ const cItem & MinecartContent = RideableMinecart.GetContent();
+ if (!MinecartContent.IsEmpty())
{
WriteByte(0x54);
- int Content = RideableMinecart.GetContent().m_ItemType;
- Content |= RideableMinecart.GetContent().m_ItemDamage << 8;
+ int Content = MinecartContent.m_ItemType;
+ Content |= MinecartContent.m_ItemDamage << 8;
WriteInt(Content);
WriteByte(0x55);
WriteInt(RideableMinecart.GetBlockHeight());
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 8a97b9713..2ccb9f197 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -1003,6 +1003,7 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema
void cProtocolRecognizer::SendLengthlessServerPing(void)
{
AString Reply;
+ cServer * Server = cRoot::Get()->GetServer();
switch (cRoot::Get()->GetPrimaryServerVersion())
{
case PROTO_VERSION_1_2_5:
@@ -1010,11 +1011,11 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
{
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29
Printf(Reply, "%s%s%i%s%i",
- cRoot::Get()->GetServer()->GetDescription().c_str(),
+ Server->GetDescription().c_str(),
cChatColor::Delimiter.c_str(),
- cRoot::Get()->GetServer()->GetNumPlayers(),
+ Server->GetNumPlayers(),
cChatColor::Delimiter.c_str(),
- cRoot::Get()->GetServer()->GetMaxPlayers()
+ Server->GetMaxPlayers()
);
break;
}
@@ -1044,9 +1045,9 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
// http://wiki.vg/wiki/index.php?title=Server_List_Ping&oldid=3100
AString NumPlayers;
- Printf(NumPlayers, "%d", cRoot::Get()->GetServer()->GetNumPlayers());
+ Printf(NumPlayers, "%d", Server->GetNumPlayers());
AString MaxPlayers;
- Printf(MaxPlayers, "%d", cRoot::Get()->GetServer()->GetMaxPlayers());
+ Printf(MaxPlayers, "%d", Server->GetMaxPlayers());
AString ProtocolVersionNum;
Printf(ProtocolVersionNum, "%d", cRoot::Get()->GetPrimaryServerVersion());
@@ -1060,7 +1061,7 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
Reply.push_back(0);
Reply.append(ProtocolVersionTxt);
Reply.push_back(0);
- Reply.append(cRoot::Get()->GetServer()->GetDescription());
+ Reply.append(Server->GetDescription());
Reply.push_back(0);
Reply.append(NumPlayers);
Reply.push_back(0);