#include "player.h"
#include "gui.h"
+/*
+ * Checks string equality but does a hash check first
+ */
static inline int const_str_eq( u32 hash, const char *str, const char *cmp )
{
if( hash == vg_strdjb2(cmp) )
return 0;
}
-static int skateshop_workshop_name_blacklisted( u32 hash, const char *name )
+/*
+ * Get an existing cache instance, allocate a new one to be loaded, or NULL if
+ * there is no space
+ */
+VG_STATIC struct cache_board *skateshop_cache_fetch( u32 registry_index )
{
- if( const_str_eq( hash, name, "skaterift_fish.mdl" ) ) return 1;
- return 0;
-}
-
-VG_STATIC void skateshop_loader_start( void (*pfn)(void *data) )
-{
- if( global_skateshop.loading )
- vg_fatal_error( "skateshop thread sync failure\n" );
+ struct registry_board *reg = NULL;
- global_skateshop.loading = 1;
- vg_loader_start( pfn, NULL );
-}
+ if( registry_index < global_skateshop.registry_count ){
+ reg = &global_skateshop.registry[ registry_index ];
-VG_STATIC void skateshop_async_post( void *payload, u32 size )
-{
- global_skateshop.loading = 0;
-}
+ if( reg->cache_ptr ){
+ return reg->cache_ptr;
+ }
+ }
-VG_STATIC
-struct dynamic_board *skateshop_lru_alloc( u32 id )
-{
+ /* lru eviction. should be a linked list maybe... */
double min_time = 1e300;
- struct dynamic_board *min_board = NULL;
+ struct cache_board *min_board = NULL;
- for( u32 i=0; i<MAX_DYNAMIC_BOARDS; i++ ){
- struct dynamic_board *db = &global_skateshop.dynamic_boards[i];
+ SDL_AtomicLock( &global_skateshop.sl_cache_access );
+ for( u32 i=0; i<SKATESHOP_BOARD_CACHE_MAX; i++ ){
+ struct cache_board *cache_ptr = &global_skateshop.cache[i];
- if( db->state == k_dynamic_board_state_loading )
- continue;
+ if( cache_ptr->state == k_cache_board_state_load_request ) continue;
+ if( cache_ptr->ref_count ) continue;
- if( db->ref_count )
- continue;
-
- if( db->last_use_time < min_time ){
- min_time = db->last_use_time;
- min_board = db;
+ if( cache_ptr->last_use_time < min_time ){
+ min_time = cache_ptr->last_use_time;
+ min_board = cache_ptr;
}
}
if( min_board ){
- if( min_board->state == k_dynamic_board_state_loaded ){
- struct board_registry *other =
- &global_skateshop.registry[min_board->registry_id];
+ if( min_board->state == k_cache_board_state_loaded ){
+ struct registry_board *other =
+ &global_skateshop.registry[ min_board->registry_id ];
vg_info( "Deallocating board: '%s'\n", min_board, other->filename );
player_board_unload( &min_board->board );
- other->dynamic = NULL;
+ other->cache_ptr = NULL;
}
- struct board_registry *reg = &global_skateshop.registry[id];
-
- vg_info( "Allocating board '%s' @%p\n", reg->filename, min_board );
+ if( reg ){
+ vg_info( "Allocating board (reg:%u) '%s'\n",
+ registry_index, reg->filename );
+ }
+ else{
+ vg_info( "Pre-allocating board (reg:%u) 'null'\n", registry_index );
+ }
- min_board->state = k_dynamic_board_state_loading;
- min_board->registry_id = id;
+ min_board->registry_id = registry_index;
min_board->last_use_time = vg.time;
min_board->ref_count = 0;
+ min_board->state = k_cache_board_state_load_request;
}
else{
vg_error( "No free boards to load registry!\n" );
}
+ SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
return min_board;
}
-VG_STATIC
-void skateshop_board_registry_path( struct board_registry *reg, char path[256] )
+VG_STATIC void skateshop_update_viewpage(void)
{
- if( reg->workshop ){
- snprintf( path, 256, "models/boards/workshop/%s/something.mdl",
- reg->filename );
- }
- else{
- snprintf( path, 256, "models/boards/%s", reg->filename );
- }
-}
+ u32 page = global_skateshop.selected_registry_id/SKATESHOP_VIEW_SLOT_MAX;
+
+ for( u32 i=0; i<SKATESHOP_VIEW_SLOT_MAX; i++ ){
+ struct shop_view_slot *slot = &global_skateshop.shop_view_slots[i];
+ u32 request_id = page*SKATESHOP_VIEW_SLOT_MAX + i;
+
+ if( slot->cache_ptr ) unwatch_cache_board( slot->cache_ptr );
-/* we can only keep using a viewslot pointer for multiple frames if we watch it
- * using this function */
-VG_STATIC void watch_dynamic_board( struct dynamic_board *db )
-{
- if( db->ref_count >= 32 ){
- vg_fatal_error( "dynamic board watch missmatch (limit is 32)\n" );
+ slot->cache_ptr = skateshop_cache_fetch( request_id );
+ if( slot->cache_ptr ) watch_cache_board( slot->cache_ptr );
}
-
- db->last_use_time = vg.time;
- db->ref_count ++;
}
-/* after this is called, the calling code only has access to the pointer for the
- * duration of a frame */
-VG_STATIC void unwatch_dynamic_board( struct dynamic_board *db )
+/* generic reciever */
+VG_STATIC void workshop_async_any_complete( void *data, u32 size )
{
- if( db->ref_count == 0 ){
- vg_fatal_error( "dynamic board unwatch missmatch (no watchers)\n" );
- }
-
- db->ref_count --;
+ workshop_end_op();
}
-VG_STATIC void skateshop_async_board_complete( void *payload, u32 size )
-{
- struct dynamic_board *db = payload;
-
- /* all possible view slots are 'listening' for this event,
- * which must be checked here */
- for( u32 i=0; i<vg_list_size(global_skateshop.shop_view_slots); i++ ){
- if( global_skateshop.shop_view_slots[i].db == db ){
- watch_dynamic_board( db );
- }
- }
+/*
+ * op/subroutine: k_workshop_op_item_load
+ * -----------------------------------------------------------------------------
+ */
- if( localplayer.board_view_slot == db ){
- watch_dynamic_board( db );
- }
-
- db->last_use_time = vg.time;
- db->state = k_dynamic_board_state_loaded;
+/*
+ * 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;
- struct board_registry *reg = &global_skateshop.registry[ db->registry_id ];
- reg->dynamic = db;
+ struct registry_board *reg =
+ &global_skateshop.registry[ cache_ptr->registry_id ];
+ reg->cache_ptr = cache_ptr;
+ SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
vg_success( "Async board loaded (%s)\n", reg->filename );
}
-VG_STATIC void skateshop_load_requested_boards(void)
+/*
+ * 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_thread( void *_args )
{
- char path[256];
- for( u32 i=0; i<MAX_DYNAMIC_BOARDS; i++ ){
- struct dynamic_board *db = &global_skateshop.dynamic_boards[i];
-
- if( db->state == k_dynamic_board_state_loading ){
- struct board_registry *reg =
- &global_skateshop.registry[ db->registry_id ];
-
- skateshop_board_registry_path( reg, path );
- player_board_load( &db->board, path );
- vg_async_call( skateshop_async_board_complete, db, 0 );
- }
- }
-}
+ char path[1024];
+ 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->registry_id >= global_skateshop.registry_count ){
+ /* 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;
+ }
-VG_STATIC void skateshop_thread1_refresh( void *data )
-{
- skateshop_load_requested_boards();
- vg_async_call( skateshop_async_post, NULL, 0 );
-}
+ /* continue with the request */
+ SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
-VG_STATIC int skateshop_use_board( int argc, const char *argv[] )
-{
- if( global_skateshop.loading ){
- vg_error( "Cannot use skateshop currently (loader thread missing)\n" );
- return 0;
- }
+ struct registry_board *reg =
+ &global_skateshop.registry[ cache_ptr->registry_id ];
- if( argc == 1 ){
- u32 hash = vg_strdjb2( argv[0] );
+ if( reg->workshop_id ){
+ vg_async_item *call =
+ vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
- for( u32 i=0; i<global_skateshop.registry_count; i++ ){
- struct board_registry *reg = &global_skateshop.registry[i];
+ struct async_workshop_filepath_info *info = call->payload;
+ info->buf = path;
+ info->id = reg->workshop_id;
+ info->len = vg_list_size(path) - strlen("/board.mdl")-1;
+ vg_async_dispatch( call, async_workshop_get_filepath );
+ vg_async_stall(); /* too bad! */
- if( const_str_eq( hash, argv[0], reg->filename ) ){
- if( reg->dynamic ){
- struct dynamic_board *db = reg->dynamic;
+ if( path[0] == '\0' ){
+ SDL_AtomicLock( &global_skateshop.sl_cache_access );
+ cache_ptr->state = k_cache_board_state_none;
+ SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- if( db->state == k_dynamic_board_state_loaded ){
- localplayer.board_view_slot = db;
- watch_dynamic_board( db );
- }
- else{
- vg_fatal_error( "Invalid state while loading board\n" );
- }
+ vg_error( "Failed SteamAPI_GetItemInstallInfo(" PRINTF_U64 ")\n",
+ reg->workshop_id );
+ continue;
}
else{
- if( localplayer.board_view_slot ){
- unwatch_dynamic_board( localplayer.board_view_slot );
- localplayer.board_view_slot = NULL;
- }
-
- struct dynamic_board *db = skateshop_lru_alloc( i );
- localplayer.board_view_slot = db;
- db->state = k_dynamic_board_state_loading;
- skateshop_loader_start( skateshop_thread1_refresh );
+ strcat( path, "/board.mdl" );
}
- return 1;
}
+ else{
+ snprintf( path, 256, "models/boards/%s", reg->filename );
+ }
+
+ player_board_load( &cache_ptr->board, path );
+ vg_async_call( skateshop_async_board_loaded, cache_ptr, 0 );
}
+ else
+ SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
}
- return 0;
+ vg_async_call( workshop_async_any_complete, NULL, 0 );
}
-VG_STATIC void skateshop_use_board_suggest( int argc, const char *argv[] )
-{
- if( argc == 1 ){
- for( u32 i=0; i<global_skateshop.registry_count; i++ ){
- struct board_registry *reg = &global_skateshop.registry[i];
-
- if( reg->ghost ) continue; /* we probably can't load these */
+/*
+ * op: k_workshop_op_item_scan
+ * -----------------------------------------------------------------------------
+ */
- console_suggest_score_text( reg->filename, argv[0], 0 );
- }
- }
+/*
+ * Reciever for scan completion. copies the registry_count back into t0
+ */
+VG_STATIC void workshop_async_reg_update( void *data, u32 size )
+{
+ vg_info( "Registry update notify\n" );
+ global_skateshop.registry_count = global_skateshop.t1_registry_count;
}
-VG_STATIC void skateshop_scan_for_items( void *data )
+/*
+ * Async thread which scans local files for boards, as well as scheduling
+ * synchronous calls to the workshop
+ */
+VG_STATIC void workshop_scan_thread( void *_args )
{
vg_linear_clear( vg_mem.scratch );
- for( u32 i=0; i<global_skateshop.registry_count; i++ ){
- struct board_registry *reg = &global_skateshop.registry[i];
- reg->ghost = 1;
+ for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
+ struct registry_board *reg = &global_skateshop.registry[i];
+ reg->state = k_registry_board_state_indexed_absent;
}
+ /*
+ * Local disk scan
+ */
+ vg_info( "Scanning models/boards/*.mdl\n" );
tinydir_dir dir;
tinydir_open( &dir, "models/boards" );
if( file.is_reg ){
u32 hash = vg_strdjb2( file.name );
- for( u32 i=0; i<global_skateshop.registry_count; i++ ){
- struct board_registry *reg = &global_skateshop.registry[i];
+ for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
+ struct registry_board *reg = &global_skateshop.registry[i];
if( const_str_eq( hash, file.name, reg->filename ) ){
- reg->ghost = 0;
+ reg->state = k_registry_board_state_indexed;
goto next_file;
}
}
- if( global_skateshop.registry_count == MAX_LOCAL_BOARDS ){
+ if( global_skateshop.t1_registry_count == SKATESHOP_REGISTRY_MAX ){
vg_error( "You have too many boards installed!\n" );
break;
}
vg_info( "new listing!: %s\n", file.name );
- struct board_registry *reg = &global_skateshop.registry[
- global_skateshop.registry_count ++ ];
+ struct registry_board *reg =
+ &global_skateshop.registry[global_skateshop.t1_registry_count ++];
- reg->dynamic = NULL;
+ reg->cache_ptr = NULL;
vg_strncpy( file.name, reg->filename, 64, k_strncpy_always_add_null );
reg->filename_hash = hash;
- reg->uid = 0;
- reg->workshop = 0;
- reg->ghost = 0;
+ reg->workshop_id = 0;
+ reg->state = k_registry_board_state_indexed;
}
next_file: tinydir_next( &dir );
tinydir_close(&dir);
- skateshop_load_requested_boards();
- vg_async_call( skateshop_async_post, NULL, 0 );
-}
-
-VG_STATIC void global_skateshop_exit(void)
-{
- vg_info( "exit skateshop\n" );
- localplayer.immobile = 0;
- global_skateshop.active = 0;
- srinput.ignore_input_frames = 2;
-}
-
-VG_STATIC void skateshop_request_viewpage( u32 page )
-{
- u32 slot_count = vg_list_size(global_skateshop.shop_view_slots);
- u32 start = page * slot_count;
+ /*
+ * Steam workshop scan
+ */
+ vg_info( "Scanning steam workshop for boards\n" );
+ PublishedFileId_t workshop_ids[ SKATESHOP_REGISTRY_MAX ];
+ u32 workshop_count = SKATESHOP_REGISTRY_MAX;
+
+ vg_async_item *call = vg_async_alloc(
+ sizeof(struct async_workshop_installed_files_info));
+ struct async_workshop_installed_files_info *info = call->payload;
+ info->buffer = workshop_ids;
+ info->len = &workshop_count;
+ vg_async_dispatch( call, async_workshop_get_installed_files );
+ vg_async_stall();
+
+ for( u32 j=0; j<workshop_count; j++ ){
+ PublishedFileId_t id = workshop_ids[j];
+
+ for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
+ struct registry_board *reg = &global_skateshop.registry[i];
+
+ if( reg->workshop_id == id ){
+ reg->state = k_registry_board_state_indexed;
+ goto next_file_workshop;
+ }
+ }
- for( u32 i=0; i<slot_count; i++ ){
- struct shop_view_slot *slot = &global_skateshop.shop_view_slots[i];
-
- if( slot->db ){
- slot->db->ref_count --;
- slot->db = NULL;
+ if( global_skateshop.t1_registry_count == SKATESHOP_REGISTRY_MAX ){
+ vg_error( "You have too many boards installed!\n" );
+ break;
}
- u32 reg_index = start+i;
- if( reg_index < global_skateshop.registry_count ){
- struct board_registry *reg = &global_skateshop.registry[ reg_index ];
+ vg_info( "new listing from the steam workshop!: "PRINTF_U64"\n", id );
- if( reg->dynamic ){
- struct dynamic_board *db = reg->dynamic;
+ struct registry_board *reg = &global_skateshop.registry[
+ global_skateshop.t1_registry_count ++ ];
- if( db->state == k_dynamic_board_state_loaded ){
- db->last_use_time = vg.time;
- db->ref_count ++;
- slot->db = db;
- }
- else{
- vg_fatal_error( "Invalid state while loading page\n" );
- }
- }
- else{
- struct dynamic_board *db = skateshop_lru_alloc( reg_index );
+ reg->cache_ptr = NULL;
+ snprintf( reg->filename, 64, PRINTF_U64, id );
+ reg->filename_hash = vg_strdjb2( reg->filename );
+ reg->workshop_id = id;
+ reg->state = k_registry_board_state_indexed;
- if( db ){
- db->ref_count ++;
- slot->db = db;
- }
- }
- }
+next_file_workshop:;
}
+
+ vg_async_call( workshop_async_reg_update, NULL, 0 );
+ vg_async_stall();
+ workshop_visibile_load_loop_thread(NULL);
}
-VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
+/*
+ * Asynchronous scan of local disk for items and add them to the registry
+ */
+VG_STATIC void workshop_op_item_scan(void)
{
- u32 index = mdl_entity_id_id( call->id );
- ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index );
- vg_info( "skateshop_call\n" );
+ workshop_begin_op( k_workshop_op_item_scan );
+ vg_loader_start( workshop_scan_thread, NULL );
+}
- if( global_skateshop.loading ){
- vg_error( "Cannot enter skateshop currently (loader thread missing)\n" );
- return;
+/*
+ * Regular stuff
+ * -----------------------------------------------------------------------------
+ */
+
+/* we can only keep using a viewslot pointer for multiple frames if we watch it
+ * using this function */
+VG_STATIC void watch_cache_board( struct cache_board *ptr )
+{
+ if( ptr->ref_count >= 32 ){
+ vg_fatal_error( "dynamic board watch missmatch (limit is 32)\n" );
}
- if( call->function == k_ent_function_trigger ){
- if( localplayer.subsystem != k_player_subsystem_walk ){
- return;
- }
-
- vg_info( "Entering skateshop\n" );
+ ptr->last_use_time = vg.time;
+ ptr->ref_count ++;
+}
- localplayer.immobile = 1;
- global_skateshop.active = 1;
- global_skateshop.interface_loc = k_skateshop_loc_page__viewing;
+/* after this is called, the calling code only has access to the pointer for the
+ * duration of the rest of the frame */
+VG_STATIC void unwatch_cache_board( struct cache_board *ptr )
+{
+ if( ptr->ref_count == 0 ){
+ vg_fatal_error( "dynamic board unwatch missmatch (no watchers)\n" );
+ }
- v3_zero( localplayer.rb.v );
- v3_zero( localplayer.rb.w );
- localplayer._walk.move_speed = 0.0f;
+ ptr->ref_count --;
+}
- global_skateshop.ptr_ent = shop;
+/*
+ * VG event init
+ */
+VG_STATIC void skateshop_init(void)
+{
+ u32 reg_size = sizeof(struct registry_board)*SKATESHOP_REGISTRY_MAX,
+ cache_size = sizeof(struct cache_board)*SKATESHOP_BOARD_CACHE_MAX;
+
+ global_skateshop.registry = vg_linear_alloc( vg_mem.rtmemory, reg_size );
+ global_skateshop.registry_count = 0;
+ global_skateshop.cache = vg_linear_alloc( vg_mem.rtmemory, cache_size );
- skateshop_request_viewpage(0);
- skateshop_loader_start( skateshop_scan_for_items );
+ memset( global_skateshop.cache, 0, cache_size );
+
+ for( u32 i=0; i<SKATESHOP_BOARD_CACHE_MAX; i++ ){
+ struct cache_board *board = &global_skateshop.cache[i];
+ board->state = k_cache_board_state_none;
+ board->registry_id = 0xffffffff;
+ board->last_use_time = -99999.9;
+ board->ref_count = 0;
}
}
+VG_STATIC struct cache_board *skateshop_selected_cache_if_loaded(void)
+{
+ if( global_skateshop.registry_count > 0 ){
+ u32 reg_id = global_skateshop.selected_registry_id;
+ struct registry_board *reg = &global_skateshop.registry[ reg_id ];
+
+ SDL_AtomicLock( &global_skateshop.sl_cache_access );
+ if( reg->cache_ptr &&
+ (reg->cache_ptr->state == k_cache_board_state_loaded ) )
+ {
+ SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
+ return reg->cache_ptr;
+ }
+ SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
+ }
+
+ return NULL;
+}
+
+/*
+ * VG event preupdate
+ */
VG_STATIC void global_skateshop_preupdate(void)
{
float rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f );
v3_copy( ref->transform.co, localplayer.cam_override_pos );
localplayer.cam_override_fov = ref->fov;
-
localplayer.cam_override_strength = global_skateshop.factive;
+ gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" );
+ gui_helper_action( button_display_string( k_srbind_mback ), "exit" );
+
+ int moved = 0;
+ struct cache_board *selected_cache = skateshop_selected_cache_if_loaded();
+
+ if( selected_cache ){
+ gui_helper_action( button_display_string( k_srbind_maccept ), "pick" );
+ }
+
+ /*
+ * Controls
+ * ----------------------
+ */
+
if( global_skateshop.interaction_cooldown > 0.0f ){
global_skateshop.interaction_cooldown -= vg.time_delta;
return;
}
- if( global_skateshop.interface_loc <= k_skateshop_loc_page__viewing ){
-
- gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" );
- gui_helper_action( button_display_string( k_srbind_mback ), "exit" );
-
- u32 reg_id = global_skateshop.selected_registry_id;
- struct board_registry *picker = &global_skateshop.registry[ reg_id ];
-
- int pick_availible = 0;
- if( picker->dynamic &&
- (picker->dynamic->state == k_dynamic_board_state_loaded ) )
- {
- pick_availible = 1;
- gui_helper_action( button_display_string( k_srbind_maccept ), "pick" );
+ if( button_down( k_srbind_mleft ) ){
+ if( global_skateshop.selected_registry_id > 0 ){
+ global_skateshop.selected_registry_id --;
+ moved = 1;
}
-
- int moved = 0;
+ }
- if( button_down( k_srbind_mleft ) ){
- if( global_skateshop.selected_registry_id > 0 ){
- global_skateshop.selected_registry_id --;
- moved = 1;
- }
+ if( button_down( k_srbind_mright ) ){
+ if( global_skateshop.selected_registry_id+1 <
+ global_skateshop.registry_count )
+ {
+ global_skateshop.selected_registry_id ++;
+ moved = 1;
}
+ }
- if( button_down( k_srbind_mright ) ){
- if( global_skateshop.selected_registry_id <
- global_skateshop.registry_count-1 )
- {
- global_skateshop.selected_registry_id ++;
- moved = 1;
- }
- }
+ if( moved ){
+ vg_info( "Select registry: %u\n",
+ global_skateshop.selected_registry_id );
+ global_skateshop.interaction_cooldown = 0.125f;
+ return;
+ }
- if( moved ){
- vg_info( "Select registry: %u\n",
+ if( selected_cache && button_down( k_srbind_maccept ) ){
+ vg_info( "chose board from skateshop (%u)\n",
global_skateshop.selected_registry_id );
- global_skateshop.interaction_cooldown = 0.125f;
- return;
- }
- if( pick_availible && button_down( k_srbind_maccept ) ){
- vg_info( "chose board from skateshop (%u)\n", reg_id );
-
- if( localplayer.board_view_slot ){
- unwatch_dynamic_board( localplayer.board_view_slot );
- localplayer.board_view_slot = NULL;
- }
-
- localplayer.board_view_slot = picker->dynamic;
- watch_dynamic_board( localplayer.board_view_slot );
-
- global_skateshop_exit();
- return;
+ if( localplayer.board_view_slot ){
+ unwatch_cache_board( localplayer.board_view_slot );
}
- if( button_down( k_srbind_mback ) ){
- global_skateshop_exit();
- return;
- }
- }
-}
+ localplayer.board_view_slot = selected_cache;
+ watch_cache_board( localplayer.board_view_slot );
-VG_STATIC void skateshop_init(void)
-{
- global_skateshop.registry =
- vg_linear_alloc( vg_mem.rtmemory,
- sizeof(struct board_registry)*MAX_LOCAL_BOARDS );
- global_skateshop.registry_count = 0;
- global_skateshop.dynamic_boards =
- vg_linear_alloc( vg_mem.rtmemory,
- sizeof(struct dynamic_board)*MAX_DYNAMIC_BOARDS );
-
- memset( global_skateshop.dynamic_boards, 0,
- sizeof(struct dynamic_board)*MAX_DYNAMIC_BOARDS );
-
- for( u32 i=0; i<MAX_DYNAMIC_BOARDS; i++ ){
- struct dynamic_board *board = &global_skateshop.dynamic_boards[i];
- board->state = k_dynamic_board_state_none;
- board->registry_id = 0xffffffff;
- board->last_use_time = -99999.9;
- board->ref_count = 0;
+ global_skateshop_exit();
+ return;
}
- vg_console_reg_cmd( "use_board",
- skateshop_use_board, skateshop_use_board_suggest );
-
- //skateshop_scan_for_items(NULL);
+ if( button_down( k_srbind_mback ) ){
+ global_skateshop_exit();
+ return;
+ }
}
+/*
+ * World: render event
+ */
VG_STATIC void skateshop_render(void)
{
if( !global_skateshop.active ) return;
mdl_entity_id_id(shop->id_rack)),
*mark_display = mdl_arritm( &world->ent_marker,
mdl_entity_id_id(shop->id_display));
+
+ int visibility[ SKATESHOP_VIEW_SLOT_MAX ];
+ SDL_AtomicLock( &global_skateshop.sl_cache_access );
+ for( u32 i=0; i<SKATESHOP_VIEW_SLOT_MAX; i++ ){
+ struct shop_view_slot *slot = &global_skateshop.shop_view_slots[i];
+
+ visibility[i] = 1;
+
+ if( slot->cache_ptr == NULL ) visibility[i] = 0;
+ else if( slot->cache_ptr->state != k_cache_board_state_loaded )
+ visibility[i] = 0;
+ }
+ SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
+ /* Render loaded boards in the view slots */
for( u32 i=0; i<slot_count; i++ ){
struct shop_view_slot *slot = &global_skateshop.shop_view_slots[i];
-
float selected = 0.0f;
-
- if( !slot->db )
- goto set_fade_amt;
- if( slot->db->state != k_dynamic_board_state_loaded )
- goto set_fade_amt;
+ if( !visibility[i] ) goto fade_out;
mdl_transform xform;
transform_identity( &xform );
xform.co[0] = -((float)i - ((float)slot_count)*0.5f)*0.45f;
-
mdl_transform_mul( &mark_rack->transform, &xform, &xform );
- if( slot->db->registry_id == global_skateshop.selected_registry_id ){
+ if( slot->cache_ptr->registry_id ==
+ global_skateshop.selected_registry_id ){
selected = 1.0f;
}
m4x3f mmdl;
mdl_transform_m4x3( &xform, mmdl );
- render_board( &main_camera, world, &slot->db->board, mmdl,
+ render_board( &main_camera, world, &slot->cache_ptr->board, mmdl,
k_board_shader_entity );
-set_fade_amt:;
+fade_out:;
float rate = 5.0f*vg.time_delta;
slot->view_blend = vg_lerpf( slot->view_blend, selected, rate );
}
ent_marker *mark_info = mdl_arritm( &world->ent_marker,
- mdl_entity_id_id(shop->id_info));
+ mdl_entity_id_id(shop->id_info));
m4x3f mtext, mrack;
mdl_transform_m4x3( &mark_info->transform, mtext );
mdl_transform_m4x3( &mark_rack->transform, mrack );
m4x3f mlocal, mmdl;
m4x3_identity( mlocal );
- /* Skin title
- * ----------------------------------------------------------------- */
float scale = 0.2f,
thickness = 0.03f;
+ font3d_bind( &world_global.font, &main_camera );
+ shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} );
+
+ /* Selection counter
+ * ------------------------------------------------------------------ */
+ m3x3_zero( mlocal );
+ v3_zero( mlocal[3] );
+ mlocal[0][0] = -scale*2.0f;
+ mlocal[1][2] = -scale*2.0f;
+ mlocal[2][1] = -thickness;
+ mlocal[3][2] = -0.7f;
+ m4x3_mul( mrack, mlocal, mmdl );
+
+ if( global_skateshop.registry_count == 0 ){
+ font3d_simple_draw( &world_global.font, 0,
+ "Nothing installed", &main_camera, mmdl );
+ }
+ else{
+ char buf[16];
+ int i=0;
+ i+=highscore_intl( buf+i, global_skateshop.selected_registry_id+1, 3 );
+ buf[i++] = '/';
+ i+=highscore_intl( buf+i, global_skateshop.registry_count, 3 );
+ buf[i++] = '\0';
+
+ font3d_simple_draw( &world_global.font, 0, buf, &main_camera, mmdl );
+ }
+
+ struct cache_board *cache_ptr = skateshop_selected_cache_if_loaded();
+ if( !cache_ptr ) return;
+
+ /* Skin title
+ * ----------------------------------------------------------------- */
m3x3_setdiagonalv3( mlocal, (v3f){ scale, scale, thickness } );
mlocal[3][0] = -font3d_string_width(&world_global.font,0,text_title);
mlocal[3][0] *= scale*0.5f;
mlocal[3][1] = 0.1f;
m4x3_mul( mtext, mlocal, mmdl );
-
- font3d_bind( &world_global.font, &main_camera );
-
- shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} );
font3d_simple_draw( &world_global.font, 0, text_title, &main_camera, mmdl );
/* Author name
mlocal[3][1] = 0.0f;
m4x3_mul( mtext, mlocal, mmdl );
font3d_simple_draw( &world_global.font, 0, text_author, &main_camera, mmdl );
+}
- /* Selection counter
- * ------------------------------------------------------------------ */
- scale = 0.4f;
- m3x3_zero( mlocal );
- v3_zero( mlocal[3] );
- mlocal[0][0] = -scale;
- mlocal[1][2] = -scale;
- mlocal[2][1] = -thickness;
- mlocal[3][2] = -0.7f;
- m4x3_mul( mrack, mlocal, mmdl );
+/*
+ * Entity logic: entrance event
+ */
+VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
+{
+ u32 index = mdl_entity_id_id( call->id );
+ ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index );
+ vg_info( "skateshop_call\n" );
- char buf[16];
- int i=0;
- i+=highscore_intl( buf+i, global_skateshop.selected_registry_id+1, 3 );
- buf[i++] = '/';
- i+=highscore_intl( buf+i, global_skateshop.registry_count, 3 );
- buf[i++] = '\0';
+ if( call->function == k_ent_function_trigger ){
+ if( localplayer.subsystem != k_player_subsystem_walk ){
+ return;
+ }
+
+ vg_info( "Entering skateshop\n" );
+
+ localplayer.immobile = 1;
+ global_skateshop.active = 1;
- font3d_simple_draw( &world_global.font, 0, buf, &main_camera, mmdl );
+ v3_zero( localplayer.rb.v );
+ v3_zero( localplayer.rb.w );
+ localplayer._walk.move_speed = 0.0f;
+ global_skateshop.ptr_ent = shop;
+
+ skateshop_update_viewpage();
+ workshop_op_item_scan();
+ }
+}
+
+/*
+ * Entity logic: exit event
+ */
+VG_STATIC void global_skateshop_exit(void)
+{
+ vg_info( "exit skateshop\n" );
+ localplayer.immobile = 0;
+ global_skateshop.active = 0;
+ srinput.ignore_input_frames = 2;
}
#endif /* ENT_SKATESHOP_C */
char description[512];
PublishedFileId_t file_id; /* 0 if not published yet */
- ERemoteStoragePublishedFileVisibility visibility;
+
+ struct ui_dropdown_value visibility;
int submit_title, /* set if the respective controls are touched */
submit_description,
}
page;
- enum workshop_form_operation{
- k_workshop_form_op_none,
- k_workshop_form_op_loading_model,
- k_workshop_form_op_downloading_submission,
- k_workshop_form_op_publishing_update,
- }
- operation;
-
/* model viewer
* -----------------------------
*/
}
static workshop_form;
-/*
- * Start a new operation and crash if we are already running one.
- */
-VG_STATIC void workshop_begin_op( enum workshop_form_operation op )
-{
- if( workshop_form.operation != k_workshop_form_op_none ){
- vg_fatal_error( "Workshop form currently executing op(%d), tried to "
- "start op(%d)\n", workshop_form.operation, op );
- }
-
- workshop_form.operation = op;
- vg_info( "Starting op( %d )\n", op );
-}
-
-/*
- * Finished operation, otheres can now run
- */
-VG_STATIC void workshop_end_op(void)
-{
- vg_info( "Finishing op( %d )\n", workshop_form.operation );
- workshop_form.operation = k_workshop_form_op_none;
-}
+static struct ui_dropdown_opt workshop_form_visibility_opts[] = {
+ { "Public", k_ERemoteStoragePublishedFileVisibilityPublic },
+ { "Unlisted", k_ERemoteStoragePublishedFileVisibilityUnlisted },
+ { "Friends Only", k_ERemoteStoragePublishedFileVisibilityFriendsOnly },
+ { "Private", k_ERemoteStoragePublishedFileVisibilityPrivate },
+};
/*
* Close the form and discard UGC query result
}
workshop_form.page = k_workshop_form_hidden;
+ workshop_end_op();
}
/*
workshop_form.submission.file_id = 0; /* assuming id of 0 is none/invalid */
workshop_form.submission.description[0] = '\0';
workshop_form.submission.title[0] = '\0';
+
+ workshop_form.submission.visibility.value =
+ k_ERemoteStoragePublishedFileVisibilityPublic;
+ workshop_form.submission.visibility.index = 0;
+
workshop_form.model_path[0] = '\0';
player_board_unload( &workshop_form.board_model );
workshop_form.file_intent = k_workshop_form_file_intent_none;
vg_info( "Setting visibility\n" );
SteamAPI_ISteamUGC_SetItemVisibility( hSteamUGC, handle,
- workshop_form.submission.visibility );
+ workshop_form.submission.visibility.value );
vg_info( "Submitting updates\n" );
vg_steam_async_call *call = vg_alloc_async_steam_api_call();
if( result->m_bUserNeedsToAcceptWorkshopLegalAgreement ){
vg_warn( "Workshop agreement currently not accepted\n" );
}
-
+
workshop_package_submission( result->m_nPublishedFileId );
}
else{
{
/* use existing file */
if( workshop_form.submission.file_id ){
- workshop_package_submission( workshop_form.submission.file_id );
+ if( workshop_form.submission.submit_file_and_image ){
+ workshop_package_submission( workshop_form.submission.file_id );
+ }
+ else{
+ struct workshop_package_info info;
+ info.abs_content_file[0] = '\0';
+ info.abs_content_folder[0] = '\0';
+ info.abs_preview_image[0] = '\0';
+ info.failure_reason = NULL;
+ info.publishing_file_id = workshop_form.submission.file_id;
+ info.success = 1;
+ workshop_form_async_package_complete( &info,
+ sizeof(struct workshop_package_info) );
+ }
}
else{
vg_steam_async_call *call = vg_alloc_async_steam_api_call();
call->p_handler = on_workshop_createitem;
ISteamUGC *hSteamUGC = SteamAPI_SteamUGC();
call->id = SteamAPI_ISteamUGC_CreateItem( hSteamUGC, SKATERIFT_APPID,
- k_EWorkshopFileTypeCommunity );
+ k_EWorkshopFileTypeCommunity );
}
}
{
workshop_begin_op( k_workshop_form_op_downloading_submission );
workshop_reset_submission_data();
+ workshop_form.submission.submit_description = 0;
+ workshop_form.submission.submit_file_and_image = 0;
+ workshop_form.submission.submit_title = 0;
vg_strncpy( details.m_rgchDescription,
workshop_form.submission.description,
workshop_form.submission.file_id = details.m_nPublishedFileId;
workshop_form.file_intent = k_workshop_form_file_intent_keep_old;
workshop_form.page = k_workshop_form_edit;
+ workshop_form.submission.visibility.value = details.m_eVisibility;
+
+ for( i32 i=0; i<vg_list_size(workshop_form_visibility_opts); i++ ){
+ if( workshop_form_visibility_opts[i].value == details.m_eVisibility ){
+ workshop_form.submission.visibility.index = i;
+ break;
+ }
+ }
if( details.m_hPreviewFile == 0 ){
vg_error( "m_hPreviewFile is 0\n" );
sizeof( struct workshop_loadpreview_info ) );
snprintf( info->abs_preview_image, 1024,
- "%smodels/boards/workshop/%lu.jpg",
+ "%smodels/boards/workshop/" PRINTF_U64 ".jpg",
vg.base_path, details.m_hPreviewFile );
call->p_handler = on_workshop_download_ugcpreview;
hSteamRemoteStorage,
details.m_hPreviewFile, info->abs_preview_image, 1 );
- vg_info( "preview file id: %lu\n", details.m_hPreviewFile );
+ vg_info( "preview file id: " PRINTF_U64 "\n",
+ details.m_hPreviewFile );
}
}
else{
VG_STATIC void workshop_form_gui_edit_page( ui_rect content )
{
ui_rect image_plane;
- ui_split_px( content, k_ui_axis_h, 300, 0, image_plane, content );
+ ui_split( content, k_ui_axis_h, 300, 0, image_plane, content );
ui_fill( image_plane, ui_colour( k_ui_bg+0 ) );
ui_rect img_box;
}
/* file path */
- ui_rect null, file_entry, file_button;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, 28, 0, file_entry, content );
- ui_split_px( file_entry, k_ui_axis_v, file_entry[2]-128, 0,
- file_entry, file_button );
+ ui_rect null, file_entry, file_button, file_label;
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, 28, 0, file_entry, content );
+ ui_split( file_entry, k_ui_axis_v, -128, 0, file_entry, file_button );
+ ui_split_label( file_entry, "File:", 1, 8, file_label, file_entry );
+ ui_text( file_label, "File:", 1, k_ui_align_middle_left, 0 );
if( workshop_form.file_intent != k_workshop_form_file_intent_none ){
ui_text( file_entry, workshop_form.model_path, 1, k_ui_align_middle_left,
}
ui_rect title_entry, label;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, 28, 0, title_entry, content );
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, 28, 0, title_entry, content );
const char *str_title = "Title:", *str_desc = "Description:";
- ui_split_px( title_entry, k_ui_axis_v,
+ ui_split( title_entry, k_ui_axis_v,
ui_text_line_width(str_title)+8, 0, label, title_entry );
+ ui_rect vis_dropdown;
+ ui_split_ratio( title_entry, k_ui_axis_v, 0.6f, 16,
+ title_entry, vis_dropdown );
+
/* title box */
{
struct ui_textbox_callbacks callbacks = {
vg_list_size(workshop_form.submission.title), 0, &callbacks );
}
+ /* visibility option */
+ {
+ ui_enum( vis_dropdown, "Visibility:", workshop_form_visibility_opts,
+ 4, &workshop_form.submission.visibility );
+ }
+
/* description box */
{
struct ui_textbox_callbacks callbacks = {
.change = workshop_changed_description
};
ui_rect desc_entry;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, 28, 0, label, content );
- ui_split_px( content, k_ui_axis_h, 28*4, 0, desc_entry, content );
+ /* TODO: Tommora, new split_px_gap and split_px() */
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, 28, 0, label, content );
+ ui_split( content, k_ui_axis_h, 28*4, 0, desc_entry, content );
ui_text( label, str_desc, 1, k_ui_align_middle_left, 0 );
ui_textbox( desc_entry, workshop_form.submission.description,
vg_list_size(workshop_form.submission.description),
/* submissionable */
ui_rect submission_row;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, content[3]-32-8, 0, content,
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, content[3]-32-8, 0, content,
submission_row );
ui_rect submission_center;
workshop_op_submit();
}
if( ui_button_text( btn_right, "Cancel", 1 ) ){
- vg_info( "left\n" );
+ workshop_form.page = k_workshop_form_open;
+ player_board_unload( &workshop_form.board_model );
+ workshop_form.file_intent = k_workshop_form_file_intent_none;
}
/* disclaimer */
- /* TODO!! OPEN THIS LINK */
const char *disclaimer_text =
"By submitting this item, you agree to the workshop terms of service";
ui_rect disclaimer_row, inner, link;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, content[3]-32, 0, content,
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, content[3]-32, 0, content,
disclaimer_row );
ui_px btn_width = 32;
inner[2] = ui_text_line_width( disclaimer_text ) + btn_width+8;
ui_rect_center( disclaimer_row, inner );
- ui_split_px( inner, k_ui_axis_v, inner[2]-btn_width, 0, label, btn_right);
- ui_rect_pad( btn_right, 2 );
+ ui_split( inner, k_ui_axis_v, inner[2]-btn_width, 0, label, btn_right);
+ ui_rect_pad( btn_right, (ui_px[2]){2,2} );
if( ui_button_text( btn_right, "\x91", 2 ) ){
ISteamFriends *hSteamFriends = SteamAPI_SteamFriends();
ui_fill( sidebar, ui_colour( k_ui_bg+2 ) );
ui_rect title;
- ui_split_px( sidebar, k_ui_axis_h, 28, 0, title, sidebar );
+ ui_split( sidebar, k_ui_axis_h, 28, 0, title, sidebar );
ui_text( title, "Your submissions", 1, k_ui_align_middle_center, 0 );
ui_rect controls, btn_create_new;
- ui_split_px( sidebar, k_ui_axis_h, 32, 0, controls, sidebar );
- ui_split_px( sidebar, k_ui_axis_h, sidebar[3]-32, 0,
- sidebar, btn_create_new );
+ ui_split( sidebar, k_ui_axis_h, 32, 0, controls, sidebar );
+ ui_split( sidebar, k_ui_axis_h, -32, 0, sidebar, btn_create_new );
ui_fill( controls, ui_colour( k_ui_bg+1 ) );
- ui_outline( controls, -1, ui_colour( k_ui_bg+4 ) );
char buf[32];
strcpy( buf, "page " );
int i = 5;
/* TODO: for what it is, this code is getting a bit.. special */
- if( workshop_form.view_published_page_id )
- i += highscore_intl( buf+i, workshop_form.view_published_page_id, 4 );
- else buf[ i ++ ] = '0';
- ;
+ i += highscore_intl( buf+i, workshop_form.view_published_page_id+1, 4 );
buf[ i ++ ] = '/';
i += highscore_intl( buf+i, workshop_form.view_published_page_count, 4 );
buf[ i ++ ] = '\0';
+ ui_rect_pad( controls, (ui_px[2]){0,4} );
ui_rect info;
ui_split_ratio( controls, k_ui_axis_v, 0.25f, 0, info, controls );
ui_text( info, buf, 1, k_ui_align_middle_center, 0 );
for( int i=0; i<workshop_form.published_files_list_length; i++ ){
ui_rect item;
- ui_split_px( sidebar, k_ui_axis_h, 28, 0, item, sidebar );
- ui_rect_pad( item, 4 );
+ ui_split( sidebar, k_ui_axis_h, 28, 0, item, sidebar );
+ ui_rect_pad( item, (ui_px[2]){4,4} );
struct published_file *pfile = &workshop_form.published_files_list[i];
if( ui_button_text( item, pfile->title, 1 ) ){
ui_outline( window, 1, ui_colour( k_ui_bg+7 ) );
ui_rect title, panel;
- ui_split_px( window, k_ui_axis_h, 28, 0, title, panel );
+ ui_split( window, k_ui_axis_h, 28, 0, title, panel );
ui_fill( title, ui_colour( k_ui_bg+7 ) );
ui_text( title, "Workshop tool", 1, k_ui_align_middle_center,
ui_colourcont(k_ui_bg+7) );
ui_rect quit_button;
- ui_split_px( title, k_ui_axis_v, title[2]-title[3], 2, title, quit_button );
+ ui_split( title, k_ui_axis_v, title[2]-title[3], 2, title, quit_button );
- if( workshop_form.operation == k_workshop_form_op_none ){
+ if( workshop.operation == k_workshop_form_op_none ){
if( ui_button_text( quit_button, "X", 1 ) ){
workshop_quit_form();
return;
* escapes here and we show them a basic string
*/
- if( workshop_form.operation != k_workshop_form_op_none ){
+ if( workshop.operation != k_workshop_form_op_none ){
const char *op_string = "The programmer has not bothered to describe "
"the current operation that is running.";
- switch(workshop_form.operation){
+ switch(workshop.operation){
case k_workshop_form_op_loading_model:
op_string = "Operation in progress: Loading model file.";
break;
ui_split_ratio( panel, k_ui_axis_v, 0.3f, 1, sidebar, content );
/* content page */
- ui_rect_pad( content, 8 );
+ ui_rect_pad( content, (ui_px[2]){8,8} );
if( stable_page == k_workshop_form_edit ){
workshop_form_gui_edit_page( content );
}
else if( stable_page >= k_workshop_form_cclosing ){
ui_rect submission_row;
- ui_split_px( content, k_ui_axis_h, content[3]-32-8, 0, content,
+ ui_split( content, k_ui_axis_h, content[3]-32-8, 0, content,
submission_row );
u32 colour;
rect_copy( submission_row, submission_center );
submission_center[2] = 128;
ui_rect_center( submission_row, submission_center );
- ui_rect_pad( submission_center, 8 );
+ ui_rect_pad( submission_center, (ui_px[2]){8,8} );
if( ui_button_text( submission_center, "OK", 1 ) ){
workshop_form.page = k_workshop_form_open;
workshop_form_gui_sidebar( sidebar );
}
+/*
+ * Some async api stuff
+ * -----------------------------------------------------------------------------
+ */
+
+VG_STATIC void async_workshop_get_filepath( void *data, u32 len )
+{
+ struct async_workshop_filepath_info *info = data;
+
+ u64 _size;
+ u32 _ts;
+
+ ISteamUGC *hSteamUGC = SteamAPI_SteamUGC();
+ if( !SteamAPI_ISteamUGC_GetItemInstallInfo( hSteamUGC, info->id, &_size,
+ info->buf, info->len, &_ts ))
+ {
+ info->buf[0] = '\0';
+ }
+}
+
+VG_STATIC void async_workshop_get_installed_files( void *data, u32 len )
+{
+ struct async_workshop_installed_files_info *info = data;
+
+ ISteamUGC *hSteamUGC = SteamAPI_SteamUGC();
+ u32 count = SteamAPI_ISteamUGC_GetSubscribedItems( hSteamUGC, info->buffer,
+ *info->len );
+
+ vg_info( "Found %u subscribed items\n", count );
+
+ u32 j=0;
+ for( u32 i=0; i<count; i++ ){
+ u32 state = SteamAPI_ISteamUGC_GetItemState( hSteamUGC, info->buffer[i] );
+ if( state & k_EItemStateInstalled ){
+ info->buffer[j ++] = info->buffer[i];
+ }
+ }
+
+ *info->len = j;
+}
+
#endif /* WORKSHOP_C */