- mdl_open( &world->meta, path, world_global.generic_heap );
- mdl_load_metadata_block( &world->meta, world_global.generic_heap );
- mdl_load_animation_block( &world->meta, world_global.generic_heap );
- mdl_load_mesh_block( &world->meta, world_global.generic_heap );
-
- /* TODO: This should get a seperate memory area */
- mdl_load_pack_block( &world->meta, world_global.generic_heap );
-
- mdl_load_array( &world->meta, &world->ent_gate,
- "ent_gate", world_global.generic_heap );
- mdl_load_array( &world->meta, &world->ent_spawn,
- "ent_spawn", world_global.generic_heap );
- mdl_load_array( &world->meta, &world->ent_light,
- "ent_light", world_global.generic_heap );
-
- mdl_load_array( &world->meta, &world->ent_route_node,
- "ent_route_node", world_global.generic_heap );
- mdl_load_array( &world->meta, &world->ent_path_index,
- "ent_path_index", world_global.generic_heap );
- mdl_load_array( &world->meta, &world->ent_checkpoint,
- "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_load_array( &world->meta, &world->ent_audio_clip,
- "ent_audio_clip", world_global.generic_heap );
- mdl_load_array( &world->meta, &world->ent_audio,
- "ent_audio", world_global.generic_heap );
- mdl_load_array( &world->meta, &world->ent_volume,
- "ent_volume", world_global.generic_heap );
-
- mdl_close( &world->meta );
+ void *allocator = NULL;
+ if( index == 0 ) allocator = world_global.heap;
+ else allocator = world_global.worlds[index-1].heap;
+
+ u32 heap_availible = vg_linear_remaining( allocator );
+ u32 min_overhead = sizeof(vg_linear_allocator);
+
+ if( heap_availible < (min_overhead+1024) ){
+ vg_fatal_exit_loop( "out of memory" );
+ }
+
+ u32 size = heap_availible - min_overhead;
+ void *heap = vg_create_linear_allocator( allocator, size,
+ VG_MEMORY_SYSTEM );
+
+ world->heap = heap;
+ mdl_context *meta = &world->meta;
+
+ mdl_open( meta, path, world->heap );
+ mdl_load_metadata_block( meta, world->heap );
+ mdl_load_animation_block( meta, world->heap );
+ mdl_load_mesh_block( meta, world->heap );
+
+ mdl_load_array( meta, &world->ent_gate, "ent_gate", heap );
+ mdl_load_array( meta, &world->ent_spawn, "ent_spawn", heap );
+ mdl_load_array( meta, &world->ent_light, "ent_light", heap );
+ mdl_load_array( meta, &world->ent_route_node,"ent_route_node", heap );
+ mdl_load_array( meta, &world->ent_path_index,"ent_path_index", heap );
+ mdl_load_array( meta, &world->ent_checkpoint,"ent_checkpoint", heap );
+ mdl_load_array( meta, &world->ent_route, "ent_route", heap );
+ mdl_load_array( meta, &world->ent_water, "ent_water", heap );
+ mdl_load_array( meta, &world->ent_audio_clip,"ent_audio_clip", heap );
+ mdl_load_array( meta, &world->ent_audio, "ent_audio", heap );
+ mdl_load_array( meta, &world->ent_volume, "ent_volume", heap );