This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#10350 - plugin lib highscore: fix and improvement
Attached to Project:
Rockbox
Opened by Teruaki Kawashima (teru) - Friday, 19 June 2009, 16:03 GMT+2
Last edited by Johannes Schwarz (Ubuntuxer) - Saturday, 18 July 2009, 17:19 GMT+2
Opened by Teruaki Kawashima (teru) - Friday, 19 June 2009, 16:03 GMT+2
Last edited by Johannes Schwarz (Ubuntuxer) - Saturday, 18 July 2009, 17:19 GMT+2
|
Details*Close file descriptor in highscore_load.
*Replace tabs with spaces. *Change format of score in file. Change format from "name:score:level" to "score:level:name". In this way, name can contain any kind of char including ':' (but currentry, name doesn't seems to be used) and settings_parseline can be used to parse string. *make highscore_update to return the postion of newly added score. return 0 if the score is not added. this value can be used to display something like "New High Score #1". *change highscore_update, reverse the oder of scores. Highest score is stored at the end of array and it is not intuitive. *Modify rockblox to fit above change. rockbox is the only plugin using highscore_update. |
This task depends upon
Closed by Johannes Schwarz (Ubuntuxer)
Saturday, 18 July 2009, 17:19 GMT+2
Reason for closing: Accepted
Additional comments about closing: Commit in r21960; exclude the usage of the standard list widget in the function show_highscore, because further changes in the list would needed
Saturday, 18 July 2009, 17:19 GMT+2
Reason for closing: Accepted
Additional comments about closing: Commit in r21960; exclude the usage of the standard list widget in the function show_highscore, because further changes in the list would needed
Also, in the highscore_update function, I'd introduce another parameter for the score buffer capacity. The existing one tells us how many entries there are now, and the new parameter would tell how many entries we can store so that we can avoid overflow if a score is inserted. Or do I miss how this API is used?
*add some comments to source code.
*move "memset" before "open" in function highscore_load.
*change function highscore_update a bit. hopefully this change makes it clearer.
In my understanding, num_scores, parameter of function highscore_update, is how many entries we can store.
And the code I wrote wouldn't cause overflow. but it didn't seems undarstandable a bit.
I updated some comments.
In this case, it makes sense that name is not passed to the update function.
e.g.
int pos;
if((pos = highscore_update(...)) > 0)
rb->kbd_input(scores[pos-1].name, sizeof(scores[pos-1].name));
BTW: wouldn't it be better (and more C-like) to return a 0-based value in the update function (and a negative one if the entry was not inserted)? You could then use it as the index in your example above, no need to subtract 1 (in a message for the user you'd have to add 1 though). But I think it's more natural to work with 0-based values in C.
*use "highscore_update" & "highscore_show" for names so that it would looks more consistent.
*remove weird "num_scores > 1" from lib/highscore.c
*add some "highsocre_updated = false;"
*disable "highscore_show" for charcells lcd.
Same here :-) I also wonder why you didn't implement the "show" function using the standard list widget. Because it doesn't allow to display data in columns?
As I started to write the "show_highscore" function I don't know anything about the standard list widget. I wouldn't change the function, even though it looks strange on big screens if sysfont is used.
The patch from terru works fine for me.