Fix arithmetic bug in CHedgehogerWidget
authorunc0rr
Mon, 29 Sep 2008 22:01:06 +0000
changeset 1300 22c03f69e142
parent 1299 fc801a832e0e
child 1301 c6fe8a4bfd34
Fix arithmetic bug in CHedgehogerWidget
QTfrontend/hedgehogerWidget.cpp
--- a/QTfrontend/hedgehogerWidget.cpp	Mon Sep 29 21:59:19 2008 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp	Mon Sep 29 22:01:06 2008 +0000
@@ -24,17 +24,17 @@
     ItemNum(im, parent, 1)
 {
   if(parent) {
-    pOurFrameTeams=dynamic_cast<FrameTeams*>(parent->parentWidget());
+    pOurFrameTeams = dynamic_cast<FrameTeams*>(parent->parentWidget());
   }
-  if(pOurFrameTeams->overallHedgehogs+4>pOurFrameTeams->maxHedgehogsPerGame) {
-    numItems=pOurFrameTeams->maxHedgehogsPerGame-pOurFrameTeams->overallHedgehogs;
-  } else numItems=4;
-  pOurFrameTeams->overallHedgehogs+=numItems;
+  if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) {
+    numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs;
+  } else numItems = 4;
+  pOurFrameTeams->overallHedgehogs += numItems;
 }
 
-void CHedgehogerWidget::incItems() 
+void CHedgehogerWidget::incItems()
 {
-  if (pOurFrameTeams->overallHedgehogs<18) {
+  if (pOurFrameTeams->overallHedgehogs < 18) {
     numItems++;
     pOurFrameTeams->overallHedgehogs++;
     emit hedgehogsNumChanged();
@@ -60,9 +60,9 @@
 
 void CHedgehogerWidget::setHHNum(unsigned int num)
 {
-  unsigned int diff=numItems-num;
-  numItems=num;
-  pOurFrameTeams->overallHedgehogs+=diff;
+  unsigned int diff = num - numItems;
+  numItems += diff;
+  pOurFrameTeams->overallHedgehogs += diff;
   repaint();
 }