X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.c;h=550ac508f0c894a64412a73923fe92cc3289068b;hb=74b2136d5b41b18e2eec698f1fd11b503aa1100a;hp=0183acbbd12997d4e3be23296e601bdad6b2c07d;hpb=c2ee05fe23699fd1de7e1d8259b9bc272b232058;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.c b/world.c index 0183acb..550ac50 100644 --- a/world.c +++ b/world.c @@ -9,7 +9,7 @@ #include "network.h" static world_instance *world_current_instance(void){ - return &world_static.worlds[ world_static.active_world ]; + return &world_static.instances[ world_static.active_instance ]; } static void world_init(void) @@ -26,6 +26,54 @@ static void world_init(void) VG_MEMORY_SYSTEM ); } +static void world_switch_instance( u32 index ){ + localplayer.subsystem = k_player_subsystem_walk; + + if( index >= vg_list_size(world_static.instances) ){ + vg_error( "Instance ID out of range (%u)\n", index ); + return; + } + + world_instance *new = &world_static.instances[ index ]; + + if( new->status != k_world_status_loaded ){ + vg_error( "Instance is not loaded (%u)\n", index ); + return; + } + + world_instance *current = + &world_static.instances[ world_static.active_instance ]; + + if( index != world_static.active_instance ){ + v3_copy( localplayer.rb.co, current->player_co ); + skaterift_autosave(1); + } + + v3_copy( new->player_co, localplayer.rb.co ); + + world_static.active_instance = index; + + player__reset(); +} + +static int skaterift_switch_instance_cmd( int argc, const char *argv[] ){ + if( argc ) + world_switch_instance( atoi(argv[0]) ); + else + vg_info( "switch_active_instance \n" ); + return 0; +} + +static void skaterift_world_get_save_path( enum world_purpose which, + char buf[128] ){ + addon_reg *reg = world_static.instance_addons[ which ]; + assert( reg ); + + char id[76]; + addon_alias_uid( ®->alias, id ); + snprintf( buf, 128, "savedata/%s.bkv", id ); +} + #include "world_entity.c" #include "world_gate.c" #include "world_gen.c" @@ -39,8 +87,7 @@ static void world_init(void) #include "world_routes.c" #include "world_traffic.c" -VG_STATIC void world_update( world_instance *world, v3f pos ) -{ +static void world_update( world_instance *world, v3f pos ){ world_render.sky_time += world_render.sky_rate * vg.time_delta; world_render.sky_rate = vg_lerp( world_render.sky_rate, world_render.sky_target_rate,