1
0

Merge branch 'master' into cmake

This commit is contained in:
Tycho Bickerstaff
2013-12-18 19:06:11 +00:00
53 changed files with 1357 additions and 312 deletions

View File

@@ -62,6 +62,7 @@ public:
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
virtual void SendDisconnect (const AString & a_Reason) = 0;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) = 0;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
virtual void SendEntityHeadLook (const cEntity & a_Entity) = 0;
virtual void SendEntityLook (const cEntity & a_Entity) = 0;
@@ -85,6 +86,7 @@ public:
virtual void SendPlayerMoveLook (void) = 0;
virtual void SendPlayerPosition (void) = 0;
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0;
virtual void SendRespawn (void) = 0;
virtual void SendExperience (void) = 0;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0;

View File

@@ -73,7 +73,9 @@ enum
PACKET_ENT_STATUS = 0x26,
PACKET_ATTACH_ENTITY = 0x27,
PACKET_METADATA = 0x28,
PACKET_ENTITY_EFFECT = 0x29,
PACKET_SPAWN_EXPERIENCE_ORB = 0x1A,
PACKET_REMOVE_ENTITY_EFFECT = 0x2a,
PACKET_EXPERIENCE = 0x2b,
PACKET_PRE_CHUNK = 0x32,
PACKET_MAP_CHUNK = 0x33,
@@ -300,6 +302,21 @@ void cProtocol125::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
void cProtocol125::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration)
{
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_ENTITY_EFFECT);
WriteInt (a_Entity.GetUniqueID());
WriteByte (a_EffectID);
WriteByte (a_Amplifier);
WriteShort(a_Duration);
Flush();
}
void cProtocol125::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
cCSLock Lock(m_CSPacket);
@@ -678,6 +695,19 @@ void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player)
void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_REMOVE_ENTITY_EFFECT);
WriteInt (a_Entity.GetUniqueID());
WriteByte (a_EffectID);
Flush();
}
void cProtocol125::SendRespawn(void)
{
cCSLock Lock(m_CSPacket);

View File

@@ -38,6 +38,7 @@ public:
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
virtual void SendEntityLook (const cEntity & a_Entity) override;
@@ -61,6 +62,7 @@ public:
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
virtual void SendRespawn (void) override;
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;

View File

@@ -236,6 +236,19 @@ void cProtocol172::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
void cProtocol172::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration)
{
cPacketizer Pkt(*this, 0x1D); // Entity Effect packet
Pkt.WriteInt(a_Entity.GetUniqueID());
Pkt.WriteByte(a_EffectID);
Pkt.WriteByte(a_Amplifier);
Pkt.WriteShort(a_Duration);
}
void cProtocol172::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
cPacketizer Pkt(*this, 0x04); // Entity Equipment packet
@@ -478,7 +491,15 @@ void cProtocol172::SendPlayerAbilities(void)
{
Flags |= 0x01;
}
// TODO: Other flags (god mode, flying, can fly
if (m_Client->GetPlayer()->IsFlying())
{
Flags |= 0x02;
}
if (m_Client->GetPlayer()->CanFly())
{
Flags |= 0x04;
}
// TODO: Other flags (god mode)
Pkt.WriteByte(Flags);
// TODO: Pkt.WriteFloat(m_Client->GetPlayer()->GetMaxFlyingSpeed());
Pkt.WriteFloat(0.05f);
@@ -541,7 +562,11 @@ void cProtocol172::SendPlayerMoveLook(void)
{
cPacketizer Pkt(*this, 0x08); // Player Position And Look packet
Pkt.WriteDouble(m_Client->GetPlayer()->GetPosX());
Pkt.WriteDouble(m_Client->GetPlayer()->GetPosY());
// 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(m_Client->GetPlayer()->GetPosZ());
Pkt.WriteFloat((float)m_Client->GetPlayer()->GetYaw());
Pkt.WriteFloat((float)m_Client->GetPlayer()->GetPitch());
@@ -585,6 +610,17 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player)
void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
cPacketizer Pkt(*this, 0x1E);
Pkt.WriteInt(a_Entity.GetUniqueID());
Pkt.WriteByte(a_EffectID);
}
void cProtocol172::SendRespawn(void)
{
cPacketizer Pkt(*this, 0x07); // Respawn packet
@@ -921,7 +957,6 @@ void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property
void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
{
LOGD("Received %d bytes of data", a_Size);
if (!m_ReceivedData.Write(a_Data, a_Size))
{
// Too much data in the incoming queue, report to caller:
@@ -958,9 +993,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
return;
}
// DEBUG:
LOGD("Packet 0x%x, len %d (0x%x), start at %d", PacketType, PacketLen, PacketLen, PacketStart);
HandlePacket(bb, PacketType);
if (bb.GetReadableSpace() != 1)
@@ -1258,7 +1290,25 @@ void cProtocol172::HandlePacketPlayerAbilities(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Flags);
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, FlyingSpeed);
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, WalkingSpeed);
// TODO: m_Client->HandlePlayerAbilities();
bool IsFlying, CanFly;
if ((Flags & 2) != 0)
{
IsFlying = true;
}
else
{
IsFlying = false;
}
if ((Flags & 4) != 0)
{
CanFly = true;
}
else
{
CanFly = false;
}
m_Client->HandlePlayerAbilities(CanFly, IsFlying, FlyingSpeed, WalkingSpeed);
}

View File

@@ -47,6 +47,7 @@ public:
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
virtual void SendEntityLook (const cEntity & a_Entity) override;
@@ -70,6 +71,7 @@ public:
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
virtual void SendRespawn (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
virtual void SendExperience (void) override;

View File

@@ -216,6 +216,16 @@ void cProtocolRecognizer::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
void cProtocolRecognizer::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration)
{
ASSERT(m_Protocol != NULL);
m_Protocol->SendEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration);
}
void cProtocolRecognizer::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
ASSERT(m_Protocol != NULL);
@@ -456,6 +466,16 @@ void cProtocolRecognizer::SendPlayerSpawn(const cPlayer & a_Player)
void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
ASSERT(m_Protocol != NULL);
m_Protocol->SendRemoveEntityEffect(a_Entity, a_EffectID);
}
void cProtocolRecognizer::SendRespawn(void)
{
ASSERT(m_Protocol != NULL);

View File

@@ -73,6 +73,7 @@ public:
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
virtual void SendEntityLook (const cEntity & a_Entity) override;
@@ -96,6 +97,7 @@ public:
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
virtual void SendRespawn (void) override;
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;