FS#9041 - Jewels - Score cleared on level change

Attached to Project: Rockbox
Opened by Corey (EMonk) - Monday, 26 May 2008, 00:37 GMT
Last edited by Adam Boot (rotator) - Friday, 30 May 2008, 23:12 GMT
Task Type Bugs
Category Games
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


When changing to a new level on Jewels the scored is cleared to the base for the level immediately after re-filling the board and before checking for 3+ groupings in the new board.

While not normally an issue, it is possible to have a multi-drop or 4+ group which brings the score above the next 100-point level threshold. Any points gained which exceed the 100-point level are discarded. The worst case I have had is an 8-point set bringing my score to 307, which was reset to 300 after level change.
This task depends upon

Closed by  Adam Boot (rotator)
Friday, 30 May 2008, 23:12 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in r17664
Comment by Bertrik Sikken (bertrik) - Wednesday, 28 May 2008, 11:57 GMT
I think this can be changed reasonably easy, but is this really a bug? AFAIK this game is a port of which apparently behaves like this.
Is the current scoring method different from other jewel-like games?
Comment by Adam Boot (rotator) - Wednesday, 28 May 2008, 19:39 GMT
You must be playing in puzzle mode, because in regular mode the points *do* roll over. This looks quite intentional to me as total points are really rather irrelevant in puzzle mode, only the level number matters.

I'll close this task if you don't have any objections.
Comment by Corey (EMonk) - Friday, 30 May 2008, 04:27 GMT
If it's by design, no worries... except I feel slightly disappointed when it happens :)

I don't play in Puzzle mode, so I have no comment on point rollover there. In normal game mode however it *does* clear the points.

I've just had my first look at the source and I think I've found the culprit near the bottom of the jewels_main loop in the following lines:

if(bj->score >= LEVEL_PTS) bj->score = jewels_nextlevel(bj);

Now, presuming that bj->level = 1 and bj->score = 103 prior to this point, immediately after jewels_nextlevel returns but prior to the assignment bj->level = 2 and bj->score = 3, which is correct. Unfortunately bj->score is then overwritten by the assignment which replaces it with the points gained from any drops that happened in the new board only. If we assume that no valid drops were generated by the newly added jewels during jewels_initlevel, then return from jewels_nextlevel will be 0 and player's total score will be (bj->level-1)*LEVEL_PTS+bj->score = 200.

Simplest fix might be to change the above to read "... bj->score += jewels_nextlevel(bj);" or similar.
Comment by Adam Boot (rotator) - Friday, 30 May 2008, 19:28 GMT
Ah, I think I see what you're talking about and it does look like a bug. It's a bit different than what I originally thought based on your description, I can have a quick fix for it as soon as I get some time.