From 7203d3407b3e6a62a4aa1eabbe176509726f0557 Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Mon, 22 Apr 2013 17:59:36 +0930 Subject: [PATCH] qbsp: replace enum errors in brush.c One shared message in surfaces.c replaced as well. Signed-off-by: Kevin Shanahan --- qbsp/brush.c | 24 +++++++++++++----------- qbsp/globals.c | 9 --------- qbsp/surfaces.c | 2 +- qbsp/warnerr.h | 9 --------- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/qbsp/brush.c b/qbsp/brush.c index e3a756a0..fe602566 100644 --- a/qbsp/brush.c +++ b/qbsp/brush.c @@ -60,7 +60,7 @@ CheckFace(face_t *f) vec3_t dir, edgenormal, facenormal; if (f->w.numpoints < 3) - Error(errTooFewPoints, f->w.numpoints); + Error_("%s: too few points (%i)", __func__, f->w.numpoints); VectorCopy(map.planes[f->planenum].normal, facenormal); if (f->planeside) { @@ -72,7 +72,7 @@ CheckFace(face_t *f) for (j = 0; j < 3; j++) if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE) - Error(errBogusRange, p1[j]); + Error_("%s: coordinate out of range (%f)", __func__, p1[j]); j = i + 1 == f->w.numpoints ? 0 : i + 1; @@ -107,7 +107,7 @@ CheckFace(face_t *f) continue; d = DotProduct(f->w.points[j], edgenormal); if (d > edgedist) - Error(errConcaveFace); + Error_("%s: Found a non-convex face", __func__); } } } @@ -244,9 +244,9 @@ NewPlane(const vec3_t normal, const vec_t dist, int *side) len = VectorLength(normal); if (len < 1 - ON_EPSILON || len > 1 + ON_EPSILON) - Error(errInvalidNormal, len); + Error_("%s: invalid normal (vector length %.4f)", __func__, len); if (map.numplanes == map.maxplanes) - Error(errLowBrushPlaneCount); + Error_("Internal error: didn't allocate enough planes? (%s)", __func__); plane = &map.planes[map.numplanes]; VectorCopy(normal, plane->normal); @@ -403,7 +403,7 @@ CreateBrushFaces(hullbrush_t *hullbrush, const vec3_t rotate_offset, f = AllocMem(FACE, 1, true); f->w.numpoints = w->numpoints; if (f->w.numpoints > MAXEDGES) - Error(errLowFacePointCount); + Error_("Internal error: face->numpoints > MAXEDGES (%s)", __func__); for (j = 0; j < w->numpoints; j++) { for (k = 0; k < 3; k++) { @@ -517,7 +517,7 @@ AddBrushPlane(hullbrush_t *hullbrush, plane_t *plane) len = VectorLength(plane->normal); if (len < 1.0 - NORMAL_EPSILON || len > 1.0 + NORMAL_EPSILON) - Error(errInvalidNormal, len); + Error_("%s: invalid normal (vector length %.4f)", __func__, len); mapface = hullbrush->faces; for (i = 0; i < hullbrush->numfaces; i++, mapface++) { @@ -526,7 +526,8 @@ AddBrushPlane(hullbrush_t *hullbrush, plane_t *plane) return; } if (hullbrush->numfaces == MAX_FACES) - Error(errLowBrushFaceCount); + Error_("Internal error: brush->faces >= MAX_FACES (%s)", __func__); + mapface->plane = *plane; mapface->texinfo = 0; hullbrush->numfaces++; @@ -609,7 +610,7 @@ AddHullPoint(hullbrush_t *hullbrush, vec3_t p, vec3_t hull_size[2]) return i; if (hullbrush->numpoints == MAX_HULL_POINTS) - Error(errLowHullPointCount); + Error_("Internal error: hullbrush->numpoints == MAX_HULL_POINTS"); VectorCopy(p, hullbrush->points[hullbrush->numpoints]); @@ -656,7 +657,7 @@ AddHullEdge(hullbrush_t *hullbrush, vec3_t p1, vec3_t p2, vec3_t hull_size[2]) return; if (hullbrush->numedges == MAX_HULL_EDGES) - Error(errLowHullEdgeCount); + Error_("Internal error: hulbrush->numedges == MAX_HULL_EDGES"); hullbrush->edges[i][0] = pt1; hullbrush->edges[i][1] = pt2; @@ -800,7 +801,8 @@ LoadBrush(const mapbrush_t *mapbrush, const vec3_t rotate_offset, // create the faces if (mapbrush->numfaces > MAX_FACES) - Error(errLowBrushFaceCount); + Error_("Internal error: brush->faces >= MAX_FACES (%s)", __func__); + hullbrush.numfaces = mapbrush->numfaces; memcpy(hullbrush.faces, mapbrush->faces, mapbrush->numfaces * sizeof(mapface_t)); diff --git a/qbsp/globals.c b/qbsp/globals.c index a4c6fb98..355ffa45 100644 --- a/qbsp/globals.c +++ b/qbsp/globals.c @@ -91,20 +91,11 @@ const char *rgszErrors[cErrors] = { "Surface without a face", "Degenerate edge at (%.3f %.3f %.3f)", - "Found a non-convex face", "Found a non-canonical vector", - "Internal error: map.numplanes >= map.maxplanes", "Normalization error in FindPlane (vector length %.4f)", - "Internal error: f->numpoints > MAXEDGES", - "Invalid normal (vector length %.4f)", - "Internal error: brush faces >= MAX_FACES", - "Internal error: brush hull points == MAX_HULL_POINTS", - "Internal error: brush hull edges == MAX_HULL_EDGES", "Attempting to split freed face", "Internal error: numpoints > MAXEDGES in SplitFace", - "Face with too few points (%i) in CheckFace", - "Face coordinate out of range (%f)", "Deformed lump in BSP file (%d size is not divisible by %d)", "Failed to open %s: %s", "Failure reading from file", diff --git a/qbsp/surfaces.c b/qbsp/surfaces.c index 1500730c..820a271a 100644 --- a/qbsp/surfaces.c +++ b/qbsp/surfaces.c @@ -310,7 +310,7 @@ FindFaceEdges(mapentity_t *entity, face_t *face) face->outputnumber = -1; if (face->w.numpoints > MAXEDGES) - Error(errLowFacePointCount); + Error_("Internal error: face->numpoints > MAXEDGES (%s)", __func__); face->edges = AllocMem(OTHER, face->w.numpoints * sizeof(int), true); for (i = 0; i < face->w.numpoints; i++) diff --git a/qbsp/warnerr.h b/qbsp/warnerr.h index 61f3c004..08b47004 100644 --- a/qbsp/warnerr.h +++ b/qbsp/warnerr.h @@ -61,19 +61,10 @@ enum { errMixedFaceContents, errNoSurfaceFace, errDegenerateEdge, - errConcaveFace, // 20 errNonCanonicalVector, - errLowBrushPlaneCount, errNormalization, - errLowFacePointCount, - errInvalidNormal, - errLowBrushFaceCount, - errLowHullPointCount, - errLowHullEdgeCount, errFreedFace, errLowSplitPointCount, // 30 - errTooFewPoints, - errBogusRange, errDeformedBSPLump, errOpenFailed, errReadFailure,