Merge pull request #589 from JoBergeron/listmap-cmd

added listmaps command
This commit is contained in:
Yamagi 2020-08-20 07:19:27 +02:00 committed by GitHub
commit 0fdc3750e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View file

@ -17,3 +17,7 @@ original clients (Vanilla Quake II) commands are still in place.
entities.
* **teleport <x y z>**: Teleports the player to the given coordinates.
* **listmaps**: Lists available maps for the player to load. Maps from
loaded pak files will be listed first followed by maps placed in
the current game's maps folder.

View file

@ -309,6 +309,40 @@ SV_Map_f(void)
SV_GameMap_f();
}
/*
* Lists available maps for user to load.
*/
SV_ListMaps_f(void)
{
char **userMapNames;
int nUserMaps = 0;
int i;
char* mapName;
Com_Printf("\n");
if ((userMapNames = FS_ListFiles2("maps/*.bsp", &nUserMaps, 0, 0)) != 0)
{
for (i = 0; i < nUserMaps - 1; i++)
{
if (strrchr(userMapNames[i], '/'))
{
mapName = strrchr(userMapNames[i], '/') + 1;
}
else
{
mapName = userMapNames[i];
}
mapName = strtok(mapName, ".");
Com_Printf("%s\n", mapName);
}
FS_FreeList(userMapNames, nUserMaps);
}
}
/*
* Kick a user off of the server
*/
@ -654,6 +688,7 @@ SV_InitOperatorCommands(void)
Cmd_AddCommand("dumpuser", SV_DumpUser_f);
Cmd_AddCommand("map", SV_Map_f);
Cmd_AddCommand("listmaps", SV_ListMaps_f);
Cmd_AddCommand("demomap", SV_DemoMap_f);
Cmd_AddCommand("gamemap", SV_GameMap_f);
Cmd_AddCommand("setmaster", SV_SetMaster_f);