X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=highscores.h;h=b096714cb9e8c16af1e93e0cf47322846ae9b134;hb=479b953c11ddf5d11c0f1f626995a3d402e6d9dd;hp=079e4d8d69af2befbed093ddbb2a5b4ddb20f6d0;hpb=e5dfbef890431a69291a9f0a9ca4a88ea8d0705a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/highscores.h b/highscores.h index 079e4d8..b096714 100644 --- a/highscores.h +++ b/highscores.h @@ -164,8 +164,7 @@ VG_STATIC int highscores_read(void) struct highscore_system *sys = &highscore_system; FILE *fp = fopen( ".aadb", "rb" ); - if( fp ) - { + if( fp ){ vg_info( "Loading existing database\n" ); u64 count = fread( &sys->dbheader, sizeof(highscore_database), 1, fp ); @@ -310,8 +309,7 @@ VG_STATIC aatree_ptr highscores_push_record( highscore_record *record ) vg_low( "Inserting record into database for track %hu\n",record->trackid ); - if( record->trackid >= vg_list_size(sys->dbheader.tracks) ) - { + if( record->trackid >= vg_list_size(sys->dbheader.tracks) ){ vg_error( "TrackID out of range (%hu>=%d)\n", record->trackid, vg_list_size(sys->dbheader.tracks) ); @@ -324,8 +322,7 @@ VG_STATIC aatree_ptr highscores_push_record( highscore_record *record ) table->root_playerid, record ); - if( existing != AATREE_PTR_NIL ) - { + if( existing != AATREE_PTR_NIL ){ highscore_record *crecord = aatree_get_data( &sys->aainfo_playerid, existing ); @@ -478,13 +475,14 @@ VG_STATIC void highscore_strr( char *buf, const char *str, int len, int width ) } } -/* Print integer (padded with: alt), right aligned into buf(width: len) */ -VG_STATIC void highscore_intr( char *buf, int value, int len, char alt ) +/* Print integer (padded with: alt), right aligned into buf(width: len) + * returns number of digits (not including alt), that were written to buf */ +VG_STATIC int highscore_intr( char *buf, int value, int len, char alt ) { int i=0; while(value){ if( i>=len ) - return; + return i; buf[ len-1 - (i ++) ] = '0' + (value % 10); value /= 10; @@ -492,16 +490,18 @@ VG_STATIC void highscore_intr( char *buf, int value, int len, char alt ) for( ;i=len ) break; @@ -513,9 +513,9 @@ VG_STATIC void highscore_intl( char *buf, int value, int len ) i = len; for( int j=0; j