From: hgn Date: Sat, 13 Jan 2024 13:42:59 +0000 (+0000) Subject: non-meaningful cleanup X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=03a46e5a504cfb2f8bef7254a66753f04540005f;p=carveJwlIkooP6JGAAIwe30JlM.git non-meaningful cleanup --- diff --git a/ent_skateshop.c b/ent_skateshop.c index 8aa5fbc..85a0fa4 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -10,7 +10,6 @@ #include "player.h" #include "gui.h" #include "menu.h" -#include "highscores.h" #include "steam.h" #include "addon.h" #include "save.h" diff --git a/highscores.c b/highscores.c deleted file mode 100644 index c72b987..0000000 --- a/highscores.c +++ /dev/null @@ -1,547 +0,0 @@ -#ifndef HIGHSCORES_C -#define HIGHSCORES_C - -#include "highscores.h" - -static int highscore_cmp_points( void *a, void *b ) -{ - highscore_record *pa = a, *pb = b; - return (int)pa->points - (int)pb->points; -} - -static int highscore_cmp_datetime( void *a, void *b ) -{ - highscore_record *pa = a, *pb = b; - - if( pa->datetime == pb->datetime ) return 0; - return pa->datetime < pb->datetime? 1: -1; -} - -static int highscore_cmp_time( void *a, void *b ) -{ - highscore_record *pa = a, *pb = b; - return (int)pb->time - (int)pa->time; -} - -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; -} - -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; -} - -static void highscores_create_db(void) -{ - struct highscore_system *sys = &highscore_system; - - vg_info( "Initializing database nodes\n" ); - memset( &sys->dbheader, 0, sizeof(highscore_database) ); - - sys->dbheader.pool_head = aatree_init_pool( &sys->aainfo, sys->pool_size ); - sys->dbheader.entry_capacity = sys->pool_size; - - for( int i=0; idbheader.tracks); i++ ) - { - highscore_track_table *table = &sys->dbheader.tracks[i]; - table->root_points = AATREE_PTR_NIL; - table->root_playerid = AATREE_PTR_NIL; - table->root_time = AATREE_PTR_NIL; - table->root_datetime = AATREE_PTR_NIL; - } - - /* Initialize secondary db */ - sys->dbheader.playerinfo_head = aatree_init_pool( - &sys->aainfo_playerinfo, - sys->playerinfo_pool_size ); - sys->dbheader.playerinfo_capacity = sys->playerinfo_pool_size; - sys->dbheader.playerinfo_root = AATREE_PTR_NIL; -} - -static int highscores_read( const char *path ){ - struct highscore_system *sys = &highscore_system; - - if( path == NULL ) - path = ".aadb"; - - FILE *fp = fopen( path, "rb" ); - if( fp ){ - vg_info( "Loading existing database\n" ); - - u64 count = fread( &sys->dbheader, sizeof(highscore_database), 1, fp ); - - if( count != 1 ) - { - vg_error( "Unexpected EOF reading database header\n" ); - return 0; - } - - count = fread( sys->data, sizeof(highscore_record), - sys->pool_size, fp ); - - if( count != sys->pool_size ) - { - vg_error( "Unexpected EOF reading database contents;" - " %lu records of %u were read\n", count, sys->pool_size ); - return 0; - } - - count = fread( sys->playerinfo_data, sizeof(highscore_playerinfo), - sys->playerinfo_pool_size, fp ); - - if( count != sys->playerinfo_pool_size ) - { - vg_error( "Unexpected EOF reading playerinfo contents;" - " %lu records of %u were read\n", count, - sys->playerinfo_pool_size ); - return 0; - } - - fclose( fp ); - return 1; - } - else - { - vg_low( "No existing database found (%s)\n", path ); - return 0; - } -} - -static void highscores_init( u32 pool_size, u32 playerinfo_pool_size ) -{ - struct highscore_system *sys = &highscore_system; - - sys->data = vg_linear_alloc( vg_mem.rtmemory, - pool_size*sizeof(highscore_record) ); - - sys->playerinfo_data = - 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; - sys->aainfo.stride = sizeof(highscore_record); - sys->aainfo.offset = offsetof(highscore_record,pool); - sys->aainfo.p_cmp = NULL; - - sys->aainfo_datetime.base = highscore_system.data; - sys->aainfo_datetime.stride = sizeof(highscore_record); - sys->aainfo_datetime.offset = offsetof(highscore_record,aa.datetime); - sys->aainfo_datetime.p_cmp = highscore_cmp_datetime; - - sys->aainfo_points.base = highscore_system.data; - sys->aainfo_points.stride = sizeof(highscore_record); - sys->aainfo_points.offset = offsetof(highscore_record,aa.points); - sys->aainfo_points.p_cmp = highscore_cmp_points; - - sys->aainfo_time.base = highscore_system.data; - sys->aainfo_time.stride = sizeof(highscore_record); - sys->aainfo_time.offset = offsetof(highscore_record,aa.time); - sys->aainfo_time.p_cmp = highscore_cmp_time; - - sys->aainfo_playerid.base = highscore_system.data; - sys->aainfo_playerid.stride = sizeof(highscore_record); - sys->aainfo_playerid.offset = offsetof(highscore_record,aa.playerid); - sys->aainfo_playerid.p_cmp = highscore_cmp_playerid; - - sys->aainfo_playerinfo_playerid.base = highscore_system.playerinfo_data; - sys->aainfo_playerinfo_playerid.stride = sizeof(highscore_playerinfo); - sys->aainfo_playerinfo_playerid.offset = - 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->aainfo_playerinfo.p_cmp = NULL; - - sys->playerinfo_pool_size = playerinfo_pool_size; - sys->pool_size = pool_size; -} - -static int highscores_serialize_all(void) -{ - struct highscore_system *sys = &highscore_system; - vg_info( "Serializing database\n" ); - - FILE *fp = fopen( ".aadb", "wb" ); - - if( !fp ) - { - vg_error( "Could not open .aadb\n" ); - return 0; - } - - fwrite( &sys->dbheader, sizeof(highscore_database), 1, fp ); - fwrite( sys->data, sizeof(highscore_record), - sys->dbheader.entry_capacity, fp ); - fwrite( sys->playerinfo_data, sizeof(highscore_playerinfo), - sys->dbheader.playerinfo_capacity, fp ); - - fclose( fp ); - return 1; -} - -static highscore_record *highscore_find_user_record( u64 playerid, - u32 trackid ) -{ - struct highscore_system *sys = &highscore_system; - - highscore_track_table *table = &sys->dbheader.tracks[trackid]; - highscore_record temp; - temp.playerid = playerid; - - aatree_ptr find = - aatree_find( &sys->aainfo_playerid, table->root_playerid, &temp ); - - if( find == AATREE_PTR_NIL ) - return NULL; - - return aatree_get_data( &sys->aainfo_playerid, find ); -} - -static aatree_ptr highscores_push_record( highscore_record *record ) -{ - struct highscore_system *sys = &highscore_system; - - vg_low( "Inserting record into database for track %hu\n",record->trackid ); - - 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) ); - - return AATREE_PTR_NIL; - } - - /* Search for existing record on this track */ - highscore_track_table *table = &sys->dbheader.tracks[record->trackid]; - aatree_ptr existing = aatree_find( &sys->aainfo_playerid, - table->root_playerid, - record ); - - if( existing != AATREE_PTR_NIL ){ - highscore_record *crecord = aatree_get_data( &sys->aainfo_playerid, - existing ); - - if( crecord->time < record->time || - (crecord->time == record->time && crecord->points > record->points)) - { - vg_low( "Not overwriting better score\n" ); - return existing; - } - - vg_low( "Freeing existing record for player %lu\n", record->playerid ); - table->root_playerid = aatree_del( &sys->aainfo_playerid, existing ); - table->root_datetime = aatree_del( &sys->aainfo_datetime, existing ); - table->root_points = aatree_del( &sys->aainfo_points, existing ); - table->root_time = aatree_del( &sys->aainfo_time, existing ); - - aatree_pool_free( &sys->aainfo, existing, &sys->dbheader.pool_head ); - } - - aatree_ptr index = - aatree_pool_alloc( &sys->aainfo, &sys->dbheader.pool_head ); - - if( index == AATREE_PTR_NIL ) - { - vg_error( "Database records are over capacity!\n" ); - return index; - } - - highscore_record *dst = aatree_get_data( &sys->aainfo, index ); - memset( dst, 0, sizeof(highscore_record) ); - - dst->trackid = record->trackid; - dst->datetime = record->datetime; - dst->playerid = record->playerid; - dst->points = record->points; - dst->time = record->time; - - table->root_time = - aatree_insert( &sys->aainfo_time, table->root_time, index ); - table->root_datetime = - aatree_insert( &sys->aainfo_datetime, table->root_datetime, index ); - table->root_playerid = - aatree_insert( &sys->aainfo_playerid, table->root_playerid, index ); - table->root_points = - aatree_insert( &sys->aainfo_points, table->root_points, index ); - - return index; -} - -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 */ -static int highscore_strlen( const char *str, int len ) -{ - int str_length; - for( str_length=0; str_length= 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 ) - return i; - - buf[ len-1 - (i ++) ] = '0' + (value % 10); - value /= 10; - } - - for( ;i=len ) - break; - - temp[ i ++ ] = '0' + (value % 10); - value /= 10; - } - - if( i>len ) - i = len; - - for( int j=0; jdbheader.tracks[ id ]; - aatree_ptr it = aatree_kth( &sys->aainfo_time, table->root_time, 0 ); - - highscore_strc ( buf+w*0, inf->name, w,w ); - highscore_clear( buf+w*1, '-', w ); - highscore_strl ( buf+w*2, " #| Player | Time ", 27 ); - - for( int i=0; iaainfo_time, it ); - highscore_playerinfo temp; - temp.playerid = record->playerid; - - aatree_ptr info_ptr = aatree_find( &sys->aainfo_playerinfo_playerid, - sys->dbheader.playerinfo_root, - &temp ); - - /* Player name */ - if( info_ptr == AATREE_PTR_NIL ) - highscore_strl( line+3, "unknown", 16 ); - else - { - highscore_playerinfo *inf = aatree_get_data( - &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, - seconds = centiseconds / 100, - minutes = seconds / 60; - - centiseconds %= 100; - seconds %= 60; - minutes %= 60; - - if( minutes > 9 ) minutes = 9; - - /* Timer */ - highscore_intr( line+20, minutes, 1, '0' ); - line[21] = ':'; - highscore_intr( line+22, seconds, 2, '0' ); - line[24] = '.'; - highscore_intr( line+25, centiseconds, 2, '0' ); - -#if 0 - /* Score */ - highscore_intl( line+22, record->points, 5 ); -#endif - it = aatree_next( &sys->aainfo_time, it ); - } -} - -/* Print string out to file using newlines. Count is number of records - * ( this requires a buffer of (count+3)*27 size */ -static void highscores_board_printf( FILE *fp, const char *buf, u32 count ) -{ - int w=27; - - for( int i=0; iupdate(); } -static void player__post_update(void){ +static void player__post_update(void) +{ struct player_subsystem_interface *sys = player_subsystems[ localplayer.subsystem ]; @@ -128,7 +129,8 @@ static void player__post_update(void){ /* * Applies gate transport to a player_interface */ -static void player__pass_gate( u32 id ){ +static void player__pass_gate( u32 id ) +{ world_instance *world = world_current_instance(); skaterift_record_frame( &skaterift.replay, 1 ); @@ -151,20 +153,16 @@ static void player__pass_gate( u32 id ){ m4x3_mulv( gate->transport, localplayer.cam.pos, localplayer.cam.pos ); - if( gate->flags & k_ent_gate_nonlocal ){ - /* FIXME: Code dupe with world_load.c */ - ent_spawn *rp = world_find_spawn_by_name( world, "start" ); - if( !rp ) rp = world_find_closest_spawn( world, (v3f){0.0f,0.0f,0.0f} ); - /* TODO: fallback to searching for a safe location using raycasts */ - assert(rp); - v3_copy( rp->transform.co, world->player_co ); - + if( gate->flags & k_ent_gate_nonlocal ) + { + world_default_spawn_pos( world, world->player_co ); world_static.active_instance = gate->target; player__clean_refs(); replay_clear( &skaterift.replay ); } - else { + else + { world_routes_activate_entry_gate( world, gate ); } @@ -178,7 +176,8 @@ static void player__pass_gate( u32 id ){ audio_unlock(); } -static void player_apply_transport_to_cam( m4x3f transport ){ +static void player_apply_transport_to_cam( m4x3f transport ) +{ /* Pre-emptively edit the camera matrices so that the motion vectors * are correct */ m4x3f transport_i; @@ -194,7 +193,8 @@ static void player_apply_transport_to_cam( m4x3f transport ){ m4x4_mul( world_gates.cam.mtx.v, transport_4, world_gates.cam.mtx.v ); } -static void player__im_gui(void){ +static void player__im_gui(void) +{ if( !k_player_debug_info ) return; ui_rect box = { diff --git a/skaterift.c b/skaterift.c index cdef5a4..aa0bc8d 100644 --- a/skaterift.c +++ b/skaterift.c @@ -48,7 +48,6 @@ #include "entity.c" #include "workshop.c" #include "addon.c" -#include "highscores.c" #include "save.c" #include "world_map.c" #include "network.c" diff --git a/workshop.c b/workshop.c index c074e15..1b3015f 100644 --- a/workshop.c +++ b/workshop.c @@ -14,7 +14,6 @@ #include "vg/vg_steam_ugc.h" #include "vg/vg_steam_friends.h" #include "steam.h" -#include "highscores.h" static struct ui_enum_opt workshop_form_visibility_opts[] = { { k_ERemoteStoragePublishedFileVisibilityPublic, "Public" }, @@ -1327,12 +1326,12 @@ static void workshop_form_gui_sidebar( ui_rect sidebar ) ui_fill( controls, ui_colour( k_ui_bg+1 ) ); char buf[32]; - strcpy( buf, "page " ); - int i = 5; - i += highscore_intl( buf+i, workshop_form.view_published_page_id+1, 4 ); - buf[ i ++ ] = '/'; - i += highscore_intl( buf+i, workshop_form.view_published_page_count, 4 ); - buf[ i ++ ] = '\0'; + vg_str str; + vg_strnull( &str, buf, sizeof(buf) ); + vg_strcat( &str, "page " ); + vg_strcati32( &str, workshop_form.view_published_page_id+1 ); + vg_strcatch( &str, '/' ); + vg_strcati32( &str, workshop_form.view_published_page_count ); ui_rect_pad( controls, (ui_px[2]){0,4} ); ui_rect info; diff --git a/world_entity.c b/world_entity.c index d8f4259..4402291 100644 --- a/world_entity.c +++ b/world_entity.c @@ -277,6 +277,19 @@ ent_spawn *world_find_spawn_by_name( world_instance *world, const char *name ) return rp; } +static void world_default_spawn_pos( world_instance *world, v3f pos ) +{ + ent_spawn *rp = world_find_spawn_by_name( world, "start" ); + if( !rp ) rp = world_find_closest_spawn( world, (v3f){0,0,0} ); + if( rp ) + v3_copy( rp->transform.co, pos ); + else + { + vg_error( "There are no valid spawns in the world\n" ); + v3_zero( pos ); + } +} + static void ent_volume_call( world_instance *world, ent_call *call ){ u32 index = mdl_entity_id_id( call->id ); ent_volume *volume = mdl_arritm( &world->ent_volume, index ); diff --git a/world_entity.h b/world_entity.h index 1e5e70c..a3c5f33 100644 --- a/world_entity.h +++ b/world_entity.h @@ -12,6 +12,7 @@ static ent_spawn *world_find_spawn_by_name( world_instance *world, const char *name ); static ent_spawn *world_find_closest_spawn( world_instance *world, v3f position ); +static void world_default_spawn_pos( world_instance *world, v3f pos ); static void world_entity_start( world_instance *world, vg_msg *sav ); static void world_entity_serialize( world_instance *world, vg_msg *sav ); diff --git a/world_info.h b/world_info.h index 772d9e1..3b29b1f 100644 --- a/world_info.h +++ b/world_info.h @@ -8,8 +8,6 @@ /* Purely an information header, shares common strings across client and * server programs. */ -#include "highscores.h" - struct track_info { const char *name, diff --git a/world_load.c b/world_load.c index b1363b7..6055d88 100644 --- a/world_load.c +++ b/world_load.c @@ -74,16 +74,20 @@ static void world_instance_load_mdl( u32 instance_id, const char *path ){ MDL_LOAD_ARRAY( meta, &infos, ent_worldinfo, vg_mem.scratch ); world->skybox = k_skybox_default; - if( mdl_arrcount(&infos) ){ + if( mdl_arrcount(&infos) ) + { world->info = *((ent_worldinfo *)mdl_arritm(&infos,0)); - if( world->meta.info.version >= 104 ){ - if( MDL_CONST_PSTREQ( &world->meta, world->info.pstr_skybox,"space")){ + if( world->meta.info.version >= 104 ) + { + if( MDL_CONST_PSTREQ( &world->meta, world->info.pstr_skybox,"space")) + { world->skybox = k_skybox_space; } } } - else{ + else + { world->info.pstr_author = 0; world->info.pstr_desc = 0; world->info.pstr_name = 0; @@ -131,21 +135,14 @@ static void world_instance_load_mdl( u32 instance_id, const char *path ){ /* init player position. * - this is overriden by the save state when(if) it loads */ - ent_spawn *rp = world_find_spawn_by_name( world, "start" ); - if( !rp ) rp = world_find_closest_spawn( world, (v3f){0.0f,0.0f,0.0f} ); - if( rp ) - v3_copy( rp->transform.co, world->player_co ); - else{ - /* FIXME: we need to find a safe place to put the player_co using - * raycasts. */ - v3_zero( world->player_co ); - } + world_default_spawn_pos( world, world->player_co ); /* allocate leaderboard buffers */ u32 bs = mdl_arrcount(&world->ent_route)*sizeof(struct leaderboard_cache); world->leaderboard_cache = vg_linear_alloc( heap, bs ); - for( u32 i=0; ient_route ); i ++ ){ + for( u32 i=0; ient_route ); i ++ ) + { struct leaderboard_cache *board = &world->leaderboard_cache[i]; board->data = vg_linear_alloc( heap, NETWORK_REQUEST_MAX ); board->status = k_request_status_client_error; @@ -347,8 +344,13 @@ static void skaterift_change_world_start( addon_reg *reg ){ } /* console command for the above function */ -static int skaterift_load_world_command( int argc, const char *argv[] ){ - if( !vg_loader_availible() ) return 0; /* FIXME */ +static int skaterift_load_world_command( int argc, const char *argv[] ) +{ + if( !vg_loader_availible() ) + { + vg_error( "Loading thread is currently unavailible\n" ); + return 0; + } if( argc == 1 ){ addon_alias q; diff --git a/world_render.c b/world_render.c index 613d3bf..9eac40e 100644 --- a/world_render.c +++ b/world_render.c @@ -565,19 +565,20 @@ static void world_render_challenges( world_instance *world, /* render texts */ font3d_bind( &gui.font, k_font_shader_world, 0, world, &skaterift.cam ); - char buf[32]; u32 count = 0; - for( u32 i=0; ient_challenge); i++ ){ + for( u32 i=0; ient_challenge); i++ ) + { ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i ); if( challenge->status ) count ++; } - int c=0; - c+=highscore_intl( buf+c, count, 3 ); - buf[c++] = '/'; - c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_challenge), 3 ); - buf[c++] = '\0'; + char buf[32]; + vg_str str; + vg_strnull( &str, buf, sizeof(buf) ); + vg_strcati32( &str, count ); + vg_strcatch( &str, '/' ); + vg_strcati32( &str, mdl_arrcount(&world->ent_challenge) ); f32 w = font3d_string_width( 1, buf ); m4x3f mlocal; @@ -586,7 +587,8 @@ static void world_render_challenges( world_instance *world, mlocal[3][1] = 0.0f; mlocal[3][2] = 0.0f; - for( u32 i=0; ient_challenge, index ); m4x3f mmdl; diff --git a/world_routes.c b/world_routes.c index ca072e6..b80e68e 100644 --- a/world_routes.c +++ b/world_routes.c @@ -10,7 +10,6 @@ #include "world_routes.h" #include "world_gate.h" #include "world_load.h" -#include "highscores.h" #include "network.h" #include "font.h" @@ -756,7 +755,11 @@ static void world_routes_update_timer_texts( world_instance *world ){ text->gate = gate; text->route = route; - if( route->valid_checkpoints >= route->checkpoints_count ){ + vg_str str; + vg_strnull( &str, text->text, sizeof(text->text) ); + + if( route->valid_checkpoints >= route->checkpoints_count ) + { double lap_time = world_static.time - route->timing_base, time_centiseconds = lap_time * 100.0; @@ -770,30 +773,32 @@ static void world_routes_update_timer_texts( world_instance *world ){ seconds %= 60; minutes %= 60; - if( minutes > 9 ) minutes = 9; + if( minutes > 9 ) + minutes = 9; - int j=0; - if( minutes ){ - highscore_intr( text->text, minutes, 1, ' ' ); j++; - text->text[j++] = ':'; + if( minutes ) + { + vg_strcati32r( &str, minutes, 1, ' ' ); + vg_strcatch( &str, ':' ); } - if( seconds >= 10 || minutes ){ - highscore_intr( text->text+j, seconds, 2, '0' ); j+=2; + if( seconds >= 10 || minutes ) + { + vg_strcati32r( &str, seconds, 2, '0' ); } - else{ - highscore_intr( text->text+j, seconds, 1, '0' ); j++; + else + { + vg_strcati32r( &str, seconds, 1, '0' ); } - text->text[j++] = '.'; - highscore_intr( text->text+j, centiseconds, 1, '0' ); j++; - text->text[j] = '\0'; + vg_strcatch( &str, '.' ); + vg_strcati32r( &str, centiseconds, 1, '0' ); } - else{ - highscore_intr( text->text, route->valid_checkpoints, 1, ' ' ); - text->text[1] = '/'; - highscore_intr( text->text+2, route->checkpoints_count+1, 1, ' ' ); - text->text[3] = '\0'; + else + { + vg_strcati32r( &str, route->valid_checkpoints, 1, ' ' ); + vg_strcatch( &str, '/' ); + vg_strcati32r( &str, route->checkpoints_count + 1, 1, ' ' ); } gui_font3d.font = &gui.font;