mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Merge pull request #1407 from ZappoMan/bugfixes
fix expectedBytes() mismatch between edit packets and normal packets
This commit is contained in:
commit
2fb4eeeb08
2 changed files with 15 additions and 1 deletions
|
@ -115,6 +115,19 @@ int Particle::expectedBytes() {
|
|||
return expectedBytes;
|
||||
}
|
||||
|
||||
int Particle::expectedEditMessageBytes() {
|
||||
int expectedBytes = sizeof(uint32_t) // id
|
||||
+ sizeof(float) // radius
|
||||
+ sizeof(glm::vec3) // position
|
||||
+ sizeof(rgbColor) // color
|
||||
+ sizeof(glm::vec3) // velocity
|
||||
+ sizeof(glm::vec3) // gravity
|
||||
+ sizeof(float) // damping
|
||||
+ sizeof(bool); // inhand
|
||||
// potentially more...
|
||||
return expectedBytes;
|
||||
}
|
||||
|
||||
int Particle::readParticleDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args) {
|
||||
int bytesRead = 0;
|
||||
if (bytesLeftToRead >= expectedBytes()) {
|
||||
|
@ -308,7 +321,7 @@ bool Particle::encodeParticleEditMessageDetails(PACKET_TYPE command, int count,
|
|||
|
||||
int octets = numberOfThreeBitSectionsInCode(octcode);
|
||||
int lengthOfOctcode = bytesRequiredForCodeLength(octets);
|
||||
int lenfthOfEditData = lengthOfOctcode + expectedBytes();
|
||||
int lenfthOfEditData = lengthOfOctcode + expectedEditMessageBytes();
|
||||
|
||||
// make sure we have room to copy this particle
|
||||
if (sizeOut + lenfthOfEditData > sizeIn) {
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
bool appendParticleData(OctreePacketData* packetData) const;
|
||||
int readParticleDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args);
|
||||
static int expectedBytes();
|
||||
static int expectedEditMessageBytes();
|
||||
|
||||
static bool encodeParticleEditMessageDetails(PACKET_TYPE command, int count, const ParticleDetail* details,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut);
|
||||
|
|
Loading…
Reference in a new issue