diff --git a/Engine/source/T3D/fx/particle.cpp b/Engine/source/T3D/fx/particle.cpp index 891f9353b..2e331fb7f 100644 --- a/Engine/source/T3D/fx/particle.cpp +++ b/Engine/source/T3D/fx/particle.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- #include "particle.h" #include "console/consoleTypes.h" +#include "console/typeValidators.h" #include "core/stream/bitStream.h" #include "math/mRandom.h" #include "math/mathIO.h" @@ -132,13 +133,13 @@ ParticleData::~ParticleData() //----------------------------------------------------------------------------- void ParticleData::initPersistFields() { - addField( "dragCoefficient", TYPEID< F32 >(), Offset(dragCoefficient, ParticleData), + addFieldV( "dragCoefficient", TYPEID< F32 >(), Offset(dragCoefficient, ParticleData), new FRangeValidator(0, 5), "Particle physics drag amount." ); addField( "windCoefficient", TYPEID< F32 >(), Offset(windCoefficient, ParticleData), "Strength of wind on the particles." ); - addField( "gravityCoefficient", TYPEID< F32 >(), Offset(gravityCoefficient, ParticleData), + addFieldV( "gravityCoefficient", TYPEID< F32 >(), Offset(gravityCoefficient, ParticleData), new FRangeValidator(-10, 10), "Strength of gravity on the particles." ); - addField( "inheritedVelFactor", TYPEID< F32 >(), Offset(inheritedVelFactor, ParticleData), + addFieldV( "inheritedVelFactor", TYPEID< F32 >(), Offset(inheritedVelFactor, ParticleData), &CommonValidators::NormalizedFloat, "Amount of emitter velocity to add to particle initial velocity." ); addField( "constantAcceleration", TYPEID< F32 >(), Offset(constantAcceleration, ParticleData), "Constant acceleration to apply to this particle." ); diff --git a/Engine/source/T3D/gameBase/gameConnectionEvents.cpp b/Engine/source/T3D/gameBase/gameConnectionEvents.cpp index 37a8167ac..04919cf8f 100644 --- a/Engine/source/T3D/gameBase/gameConnectionEvents.cpp +++ b/Engine/source/T3D/gameBase/gameConnectionEvents.cpp @@ -328,9 +328,9 @@ void Sim3DAudioEvent::pack(NetConnection *con, BitStream *bstream) AssertFatal((1.0 - ((q.x * q.x) + (q.y * q.y) + (q.z * q.z))) >= (0.0 - 0.001), "QuatF::normalize() is broken in Sim3DAudioEvent"); - bstream->writeFloat(q.x,SoundRotBits); - bstream->writeFloat(q.y,SoundRotBits); - bstream->writeFloat(q.z,SoundRotBits); + bstream->writeSignedFloat(q.x,SoundRotBits); + bstream->writeSignedFloat(q.y,SoundRotBits); + bstream->writeSignedFloat(q.z,SoundRotBits); bstream->writeFlag(q.w < 0.0); } diff --git a/Engine/source/T3D/gameBase/std/stdMoveList.cpp b/Engine/source/T3D/gameBase/std/stdMoveList.cpp index 6b4e11a72..1fd0ffdfb 100644 --- a/Engine/source/T3D/gameBase/std/stdMoveList.cpp +++ b/Engine/source/T3D/gameBase/std/stdMoveList.cpp @@ -96,7 +96,7 @@ void StdMoveList::clientWriteMovePacket(BitStream *bstream) { move[offset + i].sendCount++; move[offset + i].pack(bstream,prevMove); - bstream->writeInt(move[offset + i].checksum,Move::ChecksumBits); + bstream->writeInt(move[offset + i].checksum & (~(0xFFFFFFFF << Move::ChecksumBits)),Move::ChecksumBits); prevMove = &move[offset+i]; } } diff --git a/Engine/source/core/dnet.cpp b/Engine/source/core/dnet.cpp index 6eda3533e..76748ef52 100644 --- a/Engine/source/core/dnet.cpp +++ b/Engine/source/core/dnet.cpp @@ -79,11 +79,11 @@ void ConnectionProtocol::buildSendPacketHeader(BitStream *stream, S32 packetType stream->writeFlag(true); stream->writeInt(mConnectSequence & 1, 1); - stream->writeInt(mLastSendSeq, 9); - stream->writeInt(mLastSeqRecvd, 9); - stream->writeInt(packetType, 2); - stream->writeInt(ackByteCount, 3); - stream->writeInt(mAckMask, ackByteCount * 8); + stream->writeInt(mLastSendSeq & 0x1FF, 9); + stream->writeInt(mLastSeqRecvd & 0x1FF, 9); + stream->writeInt(packetType & 0x3, 2); + stream->writeInt(ackByteCount & 0x7, 3); + stream->writeInt(mAckMask & (~(0xFFFFFFFF << ackByteCount*8)), ackByteCount * 8); // if we're resending this header, we can't advance the // sequence recieved (in case this packet drops and the prev one diff --git a/Engine/source/core/stream/bitStream.cpp b/Engine/source/core/stream/bitStream.cpp index 6080eee94..4ea46b6f5 100644 --- a/Engine/source/core/stream/bitStream.cpp +++ b/Engine/source/core/stream/bitStream.cpp @@ -336,6 +336,8 @@ S32 BitStream::readInt(S32 bitCount) void BitStream::writeInt(S32 val, S32 bitCount) { + AssertWarn((bitCount == 32) || ((val >> bitCount) == 0), "BitStream::writeInt: value out of range"); + val = convertHostToLEndian(val); writeBits(bitCount, &val); } diff --git a/Engine/source/sfx/sfxDescription.cpp b/Engine/source/sfx/sfxDescription.cpp index 4bf06d622..658e15a45 100644 --- a/Engine/source/sfx/sfxDescription.cpp +++ b/Engine/source/sfx/sfxDescription.cpp @@ -508,8 +508,8 @@ void SFXDescription::packData( BitStream *stream ) Parent::packData( stream ); stream->writeFloat( mVolume, 6 ); - stream->writeFloat( mPitch, 6 ); - stream->writeFloat( mPriority, 6 ); + stream->write( mPitch ); + stream->write( mPriority ); stream->writeFlag( mIsLooping ); stream->writeFlag( mFadeLoops ); diff --git a/Engine/source/sim/netEvent.cpp b/Engine/source/sim/netEvent.cpp index e73a7ed4a..07b90f6ca 100644 --- a/Engine/source/sim/netEvent.cpp +++ b/Engine/source/sim/netEvent.cpp @@ -243,7 +243,7 @@ void NetConnection::eventWritePacket(BitStream *bstream, PacketNotify *notify) packQueueTail->mNextEvent = ev; packQueueTail = ev; if(!bstream->writeFlag(ev->mSeqCount == prevSeq + 1)) - bstream->writeInt(ev->mSeqCount, 7); + bstream->writeInt(ev->mSeqCount & 0x7F, 7); prevSeq = ev->mSeqCount;