~ubuntu-branches/ubuntu/natty/alien-arena/natty

« back to all changes in this revision

Viewing changes to source/utils3/bsp/qvis3/qvis3.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia, Barry deFreese, Ansgar Burchardt, Gonéri Le Bouder, Andres Mejia
  • Date: 2008-04-18 17:43:24 UTC
  • mfrom: (1.1.2 upstream) (3.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080418174324-si1umi8dngglaha4
Tags: 7.0-1
[ Barry deFreese ]
* Escape - in alien-arena-server.6.
* Add myself to uploaders.

[ Ansgar Burchardt ]
* Remove deprecated Encoding key from .desktop file.

[ Gonéri Le Bouder ]
* Remove Homepage from package description.

[ Andres Mejia ]
* New upstream release.
* Removing XS- part for Vcs-* lines.
* Removing +ssh part of Vcs-Svn line.
* Bumped to Standards-Version 3.7.3.
* Test for existence of *-stamp stamps before removing them.
* Removed Encoding field in desktop file.
* Modify patch for upstream Makefile to make Makefile more useful in building
  Debian packages.
  + Also fixes problem not detecting the existence of libcurl.
* Remove debug packages for release. Will support nostrip option instead.
* Add description for fix-CVE-2007-4754-CVE-2007-4755.dpatch, silences
  lintian warning.
* Add new link for watchfile.
  + Closes: #453555
* Moved debian/scripts/alien-arena-tarball.sh to
  debian/alien-arena-get-orig-source.
* Modified alien-arena-data-get-orig-source to make it easier to maintain.
* Switched from dpatch to quilt.
* Cut down package description.
* Closing bug about mouse constantly looking up. The submitter could not
  reproduce the bug after deleting the ~/.alien-arena directory.
  + Closes: #457700
* Updated copyright file for new release.
* Updated README.Debian files.
* Adding new images for icons. Need build dependency on sharutils.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// vis.c
 
2
 
 
3
#include "vis.h"
 
4
#include "threads.h"
 
5
#include "stdlib.h"
 
6
#include "parsecfg.h"
 
7
 
 
8
 
 
9
int                     numportals;
 
10
int                     portalclusters;
 
11
 
 
12
char            inbase[32];
 
13
char            outbase[32];
 
14
 
 
15
portal_t        *portals;
 
16
leaf_t          *leafs;
 
17
 
 
18
int                     c_portaltest, c_portalpass, c_portalcheck;
 
19
 
 
20
byte            *uncompressedvis;
 
21
 
 
22
byte    *vismap, *vismap_p, *vismap_end;        // past visfile
 
23
int             originalvismapsize;
 
24
 
 
25
int             leafbytes;                              // (portalclusters+63)>>3
 
26
int             leaflongs;
 
27
 
 
28
int             portalbytes, portallongs;
 
29
 
 
30
qboolean                fastvis;
 
31
qboolean                nosort;
 
32
 
 
33
int                     testlevel = 2;
 
34
float           maxdist = 0.0f;
 
35
 
 
36
int             totalvis;
 
37
 
 
38
portal_t        *sorted_portals[MAX_MAP_PORTALS*2];
 
39
 
 
40
 
 
41
//=============================================================================
 
42
 
 
43
void PlaneFromWinding (winding_t *w, plane_t *plane)
 
44
{
 
45
        vec3_t          v1, v2;
 
46
 
 
47
// calc plane
 
48
        VectorSubtract (w->points[2], w->points[1], v1);
 
49
        VectorSubtract (w->points[0], w->points[1], v2);
 
50
        DotProduct(v1, v2);
 
51
        CrossProduct (v2, v1, plane->normal);
 
52
        VectorNormalize (plane->normal, plane->normal);
 
53
        plane->dist = DotProduct (w->points[0], plane->normal);
 
54
}
 
55
 
 
56
 
 
57
/*
 
58
==================
 
59
NewWinding
 
60
==================
 
61
*/
 
62
winding_t *NewWinding (int points)
 
63
{
 
64
        winding_t       *w;
 
65
        int                     size;
 
66
        
 
67
        if (points > MAX_POINTS_ON_WINDING)
 
68
                Error ("NewWinding: %i points", points);
 
69
        
 
70
        size = (int)((winding_t *)0)->points[points];
 
71
        w = malloc (size);
 
72
        memset (w, 0, size);
 
73
        
 
74
        return w;
 
75
}
 
76
 
 
77
 
 
78
 
 
79
void pw(winding_t *w)
 
80
{
 
81
        int             i;
 
82
        for (i=0 ; i<w->numpoints ; i++)
 
83
                printf ("(%5.1f, %5.1f, %5.1f)\n",w->points[i][0], w->points[i][1],w->points[i][2]);
 
84
}
 
85
 
 
86
void prl(leaf_t *l)
 
87
{
 
88
        int                     i;
 
89
        portal_t        *p;
 
90
        plane_t         pl;
 
91
        
 
92
        for (i=0 ; i<l->numportals ; i++)
 
93
        {
 
94
                p = l->portals[i];
 
95
                pl = p->plane;
 
96
                printf ("portal %4i to leaf %4i : %7.1f : (%4.1f, %4.1f, %4.1f)\n",(int)(p-portals),p->leaf,pl.dist, pl.normal[0], pl.normal[1], pl.normal[2]);
 
97
        }
 
98
}
 
99
 
 
100
 
 
101
//=============================================================================
 
102
 
 
103
/*
 
104
=============
 
105
SortPortals
 
106
 
 
107
Sorts the portals from the least complex, so the later ones can reuse
 
108
the earlier information.
 
109
=============
 
110
*/
 
111
int PComp (const void *a, const void *b)
 
112
{
 
113
        if ( (*(portal_t **)a)->nummightsee == (*(portal_t **)b)->nummightsee)
 
114
                return 0;
 
115
        if ( (*(portal_t **)a)->nummightsee < (*(portal_t **)b)->nummightsee)
 
116
                return -1;
 
117
        return 1;
 
118
}
 
119
 
 
120
void SortPortals (void)
 
121
{
 
122
        int             i;
 
123
        
 
124
        for (i=0 ; i<numportals*2 ; i++)
 
125
                sorted_portals[i] = &portals[i];
 
126
 
 
127
        if (nosort)
 
128
                return;
 
129
        qsort (sorted_portals, numportals*2, sizeof(sorted_portals[0]), PComp);
 
130
}
 
131
 
 
132
 
 
133
/*
 
134
==============
 
135
LeafVectorFromPortalVector
 
136
==============
 
137
*/
 
138
int LeafVectorFromPortalVector (byte *portalbits, byte *leafbits)
 
139
{
 
140
        int                     i;
 
141
        portal_t        *p;
 
142
        int                     c_leafs;
 
143
 
 
144
 
 
145
        memset (leafbits, 0, leafbytes);
 
146
 
 
147
        for (i=0 ; i<numportals*2 ; i++)
 
148
        {
 
149
                if (portalbits[i>>3] & (1<<(i&7)) )
 
150
                {
 
151
                        p = portals+i;
 
152
                        leafbits[p->leaf>>3] |= (1<<(p->leaf&7));
 
153
                }
 
154
        }
 
155
 
 
156
        c_leafs = CountBits (leafbits, portalclusters);
 
157
 
 
158
        return c_leafs;
 
159
}
 
160
 
 
161
 
 
162
/*
 
163
===============
 
164
ClusterMerge
 
165
 
 
166
Merges the portal visibility for a leaf
 
167
===============
 
168
*/
 
169
void ClusterMerge (int leafnum)
 
170
{
 
171
        leaf_t          *leaf;
 
172
        byte            portalvector[MAX_PORTALS/8];
 
173
        byte            uncompressed[MAX_MAP_LEAFS/8];
 
174
        byte            compressed[MAX_MAP_LEAFS/8];
 
175
        int                     i, j;
 
176
        int                     numvis;
 
177
        byte            *dest;
 
178
        portal_t        *p;
 
179
        int                     pnum;
 
180
 
 
181
        // OR together all the portalvis bits
 
182
 
 
183
        memset (portalvector, 0, portalbytes);
 
184
        leaf = &leafs[leafnum];
 
185
        for (i=0 ; i<leaf->numportals ; i++)
 
186
        {
 
187
                p = leaf->portals[i];
 
188
                if (p->status != stat_done)
 
189
                        Error ("portal not done");
 
190
                for (j=0 ; j<portallongs ; j++)
 
191
                        ((long *)portalvector)[j] |= ((long *)p->portalvis)[j];
 
192
                pnum = p - portals;
 
193
                portalvector[pnum>>3] |= 1<<(pnum&7);
 
194
        }
 
195
 
 
196
        // convert portal bits to leaf bits
 
197
        numvis = LeafVectorFromPortalVector (portalvector, uncompressed);
 
198
 
 
199
        if (uncompressed[leafnum>>3] & (1<<(leafnum&7)))
 
200
                printf ("WARNING: Leaf portals saw into leaf (%d)\n", leafnum);
 
201
                
 
202
        uncompressed[leafnum>>3] |= (1<<(leafnum&7));
 
203
        numvis++;               // count the leaf itself
 
204
 
 
205
        // save uncompressed for PHS calculation
 
206
        memcpy (uncompressedvis + leafnum*leafbytes, uncompressed, leafbytes);
 
207
 
 
208
//
 
209
// compress the bit string
 
210
//
 
211
        qprintf ("cluster %4i : %4i visible\n", leafnum, numvis);
 
212
        totalvis += numvis;
 
213
 
 
214
        i = CompressVis (uncompressed, compressed);
 
215
 
 
216
        dest = vismap_p;
 
217
        vismap_p += i;
 
218
        
 
219
        if (vismap_p > vismap_end)
 
220
                Error ("Vismap expansion overflow");
 
221
 
 
222
        dvis->bitofs[leafnum][DVIS_PVS] = dest-vismap;
 
223
 
 
224
        memcpy (dest, compressed, i);   
 
225
}
 
226
 
 
227
 
 
228
/*
 
229
==================
 
230
CalcPortalVis
 
231
==================
 
232
*/
 
233
void CalcPortalVis (void)
 
234
{
 
235
        int             i;
 
236
 
 
237
// fastvis just uses mightsee for a very loose bound
 
238
        if (fastvis)
 
239
        {
 
240
                for (i=0 ; i<numportals*2 ; i++)
 
241
                {
 
242
                        portals[i].portalvis = portals[i].portalflood;
 
243
                        portals[i].status = stat_done;
 
244
                }
 
245
                return;
 
246
        }
 
247
        
 
248
        RunThreadsOnIndividual (numportals*2, true, PortalFlow);
 
249
 
 
250
}
 
251
 
 
252
 
 
253
/*
 
254
==================
 
255
CalcVis
 
256
==================
 
257
*/
 
258
void CalcVis (void)
 
259
{
 
260
        int             i;
 
261
 
 
262
        RunThreadsOnIndividual (numportals*2, true, BasePortalVis);
 
263
 
 
264
//      RunThreadsOnIndividual (numportals*2, true, BetterPortalVis);
 
265
 
 
266
        SortPortals ();
 
267
        
 
268
        CalcPortalVis ();
 
269
 
 
270
//
 
271
// assemble the leaf vis lists by oring and compressing the portal lists
 
272
//
 
273
        for (i=0 ; i<portalclusters ; i++)
 
274
                ClusterMerge (i);
 
275
                
 
276
        printf ("Average clusters visible: %i\n", totalvis / portalclusters);
 
277
}
 
278
 
 
279
 
 
280
void SetPortalSphere (portal_t *p)
 
281
{
 
282
        int             i;
 
283
        vec3_t  total, dist;
 
284
        winding_t       *w;
 
285
        float   r, bestr;
 
286
 
 
287
        w = p->winding;
 
288
        VectorCopy (vec3_origin, total);
 
289
        for (i=0 ; i<w->numpoints ; i++)
 
290
        {
 
291
                VectorAdd (total, w->points[i], total);
 
292
        }
 
293
        
 
294
        for (i=0 ; i<3 ; i++)
 
295
                total[i] /= w->numpoints;
 
296
 
 
297
        bestr = 0;              
 
298
        for (i=0 ; i<w->numpoints ; i++)
 
299
        {
 
300
                VectorSubtract (w->points[i], total, dist);
 
301
                r = VectorLength (dist);
 
302
                if (r > bestr)
 
303
                        bestr = r;
 
304
        }
 
305
        VectorCopy (total, p->origin);
 
306
        p->radius = bestr;
 
307
}
 
308
 
 
309
/*
 
310
============
 
311
LoadPortals
 
312
============
 
313
*/
 
314
void LoadPortals (char *name)
 
315
{
 
316
        int                     i, j;
 
317
        portal_t        *p;
 
318
        leaf_t          *l;
 
319
        char            magic[80];
 
320
        FILE            *f;
 
321
        int                     numpoints;
 
322
        winding_t       *w;
 
323
        int                     leafnums[2];
 
324
        plane_t         plane;
 
325
        
 
326
        if (!strcmp(name,"-"))
 
327
                f = stdin;
 
328
        else
 
329
        {
 
330
                f = fopen(name, "r");
 
331
                if (!f)
 
332
                        Error ("LoadPortals: couldn't read %s\n",name);
 
333
        }
 
334
 
 
335
        if (fscanf (f,"%79s\n%i\n%i\n",magic, &portalclusters, &numportals) != 3)
 
336
                Error ("LoadPortals: failed to read header");
 
337
        if (strcmp(magic,PORTALFILE))
 
338
                Error ("LoadPortals: not a portal file");
 
339
 
 
340
        printf ("%4i portalclusters\n", portalclusters);
 
341
        printf ("%4i numportals\n", numportals);
 
342
 
 
343
        // these counts should take advantage of 64 bit systems automatically
 
344
        leafbytes = ((portalclusters+63)&~63)>>3;
 
345
        leaflongs = leafbytes/sizeof(long);
 
346
        
 
347
        portalbytes = ((numportals*2+63)&~63)>>3;
 
348
        portallongs = portalbytes/sizeof(long);
 
349
 
 
350
// each file portal is split into two memory portals
 
351
        portals = malloc(2*numportals*sizeof(portal_t));
 
352
        memset (portals, 0, 2*numportals*sizeof(portal_t));
 
353
        
 
354
        leafs = malloc(portalclusters*sizeof(leaf_t));
 
355
        memset (leafs, 0, portalclusters*sizeof(leaf_t));
 
356
 
 
357
        originalvismapsize = portalclusters*leafbytes;
 
358
        uncompressedvis = malloc(originalvismapsize);
 
359
 
 
360
        vismap = vismap_p = dvisdata;
 
361
        dvis->numclusters = portalclusters;
 
362
        vismap_p = (byte *)&dvis->bitofs[portalclusters];
 
363
 
 
364
        vismap_end = vismap + MAX_MAP_VISIBILITY;
 
365
                
 
366
        for (i=0, p=portals ; i<numportals ; i++)
 
367
        {
 
368
                if (fscanf (f, "%i %i %i ", &numpoints, &leafnums[0], &leafnums[1])
 
369
                        != 3)
 
370
                        Error ("LoadPortals: reading portal %i", i);
 
371
                if (numpoints > MAX_POINTS_ON_WINDING)
 
372
                        Error ("LoadPortals: portal %i has too many points", i);
 
373
                if ( (unsigned)leafnums[0] > portalclusters
 
374
                || (unsigned)leafnums[1] > portalclusters)
 
375
                        Error ("LoadPortals: reading portal %i", i);
 
376
                
 
377
                w = p->winding = NewWinding (numpoints);
 
378
                w->original = true;
 
379
                w->numpoints = numpoints;
 
380
                
 
381
                for (j=0 ; j<numpoints ; j++)
 
382
                {
 
383
                        double  v[3];
 
384
                        int             k;
 
385
 
 
386
                        // scanf into double, then assign to vec_t
 
387
                        // so we don't care what size vec_t is
 
388
                        if (fscanf (f, "(%lf %lf %lf ) "
 
389
                        , &v[0], &v[1], &v[2]) != 3)
 
390
                                Error ("LoadPortals: reading portal %i", i);
 
391
                        for (k=0 ; k<3 ; k++)
 
392
                                w->points[j][k] = v[k];
 
393
                }
 
394
                fscanf (f, "\n");
 
395
                
 
396
        // calc plane
 
397
                PlaneFromWinding (w, &plane);
 
398
 
 
399
        // create forward portal
 
400
                l = &leafs[leafnums[0]];
 
401
                if (l->numportals == MAX_PORTALS_ON_LEAF)
 
402
                        Error ("Leaf with too many portals");
 
403
                l->portals[l->numportals] = p;
 
404
                l->numportals++;
 
405
                
 
406
                p->winding = w;
 
407
                VectorSubtract (vec3_origin, plane.normal, p->plane.normal);
 
408
                p->plane.dist = -plane.dist;
 
409
                p->leaf = leafnums[1];
 
410
                p->owner_leaf = leafnums[0];
 
411
                SetPortalSphere (p);
 
412
                p++;
 
413
                
 
414
        // create backwards portal
 
415
                l = &leafs[leafnums[1]];
 
416
                if (l->numportals == MAX_PORTALS_ON_LEAF)
 
417
                        Error ("Leaf with too many portals");
 
418
                l->portals[l->numportals] = p;
 
419
                l->numportals++;
 
420
                
 
421
                p->winding = NewWinding(w->numpoints);
 
422
                p->winding->numpoints = w->numpoints;
 
423
                for (j=0 ; j<w->numpoints ; j++)
 
424
                {
 
425
                        VectorCopy (w->points[w->numpoints-1-j], p->winding->points[j]);
 
426
                }
 
427
 
 
428
                p->plane = plane;
 
429
                p->leaf = leafnums[0];
 
430
                p->owner_leaf = leafnums[1];
 
431
                SetPortalSphere (p);
 
432
                p++;
 
433
 
 
434
        }
 
435
        
 
436
        fclose (f);
 
437
}
 
438
 
 
439
 
 
440
/*
 
441
================
 
442
CalcPHS
 
443
 
 
444
Calculate the PHS (Potentially Hearable Set)
 
445
by ORing together all the PVS visible from a leaf
 
446
================
 
447
*/
 
448
void CalcPHS (void)
 
449
{
 
450
        int             i, j, k, l, index;
 
451
        int             bitbyte;
 
452
        long    *dest, *src;
 
453
        byte    *scan;
 
454
        int             count;
 
455
        byte    uncompressed[MAX_MAP_LEAFS/8];
 
456
        byte    compressed[MAX_MAP_LEAFS/8];
 
457
 
 
458
        printf ("Building PHS...\n");
 
459
 
 
460
        count = 0;
 
461
        for (i=0 ; i<portalclusters ; i++)
 
462
        {
 
463
                scan = uncompressedvis + i*leafbytes;
 
464
                memcpy (uncompressed, scan, leafbytes);
 
465
                for (j=0 ; j<leafbytes ; j++)
 
466
                {
 
467
                        bitbyte = scan[j];
 
468
                        if (!bitbyte)
 
469
                                continue;
 
470
                        for (k=0 ; k<8 ; k++)
 
471
                        {
 
472
                                if (! (bitbyte & (1<<k)) )
 
473
                                        continue;
 
474
                                // OR this pvs row into the phs
 
475
                                index = ((j<<3)+k);
 
476
                                if (index >= portalclusters)
 
477
                                        Error ("Bad bit in PVS");       // pad bits should be 0
 
478
                                src = (long *)(uncompressedvis + index*leafbytes);
 
479
                                dest = (long *)uncompressed;
 
480
                                for (l=0 ; l<leaflongs ; l++)
 
481
                                        ((long *)uncompressed)[l] |= src[l];
 
482
                        }
 
483
                }
 
484
                for (j=0 ; j<portalclusters ; j++)
 
485
                        if (uncompressed[j>>3] & (1<<(j&7)) )
 
486
                                count++;
 
487
 
 
488
        //
 
489
        // compress the bit string
 
490
        //
 
491
                j = CompressVis (uncompressed, compressed);
 
492
 
 
493
                dest = (long *)vismap_p;
 
494
                vismap_p += j;
 
495
                
 
496
                if (vismap_p > vismap_end)
 
497
                        Error ("Vismap expansion overflow");
 
498
 
 
499
                dvis->bitofs[i][DVIS_PHS] = (byte *)dest-vismap;
 
500
 
 
501
                memcpy (dest, compressed, j);   
 
502
        }
 
503
 
 
504
        printf ("Average clusters hearable: %i\n", count/portalclusters);
 
505
}
 
506
 
 
507
/*
 
508
===========
 
509
main
 
510
===========
 
511
*/
 
512
int main (int argc, char **argv)
 
513
{
 
514
        char    portalfile[1024];
 
515
        char            source[1024];
 
516
        char            name[1024];
 
517
    char *param, *param2;
 
518
        double          start, end;
 
519
                
 
520
        printf ("----------- qvis3 -----------\n");
 
521
        printf ("original code by id Software\n");
 
522
    printf ("Modified by Geoffrey DeWan\n");
 
523
    printf ("Revision 1.03\n");
 
524
    printf ("-----------------------------\n");
 
525
 
 
526
    LoadConfigurationFile("qvis3", 0);
 
527
    LoadConfiguration(argc-1, argv+1);
 
528
 
 
529
        verbose = false;
 
530
        
 
531
    while((param = WalkConfiguration()) != NULL)
 
532
        {
 
533
                if (!strcmp(param,"-threads"))
 
534
                {
 
535
            param2 = WalkConfiguration();
 
536
                        numthreads = atoi (param2);
 
537
                }
 
538
                else if (!strcmp(param, "-fast"))
 
539
                {
 
540
                        printf ("fastvis = true\n");
 
541
                        fastvis = true;
 
542
                }
 
543
                else if (!strcmp(param, "-level"))
 
544
                {
 
545
            param2 = WalkConfiguration();
 
546
                        testlevel = atoi (param2);
 
547
                        printf ("Test level not used in qvis3\n");
 
548
                }
 
549
                else if (!strcmp(param, "-maxdist"))
 
550
                {
 
551
            param2 = WalkConfiguration();
 
552
                        maxdist = atof (param2);
 
553
 
 
554
                        printf ("maxdist = %.2f\n", maxdist);
 
555
                }
 
556
                else if (!strcmp(param, "-maxfovdist"))
 
557
                {
 
558
                        float fov, tmpmaxdist;
 
559
 
 
560
            param2 = WalkConfiguration();
 
561
                        fov = atof (param2);
 
562
            param2 = WalkConfiguration();
 
563
                        tmpmaxdist = atof (param2);
 
564
 
 
565
                        maxdist = tmpmaxdist / (float)cos(atan(tan(fov * Q_PI / 360.0) * 5.0 / 4.0));
 
566
 
 
567
                        printf ("maxfovdist = %.2f %.2f -> %2f\n", fov, tmpmaxdist, maxdist);
 
568
                }
 
569
                else if (!strcmp(param, "-v"))
 
570
                {
 
571
                        printf ("verbose = true\n");
 
572
                        verbose = true;
 
573
                }
 
574
                else if (!strcmp (param,"-nosort"))
 
575
                {
 
576
                        printf ("nosort = true\n");
 
577
                        nosort = true;
 
578
                }
 
579
                else if (!strcmp (param,"-cullerror"))
 
580
                {
 
581
                        printf ("cullerror = true\n");
 
582
                        cullerror = true;
 
583
                }
 
584
                else if (!strcmp (param,"-tmpin"))
 
585
                        strcpy (inbase, "/tmp");
 
586
                else if (!strcmp (param,"-tmpout"))
 
587
                        strcpy (outbase, "/tmp");
 
588
                else if (param[0] == '+')
 
589
            LoadConfigurationFile(param+1, 1);
 
590
                else if (param[0] == '-')
 
591
                        Error ("Unknown option \"%s\"", param);
 
592
                else
 
593
                        break;
 
594
        }
 
595
 
 
596
    if(param != NULL)
 
597
        param2 = WalkConfiguration();
 
598
 
 
599
    if (param == NULL || param2 != NULL)
 
600
                Error ("usage: vis [-threads #] [-fast] [-nosort] [-cullerror] [-v] [-maxdist distance] [-maxfovdist fov distance] bspfile");
 
601
 
 
602
    while(param2)  // make sure list is clean
 
603
        param2 = WalkConfiguration();
 
604
 
 
605
        start = I_FloatTime ();
 
606
        
 
607
        ThreadSetDefault ();
 
608
 
 
609
//    if(!IsFullPath(param))
 
610
//          SetQdirFromPath (param);    
 
611
 
 
612
        strcpy (source, ExpandArg(param));
 
613
        StripExtension (source);
 
614
        DefaultExtension (source, ".bsp");
 
615
 
 
616
        sprintf (name, "%s%s", inbase, source);
 
617
        printf ("reading %s\n", name);
 
618
        LoadBSPFile (name);
 
619
        if (numnodes == 0 || numfaces == 0)
 
620
                Error ("Empty map");
 
621
 
 
622
        sprintf (portalfile, "%s%s", inbase, ExpandArg(param));
 
623
        StripExtension (portalfile);
 
624
        strcat (portalfile, ".prt");
 
625
        
 
626
        printf ("reading %s\n", portalfile);
 
627
        LoadPortals (portalfile);
 
628
        
 
629
        CalcVis ();
 
630
 
 
631
        CalcPHS ();
 
632
 
 
633
        visdatasize = vismap_p - dvisdata;      
 
634
        printf ("visdatasize:%i  compressed from %i\n", visdatasize, originalvismapsize*2);
 
635
 
 
636
        sprintf (name, "%s%s", outbase, source);
 
637
        printf ("writing %s\n", name);
 
638
        WriteBSPFile (name);    
 
639
        
 
640
        end = I_FloatTime ();
 
641
        printf ("%5.1f seconds elapsed\n", end-start);
 
642
 
 
643
        return 0;
 
644
}
 
645