don't Sys_Error on invalid translation, BSP (HL/Q1/H2) loading will no longer Sys_Error

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2098 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-03-12 22:01:49 +00:00
parent 29c316a31e
commit 28979e3d12
5 changed files with 443 additions and 167 deletions

View file

@ -2635,7 +2635,7 @@ void CL_NewTranslation (int slot)
player_info_t *player;
if (slot >= MAX_CLIENTS)
Sys_Error ("CL_NewTranslation: slot > MAX_CLIENTS");
Host_Error ("CL_NewTranslation: slot > MAX_CLIENTS");
player = &cl.players[slot];

View file

@ -30,16 +30,16 @@ extern qboolean r_usinglits;
extern cvar_t r_shadow_bumpscale_basetexture;
//these are in model.c (or gl_model.c)
void GLMod_LoadVertexes (lump_t *l);
void GLMod_LoadEdges (lump_t *l);
void GLMod_LoadMarksurfaces (lump_t *l);
void GLMod_LoadSurfedges (lump_t *l);
qboolean GLMod_LoadVertexes (lump_t *l);
qboolean GLMod_LoadEdges (lump_t *l);
qboolean GLMod_LoadMarksurfaces (lump_t *l);
qboolean GLMod_LoadSurfedges (lump_t *l);
void GLMod_LoadLighting (lump_t *l);
void SWMod_LoadVertexes (lump_t *l);
void SWMod_LoadEdges (lump_t *l);
void SWMod_LoadMarksurfaces (lump_t *l);
void SWMod_LoadSurfedges (lump_t *l);
qboolean SWMod_LoadVertexes (lump_t *l);
qboolean SWMod_LoadEdges (lump_t *l);
qboolean SWMod_LoadMarksurfaces (lump_t *l);
qboolean SWMod_LoadSurfedges (lump_t *l);
void SWMod_LoadLighting (lump_t *l);
@ -3462,6 +3462,8 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
int length;
static unsigned last_checksum;
qboolean useshaders;
qboolean noerrors = true;
int start;
// free old stuff
numplanes = 0;
@ -3489,7 +3491,10 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
buf = (unsigned *)filein;
length = com_filesize;
if (!buf)
Host_Error ("Couldn't load %s", name);
{
Con_Printf (S_ERROR "Couldn't load %s\n", name);
return NULL;
}
last_checksum = LittleLong (Com_BlockChecksum (buf, length));
*checksum = last_checksum;
@ -3503,9 +3508,9 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
switch(header.version)
{
default:
if (header.version != Q2BSPVERSION && header.version != Q3BSPVERSION)
Host_Error ("Quake 2 or Quake 3 based BSP with unknown header (%i should be %i or %i)"
Con_Printf (S_ERROR "Quake 2 or Quake 3 based BSP with unknown header (%i should be %i or %i)\n"
, name, header.version, Q2BSPVERSION, Q3BSPVERSION);
return NULL;
break;
#if 1
case 1: //rbsp
@ -3665,13 +3670,15 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
#ifdef SERVERONLY
SV_Error("Cannot load q3bsps with the current renderer (only dedicated and opengl renderer)\n");
#else
Host_EndGame("Cannot load q3bsps with the current renderer (only dedicated and opengl renderer)\n");
Con_Printf(S_ERROR "Cannot load q3bsps with the current renderer (only dedicated and opengl renderer)\n");
return NULL;
#endif
}
break;
#endif
case Q2BSPVERSION:
mapisq3 = false;
start = Hunk_LowMark();
for (i=0 ; i<Q2HEADER_LUMPS ; i++)
{
header.lumps[i].filelen = LittleLong (header.lumps[i].filelen);
@ -3719,10 +3726,11 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
case QR_OPENGL:
// load into heap
#ifndef SERVERONLY
GLMod_LoadVertexes (&header.lumps[Q2LUMP_VERTEXES]);
GLMod_LoadEdges (&header.lumps[Q2LUMP_EDGES]);
GLMod_LoadSurfedges (&header.lumps[Q2LUMP_SURFEDGES]);
GLMod_LoadLighting (&header.lumps[Q2LUMP_LIGHTING]);
noerrors = noerrors && GLMod_LoadVertexes (&header.lumps[Q2LUMP_VERTEXES]);
noerrors = noerrors && GLMod_LoadEdges (&header.lumps[Q2LUMP_EDGES]);
noerrors = noerrors && GLMod_LoadSurfedges (&header.lumps[Q2LUMP_SURFEDGES]);
if (noerrors)
GLMod_LoadLighting (&header.lumps[Q2LUMP_LIGHTING]);
#endif
CMod_LoadSurfaces (&header.lumps[Q2LUMP_TEXINFO]);
CMod_LoadLeafBrushes (&header.lumps[Q2LUMP_LEAFBRUSHES]);
@ -3730,7 +3738,7 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
#ifndef SERVERONLY
CMod_LoadTexInfo (&header.lumps[Q2LUMP_TEXINFO]);
CMod_LoadFaces (&header.lumps[Q2LUMP_FACES]);
GLMod_LoadMarksurfaces (&header.lumps[Q2LUMP_LEAFFACES]);
noerrors = noerrors && GLMod_LoadMarksurfaces (&header.lumps[Q2LUMP_LEAFFACES]);
#endif
CMod_LoadVisibility (&header.lumps[Q2LUMP_VISIBILITY]);
CMod_LoadBrushes (&header.lumps[Q2LUMP_BRUSHES]);
@ -3741,6 +3749,12 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
CMod_LoadAreas (&header.lumps[Q2LUMP_AREAS]);
CMod_LoadAreaPortals (&header.lumps[Q2LUMP_AREAPORTALS]);
CMod_LoadEntityString (&header.lumps[Q2LUMP_ENTITIES]);
if (!noerrors)
{
Hunk_FreeToLowMark(start);
return NULL;
}
#ifndef CLIENTONLY
loadmodel->funcs.FatPVS = Q2BSP_FatPVS;
loadmodel->funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS;
@ -3761,10 +3775,11 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
case QR_SOFTWARE:
// load into heap
#ifndef SERVERONLY
SWMod_LoadVertexes (&header.lumps[Q2LUMP_VERTEXES]);
SWMod_LoadEdges (&header.lumps[Q2LUMP_EDGES]);
SWMod_LoadSurfedges (&header.lumps[Q2LUMP_SURFEDGES]);
SWMod_LoadLighting (&header.lumps[Q2LUMP_LIGHTING]);
noerrors = noerrors && SWMod_LoadVertexes (&header.lumps[Q2LUMP_VERTEXES]);
noerrors = noerrors && SWMod_LoadEdges (&header.lumps[Q2LUMP_EDGES]);
noerrors = noerrors && SWMod_LoadSurfedges (&header.lumps[Q2LUMP_SURFEDGES]);
if (noerrors)
SWMod_LoadLighting (&header.lumps[Q2LUMP_LIGHTING]);
#endif
CMod_LoadSurfaces (&header.lumps[Q2LUMP_TEXINFO]);
CMod_LoadLeafBrushes (&header.lumps[Q2LUMP_LEAFBRUSHES]);
@ -3772,7 +3787,7 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
#ifndef SERVERONLY
CMod_LoadTexInfo (&header.lumps[Q2LUMP_TEXINFO]);
CMod_LoadFaces (&header.lumps[Q2LUMP_FACES]);
SWMod_LoadMarksurfaces (&header.lumps[Q2LUMP_LEAFFACES]);
noerrors = noerrors && SWMod_LoadMarksurfaces (&header.lumps[Q2LUMP_LEAFFACES]);
#endif
CMod_LoadVisibility (&header.lumps[Q2LUMP_VISIBILITY]);
CMod_LoadBrushes (&header.lumps[Q2LUMP_BRUSHES]);
@ -3784,6 +3799,11 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
CMod_LoadAreaPortals (&header.lumps[Q2LUMP_AREAPORTALS]);
CMod_LoadEntityString (&header.lumps[Q2LUMP_ENTITIES]);
if (!noerrors)
{
Hunk_FreeToLowMark(start);
return NULL;
}
loadmodel->funcs.FatPVS = Q2BSP_FatPVS;
loadmodel->funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS;
@ -5620,10 +5640,10 @@ void Q2BSP_SetHullFuncs(hull_t *hull)
int map_checksum;
void Mod_LoadQ2BrushModel (model_t *mod, void *buffer)
qboolean Mod_LoadQ2BrushModel (model_t *mod, void *buffer)
{
mod->fromgame = fg_quake2;
CM_LoadMap(mod->name, buffer, true, &map_checksum);
return CM_LoadMap(mod->name, buffer, true, &map_checksum) != NULL;
}
void CM_Init(void) //register cvars.

View file

@ -51,9 +51,9 @@ qboolean GL_LoadHeightmapModel (model_t *mod, void *buffer);
qboolean GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer);
void GLMod_LoadSpriteModel (model_t *mod, void *buffer);
void GLMod_LoadSprite2Model (model_t *mod, void *buffer);
void GLMod_LoadBrushModel (model_t *mod, void *buffer);
qboolean GLMod_LoadBrushModel (model_t *mod, void *buffer);
#ifdef Q2BSPS
void Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
qboolean Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
#endif
qboolean Mod_LoadHLModel (model_t *mod, void *buffer);
#ifdef ZYMOTICMODELS
@ -442,7 +442,8 @@ model_t *GLMod_LoadModel (model_t *mod, qboolean crash)
#ifdef Q2BSPS
if (!*mod->name)
{
Mod_LoadQ2BrushModel (mod, buf);
if (!Mod_LoadQ2BrushModel (mod, buf))
goto couldntload;
mod->needload = false;
P_DefaultTrail(mod);
return mod;
@ -556,7 +557,8 @@ couldntload:
#ifdef Q2BSPS
case ('R'<<0)+('B'<<8)+('S'<<16)+('P'<<24):
case IDBSPHEADER: //looks like id switched to have proper ids
Mod_LoadQ2BrushModel (mod, buf);
if (!Mod_LoadQ2BrushModel (mod, buf))
goto couldntload;
break;
#endif
#ifdef HALFLIFEMODELS
@ -580,7 +582,8 @@ couldntload:
case 30: //hl
case 29: //q1
case 28: //prerel
GLMod_LoadBrushModel (mod, buf);
if (!GLMod_LoadBrushModel (mod, buf))
goto couldntload;
break;
#ifdef ZYMOTICMODELS
case (('O'<<24)+('M'<<16)+('Y'<<8)+'Z'):
@ -844,7 +847,7 @@ void GLMod_LoadAdvancedTexture(char *name, int *base, int *norm, int *luma, int
Mod_LoadTextures
=================
*/
void GLMod_LoadTextures (lump_t *l)
qboolean GLMod_LoadTextures (lump_t *l)
{
extern cvar_t gl_shadeq1, gl_shadeq1_name;
extern int gl_bumpmappingpossible;
@ -865,7 +868,7 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
if (!l->filelen)
{
loadmodel->textures = NULL;
return;
return true;
}
m = (dmiptexlump_t *)(mod_base + l->fileofs);
@ -886,7 +889,7 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
if (!*mt->name) //I HATE MAPPERS!
{
sprintf(mt->name, "unnamed%i", i);
Con_Printf("warning: unnamed texture in %s, renaming to %s\n", loadmodel->name, mt->name);
Con_Printf(S_WARNING "warning: unnamed texture in %s, renaming to %s\n", loadmodel->name, mt->name);
}
mt->width = LittleLong (mt->width);
@ -895,9 +898,9 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
mt->offsets[j] = LittleLong (mt->offsets[j]);
if ( (mt->width & 15) || (mt->height & 15) )
Con_Printf ("Warning: Texture %s is not 16 aligned", mt->name);
Con_Printf (S_WARNING "Warning: Texture %s is not 16 aligned", mt->name);
if (mt->width < 1 || mt->height < 1)
Con_Printf ("Warning: Texture %s has no size", mt->name);
Con_Printf (S_WARNING "Warning: Texture %s has no size", mt->name);
pixels = mt->width*mt->height/64*85;
tx = Hunk_AllocName (sizeof(texture_t)/* +pixels*/, loadname );
loadmodel->textures[i] = tx;
@ -1067,7 +1070,10 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
altmax++;
}
else
Sys_Error ("Bad animating texture %s", tx->name);
{
Con_Printf (S_ERROR "Bad animating texture %s\n", tx->name);
return false;
}
for (j=i+1 ; j<m->nummiptex ; j++)
{
@ -1095,7 +1101,10 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
altmax = num+1;
}
else
Sys_Error ("Bad animating texture %s", tx->name);
{
Con_Printf (S_ERROR "Bad animating texture %s\n", tx->name);
return false;
}
}
#define ANIM_CYCLE 2
@ -1104,7 +1113,10 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
{
tx2 = anims[j];
if (!tx2)
Sys_Error ("Missing frame %i of %s",j, tx->name);
{
Con_Printf (S_ERROR "Missing frame %i of %s\n",j, tx->name);
return false;
}
tx2->anim_total = max * ANIM_CYCLE;
tx2->anim_min = j * ANIM_CYCLE;
tx2->anim_max = (j+1) * ANIM_CYCLE;
@ -1116,7 +1128,10 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
{
tx2 = altanims[j];
if (!tx2)
Sys_Error ("Missing frame %i of %s",j, tx->name);
{
Con_Printf (S_ERROR "Missing frame %i of %s\n",j, tx->name);
return false;
}
tx2->anim_total = altmax * ANIM_CYCLE;
tx2->anim_min = j * ANIM_CYCLE;
tx2->anim_max = (j+1) * ANIM_CYCLE;
@ -1125,6 +1140,8 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
tx2->alternate_anims = anims[0];
}
}
return true;
}
void GLMod_NowLoadExternal(void)
@ -1494,7 +1511,7 @@ void GLMod_LoadEntities (lump_t *l)
Mod_LoadVertexes
=================
*/
void GLMod_LoadVertexes (lump_t *l)
qboolean GLMod_LoadVertexes (lump_t *l)
{
dvertex_t *in;
mvertex_t *out;
@ -1502,7 +1519,10 @@ void GLMod_LoadVertexes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n", loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1515,6 +1535,8 @@ void GLMod_LoadVertexes (lump_t *l)
out->position[1] = LittleFloat (in->point[1]);
out->position[2] = LittleFloat (in->point[2]);
}
return true;
}
/*
@ -1523,7 +1545,7 @@ Mod_LoadSubmodels
=================
*/
static qboolean hexen2map;
void GLMod_LoadSubmodels (lump_t *l)
qboolean GLMod_LoadSubmodels (lump_t *l)
{
dq1model_t *inq;
dh2model_t *inh;
@ -1538,7 +1560,10 @@ void GLMod_LoadSubmodels (lump_t *l)
{
hexen2map = true;
if (l->filelen % sizeof(*inh))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*inh);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1573,7 +1598,10 @@ void GLMod_LoadSubmodels (lump_t *l)
{
hexen2map = false;
if (l->filelen % sizeof(*inq))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*inq);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1603,6 +1631,8 @@ void GLMod_LoadSubmodels (lump_t *l)
out->numfaces = LittleLong (inq->numfaces);
}
}
return true;
}
/*
@ -1610,7 +1640,7 @@ void GLMod_LoadSubmodels (lump_t *l)
Mod_LoadEdges
=================
*/
void GLMod_LoadEdges (lump_t *l)
qboolean GLMod_LoadEdges (lump_t *l)
{
dedge_t *in;
medge_t *out;
@ -1618,7 +1648,10 @@ void GLMod_LoadEdges (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf ("MOD_LoadBmodel: funny lump size in %s\n", loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count + 1) * sizeof(*out), loadname);
@ -1630,6 +1663,8 @@ void GLMod_LoadEdges (lump_t *l)
out->v[0] = (unsigned short)LittleShort(in->v[0]);
out->v[1] = (unsigned short)LittleShort(in->v[1]);
}
return true;
}
/*
@ -1637,7 +1672,7 @@ void GLMod_LoadEdges (lump_t *l)
Mod_LoadTexinfo
=================
*/
void GLMod_LoadTexinfo (lump_t *l)
qboolean GLMod_LoadTexinfo (lump_t *l)
{
texinfo_t *in;
mtexinfo_t *out;
@ -1647,7 +1682,10 @@ void GLMod_LoadTexinfo (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1694,6 +1732,8 @@ void GLMod_LoadTexinfo (lump_t *l)
}
}
}
return true;
}
/*
@ -1758,7 +1798,7 @@ void CalcSurfaceExtents (msurface_t *s);
Mod_LoadFaces
=================
*/
void GLMod_LoadFaces (lump_t *l)
qboolean GLMod_LoadFaces (lump_t *l)
{
dface_t *in;
msurface_t *out;
@ -1768,7 +1808,10 @@ void GLMod_LoadFaces (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1841,6 +1884,8 @@ void GLMod_LoadFaces (lump_t *l)
if (out->flags & SURF_DRAWALPHA)
out->flags &= ~SURF_DRAWALPHA;
}
return true;
}
@ -1865,7 +1910,7 @@ void GLMod_SetParent (mnode_t *node, mnode_t *parent)
Mod_LoadNodes
=================
*/
void GLMod_LoadNodes (lump_t *l)
qboolean GLMod_LoadNodes (lump_t *l)
{
int i, j, count, p;
dnode_t *in;
@ -1873,7 +1918,10 @@ void GLMod_LoadNodes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1905,6 +1953,7 @@ void GLMod_LoadNodes (lump_t *l)
}
GLMod_SetParent (loadmodel->nodes, NULL); // sets nodes and leafs
return true;
}
/*
@ -1912,7 +1961,7 @@ void GLMod_LoadNodes (lump_t *l)
Mod_LoadLeafs
=================
*/
void GLMod_LoadLeafs (lump_t *l)
qboolean GLMod_LoadLeafs (lump_t *l)
{
dleaf_t *in;
mleaf_t *out;
@ -1921,7 +1970,10 @@ void GLMod_LoadLeafs (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1970,6 +2022,8 @@ void GLMod_LoadLeafs (lump_t *l)
}
}
}
return true;
}
@ -2054,7 +2108,7 @@ void GLMod_LoadCrouchHull(void)
Mod_LoadClipnodes
=================
*/
void GLMod_LoadClipnodes (lump_t *l)
qboolean GLMod_LoadClipnodes (lump_t *l)
{
dclipnode_t *in, *out;
int i, count;
@ -2062,7 +2116,10 @@ void GLMod_LoadClipnodes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count+numsuplementryclipnodes)*sizeof(*out), loadname);//space for both
@ -2251,6 +2308,8 @@ void GLMod_LoadClipnodes (lump_t *l)
out->children[1] += out->children[1]>=0?1:0;
}
}
return true;
}
/*
@ -2297,7 +2356,7 @@ void GLMod_MakeHull0 (void)
Mod_LoadMarksurfaces
=================
*/
void GLMod_LoadMarksurfaces (lump_t *l)
qboolean GLMod_LoadMarksurfaces (lump_t *l)
{
int i, j, count;
short *in;
@ -2305,7 +2364,10 @@ void GLMod_LoadMarksurfaces (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -2316,9 +2378,14 @@ void GLMod_LoadMarksurfaces (lump_t *l)
{
j = LittleShort(in[i]);
if (j < 0 || j >= loadmodel->numsurfaces)
Sys_Error ("Mod_ParseMarksurfaces: bad surface number");
{
Con_Printf (S_ERROR "Mod_ParseMarksurfaces: bad surface number\n");
return false;
}
out[i] = loadmodel->surfaces + j;
}
return true;
}
/*
@ -2326,14 +2393,17 @@ void GLMod_LoadMarksurfaces (lump_t *l)
Mod_LoadSurfedges
=================
*/
void GLMod_LoadSurfedges (lump_t *l)
qboolean GLMod_LoadSurfedges (lump_t *l)
{
int i, count;
int *in, *out;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -2342,6 +2412,8 @@ void GLMod_LoadSurfedges (lump_t *l)
for ( i=0 ; i<count ; i++)
out[i] = LittleLong (in[i]);
return true;
}
@ -2350,7 +2422,7 @@ void GLMod_LoadSurfedges (lump_t *l)
Mod_LoadPlanes
=================
*/
void GLMod_LoadPlanes (lump_t *l)
qboolean GLMod_LoadPlanes (lump_t *l)
{
int i, j;
mplane_t *out;
@ -2360,7 +2432,10 @@ void GLMod_LoadPlanes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count+numsuplementryplanes)*2*sizeof(*out), loadname);
@ -2401,6 +2476,8 @@ void GLMod_LoadPlanes (lump_t *l)
out->signbits = bits;
}
}
return true;
}
/*
@ -2474,14 +2551,18 @@ void GLQ1BSP_LightPointValues(vec3_t point, vec3_t res_diffuse, vec3_t res_ambie
Mod_LoadBrushModel
=================
*/
void GLMod_LoadBrushModel (model_t *mod, void *buffer)
qboolean GLMod_LoadBrushModel (model_t *mod, void *buffer)
{
int i, j;
dheader_t *header;
mmodel_t *bm;
model_t *lm=mod;
unsigned int chksum;
int start;
qboolean noerrors;
start = Hunk_LowMark();
loadmodel->type = mod_brush;
header = (dheader_t *)buffer;
@ -2502,7 +2583,10 @@ void GLMod_LoadBrushModel (model_t *mod, void *buffer)
else if (i == BSPVERSIONHL) //halflife support
loadmodel->fromgame = fg_halflife;
else
Sys_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
{
Con_Printf (S_ERROR "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)\n", mod->name, i, BSPVERSION);
return false;
}
// swap all the lumps
mod_base = (qbyte *)header;
@ -2537,34 +2621,44 @@ void GLMod_LoadBrushModel (model_t *mod, void *buffer)
mod->checksum2 ^= chksum;
}
noerrors = true;
crouchhullfile = NULL;
// load into heap
#ifndef CLIENTONLY
if (!isDedicated)
#endif
{
GLMod_LoadVertexes (&header->lumps[LUMP_VERTEXES]);
GLMod_LoadEdges (&header->lumps[LUMP_EDGES]);
GLMod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]);
GLMod_LoadTextures (&header->lumps[LUMP_TEXTURES]);
GLMod_LoadLighting (&header->lumps[LUMP_LIGHTING]);
noerrors = noerrors && GLMod_LoadVertexes (&header->lumps[LUMP_VERTEXES]);
noerrors = noerrors && GLMod_LoadEdges (&header->lumps[LUMP_EDGES]);
noerrors = noerrors && GLMod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]);
noerrors = noerrors && GLMod_LoadTextures (&header->lumps[LUMP_TEXTURES]);
if (noerrors)
GLMod_LoadLighting (&header->lumps[LUMP_LIGHTING]);
}
GLMod_LoadSubmodels (&header->lumps[LUMP_MODELS]);
GLMod_LoadCrouchHull();
GLMod_LoadPlanes (&header->lumps[LUMP_PLANES]);
noerrors = noerrors && GLMod_LoadSubmodels (&header->lumps[LUMP_MODELS]);
if (noerrors)
GLMod_LoadCrouchHull();
noerrors = noerrors && GLMod_LoadPlanes (&header->lumps[LUMP_PLANES]);
#ifndef CLIENTONLY
if (!isDedicated)
#endif
{
GLMod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
GLMod_LoadFaces (&header->lumps[LUMP_FACES]);
GLMod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]);
noerrors = noerrors && GLMod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
noerrors = noerrors && GLMod_LoadFaces (&header->lumps[LUMP_FACES]);
noerrors = noerrors && GLMod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]);
}
GLMod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]);
GLMod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
GLMod_LoadNodes (&header->lumps[LUMP_NODES]);
GLMod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]);
GLMod_LoadEntities (&header->lumps[LUMP_ENTITIES]);
GLMod_MakeHull0 ();
if (noerrors)
GLMod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]);
noerrors = noerrors && GLMod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
noerrors = noerrors && GLMod_LoadNodes (&header->lumps[LUMP_NODES]);
noerrors = noerrors && GLMod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]);
if (noerrors)
{
GLMod_LoadEntities (&header->lumps[LUMP_ENTITIES]);
GLMod_MakeHull0 ();
}
if (crouchhullfile)
{
@ -2572,6 +2666,12 @@ void GLMod_LoadBrushModel (model_t *mod, void *buffer)
crouchhullfile=NULL;
}
if (!noerrors)
{
Hunk_FreeToLowMark(start);
return false;
}
#ifndef CLIENTONLY
if (sv.state) //if the server is running
{
@ -2642,6 +2742,8 @@ void GLMod_LoadBrushModel (model_t *mod, void *buffer)
if (lightmodel == lm)
LightLoadEntities(lightmodel->entities);
#endif
return true;
}
/*

View file

@ -25,8 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
model_t *loadmodel;
char loadname[32]; // for hunk tags
void Mod_LoadBrushModel (model_t *mod, void *buffer);
void Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
qboolean Mod_LoadBrushModel (model_t *mod, void *buffer);
qboolean Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
qboolean GL_LoadQ1Model (model_t *mod, void *buffer);
qboolean GL_LoadQ2Model (model_t *mod, void *buffer);
@ -279,49 +279,53 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash)
{
#if defined(Q2BSPS)
case IDBSPHEADER: //looks like id switched to have proper ids
Mod_LoadQ2BrushModel (mod, buf);
if (!Mod_LoadQ2BrushModel (mod, buf))
goto couldntload;
break;
#endif
case BSPVERSIONPREREL:
case BSPVERSION:
case BSPVERSIONHL:
Mod_LoadBrushModel (mod, buf);
if (!Mod_LoadBrushModel (mod, buf))
goto couldntload;
break;
case IDPOLYHEADER:
if (!GL_LoadQ1Model(mod, buf))
return NULL;
goto couldntload;
break;
#ifdef MD2MODELS
case MD2IDALIASHEADER:
if (!GL_LoadQ2Model(mod, buf))
return NULL;
goto couldntload;
break;
#endif
#ifdef MD3MODELS
case MD3_IDENT:
if (!GL_LoadQ3Model (mod, buf))
return NULL;
goto couldntload;
break;
#endif
#ifdef ZYMOTICMODELS
case (('O'<<24)+('M'<<16)+('Y'<<8)+'Z'):
if (!GLMod_LoadZymoticModel(mod, buf))
return NULL;
goto couldntload;
break;
#endif
#ifdef ZYMOTICMODELS
case (('K'<<24)+('R'<<16)+('A'<<8)+'D'):
if (!GLMod_LoadDarkPlacesModel(mod, buf))
return NULL;
goto couldntload;
break;
#endif
default:
Con_Printf (S_ERROR "Mod_NumForName: %s: format not recognised\n", mod->name);
couldntload:
if (crash)
SV_Error ("Mod_NumForName: %s: format not recognised", mod->name);
SV_Error ("Load failed on critical model %s", mod->name);
return NULL;
}
@ -591,7 +595,7 @@ Mod_LoadSubmodels
=================
*/
static qboolean hexen2map;
void Mod_LoadSubmodels (lump_t *l)
qboolean Mod_LoadSubmodels (lump_t *l)
{
dq1model_t *inq;
dh2model_t *inh;
@ -606,7 +610,10 @@ void Mod_LoadSubmodels (lump_t *l)
{
hexen2map = true;
if (l->filelen % sizeof(*inh))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*inh);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -641,7 +648,10 @@ void Mod_LoadSubmodels (lump_t *l)
{
hexen2map = false;
if (l->filelen % sizeof(*inq))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*inq);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -671,6 +681,8 @@ void Mod_LoadSubmodels (lump_t *l)
out->numfaces = LittleLong (inq->numfaces);
}
}
return true;
}
/*
@ -909,7 +921,7 @@ void Mod_SetParent (mnode_t *node, mnode_t *parent)
Mod_LoadNodes
=================
*/
void Mod_LoadNodes (lump_t *l)
qboolean Mod_LoadNodes (lump_t *l)
{
int i, j, count, p;
dnode_t *in;
@ -917,7 +929,10 @@ void Mod_LoadNodes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -949,6 +964,8 @@ void Mod_LoadNodes (lump_t *l)
}
Mod_SetParent (loadmodel->nodes, NULL); // sets nodes and leafs
return true;
}
/*
@ -956,7 +973,7 @@ void Mod_LoadNodes (lump_t *l)
Mod_LoadLeafs
=================
*/
void Mod_LoadLeafs (lump_t *l)
qboolean Mod_LoadLeafs (lump_t *l)
{
dleaf_t *in;
mleaf_t *out;
@ -964,7 +981,10 @@ void Mod_LoadLeafs (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -996,6 +1016,8 @@ void Mod_LoadLeafs (lump_t *l)
for (j=0 ; j<4 ; j++)
out->ambient_sound_level[j] = in->ambient_level[j];
}
return true;
}
/*
@ -1003,7 +1025,7 @@ void Mod_LoadLeafs (lump_t *l)
Mod_LoadClipnodes
=================
*/
void Mod_LoadClipnodes (lump_t *l)
qboolean Mod_LoadClipnodes (lump_t *l)
{
dclipnode_t *in, *out;
int i, count;
@ -1011,7 +1033,10 @@ void Mod_LoadClipnodes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1107,6 +1132,8 @@ void Mod_LoadClipnodes (lump_t *l)
out->children[0] = LittleShort(in->children[0]);
out->children[1] = LittleShort(in->children[1]);
}
return true;
}
/*
@ -1205,7 +1232,7 @@ void Mod_LoadSurfedges (lump_t *l)
Mod_LoadPlanes
=================
*/
void Mod_LoadPlanes (lump_t *l)
qboolean Mod_LoadPlanes (lump_t *l)
{
int i, j;
mplane_t *out;
@ -1215,7 +1242,10 @@ void Mod_LoadPlanes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*2*sizeof(*out), loadname);
@ -1236,6 +1266,8 @@ void Mod_LoadPlanes (lump_t *l)
out->type = LittleLong (in->type);
out->signbits = bits;
}
return true;
}
/*
@ -1243,12 +1275,16 @@ void Mod_LoadPlanes (lump_t *l)
Mod_LoadBrushModel
=================
*/
void Mod_LoadBrushModel (model_t *mod, void *buffer)
qboolean Mod_LoadBrushModel (model_t *mod, void *buffer)
{
int i, j;
dheader_t *header;
mmodel_t *bm;
unsigned int chksum;
int start;
qboolean noerrors;
start = Hunk_LowMark();
loadmodel->type = mod_brush;
@ -1262,7 +1298,10 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
else if (i == BSPVERSIONHL)
loadmodel->fromgame = fg_halflife;
else
SV_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
{
Con_Printf (S_ERROR "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)\n", mod->name, i, BSPVERSION);
return false;
}
// swap all the lumps
mod_base = (qbyte *)header;
@ -1288,23 +1327,33 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
mod->checksum2 ^= chksum;
}
noerrors = true;
// Mod_LoadVertexes (&header->lumps[LUMP_VERTEXES]);
// Mod_LoadEdges (&header->lumps[LUMP_EDGES]);
// Mod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]);
///*/on server?*/ Mod_LoadTextures (&header->lumps[LUMP_TEXTURES]);
// Mod_LoadLighting (&header->lumps[LUMP_LIGHTING]);
Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]);
Mod_LoadPlanes (&header->lumps[LUMP_PLANES]);
noerrors = noerrors && Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]);
noerrors = noerrors && Mod_LoadPlanes (&header->lumps[LUMP_PLANES]);
///*/on server?*/ Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
// Mod_LoadFaces (&header->lumps[LUMP_FACES]);
// Mod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]);
Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]);
Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
Mod_LoadNodes (&header->lumps[LUMP_NODES]);
Mod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]);
Mod_LoadEntities (&header->lumps[LUMP_ENTITIES]);
if (noerrors)
Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]);
noerrors = noerrors && Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
noerrors = noerrors && Mod_LoadNodes (&header->lumps[LUMP_NODES]);
noerrors = noerrors && Mod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]);
if (noerrors)
{
Mod_LoadEntities (&header->lumps[LUMP_ENTITIES]);
Mod_MakeHull0 ();
}
Mod_MakeHull0 ();
if (!noerrors)
{
Hunk_FreeToLowMark(start);
return false;
}
Q1BSP_SetModelFuncs(mod);
@ -1345,6 +1394,8 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
mod = loadmodel;
}
}
return true;
}

