1
0
Fork 0
forked from fte/fteqw

console line scrolling fix, MDL/MD2/MD3/ZYM/DPM loading will no longer Sys_Error (still need bounds checking)

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2095 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-03-12 08:01:48 +00:00
parent 3b73a69432
commit 2df1c6674b
5 changed files with 293 additions and 101 deletions

View file

@ -519,6 +519,7 @@ Interactive line editing and console scrollback
void Key_Console (int key)
{
char *clipText;
int upperconbound;
if (con_current->redirect)
{
@ -693,15 +694,21 @@ void Key_Console (int key)
return;
}
upperconbound = con_current->current - con_current->totallines + 1;
if (key == K_PGUP || key==K_MWHEELUP)
{
con_current->display -= 2;
if (con_current->display < upperconbound)
con_current->display = upperconbound;
return;
}
if (key == K_PGDN || key==K_MWHEELDOWN)
{
con_current->display += 2;
if (con_current->display < upperconbound)
con_current->display = upperconbound;
if (con_current->display > con_current->current)
con_current->display = con_current->current;
return;
@ -710,7 +717,7 @@ void Key_Console (int key)
if (key == K_HOME)
{
if (keydown[K_CTRL])
con_current->display = con_current->current - con_current->totallines + 10;
con_current->display = upperconbound;
else
key_linepos = 1;
return;

View file

@ -3081,7 +3081,8 @@ static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
pframetype = (daliasframetype_t *)pinframe;
break;
default:
Sys_Error("Bad frame type in %s\n", loadmodel->name);
Con_Printf(S_ERROR "Bad frame type in %s\n", loadmodel->name);
return NULL;
}
frame++;
}
@ -3315,7 +3316,7 @@ static void *Q1_LoadSkins (daliasskintype_t *pskintype, qboolean alpha)
}
#endif
void GL_LoadQ1Model (model_t *mod, void *buffer)
qboolean GL_LoadQ1Model (model_t *mod, void *buffer)
{
#ifndef SERVERONLY
vec2_t *st_array;
@ -3345,8 +3346,11 @@ void GL_LoadQ1Model (model_t *mod, void *buffer)
version = pq1inmodel->version;
if (version != ALIAS_VERSION)
Sys_Error ("%s has wrong version number (%i should be %i)",
{
Con_Printf (S_ERROR "%s has wrong version number (%i should be %i)",
mod->name, version, ALIAS_VERSION);
return false;
}
if (pq1inmodel->numframes < 1 ||
pq1inmodel->numskins < 1 ||
@ -3354,7 +3358,10 @@ void GL_LoadQ1Model (model_t *mod, void *buffer)
pq1inmodel->numverts < 3 ||
pq1inmodel->skinheight < 1 ||
pq1inmodel->skinwidth < 1)
Sys_Error("Model %s has an invalid quantity\n", mod->name);
{
Con_Printf(S_ERROR "Model %s has an invalid quantity\n", mod->name);
return false;
}
mod->flags = pq1inmodel->flags;
@ -3437,8 +3444,15 @@ void GL_LoadQ1Model (model_t *mod, void *buffer)
}
//frames
Q1_LoadFrameGroup((daliasframetype_t *)&pintriangles[pq1inmodel->numtris], seamremap);
if (Q1_LoadFrameGroup((daliasframetype_t *)&pintriangles[pq1inmodel->numtris], seamremap) == NULL)
{
BZ_Free(seamremap);
Hunk_FreeToLowMark (hunkstart);
return false;
}
BZ_Free(seamremap);
#ifndef SERVERONLY
if (r_shadows.value)
{
@ -3462,13 +3476,15 @@ void GL_LoadQ1Model (model_t *mod, void *buffer)
if (!mod->cache.data)
{
Hunk_FreeToLowMark (hunkstart);
return;
return false;
}
memcpy (mod->cache.data, galias, hunktotal);
Hunk_FreeToLowMark (hunkstart);
mod->funcs.Trace = GLMod_Trace;
return true;
}
#endif
@ -3554,7 +3570,7 @@ static void Q2_LoadSkins(char *skins)
}
#define MD2_MAX_TRIANGLES 4096
void GL_LoadQ2Model (model_t *mod, void *buffer)
qboolean GL_LoadQ2Model (model_t *mod, void *buffer)
{
#ifndef SERVERONLY
dmd2stvert_t *pinstverts;
@ -3596,8 +3612,11 @@ void GL_LoadQ2Model (model_t *mod, void *buffer)
version = LittleLong (pq2inmodel->version);
if (version != MD2ALIAS_VERSION)
Sys_Error ("%s has wrong version number (%i should be %i)",
{
Con_Printf (S_ERROR "%s has wrong version number (%i should be %i)",
mod->name, version, MD2ALIAS_VERSION);
return false;
}
if (LittleLong(pq2inmodel->num_frames) < 1 ||
LittleLong(pq2inmodel->num_skins) < 0 ||
@ -3606,7 +3625,10 @@ void GL_LoadQ2Model (model_t *mod, void *buffer)
LittleLong(pq2inmodel->num_st) < 3 ||
LittleLong(pq2inmodel->skinheight) < 1 ||
LittleLong(pq2inmodel->skinwidth) < 1)
Sys_Error("Model %s has an invalid quantity\n", mod->name);
{
Con_Printf(S_ERROR "Model %s has an invalid quantity\n", mod->name);
return false;
}
mod->flags = 0;
@ -3788,13 +3810,15 @@ void GL_LoadQ2Model (model_t *mod, void *buffer)
if (!mod->cache.data)
{
Hunk_FreeToLowMark (hunkstart);
return;
return false;
}
memcpy (mod->cache.data, galias, hunktotal);
Hunk_FreeToLowMark (hunkstart);
mod->funcs.Trace = GLMod_Trace;
return true;
}
#endif
@ -4117,7 +4141,7 @@ typedef struct {
} md3Shader_t;
//End of Tenebrae 'assistance'
void GL_LoadQ3Model(model_t *mod, void *buffer)
qboolean GL_LoadQ3Model(model_t *mod, void *buffer)
{
#ifndef SERVERONLY
galiasskin_t *skin;
@ -4181,7 +4205,7 @@ void GL_LoadQ3Model(model_t *mod, void *buffer)
for (s = 0; s < LittleLong(header->numSurfaces); s++)
{
if (LittleLong(surf->ident) != MD3_IDENT)
Con_Printf("Warning: md3 sub-surface doesn't match ident\n");
Con_Printf(S_WARNING "Warning: md3 sub-surface doesn't match ident\n");
size = sizeof(galiasinfo_t) + sizeof(galiasgroup_t)*LittleLong(header->numFrames);
galias = Hunk_Alloc(size);
galias->groupofs = sizeof(*galias); //frame groups
@ -4450,13 +4474,15 @@ void GL_LoadQ3Model(model_t *mod, void *buffer)
if (!mod->cache.data)
{
Hunk_FreeToLowMark (hunkstart);
return;
return false;
}
memcpy (mod->cache.data, root, hunktotal);
Hunk_FreeToLowMark (hunkstart);
mod->funcs.Trace = GLMod_Trace;
return true;
}
#endif
@ -4521,7 +4547,7 @@ typedef struct zymvertex_s
//this can generate multiple meshes (one for each shader).
//but only one set of transforms are ever generated.
void GLMod_LoadZymoticModel(model_t *mod, void *buffer)
qboolean GLMod_LoadZymoticModel(model_t *mod, void *buffer)
{
#ifndef SERVERONLY
galiasskin_t *skin;
@ -4568,20 +4594,31 @@ void GLMod_LoadZymoticModel(model_t *mod, void *buffer)
header = buffer;
if (memcmp(header->id, "ZYMOTICMODEL", 12))
Sys_Error("GLMod_LoadZymoticModel: doesn't appear to BE a zymotic!\n");
{
Con_Printf("GLMod_LoadZymoticModel: %s, doesn't appear to BE a zymotic!\n", mod->name);
return false;
}
if (BigLong(header->type) != 1)
Sys_Error("GLMod_LoadZymoticModel: only type 1 is supported\n");
{
Con_Printf("GLMod_LoadZymoticModel: %s, only type 1 is supported\n", mod->name);
return false;
}
for (i = 0; i < sizeof(zymtype1header_t)/4; i++)
((int*)header)[i] = BigLong(((int*)header)[i]);
if (!header->numverts)
Sys_Error("GLMod_LoadZymoticModel: no vertexes\n");
{
Con_Printf("GLMod_LoadZymoticModel: %s, no vertexes\n", mod->name);
return false;
}
if (!header->numsurfaces)
Sys_Error("GLMod_LoadZymoticModel: no surfaces\n");
{
Con_Printf("GLMod_LoadZymoticModel: %s, no surfaces\n", mod->name);
return false;
}
VectorCopy(header->mins, mod->mins);
VectorCopy(header->maxs, mod->maxs);
@ -4603,7 +4640,11 @@ void GLMod_LoadZymoticModel(model_t *mod, void *buffer)
{
v++;
if (v == header->numverts)
Sys_Error("GLMod_LoadZymoticModel: Too many transformations\n");
{
Con_Printf("GLMod_LoadZymoticModel: %s, too many transformations\n", mod->name);
Hunk_FreeToLowMark(hunkstart);
return false;
}
vertbonecounts[v] = BigLong(vertbonecounts[v]);
multiplier = 1.0f / vertbonecounts[v];
}
@ -4616,10 +4657,17 @@ void GLMod_LoadZymoticModel(model_t *mod, void *buffer)
vertbonecounts[v]--;
}
if (intrans != (zymvertex_t *)((char*)header + header->lump_verts.start))
Sys_Error("Vertex transforms list appears corrupt.");
{
Con_Printf(S_ERROR "%s, Vertex transforms list appears corrupt.", mod->name);
Hunk_FreeToLowMark(hunkstart);
return false;
}
if (vertbonecounts != (int *)((char*)header + header->lump_vertbonecounts.start))
Sys_Error("Vertex bone counts list appears corrupt.");
{
Con_Printf(S_ERROR "%s, Vertex bone counts list appears corrupt.", mod->name);
Hunk_FreeToLowMark(hunkstart);
return false;
}
root->numverts = v+1;
@ -4651,7 +4699,11 @@ void GLMod_LoadZymoticModel(model_t *mod, void *buffer)
renderlist += root[i].numindexes;
}
if (renderlist != (int*)((char*)header + header->lump_render.start + header->lump_render.length))
Sys_Error("Render list appears corrupt.");
{
Con_Printf(S_ERROR "%s, render list appears corrupt.", mod->name);
Hunk_FreeToLowMark(hunkstart);
return false;
}
grp = Hunk_Alloc(sizeof(*grp)*header->numscenes*header->numsurfaces);
matrix = Hunk_Alloc(header->lump_poses.length);
@ -4714,7 +4766,11 @@ void GLMod_LoadZymoticModel(model_t *mod, void *buffer)
}
if (inscene != (zymscene_t*)((char*)header + header->lump_scenes.start+header->lump_scenes.length))
Sys_Error("scene list appears corrupt.");
{
Con_Printf(S_ERROR "%s, scene list appears corrupt.", mod->name);
Hunk_FreeToLowMark(hunkstart);
return false;
}
for (i = 0; i < header->numsurfaces-1; i++)
root[i].nextsurf = sizeof(galiasinfo_t);
@ -4745,7 +4801,7 @@ void GLMod_LoadZymoticModel(model_t *mod, void *buffer)
if (!mod->cache.data)
{
Hunk_FreeToLowMark (hunkstart);
return;
return false;
}
memcpy (mod->cache.data, root, hunktotal);
@ -4753,6 +4809,8 @@ void GLMod_LoadZymoticModel(model_t *mod, void *buffer)
mod->funcs.Trace = GLMod_Trace;
return true;
}
@ -4846,7 +4904,7 @@ typedef struct dpmvertex_s
// immediately followed by 1 or more dpmbonevert_t structures
} dpmvertex_t;
void GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer)
qboolean GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer)
{
#ifndef SERVERONLY
galiasskin_t *skin;
@ -4890,20 +4948,35 @@ void GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer)
header = buffer;
if (memcmp(header->id, "DARKPLACESMODEL\0", 16))
Sys_Error("GLMod_LoadDarkPlacesModel: doesn't appear to be a darkplaces model!\n");
{
Con_Printf(S_ERROR "GLMod_LoadDarkPlacesModel: %s, doesn't appear to be a darkplaces model!\n", mod->name);
return false;
}
if (BigLong(header->type) != 2)
Sys_Error("GLMod_LoadDarkPlacesModel: only type 2 is supported\n");
{
Con_Printf(S_ERROR "GLMod_LoadDarkPlacesModel: %s, only type 2 is supported\n", mod->name);
return false;
}
for (i = 0; i < sizeof(dpmheader_t)/4; i++)
((int*)header)[i] = BigLong(((int*)header)[i]);
if (!header->num_bones)
Sys_Error("GLMod_LoadDarkPlacesModel: no bones\n");
{
Con_Printf(S_ERROR "GLMod_LoadDarkPlacesModel: %s, no bones\n", mod->name);
return false;
}
if (!header->num_frames)
Sys_Error("GLMod_LoadDarkPlacesModel: no frames\n");
{
Con_Printf(S_ERROR "GLMod_LoadDarkPlacesModel: %s, no frames\n", mod->name);
return false;
}
if (!header->num_meshs)
Sys_Error("GLMod_LoadDarkPlacesModel: no surfaces\n");
{
Con_Printf(S_ERROR "GLMod_LoadDarkPlacesModel: %s, no surfaces\n", mod->name);
return false;
}
VectorCopy(header->mins, mod->mins);
@ -4989,7 +5062,11 @@ void GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer)
{
outbone[i].parent = BigLong(inbone[i].parent);
if (outbone[i].parent >= i || outbone[i].parent < -1)
Sys_Error("GLMod_LoadDarkPlacesModel: bad bone index in %s\n", mod->name);
{
Con_Printf(S_ERROR "GLMod_LoadDarkPlacesModel: bad bone index in %s\n", mod->name);
Hunk_FreeToLowMark(hunkstart);
return false;
}
Q_strncpyz(outbone[i].name, inbone[i].name, sizeof(outbone[i].name));
//throw away the flags.
@ -5083,7 +5160,7 @@ void GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer)
if (!mod->cache.data)
{
Hunk_FreeToLowMark (hunkstart);
return;
return false;
}
memcpy (mod->cache.data, root, hunktotal);
@ -5091,6 +5168,8 @@ void GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer)
mod->funcs.Trace = GLMod_Trace;
return true;
}

