]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake3/q3map2/help.c
0dc528ad4221fbfcd2e2482516c17aa8601b94fd
[xonotic/netradiant.git] / tools / quake3 / q3map2 / help.c
1 /* -------------------------------------------------------------------------------
2
3    Copyright (C) 1999-2007 id Software, Inc. and contributors.
4    For a list of contributors, see the accompanying CONTRIBUTORS file.
5
6    This file is part of GtkRadiant.
7
8    GtkRadiant is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12
13    GtkRadiant is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with GtkRadiant; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
22    -------------------------------------------------------------------------------
23
24    This code has been altered significantly from its original form, to support
25    several games based on the Quake III Arena engine, in the form of "Q3Map2."
26
27    ------------------------------------------------------------------------------- */
28
29
30
31 /* dependencies */
32 #include "q3map2.h"
33
34
35
36 struct HelpOption
37 {
38         const char* name;
39         const char* description;
40 };
41
42 void HelpOptions(const char* group_name, int indentation, int width, struct HelpOption* options, int count)
43 {
44         indentation *= 2;
45         char* indent = malloc(indentation+1);
46         memset(indent, ' ', indentation);
47         indent[indentation] = 0;
48         printf("%s%s:\n", indent, group_name);
49         indentation += 2;
50         indent = realloc(indent, indentation+1);
51         memset(indent, ' ', indentation);
52         indent[indentation] = 0;
53
54         int i;
55         for ( i = 0; i < count; i++ )
56         {
57                 int printed = printf("%s%-24s  ", indent, options[i].name);
58                 int descsz = strlen(options[i].description);
59                 int j = 0;
60                 while ( j < descsz && descsz-j > width - printed )
61                 {
62                         if ( j != 0 )
63                                 printf("%s%26c",indent,' ');
64                         int fragment = width - printed;
65                         while ( fragment > 0 && options[i].description[j+fragment-1] != ' ')
66                                         fragment--;
67                         j += fwrite(options[i].description+j, sizeof(char), fragment, stdout);
68                         putchar('\n');
69                         printed = indentation+26;
70                 }
71                 if ( j == 0 )
72                 {
73                         printf("%s\n",options[i].description+j);
74                 }
75                 else if ( j < descsz )
76                 {
77                         printf("%s%26c%s\n",indent,' ',options[i].description+j);
78                 }
79         }
80
81         putchar('\n');
82
83         free(indent);
84 }
85
86 void HelpBsp()
87 {
88         struct HelpOption bsp[] = {
89                 {"-bsp <filename.map>", "Switch that enters this stage"},
90                 {"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"},
91                 {"-celshader <shadername>", "Sets a global cel shader name"},
92                 {"-custinfoparms", "Read scripts/custinfoparms.txt"},
93                 {"-debuginset", "Push all triangle vertexes towards the triangle center"},
94                 {"-debugportals", "Make BSP portals visible in the map"},
95                 {"-debugsurfaces", "Color the vertexes according to the index of the surface"},
96                 {"-deep", "Use detail brushes in the BSP tree, but at lowest priority (should give more fps)"},
97                 {"-de <F>", "Distance epsilon for plane snapping etc."},
98                 {"-fakemap", "Write fakemap.map containing all world brushes"},
99                 {"-flares", "Turn on support for flares (TEST?)"},
100                 {"-flat", "Enable flat shading (good for combining with -celshader)"},
101                 {"-fulldetail", "Treat detail brushes as structural ones"},
102                 {"-leaktest", "Abort if a leak was found"},
103                 {"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"},
104                 {"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
105                 {"-mi <N>", "Sets the maximum number of indexes per surface"},
106                 {"-mv <N>", "Sets the maximum number of vertices of a lightmapped surface"},
107                 {"-ne <F>", "Normal epsilon for plane snapping etc."},
108                 {"-nocurves", "Turn off support for patches"},
109                 {"-nodetail", "Leave out detail brushes"},
110                 {"-noflares", "Turn off support for flares"},
111                 {"-nofog", "Turn off support for fog volumes"},
112                 {"-nohint", "Turn off support for hint brushes"},
113                 {"-nosubdivide", "Turn off support for `q3map_tessSize` (breaks water vertex deforms)"},
114                 {"-notjunc", "Do not fix T-junctions (causes cracks between triangles, do not use)"},
115                 {"-nowater", "Turn off support for water, slime or lava (Stef, this is for you)"},
116                 {"-np <A>", "Force all surfaces to be nonplanar with a given shade angle"},
117                 {"-onlyents", "Only update entities in the BSP"},
118                 {"-patchmeta", "Turn patches into triangle meshes for display"},
119                 {"-rename", "Append â€œbspâ€\9d suffix to miscmodel shaders (needed for SoF2)"},
120                 {"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
121                 {"-skyfix", "Turn sky box into six surfaces to work around ATI problems"},
122                 {"-snap <N>", "Snap brush bevel planes to the given number of units"},
123                 {"-tempname <filename.map>", "Read the MAP file from the given file name"},
124                 {"-texrange <N>", "Limit per-surface texture range to the given number of units, and subdivide surfaces like with `q3map_tessSize` if this is not met"},
125                 {"-tmpout", "Write the BSP file to /tmp"},
126                 {"-verboseentities", "Enable `-v` only for map entities, not for the world"},
127         };
128         HelpOptions("BSP Stage", 0, 80, bsp, sizeof(bsp)/sizeof(struct HelpOption));
129 }
130
131 void HelpVis()
132 {
133         struct HelpOption vis[] = {
134                 {"-vis <filename.map>", "Switch that enters this stage"},
135                 {"-fast", "Very fast and crude vis calculation"},
136                 {"-mergeportals", "The less crude half of `-merge`, makes vis sometimes much faster but doesn't hurt fps usually"},
137                 {"-merge", "Faster but still okay vis calculation"},
138                 {"-nopassage", "Just use PortalFlow vis (usually less fps)"},
139                 {"-nosort", "Do not sort the portals before calculating vis (usually slower)"},
140                 {"-passageOnly", "Just use PassageFlow vis (usually less fps)"},
141                 {"-saveprt", "Keep the PRT file after running vis (so you can run vis again)"},
142                 {"-tmpin", "Use /tmp folder for input"},
143                 {"-tmpout", "Use /tmp folder for output"},
144         };
145         HelpOptions("VIS Stage", 0, 80, vis, sizeof(vis)/sizeof(struct HelpOption));
146 }
147
148 void HelpLight()
149 {
150         struct HelpOption light[] = {
151                 {"-light <filename.map>", "Switch that enters this stage"},
152                 {"-vlight <filename.map>", "Deprecated alias for `-light -fast` ... filename.map"},
153                 {"-approx <N>", "Vertex light approximation tolerance (never use in conjunction with deluxemapping)"},
154                 {"-areascale <F, `-area` F>", "Scaling factor for area lights (surfacelight)"},
155                 {"-border", "Add a red border to lightmaps for debugging"},
156                 {"-bouncegrid", "Also compute radiosity on the light grid"},
157                 {"-bounceonly", "Only compute radiosity"},
158                 {"-bouncescale <F>", "Scaling factor for radiosity"},
159                 {"-bounce <N>", "Number of bounces for radiosity"},
160                 {"-cheapgrid", "Use `-cheap` style lighting for radiosity"},
161                 {"-cheap", "Abort vertex light calculations when white is reached"},
162                 {"-compensate <F>", "Lightmap compensate (darkening factor applied after everything else)"},
163                 {"-cpma", "CPMA vertex lighting mode"},
164                 {"-custinfoparms", "Read scripts/custinfoparms.txt"},
165                 {"-dark", "Darken lightmap seams"},
166                 {"-debugaxis", "Color the lightmaps according to the lightmap axis"},
167                 {"-debugcluster", "Color the lightmaps according to the index of the cluster"},
168                 {"-debugdeluxe", "Show deluxemaps on the lightmap"},
169                 {"-debugnormals", "Color the lightmaps according to the direction of the surface normal"},
170                 {"-debugorigin", "Color the lightmaps according to the origin of the luxels"},
171                 {"-debugsurfaces, -debugsurface", "Color the lightmaps according to the index of the surface"},
172                 {"-debugunused", "This option does nothing"},
173                 {"-debug", "Mark the lightmaps according to the cluster: unmapped clusters get yellow, occluded ones get pink, flooded ones get blue overlay color, otherwise red"},
174                 {"-deluxemode 0", "Use modelspace deluxemaps (DarkPlaces)"},
175                 {"-deluxemode 1", "Use tangentspace deluxemaps"},
176                 {"-deluxe, -deluxemap", "Enable deluxemapping (light direction maps)"},
177                 {"-dirtdebug, -debugdirt", "Store the dirtmaps as lightmaps for debugging"},
178                 {"-dirtdepth", "Dirtmapping depth"},
179                 {"-dirtgain", "Dirtmapping exponent"},
180                 {"-dirtmode 0", "Ordered direction dirtmapping"},
181                 {"-dirtmode 1", "Randomized direction dirtmapping"},
182                 {"-dirtscale", "Dirtmapping scaling factor"},
183                 {"-dirty", "Enable dirtmapping"},
184                 {"-dump", "Dump radiosity from `-bounce` into numbered MAP file prefabs"},
185                 {"-export", "Export lightmaps when compile finished (like `-export` mode)"},
186                 {"-exposure <F>", "Lightmap exposure to better support overbright spots"},
187                 {"-external", "Force external lightmaps even if at size of internal lightmaps"},
188                 {"-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster"},
189                 {"-extrawide", "Deprecated alias for `-super 2 -filter`"},
190                 {"-extra", "Deprecated alias for `-super 2`"},
191                 {"-fastbounce", "Use `-fast` style lighting for radiosity"},
192                 {"-faster", "Use a faster falloff curve for lighting; also implies `-fast`"},
193                 {"-fastgrid", "Use `-fast` style lighting for the light grid"},
194                 {"-fast", "Ignore tiny light contributions"},
195                 {"-filter", "Lightmap filtering"},
196                 {"-floodlight", "Enable floodlight (zero-effort somewhat decent lighting)"},
197                 {"-gamma <F>", "Lightmap gamma"},
198                 {"-gridambientscale <F>", "Scaling factor for the light grid ambient components only"},
199                 {"-gridscale <F>", "Scaling factor for the light grid only"},
200                 {"-keeplights", "Keep light entities in the BSP file after compile"},
201                 {"-lightmapdir <directory>", "Directory to store external lightmaps (default: same as map name without extension)"},
202                 {"-lightmapsize <N>", "Size of lightmaps to generate (must be a power of two)"},
203                 {"-lomem", "Low memory but slower lighting mode"},
204                 {"-lowquality", "Low quality floodlight (appears to currently break floodlight)"},
205                 {"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
206                 {"-nocollapse", "Do not collapse identical lightmaps"},
207                 {"-nodeluxe, -nodeluxemap", "Disable deluxemapping"},
208                 {"-nogrid", "Disable grid light calculation (makes all entities fullbright)"},
209                 {"-nolightmapsearch", "Do not optimize lightmap packing for GPU memory usage (as doing so costs fps)"},
210                 {"-normalmap", "Color the lightmaps according to the direction of the surface normal (TODO is this identical to `-debugnormals`?)"},
211                 {"-nostyle, -nostyles", "Disable support for light styles"},
212                 {"-nosurf", "Disable tracing against surfaces (only uses BSP nodes then)"},
213                 {"-notrace", "Disable shadow occlusion"},
214                 {"-novertex", "Disable vertex lighting"},
215                 {"-patchshadows", "Cast shadows from patches"},
216                 {"-pointscale <F, `-point` F>", "Scaling factor for point lights (light entities)"},
217                 {"-q3", "Use nonlinear falloff curve by default (like Q3A)"},
218                 {"-samplescale <F>", "Scales all lightmap resolutions"},
219                 {"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
220                 {"-samples <N>", "Adaptive supersampling quality"},
221                 {"-scale <F>", "Scaling factor for all light types"},
222                 {"-shadeangle <A>", "Angle for phong shading"},
223                 {"-shade", "Enable phong shading at default shade angle"},
224                 {"-skyscale <F, `-sky` F>", "Scaling factor for sky and sun light"},
225                 {"-smooth", "Deprecated alias for `-samples 2`"},
226                 {"-style, -styles", "Enable support for light styles"},
227                 {"-sunonly", "Only compute sun light"},
228                 {"-super <N, `-supersample` N>", "Ordered grid supersampling quality"},
229                 {"-thresh <F>", "Triangle subdivision threshold"},
230                 {"-trianglecheck", "Broken check that should ensure luxels apply to the right triangle"},
231                 {"-trisoup", "Convert brush faces to triangle soup"},
232                 {"-wolf", "Use linear falloff curve by default (like W:ET)"},
233         };
234
235         HelpOptions("Light Stage", 0, 80, light, sizeof(light)/sizeof(struct HelpOption));
236 }
237
238 void HelpAnalyze()
239 {
240         struct HelpOption analyze[] = {
241                 {"-analyze <filename.bsp>", "Switch that enters this mode"},
242                 {"-lumpswap", "Swap byte order in the lumps"},
243         };
244
245         HelpOptions("Analyzing BSP-like file structure", 0, 80, analyze, sizeof(analyze)/sizeof(struct HelpOption));
246 }
247
248 void HelpScale()
249 {
250         struct HelpOption scale[] = {
251                 {"-scale <S filename.bsp>", "Scale uniformly"},
252                 {"-scale <SX SY SZ filename.bsp>", "Scale non-uniformly"},
253                 {"-scale -tex <S filename.bsp>", "Scale uniformly without texture lock"},
254                 {"-scale -tex <SX SY SZ filename.bsp>", "Scale non-uniformly without texture lock"},
255         };
256         HelpOptions("Scaling", 0, 80, scale, sizeof(scale)/sizeof(struct HelpOption));
257 }
258
259 void HelpConvert()
260 {
261         struct HelpOption convert[] = {
262                 {"-convert <filename.bsp>", "Switch that enters this mode"},
263                 {"-de <number>", "Distance epsilon for the conversion"},
264                 {"-format <converter>", "Select the converter (available: map, ase, or game names)"},
265                 {"-ne <F>", "Normal epsilon for the conversion"},
266                 {"-shadersasbitmap", "(only for ase) use the shader names as \\*BITMAP key so they work as prefabs"},
267         };
268
269         HelpOptions("Converting & Decompiling", 0, 80, convert, sizeof(convert)/sizeof(struct HelpOption));
270 }
271
272 void HelpExport()
273 {
274         struct HelpOption exportl[] = {
275                 {"-export <filename.bsp>", "Copies lightmaps from the BSP to `filename/lightmap_0000.tga` ff"}
276         };
277
278         HelpOptions("Exporting lightmaps", 0, 80, exportl, sizeof(exportl)/sizeof(struct HelpOption));
279 }
280
281 void HelpFixaas()
282 {
283         struct HelpOption fixaas[] = {
284                 {"-fixaas <filename.bsp>", "Switch that enters this mode"},
285         };
286
287         HelpOptions("Fixing AAS checksum", 0, 80, fixaas, sizeof(fixaas)/sizeof(struct HelpOption));
288 }
289
290 void HelpInfo()
291 {
292         struct HelpOption info[] = {
293                 {"-info <filename.bsp>", "Switch that enters this mode"},
294         };
295
296         HelpOptions("Get info about BSP file", 0, 80, info, sizeof(info)/sizeof(struct HelpOption));
297 }
298
299 void HelpImport()
300 {
301         struct HelpOption import[] = {
302                 {"-import <filename.bsp>", "Copies lightmaps from `filename/lightmap_0000.tga` ff into the BSP"},
303         };
304
305         HelpOptions("Importing lightmaps", 0, 80, import, sizeof(import)/sizeof(struct HelpOption));
306 }
307
308 void HelpMinimap()
309 {
310         struct HelpOption minimap[] = {
311                 {"-minimap <filename.bsp>", "Creates a minimap of the BSP, by default writes to `../gfx/filename_mini.tga`"},
312                 {"-black", "Write the minimap as a black-on-transparency RGBA32 image"},
313                 {"-boost <F>", "Sets the contrast boost value (higher values make a brighter image); contrast boost is somewhat similar to gamma, but continuous even at zero"},
314                 {"-border <F>", "Sets the amount of border pixels relative to the total image size"},
315                 {"-gray", "Write the minimap as a white-on-black GRAY8 image"},
316                 {"-keepaspect", "Ensure the aspect ratio is kept (the minimap is then letterboxed to keep aspect)"},
317                 {"-minmax <xmin ymin zmin xmax ymax zmax>", "Forces specific map dimensions (note: the minimap actually uses these dimensions, scaled to the target size while keeping aspect with centering, and 1/64 of border appended to all sides)"},
318                 {"-nokeepaspect", "Do not ensure the aspect ratio is kept (makes it easier to use the image in your code, but looks bad together with sharpening)"},
319                 {"-o <filename.tga>", "Sets the output file name"},
320                 {"-random <N>", "Sets the randomized supersampling count (cannot be combined with `-samples`)"},
321                 {"-samples <N>", "Sets the ordered supersampling count (cannot be combined with `-random`)"},
322                 {"-sharpen <F>", "Sets the sharpening coefficient"},
323                 {"-size <N>", "Sets the width and height of the output image"},
324                 {"-white", "Write the minimap as a white-on-transparency RGBA32 image"},
325         };
326
327         HelpOptions("MiniMap", 0, 80, minimap, sizeof(minimap)/sizeof(struct HelpOption));
328 }
329
330 void HelpCommon()
331 {
332         struct HelpOption common[] = {
333                 {"-connect <address>", "Talk to a NetRadiant instance using a specific XML based protocol"},
334                 {"-force", "Allow reading some broken/unsupported BSP files e.g. when decompiling, may also crash"},
335                 {"-fs_basepath <path>", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)"},
336                 {"-fs_game <gamename>", "Sets a different game directory name (default for Q3A: baseq3)"},
337                 {"-fs_homebase <dir>", "Specifies where the user home directory name is on Linux (default for Q3A: .q3a)"},
338                 {"-game <gamename>", "Load settings for the given game (default: quake3)"},
339                 {"-subdivisions <F>", "multiplier for patch subdivisions quality"},
340                 {"-threads <N>", "number of threads to use"},
341                 {"-v", "Verbose mode"}
342         };
343
344         HelpOptions("Common Options", 0, 80, common, sizeof(common)/sizeof(struct HelpOption));
345
346 }
347
348 void HelpMain(const char* arg)
349 {
350         printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n");
351         printf("       q3map2 -help [stage]\n\n");
352
353         HelpCommon();
354
355         struct HelpOption stages[] = {
356                 {"-bsp", "BSP Stage"},
357                 {"-vis", "VIS Stage"},
358                 {"-light", "Light Stage"},
359                 {"-analyze", "Analyzing BSP-like file structure"},
360                 {"-scale", "Scaling"},
361                 {"-convert", "Converting & Decompiling"},
362                 {"-export", "Exporting lightmaps"},
363                 {"-fixaas", "Fixing AAS checksum"},
364                 {"-info", "Get info about BSP file"},
365                 {"-import", "Importing lightmaps"},
366                 {"-minimap", "MiniMap"},
367         };
368         void(*help_funcs[])() = {
369                 HelpBsp,
370                 HelpVis,
371                 HelpLight,
372                 HelpAnalyze,
373                 HelpScale,
374                 HelpConvert,
375                 HelpExport,
376                 HelpFixaas,
377                 HelpInfo,
378                 HelpImport,
379                 HelpMinimap,
380         };
381
382         if ( arg && strlen(arg) > 0 )
383         {
384                 if ( arg[0] == '-' )
385                         arg++;
386
387                 unsigned i;
388                 for ( i = 0; i < sizeof(stages)/sizeof(struct HelpOption); i++ )
389                         if ( strcmp(arg, stages[i].name+1) == 0 )
390                         {
391                                 help_funcs[i]();
392                                 return;
393                         }
394         }
395
396         HelpOptions("Stages", 0, 80, stages, sizeof(stages)/sizeof(struct HelpOption));
397 }