diff --git a/qbsp/brush.cc b/qbsp/brush.cc index 14473e8b..2c96f9e0 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -303,7 +303,7 @@ static std::vector CreateBrushFaces(const mapentity_t *src, hullbrush_t vec_t r; std::optional w; qbsp_plane_t plane; - std::vector facelist; + std::list facelist; qvec3d point; vec_t max, min; @@ -345,7 +345,7 @@ static std::vector CreateBrushFaces(const mapentity_t *src, hullbrush_t FError("face->numpoints > MAXEDGES ({}), source face on line {}", MAXEDGES, mapface.linenum); // this face is a keeper - face_t &f = facelist.emplace_back(); + face_t &f = facelist.emplace_front(); f.planenum = PLANENUM_LEAF; f.w.resize(w->size()); @@ -414,7 +414,7 @@ static std::vector CreateBrushFaces(const mapentity_t *src, hullbrush_t hullbrush->bounds = {-delta, delta}; } - return facelist; + return { std::make_move_iterator(facelist.begin()), std::make_move_iterator(facelist.end()) }; } /* diff --git a/vis/vis.cc b/vis/vis.cc index e2221a7c..06c720cd 100644 --- a/vis/vis.cc +++ b/vis/vis.cc @@ -531,10 +531,10 @@ static void ClusterFlow(int clusternum, leafbits_t &buffer, mbsp_t *bsp) /* Allocate for worst case where RLE might grow the data (unlikely) */ if (bsp->loadversion->game->id == GAME_QUAKE_II) { - compressed = new uint8_t[(portalleafs * 2) / 8]; + compressed = new uint8_t[max(1, (portalleafs * 2) / 8)]; len = CompressRow(outbuffer, (portalleafs + 7) >> 3, compressed); } else { - compressed = new uint8_t[(portalleafs_real * 2) / 8]; + compressed = new uint8_t[max(1, (portalleafs_real * 2) / 8)]; len = CompressRow(outbuffer, (portalleafs_real + 7) >> 3, compressed); }