From: hgn Date: Sun, 17 Aug 2025 00:23:11 +0000 (+0000) Subject: some FIXMES X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=carveJwlIkooP6JGAAIwe30JlM.git some FIXMES --- diff --git a/src/client.c b/src/client.c index 4a61769..56f1fb3 100644 --- a/src/client.c +++ b/src/client.c @@ -141,7 +141,7 @@ void client_event_handler( vg_event_info *info ) { addon_id world_to_load = _world.default_hub_addon; - vg_kvs *kvs = _savefile_kvs( skaterift.main_save_handle ); + vg_kvs *kvs = _savefile_kvs( skaterift.main_save_handle, SAVE_READ ); u32 player_block = vg_kv_find( kvs, 0, "player" ); if( player_block ) { diff --git a/src/ent_atom.c b/src/ent_atom.c index b2d96e3..287cd41 100644 --- a/src/ent_atom.c +++ b/src/ent_atom.c @@ -118,14 +118,11 @@ entity_event_result _ent_atom_event( ent_event *event ) void serialize_atoms( enum e_atom_list list, vg_kvs *savedata, u32 root ) { - // FIXME -#if 0 for( u32 i=0; i<_atom.lists[list].count; i ++ ) { atom *a = &_atom.lists[list].atoms[i]; - vg_kv_append_vu32( savedata, root, a->alias, &a->status, 1 ); + vg_kv_append_vi32( savedata, root, a->alias, &a->status, 1 ); } -#endif } static atom *_atom_internal( enum e_atom_list list, const char *alias ) diff --git a/src/save2.c b/src/save2.c index 9677bc8..cf242bf 100644 --- a/src/save2.c +++ b/src/save2.c @@ -110,7 +110,7 @@ VG_API u16 _savedata_handle( addon_id addon ) return unused_save; } -VG_API void savedata_release_handle( u16 save_handle ) +VG_API void _savedata_release_handle( u16 save_handle ) { VG_ASSERT( save_handle ); struct savefile *save = &_savedata.files[save_handle-1]; @@ -124,11 +124,16 @@ VG_API enum savefile_state _savefile_state( u16 save_handle ) return _savedata.files[ save_handle-1 ].state; } -VG_API vg_kvs *_savefile_kvs( u16 save_handle ) +VG_API vg_kvs *_savefile_kvs( u16 save_handle, bool reset ) { VG_ASSERT( save_handle ); struct savefile *save = &_savedata.files[save_handle-1]; VG_ASSERT( save->state == k_savefile_ready ); + if( reset ) + { + vg_stack_clear( &save->stack ); + vg_kvs_init( &save->kvs, &save->stack ); + } return &save->kvs; } diff --git a/src/save2.h b/src/save2.h index 2898b0e..7b03002 100644 --- a/src/save2.h +++ b/src/save2.h @@ -9,11 +9,15 @@ enum savefile_state k_savefile_ready }; +#define SAVE_RESET 1 +#define SAVE_READ 0 + VG_API void _savedata_init(void); VG_API void _skaterift_autosave_post_update( void ); VG_API u16 _savedata_handle( addon_id addon ); +VG_API void _savedata_release_handle( u16 save_handle ); VG_API enum savefile_state _savefile_state( u16 save_handle ); -VG_API vg_kvs *_savefile_kvs( u16 save_handle ); +VG_API vg_kvs *_savefile_kvs( u16 save_handle, bool reset ); #endif diff --git a/src/world_load.c b/src/world_load.c index 0a0b4cf..d07d8fe 100644 --- a/src/world_load.c +++ b/src/world_load.c @@ -312,9 +312,20 @@ void world_switcher_update(void) if( _world.loader_state == k_world_loader_saving_current ) { - VG_ASSERT(0); - //FIXME FIXME FIMXE - //skaterift_write_all_savedata(1); + vg_kvs *kvs = _savefile_kvs( _world.save_handle, SAVE_RESET ); + u32 player_block = vg_kv_append( kvs, 0, "player", VG_KV_APPEND_FRAME ); + { + vg_kv_append_vf32( kvs, player_block, "co", localplayer.rb.co, 3 ); + } + u32 atom_block = vg_kv_append( kvs, 0, "atoms", VG_KV_APPEND_FRAME ); + { + serialize_atoms( k_atom_list_world, kvs, atom_block ); + } + world_entity_serialize( &_world.main, kvs ); + _savedata_write( _world.save_handle ); + _savedata_release_handle( _world.save_handle ); + _world.save_handle = 0; + _world.loader_state = k_world_loader_unloading_current; _vg_loader_set_user_information( "Unloading current world" ); } @@ -371,7 +382,7 @@ void world_switcher_update(void) { _world.loader_state = k_world_loader_done; - vg_kvs *kvs = _savefile_kvs( _world.save_handle ); + vg_kvs *kvs = _savefile_kvs( _world.save_handle, SAVE_READ ); world_entity_start( &_world.main, kvs ); /* start player in the world */ @@ -442,6 +453,8 @@ void skaterift_load_world_start( addon_id addon_id, bool preview ) player__clear_world_dependent_variables(); relink_all_remote_player_worlds(); _ent_npc_reset(); + + _vg_loader_increment( +1 ); _vg_loader_set_user_information( "Saving current world" ); } else @@ -583,7 +596,8 @@ void world_instance_free_graphics_data( world_instance *world ) } for( u32 i=0; inonlocal_gate_count; i ++ ) - vg_tex_delete( &world->nonlocal_gates_cubemaps[i] ); + if( world->nonlocal_gates_cubemaps[i].flags & VG_TEX_COMPLETE ) + vg_tex_delete( &world->nonlocal_gates_cubemaps[i] ); } /*