already apply some safe changes:
[divverent/netradiant.git] / tools / quake3 / q3map2 / q3map2_fsr_newfiles / q3map2_fsr_svn158.patch
1 Index: bspfile_abstract.c\r
2 ===================================================================\r
3 --- bspfile_abstract.c  (revision 158)\r
4 +++ bspfile_abstract.c  (working copy)\r
5 @@ -683,8 +683,26 @@\r
6         ep->value = copystring( value );
7  }
8  
9 +/*
10 +KeyExists()
11 +returns true if entity has this key
12 +*/
13  
14 +qboolean KeyExists( const entity_t *ent, const char *key )
15 +{
16 +       epair_t *ep;
17 +       
18 +       /* walk epair list */
19 +       for( ep = ent->epairs; ep != NULL; ep = ep->next )
20 +       {
21 +               if( !EPAIR_STRCMP( ep->key, key ) )
22 +                       return qtrue;
23 +       }
24  
25 +       /* no match */
26 +       return qfalse;
27 +}
28 +
29  /*
30  ValueForKey()
31  gets the value for an entity key
32 @@ -803,7 +821,6 @@\r
33  {
34         const char      *value;
35         
36 -       
37         /* get cast shadows */
38         if( castShadows != NULL )
39         {
40 @@ -831,5 +848,19 @@\r
41                 if( value[ 0 ] != '\0' )
42                         *recvShadows = atoi( value );
43         }
44 +
45 +       /* vortex: game-specific default eneity keys */
46 +       value = ValueForKey( ent, "classname" );
47 +       if (!Q_stricmp( game->magic, "dq" ) || !Q_stricmp( game->magic, "prophecy" ) )
48 +       {
49 +               /* vortex: deluxe quake default shadow flags */
50 +               if (!Q_stricmp( value, "func_wall" ) )
51 +               {
52 +                       if( recvShadows != NULL )
53 +                               *recvShadows = 1;
54 +                       if( castShadows != NULL )
55 +                               *castShadows = 1;
56 +               }
57 +       }
58  }
59  
60 Index: game_ef.h\r
61 ===================================================================\r
62 --- game_ef.h   (revision 158)\r
63 +++ game_ef.h   (working copy)\r
64 @@ -113,7 +113,16 @@\r
65         qfalse,                         /* wolf lighting model? */
66         128,                            /* lightmap width/height */
67         1.0f,                           /* lightmap gamma */
68 +       1.0f,                           /* lightmap exposure */
69         1.0f,                           /* lightmap compensate */
70 +       1.0f,                           /* lightgrid scale */
71 +       1.0f,                           /* lightgrid ambient scale */
72 +       qfalse,                         /* disable shader lightstyles hack */
73 +       qfalse,                         /* keep light entities on bsp */
74 +       8,                                      /* default patchMeta subdivisions tolerance */
75 +       qfalse,                         /* patch casting enabled */
76 +       qfalse,                         /* compile deluxemaps */
77 +       0,                                      /* deluxemaps default mode */
78         "IBSP",                         /* bsp file prefix */
79         46,                                     /* bsp file version */
80         qfalse,                         /* cod-style lump len/ofs order */
81 Index: game_etut.h\r
82 ===================================================================\r
83 --- game_etut.h (revision 158)\r
84 +++ game_etut.h (working copy)\r
85 @@ -148,7 +148,16 @@\r
86         qfalse,                         /* wolf lighting model? */
87         128,                            /* lightmap width/height */
88         2.2f,                           /* lightmap gamma */
89 +       1.0f,                           /* lightmap exposure */
90         1.0f,                           /* lightmap compensate */
91 +       1.0f,                           /* lightgrid scale */
92 +       1.0f,                           /* lightgrid ambient scale */
93 +       qfalse,                         /* disable shader lightstyles hack */
94 +       qfalse,                         /* keep light entities on bsp */
95 +       8,                                      /* default patchMeta subdivisions tolerance */
96 +       qfalse,                         /* patch casting enabled */
97 +       qfalse,                         /* compile deluxemaps */
98 +       0,                                      /* deluxemaps default mode */
99         "IBSP",                         /* bsp file prefix */
100         47,                                     /* bsp file version */
101         qfalse,                         /* cod-style lump len/ofs order */
102 Index: game_ja.h\r
103 ===================================================================\r
104 --- game_ja.h   (revision 158)\r
105 +++ game_ja.h   (working copy)\r
106 @@ -67,7 +67,16 @@\r
107         qfalse,                         /* wolf lighting model? */
108         128,                            /* lightmap width/height */
109         1.0f,                           /* lightmap gamma */
110 +       1.0f,                           /* lightmap exposure */
111         1.0f,                           /* lightmap compensate */
112 +       1.0f,                           /* lightgrid scale */
113 +       1.0f,                           /* lightgrid ambient scale */
114 +       qfalse,                         /* disable shader lightstyles hack */
115 +       qfalse,                         /* keep light entities on bsp */
116 +       8,                                      /* default patchMeta subdivisions tolerance */
117 +       qfalse,                         /* patch casting enabled */
118 +       qfalse,                         /* compile deluxemaps */
119 +       0,                                      /* deluxemaps default mode */
120         "RBSP",                         /* bsp file prefix */
121         1,                                      /* bsp file version */
122         qfalse,                         /* cod-style lump len/ofs order */
123 Index: game_jk2.h\r
124 ===================================================================\r
125 --- game_jk2.h  (revision 158)\r
126 +++ game_jk2.h  (working copy)\r
127 @@ -64,7 +64,16 @@\r
128         qfalse,                         /* wolf lighting model? */
129         128,                            /* lightmap width/height */
130         1.0f,                           /* lightmap gamma */
131 +       1.0f,                           /* lightmap exposure */
132         1.0f,                           /* lightmap compensate */
133 +       1.0f,                           /* lightgrid scale */
134 +       1.0f,                           /* lightgrid ambient scale */
135 +       qfalse,                         /* disable shader lightstyles hack */
136 +       qfalse,                         /* keep light entities on bsp */
137 +       8,                                      /* default patchMeta subdivisions tolerance */
138 +       qfalse,                         /* patch casting enabled */
139 +       qfalse,                         /* compile deluxemaps */
140 +       0,                                      /* deluxemaps default mode */
141         "RBSP",                         /* bsp file prefix */
142         1,                                      /* bsp file version */
143         qfalse,                         /* cod-style lump len/ofs order */
144 Index: game_qfusion.h\r
145 ===================================================================\r
146 --- game_qfusion.h      (revision 158)\r
147 +++ game_qfusion.h      (working copy)\r
148 @@ -1,195 +1,204 @@\r
149 -/* -------------------------------------------------------------------------------
150 -
151 -This code is based on source provided under the terms of the Id Software 
152 -LIMITED USE SOFTWARE LICENSE AGREEMENT, a copy of which is included with the
153 -GtkRadiant sources (see LICENSE_ID). If you did not receive a copy of 
154 -LICENSE_ID, please contact Id Software immediately at info@idsoftware.com.
155 -
156 -All changes and additions to the original source which have been developed by
157 -other contributors (see CONTRIBUTORS) are provided under the terms of the
158 -license the contributors choose (see LICENSE), to the extent permitted by the
159 -LICENSE_ID. If you did not receive a copy of the contributor license,
160 -please contact the GtkRadiant maintainers at info@gtkradiant.com immediately.
161 -
162 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
163 -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
164 -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
165 -DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
166 -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
167 -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
168 -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
169 -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
170 -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
171 -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
172 -
173 -----------------------------------------------------------------------------------
174 -
175 -This code has been altered significantly from its original form, to support
176 -several games based on the Quake III Arena engine, in the form of "Q3Map2."
177 -
178 -------------------------------------------------------------------------------- */
179 -
180 -
181 -
182 -/* marker */
183 -#ifndef GAME_QFUSION_H
184 -#define GAME_QFUSION_H
185 -
186 -
187 -
188 -/* -------------------------------------------------------------------------------
189 -
190 -content and surface flags
191 -
192 -------------------------------------------------------------------------------- */
193 -
194 -/* game flags */
195 -#define F_CONT_SOLID                           1                       /* an eye is never valid in a solid */
196 -#define F_CONT_LAVA                                    8
197 -#define F_CONT_SLIME                           16
198 -#define F_CONT_WATER                           32
199 -#define F_CONT_FOG                                     64
200 -
201 -#define F_CONT_AREAPORTAL                      0x8000
202 -
203 -#define F_CONT_PLAYERCLIP                      0x10000
204 -#define F_CONT_MONSTERCLIP                     0x20000
205 -#define F_CONT_TELEPORTER                      0x40000
206 -#define F_CONT_JUMPPAD                         0x80000
207 -#define F_CONT_CLUSTERPORTAL           0x100000
208 -#define F_CONT_DONOTENTER                      0x200000
209 -#define F_CONT_BOTCLIP                         0x400000
210 -
211 -#define F_CONT_ORIGIN                          0x1000000       /* removed before bsping an entity */
212 -
213 -#define F_CONT_BODY                                    0x2000000       /* should never be on a brush, only in game */
214 -#define F_CONT_CORPSE                          0x4000000
215 -#define F_CONT_DETAIL                          0x8000000       /* brushes not used for the bsp */
216 -#define F_CONT_STRUCTURAL                      0x10000000      /* brushes used for the bsp */
217 -#define F_CONT_TRANSLUCENT                     0x20000000      /* don't consume surface fragments inside */
218 -#define F_CONT_TRIGGER                         0x40000000
219 -#define F_CONT_NODROP                          0x80000000      /* don't leave bodies or items (death fog, lava) */
220 -
221 -#define F_SURF_NODAMAGE                                0x1                     /* never give falling damage */
222 -#define F_SURF_SLICK                           0x2                     /* effects game physics */
223 -#define F_SURF_SKY                                     0x4                     /* lighting from environment map */
224 -#define F_SURF_LADDER                          0x8
225 -#define F_SURF_NOIMPACT                                0x10            /* don't make missile explosions */
226 -#define F_SURF_NOMARKS                         0x20            /* don't leave missile marks */
227 -#define F_SURF_FLESH                           0x40            /* make flesh sounds and effects */
228 -#define F_SURF_NODRAW                          0x80            /* don't generate a drawsurface at all */
229 -#define F_SURF_HINT                                    0x100           /* make a primary bsp splitter */
230 -#define F_SURF_SKIP                                    0x200           /* completely ignore, allowing non-closed brushes */
231 -#define F_SURF_NOLIGHTMAP                      0x400           /* surface doesn't need a lightmap */
232 -#define F_SURF_POINTLIGHT                      0x800           /* generate lighting info at vertexes */
233 -#define F_SURF_METALSTEPS                      0x1000          /* clanking footsteps */
234 -#define F_SURF_NOSTEPS                         0x2000          /* no footstep sounds */
235 -#define F_SURF_NONSOLID                                0x4000          /* don't collide against curves with this set */
236 -#define F_SURF_LIGHTFILTER                     0x8000          /* act as a light filter during q3map -light */
237 -#define F_SURF_ALPHASHADOW                     0x10000         /* do per-pixel light shadow casting in q3map */
238 -#define F_SURF_NODLIGHT                                0x20000         /* don't dlight even if solid (solid lava, skies) */
239 -#define F_SURF_DUST                                    0x40000         /* leave a dust trail when walking on this surface */
240 -
241 -/* ydnar flags */
242 -#define F_SURF_VERTEXLIT                       (F_SURF_POINTLIGHT | F_SURF_NOLIGHTMAP)
243 -
244 -
245 -
246 -/* -------------------------------------------------------------------------------
247 -
248 -game_t struct
249 -
250 -------------------------------------------------------------------------------- */
251 -
252 -{
253 -       "qfusion",                      /* -game x */
254 -       "baseq3",                       /* default base game data dir */
255 -       ".q3a",                         /* unix home sub-dir */
256 -       "quake",                        /* magic path word */
257 -       "scripts",                      /* shader directory */
258 -       2048,                           /* max lightmapped surface verts */
259 -       2048,                           /* max surface verts */
260 -       12288,                          /* max surface indexes */
261 -       qtrue,                          /* flares */
262 -       "flareshader",          /* default flare shader */
263 -       qfalse,                         /* wolf lighting model? */
264 -       512,                            /* lightmap width/height */
265 -       1.0f,                           /* lightmap gamma */
266 -       1.0f,                           /* lightmap compensate */
267 -       "FBSP",                         /* bsp file prefix */
268 -       1,                                      /* bsp file version */
269 -       qfalse,                         /* cod-style lump len/ofs order */
270 -       LoadRBSPFile,           /* bsp load function */
271 -       WriteRBSPFile,          /* bsp write function */
272 -
273 -       {
274 -               /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */
275 -               
276 -               /* default */
277 -               { "default",            F_CONT_SOLID,                           -1,                                                     0,                                                      -1,                                                     C_SOLID,                                        -1 },
278 -               
279 -               
280 -               /* ydnar */
281 -               { "lightgrid",          0,                                                      0,                                                      0,                                                      0,                                                      C_LIGHTGRID,                            0 },
282 -               { "antiportal",         0,                                                      0,                                                      0,                                                      0,                                                      C_ANTIPORTAL,                           0 },
283 -               { "skip",                       0,                                                      0,                                                      0,                                                      0,                                                      C_SKIP,                                         0 },
284 -               
285 -               
286 -               /* compiler */
287 -               { "origin",                     F_CONT_ORIGIN,                          F_CONT_SOLID,                           0,                                                      0,                                                      C_ORIGIN | C_TRANSLUCENT,       C_SOLID },
288 -               { "areaportal",         F_CONT_AREAPORTAL,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },
289 -               { "trans",                      F_CONT_TRANSLUCENT,                     0,                                                      0,                                                      0,                                                      C_TRANSLUCENT,                          0 },
290 -               { "detail",                     F_CONT_DETAIL,                          0,                                                      0,                                                      0,                                                      C_DETAIL,                                       0 },
291 -               { "structural",         F_CONT_STRUCTURAL,                      0,                                                      0,                                                      0,                                                      C_STRUCTURAL,                           0 },
292 -               { "hint",                       0,                                                      0,                                                      F_SURF_HINT,                            0,                                                      C_HINT,                                         0 },
293 -               { "nodraw",                     0,                                                      0,                                                      F_SURF_NODRAW,                          0,                                                      C_NODRAW,                                       0 },
294 -               
295 -               { "alphashadow",        0,                                                      0,                                                      F_SURF_ALPHASHADOW,                     0,                                                      C_ALPHASHADOW | C_TRANSLUCENT,  0 },
296 -               { "lightfilter",        0,                                                      0,                                                      F_SURF_LIGHTFILTER,                     0,                                                      C_LIGHTFILTER | C_TRANSLUCENT,  0 },
297 -               { "nolightmap",         0,                                                      0,                                                      F_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },
298 -               { "pointlight",         0,                                                      0,                                                      F_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },
299 -               
300 -               
301 -               /* game */
302 -               { "nonsolid",           0,                                                      F_CONT_SOLID,                           F_SURF_NONSOLID,                        0,                                                      0,                                                      C_SOLID },
303 -               
304 -               { "trigger",            F_CONT_TRIGGER,                         F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
305 -               
306 -               { "water",                      F_CONT_WATER,                           F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
307 -               { "slime",                      F_CONT_SLIME,                           F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
308 -               { "lava",                       F_CONT_LAVA,                            F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
309 -               
310 -               { "playerclip",         F_CONT_PLAYERCLIP,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },
311 -               { "monsterclip",        F_CONT_MONSTERCLIP,                     F_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },
312 -               { "nodrop",                     F_CONT_NODROP,                          F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
313 -               
314 -               { "clusterportal",      F_CONT_CLUSTERPORTAL,           F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
315 -               { "donotenter",         F_CONT_DONOTENTER,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
316 -               { "botclip",            F_CONT_BOTCLIP,                         F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
317 -               
318 -               { "fog",                        F_CONT_FOG,                                     F_CONT_SOLID,                           0,                                                      0,                                                      C_FOG,                                          C_SOLID },
319 -               { "sky",                        0,                                                      0,                                                      F_SURF_SKY,                                     0,                                                      C_SKY,                                          0 },
320 -               
321 -               { "slick",                      0,                                                      0,                                                      F_SURF_SLICK,                           0,                                                      0,                                                      0 },
322 -               
323 -               { "noimpact",           0,                                                      0,                                                      F_SURF_NOIMPACT,                        0,                                                      0,                                                      0 },
324 -               { "nomarks",            0,                                                      0,                                                      F_SURF_NOMARKS,                         0,                                                      C_NOMARKS,                                      0 },
325 -               { "ladder",                     0,                                                      0,                                                      F_SURF_LADDER,                          0,                                                      0,                                                      0 },
326 -               { "nodamage",           0,                                                      0,                                                      F_SURF_NODAMAGE,                        0,                                                      0,                                                      0 },
327 -               { "metalsteps",         0,                                                      0,                                                      F_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },
328 -               { "flesh",                      0,                                                      0,                                                      F_SURF_FLESH,                           0,                                                      0,                                                      0 },
329 -               { "nosteps",            0,                                                      0,                                                      F_SURF_NOSTEPS,                         0,                                                      0,                                                      0 },
330 -               { "nodlight",           0,                                                      0,                                                      F_SURF_NODLIGHT,                        0,                                                      0,                                                      0 },
331 -               { "dust",                       0,                                                      0,                                                      F_SURF_DUST,                            0,                                                      0,                                                      0 },
332 -               
333 -               
334 -               /* null */
335 -               { NULL, 0, 0, 0, 0, 0, 0 }
336 -       }
337 -}
338 -
339 -
340 -
341 -/* end marker */
342 -#endif
343 -
344 +/* -------------------------------------------------------------------------------\r
345 +\r
346 +This code is based on source provided under the terms of the Id Software \r
347 +LIMITED USE SOFTWARE LICENSE AGREEMENT, a copy of which is included with the\r
348 +GtkRadiant sources (see LICENSE_ID). If you did not receive a copy of \r
349 +LICENSE_ID, please contact Id Software immediately at info@idsoftware.com.\r
350 +\r
351 +All changes and additions to the original source which have been developed by\r
352 +other contributors (see CONTRIBUTORS) are provided under the terms of the\r
353 +license the contributors choose (see LICENSE), to the extent permitted by the\r
354 +LICENSE_ID. If you did not receive a copy of the contributor license,\r
355 +please contact the GtkRadiant maintainers at info@gtkradiant.com immediately.\r
356 +\r
357 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''\r
358 +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
359 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
360 +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY\r
361 +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
362 +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
363 +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
364 +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
365 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
366 +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
367 +\r
368 +----------------------------------------------------------------------------------\r
369 +\r
370 +This code has been altered significantly from its original form, to support\r
371 +several games based on the Quake III Arena engine, in the form of "Q3Map2."\r
372 +\r
373 +------------------------------------------------------------------------------- */\r
374 +\r
375 +\r
376 +\r
377 +/* marker */\r
378 +#ifndef GAME_QFUSION_H\r
379 +#define GAME_QFUSION_H\r
380 +\r
381 +\r
382 +\r
383 +/* -------------------------------------------------------------------------------\r
384 +\r
385 +content and surface flags\r
386 +\r
387 +------------------------------------------------------------------------------- */\r
388 +\r
389 +/* game flags */\r
390 +#define F_CONT_SOLID                           1                       /* an eye is never valid in a solid */\r
391 +#define F_CONT_LAVA                                    8\r
392 +#define F_CONT_SLIME                           16\r
393 +#define F_CONT_WATER                           32\r
394 +#define F_CONT_FOG                                     64\r
395 +\r
396 +#define F_CONT_AREAPORTAL                      0x8000\r
397 +\r
398 +#define F_CONT_PLAYERCLIP                      0x10000\r
399 +#define F_CONT_MONSTERCLIP                     0x20000\r
400 +#define F_CONT_TELEPORTER                      0x40000\r
401 +#define F_CONT_JUMPPAD                         0x80000\r
402 +#define F_CONT_CLUSTERPORTAL           0x100000\r
403 +#define F_CONT_DONOTENTER                      0x200000\r
404 +#define F_CONT_BOTCLIP                         0x400000\r
405 +\r
406 +#define F_CONT_ORIGIN                          0x1000000       /* removed before bsping an entity */\r
407 +\r
408 +#define F_CONT_BODY                                    0x2000000       /* should never be on a brush, only in game */\r
409 +#define F_CONT_CORPSE                          0x4000000\r
410 +#define F_CONT_DETAIL                          0x8000000       /* brushes not used for the bsp */\r
411 +#define F_CONT_STRUCTURAL                      0x10000000      /* brushes used for the bsp */\r
412 +#define F_CONT_TRANSLUCENT                     0x20000000      /* don't consume surface fragments inside */\r
413 +#define F_CONT_TRIGGER                         0x40000000\r
414 +#define F_CONT_NODROP                          0x80000000      /* don't leave bodies or items (death fog, lava) */\r
415 +\r
416 +#define F_SURF_NODAMAGE                                0x1                     /* never give falling damage */\r
417 +#define F_SURF_SLICK                           0x2                     /* effects game physics */\r
418 +#define F_SURF_SKY                                     0x4                     /* lighting from environment map */\r
419 +#define F_SURF_LADDER                          0x8\r
420 +#define F_SURF_NOIMPACT                                0x10            /* don't make missile explosions */\r
421 +#define F_SURF_NOMARKS                         0x20            /* don't leave missile marks */\r
422 +#define F_SURF_FLESH                           0x40            /* make flesh sounds and effects */\r
423 +#define F_SURF_NODRAW                          0x80            /* don't generate a drawsurface at all */\r
424 +#define F_SURF_HINT                                    0x100           /* make a primary bsp splitter */\r
425 +#define F_SURF_SKIP                                    0x200           /* completely ignore, allowing non-closed brushes */\r
426 +#define F_SURF_NOLIGHTMAP                      0x400           /* surface doesn't need a lightmap */\r
427 +#define F_SURF_POINTLIGHT                      0x800           /* generate lighting info at vertexes */\r
428 +#define F_SURF_METALSTEPS                      0x1000          /* clanking footsteps */\r
429 +#define F_SURF_NOSTEPS                         0x2000          /* no footstep sounds */\r
430 +#define F_SURF_NONSOLID                                0x4000          /* don't collide against curves with this set */\r
431 +#define F_SURF_LIGHTFILTER                     0x8000          /* act as a light filter during q3map -light */\r
432 +#define F_SURF_ALPHASHADOW                     0x10000         /* do per-pixel light shadow casting in q3map */\r
433 +#define F_SURF_NODLIGHT                                0x20000         /* don't dlight even if solid (solid lava, skies) */\r
434 +#define F_SURF_DUST                                    0x40000         /* leave a dust trail when walking on this surface */\r
435 +\r
436 +/* ydnar flags */\r
437 +#define F_SURF_VERTEXLIT                       (F_SURF_POINTLIGHT | F_SURF_NOLIGHTMAP)\r
438 +\r
439 +\r
440 +\r
441 +/* -------------------------------------------------------------------------------\r
442 +\r
443 +game_t struct\r
444 +\r
445 +------------------------------------------------------------------------------- */\r
446 +\r
447 +{\r
448 +       "qfusion",                      /* -game x */\r
449 +       "baseq3",                       /* default base game data dir */\r
450 +       ".q3a",                         /* unix home sub-dir */\r
451 +       "quake",                        /* magic path word */\r
452 +       "scripts",                      /* shader directory */\r
453 +       2048,                           /* max lightmapped surface verts */\r
454 +       2048,                           /* max surface verts */\r
455 +       12288,                          /* max surface indexes */\r
456 +       qtrue,                          /* flares */\r
457 +       "flareshader",          /* default flare shader */\r
458 +       qfalse,                         /* wolf lighting model? */\r
459 +       512,                            /* lightmap width/height */\r
460 +       1.0f,                           /* lightmap gamma */\r
461 +       1.0f,                           /* lightmap exposure */\r
462 +       1.0f,                           /* lightmap compensate */\r
463 +       1.0f,                           /* lightgrid scale */\r
464 +       1.0f,                           /* lightgrid ambient scale */\r
465 +       qfalse,                         /* disable shader lightstyles hack */\r
466 +       qfalse,                         /* keep light entities on bsp */\r
467 +       8,                                      /* default patchMeta subdivisions tolerance */\r
468 +       qfalse,                         /* patch casting enabled */\r
469 +       qfalse,                         /* compile deluxemaps */\r
470 +       0,                                      /* deluxemaps default mode */\r
471 +       "FBSP",                         /* bsp file prefix */\r
472 +       1,                                      /* bsp file version */\r
473 +       qfalse,                         /* cod-style lump len/ofs order */\r
474 +       LoadRBSPFile,           /* bsp load function */\r
475 +       WriteRBSPFile,          /* bsp write function */\r
476 +\r
477 +       {\r
478 +               /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */\r
479 +               \r
480 +               /* default */\r
481 +               { "default",            F_CONT_SOLID,                           -1,                                                     0,                                                      -1,                                                     C_SOLID,                                        -1 },\r
482 +               \r
483 +               \r
484 +               /* ydnar */\r
485 +               { "lightgrid",          0,                                                      0,                                                      0,                                                      0,                                                      C_LIGHTGRID,                            0 },\r
486 +               { "antiportal",         0,                                                      0,                                                      0,                                                      0,                                                      C_ANTIPORTAL,                           0 },\r
487 +               { "skip",                       0,                                                      0,                                                      0,                                                      0,                                                      C_SKIP,                                         0 },\r
488 +               \r
489 +               \r
490 +               /* compiler */\r
491 +               { "origin",                     F_CONT_ORIGIN,                          F_CONT_SOLID,                           0,                                                      0,                                                      C_ORIGIN | C_TRANSLUCENT,       C_SOLID },\r
492 +               { "areaportal",         F_CONT_AREAPORTAL,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },\r
493 +               { "trans",                      F_CONT_TRANSLUCENT,                     0,                                                      0,                                                      0,                                                      C_TRANSLUCENT,                          0 },\r
494 +               { "detail",                     F_CONT_DETAIL,                          0,                                                      0,                                                      0,                                                      C_DETAIL,                                       0 },\r
495 +               { "structural",         F_CONT_STRUCTURAL,                      0,                                                      0,                                                      0,                                                      C_STRUCTURAL,                           0 },\r
496 +               { "hint",                       0,                                                      0,                                                      F_SURF_HINT,                            0,                                                      C_HINT,                                         0 },\r
497 +               { "nodraw",                     0,                                                      0,                                                      F_SURF_NODRAW,                          0,                                                      C_NODRAW,                                       0 },\r
498 +               \r
499 +               { "alphashadow",        0,                                                      0,                                                      F_SURF_ALPHASHADOW,                     0,                                                      C_ALPHASHADOW | C_TRANSLUCENT,  0 },\r
500 +               { "lightfilter",        0,                                                      0,                                                      F_SURF_LIGHTFILTER,                     0,                                                      C_LIGHTFILTER | C_TRANSLUCENT,  0 },\r
501 +               { "nolightmap",         0,                                                      0,                                                      F_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },\r
502 +               { "pointlight",         0,                                                      0,                                                      F_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },\r
503 +               \r
504 +               \r
505 +               /* game */\r
506 +               { "nonsolid",           0,                                                      F_CONT_SOLID,                           F_SURF_NONSOLID,                        0,                                                      0,                                                      C_SOLID },\r
507 +               \r
508 +               { "trigger",            F_CONT_TRIGGER,                         F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
509 +               \r
510 +               { "water",                      F_CONT_WATER,                           F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
511 +               { "slime",                      F_CONT_SLIME,                           F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
512 +               { "lava",                       F_CONT_LAVA,                            F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
513 +               \r
514 +               { "playerclip",         F_CONT_PLAYERCLIP,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },\r
515 +               { "monsterclip",        F_CONT_MONSTERCLIP,                     F_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },\r
516 +               { "nodrop",                     F_CONT_NODROP,                          F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
517 +               \r
518 +               { "clusterportal",      F_CONT_CLUSTERPORTAL,           F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
519 +               { "donotenter",         F_CONT_DONOTENTER,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
520 +               { "botclip",            F_CONT_BOTCLIP,                         F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
521 +               \r
522 +               { "fog",                        F_CONT_FOG,                                     F_CONT_SOLID,                           0,                                                      0,                                                      C_FOG,                                          C_SOLID },\r
523 +               { "sky",                        0,                                                      0,                                                      F_SURF_SKY,                                     0,                                                      C_SKY,                                          0 },\r
524 +               \r
525 +               { "slick",                      0,                                                      0,                                                      F_SURF_SLICK,                           0,                                                      0,                                                      0 },\r
526 +               \r
527 +               { "noimpact",           0,                                                      0,                                                      F_SURF_NOIMPACT,                        0,                                                      0,                                                      0 },\r
528 +               { "nomarks",            0,                                                      0,                                                      F_SURF_NOMARKS,                         0,                                                      C_NOMARKS,                                      0 },\r
529 +               { "ladder",                     0,                                                      0,                                                      F_SURF_LADDER,                          0,                                                      0,                                                      0 },\r
530 +               { "nodamage",           0,                                                      0,                                                      F_SURF_NODAMAGE,                        0,                                                      0,                                                      0 },\r
531 +               { "metalsteps",         0,                                                      0,                                                      F_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },\r
532 +               { "flesh",                      0,                                                      0,                                                      F_SURF_FLESH,                           0,                                                      0,                                                      0 },\r
533 +               { "nosteps",            0,                                                      0,                                                      F_SURF_NOSTEPS,                         0,                                                      0,                                                      0 },\r
534 +               { "nodlight",           0,                                                      0,                                                      F_SURF_NODLIGHT,                        0,                                                      0,                                                      0 },\r
535 +               { "dust",                       0,                                                      0,                                                      F_SURF_DUST,                            0,                                                      0,                                                      0 },\r
536 +               \r
537 +               \r
538 +               /* null */\r
539 +               { NULL, 0, 0, 0, 0, 0, 0 }\r
540 +       }\r
541 +}\r
542 +\r
543 +\r
544 +\r
545 +/* end marker */\r
546 +#endif\r
547 +\r
548 Index: game_quake3.h\r
549 ===================================================================\r
550 --- game_quake3.h       (revision 158)\r
551 +++ game_quake3.h       (working copy)\r
552 @@ -112,7 +112,16 @@\r
553         qfalse,                         /* wolf lighting model? */
554         128,                            /* lightmap width/height */
555         1.0f,                           /* lightmap gamma */
556 +       1.0f,                           /* lightmap exposure */
557         1.0f,                           /* lightmap compensate */
558 +       1.0f,                           /* lightgrid scale */
559 +       1.0f,                           /* lightgrid ambient scale */
560 +       qfalse,                         /* disable shader lightstyles hack */
561 +       qfalse,                         /* keep light entities on bsp */
562 +       8,                                      /* default patchMeta subdivisions tolerance */
563 +       qfalse,                         /* patch casting enabled */
564 +       qfalse,                         /* compile deluxemaps */
565 +       0,                                      /* deluxemaps default mode */
566         "IBSP",                         /* bsp file prefix */
567         46,                                     /* bsp file version */
568         qfalse,                         /* cod-style lump len/ofs order */
569 Index: game_sof2.h\r
570 ===================================================================\r
571 --- game_sof2.h (revision 158)\r
572 +++ game_sof2.h (working copy)\r
573 @@ -139,7 +139,16 @@\r
574         qfalse,                                 /* wolf lighting model? */
575         128,                                    /* lightmap width/height */
576         1.0f,                                   /* lightmap gamma */
577 +       1.0f,                                   /* lightmap exposure */
578         1.0f,                                   /* lightmap compensate */
579 +       1.0f,                           /* lightgrid scale */
580 +       1.0f,                           /* lightgrid ambient scale */
581 +       qfalse,                         /* disable shader lightstyles hack */
582 +       qfalse,                         /* keep light entities on bsp */
583 +       8,                                      /* default patchMeta subdivisions tolerance */
584 +       qfalse,                         /* patch casting enabled */
585 +       qfalse,                         /* compile deluxemaps */
586 +       0,                                      /* deluxemaps default mode */
587         "RBSP",                                 /* bsp file prefix */
588         1,                                              /* bsp file version */
589         qfalse,                                 /* cod-style lump len/ofs order */
590 Index: game_tenebrae.h\r
591 ===================================================================\r
592 --- game_tenebrae.h     (revision 158)\r
593 +++ game_tenebrae.h     (working copy)\r
594 @@ -112,7 +112,16 @@\r
595         qfalse,                         /* wolf lighting model? */
596         512,                            /* lightmap width/height */
597         2.0f,                           /* lightmap gamma */
598 +       1.0f,                           /* lightmap exposure */
599         1.0f,                           /* lightmap compensate */
600 +       1.0f,                           /* lightgrid scale */
601 +       1.0f,                           /* lightgrid ambient scale */
602 +       qtrue,                          /* disable shader lightstyles hack */
603 +       qfalse,                         /* keep light entities on bsp */
604 +       8,                                      /* default patchMeta subdivisions tolerance */
605 +       qfalse,                         /* patch casting enabled */
606 +       qtrue,                          /* compile deluxemaps */
607 +       0,                                      /* deluxemaps default mode */
608         "IBSP",                         /* bsp file prefix */
609         46,                                     /* bsp file version */
610         qfalse,                         /* cod-style lump len/ofs order */
611 Index: game_tremulous.h\r
612 ===================================================================\r
613 --- game_tremulous.h    (revision 158)\r
614 +++ game_tremulous.h    (working copy)\r
615 @@ -1,160 +1,169 @@\r
616 -/* -------------------------------------------------------------------------------
617 -
618 -Copyright (C) 1999-2006 Id Software, Inc. and contributors.
619 -For a list of contributors, see the accompanying CONTRIBUTORS file.
620 -
621 -This file is part of GtkRadiant.
622 -
623 -GtkRadiant is free software; you can redistribute it and/or modify
624 -it under the terms of the GNU General Public License as published by
625 -the Free Software Foundation; either version 2 of the License, or
626 -(at your option) any later version.
627 -
628 -GtkRadiant is distributed in the hope that it will be useful,
629 -but WITHOUT ANY WARRANTY; without even the implied warranty of
630 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
631 -GNU General Public License for more details.
632 -
633 -You should have received a copy of the GNU General Public License
634 -along with GtkRadiant; if not, write to the Free Software
635 -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
636 -
637 -----------------------------------------------------------------------------------
638 -
639 -This code has been altered significantly from its original form, to support
640 -several games based on the Quake III Arena engine, in the form of "Q3Map2."
641 -
642 -------------------------------------------------------------------------------- */
643 -
644 -/* Tremulous support, by LinuxManMikeC */
645 -
646 -
647 -/* marker */
648 -#ifndef GAME_TREMULOUS_H
649 -#define GAME_TREMULOUS_H
650 -
651 -
652 -
653 -/* -------------------------------------------------------------------------------
654 -
655 -content and surface flags - also uses defines from game_quake3.h
656 -
657 -------------------------------------------------------------------------------- */
658 -#define TREM_CONT_NOALIENBUILD         0x1000
659 -#define TREM_CONT_NOHUMANBUILD         0x2000
660 -#define TREM_CONT_NOBUILD              0x4000
661 -  
662 -#define TREM_SURF_NOALIENBUILDSURFACE  0x80000 
663 -#define TREM_SURF_NOHUMANBUILDSURFACE  0x100000
664 -#define TREM_SURF_NOBUILDSURFACE       0x200000
665 -
666 -
667 -
668 -/* -------------------------------------------------------------------------------
669 -
670 -game_t struct
671 -
672 -------------------------------------------------------------------------------- */
673 -
674 -{
675 -       "tremulous",                    /* -game x */
676 -       "base",                 /* default base game data dir */
677 -       ".tremulous",                           /* unix home sub-dir */
678 -       "tremulous",                    /* magic path word - think this is right for trem*/
679 -       "scripts",                      /* shader directory */
680 -       64,                                     /* max lightmapped surface verts */
681 -       999,                            /* max surface verts */
682 -       6000,                           /* max surface indexes */
683 -       qfalse,                         /* flares */
684 -       "flareshader",          /* default flare shader */
685 -       qfalse,                         /* wolf lighting model? */
686 -       128,                            /* lightmap width/height */
687 -       1.0f,                           /* lightmap gamma */
688 -       1.0f,                           /* lightmap compensate */
689 -       "IBSP",                         /* bsp file prefix */
690 -       46,                                     /* bsp file version */
691 -       qfalse,                         /* cod-style lump len/ofs order */
692 -       LoadIBSPFile,           /* bsp load function */
693 -       WriteIBSPFile,          /* bsp write function */
694 -
695 -       {
696 -               /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */
697 -               
698 -               /* default */
699 -               { "default",            Q_CONT_SOLID,                           -1,                                                     0,                                                      -1,                                                     C_SOLID,                                        -1 },
700 -               
701 -               
702 -               /* ydnar */
703 -               { "lightgrid",          0,                                                      0,                                                      0,                                                      0,                                                      C_LIGHTGRID,                            0 },
704 -               { "antiportal",         0,                                                      0,                                                      0,                                                      0,                                                      C_ANTIPORTAL,                           0 },
705 -               { "skip",                       0,                                                      0,                                                      0,                                                      0,                                                      C_SKIP,                                         0 },
706 -               
707 -               
708 -               /* compiler */
709 -               { "origin",                     Q_CONT_ORIGIN,                          Q_CONT_SOLID,                           0,                                                      0,                                                      C_ORIGIN | C_TRANSLUCENT,       C_SOLID },
710 -               { "areaportal",         Q_CONT_AREAPORTAL,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },
711 -               { "trans",                      Q_CONT_TRANSLUCENT,                     0,                                                      0,                                                      0,                                                      C_TRANSLUCENT,                          0 },
712 -               { "detail",                     Q_CONT_DETAIL,                          0,                                                      0,                                                      0,                                                      C_DETAIL,                                       0 },
713 -               { "structural",         Q_CONT_STRUCTURAL,                      0,                                                      0,                                                      0,                                                      C_STRUCTURAL,                           0 },
714 -               { "hint",                       0,                                                      0,                                                      Q_SURF_HINT,                            0,                                                      C_HINT,                                         0 },
715 -               { "nodraw",                     0,                                                      0,                                                      Q_SURF_NODRAW,                          0,                                                      C_NODRAW,                                       0 },
716 -               
717 -               { "alphashadow",        0,                                                      0,                                                      Q_SURF_ALPHASHADOW,                     0,                                                      C_ALPHASHADOW | C_TRANSLUCENT,  0 },
718 -               { "lightfilter",        0,                                                      0,                                                      Q_SURF_LIGHTFILTER,                     0,                                                      C_LIGHTFILTER | C_TRANSLUCENT,  0 },
719 -               { "nolightmap",         0,                                                      0,                                                      Q_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },
720 -               { "pointlight",         0,                                                      0,                                                      Q_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },
721 -               
722 -               
723 -               /* game */
724 -               { "nonsolid",           0,                                                      Q_CONT_SOLID,                           Q_SURF_NONSOLID,                        0,                                                      0,                                                      C_SOLID },
725 -               
726 -               { "trigger",            Q_CONT_TRIGGER,                         Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
727 -               
728 -               { "water",                      Q_CONT_WATER,                           Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
729 -               { "slime",                      Q_CONT_SLIME,                           Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
730 -               { "lava",                       Q_CONT_LAVA,                            Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
731 -               
732 -               { "playerclip",         Q_CONT_PLAYERCLIP,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },
733 -               { "monsterclip",        Q_CONT_MONSTERCLIP,                     Q_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },
734 -               { "nodrop",                     Q_CONT_NODROP,                          Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
735 -               
736 -               { "clusterportal",      Q_CONT_CLUSTERPORTAL,           Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
737 -               { "donotenter",         Q_CONT_DONOTENTER,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
738 -               { "botclip",            Q_CONT_BOTCLIP,                         Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
739 -               
740 -               { "fog",                        Q_CONT_FOG,                                     Q_CONT_SOLID,                           0,                                                      0,                                                      C_FOG,                                          C_SOLID },
741 -               { "sky",                        0,                                                      0,                                                      Q_SURF_SKY,                                     0,                                                      C_SKY,                                          0 },
742 -               
743 -               { "slick",                      0,                                                      0,                                                      Q_SURF_SLICK,                           0,                                                      0,                                                      0 },
744 -               
745 -               { "noimpact",           0,                                                      0,                                                      Q_SURF_NOIMPACT,                        0,                                                      0,                                                      0 },
746 -               { "nomarks",            0,                                                      0,                                                      Q_SURF_NOMARKS,                         0,                                                      C_NOMARKS,                                      0 },
747 -               { "ladder",                     0,                                                      0,                                                      Q_SURF_LADDER,                          0,                                                      0,                                                      0 },
748 -               { "nodamage",           0,                                                      0,                                                      Q_SURF_NODAMAGE,                        0,                                                      0,                                                      0 },
749 -               { "metalsteps",         0,                                                      0,                                                      Q_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },
750 -               { "flesh",                      0,                                                      0,                                                      Q_SURF_FLESH,                           0,                                                      0,                                                      0 },
751 -               { "nosteps",            0,                                                      0,                                                      Q_SURF_NOSTEPS,                         0,                                                      0,                                                      0 },
752 -               { "nodlight",           0,                                                      0,                                                      Q_SURF_NODLIGHT,                        0,                                                      0,                                                      0 },
753 -               { "dust",                       0,                                                      0,                                                      Q_SURF_DUST,                            0,                                                      0,                                                      0 },
754 -               
755 -               
756 -               /* tremulous */
757 -               {"noalienbuild",                        TREM_CONT_NOALIENBUILD,0,0,0,0,0},
758 -               {"nohumanbuild",                        TREM_CONT_NOHUMANBUILD,0,0,0,0,0},
759 -               {"nobuild",                                     TREM_CONT_NOBUILD,0,0,0,0,0},
760 -               
761 -               {"noalienbuildsurface", 0,0,TREM_SURF_NOALIENBUILDSURFACE,0,0,0},
762 -               {"nohumanbuildsurface", 0,0,TREM_SURF_NOHUMANBUILDSURFACE,0,0,0},
763 -               {"nobuildsurface",              0,0,TREM_SURF_NOBUILDSURFACE,0,0,0},
764 -               
765 -               
766 -               /* null */
767 -               { NULL, 0, 0, 0, 0, 0, 0 }
768 -       }
769 -}
770 -
771 -
772 -
773 -/* end marker */
774 -#endif
775 -
776 +/* -------------------------------------------------------------------------------\r
777 +\r
778 +Copyright (C) 1999-2006 Id Software, Inc. and contributors.\r
779 +For a list of contributors, see the accompanying CONTRIBUTORS file.\r
780 +\r
781 +This file is part of GtkRadiant.\r
782 +\r
783 +GtkRadiant is free software; you can redistribute it and/or modify\r
784 +it under the terms of the GNU General Public License as published by\r
785 +the Free Software Foundation; either version 2 of the License, or\r
786 +(at your option) any later version.\r
787 +\r
788 +GtkRadiant is distributed in the hope that it will be useful,\r
789 +but WITHOUT ANY WARRANTY; without even the implied warranty of\r
790 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
791 +GNU General Public License for more details.\r
792 +\r
793 +You should have received a copy of the GNU General Public License\r
794 +along with GtkRadiant; if not, write to the Free Software\r
795 +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
796 +\r
797 +----------------------------------------------------------------------------------\r
798 +\r
799 +This code has been altered significantly from its original form, to support\r
800 +several games based on the Quake III Arena engine, in the form of "Q3Map2."\r
801 +\r
802 +------------------------------------------------------------------------------- */\r
803 +\r
804 +/* Tremulous support, by LinuxManMikeC */\r
805 +\r
806 +\r
807 +/* marker */\r
808 +#ifndef GAME_TREMULOUS_H\r
809 +#define GAME_TREMULOUS_H\r
810 +\r
811 +\r
812 +\r
813 +/* -------------------------------------------------------------------------------\r
814 +\r
815 +content and surface flags - also uses defines from game_quake3.h\r
816 +\r
817 +------------------------------------------------------------------------------- */\r
818 +#define TREM_CONT_NOALIENBUILD         0x1000\r
819 +#define TREM_CONT_NOHUMANBUILD         0x2000\r
820 +#define TREM_CONT_NOBUILD              0x4000\r
821 +  \r
822 +#define TREM_SURF_NOALIENBUILDSURFACE  0x80000 \r
823 +#define TREM_SURF_NOHUMANBUILDSURFACE  0x100000\r
824 +#define TREM_SURF_NOBUILDSURFACE       0x200000\r
825 +\r
826 +\r
827 +\r
828 +/* -------------------------------------------------------------------------------\r
829 +\r
830 +game_t struct\r
831 +\r
832 +------------------------------------------------------------------------------- */\r
833 +\r
834 +{\r
835 +       "tremulous",                    /* -game x */\r
836 +       "base",                 /* default base game data dir */\r
837 +       ".tremulous",                           /* unix home sub-dir */\r
838 +       "tremulous",                    /* magic path word - think this is right for trem*/\r
839 +       "scripts",                      /* shader directory */\r
840 +       64,                                     /* max lightmapped surface verts */\r
841 +       999,                            /* max surface verts */\r
842 +       6000,                           /* max surface indexes */\r
843 +       qfalse,                         /* flares */\r
844 +       "flareshader",          /* default flare shader */\r
845 +       qfalse,                         /* wolf lighting model? */\r
846 +       128,                            /* lightmap width/height */\r
847 +       1.0f,                           /* lightmap gamma */\r
848 +       1.0f,                           /* lightmap exposure */\r
849 +       1.0f,                           /* lightmap compensate */\r
850 +       1.0f,                           /* lightgrid scale */\r
851 +       1.0f,                           /* lightgrid ambient scale */\r
852 +       qfalse,                         /* disable shader lightstyles hack */\r
853 +       qfalse,                         /* keep light entities on bsp */\r
854 +       8,                                      /* default patchMeta subdivisions tolerance */\r
855 +       qfalse,                         /* patch casting enabled */\r
856 +       qfalse,                         /* compile deluxemaps */\r
857 +       0,                                      /* deluxemaps default mode */\r
858 +       "IBSP",                         /* bsp file prefix */\r
859 +       46,                                     /* bsp file version */\r
860 +       qfalse,                         /* cod-style lump len/ofs order */\r
861 +       LoadIBSPFile,           /* bsp load function */\r
862 +       WriteIBSPFile,          /* bsp write function */\r
863 +\r
864 +       {\r
865 +               /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */\r
866 +               \r
867 +               /* default */\r
868 +               { "default",            Q_CONT_SOLID,                           -1,                                                     0,                                                      -1,                                                     C_SOLID,                                        -1 },\r
869 +               \r
870 +               \r
871 +               /* ydnar */\r
872 +               { "lightgrid",          0,                                                      0,                                                      0,                                                      0,                                                      C_LIGHTGRID,                            0 },\r
873 +               { "antiportal",         0,                                                      0,                                                      0,                                                      0,                                                      C_ANTIPORTAL,                           0 },\r
874 +               { "skip",                       0,                                                      0,                                                      0,                                                      0,                                                      C_SKIP,                                         0 },\r
875 +               \r
876 +               \r
877 +               /* compiler */\r
878 +               { "origin",                     Q_CONT_ORIGIN,                          Q_CONT_SOLID,                           0,                                                      0,                                                      C_ORIGIN | C_TRANSLUCENT,       C_SOLID },\r
879 +               { "areaportal",         Q_CONT_AREAPORTAL,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },\r
880 +               { "trans",                      Q_CONT_TRANSLUCENT,                     0,                                                      0,                                                      0,                                                      C_TRANSLUCENT,                          0 },\r
881 +               { "detail",                     Q_CONT_DETAIL,                          0,                                                      0,                                                      0,                                                      C_DETAIL,                                       0 },\r
882 +               { "structural",         Q_CONT_STRUCTURAL,                      0,                                                      0,                                                      0,                                                      C_STRUCTURAL,                           0 },\r
883 +               { "hint",                       0,                                                      0,                                                      Q_SURF_HINT,                            0,                                                      C_HINT,                                         0 },\r
884 +               { "nodraw",                     0,                                                      0,                                                      Q_SURF_NODRAW,                          0,                                                      C_NODRAW,                                       0 },\r
885 +               \r
886 +               { "alphashadow",        0,                                                      0,                                                      Q_SURF_ALPHASHADOW,                     0,                                                      C_ALPHASHADOW | C_TRANSLUCENT,  0 },\r
887 +               { "lightfilter",        0,                                                      0,                                                      Q_SURF_LIGHTFILTER,                     0,                                                      C_LIGHTFILTER | C_TRANSLUCENT,  0 },\r
888 +               { "nolightmap",         0,                                                      0,                                                      Q_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },\r
889 +               { "pointlight",         0,                                                      0,                                                      Q_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },\r
890 +               \r
891 +               \r
892 +               /* game */\r
893 +               { "nonsolid",           0,                                                      Q_CONT_SOLID,                           Q_SURF_NONSOLID,                        0,                                                      0,                                                      C_SOLID },\r
894 +               \r
895 +               { "trigger",            Q_CONT_TRIGGER,                         Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
896 +               \r
897 +               { "water",                      Q_CONT_WATER,                           Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
898 +               { "slime",                      Q_CONT_SLIME,                           Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
899 +               { "lava",                       Q_CONT_LAVA,                            Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
900 +               \r
901 +               { "playerclip",         Q_CONT_PLAYERCLIP,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },\r
902 +               { "monsterclip",        Q_CONT_MONSTERCLIP,                     Q_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },\r
903 +               { "nodrop",                     Q_CONT_NODROP,                          Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
904 +               \r
905 +               { "clusterportal",      Q_CONT_CLUSTERPORTAL,           Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
906 +               { "donotenter",         Q_CONT_DONOTENTER,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
907 +               { "botclip",            Q_CONT_BOTCLIP,                         Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
908 +               \r
909 +               { "fog",                        Q_CONT_FOG,                                     Q_CONT_SOLID,                           0,                                                      0,                                                      C_FOG,                                          C_SOLID },\r
910 +               { "sky",                        0,                                                      0,                                                      Q_SURF_SKY,                                     0,                                                      C_SKY,                                          0 },\r
911 +               \r
912 +               { "slick",                      0,                                                      0,                                                      Q_SURF_SLICK,                           0,                                                      0,                                                      0 },\r
913 +               \r
914 +               { "noimpact",           0,                                                      0,                                                      Q_SURF_NOIMPACT,                        0,                                                      0,                                                      0 },\r
915 +               { "nomarks",            0,                                                      0,                                                      Q_SURF_NOMARKS,                         0,                                                      C_NOMARKS,                                      0 },\r
916 +               { "ladder",                     0,                                                      0,                                                      Q_SURF_LADDER,                          0,                                                      0,                                                      0 },\r
917 +               { "nodamage",           0,                                                      0,                                                      Q_SURF_NODAMAGE,                        0,                                                      0,                                                      0 },\r
918 +               { "metalsteps",         0,                                                      0,                                                      Q_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },\r
919 +               { "flesh",                      0,                                                      0,                                                      Q_SURF_FLESH,                           0,                                                      0,                                                      0 },\r
920 +               { "nosteps",            0,                                                      0,                                                      Q_SURF_NOSTEPS,                         0,                                                      0,                                                      0 },\r
921 +               { "nodlight",           0,                                                      0,                                                      Q_SURF_NODLIGHT,                        0,                                                      0,                                                      0 },\r
922 +               { "dust",                       0,                                                      0,                                                      Q_SURF_DUST,                            0,                                                      0,                                                      0 },\r
923 +               \r
924 +               \r
925 +               /* tremulous */\r
926 +               {"noalienbuild",                        TREM_CONT_NOALIENBUILD,0,0,0,0,0},\r
927 +               {"nohumanbuild",                        TREM_CONT_NOHUMANBUILD,0,0,0,0,0},\r
928 +               {"nobuild",                                     TREM_CONT_NOBUILD,0,0,0,0,0},\r
929 +               \r
930 +               {"noalienbuildsurface", 0,0,TREM_SURF_NOALIENBUILDSURFACE,0,0,0},\r
931 +               {"nohumanbuildsurface", 0,0,TREM_SURF_NOHUMANBUILDSURFACE,0,0,0},\r
932 +               {"nobuildsurface",              0,0,TREM_SURF_NOBUILDSURFACE,0,0,0},\r
933 +               \r
934 +               \r
935 +               /* null */\r
936 +               { NULL, 0, 0, 0, 0, 0, 0 }\r
937 +       }\r
938 +}\r
939 +\r
940 +\r
941 +\r
942 +/* end marker */\r
943 +#endif\r
944 +\r
945 Index: game_wolf.h\r
946 ===================================================================\r
947 --- game_wolf.h (revision 158)\r
948 +++ game_wolf.h (working copy)\r
949 @@ -129,7 +129,16 @@\r
950         qtrue,                          /* wolf lighting model? */
951         128,                            /* lightmap width/height */
952         1.0f,                           /* lightmap gamma */
953 +       1.0f,                           /* lightmap exposure */
954         1.0f,                           /* lightmap compensate */
955 +       1.0f,                           /* lightgrid scale */
956 +       1.0f,                           /* lightgrid ambient scale */
957 +       qfalse,                         /* disable shader lightstyles hack */
958 +       qfalse,                         /* keep light entities on bsp */
959 +       8,                                      /* default patchMeta subdivisions tolerance */
960 +       qfalse,                         /* patch casting enabled */
961 +       qfalse,                         /* compile deluxemaps */
962 +       0,                                      /* deluxemaps default mode */
963         "IBSP",                         /* bsp file prefix */
964         47,                                     /* bsp file version */
965         qfalse,                         /* cod-style lump len/ofs order */
966 Index: game_wolfet.h\r
967 ===================================================================\r
968 --- game_wolfet.h       (revision 158)\r
969 +++ game_wolfet.h       (working copy)\r
970 @@ -66,7 +66,16 @@\r
971         qtrue,                          /* wolf lighting model? */
972         128,                            /* lightmap width/height */
973         1.0f,                           /* lightmap gamma */
974 +       1.0f,                           /* lightmap exposure */
975         1.0f,                           /* lightmap compensate */
976 +       1.0f,                           /* lightgrid scale */
977 +       1.0f,                           /* lightgrid ambient scale */
978 +       qfalse,                         /* disable shader lightstyles hack */
979 +       qfalse,                         /* keep light entities on bsp */
980 +       8,                                      /* default patchMeta subdivisions tolerance */
981 +       qfalse,                         /* patch casting enabled */
982 +       qfalse,                         /* compile deluxemaps */
983 +       0,                                      /* deluxemaps default mode */
984         "IBSP",                         /* bsp file prefix */
985         47,                                     /* bsp file version */
986         qfalse,                         /* cod-style lump len/ofs order */
987 Index: light.c\r
988 ===================================================================\r
989 --- light.c     (revision 158)\r
990 +++ light.c     (working copy)\r
991 @@ -313,7 +313,15 @@\r
992                         flags |= LIGHT_GRID;
993                         flags &= ~LIGHT_SURFACES;
994                 }
995 -               
996 +
997 +               /* vortex: unnormalized? */
998 +               if (spawnflags & 32)
999 +                       flags |= LIGHT_UNNORMALIZED;
1000 +
1001 +               /* vortex: distance atten? */
1002 +               if (spawnflags & 64)
1003 +                       flags |= LIGHT_ATTEN_DISTANCE;
1004 +
1005                 /* store the flags */
1006                 light->flags = flags;
1007                 
1008 @@ -357,12 +365,13 @@\r
1009                 intensity *= scale;
1010                 
1011                 /* ydnar: get deviance and samples */
1012 +               /* VorteX: now set start value for _samples when _deviance is found */
1013                 deviance = FloatForKey( e, "_deviance" );
1014                 if( deviance == 0.0f )
1015                         deviance = FloatForKey( e, "_deviation" );
1016                 if( deviance == 0.0f )
1017                         deviance = FloatForKey( e, "_jitter" );
1018 -               numSamples = IntForKey( e, "_samples" );
1019 +               numSamples = max(IntForKey( e, "_samples" ), deviance);
1020                 if( deviance < 0.0f || numSamples < 1 )
1021                 {
1022                         deviance = 0.0f;
1023 @@ -385,14 +394,16 @@\r
1024                 if( _color && _color[ 0 ] )
1025                 {
1026                         sscanf( _color, "%f %f %f", &light->color[ 0 ], &light->color[ 1 ], &light->color[ 2 ] );
1027 -                       ColorNormalize( light->color, light->color );
1028 +                       if (!(light->flags & LIGHT_UNNORMALIZED))
1029 +                       {
1030 +                               ColorNormalize( light->color, light->color );
1031 +                       }
1032                 }
1033                 else
1034                         light->color[ 0 ] = light->color[ 1 ] = light->color[ 2 ] = 1.0f;
1035 -               
1036 +
1037                 intensity = intensity * pointScale;
1038                 light->photons = intensity;
1039 -               
1040                 light->type = EMIT_POINT;
1041                 
1042                 /* set falloff threshold */
1043 @@ -741,6 +752,7 @@\r
1044         
1045         /* clear color */
1046         VectorClear( trace->color );
1047 +       VectorClear( trace->colorNoShadow );
1048         
1049         /* ydnar: early out */
1050         if( !(light->flags & LIGHT_SURFACES) || light->envelope <= 0.0f )
1051 @@ -766,7 +778,6 @@\r
1052                 float           d;
1053                 vec3_t          pushedOrigin;
1054                 
1055 -               
1056                 /* project sample point into light plane */
1057                 d = DotProduct( trace->origin, light->normal ) - light->dist;
1058                 if( d < 3.0f )
1059 @@ -881,8 +892,7 @@\r
1060                 {
1061                         float   distByNormal, radiusAtDist, sampleRadius;
1062                         vec3_t  pointAtDist, distToSample;
1063 -                       
1064 -                       
1065 +       
1066                         /* do cone calculation */
1067                         distByNormal = -DotProduct( trace->displacement, light->normal );
1068                         if( distByNormal < 0.0f )
1069 @@ -922,6 +932,9 @@\r
1070                 add = light->photons * angle;
1071                 if( add <= 0.0f )
1072                         return 0;
1073 +
1074 +               /* VorteX: set noShadow color */
1075 +               VectorScale(light->color, add, trace->colorNoShadow);
1076                 
1077                 /* setup trace */
1078                 trace->testAll = qtrue;
1079 @@ -942,6 +955,9 @@\r
1080                 /* return to sender */
1081                 return 1;
1082         }
1083 +
1084 +       /* VorteX: set noShadow color */
1085 +       VectorScale(light->color, add, trace->colorNoShadow);
1086         
1087         /* ydnar: changed to a variable number */
1088         if( add <= 0.0f || (add <= light->falloffTolerance && (light->flags & LIGHT_FAST_ACTUAL)) )
1089 @@ -1378,6 +1394,56 @@\r
1090                         break;
1091         }
1092         
1093 +       /////// Floodlighting for point //////////////////
1094 +       //do our floodlight ambient occlusion loop, and add a single contribution based on the brightest dir
1095 +       if (floodlighty)
1096 +       {
1097 +               int q;
1098 +               float addSize,f;
1099 +               vec3_t col,dir;
1100 +               col[0]=col[1]=col[2]=floodlightIntensity;
1101 +               dir[0]=dir[1]=0;
1102 +               dir[2]=1;
1103 +      
1104 +               trace.testOcclusion = qtrue;
1105 +               trace.forceSunlight = qfalse;
1106 +               trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS;
1107 +               trace.testAll = qtrue;     
1108 +      
1109 +               for (q=0;q<2;q++)
1110 +               {
1111 +                       if (q==0) //upper hemisphere
1112 +                       {
1113 +                               trace.normal[0]=0;
1114 +                               trace.normal[1]=0;
1115 +                               trace.normal[2]=1;
1116 +                       }
1117 +                       else //lower hemisphere
1118 +                       {
1119 +                               trace.normal[0]=0;
1120 +                               trace.normal[1]=0;
1121 +                               trace.normal[2]=-1;
1122 +                       }
1123 +
1124 +                       f = FloodLightForSample(&trace, floodlightDistance, floodlight_lowquality);
1125 +
1126 +                       contributions[ numCon ].color[0]=col[0]*f;
1127 +                       contributions[ numCon ].color[1]=col[1]*f;
1128 +                       contributions[ numCon ].color[2]=col[2]*f;
1129 +
1130 +                       contributions[ numCon ].dir[0]=dir[0];
1131 +                       contributions[ numCon ].dir[1]=dir[1];
1132 +                       contributions[ numCon ].dir[2]=dir[2];
1133 +
1134 +                       contributions[ numCon ].style = 0;
1135 +                       numCon++;               
1136 +                       /* push average direction around */
1137 +                       addSize = VectorLength( col );
1138 +                       VectorMA( gp->dir, addSize, dir, gp->dir );
1139 +               }
1140 +       }
1141 +       /////////////////////
1142 +
1143         /* normalize to get primary light direction */
1144         VectorNormalize( gp->dir, gp->dir );
1145         
1146 @@ -1420,6 +1486,9 @@\r
1147                 
1148                 /* ambient light will be at 1/4 the value of directed light */
1149                 /* (ydnar: nuke this in favor of more dramatic lighting?) */
1150 +               /* (PM: how about actually making it work? d=1 when it got here for single lights/sun :P */
1151 +//             d = 0.25f;
1152 +               /* (Hobbes: always setting it to .25 is hardly any better) */
1153                 d = 0.25f * (1.0f - d);
1154                 VectorMA( gp->ambient[ j ], d, contributions[ i ].color, gp->ambient[ j ] );
1155         }
1156 @@ -1437,8 +1506,10 @@\r
1157                 for( j = 0; j < 3; j++ )
1158                         if( color[ j ] < minGridLight[ j ] )
1159                                 color[ j ] = minGridLight[ j ];
1160 -               ColorToBytes( color, bgp->ambient[ i ], 1.0f );
1161 -               ColorToBytes( gp->directed[ i ], bgp->directed[ i ], 1.0f );
1162 +
1163 +               /* vortex: apply gridscale and gridambientscale here */
1164 +               ColorToBytes( color, bgp->ambient[ i ], gridScale*gridAmbientScale );
1165 +               ColorToBytes( gp->directed[ i ], bgp->directed[ i ], gridScale );
1166         }
1167         
1168         /* debug code */
1169 @@ -1654,14 +1725,12 @@\r
1170         if( dirty )
1171         {
1172                 Sys_Printf( "--- DirtyRawLightmap ---\n" );
1173 -
1174 -
1175 -
1176 -
1177                 RunThreadsOnIndividual( numRawLightmaps, qtrue, DirtyRawLightmap );
1178         }
1179 -       
1180  
1181 +       /* floodlight pass */
1182 +       FloodlightRawLightmaps();
1183 +
1184         /* ydnar: set up light envelopes */
1185         SetupEnvelopes( qfalse, fast );
1186         
1187 @@ -1774,12 +1843,64 @@\r
1188         
1189         /* note it */
1190         Sys_Printf( "--- Light ---\n" );
1191 -       
1192 +       Sys_Printf( "--- ProcessGameSpecific ---\n" );
1193 +
1194         /* set standard game flags */
1195         wolfLight = game->wolfLight;
1196 +       if (wolfLight == qtrue)
1197 +               Sys_Printf( " lightning model: wolf\n" );
1198 +       else
1199 +               Sys_Printf( " lightning model: quake3\n" );
1200 +
1201         lmCustomSize = game->lightmapSize;
1202 +       Sys_Printf( " lightmap size: %d x %d pixels\n", lmCustomSize, lmCustomSize );
1203 +
1204         lightmapGamma = game->lightmapGamma;
1205 +       Sys_Printf( " lightning gamma: %f\n", lightmapGamma );
1206 +
1207         lightmapCompensate = game->lightmapCompensate;
1208 +       Sys_Printf( " lightning compensation: %f\n", lightmapCompensate );
1209 +
1210 +       lightmapExposure = game->lightmapExposure;
1211 +       Sys_Printf( " lightning exposure: %f\n", lightmapExposure );
1212 +
1213 +       gridScale = game->gridScale;
1214 +       Sys_Printf( " lightgrid scale: %f\n", gridScale );
1215 +
1216 +       gridAmbientScale = game->gridAmbientScale;
1217 +       Sys_Printf( " lightgrid ambient scale: %f\n", gridAmbientScale );
1218 +
1219 +       noStyles = game->noStyles;
1220 +       if (noStyles == qtrue)
1221 +               Sys_Printf( " shader lightstyles hack: disabled\n" );
1222 +       else
1223 +               Sys_Printf( " shader lightstyles hack: enabled\n" );
1224 +
1225 +       keepLights = game->keepLights;
1226 +       if (keepLights == qtrue)
1227 +               Sys_Printf( " keep lights: enabled\n" );
1228 +       else
1229 +               Sys_Printf( " keep lights: disabled\n" );
1230 +
1231 +       patchShadows = game->patchShadows;
1232 +       if (patchShadows == qtrue)
1233 +               Sys_Printf( " patch shadows: enabled\n" );
1234 +       else
1235 +               Sys_Printf( " patch shadows: disabled\n" );
1236 +
1237 +       deluxemap = game->deluxeMap;
1238 +       deluxemode = game->deluxeMode;
1239 +       if (deluxemap == qtrue)
1240 +       {
1241 +               if (deluxemode)
1242 +                       Sys_Printf( " deluxemapping: enabled with tangentspace deluxemaps\n" );
1243 +               else
1244 +                       Sys_Printf( " deluxemapping: enabled with modelspace deluxemaps\n" );
1245 +       }
1246 +       else
1247 +               Sys_Printf( " deluxemapping: disabled\n" );
1248 +
1249 +       Sys_Printf( "--- ProcessCommandLine ---\n" );
1250         
1251         /* process commandline arguments */
1252         for( i = 1; i < (argc - 1); i++ )
1253 @@ -1827,6 +1948,22 @@\r
1254                         Sys_Printf( "All light scaled by %f\n", f );
1255                         i++;
1256                 }
1257 +
1258 +               else if( !strcmp( argv[ i ], "-gridscale" ) )
1259 +               {
1260 +                       f = atof( argv[ i + 1 ] );
1261 +                       Sys_Printf( "Grid lightning scaled by %f\n", f );
1262 +                       gridScale *= f;
1263 +                       i++;
1264 +               }
1265 +
1266 +               else if( !strcmp( argv[ i ], "-gridambientscale" ) )
1267 +               {
1268 +                       f = atof( argv[ i + 1 ] );
1269 +                       Sys_Printf( "Grid ambient lightning scaled by %f\n", f );
1270 +                       gridAmbientScale *= f;
1271 +                       i++;
1272 +               }
1273                 
1274                 else if( !strcmp( argv[ i ], "-gamma" ) )
1275                 {
1276 @@ -1836,6 +1973,14 @@\r
1277                         i++;
1278                 }
1279                 
1280 +               else if( !strcmp( argv[ i ], "-exposure" ) )
1281 +               {
1282 +                       f = atof( argv[ i + 1 ] );
1283 +                       lightmapExposure = f;
1284 +                       Sys_Printf( "Lighting exposure set to %f\n", lightmapExposure );
1285 +                       i++;
1286 +               }
1287 +               
1288                 else if( !strcmp( argv[ i ], "-compensate" ) )
1289                 {
1290                         f = atof( argv[ i + 1 ] );
1291 @@ -1889,12 +2034,6 @@\r
1292                         Sys_Printf( "Dark lightmap seams enabled\n" );
1293                 }
1294                 
1295 -
1296 -
1297 -
1298 -
1299 -
1300 -
1301                 else if( !strcmp( argv[ i ], "-shadeangle" ) )
1302                 {
1303                         shadeAngleDegrees = atof( argv[ i + 1 ] );
1304 @@ -1927,13 +2066,28 @@\r
1305                                 Sys_Printf( "Approximating lightmaps within a byte tolerance of %d\n", approximateTolerance );
1306                         i++;
1307                 }
1308 -               
1309                 else if( !strcmp( argv[ i ], "-deluxe" ) || !strcmp( argv[ i ], "-deluxemap" ) )
1310                 {
1311                         deluxemap = qtrue;
1312                         Sys_Printf( "Generating deluxemaps for average light direction\n" );
1313                 }
1314 -               
1315 +               else if( !strcmp( argv[ i ], "-deluxemode" ))
1316 +               {
1317 +                       deluxemode = atoi( argv[ i + 1 ] );
1318 +                       if (deluxemode == 0 || deluxemode > 1 || deluxemode < 0)
1319 +                       {
1320 +                               Sys_Printf( "Generating modelspace deluxemaps\n" );
1321 +                               deluxemode = 0;
1322 +                       }
1323 +                       else 
1324 +                               Sys_Printf( "Generating tangentspace deluxemaps\n" );
1325 +                       i++;
1326 +               }
1327 +               else if( !strcmp( argv[ i ], "-nodeluxe" ) || !strcmp( argv[ i ], "-nodeluxemap" ) )
1328 +               {
1329 +                       deluxemap = qfalse;
1330 +                       Sys_Printf( "Disabling generating of deluxemaps for average light direction\n" );
1331 +               }
1332                 else if( !strcmp( argv[ i ], "-external" ) )
1333                 {
1334                         externalLightmaps = qtrue;
1335 @@ -2151,6 +2305,12 @@\r
1336                         i++;
1337                         Sys_Printf( "Default lightmap sample size set to %dx%d units\n", sampleSize, sampleSize );
1338                 }
1339 +               else if( !strcmp( argv[ i ],  "-samplescale" ) )
1340 +               {
1341 +                       sampleScale = atoi( argv[ i + 1 ] );
1342 +                       i++;
1343 +                       Sys_Printf( "Lightmaps sample scale set to %d\n", sampleScale);
1344 +               }
1345                 else if( !strcmp( argv[ i ], "-novertex" ) )
1346                 {
1347                         noVertexLighting = qtrue;
1348 @@ -2186,11 +2346,36 @@\r
1349                         noStyles = qtrue;
1350                         Sys_Printf( "Disabling lightstyles\n" );
1351                 }
1352 +               else if( !strcmp( argv[ i ], "-style" ) || !strcmp( argv[ i ], "-styles" ) )
1353 +               {
1354 +                       noStyles = qfalse;
1355 +                       Sys_Printf( "Enabling lightstyles\n" );
1356 +               }
1357 +               else if( !strcmp( argv[ i ], "-keeplights" ))
1358 +               {
1359 +                       keepLights = qtrue;
1360 +                       Sys_Printf( "Leaving light entities on map after compile\n" );
1361 +               }
1362                 else if( !strcmp( argv[ i ], "-cpma" ) )
1363                 {
1364                         cpmaHack = qtrue;
1365                         Sys_Printf( "Enabling Challenge Pro Mode Asstacular Vertex Lighting Mode (tm)\n" );
1366                 }
1367 +               else if( !strcmp( argv[ i ], "-floodlight" ) )
1368 +               {
1369 +                       floodlighty = qtrue;
1370 +                       Sys_Printf( "FloodLighting enabled\n" );
1371 +               }
1372 +               else if( !strcmp( argv[ i ], "-debugnormals" ) )
1373 +               {
1374 +                       debugnormals = qtrue;
1375 +                       Sys_Printf( "DebugNormals enabled\n" );
1376 +               }
1377 +               else if( !strcmp( argv[ i ], "-lowquality" ) )
1378 +               {
1379 +                       floodlight_lowquality = qtrue;
1380 +                       Sys_Printf( "Low Quality FloodLighting enabled\n" );
1381 +               }
1382                 
1383                 /* r7: dirtmapping */
1384                 else if( !strcmp( argv[ i ], "-dirty" ) )
1385 @@ -2212,6 +2397,7 @@\r
1386                                 Sys_Printf( "Enabling randomized dirtmapping\n" );
1387                         else
1388                                 Sys_Printf( "Enabling ordered dir mapping\n" );
1389 +                       i++;
1390                 }
1391                 else if( !strcmp( argv[ i ], "-dirtdepth" ) )
1392                 {
1393 @@ -2219,6 +2405,7 @@\r
1394                         if( dirtDepth <= 0.0f )
1395                                 dirtDepth = 128.0f;
1396                         Sys_Printf( "Dirtmapping depth set to %.1f\n", dirtDepth );
1397 +                       i++;
1398                 }
1399                 else if( !strcmp( argv[ i ], "-dirtscale" ) )
1400                 {
1401 @@ -2226,6 +2413,7 @@\r
1402                         if( dirtScale <= 0.0f )
1403                                 dirtScale = 1.0f;
1404                         Sys_Printf( "Dirtmapping scale set to %.1f\n", dirtScale );
1405 +                       i++;
1406                 }
1407                 else if( !strcmp( argv[ i ], "-dirtgain" ) )
1408                 {
1409 @@ -2233,6 +2421,7 @@\r
1410                         if( dirtGain <= 0.0f )
1411                                 dirtGain = 1.0f;
1412                         Sys_Printf( "Dirtmapping gain set to %.1f\n", dirtGain );
1413 +                       i++;
1414                 }
1415                 
1416                 /* unhandled args */
1417 @@ -2279,6 +2468,7 @@\r
1418         /* ydnar: set up optimization */
1419         SetupBrushes();
1420         SetupDirt();
1421 +       SetupFloodLight();
1422         SetupSurfaceLightmaps();
1423         
1424         /* initialize the surface facet tracing */
1425 Index: light_bounce.c\r
1426 ===================================================================\r
1427 --- light_bounce.c      (revision 158)\r
1428 +++ light_bounce.c      (working copy)\r
1429 @@ -510,7 +510,7 @@\r
1430                         break;
1431                 
1432                 case MST_TRIANGLE_SOUP:
1433 -                       numTriangleDiffuseLights;
1434 +                       numTriangleDiffuseLights++;
1435                         break;
1436                 
1437                 case MST_PATCH:
1438 Index: light_trace.c\r
1439 ===================================================================\r
1440 --- light_trace.c       (revision 158)\r
1441 +++ light_trace.c       (working copy)\r
1442 @@ -56,7 +56,7 @@\r
1443  #define GROW_TRACE_NODES               16384           //%     16384
1444  #define GROW_NODE_ITEMS                        16                      //%     256
1445  
1446 -#define MAX_TW_VERTS                   12
1447 +#define MAX_TW_VERTS                   24 // vortex: increased from 12 to 24 for ability co compile some insane maps with large curve count
1448  
1449  #define        TRACE_ON_EPSILON                0.1f
1450  
1451 Index: light_ydnar.c\r
1452 ===================================================================\r
1453 --- light_ydnar.c       (revision 158)\r
1454 +++ light_ydnar.c       (working copy)\r
1455 @@ -49,6 +49,7 @@\r
1456         int             i;
1457         float   max, gamma;
1458         vec3_t  sample;
1459 +       float   inv, dif;
1460         
1461         
1462         /* ydnar: scaling necessary for simulating r_overbrightBits on external lightmaps */
1463 @@ -72,16 +73,51 @@\r
1464                 /* gamma */
1465                 sample[ i ] = pow( sample[ i ] / 255.0f, gamma ) * 255.0f;
1466         }
1467 +
1468 +       if (lightmapExposure == 1)
1469 +       {
1470 +               /* clamp with color normalization */
1471 +               max = sample[ 0 ];
1472 +               if( sample[ 1 ] > max )
1473 +                       max = sample[ 1 ];
1474 +               if( sample[ 2 ] > max )
1475 +                       max = sample[ 2 ];
1476 +               if( max > 255.0f )
1477 +                       VectorScale( sample, (255.0f / max), sample );
1478 +       }
1479 +       else
1480 +       {
1481 +               if (lightmapExposure==0)
1482 +               {
1483 +                       lightmapExposure=1.0f;
1484 +               }
1485 +               inv=1.f/lightmapExposure;
1486 +               //Exposure
1487 +       
1488 +               max = sample[ 0 ];
1489 +               if( sample[ 1 ] > max )
1490 +                       max = sample[ 1 ];
1491 +               if( sample[ 2 ] > max )
1492 +                       max = sample[ 2 ];  
1493 +      
1494 +               dif = (1-  exp(-max * inv) )  *  255;
1495 +
1496 +               if (max >0) 
1497 +               {
1498 +                       dif = dif / max;
1499 +               }
1500 +               else
1501 +               {
1502 +                       dif = 0;
1503 +               }
1504 +
1505 +               for (i=0;i<3;i++)
1506 +               {
1507 +                       sample[i]*=dif;
1508 +               }
1509 +       }
1510 +
1511         
1512 -       /* clamp with color normalization */
1513 -       max = sample[ 0 ];
1514 -       if( sample[ 1 ] > max )
1515 -               max = sample[ 1 ];
1516 -       if( sample[ 2 ] > max )
1517 -               max = sample[ 2 ];
1518 -       if( max > 255.0f )
1519 -               VectorScale( sample, (255.0f / max), sample );
1520 -       
1521         /* compensate for ingame overbrighting/bitshifting */
1522         VectorScale( sample, (1.0f / lightmapCompensate), sample );
1523         
1524 @@ -384,7 +420,7 @@\r
1525  #define NUDGE                  0.5f
1526  #define BOGUS_NUDGE            -99999.0f
1527  
1528 -static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *dv, vec4_t plane, float pass, vec3_t stv[ 3 ], vec3_t ttv[ 3 ] )
1529 +static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *dv, vec4_t plane, float pass, vec3_t stv[ 3 ], vec3_t ttv[ 3 ], vec3_t worldverts[ 3 ] )
1530  {
1531         int                             i, x, y, numClusters, *clusters, pointCluster, *cluster;
1532         float                   *luxel, *origin, *normal, d, lightmapSampleOffset;
1533 @@ -392,6 +428,12 @@\r
1534         vec3_t                  pNormal;
1535         vec3_t                  vecs[ 3 ];
1536         vec3_t                  nudged;
1537 +       vec3_t                  cverts[ 3 ];
1538 +       vec3_t                  temp;
1539 +       vec4_t                  sideplane, hostplane;
1540 +       vec3_t                  origintwo;
1541 +       int                             j, next;
1542 +       float                   e;
1543         float                   *nudge;
1544         static float    nudges[][ 2 ] =
1545                                         {
1546 @@ -485,6 +527,51 @@\r
1547         /* non axial lightmap projection (explicit xyz) */
1548         else
1549                 VectorCopy( dv->xyz, origin );
1550 +
1551 +       //////////////////////
1552 +       //27's test to make sure samples stay within the triangle boundaries
1553 +       //1) Test the sample origin to see if it lays on the wrong side of any edge (x/y)
1554 +       //2) if it does, nudge it onto the correct side.
1555 +
1556 +       if (worldverts!=NULL)
1557 +       {
1558 +               for (j=0;j<3;j++)
1559 +               {
1560 +                       VectorCopy(worldverts[j],cverts[j]);    
1561 +               }
1562 +               PlaneFromPoints(hostplane,cverts[0],cverts[1],cverts[2]);
1563 +
1564 +               for (j=0;j<3;j++)
1565 +               {
1566 +                       for (i=0;i<3;i++)
1567 +                       {
1568 +                               //build plane using 2 edges and a normal
1569 +                               next=(i+1)%3;
1570 +
1571 +                               VectorCopy(cverts[next],temp);
1572 +                               VectorAdd(temp,hostplane,temp);
1573 +                               PlaneFromPoints(sideplane,cverts[i],cverts[ next ], temp);
1574 +
1575 +                               //planetest sample point  
1576 +                               e=DotProduct(origin,sideplane);
1577 +                               e=e-sideplane[3];
1578 +                               if (e>0)
1579 +                               {
1580 +                                       //we're bad.
1581 +                                       //VectorClear(origin);
1582 +                                       //Move the sample point back inside triangle bounds
1583 +                                       origin[0]-=sideplane[0]*(e+1);
1584 +                                       origin[1]-=sideplane[1]*(e+1);
1585 +                                       origin[2]-=sideplane[2]*(e+1);
1586 +#ifdef DEBUG_27_1
1587 +                                       VectorClear(origin);
1588 +#endif 
1589 +                               }
1590 +                       }
1591 +               }
1592 +       }
1593 +
1594 +       ////////////////////////
1595         
1596         /* planar surfaces have precalculated lightmap vectors for nudging */
1597         if( lm->plane != NULL )
1598 @@ -516,8 +603,13 @@\r
1599         else
1600                 origin[ lm->axisNum ] += lightmapSampleOffset;
1601         
1602 +       VectorCopy(origin,origintwo);
1603 +       origintwo[0]+=vecs[2][0];
1604 +       origintwo[1]+=vecs[2][1];
1605 +       origintwo[2]+=vecs[2][2];
1606 +       
1607         /* get cluster */
1608 -       pointCluster = ClusterForPointExtFilter( origin, LUXEL_EPSILON, numClusters, clusters );
1609 +       pointCluster = ClusterForPointExtFilter( origintwo, LUXEL_EPSILON, numClusters, clusters );
1610         
1611         /* another retarded hack, storing nudge count in luxel[ 1 ] */
1612         luxel[ 1 ] = 0.0f;      
1613 @@ -533,14 +625,14 @@\r
1614                         for( i = 0; i < 3; i++ )
1615                         {
1616                                 /* set nudged point*/
1617 -                               nudged[ i ] = origin[ i ] + (nudge[ 0 ] * vecs[ 0 ][ i ]) + (nudge[ 1 ] * vecs[ 1 ][ i ]);
1618 +                               nudged[ i ] = origintwo[ i ] + (nudge[ 0 ] * vecs[ 0 ][ i ]) + (nudge[ 1 ] * vecs[ 1 ][ i ]);
1619                         }
1620                         nudge += 2;
1621                         
1622                         /* get pvs cluster */
1623                         pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters ); //% + 0.625 );
1624 -                       if( pointCluster >= 0 ) 
1625 -                               VectorCopy( nudged, origin );
1626 +                       //if( pointCluster >= 0 )       
1627 +                       //      VectorCopy( nudged, origin );
1628                         luxel[ 1 ] += 1.0f;
1629                 }
1630         }
1631 @@ -550,8 +642,8 @@\r
1632         {
1633                 VectorMA( dv->xyz, lightmapSampleOffset, dv->normal, nudged );
1634                 pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters );
1635 -               if( pointCluster >= 0 )
1636 -                       VectorCopy( nudged, origin );
1637 +               //if( pointCluster >= 0 )
1638 +               //      VectorCopy( nudged, origin );
1639                 luxel[ 1 ] += 1.0f;
1640         }
1641         
1642 @@ -597,7 +689,7 @@\r
1643  than the distance between two luxels (thanks jc :)
1644  */
1645  
1646 -static void MapTriangle_r( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *dv[ 3 ], vec4_t plane, vec3_t stv[ 3 ], vec3_t ttv[ 3 ] )
1647 +static void MapTriangle_r( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *dv[ 3 ], vec4_t plane, vec3_t stv[ 3 ], vec3_t ttv[ 3 ], vec3_t worldverts[ 3 ] )
1648  {
1649         bspDrawVert_t   mid, *dv2[ 3 ];
1650         int                             max;
1651 @@ -645,7 +737,7 @@\r
1652         
1653         /* split the longest edge and map it */
1654         LerpDrawVert( dv[ max ], dv[ (max + 1) % 3 ], &mid );
1655 -       MapSingleLuxel( lm, info, &mid, plane, 1, stv, ttv );
1656 +       MapSingleLuxel( lm, info, &mid, plane, 1, stv, ttv, worldverts );
1657         
1658         /* push the point up a little bit to account for fp creep (fixme: revisit this) */
1659         //%     VectorMA( mid.xyz, 2.0f, mid.normal, mid.xyz );
1660 @@ -653,12 +745,12 @@\r
1661         /* recurse to first triangle */
1662         VectorCopy( dv, dv2 );
1663         dv2[ max ] = &mid;
1664 -       MapTriangle_r( lm, info, dv2, plane, stv, ttv );
1665 +       MapTriangle_r( lm, info, dv2, plane, stv, ttv, worldverts );
1666         
1667         /* recurse to second triangle */
1668         VectorCopy( dv, dv2 );
1669         dv2[ (max + 1) % 3 ] = &mid;
1670 -       MapTriangle_r( lm, info, dv2, plane, stv, ttv );
1671 +       MapTriangle_r( lm, info, dv2, plane, stv, ttv, worldverts );
1672  }
1673  
1674  
1675 @@ -674,8 +766,8 @@\r
1676         int                             i;
1677         vec4_t                  plane;
1678         vec3_t                  *stv, *ttv, stvStatic[ 3 ], ttvStatic[ 3 ];
1679 +       vec3_t                  worldverts[ 3 ];
1680         
1681 -       
1682         /* get plane if possible */
1683         if( lm->plane != NULL )
1684         {
1685 @@ -699,16 +791,20 @@\r
1686                 ttv = NULL;
1687         }
1688         
1689 +       VectorCopy( dv[ 0 ]->xyz, worldverts[ 0 ] );
1690 +       VectorCopy( dv[ 1 ]->xyz, worldverts[ 1 ] );
1691 +       VectorCopy( dv[ 2 ]->xyz, worldverts[ 2 ] );
1692 +       
1693         /* map the vertexes */
1694 -       MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv );
1695 -       MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv );
1696 -       MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv );
1697 +       MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv, worldverts );
1698 +       MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv, worldverts );
1699 +       MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv, worldverts );
1700         
1701         /* 2002-11-20: prefer axial triangle edges */
1702         if( mapNonAxial )
1703         {
1704                 /* subdivide the triangle */
1705 -               MapTriangle_r( lm, info, dv, plane, stv, ttv );
1706 +               MapTriangle_r( lm, info, dv, plane, stv, ttv, worldverts );
1707                 return qtrue;
1708         }
1709         
1710 @@ -730,7 +826,7 @@\r
1711                         dv2[ 2 ] = dv[ (i + 1) % 3 ];
1712                         
1713                         /* map the degenerate triangle */
1714 -                       MapTriangle_r( lm, info, dv2, plane, stv, ttv );
1715 +                       MapTriangle_r( lm, info, dv2, plane, stv, ttv, worldverts );
1716                 }
1717         }
1718         
1719 @@ -792,8 +888,8 @@\r
1720         LerpDrawVert( dv[ max + 2 ], dv[ (max + 3) % 4 ], &mid[ 1 ] );
1721         
1722         /* map the vertexes */
1723 -       MapSingleLuxel( lm, info, &mid[ 0 ], plane, 1, stv, ttv );
1724 -       MapSingleLuxel( lm, info, &mid[ 1 ], plane, 1, stv, ttv );
1725 +       MapSingleLuxel( lm, info, &mid[ 0 ], plane, 1, stv, ttv, NULL );
1726 +       MapSingleLuxel( lm, info, &mid[ 1 ], plane, 1, stv, ttv, NULL );
1727         
1728         /* 0 and 2 */
1729         if( max == 0 )
1730 @@ -848,7 +944,6 @@\r
1731         vec4_t                  plane;
1732         vec3_t                  *stv, *ttv, stvStatic[ 4 ], ttvStatic[ 4 ];
1733         
1734 -       
1735         /* get plane if possible */
1736         if( lm->plane != NULL )
1737         {
1738 @@ -878,18 +973,16 @@\r
1739         }
1740         
1741         /* map the vertexes */
1742 -       MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv );
1743 -       MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv );
1744 -       MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv );
1745 -       MapSingleLuxel( lm, info, dv[ 3 ], plane, 1, stv, ttv );
1746 +       MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv, NULL );
1747 +       MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv, NULL );
1748 +       MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv, NULL );
1749 +       MapSingleLuxel( lm, info, dv[ 3 ], plane, 1, stv, ttv, NULL );
1750         
1751         /* subdivide the quad */
1752         MapQuad_r( lm, info, dv, plane, stv, ttv );
1753         return qtrue;
1754  }
1755  
1756 -
1757 -
1758  /*
1759  MapRawLightmap()
1760  maps the locations, normals, and pvs clusters for a raw lightmap
1761 @@ -941,7 +1034,7 @@\r
1762                 num = lightSurfaces[ lm->firstLightSurface + n ];
1763                 ds = &bspDrawSurfaces[ num ];
1764                 info = &surfaceInfos[ num ];
1765 -               
1766 +
1767                 /* bail if no lightmap to calculate */
1768                 if( info->lm != lm )
1769                 {
1770 @@ -1173,7 +1266,7 @@\r
1771                                         continue;
1772                                 
1773                                 /* map the fake vert */
1774 -                               MapSingleLuxel( lm, NULL, &fake, lm->plane, pass, NULL, NULL );
1775 +                               MapSingleLuxel( lm, NULL, &fake, lm->plane, pass, NULL, NULL, NULL );
1776                         }
1777                 }
1778         }
1779 @@ -1596,7 +1689,6 @@\r
1780         
1781         VectorSubtract( origin2, origin, originVecs[ 0 ] );
1782         //%     VectorSubtract( normal2, normal, normalVecs[ 0 ] );
1783 -       
1784         /* calulate y vector */
1785         if( (y < (lm->sh - 1) && bx >= 0.0f) || (y == 0 && bx <= 0.0f) )
1786         {
1787 @@ -1660,7 +1752,6 @@\r
1788         float           biasDirs[ 4 ][ 2 ] = { { -1.0f, -1.0f }, { 1.0f, -1.0f }, { -1.0f, 1.0f }, { 1.0f, 1.0f } };
1789         vec3_t          color, total;
1790         
1791 -       
1792         /* limit check */
1793         if( lightLuxel[ 3 ] >= lightSamples )
1794                 return;
1795 @@ -1693,7 +1784,6 @@\r
1796                 VectorCopy( normal[ b ], trace->normal );
1797                 
1798                 /* sample light */
1799 -
1800                 LightContributionToSample( trace );
1801                 
1802                 /* add to totals (fixme: make contrast function) */
1803 @@ -1768,7 +1858,6 @@\r
1804         trace_t                         trace;
1805         float                           stackLightLuxels[ STACK_LL_SIZE ];
1806         
1807 -       
1808         /* bail if this number exceeds the number of raw lightmaps */
1809         if( rawLightmapNum >= numRawLightmaps )
1810                 return;
1811 @@ -1904,7 +1993,7 @@\r
1812                                 else
1813                                 {
1814                                         VectorCopy( ambientColor, luxel );
1815 -                                       if( deluxemap )
1816 +                                       if( deluxemap)
1817                                                 VectorScale( normal, 0.00390625f, deluxel );
1818                                         luxel[ 3 ] = 1.0f;
1819                                 }
1820 @@ -1963,28 +2052,39 @@\r
1821                                         deluxel = SUPER_DELUXEL( x, y );
1822                                         origin = SUPER_ORIGIN( x, y );
1823                                         normal = SUPER_NORMAL( x, y );
1824 -                                       
1825 -                                       /* set contribution count */
1826 -                                       lightLuxel[ 3 ] = 1.0f;
1827 -                                       
1828 -                                       /* setup trace */
1829 -                                       trace.cluster = *cluster;
1830 -                                       VectorCopy( origin, trace.origin );
1831 -                                       VectorCopy( normal, trace.normal );
1832 -                                       
1833 -                                       /* get light for this sample */
1834 -                                       LightContributionToSample( &trace );
1835 -                                       VectorCopy( trace.color, lightLuxel );
1836 -                                       
1837 -                                       /* add to count */
1838 -                                       if( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] )
1839 +
1840 +                                       ////////// 27's temp hack for testing edge clipping ////
1841 +                                       if( origin[0]==0 && origin[1]==0 && origin[2]==0 )
1842 +                                       {
1843 +                                               lightLuxel[ 1 ] = 255;
1844 +                                               lightLuxel[ 3 ] = 1.0f;
1845                                                 totalLighted++;
1846 +                                       }
1847 +                                       else
1848 +                                       {
1849 +                                               /* set contribution count */
1850 +                                               lightLuxel[ 3 ] = 1.0f;
1851 +                                               
1852 +                                               /* setup trace */
1853 +                                               trace.cluster = *cluster;
1854 +                                               VectorCopy( origin, trace.origin );
1855 +                                               VectorCopy( normal, trace.normal );
1856 +                                               
1857 +                                               /* get light for this sample */
1858 +                                               LightContributionToSample( &trace );
1859 +                                               VectorCopy( trace.color, lightLuxel );
1860 +                                               
1861 +                                               /* add to count */
1862 +                                               if( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] )
1863 +                                                       totalLighted++;
1864 +                                       }
1865                                         
1866                                         /* add to light direction map (fixme: use luxel normal as starting point for deluxel?) */
1867                                         if( deluxemap )
1868                                         {
1869 +                                               /* vortex: use noShadow color */
1870                                                 /* color to grayscale (photoshop rgb weighting) */
1871 -                                               brightness = trace.color[ 0 ] * 0.3f + trace.color[ 1 ] * 0.59f + trace.color[ 2 ] * 0.11f;
1872 +                                               brightness = trace.colorNoShadow[ 0 ] * 0.3f + trace.colorNoShadow[ 1 ] * 0.59f + trace.colorNoShadow[ 2 ] * 0.11f;
1873                                                 brightness *= (1.0 / 255.0);
1874                                                 VectorScale( trace.direction, brightness, trace.direction );
1875                                                 VectorAdd( deluxel, trace.direction, deluxel );
1876 @@ -2222,6 +2322,38 @@\r
1877         /* free light list */
1878         FreeTraceLights( &trace );
1879         
1880 +       /* floodlight pass */
1881 +       FloodlightIlluminateLightmap(lm);
1882 +
1883 +       if (debugnormals)
1884 +       {
1885 +               for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
1886 +               {
1887 +                       /* early out */
1888 +                       if( lm->superLuxels[ lightmapNum ] == NULL )
1889 +                               continue;
1890 +                       
1891 +                       for( y = 0; y < lm->sh; y++ )
1892 +                       {
1893 +                               for( x = 0; x < lm->sw; x++ )
1894 +                               {
1895 +                                       /* get cluster */
1896 +                                       cluster = SUPER_CLUSTER( x, y );
1897 +                                       //%     if( *cluster < 0 )
1898 +                                       //%             continue;
1899 +                                       
1900 +                                       /* get particulars */
1901 +                                       luxel = SUPER_LUXEL( lightmapNum, x, y );
1902 +                                       normal = SUPER_NORMAL (  x, y );
1903 +               
1904 +                                       luxel[0]=(normal[0]*127)+127;
1905 +                                       luxel[1]=(normal[1]*127)+127;
1906 +                                       luxel[2]=(normal[2]*127)+127;
1907 +                               }
1908 +                       }
1909 +               }
1910 +       }
1911 +       
1912         /*      -----------------------------------------------------------------
1913                 dirt pass
1914                 ----------------------------------------------------------------- */
1915 @@ -2263,7 +2395,7 @@\r
1916         /* -----------------------------------------------------------------
1917            filter pass
1918            ----------------------------------------------------------------- */
1919 -       
1920 +
1921         /* walk lightmaps */
1922         for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
1923         {
1924 @@ -3112,7 +3244,7 @@\r
1925         int                     i, x, y, z, x1, y1, z1;
1926         light_t         *light, *light2, **owner;
1927         bspLeaf_t       *leaf;
1928 -       vec3_t          origin, dir, mins, maxs, nullVector = { 0, 0, 0 };
1929 +       vec3_t          origin, dir, mins, maxs;
1930         float           radius, intensity;
1931         light_t         *buckets[ 256 ];
1932         
1933 @@ -3587,7 +3719,430 @@\r
1934         CreateTraceLightsForBounds( mins, maxs, normal, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ], LIGHT_SURFACES, trace );
1935  }
1936  
1937 +/////////////////////////////////////////////////////////////
1938  
1939 +#define FLOODLIGHT_CONE_ANGLE                  88      /* degrees */
1940 +#define FLOODLIGHT_NUM_ANGLE_STEPS             16
1941 +#define FLOODLIGHT_NUM_ELEVATION_STEPS 4
1942 +#define FLOODLIGHT_NUM_VECTORS                 (FLOODLIGHT_NUM_ANGLE_STEPS * FLOODLIGHT_NUM_ELEVATION_STEPS)
1943  
1944 +static vec3_t  floodVectors[ FLOODLIGHT_NUM_VECTORS ];
1945 +static int             numFloodVectors = 0;
1946  
1947 +void SetupFloodLight( void )
1948 +{
1949 +       int             i, j;
1950 +       float   angle, elevation, angleStep, elevationStep;
1951 +       const char      *value;
1952 +       double v1,v2,v3,v4,v5;
1953 +       
1954 +       /* note it */
1955 +       Sys_FPrintf( SYS_VRB, "--- SetupFloodLight ---\n" );
1956 +       
1957 +       /* calculate angular steps */
1958 +       angleStep = DEG2RAD( 360.0f / FLOODLIGHT_NUM_ANGLE_STEPS );
1959 +       elevationStep = DEG2RAD( FLOODLIGHT_CONE_ANGLE / FLOODLIGHT_NUM_ELEVATION_STEPS );
1960 +       
1961 +       /* iterate angle */
1962 +       angle = 0.0f;
1963 +       for( i = 0, angle = 0.0f; i < FLOODLIGHT_NUM_ANGLE_STEPS; i++, angle += angleStep )
1964 +       {
1965 +               /* iterate elevation */
1966 +               for( j = 0, elevation = elevationStep * 0.5f; j < FLOODLIGHT_NUM_ELEVATION_STEPS; j++, elevation += elevationStep )
1967 +               {
1968 +                       floodVectors[ numFloodVectors ][ 0 ] = sin( elevation ) * cos( angle );
1969 +                       floodVectors[ numFloodVectors ][ 1 ] = sin( elevation ) * sin( angle );
1970 +                       floodVectors[ numFloodVectors ][ 2 ] = cos( elevation );
1971 +                       numFloodVectors++;
1972 +               }
1973 +       }
1974 +       
1975 +       /* emit some statistics */
1976 +       Sys_FPrintf( SYS_VRB, "%9d numFloodVectors\n", numFloodVectors );
1977  
1978 +    /* floodlight */
1979 +       value = ValueForKey( &entities[ 0 ], "_floodlight" );
1980 +       
1981 +       if( value[ 0 ] != '\0' )
1982 +       {
1983 +               v1=v2=v3=0;
1984 +               v4=floodlightDistance;
1985 +               v5=floodlightIntensity;
1986 +               
1987 +               sscanf( value, "%lf %lf %lf %lf %lf", &v1, &v2, &v3, &v4, &v5);
1988 +               
1989 +               floodlightRGB[0]=v1;
1990 +               floodlightRGB[1]=v2;
1991 +               floodlightRGB[2]=v3;
1992 +               
1993 +               if (VectorLength(floodlightRGB)==0)
1994 +               {
1995 +                       VectorSet(floodlightRGB,240,240,255);
1996 +               }
1997 +               
1998 +               if (v4<1) v4=1024;
1999 +               if (v5<1) v5=128;
2000 +               
2001 +               floodlightDistance = v4;
2002 +               floodlightIntensity = v5;
2003 +    
2004 +               floodlighty = qtrue;
2005 +               Sys_Printf( "FloodLighting enabled via worldspawn _floodlight key.\n" );
2006 +       }
2007 +       else
2008 +       {
2009 +               VectorSet(floodlightRGB,240,240,255);
2010 +               //floodlighty = qtrue;
2011 +               //Sys_Printf( "FloodLighting enabled via worldspawn _floodlight key.\n" );
2012 +       }
2013 +       VectorNormalize(floodlightRGB,floodlightRGB);
2014 +}
2015 +
2016 +/*
2017 +FloodLightForSample()
2018 +calculates floodlight value for a given sample
2019 +once again, kudos to the dirtmapping coder
2020 +*/
2021 +
2022 +float FloodLightForSample( trace_t *trace , float floodLightDistance, qboolean floodLightLowQuality)
2023 +{
2024 +       int             i;
2025 +       float   d;
2026 +       float   contribution;
2027 +       int     sub = 0;
2028 +       float   gatherLight, outLight;
2029 +       vec3_t  normal, worldUp, myUp, myRt, direction, displacement;
2030 +       float   dd;
2031 +       int     vecs = 0;
2032
2033 +       gatherLight=0;
2034 +       /* dummy check */
2035 +       //if( !dirty )
2036 +       //      return 1.0f;
2037 +       if( trace == NULL || trace->cluster < 0 )