summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-08-13 20:40:35 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-08-13 20:40:35 +0000
commit0a0be62b8dbd147148dc8fca71866e1038e9c76f (patch)
treef9358507c9ea6ae4d0f10353fc3ba06e496154d0 /apps/plugins
parent6cf8df810af117bff9197a91327737cb2efecbcf (diff)
downloadrockbox-0a0be62b8dbd147148dc8fca71866e1038e9c76f.zip
rockbox-0a0be62b8dbd147148dc8fca71866e1038e9c76f.tar.gz
rockbox-0a0be62b8dbd147148dc8fca71866e1038e9c76f.tar.bz2
rockbox-0a0be62b8dbd147148dc8fca71866e1038e9c76f.tar.xz
reverted the fixed 4 bytes write, made the read code more reliable, use
fdprintf() when writing the highscore, add newline after score in the saved file for easier loading (but the load code is fixed to better deal with files saved using the former method as well) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7323 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/snake2.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c
index a74394c..8221c98 100644
--- a/apps/plugins/snake2.c
+++ b/apps/plugins/snake2.c
@@ -473,18 +473,21 @@ void iohiscore(void)
{
int fd;
unsigned int compare,init=0;
-
- rb->snprintf(phscore,sizeof(phscore),"%d",init);
- fd = rb->open(HISCORE_FILE,O_RDWR | O_CREAT);
- rb->read(fd,phscore,4);
+ /* clear the buffer we're about to load the highscore data into */
+ rb->memset(phscore, 0, sizeof(phscore));
+
+ fd = rb->open(HISCORE_FILE,O_RDWR | O_CREAT);
+
+ /* highscore used to %d, is now %d\n
+ Deal with no file or bad file */
+ rb->read(fd,phscore, sizeof(phscore));
compare = rb->atoi(phscore);
if(hiscore > compare){
- rb->snprintf(phscore,sizeof(phscore),"%d",hiscore);
rb->lseek(fd,0,SEEK_SET);
- rb->write(fd,phscore,4);
+ rb->fdprintf(fd, "%d\n", hiscore);
}
else
hiscore = compare;