#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;
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;
sys->dbheader.playerinfo_root = AATREE_PTR_NIL;
}
-VG_STATIC int highscores_read(void)
-{
+static int highscores_read( const char *path ){
struct highscore_system *sys = &highscore_system;
- FILE *fp = fopen( ".aadb", "rb" );
+ if( path == NULL )
+ path = ".aadb";
+
+ FILE *fp = fopen( path, "rb" );
if( fp ){
vg_info( "Loading existing database\n" );
}
else
{
- vg_low( "No existing database found (.aadb)\n" );
+ vg_low( "No existing database found (%s)\n", path );
return 0;
}
}
-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;
offsetof(highscore_playerinfo,aa_playerid);
sys->aainfo_playerinfo_playerid.p_cmp = highscore_cmp_playerinfo_playerid;
+ /* TODO: Is this even useable? */
sys->aainfo_playerinfo.base = highscore_system.playerinfo_data;
sys->aainfo_playerinfo.stride = sizeof(highscore_playerinfo);
sys->aainfo_playerinfo.offset = offsetof(highscore_playerinfo,aapn);
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" );
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;
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;
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++ )
}
/* 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; str_length++ )
}
/* Print the string(max length:len) centered into buf (has width:width) */
-VG_STATIC void highscore_strc( char *buf, const char *str, int len, int width )
+static void highscore_strc( char *buf, const char *str, int len, int width )
{
int str_length = highscore_strlen( str, len ),
offs = (width-str_length)/2;
}
/* Print the string(max length:len) left aligned into buf */
-VG_STATIC void highscore_strl( char *buf, const char *str, int len )
+static void highscore_strl( char *buf, const char *str, int len )
{
for( int i=0; i<len; i++ )
{
}
/* Print the string (max length:len) right aligned into buf (has width:width) */
-VG_STATIC void highscore_strr( char *buf, const char *str, int len, int width )
+static void highscore_strr( char *buf, const char *str, int len, int width )
{
int str_length = highscore_strlen( str, len );
/* 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 )
+static int highscore_intr( char *buf, int value, int len, char alt )
{
int i=0;
while(value){
/* Print integer into buffer with max length len
* retuns the number of digits written to buf */
-VG_STATIC int highscore_intl( char *buf, int value, int len ){
+static int highscore_intl( char *buf, int value, int len ){
if( value ){
char temp[32];
int i=0;
}
/* Clear buffer with length using clr character */
-VG_STATIC void highscore_clear( char *buf, char clr, int length )
+static void highscore_clear( char *buf, char clr, int length )
{
for( int i=0; i<length; i++ )
buf[i] = clr;
/* Generate a highscores board in text form, the width is always 27. Buffer
* must be (count+3)*27 in size. */
-VG_STATIC void highscores_board_generate( char *buf, u32 id, u32 count )
+static void highscores_board_generate( char *buf, u32 id, u32 count )
{
int w=27;
highscore_clear( buf, ' ', (count+3)*w );
/* Print string out to file using newlines. Count is number of records
* ( this requires a buffer of (count+3)*27 size */
-VG_STATIC void highscores_board_printf( FILE *fp, const char *buf, u32 count )
+static void highscores_board_printf( FILE *fp, const char *buf, u32 count )
{
int w=27;