View file

@ -48,7 +48,7 @@ void CM_Init(void);
void GLMod_LoadCompositeAnim(model_t *mod, void *buffer);
void GL_LoadHeightmapModel (model_t *mod, void *buffer);
void GLMod_LoadDarkPlacesModel(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);
@ -59,7 +59,7 @@ void Mod_LoadHLModel (model_t *mod, void *buffer);
void Mod_LoadAlias3Model (model_t *mod, void *buffer);
void Mod_LoadGroupModel (model_t *mod, void *buffer);
#ifdef ZYMOTICMODELS
void GLMod_LoadZymoticModel(model_t *mod, void *buffer);
qboolean GLMod_LoadZymoticModel(model_t *mod, void *buffer);
#endif
#ifdef MD5MODELS
void GLMod_LoadMD5MeshModel(model_t *mod, void *buffer);
@ -70,12 +70,12 @@ model_t *GLMod_LoadModel (model_t *mod, qboolean crash);
qboolean Mod_LoadDoomLevel(model_t *mod);
#endif
void GL_LoadQ1Model (model_t *mod, void *buffer);
qboolean GL_LoadQ1Model (model_t *mod, void *buffer);
#ifdef MD2MODELS
void GL_LoadQ2Model (model_t *mod, void *buffer);
qboolean GL_LoadQ2Model (model_t *mod, void *buffer);
#endif
#ifdef MD3MODELS
void GL_LoadQ3Model (model_t *mod, void *buffer);
qboolean GL_LoadQ3Model (model_t *mod, void *buffer);
#endif
#ifdef DOOMWADS
@ -528,18 +528,21 @@ couldntload:
switch (LittleLong(*(unsigned *)buf))
{
case IDPOLYHEADER:
GL_LoadQ1Model(mod, buf);
if (!GL_LoadQ1Model(mod, buf))
goto couldntload;
break;
#ifdef MD2MODELS
case MD2IDALIASHEADER:
GL_LoadQ2Model(mod, buf);
if (!GL_LoadQ2Model(mod, buf))
goto couldntload;
break;
#endif
#ifdef MD3MODELS
case MD3_IDENT:
GL_LoadQ3Model (mod, buf);
if (!GL_LoadQ3Model (mod, buf))
goto couldntload;
break;
#endif
@ -582,10 +585,12 @@ couldntload:
break;
#ifdef ZYMOTICMODELS
case (('O'<<24)+('M'<<16)+('Y'<<8)+'Z'):
GLMod_LoadZymoticModel(mod, buf);
if (!GLMod_LoadZymoticModel(mod, buf))
goto couldntload;
break;
case (('K'<<24)+('R'<<16)+('A'<<8)+'D'):
GLMod_LoadDarkPlacesModel(mod, buf);
if (!GLMod_LoadDarkPlacesModel(mod, buf))
goto couldntload;
break;
#endif
default:
@ -611,7 +616,7 @@ couldntload:
}
#endif
Con_Printf("Unrecognised model format %i\n", LittleLong(*(unsigned *)buf));
Con_Printf(S_ERROR "Unrecognised model format %i loading %s\n", LittleLong(*(unsigned *)buf), mod->name);
goto couldntload;
}

