mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-16 01:31:30 +00:00
Merge branch 'next' into public_next
This commit is contained in:
commit
90d82a8358
2 changed files with 23 additions and 4 deletions
|
@ -308,6 +308,23 @@ static md2_model_t *md2_readModel(const char *filename)
|
||||||
|
|
||||||
model->header.numSkins = 1;
|
model->header.numSkins = 1;
|
||||||
|
|
||||||
|
#define MD2LIMITCHECK(field, max, msgname) \
|
||||||
|
if (field > max) \
|
||||||
|
{ \
|
||||||
|
CONS_Alert(CONS_ERROR, "md2_readModel: %s has too many " msgname " (# found: %d, maximum: %d)\n", filename, field, max); \
|
||||||
|
md2_freeModel (model); \
|
||||||
|
return 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uncomment if these are actually needed
|
||||||
|
// MD2LIMITCHECK(model->header.numSkins, MD2_MAX_SKINS, "skins")
|
||||||
|
// MD2LIMITCHECK(model->header.numTexCoords, MD2_MAX_TEXCOORDS, "texture coordinates")
|
||||||
|
MD2LIMITCHECK(model->header.numTriangles, MD2_MAX_TRIANGLES, "triangles")
|
||||||
|
MD2LIMITCHECK(model->header.numFrames, MD2_MAX_FRAMES, "frames")
|
||||||
|
MD2LIMITCHECK(model->header.numVertices, MD2_MAX_VERTICES, "vertices")
|
||||||
|
|
||||||
|
#undef MD2LIMITCHECK
|
||||||
|
|
||||||
// read skins
|
// read skins
|
||||||
fseek(file, model->header.offsetSkins, SEEK_SET);
|
fseek(file, model->header.offsetSkins, SEEK_SET);
|
||||||
if (model->header.numSkins > 0)
|
if (model->header.numSkins > 0)
|
||||||
|
@ -319,8 +336,6 @@ static md2_model_t *md2_readModel(const char *filename)
|
||||||
md2_freeModel (model);
|
md2_freeModel (model);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read texture coordinates
|
// read texture coordinates
|
||||||
|
@ -334,8 +349,6 @@ static md2_model_t *md2_readModel(const char *filename)
|
||||||
md2_freeModel (model);
|
md2_freeModel (model);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read triangles
|
// read triangles
|
||||||
|
@ -769,6 +782,7 @@ void HWR_InitMD2(void)
|
||||||
md2_playermodels[s].grpatch = NULL;
|
md2_playermodels[s].grpatch = NULL;
|
||||||
md2_playermodels[s].skin = -1;
|
md2_playermodels[s].skin = -1;
|
||||||
md2_playermodels[s].notfound = true;
|
md2_playermodels[s].notfound = true;
|
||||||
|
md2_playermodels[s].error = false;
|
||||||
}
|
}
|
||||||
for (i = 0; i < NUMSPRITES; i++)
|
for (i = 0; i < NUMSPRITES; i++)
|
||||||
{
|
{
|
||||||
|
@ -777,6 +791,7 @@ void HWR_InitMD2(void)
|
||||||
md2_models[i].grpatch = NULL;
|
md2_models[i].grpatch = NULL;
|
||||||
md2_models[i].skin = -1;
|
md2_models[i].skin = -1;
|
||||||
md2_models[i].notfound = true;
|
md2_models[i].notfound = true;
|
||||||
|
md2_models[s].error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the md2.dat file
|
// read the md2.dat file
|
||||||
|
@ -1269,6 +1284,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||||
else
|
else
|
||||||
md2 = &md2_models[spr->mobj->sprite];
|
md2 = &md2_models[spr->mobj->sprite];
|
||||||
|
|
||||||
|
if (md2->error)
|
||||||
|
return; // we already failed loading this before :(
|
||||||
if (!md2->model)
|
if (!md2->model)
|
||||||
{
|
{
|
||||||
//CONS_Debug(DBG_RENDER, "Loading MD2... (%s)", sprnames[spr->mobj->sprite]);
|
//CONS_Debug(DBG_RENDER, "Loading MD2... (%s)", sprnames[spr->mobj->sprite]);
|
||||||
|
@ -1282,6 +1299,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//CONS_Debug(DBG_RENDER, " FAILED\n");
|
//CONS_Debug(DBG_RENDER, " FAILED\n");
|
||||||
|
md2->error = true; // prevent endless fail
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,7 @@ typedef struct
|
||||||
void *blendgrpatch;
|
void *blendgrpatch;
|
||||||
boolean notfound;
|
boolean notfound;
|
||||||
INT32 skin;
|
INT32 skin;
|
||||||
|
boolean error;
|
||||||
} md2_t;
|
} md2_t;
|
||||||
|
|
||||||
extern md2_t md2_models[NUMSPRITES];
|
extern md2_t md2_models[NUMSPRITES];
|
||||||
|
|
Loading…
Reference in a new issue