Bug 111916 - Number of enemy balls is always one no matter what it is set to
Summary: Number of enemy balls is always one no matter what it is set to
Status: RESOLVED FIXED
Alias: None
Product: ksnake
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Andrew Chant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-02 02:03 UTC by mgutowski04
Modified: 2006-01-16 21:10 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
simple rewrite of Rattler::setBalls (1009 bytes, patch)
2006-01-14 08:22 UTC, Henry Malthus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mgutowski04 2005-09-02 02:03:56 UTC
Version:           0.4.0 (using KDE 3.4.1, Gentoo)
Compiler:          gcc version 3.3.5-20050130 (Gentoo Linux 3.3.5.20050130-r1, ssp-3.3.5.20050130-1, pie-8.7.7.1)
OS:                Linux (i686) release 2.6.12-gentoo-r6

The number of enemy balls that appear in the level does not change not matter what it is set to.  For example, when set to be 0, 1, 2, or 13, 1 (one) ball appears.
Comment 1 mgutowski04 2005-09-02 03:05:08 UTC
The original bug report was inaccurate.  You must exit and restart the game for the changed number of balls to take effect.  This is not the case for the number of enemy snakes.
Comment 2 Henry Malthus 2006-01-14 08:22:26 UTC
Created attachment 14248 [details]
simple rewrite of Rattler::setBalls

Attached patch is just a rewrite of Rattler::setBalls to work more like
Rattler::setComputerSnakes. 

I've done some minimal testing, and it seems to work fine.
Comment 3 Henry Malthus 2006-01-14 08:24:16 UTC
Sorry, the patch is for 3.5 branch (I haven't got a KDE4 install working yet).
Comment 4 Albert Astals Cid 2006-01-16 21:10:50 UTC
SVN commit 499007 by aacid:

Apply a patch to fix bug 111916 inspired in one by Henry Malthus. I've applied mine becasue changes the code less heaviliy. Thanks for reporting
BUGS: 111916


 M  +7 -9      rattler.cpp  


--- branches/KDE/3.5/kdegames/ksnake/rattler.cpp #499006:499007
@@ -589,25 +589,23 @@
 	}
 }
 
-void Rattler::setBalls(int numBalls)
+void Rattler::setBalls(int newNumBalls)
 {
-	int count = balls->count();
+	numBalls = balls->count();
 
-	if (!gameState.testBit(Playing) ||
-      !gameState.testBit(Demo) ||
-       numBalls == count)
+	if (!(gameState.testBit(Playing) || gameState.testBit(Demo)) || numBalls == newNumBalls)
 		return;
 
-	while ( numBalls > count) {
+	while ( newNumBalls > numBalls) {
 		Ball *b = new Ball(board, pix);
 		balls->append(b);
-		numBalls--;
+		numBalls++;
 	}
-	while (numBalls < count) {
+	while (newNumBalls < numBalls) {
 		Ball *b = balls->getLast();
 		b->zero();
 		balls->removeLast();
-		numBalls++;
+		numBalls--;
 	}
 }