Revert "Rewrote the entity movement packets to use full 16-bit signed short increasing the entity ID limit from 2048 (artifical lce limit) to 32768 ids (0 to 32767)"

This reverts commit dac0e883b6.
This commit is contained in:
MathiewMay
2026-03-11 08:39:22 -04:00
parent 047615dbbe
commit 77deb67b4a
4 changed files with 162 additions and 94 deletions

View File

@@ -19,19 +19,30 @@ MoveEntityPacketSmall::MoveEntityPacketSmall()
MoveEntityPacketSmall::MoveEntityPacketSmall(int id)
{
if( (id < 0 ) || (id >= 2048 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
}
this->id = id;
hasRot = false;
xa = ya = za = yRot = xRot = 0;
xa = 0;
ya = 0;
za = 0;
yRot = 0;
xRot = 0;
}
void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException
void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException
{
id = dis->readShort();
}
void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
{
if(id < 0 || id > 32767 )
if( (id < 0 ) || (id >= 2048 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
@@ -44,7 +55,7 @@ void MoveEntityPacketSmall::handle(PacketListener *listener)
listener->handleMoveEntitySmall(shared_from_this());
}
int MoveEntityPacketSmall::getEstimatedSize()
int MoveEntityPacketSmall::getEstimatedSize()
{
return 2;
}
@@ -75,32 +86,36 @@ MoveEntityPacketSmall::PosRot::PosRot(int id, char xa, char ya, char za, char yR
hasRot = true;
}
void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOException
void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOException
{
MoveEntityPacketSmall::read(dis);
xa = (signed char)dis->readByte();
ya = (signed char)dis->readByte();
za = (signed char)dis->readByte();
yRot = (signed char)dis->readByte();
xRot = (signed char)dis->readByte();
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;
}
void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException
void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacketSmall::write(dos);
dos->writeByte((uint8_t)(xa & 0xFF));
dos->writeByte((uint8_t)(ya & 0xFF));
dos->writeByte((uint8_t)(za & 0xFF));
dos->writeByte((uint8_t)(yRot & 0xFF));
dos->writeByte((uint8_t)(xRot & 0xFF));
if( (id < 0 ) || (id >= 2048 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
}
short idAndRot = id | yRot << 11;
dos->writeShort(idAndRot);
short xAndYAndZ = ( xa << 11 ) | ( ( ya & 0x3f ) << 5 ) | ( za & 0x1f );
dos->writeShort(xAndYAndZ);
}
int MoveEntityPacketSmall::PosRot::getEstimatedSize()
int MoveEntityPacketSmall::PosRot::getEstimatedSize()
{
return 2+5;
return 4;
}
MoveEntityPacketSmall::Pos::Pos()
MoveEntityPacketSmall::Pos::Pos()
{
}
@@ -111,28 +126,35 @@ MoveEntityPacketSmall::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityP
this->za = za;
}
void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException
void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException
{
MoveEntityPacketSmall::read(dis);
xa = (signed char)dis->readByte();
ya = (signed char)dis->readByte();
za = (signed char)dis->readByte();
int idAndY = dis->readShort();
this->id = idAndY & 0x07ff;
this->ya = idAndY >> 11;
int XandZ = (int)((signed char)(dis->readByte()));
xa = XandZ >> 4;
za = ( XandZ << 28 ) >> 28;
}
void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacketSmall::write(dos);
dos->writeByte((uint8_t)(xa & 0xFF));
dos->writeByte((uint8_t)(ya & 0xFF));
dos->writeByte((uint8_t)(za & 0xFF));
if( (id < 0 ) || (id >= 2048 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
}
short idAndY = id | ya << 11;
dos->writeShort(idAndY);
char XandZ = ( xa << 4 ) | ( za & 0x0f );
dos->writeByte((uint8_t)XandZ);
}
int MoveEntityPacketSmall::Pos::getEstimatedSize()
{
return 2+3;
return 3;
}
MoveEntityPacketSmall::Rot::Rot()
MoveEntityPacketSmall::Rot::Rot()
{
hasRot = true;
}
@@ -145,19 +167,25 @@ MoveEntityPacketSmall::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket
hasRot = true;
}
void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException
void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException
{
MoveEntityPacketSmall::read(dis);
yRot = (signed char)dis->readByte();
int idAndRot = (int)dis->readShort();
this->id = idAndRot & 0x07ff;
this->yRot = idAndRot >> 11;
}
void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException
void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacketSmall::write(dos);
dos->writeByte((uint8_t)(yRot & 0xFF));
if( (id < 0 ) || (id >= 2048 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
}
short idAndRot = id | yRot << 11;
dos->writeShort(idAndRot);
}
int MoveEntityPacketSmall::Rot::getEstimatedSize()
{
return 2+1;
return 2;
}