add safeties for enum math across define boundaries

This commit is contained in:
AzaezelX 2023-04-26 22:27:35 -05:00
parent 1230d0d280
commit aa02e48c8d
20 changed files with 71 additions and 71 deletions

View file

@ -104,7 +104,7 @@ public:
static StringTableEntry smNoShapeAssetFallback;
static const String mShapeErrCodeStrings[ShapeAssetErrCode::Extended - Parent::Extended + 1];
static const String mShapeErrCodeStrings[U32(ShapeAssetErrCode::Extended) - U32(Parent::Extended) + 1];
static U32 getAssetErrCode(AssetPtr<ShapeAsset> shapeAsset) { if (shapeAsset) return shapeAsset->mLoadedState; else return 0; }

View file

@ -691,7 +691,7 @@ void Lightning::processEvent(LightningStrikeEvent* pEvent)
start.z = mObjScale.z * 0.5f + getPosition().z;
strikePoint.z += -mObjScale.z * 0.5f;
bool rayHit = gClientContainer.castRay( start, strikePoint,
(STATIC_COLLISION_TYPEMASK | WaterObjectType),
((U32)STATIC_COLLISION_TYPEMASK | (U32)WaterObjectType),
&rayInfo);
if( rayHit )
{
@ -933,7 +933,7 @@ U32 Lightning::packUpdate(NetConnection* con, U32 mask, BitStream* stream)
U32 retMask = Parent::packUpdate(con, mask, stream);
// Only write data if this is the initial packet or we've been inspected.
if (stream->writeFlag(mask & (InitialUpdateMask | ExtendedInfoMask)))
if (stream->writeFlag(mask & ((U32)InitialUpdateMask | (U32)ExtendedInfoMask)))
{
// Initial update
mathWrite(*stream, getPosition());

View file

@ -442,7 +442,7 @@ void GroundPlane::createGeometry( const Frustum& frustum )
U32 width = mCeil( ( max.x - min.x ) / mSquareSize );
if( width > MAX_WIDTH )
{
mSquareSize = mCeil( ( max.x - min.x ) / MAX_WIDTH );
mSquareSize = mCeil( ( max.x - min.x ) / (F32)MAX_WIDTH );
width = MAX_WIDTH;
}
else if( !width )
@ -451,7 +451,7 @@ void GroundPlane::createGeometry( const Frustum& frustum )
U32 height = mCeil( ( max.y - min.y ) / mSquareSize );
if( height > MAX_HEIGHT )
{
mSquareSize = mCeil( ( max.y - min.y ) / MAX_HEIGHT );
mSquareSize = mCeil( ( max.y - min.y ) / (F32)MAX_HEIGHT );
height = MAX_HEIGHT;
}
else if( !height )

View file

@ -1289,14 +1289,14 @@ bool Item::_setStatic(void *object, const char *index, const char *data)
{
Item *i = static_cast<Item*>(object);
i->mAtRest = dAtob(data);
i->setMaskBits(InitialUpdateMask | PositionMask);
i->setMaskBits((U32)InitialUpdateMask | (U32)PositionMask);
return true;
}
bool Item::_setRotate(void *object, const char *index, const char *data)
{
Item *i = static_cast<Item*>(object);
i->setMaskBits(InitialUpdateMask | RotationMask);
i->setMaskBits((U32)InitialUpdateMask | (U32)RotationMask);
return true;
}

View file

@ -40,10 +40,10 @@
#include "collision/collision.h"
#include "lighting/lightManager.h"
const U32 LightFlareData::LosMask = STATIC_COLLISION_TYPEMASK |
ShapeBaseObjectType |
StaticShapeObjectType |
ItemObjectType;
const U32 LightFlareData::LosMask = (U32)STATIC_COLLISION_TYPEMASK |
(U32)ShapeBaseObjectType |
(U32)StaticShapeObjectType |
(U32)ItemObjectType;
LightFlareState::~LightFlareState()

View file

@ -3937,7 +3937,7 @@ void Player::updateActionThread()
if( gClientContainer.castRay( Point3F( pos.x, pos.y, pos.z + 0.01f ),
Point3F( pos.x, pos.y, pos.z - 2.0f ),
STATIC_COLLISION_TYPEMASK | VehicleObjectType, &rInfo ) )
(U32)STATIC_COLLISION_TYPEMASK | (U32)VehicleObjectType, &rInfo ) )
{
Material* material = ( rInfo.material ? dynamic_cast< Material* >( rInfo.material->getMaterial() ) : 0 );
@ -5562,7 +5562,7 @@ void Player::setTransform(const MatrixF& mat)
mat.getColumn(3,&pos);
Point3F rot(0.0f, 0.0f, -mAtan2(-vec.x,vec.y));
setPosition(pos,rot);
setMaskBits(MoveMask | NoWarpMask);
setMaskBits((U32)MoveMask | (U32)NoWarpMask);
}
void Player::getEyeTransform(MatrixF* mat)
@ -7073,7 +7073,7 @@ void Player:: playImpactSound()
if( gClientContainer.castRay( Point3F( pos.x, pos.y, pos.z + 0.01f ),
Point3F( pos.x, pos.y, pos.z - 2.0f ),
STATIC_COLLISION_TYPEMASK | VehicleObjectType,
(U32)STATIC_COLLISION_TYPEMASK | (U32)VehicleObjectType,
&rInfo ) )
{
Material* material = ( rInfo.material ? dynamic_cast< Material* >( rInfo.material->getMaterial() ) : 0 );

View file

@ -271,7 +271,7 @@ void StaticShape::onUnmount(SceneObject* obj, S32 node)
U32 StaticShape::packUpdate(NetConnection *connection, U32 mask, BitStream *bstream)
{
U32 retMask = Parent::packUpdate(connection,mask,bstream);
if (bstream->writeFlag(mask & (PositionMask | ExtendedInfoMask)))
if (bstream->writeFlag(mask & ((U32)PositionMask | (U32)ExtendedInfoMask)))
{
// Write the transform (do _not_ use writeAffineTransform. Since this is a static

View file

@ -554,7 +554,7 @@ void Trigger::setTransform(const MatrixF & mat)
base.mul(mWorldToObj);
mClippedList.setBaseTransform(base);
setMaskBits(TransformMask | ScaleMask);
setMaskBits((U32)TransformMask | (U32)ScaleMask);
}
testObjects();
@ -564,7 +564,7 @@ void Trigger::onUnmount( SceneObject *obj, S32 node )
{
Parent::onUnmount( obj, node );
// Make sure the client get's the final server pos.
setMaskBits(TransformMask | ScaleMask);
setMaskBits((U32)TransformMask | (U32)ScaleMask);
}
void Trigger::prepRenderImage( SceneRenderState *state )

View file

@ -1169,7 +1169,7 @@ U32 AITurretShape::packUpdate(NetConnection *connection, U32 mask, BitStream *bs
U32 retMask = Parent::packUpdate(connection,mask,bstream);
// Indicate that the transform has changed to update the scan box
bstream->writeFlag(mask & (PositionMask | ExtendedInfoMask));
bstream->writeFlag(mask & ((U32)PositionMask | (U32)ExtendedInfoMask));
// Handle any state changes that need to be passed along
if (bstream->writeFlag(mask & TurretStateMask))