world save position
[carveJwlIkooP6JGAAIwe30JlM.git] / world_load.c
index 50a882c2fab5dc1f8907a87c051d189eb55fed62..e2c2bb3f3c6c783304f8e0a540713e325f4792ec 100644 (file)
@@ -137,12 +137,18 @@ struct world_load_complete_data{
 
 static void skaterift_world_load_done( void *payload, u32 size ){
    struct world_load_complete_data *data = payload;
+   world_instance *world = &world_static.instances[ data->purpose ];
 
-   /* TODO(W2): Load player position from this save file */
    vg_msg sav;
    vg_msg_init( &sav, data->save.buf, data->save.len );
 
-   world_instance *world = &world_static.instances[ data->purpose ];
+   if( data->purpose != k_world_purpose_hub ){
+      vg_msg player_frame = sav;
+      if( vg_msg_seekframe( &player_frame, "player" ) ){
+         vg_msg_getkvv3f( &player_frame, "position", world->player_co, NULL );
+      }
+   }
+
    world_entity_start( world, &sav );
    world->status = k_world_status_loaded;
    world_static.load_state = k_world_loader_none;
@@ -157,7 +163,6 @@ struct world_load_args {
  * Does a complete world switch using the remaining free slots
  */
 static void skaterift_world_load_thread( void *_args ){
-   /* FIXME: we need to check all threads that take args. args can dissapear! */
    struct world_load_args args = *((struct world_load_args *)_args);
 
    addon_reg *reg = args.reg;