}
}
-VG_STATIC void world_write_preview( pointcloud_buffer *pcbuf ){
+VG_STATIC void world_write_preview( addon_reg *reg, pointcloud_buffer *pcbuf ){
+ if( reg->alias.workshop_id ) return;
+
+ /*
+ * FIXME: BUG: cannot correctly handle workshop because there is a stalling
+ * call below, which deadlocks the scene upload. TODO: improve the async
+ * stack to handle out of order execution. MAYBE
+ */
+
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 );
- }
-
+ addon_get_content_folder( reg, &path );
vg_strcat( &path, "/preview.bin" );
if( !vg_strgood( &path ) ) vg_fatal_error( "Path too long\n" );
fwrite( pcbuf, sizeof(struct pointcloud_buffer) +
sizeof(struct pointcloud_vert)*pcbuf->count, 1, fp );
fclose( fp );
+ vg_info( "written %s\n", path_buf );
}
/*
* Create the strips of colour that run through the world along course paths
*/
-VG_STATIC void world_gen_routes_generate(void)
-{
- world_instance *world = world_loading_instance();
+VG_STATIC void world_gen_routes_generate( u32 instance_id ){
+ world_instance *world = &world_static.instances[ instance_id ];
vg_info( "Generating route meshes\n" );
vg_async_stall();
vg_async_item *call_pointcloud = NULL;
pointcloud_buffer *pcbuf = NULL;
- if( world_loader.generate_point_cloud ){
+ if( instance_id <= 1 /*world_loader.generate_point_cloud*/ ){
call_pointcloud = vg_async_alloc(
sizeof(pointcloud_buffer) +
sizeof(pointcloud_vert)*POINTCLOUD_POINTS );
world_routes_gen_meshes( world, i, &world->scene_lines, pcbuf );
}
- if( world_loader.generate_point_cloud ){
+ if( instance_id <= 1 /*world_loader.generate_point_cloud*/ ){
f64 area = 0.0;
area = world_routes_scatter_surface_points( world, pcbuf, 16.0f );
world_routes_surface_grid( world, pcbuf );
vg_info( "Distrubuted %u points over %fkm^2!\n",
pcbuf->count, area/1e6f );
- world_write_preview( pcbuf );
+ world_write_preview( instance_id? world_static.addon_client:
+ world_static.addon_hub,
+ pcbuf );
vg_async_dispatch( call_pointcloud, async_pointcloud_sub );
}
}
/* load all routes from model header */
-VG_STATIC void world_gen_routes_ent_init(void)
-{
- world_instance *world = world_loading_instance();
+VG_STATIC void world_gen_routes_ent_init( world_instance *world ){
vg_info( "Initializing routes\n" );
for( u32 i=0; i<mdl_arrcount(&world->ent_gate); i++ ){