X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player.c;h=de96060710677edb746e08277838848ea485e8e8;hb=137d40d96fe923600d8378b8e138e3c276f27ff4;hp=1cd1bec67a2b323303cf9c798c2a45265a1a5ad4;hpb=22f62f001f21d1b91fefd9fc495c122d9ddf205a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player.c b/player.c index 1cd1bec..de96060 100644 --- a/player.c +++ b/player.c @@ -8,6 +8,9 @@ #include "world.h" #include "audio.h" #include "player_replay.h" +#include "network.h" +#include "network_common.h" +#include "world_routes.h" static int localplayer_cmd_respawn( int argc, const char *argv[] ){ ent_spawn *rp = NULL, *r; @@ -113,9 +116,17 @@ static void player__post_update(void){ /* * Applies gate transport to a player_interface */ -static void player__pass_gate( ent_gate *gate ){ - world_routes_fracture( world_current_instance(), gate, - localplayer.rb.co, localplayer.rb.v ); +static void player__pass_gate( u32 id ){ + world_instance *world = world_current_instance(); + + /* update boundary hash (network animation) */ + u16 index = mdl_entity_id_id(id) & ~NETMSG_BOUNDARY_MASK; + localplayer.boundary_hash ^= NETMSG_GATE_BOUNDARY_BIT; + localplayer.boundary_hash &= ~NETMSG_BOUNDARY_MASK; + localplayer.boundary_hash |= index; + + ent_gate *gate = mdl_arritm( &world->ent_gate, mdl_entity_id_id(id) ); + world_routes_fracture( world, gate, localplayer.rb.co, localplayer.rb.v ); localplayer.gate_waiting = gate; world_routes_activate_entry_gate( world_current_instance(), gate ); @@ -163,23 +174,6 @@ static void player_apply_transport_to_cam( m4x3f transport ){ m4x4_mul( world_gates.cam.mtx.v, transport_4, world_gates.cam.mtx.v ); } -#if 0 -__attribute__ ((deprecated)) -static void gate_rotate_angles( ent_gate *gate, v3f angles, v3f d ) -{ - v3_copy( angles, d ); - return; - - v3f fwd_dir = { cosf(angles[0]), - 0.0f, - sinf(angles[0])}; - m3x3_mulv( gate->transport, fwd_dir, fwd_dir ); - - v3_copy( angles, d ); - d[0] = atan2f( fwd_dir[2], fwd_dir[0] ); -} -#endif - static void player__im_gui(void){ if( !k_player_debug_info ) return; @@ -199,20 +193,16 @@ static void player__im_gui(void){ 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" ); + char buf[96]; + for( u32 i=0; ialias, buf ); + else + strcpy( buf, "none" ); - if( world_static.addon_hub ) - addon_alias_uid( &world_static.addon_hub->alias, buf_hub ); - else - strcpy( buf_hub, "none" ); + player__debugtext( 1, "world #%u: %s", i, buf ); + } - 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", @@ -262,18 +252,78 @@ static void player__spawn( ent_spawn *rp ){ if( player_subsystems[ localplayer.subsystem ]->reset ) player_subsystems[ localplayer.subsystem ]->reset( rp ); + + localplayer.boundary_hash ^= NETMSG_BOUNDARY_BIT; + + for( u32 i=0; istatus == k_world_status_loaded ){ + world_routes_clear( instance ); + } + } } static void player__kill(void){ } -static void player__begin_holdout(void){ +static void player__begin_holdout( v3f offset ){ memcpy( &localplayer.holdout_pose, &localplayer.pose, sizeof(localplayer.pose) ); + v3_copy( offset, localplayer.holdout_pose.root_co ); localplayer.holdout_time = 1.0f; } +static void net_sfx_exchange( bitpack_ctx *ctx, struct net_sfx *sfx ){ + bitpack_bytes( ctx, 1, &sfx->system ); + bitpack_bytes( ctx, 1, &sfx->priority ); + bitpack_bytes( ctx, 1, &sfx->id ); + bitpack_qf32( ctx, 8, 0.0f, 1.0f, &sfx->subframe ); + bitpack_qf32( ctx, 8, 0.0f, 1.0f, &sfx->volume ); + bitpack_qv3f( ctx, 16, -1024.0f, 1024.0f, sfx->location ); +} + +static void net_sfx_play( struct net_sfx *sfx ){ + if( sfx->system < k_player_subsystem_max ){ + struct player_subsystem_interface *sys = player_subsystems[sfx->system]; + if( sys->sfx_oneshot ){ + sys->sfx_oneshot( sfx->id, sfx->location, sfx->volume ); + } + } +}; + +static void player__networked_sfx( u8 system, u8 priority, u8 id, + v3f pos, f32 volume ){ + struct net_sfx null, *sfx = &null; + + if( localplayer.sfx_buffer_count < vg_list_size(localplayer.sfx_buffer) ) + sfx = &localplayer.sfx_buffer[ localplayer.sfx_buffer_count ++ ]; + else { + for( u32 i=0; ipriority < priority ){ + sfx = a; + break; + } + } + } + + sfx->id = id; + sfx->priority = priority; + sfx->volume = volume; + v3_copy( pos, sfx->location ); + sfx->system = system; + + f32 t = (vg.time_real - network_client.last_frame) / NETWORK_FRAMERATE; + sfx->subframe = vg_clampf( t, 0.0f, 1.0f ); + + net_sfx_play( sfx ); +} + +static void player__clear_sfx_buffer(void){ + localplayer.sfx_buffer_count = 0; +} + /* implementation */ #include "player_common.c" #include "player_walk.c"