fixe
[carveJwlIkooP6JGAAIwe30JlM.git] / world_gen.h
index b35c6c25f036a3a4380b1d7a0b24afa47ee2f401..5120bd758fe6e2ff09c7ec6ce5051fdba5b756fc 100644 (file)
@@ -126,92 +126,6 @@ VG_STATIC void world_apply_procedural_foliage( world_instance *world,
    vg_info( "%d foliage models added\n", count );
 }
 
-#if 0
-VG_STATIC void world_ents_allocate( world_instance *world )
-{
-   vg_info( "Allocating entities\n" );
-
-   /* --count entites to allocate buffers for them.--
-    * --maybe in the future we just store these numbers in the model file...--
-    *
-    *        ... 16.03.23: I HOPE YOUR FUCKING HAPPY
-    *        ... 22.03.23: incomprehensible pain
-    *        
-    * -- use this in world_routes too  --
-    *
-    */
-
-   struct countable
-   {
-      enum   classtype ct, ct1;
-      void **to_allocate;
-      u32    item_size;
-      int    count;
-   }
-   entity_counts[] =
-   {
-      { 
-         k_classtype_spawn, 
-         k_classtype_none,
-         (void*)&world->spawns,       
-         sizeof(struct respawn_point) 
-      },
-      { 
-         k_classtype_audio, 
-         k_classtype_none,
-         (void*)&world->audio_things, 
-         sizeof(struct world_audio_thing) 
-      },
-      {
-         k_classtype_world_light,
-         k_classtype_none,
-         (void*)&world->lights,
-         sizeof(struct world_light)
-      },
-      {
-         k_classtype_nonlocal_gate,
-         k_classtype_none,
-         (void*)&world->nonlocal_gates,
-         sizeof(struct nonlocal_gate)
-      },
-   };
-
-   for( int i=0; i<vg_list_size(entity_counts); i++ )
-      entity_counts[i].count = 0;
-
-   for( int i=0; i<world->meta->info.node_count; i++ )
-   {
-      mdl_node *pnode = mdl_node_from_id( world->meta, i );
-      
-      for( int j=0; j<vg_list_size(entity_counts); j ++ )
-      {
-         if( (pnode->classtype == entity_counts[j].ct) ||
-             (pnode->classtype == entity_counts[j].ct1) )
-         {
-            pnode->sub_uid = entity_counts[j].count;
-            entity_counts[j].count ++;
-            break;
-         }
-      }
-   }
-
-   for( int i=0; i<vg_list_size(entity_counts); i++ )
-   {
-      struct countable *counter = &entity_counts[i];
-      
-      u32 bufsize = counter->item_size*counter->count;
-      *counter->to_allocate = vg_linear_alloc( world_global.generic_heap, 
-                                               bufsize );
-      memset( *counter->to_allocate, 0, bufsize );
-   }
-
-   world->volume_bh = bh_create( world_global.generic_heap,
-                                  &bh_system_volumes,
-                                  world,
-                                  world->volume_count,
-                                  1 );
-}
-#endif
 
 #if 0
 VG_STATIC void world_pct_spawn( world_instance *world, mdl_node *pnode )
@@ -223,19 +137,6 @@ VG_STATIC void world_pct_spawn( world_instance *world, mdl_node *pnode )
    rp->name = mdl_pstr( world->meta, pnode->pstr_name );
 }
 
-VG_STATIC void world_pct_water( world_instance *world, mdl_node *pnode )
-{
-   if( world->water.enabled )
-   {
-      vg_warn( "Multiple water surfaces in level! ('%s')\n", 
-               mdl_pstr( world->meta, pnode->pstr_name ));
-      return;
-   }
-
-   world->water.enabled = 1;
-   water_set_surface( world, pnode->co[1] );
-}
-
 VG_STATIC void world_pct_audio( world_instance *world, mdl_node *pnode )
 {
    struct world_audio_thing *thing = &world->audio_things[
@@ -974,6 +875,18 @@ VG_STATIC void world_entities_init( world_instance *world )
       ent_gate *gate = mdl_arritm( &world->ent_gate, j );
       gate_transform_update( gate );
    }
+
+   /* water */
+   for( u32 j=0; j<mdl_arrcount(&world->ent_water); j++ ){
+      ent_water *water = mdl_arritm( &world->ent_water, j );
+      if( world->water.enabled ){
+         vg_warn( "Multiple water surfaces in level!\n" );
+         break;
+      }
+
+      world->water.enabled = 1;
+      water_set_surface( world, water->transform.co[1] );
+   }
 }
 
 VG_STATIC void world_load( world_instance *world, const char *path )
@@ -1004,6 +917,8 @@ VG_STATIC void world_load( world_instance *world, const char *path )
                    "ent_checkpoint", world_global.generic_heap );
    mdl_load_array( &world->meta, &world->ent_route,
                    "ent_route", world_global.generic_heap );
+   mdl_load_array( &world->meta, &world->ent_water,
+                   "ent_water", world_global.generic_heap );
 
    mdl_close( &world->meta );