if (!loadmodel->surfmesh.isanimated)
{
- Mod_MakeCollisionBIH(loadmodel, true);
+ Mod_MakeCollisionBIH(loadmodel, true, &loadmodel->collision_bih);
loadmodel->TraceBox = Mod_CollisionBIH_TraceBox;
loadmodel->TraceLine = Mod_CollisionBIH_TraceLine;
loadmodel->TracePoint = Mod_CollisionBIH_TracePoint_Mesh;
if (!loadmodel->surfmesh.isanimated)
{
- Mod_MakeCollisionBIH(loadmodel, true);
+ Mod_MakeCollisionBIH(loadmodel, true, &loadmodel->collision_bih);
loadmodel->TraceBox = Mod_CollisionBIH_TraceBox;
loadmodel->TraceLine = Mod_CollisionBIH_TraceLine;
loadmodel->TracePoint = Mod_CollisionBIH_TracePoint_Mesh;
if (!loadmodel->surfmesh.isanimated)
{
- Mod_MakeCollisionBIH(loadmodel, true);
+ Mod_MakeCollisionBIH(loadmodel, true, &loadmodel->collision_bih);
loadmodel->TraceBox = Mod_CollisionBIH_TraceBox;
loadmodel->TraceLine = Mod_CollisionBIH_TraceLine;
loadmodel->TracePoint = Mod_CollisionBIH_TracePoint_Mesh;
if (!loadmodel->surfmesh.isanimated)
{
- Mod_MakeCollisionBIH(loadmodel, true);
+ Mod_MakeCollisionBIH(loadmodel, true, &loadmodel->collision_bih);
loadmodel->TraceBox = Mod_CollisionBIH_TraceBox;
loadmodel->TraceLine = Mod_CollisionBIH_TraceLine;
loadmodel->TracePoint = Mod_CollisionBIH_TracePoint_Mesh;
if (!loadmodel->surfmesh.isanimated)
{
- Mod_MakeCollisionBIH(loadmodel, true);
+ Mod_MakeCollisionBIH(loadmodel, true, &loadmodel->collision_bih);
loadmodel->TraceBox = Mod_CollisionBIH_TraceBox;
loadmodel->TraceLine = Mod_CollisionBIH_TraceLine;
loadmodel->TracePoint = Mod_CollisionBIH_TracePoint_Mesh;
if (!loadmodel->surfmesh.isanimated)
{
- Mod_MakeCollisionBIH(loadmodel, true);
+ Mod_MakeCollisionBIH(loadmodel, true, &loadmodel->collision_bih);
loadmodel->TraceBox = Mod_CollisionBIH_TraceBox;
loadmodel->TraceLine = Mod_CollisionBIH_TraceLine;
loadmodel->TracePoint = Mod_CollisionBIH_TracePoint_Mesh;
{
unsigned char *data;
const char *text;
- unsigned char *pbase;
+ unsigned char *pbase, *pend;
iqmheader_t *header;
skinfile_t *skinfiles;
int i, j, k, meshvertices, meshtriangles;
float *outvertex, *outnormal, *outtexcoord, *outsvector, *outtvector;
pbase = (unsigned char *)buffer;
+ pend = (unsigned char *)bufferend;
header = (iqmheader_t *)buffer;
if (memcmp(header->id, "INTERQUAKEMODEL", 16))
Host_Error ("Mod_INTERQUAKEMODEL_Load: %s is not an Inter-Quake Model", loadmodel->name);
header->num_frames = LittleLong(header->num_frames);
header->num_framechannels = LittleLong(header->num_framechannels);
header->ofs_frames = LittleLong(header->ofs_frames);
+ header->ofs_bounds = LittleLong(header->ofs_bounds);
header->num_comment = LittleLong(header->num_comment);
header->ofs_comment = LittleLong(header->ofs_comment);
header->num_extensions = LittleLong(header->num_extensions);
return;
}
+ if (pbase + header->ofs_text + header->num_text > pend ||
+ pbase + header->ofs_meshes + header->num_meshes*sizeof(iqmmesh_t) > pend ||
+ pbase + header->ofs_vertexarrays + header->num_vertexarrays*sizeof(iqmvertexarray_t) > pend ||
+ pbase + header->ofs_triangles + header->num_triangles*sizeof(int[3]) > pend ||
+ (header->ofs_neighbors && pbase + header->ofs_neighbors + header->num_triangles*sizeof(int[3]) > pend) ||
+ pbase + header->ofs_joints + header->num_joints*sizeof(iqmjoint_t) > pend ||
+ pbase + header->ofs_poses + header->num_poses*sizeof(iqmpose_t) > pend ||
+ pbase + header->ofs_anims + header->num_anims*sizeof(iqmanim_t) > pend ||
+ pbase + header->ofs_frames + header->num_frames*header->num_framechannels*sizeof(unsigned short) > pend ||
+ (header->ofs_bounds && pbase + header->ofs_bounds + header->num_frames*sizeof(iqmbounds_t) > pend) ||
+ pbase + header->ofs_comment + header->num_comment > pend)
+ {
+ Con_Printf("%s has invalid size or offset information\n", loadmodel->name);
+ return;
+ }
+
va = (iqmvertexarray_t *)(pbase + header->ofs_vertexarrays);
for (i = 0;i < (int)header->num_vertexarrays;i++)
{
+ size_t vsize;
va[i].type = LittleLong(va[i].type);
va[i].flags = LittleLong(va[i].flags);
va[i].format = LittleLong(va[i].format);
va[i].size = LittleLong(va[i].size);
va[i].offset = LittleLong(va[i].offset);
+ vsize = header->num_vertexes*va[i].size;
+ switch (va[i].format)
+ {
+ case IQM_FLOAT: vsize *= sizeof(float); break;
+ case IQM_UBYTE: vsize *= sizeof(unsigned char); break;
+ default: continue;
+ }
+ if (pbase + va[i].offset + vsize > pend)
+ continue;
switch (va[i].type)
{
case IQM_POSITION:
if (!loadmodel->surfmesh.isanimated)
{
- Mod_MakeCollisionBIH(loadmodel, true);
+ Mod_MakeCollisionBIH(loadmodel, true, &loadmodel->collision_bih);
loadmodel->TraceBox = Mod_CollisionBIH_TraceBox;
loadmodel->TraceLine = Mod_CollisionBIH_TraceLine;
loadmodel->TracePoint = Mod_CollisionBIH_TracePoint_Mesh;