X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_routes.c;h=56e6e4b6c8bbae9dbcb50e3208a845668385366e;hb=7b1e8a237acc3121c86fab9b5946da6a8d3bf6c4;hp=d366a123e09ee0f3f5e079504dacf1e66bdbb440;hpb=9fb26bfce5b8130703a8c31818783912c2b3dfac;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_routes.c b/world_routes.c index d366a12..56e6e4b 100644 --- a/world_routes.c +++ b/world_routes.c @@ -31,17 +31,13 @@ void world_routes_local_set_record( world_instance *world, ent_route *route, if( time_centiseconds > (float)0xfffe ) /* skill issue */ return; - highscore_record temp; - temp.trackid = route->official_track_id; - temp.datetime = time(NULL); - temp.playerid = 0; - temp.points = 0; - temp.time = time_centiseconds; -#if 0 - highscores_push_record( &temp ); -#endif - struct track_info *ti = &track_infos[ route->official_track_id ]; + highscore_record *record = &ti->record; + record->trackid = route->official_track_id; + record->datetime = time(NULL); + record->playerid = 0; + record->points = 0; + record->time = time_centiseconds; ti->push = 1; if( ti->achievement_id ){ @@ -771,6 +767,33 @@ VG_STATIC void world_routes_surface_grid( world_instance *world, } } +VG_STATIC void world_write_preview( pointcloud_buffer *pcbuf ){ + char path_buf[4096]; + vg_str path; + vg_strnull( &path, path_buf, 4096 ); + + if( world_loader.reg ){ + /* Don't want to override the one we get from the workshop */ + if( world_loader.reg->workshop_id ) return; + + addon_get_content_folder( world_loader.reg, &path ); + } + else{ + vg_strcat( &path, "maps/" ); + vg_strcat( &path, world_loader.override_name ); + } + + vg_strcat( &path, "/preview.bin" ); + + if( !vg_strgood( &path ) ) vg_fatal_error( "Path too long\n" ); + FILE *fp = fopen( path_buf, "wb" ); + if( !fp ) vg_fatal_error( "Cannot open '%s' for writing\n", path_buf ); + + fwrite( pcbuf, sizeof(struct pointcloud_buffer) + + sizeof(struct pointcloud_vert)*pcbuf->count, 1, fp ); + fclose( fp ); +} + /* * Create the strips of colour that run through the world along course paths */ @@ -865,23 +888,7 @@ VG_STATIC void world_gen_routes_generate(void) vg_info( "Distrubuted %u points over %fkm^2!\n", pcbuf->count, area/1e6f ); - if( world_loader.location == k_world_load_type_local ){ - char path_buf[4096]; - vg_str path; - vg_strnull( &path, path_buf, 4096 ); - vg_strcat( &path, "maps/" ); - vg_strcat( &path, world_loader.name ); - vg_strcat( &path, "/preview.bin" ); - - if( !vg_strgood( &path ) ) vg_fatal_error( "Path too long\n" ); - FILE *fp = fopen( path_buf, "wb" ); - if( !fp ) vg_fatal_error( "Cannot open '%s' for writing\n", path_buf ); - - fwrite( pcbuf, sizeof(pcbuf) + - sizeof(struct pointcloud_vert)*pcbuf->count, 1, fp ); - fclose( fp ); - } - + world_write_preview( pcbuf ); vg_async_dispatch( call_pointcloud, async_pointcloud_sub ); }