moved some stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / world.h
diff --git a/world.h b/world.h
index 3b30973099152990e276dbc780869f1f08dc623c..08fe437fc8cdb9821ed7f7c1933c6dda7ffda79c 100644 (file)
--- a/world.h
+++ b/world.h
@@ -42,12 +42,6 @@ enum { k_route_ui_max_indices = k_max_ui_elements*k_max_element_indices };
 
 static struct gworld
 {
-   struct subworld_gen
-   {
-      
-   }
-   subworld_gen;
-
    /* gameplay */
    struct respawn_point
    {
@@ -89,107 +83,6 @@ static struct gworld
    u32 achievement_zones_count,
        achievement_zones_cap;
 
-   struct subworld_routes
-   {
-      struct route_node
-      {
-         v3f co, right, up, h;
-         u32 next[2];
-
-         u32 special_type, special_id, current_refs, ref_count;
-         u32 route_ids[4];    /* Gates can be linked into up to four routes */
-      }
-      *nodes;
-
-      u32 node_count,
-          node_cap;
-
-      struct route
-      {
-         u32 track_id;
-         v4f colour;
-
-         u32 start;
-         mdl_submesh sm;
-         
-         int active;
-         float factive;
-
-         double best_lap, latest_pass; /* Session */
-
-         struct 
-         {
-            GLuint vao, vbo, ebo;
-
-            u32  indices_head;
-            u32  vertex_head;
-
-            float last_notch;
-
-            struct route_ui_segment
-            {
-               float length;
-               u32 vertex_start, vertex_count,
-                   index_start, index_count, notches;
-            }
-            segments[k_max_ui_segments];
-
-            u32 segment_start, segment_count, fade_start, fade_count;
-            double fade_timer_start;
-            float xpos;
-         }
-         ui;
-
-         m4x3f scoreboard_transform;
-      }
-      *routes;
-
-      double time, rewind_from, rewind_to, last_use;
-
-      u32 route_count,
-          route_cap;
-
-      struct route_gate
-      {
-         struct teleport_gate
-         { 
-            v3f co[2];
-            v4f q[2];
-            v2f dims;
-
-            m4x3f to_world, recv_to_world, transport;
-         } 
-         gate;
-         
-         u32 node_id;
-
-         struct route_timing
-         {
-            u32 version; /* Incremented on every teleport */
-            double time;
-         } 
-         timing;
-      }
-      *gates;
-
-      struct route_collector
-      {
-         struct route_timing timing;
-      }
-      *collectors;
-
-      u32 gate_count,
-          gate_cap,
-          collector_count,
-          collector_cap;
-
-      u32 active_gate,
-          current_run_version;
-
-      scene scene_lines;
-   }
-   routes;
-
    struct subworld_sfd
    {
       scene mesh;
@@ -249,6 +142,109 @@ static struct gworld
 }
 world ;
 
+typedef struct teleport_gate teleport_gate;
+struct teleport_gate
+{ 
+   v3f co[2];
+   v4f q[2];
+   v2f dims;
+
+   m4x3f to_world, recv_to_world, transport;
+};
+
+struct subworld_routes
+{
+   struct route_node
+   {
+      v3f co, right, up, h;
+      u32 next[2];
+
+      u32 special_type, special_id, current_refs, ref_count;
+      u32 route_ids[4];    /* Gates can be linked into up to four routes */
+   }
+   *nodes;
+
+   u32 node_count,
+       node_cap;
+
+   struct route
+   {
+      u32 track_id;
+      v4f colour;
+
+      u32 start;
+      mdl_submesh sm;
+      
+      int active;
+      float factive;
+
+      double best_lap, latest_pass; /* Session */
+
+      struct 
+      {
+         GLuint vao, vbo, ebo;
+
+         u32  indices_head;
+         u32  vertex_head;
+
+         float last_notch;
+
+         struct route_ui_segment
+         {
+            float length;
+            u32 vertex_start, vertex_count,
+                index_start, index_count, notches;
+         }
+         segments[k_max_ui_segments];
+
+         u32 segment_start, segment_count, fade_start, fade_count;
+         double fade_timer_start;
+         float xpos;
+      }
+      ui;
+
+      m4x3f scoreboard_transform;
+   }
+   *routes;
+
+   double time, rewind_from, rewind_to, last_use;
+
+   u32 route_count,
+       route_cap;
+
+   struct route_gate
+   {
+      teleport_gate gate;
+      u32 node_id;
+
+      struct route_timing
+      {
+         u32 version; /* Incremented on every teleport */
+         double time;
+      } 
+      timing;
+   }
+   *gates;
+
+   struct route_collector
+   {
+      struct route_timing timing;
+   }
+   *collectors;
+
+   u32 gate_count,
+       gate_cap,
+       collector_count,
+       collector_cap;
+
+   u32 active_gate,
+       current_run_version;
+
+   scene scene_lines;
+}
+static world_routes;
+
+
 /*
  * API
  */
@@ -261,6 +257,7 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit );
 /*
  * Submodules
  */
+
 #include "world_routes.h"
 #include "world_sfd.h"
 #include "world_render.h"
@@ -346,9 +343,9 @@ static void world_update( v3f pos )
    int closest = 0;
    float min_dist = INFINITY;
 
-   for( int i=0; i<world.routes.route_count; i++ )
+   for( int i=0; i<world_routes.route_count; i++ )
    {
-      float d = v3_dist2( world.routes.routes[i].scoreboard_transform[3], pos );
+      float d = v3_dist2( world_routes.routes[i].scoreboard_transform[3], pos );
 
       if( d < min_dist )
       {
@@ -363,7 +360,7 @@ static void world_update( v3f pos )
       world.active_route_board = closest;
       struct subworld_sfd *sfd = &world.sfd;
 
-      struct route *route = &world.routes.routes[closest];
+      struct route *route = &world_routes.routes[closest];
 
       u32 id = route->track_id;