diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-29 23:02:39 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-29 23:02:39 +0200 |
commit | f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5 (patch) | |
tree | c57d967bab26888ae83692ab09cbbc7fabbae6f5 /source | |
parent | Added a check if torch is placed on the bottom face, temporarily fix the assert. (diff) | |
download | cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.gz cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.bz2 cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.lz cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.xz cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.zst cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.zip |
Diffstat (limited to 'source')
70 files changed, 297 insertions, 2253 deletions
diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg index 7a81ff919..71d9cecb5 100644 --- a/source/AllToLua.pkg +++ b/source/AllToLua.pkg @@ -13,7 +13,6 @@ $cfile "cVine.h" $cfile "../iniFile/iniFile.h" $cfile "BlockID.h" -$cfile "PacketID.h" $cfile "Defines.h" $cfile "LuaFunctions.h" $cfile "cStringMap.h" diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 9b356ab5f..0e5803dd6 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 08/27/12 16:12:30. +** Generated automatically by tolua++-1.0.92 on 08/29/12 22:33:21. */ #ifndef __cplusplus @@ -22,7 +22,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S); #include "cVine.h" #include "../iniFile/iniFile.h" #include "BlockID.h" -#include "PacketID.h" #include "Defines.h" #include "LuaFunctions.h" #include "cStringMap.h" @@ -6650,9 +6649,9 @@ static int tolua_AllToLua_cPlayer_TossItem00(lua_State* tolua_S) { cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0); bool a_bDraggingItem = ((bool) tolua_toboolean(tolua_S,2,0)); - int a_Amount = ((int) tolua_tonumber(tolua_S,3,1)); - int a_CreateType = ((int) tolua_tonumber(tolua_S,4,0)); - int a_CreateHealth = ((int) tolua_tonumber(tolua_S,5,0)); + char a_Amount = ((char) tolua_tonumber(tolua_S,3,1)); + short a_CreateType = ((short) tolua_tonumber(tolua_S,4,0)); + short a_CreateHealth = ((short) tolua_tonumber(tolua_S,5,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TossItem'", NULL); #endif @@ -21100,61 +21099,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_META_SPAWN_EGG_IRON_GOLEM",E_META_SPAWN_EGG_IRON_GOLEM); tolua_function(tolua_S,"BlockStringToType",tolua_AllToLua_BlockStringToType00); tolua_function(tolua_S,"StringToItem",tolua_AllToLua_StringToItem00); - tolua_constant(tolua_S,"E_KEEP_ALIVE",E_KEEP_ALIVE); - tolua_constant(tolua_S,"E_LOGIN",E_LOGIN); - tolua_constant(tolua_S,"E_HANDSHAKE",E_HANDSHAKE); - tolua_constant(tolua_S,"E_CHAT",E_CHAT); - tolua_constant(tolua_S,"E_UPDATE_TIME",E_UPDATE_TIME); - tolua_constant(tolua_S,"E_ENTITY_EQUIPMENT",E_ENTITY_EQUIPMENT); - tolua_constant(tolua_S,"E_USE_ENTITY",E_USE_ENTITY); - tolua_constant(tolua_S,"E_UPDATE_HEALTH",E_UPDATE_HEALTH); - tolua_constant(tolua_S,"E_RESPAWN",E_RESPAWN); - tolua_constant(tolua_S,"E_FLYING",E_FLYING); - tolua_constant(tolua_S,"E_PLAYERPOS",E_PLAYERPOS); - tolua_constant(tolua_S,"E_PLAYERLOOK",E_PLAYERLOOK); - tolua_constant(tolua_S,"E_PLAYERMOVELOOK",E_PLAYERMOVELOOK); - tolua_constant(tolua_S,"E_BLOCK_DIG",E_BLOCK_DIG); - tolua_constant(tolua_S,"E_BLOCK_PLACE",E_BLOCK_PLACE); - tolua_constant(tolua_S,"E_SLOT_SELECTED",E_SLOT_SELECTED); - tolua_constant(tolua_S,"E_ITEM_SWITCH",E_ITEM_SWITCH); - tolua_constant(tolua_S,"E_ADD_TO_INV",E_ADD_TO_INV); - tolua_constant(tolua_S,"E_ANIMATION",E_ANIMATION); - tolua_constant(tolua_S,"E_PACKET_ENTITY_ACTION",E_PACKET_ENTITY_ACTION); - tolua_constant(tolua_S,"E_NAMED_ENTITY_SPAWN",E_NAMED_ENTITY_SPAWN); - tolua_constant(tolua_S,"E_PICKUP_SPAWN",E_PICKUP_SPAWN); - tolua_constant(tolua_S,"E_COLLECT_ITEM",E_COLLECT_ITEM); - tolua_constant(tolua_S,"E_ADD_VEHICLE",E_ADD_VEHICLE); - tolua_constant(tolua_S,"E_SPAWN_MOB",E_SPAWN_MOB); - tolua_constant(tolua_S,"E_DESTROY_ENT",E_DESTROY_ENT); - tolua_constant(tolua_S,"E_ENTITY",E_ENTITY); - tolua_constant(tolua_S,"E_REL_ENT_MOVE",E_REL_ENT_MOVE); - tolua_constant(tolua_S,"E_ENT_LOOK",E_ENT_LOOK); - tolua_constant(tolua_S,"E_REL_ENT_MOVE_LOOK",E_REL_ENT_MOVE_LOOK); - tolua_constant(tolua_S,"E_ENT_TELEPORT",E_ENT_TELEPORT); - tolua_constant(tolua_S,"E_ENT_HEAD_LOOK",E_ENT_HEAD_LOOK); - tolua_constant(tolua_S,"E_ENT_STATUS",E_ENT_STATUS); - tolua_constant(tolua_S,"E_METADATA",E_METADATA); - tolua_constant(tolua_S,"E_PRE_CHUNK",E_PRE_CHUNK); - tolua_constant(tolua_S,"E_MAP_CHUNK",E_MAP_CHUNK); - tolua_constant(tolua_S,"E_MULTI_BLOCK",E_MULTI_BLOCK); - tolua_constant(tolua_S,"E_BLOCK_CHANGE",E_BLOCK_CHANGE); - tolua_constant(tolua_S,"E_BLOCK_ACTION",E_BLOCK_ACTION); - tolua_constant(tolua_S,"E_EXPLOSION",E_EXPLOSION); - tolua_constant(tolua_S,"E_SOUND_EFFECT",E_SOUND_EFFECT); - tolua_constant(tolua_S,"E_NEW_INVALID_STATE",E_NEW_INVALID_STATE); - tolua_constant(tolua_S,"E_THUNDERBOLT",E_THUNDERBOLT); - tolua_constant(tolua_S,"E_WINDOW_OPEN",E_WINDOW_OPEN); - tolua_constant(tolua_S,"E_WINDOW_CLOSE",E_WINDOW_CLOSE); - tolua_constant(tolua_S,"E_WINDOW_CLICK",E_WINDOW_CLICK); - tolua_constant(tolua_S,"E_INVENTORY_SLOT",E_INVENTORY_SLOT); - tolua_constant(tolua_S,"E_INVENTORY_WHOLE",E_INVENTORY_WHOLE); - tolua_constant(tolua_S,"E_INVENTORY_PROGRESS",E_INVENTORY_PROGRESS); - tolua_constant(tolua_S,"E_CREATIVE_INVENTORY_ACTION",E_CREATIVE_INVENTORY_ACTION); - tolua_constant(tolua_S,"E_UPDATE_SIGN",E_UPDATE_SIGN); - tolua_constant(tolua_S,"E_PLAYER_LIST_ITEM",E_PLAYER_LIST_ITEM); - tolua_constant(tolua_S,"E_PLAYER_ABILITIES",E_PLAYER_ABILITIES); - tolua_constant(tolua_S,"E_PING",E_PING); - tolua_constant(tolua_S,"E_DISCONNECT",E_DISCONNECT); tolua_array(tolua_S,"g_BlockLightValue",tolua_get_AllToLua_g_BlockLightValue,tolua_set_AllToLua_g_BlockLightValue); tolua_array(tolua_S,"g_BlockSpreadLightFalloff",tolua_get_AllToLua_g_BlockSpreadLightFalloff,tolua_set_AllToLua_g_BlockSpreadLightFalloff); tolua_array(tolua_S,"g_BlockTransparent",tolua_get_AllToLua_g_BlockTransparent,tolua_set_AllToLua_g_BlockTransparent); diff --git a/source/Bindings.h b/source/Bindings.h index 39946bd56..fe7089222 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 08/27/12 16:12:30. +** Generated automatically by tolua++-1.0.92 on 08/29/12 22:33:21. */ /* Exported function */ diff --git a/source/PacketID.h b/source/PacketID.h deleted file mode 100644 index 3167d04a8..000000000 --- a/source/PacketID.h +++ /dev/null @@ -1,71 +0,0 @@ - -#pragma once - - - - - -//tolua_begin -enum ENUM_PACKET_ID -{ - E_KEEP_ALIVE = 0x00, - E_LOGIN = 0x01, - E_HANDSHAKE = 0x02, - E_CHAT = 0x03, - E_UPDATE_TIME = 0x04, - E_ENTITY_EQUIPMENT = 0x05, - E_USE_ENTITY = 0x07, - E_UPDATE_HEALTH = 0x08, - E_RESPAWN = 0x09, - E_FLYING = 0x0a, - E_PLAYERPOS = 0x0b, - E_PLAYERLOOK = 0x0c, - E_PLAYERMOVELOOK = 0x0d, - E_BLOCK_DIG = 0x0e, - E_BLOCK_PLACE = 0x0f, - E_SLOT_SELECTED = 0x10, - E_ITEM_SWITCH = 0x10, // OBSOLETE, use E_SLOT_SELECTED instead - E_ADD_TO_INV = 0x11, // TODO: Sure this is not Use Bed?? - E_ANIMATION = 0x12, - E_PACKET_ENTITY_ACTION = 0x13, - E_NAMED_ENTITY_SPAWN = 0x14, - E_PICKUP_SPAWN = 0x15, - E_COLLECT_ITEM = 0x16, - E_ADD_VEHICLE = 0x17, - E_SPAWN_MOB = 0x18, - E_DESTROY_ENT = 0x1d, - E_ENTITY = 0x1e, - E_REL_ENT_MOVE = 0x1f, - E_ENT_LOOK = 0x20, - E_REL_ENT_MOVE_LOOK = 0x21, - E_ENT_TELEPORT = 0x22, - E_ENT_HEAD_LOOK = 0x23, - E_ENT_STATUS = 0x26, - E_METADATA = 0x28, - E_PRE_CHUNK = 0x32, - E_MAP_CHUNK = 0x33, - E_MULTI_BLOCK = 0x34, - E_BLOCK_CHANGE = 0x35, - E_BLOCK_ACTION = 0x36, - E_EXPLOSION = 0x3C, - E_SOUND_EFFECT = 0x3D, - E_NEW_INVALID_STATE = 0x46, - E_THUNDERBOLT = 0x47, - E_WINDOW_OPEN = 0x64, - E_WINDOW_CLOSE = 0x65, - E_WINDOW_CLICK = 0x66, - E_INVENTORY_SLOT = 0x67, - E_INVENTORY_WHOLE = 0x68, - E_INVENTORY_PROGRESS = 0x69, - E_CREATIVE_INVENTORY_ACTION = 0x6B, - E_UPDATE_SIGN = 0x82, - E_PLAYER_LIST_ITEM = 0xC9, - E_PLAYER_ABILITIES = 0xca, // since 1.2.4, protocol version 29 - E_PING = 0xfe, - E_DISCONNECT = 0xff -} ; -//tolua_end - - - - diff --git a/source/Protocol.h b/source/Protocol.h index ee0ccddfd..1b313ce09 100644 --- a/source/Protocol.h +++ b/source/Protocol.h @@ -53,6 +53,8 @@ public: virtual void SendEntLook (const cEntity & a_Entity) = 0;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) = 0;
+ virtual void SendEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
+ virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
virtual void SendGameMode (eGameMode a_GameMode) = 0;
virtual void SendHandshake (const AString & a_ServerName) = 0;
virtual void SendHealth (void) = 0;
@@ -67,8 +69,6 @@ public: virtual void SendPlayerMoveLook (void) = 0;
virtual void SendPlayerPosition (void) = 0;
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
- virtual void SendRelEntMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
- virtual void SendRelEntMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
virtual void SendRespawn (void) = 0;
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
diff --git a/source/Protocol125.cpp b/source/Protocol125.cpp index 5b16e5728..d9faefb77 100644 --- a/source/Protocol125.cpp +++ b/source/Protocol125.cpp @@ -7,27 +7,6 @@ #include "Protocol125.h"
-#include "packets/cPacket.h"
-#include "packets/cPacket_13.h"
-#include "packets/cPacket_ArmAnim.h"
-#include "packets/cPacket_BlockDig.h"
-#include "packets/cPacket_BlockPlace.h"
-#include "packets/cPacket_Chat.h"
-#include "packets/cPacket_CreativeInventoryAction.h"
-#include "packets/cPacket_Disconnect.h"
-#include "packets/cPacket_Flying.h"
-#include "packets/cPacket_Handshake.h"
-#include "packets/cPacket_ItemSwitch.h"
-#include "packets/cPacket_KeepAlive.h"
-#include "packets/cPacket_Login.h"
-#include "packets/cPacket_Ping.h"
-#include "packets/cPacket_Player.h"
-#include "packets/cPacket_Respawn.h"
-#include "packets/cPacket_UpdateSign.h"
-#include "packets/cPacket_UseEntity.h"
-#include "packets/cPacket_WindowClick.h"
-#include "packets/cPacket_WindowClose.h"
-
#include "cClientHandle.h"
#include "ChunkDataSerializer.h"
#include "cEntity.h"
@@ -52,10 +31,10 @@ enum PACKET_USE_ENTITY = 0x07,
PACKET_UPDATE_HEALTH = 0x08,
PACKET_RESPAWN = 0x09,
- PACKET_FLYING = 0x0a,
- PACKET_PLAYERPOS = 0x0b,
- PACKET_PLAYERLOOK = 0x0c,
- PACKET_PLAYERMOVELOOK = 0x0d,
+ PACKET_PLAYER_ON_GROUND = 0x0a,
+ PACKET_PLAYER_POS = 0x0b,
+ PACKET_PLAYER_LOOK = 0x0c,
+ PACKET_PLAYER_MOVE_LOOK = 0x0d,
PACKET_BLOCK_DIG = 0x0e,
PACKET_BLOCK_PLACE = 0x0f,
PACKET_SLOT_SELECTED = 0x10,
@@ -69,9 +48,9 @@ enum PACKET_SPAWN_MOB = 0x18,
PACKET_DESTROY_ENTITY = 0x1d,
PACKET_ENTITY = 0x1e,
- PACKET_REL_ENT_MOVE = 0x1f,
+ PACKET_ENT_REL_MOVE = 0x1f,
PACKET_ENT_LOOK = 0x20,
- PACKET_REL_ENT_MOVE_LOOK = 0x21,
+ PACKET_ENT_REL_MOVE_LOOK = 0x21,
PACKET_ENT_TELEPORT = 0x22,
PACKET_ENT_HEAD_LOOK = 0x23,
PACKET_ENT_STATUS = 0x26,
@@ -103,6 +82,24 @@ enum +#define HANDLE_PACKET_READ(Proc, Type, Var) \
+ Type Var; \
+ { \
+ if (!m_ReceivedData.Proc(Var)) \
+ { \
+ return PARSE_INCOMPLETE; \
+ } \
+ }
+
+
+
+
+typedef unsigned char Byte;
+
+
+
+
+
cProtocol125::cProtocol125(cClientHandle * a_Client) :
super(a_Client),
m_ReceivedData(64 KiB)
@@ -384,7 +381,7 @@ void cProtocol125::SendLogin(const cPlayer & a_Player) {
cCSLock Lock(m_CSPacket);
- WriteByte (E_LOGIN);
+ WriteByte (PACKET_LOGIN);
WriteInt (a_Player.GetUniqueID()); // EntityID of the player
WriteString(""); // Username, not used
WriteString("DEFAULT"); // Level type
@@ -480,7 +477,7 @@ void cProtocol125::SendPlayerMoveLook(void) );
*/
- WriteByte (PACKET_PLAYERMOVELOOK);
+ WriteByte (PACKET_PLAYER_MOVE_LOOK);
cPlayer * Player = m_Client->GetPlayer();
WriteDouble(Player->GetPosX());
WriteDouble(Player->GetStance() + 0.03); // Add a small amount so that the player doesn't start inside a block
@@ -526,12 +523,12 @@ void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player) -void cProtocol125::SendRelEntMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+void cProtocol125::SendEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_REL_ENT_MOVE);
+ WriteByte(PACKET_ENT_REL_MOVE);
WriteInt (a_Entity.GetUniqueID());
WriteByte(a_RelX);
WriteByte(a_RelY);
@@ -543,12 +540,12 @@ void cProtocol125::SendRelEntMove(const cEntity & a_Entity, char a_RelX, char a_ -void cProtocol125::SendRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+void cProtocol125::SendEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_REL_ENT_MOVE_LOOK);
+ WriteByte(PACKET_ENT_REL_MOVE_LOOK);
WriteInt (a_Entity.GetUniqueID());
WriteByte(a_RelX);
WriteByte(a_RelY);
@@ -779,19 +776,19 @@ void cProtocol125::DataReceived(const char * a_Data, int a_Size) m_ReceivedData.ReadByte(PacketType);
switch (ParsePacket(PacketType))
{
- case PACKET_UNKNOWN:
+ case PARSE_UNKNOWN:
{
// An unknown packet has been received, notify the client and abort:
m_Client->PacketUnknown(PacketType);
return;
}
- case PACKET_ERROR:
+ case PARSE_ERROR:
{
// An error occurred while parsing a known packet, notify the client and abort:
m_Client->PacketError(PacketType);
return;
}
- case PACKET_INCOMPLETE:
+ case PARSE_INCOMPLETE:
{
// Incomplete packet, bail out and process with the next batch of data
m_ReceivedData.ResetRead();
@@ -815,23 +812,23 @@ int cProtocol125::ParsePacket(unsigned char a_PacketType) {
switch (a_PacketType)
{
- default: return PACKET_UNKNOWN;
+ default: return PARSE_UNKNOWN;
case PACKET_ANIMATION: return ParseArmAnim();
case PACKET_BLOCK_DIG: return ParseBlockDig();
case PACKET_BLOCK_PLACE: return ParseBlockPlace();
case PACKET_CHAT: return ParseChat();
case PACKET_CREATIVE_INVENTORY_ACTION: return ParseCreativeInventoryAction();
case PACKET_DISCONNECT: return ParseDisconnect();
- case PACKET_FLYING: return ParseFlying();
case PACKET_HANDSHAKE: return ParseHandshake();
case PACKET_KEEP_ALIVE: return ParseKeepAlive();
case PACKET_LOGIN: return ParseLogin();
case PACKET_PACKET_ENTITY_ACTION: return ParseEntityAction();
case PACKET_PING: return ParsePing();
- case PACKET_PLAYERLOOK: return ParsePlayerLook();
- case PACKET_PLAYERMOVELOOK: return ParsePlayerMoveLook();
- case PACKET_PLAYERPOS: return ParsePlayerPosition();
case PACKET_PLAYER_ABILITIES: return ParsePlayerAbilities();
+ case PACKET_PLAYER_LOOK: return ParsePlayerLook();
+ case PACKET_PLAYER_MOVE_LOOK: return ParsePlayerMoveLook();
+ case PACKET_PLAYER_ON_GROUND: return ParsePlayerOnGround();
+ case PACKET_PLAYER_POS: return ParsePlayerPosition();
case PACKET_RESPAWN: return ParseRespawn();
case PACKET_SLOT_SELECTED: return ParseSlotSelected();
case PACKET_UPDATE_SIGN: return ParseUpdateSign();
@@ -858,277 +855,320 @@ int cProtocol125::ParsePacket(unsigned char a_PacketType) -int cProtocol125::ParseKeepAlive(void)
+int cProtocol125::ParseArmAnim(void)
{
- cPacket_KeepAlive KeepAlive;
- HANDLE_PACKET_PARSE(KeepAlive);
- m_Client->HandleKeepAlive(KeepAlive.m_KeepAliveID);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_PACKET_READ(ReadChar, char, Animation);
+ m_Client->HandleAnimation(Animation);
+ return PARSE_OK;
}
-int cProtocol125::ParseHandshake(void)
+int cProtocol125::ParseBlockDig(void)
{
- cPacket_Handshake Handshake;
- HANDLE_PACKET_PARSE(Handshake);
- m_Client->HandleHandshake(Handshake.m_Username);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadChar, char, Status);
+ HANDLE_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_PACKET_READ(ReadByte, Byte, PosY);
+ HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_PACKET_READ(ReadChar, char, Direction);
+ m_Client->HandleBlockDig(PosX, PosY, PosZ, Direction, Status);
+ return PARSE_OK;
}
-int cProtocol125::ParseLogin(void)
+int cProtocol125::ParseBlockPlace(void)
{
- cPacket_Login Login;
- HANDLE_PACKET_PARSE(Login);
- m_Client->HandleLogin(Login.m_ProtocolVersion, Login.m_Username);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_PACKET_READ(ReadByte, Byte, PosY);
+ HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_PACKET_READ(ReadChar, char, Direction);
+
+ cItem HeldItem;
+ int res = ParseItem(HeldItem);
+ if (res < 0)
+ {
+ return res;
+ }
+
+ m_Client->HandleBlockPlace(PosX, PosY, PosZ, Direction, HeldItem);
+ return PARSE_OK;
}
-int cProtocol125::ParsePlayerPosition(void)
+int cProtocol125::ParseChat(void)
{
- cPacket_PlayerPosition pp;
- HANDLE_PACKET_PARSE(pp);
- m_Client->HandlePlayerPos(pp.m_PosX, pp.m_PosY, pp.m_PosZ, pp.m_Stance, pp.m_IsOnGround);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Message);
+ m_Client->HandleChat(Message);
+ return PARSE_OK;
}
-int cProtocol125::ParsePlayerLook(void)
+int cProtocol125::ParseCreativeInventoryAction(void)
{
- cPacket_PlayerLook pl;
- HANDLE_PACKET_PARSE(pl);
- m_Client->HandlePlayerLook(pl.m_Rotation, pl.m_Pitch, pl.m_IsOnGround);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
+ cItem HeldItem;
+ int res = ParseItem(HeldItem);
+ if (res < 0)
+ {
+ return res;
+ }
+ m_Client->HandleCreativeInventory(SlotNum, HeldItem);
+ return PARSE_OK;
}
-int cProtocol125::ParsePlayerMoveLook(void)
+int cProtocol125::ParseDisconnect(void)
{
- cPacket_PlayerMoveLook pml;
- HANDLE_PACKET_PARSE(pml);
- m_Client->HandlePlayerMoveLook(pml.m_PosX, pml.m_PosY, pml.m_PosZ, pml.m_Stance, pml.m_Rotation, pml.m_Pitch, pml.m_IsOnGround);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Reason);
+ m_Client->HandleDisconnect(Reason);
+ return PARSE_OK;
}
-int cProtocol125::ParsePlayerAbilities(void)
+int cProtocol125::ParseEntityAction(void)
{
- cPacket_PlayerAbilities pa;
- HANDLE_PACKET_PARSE(pa);
- // TODO: m_Client->HandlePlayerAbilities(...);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_PACKET_READ(ReadChar, char, ActionID);
+ // TODO: m_Client->HandleEntityAction(...);
+ return PARSE_OK;
}
-int cProtocol125::ParseChat(void)
+int cProtocol125::ParseHandshake(void)
{
- cPacket_Chat ch;
- HANDLE_PACKET_PARSE(ch);
- m_Client->HandleChat(ch.m_Message);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
+ m_Client->HandleHandshake(Username);
+ return PARSE_OK;
}
-int cProtocol125::ParseArmAnim(void)
+int cProtocol125::ParseKeepAlive(void)
{
- cPacket_ArmAnim aa;
- HANDLE_PACKET_PARSE(aa);
- m_Client->HandleAnimation(aa.m_Animation);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEInt, int, KeepAliveID);
+ m_Client->HandleKeepAlive(KeepAliveID);
+ return PARSE_OK;
}
-int cProtocol125::ParseFlying(void)
+int cProtocol125::ParseLogin(void)
{
- cPacket_Flying fl;
- HANDLE_PACKET_PARSE(fl);
- // TODO: m_Client->HandleFlying(fl.m_bFlying);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEInt, int, ProtocolVersion);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, LevelType);
+ HANDLE_PACKET_READ(ReadBEInt, int, ServerMode);
+ HANDLE_PACKET_READ(ReadBEInt, int, Dimension);
+ HANDLE_PACKET_READ(ReadChar, char, Difficulty);
+ HANDLE_PACKET_READ(ReadByte, Byte, WorldHeight);
+ HANDLE_PACKET_READ(ReadByte, Byte, MaxPlayers);
+ m_Client->HandleLogin(ProtocolVersion, Username);
+ return PARSE_OK;
}
-int cProtocol125::ParseBlockDig(void)
+int cProtocol125::ParsePing(void)
{
- cPacket_BlockDig bd;
- HANDLE_PACKET_PARSE(bd);
- m_Client->HandleBlockDig(bd.m_PosX, bd.m_PosY, bd.m_PosZ, bd.m_Direction, bd.m_Status);
- return PACKET_OK;
+ // Packet has no more data
+ m_Client->HandlePing();
+ return PARSE_OK;
}
-int cProtocol125::ParseBlockPlace(void)
+
+int cProtocol125::ParsePlayerAbilities(void)
{
- cPacket_BlockPlace bp;
- HANDLE_PACKET_PARSE(bp);
- m_Client->HandleBlockPlace(bp.m_PosX, bp.m_PosY, bp.m_PosZ, bp.m_Direction, bp.m_HeldItem);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBool, bool, Invulnerable);
+ HANDLE_PACKET_READ(ReadBool, bool, IsFlying);
+ HANDLE_PACKET_READ(ReadBool, bool, CanFly);
+ HANDLE_PACKET_READ(ReadBool, bool, InstaMine);
+ // TODO: m_Client->HandlePlayerAbilities(...);
+ return PARSE_OK;
}
-int cProtocol125::ParseDisconnect(void)
+int cProtocol125::ParsePlayerLook(void)
{
- cPacket_Disconnect dc;
- HANDLE_PACKET_PARSE(dc);
- m_Client->HandleDisconnect(dc.m_Reason);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEFloat, float, Rotation);
+ HANDLE_PACKET_READ(ReadBEFloat, float, Pitch);
+ HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
+ m_Client->HandlePlayerLook(Rotation, Pitch, IsOnGround);
+ return PARSE_OK;
}
-int cProtocol125::ParseSlotSelected(void)
+int cProtocol125::ParsePlayerMoveLook(void)
{
- cPacket_ItemSwitch its;
- HANDLE_PACKET_PARSE(its);
- m_Client->HandleSlotSelected(its.m_SlotNum);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosX);
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosY);
+ HANDLE_PACKET_READ(ReadBEDouble, double, Stance);
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosZ);
+ HANDLE_PACKET_READ(ReadBEFloat, float, Rotation);
+ HANDLE_PACKET_READ(ReadBEFloat, float, Pitch);
+ HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
+ // LOGD("Recv PML: {%0.2f, %0.2f, %0.2f}, Stance %0.2f, Gnd: %d", PosX, PosY, PosZ, Stance, IsOnGround ? 1 : 0);
+ m_Client->HandlePlayerMoveLook(PosX, PosY, PosZ, Stance, Rotation, Pitch, IsOnGround);
+ return PARSE_OK;
}
-int cProtocol125::ParseCreativeInventoryAction(void)
+int cProtocol125::ParsePlayerOnGround(void)
{
- cPacket_CreativeInventoryAction cia;
- HANDLE_PACKET_PARSE(cia);
- m_Client->HandleCreativeInventory(cia.m_SlotNum, cia.m_ClickedItem);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
+ // TODO: m_Client->HandleFlying(IsOnGround);
+ return PARSE_OK;
}
-int cProtocol125::ParseUseEntity(void)
+int cProtocol125::ParsePlayerPosition(void)
{
- cPacket_UseEntity ue;
- HANDLE_PACKET_PARSE(ue);
- m_Client->HandleUseEntity(ue.m_TargetEntityID, ue.m_IsLeftClick);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosX);
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosY);
+ HANDLE_PACKET_READ(ReadBEDouble, double, Stance);
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosZ);
+ HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
+ m_Client->HandlePlayerPos(PosX, PosY, PosZ, Stance, IsOnGround);
+ return PARSE_OK;
}
-int cProtocol125::ParseWindowClose(void)
+int cProtocol125::ParseRespawn(void)
{
- cPacket_WindowClose wc;
- HANDLE_PACKET_PARSE(wc);
- m_Client->HandleWindowClose(wc.m_WindowID);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEInt, int, Dimension);
+ HANDLE_PACKET_READ(ReadChar, char, Difficulty);
+ HANDLE_PACKET_READ(ReadChar, char, CreativeMode);
+ HANDLE_PACKET_READ(ReadBEShort, short, WorldHeight);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, LevelType);
+ m_Client->HandleRespawn();
+ return PARSE_OK;
}
-int cProtocol125::ParseWindowClick(void)
+int cProtocol125::ParseSlotSelected(void)
{
- cPacket_WindowClick wc;
- HANDLE_PACKET_PARSE(wc);
- m_Client->HandleWindowClick(wc.m_WindowID, wc.m_SlotNum, wc.m_IsRightClick, wc.m_IsShiftPressed, wc.m_HeldItem);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
+ m_Client->HandleSlotSelected(SlotNum);
+ return PARSE_OK;
}
-int cProtocol125::ParseEntityAction(void)
+int cProtocol125::ParseUpdateSign(void)
{
- cPacket_13 ea;
- HANDLE_PACKET_PARSE(ea);
- // TODO: m_Client->HandleEntityAction(...);
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_PACKET_READ(ReadBEShort, short, BlockY);
+ HANDLE_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line1);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line2);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line3);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line4);
+ m_Client->HandleUpdateSign(BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4);
+ return PARSE_OK;
}
-int cProtocol125::ParseUpdateSign(void)
+int cProtocol125::ParseUseEntity(void)
{
- cPacket_UpdateSign us;
- HANDLE_PACKET_PARSE(us);
- m_Client->HandleUpdateSign(
- us.m_BlockX, us.m_BlockY, us.m_BlockZ,
- us.m_Line1, us.m_Line2, us.m_Line3, us.m_Line4
- );
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadBEInt, int, SourceEntityID);
+ HANDLE_PACKET_READ(ReadBEInt, int, TargetEntityID);
+ HANDLE_PACKET_READ(ReadBool, bool, IsLeftClick);
+ m_Client->HandleUseEntity(TargetEntityID, IsLeftClick);
+ return PARSE_OK;
}
-int cProtocol125::ParseRespawn(void)
+int cProtocol125::ParseWindowClick(void)
{
- cPacket_Respawn rsp;
- HANDLE_PACKET_PARSE(rsp);
- m_Client->HandleRespawn();
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadChar, char, WindowID);
+ HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
+ HANDLE_PACKET_READ(ReadBool, bool, IsRightClick);
+ HANDLE_PACKET_READ(ReadBEShort, short, TransactionID);
+ HANDLE_PACKET_READ(ReadBool, bool, IsShiftPressed);
+ cItem HeldItem;
+ int res = ParseItem(HeldItem);
+ if (res < 0)
+ {
+ return res;
+ }
+ m_Client->HandleWindowClick(WindowID, SlotNum, IsRightClick, IsShiftPressed, HeldItem);
+ return PARSE_OK;
}
-int cProtocol125::ParsePing(void)
+int cProtocol125::ParseWindowClose(void)
{
- cPacket_Ping ping;
- HANDLE_PACKET_PARSE(ping);
- m_Client->HandlePing();
- return PACKET_OK;
+ HANDLE_PACKET_READ(ReadChar, char, WindowID);
+ m_Client->HandleWindowClose(WindowID);
+ return PARSE_OK;
}
-
void cProtocol125::SendPreChunk(int a_ChunkX, int a_ChunkZ, bool a_ShouldLoad)
{
- WriteByte(E_PRE_CHUNK);
+ WriteByte(PACKET_PRE_CHUNK);
WriteInt (a_ChunkX);
WriteInt (a_ChunkZ);
WriteBool(a_ShouldLoad);
@@ -1186,6 +1226,51 @@ void cProtocol125::WriteItem(const cItem & a_Item) +int cProtocol125::ParseItem(cItem & a_Item)
+{
+ HANDLE_PACKET_READ(ReadBEShort, short, ItemType);
+
+ if (ItemType <= -1)
+ {
+ a_Item.Empty();
+ return PARSE_OK;
+ }
+ a_Item.m_ItemType = ItemType;
+
+ HANDLE_PACKET_READ(ReadChar, char, ItemCount);
+ HANDLE_PACKET_READ(ReadBEShort, short, ItemDamage);
+ a_Item.m_ItemCount = ItemCount;
+ a_Item.m_ItemDamage = ItemDamage;
+ if (ItemCount <= 0)
+ {
+ a_Item.Empty();
+ }
+
+ if (!cItem::IsEnchantable(ItemType))
+ {
+ return PARSE_OK;
+ }
+
+ HANDLE_PACKET_READ(ReadBEShort, short, EnchantNumBytes);
+
+ if (EnchantNumBytes == 0)
+ {
+ return PARSE_OK;
+ }
+
+ // TODO: Enchantment not implemented yet!
+ if (!m_ReceivedData.SkipRead(EnchantNumBytes))
+ {
+ return PARSE_INCOMPLETE;
+ }
+
+ return PARSE_OK;
+}
+
+
+
+
+
AString cProtocol125::GetEntityMetaData(const cEntity & a_Entity)
{
// We should send all the metadata here
diff --git a/source/Protocol125.h b/source/Protocol125.h index de1be4fd7..c1b10bd52 100644 --- a/source/Protocol125.h +++ b/source/Protocol125.h @@ -16,13 +16,6 @@ -// fwd:
-class cPacket;
-
-
-
-
-
class cProtocol125 :
public cProtocol
{
@@ -46,6 +39,8 @@ public: virtual void SendEntLook (const cEntity & a_Entity) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
+ virtual void SendEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
+ virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
virtual void SendGameMode (eGameMode a_GameMode) override;
virtual void SendHandshake (const AString & a_ConnectionHash) override;
virtual void SendHealth (void) override;
@@ -60,8 +55,6 @@ public: virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
- virtual void SendRelEntMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
- virtual void SendRelEntMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
virtual void SendRespawn (void) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
@@ -78,10 +71,10 @@ public: protected:
/// Results of packet-parsing:
enum {
- PACKET_OK = 1,
- PACKET_ERROR = -1,
- PACKET_UNKNOWN = -2,
- PACKET_INCOMPLETE = -3,
+ PARSE_OK = 1,
+ PARSE_ERROR = -1,
+ PARSE_UNKNOWN = -2,
+ PARSE_INCOMPLETE = -3,
} ;
cByteBuffer m_ReceivedData; //< Buffer for the received data
@@ -99,17 +92,17 @@ protected: virtual int ParseCreativeInventoryAction(void);
virtual int ParseDisconnect (void);
virtual int ParseEntityAction (void);
- virtual int ParseFlying (void);
virtual int ParseHandshake (void);
- virtual int ParseSlotSelected (void);
virtual int ParseKeepAlive (void);
virtual int ParseLogin (void);
virtual int ParsePing (void);
virtual int ParsePlayerAbilities (void);
virtual int ParsePlayerLook (void);
virtual int ParsePlayerMoveLook (void);
+ virtual int ParsePlayerOnGround (void);
virtual int ParsePlayerPosition (void);
virtual int ParseRespawn (void);
+ virtual int ParseSlotSelected (void);
virtual int ParseUpdateSign (void);
virtual int ParseUseEntity (void);
virtual int ParseWindowClick (void);
@@ -125,6 +118,9 @@ protected: /// Writes one item, "slot" as the protocol wiki calls it
virtual void WriteItem(const cItem & a_Item);
+ /// Parses one item, "slot" as the protocol wiki calls it, from m_ReceivedData; returns the usual ParsePacket() codes
+ virtual int ParseItem(cItem & a_Item);
+
/// Returns the entity metadata representation
AString GetEntityMetaData(const cEntity & a_Entity);
diff --git a/source/cChunk.cpp b/source/cChunk.cpp index 351f456af..17b961d3c 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -1651,7 +1651,7 @@ void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, -void cChunk::BroadcastRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) +void cChunk::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) { @@ -1659,7 +1659,7 @@ void cChunk::BroadcastRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char { continue; } - (*itr)->SendRelEntMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ); + (*itr)->SendEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ); } // for itr - LoadedByClient[] } @@ -1667,7 +1667,7 @@ void cChunk::BroadcastRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char -void cChunk::BroadcastRelEntMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) +void cChunk::BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) { @@ -1675,7 +1675,7 @@ void cChunk::BroadcastRelEntMove(const cEntity & a_Entity, char a_RelX, char a_R { continue; } - (*itr)->SendRelEntMove(a_Entity, a_RelX, a_RelY, a_RelZ); + (*itr)->SendEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ); } // for itr - LoadedByClient[] } diff --git a/source/cChunk.h b/source/cChunk.h index 9539b20d5..c63bd8a92 100644 --- a/source/cChunk.h +++ b/source/cChunk.h @@ -32,7 +32,6 @@ namespace Json class cWorld; class cFurnaceEntity; -class cPacket; class cClientHandle; class cServer; class MTRand; @@ -174,14 +173,10 @@ public: void CalculateLighting(); // Recalculate right now void CalculateHeightmap(); - // Broadcasts to all clients that have loaded this chunk - void Broadcast( const cPacket & a_Packet, cClientHandle * a_Exclude = NULL) {Broadcast(&a_Packet, a_Exclude); } - void Broadcast( const cPacket * a_Packet, cClientHandle * a_Exclude = NULL); - void BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL); - void BroadcastRelEntMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); - void BroadcastRelEntMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); + void BroadcastEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); + void BroadcastEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); void BroadcastEntLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, const cClientHandle * a_Exclude = NULL); diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp index f4203ca4e..c764a0321 100644 --- a/source/cChunkMap.cpp +++ b/source/cChunkMap.cpp @@ -257,7 +257,7 @@ void cChunkMap::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotN -void cChunkMap::BroadcastRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) +void cChunkMap::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), a_Entity.GetChunkY(), a_Entity.GetChunkZ()); @@ -266,7 +266,7 @@ void cChunkMap::BroadcastRelEntMoveLook(const cEntity & a_Entity, char a_RelX, c return; } // It's perfectly legal to broadcast packets even to invalid chunks! - Chunk->BroadcastRelEntMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude); + Chunk->BroadcastEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude); } @@ -274,7 +274,7 @@ void cChunkMap::BroadcastRelEntMoveLook(const cEntity & a_Entity, char a_RelX, c -void cChunkMap::BroadcastRelEntMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) +void cChunkMap::BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), a_Entity.GetChunkY(), a_Entity.GetChunkZ()); @@ -283,7 +283,7 @@ void cChunkMap::BroadcastRelEntMove(const cEntity & a_Entity, char a_RelX, char return; } // It's perfectly legal to broadcast packets even to invalid chunks! - Chunk->BroadcastRelEntMove(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude); + Chunk->BroadcastEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude); } diff --git a/source/cChunkMap.h b/source/cChunkMap.h index a28b35fb6..36cb704a2 100644 --- a/source/cChunkMap.h +++ b/source/cChunkMap.h @@ -49,10 +49,10 @@ public: void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL); /// Broadcasts a RelEntMoveLook packet to all clients in the chunk where a_Entity is - void BroadcastRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); + void BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); /// Broadcasts a RelEntMove packet to all clients in the chunk where a_Entity is - void BroadcastRelEntMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); + void BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); /// Broadcasts a EntLook packet to all clients in the chunk where a_Entity is void BroadcastEntLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index d966831b9..0fd1597c4 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -1174,22 +1174,22 @@ void cClientHandle::SendPlayerPosition(void) -void cClientHandle::SendRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) +void cClientHandle::SendEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) { ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self - m_Protocol->SendRelEntMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ); + m_Protocol->SendEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ); } -void cClientHandle::SendRelEntMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) +void cClientHandle::SendEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) { ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self - m_Protocol->SendRelEntMove(a_Entity, a_RelX, a_RelY, a_RelZ); + m_Protocol->SendEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ); } diff --git a/source/cClientHandle.h b/source/cClientHandle.h index ee3e8b1ee..3ae37c2e7 100644 --- a/source/cClientHandle.h +++ b/source/cClientHandle.h @@ -95,8 +95,8 @@ public: void SendTeleportEntity(const cEntity & a_Entity); void SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline); void SendPlayerPosition(void); - void SendRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ); - void SendRelEntMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ); + void SendEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ); + void SendEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ); void SendEntLook (const cEntity & a_Entity); void SendEntHeadLook (const cEntity & a_Entity); void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2); @@ -226,11 +226,6 @@ private: bool m_bKeepThreadGoing; - /* - /// Handles rclk with a dye; returns true if the dye is to be be consumed - bool HandleDyes(cPacket_BlockPlace * a_Packet); - */ - /// Returns true if the rate block interactions is within a reasonable limit (bot protection) bool CheckBlockInteractionsRate(void); diff --git a/source/cEntity.h b/source/cEntity.h index a34b7518f..15c351a09 100644 --- a/source/cEntity.h +++ b/source/cEntity.h @@ -43,7 +43,6 @@ class cWorld; class cReferenceManager; class cClientHandle; -class cPacket; diff --git a/source/cInventory.h b/source/cInventory.h index bb8519828..96d744baf 100644 --- a/source/cInventory.h +++ b/source/cInventory.h @@ -15,8 +15,6 @@ namespace Json class cItem; class cClientHandle; class cPlayer; -class cPacket; -class cPacket_EntityEquipment; diff --git a/source/cMonster.cpp b/source/cMonster.cpp index 24d790dc3..8b1a22bb7 100644 --- a/source/cMonster.cpp +++ b/source/cMonster.cpp @@ -228,12 +228,12 @@ void cMonster::ReplicateMovement() // Relative move sucks balls! It's always wrong wtf! if (m_bDirtyOrientation) { - m_World->BroadcastRelEntMoveLook(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32)); + m_World->BroadcastEntRelMoveLook(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32)); m_bDirtyOrientation = false; } else { - m_World->BroadcastRelEntMove(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32)); + m_World->BroadcastEntRelMove(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32)); } } m_LastPosX = GetPosX(); diff --git a/source/cPickup.h b/source/cPickup.h index 06d5fe301..8e8f514b8 100644 --- a/source/cPickup.h +++ b/source/cPickup.h @@ -6,7 +6,6 @@ -class cPacket_PickupSpawn; class cPlayer; class cItem; diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp index b7c05b402..d3c0107ec 100644 --- a/source/cPlayer.cpp +++ b/source/cPlayer.cpp @@ -198,12 +198,12 @@ void cPlayer::Tick(float a_Dt) // Relative move sucks balls! It's always wrong wtf! if (m_bDirtyOrientation) { - m_World->BroadcastRelEntMoveLook(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32), m_ClientHandle); + m_World->BroadcastEntRelMoveLook(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32), m_ClientHandle); m_bDirtyOrientation = false; } else { - m_World->BroadcastRelEntMove(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32), m_ClientHandle); + m_World->BroadcastEntRelMove(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32), m_ClientHandle); } } m_LastPosX = GetPosX(); diff --git a/source/cPlugin.h b/source/cPlugin.h index f040ba823..15029886b 100644 --- a/source/cPlugin.h +++ b/source/cPlugin.h @@ -3,13 +3,6 @@ #include "cItem.h" -class cPacket_BlockPlace; -class cPacket_PickupSpawn; -class cPacket_EntityEquipment; -class cPacket_Disconnect; -class cPacket_Chat; -class cPacket_BlockDig; -class cPacket_Login; class cClientHandle; class cPlayer; class cPickup; diff --git a/source/cPlugin_Lua.h b/source/cPlugin_Lua.h index 6e5d027d4..73787de0c 100644 --- a/source/cPlugin_Lua.h +++ b/source/cPlugin_Lua.h @@ -3,10 +3,12 @@ class cPickup; class cPlayer; -class cPacket_BlockPlace; -class cPacket_BlockDig; -class cPacket_Login; class cPlugin; + + + + + class cPlugin_Lua //tolua_export { //tolua_export public: @@ -29,4 +31,8 @@ private: typedef std::list< cPlugin* > PluginList; PluginList m_Plugins; -}; //tolua_export
\ No newline at end of file +}; //tolua_export + + + + diff --git a/source/cServer.h b/source/cServer.h index 48a39db7d..a97bcbd7a 100644 --- a/source/cServer.h +++ b/source/cServer.h @@ -19,7 +19,6 @@ class cPlayer; class cClientHandle; -class cPacket; typedef std::list<cClientHandle *> cClientHandleList; diff --git a/source/cWorld.cpp b/source/cWorld.cpp index ee41a6aa1..9348eda7d 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -1268,18 +1268,18 @@ void cWorld::BroadcastTeleportEntity(const cEntity & a_Entity, const cClientHand -void cWorld::BroadcastRelEntMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) +void cWorld::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { - m_ChunkMap->BroadcastRelEntMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude); + m_ChunkMap->BroadcastEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude); } -void cWorld::BroadcastRelEntMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) +void cWorld::BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { - m_ChunkMap->BroadcastRelEntMove(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude); + m_ChunkMap->BroadcastEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude); } diff --git a/source/cWorld.h b/source/cWorld.h index 688ce5857..0751daf5c 100644 --- a/source/cWorld.h +++ b/source/cWorld.h @@ -77,8 +77,8 @@ public: void BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL); void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); - void BroadcastRelEntMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); - void BroadcastRelEntMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); + void BroadcastEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); + void BroadcastEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); void BroadcastEntLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, const cClientHandle * a_Exclude = NULL); diff --git a/source/packets/cPacket.cpp b/source/packets/cPacket.cpp deleted file mode 100644 index 8307e67fa..000000000 --- a/source/packets/cPacket.cpp +++ /dev/null @@ -1,153 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket.h" -#include "../Endianness.h" - - - - - -/* -// These checks cannot be done in preprocessor, since sizeof() is evaluated while compiling, so in preprocessing it's unknown. -// Check some basic type assumptions: -#if (sizeof(int) != 4) - #error "Bad size for int, protocol won't work" -#endif - -#if (sizeof(float) != 4) - #error "Bad size for float, protocol won't work" -#endif - -#if (sizeof(double) != 8) - #error "Bad size for double, protocol won't work" -#endif -*/ - - - - - -void cPacket::AppendString(AString & a_Dst, const AString & a_String) -{ - AppendShort(a_Dst, (unsigned short)a_String.size()); - a_Dst.append(a_String); -} - - - - - -void cPacket::AppendString16(AString & a_Dst, const AString & a_String) -{ - AppendShort(a_Dst, (unsigned short)a_String.size()); - AString UTF16; - UTF16.resize(a_String.size() * sizeof(short)); - for( unsigned int i = 0; i < a_String.size(); ++i ) - { - UTF16[i * sizeof( short )] = 0x00; - UTF16[i * sizeof( short ) + 1] = a_String[i]; - } - a_Dst.append(UTF16.data(), a_String.size() * sizeof(short)); -} - - - - - -void cPacket::AppendShort(AString & a_Dst, short a_Short) -{ - short ConvertedShort = htons( a_Short ); - a_Dst.append((const char *)&ConvertedShort, sizeof(short)); -} - - - - - -void cPacket::AppendShort(AString & a_Dst, unsigned short a_Short) -{ - short ConvertedShort = htons( a_Short ); - a_Dst.append((const char *)&ConvertedShort, sizeof(short)); -} - - - - - -void cPacket::AppendInteger(AString & a_Dst, int a_Integer) -{ - int ConvertedInt = htonl( a_Integer ); - a_Dst.append((const char *)&ConvertedInt, sizeof(int)); -} - - - - - -void cPacket::AppendInteger(AString & a_Dst, unsigned int a_Integer) -{ - unsigned int ConvertedInt = htonl( a_Integer ); - a_Dst.append((const char *)&ConvertedInt, sizeof(int)); -} - - - - - -void cPacket::AppendFloat(AString & a_Dst, float a_Float) -{ - unsigned int ConvertedFloat = HostToNetwork4(&a_Float); - a_Dst.append((const char *)&ConvertedFloat, sizeof(int)); -} - - - - - -void cPacket::AppendDouble(AString & a_Dst, const double & a_Double) -{ - unsigned long long ConvertedDouble = HostToNetwork8(&a_Double); - a_Dst.append((const char *)&ConvertedDouble, 8); -} - - - - - -void cPacket::AppendByte(AString & a_Dst, char a_Byte) -{ - a_Dst.append(&a_Byte, 1); -} - - - - - -void cPacket::AppendLong(AString & a_Dst, const long long & a_Long) -{ - unsigned long long ConvertedLong = HostToNetwork8(&a_Long); - a_Dst.append((const char *)&ConvertedLong, sizeof(a_Long)); -} - - - - - -void cPacket::AppendBool(AString & a_Dst, bool a_Bool) -{ - a_Dst.append((const char *)&a_Bool, 1); -} - - - - - -void cPacket::AppendData(AString & a_Dst, const char * a_Data, unsigned int a_Size) -{ - a_Dst.append(a_Data, a_Size); -} - - - - diff --git a/source/packets/cPacket.h b/source/packets/cPacket.h deleted file mode 100644 index 580cd6771..000000000 --- a/source/packets/cPacket.h +++ /dev/null @@ -1,80 +0,0 @@ - -#pragma once - -#include "../cSocket.h" -#include "../PacketID.h" -#include "../ByteBuffer.h" - - - - - -enum -{ - PACKET_INCOMPLETE = -2, - PACKET_ERROR = -1, - PACKET_OK = 1, -} ; - - - - - -// Use this macro to simplify handling several ReadXXX in a row. It assumes that you want [a_Data, a_Size] parsed (which is true for all Parse() functions) -#define HANDLE_PACKET_READ(Proc, Var, TotalBytes) \ - { \ - if (!a_Buffer.Proc(Var)) \ - { \ - return PACKET_INCOMPLETE; \ - } \ - TotalBytes = PACKET_OK; \ - } - - - - - -class cPacket -{ -public: - cPacket() - : m_PacketID( 0 ) - {} - virtual ~cPacket() {} - - /// Called to parse the packet. Packet type has already been read and the correct packet type created. Return PACKET_INCOMPLETE for incomplete data, PACKET_ERROR for error, any positive number for success - virtual int Parse(cByteBuffer & a_Buffer) - { - // There are packets that are sent S->C only, those don't have a parsing function - UNUSED(a_Buffer); - LOGERROR("Packet type 0x%02x has no parser defined!", m_PacketID); - ASSERT(!"Unparsed packet type!"); - return PACKET_ERROR; - } - - virtual cPacket * Clone() const = 0; - - unsigned char m_PacketID; - -protected: - // These append the data into the a_Dst string: - static void AppendString ( AString & a_Dst, const AString & a_String); - static void AppendString16( AString & a_Dst, const AString & a_String); - static void AppendShort ( AString & a_Dst, short a_Short); - static void AppendShort ( AString & a_Dst, unsigned short a_Short); - static void AppendInteger ( AString & a_Dst, int a_Integer); - static void AppendInteger ( AString & a_Dst, unsigned int a_Integer); - static void AppendFloat ( AString & a_Dst, float a_Float); - static void AppendDouble ( AString & a_Dst, const double & a_Double); - static void AppendByte ( AString & a_Dst, char a_Byte); - static void AppendLong ( AString & a_Dst, const long long & a_Long); - static void AppendBool ( AString & a_Dst, bool a_Bool); - static void AppendData ( AString & a_Dst, const char * a_Data, unsigned int a_Size); -}; - -typedef std::list <cPacket*> PacketList; -typedef std::deque<cPacket *> PacketQueue; - - - - diff --git a/source/packets/cPacket_13.cpp b/source/packets/cPacket_13.cpp deleted file mode 100644 index f31c67704..000000000 --- a/source/packets/cPacket_13.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_13.h" - - - - - -int cPacket_13::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt, m_EntityID, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_ActionID, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_13.h b/source/packets/cPacket_13.h deleted file mode 100644 index c9f274b38..000000000 --- a/source/packets/cPacket_13.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "cPacket.h" - - -class cPacket_13 : public cPacket -{ -public: - enum ENUM_ACTION - { - ACTION_CROUCH = 1, - ACTION_UNCROUCH = 2, - ACTION_LEAVEBED = 3, - ACTION_STARTSPRINTING = 4, - ACTION_STOPSPRINTING = 5, - }; - - cPacket_13() - : m_EntityID( 0 ) - , m_ActionID( 0 ) - { m_PacketID = E_PACKET_ENTITY_ACTION; } - virtual cPacket* Clone() const { return new cPacket_13( *this ); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - int m_EntityID; - char m_ActionID; - - static const unsigned int c_Size = 1; -}; - - - - diff --git a/source/packets/cPacket_ArmAnim.cpp b/source/packets/cPacket_ArmAnim.cpp deleted file mode 100644 index 8d46da39f..000000000 --- a/source/packets/cPacket_ArmAnim.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_ArmAnim.h" - - - - - -int cPacket_ArmAnim::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt, m_EntityID, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_Animation, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_ArmAnim.h b/source/packets/cPacket_ArmAnim.h deleted file mode 100644 index c4f4694ce..000000000 --- a/source/packets/cPacket_ArmAnim.h +++ /dev/null @@ -1,30 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_ArmAnim : - public cPacket -{ -public: - cPacket_ArmAnim() - : m_EntityID( 0 ) - , m_Animation( 0 ) - { - m_PacketID = E_ANIMATION; - } - virtual cPacket* Clone() const { return new cPacket_ArmAnim(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - int m_EntityID; - char m_Animation; -}; - - - - diff --git a/source/packets/cPacket_BlockDig.cpp b/source/packets/cPacket_BlockDig.cpp deleted file mode 100644 index 8c7cc5955..000000000 --- a/source/packets/cPacket_BlockDig.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_BlockDig.h" - - - - - -int cPacket_BlockDig::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadChar, m_Status, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_PosX, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_PosY, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_PosZ, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_Direction, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_BlockDig.h b/source/packets/cPacket_BlockDig.h deleted file mode 100644 index 1678dcaf3..000000000 --- a/source/packets/cPacket_BlockDig.h +++ /dev/null @@ -1,37 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_BlockDig : - public cPacket -{ -public: - cPacket_BlockDig() - : m_Status( 0 ) - , m_PosX( 0 ) - , m_PosY( 0 ) - , m_PosZ( 0 ) - , m_Direction( 0 ) - { - m_PacketID = E_BLOCK_DIG; - } - - virtual cPacket* Clone() const { return new cPacket_BlockDig(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - char m_Status; - int m_PosX; - char m_PosY; - int m_PosZ; - char m_Direction; -}; - - - - diff --git a/source/packets/cPacket_BlockPlace.cpp b/source/packets/cPacket_BlockPlace.cpp deleted file mode 100644 index 6b4219a8b..000000000 --- a/source/packets/cPacket_BlockPlace.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_BlockPlace.h" -#include "cPacket_ItemData.h" - - - - - -int cPacket_BlockPlace::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt, m_PosX, TotalBytes); - HANDLE_PACKET_READ(ReadByte, m_PosY, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_PosZ, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_Direction, TotalBytes); - - cPacket_ItemData Item(m_HeldItem); - int res = Item.Parse(a_Buffer); - if (res < 0) - { - return res; - } - TotalBytes += res; - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_BlockPlace.h b/source/packets/cPacket_BlockPlace.h deleted file mode 100644 index 187abf549..000000000 --- a/source/packets/cPacket_BlockPlace.h +++ /dev/null @@ -1,38 +0,0 @@ - -#pragma once - -#include "cPacket.h" -#include "../cItem.h" - - - - - -class cPacket_BlockPlace : - public cPacket -{ -public: - cPacket_BlockPlace() - : m_PosX( 0 ) - , m_PosY( 0 ) - , m_PosZ( 0 ) - , m_Direction( 0 ) - { - m_PacketID = E_BLOCK_PLACE; - } - - virtual cPacket* Clone() const { return new cPacket_BlockPlace(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - int m_PosX; - unsigned char m_PosY; - int m_PosZ; - char m_Direction; - - cItem m_HeldItem; -} ; - - - - diff --git a/source/packets/cPacket_Chat.cpp b/source/packets/cPacket_Chat.cpp deleted file mode 100644 index b475848b0..000000000 --- a/source/packets/cPacket_Chat.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Chat.h" - - - - - -int cPacket_Chat::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEUTF16String16, m_Message, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_Chat.h b/source/packets/cPacket_Chat.h deleted file mode 100644 index ff5c70b5b..000000000 --- a/source/packets/cPacket_Chat.h +++ /dev/null @@ -1,24 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_Chat : - public cPacket -{ -public: - cPacket_Chat() { m_PacketID = E_CHAT; } - virtual cPacket* Clone() const { return new cPacket_Chat(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - AString m_Message; -}; - - - - diff --git a/source/packets/cPacket_CreativeInventoryAction.cpp b/source/packets/cPacket_CreativeInventoryAction.cpp deleted file mode 100644 index 41a45125b..000000000 --- a/source/packets/cPacket_CreativeInventoryAction.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_CreativeInventoryAction.h" -#include "cPacket_ItemData.h" - - - - - -cPacket_CreativeInventoryAction::cPacket_CreativeInventoryAction( const cPacket_CreativeInventoryAction & a_Copy ) -{ - m_PacketID = E_CREATIVE_INVENTORY_ACTION; - m_SlotNum = a_Copy.m_SlotNum; - m_ClickedItem = a_Copy.m_ClickedItem; -} - - - - - -int cPacket_CreativeInventoryAction::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEShort, m_SlotNum, TotalBytes); - - cPacket_ItemData Item(m_ClickedItem); - int res = Item.Parse(a_Buffer); - if (res < 0) - { - return res; - } - TotalBytes += res; - return TotalBytes; -} - - - - - diff --git a/source/packets/cPacket_CreativeInventoryAction.h b/source/packets/cPacket_CreativeInventoryAction.h deleted file mode 100644 index 885478496..000000000 --- a/source/packets/cPacket_CreativeInventoryAction.h +++ /dev/null @@ -1,32 +0,0 @@ - -#pragma once - -#include "cPacket.h" -#include "../cItem.h" - - - - - -class cPacket_CreativeInventoryAction : - public cPacket -{ -public: - cPacket_CreativeInventoryAction() : - m_SlotNum(0) - { - m_PacketID = E_CREATIVE_INVENTORY_ACTION; - } - - cPacket_CreativeInventoryAction( const cPacket_CreativeInventoryAction & a_Copy ); - virtual cPacket* Clone() const { return new cPacket_CreativeInventoryAction(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - short m_SlotNum; - cItem m_ClickedItem; -} ; - - - - diff --git a/source/packets/cPacket_Disconnect.cpp b/source/packets/cPacket_Disconnect.cpp deleted file mode 100644 index d1d433475..000000000 --- a/source/packets/cPacket_Disconnect.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Disconnect.h" - - - - - -int cPacket_Disconnect::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEUTF16String16, m_Reason, TotalBytes); - return TotalBytes; -} - - - - - diff --git a/source/packets/cPacket_Disconnect.h b/source/packets/cPacket_Disconnect.h deleted file mode 100644 index 77b6cf615..000000000 --- a/source/packets/cPacket_Disconnect.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_Disconnect : public cPacket -{ -public: - cPacket_Disconnect() { m_PacketID = E_DISCONNECT; } - cPacket_Disconnect(const AString & a_Reason) { m_PacketID = E_DISCONNECT; m_Reason = a_Reason; } - virtual cPacket* Clone() const { return new cPacket_Disconnect(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - AString m_Reason; - static const unsigned int c_Size = 3; // Minimum size -}; - - - - diff --git a/source/packets/cPacket_Explosion.cpp b/source/packets/cPacket_Explosion.cpp deleted file mode 100644 index d4a244c01..000000000 --- a/source/packets/cPacket_Explosion.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Explosion.h" - - - - - -cPacket_Explosion::~cPacket_Explosion() -{ - if( m_Records ) - { - delete [] m_Records; - } -} - - - - - -cPacket_Explosion::cPacket_Explosion( const cPacket_Explosion & a_Copy ) -{ - m_PacketID = E_EXPLOSION; - m_PosX = a_Copy.m_PosX; - m_PosY = a_Copy.m_PosY; - m_PosZ = a_Copy.m_PosZ; - m_Radius = a_Copy.m_Radius; //might not be radius - m_RecordsCount= a_Copy.m_RecordsCount; - - m_Records = new char[(m_RecordsCount * 3)]; - memcpy( m_Records, a_Copy.m_Records, (m_RecordsCount * 3) ); -} - - - - - -void cPacket_Explosion::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendDouble (a_Data, m_PosX); - AppendDouble (a_Data, m_PosY); - AppendDouble (a_Data, m_PosZ); - AppendFloat (a_Data, m_Radius); - AppendInteger(a_Data, m_RecordsCount); - AppendData (a_Data, m_Records, (m_RecordsCount * 3)); -} - - - - diff --git a/source/packets/cPacket_Explosion.h b/source/packets/cPacket_Explosion.h deleted file mode 100644 index 468d72fe4..000000000 --- a/source/packets/cPacket_Explosion.h +++ /dev/null @@ -1,40 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_Explosion : public cPacket -{ -public: - cPacket_Explosion() - : m_PosX( 0 ) - , m_PosY( 0 ) - , m_PosZ( 0 ) - , m_Radius( 0 ) - , m_RecordsCount( 0 ) - , m_Records( 0 ) - { m_PacketID = E_EXPLOSION; m_Records = 0; } - cPacket_Explosion( const cPacket_Explosion & a_Copy ); - ~cPacket_Explosion(); - virtual cPacket* Clone() const { return new cPacket_Explosion(*this); } - - virtual void Serialize(AString & a_Data) const; - - double m_PosX; // The entity ID of the thunderbolt - double m_PosY; // Always true. Might have a meaning in the future... - double m_PosZ; // Thunderbolt X as Absolute Integer - float m_Radius; // Thunderbolt Y as Absolute Integer - int m_RecordsCount; // Thunderbolt Z as Absolute Integer - - static const unsigned int c_Size = 1 + 8 + 8 + 8 + 4 + 4; - - char* m_Records; -}; - - - - diff --git a/source/packets/cPacket_Flying.cpp b/source/packets/cPacket_Flying.cpp deleted file mode 100644 index bc730cb5e..000000000 --- a/source/packets/cPacket_Flying.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Flying.h" - - - - - -int cPacket_Flying::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes= 0; - HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_Flying.h b/source/packets/cPacket_Flying.h deleted file mode 100644 index 52f33e7fd..000000000 --- a/source/packets/cPacket_Flying.h +++ /dev/null @@ -1,27 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_Flying : public cPacket -{ -public: - // The BS packet - cPacket_Flying() - : m_bFlying( false ) - { m_PacketID = E_FLYING; } - virtual cPacket* Clone() const { return new cPacket_Flying(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - bool m_bFlying; - static const unsigned int c_Size = 2; -}; - - - - diff --git a/source/packets/cPacket_Handshake.cpp b/source/packets/cPacket_Handshake.cpp deleted file mode 100644 index 5229cdba3..000000000 --- a/source/packets/cPacket_Handshake.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Handshake.h" - - - - - -int cPacket_Handshake::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEUTF16String16, m_Username, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_Handshake.h b/source/packets/cPacket_Handshake.h deleted file mode 100644 index 86bc8a286..000000000 --- a/source/packets/cPacket_Handshake.h +++ /dev/null @@ -1,23 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_Handshake : public cPacket -{ -public: - cPacket_Handshake() { m_PacketID = E_HANDSHAKE; } - virtual cPacket* Clone() const { return new cPacket_Handshake(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - std::string m_Username; -}; - - - - diff --git a/source/packets/cPacket_ItemData.cpp b/source/packets/cPacket_ItemData.cpp deleted file mode 100644 index 4f0803475..000000000 --- a/source/packets/cPacket_ItemData.cpp +++ /dev/null @@ -1,90 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_ItemData.h" - - - - - -int cPacket_ItemData::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEShort, m_Dst.m_ItemType, TotalBytes); - - if (m_Dst.m_ItemType <= -1) - { - m_Dst.Empty(); - return TotalBytes; - } - - HANDLE_PACKET_READ(ReadChar, m_Dst.m_ItemCount, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_Dst.m_ItemDamage, TotalBytes); - - if (cItem::IsEnchantable(m_Dst.m_ItemType)) - { - short EnchantNumBytes; - HANDLE_PACKET_READ(ReadBEShort, EnchantNumBytes, TotalBytes); - - if (EnchantNumBytes > 0) - { - // TODO: Enchantment not implemented yet! - a_Buffer.SkipRead(EnchantNumBytes); - } - } - return TotalBytes; -} - - - - - -int cPacket_ItemData::GetSize(short a_ItemID) -{ - if(a_ItemID <= -1) - return 2; - if(cItem::IsEnchantable((ENUM_ITEM_ID) a_ItemID)) - return 7; - return 5; -} - - - - - -void cPacket_ItemData::AppendItem(AString & a_Data, const cItem & a_Item) -{ - return AppendItem(a_Data, a_Item.m_ItemType, a_Item.m_ItemCount, a_Item.m_ItemDamage); -} - - - - - -void cPacket_ItemData::AppendItem(AString & a_Data, short a_ItemType, char a_Quantity, short a_Damage) -{ - short ItemType = a_ItemType; - ASSERT(ItemType >= -1); // Check validity of packets in debug runtime - if (ItemType <= 0) - { - // Fix, to make sure no invalid values are sent. - ItemType = -1; - } - - AppendShort(a_Data, ItemType); - if (a_ItemType > -1) - { - AppendByte (a_Data, a_Quantity); - AppendShort(a_Data, a_Damage); - - if (cItem::IsEnchantable(a_ItemType)) - { - // TODO: Implement enchantments - AppendShort(a_Data, (short) -1); - } - } -} - - - - diff --git a/source/packets/cPacket_ItemData.h b/source/packets/cPacket_ItemData.h deleted file mode 100644 index e1a6c547d..000000000 --- a/source/packets/cPacket_ItemData.h +++ /dev/null @@ -1,34 +0,0 @@ - -#pragma once - - -#include "cPacket.h" -#include "../cItem.h" - - - - - -class cPacket_ItemData : public cPacket -{ - cItem & m_Dst; - -public: - cPacket_ItemData(cItem & a_Dst) : - m_Dst(a_Dst) - { - } - - virtual cPacket * Clone() const { return new cPacket_ItemData(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - static void AppendItem(AString & a_Data, short a_ItemType, char a_Quantity, short a_Damage); - static void AppendItem(AString & a_Data, const cItem & a_Item); - - int GetSize(short a_ItemID); -} ; - - - - diff --git a/source/packets/cPacket_ItemSwitch.cpp b/source/packets/cPacket_ItemSwitch.cpp deleted file mode 100644 index 864214a66..000000000 --- a/source/packets/cPacket_ItemSwitch.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_ItemSwitch.h" - - - - - -int cPacket_ItemSwitch::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEShort, m_SlotNum, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_ItemSwitch.h b/source/packets/cPacket_ItemSwitch.h deleted file mode 100644 index 667b24044..000000000 --- a/source/packets/cPacket_ItemSwitch.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_ItemSwitch : public cPacket -{ -public: - cPacket_ItemSwitch() - : m_SlotNum( 0 ) - { m_PacketID = E_ITEM_SWITCH; } - virtual cPacket* Clone() const { return new cPacket_ItemSwitch(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - short m_SlotNum; -}; - - - - diff --git a/source/packets/cPacket_KeepAlive.cpp b/source/packets/cPacket_KeepAlive.cpp deleted file mode 100644 index 090e90671..000000000 --- a/source/packets/cPacket_KeepAlive.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_KeepAlive.h" - - - - - -int cPacket_KeepAlive::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt, m_KeepAliveID, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_KeepAlive.h b/source/packets/cPacket_KeepAlive.h deleted file mode 100644 index b68aa5691..000000000 --- a/source/packets/cPacket_KeepAlive.h +++ /dev/null @@ -1,24 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_KeepAlive : public cPacket -{ -public: - cPacket_KeepAlive() { m_PacketID = E_KEEP_ALIVE; } - cPacket_KeepAlive(int a_PingID) { m_KeepAliveID = a_PingID; } - virtual cPacket * Clone() const { return new cPacket_KeepAlive(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - int m_KeepAliveID; -}; - - - - diff --git a/source/packets/cPacket_Login.cpp b/source/packets/cPacket_Login.cpp deleted file mode 100644 index 017227071..000000000 --- a/source/packets/cPacket_Login.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Login.h" - - - - - -const char * cPacket_Login::LEVEL_TYPE_DEFAULT = "DEFAULT"; -const char * cPacket_Login::LEVEL_TYPE_SUPERFLAT = "SUPERFLAT"; - - - - - -int cPacket_Login::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - m_Username.clear(); - HANDLE_PACKET_READ(ReadBEInt, m_ProtocolVersion, TotalBytes); - HANDLE_PACKET_READ(ReadBEUTF16String16, m_Username, TotalBytes); - HANDLE_PACKET_READ(ReadBEUTF16String16, m_LevelType, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_ServerMode, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_Dimension, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_Difficulty, TotalBytes); - HANDLE_PACKET_READ(ReadByte, m_WorldHeight, TotalBytes); - HANDLE_PACKET_READ(ReadByte, m_MaxPlayers, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h deleted file mode 100644 index df7545edd..000000000 --- a/source/packets/cPacket_Login.h +++ /dev/null @@ -1,41 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_Login : public cPacket -{ -public: - cPacket_Login() - : m_ProtocolVersion( 0 ) - , m_ServerMode( 0 ) - , m_Dimension( 0 ) - , m_Difficulty( 0 ) - , m_WorldHeight( 0 ) - , m_MaxPlayers( 0 ) - , m_LevelType( LEVEL_TYPE_DEFAULT ) - { m_PacketID = E_LOGIN; } - virtual cPacket* Clone() const { return new cPacket_Login(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - int m_ProtocolVersion; - AString m_Username; - AString m_LevelType; - int m_ServerMode; - int m_Dimension; - char m_Difficulty; - unsigned char m_WorldHeight; - unsigned char m_MaxPlayers; - - static const char * LEVEL_TYPE_DEFAULT; - static const char * LEVEL_TYPE_SUPERFLAT; -}; - - - - diff --git a/source/packets/cPacket_MultiBlock.cpp b/source/packets/cPacket_MultiBlock.cpp deleted file mode 100644 index 68daf2700..000000000 --- a/source/packets/cPacket_MultiBlock.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_MultiBlock.h" - - - - - -cPacket_MultiBlock::cPacket_MultiBlock(const cPacket_MultiBlock & a_Copy) -{ - m_PacketID = E_MULTI_BLOCK; - m_ChunkX = a_Copy.m_ChunkX; - m_ChunkZ = a_Copy.m_ChunkZ; - m_NumBlocks = a_Copy.m_NumBlocks; - m_Data = new sBlockChange[m_NumBlocks]; - memcpy(m_Data, a_Copy.m_Data, sizeof(sBlockChange) * m_NumBlocks); -} - - - - - -cPacket_MultiBlock::~cPacket_MultiBlock() -{ - delete[] m_Data; -} - - - - - -void cPacket_MultiBlock::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_ChunkX); - AppendInteger(a_Data, m_ChunkZ); - AppendShort (a_Data, m_NumBlocks); - - AppendInteger(a_Data, sizeof(*m_Data) * m_NumBlocks); - for (short i = 0; i < m_NumBlocks; ++i) - { - AppendInteger(a_Data, m_Data[i].Data); - } -} - - - - diff --git a/source/packets/cPacket_MultiBlock.h b/source/packets/cPacket_MultiBlock.h deleted file mode 100644 index 7399fe853..000000000 --- a/source/packets/cPacket_MultiBlock.h +++ /dev/null @@ -1,43 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_MultiBlock : public cPacket -{ -public: - struct sBlockChange - { - unsigned int Data; - // short Data; // 4bits metadata ... 12bits block ID - // short Coords; // 8bits Y ... 4bits Z ... 4bits X - }; - - cPacket_MultiBlock() - : m_ChunkX( 0 ) - , m_ChunkZ( 0 ) - , m_NumBlocks( 0 ) - , m_Data( NULL ) - { - m_PacketID = E_MULTI_BLOCK; - } - - cPacket_MultiBlock(const cPacket_MultiBlock & a_Copy); - ~cPacket_MultiBlock(); - virtual cPacket* Clone() const { return new cPacket_MultiBlock(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_ChunkX; - int m_ChunkZ; - short m_NumBlocks; - sBlockChange * m_Data; // m_NumBlocks items in the array -}; - - - - diff --git a/source/packets/cPacket_Ping.h b/source/packets/cPacket_Ping.h deleted file mode 100644 index f74385a81..000000000 --- a/source/packets/cPacket_Ping.h +++ /dev/null @@ -1,24 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_Ping : public cPacket -{ -public: - cPacket_Ping() - { m_PacketID = E_PING; } - virtual cPacket* Clone() const { return new cPacket_Ping(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override {return 0; } - - static const unsigned int c_Size = 1; -}; - - - - diff --git a/source/packets/cPacket_Player.cpp b/source/packets/cPacket_Player.cpp deleted file mode 100644 index d0acc17d0..000000000 --- a/source/packets/cPacket_Player.cpp +++ /dev/null @@ -1,166 +0,0 @@ - -// cPacket_Player.cpp - -/* Implements the player-related packets: - - PlayerAbilities (0xca) - - PlayerListItem (0xc9) - - PlayerLook (0x0c) - - PlayerMoveLook (0x0d) - - PlayerPosition (0x0b) -*/ - -#include "Globals.h" - -#include "cPacket_Player.h" -#include "../cPlayer.h" -#include "../cChatColor.h" - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cPacket_PlayerAbilities: - -int cPacket_PlayerAbilities::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBool, m_Invulnerable, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_IsFlying, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_CanFly, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_InstaMine, TotalBytes); - return TotalBytes; -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cPacket_PlayerListItem: - -cPacket_PlayerListItem::cPacket_PlayerListItem(const AString & a_PlayerName, bool a_Online, short a_Ping) -{ - m_PacketID = E_PLAYER_LIST_ITEM; - m_PlayerName = a_PlayerName; - m_Online = a_Online; - m_Ping = a_Ping; -} - - - - - -int cPacket_PlayerListItem::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEUTF16String16, m_PlayerName, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_Online, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_Ping, TotalBytes); - return TotalBytes; -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cPacket_PlayerLook: - -cPacket_PlayerLook::cPacket_PlayerLook( cPlayer* a_Player ) -{ - m_PacketID = E_PLAYERLOOK; - m_Rotation = a_Player->GetRotation(); - m_Pitch = a_Player->GetPitch(); - m_IsOnGround = a_Player->IsOnGround(); -} - - - - - -int cPacket_PlayerLook::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEFloat, m_Rotation, TotalBytes); - HANDLE_PACKET_READ(ReadBEFloat, m_Pitch, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_IsOnGround, TotalBytes); - return TotalBytes; -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cPacket_PlayerMoveLook: - -cPacket_PlayerMoveLook::cPacket_PlayerMoveLook(const cPlayer & a_Player) -{ - m_PacketID = E_PLAYERMOVELOOK; - m_PosX = a_Player.GetPosX(); - m_PosY = a_Player.GetPosY() + 0.03; // Add a small amount so that the player doesn't start inside a block - m_PosZ = a_Player.GetPosZ(); - m_Stance = a_Player.GetStance() + 0.03; // Add a small amount so that the player doesn't start inside a block - m_Rotation = a_Player.GetRotation(); - m_Pitch = a_Player.GetPitch(); - m_IsOnGround = a_Player.IsOnGround(); -} - - - - - -int cPacket_PlayerMoveLook::Parse(cByteBuffer & a_Buffer) -{ - // NOTE that Stance and Y are swapped when sent C->S vs S->C - // This is the C->S case: - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEDouble, m_PosX, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_PosY, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_Stance, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_PosZ, TotalBytes); - HANDLE_PACKET_READ(ReadBEFloat, m_Rotation, TotalBytes); - HANDLE_PACKET_READ(ReadBEFloat, m_Pitch, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_IsOnGround, TotalBytes); - // LOGD("Recv PML: {%0.2f, %0.2f, %0.2f}, Stance %0.2f, Gnd: %d", m_PosX, m_PosY, m_PosZ, m_Stance, m_IsOnGround ? 1 : 0); - return TotalBytes; -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cPacket_PlayerPosition: - -cPacket_PlayerPosition::cPacket_PlayerPosition(const cPlayer & a_Player) -{ - m_PacketID = E_PLAYERPOS; - - m_PosX = a_Player.GetPosX(); - m_PosY = a_Player.GetPosY(); - m_PosZ = a_Player.GetPosZ(); - m_Stance = a_Player.GetStance(); - m_IsOnGround = a_Player.IsOnGround(); -} - - - - - -int cPacket_PlayerPosition::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEDouble, m_PosX, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_PosY, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_Stance, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_PosZ, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_IsOnGround, TotalBytes); - // LOGD("Recv PlayerPos: {%0.2f %0.2f %0.2f}, Stance %0.2f, Gnd: %d", m_PosX, m_PosY, m_PosZ, m_Stance, m_IsOnGround ? 1 : 0); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_Player.h b/source/packets/cPacket_Player.h deleted file mode 100644 index 1a647a5fc..000000000 --- a/source/packets/cPacket_Player.h +++ /dev/null @@ -1,151 +0,0 @@ - -// cPacket_Player.h - -/* Interfaces to the player-related packets: - - PlayerAbilities (0xca) - - PlayerListItem (0xc9) - - PlayerLook (0x0c) - - PlayerMoveLook (0x0d) - - PlayerPosition (0x0b) -*/ - -#pragma once - - - - - -#include "cPacket.h" - - - - - -// fwd: -class cPlayer; - - - - - -class cPacket_PlayerAbilities : public cPacket -{ -public: - cPacket_PlayerAbilities(void) { m_PacketID = E_PLAYER_LIST_ITEM; } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - virtual cPacket * Clone() const { return new cPacket_PlayerAbilities(*this); } - - bool m_Invulnerable; // Speculation - bool m_IsFlying; - bool m_CanFly; - bool m_InstaMine; // Speculation -} ; - - - - - -class cPacket_PlayerListItem : public cPacket -{ -public: - cPacket_PlayerListItem() { m_PacketID = E_PLAYER_LIST_ITEM; } - cPacket_PlayerListItem(const AString & a_PlayerName, bool a_Online, short a_Ping); - - virtual int Parse(cByteBuffer & a_Buffer) override; - - virtual cPacket* Clone() const { return new cPacket_PlayerListItem(*this); } - - AString m_PlayerName; // Supports chat coloring, limited to 16 characters. - bool m_Online; - short m_Ping; -} ; - - - - - -class cPacket_PlayerLook : public cPacket -{ -public: - cPacket_PlayerLook() - : m_Rotation( 0 ) - , m_Pitch( 0 ) - , m_IsOnGround( false ) - { - m_PacketID = E_PLAYERLOOK; - } - - cPacket_PlayerLook( cPlayer* a_Player ); - virtual cPacket* Clone() const { return new cPacket_PlayerLook(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - float m_Rotation; - float m_Pitch; - bool m_IsOnGround; -} ; - - - - - -class cPacket_PlayerMoveLook : public cPacket -{ -public: - cPacket_PlayerMoveLook() - : m_PosX( 0.0 ) - , m_PosY( 0.0 ) - , m_Stance( 0.0 ) - , m_PosZ( 0.0 ) - , m_Rotation( 0.f ) - , m_Pitch( 0.f ) - , m_IsOnGround( false ) - { - m_PacketID = E_PLAYERMOVELOOK; - } - - cPacket_PlayerMoveLook(const cPlayer & a_Player); - virtual cPacket * Clone() const { return new cPacket_PlayerMoveLook(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - double m_PosX; - double m_PosY; - double m_Stance; - double m_PosZ; - float m_Rotation; - float m_Pitch; - bool m_IsOnGround; -} ; - - - - - -class cPacket_PlayerPosition : public cPacket -{ -public: - cPacket_PlayerPosition(const cPlayer & a_Player); - cPacket_PlayerPosition() - : m_PosX( 0.0 ) - , m_PosY( 0.0 ) - , m_PosZ( 0.0 ) - , m_Stance( 0.0 ) - , m_IsOnGround(true) - { m_PacketID = E_PLAYERPOS; } - virtual cPacket* Clone() const { return new cPacket_PlayerPosition(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - double m_PosX; - double m_PosY; - double m_PosZ; - double m_Stance; - bool m_IsOnGround; -} ; - - - - diff --git a/source/packets/cPacket_Respawn.cpp b/source/packets/cPacket_Respawn.cpp deleted file mode 100644 index 0e46ea01e..000000000 --- a/source/packets/cPacket_Respawn.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Respawn.h" - - - - - -int cPacket_Respawn::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - - HANDLE_PACKET_READ(ReadBEInt, m_Dimension, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_Difficulty, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_CreativeMode, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_WorldHeight, TotalBytes); - HANDLE_PACKET_READ(ReadBEUTF16String16, m_LevelType, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_Respawn.h b/source/packets/cPacket_Respawn.h deleted file mode 100644 index 9292658e7..000000000 --- a/source/packets/cPacket_Respawn.h +++ /dev/null @@ -1,38 +0,0 @@ - -#pragma once - -#include "cPacket.h" -#include "cPacket_Login.h" - - - - - -class cPacket_Respawn : - public cPacket -{ -public: - cPacket_Respawn() - : m_Dimension(0) - , m_Difficulty(0) - , m_CreativeMode(0) - , m_WorldHeight(256) - , m_LevelType( cPacket_Login::LEVEL_TYPE_DEFAULT ) - { - m_PacketID = E_RESPAWN; - } - - virtual cPacket * Clone() const { return new cPacket_Respawn( *this ); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - int m_Dimension; - char m_Difficulty; - char m_CreativeMode; - short m_WorldHeight; - AString m_LevelType; -}; - - - - diff --git a/source/packets/cPacket_SoundEffect.cpp b/source/packets/cPacket_SoundEffect.cpp deleted file mode 100644 index efc9b8e6b..000000000 --- a/source/packets/cPacket_SoundEffect.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_SoundEffect.h" - - - - - -cPacket_SoundEffect::cPacket_SoundEffect( const cPacket_SoundEffect & a_Copy ) -{ - m_PacketID = E_SOUND_EFFECT; - m_SoundID = a_Copy.m_SoundID; - m_PosX = a_Copy.m_PosX; - m_PosY = a_Copy.m_PosY; - m_PosZ = a_Copy.m_PosZ; - m_SoundData = a_Copy.m_SoundData; -} - - - - - -void cPacket_SoundEffect::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_SoundID); - AppendInteger(a_Data, m_PosX); - AppendByte (a_Data, m_PosY); - AppendInteger(a_Data, m_PosZ); - AppendInteger(a_Data, m_SoundData); -} - - - - diff --git a/source/packets/cPacket_SoundEffect.h b/source/packets/cPacket_SoundEffect.h deleted file mode 100644 index 9293d53f0..000000000 --- a/source/packets/cPacket_SoundEffect.h +++ /dev/null @@ -1,36 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_SoundEffect : public cPacket -{ -public: - cPacket_SoundEffect() - : m_SoundID( 0 ) - , m_PosX( 0 ) - , m_PosY( 0 ) - , m_PosZ( 0 ) - , m_SoundData( 0 ) - { m_PacketID = E_SOUND_EFFECT; } - cPacket_SoundEffect( const cPacket_SoundEffect & a_Copy ); - virtual cPacket* Clone() const { return new cPacket_SoundEffect(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_SoundID; // Sound ID - int m_PosX; // Block X Coordinate - char m_PosY; // Block Y Coordinate - int m_PosZ; // Block Z Coordinate - int m_SoundData;// Extra Sound Data - - static const unsigned int c_Size = 1 + 4 + 4 + 1 + 4 + 4; -}; - - - - diff --git a/source/packets/cPacket_UpdateSign.cpp b/source/packets/cPacket_UpdateSign.cpp deleted file mode 100644 index b258fc9c3..000000000 --- a/source/packets/cPacket_UpdateSign.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_UpdateSign.h" - - - - - -int cPacket_UpdateSign::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt, m_BlockX, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_BlockY, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_BlockZ, TotalBytes); - HANDLE_PACKET_READ(ReadBEUTF16String16, m_Line1, TotalBytes); - HANDLE_PACKET_READ(ReadBEUTF16String16, m_Line2, TotalBytes); - HANDLE_PACKET_READ(ReadBEUTF16String16, m_Line3, TotalBytes); - HANDLE_PACKET_READ(ReadBEUTF16String16, m_Line4, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_UpdateSign.h b/source/packets/cPacket_UpdateSign.h deleted file mode 100644 index e7b4977b2..000000000 --- a/source/packets/cPacket_UpdateSign.h +++ /dev/null @@ -1,36 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_UpdateSign : public cPacket -{ -public: - cPacket_UpdateSign() - : m_BlockX( 0 ) - , m_BlockY( 0 ) - , m_BlockZ( 0 ) - { - m_PacketID = E_UPDATE_SIGN; - } - - virtual cPacket * Clone() const { return new cPacket_UpdateSign( *this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - int m_BlockX; - short m_BlockY; - int m_BlockZ; - AString m_Line1; - AString m_Line2; - AString m_Line3; - AString m_Line4; -}; - - - - diff --git a/source/packets/cPacket_UseEntity.cpp b/source/packets/cPacket_UseEntity.cpp deleted file mode 100644 index 9ecb3bffc..000000000 --- a/source/packets/cPacket_UseEntity.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_UseEntity.h" - - - - - -int cPacket_UseEntity::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt, m_SourceEntityID, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_TargetEntityID, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_IsLeftClick, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_UseEntity.h b/source/packets/cPacket_UseEntity.h deleted file mode 100644 index ff33ccd93..000000000 --- a/source/packets/cPacket_UseEntity.h +++ /dev/null @@ -1,33 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_UseEntity : - public cPacket -{ -public: - cPacket_UseEntity() - : m_SourceEntityID(0) - , m_TargetEntityID(0) - , m_IsLeftClick(false) - { - m_PacketID = E_USE_ENTITY; - } - - virtual cPacket * Clone() const { return new cPacket_UseEntity(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - int m_SourceEntityID; - int m_TargetEntityID; - bool m_IsLeftClick; -}; - - - - diff --git a/source/packets/cPacket_WindowClick.cpp b/source/packets/cPacket_WindowClick.cpp deleted file mode 100644 index a0a7afbda..000000000 --- a/source/packets/cPacket_WindowClick.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_WindowClick.h" -#include "cPacket_ItemData.h" - - - - - -int cPacket_WindowClick::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadChar, m_WindowID, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_SlotNum, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_IsRightClick, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_TransactionID, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_IsShiftPressed, TotalBytes); - - cPacket_ItemData Item(m_HeldItem); - int res = Item.Parse(a_Buffer); - if (res < 0) - { - return res; - } - TotalBytes += res; - - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_WindowClick.h b/source/packets/cPacket_WindowClick.h deleted file mode 100644 index e0f6f964e..000000000 --- a/source/packets/cPacket_WindowClick.h +++ /dev/null @@ -1,39 +0,0 @@ - -#pragma once - -#include "cPacket.h" -#include "../cItem.h" - - - - - -class cPacket_WindowClick : public cPacket // [C -> S] -{ -public: - cPacket_WindowClick() - : m_WindowID( 0 ) - , m_SlotNum( 0 ) - , m_IsRightClick(false) - , m_TransactionID( 0 ) - , m_IsShiftPressed( false ) - { - m_PacketID = E_WINDOW_CLICK; - } - - virtual cPacket* Clone() const { return new cPacket_WindowClick(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - char m_WindowID; - short m_SlotNum; - bool m_IsRightClick; - short m_TransactionID; - bool m_IsShiftPressed; // Shift pressed when clicked? - - cItem m_HeldItem; -}; - - - - diff --git a/source/packets/cPacket_WindowClose.cpp b/source/packets/cPacket_WindowClose.cpp deleted file mode 100644 index f1280ae28..000000000 --- a/source/packets/cPacket_WindowClose.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_WindowClose.h" - - - - - -int cPacket_WindowClose::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadChar, m_WindowID, TotalBytes); - return TotalBytes; -} - - - - diff --git a/source/packets/cPacket_WindowClose.h b/source/packets/cPacket_WindowClose.h deleted file mode 100644 index 0851fa20d..000000000 --- a/source/packets/cPacket_WindowClose.h +++ /dev/null @@ -1,28 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_WindowClose : public cPacket -{ -public: - cPacket_WindowClose() - : m_WindowID( 0 ) - { - m_PacketID = E_WINDOW_CLOSE; - } - - virtual cPacket* Clone() const { return new cPacket_WindowClose(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - - char m_WindowID; -}; - - - - |