ref: 802e7e75604dab17e98c4d7da3252d8e35d81e7c
parent: a9de1dc067febe2b0a58ce944468fe3deec0d26c
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Oct 14 14:20:48 EDT 2023
use Q_MAXFLOAT; increase bmodel limits
--- a/common.c
+++ b/common.c
@@ -367,9 +367,9 @@
if(buf->cursize + length > buf->maxsize){
if(!buf->allowoverflow)
- fatal("SZ_GetSpace: overflow without allowoverflow set");
+ Host_Error("SZ_GetSpace: overflow without allowoverflow set");
if(length > buf->maxsize)
- fatal("SZ_GetSpace: %d is > full buffer size", length);
+ Host_Error("SZ_GetSpace: %d is > full buffer size", length);
buf->overflowed = true;
Con_Printf("SZ_GetSpace: overflow");
SZ_Clear(buf);
--- a/common.h
+++ b/common.h
@@ -44,13 +44,13 @@
#define Q_MAXSHORT ((short)0x7fff)
#define Q_MAXINT ((int)0x7fffffff)
#define Q_MAXLONG ((int)0x7fffffff)
-#define Q_MAXFLOAT ((int)0x7fffffff)
+#define Q_MAXFLOAT 3.40282347e+38
#define Q_MINCHAR ((char)0x80)
#define Q_MINSHORT ((short)0x8000)
#define Q_MININT ((int)0x80000000)
#define Q_MINLONG ((int)0x80000000)
-#define Q_MINFLOAT ((int)0x7fffffff)
+#define Q_MINFLOAT 1.17549435e-38
//============================================================================
--- a/d_polyse.c
+++ b/d_polyse.c
@@ -631,7 +631,7 @@
}
pspanpackage++;
- } while (pspanpackage->count != -999999);
+ } while (pspanpackage->count != Q_MININT);
}
@@ -862,7 +862,7 @@
d_aspancount = 0;
d_countextrastep = ubasestep + 1;
originalcount = a_spans[initialrightheight].count;
- a_spans[initialrightheight].count = -999999; // mark end of the spanpackages
+ a_spans[initialrightheight].count = Q_MININT; // mark end of the spanpackages
D_PolysetDrawSpans8 (a_spans);
// scan out the bottom part of the right edge, if it exists
@@ -885,7 +885,7 @@
prightbottom[0], prightbottom[1]);
d_countextrastep = ubasestep + 1;
- a_spans[initialrightheight + height].count = -999999;
+ a_spans[initialrightheight + height].count = Q_MININT;
// mark end of the spanpackages
D_PolysetDrawSpans8 (pstart);
}
--- a/d_sprite.c
+++ b/d_sprite.c
@@ -374,8 +374,8 @@
// find the top and bottom vertices, and make sure there's at least one scan to
// draw
- ymin = 999999.9;
- ymax = -999999.9;
+ ymin = Q_MAXFLOAT;
+ ymax = -Q_MAXFLOAT;
pverts = r_spritedesc.pverts;
for (i=0 ; i<r_spritedesc.nump ; i++)
--- a/d_surf.c
+++ b/d_surf.c
@@ -108,15 +108,15 @@
qboolean wrapped_this_time;
if ((width < 0) || (width > 256))
- fatal ("D_SCAlloc: bad cache width %d\n", width);
+ Host_Error("D_SCAlloc: bad cache width %d\n", width);
if ((size <= 0) || (size > 0x10000))
- fatal ("D_SCAlloc: bad cache size %zud\n", size);
+ Host_Error("D_SCAlloc: bad cache size %zud\n", size);
size = (uintptr)&((surfcache_t *)0)->data[size];
size = (size + 3) & ~3;
if (size > sc_size)
- fatal ("D_SCAlloc: %zud > cache size",size);
+ Host_Error("D_SCAlloc: %zud > cache size",size);
// if there is not size bytes after the rover, reset to the start
wrapped_this_time = false;
--- a/fs.c
+++ b/fs.c
@@ -444,7 +444,7 @@
free_particles = p->next;
p->next = active_particles;
active_particles = p;
- p->die = 99999;
+ p->die = Q_MAXFLOAT;
p->color = -nv & 15;
p->type = pt_static;
VectorCopy(vec3_origin, p->vel);
--- a/host.c
+++ b/host.c
@@ -288,7 +288,7 @@
// free the client (the body stays around)
host_client->active = false;
host_client->name[0] = 0;
- host_client->old_frags = -999999;
+ host_client->old_frags = Q_MININT;
net_activeconnections--;
// send notification to all clients
--- a/model.c
+++ b/model.c
@@ -44,9 +44,8 @@
Mod_LoadModel (mod, true);
- if (!mod->cache.data){
- fatal ("Mod_Extradata: caching failed: %s", mod->name);
- }
+ if (!mod->cache.data)
+ Host_Error("Mod_Extradata: caching failed: %s", mod->name);
return mod->cache.data;
}
@@ -62,7 +61,7 @@
mplane_t *plane;
if (!model || !model->nodes)
- fatal ("Mod_PointInLeaf: bad model");
+ Host_Error("Mod_PointInLeaf: bad model");
node = model->nodes;
while (1)
@@ -170,7 +169,7 @@
model_t *avail = nil;
if (!name[0])
- fatal ("Mod_FindName: nil name");
+ Host_Error("Mod_FindName: nil name");
//
// search the currently loaded models
@@ -196,7 +195,7 @@
Cache_Free (&mod->cache);
}
else
- fatal ("mod_numknown == MAX_MOD_KNOWN");
+ Host_Error("mod_numknown == MAX_MOD_KNOWN");
}
else
mod_numknown++;
@@ -260,7 +259,7 @@
buf = loadstklmp(mod->name, stackbuf, sizeof stackbuf, nil);
if(buf == nil){
if(crash)
- fatal("Mod_LoadModel: %r");
+ Host_Error("Mod_LoadModel: %r");
return nil;
}
@@ -361,7 +360,7 @@
mt->offsets[j] = LittleLong (mt->offsets[j]);
if ( (mt->width & 15) || (mt->height & 15) )
- fatal ("Texture %s is not 16 aligned", mt->name);
+ Host_Error("Texture %s is not 16 aligned", mt->name);
pixels = mt->width*mt->height/64*85;
tx = Hunk_Alloc(pixels + sizeof *tx);
loadmodel->textures[i] = tx;
@@ -412,7 +411,7 @@
altmax++;
}
else
- fatal ("Bad animating texture %s", tx->name);
+ Host_Error("Bad animating texture %s", tx->name);
for (j=i+1 ; j<m->nummiptex ; j++)
{
@@ -440,7 +439,7 @@
altmax = num+1;
}
else
- fatal ("Bad animating texture %s", tx->name);
+ Host_Error("Bad animating texture %s", tx->name);
}
#define ANIM_CYCLE 2
@@ -449,7 +448,7 @@
{
tx2 = anims[j];
if (!tx2)
- fatal("Missing frame %d of %s", j, tx->name);
+ Host_Error("Missing frame %d of %s", j, tx->name);
tx2->anim_total = max * ANIM_CYCLE;
tx2->anim_min = j * ANIM_CYCLE;
tx2->anim_max = (j+1) * ANIM_CYCLE;
@@ -461,7 +460,7 @@
{
tx2 = altanims[j];
if (!tx2)
- fatal("Missing frame %d of %s", j, tx->name);
+ Host_Error("Missing frame %d of %s", j, tx->name);
tx2->anim_total = altmax * ANIM_CYCLE;
tx2->anim_min = j * ANIM_CYCLE;
tx2->anim_max = (j+1) * ANIM_CYCLE;
@@ -536,7 +535,7 @@
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
- fatal("Mod_LoadVertexes: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadVertexes: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count * sizeof *out);
@@ -564,7 +563,7 @@
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
- fatal("Mod_LoadSubmodels: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadSubmodels: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count * sizeof *out);
@@ -601,7 +600,7 @@
in = (void *)(mod_base + l->fileofs);
sz = ver == BSP2VERSION ? sizeof(bsp2_dedge_t) : sizeof(dedge_t);
if (l->filelen % sz)
- fatal("Mod_LoadEdges: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadEdges: funny lump size in %s", loadmodel->name);
count = l->filelen / sz;
out = Hunk_Alloc((count+1) * sizeof *out);
@@ -630,7 +629,7 @@
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
- fatal("Mod_LoadTexInfo: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadTexInfo: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count * sizeof *out);
@@ -670,7 +669,7 @@
else
{
if (miptex >= loadmodel->numtextures)
- fatal ("miptex >= loadmodel->numtextures");
+ Host_Error("miptex >= loadmodel->numtextures");
out->texture = loadmodel->textures[miptex];
if (!out->texture)
{
@@ -690,17 +689,16 @@
*/
void CalcSurfaceExtents (msurface_t *s)
{
- float mins[2], maxs[2], val;
+ double mins[2], maxs[2], val;
int i,j, e;
mvertex_t *v;
mtexinfo_t *tex;
int bmins[2], bmaxs[2];
- mins[0] = mins[1] = 999999;
- maxs[0] = maxs[1] = -999999;
-
+ mins[0] = mins[1] = Q_MAXFLOAT;
+ maxs[0] = maxs[1] = -Q_MAXFLOAT;
tex = s->texinfo;
-
+
for (i=0 ; i<s->numedges ; i++)
{
e = loadmodel->surfedges[s->firstedge+i];
@@ -711,10 +709,10 @@
for (j=0 ; j<2 ; j++)
{
- val = v->position[0] * tex->vecs[j][0] +
- v->position[1] * tex->vecs[j][1] +
- v->position[2] * tex->vecs[j][2] +
- tex->vecs[j][3];
+ val = (double)v->position[0] * (double)tex->vecs[j][0] +
+ (double)v->position[1] * (double)tex->vecs[j][1] +
+ (double)v->position[2] * (double)tex->vecs[j][2] +
+ (double)tex->vecs[j][3];
if (val < mins[j])
mins[j] = val;
if (val > maxs[j])
@@ -724,13 +722,18 @@
for (i=0 ; i<2 ; i++)
{
- bmins[i] = floor(mins[i]/16);
- bmaxs[i] = ceil(maxs[i]/16);
+ bmins[i] = floor(mins[i]/16.0);
+ bmaxs[i] = ceil(maxs[i]/16.0);
s->texturemins[i] = bmins[i] * 16;
s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
if ( !(tex->flags & TEX_SPECIAL) && s->extents[i] > 256)
- fatal ("Bad surface extents");
+ Host_Error("Bad surface: texture=%s flags=%ux extents[%d]=%d",
+ tex->texture->name,
+ tex->flags,
+ i,
+ s->extents[i]
+ );
}
}
@@ -749,7 +752,7 @@
in = (void *)(mod_base + l->fileofs);
sz = ver == BSP2VERSION ? sizeof(bsp2_dface_t) : sizeof(dface_t);
if (l->filelen % sz)
- fatal("Mod_LoadFaces: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadFaces: funny lump size in %s", loadmodel->name);
count = l->filelen / sz;
out = Hunk_Alloc(count * sizeof *out);
@@ -815,7 +818,7 @@
in = (void *)(mod_base + l->fileofs);
sz = ver == BSP2VERSION ? sizeof(bsp2_dnode_t) : sizeof(dnode_t);
if (l->filelen % sz)
- fatal("Mod_LoadNodes: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadNodes: funny lump size in %s", loadmodel->name);
count = l->filelen / sz;
out = Hunk_Alloc(count * sizeof *out);
@@ -867,7 +870,7 @@
in = (void *)(mod_base + l->fileofs);
sz = ver == BSP2VERSION ? sizeof(bsp2_dleaf_t) : sizeof(dleaf_t);
if (l->filelen % sz)
- fatal("Mod_LoadLeafs: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadLeafs: funny lump size in %s", loadmodel->name);
count = l->filelen / sz;
out = Hunk_Alloc(count * sizeof *out);
@@ -907,7 +910,7 @@
in = (void *)(mod_base + l->fileofs);
sz = ver == BSP2VERSION ? sizeof(bsp2_dclipnode_t) : sizeof(dclipnode_t);
if (l->filelen % sz)
- fatal("Mod_LoadClipnodes: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadClipnodes: funny lump size in %s", loadmodel->name);
count = l->filelen / sz;
out = Hunk_Alloc(count * sizeof *out);
@@ -1003,7 +1006,7 @@
in = (void *)(mod_base + l->fileofs);
sz = ver == BSP2VERSION ? sizeof(u32int) : sizeof(u16int);
if (l->filelen % sz)
- fatal("Mod_LoadMarksurfaces: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadMarksurfaces: funny lump size in %s", loadmodel->name);
count = l->filelen / sz;
out = Hunk_Alloc(count * sizeof *out);
@@ -1014,7 +1017,7 @@
{
j = ver == BSP2VERSION ? le32u(in) : le16u(in);
if(j < 0 || j >= loadmodel->numsurfaces)
- fatal("Mod_ParseMarksurfaces: bad surface number");
+ Host_Error("Mod_ParseMarksurfaces: bad surface number");
out[i] = loadmodel->surfaces + j;
}
}
@@ -1031,7 +1034,7 @@
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
- fatal("Mod_LoadSurfedges: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadSurfedges: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count * sizeof *out);
@@ -1057,7 +1060,7 @@
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
- fatal("Mod_LoadPlanes: funny lump size in %s", loadmodel->name);
+ Host_Error("Mod_LoadPlanes: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count * 2 * sizeof *out);
@@ -1115,7 +1118,7 @@
ver = LittleLong (header->version);
if (ver != BSPVERSION && ver != BSP2VERSION)
- fatal("Mod_LoadBrushModel: %s has wrong version number (%ux should be %ux or %ux)", mod->name, ver, BSPVERSION, BSP2VERSION);
+ Host_Error("Mod_LoadBrushModel: %s has wrong version number (%ux should be %ux or %ux)", mod->name, ver, BSPVERSION, BSP2VERSION);
// swap all the lumps
mod_base = (byte *)header;
@@ -1278,7 +1281,7 @@
{
*poutintervals = LittleFloat (pin_intervals->interval);
if (*poutintervals <= 0.0)
- fatal ("Mod_LoadAliasGroup: interval<=0");
+ Host_Error("Mod_LoadAliasGroup: interval<=0");
poutintervals++;
pin_intervals++;
@@ -1347,7 +1350,7 @@
{
*poutskinintervals = LittleFloat (pinskinintervals->interval);
if (*poutskinintervals <= 0)
- fatal ("Mod_LoadAliasSkinGroup: interval<=0");
+ Host_Error("Mod_LoadAliasSkinGroup: interval<=0");
poutskinintervals++;
pinskinintervals++;
@@ -1389,7 +1392,7 @@
version = LittleLong (pinmodel->version);
if (version != ALIAS_VERSION)
- fatal ("%s has wrong version number (%d should be %d)",
+ Host_Error("%s has wrong version number (%d should be %d)",
mod->name, version, ALIAS_VERSION);
//
@@ -1420,21 +1423,21 @@
pmodel->skinheight = LittleLong (pinmodel->skinheight);
if (pmodel->skinheight > MAX_LBM_HEIGHT)
- fatal ("model %s has a skin taller than %d", mod->name,
+ Host_Error("model %s has a skin taller than %d", mod->name,
MAX_LBM_HEIGHT);
pmodel->numverts = LittleLong (pinmodel->numverts);
if (pmodel->numverts <= 0)
- fatal ("model %s has no vertices", mod->name);
+ Host_Error("model %s has no vertices", mod->name);
if (pmodel->numverts > MAXALIASVERTS)
- fatal ("model %s has too many vertices", mod->name);
+ Host_Error("model %s has too many vertices", mod->name);
pmodel->numtris = LittleLong (pinmodel->numtris);
if (pmodel->numtris <= 0)
- fatal ("model %s has no triangles", mod->name);
+ Host_Error("model %s has no triangles", mod->name);
pmodel->numframes = LittleLong (pinmodel->numframes);
pmodel->size = LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO;
@@ -1452,7 +1455,7 @@
numframes = pmodel->numframes;
if (pmodel->skinwidth & 0x03)
- fatal ("Mod_LoadAliasModel: skinwidth not multiple of 4");
+ Host_Error("Mod_LoadAliasModel: skinwidth not multiple of 4");
//
// load the skins
@@ -1460,7 +1463,7 @@
skinsize = pmodel->skinheight * pmodel->skinwidth;
if (numskins < 1)
- fatal ("Mod_LoadAliasModel: Invalid # of skins: %d\n", numskins);
+ Host_Error("Mod_LoadAliasModel: Invalid # of skins: %d\n", numskins);
pskintype = (daliasskintype_t *)&pinmodel[1];
@@ -1531,7 +1534,7 @@
// load the frames
//
if (numframes < 1)
- fatal ("Mod_LoadAliasModel: Invalid # of frames: %d\n", numframes);
+ Host_Error("Mod_LoadAliasModel: Invalid # of frames: %d\n", numframes);
pframetype = (daliasframetype_t *)&pintriangles[pmodel->numtris];
@@ -1645,7 +1648,7 @@
{
*poutintervals = LittleFloat (pin_intervals->interval);
if (*poutintervals <= 0.0)
- fatal ("Mod_LoadSpriteGroup: interval<=0");
+ Host_Error("Mod_LoadSpriteGroup: interval<=0");
poutintervals++;
pin_intervals++;
@@ -1681,7 +1684,7 @@
version = LittleLong (pin->version);
if (version != SPRITE_VERSION)
- fatal ("%s has wrong version number "
+ Host_Error("%s has wrong version number "
"(%d should be %d)", mod->name, version, SPRITE_VERSION);
numframes = LittleLong (pin->numframes);
@@ -1708,7 +1711,7 @@
// load the frames
//
if (numframes < 1)
- fatal ("Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
+ Host_Error("Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
mod->numframes = numframes;
mod->flags = 0;
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -149,8 +149,8 @@
VectorCopy (min, bounds[0]);
VectorCopy (max, bounds[1]);
- rmin[0] = rmin[1] = rmin[2] = 9999;
- rmax[0] = rmax[1] = rmax[2] = -9999;
+ rmin[0] = rmin[1] = rmin[2] = Q_MAXFLOAT;
+ rmax[0] = rmax[1] = rmax[2] = -Q_MAXFLOAT;
for (i=0 ; i<= 1 ; i++)
{
--- a/r_alias.c
+++ b/r_alias.c
@@ -119,7 +119,7 @@
zclipped = false;
zfullyclipped = true;
- minz = 9999;
+ minz = Q_MAXINT;
for (i=0; i<8 ; i++)
{
R_AliasTransformVector (&basepts[i][0], &viewaux[i].fv[0]);
--- a/r_bsp.c
+++ b/r_bsp.c
@@ -23,8 +23,10 @@
typedef enum {touchessolid, drawnode, nodrawnode} solidstate_t;
-#define MAX_BMODEL_VERTS 1000 // 6K
-#define MAX_BMODEL_EDGES 3000 // 12K
+#define MAX_BMODEL_VERTS 6000
+#define MAX_BMODEL_EDGES 12000
+static mvertex_t bverts[MAX_BMODEL_VERTS];
+static bedge_t bedges[MAX_BMODEL_EDGES];
static mvertex_t *pbverts;
static bedge_t *pbedges;
@@ -314,8 +316,7 @@
msurface_t *psurf;
int numsurfaces;
mplane_t *pplane;
- mvertex_t bverts[MAX_BMODEL_VERTS];
- bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
+ bedge_t *pbedge;
medge_t *pedge, *pedges;
// FIXME: use bounding-box-based frustum clipping info?
--- a/r_sprite.c
+++ b/r_sprite.c
@@ -176,7 +176,7 @@
// transform vertices into viewspace and project
pv = &clip_verts[clip_current][0][0];
- r_spritedesc.nearzi = -999999;
+ r_spritedesc.nearzi = -Q_MAXFLOAT;
for (i=0 ; i<nump ; i++)
{
--- a/screen.c
+++ b/screen.c
@@ -114,7 +114,7 @@
if (cl.intermission)
remaining = scr_printspeed.value * (cl.time - scr_centertime_start);
else
- remaining = 9999;
+ remaining = Q_MAXINT;
scr_erase_center = 0;
start = scr_centerstring;
--- a/world.c
+++ b/world.c
@@ -792,8 +792,8 @@
void SV_MoveBounds (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, vec3_t boxmins, vec3_t boxmaxs)
{
/* debug to test against everything
- boxmins[0] = boxmins[1] = boxmins[2] = -9999;
- boxmaxs[0] = boxmaxs[1] = boxmaxs[2] = 9999;
+ boxmins[0] = boxmins[1] = boxmins[2] = -Q_MAXFLOAT;
+ boxmaxs[0] = boxmaxs[1] = boxmaxs[2] = Q_MAXFLOAT;
*/
int i;