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:
parent
4fea8f28b5
commit
744f542203
|
|
@ -4,6 +4,7 @@
|
|||
* 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: 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 bug preventing use of all 4 light styles in a common case
|
||||
* light: implemented attenutation formulae "delay" 4+5, ala Bengt's tools
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
bool fill;
|
||||
int hullnum;
|
||||
int fillmark;
|
||||
int numportals;
|
||||
} fillparms_t;
|
||||
|
|
@ -334,6 +333,7 @@ RecursiveFillOutside(fillstate_t *state, const fillparms_t *parms, node_t *node)
|
|||
{
|
||||
portal_t *p;
|
||||
int side;
|
||||
bool leak;
|
||||
|
||||
if (node->contents == CONTENTS_SOLID || node->contents == CONTENTS_SKY)
|
||||
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]) {
|
||||
side = (p->nodes[0] == node);
|
||||
if (RecursiveFillOutside(state, parms, p->nodes[side])) {
|
||||
/* leaked, so stop filling */
|
||||
leak = RecursiveFillOutside(state, parms, p->nodes[side]);
|
||||
if (leak) {
|
||||
if (state->backdraw) {
|
||||
state->backdraw--;
|
||||
if (parms->hullnum == 2) /* FIXME!!! */
|
||||
if (!map.leakfile)
|
||||
MarkLeakTrail(p, state->hit_occupied, parms->numportals);
|
||||
}
|
||||
return true;
|
||||
|
|
@ -413,7 +413,7 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
|||
int side;
|
||||
vec_t *v;
|
||||
int i;
|
||||
bool inside;
|
||||
bool inside, leak;
|
||||
fillstate_t fillstate;
|
||||
fillparms_t fillparms;
|
||||
const mapentity_t *entity;
|
||||
|
|
@ -439,7 +439,7 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hullnum == 2) {
|
||||
if (!map.leakfile) {
|
||||
pLeaks = AllocMem(OTHER, sizeof(portal_t *) * numportals, true);
|
||||
StripExtension(options.szBSPName);
|
||||
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 */
|
||||
fillparms.hullnum = hullnum;
|
||||
fillparms.numportals = numportals;
|
||||
fillstate.outleafs = 0;
|
||||
fillstate.backdraw = 0;
|
||||
|
|
@ -474,17 +473,20 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
|||
fillparms.fillmark = ++map.fillmark;
|
||||
side = !(outside_node.portals->nodes[1] == &outside_node);
|
||||
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;
|
||||
Message(msgWarning, warnMapLeak, v[0], v[1], v[2]);
|
||||
if (hullnum == 2) {
|
||||
if (map.leakfile)
|
||||
return false;
|
||||
|
||||
if (!options.fOldleak)
|
||||
SimplifyLeakline(node);
|
||||
|
||||
// heh slight little kludge thing
|
||||
StripExtension(options.szBSPName);
|
||||
Message(msgLiteral, "Leak file written to %s.pts\n",
|
||||
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
|
||||
|
|
@ -498,11 +500,12 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
|||
fprintf(PorFile, "%11i", numports);
|
||||
fclose(PorFile);
|
||||
}
|
||||
}
|
||||
map.leakfile = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hullnum == 2) {
|
||||
if (!map.leakfile) {
|
||||
FreeMem(pLeaks, OTHER, sizeof(portal_t *) * numportals);
|
||||
fclose(LeakFile);
|
||||
|
||||
|
|
|
|||
|
|
@ -630,6 +630,7 @@ typedef struct mapdata_s {
|
|||
|
||||
/* Misc other global state for the compile process */
|
||||
int fillmark; /* For marking leaves while outside filling */
|
||||
bool leakfile; /* Flag once we've written a leak (.por/.pts) file */
|
||||
} mapdata_t;
|
||||
|
||||
extern mapdata_t map;
|
||||
|
|
|
|||
Loading…
Reference in New Issue