View file

@ -25,17 +25,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
model_t *loadmodel;
char loadname[32]; // for hunk tags
void Mod_LoadSpriteModel (model_t *mod, void *buffer);
void Mod_LoadBrushModel (model_t *mod, void *buffer);
void Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
void Mod_LoadAliasModel (model_t *mod, void *buffer);
model_t *Mod_LoadModel (model_t *mod, qboolean crash);
void GL_LoadQ1Model (model_t *mod, void *buffer);
void GL_LoadQ2Model (model_t *mod, void *buffer);
void GL_LoadQ3Model (model_t *mod, void *buffer);
void GLMod_LoadZymoticModel (model_t *mod, void *buffer);
void GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer);
qboolean GL_LoadQ1Model (model_t *mod, void *buffer);
qboolean GL_LoadQ2Model (model_t *mod, void *buffer);
qboolean GL_LoadQ3Model (model_t *mod, void *buffer);
qboolean GLMod_LoadZymoticModel (model_t *mod, void *buffer);
qboolean GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer);
qbyte mod_novis[MAX_MAP_LEAFS/8];
@ -294,26 +291,31 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash)
case IDPOLYHEADER:
GL_LoadQ1Model(mod, buf);
if (!GL_LoadQ1Model(mod, buf))
return NULL;
break;
#ifdef MD2MODELS
case MD2IDALIASHEADER:
GL_LoadQ2Model(mod, buf);
if (!GL_LoadQ2Model(mod, buf))
return NULL;
break;
#endif
#ifdef MD3MODELS
case MD3_IDENT:
GL_LoadQ3Model (mod, buf);
if (!GL_LoadQ3Model (mod, buf))
return NULL;
break;
#endif
#ifdef ZYMOTICMODELS
case (('O'<<24)+('M'<<16)+('Y'<<8)+'Z'):
GLMod_LoadZymoticModel(mod, buf);
if (!GLMod_LoadZymoticModel(mod, buf))
return NULL;
break;
#endif
#ifdef ZYMOTICMODELS
case (('K'<<24)+('R'<<16)+('A'<<8)+'D'):
GLMod_LoadDarkPlacesModel(mod, buf);
if (!GLMod_LoadDarkPlacesModel(mod, buf))
return NULL;
break;
#endif

