fix: remove byte type alias

This commit is contained in:
Tropical
2026-03-06 05:03:37 -06:00
parent 09eae49d21
commit 15af35eef2
208 changed files with 700 additions and 701 deletions
@@ -16,8 +16,8 @@ void AddEntityPacket::_init(shared_ptr<Entity> e, int type, int data, int xp, in
x = xp;//(int) floor(e->x * 32);
y = yp;//(int) floor(e->y * 32);
z = zp;//(int) floor(e->z * 32);
yRot = static_cast<byte>(yRotp);
xRot = static_cast<byte>(xRotp);
yRot = static_cast<uint8_t>(yRotp);
xRot = static_cast<uint8_t>(xRotp);
this->type = type;
this->data = data;
if (data > -1) // 4J - changed "no data" value to be -1, we can have a valid entity id of 0
@@ -79,7 +79,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->writeByte(static_cast<byte>(type));
dos->writeByte(static_cast<uint8_t>(type));
#ifdef _LARGE_WORLDS
dos->writeInt(x);
dos->writeInt(y);
@@ -37,7 +37,7 @@ public:
int xa, ya, za;
int type;
int data;
byte yRot,xRot; // 4J added
uint8_t yRot,xRot; // 4J added
private:
void _init(shared_ptr<Entity> e, int type, int data, int xp, int yp, int zp, int yRotp, int xRotp );
@@ -48,7 +48,7 @@ void AddGlobalEntityPacket::read(DataInputStream *dis) // throws IOException
void AddGlobalEntityPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeInt(id);
dos->writeByte(static_cast<byte>(type));
dos->writeByte(static_cast<uint8_t>(type));
dos->writeInt(x);
dos->writeInt(y);
dos->writeInt(z);
@@ -14,8 +14,8 @@ AddMobPacket::AddMobPacket()
x = 0;
y = 0;
z = 0;
yRot = static_cast<byte>(0);
xRot = static_cast<byte>(0);
yRot = static_cast<uint8_t>(0);
xRot = static_cast<uint8_t>(0);
entityData = nullptr;
unpack = NULL;
}
@@ -36,12 +36,12 @@ AddMobPacket::AddMobPacket(shared_ptr<Mob> mob, int yRotp, int xRotp, int xp, in
y = yp;//Mth::floor(mob->y * 32);
z = zp;//Mth::floor(mob->z * 32);
// 4J - changed - send current "previously sent" value of rotations to put this in sync with other clients
yRot = static_cast<byte>(yRotp);
xRot = static_cast<byte>(xRotp);
yHeadRot = static_cast<byte>(yHeadRotp);
// yRot = (byte) (mob->yRot * 256 / 360);
// xRot = (byte) (mob->xRot * 256 / 360);
// yHeadRot = (byte) (mob->yHeadRot * 256 / 360);
yRot = static_cast<uint8_t>(yRotp);
xRot = static_cast<uint8_t>(xRotp);
yHeadRot = static_cast<uint8_t>(yHeadRotp);
// yRot = (uint8_t) (mob->yRot * 256 / 360);
// xRot = (uint8_t) (mob->xRot * 256 / 360);
// yHeadRot = (uint8_t) (mob->yHeadRot * 256 / 360);
// From SetEntityMotionpacket
double m = 3.9;
@@ -91,7 +91,7 @@ void AddMobPacket::read(DataInputStream *dis) //throws IOException
void AddMobPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeShort(id);
dos->writeByte(static_cast<byte>(type & 0xff));
dos->writeByte(static_cast<uint8_t>(type & 0xff));
#ifdef _LARGE_WORLDS
dos->writeInt(x);
dos->writeInt(y);
@@ -13,7 +13,7 @@ public:
int type;
int x, y, z;
int xd, yd, zd;
byte yRot, xRot, yHeadRot;
uint8_t yRot, xRot, yHeadRot;
private:
shared_ptr<SynchedEntityData> entityData;
@@ -44,9 +44,9 @@ AddPlayerPacket::AddPlayerPacket(shared_ptr<Player> player, PlayerUID xuid, Play
// 4J - changed - send current "previously sent" value of rotations to put this in sync with other clients
yRot = yRotp;
xRot = xRotp;
yHeadRot = static_cast<byte>(yHeadRotp); // 4J Added
// yRot = (byte) (player->yRot * 256 / 360);
// xRot = (byte) (player->xRot * 256 / 360);
yHeadRot = static_cast<uint8_t>(yHeadRotp); // 4J Added
// yRot = (uint8_t) (player->yRot * 256 / 360);
// xRot = (uint8_t) (player->xRot * 256 / 360);
//printf("%d: New add player (%f,%f,%f) : (%d,%d,%d) : xRot %d, yRot %d\n",id,player->x,player->y,player->z,x,y,z,xRot,yRot);
@@ -96,13 +96,13 @@ void AddPlayerPacket::write(DataOutputStream *dos) //throws IOException
dos->writeInt(x);
dos->writeInt(y);
dos->writeInt(z);
dos->writeByte(static_cast<byte>(yRot));
dos->writeByte(static_cast<byte>(xRot));
dos->writeByte(static_cast<byte>(m_playerIndex)); // 4J Added
dos->writeByte(static_cast<uint8_t>(yRot));
dos->writeByte(static_cast<uint8_t>(xRot));
dos->writeByte(static_cast<uint8_t>(m_playerIndex)); // 4J Added
dos->writeShort(carriedItem);
dos->writePlayerUID(xuid);
dos->writePlayerUID(OnlineXuid);
dos->writeByte(static_cast<byte>(m_playerIndex)); // 4J Added
dos->writeByte(static_cast<uint8_t>(m_playerIndex)); // 4J Added
dos->writeInt(m_skinId);
dos->writeInt(m_capeId);
dos->writeInt(m_uiGamePrivileges);
@@ -117,7 +117,7 @@ void AddPlayerPacket::handle(PacketListener *listener)
int AddPlayerPacket::getEstimatedSize()
{
int iSize= sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(BYTE) + sizeof(BYTE) +sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + sizeof(int) + sizeof(BYTE) + sizeof(unsigned int) + sizeof(byte);
int iSize= sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(BYTE) + sizeof(BYTE) +sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + sizeof(int) + sizeof(BYTE) + sizeof(unsigned int) + sizeof(uint8_t);
if( entityData != NULL )
{
@@ -25,7 +25,7 @@ public:
DWORD m_skinId; // 4J Added
DWORD m_capeId; // 4J Added
unsigned int m_uiGamePrivileges; // 4J Added
byte yHeadRot; // 4J Added
uint8_t yHeadRot; // 4J Added
AddPlayerPacket();
~AddPlayerPacket();
@@ -28,7 +28,7 @@ void AnimatePacket::read(DataInputStream *dis) //throws IOException
void AnimatePacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(id);
dos->writeByte(static_cast<byte>(action));
dos->writeByte(static_cast<uint8_t>(action));
}
void AnimatePacket::handle(PacketListener *listener)
@@ -16,7 +16,7 @@ AwardStatPacket::AwardStatPacket(int statId, int count)
{
this->statId = statId;
this->m_paramData.data = (byte *) new int(count);
this->m_paramData.data = (uint8_t *) new int(count);
this->m_paramData.length = sizeof(int);
}
@@ -21,10 +21,10 @@ ChunkTilesUpdatePacket::ChunkTilesUpdatePacket()
shouldDelay = true;
xc = 0;
zc = 0;
count = (byte)0;
count = (uint8_t)0;
}
ChunkTilesUpdatePacket::ChunkTilesUpdatePacket(int xc, int zc, shortArray positions, byte count, Level *level)
ChunkTilesUpdatePacket::ChunkTilesUpdatePacket(int xc, int zc, shortArray positions, uint8_t count, Level *level)
{
shouldDelay = true;
this->xc = xc;
@@ -35,15 +35,15 @@ ChunkTilesUpdatePacket::ChunkTilesUpdatePacket(int xc, int zc, shortArray positi
this->blocks = byteArray((unsigned int)count);
this->data = byteArray((unsigned int)count);
LevelChunk *levelChunk = level->getChunk(xc, zc);
for (int i = 0; (byte)i < count; i++)
for (int i = 0; (uint8_t)i < count; i++)
{
int x = (positions[i] >> 12) & 15;
int z = (positions[i] >> 8) & 15;
int y = (positions[i]) & 255;
this->positions[i] = positions[i];
blocks[i] = (byte) levelChunk->getTile(x, y, z);
data[i] = (byte) levelChunk->getData(x, y, z);
blocks[i] = (uint8_t) levelChunk->getTile(x, y, z);
data[i] = (uint8_t) levelChunk->getData(x, y, z);
}
levelIdx = ( ( level->dimension->id == 0 ) ? 0 : ( (level->dimension->id == -1) ? 1 : 2 ) );
}
@@ -66,14 +66,14 @@ void ChunkTilesUpdatePacket::read(DataInputStream *dis) //throws IOException
int countAndFlags = (int)dis->readByte();
bool dataAllZero = (( countAndFlags & 0x80 ) == 0x80 );
levelIdx = ( countAndFlags >> 5 ) & 3;
count = (byte)countAndFlags & (byte)0x1f;
count = (uint8_t)countAndFlags & (uint8_t)0x1f;
positions = shortArray((short int)count);
blocks = byteArray((unsigned int)count);
data = byteArray((unsigned int)count);
int currentBlockType = -1;
for( int i = 0; (byte)i < count; i++ )
for( int i = 0; (uint8_t)i < count; i++ )
{
int xzAndFlag = dis->readShort();
int y = (int)dis->readByte();
@@ -82,14 +82,14 @@ void ChunkTilesUpdatePacket::read(DataInputStream *dis) //throws IOException
{
currentBlockType = dis->read();
}
blocks[i] = (byte)currentBlockType;
blocks[i] = (uint8_t)currentBlockType;
if( !dataAllZero)
{
data[i] = (byte)dis->read();
data[i] = (uint8_t)dis->read();
}
else
{
data[i] = (byte)0;
data[i] = (uint8_t)0;
}
}
}
@@ -12,12 +12,12 @@ public:
shortArray positions;
byteArray blocks;
byteArray data;
byte count; // 4J Was int but never has a value higher than 10
uint8_t count; // 4J Was int but never has a value higher than 10
int levelIdx;
ChunkTilesUpdatePacket();
~ChunkTilesUpdatePacket();
ChunkTilesUpdatePacket(int xc, int zc, shortArray positions, byte count, Level *level);
ChunkTilesUpdatePacket(int xc, int zc, shortArray positions, uint8_t count, Level *level);
virtual void read(DataInputStream *dis);
virtual void write(DataOutputStream *dos);
@@ -19,7 +19,7 @@ void ClientCommandPacket::read(DataInputStream *dis)
void ClientCommandPacket::write(DataOutputStream *dos)
{
dos->writeByte((byte)action & (byte)0xff);
dos->writeByte((uint8_t)action & (uint8_t)0xff);
}
void ClientCommandPacket::handle(PacketListener *listener)
@@ -42,7 +42,7 @@ void ComplexItemDataPacket::write(DataOutputStream *dos) //throws IOException
dos->writeShort(itemId);
dos->writeShort(data.length);
byteArray ba( (byte*)data.data, data.length );
byteArray ba( (uint8_t*)data.data, data.length );
dos->write(ba);
}
@@ -34,9 +34,9 @@ void ContainerAckPacket::read(DataInputStream *dis) //throws IOException
void ContainerAckPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((byte)containerId);
dos->writeByte((uint8_t)containerId);
dos->writeShort(uid);
dos->writeByte((byte)(accepted ? 1 : 0));
dos->writeByte((uint8_t)(accepted ? 1 : 0));
}
int ContainerAckPacket::getEstimatedSize()
@@ -30,8 +30,8 @@ void ContainerButtonClickPacket::read(DataInputStream *dis)
void ContainerButtonClickPacket::write(DataOutputStream *dos)
{
dos->writeByte((byte)containerId);
dos->writeByte((byte)buttonId);
dos->writeByte((uint8_t)containerId);
dos->writeByte((uint8_t)buttonId);
}
int ContainerButtonClickPacket::getEstimatedSize()
@@ -50,9 +50,9 @@ void ContainerClickPacket::read(DataInputStream *dis) //throws IOException
void ContainerClickPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeByte((byte)containerId);
dos->writeByte((uint8_t)containerId);
dos->writeShort(slotNum);
dos->writeByte((byte)buttonNum);
dos->writeByte((uint8_t)buttonNum);
dos->writeShort(uid);
dos->writeBoolean(quickKey);
@@ -28,7 +28,7 @@ void ContainerClosePacket::read(DataInputStream *dis) //throws IOException
void ContainerClosePacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((byte)containerId);
dos->writeByte((uint8_t)containerId);
}
int ContainerClosePacket::getEstimatedSize()
@@ -28,18 +28,18 @@ void ContainerOpenPacket::handle(PacketListener *listener)
void ContainerOpenPacket::read(DataInputStream *dis) //throws IOException
{
containerId = (int)(dis->readByte() & (byte)0xff);
type = (int)(dis->readByte() & (byte)0xff);
containerId = (int)(dis->readByte() & (uint8_t)0xff);
type = (int)(dis->readByte() & (uint8_t)0xff);
title = dis->readShort();
size = (int)(dis->readByte() & (byte)0xff);
size = (int)(dis->readByte() & (uint8_t)0xff);
}
void ContainerOpenPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((byte)containerId & (byte)0xff);
dos->writeByte((byte)type & (byte)0xff);
dos->writeByte((uint8_t)containerId & (uint8_t)0xff);
dos->writeByte((uint8_t)type & (uint8_t)0xff);
dos->writeShort(title & 0xffff);
dos->writeByte((byte)size & (byte)0xff);
dos->writeByte((uint8_t)size & (uint8_t)0xff);
}
int ContainerOpenPacket::getEstimatedSize()
@@ -41,7 +41,7 @@ void ContainerSetContentPacket::read(DataInputStream *dis) //throws IOException
void ContainerSetContentPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((byte)containerId);
dos->writeByte((uint8_t)containerId);
dos->writeShort(items.length);
for (unsigned int i = 0; i < items.length; i++)
{
@@ -34,7 +34,7 @@ void ContainerSetDataPacket::read(DataInputStream *dis) //throws IOException
void ContainerSetDataPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeByte((byte)containerId);
dos->writeByte((uint8_t)containerId);
dos->writeShort(id);
dos->writeShort(value);
}
@@ -34,7 +34,7 @@ void ContainerSetSlotPacket::read(DataInputStream *dis) //throws IOException
{
// 4J Stu - TU-1 hotfix
// Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts
byte byteId = dis->readByte();
uint8_t byteId = dis->readByte();
containerId = *(char *)&byteId;
slot = dis->readShort();
item = readItem(dis);
@@ -42,7 +42,7 @@ void ContainerSetSlotPacket::read(DataInputStream *dis) //throws IOException
void ContainerSetSlotPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((byte)containerId);
dos->writeByte((uint8_t)containerId);
dos->writeShort(slot);
writeItem(item, dos);
}
@@ -39,9 +39,9 @@ void EntityActionAtPositionPacket::read(DataInputStream *dis) //throws IOExcepti
void EntityActionAtPositionPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(id);
dos->writeByte((byte)action);
dos->writeByte((uint8_t)action);
dos->writeInt(x);
dos->writeByte((byte)y);
dos->writeByte((uint8_t)y);
dos->writeInt(z);
}
@@ -9,10 +9,10 @@
EntityEventPacket::EntityEventPacket()
{
entityId = 0;
eventId = (byte)0;
eventId = (uint8_t)0;
}
EntityEventPacket::EntityEventPacket(int entityId, byte eventId)
EntityEventPacket::EntityEventPacket(int entityId, uint8_t eventId)
{
this->entityId = entityId;
this->eventId = eventId;
@@ -7,10 +7,10 @@ class EntityEventPacket : public Packet, public enable_shared_from_this<EntityEv
{
public:
int entityId;
byte eventId;
uint8_t eventId;
EntityEventPacket();
EntityEventPacket(int entityId, byte eventId);
EntityEventPacket(int entityId, uint8_t eventId);
virtual void read(DataInputStream *dis);
virtual void write(DataOutputStream *dos);
@@ -99,9 +99,9 @@ void ExplodePacket::write(DataOutputStream *dos) //throws IOException
int xx = tp.x-xp;
int yy = tp.y-yp;
int zz = tp.z-zp;
dos->writeByte((byte)xx);
dos->writeByte((byte)yy);
dos->writeByte((byte)zz);
dos->writeByte((uint8_t)xx);
dos->writeByte((uint8_t)yy);
dos->writeByte((uint8_t)zz);
}
}
@@ -43,8 +43,8 @@ void GameEventPacket::read(DataInputStream *dis) //throws IOException
void GameEventPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((byte)_event);
dos->writeByte((byte)param);
dos->writeByte((uint8_t)_event);
dos->writeByte((uint8_t)param);
}
void GameEventPacket::handle(PacketListener *listener)
@@ -34,7 +34,7 @@ void InteractPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeInt(source);
dos->writeInt(target);
dos->writeByte((byte)action);
dos->writeByte((uint8_t)action);
}
void InteractPacket::handle(PacketListener *listener)
@@ -28,7 +28,7 @@ void KickPlayerPacket::read(DataInputStream *dis) //throws IOException
void KickPlayerPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((byte)m_networkSmallId);
dos->writeByte((uint8_t)m_networkSmallId);
}
int KickPlayerPacket::getEstimatedSize()
@@ -28,7 +28,7 @@ void LevelEventPacket::read(DataInputStream *dis) //throws IOException
{
type = dis->readInt();
x = dis->readInt();
y = (int)(dis->readByte() & (byte)0xff);
y = (int)(dis->readByte() & (uint8_t)0xff);
z = dis->readInt();
data = dis->readInt();
}
@@ -37,7 +37,7 @@ void LevelEventPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(type);
dos->writeInt(x);
dos->writeByte((byte)(y & 0xff));
dos->writeByte((uint8_t)(y & 0xff));
dos->writeInt(z);
dos->writeInt(data);
}
@@ -144,16 +144,16 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException
}
dos->writeLong(seed);
dos->writeInt(gameType);
dos->writeByte((byte)dimension);
dos->writeByte((byte)mapHeight);
dos->writeByte((byte)maxPlayers);
dos->writeByte((uint8_t)dimension);
dos->writeByte((uint8_t)mapHeight);
dos->writeByte((uint8_t)maxPlayers);
dos->writePlayerUID(m_offlineXuid);
dos->writePlayerUID(m_onlineXuid);
dos->writeBoolean(m_friendsOnlyUGC);
dos->writeInt(m_ugcPlayersVersion);
dos->writeByte((byte)difficulty);
dos->writeByte((uint8_t)difficulty);
dos->writeInt(m_multiplayerInstanceId);
dos->writeByte((byte)m_playerIndex);
dos->writeByte((uint8_t)m_playerIndex);
dos->writeInt(m_playerSkinId);
dos->writeInt(m_playerCapeId);
dos->writeBoolean(m_isGuest);
@@ -92,11 +92,11 @@ void MoveEntityPacket::PosRot::read(DataInputStream *dis) //throws IOException
void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacket::write(dos);
dos->writeByte((byte)xa);
dos->writeByte((byte)ya);
dos->writeByte((byte)za);
dos->writeByte((byte)yRot);
dos->writeByte((byte)xRot);
dos->writeByte((uint8_t)xa);
dos->writeByte((uint8_t)ya);
dos->writeByte((uint8_t)za);
dos->writeByte((uint8_t)yRot);
dos->writeByte((uint8_t)xRot);
}
int MoveEntityPacket::PosRot::getEstimatedSize()
@@ -126,9 +126,9 @@ void MoveEntityPacket::Pos::read(DataInputStream *dis) //throws IOException
void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacket::write(dos);
dos->writeByte((byte)xa);
dos->writeByte((byte)ya);
dos->writeByte((byte)za);
dos->writeByte((uint8_t)xa);
dos->writeByte((uint8_t)ya);
dos->writeByte((uint8_t)za);
}
int MoveEntityPacket::Pos::getEstimatedSize()
@@ -158,8 +158,8 @@ void MoveEntityPacket::Rot::read(DataInputStream *dis) //throws IOException
void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacket::write(dos);
dos->writeByte((byte)yRot);
dos->writeByte((byte)xRot);
dos->writeByte((uint8_t)yRot);
dos->writeByte((uint8_t)xRot);
}
int MoveEntityPacket::Rot::getEstimatedSize()
@@ -146,7 +146,7 @@ void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOExcepti
short idAndY = id | ya << 11;
dos->writeShort(idAndY);
char XandZ = ( xa << 4 ) | ( za & 0x0f );
dos->writeByte((byte)XandZ);
dos->writeByte((uint8_t)XandZ);
}
int MoveEntityPacketSmall::Pos::getEstimatedSize()
@@ -27,7 +27,7 @@ PlayerAbilitiesPacket::PlayerAbilitiesPacket(Abilities *abilities)
void PlayerAbilitiesPacket::read(DataInputStream *dis)
{
byte bitfield = dis->readByte();
uint8_t bitfield = dis->readByte();
this->setInvulnerable((bitfield & FLAG_INVULNERABLE) > 0);
this->setFlying((bitfield & FLAG_FLYING) > 0);
@@ -39,7 +39,7 @@ void PlayerAbilitiesPacket::read(DataInputStream *dis)
void PlayerAbilitiesPacket::write(DataOutputStream *dos)
{
byte bitfield = 0;
uint8_t bitfield = 0;
if (isInvulnerable()) bitfield |= FLAG_INVULNERABLE;
if (isFlying()) bitfield |= FLAG_FLYING;
@@ -90,7 +90,7 @@ void PreLoginPacket::write(DataOutputStream *dos) //throws IOException
dos->writeByte(m_friendsOnlyBits);
dos->writeInt(m_ugcPlayersVersion);
dos->writeByte((byte)m_dwPlayerCount);
dos->writeByte((uint8_t)m_dwPlayerCount);
for(DWORD i = 0; i < m_dwPlayerCount; ++i)
{
dos->writePlayerUID( m_playerXuids[i] );
@@ -13,7 +13,7 @@ RemoveMobEffectPacket::RemoveMobEffectPacket()
RemoveMobEffectPacket::RemoveMobEffectPacket(int entityId, MobEffectInstance *effect)
{
this->entityId = entityId;
this->effectId = (byte) (effect->getId() & 0xff);
this->effectId = (uint8_t) (effect->getId() & 0xff);
}
void RemoveMobEffectPacket::read(DataInputStream *dis)
@@ -7,7 +7,7 @@ class ServerAuthDataPacket : public Packet
#if 0
private String serverId;
private PublicKey publicKey;
private byte[] nonce = new byte[]{};
private byte[] nonce = new uint8_t[]{};
public ServerAuthDataPacket() {
// Needed
@@ -5,8 +5,8 @@
class SharedKeyPacket : public Packet
{
#if 0
private byte[] keybytes = new byte[]{};
private byte[] nonce = new byte[]{};
private byte[] keybytes = new uint8_t[]{};
private byte[] nonce = new uint8_t[]{};
private SecretKey secretKey;
@@ -62,8 +62,8 @@ int SignUpdatePacket::getEstimatedSize()
l+=sizeof(int);
l+=sizeof(short);
l+=sizeof(int);
l+=sizeof(byte);
l+=sizeof(byte);
l+=sizeof(uint8_t);
l+=sizeof(uint8_t);
for (int i = 0; i < MAX_SIGN_LINES; i++)
l += (int)lines[i].length();
@@ -23,11 +23,11 @@ TeleportEntityPacket::TeleportEntityPacket(shared_ptr<Entity> e)
x = Mth::floor(e->x * 32);
y = Mth::floor(e->y * 32);
z = Mth::floor(e->z * 32);
yRot = (byte) (e->yRot * 256 / 360);
xRot = (byte) (e->xRot * 256 / 360);
yRot = (uint8_t) (e->yRot * 256 / 360);
xRot = (uint8_t) (e->xRot * 256 / 360);
}
TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, byte yRot, byte xRot)
TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, uint8_t yRot, uint8_t xRot)
{
this->id = id;
this->x = x;
@@ -49,8 +49,8 @@ void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException
y = dis->readShort();
z = dis->readShort();
#endif
yRot = (byte) dis->read();
xRot = (byte) dis->read();
yRot = (uint8_t) dis->read();
xRot = (uint8_t) dis->read();
}
void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException
@@ -8,11 +8,11 @@ class TeleportEntityPacket : public Packet, public enable_shared_from_this<Telep
public:
int id;
int x, y, z;
byte yRot, xRot;
uint8_t yRot, xRot;
TeleportEntityPacket();
TeleportEntityPacket(shared_ptr<Entity> e);
TeleportEntityPacket(int id, int x, int y, int z, byte yRot, byte xRot);
TeleportEntityPacket(int id, int x, int y, int z, uint8_t yRot, uint8_t xRot);
virtual void read(DataInputStream *dis);
virtual void write(DataOutputStream *dos);
@@ -50,7 +50,7 @@ void TileEntityDataPacket::write(DataOutputStream *dos)
dos->writeInt(x);
dos->writeShort(y);
dos->writeInt(z);
dos->writeByte((byte) type);
dos->writeByte((uint8_t) type);
writeNbt(tag, dos);
}
+7 -7
View File
@@ -11,7 +11,7 @@
// link, the end (0 or 1) is passed as a parameter to the ctor.
CRITICAL_SECTION Socket::s_hostQueueLock[2];
std::queue<byte> Socket::s_hostQueue[2];
std::queue<uint8_t> Socket::s_hostQueue[2];
Socket::SocketOutputStreamLocal *Socket::s_hostOutStream[2];
Socket::SocketInputStreamLocal *Socket::s_hostInStream[2];
ServerConnection *Socket::s_serverConnection = NULL;
@@ -29,7 +29,7 @@ void Socket::Initialise(ServerConnection *serverConnection)
if(TryEnterCriticalSection(&s_hostQueueLock[i]))
{
// Clear the queue
std::queue<byte> empty;
std::queue<uint8_t> empty;
std::swap( s_hostQueue[i], empty );
LeaveCriticalSection(&s_hostQueueLock[i]);
}
@@ -272,7 +272,7 @@ int Socket::SocketInputStreamLocal::read()
{
if( s_hostQueue[m_queueIdx].size() )
{
byte retval = s_hostQueue[m_queueIdx].front();
uint8_t retval = s_hostQueue[m_queueIdx].front();
s_hostQueue[m_queueIdx].pop();
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
return retval;
@@ -337,7 +337,7 @@ void Socket::SocketOutputStreamLocal::write(unsigned int b)
return;
}
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
s_hostQueue[m_queueIdx].push((byte)b);
s_hostQueue[m_queueIdx].push((uint8_t)b);
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
}
@@ -388,7 +388,7 @@ int Socket::SocketInputStreamNetwork::read()
{
if( m_socket->m_queueNetwork[m_queueIdx].size() )
{
byte retval = m_socket->m_queueNetwork[m_queueIdx].front();
uint8_t retval = m_socket->m_queueNetwork[m_queueIdx].front();
m_socket->m_queueNetwork[m_queueIdx].pop();
LeaveCriticalSection(&m_socket->m_queueLockNetwork[m_queueIdx]);
return retval;
@@ -448,8 +448,8 @@ void Socket::SocketOutputStreamNetwork::write(unsigned int b)
{
if( m_streamOpen != true ) return;
byteArray barray;
byte bb;
bb = (byte)b;
uint8_t bb;
bb = (uint8_t)b;
barray.data = &bb;
barray.length = 1;
write(barray, 0, 1);
+2 -2
View File
@@ -95,12 +95,12 @@ private:
// For local connections between the host player and the server
static CRITICAL_SECTION s_hostQueueLock[2];
static std::queue<byte> s_hostQueue[2];
static std::queue<uint8_t> s_hostQueue[2];
static SocketOutputStreamLocal *s_hostOutStream[2];
static SocketInputStreamLocal *s_hostInStream[2];
// For network connections
std::queue<byte> m_queueNetwork[2]; // For input data
std::queue<uint8_t> m_queueNetwork[2]; // For input data
CRITICAL_SECTION m_queueLockNetwork[2]; // For input data
SocketInputStreamNetwork *m_inputStream[2];
SocketOutputStreamNetwork *m_outputStream[2];