From e3da31b30809b5717114c2d3cdf404ddbba66a10 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 4 Jun 2017 20:38:21 -0600 Subject: [PATCH] writebsp.cc: Assert we never write a private contents type to the bsp --- include/qbsp/solidbsp.hh | 1 + qbsp/writebsp.cc | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/qbsp/solidbsp.hh b/include/qbsp/solidbsp.hh index bfe93c5d..e0dd9dda 100644 --- a/include/qbsp/solidbsp.hh +++ b/include/qbsp/solidbsp.hh @@ -24,6 +24,7 @@ extern int splitnodes; +const char *GetContentsName( int Contents ); void DivideFacet(face_t *in, qbsp_plane_t *split, face_t **front, face_t **back); void CalcSurfaceInfo(surface_t *surf); void SubdivideFace(face_t *f, face_t **prevptr); diff --git a/qbsp/writebsp.cc b/qbsp/writebsp.cc index 388fc517..d4457d35 100644 --- a/qbsp/writebsp.cc +++ b/qbsp/writebsp.cc @@ -23,6 +23,22 @@ #include #include +static void +AssertVanillaContentType(int content) +{ + switch (content) { + case CONTENTS_EMPTY: + case CONTENTS_SOLID: + case CONTENTS_WATER: + case CONTENTS_SLIME: + case CONTENTS_LAVA: + case CONTENTS_SKY: + break; + default: + Error("Internal error: Tried to save compiler-internal contents type %s\n", GetContentsName(content)); + } +} + static void ExportNodePlanes_r(node_t *node, int *planemap) { @@ -347,6 +363,7 @@ ExportLeaf_BSP29(mapentity_t *entity, node_t *node) map.cTotal[LUMP_LEAFS]++; dleaf->contents = node->contents; + AssertVanillaContentType(dleaf->contents); /* * write bounding box info @@ -396,7 +413,8 @@ ExportLeaf_BSP2(mapentity_t *entity, node_t *node) map.cTotal[LUMP_LEAFS]++; dleaf->contents = node->contents; - + AssertVanillaContentType(dleaf->contents); + /* * write bounding box info * (VectorCopy doesn't work double->float) @@ -445,6 +463,7 @@ ExportLeaf_BSP2rmq(mapentity_t *entity, node_t *node) map.cTotal[LUMP_LEAFS]++; dleaf->contents = node->contents; + AssertVanillaContentType(dleaf->contents); /* * write bounding box info