X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=skaterift.c;h=5400e76b43f1dd7234d80f2bebc523d9a33a78a4;hb=7b1e8a237acc3121c86fab9b5946da6a8d3bf6c4;hp=2edd7dc5231a84d5fa148270f815b124dbeb2e2b;hpb=a8ba9cc44e1ae9aeca62fb579a3105c625e59133;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/skaterift.c b/skaterift.c index 2edd7dc..5400e76 100644 --- a/skaterift.c +++ b/skaterift.c @@ -14,28 +14,42 @@ #if 1 #define SR_NETWORKED -#define VG_DEVWINDOW +//#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" +#include "highscores.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; @@ -44,10 +58,12 @@ int main( int argc, char *argv[] ) return 0; } +#if 0 VG_STATIC void highscores_save_at_exit(void) { highscores_serialize_all(); } +#endif VG_STATIC void vg_launch_opt(void) { @@ -65,11 +81,13 @@ vg_info(" | \\/ | | / | | \\ | / | \n" ); vg_info(" ' ' '--' [] '----- '----- ' ' '---' " "SOFTWARE\n" ); + /* 31.05.23 (hgn): this is only a server feature now */ +#if 0 highscores_init( 2000, 50 ); if( !highscores_read() ) highscores_create_db(); - vg_loader_step( NULL, highscores_save_at_exit ); +#endif steam_init(); vg_loader_step( NULL, steam_end ); @@ -94,7 +112,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(); @@ -106,14 +124,17 @@ VG_STATIC void vg_load(void) vg_loader_step( render_init, NULL ); vg_loader_step( menu_init, NULL ); + vg_loader_step( pointcloud_init, NULL ); 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 ); @@ -133,11 +154,48 @@ 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.mdl" ); - + + /* load home/permanent world manually */ + world_loader.reg = NULL; + strcpy( world_loader.override_name, "mp_spawn" ); + world_loader.generate_point_cloud = 1; + world_loader.world_index = 0; + 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(); + temp_update_playermodel(); vg_async_call( async_skaterift_complete, NULL, 0 ); } @@ -165,8 +223,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" ); } @@ -174,7 +232,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(); } @@ -291,9 +349,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