diff --git a/qbsp/brush.cc b/qbsp/brush.cc index b0d2e595..a316f706 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -409,7 +409,8 @@ CreateBrushFaces(const mapentity_t *src, hullbrush_t *hullbrush, continue; // overconstrained plane // this face is a keeper - f = (face_t *)AllocMem(FACE, 1, true); + f = (face_t *)AllocMem(OTHER, sizeof(face_t), true); + f->planenum = -1; f->w.numpoints = w->numpoints; if (f->w.numpoints > MAXEDGES) Error("face->numpoints > MAXEDGES (%d), source face on line %d", @@ -990,7 +991,7 @@ brush_t *LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, int conte } // create the brush - brush = (brush_t *)AllocMem(BRUSH, 1, true); + brush = (brush_t *)AllocMem(OTHER, sizeof(brush_t), true); brush->contents = contents; brush->faces = facelist; @@ -1435,7 +1436,7 @@ int BrushMostlyOnSide (const brush_t *brush, const vec3_t planenormal, vec_t pla face_t *CopyFace(const face_t *face) { - face_t *newface = (face_t *)AllocMem(FACE, 1, true); + face_t *newface = (face_t *)AllocMem(OTHER, sizeof(face_t), true); memcpy(newface, face, sizeof(face_t)); @@ -1459,7 +1460,7 @@ Duplicates the brush, the sides, and the windings */ brush_t *CopyBrush (const brush_t *brush) { - brush_t *newbrush = (brush_t *)AllocMem(BRUSH, 1, true); + brush_t *newbrush = (brush_t *)AllocMem(OTHER, sizeof(brush_t), true); memcpy(newbrush, brush, sizeof(brush_t)); @@ -1637,7 +1638,7 @@ void SplitBrush (const brush_t *brush, for (int i=0 ; i<2 ; i++) { - b[i] = (brush_t *) AllocMem (BRUSH, 1, true); + b[i] = (brush_t *) AllocMem (OTHER, sizeof(brush_t), true); //memcpy( b[i], brush, sizeof( brush_t ) ); // NOTE: brush copying diff --git a/qbsp/csg4.cc b/qbsp/csg4.cc index ff4a3771..4eabd7e9 100644 --- a/qbsp/csg4.cc +++ b/qbsp/csg4.cc @@ -78,7 +78,7 @@ NewFaceFromFace(face_t *in) { face_t *newf; - newf = (face_t *)AllocMem(FACE, 1, true); + newf = (face_t *)AllocMem(OTHER, sizeof(face_t), true); newf->planenum = in->planenum; newf->texinfo = in->texinfo; @@ -514,7 +514,7 @@ BuildSurfaces(const std::map &planefaces) continue; /* create a new surface to hold the faces on this plane */ - surface_t *surf = (surface_t *)AllocMem(SURFACE, 1, true); + surface_t *surf = (surface_t *)AllocMem(OTHER, sizeof(surface_t), true); surf->planenum = entry->first; surf->next = surfaces; surfaces = surf; @@ -544,7 +544,7 @@ CopyBrushFaces(const brush_t *brush) facelist = NULL; for (face = brush->faces; face; face = face->next) { brushfaces++; - newface = (face_t *)AllocMem(FACE, 1, true); + newface = (face_t *)AllocMem(OTHER, sizeof(face_t), true); *newface = *face; newface->contents[0] = CONTENTS_EMPTY; newface->contents[1] = brush->contents; diff --git a/qbsp/portals.cc b/qbsp/portals.cc index 6dd477f2..fdac7c6d 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -410,7 +410,7 @@ MakeHeadnodePortals(const mapentity_t *entity, node_t *node) for (j = 0; j < 2; j++) { n = j * 3 + i; - p = (portal_t *)AllocMem(PORTAL, 1, true); + p = (portal_t *)AllocMem(OTHER, sizeof(portal_t), true); portals[n] = p; pl = &bplanes[n]; @@ -580,7 +580,7 @@ CutNodePortals_r(node_t *node, portal_state_t *state) * create the new portal by taking the full plane winding for the cutting * plane and clipping it by all of the planes from the other portals */ - new_portal = (portal_t *)AllocMem(PORTAL, 1, true); + new_portal = (portal_t *)AllocMem(OTHER, sizeof(portal_t), true); new_portal->planenum = node->planenum; winding = BaseWindingForPlane(plane); @@ -650,7 +650,7 @@ CutNodePortals_r(node_t *node, portal_state_t *state) } /* the winding is split */ - new_portal = (portal_t *)AllocMem(PORTAL, 1, true); + new_portal = (portal_t *)AllocMem(OTHER, sizeof(portal_t), true); *new_portal = *portal; new_portal->winding = backwinding; FreeMem(portal->winding, WINDING, 1); diff --git a/qbsp/solidbsp.cc b/qbsp/solidbsp.cc index e482eec9..c571f225 100644 --- a/qbsp/solidbsp.cc +++ b/qbsp/solidbsp.cc @@ -609,7 +609,7 @@ DividePlane(surface_t *in, const qbsp_plane_t *split, surface_t **front, in->onnode = true; // divide the facets to the front and back sides - surface_t *newsurf = (surface_t *)AllocMem(SURFACE, 1, true); + surface_t *newsurf = (surface_t *)AllocMem(OTHER, sizeof(surface_t), true); *newsurf = *in; // Prepend each face in facet list to either in or newsurf lists @@ -685,7 +685,7 @@ DividePlane(surface_t *in, const qbsp_plane_t *split, surface_t **front, } // stuff got split, so allocate one new plane and reuse in - surface_t *newsurf = (surface_t *)AllocMem(SURFACE, 1, true); + surface_t *newsurf = (surface_t *)AllocMem(OTHER, sizeof(surface_t), true); *newsurf = *in; newsurf->faces = backlist; *back = newsurf; @@ -907,7 +907,7 @@ LinkNodeFaces(surface_t *surface) // copy for (face_t *f = surface->faces; f; f = f->next) { nodefaces++; - face_t *newf = (face_t *)AllocMem(FACE, 1, true); + face_t *newf = (face_t *)AllocMem(OTHER, sizeof(face_t), true); *newf = *f; f->original = newf; newf->next = list; @@ -942,8 +942,8 @@ PartitionSurfaces(surface_t *surfaces, node_t *node) Message(msgPercent, splitnodes.load(), csgmergefaces); node->faces = LinkNodeFaces(split); - node->children[0] = (node_t *)AllocMem(NODE, 1, true); - node->children[1] = (node_t *)AllocMem(NODE, 1, true); + node->children[0] = (node_t *)AllocMem(OTHER, sizeof(node_t), true); + node->children[1] = (node_t *)AllocMem(OTHER, sizeof(node_t), true); node->planenum = split->planenum; node->detail_separator = split->detail_separator; @@ -1004,16 +1004,16 @@ SolidBSP(const mapentity_t *entity, surface_t *surfhead, bool midsplit) * collision hull for the engine. Probably could be done a little * smarter, but this works. */ - node_t *headnode = (node_t *)AllocMem(NODE, 1, true); + node_t *headnode = (node_t *)AllocMem(OTHER, sizeof(node_t), true); for (int i = 0; i < 3; i++) { headnode->mins[i] = entity->mins[i] - SIDESPACE; headnode->maxs[i] = entity->maxs[i] + SIDESPACE; } - headnode->children[0] = (node_t *)AllocMem(NODE, 1, true); + headnode->children[0] = (node_t *)AllocMem(OTHER, sizeof(node_t), true); headnode->children[0]->planenum = PLANENUM_LEAF; headnode->children[0]->contents = CONTENTS_EMPTY; headnode->children[0]->markfaces = (face_t **)AllocMem(OTHER, sizeof(face_t *), true); - headnode->children[1] = (node_t *)AllocMem(NODE, 1, true); + headnode->children[1] = (node_t *)AllocMem(OTHER, sizeof(node_t), true); headnode->children[1]->planenum = PLANENUM_LEAF; headnode->children[1]->contents = CONTENTS_EMPTY; headnode->children[1]->markfaces = (face_t **)AllocMem(OTHER, sizeof(face_t *), true); @@ -1023,7 +1023,7 @@ SolidBSP(const mapentity_t *entity, surface_t *surfhead, bool midsplit) Message(msgProgress, "SolidBSP"); - node_t *headnode = (node_t *)AllocMem(NODE, 1, true); + node_t *headnode = (node_t *)AllocMem(OTHER, sizeof(node_t), true); usemidsplit = midsplit; // calculate a bounding box for the entire model diff --git a/qbsp/tjunc.cc b/qbsp/tjunc.cc index 5e5d290e..0703e7d5 100644 --- a/qbsp/tjunc.cc +++ b/qbsp/tjunc.cc @@ -478,8 +478,8 @@ TJunc(const mapentity_t *entity, node_t *headnode) cWEdges = cWVerts; cWVerts *= 2; - pWVerts = (wvert_t *)AllocMem(WVERT, cWVerts, true); - pWEdges = (wedge_t *)AllocMem(WEDGE, cWEdges, true); + pWVerts = (wvert_t *)AllocMem(OTHER, cWVerts * sizeof(wvert_t), true); + pWEdges = (wedge_t *)AllocMem(OTHER, cWEdges * sizeof(wedge_t), true); /* * identify all points on common edges diff --git a/qbsp/util.cc b/qbsp/util.cc index 8ae9c33c..8fc594fa 100644 --- a/qbsp/util.cc +++ b/qbsp/util.cc @@ -73,10 +73,6 @@ AllocMem(int Type, int cElements, bool fZero) if (fZero) memset(pTemp, 0, cSize); - // Special stuff for face_t - if (Type == FACE && cElements == 1) - ((face_t *)pTemp)->planenum = -1; - std::unique_lock lck { memoryStatsLock }; rgMemTotal[Type] += cElements;