st
[carveJwlIkooP6JGAAIwe30JlM.git] / highscores.h
index f2c5eabc855b0654a1d3c3d5b6eca3dcdedf8b56..817a503870ef602ed543f81338873e2e5fc6238d 100644 (file)
@@ -218,6 +218,10 @@ VG_STATIC void highscores_init( u32 pool_size, u32 playerinfo_pool_size )
       vg_linear_alloc( vg_mem.rtmemory,
                        playerinfo_pool_size * sizeof(highscore_playerinfo) );
 
+   memset( sys->data, 0, pool_size*sizeof(highscore_record) );
+   memset( sys->playerinfo_data, 0, 
+         playerinfo_pool_size*sizeof(highscore_playerinfo) );
+
 
    /* This is ugly.. too bad! */
    sys->aainfo.base = highscore_system.data;
@@ -306,8 +310,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) );
 
@@ -320,8 +323,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 );
 
@@ -474,14 +476,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)
-   {
+   while(value){
       if( i>=len ) 
-         return;
+         return i;
 
       buf[ len-1 - (i ++) ] = '0' + (value % 10);
       value /= 10;
@@ -489,16 +491,18 @@ VG_STATIC void highscore_intr( char *buf, int value, int len, char alt )
 
    for( ;i<len; i ++ )
       buf[ len-1 - i ] = alt;
+
+   return i;
 }
 
-/* Print integer into buffer with max length len */
-VG_STATIC void highscore_intl( char *buf, int value, int len )
+/* 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 )
 {
    char temp[32];
 
    int i=0;
-   while(value)
-   {
+   while(value){
       if( i>=len ) 
          break;
 
@@ -510,9 +514,9 @@ VG_STATIC void highscore_intl( char *buf, int value, int len )
       i = len;
 
    for( int j=0; j<i; j ++ )
-   {
       buf[j] = temp[ i-1-j ];
-   }
+
+   return i;
 }
 
 /* Clear buffer with length using clr character */
@@ -581,6 +585,16 @@ VG_STATIC void highscores_board_generate( char *buf, u32 id, u32 count )
                &sys->aainfo_playerinfo_playerid, info_ptr );
 
          highscore_strl( line+3, inf->nickname, 16 );
+
+         /* yep, this is fucking awesome! */
+         if( inf->playerid == 0x8297744501001001 ||
+             inf->playerid == 0x1ec4620101001001 ||
+             inf->playerid == 0x0110000145749782 ||
+             inf->playerid == 0x011000010162c41e )
+         {
+            i --;
+            /* FIXME: Clear line, or yknow, do it properly */
+         }
       }
 
       u16 centiseconds = record->time,