X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=skaterift.c;h=50939ae270019e8cbfcbd39f68e0478ae635ee96;hb=d43d7f62ff83799b6d99221d881179814cb239a6;hp=6f0364a9db7970728743a4ab2f1e68274eeca3cc;hpb=63b5ac44f74599b21c4b9b18398c29b797337bea;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/skaterift.c b/skaterift.c index 6f0364a..50939ae 100644 --- a/skaterift.c +++ b/skaterift.c @@ -16,27 +16,39 @@ #define SR_NETWORKED #define VG_DEVWINDOW +/* + * system headers + * --------------------- */ + #include "common.h" #include "conf.h" #include "steam.h" #include "render.h" #include "audio.h" + #include "world.h" + #include "font.h" #include "player.h" -#include "entity.c" -#include "workshop.c" - #include "network.h" #include "menu.h" #include "vehicle.h" #include "pointcloud.h" +/* unity build + * ----------------- */ + +#include "world.c" +#include "player.c" +#include "vehicle.c" +#include "entity.c" +#include "workshop.c" +#include "addon.c" + static struct player_avatar localplayer_avatar; static struct player_model localplayer_models[3]; - int main( int argc, char *argv[] ) { vg_mem.use_libc_malloc = 0; @@ -95,7 +107,7 @@ void temp_update_playermodel(void){ VG_STATIC void async_skaterift_complete( void *payload, u32 size ) { - localplayer.viewable_world = get_active_world(); + localplayer.viewable_world = world_current_instance(); localplayer_cmd_respawn( 1, (const char *[]){ "start" } ); skaterift_end_op(); @@ -111,11 +123,13 @@ VG_STATIC void vg_load(void) vg_loader_step( world_init, NULL ); vg_loader_step( vehicle_init, NULL ); vg_loader_step( font3d_init, NULL ); - - font3d_load( &world_global.font, "models/rs_font.mdl", vg_mem.rtmemory ); + vg_loader_step( gui_init, NULL ); vg_loader_step( player_init, NULL ); vg_loader_step( player_ragdoll_init, NULL ); + + /* content stuff */ + vg_loader_step( addon_system_init, NULL ); vg_loader_step( workshop_init, NULL ); vg_loader_step( skateshop_init, NULL ); @@ -135,9 +149,45 @@ VG_STATIC void vg_load(void) vg_loader_step( audio_init, audio_free ); /* 'systems' are completely loaded now */ - /* load home/permanent world */ - world_load( 0, "maps/mp_spawn/main.mdl" ); - + + /* load home/permanent world manually */ + strcpy( world_loader.name, "mp_spawn" ); + world_loader.generate_point_cloud = 1; + world_loader.world_index = 0; + world_loader.location = k_world_load_type_local; + world_load_mdl( "maps/mp_spawn/main.mdl" ); + + /* Completing addon registrations + * ------------------------------------- + */ + vg_msg msg; + + /* understate diy. */ + addon_reg *spawn = addon_mount_local_addon( "maps/mp_spawn", + k_workshop_file_type_world, + ".mdl" ); + vg_msg_init( &msg, spawn->metadata, sizeof(spawn->metadata) ); + vg_msg_frame( &msg, "workshop" ); + vg_msg_wkvstr( &msg, "title", "Understate DIY" ); + vg_msg_end_frame( &msg ); + vg_msg_wkvstr( &msg, "location", "USA" ); + spawn->metadata_len = msg.cur; + + /* mtzero island */ + addon_reg *mtzero = addon_mount_local_addon( "maps/mp_mtzero", + k_workshop_file_type_world, + ".mdl" ); + vg_msg_init( &msg, mtzero->metadata, sizeof(mtzero->metadata) ); + vg_msg_frame( &msg, "workshop" ); + vg_msg_wkvstr( &msg, "title", "Mt.Zero Island" ); + vg_msg_end_frame( &msg ); + vg_msg_wkvstr( &msg, "location", "Australia" ); + mtzero->metadata_len = msg.cur; + global_skateshop.selected_world_id=1; + global_skateshop.pointcloud_world_id=1; + skateshop_preview_loader_thread( mtzero ); /* HACK */ + + vg_async_call( async_addon_reg_update, NULL, 0 ); vg_console_load_autos(); menu_link(); @@ -167,8 +217,8 @@ VG_STATIC void vg_update(void) player__pre_update( &localplayer ); global_skateshop_preupdate(); - world_update( get_active_world(), localplayer.rb.co ); - audio_ambient_sprites_update( get_active_world(), localplayer.rb.co ); + world_update( world_current_instance(), localplayer.rb.co ); + audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co ); //gui_helper_action( localplayer.input_use, "\x7f Hello \x1f""A \x1e\x84" ); } @@ -176,7 +226,7 @@ VG_STATIC void vg_update_fixed(void) { if( skaterift.async_op == k_async_op_clientloading ) return; - world_routes_fixedupdate( get_active_world() ); + world_routes_fixedupdate( world_current_instance() ); player__update( &localplayer ); vehicle_update_fixed(); } @@ -293,9 +343,9 @@ VG_STATIC void render_scene(void) return; } - for( u32 i=0; istatus == k_world_status_unloading ){ - if( world_freeable( inst ) ){ - world_free( inst ); - } - return; - } - } - - vg_info( "worlds cleared, begining load\n" ); - skaterift_shift_op( k_async_op_world_loading ); - - /* finally can start the loader */ - vg_loader_start( skaterift_world_changer_thread, NULL ); -} - -/* places all loaded worlds into unloading state */ -static void skaterift_change_world( const char *world_path ) -{ - vg_info( "switching to %s\n", world_path ); - - if( world_global.active_world != 0 ){ - vg_error( "Cannot change worlds while in non-root world\n" ); - } - else{ - skaterift_begin_op( k_async_op_world_preloading ); - - vg_linear_clear( vg_mem.scratch ); - world_global.load_target = vg_linear_alloc( vg_mem.scratch, 1024 ); - vg_strncpy( world_path, world_global.load_target, - 1024, k_strncpy_overflow_fatal ); - - vg_info( "unloading old worlds\n" ); - world_unlink_nonlocal( &world_global.worlds[0] ); - - for( u32 i=1; istatus == k_world_status_loaded ){ - inst->status = k_world_status_unloading; - world_fadeout_audio( inst ); - } - } - } -} - -static int skaterift_change_world_command( int argc, const char *argv[] ) -{ - if( argc == 1 ) - skaterift_change_world( argv[0] ); - - return 0; -} #else