X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.c;h=def59a36b3edec09d1fe06aa2a9e1a2c4dd34886;hb=63fe317d7db724162561da52aa382c82ac3c29be;hp=c3b55163110fe686905d99ba31e0d878719a9ad8;hpb=c77e15a8dc7b976371a473bc8794cb55601d82f6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.c b/world.c index c3b5516..def59a3 100644 --- a/world.c +++ b/world.c @@ -26,13 +26,49 @@ static void world_init(void) VG_MEMORY_SYSTEM ); } -static void skaterift_world_get_save_path( enum world_purpose which, - char buf[128] ){ - addon_reg *reg; +static void world_switch_instance( u32 index ){ + assert( 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( which == k_world_purpose_hub ) reg = world_static.addon_hub; - else reg = world_static.addon_client; + if( new->status != k_world_status_loaded ){ + vg_error( "Instance is not loaded (%u)\n", index ); + return; + } + if( index != world_static.active_instance ){ + world_instance *current = + &world_static.instances[ world_static.active_instance ]; + v3_copy( localplayer.rb.co, current->player_co ); + v3_copy( localplayer.angles, current->player_angles ); + current->player_angles[3] = player_get_heading_yaw(); + } + + v3_copy( new->player_co, localplayer.rb.co ); + v3_copy( new->player_angles, localplayer.angles ); + q_axis_angle( localplayer.rb.q, (v3f){0,1,0}, new->player_angles[3] ); + + 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]; @@ -40,7 +76,6 @@ static void skaterift_world_get_save_path( enum world_purpose which, snprintf( buf, 128, "savedata/%s.bkv", id ); } - #include "world_entity.c" #include "world_gate.c" #include "world_gen.c" @@ -54,8 +89,7 @@ static void skaterift_world_get_save_path( enum world_purpose which, #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,