From: TimePath Date: Fri, 2 Oct 2015 23:40:17 +0000 (+1000) Subject: Menu: check for division by 0 X-Git-Tag: xonotic-v0.8.2~1893 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=eb40684da491b9862d8944381b4d47997c46fef5;p=xonotic%2Fxonotic-data.pk3dir.git Menu: check for division by 0 --- diff --git a/qcsrc/menu/item/button.qc b/qcsrc/menu/item/button.qc index 343bf1d93..934e8cd34 100644 --- a/qcsrc/menu/item/button.qc +++ b/qcsrc/menu/item/button.qc @@ -44,7 +44,7 @@ void Button_resizeNotify(entity me, vector relOrigin, vector relSize, vector abs if(me.srcMulti) me.keepspaceLeft = 0; else - me.keepspaceLeft = min(0.8, absSize.y / absSize.x); + me.keepspaceLeft = min(0.8, absSize.x == 0 ? 0 : (absSize.y / absSize.x)); SUPER(Button).resizeNotify(me, relOrigin, relSize, absOrigin, absSize); } void Button_configureButton(entity me, string txt, float sz, string gfx) diff --git a/qcsrc/menu/item/label.qc b/qcsrc/menu/item/label.qc index e02642f69..ea170777e 100644 --- a/qcsrc/menu/item/label.qc +++ b/qcsrc/menu/item/label.qc @@ -130,8 +130,8 @@ void Label_resizeNotify(entity me, vector relOrigin, vector relSize, vector absO SUPER(Label).resizeNotify(me, relOrigin, relSize, absOrigin, absSize); // absSize_y is height of label - me.realFontSize_y = me.fontSize / absSize.y; - me.realFontSize_x = me.fontSize / absSize.x; + me.realFontSize_y = absSize.y == 0 ? 0 : (me.fontSize / absSize.y); + me.realFontSize_x = absSize.x == 0 ? 0 : (me.fontSize / absSize.x); if(me.marginLeft) me.keepspaceLeft = me.marginLeft * me.realFontSize.x; if(me.marginRight) diff --git a/qcsrc/menu/item/slider.qc b/qcsrc/menu/item/slider.qc index 465442543..03ad736b8 100644 --- a/qcsrc/menu/item/slider.qc +++ b/qcsrc/menu/item/slider.qc @@ -69,7 +69,7 @@ string Slider_toString(entity me) void Slider_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize) { SUPER(Slider).resizeNotify(me, relOrigin, relSize, absOrigin, absSize); - me.controlWidth = absSize.y / absSize.x; + me.controlWidth = absSize.x == 0 ? 0 : (absSize.y / absSize.x); } string Slider_valueToText(entity me, float val) {