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; i<world.spawn_count; i++ )
+ {
+ r = &world.spawns[i];
+ if( !strcmp( r->name, 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; i<world.spawn_count; i++ )
+ {
+ r = &world.spawns[i];
+ float d = v3_dist2( r->co, 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;
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)
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