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

@ -149,15 +149,15 @@ bool GuiScrollCtrl::onWake()
return false;
mTextureObject = mProfile->getBitmapResource();
if (mTextureObject && (mProfile->constructBitmapArray() >= BmpStates * BmpCount))
if (mTextureObject && (mProfile->constructBitmapArray() >= (U32)BmpStates * (U32)BmpCount))
{
mBitmapBounds = mProfile->mBitmapArrayRects.address();
//init
mBaseThumbSize = mBitmapBounds[BmpStates * BmpVThumbTopCap].extent.y +
mBitmapBounds[BmpStates * BmpVThumbBottomCap].extent.y;
mScrollBarThickness = mBitmapBounds[BmpStates * BmpVPage].extent.x;
mScrollBarArrowBtnLength = mBitmapBounds[BmpStates * BmpUp].extent.y;
mBaseThumbSize = mBitmapBounds[(U32)BmpStates * (U32)BmpVThumbTopCap].extent.y +
mBitmapBounds[(U32)BmpStates * (U32)BmpVThumbBottomCap].extent.y;
mScrollBarThickness = mBitmapBounds[(U32)BmpStates * (U32)BmpVPage].extent.x;
mScrollBarArrowBtnLength = mBitmapBounds[(U32)BmpStates * (U32)BmpUp].extent.y;
computeSizes();
}
else
@ -1095,7 +1095,7 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
Point2I pos = ( offset + mUpArrowRect.point );
// Up Arrow.
S32 upArrowBitmap = ( BmpStates * BmpUp );
S32 upArrowBitmap = ((U32)BmpStates * (U32)BmpUp );
if ( !mVBarEnabled )
{
upArrowBitmap += BmpDisabled;
@ -1114,7 +1114,7 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
pos.y += mBitmapBounds[upArrowBitmap].extent.y;
// Track.
S32 trackBitmap = ( BmpStates * BmpVPage );
S32 trackBitmap = ((U32)BmpStates * (U32)BmpVPage );
if ( !mVBarEnabled )
{
trackBitmap += BmpDisabled;
@ -1142,7 +1142,7 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
pos.y += trackRect.extent.y;
// Down Arrow.
S32 downArrowBitmap = ( BmpStates * BmpDown );
S32 downArrowBitmap = ((U32)BmpStates * (U32)BmpDown );
if ( !mVBarEnabled )
{
downArrowBitmap += BmpDisabled;
@ -1167,9 +1167,9 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
pos.y = ( offset.y + mVThumbPos );
// Determine the Bitmaps.
S32 thumbBitmapTop = ( BmpStates * BmpVThumbTopCap );
S32 thumbBitmapMiddle = ( BmpStates * BmpVThumb );
S32 thumbBitmapBottom = ( BmpStates * BmpVThumbBottomCap );
S32 thumbBitmapTop = ((U32)BmpStates * (U32)BmpVThumbTopCap );
S32 thumbBitmapMiddle = ((U32)BmpStates * (U32)BmpVThumb );
S32 thumbBitmapBottom = ((U32)BmpStates * (U32)BmpVThumbBottomCap );
if ( mHitRegion == VertThumb && mStateDepressed )
{
@ -1220,7 +1220,7 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
Point2I pos = ( offset + mLeftArrowRect.point );
// Left Arrow.
S32 leftArrowBitmap = ( BmpStates * BmpLeft );
S32 leftArrowBitmap = ((U32)BmpStates * (U32)BmpLeft );
if ( !mHBarEnabled )
{
leftArrowBitmap += BmpDisabled;
@ -1239,7 +1239,7 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
pos.x += mBitmapBounds[leftArrowBitmap].extent.x;
// Track.
S32 trackBitmap = ( BmpStates * BmpHPage );
S32 trackBitmap = ((U32)BmpStates * (U32)BmpHPage );
if ( !mHBarEnabled )
{
trackBitmap += BmpDisabled;
@ -1267,7 +1267,7 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
pos.x += trackRect.extent.x;
// Right Arrow.
S32 rightArrowBitmap = ( BmpStates * BmpRight );
S32 rightArrowBitmap = ((U32)BmpStates * (U32)BmpRight );
if ( !mHBarEnabled )
{
rightArrowBitmap += BmpDisabled;
@ -1292,9 +1292,9 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
pos.x = ( offset.x + mHThumbPos );
// Determine the Bitmaps.
S32 thumbBitmapLeft = ( BmpStates * BmpHThumbLeftCap );
S32 thumbBitmapMiddle = ( BmpStates * BmpHThumb );
S32 thumbBitmapRight = ( BmpStates * BmpHThumbRightCap );
S32 thumbBitmapLeft = ((U32)BmpStates * (U32)BmpHThumbLeftCap );
S32 thumbBitmapMiddle = ((U32)BmpStates * (U32)BmpHThumb );
S32 thumbBitmapRight = ((U32)BmpStates * (U32)BmpHThumbRightCap );
if ( mHitRegion == HorizThumb && mStateDepressed )
{
@ -1340,7 +1340,7 @@ void GuiScrollCtrl::drawScrollCorner(const Point2I &offset)
pos.x += mRightArrowRect.point.x + mRightArrowRect.extent.x - 1;
pos.y += mRightArrowRect.point.y;
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, pos, mBitmapBounds[BmpStates * BmpResize]);
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, pos, mBitmapBounds[(U32)BmpStates * (U32)BmpResize]);
}
//-----------------------------------------------------------------------------

View file

@ -692,7 +692,7 @@ bool GuiWindowCtrl::onWake()
mTextureObject = mProfile->getBitmapResource();
mBitmapBounds = mProfile->mBitmapArrayRects.address();
S32 buttonHeight = mBitmapBounds[BmpStates * BmpClose].extent.y;
S32 buttonHeight = mBitmapBounds[(U32)BmpStates * (U32)BmpClose].extent.y;
mTitleHeight = buttonHeight + 4;
@ -1397,7 +1397,7 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
// Draw the close button
Point2I tempUL;
Point2I tempLR;
S32 bmp = BmpStates * BmpClose;
S32 bmp = (U32)BmpStates * (U32)BmpClose;
if( mCanClose ) {
if( mCloseButton.pointInRect( mMousePosition ) )
@ -1414,9 +1414,9 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
// Draw the maximize button
if( mMaximized )
bmp = BmpStates * BmpNormal;
bmp = (U32)BmpStates * (U32)BmpNormal;
else
bmp = BmpStates * BmpMaximize;
bmp = (U32)BmpStates * (U32)BmpMaximize;
if( mCanMaximize ) {
if( mMaximizeButton.pointInRect( mMousePosition ) )
@ -1433,9 +1433,9 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
// Draw the minimize button
if( mMinimized )
bmp = BmpStates * BmpNormal;
bmp = (U32)BmpStates * (U32)BmpNormal;
else
bmp = BmpStates * BmpMinimize;
bmp = (U32)BmpStates * (U32)BmpMinimize;
if( mCanMinimize ) {
if( mMinimizeButton.pointInRect( mMousePosition ) )
@ -1502,8 +1502,8 @@ void GuiWindowCtrl::positionButtons(void)
if( !mBitmapBounds || !mAwake )
return;
S32 buttonWidth = mBitmapBounds[BmpStates * BmpClose].extent.x;
S32 buttonHeight = mBitmapBounds[BmpStates * BmpClose].extent.y;
S32 buttonWidth = mBitmapBounds[(U32)BmpStates * (U32)BmpClose].extent.x;
S32 buttonHeight = mBitmapBounds[(U32)BmpStates * (U32)BmpClose].extent.y;
Point2I mainOff = mProfile->mTextOffset;
// Until a pref, if alignment is LEFT, put buttons RIGHT justified.