revision 2
[carveJwlIkooP6JGAAIwe30JlM.git] / world.c
diff --git a/world.c b/world.c
index 9ff62bcb3df1b3471462542c21cda5ea53b82d51..9b19387208ad9a47a5c96805b6923a83185af09b 100644 (file)
--- a/world.c
+++ b/world.c
@@ -2,19 +2,25 @@
  * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved
  */
 
-#ifndef WORLD_C
-#define WORLD_C
-
+#include "skaterift.h"
 #include "world.h"
 #include "network.h"
 #include "vg/vg_loader.h"
 #include "vg/vg_mem.h"
+#include "save.h"
+#include "player.h"
+#include "ent_traffic.h"
+
+struct world_static world_static;
 
-static world_instance *world_current_instance(void){
+world_instance *world_current_instance(void)
+{
    return &world_static.instances[ world_static.active_instance ];
 }
 
-static void world_init(void)
+static int skaterift_switch_instance_cmd( int argc, const char *argv[] );
+
+void world_init(void)
 {
    vg_loader_step( world_render_init, NULL );
    vg_loader_step( world_sfd_init, NULL );
@@ -26,9 +32,13 @@ static void world_init(void)
    u32 max_size = 76*1024*1024;
    world_static.heap = vg_create_linear_allocator( vg_mem.rtmemory, max_size,
                                                    VG_MEMORY_SYSTEM );
+
+   vg_console_reg_cmd( "switch_active_instance", 
+                        skaterift_switch_instance_cmd, NULL );
 }
 
-static void world_switch_instance( u32 index ){
+void world_switch_instance( u32 index )
+{
    localplayer.subsystem = k_player_subsystem_walk;
 
    if( index >= vg_list_size(world_static.instances) ){
@@ -64,7 +74,8 @@ static void world_switch_instance( u32 index ){
    player__reset();
 }
 
-static int skaterift_switch_instance_cmd( int argc, const char *argv[] ){
+static int skaterift_switch_instance_cmd( int argc, const char *argv[] )
+{
    if( argc )
       world_switch_instance( atoi(argv[0]) );
    else 
@@ -72,8 +83,8 @@ static int skaterift_switch_instance_cmd( int argc, const char *argv[] ){
    return 0;
 }
 
-static void skaterift_world_get_save_path( enum world_purpose which, 
-                                           char buf[128] ){
+void skaterift_world_get_save_path( enum world_purpose which, char buf[128] )
+{
    addon_reg *reg = world_static.instance_addons[ which ];
 
    if( !reg )
@@ -84,19 +95,8 @@ static void skaterift_world_get_save_path( enum world_purpose which,
    snprintf( buf, 128, "savedata/%s.bkv", id );
 }
 
-#include "world_entity.c"
-#include "world_gate.c"
-#include "world_gen.c"
-#include "world_load.c"
-#include "world_physics.c"
-#include "world_render.c"
-#include "world_sfd.c"
-#include "world_volumes.c"
-#include "world_water.c"
-#include "world_audio.c"
-#include "world_routes.c"
-
-static void world_update( world_instance *world, v3f pos ){
+void world_update( world_instance *world, v3f pos )
+{
    world_render.sky_time += world_render.sky_rate * vg.time_delta;
    world_render.sky_rate = vg_lerp( world_render.sky_rate, 
                                     world_render.sky_target_rate, 
@@ -108,5 +108,3 @@ static void world_update( world_instance *world, v3f pos ){
    world_sfd_update( world, pos );
    world_volumes_update( world, pos );
 }
-
-#endif /* WORLD_C */