qbsp: fix handling of leak files

Previously, leak files would only be written for a leak in hull 2. This is
actually pretty bad because a small leak in hull 0 or 1 might not show up
in hull 2 and you would never get a leak file to chase it down.

Place a flag in the global mapdata to indicate whether we have written a
leak file or not so we only write for the first hull that leaks. Hullnum
is no longer needed as a parameter to RecursiveFillOutside, so remove
that from the fillparms struct.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-03-06 09:41:15 +10:30
parent 4fea8f28b5
commit 744f542203
3 changed files with 33 additions and 28 deletions

View File

@ -4,6 +4,7 @@
* qbsp: support for Valve's 220 map format used in later Worldcraft/Hammer * qbsp: support for Valve's 220 map format used in later Worldcraft/Hammer
* qbsp: support func_group entities used by Radiant and similar editors * qbsp: support func_group entities used by Radiant and similar editors
* qbsp: surfaces with the skip texture are now removed from the compiled bsp * qbsp: surfaces with the skip texture are now removed from the compiled bsp
* qbsp: fixed a problem where leak files were not written for hull0 or hull1
* light: fixed a race condition in multithreaded coloured light processing * light: fixed a race condition in multithreaded coloured light processing
* light: fixed bug preventing use of all 4 light styles in a common case * light: fixed bug preventing use of all 4 light styles in a common case
* light: implemented attenutation formulae "delay" 4+5, ala Bengt's tools * light: implemented attenutation formulae "delay" 4+5, ala Bengt's tools

View File

@ -29,7 +29,6 @@ typedef struct {
typedef struct { typedef struct {
bool fill; bool fill;
int hullnum;
int fillmark; int fillmark;
int numportals; int numportals;
} fillparms_t; } fillparms_t;
@ -334,6 +333,7 @@ RecursiveFillOutside(fillstate_t *state, const fillparms_t *parms, node_t *node)
{ {
portal_t *p; portal_t *p;
int side; int side;
bool leak;
if (node->contents == CONTENTS_SOLID || node->contents == CONTENTS_SKY) if (node->contents == CONTENTS_SOLID || node->contents == CONTENTS_SKY)
return false; return false;
@ -358,11 +358,11 @@ RecursiveFillOutside(fillstate_t *state, const fillparms_t *parms, node_t *node)
for (p = node->portals; p; p = p->next[!side]) { for (p = node->portals; p; p = p->next[!side]) {
side = (p->nodes[0] == node); side = (p->nodes[0] == node);
if (RecursiveFillOutside(state, parms, p->nodes[side])) { leak = RecursiveFillOutside(state, parms, p->nodes[side]);
/* leaked, so stop filling */ if (leak) {
if (state->backdraw) { if (state->backdraw) {
state->backdraw--; state->backdraw--;
if (parms->hullnum == 2) /* FIXME!!! */ if (!map.leakfile)
MarkLeakTrail(p, state->hit_occupied, parms->numportals); MarkLeakTrail(p, state->hit_occupied, parms->numportals);
} }
return true; return true;
@ -413,7 +413,7 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
int side; int side;
vec_t *v; vec_t *v;
int i; int i;
bool inside; bool inside, leak;
fillstate_t fillstate; fillstate_t fillstate;
fillparms_t fillparms; fillparms_t fillparms;
const mapentity_t *entity; const mapentity_t *entity;
@ -439,7 +439,7 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
return false; return false;
} }
if (hullnum == 2) { if (!map.leakfile) {
pLeaks = AllocMem(OTHER, sizeof(portal_t *) * numportals, true); pLeaks = AllocMem(OTHER, sizeof(portal_t *) * numportals, true);
StripExtension(options.szBSPName); StripExtension(options.szBSPName);
strcat(options.szBSPName, ".pts"); strcat(options.szBSPName, ".pts");
@ -462,7 +462,6 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
} }
/* Set up state and parameters for the recursive fill */ /* Set up state and parameters for the recursive fill */
fillparms.hullnum = hullnum;
fillparms.numportals = numportals; fillparms.numportals = numportals;
fillstate.outleafs = 0; fillstate.outleafs = 0;
fillstate.backdraw = 0; fillstate.backdraw = 0;
@ -474,35 +473,39 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
fillparms.fillmark = ++map.fillmark; fillparms.fillmark = ++map.fillmark;
side = !(outside_node.portals->nodes[1] == &outside_node); side = !(outside_node.portals->nodes[1] == &outside_node);
fillnode = outside_node.portals->nodes[side]; fillnode = outside_node.portals->nodes[side];
if (RecursiveFillOutside(&fillstate, &fillparms, fillnode)) {
leak = RecursiveFillOutside(&fillstate, &fillparms, fillnode);
if (leak) {
v = map.entities[fillstate.hit_occupied].origin; v = map.entities[fillstate.hit_occupied].origin;
Message(msgWarning, warnMapLeak, v[0], v[1], v[2]); Message(msgWarning, warnMapLeak, v[0], v[1], v[2]);
if (hullnum == 2) { if (map.leakfile)
if (!options.fOldleak) return false;
SimplifyLeakline(node);
// heh slight little kludge thing if (!options.fOldleak)
StripExtension(options.szBSPName); SimplifyLeakline(node);
Message(msgLiteral, "Leak file written to %s.pts\n",
// heh slight little kludge thing
StripExtension(options.szBSPName);
Message(msgLiteral, "Leak file written to %s.pts\n", options.szBSPName);
fclose(LeakFile);
// Get rid of .prt file if .pts file is generated
strcat(options.szBSPName, ".prt");
remove(options.szBSPName);
if (options.fBspleak) {
Message(msgLiteral, "BSP portal file written to %s.por\n",
options.szBSPName); options.szBSPName);
fclose(LeakFile); fseek(PorFile, 0, SEEK_SET);
fprintf(PorFile, "%11i", numports);
// Get rid of .prt file if .pts file is generated fclose(PorFile);
strcat(options.szBSPName, ".prt");
remove(options.szBSPName);
if (options.fBspleak) {
Message(msgLiteral, "BSP portal file written to %s.por\n",
options.szBSPName);
fseek(PorFile, 0, SEEK_SET);
fprintf(PorFile, "%11i", numports);
fclose(PorFile);
}
} }
map.leakfile = true;
return false; return false;
} }
if (hullnum == 2) { if (!map.leakfile) {
FreeMem(pLeaks, OTHER, sizeof(portal_t *) * numportals); FreeMem(pLeaks, OTHER, sizeof(portal_t *) * numportals);
fclose(LeakFile); fclose(LeakFile);

View File

@ -630,6 +630,7 @@ typedef struct mapdata_s {
/* Misc other global state for the compile process */ /* Misc other global state for the compile process */
int fillmark; /* For marking leaves while outside filling */ int fillmark; /* For marking leaves while outside filling */
bool leakfile; /* Flag once we've written a leak (.por/.pts) file */
} mapdata_t; } mapdata_t;
extern mapdata_t map; extern mapdata_t map;