X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player.c;h=07e5f306ac7f3e6163cf694f9e22bd6190cd8026;hb=5f5d02725031cad23f1cab3290b8a9d661c89728;hp=7a31eda047382aba659f289a36f156494b77d5c4;hpb=3749ad2919d75b87c73deb2e8fe7e505cbdcf739;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player.c b/player.c index 7a31eda..07e5f30 100644 --- a/player.c +++ b/player.c @@ -11,10 +11,12 @@ #include "network.h" #include "network_common.h" #include "world_routes.h" +#include "ent_miniworld.h" +#include "gui.h" static int localplayer_cmd_respawn( int argc, const char *argv[] ){ ent_spawn *rp = NULL, *r; - world_instance *world = localplayer.viewable_world; + world_instance *world = world_current_instance(); if( argc == 1 ){ rp = world_find_spawn_by_name( world, argv[0] ); @@ -66,10 +68,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, @@ -92,7 +90,8 @@ static void player__bind(void){ */ static void player__pre_update(void){ - if( button_down( k_srbind_camera ) && !localplayer.immobile ){ + if( button_down( k_srbind_camera ) && !localplayer.immobile && + (localplayer.subsystem != k_player_subsystem_dead) ){ if( localplayer.cam_control.camera_mode == k_cam_firstperson ) localplayer.cam_control.camera_mode = k_cam_thirdperson; else @@ -124,30 +123,37 @@ static void player__pass_gate( u32 id ){ 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 ); struct player_cam_controller *cc = &localplayer.cam_control; m4x3_mulv( gate->transport, cc->tpv_lpf, cc->tpv_lpf ); m3x3_mulv( gate->transport, cc->cam_velocity_smooth, cc->cam_velocity_smooth ); - m3x3_copy( localplayer.basis, localplayer.basis_gate ); - - v4f q; - m3x3_q( gate->transport, q ); - q_mul( q, localplayer.qbasis, localplayer.qbasis ); - q_normalize( localplayer.qbasis ); - q_m3x3( localplayer.qbasis, localplayer.basis ); - m3x3_transpose( localplayer.basis, localplayer.invbasis ); m4x3_mulv( gate->transport, localplayer.cam.pos, localplayer.cam.pos ); - if( gate->flags & k_ent_gate_nonlocal ) - world_set_active_instance( gate->target ); + if( gate->flags & k_ent_gate_nonlocal ){ + /* FIXME: Code dupe with world_load.c */ + ent_spawn *rp = world_find_spawn_by_name( world, "start" ); + if( !rp ) rp = world_find_closest_spawn( world, (v3f){0.0f,0.0f,0.0f} ); + /* TODO: fallback to searching for a safe location using raycasts */ + assert(rp); + v3_copy( rp->transform.co, world->player_co ); + + world_static.active_instance = gate->target; + player__clean_refs(); + } + else + world_routes_activate_entry_gate( world, gate ); + + v3f v0; + v3_angles_vector( localplayer.angles, v0 ); + m3x3_mulv( gate->transport, v0, v0 ); + v3_angles( v0, localplayer.angles ); audio_lock(); audio_oneshot( &audio_gate_pass, 1.0f, 0.0f ); @@ -193,33 +199,28 @@ 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", [k_skaterift_replay] = "replay", [k_skaterift_ent_focus] = "ent_focus", [k_skaterift_default] = "default", - [k_skaterift_respawning]= "respawning", + [k_skaterift_respawning]= "map" } [skaterift.activity] ); player__debugtext( 1, "time_rate: %.4f", skaterift.time_rate ); player__debugtext( 2, "player" ); player__debugtext( 1, "angles: " PRINTF_v3f( localplayer.cam.angles ) ); - player__debugtext( 1, "basis: " PRINTF_v4f( localplayer.qbasis ) ); if( player_subsystems[ localplayer.subsystem ]->im_gui ) player_subsystems[ localplayer.subsystem ]->im_gui(); @@ -227,36 +228,23 @@ 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__clean_refs(void){ replay_clear( &skaterift.replay ); - player__setpos( rp->transform.co ); - v3_zero( localplayer.rb.w ); - q_identity( localplayer.rb.q ); - rb_update_transform( &localplayer.rb ); + gui_helper_clear(); - q_identity( localplayer.qbasis ); - m3x3_identity( localplayer.basis ); - m3x3_identity( localplayer.invbasis ); - - localplayer.subsystem = k_player_subsystem_walk; - localplayer.immobile = 0; - localplayer.gate_waiting = NULL; - world_static.last_use = 0.0; - world_static.focused_entity = 0; 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; i 1.1f) ) + q_identity( localplayer.rb.q ); + + rb_update_transform( &localplayer.rb ); + + localplayer.subsystem = k_player_subsystem_walk; + player__walk_reset(); + + localplayer.immobile = 0; + localplayer.gate_waiting = NULL; + + v3_copy( localplayer.rb.co, localplayer.cam_control.tpv_lpf ); + player__clean_refs(); +} + +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; } @@ -329,10 +343,13 @@ static void player__clear_sfx_buffer(void){ /* implementation */ #include "player_common.c" + #include "player_walk.c" #include "player_skate.c" #include "player_dead.c" #include "player_drive.c" +#include "player_basic_info.c" + #include "player_render.c" #include "player_ragdoll.c" #include "player_replay.c"