numerous
[carveJwlIkooP6JGAAIwe30JlM.git] / world.h
diff --git a/world.h b/world.h
index 9d35d304be7e8c6682f73e5cdae665857cd43749..cf721e8402c097d95bcc5a5ba274acb9c43f0a5a 100644 (file)
--- a/world.h
+++ b/world.h
@@ -19,6 +19,8 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit );
 #include "world_routes.h"
 #include "world_sfd.h"
 #include "world_audio.h"
+#include "network.h"
+#include "network_msg.h"
 
 #include "shaders/terrain.h"
 #include "shaders/sky.h"
@@ -44,11 +46,6 @@ static struct gworld
    struct subworld_routes routes;
    struct subworld_sfd sfd;
 
-   /* ...
-   struct subworld_spawns system_spawns;
-   struct subworld_physics system_physics;
-   */
-
    /* Paths */
    traffic_node traffic[128];
    u32 traffic_count;
@@ -552,6 +549,41 @@ static void world_update(void)
    world_routes_update();
    world_routes_debug();
    
+   int closest = 0;
+   float min_dist = INFINITY;
+
+   for( int i=0; i<world.routes.route_count; i++ )
+   {
+      float dist = v3_dist2( world.routes.routes[i].scoreboard_transform[3],
+                              player_get_pos() );
+
+      if( dist < min_dist )
+      {
+         min_dist = dist;
+         closest = i;
+      }
+   }
+
+   if( (world.active_route_board != closest) || network_scores_updated )
+   {
+      network_scores_updated = 0;
+      world.active_route_board = closest;
+      struct subworld_sfd *sfd = subworld_sfd();
+
+      struct route *route = &world.routes.routes[closest];
+
+      u32 id = route->track_id;
+
+      if( id != 0xffffffff )
+      {
+         struct netmsg_board *local_board = &scoreboard_client_data.boards[id];
+
+         for( int i=0; i<13; i++ )
+         {
+            sfd_encode( &sfd->tester, i, &local_board->data[27*i] );
+         }
+      }
+   }
    
    sfd_update( &world.sfd.tester );
 
@@ -723,7 +755,7 @@ static void render_sky(m4x3f camera)
    glDepthMask( GL_TRUE );
 }
 
-static void render_world_gates( m4x4f projection, m4x3f camera )
+static void render_world_gates( m4x4f projection, v3f playerco, m4x3f camera )
 {
    float closest = INFINITY;
    int   id = 0;
@@ -740,7 +772,7 @@ static void render_world_gates( m4x4f projection, m4x3f camera )
       }
    }
 
-   render_gate( &world.routes.gates[id].gate, camera );
+   render_gate( &world.routes.gates[id].gate, playerco, camera );
    v3_lerp( world.render_gate_pos, 
             world.routes.gates[id].gate.co[0],
             1.0f,