From 7c49d499c207012e2a3bec0d93312ef891d164d2 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 23 Jul 2017 02:48:58 -0600 Subject: [PATCH] qbsp: tidy FreeBrushes --- include/qbsp/brush.hh | 2 +- qbsp/brush.cc | 5 +++-- qbsp/qbsp.cc | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/qbsp/brush.hh b/include/qbsp/brush.hh index 4d1c45ce..5673292a 100644 --- a/include/qbsp/brush.hh +++ b/include/qbsp/brush.hh @@ -42,7 +42,7 @@ int Brush_ListCount(const brush_t *brush); int Brush_NumFaces(const brush_t *brush); brush_t *LoadBrush(const mapbrush_t *mapbrush, const vec3_t rotate_offset, const int hullnum); -void FreeBrushes(brush_t *brushlist); +void FreeBrushes(mapentity_t *ent); int FindPlane(const vec3_t normal, const vec_t dist, int *side); bool PlaneEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2); diff --git a/qbsp/brush.cc b/qbsp/brush.cc index d7891149..91c32321 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -508,15 +508,16 @@ FreeBrushes ===================== */ void -FreeBrushes(brush_t *brushlist) +FreeBrushes(mapentity_t *ent) { brush_t *brush, *next; - for (brush = brushlist; brush; brush = next) { + for (brush = ent->brushes; brush; brush = next) { next = brush->next; FreeBrushFaces(brush->faces); FreeMem(brush, BRUSH, 1); } + ent->brushes = nullptr; } /* diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index 2933c262..d23832b7 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -153,8 +153,7 @@ ProcessEntity(mapentity_t *entity, const int hullnum) * leaving a perfect skin of the model with no hidden faces */ surfs = CSGFaces(entity); - FreeBrushes(entity->brushes); - + if (options.fObjExport && entity == pWorldEnt() && hullnum == 0) { ExportObj(surfs); } @@ -232,6 +231,8 @@ ProcessEntity(mapentity_t *entity, const int hullnum) ExportDrawNodes(entity, nodes, firstface); } + FreeBrushes(entity); + map.cTotal[LUMP_MODELS]++; } @@ -503,7 +504,7 @@ static void BSPX_CreateBrushList(void) } BSPX_Brushes_AddModel(&ctx, modelnum , ent->brushes); - FreeBrushes(ent->brushes); + FreeBrushes(ent); } BSPX_Brushes_Finalize(&ctx);