*/
int PComp (const void *a, const void *b)
{
- if ( (*(vportal_t **)a)->nummightsee == (*(vportal_t **)b)->nummightsee)
+ if ( (*(const vportal_t *const *)a)->nummightsee == (*(const vportal_t *const *)b)->nummightsee)
return 0;
- if ( (*(vportal_t **)a)->nummightsee < (*(vportal_t **)b)->nummightsee)
+ if ( (*(const vportal_t *const *)a)->nummightsee < (*(const vportal_t *const *)b)->nummightsee)
return -1;
return 1;
}
Sys_Printf( "Total clusters: %i\n", portalclusters );
Sys_Printf( "Total visible clusters: %.0f\n", totalvis );
- Sys_Printf( "Average clusters visible: %.2f (%.3f %%/total)\n", mu, mu / portalclusters * 100.0);
- Sys_Printf( " Standard deviation: %.2f (%.3f %%/total, %.3f %%/avg)\n", sigma, sigma / portalclusters * 100.0, sigma / mu * 100.0);
- Sys_Printf( " Minimum: %i (%.3f %%/total, %.3f %%/avg)\n", minvis, minvis / (double) portalclusters * 100.0, minvis / mu * 100.0);
- Sys_Printf( " Maximum: %i (%.3f %%/total, %.3f %%/avg)\n", maxvis, maxvis / (double) portalclusters * 100.0, maxvis / mu * 100.0);
+ Sys_Printf( "Average clusters visible: %.2f (%.3f%%/total)\n", mu, mu / portalclusters * 100.0);
+ Sys_Printf( " Standard deviation: %.2f (%.3f%%/total, %.3f%%/avg)\n", sigma, sigma / portalclusters * 100.0, sigma / mu * 100.0);
+ Sys_Printf( " Minimum: %i (%.3f%%/total, %.3f%%/avg)\n", minvis, minvis / (double) portalclusters * 100.0, minvis / mu * 100.0);
+ Sys_Printf( " Maximum: %i (%.3f%%/total, %.3f%%/avg)\n", maxvis, maxvis / (double) portalclusters * 100.0, maxvis / mu * 100.0);
}
/*
*/
void LoadPortals (char *name)
{
- int i, j, hint;
+ int i, j, flags;
vportal_t *p;
leaf_t *l;
char magic[80];
Sys_Printf ("%6i portalclusters\n", portalclusters);
Sys_Printf ("%6i numportals\n", numportals);
Sys_Printf ("%6i numfaces\n", numfaces);
+
+ if(numportals > MAX_PORTALS)
+ Error("MAX_PORTALS");
// these counts should take advantage of 64 bit systems automatically
leafbytes = ((portalclusters+63)&~63)>>3;
Error ("LoadPortals: reading portal %i", i);
if (numpoints > MAX_POINTS_ON_WINDING)
Error ("LoadPortals: portal %i has too many points", i);
- if ( (unsigned)leafnums[0] > portalclusters
- || (unsigned)leafnums[1] > portalclusters)
+ if (leafnums[0] > portalclusters
+ || leafnums[1] > portalclusters)
Error ("LoadPortals: reading portal %i", i);
- if (fscanf (f, "%i ", &hint) != 1)
- Error ("LoadPortals: reading hint state");
+ if (fscanf (f, "%i ", &flags) != 1)
+ Error ("LoadPortals: reading flags");
w = p->winding = NewFixedWinding (numpoints);
w->numpoints = numpoints;
for (k=0 ; k<3 ; k++)
w->points[j][k] = v[k];
}
- fscanf (f, "\n");
+ if(fscanf (f, "\n") != 0)
+ {
+ // silence gcc warning
+ }
// calc plane
PlaneFromWinding (w, &plane);
l->numportals++;
p->num = i+1;
- p->hint = hint;
+ p->hint = ((flags & 1) != 0);
+ p->sky = ((flags & 2) != 0);
p->winding = w;
VectorSubtract (vec3_origin, plane.normal, p->plane.normal);
p->plane.dist = -plane.dist;
for (k=0 ; k<3 ; k++)
w->points[j][k] = v[k];
}
- fscanf (f, "\n");
+ if(fscanf (f, "\n") != 0)
+ {
+ // silence gcc warning
+ }
// calc plane
PlaneFromWinding (w, &plane);