Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 99395 - project-starfighter: Ammo Counter Overflow Bug
Summary: project-starfighter: Ammo Counter Overflow Bug
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Games (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo Games
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-17 20:58 UTC by Jason Bucata
Modified: 2005-07-21 21:13 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for plasma ammo counter (patch1.txt,1.76 KB, patch)
2005-07-17 21:00 UTC, Jason Bucata
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Bucata 2005-07-17 20:58:26 UTC
While playing Project: Starfighter, if your ship's capacity of plasma ammo is
set to, or close to, the maximum the game will let you set (250), it's possible
to pick up a power-up droplet (or whatever they're officially called) to add
plasma ammo to what your ship currently has, where the sum would exceed 255. 
The plasma ammo is stored in an unsigned char, so this causes wraparound to a
very low number, which can be quite disconcerting while you're in the thick of a
fight and suddenly run out of ammo, when you had plenty only a moment before.

There is code to limit the ammo to whatever your current ship's capacity is (say
250), but the check occurs after the addition of the droplet's ammo to your
stockpile--i.e., after the overflow has already occurred.  The solution is to do
the addition in a wider temp variable (an int) and bounds-check there.

Will upload a patch that does precisely this.  This fixes the immediate case,
though I see plenty of other cases where it's conceivable that such
over/underflow could occur.  I've tested this and it now Works For Me in the
indicated case.

If this passes muster here, it would be a good idea to pass this upstream.
Comment 1 Jason Bucata 2005-07-17 21:00:34 UTC
Created attachment 63670 [details, diff]
Patch for plasma ammo counter
Comment 2 Mr. Bones. (RETIRED) gentoo-dev 2005-07-21 21:13:10 UTC
Thanks for the patch and bug report.

Added to CVS.  resync/remerge to get the fix.