X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_routes.c;h=26261a1ed72cc56e4658827dbf83af118e24b1c6;hb=844527ec68c063d78d4993bd8e4053f9ddc47b78;hp=d2816d111ba4a4a45ddb4dbb26224911b734ac01;hpb=302b008f2298f54a95a5c5e0b46f2f573b49bb8e;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_routes.c b/world_routes.c index d2816d1..26261a1 100644 --- a/world_routes.c +++ b/world_routes.c @@ -133,7 +133,7 @@ VG_STATIC void world_routes_activate_entry_gate( world_instance *world, world_static.last_use = world_static.time; /* disable all routes and leave the world */ - if( rg->type == k_gate_type_nonlocel ){ + if( rg->flags & k_ent_gate_nonlocal ){ for( u32 i=0; ient_route); i++ ){ ent_route *route = mdl_arritm( &world->ent_route, i ); route->active_checkpoint = 0xffff; @@ -745,22 +745,20 @@ VG_STATIC void world_routes_surface_grid( world_instance *world, } } -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" ); @@ -770,14 +768,14 @@ VG_STATIC void world_write_preview( pointcloud_buffer *pcbuf ){ 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(); @@ -789,7 +787,7 @@ VG_STATIC void world_gen_routes_generate(void) 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 ); @@ -850,7 +848,7 @@ VG_STATIC void world_gen_routes_generate(void) 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 ); @@ -866,7 +864,9 @@ VG_STATIC void world_gen_routes_generate(void) 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 ); } @@ -875,9 +875,7 @@ VG_STATIC void world_gen_routes_generate(void) } /* 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; ient_gate); i++ ){ @@ -912,7 +910,8 @@ VG_STATIC void world_gen_routes_ent_init(void) } } - if( gate->type == k_gate_type_teleport ){ + if( (gate->flags & k_ent_gate_linked) & + !(gate->flags & k_ent_gate_nonlocal) ){ gate = mdl_arritm(&world->ent_gate, gate->target ); for( u32 k=0; k<4; k++ ){