-/*
- * Reciever for board completion; only promotes the status in the main thread
- */
-VG_STATIC void skateshop_async_board_loaded( void *payload, u32 size )
-{
- SDL_AtomicLock( &global_skateshop.sl_cache_access );
- struct cache_board *cache_ptr = payload;
- cache_ptr->last_use_time = vg.time;
- cache_ptr->state = k_cache_board_state_loaded;
-
- cache_ptr->reg_ptr->userdata = cache_ptr;
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- vg_success( "Async board loaded (%s)\n", cache_ptr->reg_ptr->foldername );
-}
-
-/*
- * Thread(or subroutine of thread), for checking view slots that weve installed.
- * Load the model if a view slot wants it
- */
-VG_STATIC void workshop_visibile_load_loop(void)
-{
- vg_info( "Running load loop\n" );
- char path_buf[4096];
- vg_str folder;
-
- for( u32 i=0; i<SKATESHOP_BOARD_CACHE_MAX; i++ ){
- struct cache_board *cache_ptr = &global_skateshop.cache[i];
-
- SDL_AtomicLock( &global_skateshop.sl_cache_access );
- if( cache_ptr->state == k_cache_board_state_load_request ){
- if( cache_ptr->reg_index >= addon_count(k_workshop_file_type_board) ){
- /* should maybe have a different value for this case */
- cache_ptr->state = k_cache_board_state_none;
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- continue;
- }
-
- /* continue with the request */
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
-
- cache_ptr->reg_ptr = get_addon_from_index( k_workshop_file_type_board,
- cache_ptr->reg_index );
-
- if( cache_ptr->reg_ptr->workshop_id ){
- vg_async_item *call =
- vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
-
- struct async_workshop_filepath_info *info = call->payload;
- info->buf = path_buf;
- info->id = cache_ptr->reg_ptr->workshop_id;
- info->len = vg_list_size(path_buf);
- vg_async_dispatch( call, async_workshop_get_filepath );
- vg_async_stall(); /* too bad! */
-
- if( path_buf[0] == '\0' ){
- vg_error( "Failed SteamAPI_GetItemInstallInfo(" PRINTF_U64 ")\n",
- cache_ptr->reg_ptr->workshop_id );
- goto file_is_broken;
- }
-
- folder.buffer = path_buf;
- folder.i = strlen(path_buf);
- folder.len = 4096;
- }
- else{
- vg_strnull( &folder, path_buf, 4096 );
- vg_strcat( &folder, "boards/" );
- vg_strcat( &folder, cache_ptr->reg_ptr->foldername );
- }
-
- /* load content files
- * --------------------------------- */
-
- vg_str content_path = folder;
-
- int found = 0;
- vg_msg msg;
- vg_msg_init( &msg, cache_ptr->reg_ptr->metadata,
- cache_ptr->reg_ptr->metadata_len );
- vg_msg_cmd cmd;
- while( vg_msg_next( &msg, &cmd ) ){
- if( (msg.depth == 0) && (cmd.code == k_vg_msg_code_kvstring) ){
- if( VG_STRDJB2_EQ( "content", cmd.key, cmd.key_djb2 ) ){
- vg_strcat( &content_path, "/" );
- vg_strcat( &content_path, cmd.value._buf );
- found = 1;
- break;
- }
- }
- }
-
- if( !vg_strgood( &content_path ) ) {
- vg_error( "Metadata path too long\n" );
- goto file_is_broken;
- }
-
- if( !found ){
- vg_error( "No content paths in metadata\n" );
- goto file_is_broken;
- }
-
- vg_info( "Load content: %s\n", content_path.buffer );
- player_board_load( &cache_ptr->board, content_path.buffer );
- vg_async_call( skateshop_async_board_loaded, cache_ptr, 0 );
- continue;
-
-file_is_broken:;
- SDL_AtomicLock( &global_skateshop.sl_cache_access );
- cache_ptr->state = k_cache_board_state_none;
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- }
- else
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- }
-}
-
-
-VG_STATIC void world_scan_thread( void *_args ){
- addon_mount_local_folder( k_workshop_file_type_world, "maps", ".mdl" );