From 51bed53570fc1928606c4cf47c5c64c1ef1e328b Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Mon, 22 Apr 2013 20:15:07 +0930 Subject: [PATCH] qbsp: remove remaining enum errors Remove the enum Error() function and global error strings as well. Signed-off-by: Kevin Shanahan --- qbsp/globals.c | 16 ---------------- qbsp/qbsp.h | 2 -- qbsp/tjunc.c | 9 +++++---- qbsp/util.c | 32 +++----------------------------- qbsp/warnerr.h | 17 ----------------- qbsp/winding.c | 6 +++--- qbsp/writebsp.c | 5 +++-- 7 files changed, 14 insertions(+), 73 deletions(-) diff --git a/qbsp/globals.c b/qbsp/globals.c index 2eae07d5..bfdd16b9 100644 --- a/qbsp/globals.c +++ b/qbsp/globals.c @@ -77,19 +77,3 @@ const char *rgszWarnings[cWarnings] = { "No target for rotation entity \"%s\"", "line %d: Face with degenerate QuArK-style texture axes", }; - -const char *rgszErrors[cErrors] = { - "No axis found for winding", - "Points on winding exceeded estimate", - "Degenerate edge at (%.3f %.3f %.3f)", - "Found a non-canonical vector", - "Normalization error in FindPlane (vector length %.4f)", - "Internal error: pWorldEnt->lumps[BSPPLANE].index >= pWorldEnt->lumps[BSPPLANE].count", - "Internal error: numwedges >= cWEdges", - "Internal error: numwverts >= cWVerts", - "f->original exists in SplitFaceForTjunc", - "Internal error: invalid memory %i type in AllocMem", - "Too many points on winding (%d)", - "Out of memory", - "Clipnodes in map exceed " stringify(MAX_BSP_CLIPNODES), -}; diff --git a/qbsp/qbsp.h b/qbsp/qbsp.h index 4a53a054..cf1ec605 100644 --- a/qbsp/qbsp.h +++ b/qbsp/qbsp.h @@ -675,7 +675,6 @@ void ExportDrawNodes(mapentity_t *entity, node_t *headnode, int firstface); #define msgPercent 7 extern const char *rgszWarnings[cWarnings]; -extern const char *rgszErrors[cErrors]; extern const int rgcMemSize[]; extern void *AllocMem(int Type, int cSize, bool fZero); @@ -684,7 +683,6 @@ extern void FreeAllMem(void); extern void PrintMem(void); extern void Message(int MsgType, ...); -extern void Error(int ErrType, ...) __attribute__((noreturn)); extern void Error_(const char *error, ...) __attribute__((format(printf,1,2),noreturn)); diff --git a/qbsp/tjunc.c b/qbsp/tjunc.c index 6d060369..67cb039e 100644 --- a/qbsp/tjunc.c +++ b/qbsp/tjunc.c @@ -105,7 +105,8 @@ CanonicalVector(vec3_t vec) return; } else vec[2] = 0; - Error(errDegenerateEdge, vec[0], vec[1], vec[2]); + + Error_("Degenerate edge at (%.3f %.3f %.3f)", vec[0], vec[1], vec[2]); } static wedge_t * @@ -158,7 +159,7 @@ FindEdge(vec3_t p1, vec3_t p2, vec_t *t1, vec_t *t2) } if (numwedges >= cWEdges) - Error(errLowWedgeCount); + Error_("Internal error: didn't allocate enough edges for tjuncs?"); w = pWEdges + numwedges; numwedges++; @@ -195,7 +196,7 @@ AddVert(wedge_t *w, vec_t t) // insert a new wvert before v if (numwverts >= cWVerts) - Error(errLowWvertCount); + Error_("Internal error: didn't allocate enough vertices for tjuncs?"); newv = pWVerts + numwverts; numwverts++; @@ -313,7 +314,7 @@ SplitFaceForTjunc(face_t *f, face_t *original) newf = NewFaceFromFace(f); if (f->original) - Error(errOriginalExists); + Error_("original face still exists (%s)", __func__); newf->original = chain; chain = newf; diff --git a/qbsp/util.c b/qbsp/util.c index 77c99bc3..53d089c7 100644 --- a/qbsp/util.c +++ b/qbsp/util.c @@ -43,12 +43,12 @@ AllocMem(int Type, int cElements, bool fZero) int cSize; if (Type < 0 || Type > OTHER) - Error(errInvalidMemType, Type); + Error_("Internal error: invalid memory type %d (%s)", Type, __func__); // For windings, cElements == number of points on winding if (Type == WINDING) { if (cElements > MAX_POINTS_ON_WINDING) - Error(errTooManyPoints, cElements); + Error_("Too many points (%d) on winding (%s)", cElements, __func__); cSize = offsetof(winding_t, points[cElements]) + sizeof(int); @@ -59,7 +59,7 @@ AllocMem(int Type, int cElements, bool fZero) pTemp = malloc(cSize); if (!pTemp) - Error(errOutOfMemory); + Error_("allocation of %d bytes failed (%s)", cSize, __func__); if (fZero) memset(pTemp, 0, cSize); @@ -201,32 +201,6 @@ FreeAllMem(void) /* Keep track of output state */ static bool fInPercent = false; -void -Error(int ErrType, ...) -{ - va_list argptr; - char szBuffer[512]; - - va_start(argptr, ErrType); - - if (fInPercent) { - printf("\r"); - fInPercent = false; - } - if (ErrType >= cErrors) { - printf("Program error: unknown ErrType in Message!\n"); - exit(1); - } - sprintf(szBuffer, "*** ERROR %02d: ", ErrType); - vsprintf(szBuffer + strlen(szBuffer), rgszErrors[ErrType], argptr); - puts(szBuffer); - if (logfile) { - fprintf(logfile, "%s\n", szBuffer); - fclose(logfile); - } - exit(1); -} - void Error_(const char *error, ...) { diff --git a/qbsp/warnerr.h b/qbsp/warnerr.h index 24688d0e..16a3077f 100644 --- a/qbsp/warnerr.h +++ b/qbsp/warnerr.h @@ -48,20 +48,3 @@ enum { warnDegenerateQuArKTX, cWarnings }; - -enum { - errNoWindingAxis, - errLowPointCount, - errDegenerateEdge, - errNonCanonicalVector, - errNormalization, - errLowPlaneCount, - errLowWedgeCount, - errLowWvertCount, - errOriginalExists, - errInvalidMemType, // 50 - errTooManyPoints, - errOutOfMemory, - errTooManyClipnodes, - cErrors -}; diff --git a/qbsp/winding.c b/qbsp/winding.c index 8d9befb1..72023a3a 100644 --- a/qbsp/winding.c +++ b/qbsp/winding.c @@ -58,7 +58,7 @@ BaseWindingForPlane(const plane_t *p) vup[0] = 1; break; default: - Error(errNoWindingAxis); + Error_("Internal error: no axis for winding (%s)", __func__); } v = DotProduct(vup, p->normal); @@ -227,7 +227,7 @@ ClipWinding(winding_t *in, const plane_t *split, bool keepon) } if (neww->numpoints > maxpts) - Error(errLowPointCount); + Error_("Internal error: excess clipped points (%s)", __func__); // free the original winding FreeMem(in, WINDING, 1); @@ -324,7 +324,7 @@ DivideWinding(winding_t *in, const plane_t *split, winding_t **front, } if (f->numpoints > maxpts || b->numpoints > maxpts) - Error(errLowPointCount); + Error_("Internal error: excess clipped points (%s)", __func__); } diff --git a/qbsp/writebsp.c b/qbsp/writebsp.c index 3fe792a3..76968b23 100644 --- a/qbsp/writebsp.c +++ b/qbsp/writebsp.c @@ -54,7 +54,7 @@ ExportNodePlanes_r(node_t *node, int *planemap) if (i == planes->index) { if (planes->index >= planes->count) - Error(errLowPlaneCount); + Error_("Internal error: plane count mismatch (%s)", __func__); plane = &map.planes[node->planenum]; dplane = (dplane_t *)planes->data + planes->index; dplane->normal[0] = plane->normal[0]; @@ -188,7 +188,8 @@ ExportClipNodes(mapentity_t *entity, node_t *nodes, const int hullnum) CountClipNodes_r(entity, nodes); if (clipnodes->count > MAX_BSP_CLIPNODES) - Error(errTooManyClipnodes); + Error_("Clipnode count exceeds bsp29 max (%d > %d)", + clipnodes->count, MAX_BSP_CLIPNODES); olddata = clipnodes->data; clipnodes->data = AllocMem(BSPCLIPNODE, clipnodes->count, true);