X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.c;h=5a97d944b5f0bb6c79899765a636bab0398b450e;hb=38514b4ba03412ad51df02dc2ba345e1be41005d;hp=019e572a63b714c6c690a0ecb438bdc369b7f518;hpb=99376ce8eaf30125fb08dd5dc8b534800580fe47;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.c b/world.c index 019e572..5a97d94 100644 --- a/world.c +++ b/world.c @@ -26,22 +26,53 @@ static void world_init(void) VG_MEMORY_SYSTEM ); } -static void world_set_active_instance( u32 index ){ - world_static.challenge_target = NULL; - world_static.challenge_timer = 0.0f; - world_static.focused_entity = 0; - world_static.focus_strength = 0.0f; - world_static.active_trigger_volume_count = 0; +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; + } + + if( skaterift.demo_mode ){ + if( world_static.instance_addons[index]->flags & ADDON_REG_PREMIUM ){ + vg_error( "Can't switch to a premium world in the demo version\n" ); + 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; - - if( which == k_world_purpose_hub ) reg = world_static.addon_hub; - else reg = world_static.addon_client; - + addon_reg *reg = world_static.instance_addons[ which ]; assert( reg ); char id[76]; @@ -49,7 +80,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" @@ -61,10 +91,8 @@ static void skaterift_world_get_save_path( enum world_purpose which, #include "world_water.c" #include "world_audio.c" #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, @@ -72,7 +100,7 @@ VG_STATIC void world_update( world_instance *world, v3f pos ) world_routes_update_timer_texts( world ); world_routes_update( world ); - world_traffic_update( world, pos ); + ent_traffic_update( world, pos ); world_sfd_update( world, pos ); world_volumes_update( world, pos ); }