Browse Source

engine: server: backport maps command implementation from old engine

pull/2/head
tyabus 4 years ago committed by Alibek Omarov
parent
commit
0260a6c234
  1. 39
      engine/server/sv_cmds.c

39
engine/server/sv_cmds.c

@ -231,6 +231,44 @@ void SV_Map_f( void ) @@ -231,6 +231,44 @@ void SV_Map_f( void )
COM_LoadLevel( mapname, false );
}
/*
==================
SV_Maps_f
Lists maps according to given substring.
TODO: Make it more convenient. (Timestamp check, temporary file, ...)
==================
*/
void SV_Maps_f( void )
{
const char *separator = "-------------------";
const char *argStr = Cmd_Argv( 1 ); // Substr
int listIndex;
search_t *mapList;
if( Cmd_Argc() != 2 )
{
Msg( "Usage: maps <substring>\nmaps * for full listing\n" );
return;
}
mapList = FS_Search( va( "maps/*%s*.bsp", argStr ), true, true );
if( !mapList )
{
Msg( "No related map found in \"%s/maps\"\n", GI->gamefolder );
return;
}
for( listIndex = 0; listIndex != mapList->numfilenames; ++listIndex )
{
Msg( "%s\n", mapList->filenames[listIndex] + 5 ); // Do not show "maps/"
}
Msg( "%s\nDirectory: \"%s/maps\" - Maps listed: %d\n", separator, GI->basedir, mapList->numfilenames );
}
/*
==================
SV_MapBackground_f
@ -966,6 +1004,7 @@ is available always @@ -966,6 +1004,7 @@ is available always
void SV_InitHostCommands( void )
{
Cmd_AddCommand( "map", SV_Map_f, "start new level" );
Cmd_AddCommand( "maps", SV_Maps_f, "list maps" );
if( host.type == HOST_NORMAL )
{

Loading…
Cancel
Save