grid based
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
index c724906a2a1ff5c88da28825fb169648c8520cc4..a410301d171e836ae82697678606ce19a4941ef2 100644 (file)
 #include "audio.h"
 #include "world.h"
 
-#if 0
-#include "player.h"
-#else
+
 
 #include "player.h"
 VG_STATIC player_instance localplayer;
+VG_STATIC struct player_avatar localplayer_avatar;
+VG_STATIC glmesh localplayer_meshes[3];
+vg_tex2d localplayer_texture = { .path = "textures/ch_gradient.qoi" };
 
-#if 0
 
-#include "player_interface.h"
-#include "player_device_walk.h"
-#include "player_device_skate.h"
-#include "player_device_dead.h"
-#include "player_model.h"
 
 
-/* temp */
-VG_STATIC player_interface localplayer;
-#endif
 
-VG_STATIC struct player_avatar localplayer_avatar;
-VG_STATIC glmesh localplayer_meshes[3];
-vg_tex2d localplayer_texture = { .path = "textures/ch_gradient.qoi" };
-
-#endif
 
 #include "network.h"
 
@@ -87,11 +74,13 @@ VG_STATIC int __respawn( int argc, const char *argv[] )
 {
    struct respawn_point *rp = NULL, *r;
 
+   world_instance *world = get_active_world();
+
    if( argc == 1 )
    {
-      for( int i=0; i<world.spawn_count; i++ )
+      for( int i=0; i<world->spawn_count; i++ )
       {
-         r = &world.spawns[i];
+         r = &world->spawns[i];
          if( !strcmp( r->name, argv[0] ) )
          {
             rp = r;
@@ -107,9 +96,9 @@ VG_STATIC int __respawn( int argc, const char *argv[] )
    {
       float min_dist = INFINITY;
 
-      for( int i=0; i<world.spawn_count; i++ )
+      for( int i=0; i<world->spawn_count; i++ )
       {
-         r = &world.spawns[i];
+         r = &world->spawns[i];
          float d = v3_dist2( r->co, localplayer.rb.co );
          
          vg_info( "Dist %s : %f\n", r->name, d );
@@ -125,10 +114,10 @@ VG_STATIC int __respawn( int argc, const char *argv[] )
    {
       vg_error( "No spawn found\n" );
 
-      if( !world.spawn_count )
+      if( !world->spawn_count )
          return 0;
 
-      rp = &world.spawns[0];
+      rp = &world->spawns[0];
    }
 
    player__spawn( &localplayer, rp );
@@ -232,7 +221,7 @@ VG_STATIC void load_playermodels(void)
    vg_release_thread_sync();
 
    /* FIXME: hack */
-   shader_viewchar_register();
+   shader_model_character_view_register();
    vg_acquire_thread_sync();
    {
       vg_tex2d_init( (vg_tex2d *[]){ &localplayer_texture }, 1 );
@@ -268,9 +257,15 @@ VG_STATIC void vg_load(void)
    world_audio_init();
 
    /* 'systems' are completely loaded now */
-   strcpy( world.world_name, "maps/mp_mtzero.mdl" );
-   strcpy( world.world_name, "maps/mp_gridmap.mdl" );
-   world_load();
+
+   /* load home world */
+   world_load( &world_global.worlds[0], "maps/mp_home.mdl" );
+
+   world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" );
+   world_load( &world_global.worlds[2], "maps/mp_mtzero.mdl" );
+   world_link_nonlocal_gates( 0, 1 );
+   world_link_nonlocal_gates( 0, 2 );
+
    vg_console_load_autos();
 }
 
@@ -301,7 +296,7 @@ VG_STATIC void vg_update(void)
 #endif
 
       player__pre_update( &localplayer );
-      world_update( localplayer.rb.co );
+      world_update( get_active_world(), localplayer.rb.co );
    }
 }
 
@@ -417,9 +412,9 @@ VG_STATIC void render_scene(void)
 
    /* Draw world */
    glEnable( GL_DEPTH_TEST );
-   render_world( &main_camera );
-
 
+   world_instance *view_world = localplayer.viewable_world;
+   render_world( view_world, &main_camera );
 
    int player_transparent = 1,
        player_draw        = 1;
@@ -433,10 +428,11 @@ VG_STATIC void render_scene(void)
    if( !player_transparent && player_draw )
       player__render( &main_camera, &localplayer );
 
-   render_water_texture( &main_camera );
+
+   render_water_texture( view_world, &main_camera );
    render_fb_bind( gpipeline.fb_main );
-   render_water_surface( &main_camera );
-   render_world_gates( &main_camera );
+   render_water_surface( view_world, &main_camera );
+   render_world_gates( view_world, &main_camera );
 
    if( player_transparent && player_draw )
       render_player_transparent();
@@ -535,11 +531,13 @@ VG_STATIC void run_light_widget( struct light_widget *lw );
 VG_STATIC void vg_ui(void)
 {
    player__im_gui( &localplayer );
+   world_instance *world = get_active_world();
 
 #if 0
    menu_crap_ui();
 #endif
 
+#if 0
    if( cl_light_edit )
    {
       vg_uictx.cursor[0] = 10;
@@ -574,11 +572,12 @@ VG_STATIC void vg_ui(void)
 
       render_update_lighting_ub();
    }
+#endif
    
    //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
    if( cl_ui )
    {
-      render_world_routes_ui();
+      render_world_routes_ui( world );
    }
    //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );