* -------------------------------------------------------------*/
for( u32 i=0; i<frame->sound_effects; i ++ ){
- /* CHEATING for now */
struct net_sfx sfx;
net_sfx_exchange( &ctx, &sfx );
- net_sfx_play( &sfx );
+
+ f64 t = (frame->timestamp - NETWORK_FRAMERATE) +
+ (sfx.subframe*NETWORK_FRAMERATE);
+
+ f32 remaining = t - ib->t;
+
+ if( remaining <= 0.0f )
+ net_sfx_play( &sfx );
+ else{
+ struct net_sfx *dst = NULL;
+
+ for( u32 j=0; j<NETWORK_SFX_QUEUE_LENGTH; j ++ ){
+ struct net_sfx *sj = &netplayers.sfx_queue[j];
+ if( sj->system == k_player_subsystem_invalid ){
+ dst = sj;
+ break;
+ }
+
+ if( sj->priority < sfx.priority )
+ dst = sj;
+ }
+
+ *dst = sfx;
+ dst->subframe = remaining;
+ }
}
/* animation
SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
}
-/* TODO: Which world is the player in
- * nametags with occlusion
- */
+static void remote_players_init(void){
+ for( u32 i=0; i<NETWORK_SFX_QUEUE_LENGTH; i ++ ){
+ netplayers.sfx_queue[i].system = k_player_subsystem_invalid;
+ }
+}
+
+static void remote_sfx_pre_update(void){
+ for( u32 i=0; i<NETWORK_SFX_QUEUE_LENGTH; i ++ ){
+ struct net_sfx *si = &netplayers.sfx_queue[i];
+
+ if( si->system != k_player_subsystem_invalid ){
+ si->subframe -= vg.time_frame_delta;
+ if( si->subframe <= 0.0f ){
+ net_sfx_play( si );
+ si->system = k_player_subsystem_invalid;
+ }
+ }
+ }
+}
steam_init();
vg_loader_step( NULL, steam_end );
+ vg_loader_step( remote_players_init, NULL );
vg_loader_step( network_init, network_end );
}
player__pre_update();
world_entity_focus_preupdate();
skaterift_replay_pre_update();
+ remote_sfx_pre_update();
world_update( world_current_instance(), localplayer.rb.co );
audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co );