X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=highscores.c;h=d1866ae58d5a86a1cba27503e508ae3003fb9a78;hb=5fba3602f053116a8e3849bc12c03198d6d7461c;hp=77ffc412de82d4a32c9246d304a89cf692b02ad5;hpb=d07048b61445be11605adba43667e19214358a24;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/highscores.c b/highscores.c index 77ffc41..d1866ae 100644 --- a/highscores.c +++ b/highscores.c @@ -3,13 +3,13 @@ #include "highscores.h" -VG_STATIC int highscore_cmp_points( void *a, void *b ) +static int highscore_cmp_points( void *a, void *b ) { highscore_record *pa = a, *pb = b; return (int)pa->points - (int)pb->points; } -VG_STATIC int highscore_cmp_datetime( void *a, void *b ) +static int highscore_cmp_datetime( void *a, void *b ) { highscore_record *pa = a, *pb = b; @@ -17,27 +17,27 @@ VG_STATIC int highscore_cmp_datetime( void *a, void *b ) return pa->datetime < pb->datetime? 1: -1; } -VG_STATIC int highscore_cmp_time( void *a, void *b ) +static int highscore_cmp_time( void *a, void *b ) { highscore_record *pa = a, *pb = b; return (int)pb->time - (int)pa->time; } -VG_STATIC int highscore_cmp_playerid( void *a, void *b ) +static int highscore_cmp_playerid( void *a, void *b ) { highscore_record *pa = a, *pb = b; if( pa->playerid == pb->playerid ) return 0; return pa->playerid < pb->playerid? -1: 1; } -VG_STATIC int highscore_cmp_playerinfo_playerid( void *a, void *b ) +static int highscore_cmp_playerinfo_playerid( void *a, void *b ) { highscore_playerinfo *pa = a, *pb = b; if( pa->playerid == pb->playerid ) return 0; return pa->playerid < pb->playerid? -1: 1; } -VG_STATIC void highscores_create_db(void) +static void highscores_create_db(void) { struct highscore_system *sys = &highscore_system; @@ -64,7 +64,7 @@ VG_STATIC void highscores_create_db(void) sys->dbheader.playerinfo_root = AATREE_PTR_NIL; } -VG_STATIC int highscores_read(void) +static int highscores_read(void) { struct highscore_system *sys = &highscore_system; @@ -111,7 +111,7 @@ VG_STATIC int highscores_read(void) } } -VG_STATIC void highscores_init( u32 pool_size, u32 playerinfo_pool_size ) +static void highscores_init( u32 pool_size, u32 playerinfo_pool_size ) { struct highscore_system *sys = &highscore_system; @@ -168,7 +168,7 @@ VG_STATIC void highscores_init( u32 pool_size, u32 playerinfo_pool_size ) sys->pool_size = pool_size; } -VG_STATIC int highscores_serialize_all(void) +static int highscores_serialize_all(void) { struct highscore_system *sys = &highscore_system; vg_info( "Serializing database\n" ); @@ -191,7 +191,7 @@ VG_STATIC int highscores_serialize_all(void) return 1; } -VG_STATIC highscore_record *highscore_find_user_record( u64 playerid, +static highscore_record *highscore_find_user_record( u64 playerid, u32 trackid ) { struct highscore_system *sys = &highscore_system; @@ -209,7 +209,7 @@ VG_STATIC highscore_record *highscore_find_user_record( u64 playerid, return aatree_get_data( &sys->aainfo_playerid, find ); } -VG_STATIC aatree_ptr highscores_push_record( highscore_record *record ) +static aatree_ptr highscores_push_record( highscore_record *record ) { struct highscore_system *sys = &highscore_system; @@ -278,7 +278,7 @@ VG_STATIC aatree_ptr highscores_push_record( highscore_record *record ) return index; } -VG_STATIC aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] ) +static aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] ) { char name[17]; for( int i=0; i<16; i++ ) @@ -328,7 +328,7 @@ VG_STATIC aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] ) } /* Get the length of a string, bounded by '\0' or len, whichever is first */ -VG_STATIC int highscore_strlen( const char *str, int len ) +static int highscore_strlen( const char *str, int len ) { int str_length; for( str_length=0; str_length=len ) + break; + + temp[ i ++ ] = '0' + (value % 10); + value /= 10; + } - int i=0; - while(value){ - if( i>=len ) - break; + if( i>len ) + i = len; - temp[ i ++ ] = '0' + (value % 10); - value /= 10; - } - - if( i>len ) - i = len; - - for( int j=0; j