]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/help.c
q3map2/help: only read terminal columns using ioctl on Posix systems
[xonotic/netradiant.git] / tools / quake3 / q3map2 / help.c
index 9afb60d349bb9a15c735ac654f7affd7ed60a749..60631e3d72f175a38c581b28a50df232ea8289ab 100644 (file)
 /* dependencies */
 #include "q3map2.h"
 
+#if GDEF_OS_POSIX
+#include <sys/ioctl.h>
+#endif // GDEF_OS_POSIX
 
-
-unsigned terminalColumns = 80;
+static unsigned terminalColumns = 80;
 
 struct HelpOption
 {
@@ -41,6 +43,7 @@ struct HelpOption
        const char* description;
 };
 
+// FIXME: low column width cause an endless loop
 void HelpOptions(const char* group_name, int indentation, int width, struct HelpOption* options, int count)
 {
        indentation *= 2;
@@ -223,7 +226,7 @@ void HelpLight()
                {"-fastlightmapsearch", "Deprecated alias for `-fastallocate`"},
                {"-fast", "Ignore tiny light contributions"},
                {"-fill", "Fill lightmap colors from surrounding pixels to improve JPEG compression"},
-               {"-filter", "Lightmap filtering"},
+               {"-filter", "Lightmap filtering, doesn't play nice with some other effects, don't use it, use `-samples` instead"},
                {"-floodlight", "Enable floodlight (zero-effort somewhat decent lighting)"},
                {"-gamma <F>", "Lightmap gamma"},
                {"-gridambientdirectionality <F>", "Ambient directional lighting received (default: 0.0)"},
@@ -279,7 +282,7 @@ void HelpLight()
                {"-sRGBtex", "Treat textures as sRGB colorspace"},
                {"-style, -styles", "Enable support for light styles"},
                {"-sunonly", "Only compute sun light"},
-               {"-super <N, `-supersample` N>", "Ordered grid supersampling quality"},
+               {"-super <N, `-supersample` N>", "Ordered grid supersampling quality, much slower than `-samples`"},
                {"-thresh <F>", "Triangle subdivision threshold"},
                {"-trianglecheck", "Broken check that should ensure luxels apply to the right triangle"},
                {"-trisoup", "Convert brush faces to triangle soup"},
@@ -416,8 +419,8 @@ void HelpCommon()
                {"-fs_nohomepath", "Do not load home path in VFS"},
                {"-fs_pakpath <path>", "Specify a package directory (can be used more than once to look in multiple paths)"},
                {"-game <gamename>", "Load settings for the given game (default: quake3)"},
-               {"-subdivisions <F>", "multiplier for patch subdivisions quality"},
-               {"-threads <N>", "number of threads to use"},
+               {"-subdivisions <F>", "Multiplier for patch subdivisions quality"},
+               {"-threads <N>", "Number of threads to use"},
                {"-v", "Verbose mode"},
                {"-werror", "Make all warnings into errors"}
        };
@@ -457,19 +460,19 @@ void HelpGames()
        printf("\n\n");
 }
 
-#include <termcap.h>
-
 void HelpMain(const char* arg)
 {
        printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n");
        printf("       q3map2 -help [stage]\n");
        printf("       q3map2 -help all\n\n");
 
-       static char termbuf[2048];
-       char *termtype = getenv("TERM");
-       if (tgetent(termbuf, termtype) >= 0) {
-               terminalColumns = tgetnum("co");
+#if GDEF_OS_POSIX
+       struct winsize ws;
+       ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
+       if (ws.ws_col > 60) {
+               terminalColumns = ws.ws_col;
        }
+#endif // GDEF_OS_POSIX
 
        HelpCommon();