TurboFisto
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
index a6abbee67913f079006d93baf1e3477ffc771685..795ca58fdf38b7c0f06745606c64ecbfa6f971db 100644 (file)
@@ -22,7 +22,7 @@
 
 
 #include "player.h"
-VG_STATIC player_instance localplayer;
+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" };
@@ -72,17 +72,13 @@ VG_STATIC int __kill( int argc, const char *argv[] )
 
 VG_STATIC int __respawn( int argc, const char *argv[] )
 {
-   struct respawn_point *rp = NULL, *r;
-
+   ent_spawn *rp = NULL, *r;
    world_instance *world = get_active_world();
 
-   if( argc == 1 )
-   {
-      for( int i=0; i<world->spawn_count; i++ )
-      {
-         r = &world->spawns[i];
-         if( !strcmp( r->name, argv[0] ) )
-         {
+   if( argc == 1 ){
+      for( u32 i=0; i<mdl_arrcount(&world->ent_spawn); i++ ){
+         r = mdl_arritm( &world->ent_spawn, i );
+         if( !strcmp( mdl_pstr(&world->meta, r->pstr_name),argv[0] ) ){
             rp = r;
             break;
          }
@@ -92,32 +88,27 @@ VG_STATIC int __respawn( int argc, const char *argv[] )
          vg_warn( "No spawn named '%s'\n", argv[0] );
    }
 
-   if( !rp )
-   {
+   if( !rp ){
       float min_dist = INFINITY;
 
-      for( int i=0; i<world->spawn_count; i++ )
-      {
-         r = &world->spawns[i];
-         float d = v3_dist2( r->co, localplayer.rb.co );
+      for( u32 i=0; i<mdl_arrcount(&world->ent_spawn); i++ ){
+         r = mdl_arritm( &world->ent_spawn, i );
+         float d = v3_dist2( r->transform.co, localplayer.rb.co );
          
-         vg_info( "Dist %s : %f\n", r->name, d );
-         if( d < min_dist )
-         {
+         if( d < min_dist ){
             min_dist = d;
             rp = r;
          }
       }
    }
 
-   if( !rp )
-   {
+   if( !rp ){
       vg_error( "No spawn found\n" );
 
-      if( !world->spawn_count )
+      if( !mdl_arrcount(&world->ent_spawn) )
          return 0;
 
-      rp = &world->spawns[0];
+      rp = mdl_arritm( &world->ent_spawn, 0 );
    }
 
    player__spawn( &localplayer, rp );
@@ -197,19 +188,19 @@ VG_STATIC void load_playermodels(void)
                ctx_outlaw,
                ctx_jordan;
 
-   mdl_open( &ctx_default, "models/ch_new.mdl" );
-   mdl_load_metadata( &ctx_default, vg_mem.scratch );
-   mdl_load_mesh_data( &ctx_default, vg_mem.scratch );
+   mdl_open( &ctx_default, "models/ch_new.mdl", vg_mem.scratch );
+   mdl_load_metadata_block( &ctx_default, vg_mem.scratch );
+   mdl_load_mesh_block( &ctx_default, vg_mem.scratch );
    mdl_close( &ctx_default );
 
-   mdl_open( &ctx_outlaw, "models/ch_outlaw.mdl" );
-   mdl_load_metadata( &ctx_outlaw, vg_mem.scratch );
-   mdl_load_mesh_data( &ctx_outlaw, vg_mem.scratch );
+   mdl_open( &ctx_outlaw, "models/ch_outlaw.mdl", vg_mem.scratch );
+   mdl_load_metadata_block( &ctx_outlaw, vg_mem.scratch );
+   mdl_load_mesh_block( &ctx_outlaw, vg_mem.scratch );
    mdl_close( &ctx_outlaw );
 
-   mdl_open( &ctx_jordan, "models/ch_jordan.mdl" );
-   mdl_load_metadata( &ctx_jordan, vg_mem.scratch );
-   mdl_load_mesh_data( &ctx_jordan, vg_mem.scratch );
+   mdl_open( &ctx_jordan, "models/ch_jordan.mdl", vg_mem.scratch );
+   mdl_load_metadata_block( &ctx_jordan, vg_mem.scratch );
+   mdl_load_mesh_block( &ctx_jordan, vg_mem.scratch );
    mdl_close( &ctx_jordan );
    
    vg_acquire_thread_sync();
@@ -258,14 +249,14 @@ VG_STATIC void vg_load(void)
    /* 'systems' are completely loaded now */
 
    /* load home world */
-   world_load( &world_global.worlds[0], "maps/mp_home.mdl" );
+   world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" );
 
 #if 0
    world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" );
    world_link_nonlocal_gates( 0, 1 );
-#endif
    world_load( &world_global.worlds[2], "maps/mp_mtzero.mdl" );
    world_link_nonlocal_gates( 0, 2 );
+#endif
 
    vg_console_load_autos();
 }
@@ -500,7 +491,14 @@ VG_STATIC void render_scene(void)
    glEnable( GL_DEPTH_TEST );
 
    world_instance *view_world = localplayer.viewable_world;
-   render_world( view_world, &main_camera );
+
+   if( view_world == NULL ){
+      glClearColor( 0.25f, 0.25f, 0.0f, 1.0f );
+      glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT );
+      return;
+   }
+
+   render_world( view_world, &main_camera, 0 );
 
    int player_transparent = 1,
        player_draw        = 1;
@@ -514,11 +512,13 @@ VG_STATIC void render_scene(void)
    if( !player_transparent && player_draw )
       player__render( &main_camera, &localplayer );
 
-
-   render_water_texture( view_world, &main_camera );
+   render_water_texture( view_world, &main_camera, 0 );
    render_fb_bind( gpipeline.fb_main );
    render_water_surface( view_world, &main_camera );
-   render_world_gates( view_world, &main_camera );
+
+   int depth = 1;
+   if( localplayer.gate_waiting ) depth = 0;
+   render_world_gates( view_world, &main_camera, depth );
 
    if( player_transparent && player_draw )
       render_player_transparent();
@@ -610,7 +610,7 @@ VG_STATIC void vg_render(void)
    
    /* Other shite */
    glDisable(GL_BLEND);
-   glDisable( GL_DEPTH_TEST );
+   glDisable(GL_DEPTH_TEST);
    vg_lines_drawall();
    glViewport( 0,0, vg.window_x, vg.window_y );
 }
@@ -662,13 +662,6 @@ VG_STATIC void vg_ui(void)
    }
 #endif
    
-   //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
-   if( cl_ui )
-   {
-      render_world_routes_ui( world );
-   }
-   //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-   
    audio_debug_soundscapes();
    render_view_framebuffer_ui();