return 0xffffffff;
}
+static void addon_alias_uid( addon_alias *alias, char buf[76] ){
+ if( alias->workshop_id ){
+ snprintf( buf, 128, "sr%03d-steam-"PRINTF_U64,
+ alias->type, alias->workshop_id );
+ }
+ else {
+ snprintf( buf, 128, "sr%03d-local-%s",
+ alias->type, alias->foldername );
+ }
+}
+
static void addon_system_init( void ){
u32 reg_size = sizeof(addon_reg)*ADDON_MOUNTED_MAX;
addon_system.registry = vg_linear_alloc( vg_mem.rtmemory, reg_size );
static int addon_get_content_folder( addon_reg *reg, vg_str *folder );
/* scanning routines */
+static u32 addon_match( addon_alias *alias );
+static void addon_alias_uid( addon_alias *alias, char buf[76] );
VG_STATIC void addon_mount_content_folder( enum addon_type type,
const char *base_folder,
const char *content_ext );
if( loadable && button_down( k_srbind_maccept ) ){
vg_info( "Select rift (%u)\n",
global_skateshop.selected_world_id );
- world_loader.reg = reg;
- world_loader.override_name[0] = '\0';
- skaterift_change_world_start();
+ skaterift_change_world_start( reg );
return;
}
else{
menu_close();
}
else if( MDL_CONST_PSTREQ( &menu.model, q, "reset_home" ) ){
- world_static.active_world = 0;
+ world_static.active_instance = 0;
world_static.active_trigger_volume_count = 0;
localplayer.viewable_world = world_current_instance();
localplayer_cmd_respawn( 1, (const char *[]){"start"} );
m4x3_mulv( gate->transport, player->cam.pos, player->cam.pos );
if( gate->flags & k_ent_gate_nonlocal )
- world_static.active_world = gate->target;
+ world_static.active_instance = gate->target;
audio_lock();
audio_oneshot( &audio_gate_pass, 1.0f, 0.0f );
g_player_debugger[2] = 300;
g_player_debugger[3] = 32;
- player__debugtext( 2, "world (%u)", world_static.active_world );
- player__debugtext( 1, "model version: %u",
- world_current_instance()->meta.info.version );
+ player__debugtext( 2, "instance #%u", world_static.active_instance );
+ char buf_hub[96],
+ buf_client[96];
+ if( world_static.addon_client )
+ addon_alias_uid( &world_static.addon_client->alias, buf_client );
+ else
+ strcpy( buf_client, "none" );
+
+ if( world_static.addon_hub )
+ addon_alias_uid( &world_static.addon_hub->alias, buf_hub );
+ else
+ strcpy( buf_hub, "none" );
+
+ player__debugtext( 1, "hub uid: %s", buf_hub );
+ player__debugtext( 1, "client uid: %s", buf_client );
player__debugtext( 2, "director" );
player__debugtext( 1, "activity: %s",
(const char *[]){ [k_skaterift_menu] = "menu",
m3x3_mul( gate->transport, basis, basis );
if( gate->flags & k_ent_gate_nonlocal ){
- trace_world = &world_static.worlds[ gate->target ];
+ trace_world = &world_static.instances[ gate->target ];
}
}
}
vg_msg_frame( &sav, "world" );
{
- if( world_loader.reg && (world_static.active_world > 0) ){
- skaterift_write_addon_alias( &sav, "alias", &world_loader.reg->alias );
- vg_msg_wkvu32( &sav, "index", world_static.active_world );
+ addon_reg *reg = world_static.addon_client;
+ if( reg && (world_static.active_instance > 0) ){
+ skaterift_write_addon_alias( &sav, "alias", ®->alias );
+ vg_msg_wkvu32( &sav, "index", world_static.active_instance );
vg_msg_wkvnum( &sav, "position", k_vg_msg_float|k_vg_msg_32b, 3,
localplayer.rb.co );
}
if( reg_id != 0xffffffff ){
addon_reg *reg = get_addon_from_index( k_addon_type_world, reg_id );
- world_loader.generate_point_cloud = 0;
- world_loader.reg = reg;
- world_loader.state = k_world_loader_load;
- skaterift_world_changer_thread(NULL);
+ world_static.addon_client = reg;
+ world_static.load_state = k_world_loader_load;
+ skaterift_client_world_changer_thread(NULL);
- world_static.active_world = vg_msg_seekkvu32( &world, "index", 0 );
+ world_static.active_instance = vg_msg_seekkvu32( &world, "index", 0 );
world_static.active_trigger_volume_count = 0;
localplayer.viewable_world = world_current_instance();
vg_loader_step( audio_init, audio_free );
/* 'systems' are completely loaded now */
-
- /* 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" );
-
- vg_async_call( async_skaterift_player_start, NULL, 0 );
- vg_async_stall();
/* Completing addon registrations
* -------------------------------------
mtzero->metadata_len = msg.cur;
}
+ /* load home/permanent world manually */
+ world_static.addon_hub = spawn;
+ world_instance_load_mdl( 0, "maps/mp_spawn/main.mdl" );
+
+ vg_async_call( async_skaterift_player_start, NULL, 0 );
+ vg_async_stall();
+
+
global_skateshop.selected_world_id=1;
global_skateshop.pointcloud_world_id=1;
skateshop_world_preview_loader_thread( mtzero ); /* HACK */
vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
}
-static void skaterift_change_world_preupdate(void);
+static void skaterift_change_client_world_preupdate(void);
/*
* UPDATE LOOP
steam_update();
skaterift_preupdate_inputs();
if( skaterift.op == k_async_op_clientloading ) return;
- if( world_loader.state == k_world_loader_preload )
- skaterift_change_world_preupdate();
+ if( world_static.load_state == k_world_loader_preload )
+ skaterift_change_client_world_preupdate();
draw_origin_axis();
network_update();
return;
}
- for( u32 i=0; i<vg_list_size(world_static.worlds); i++ ){
- if( world_static.worlds[i].status == k_world_status_loaded ){
- world_prerender( &world_static.worlds[i] );
+ for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
+ if( world_static.instances[i].status == k_world_status_loaded ){
+ world_prerender( &world_static.instances[i] );
}
}
static skaterift = { .op = k_async_op_clientloading, .time_rate = 1.0f };
/* Skaterift api */
-static void skaterift_change_world_start( void );
+static void skaterift_change_world_start( addon_reg *reg );
static int skaterift_change_world_command( int argc, const char *argv[] );
#endif /* SKATERIFT_H */
#include "network.h"
static world_instance *world_current_instance(void){
- return &world_static.worlds[ world_static.active_world ];
+ return &world_static.instances[ world_static.active_instance ];
}
static void world_init(void)
u32 active_trigger_volumes[8];
u32 active_trigger_volume_count;
- world_instance worlds[4];
- i32 active_world;
+ world_instance instances[4];
+ i32 active_instance;
+
+ addon_reg *addon_hub,
+ *addon_client;
+
+ enum world_loader_state{
+ k_world_loader_none,
+ k_world_loader_preload,
+ k_world_loader_load
+ }
+ load_state;
}
static world_static;
" audio.\n" );
}
- u8 world_id = (world - world_static.worlds) + 1;
+ u8 world_id = (world - world_static.instances) + 1;
audio_lock();
for( u32 i=0; i<AUDIO_CHANNELS; i++ ){
#include "world.h"
#include "world_load.h"
-VG_STATIC void world_gen_entities_init(void){
- world_instance *world = world_loading_instance();
-
+VG_STATIC void world_gen_entities_init( world_instance *world ){
/* lights */
for( u32 j=0; j<mdl_arrcount(&world->ent_light); j ++ ){
ent_light *light = mdl_arritm( &world->ent_light, j );
return;
}
- u8 world_id = (world - world_static.worlds) + 1;
+ u8 world_id = (world - world_static.instances) + 1;
u32 index = mdl_entity_id_id( call->id );
ent_audio *audio = mdl_arritm( &world->ent_audio, index );
#include "entity.h"
#include "bvh.h"
-VG_STATIC void world_gen_entities_init(void);
+VG_STATIC void world_gen_entities_init( world_instance *world );
VG_STATIC ent_spawn *world_find_spawn_by_name( world_instance *world,
const char *name );
VG_STATIC ent_spawn *world_find_closest_spawn( world_instance *world,
if( gate->flags & k_ent_gate_locked ) continue;
if( gate->flags & k_ent_gate_nonlocal ){
- if( world_loader.state != k_world_loader_none ){
+ if( world_static.load_state != k_world_loader_none ){
continue;
}
}
/*
* attatches nonlocal gates, to be called from main thread ONLY!
*/
-VG_STATIC void world_link_nonlocal_async( void *payload, u32 size )
-{
+VG_STATIC void world_link_nonlocal_async( void *payload, u32 size ){
world_instance *world = payload;
- u32 world_id = world - world_static.worlds;
+ u32 world_id = world - world_static.instances;
for( u32 j=0; j<mdl_arrcount(&world->ent_gate); j ++ ){
ent_gate *gate = mdl_arritm( &world->ent_gate, j );
const char *key = mdl_pstr( &world->meta, gate->key );
vg_info( "key: %s\n", key );
- for( u32 i=0; i<vg_list_size(world_static.worlds); i++ ){
- world_instance *other = &world_static.worlds[i];
+ for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
+ world_instance *other = &world_static.instances[i];
if( other == world ) continue;
if( other->status != k_world_status_loaded ) continue;
vg_info( "Checking world %u for key matches\n", i );
* | |
* |________|
*/
-VG_STATIC void world_gen_add_blob( scene_context *scene, ray_hit *hit )
+VG_STATIC void world_gen_add_blob( world_instance *world,
+ scene_context *scene, ray_hit *hit )
{
- world_instance *world = world_loading_instance();
m4x3f transform;
v4f qsurface, qrandom;
v3f axis;
/*
* Sprinkle foliage models over the map on terrain material
*/
-VG_STATIC void world_apply_procedural_foliage( scene_context *scene,
+VG_STATIC void world_apply_procedural_foliage( world_instance *world,
+ scene_context *scene,
struct world_surface *mat )
{
if( vg.quality_profile == k_quality_profile_low )
return;
- world_instance *world = world_loading_instance();
vg_info( "Applying foliage (%u)\n", mat->info.pstr_name );
v3f volume;
if( ray_world( world, pos, (v3f){0.0f,-1.0f,0.0f}, &hit )){
struct world_surface *m1 = ray_hit_surface( world, &hit );
if((hit.normal[1] > 0.8f) && (m1 == mat) && (hit.pos[1] > 0.0f+10.0f)){
- world_gen_add_blob( scene, &hit );
+ world_gen_add_blob( world, scene, &hit );
count ++;
}
}
/*
* Create the main meshes for the world
*/
-VG_STATIC void world_gen_generate_meshes(void)
-{
+VG_STATIC void world_gen_generate_meshes( world_instance *world ){
/*
* Compile meshes into the world scenes
*/
- world_instance *world = world_loading_instance();
scene_init( &world->scene_geo, 320000, 1200000 );
u32 buf_size = scene_mem_required( &world->scene_geo );
u8 *buffer = vg_linear_alloc( world->heap, buf_size );
&world->scene_no_collide, &world->meta, i );
}
- if( surf->info.flags & k_material_flag_grow_grass )
- world_apply_procedural_foliage( &world->scene_no_collide, surf );
+ if( surf->info.flags & k_material_flag_grow_grass ){
+ world_apply_procedural_foliage( world, &world->scene_no_collide,
+ surf );
+ }
scene_copy_slice( &world->scene_no_collide, &surf->sm_no_collide );
}
}
/* signed distance function for cone */
-static f32 fsd_cone_infinite( v3f p, v2f c )
-{
+static f32 fsd_cone_infinite( v3f p, v2f c ){
v2f q = { v2_length( (v2f){ p[0], p[2] } ), -p[1] };
float s = vg_maxf( 0.0f, v2_dot( q, c ) );
/*
* Async reciever to buffer light index data
*/
-VG_STATIC void async_upload_light_indices( void *payload, u32 size )
-{
+VG_STATIC void async_upload_light_indices( void *payload, u32 size ){
struct light_indices_upload_info *info = payload;
glGenTextures( 1, &info->world->tex_light_cubes );
/*
* Computes light indices for world
*/
-VG_STATIC void world_gen_compute_light_indices(void)
-{
+VG_STATIC void world_gen_compute_light_indices( world_instance *world ){
/* light cubes */
- world_instance *world = world_loading_instance();
v3f cubes_min, cubes_max;
v3_muls( world->scene_geo.bbx[0], 1.0f/k_world_light_cube_size, cubes_min );
v3_muls( world->scene_geo.bbx[1], 1.0f/k_world_light_cube_size, cubes_max );
/*
* Rendering pass needed to complete the world
*/
-VG_STATIC void async_world_postprocess_render( void *payload, u32 _size )
-{
+VG_STATIC void async_world_postprocess_render( void *payload, u32 _size ){
/* create scene lighting buffer */
- world_instance *world = world_loading_instance();
+ world_instance *world = payload;
u32 size = VG_MAX(mdl_arrcount(&world->ent_light),1) * sizeof(float)*12;
vg_info( "Upload %ubytes (lighting)\n", size );
}
/* Loads textures from the pack file */
-VG_STATIC void world_gen_load_surfaces(void)
-{
- world_instance *world = world_loading_instance();
+VG_STATIC void world_gen_load_surfaces( world_instance *world ){
vg_info( "Loading textures\n" );
world->texture_count = 0;
#include "world.h"
VG_STATIC void world_init_blank( world_instance *world );
-VG_STATIC void world_gen_load_surfaces(void);
-VG_STATIC void world_gen_generate_meshes(void);
-VG_STATIC void world_gen_compute_light_indices(void);
+VG_STATIC void world_gen_load_surfaces( world_instance *world );
+VG_STATIC void world_gen_generate_meshes( world_instance *world );
+VG_STATIC void world_gen_compute_light_indices( world_instance *world );
VG_STATIC void async_world_postprocess_render( void *payload, u32 _size );
#endif /* WORLD_GEN_H */
#include "world_routes.h"
#include "world_gate.h"
#include "ent_skateshop.h"
+#include "addon.h"
/*
- * load the .mdl file located in path (relative to exe), it will load into the
- * slot specified by world_loader.world_index
+ * load the .mdl file located in path as a world instance
*/
-VG_STATIC void world_load_mdl( const char *path )
-{
+VG_STATIC void world_instance_load_mdl( u32 instance_id, const char *path ){
vg_rand_seed( 9001 );
- world_instance *world = world_loading_instance();
+ world_instance *world = &world_static.instances[ instance_id ];
world_init_blank( world );
world->status = k_world_status_loading;
vg_info( "Loading world: %s\n", path );
void *allocator = NULL;
- if( world_loader.world_index == 0 ) allocator = world_static.heap;
- else allocator = world_static.worlds[world_loader.world_index-1].heap;
+ if( instance_id == 0 ) allocator = world_static.heap;
+ else allocator = world_static.instances[instance_id-1].heap;
u32 heap_availible = vg_linear_remaining( allocator );
u32 min_overhead = sizeof(vg_linear_allocator);
world->time = (float)tm->tm_min/20.0f + (world->info.timezone/24.0f);
/* process resources from pack */
- world_gen_load_surfaces();
- world_gen_routes_ent_init();
- world_gen_entities_init();
+ world_gen_load_surfaces( world );
+ world_gen_routes_ent_init( world );
+ world_gen_entities_init( world );
/* main bulk */
- world_gen_generate_meshes();
- world_gen_routes_generate();
- world_gen_compute_light_indices();
- vg_async_call( async_world_postprocess_render, NULL, 0 );
+ world_gen_generate_meshes( world );
+ world_gen_routes_generate( instance_id );
+ world_gen_compute_light_indices( world );
+ vg_async_call( async_world_postprocess_render, world, 0 );
vg_async_stall();
mdl_close( meta );
world->status = k_world_status_loaded;
}
-static void skaterift_world_change_done( void *payload, u32 size ){
- world_loader.state = k_world_loader_none;
+static void skaterift_client_world_change_done( void *payload, u32 size ){
+ world_static.load_state = k_world_loader_none;
}
/*
* Does a complete world switch using the remaining free slots
*/
-static void skaterift_world_changer_thread( void *_ ){
+static void skaterift_client_world_changer_thread( void *_ ){
char path_buf[4096];
vg_str path;
vg_strnull( &path, path_buf, 4096 );
- if( world_loader.reg ){
- addon_get_content_folder( world_loader.reg, &path );
- }
- else {
- vg_strcat( &path, "maps/" );
- vg_strcat( &path, world_loader.override_name );
- }
+ assert( world_static.addon_client );
+ addon_get_content_folder( world_static.addon_client, &path );
vg_str folder = path;
if( !vg_strgood( &folder ) ) {
}
}
- world_loader.generate_point_cloud = 1;
- world_loader.world_index = 1;
- world_load_mdl( worlds[first_index] );
+ world_instance_load_mdl( 1, worlds[first_index] );
+ /* TODO: Support multiply packed worlds */
+#if 0
world_loader.generate_point_cloud = 0;
for( u32 j=0; j<i; j++ ){
if( j != first_index ){
world_load_mdl( worlds[j] );
}
}
+#endif
- vg_async_call( skaterift_world_change_done, NULL, 0 );
+ vg_async_call( skaterift_client_world_change_done, NULL, 0 );
}
/* holding pattern before we can start loading the new world, since we might be
* waiting for audio to stop */
-static void skaterift_change_world_preupdate(void){
- for( u32 i=1; i<vg_list_size(world_static.worlds); i++ ){
- world_instance *inst = &world_static.worlds[i];
+static void skaterift_change_client_world_preupdate(void){
+ for( u32 i=1; i<vg_list_size(world_static.instances); i++ ){
+ world_instance *inst = &world_static.instances[i];
if( inst->status == k_world_status_unloading ){
if( world_freeable( inst ) ){
}
vg_info( "worlds cleared, begining load\n" );
- world_loader.state = k_world_loader_load;
+ world_static.load_state = k_world_loader_load;
/* finally can start the loader */
- vg_loader_start( skaterift_world_changer_thread, NULL );
+ vg_loader_start( skaterift_client_world_changer_thread, NULL );
}
/* places all loaded worlds into unloading state */
-static void skaterift_change_world_start(void){
- if( world_loader.reg ){
- vg_info( "switching to %s ("PRINTF_U64"\n",
- world_loader.reg->alias.foldername,
- world_loader.reg->alias.workshop_id );
- }
- else{
- vg_info( "switching to %s(local)\n", world_loader.override_name );
- }
-
- if( world_static.active_world != 0 ){
+static void skaterift_change_world_start( addon_reg *reg ){
+ if( world_static.active_instance != 0 )
vg_error( "Cannot change worlds while in non-root world\n" );
- }
else{
- world_loader.state = k_world_loader_preload;
+ char buf[76];
+ addon_alias_uid( ®->alias, buf );
+ vg_info( "switching to: %s\n", buf );
+
+ world_static.load_state = k_world_loader_preload;
vg_linear_clear( vg_mem.scratch ); /* ?? */
vg_info( "unloading old worlds\n" );
- world_unlink_nonlocal( &world_static.worlds[0] );
+ world_unlink_nonlocal( &world_static.instances[0] );
- for( u32 i=1; i<vg_list_size(world_static.worlds); i++ ){
- world_instance *inst = &world_static.worlds[i];
+ for( u32 i=1; i<vg_list_size(world_static.instances); i++ ){
+ world_instance *inst = &world_static.instances[i];
if( inst->status == k_world_status_loaded ){
inst->status = k_world_status_unloading;
world_fadeout_audio( inst );
+
+ /* TODO: THIS IS WHERE A SAVE SHOULD BE DONE */
}
}
+
+ world_static.addon_client = reg;
}
}
/* console command for the above function */
-static int skaterift_change_world_command( int argc, const char *argv[] )
-{
+static int skaterift_change_world_command( int argc, const char *argv[] ){
if( argc == 1 ){
- world_loader.reg = NULL;
- vg_strncpy( argv[0], world_loader.override_name,
- vg_list_size( world_loader.override_name ),
- k_strncpy_always_add_null );
- skaterift_change_world_start();
+ addon_alias q;
+ q.type = k_addon_type_world;
+ q.workshop_id = 0;
+ vg_strncpy( argv[0], q.foldername, 64, k_strncpy_always_add_null );
+
+ u32 reg_id = addon_match( &q );
+ if( reg_id != 0xffffffff ){
+ addon_reg *reg = get_addon_from_index( k_addon_type_world, reg_id );
+ skaterift_change_world_start( reg );
+ }
+ else {
+ char buf[76];
+ addon_alias_uid( &q, buf );
+ vg_error( "Addon '%s' is not installed or not found.\n", buf );
+ }
}
return 0;
}
-
+#if 0
static world_instance *world_loading_instance(void){
- return &world_static.worlds[ world_loader.world_index ];
+ return &world_static.instances[ world_loader.world_index ];
}
+#endif
/*
* checks:
* 1. to see if all audios owned by the world have been stopped
* 2. that this is the least significant world
*/
-static int world_freeable( world_instance *world )
-{
+static int world_freeable( world_instance *world ){
if( world->status != k_world_status_unloading ) return 0;
- u8 world_id = (world - world_static.worlds) + 1;
+ u8 world_id = (world - world_static.instances) + 1;
- for( u32 i=world_id; i<vg_list_size(world_static.worlds); i++ ){
- if( world_static.worlds[i].status != k_world_status_unloaded ){
+ for( u32 i=world_id; i<vg_list_size(world_static.instances); i++ ){
+ if( world_static.instances[i].status != k_world_status_unloaded ){
return 0;
}
}
/* delete textures and meshes */
glDeleteTextures( world->texture_count, world->textures );
- u32 world_index = world - world_static.worlds;
+ u32 world_index = world - world_static.instances;
if( world_index ){
- vg_linear_del( world_static.worlds[world_index-1].heap,
+ vg_linear_del( world_static.instances[world_index-1].heap,
vg_linear_header(world->heap) );
}
v3_copy( (v3f){1.10f, 0.89f, 0.35f}, state->g_sun_colour );
}
-
-
#endif /* WORLD_LOAD_C */
#include "world_volumes.h"
#include "addon.h"
-struct{
- addon_reg *reg;
- char override_name[64];
- int generate_point_cloud;
- u32 world_index;
-
- enum world_loader_state{
- k_world_loader_none,
- k_world_loader_preload,
- k_world_loader_load
- }
- state;
-}
-static world_loader;
-
-static world_instance *world_loading_instance(void);
static void world_free( world_instance *world );
static int world_freeable( world_instance *world );
{
vg_info( "Allocate uniform buffers\n" );
for( int i=0; i<4; i++ ){
- world_instance *world = &world_static.worlds[i];
+ world_instance *world = &world_static.instances[i];
world->ubo_bind_point = i;
glGenBuffers( 1, &world->ubo_lighting );
vg_info( "Allocate frame buffers\n" );
for( int i=0; i<4; i++ ){
- world_instance *world = &world_static.worlds[i];
+ world_instance *world = &world_static.instances[i];
struct framebuffer *fb = &world->heightmap;
fb->display_name = NULL;
if( gate->flags & k_ent_gate_locked ) return;
if( gate->flags & k_ent_gate_nonlocal ){
- if( world_loader.state != k_world_loader_none ){
+ if( world_static.load_state != k_world_loader_none ){
world->rendering_gate = NULL;
return;
}
- world_instance *dest_world = &world_static.worlds[ gate->target ];
+ world_instance *dest_world = &world_static.instances[ gate->target ];
render_gate( world, dest_world, gate, cam, layer_depth );
}
else{
}
}
-VG_STATIC void world_write_preview( pointcloud_buffer *pcbuf ){
+VG_STATIC void world_write_preview( addon_reg *reg, pointcloud_buffer *pcbuf ){
+ if( reg->alias.workshop_id ) return;
+
+ /*
+ * FIXME: BUG: cannot correctly handle workshop because there is a stalling
+ * call below, which deadlocks the scene upload. TODO: improve the async
+ * stack to handle out of order execution. MAYBE
+ */
+
char path_buf[4096];
vg_str path;
vg_strnull( &path, path_buf, 4096 );
- if( world_loader.reg ){
- /* Don't want to override the one we get from the workshop */
- if( world_loader.reg->alias.workshop_id ) return;
-
- addon_get_content_folder( world_loader.reg, &path );
- }
- else{
- vg_strcat( &path, "maps/" );
- vg_strcat( &path, world_loader.override_name );
- }
-
+ addon_get_content_folder( reg, &path );
vg_strcat( &path, "/preview.bin" );
if( !vg_strgood( &path ) ) vg_fatal_error( "Path too long\n" );
fwrite( pcbuf, sizeof(struct pointcloud_buffer) +
sizeof(struct pointcloud_vert)*pcbuf->count, 1, fp );
fclose( fp );
+ vg_info( "written %s\n", path_buf );
}
/*
* Create the strips of colour that run through the world along course paths
*/
-VG_STATIC void world_gen_routes_generate(void)
-{
- world_instance *world = world_loading_instance();
+VG_STATIC void world_gen_routes_generate( u32 instance_id ){
+ world_instance *world = &world_static.instances[ instance_id ];
vg_info( "Generating route meshes\n" );
vg_async_stall();
vg_async_item *call_pointcloud = NULL;
pointcloud_buffer *pcbuf = NULL;
- if( world_loader.generate_point_cloud ){
+ if( instance_id <= 1 /*world_loader.generate_point_cloud*/ ){
call_pointcloud = vg_async_alloc(
sizeof(pointcloud_buffer) +
sizeof(pointcloud_vert)*POINTCLOUD_POINTS );
world_routes_gen_meshes( world, i, &world->scene_lines, pcbuf );
}
- if( world_loader.generate_point_cloud ){
+ if( instance_id <= 1 /*world_loader.generate_point_cloud*/ ){
f64 area = 0.0;
area = world_routes_scatter_surface_points( world, pcbuf, 16.0f );
world_routes_surface_grid( world, pcbuf );
vg_info( "Distrubuted %u points over %fkm^2!\n",
pcbuf->count, area/1e6f );
- world_write_preview( pcbuf );
+ world_write_preview( instance_id? world_static.addon_client:
+ world_static.addon_hub,
+ pcbuf );
vg_async_dispatch( call_pointcloud, async_pointcloud_sub );
}
}
/* load all routes from model header */
-VG_STATIC void world_gen_routes_ent_init(void)
-{
- world_instance *world = world_loading_instance();
+VG_STATIC void world_gen_routes_ent_init( world_instance *world ){
vg_info( "Initializing routes\n" );
for( u32 i=0; i<mdl_arrcount(&world->ent_gate); i++ ){
VG_STATIC void render_world_routes( world_instance *world, camera *cam,
int layer_depth );
-VG_STATIC void world_gen_routes_ent_init(void);
-VG_STATIC void world_gen_routes_generate(void);
+VG_STATIC void world_gen_routes_ent_init( world_instance *world );
+VG_STATIC void world_gen_routes_generate( u32 instance_id );
VG_STATIC void world_routes_update_timer_texts( world_instance *world );
VG_STATIC void world_routes_update( world_instance *world );
VG_STATIC void world_routes_fixedupdate( world_instance *world );