mdl_load_array( meta, &world->ent_skateshop, "ent_skateshop", heap );
mdl_load_array( meta, &world->ent_swspreview,"ent_swspreview", heap );
mdl_load_array( meta, &world->ent_ccmd, "ent_ccmd", heap );
+ mdl_load_array( meta, &world->ent_challenge, "ent_challenge", heap );
mdl_array_ptr infos;
mdl_load_array( meta, &infos, "ent_worldinfo", vg_mem.scratch );
world_gen_routes_generate();
world_gen_compute_light_indices();
vg_async_call( async_world_postprocess_render, NULL, 0 );
+ vg_async_stall();
mdl_close( meta );
world->status = k_world_status_loaded;
}
-/*
- * op: k_async_op_world_loading
- * k_async_op_world_preloading
- * -----------------------------------------------------------------------------
- */
-
-static void async_skaterift_world_loaded( void *payload, u32 size )
-{
- skaterift_end_op();
+static void skaterift_world_change_done( void *payload, u32 size ){
+ world_loader.state = k_world_loader_none;
}
/*
* Does a complete world switch using the remaining free slots
*/
-static void skaterift_world_changer_thread( void *data )
-{
- if( world_loader.location == k_world_load_type_workshop ){
- vg_fatal_error( "Unimplemented\n" );
- }
-
+static void skaterift_world_changer_thread( void *_ ){
char path_buf[4096];
vg_str path;
vg_strnull( &path, path_buf, 4096 );
- vg_strcat( &path, "maps/" );
+
+ if( world_loader.reg ){
+ addon_get_content_folder( world_loader.reg, &path );
+ }
+ else {
+ vg_strcat( &path, "maps/" );
+ vg_strcat( &path, world_loader.override_name );
+ }
vg_str folder = path;
- vg_strcat( &folder, world_loader.name );
if( !vg_strgood( &folder ) ) {
vg_error( "Load target too long\n" );
- vg_async_call( workshop_async_any_complete, NULL, 0 );
return;
}
vg_dir dir;
if( !vg_dir_open(&dir, folder.buffer) ){
vg_error( "opendir('%s') failed\n", folder.buffer );
- vg_async_call( async_skaterift_world_loaded, NULL, 0 );
return;
}
}
}
- vg_async_call( async_skaterift_world_loaded, NULL, 0 );
+ vg_async_call( skaterift_world_change_done, NULL, 0 );
}
/* holding pattern before we can start loading the new world, since we might be
* waiting for audio to stop */
-static void skaterift_change_world_preupdate(void)
-{
+static void skaterift_change_world_preupdate(void){
for( u32 i=1; i<vg_list_size(world_static.worlds); i++ ){
world_instance *inst = &world_static.worlds[i];
}
vg_info( "worlds cleared, begining load\n" );
- skaterift_shift_op( k_async_op_world_loading );
+ world_loader.state = k_world_loader_load;
/* finally can start the loader */
vg_loader_start( skaterift_world_changer_thread, NULL );
}
/* places all loaded worlds into unloading state */
-static void skaterift_change_world( const char *world_name )
-{
- vg_info( "switching to %s\n", world_name );
+static void skaterift_change_world_start(void){
+ if( world_loader.reg ){
+ vg_info( "switching to %s ("PRINTF_U64"\n",
+ world_loader.reg->alias.foldername,
+ world_loader.reg->alias.workshop_id );
+ }
+ else{
+ vg_info( "switching to %s(local)\n", world_loader.override_name );
+ }
if( world_static.active_world != 0 ){
vg_error( "Cannot change worlds while in non-root world\n" );
}
else{
- skaterift_begin_op( k_async_op_world_preloading );
+ world_loader.state = k_world_loader_preload;
- vg_linear_clear( vg_mem.scratch );
- vg_strncpy( world_name, world_loader.name,
- vg_list_size(world_loader.name), k_strncpy_overflow_fatal );
-
+ vg_linear_clear( vg_mem.scratch ); /* ?? */
vg_info( "unloading old worlds\n" );
world_unlink_nonlocal( &world_static.worlds[0] );
/* console command for the above function */
static int skaterift_change_world_command( int argc, const char *argv[] )
{
- if( argc == 1 )
- skaterift_change_world( argv[0] );
+ if( argc == 1 ){
+ world_loader.reg = NULL;
+ vg_strncpy( argv[0], world_loader.override_name,
+ vg_list_size( world_loader.override_name ),
+ k_strncpy_always_add_null );
+ skaterift_change_world_start();
+ }
return 0;
}