+ char name[11];
+ for( int i=0; i<10; i++ )
+ name[i] = nick[i];
+ name[10] = '\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<10; i++ )
+ info->nickname[i] = nick[i];
+
+ return AATREE_PTR_NIL;
+}
+
+/* Get the length of a string, bounded by '\0' or len, whichever is first */
+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) */
+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 */
+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) */
+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];
+ }