From: hgn Date: Mon, 4 Mar 2024 12:16:09 +0000 (+0000) Subject: fix couple TODO X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=670daa775dec0954adb27354c3e37c66fc6567dd;p=carveJwlIkooP6JGAAIwe30JlM.git fix couple TODO --- diff --git a/addon.c b/addon.c index 59b3e32..1b9f622 100644 --- a/addon.c +++ b/addon.c @@ -1,4 +1,6 @@ #include "vg/vg_engine.h" +#include "vg/vg_io.h" +#include "vg/vg_loader.h" #include "addon.h" #include "addon_types.h" #include "vg/vg_msg.h" @@ -729,23 +731,27 @@ static void addon_cache_free_item( enum addon_type type, u16 id ){ /* * Goes over cache item load requests and calls the above ^ */ -void addon_cache_load_loop(void) +static void T1_addon_cache_load_loop(void *_) { vg_info( "Running load loop\n" ); char path_buf[4096]; - for( u32 type=0; typepool.count; id++ ){ + for( u32 id=1; id<=cache->pool.count; id++ ) + { addon_cache_entry *entry = vg_pool_item( &cache->pool, id ); SDL_AtomicLock( &addon_system.sl_cache_using_resources ); - if( entry->state == k_addon_cache_state_load_request ){ + if( entry->state == k_addon_cache_state_load_request ) + { vg_info( "process cache load request (%u#%u, reg:%u)\n", type, id, entry->reg_index ); - if( entry->reg_index >= addon_count(type,0) ){ + if( entry->reg_index >= addon_count(type,0) ) + { /* should maybe have a different value for this case */ entry->state = k_addon_cache_state_none; SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); @@ -760,8 +766,10 @@ void addon_cache_load_loop(void) vg_str folder; vg_strnull( &folder, path_buf, 4096 ); - if( addon_get_content_folder( reg, &folder, 1 ) ){ - if( addon_cache_load_request( type, id, reg, folder ) ){ + if( addon_get_content_folder( reg, &folder, 1 ) ) + { + if( addon_cache_load_request( type, id, reg, folder ) ) + { vg_async_call( async_addon_setstate, entry, k_addon_cache_state_loaded ); continue; @@ -779,6 +787,30 @@ void addon_cache_load_loop(void) } } +/* TODO: migrate to addon.c */ +void addon_system_pre_update(void) +{ + if( !vg_loader_availible() ) return; + + SDL_AtomicLock( &addon_system.sl_cache_using_resources ); + for( u32 type=0; typepool.count; id++ ) + { + addon_cache_entry *entry = vg_pool_item( &cache->pool, id ); + if( entry->state == k_addon_cache_state_load_request ) + { + SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); + vg_loader_start( T1_addon_cache_load_loop, NULL ); + return; + } + } + } + SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); +} + /* * Perform the cache interactions required to create a viewslot which will * eventually be loaded by other parts of the system. diff --git a/addon.h b/addon.h index bb5747d..c43277c 100644 --- a/addon.h +++ b/addon.h @@ -98,7 +98,8 @@ u16 addon_cache_alloc( enum addon_type type, u32 reg_index ); void *addon_cache_item( enum addon_type type, u16 id ); void *addon_cache_item_if_loaded( enum addon_type type, u16 id ); void async_addon_setstate( void *data, u32 size ); -void addon_cache_load_loop(void); + +void addon_system_pre_update(void); u16 addon_cache_create_viewer( enum addon_type type, u16 reg_id); void addon_cache_watch( enum addon_type type, u16 cache_id ); diff --git a/audio.c b/audio.c index bbbe476..1b0a2cf 100644 --- a/audio.c +++ b/audio.c @@ -213,12 +213,6 @@ void audio_init(void) audio_unlock(); } -void audio_free(void) -{ - /* TODO! */ - vg_warn( "UNIMPLEMENTED: audio_free()\n" ); -} - void audio_ambient_sprite_play( v3f co, audio_clip *clip ) { audio_lock(); diff --git a/audio.h b/audio.h index 4b57a79..95894f1 100644 --- a/audio.h +++ b/audio.h @@ -23,7 +23,6 @@ struct air_synth_data { extern air_audio_data; void audio_init(void); -void audio_free(void); void audio_ambient_sprite_play( v3f co, audio_clip *clip ); void audio_ambient_sprites_update( world_instance *world, v3f co ); diff --git a/build.c b/build.c index 3190da1..68e485a 100644 --- a/build.c +++ b/build.c @@ -242,7 +242,8 @@ void s_release_all(void){ fclose( fp ); } -void s_testing_build(void){ +void s_testing_build(void) +{ vg_info( "running script: s_testing_build(void)\n" ); struct vg_project test_proj; @@ -250,9 +251,11 @@ void s_testing_build(void){ build_game_bin( &test_proj ); build_game_content( &test_proj ); + vg_add_blob( &test_proj, "steam_appid.txt", "" ); } -void s_testing_server(void){ +void s_testing_server(void) +{ vg_info( "running script: s_testing_server(void)\n" ); struct vg_project test_proj; @@ -260,7 +263,8 @@ void s_testing_server(void){ compile_server( &test_proj ); } -int main( int argc, char *argv[] ){ +int main( int argc, char *argv[] ) +{ char *arg; while( vg_argp( argc, argv ) ){ if( vg_long_opt( "release-all" ) ) diff --git a/ent_skateshop.c b/ent_skateshop.c index fd59f3e..d5128f0 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -74,7 +74,8 @@ static void skateshop_async_preview_imageload( void *data, u32 len ){ SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); } -static void skateshop_update_preview_image_thread(void *_args){ +static void skateshop_update_preview_image_thread(void *_args) +{ char path_buf[4096]; vg_str folder; vg_strnull( &folder, path_buf, sizeof(path_buf) ); @@ -83,7 +84,8 @@ static void skateshop_update_preview_image_thread(void *_args){ addon_reg *reg_preview = global_skateshop.reg_preview; SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); - if( !addon_get_content_folder( reg_preview, &folder, 1 ) ){ + if( !addon_get_content_folder( reg_preview, &folder, 1 ) ) + { SDL_AtomicLock( &addon_system.sl_cache_using_resources ); global_skateshop.reg_loaded_preview = reg_preview; SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); @@ -97,13 +99,16 @@ static void skateshop_update_preview_image_thread(void *_args){ inf->reg = reg_preview; - if( vg_strgood( &folder ) ){ + if( vg_strgood( &folder ) ) + { stbi_set_flip_vertically_on_load(1); int x, y, nc; inf->data = stbi_load( folder.buffer, &x, &y, &nc, 3 ); - if( inf->data ){ - if( (x != WORKSHOP_PREVIEW_WIDTH) || (y != WORKSHOP_PREVIEW_HEIGHT) ){ + if( inf->data ) + { + if( (x != WORKSHOP_PREVIEW_WIDTH) || (y != WORKSHOP_PREVIEW_HEIGHT) ) + { vg_error( "Resolution does not match framebuffer, so we can't" " show it\n" ); stbi_image_free( inf->data ); @@ -113,70 +118,36 @@ static void skateshop_update_preview_image_thread(void *_args){ vg_async_dispatch( call, skateshop_async_preview_imageload ); } -} - -/* - * op/subroutine: k_workshop_op_item_load - * ----------------------------------------------------------------------------- - */ - -static void world_scan_thread( void *_args ){ - addon_mount_content_folder( k_addon_type_world, "maps", ".mdl" ); - addon_mount_workshop_items(); - vg_async_call( async_addon_reg_update, NULL, 0 ); -} - -/* - * Asynchronous scan of local disk for worlds - */ -static void skateshop_op_world_scan(void){ - vg_loader_start( world_scan_thread, NULL ); -} - -static void board_processview_thread( void *_args ){ - addon_cache_load_loop(); -} - -static void board_scan_thread( void *_args ){ - addon_mount_content_folder( k_addon_type_board, "boards", ".mdl" ); - addon_mount_workshop_items(); - vg_async_call( async_addon_reg_update, NULL, 0 ); - vg_async_stall(); - board_processview_thread(NULL); -} - -/* TODO: migrate to addon.c */ -static void skateshop_op_board_scan(void){ - vg_loader_start( board_scan_thread, NULL ); -} - -/* TODO: migrate to addon.c */ -void skateshop_autostart_loading(void) -{ - if( !vg_loader_availible() ) return; + else + { + vg_error( "Path too long to workshop preview image.\n" ); - SDL_AtomicLock( &addon_system.sl_cache_using_resources ); - if( global_skateshop.reg_preview != global_skateshop.reg_loaded_preview ){ + SDL_AtomicLock( &addon_system.sl_cache_using_resources ); + global_skateshop.reg_loaded_preview = reg_preview; SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); - vg_loader_start( skateshop_update_preview_image_thread, NULL ); - return; } +} - for( u32 type=0; typepool.count; id++ ){ - addon_cache_entry *entry = vg_pool_item( &cache->pool, id ); - if( entry->state == k_addon_cache_state_load_request ){ - SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); - vg_loader_start( board_processview_thread, NULL ); - return; - } +void skateshop_world_preview_preupdate(void) +{ + /* try to load preview image if we availible to do. */ + if( vg_loader_availible() ) + { + SDL_AtomicLock( &addon_system.sl_cache_using_resources ); + if( global_skateshop.reg_preview != global_skateshop.reg_loaded_preview ) + { + SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); + vg_loader_start( skateshop_update_preview_image_thread, NULL ); } + else SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); } - SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); } +/* + * op/subroutine: k_workshop_op_item_load + * ----------------------------------------------------------------------------- + */ + /* * Regular stuff * ----------------------------------------------------------------------------- @@ -643,14 +614,16 @@ static void skateshop_render_worldshop( ent_skateshop *shop ){ if( !reg ) goto none; - if( reg->alias.workshop_id ){ + if( reg->alias.workshop_id ) + { vg_msg msg; vg_msg_init( &msg, reg->metadata, reg->metadata_len ); global_skateshop.render.world_loc = vg_msg_getkvstr(&msg,"location"); global_skateshop.render.world_reg = global_skateshop.selected_world_id; - if( vg_msg_seekframe( &msg, "workshop" ) ){ + if( vg_msg_seekframe( &msg, "workshop" ) ) + { global_skateshop.render.world_title = vg_msg_getkvstr(&msg,"title"); vg_msg_skip_frame( &msg ); } @@ -672,17 +645,20 @@ none:; vg_strnull( &subtext, bufsubtext, 128 ); u32 valid_count = addon_count(k_addon_type_world,ADDON_REG_HIDDEN); - if( valid_count ){ + if( valid_count ) + { vg_strcati32( &info, global_skateshop.selected_world_id+1 ); vg_strcatch( &info, '/' ); vg_strcati32( &info, valid_count ); vg_strcatch( &info, ' ' ); vg_strcat( &info, global_skateshop.render.world_title ); - if( !vg_loader_availible() ){ + if( !vg_loader_availible() ) + { vg_strcat( &subtext, "Loading..." ); } - else{ + else + { addon_reg *reg = get_addon_from_index( k_addon_type_world, global_skateshop.selected_world_id, ADDON_REG_HIDDEN ); @@ -692,7 +668,8 @@ none:; vg_strcat( &subtext, global_skateshop.render.world_loc ); } } - else{ + else + { vg_strcat( &info, "No workshop worlds installed" ); } @@ -739,7 +716,8 @@ void skateshop_render( ent_skateshop *shop ) void skateshop_render_nonfocused( world_instance *world, vg_camera *cam ) { - for( u32 j=0; jent_skateshop ); j ++ ){ + for( u32 j=0; jent_skateshop ); j ++ ) + { ent_skateshop *shop = mdl_arritm(&world->ent_skateshop, j ); if( shop->type != k_skateshop_type_boardshop ) continue; @@ -755,7 +733,8 @@ void skateshop_render_nonfocused( world_instance *world, vg_camera *cam ) continue; u32 slot_count = vg_list_size(global_skateshop.shop_view_slots); - for( u32 i=0; ifunction == k_ent_function_trigger ){ + if( call->function == k_ent_function_trigger ) + { if( localplayer.subsystem != k_player_subsystem_walk ) return; vg_info( "Entering skateshop\n" ); @@ -810,19 +816,23 @@ void ent_skateshop_call( world_instance *world, ent_call *call ) world_entity_focus_modal(); gui_helper_clear(); - if( shop->type == k_skateshop_type_boardshop ){ + if( shop->type == k_skateshop_type_boardshop ) + { skateshop_update_viewpage(); - skateshop_op_board_scan(); + vg_loader_start( board_scan_thread, NULL ); ent_skateshop_helpers_pickable( "pick" ); } - else if( shop->type == k_skateshop_type_charshop ){ + else if( shop->type == k_skateshop_type_charshop ) + { ent_skateshop_helpers_pickable( "pick" ); } - else if( shop->type == k_skateshop_type_worldshop ){ + else if( shop->type == k_skateshop_type_worldshop ) + { ent_skateshop_helpers_pickable( "open rift" ); - skateshop_op_world_scan(); + vg_loader_start( world_scan_thread, NULL ); } - else if( shop->type == k_skateshop_type_server ){ + else if( shop->type == k_skateshop_type_server ) + { vg_str text; global_skateshop.helper_pick = gui_new_helper( input_button_list[k_srbind_maccept], &text); diff --git a/ent_skateshop.h b/ent_skateshop.h index 0bbeb8d..cf8b983 100644 --- a/ent_skateshop.h +++ b/ent_skateshop.h @@ -51,3 +51,4 @@ void skateshop_render_nonfocused( world_instance *world, vg_camera *cam ); void skateshop_autostart_loading(void); void skateshop_world_preupdate( world_instance *world ); void ent_skateshop_call( world_instance *world, ent_call *call ); +void skateshop_world_preview_preupdate(void); diff --git a/skaterift.c b/skaterift.c index cbb9692..c9f9371 100644 --- a/skaterift.c +++ b/skaterift.c @@ -22,6 +22,7 @@ #include "render.h" #include "vg/vg_opt.h" #include "vg/vg_loader.h" +#include "vg/vg_io.h" #include "world.h" @@ -235,7 +236,7 @@ void vg_load(void) /* --------------------- */ vg_bake_shaders(); - vg_loader_step( audio_init, audio_free ); + vg_loader_step( audio_init, NULL ); /* 'systems' are completely loaded now */ @@ -292,7 +293,8 @@ void vg_pre_update(void) if( skaterift.op == k_async_op_clientloading ) return; draw_origin_axis(); - skateshop_autostart_loading(); + addon_system_pre_update(); + skateshop_world_preview_preupdate(); network_update(); /* time rate */ diff --git a/skaterift.h b/skaterift.h index f3e0258..4ea1b88 100644 --- a/skaterift.h +++ b/skaterift.h @@ -16,12 +16,6 @@ struct skaterift_globals { k_async_op_none, k_async_op_clientloading, - k_async_op_world_scan, - k_async_op_world_load_preview, - k_async_op_board_scan, - k_async_op_player_scan, - k_async_op_board_load, - k_async_op_write_savedata, } op; diff --git a/steam_appid.txt b/steam_appid.txt new file mode 100644 index 0000000..6d81222 --- /dev/null +++ b/steam_appid.txt @@ -0,0 +1 @@ +2103940