challenge effects
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
index c9afd0b4ef6e2f5fe84a6b41670b79f650418cc9..9b90548c3f64a28f4e62949ce5c83f77b7d240cd 100644 (file)
@@ -13,7 +13,7 @@
 
 #if 1
 
-#define SR_NETWORKED
+//#define SR_NETWORKED
 
 #ifndef VG_RELEASE
  #define VG_DEVWINDOW
@@ -95,8 +95,10 @@ static void async_call_ready( void *payload, u32 size ){
 }
 
 static void skaterift_restore_state(void){
-   struct savedata sav;
-   skaterift_read_main_savedata( &sav );
+   savedata_file sav;
+   strcpy( sav.path, str_skaterift_main_save );
+   savedata_file_read( &sav );
+
    vg_msg kvsav = {0};
    kvsav.buf = sav.buf;
    kvsav.len = sav.len;
@@ -141,15 +143,17 @@ static void skaterift_restore_state(void){
          };
          skaterift_world_load_thread( &args );
 
-         world_static.active_instance = vg_msg_seekkvu32( &world, "index", 0 );
+         world_set_active_instance( vg_msg_seekkvu32( &world, "index", 0 ) );
          world_static.active_trigger_volume_count = 0;
          localplayer.viewable_world = world_current_instance();
+      }
+
+      vg_msg_cmd position = vg_msg_seekkv( &world, "position", 0 );
+      v3f pos;
+      vg_msg_convert_num( &position, k_vg_msg_float|k_vg_msg_32b, 3, pos );
 
-         vg_msg_cmd position = vg_msg_seekkv( &world, "position", 0 );
-         v3f pos;
-         vg_msg_convert_num( &position, k_vg_msg_float|k_vg_msg_32b, 3, pos );
+      if( v3_length2(pos) > 1.0f )
          player__setpos( &localplayer, pos );
-      }
    }
 }
 
@@ -257,7 +261,7 @@ VG_STATIC void vg_load(void){
 
    /* and now */
    skaterift_restore_state();
-   vg_loader_step( NULL, skaterift_write_main_savedata );
+   vg_loader_step( NULL, skaterift_autosave_synchronous );
 
    board_processview_thread(NULL);
    vg_async_call( async_call_ready, NULL, 0 );
@@ -295,7 +299,7 @@ VG_STATIC void vg_pre_update(void){
    vg.time_rate = vg_smoothstepf( skaterift.time_rate );
    
    player__pre_update( &localplayer );
-   global_skateshop_preupdate();
+   world_entity_focus_preupdate();
    skaterift_replay_pre_update();
 
    world_update( world_current_instance(), localplayer.rb.co );
@@ -337,6 +341,12 @@ VG_STATIC void vg_post_update(void){
    audio_unlock();
 
    vehicle_update_post();
+
+   if( vg.time - skaterift.last_autosave > 20.0 ){
+      if( skaterift_autosave(1) ){
+         skaterift.last_autosave = vg.time;
+      }
+   }
 }
 
 /*
@@ -459,8 +469,8 @@ VG_STATIC void render_scene_gate_subview(void){
 }
 
 VG_STATIC void skaterift_composite_maincamera(void){
-   camera_lerp( &localplayer.cam, &global_skateshop.cam, 
-                vg_smoothstepf(global_skateshop.factive), &skaterift.cam );
+   camera_lerp( &localplayer.cam, &world_static.focus_cam,
+                vg_smoothstepf(world_static.focus_strength), &skaterift.cam );
 
    if( skaterift.activity == k_skaterift_replay ){
       skaterift_get_replay_camera( &skaterift.cam );
@@ -499,6 +509,19 @@ VG_STATIC void render_main_game(void){
 
    /* --------------------------------------------------------------------- */
 
+   world_instance *view_world = localplayer.viewable_world;
+   if( view_world != NULL ){
+      render_world_cubemaps( view_world );
+
+      ent_gate *gate = view_world->rendering_gate;
+      if( gate ){
+         if( gate->flags & k_ent_gate_nonlocal ){
+            world_instance *dest = &world_static.instances[ gate->target ];
+            render_world_cubemaps( dest );
+         }
+      }
+   }
+
    /* variable res target */
    render_fb_bind( gpipeline.fb_main, 1 );
    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );