q3map2/help: list supported games
authorThomas Debesse <dev@illwieckz.net>
Mon, 3 May 2021 04:23:06 +0000 (06:23 +0200)
committerThomas Debesse <dev@illwieckz.net>
Mon, 3 May 2021 06:16:22 +0000 (08:16 +0200)
tools/quake3/q3map2/help.c

index 96409f42f2721162b7789a5c2a50ba5557bb3156..5f5664d79e57f45196fbeb2ca751aa8c998970c4 100644 (file)
@@ -423,6 +423,38 @@ void HelpCommon()
        HelpOptions("Common Options", 0, 80, common, sizeof(common)/sizeof(struct HelpOption));
 }
 
+void HelpGames()
+{
+       printf("Games:\n");
+       qboolean begin = qtrue;
+
+       // TODO: sort alphabetically
+       for ( unsigned i = 0, length = 0; games[ i ].arg != NULL; i++ )
+       {
+               // 3 for two whitespaces at the beginning and one (optional) comma a the end
+               if ( length + 3 + strlen( games[ i ].arg ) > 80 )
+               {
+                       printf(",\n");
+                       length = 0;
+                       begin = qtrue;
+               }
+
+               if ( begin )
+               {
+                       printf("  %s", games[ i ].arg );
+                       begin = qfalse;
+               }
+               else
+               {
+                       printf(", %s", games[ i ].arg );
+               }
+
+               length += 2 + strlen( games[ i ].arg );
+       }
+
+       printf("\n\n");
+}
+
 void HelpMain(const char* arg)
 {
        printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n");
@@ -430,6 +462,8 @@ void HelpMain(const char* arg)
 
        HelpCommon();
 
+       HelpGames();
+
        struct HelpOption stages[] = {
                {"-bsp", "BSP Stage"},
                {"-vis", "VIS Stage"},