X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player.h;h=bd7304dc614550c8978345c08cce9fb893a363ae;hb=9c85e110fa8b965195438d96625ff9753af362a6;hp=3501c72b5d0e39b6c2f9acb434154da38b0816a9;hpb=168eb5c363f510d60703498e01ffcdb52bf9fd07;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player.h b/player.h index 3501c72..bd7304d 100644 --- a/player.h +++ b/player.h @@ -66,15 +66,49 @@ static void player_transform_update(void) static int reset_player( int argc, char const *argv[] ) { - v3_copy( world.tutorial, player.co ); - if( argc == 1 ) + struct respawn_point *rp = NULL, *r; + + if( argc > 1 ) { - if( !strcmp( argv[0], "tutorial" )) - v3_copy( world.tutorial, player.co ); + for( int i=0; iname, argv[0] ) ) + { + rp = r; + break; + } + } + + if( !rp ) + vg_warn( "No spawn named '%s'\n", argv[0] ); } - v3_copy( (v3f){ 0.0f, 0.0f, -0.2f }, player.v ); - q_identity( player.rot ); + if( !rp ) + { + float min_dist = INFINITY; + for( int i=0; ico, player.co ); + + if( d < min_dist ) + { + min_dist = d; + rp = r; + } + } + } + + if( !rp ) + { + vg_error( "No spawn found\n" ); + return 0; + } + + v4_copy( r->q, player.rot ); + v3_copy( r->co, player.co ); + player.vswitch = 1.0f; player.slip_last = 0.0f; player.is_dead = 0; @@ -85,7 +119,8 @@ static int reset_player( int argc, char const *argv[] ) player.mdl.shoes[1] = 1; player_transform_update(); - return 0; + m3x3_mulv( player.to_world, (v3f){ 0.0f, 0.0f, -0.2f }, player.v ); + return 1; } static void player_mouseview(void) @@ -597,7 +632,7 @@ static void player_do_motion(void) static int player_walkgrid_tri_walkable( u32 tri[3] ) { - return tri[0] < world.sm_road.vertex_count; + return tri[0] < world.sm_surface.vertex_count; } #define WALKGRID_SIZE 16