From 1bb4d7941267ee55cdf7f35fa6a0055521115960 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 2 Sep 2014 19:12:35 +0200 Subject: Added SetCustomName() to players. --- src/Protocol/Protocol125.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index a66c64309..0b5e3de91 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -719,21 +719,13 @@ void cProtocol125::SendPaintingSpawn(const cPainting & a_Painting) -void cProtocol125::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline) +void cProtocol125::SendPlayerListItem(const AString & a_PlayerName, bool a_IsOnline, short a_Ping) { cCSLock Lock(m_CSPacket); - AString PlayerName(a_Player.GetColor()); - PlayerName.append(a_Player.GetName()); - if (PlayerName.length() > 14) - { - PlayerName.erase(14); - } - PlayerName += cChatColor::White; - WriteByte ((unsigned char)PACKET_PLAYER_LIST_ITEM); - WriteString(PlayerName); + WriteString(a_PlayerName); WriteBool (a_IsOnline); - WriteShort (a_IsOnline ? a_Player.GetClientHandle()->GetPing() : 0); + WriteShort (a_Ping); Flush(); } @@ -792,7 +784,14 @@ void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player) cCSLock Lock(m_CSPacket); WriteByte (PACKET_PLAYER_SPAWN); WriteInt (a_Player.GetUniqueID()); - WriteString(a_Player.GetName()); + if (a_Player.HasCustomName()) + { + WriteString(a_Player.GetCustomName()); + } + else + { + WriteString(a_Player.GetName()); + } WriteInt ((int)(a_Player.GetPosX() * 32)); WriteInt ((int)(a_Player.GetPosY() * 32)); WriteInt ((int)(a_Player.GetPosZ() * 32)); -- cgit v1.2.3 From 09ff17b71ea5659dc628d9d6e3f1fd308d10037a Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 8 Sep 2014 00:36:30 +0200 Subject: Implemented packet compression. ChunkData packet needs this. --- src/Protocol/Protocol125.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index a66c64309..a74be28a5 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -262,7 +262,7 @@ void cProtocol125::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize SendPreChunk(a_ChunkX, a_ChunkZ, true); // Send the chunk data: - AString Serialized = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_2_5); + AString Serialized = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_2_5, a_ChunkX, a_ChunkZ); WriteByte(PACKET_MAP_CHUNK); WriteInt (a_ChunkX); WriteInt (a_ChunkZ); -- cgit v1.2.3 From 10a30a03e38116fe084138662bd59147331dd883 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 8 Sep 2014 11:35:21 +0200 Subject: Added GetProtocolVersion() to cProtocol. --- src/Protocol/Protocol125.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index a74be28a5..77939d933 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -16,6 +16,7 @@ Documentation: #include "../ClientHandle.h" #include "../World.h" #include "ChunkDataSerializer.h" +#include "ProtocolRecognizer.h" #include "../Entities/Entity.h" #include "../Entities/ExpOrb.h" #include "../Mobs/Monster.h" @@ -132,7 +133,7 @@ typedef unsigned char Byte; cProtocol125::cProtocol125(cClientHandle * a_Client) : - super(a_Client), + super(a_Client, cProtocolRecognizer::PROTO_VERSION_1_2_5), m_ReceivedData(32 KiB), m_LastSentDimension(dimNotSet) { -- cgit v1.2.3 From f94df06b6601f9dcecd383f5d093d225f41d1c65 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 9 Sep 2014 03:02:25 +0200 Subject: Added the player list to the 1.8 protocol. --- src/Protocol/Protocol125.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/Protocol/Protocol125.cpp') 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(); } -- cgit v1.2.3 From 3bd3ac2200392542b111d2bcd2951bd342edf721 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 11 Sep 2014 17:03:09 +0200 Subject: 1.8: Added ParticleEffect packet. --- src/Protocol/Protocol125.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 8c4534ff7..1d6049097 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -701,7 +701,7 @@ void cProtocol125::SendEntityAnimation(const cEntity & a_Entity, char a_Animatio -void cProtocol125::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 cProtocol125::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_ParticleAmount) { // Not supported by this protocol version } -- cgit v1.2.3 From 6d5a5eb665d8f13dd3e4e7c279967556b0f9fa91 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 11 Sep 2014 22:27:35 +0200 Subject: Removed GetProtocolVersion() from the protocols. --- src/Protocol/Protocol125.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 1d6049097..0c481024e 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -16,7 +16,6 @@ Documentation: #include "../ClientHandle.h" #include "../World.h" #include "ChunkDataSerializer.h" -#include "ProtocolRecognizer.h" #include "../Entities/Entity.h" #include "../Entities/ExpOrb.h" #include "../Mobs/Monster.h" @@ -133,7 +132,7 @@ typedef unsigned char Byte; cProtocol125::cProtocol125(cClientHandle * a_Client) : - super(a_Client, cProtocolRecognizer::PROTO_VERSION_1_2_5), + super(a_Client), m_ReceivedData(32 KiB), m_LastSentDimension(dimNotSet) { -- cgit v1.2.3 From b462416e1fef58b3ddccc92f3dfe613fc27d5483 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 13 Sep 2014 02:20:04 +0200 Subject: 1.8: Fixed maps. --- src/Protocol/Protocol125.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 0c481024e..c785553a5 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -608,7 +608,7 @@ void cProtocol125::SendLoginSuccess(void) -void cProtocol125::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length) +void cProtocol125::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) { cCSLock Lock(m_CSPacket); @@ -630,7 +630,7 @@ void cProtocol125::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colo -void cProtocol125::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators) +void cProtocol125::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) { cCSLock Lock(m_CSPacket); -- cgit v1.2.3 From 6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 17 Sep 2014 18:40:10 +0100 Subject: Added first test to show the object can be created --- src/Protocol/Protocol125.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index a66c64309..4a69bc1ac 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -1946,7 +1946,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) { switch (a_Mob.GetMobType()) { - case cMonster::mtCreeper: + case mtCreeper: { WriteByte(0x10); WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up? @@ -1954,25 +1954,25 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged? break; } - case cMonster::mtBat: + case mtBat: { WriteByte(0x10); WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down? break; } - case cMonster::mtPig: + case mtPig: { WriteByte(0x10); WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled? break; } - case cMonster::mtVillager: + case mtVillager: { WriteByte(0x50); WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE? break; } - case cMonster::mtZombie: + case mtZombie: { WriteByte(0xC); WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Baby zombie? @@ -1982,13 +1982,13 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager? break; } - case cMonster::mtGhast: + case mtGhast: { WriteByte(0x10); WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to spit a flameball? break; } - case cMonster::mtWolf: + case mtWolf: { Byte WolfStatus = 0; if (((const cWolf &)a_Mob).IsSitting()) @@ -2012,7 +2012,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode? break; } - case cMonster::mtSheep: + case mtSheep: { // [1](1111) // [] = Is sheared? () = Color, from 0 to 15 @@ -2028,7 +2028,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(SheepMetadata); break; } - case cMonster::mtEnderman: + case mtEnderman: { WriteByte(0x10); WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house @@ -2038,19 +2038,19 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face? break; } - case cMonster::mtSkeleton: + case mtSkeleton: { WriteByte(0xD); WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not break; } - case cMonster::mtWitch: + case mtWitch: { WriteByte(0x15); WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything break; } - case cMonster::mtWither: + case mtWither: { WriteByte(0x54); // Int at index 20 WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks()); @@ -2058,11 +2058,11 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteFloat((float)(a_Mob.GetHealth())); break; } - case cMonster::mtSlime: - case cMonster::mtMagmaCube: + case mtSlime: + case mtMagmaCube: { WriteByte(0x10); - if (a_Mob.GetMobType() == cMonster::mtSlime) + if (a_Mob.GetMobType() == mtSlime) { WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME } @@ -2072,7 +2072,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) } break; } - case cMonster::mtHorse: + case mtHorse: { int Flags = 0; if (((const cHorse &)a_Mob).IsTame()) -- cgit v1.2.3 From 43ed690520d3c3b47ed7ff6f48f868e8011565e0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 18 Sep 2014 18:50:17 +0200 Subject: Exported player list states to extra functions. --- src/Protocol/Protocol125.cpp | 71 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 13 deletions(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index c785553a5..4378ef466 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -719,28 +719,73 @@ void cProtocol125::SendPaintingSpawn(const cPainting & a_Painting) -void cProtocol125::SendPlayerListItem(const cPlayer & a_Player, char a_Action) +void cProtocol125::SendPlayerListAddPlayer(const cPlayer & a_Player) { cCSLock Lock(m_CSPacket); - if (a_Action == 1) + WriteByte (PACKET_PLAYER_LIST_ITEM); + WriteString(a_Player.GetName()); + WriteBool (true); + WriteShort (a_Player.GetClientHandle()->GetPing()); + Flush(); +} + + + + + +void cProtocol125::SendPlayerListRemovePlayer(const cPlayer & a_Player) +{ + cCSLock Lock(m_CSPacket); + WriteByte (PACKET_PLAYER_LIST_ITEM); + WriteString(a_Player.GetName()); + WriteBool (false); + WriteShort (0); + Flush(); +} + + + + + +void cProtocol125::SendPlayerListUpdateGameMode(const cPlayer & a_Player) +{ + // Not implemented in this protocol version + UNUSED(a_Player); +} + + + + + +void cProtocol125::SendPlayerListUpdatePing(const cPlayer & a_Player) +{ + // It is a simple add player packet in this protocol. + SendPlayerListAddPlayer(a_Player); +} + + + + + +void cProtocol125::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) +{ + if (a_OldListName == a_Player.GetName()) { - // Ignore gamemode update return; } - AString PlayerName(a_Player.GetColor()); - PlayerName.append(a_Player.GetName()); - if (PlayerName.length() > 14) + cCSLock Lock(m_CSPacket); + + // Remove the old name from the tablist: { - PlayerName.erase(14); + WriteByte (PACKET_PLAYER_LIST_ITEM); + WriteString(a_OldListName); + WriteBool (false); + WriteShort (0); + Flush(); } - PlayerName += cChatColor::White; - WriteByte ((unsigned char)PACKET_PLAYER_LIST_ITEM); - WriteString(PlayerName); - WriteBool (a_Action != 4); - WriteShort ((a_Action == 4) ? 0 : a_Player.GetClientHandle()->GetPing()); - Flush(); + SendPlayerListAddPlayer(a_Player); } -- cgit v1.2.3 From d83d6456e8aedf84dcda89eb29d20d8ba834748e Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 26 Sep 2014 17:37:19 +0200 Subject: Fixed players custom name in 1.8 --- src/Protocol/Protocol125.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/Protocol/Protocol125.cpp') diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index ba4cfa7ef..8a5f26c8b 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); } -- cgit v1.2.3