X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player.c;h=b1788c626e8a410d148849144afa4bed296592ed;hb=2c91a71533b4ce86b9e7fd708420ae05c74d8f52;hp=78449ad1e04b2a80338948ccff385cccc4df7abb;hpb=074fa69f479724f9800849430bad5caf730b01ef;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player.c b/player.c index 78449ad..b1788c6 100644 --- a/player.c +++ b/player.c @@ -9,6 +9,8 @@ #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; @@ -64,10 +66,6 @@ static void player__debugtext( int size, const char *fmt, ... ){ /* * Appearence */ -static void player__use_avatar( struct player_avatar *av ){ - localplayer.playeravatar = av; - player_setup_ragdoll_from_avatar( &localplayer.ragdoll, av ); -} static void player__use_model( u16 reg_id ){ addon_cache_unwatch( k_addon_type_player, @@ -144,9 +142,6 @@ static void player__pass_gate( u32 id ){ m4x3_mulv( gate->transport, localplayer.cam.pos, localplayer.cam.pos ); - if( gate->flags & k_ent_gate_nonlocal ) - world_set_active_instance( gate->target ); - audio_lock(); audio_oneshot( &audio_gate_pass, 1.0f, 0.0f ); audio_unlock(); @@ -191,20 +186,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", @@ -225,18 +216,22 @@ static void player__im_gui(void){ skaterift_replay_debug_info(); } - static void player__setpos( v3f pos ){ v3_copy( pos, localplayer.rb.co ); v3_zero( localplayer.rb.v ); rb_update_transform( &localplayer.rb ); } -static void player__spawn( ent_spawn *rp ){ +static void player__reset(void){ replay_clear( &skaterift.replay ); - player__setpos( rp->transform.co ); + + v3_zero( localplayer.rb.v ); v3_zero( localplayer.rb.w ); - q_identity( localplayer.rb.q ); + + f32 l = v4_length( localplayer.rb.q ); + if( (l < 0.9f) || (l > 1.1f) ) + q_identity( localplayer.rb.q ); + rb_update_transform( &localplayer.rb ); q_identity( localplayer.qbasis ); @@ -244,30 +239,95 @@ static void player__spawn( ent_spawn *rp ){ m3x3_identity( localplayer.invbasis ); localplayer.subsystem = k_player_subsystem_walk; + player__walk_reset(); + localplayer.immobile = 0; localplayer.gate_waiting = NULL; - world_static.last_use = 0.0; - world_static.focused_entity = 0; + localplayer.viewable_world = world_current_instance(); + world_static.challenge_target = NULL; world_static.challenge_timer = 0.0f; + world_static.focused_entity = 0; + world_static.active_trigger_volume_count = 0; + world_static.last_use = 0.0; world_entity_unfocus(); - 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__spawn( ent_spawn *rp ){ + player__setpos( rp->transform.co ); + player__reset(); } 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"