View file

@ -30,8 +30,8 @@ char loadname[32]; // for hunk tags
void SWMod_LoadSpriteModel (model_t *mod, void *buffer);
void SWMod_LoadSprite2Model (model_t *mod, void *buffer);
void SWMod_LoadBrushModel (model_t *mod, void *buffer);
void Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
qboolean SWMod_LoadBrushModel (model_t *mod, void *buffer);
qboolean Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer);
qboolean SWMod_LoadAlias2Model (model_t *mod, void *buffer);
qboolean SWMod_LoadAlias3Model (model_t *mod, void *buffer);
@ -294,8 +294,9 @@ model_t *SWMod_LoadModel (model_t *mod, qboolean crash)
if (!*mod->name)
{
loadmodel = mod;
if (!Mod_LoadQ2BrushModel(mod, NULL))
goto couldntload;
mod->needload = false;
Mod_LoadQ2BrushModel(mod, NULL);
P_DefaultTrail(mod);
return mod;
}
@ -399,14 +400,16 @@ model_t *SWMod_LoadModel (model_t *mod, qboolean crash)
#endif
#ifdef Q2BSPS
case IDBSPHEADER: //looks like id switched to have proper ids
Mod_LoadQ2BrushModel (mod, buf);
if (!Mod_LoadQ2BrushModel (mod, buf))
goto couldntload;
break;
#endif
case BSPVERSIONHL:
case BSPVERSION: //hmm.
case BSPVERSIONPREREL:
SWMod_LoadBrushModel (mod, buf);
if (!SWMod_LoadBrushModel (mod, buf))
goto couldntload;
break;
default: //some telejano mods can do this
@ -467,7 +470,7 @@ Mod_LoadTextures
=================
*/
#ifndef SERVERONLY
void SWMod_LoadTextures (lump_t *l)
qboolean SWMod_LoadTextures (lump_t *l)
{
int i, j, pixels, num, max, altmax;
miptex_t *mt;
@ -479,7 +482,7 @@ void SWMod_LoadTextures (lump_t *l)
if (!l->filelen)
{
loadmodel->textures = NULL;
return;
return true;
}
m = (dmiptexlump_t *)(mod_base + l->fileofs);
@ -500,7 +503,10 @@ void SWMod_LoadTextures (lump_t *l)
mt->offsets[j] = LittleLong (mt->offsets[j]);
if ( (mt->width & 15) || (mt->height & 15) )
Sys_Error ("Texture %s is not 16 aligned", mt->name);
{
Con_Printf (S_ERROR "Texture %s is not 16 aligned\n", mt->name);
return false;
}
if (!mt->offsets[0]) //external hl texture.
{
@ -654,7 +660,10 @@ void SWMod_LoadTextures (lump_t *l)
altmax++;
}
else
Sys_Error ("Bad animating texture %s", tx->name);
{
Con_Printf (S_ERROR "Bad animating texture %s\n", tx->name);
return false;
}
for (j=i+1 ; j<m->nummiptex ; j++)
{
@ -682,7 +691,10 @@ void SWMod_LoadTextures (lump_t *l)
altmax = num+1;
}
else
Sys_Error ("Bad animating texture %s", tx->name);
{
Con_Printf (S_ERROR "Bad animating texture %s\n", tx->name);
return false;
}
}
#define ANIM_CYCLE 2
@ -691,7 +703,10 @@ void SWMod_LoadTextures (lump_t *l)
{
tx2 = anims[j];
if (!tx2)
Sys_Error ("Missing frame %i of %s",j, tx->name);
{
Con_Printf (S_ERROR "Missing frame %i of %s\n",j, tx->name);
return false;
}
tx2->anim_total = max * ANIM_CYCLE;
tx2->anim_min = j * ANIM_CYCLE;
tx2->anim_max = (j+1) * ANIM_CYCLE;
@ -703,7 +718,10 @@ void SWMod_LoadTextures (lump_t *l)
{
tx2 = altanims[j];
if (!tx2)
Sys_Error ("Missing frame %i of %s",j, tx->name);
{
Con_Printf (S_ERROR "Missing frame %i of %s\n",j, tx->name);
return false;
}
tx2->anim_total = altmax * ANIM_CYCLE;
tx2->anim_min = j * ANIM_CYCLE;
tx2->anim_max = (j+1) * ANIM_CYCLE;
@ -712,6 +730,8 @@ void SWMod_LoadTextures (lump_t *l)
tx2->alternate_anims = anims[0];
}
}
return true;
}
void SWMod_NowLoadExternal(void)
@ -978,7 +998,7 @@ void SWMod_LoadEntities (lump_t *l)
Mod_LoadVertexes
=================
*/
void SWMod_LoadVertexes (lump_t *l)
qboolean SWMod_LoadVertexes (lump_t *l)
{
dvertex_t *in;
mvertex_t *out;
@ -986,7 +1006,10 @@ void SWMod_LoadVertexes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count+8)*sizeof(*out), loadname); //spare for skybox
@ -999,6 +1022,8 @@ void SWMod_LoadVertexes (lump_t *l)
out->position[1] = LittleFloat (in->point[1]);
out->position[2] = LittleFloat (in->point[2]);
}
return true;
}
static qboolean hexen2map;
@ -1007,7 +1032,7 @@ static qboolean hexen2map;
Mod_LoadSubmodels
=================
*/
void SWMod_LoadSubmodels (lump_t *l)
qboolean SWMod_LoadSubmodels (lump_t *l)
{
dq1model_t *inq;
dh2model_t *inh;
@ -1022,7 +1047,10 @@ void SWMod_LoadSubmodels (lump_t *l)
{
hexen2map = true;
if (l->filelen % sizeof(*inh))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*inh);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1057,7 +1085,10 @@ void SWMod_LoadSubmodels (lump_t *l)
{
hexen2map = false;
if (l->filelen % sizeof(*inq))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*inq);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1087,6 +1118,8 @@ void SWMod_LoadSubmodels (lump_t *l)
out->numfaces = LittleLong (inq->numfaces);
}
}
return true;
}
/*
@ -1094,7 +1127,7 @@ void SWMod_LoadSubmodels (lump_t *l)
Mod_LoadEdges
=================
*/
void SWMod_LoadEdges (lump_t *l)
qboolean SWMod_LoadEdges (lump_t *l)
{
dedge_t *in;
medge_t *out;
@ -1102,7 +1135,10 @@ void SWMod_LoadEdges (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count + 1 + 12) * sizeof(*out), loadname); //spare for skybox
@ -1114,6 +1150,8 @@ void SWMod_LoadEdges (lump_t *l)
out->v[0] = (unsigned short)LittleShort(in->v[0]);
out->v[1] = (unsigned short)LittleShort(in->v[1]);
}
return true;
}
/*
@ -1122,7 +1160,7 @@ Mod_LoadTexinfo
=================
*/
#ifndef SERVERONLY
void SWMod_LoadTexinfo (lump_t *l)
qboolean SWMod_LoadTexinfo (lump_t *l)
{
texinfo_t *in;
mtexinfo_t *out;
@ -1132,7 +1170,10 @@ void SWMod_LoadTexinfo (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1197,6 +1238,8 @@ void SWMod_LoadTexinfo (lump_t *l)
}
}
}
return true;
}
#endif
/*
@ -1264,7 +1307,7 @@ Mod_LoadFaces
=================
*/
#ifndef SERVERONLY
void SWMod_LoadFaces (lump_t *l)
qboolean SWMod_LoadFaces (lump_t *l)
{
dface_t *in;
msurface_t *out;
@ -1273,7 +1316,10 @@ void SWMod_LoadFaces (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count+6)*sizeof(*out), loadname); //spare for skybox
@ -1344,6 +1390,8 @@ void SWMod_LoadFaces (lump_t *l)
continue;
}
}
return true;
}
#endif
@ -1366,7 +1414,7 @@ void SWMod_SetParent (mnode_t *node, mnode_t *parent)
Mod_LoadNodes
=================
*/
void SWMod_LoadNodes (lump_t *l)
qboolean SWMod_LoadNodes (lump_t *l)
{
int i, j, count, p;
dnode_t *in;
@ -1374,7 +1422,10 @@ void SWMod_LoadNodes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1406,6 +1457,8 @@ void SWMod_LoadNodes (lump_t *l)
}
SWMod_SetParent (loadmodel->nodes, NULL); // sets nodes and leafs
return true;
}
/*
@ -1413,7 +1466,7 @@ void SWMod_LoadNodes (lump_t *l)
Mod_LoadLeafs
=================
*/
void SWMod_LoadLeafs (lump_t *l)
qboolean SWMod_LoadLeafs (lump_t *l)
{
dleaf_t *in;
mleaf_t *out;
@ -1421,7 +1474,10 @@ void SWMod_LoadLeafs (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1453,6 +1509,8 @@ void SWMod_LoadLeafs (lump_t *l)
for (j=0 ; j<4 ; j++)
out->ambient_sound_level[j] = in->ambient_level[j];
}
return true;
}
//these are used to boost other info sizes
@ -1513,7 +1571,7 @@ void SWMod_LoadCrouchHull(void)
Mod_LoadClipnodes
=================
*/
void SWMod_LoadClipnodes (lump_t *l)
qboolean SWMod_LoadClipnodes (lump_t *l)
{
dclipnode_t *in, *out;
int i, count;
@ -1521,7 +1579,10 @@ void SWMod_LoadClipnodes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n", loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count+numsuplementryclipnodes)*sizeof(*out), loadname);//space for both
@ -1703,6 +1764,8 @@ void SWMod_LoadClipnodes (lump_t *l)
out->children[1] += out->children[1]>=0?1:0;
}
}
return true;
}
/*
@ -1749,7 +1812,7 @@ void SWMod_MakeHull0 (void)
Mod_LoadMarksurfaces
=================
*/
void SWMod_LoadMarksurfaces (lump_t *l)
qboolean SWMod_LoadMarksurfaces (lump_t *l)
{
int i, j, count;
short *in;
@ -1757,7 +1820,10 @@ void SWMod_LoadMarksurfaces (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( count*sizeof(*out), loadname);
@ -1768,9 +1834,14 @@ void SWMod_LoadMarksurfaces (lump_t *l)
{
j = LittleShort(in[i]);
if (j >= loadmodel->numsurfaces)
Sys_Error ("Mod_ParseMarksurfaces: bad surface number");
{
Con_Printf (S_ERROR "Mod_ParseMarksurfaces: bad surface number\n");
return false;
}
out[i] = loadmodel->surfaces + j;
}
return true;
}
/*
@ -1778,14 +1849,17 @@ void SWMod_LoadMarksurfaces (lump_t *l)
Mod_LoadSurfedges
=================
*/
void SWMod_LoadSurfedges (lump_t *l)
qboolean SWMod_LoadSurfedges (lump_t *l)
{
int i, count;
int *in, *out;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count+24)*sizeof(*out), loadname); //spare for skybox
@ -1794,6 +1868,8 @@ void SWMod_LoadSurfedges (lump_t *l)
for ( i=0 ; i<count ; i++)
out[i] = LittleLong (in[i]);
return true;
}
/*
@ -1801,7 +1877,7 @@ void SWMod_LoadSurfedges (lump_t *l)
Mod_LoadPlanes
=================
*/
void SWMod_LoadPlanes (lump_t *l)
qboolean SWMod_LoadPlanes (lump_t *l)
{
int i, j;
mplane_t *out;
@ -1811,7 +1887,10 @@ void SWMod_LoadPlanes (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
Con_Printf (S_ERROR "MOD_LoadBmodel: funny lump size in %s\n",loadmodel->name);
return false;
}
count = l->filelen / sizeof(*in);
out = Hunk_AllocName ( (count+numsuplementryplanes)*2*sizeof(*out), loadname);
@ -1852,6 +1931,8 @@ void SWMod_LoadPlanes (lump_t *l)
out->signbits = bits;
}
}
return true;
}
/*
@ -1885,11 +1966,15 @@ void SWR_Q1BSP_StainNode (mnode_t *node, float *parms);
Mod_LoadBrushModel
=================
*/
void SWMod_LoadBrushModel (model_t *mod, void *buffer)
qboolean SWMod_LoadBrushModel (model_t *mod, void *buffer)
{
int i, j;
dheader_t *header;
mmodel_t *bm;
int start;
qboolean noerrors;
start = Hunk_LowMark();
loadmodel->type = mod_brush;
@ -1902,7 +1987,10 @@ void SWMod_LoadBrushModel (model_t *mod, void *buffer)
else if (i == BSPVERSIONHL)
loadmodel->fromgame = fg_halflife;
else
Sys_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
{
Con_Printf (S_ERROR "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
return false;
}
// if (i != BSPVERSION)
// Sys_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
@ -1928,36 +2016,43 @@ void SWMod_LoadBrushModel (model_t *mod, void *buffer)
header->lumps[i].filelen);
}
noerrors = true;
crouchhullfile = NULL;
// load into heap
#ifndef CLIENTONLY
if (!isDedicated)
#endif
{
SWMod_LoadVertexes (&header->lumps[LUMP_VERTEXES]);
SWMod_LoadEdges (&header->lumps[LUMP_EDGES]);
SWMod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]);
SWMod_LoadLighting (&header->lumps[LUMP_LIGHTING]); //DMW, made lighting load first. (so we know if lighting is rgb or luminance)
SWMod_LoadTextures (&header->lumps[LUMP_TEXTURES]);
noerrors = noerrors && SWMod_LoadVertexes (&header->lumps[LUMP_VERTEXES]);
noerrors = noerrors && SWMod_LoadEdges (&header->lumps[LUMP_EDGES]);
noerrors = noerrors && SWMod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]);
if (noerrors)
SWMod_LoadLighting (&header->lumps[LUMP_LIGHTING]); //DMW, made lighting load first. (so we know if lighting is rgb or luminance)
noerrors = noerrors && SWMod_LoadTextures (&header->lumps[LUMP_TEXTURES]);
}
SWMod_LoadSubmodels (&header->lumps[LUMP_MODELS]); //needs to come before we set the headnodes[3]
SWMod_LoadCrouchHull ();
SWMod_LoadPlanes (&header->lumps[LUMP_PLANES]);
noerrors = noerrors && SWMod_LoadSubmodels (&header->lumps[LUMP_MODELS]); //needs to come before we set the headnodes[3]
if (noerrors)
SWMod_LoadCrouchHull ();
noerrors = noerrors && SWMod_LoadPlanes (&header->lumps[LUMP_PLANES]);
#ifndef CLIENTONLY
if (!isDedicated)
#endif
{
SWMod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
SWMod_LoadFaces (&header->lumps[LUMP_FACES]);
SWMod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]);
noerrors = noerrors && SWMod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
noerrors = noerrors && SWMod_LoadFaces (&header->lumps[LUMP_FACES]);
noerrors = noerrors && SWMod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]);
}
SWMod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]);
SWMod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
SWMod_LoadNodes (&header->lumps[LUMP_NODES]);
SWMod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]);
SWMod_LoadEntities (&header->lumps[LUMP_ENTITIES]);
if (noerrors)
SWMod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]);
noerrors = noerrors && SWMod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
noerrors = noerrors && SWMod_LoadNodes (&header->lumps[LUMP_NODES]);
noerrors = noerrors && SWMod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]);
if (noerrors)
SWMod_LoadEntities (&header->lumps[LUMP_ENTITIES]);
if (crouchhullfile)
{
@ -1965,6 +2060,12 @@ void SWMod_LoadBrushModel (model_t *mod, void *buffer)
crouchhullfile=NULL;
}
if (!noerrors)
{
Hunk_FreeToLowMark(start);
return false;
}
Q1BSP_SetModelFuncs(mod);
mod->funcs.LightPointValues = SWQ1BSP_LightPointValues;
mod->funcs.StainNode = SWR_Q1BSP_StainNode;
@ -2029,6 +2130,8 @@ void SWMod_LoadBrushModel (model_t *mod, void *buffer)
P_DefaultTrail(mod);
}
}
return true;
}
#ifndef SERVERONLY
/*