X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.h;h=66b3b28f2c0b14a961cf7ea04ef4b27321332cc7;hb=a8ba9cc44e1ae9aeca62fb579a3105c625e59133;hp=68c3f2b2ed4e9217fda06834e979f50f4cda5ca6;hpb=e5d79dc0355e04baecce8908e29b8e7569d1e857;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.h b/world.h index 68c3f2b..66b3b28 100644 --- a/world.h +++ b/world.h @@ -62,11 +62,11 @@ struct world_instance { */ void *heap; - char world_name[ 64 ]; enum world_status{ k_world_status_unloaded = 0, k_world_status_loading = 1, - k_world_status_loaded = 2 + k_world_status_loaded = 2, + k_world_status_unloading = 3 /* dont spawn sounds and stuff */ } status; @@ -127,7 +127,6 @@ struct world_instance { float probabilities[3]; v3i light_cubes; - struct framebuffer heightmap; /* @@ -206,6 +205,7 @@ struct world_global{ * -------------------------------------------------------------------------- */ void *heap; + char *load_target; /* rendering */ glmesh skydome; @@ -239,8 +239,6 @@ struct world_global{ v3f render_gate_pos; int in_volume; - int switching_to_new_world; - world_instance worlds[4]; u32 active_world; @@ -441,6 +439,12 @@ VG_STATIC void ent_volume_call( world_instance *world, ent_call *call ) VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ) { + if( world->status == k_world_status_unloading ){ + vg_warn( "cannot modify audio while unloading world\n" ); + return; + } + + u8 world_id = (world - world_global.worlds) + 1; u32 index = mdl_entity_id_id( call->id ); ent_audio *audio = mdl_arritm( &world->ent_audio, index ); @@ -468,7 +472,6 @@ VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ) bar += p; if( chance < bar ){ - audio_lock(); if( audio->behaviour == k_channel_behaviour_unlimited ){ @@ -484,6 +487,7 @@ VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ) if( ch ){ audio_channel_init( ch, &clip->clip, audio->flags ); audio_channel_group( ch, audio->group ); + audio_channel_world( ch, world_id ); audio_channel_set_spacial( ch, sound_co, audio->transform.s[0] ); audio_channel_edit_volume( ch, audio->volume, 1 ); ch = audio_relinquish_channel( ch ); @@ -515,6 +519,7 @@ VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ) if( ch ){ audio_channel_init( ch, &clip->clip, audio->flags ); audio_channel_group( ch, audio->group ); + audio_channel_world( ch, world_id ); audio_channel_fadein( ch, audio->crossfade ); ch = audio_relinquish_channel( ch ); } @@ -526,6 +531,28 @@ VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ) } } +/* finds any active playing in world and fades them out, we can only do this + * while unloading */ +VG_STATIC void world_fadeout_audio( world_instance *world ) +{ + if( world->status != k_world_status_unloading ){ + vg_fatal_error( "World status must be set to 'unloading', to fadeout" + " audio.\n" ); + } + + u8 world_id = (world - world_global.worlds) + 1; + + audio_lock(); + for( u32 i=0; iallocated && (ch->world_id == world_id) ){ + ch = audio_channel_fadeout( ch, 1.0f ); + } + } + audio_unlock(); +} + VG_STATIC void world_update( world_instance *world, v3f pos ) { world_global.sky_time += world_global.sky_rate * vg.time_delta;