View file

@ -32,9 +32,9 @@ 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);
void SWMod_LoadAliasModel (model_t *mod, void *buffer);
void SWMod_LoadAlias2Model (model_t *mod, void *buffer);
void SWMod_LoadAlias3Model (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);
model_t *SWMod_LoadModel (model_t *mod, qboolean crash);
int Mod_ReadFlagsFromMD1(char *name, int md3version);
@ -375,15 +375,18 @@ model_t *SWMod_LoadModel (model_t *mod, qboolean crash)
{
#ifndef SERVERONLY
case IDPOLYHEADER:
SWMod_LoadAliasModel (mod, buf);
if (!SWMod_LoadAliasModel (mod, buf))
goto couldntload;
break;
case MD2IDALIASHEADER:
SWMod_LoadAlias2Model (mod, buf);
if (!SWMod_LoadAlias2Model (mod, buf))
goto couldntload;
break;
case MD3_IDENT:
SWMod_LoadAlias3Model (mod, buf);
if (!SWMod_LoadAlias3Model (mod, buf))
goto couldntload;
break;
case IDSPRITEHEADER:
@ -407,6 +410,7 @@ model_t *SWMod_LoadModel (model_t *mod, qboolean crash)
break;
default: //some telejano mods can do this
couldntload:
if (crash)
Sys_Error ("Mod_NumForName: %s not found", mod->name);
@ -2124,7 +2128,7 @@ void * SWMod_LoadAliasGroup (void * pin, int *pframeindex, int numv,
{
*poutintervals = LittleFloat (pin_intervals->interval);
if (*poutintervals <= 0.0)
Sys_Error ("Mod_LoadAliasGroup: interval<=0");
return NULL;
poutintervals++;
pin_intervals++;
@ -2140,6 +2144,8 @@ void * SWMod_LoadAliasGroup (void * pin, int *pframeindex, int numv,
&paliasgroup->frames[i].bboxmin,
&paliasgroup->frames[i].bboxmax,
pheader, name);
if (ptemp == NULL)
return NULL;
}
return ptemp;
@ -2252,7 +2258,7 @@ void * SWMod_LoadAliasSkinGroup (void * pin, int *pskinindex, int skinsize,
Mod_LoadAliasModel
=================
*/
void SWMod_LoadAliasModel (model_t *mod, void *buffer)
qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer)
{
int i;
mmdl_t *pmodel;
@ -2300,8 +2306,11 @@ void SWMod_LoadAliasModel (model_t *mod, void *buffer)
version = LittleLong (pinmodel->version);
if (version != ALIAS_VERSION)
Sys_Error ("%s has wrong version number (%i should be %i)",
{
Con_Printf (S_ERROR "%s has wrong version number (%i should be %i)",
mod->name, version, ALIAS_VERSION);
return false;
}
//
// allocate space for a working header, plus all the data except the frames,
@ -2330,21 +2339,38 @@ void SWMod_LoadAliasModel (model_t *mod, void *buffer)
pmodel->skinheight = LittleLong (pinmodel->skinheight);
if (pmodel->skinheight > MAX_LBM_HEIGHT)
Sys_Error ("model %s has a skin taller than %d", mod->name,
{
// TODO: at least downsize the skin
Con_Printf (S_ERROR "model %s has a skin taller than %d", mod->name,
MAX_LBM_HEIGHT);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numstverts = pmodel->numverts = LittleLong (pinmodel->numverts);
if (pmodel->numverts <= 0)
Sys_Error ("model %s has no vertices", mod->name);
{
Con_Printf (S_ERROR "model %s has no vertices", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
if (pmodel->numverts > MAXALIASVERTS)
Sys_Error ("model %s has too many vertices", mod->name);
{
Con_Printf (S_ERROR "model %s has too many vertices", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numtris = LittleLong (pinmodel->numtris);
if (pmodel->numtris <= 0)
Sys_Error ("model %s has no triangles", mod->name);
{
Con_Printf (S_ERROR "model %s has no triangles", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numframes = LittleLong (pinmodel->numframes);
pmodel->size = LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO;
@ -2362,7 +2388,11 @@ void SWMod_LoadAliasModel (model_t *mod, void *buffer)
numframes = pmodel->numframes;
if (pmodel->skinwidth & 0x03)
Sys_Error ("Mod_LoadAliasModel: \"%s\" skinwidth not multiple of 4", loadmodel->name);
{
Con_Printf (S_ERROR "Mod_LoadAliasModel: \"%s\" skinwidth not multiple of 4", loadmodel->name);
Hunk_FreeToLowMark(start);
return false;
}
pheader->model = (qbyte *)pmodel - (qbyte *)pheader;
@ -2372,7 +2402,11 @@ void SWMod_LoadAliasModel (model_t *mod, void *buffer)
skinsize = pmodel->skinheight * pmodel->skinwidth;
if (numskins < 1)
Sys_Error ("Mod_LoadAliasModel: Invalid # of skins: %d\n", numskins);
{
Con_Printf (S_ERROR "Mod_LoadAliasModel: %s, invalid # of skins: %d\n", loadmodel->name, numskins);
Hunk_FreeToLowMark(start);
return false;
}
pskintype = (daliasskintype_t *)&pinmodel[1];
@ -2454,7 +2488,11 @@ void SWMod_LoadAliasModel (model_t *mod, void *buffer)
// load the frames
//
if (numframes < 1)
Sys_Error ("Mod_LoadAliasModel: Invalid # of frames: %d\n", numframes);
{
Con_Printf (S_ERROR "Mod_LoadAliasModel: %s, invalid # of frames: %d\n", mod->name, numframes);
Hunk_FreeToLowMark(start);
return false;
}
pframetype = (daliasframetype_t *)&pintriangles[pmodel->numtris];
@ -2488,6 +2526,13 @@ void SWMod_LoadAliasModel (model_t *mod, void *buffer)
&pheader->frames[i].bboxmax,
pheader, pheader->frames[i].name);
}
if (pframetype == NULL)
{
Con_Printf (S_ERROR "SWMod_LoadAliasModel: %s, couldn't load frame data\n", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
}
mod->type = mod_alias;
@ -2511,10 +2556,11 @@ void SWMod_LoadAliasModel (model_t *mod, void *buffer)
Cache_Alloc (&mod->cache, total, loadname);
if (!mod->cache.data)
return;
return false;
memcpy (mod->cache.data, pheader, total);
Hunk_FreeToLowMark (start);
return true;
}
typedef struct
@ -2525,7 +2571,7 @@ typedef struct
dtrivertx_t verts[1]; // variable sized
} dmd2aliasframe_t;
void SWMod_LoadAlias2Model (model_t *mod, void *buffer)
qboolean SWMod_LoadAlias2Model (model_t *mod, void *buffer)
{
int i, j;
mmdl_t *pmodel;
@ -2577,8 +2623,11 @@ void SWMod_LoadAlias2Model (model_t *mod, void *buffer)
version = LittleLong (pinmodel->version);
if (version != MD2ALIAS_VERSION)
Sys_Error ("%s has wrong version number (%i should be %i)",
{
Con_Printf (S_ERROR "%s has wrong version number (%i should be %i)",
mod->name, version, MD2ALIAS_VERSION);
return false;
}
//
// allocate space for a working header, plus all the data except the frames,
@ -2606,22 +2655,38 @@ void SWMod_LoadAlias2Model (model_t *mod, void *buffer)
pmodel->skinheight = LittleLong (pinmodel->skinheight);
if (pmodel->skinheight > MAX_LBM_HEIGHT)
Sys_Error ("model %s has a skin taller than %d", mod->name,
{
Con_Printf (S_ERROR "model %s has a skin taller than %d", mod->name,
MAX_LBM_HEIGHT);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numverts = LittleLong (pinmodel->num_xyz);
pmodel->numstverts = LittleLong (pinmodel->num_st);
if (pmodel->numverts <= 0)
Sys_Error ("model %s has no vertices", mod->name);
{
Con_Printf (S_ERROR "model %s has no vertices", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
if (pmodel->numverts > MAXALIASVERTS)
Sys_Error ("model %s has too many vertices", mod->name);
{
Con_Printf (S_ERROR "model %s has too many vertices", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numtris = LittleLong (pinmodel->num_tris);
if (pmodel->numtris <= 0)
Sys_Error ("model %s has no triangles", mod->name);
{
Con_Printf (S_ERROR "model %s has no triangles", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numframes = LittleLong (pinmodel->num_frames);
pmodel->size = 1000;//LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO;
@ -2639,7 +2704,11 @@ void SWMod_LoadAlias2Model (model_t *mod, void *buffer)
numframes = pmodel->numframes;
if (pmodel->skinwidth & 0x03)
Sys_Error ("Mod_LoadAliasModel: skinwidth not multiple of 4");
{
Con_Printf (S_ERROR "Mod_LoadAliasModel: %s, skinwidth not multiple of 4", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
pheader->model = (qbyte *)pmodel - (qbyte *)pheader;
@ -2681,7 +2750,11 @@ void SWMod_LoadAlias2Model (model_t *mod, void *buffer)
// load the frames
//
if (numframes < 1)
Sys_Error ("Mod_LoadAliasModel: Invalid # of frames: %d\n", numframes);
{
Con_Printf (S_ERROR "Mod_LoadAliasModel: %s, Invalid # of frames: %d\n", mod->name, numframes);
Hunk_FreeToLowMark(start);
return false;
}
for (i=0 ; i<numframes ; i++)
{
@ -2757,20 +2830,20 @@ void SWMod_LoadAlias2Model (model_t *mod, void *buffer)
buffer = COM_LoadTempFile(skinnames);
if (!buffer)
{
Con_Printf("Skin %s not found\n", skinnames);
Con_Printf(S_WARNING "Skin %s not found\n", skinnames);
continue;
}
texture = ReadPCXFile(buffer, com_filesize, &width, &height);
// BZ_Free(buffer);
if (!texture)
{
Con_Printf("Skin %s not a pcx\n", skinnames);
Con_Printf(S_WARNING "Skin %s not a pcx\n", skinnames);
continue;
}
if (width != pmodel->skinwidth || height != pmodel->skinheight) //FIXME: scale
{
BZ_Free(texture);
Con_Printf("Skin %s not same size as model specifies it should be\n", skinnames);
Con_Printf(S_WARNING "Skin %s not same size as model specifies it should be\n", skinnames);
continue;
}
@ -2811,10 +2884,11 @@ void SWMod_LoadAlias2Model (model_t *mod, void *buffer)
Cache_Alloc (&mod->cache, total, loadname);
if (!mod->cache.data)
return;
return false;
memcpy (mod->cache.data, pheader, total);
Hunk_FreeToLowMark (start);
return true;
}
@ -2915,7 +2989,7 @@ qbyte *LoadTextureFile(char *texturename)
return NULL;
}
void SWMod_LoadAlias3Model (model_t *mod, void *buffer)
qboolean SWMod_LoadAlias3Model (model_t *mod, void *buffer)
{
int i, j;
mmdl_t *pmodel;
@ -3001,22 +3075,38 @@ void SWMod_LoadAlias3Model (model_t *mod, void *buffer)
// pmodel->skinheight = LittleLong (pinmodel->skinheight);
if (pmodel->skinheight > MAX_LBM_HEIGHT)
Sys_Error ("model %s has a skin taller than %d", mod->name,
{
Con_Printf (S_ERROR "model %s has a skin taller than %d", mod->name,
MAX_LBM_HEIGHT);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numverts = LittleLong (surface->numVerts);
pmodel->numstverts = LittleLong (surface->numVerts);
if (surface->numVerts <= 0)
Sys_Error ("model %s has no vertices", mod->name);
{
Con_Printf (S_ERROR "model %s has no vertices", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
if (pmodel->numverts > MAXALIASVERTS)
Sys_Error ("model %s has too many vertices", mod->name);
{
Con_Printf (S_ERROR "model %s has too many vertices", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numtris = LittleLong (surface->numTriangles);
if (pmodel->numtris <= 0)
Sys_Error ("model %s has no triangles", mod->name);
{
Con_Printf (S_ERROR "model %s has no triangles", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
pmodel->numframes = LittleLong (surface->numFrames);
pmodel->size = 1000;//LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO;
@ -3066,7 +3156,7 @@ void SWMod_LoadAlias3Model (model_t *mod, void *buffer)
if (!buffer)
{
Con_Printf("Skin %s not found\n", pinskin->name);
Con_Printf(S_WARNING "Skin %s not found\n", pinskin->name);
continue;
}
texture = ReadTargaFile(buffer, com_filesize, &width, &height, false);
@ -3083,7 +3173,7 @@ void SWMod_LoadAlias3Model (model_t *mod, void *buffer)
BZ_Free(buffer);
if (!texture)
{
Con_Printf("Skin %s filetype not recognised\n", pinskin->name);
Con_Printf(S_WARNING "Skin %s filetype not recognised\n", pinskin->name);
continue;
}
if (!pmodel->numskins) //this is the first skin.
@ -3095,7 +3185,7 @@ void SWMod_LoadAlias3Model (model_t *mod, void *buffer)
if (width != pmodel->skinwidth || height != pmodel->skinheight) //FIXME: scale
{
BZ_Free(texture);
Con_Printf("Skin %s not same size as model specifies it should be\n", pinskin->name);
Con_Printf(S_WARNING "Skin %s not same size as model specifies it should be\n", pinskin->name);
continue;
}
@ -3127,11 +3217,14 @@ void SWMod_LoadAlias3Model (model_t *mod, void *buffer)
}
if (!pmodel->numskins)
Con_Printf("model %s has no skins\n", loadmodel->name);
Con_Printf(S_WARNING "model %s has no skins\n", loadmodel->name);
if (pmodel->skinwidth & 0x03)
Sys_Error ("Mod_LoadAliasModel: skinwidth not multiple of 4");
{
Con_Printf (S_ERROR "Mod_LoadAliasModel: %s, skinwidth not multiple of 4", mod->name);
Hunk_FreeToLowMark(start);
return false;
}
//
// set base s and t vertices
@ -3170,7 +3263,11 @@ void SWMod_LoadAlias3Model (model_t *mod, void *buffer)
// load the frames
//
if (numframes < 1)
Sys_Error ("Mod_LoadAliasModel: Invalid # of frames: %d\n", numframes);
{
Con_Printf (S_ERROR "Mod_LoadAliasModel: %s, Invalid # of frames: %d\n", mod->name, numframes);
Hunk_FreeToLowMark(start);
return false;
}
pinverts = (md3XyzNormal_t *)((qbyte *)surface + surface->ofsXyzNormals);
for (i=0 ; i<numframes ; i++)
@ -3241,13 +3338,15 @@ void SWMod_LoadAlias3Model (model_t *mod, void *buffer)
Cache_Alloc (&mod->cache, total, loadname);
if (!mod->cache.data)
return;
return false;
memcpy (mod->cache.data, pheader, total);
Hunk_FreeToLowMark (start);
#ifdef RGLQUAKE
mod->flags = Mod_ReadFlagsFromMD1(mod->name, 0);
#endif
return true;
}