+VG_STATIC aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] )
+{
+ char name[17];
+ for( int i=0; i<16; i++ )
+ name[i] = nick[i];
+ name[16] = '\0';
+
+ vg_low( "Updating %lu's nickname -> %s\n", steamid, name );
+
+ struct highscore_system *sys = &highscore_system;
+
+ highscore_playerinfo temp;
+ temp.playerid = steamid;
+
+ aatree_ptr record = aatree_find( &sys->aainfo_playerinfo_playerid,
+ sys->dbheader.playerinfo_root,
+ &temp );
+ highscore_playerinfo *info;
+
+ if( record != AATREE_PTR_NIL )
+ {
+ info = aatree_get_data( &sys->aainfo_playerinfo, record );
+ }
+ else
+ {
+ record = aatree_pool_alloc( &sys->aainfo_playerinfo,
+ &sys->dbheader.playerinfo_head );
+
+ if( record == AATREE_PTR_NIL )
+ {
+ vg_error( "Player info database is over capacity!\n" );
+ return AATREE_PTR_NIL;
+ }
+
+ info = aatree_get_data( &sys->aainfo_playerinfo, record );
+ memset( info, 0, sizeof(highscore_playerinfo) );
+
+ info->playerid = steamid;
+ sys->dbheader.playerinfo_root = aatree_insert(
+ &sys->aainfo_playerinfo_playerid,
+ sys->dbheader.playerinfo_root, record );
+ }
+
+ for( int i=0; i<16; i++ )
+ info->nickname[i] = nick[i];
+
+ return AATREE_PTR_NIL;
+}
+
+/* Get the length of a string, bounded by '\0' or len, whichever is first */
+VG_STATIC int highscore_strlen( const char *str, int len )
+{
+ int str_length;
+ for( str_length=0; str_length<len; str_length++ )
+ if( !str[str_length] )
+ return str_length;
+
+ return 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 )
+{
+ int str_length = highscore_strlen( str, len ),
+ offs = (width-str_length)/2;
+
+ for( int i=0; i<str_length; i++ )
+ {
+ int j=i+offs;
+
+ if( j >= width )
+ return;
+
+ buf[j] = str[i];
+ }
+}
+
+/* Print the string(max length:len) left aligned into buf */
+VG_STATIC void highscore_strl( char *buf, const char *str, int len )
+{
+ for( int i=0; i<len; i++ )
+ {
+ if( !str[i] )
+ return;
+
+ buf[i] = str[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 )
+{
+ int str_length = highscore_strlen( str, len );
+
+ for( int i=0; i<len; i++ )
+ {
+ if( !str[i] )
+ return;
+
+ buf[width-str_length+i] = str[i];
+ }
+}
+
+/* Print integer (padded with: alt), right aligned into buf(width: len) */
+VG_STATIC void highscore_intr( char *buf, int value, int len, char alt )
+{
+ int i=0;
+ while(value){
+ if( i>=len )
+ return;
+
+ buf[ len-1 - (i ++) ] = '0' + (value % 10);
+ value /= 10;
+ }
+
+ for( ;i<len; i ++ )
+ buf[ len-1 - i ] = alt;
+}
+
+/* Print integer into buffer with max length len */
+VG_STATIC void highscore_intl( char *buf, int value, int len )
+{
+ char temp[32];
+
+ int i=0;
+ while(value)
+ {
+ if( i>=len )
+ break;
+
+ temp[ i ++ ] = '0' + (value % 10);
+ value /= 10;
+ }
+
+ if( i>len )
+ i = len;
+
+ for( int j=0; j<i; j ++ )
+ {
+ buf[j] = temp[ i-1-j ];
+ }
+}
+
+/* Clear buffer with length using clr character */
+VG_STATIC void highscore_clear( char *buf, char clr, int length )