summaryrefslogtreecommitdiff
path: root/source/common.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2008-05-10 16:15:57 +0000
committerAndrey Nazarov <skuller@skuller.net>2008-05-10 16:15:57 +0000
commit98c3c29c4f106c98bac64c882c8255f977a3980a (patch)
tree24158ccc8af8721e1fd92b1069e0458ebfaa655e /source/common.c
parent1f71b2b7cb486c1f3fd5b69c814a234460471414 (diff)
Added `field', `strings', `blank' menu control types.
Diffstat (limited to 'source/common.c')
-rw-r--r--source/common.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/common.c b/source/common.c
index 3628449..d91dfda 100644
--- a/source/common.c
+++ b/source/common.c
@@ -1013,6 +1013,31 @@ size_t Com_Random_m( char *buffer, size_t size ) {
return Com_sprintf( buffer, size, "%d", ( rand() ^ ( rand() >> 8 ) ) % 10 );
}
+static size_t Com_MapList_m( char *buffer, size_t size ) {
+ int i, numFiles;
+ void **list;
+ char *s, *p;
+ size_t len, total = 0;
+
+ list = FS_ListFiles( "maps", ".bsp", 0, &numFiles );
+ for( i = 0; i < numFiles; i++ ) {
+ s = list[i];
+ p = COM_FileExtension( list[i] );
+ *p = 0;
+ len = strlen( s );
+ if( total + len + 1 < size ) {
+ memcpy( buffer + total, s, len );
+ buffer[total + len] = ' ';
+ total += len + 1;
+ }
+ Z_Free( s );
+ }
+ buffer[total] = 0;
+
+ Z_Free( list );
+ return total;
+}
+
static void Com_LastError_f( void ) {
if( com_errorMsg[0] ) {
Com_Printf( "%s\n", com_errorMsg );
@@ -1291,6 +1316,7 @@ void Qcommon_Init( int argc, char **argv ) {
Cmd_AddMacro( "com_time", Com_Time_m );
Cmd_AddMacro( "com_uptime", Com_Uptime_m );
Cmd_AddMacro( "random", Com_Random_m );
+ Cmd_AddMacro( "com_maplist", Com_MapList_m );
// add any system-wide configuration files
Sys_AddDefaultConfig();