mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-27 01:43:37 +00:00
applied changes requested by tropicaaal
"i would prefer that these be cast to sized integer types int8_t for portability reasons." "The light layer changes are ultimately a hack over the broken renderer implementation and probably out of scope for this PR. There's an in-progress fix for the root cause of this, so this should be removed." "std::numeric_limits<int16_t>::max()"
This commit is contained in:
parent
752daaa873
commit
41d8202c47
|
|
@ -1402,7 +1402,7 @@ void GameRenderer::renderLevel(float a, __int64 until)
|
|||
#endif
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Particle render");
|
||||
//turnOnLightLayer(a); // 4J - brought forward from 1.8.2
|
||||
turnOnLightLayer(a); // 4J - brought forward from 1.8.2
|
||||
particleEngine->renderLit(cameraEntity, a);
|
||||
Lighting::turnOff();
|
||||
setupFog(0, a);
|
||||
|
|
|
|||
|
|
@ -69,24 +69,24 @@ MoveEntityPacket::PosRot::PosRot()
|
|||
hasRot = true;
|
||||
}
|
||||
|
||||
MoveEntityPacket::PosRot::PosRot(int id, char xa, char ya, char za, char yRot, char xRot) : MoveEntityPacket( id )
|
||||
MoveEntityPacket::PosRot::PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot) : MoveEntityPacket( id )
|
||||
{
|
||||
this->xa = (int)(signed char)xa;
|
||||
this->ya = (int)(signed char)ya;
|
||||
this->za = (int)(signed char)za;
|
||||
this->yRot = (int)(signed char)yRot;
|
||||
this->xRot = (int)(signed char)xRot;
|
||||
this->xa = (int)(int8_t)xa;
|
||||
this->ya = (int)(int8_t)ya;
|
||||
this->za = (int)(int8_t)za;
|
||||
this->yRot = (int)(int8_t)yRot;
|
||||
this->xRot = (int)(int8_t)xRot;
|
||||
hasRot = true;
|
||||
}
|
||||
|
||||
void MoveEntityPacket::PosRot::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
MoveEntityPacket::read(dis);
|
||||
xa = (int)(signed char)dis->readByte();
|
||||
ya = (int)(signed char)dis->readByte();
|
||||
za = (int)(signed char)dis->readByte();
|
||||
yRot = (int)(signed char)dis->readByte();
|
||||
xRot = (int)(signed char)dis->readByte();
|
||||
xa = (int)(int8_t)dis->readByte();
|
||||
ya = (int)(int8_t)dis->readByte();
|
||||
za = (int)(int8_t)dis->readByte();
|
||||
yRot = (int)(int8_t)dis->readByte();
|
||||
xRot = (int)(int8_t)dis->readByte();
|
||||
}
|
||||
|
||||
void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
@ -108,7 +108,7 @@ MoveEntityPacket::Pos::Pos()
|
|||
{
|
||||
}
|
||||
|
||||
MoveEntityPacket::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityPacket(id)
|
||||
MoveEntityPacket::Pos::Pos(int id, int8_t xa, int8_t ya, int8_t za) : MoveEntityPacket(id)
|
||||
{
|
||||
this->xa = xa;
|
||||
this->ya = ya;
|
||||
|
|
@ -118,9 +118,9 @@ MoveEntityPacket::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityPacket
|
|||
void MoveEntityPacket::Pos::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
MoveEntityPacket::read(dis);
|
||||
xa = (int)(signed char)dis->readByte();
|
||||
ya = (int)(signed char)dis->readByte();
|
||||
za = (int)(signed char)dis->readByte();
|
||||
xa = (int)(int8_t)dis->readByte();
|
||||
ya = (int)(int8_t)dis->readByte();
|
||||
za = (int)(int8_t)dis->readByte();
|
||||
}
|
||||
|
||||
void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
@ -141,7 +141,7 @@ MoveEntityPacket::Rot::Rot()
|
|||
hasRot = true;
|
||||
}
|
||||
|
||||
MoveEntityPacket::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket(id)
|
||||
MoveEntityPacket::Rot::Rot(int id, int8_t yRot, int8_t xRot) : MoveEntityPacket(id)
|
||||
{
|
||||
this->yRot = yRot;
|
||||
this->xRot = xRot;
|
||||
|
|
@ -151,8 +151,8 @@ MoveEntityPacket::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket(id)
|
|||
void MoveEntityPacket::Rot::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
MoveEntityPacket::read(dis);
|
||||
yRot = (int)(signed char)dis->readByte();
|
||||
xRot = (int)(signed char)dis->readByte();
|
||||
yRot = (int)(int8_t)dis->readByte();
|
||||
xRot = (int)(int8_t)dis->readByte();
|
||||
}
|
||||
|
||||
void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
class Rot;
|
||||
|
||||
int id;
|
||||
char xa, ya, za, yRot, xRot;
|
||||
int8_t xa, ya, za, yRot, xRot;
|
||||
bool hasRot;
|
||||
|
||||
MoveEntityPacket();
|
||||
|
|
@ -35,7 +35,7 @@ class MoveEntityPacket::PosRot : public MoveEntityPacket
|
|||
{
|
||||
public:
|
||||
PosRot();
|
||||
PosRot(int id, char xa, char ya, char za, char yRot, char xRot);
|
||||
PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot);
|
||||
|
||||
virtual void read(DataInputStream *dis);
|
||||
virtual void write(DataOutputStream *dos);
|
||||
|
|
@ -50,7 +50,7 @@ class MoveEntityPacket::Pos : public MoveEntityPacket
|
|||
{
|
||||
public:
|
||||
Pos();
|
||||
Pos(int id, char xa, char ya, char za);
|
||||
Pos(int id, int8_t xa, int8_t ya, int8_t za);
|
||||
|
||||
virtual void read(DataInputStream *dis);
|
||||
virtual void write(DataOutputStream *dos);
|
||||
|
|
@ -65,7 +65,7 @@ class MoveEntityPacket::Rot : public MoveEntityPacket
|
|||
{
|
||||
public:
|
||||
Rot();
|
||||
Rot(int id, char yRot, char xRot);
|
||||
Rot(int id, int8_t yRot, int8_t xRot);
|
||||
|
||||
virtual void read(DataInputStream *dis);
|
||||
virtual void write(DataOutputStream *dos);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include "../../IO/Streams/InputOutputStream.h"
|
||||
#include "PacketListener.h"
|
||||
#include "MoveEntityPacketSmall.h"
|
||||
|
|
@ -31,7 +32,7 @@ void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException
|
|||
|
||||
void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
if(id < 0 || id > 32767 )
|
||||
if(id < 0 || id > std::numeric_limits<int16_t>::max() )
|
||||
{
|
||||
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||
__debugbreak();
|
||||
|
|
@ -65,7 +66,7 @@ MoveEntityPacketSmall::PosRot::PosRot()
|
|||
hasRot = true;
|
||||
}
|
||||
|
||||
MoveEntityPacketSmall::PosRot::PosRot(int id, char xa, char ya, char za, char yRot, char xRot) : MoveEntityPacketSmall( id )
|
||||
MoveEntityPacketSmall::PosRot::PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot) : MoveEntityPacketSmall( id )
|
||||
{
|
||||
this->xa = xa;
|
||||
this->ya = ya;
|
||||
|
|
@ -77,22 +78,22 @@ MoveEntityPacketSmall::PosRot::PosRot(int id, char xa, char ya, char za, char yR
|
|||
|
||||
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();
|
||||
MoveEntityPacketSmall::read(dis);
|
||||
xa = (int8_t)dis->readByte();
|
||||
ya = (int8_t)dis->readByte();
|
||||
za = (int8_t)dis->readByte();
|
||||
yRot = (int8_t)dis->readByte();
|
||||
xRot = (int8_t)dis->readByte();
|
||||
}
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
int MoveEntityPacketSmall::PosRot::getEstimatedSize()
|
||||
|
|
@ -104,7 +105,7 @@ MoveEntityPacketSmall::Pos::Pos()
|
|||
{
|
||||
}
|
||||
|
||||
MoveEntityPacketSmall::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityPacketSmall(id)
|
||||
MoveEntityPacketSmall::Pos::Pos(int id, int8_t xa, int8_t ya, int8_t za) : MoveEntityPacketSmall(id)
|
||||
{
|
||||
this->xa = xa;
|
||||
this->ya = ya;
|
||||
|
|
@ -113,10 +114,10 @@ MoveEntityPacketSmall::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityP
|
|||
|
||||
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();
|
||||
MoveEntityPacketSmall::read(dis);
|
||||
xa = (int8_t)dis->readByte();
|
||||
ya = (int8_t)dis->readByte();
|
||||
za = (int8_t)dis->readByte();
|
||||
}
|
||||
|
||||
void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
@ -137,7 +138,7 @@ MoveEntityPacketSmall::Rot::Rot()
|
|||
hasRot = true;
|
||||
}
|
||||
|
||||
MoveEntityPacketSmall::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacketSmall(id)
|
||||
MoveEntityPacketSmall::Rot::Rot(int id, int8_t yRot, int8_t xRot) : MoveEntityPacketSmall(id)
|
||||
{
|
||||
|
||||
this->yRot = yRot;
|
||||
|
|
@ -147,8 +148,8 @@ MoveEntityPacketSmall::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket
|
|||
|
||||
void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
MoveEntityPacketSmall::read(dis);
|
||||
yRot = (signed char)dis->readByte();
|
||||
MoveEntityPacketSmall::read(dis);
|
||||
yRot = (int8_t)dis->readByte();
|
||||
}
|
||||
|
||||
void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ public:
|
|||
class Rot;
|
||||
|
||||
int id;
|
||||
char xa, ya, za, yRot, xRot;
|
||||
bool hasRot;
|
||||
int8_t xa, ya, za, yRot, xRot;
|
||||
bool hasRot;
|
||||
|
||||
MoveEntityPacketSmall();
|
||||
MoveEntityPacketSmall(int id);
|
||||
|
|
@ -34,8 +34,8 @@ public:
|
|||
class MoveEntityPacketSmall::PosRot : public MoveEntityPacketSmall
|
||||
{
|
||||
public:
|
||||
PosRot();
|
||||
PosRot(int id, char xa, char ya, char za, char yRot, char xRot);
|
||||
PosRot();
|
||||
PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot);
|
||||
|
||||
virtual void read(DataInputStream *dis);
|
||||
virtual void write(DataOutputStream *dos);
|
||||
|
|
@ -50,7 +50,7 @@ class MoveEntityPacketSmall::Pos : public MoveEntityPacketSmall
|
|||
{
|
||||
public:
|
||||
Pos();
|
||||
Pos(int id, char xa, char ya, char za);
|
||||
Pos(int id, int8_t xa, int8_t ya, int8_t za);
|
||||
|
||||
virtual void read(DataInputStream *dis);
|
||||
virtual void write(DataOutputStream *dos);
|
||||
|
|
@ -66,7 +66,7 @@ class MoveEntityPacketSmall::Rot : public MoveEntityPacketSmall
|
|||
{
|
||||
public:
|
||||
Rot();
|
||||
Rot(int id, char yRot, char xRot);
|
||||
Rot(int id, int8_t yRot, int8_t xRot);
|
||||
|
||||
virtual void read(DataInputStream *dis);
|
||||
virtual void write(DataOutputStream *dos);
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ void SetEntityMotionPacket::_init(int id, double xd, double yd, double zd)
|
|||
if (xd > m) xd = m;
|
||||
if (yd > m) yd = m;
|
||||
if (zd > m) zd = m;
|
||||
xa = (int) (xd * 8000.0);
|
||||
ya = (int) (yd * 8000.0);
|
||||
za = (int) (zd * 8000.0);
|
||||
xa = (int16_t) (xd * 8000.0);
|
||||
ya = (int16_t) (yd * 8000.0);
|
||||
za = (int16_t) (zd * 8000.0);
|
||||
|
||||
useBytes = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class SetEntityMotionPacket : public Packet, public std::enable_shared_from_this
|
|||
{
|
||||
public:
|
||||
int id;
|
||||
int xa, ya, za;
|
||||
int16_t xa, ya, za;
|
||||
bool useBytes; // 4J added
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ TeleportEntityPacket::TeleportEntityPacket()
|
|||
xRot = 0;
|
||||
}
|
||||
|
||||
TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr<Entity> e)
|
||||
TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr<Entity> e)
|
||||
{
|
||||
id = e->entityId;
|
||||
x = Mth::floor(e->x * 32);
|
||||
|
|
@ -27,7 +27,7 @@ TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr<Entity> e)
|
|||
xRot = (uint8_t) (e->xRot * 256 / 360);
|
||||
}
|
||||
|
||||
TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, uint8_t yRot, uint8_t xRot)
|
||||
TeleportEntityPacket::TeleportEntityPacket(int id, int32_t x, int32_t y, int32_t z, uint8_t yRot, uint8_t xRot)
|
||||
{
|
||||
this->id = id;
|
||||
this->x = x;
|
||||
|
|
@ -53,7 +53,7 @@ void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException
|
|||
xRot = (uint8_t) dis->read();
|
||||
}
|
||||
|
||||
void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException
|
||||
void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
dos->writeShort((short)id);
|
||||
dos->writeInt(x);
|
||||
|
|
@ -63,12 +63,12 @@ void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException
|
|||
dos->write(xRot);
|
||||
}
|
||||
|
||||
void TeleportEntityPacket::handle(PacketListener *listener)
|
||||
void TeleportEntityPacket::handle(PacketListener *listener)
|
||||
{
|
||||
listener->handleTeleportEntity(shared_from_this());
|
||||
}
|
||||
|
||||
int TeleportEntityPacket::getEstimatedSize()
|
||||
int TeleportEntityPacket::getEstimatedSize()
|
||||
{
|
||||
return 2 + 2 + 2 + 2 + 1 + 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,19 +7,19 @@ class TeleportEntityPacket : public Packet, public std::enable_shared_from_this<
|
|||
{
|
||||
public:
|
||||
int id;
|
||||
int x, y, z;
|
||||
uint8_t yRot, xRot;
|
||||
int32_t x, y, z;
|
||||
uint8_t yRot, xRot;
|
||||
|
||||
TeleportEntityPacket();
|
||||
TeleportEntityPacket(std::shared_ptr<Entity> e);
|
||||
TeleportEntityPacket(int id, int x, int y, int z, uint8_t yRot, uint8_t xRot);
|
||||
TeleportEntityPacket(int id, int32_t x, int32_t y, int32_t z, uint8_t yRot, uint8_t xRot);
|
||||
|
||||
virtual void read(DataInputStream *dis);
|
||||
virtual void write(DataOutputStream *dos);
|
||||
virtual void handle(PacketListener *listener);
|
||||
virtual int getEstimatedSize();
|
||||
virtual bool canBeInvalidated();
|
||||
virtual bool isInvalidatedBy(std::shared_ptr<Packet> packet);
|
||||
virtual bool isInvalidatedBy(std::shared_ptr<Packet> packet);
|
||||
|
||||
public:
|
||||
static std::shared_ptr<Packet> create() { return std::shared_ptr<Packet>(new TeleportEntityPacket()); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue