mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-08 23:22:56 +00:00
chore: switch all entity ids to dedicated ints (#86)
* switch all entity ids to dedicated ints * Increment NETWORK_PROTOCOL_VERSION to 79
This commit is contained in:
parent
28d9500eca
commit
9f37450178
|
|
@ -54,7 +54,7 @@ AddEntityPacket::AddEntityPacket(shared_ptr<Entity> e, int type, int data, int y
|
|||
|
||||
void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J JEV add throws statement
|
||||
{
|
||||
id = dis->readShort();
|
||||
id = dis->readInt();
|
||||
type = dis->readByte();
|
||||
#ifdef _LARGE_WORLDS
|
||||
x = dis->readInt();
|
||||
|
|
@ -78,7 +78,7 @@ void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J
|
|||
|
||||
void AddEntityPacket::write(DataOutputStream *dos) // throws IOException TODO 4J JEV add throws statement
|
||||
{
|
||||
dos->writeShort(id);
|
||||
dos->writeInt(id);
|
||||
dos->writeByte(type);
|
||||
#ifdef _LARGE_WORLDS
|
||||
dos->writeInt(x);
|
||||
|
|
@ -107,5 +107,5 @@ void AddEntityPacket::handle(PacketListener *listener)
|
|||
|
||||
int AddEntityPacket::getEstimatedSize()
|
||||
{
|
||||
return 11 + data > -1 ? 6 : 0;
|
||||
return (11 + data > -1 ? 6 : 0) + 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ AddMobPacket::AddMobPacket(shared_ptr<LivingEntity> mob, int yRotp, int xRotp, i
|
|||
|
||||
void AddMobPacket::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
id = dis->readShort();
|
||||
id = dis->readInt();
|
||||
type = dis->readByte() & 0xff;
|
||||
#ifdef _LARGE_WORLDS
|
||||
x = dis->readInt();
|
||||
|
|
@ -90,7 +90,7 @@ void AddMobPacket::read(DataInputStream *dis) //throws IOException
|
|||
|
||||
void AddMobPacket::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
dos->writeShort(id);
|
||||
dos->writeInt(id);
|
||||
dos->writeByte(type & 0xff);
|
||||
#ifdef _LARGE_WORLDS
|
||||
dos->writeInt(x);
|
||||
|
|
@ -127,7 +127,7 @@ int AddMobPacket::getEstimatedSize()
|
|||
// 4J Stu - This is an incoming value which we aren't currently analysing
|
||||
//size += unpack->get
|
||||
}
|
||||
return size;
|
||||
return size + 2;
|
||||
}
|
||||
|
||||
vector<shared_ptr<SynchedEntityData::DataItem> > *AddMobPacket::getUnpackedData()
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ MoveEntityPacket::MoveEntityPacket(int id)
|
|||
|
||||
void MoveEntityPacket::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
id = dis->readShort();
|
||||
id = dis->readInt();
|
||||
}
|
||||
|
||||
void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
@ -40,7 +40,7 @@ void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
|
|||
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||
DEBUG_BREAK();
|
||||
}
|
||||
dos->writeShort(static_cast<short>(id));
|
||||
dos->writeInt(static_cast<short>(id));
|
||||
}
|
||||
|
||||
void MoveEntityPacket::handle(PacketListener *listener)
|
||||
|
|
@ -50,7 +50,7 @@ void MoveEntityPacket::handle(PacketListener *listener)
|
|||
|
||||
int MoveEntityPacket::getEstimatedSize()
|
||||
{
|
||||
return 2;
|
||||
return 4;
|
||||
}
|
||||
|
||||
bool MoveEntityPacket::canBeInvalidated()
|
||||
|
|
@ -101,7 +101,7 @@ void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException
|
|||
|
||||
int MoveEntityPacket::PosRot::getEstimatedSize()
|
||||
{
|
||||
return 2+5;
|
||||
return 4+5;
|
||||
}
|
||||
|
||||
MoveEntityPacket::Pos::Pos()
|
||||
|
|
@ -133,7 +133,7 @@ void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException
|
|||
|
||||
int MoveEntityPacket::Pos::getEstimatedSize()
|
||||
{
|
||||
return 2+3;
|
||||
return 4+3;
|
||||
}
|
||||
|
||||
MoveEntityPacket::Rot::Rot()
|
||||
|
|
@ -164,5 +164,5 @@ void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException
|
|||
|
||||
int MoveEntityPacket::Rot::getEstimatedSize()
|
||||
{
|
||||
return 2+2;
|
||||
return 4+2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ MoveEntityPacketSmall::MoveEntityPacketSmall(int id)
|
|||
|
||||
void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
id = dis->readShort();
|
||||
id = dis->readInt();
|
||||
}
|
||||
|
||||
void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
@ -47,7 +47,7 @@ void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
|
|||
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||
DEBUG_BREAK();
|
||||
}
|
||||
dos->writeShort(static_cast<short>(id));
|
||||
dos->writeInt(id);
|
||||
}
|
||||
|
||||
void MoveEntityPacketSmall::handle(PacketListener *listener)
|
||||
|
|
@ -57,7 +57,7 @@ void MoveEntityPacketSmall::handle(PacketListener *listener)
|
|||
|
||||
int MoveEntityPacketSmall::getEstimatedSize()
|
||||
{
|
||||
return 2;
|
||||
return 4;
|
||||
}
|
||||
|
||||
bool MoveEntityPacketSmall::canBeInvalidated()
|
||||
|
|
@ -88,13 +88,12 @@ MoveEntityPacketSmall::PosRot::PosRot(int id, char xa, char ya, char za, char yR
|
|||
|
||||
void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
int idAndRot = dis->readShort();
|
||||
this->id = idAndRot & 0x07ff;
|
||||
this->yRot = idAndRot >> 11;
|
||||
int xAndYAndZ = (int)dis->readShort();
|
||||
this->xa = xAndYAndZ >> 11;
|
||||
this->ya = (xAndYAndZ << 21 ) >> 26;
|
||||
this->za = (xAndYAndZ << 27 ) >> 27;
|
||||
this->id = dis->readInt();
|
||||
this->yRot = dis->readChar();
|
||||
int XandYandZ = (int)dis->readShort();
|
||||
this->xa = XandYandZ >> 11;
|
||||
this->ya = (XandYandZ << 21 ) >> 26;
|
||||
this->za = (XandYandZ << 27 ) >> 27;
|
||||
}
|
||||
|
||||
void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
@ -104,15 +103,15 @@ void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOExce
|
|||
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||
DEBUG_BREAK();
|
||||
}
|
||||
short idAndRot = id | yRot << 11;
|
||||
dos->writeShort(idAndRot);
|
||||
short xAndYAndZ = ( xa << 11 ) | ( ( ya & 0x3f ) << 5 ) | ( za & 0x1f );
|
||||
dos->writeShort(xAndYAndZ);
|
||||
dos->writeInt(id);
|
||||
dos->writeChar(yRot);
|
||||
short XandYandZ = ( xa << 11 ) | ( ( ya & 0x3f ) << 5 ) | ( za & 0x1f );
|
||||
dos->writeShort(XandYandZ);
|
||||
}
|
||||
|
||||
int MoveEntityPacketSmall::PosRot::getEstimatedSize()
|
||||
{
|
||||
return 4;
|
||||
return 7;
|
||||
}
|
||||
|
||||
MoveEntityPacketSmall::Pos::Pos()
|
||||
|
|
@ -128,9 +127,8 @@ MoveEntityPacketSmall::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityP
|
|||
|
||||
void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
int idAndY = dis->readShort();
|
||||
this->id = idAndY & 0x07ff;
|
||||
this->ya = idAndY >> 11;
|
||||
this->id = dis->readInt();
|
||||
this->ya = dis->readChar();
|
||||
int XandZ = (int)static_cast<signed char>(dis->readByte());
|
||||
xa = XandZ >> 4;
|
||||
za = ( XandZ << 28 ) >> 28;
|
||||
|
|
@ -143,15 +141,15 @@ void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOExcepti
|
|||
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||
DEBUG_BREAK();
|
||||
}
|
||||
short idAndY = id | ya << 11;
|
||||
dos->writeShort(idAndY);
|
||||
dos->writeInt(id);
|
||||
dos->writeChar(ya);
|
||||
char XandZ = ( xa << 4 ) | ( za & 0x0f );
|
||||
dos->writeByte(XandZ);
|
||||
}
|
||||
|
||||
int MoveEntityPacketSmall::Pos::getEstimatedSize()
|
||||
{
|
||||
return 3;
|
||||
return 7;
|
||||
}
|
||||
|
||||
MoveEntityPacketSmall::Rot::Rot()
|
||||
|
|
@ -169,9 +167,8 @@ MoveEntityPacketSmall::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket
|
|||
|
||||
void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
int idAndRot = (int)dis->readShort();
|
||||
this->id = idAndRot & 0x07ff;
|
||||
this->yRot = idAndRot >> 11;
|
||||
this->id = dis->readInt();
|
||||
this->yRot = dis->readChar();
|
||||
}
|
||||
|
||||
void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
@ -181,11 +178,11 @@ void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOExcepti
|
|||
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||
DEBUG_BREAK();
|
||||
}
|
||||
short idAndRot = id | yRot << 11;
|
||||
dos->writeShort(idAndRot);
|
||||
dos->writeInt(id);
|
||||
dos->writeChar(yRot);
|
||||
}
|
||||
|
||||
int MoveEntityPacketSmall::Rot::getEstimatedSize()
|
||||
{
|
||||
return 2;
|
||||
return 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void RespawnPacket::read(DataInputStream *dis) //throws IOException
|
|||
mapSeed = dis->readLong();
|
||||
difficulty = dis->readByte();
|
||||
m_newSeaLevel = dis->readBoolean();
|
||||
m_newEntityId = dis->readShort();
|
||||
m_newEntityId = dis->readInt();
|
||||
#ifdef _LARGE_WORLDS
|
||||
m_xzSize = dis->readShort();
|
||||
m_hellScale = dis->read();
|
||||
|
|
@ -83,7 +83,7 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException
|
|||
dos->writeLong(mapSeed);
|
||||
dos->writeByte(difficulty);
|
||||
dos->writeBoolean(m_newSeaLevel);
|
||||
dos->writeShort(m_newEntityId);
|
||||
dos->writeInt(m_newEntityId);
|
||||
#ifdef _LARGE_WORLDS
|
||||
dos->writeShort(m_xzSize);
|
||||
dos->write(m_hellScale);
|
||||
|
|
@ -97,5 +97,5 @@ int RespawnPacket::getEstimatedSize()
|
|||
{
|
||||
length = static_cast<int>(m_pLevelType->getGeneratorName().length());
|
||||
}
|
||||
return 13+length;
|
||||
return 13+length+2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ SetEntityMotionPacket::SetEntityMotionPacket(int id, double xd, double yd, doubl
|
|||
|
||||
void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
short idAndFlag = dis->readShort();
|
||||
id = idAndFlag & 0x07ff;
|
||||
if( idAndFlag & 0x0800 )
|
||||
useBytes = dis->readBoolean();
|
||||
id = dis->readInt();
|
||||
if(useBytes)
|
||||
{
|
||||
xa = static_cast<int>(dis->readByte());
|
||||
ya = static_cast<int>(dis->readByte());
|
||||
|
|
@ -62,29 +62,28 @@ void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
|
|||
xa *= 16;
|
||||
ya *= 16;
|
||||
za *= 16;
|
||||
useBytes = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
xa = dis->readShort();
|
||||
ya = dis->readShort();
|
||||
za = dis->readShort();
|
||||
useBytes = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SetEntityMotionPacket::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
dos->writeBoolean(useBytes);
|
||||
if( useBytes )
|
||||
{
|
||||
dos->writeShort(id | 0x800);
|
||||
dos->writeInt(id);
|
||||
dos->writeByte(xa/16);
|
||||
dos->writeByte(ya/16);
|
||||
dos->writeByte(za/16);
|
||||
}
|
||||
else
|
||||
{
|
||||
dos->writeShort(id);
|
||||
dos->writeInt(id);
|
||||
dos->writeShort(xa);
|
||||
dos->writeShort(ya);
|
||||
dos->writeShort(za);
|
||||
|
|
@ -98,7 +97,7 @@ void SetEntityMotionPacket::handle(PacketListener *listener)
|
|||
|
||||
int SetEntityMotionPacket::getEstimatedSize()
|
||||
{
|
||||
return useBytes ? 5 : 8;
|
||||
return useBytes ? 8 : 11;
|
||||
}
|
||||
|
||||
bool SetEntityMotionPacket::canBeInvalidated()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class SharedConstants
|
|||
public:
|
||||
static void staticCtor();
|
||||
static const wstring VERSION_STRING;
|
||||
static const int NETWORK_PROTOCOL_VERSION = 78;
|
||||
static const int NETWORK_PROTOCOL_VERSION = 79;
|
||||
static const bool INGAME_DEBUG_OUTPUT = false;
|
||||
|
||||
// NOT texture resolution. How many sub-blocks each block face is made up of.
|
||||
|
|
@ -31,4 +31,4 @@ class SharedConstants
|
|||
static const int TICKS_PER_SECOND = 20;
|
||||
|
||||
static const int FULLBRIGHT_LIGHTVALUE = 15 << 20 | 15 << 4;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, byte yRo
|
|||
|
||||
void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
id = dis->readShort();
|
||||
id = dis->readInt();
|
||||
#ifdef _LARGE_WORLDS
|
||||
x = dis->readInt();
|
||||
y = dis->readInt();
|
||||
|
|
@ -55,7 +55,7 @@ void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException
|
|||
|
||||
void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
dos->writeShort(id);
|
||||
dos->writeInt(id);
|
||||
#ifdef _LARGE_WORLDS
|
||||
dos->writeInt(x);
|
||||
dos->writeInt(y);
|
||||
|
|
@ -76,7 +76,7 @@ void TeleportEntityPacket::handle(PacketListener *listener)
|
|||
|
||||
int TeleportEntityPacket::getEstimatedSize()
|
||||
{
|
||||
return 2 + 2 + 2 + 2 + 1 + 1;
|
||||
return 4 + 2 + 2 + 2 + 1 + 1;
|
||||
}
|
||||
|
||||
bool TeleportEntityPacket::canBeInvalidated()
|
||||
|
|
|
|||
Loading…
Reference in a new issue