summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol.h4
-rw-r--r--src/Protocol/Protocol17x.cpp79
-rw-r--r--src/Protocol/Protocol17x.h4
-rw-r--r--src/Protocol/Protocol18x.cpp122
-rw-r--r--src/Protocol/Protocol18x.h4
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp24
-rw-r--r--src/Protocol/ProtocolRecognizer.h4
7 files changed, 104 insertions, 137 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 1a19249bf..9e80f7bd5 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -99,9 +99,7 @@ public:
virtual void SendKeepAlive (int a_PingID) = 0;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) = 0;
virtual void SendLoginSuccess (void) = 0;
- virtual void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) = 0;
- virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) = 0;
- virtual void SendMapInfo (int a_ID, unsigned int a_Scale) = 0;
+ virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) = 0;
virtual void SendPaintingSpawn (const cPainting & a_Painting) = 0;
virtual void SendPickupSpawn (const cPickup & a_Pickup) = 0;
virtual void SendPlayerAbilities (void) = 0;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index c5c0f4a03..dc602ec6c 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -723,64 +723,55 @@ void cProtocol172::SendPaintingSpawn(const cPainting & a_Painting)
-void cProtocol172::SendMapColumn(int a_MapID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale)
+void cProtocol172::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
{
ASSERT(m_State == 3); // In game mode?
- ASSERT(a_Length + 3 <= USHRT_MAX);
- ASSERT((a_X >= 0) && (a_X < 256));
- ASSERT((a_Y >= 0) && (a_Y < 256));
-
- cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
- Pkt.WriteBEUInt16(static_cast<UInt16>(3 + a_Length));
- Pkt.WriteBEUInt8(0);
- Pkt.WriteBEUInt8(static_cast<Byte>(a_X));
- Pkt.WriteBEUInt8(static_cast<Byte>(a_Y));
-
- Pkt.WriteBuf(reinterpret_cast<const char *>(a_Colors), a_Length);
-}
+ {
+ ASSERT(a_Map.GetScale() < 256);
+ cPacketizer Pkt(*this, 0x34);
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetID()));
+ Pkt.WriteBEUInt16(2);
+ Pkt.WriteBEUInt8(2);
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Map.GetScale()));
+ }
+ {
+ ASSERT(a_Map.GetData().size() + 3 <= USHRT_MAX);
+ ASSERT((a_DataStartX >= 0) && (a_DataStartX < 256));
+ ASSERT((a_DataStartY >= 0) && (a_DataStartY < 256));
+ cPacketizer Pkt(*this, 0x34);
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetID()));
+ Pkt.WriteBEUInt16(static_cast<UInt16>(3 + a_Map.GetData().size()));
-void cProtocol172::SendMapDecorators(int a_MapID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale)
-{
- ASSERT(m_State == 3); // In game mode?
- ASSERT(1 + 3 * a_Decorators.size() < USHRT_MAX);
-
- cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
- Pkt.WriteBEUInt16(static_cast<UInt16>(1 + (3 * a_Decorators.size())));
+ Pkt.WriteBEUInt8(0);
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_DataStartX));
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_DataStartX));
- Pkt.WriteBEUInt8(1);
-
- for (cMapDecoratorList::const_iterator it = a_Decorators.begin(); it != a_Decorators.end(); ++it)
- {
- ASSERT(it->GetPixelX() < 256);
- ASSERT(it->GetPixelZ() < 256);
- Pkt.WriteBEUInt8(static_cast<Byte>((it->GetType() << 4) | static_cast<Byte>(it->GetRot() & 0xf)));
- Pkt.WriteBEUInt8(static_cast<Byte>(it->GetPixelX()));
- Pkt.WriteBEUInt8(static_cast<Byte>(it->GetPixelZ()));
+ Pkt.WriteBuf(reinterpret_cast<const char *>(a_Map.GetData().data()), a_Map.GetData().size());
}
-}
-
+ {
+ ASSERT(1 + 3 * a_Map.GetDecorators().size() < USHRT_MAX);
+ cPacketizer Pkt(*this, 0x34);
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetID()));
+ Pkt.WriteBEUInt16(static_cast<UInt16>(1 + (3 * a_Map.GetDecorators().size())));
+ Pkt.WriteBEUInt8(1);
-void cProtocol172::SendMapInfo(int a_MapID, unsigned int a_Scale)
-{
- ASSERT(m_State == 3); // In game mode?
- ASSERT(a_Scale < 256);
-
- cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
- Pkt.WriteBEUInt16(2);
-
- Pkt.WriteBEUInt8(2);
- Pkt.WriteBEUInt8(static_cast<Byte>(a_Scale));
+ for (const auto & Decorator : a_Map.GetDecorators())
+ {
+ ASSERT(Decorator.GetPixelX() < 256);
+ ASSERT(Decorator.GetPixelZ() < 256);
+ Pkt.WriteBEUInt8(static_cast<Byte>((Decorator.GetRot() << 4) | static_cast<int>(Decorator.GetType())));
+ Pkt.WriteBEUInt8(static_cast<Byte>(Decorator.GetPixelX()));
+ Pkt.WriteBEUInt8(static_cast<Byte>(Decorator.GetPixelZ()));
+ }
+ }
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index b07fa9ed9..c5625dd62 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -101,9 +101,7 @@ public:
virtual void SendKeepAlive (int a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
- virtual void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) override;
- virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) override;
- virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override;
+ virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) 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_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index 99bba63e3..db510825e 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -715,60 +715,31 @@ void cProtocol180::SendPaintingSpawn(const cPainting & a_Painting)
-void cProtocol180::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale)
+void cProtocol180::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt32(a_ID);
- Pkt.WriteBEUInt8(m_Scale);
+ Pkt.WriteVarInt32(a_Map.GetID());
+ Pkt.WriteBEUInt8(a_Map.GetScale());
- Pkt.WriteVarInt32(0);
- Pkt.WriteBEUInt8(1);
- Pkt.WriteBEUInt8(a_Length);
- Pkt.WriteBEUInt8(a_X);
- Pkt.WriteBEUInt8(a_Y);
-
- Pkt.WriteVarInt32(a_Length);
- for (unsigned int i = 0; i < a_Length; ++i)
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetDecorators().size()));
+ for (const auto Decorator : a_Map.GetDecorators())
{
- Pkt.WriteBEUInt8(a_Colors[i]);
+ Pkt.WriteBEUInt8(static_cast<Byte>((static_cast<int>(Decorator.GetType()) << 4) | (Decorator.GetRot() & 0xF)));
+ Pkt.WriteBEUInt8(Decorator.GetPixelX());
+ Pkt.WriteBEUInt8(Decorator.GetPixelZ());
}
-}
-
-
-
-
-
-void cProtocol180::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt32(a_ID);
- Pkt.WriteBEUInt8(m_Scale);
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Decorators.size()));
- for (cMapDecoratorList::const_iterator it = a_Decorators.begin(); it != a_Decorators.end(); ++it)
+ Pkt.WriteBEUInt8(128);
+ Pkt.WriteBEUInt8(128);
+ Pkt.WriteBEUInt8(a_DataStartX);
+ Pkt.WriteBEUInt8(a_DataStartY);
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetData().size()));
+ for (auto itr = a_Map.GetData().cbegin(); itr != a_Map.GetData().cend(); ++itr)
{
- Pkt.WriteBEUInt8((it->GetType() << 4) | (it->GetRot() & 0xf));
- Pkt.WriteBEUInt8(it->GetPixelX());
- Pkt.WriteBEUInt8(it->GetPixelZ());
+ Pkt.WriteBEUInt8(*itr);
}
-
- Pkt.WriteBEUInt8(0);
-}
-
-
-
-
-
-void cProtocol180::SendMapInfo(int a_ID, unsigned int a_Scale)
-{
- UNUSED(a_ID);
- UNUSED(a_Scale);
-
- // This packet was removed in 1.8
}
@@ -3341,7 +3312,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Bat.IsHanging() ? 1 : 0);
break;
} // case mtBat
-
+
case mtCreeper:
{
auto & Creeper = reinterpret_cast<const cCreeper &>(a_Mob);
@@ -3351,7 +3322,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Creeper.IsCharged() ? 1 : 0);
break;
} // case mtCreeper
-
+
case mtEnderman:
{
auto & Enderman = reinterpret_cast<const cEnderman &>(a_Mob);
@@ -3363,7 +3334,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Enderman.IsScreaming() ? 1 : 0);
break;
} // case mtEnderman
-
+
case mtGhast:
{
auto & Ghast = reinterpret_cast<const cGhast &>(a_Mob);
@@ -3371,7 +3342,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Ghast.IsCharging());
break;
} // case mtGhast
-
+
case mtHorse:
{
auto & Horse = reinterpret_cast<const cHorse &>(a_Mob);
@@ -3388,10 +3359,6 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
Flags |= 0x08;
}
- if (Horse.IsBaby())
- {
- Flags |= 0x10;
- }
if (Horse.IsEating())
{
Flags |= 0x20;
@@ -3415,6 +3382,9 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEInt32(Appearance);
a_Pkt.WriteBEUInt8(0x56); // Int at index 22
a_Pkt.WriteBEInt32(Horse.GetHorseArmour());
+
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Horse.GetAge());
break;
} // case mtHorse
@@ -3426,17 +3396,38 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
break;
} // case mtMagmaCube
+ case mtOcelot:
+ {
+ auto & Ocelot = reinterpret_cast<const cOcelot &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Ocelot.GetAge());
+ break;
+ } // case mtOcelot
+
case mtPig:
{
auto & Pig = reinterpret_cast<const cPig &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Pig.GetAge());
a_Pkt.WriteBEUInt8(0x10);
a_Pkt.WriteBEUInt8(Pig.IsSaddled() ? 1 : 0);
break;
} // case mtPig
-
+
+ case mtRabbit:
+ {
+ auto & Rabbit = reinterpret_cast<const cRabbit &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Rabbit.GetAge());
+ break;
+ } // case mtRabbit
+
case mtSheep:
{
auto & Sheep = reinterpret_cast<const cSheep &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Sheep.GetAge());
+
a_Pkt.WriteBEUInt8(0x10);
Byte SheepMetadata = 0;
SheepMetadata = Sheep.GetFurColor();
@@ -3447,7 +3438,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(SheepMetadata);
break;
} // case mtSheep
-
+
case mtSkeleton:
{
auto & Skeleton = reinterpret_cast<const cSkeleton &>(a_Mob);
@@ -3455,7 +3446,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Skeleton.IsWither() ? 1 : 0);
break;
} // case mtSkeleton
-
+
case mtSlime:
{
auto & Slime = reinterpret_cast<const cSlime &>(a_Mob);
@@ -3469,9 +3460,11 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
auto & Villager = reinterpret_cast<const cVillager &>(a_Mob);
a_Pkt.WriteBEUInt8(0x50);
a_Pkt.WriteBEInt32(Villager.GetVilType());
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Villager.GetAge());
break;
} // case mtVillager
-
+
case mtWitch:
{
auto & Witch = reinterpret_cast<const cWitch &>(a_Mob);
@@ -3489,7 +3482,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
break;
} // case mtWither
-
+
case mtWolf:
{
auto & Wolf = reinterpret_cast<const cWolf &>(a_Mob);
@@ -3515,20 +3508,31 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Wolf.IsBegging() ? 1 : 0);
a_Pkt.WriteBEUInt8(0x14);
a_Pkt.WriteBEUInt8(Wolf.GetCollarColor());
+
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Wolf.GetAge());
break;
} // case mtWolf
-
+
case mtZombie:
{
auto & Zombie = reinterpret_cast<const cZombie &>(a_Mob);
a_Pkt.WriteBEUInt8(0x0c);
- a_Pkt.WriteBEUInt8(Zombie.IsBaby() ? 1 : 0);
+ a_Pkt.WriteBEInt8(Zombie.IsBaby() ? 1 : -1);
a_Pkt.WriteBEUInt8(0x0d);
a_Pkt.WriteBEUInt8(Zombie.IsVillagerZombie() ? 1 : 0);
a_Pkt.WriteBEUInt8(0x0e);
a_Pkt.WriteBEUInt8(Zombie.IsConverting() ? 1 : 0);
break;
} // case mtZombie
+
+ case mtZombiePigman:
+ {
+ auto & ZombiePigman = reinterpret_cast<const cZombiePigman &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(ZombiePigman.IsBaby() ? 1 : -1);
+ break;
+ } // case mtZombiePigman
} // switch (a_Mob.GetType())
}
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index 36ed251fe..99774d242 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -96,9 +96,7 @@ public:
virtual void SendKeepAlive (int a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
- virtual void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) override;
- virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) override;
- virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override;
+ virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAbilities (void) override;
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index c89c745a4..574875831 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -470,30 +470,10 @@ void cProtocolRecognizer::SendLoginSuccess(void)
-void cProtocolRecognizer::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale)
+void cProtocolRecognizer::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
{
ASSERT(m_Protocol != nullptr);
- m_Protocol->SendMapColumn(a_ID, a_X, a_Y, a_Colors, a_Length, m_Scale);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale)
-{
- ASSERT(m_Protocol != nullptr);
- m_Protocol->SendMapDecorators(a_ID, a_Decorators, m_Scale);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendMapInfo(int a_ID, unsigned int a_Scale)
-{
- ASSERT(m_Protocol != nullptr);
- m_Protocol->SendMapInfo(a_ID, a_Scale);
+ m_Protocol->SendMapData(a_Map, a_DataStartX, a_DataStartY);
}
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 29eddcbc9..491645cff 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -84,9 +84,7 @@ public:
virtual void SendKeepAlive (int a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
- virtual void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) override;
- virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) override;
- virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override;
+ virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) 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_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;