diff --git a/Utils/PopUpBox.cpp b/Utils/PopUpBox.cpp index 577c11cf..26480dd1 100644 --- a/Utils/PopUpBox.cpp +++ b/Utils/PopUpBox.cpp @@ -1546,8 +1546,10 @@ void ResizeBoxToText(INT32 hBoxHandle) break; } } - PopUpBoxList[hBoxHandle]->Dimensions.iBottom=iHeight; - PopUpBoxList[hBoxHandle]->Dimensions.iRight=iWidth; + + // Flugente we shouldn't have added more popup options than we can display anyway, but I have no idea where to stop that, so at least we can fix this + PopUpBoxList[hBoxHandle]->Dimensions.iBottom = min( iHeight, SCREEN_HEIGHT - PopUpBoxList[hBoxHandle]->Position.iY); + PopUpBoxList[hBoxHandle]->Dimensions.iRight = min( iWidth, SCREEN_WIDTH - PopUpBoxList[hBoxHandle]->Position.iX ); } diff --git a/Utils/popup_class.cpp b/Utils/popup_class.cpp index a2a2cca3..b35cee4b 100644 --- a/Utils/popup_class.cpp +++ b/Utils/popup_class.cpp @@ -1646,6 +1646,13 @@ void POPUP::DetermineBoxPositions( void ) return; } + // Flugente: fix obvious errors + pPoint.iX = max( pPoint.iX, 0 ); + pPoint.iX = min( pPoint.iX, SCREEN_WIDTH ); + + pPoint.iY = max( pPoint.iY, 0 ); + pPoint.iY = min( pPoint.iY, SCREEN_HEIGHT ); + // set all the other positions to match this one this->Position = pPoint; this->BoxesX = pPoint.iX;