X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_routes.c;h=8567cdb7cc580513f120737f6bb78d5a3bf8cf75;hb=73adac381b2c72f08293416a960942dc40db3c7f;hp=1ff33fe8501e9b90201613f1e0701fd63119257a;hpb=d07048b61445be11605adba43667e19214358a24;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_routes.c b/world_routes.c index 1ff33fe..8567cdb 100644 --- a/world_routes.c +++ b/world_routes.c @@ -178,7 +178,7 @@ VG_STATIC void world_routes_debug( world_instance *world ) { for( u32 i=0; ient_route_node); i++ ){ ent_route_node *rn = mdl_arritm(&world->ent_route_node,i); - vg_line_pt3( rn->co, 0.25f, VG__WHITE ); + vg_line_point( rn->co, 0.25f, VG__WHITE ); } for( u32 i=0; ient_route); i++ ){ @@ -767,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->alias.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 */ @@ -861,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 ); }