Add warnings for any misaligned lumps. These crash on arm ports of engines.

This commit is contained in:
Spike 2018-05-25 11:51:10 +01:00 committed by Shpoike
parent 0501ec2e98
commit 9d1c386a1b

View file

@ -502,15 +502,20 @@ static void Q1BSPX_Setup(qmodel_t *mod, char *filebase, unsigned int filelen, lu
int i;
int offs = 0;
bspx_header_t *h;
qboolean misaligned = false;
bspxbase = filebase;
bspxheader = NULL;
for (i = 0; i < numlumps; i++, lumps++)
{
if (lumps->fileofs & 3)
misaligned = true;
if (offs < lumps->fileofs + lumps->filelen)
offs = lumps->fileofs + lumps->filelen;
}
if (misaligned)
Con_Warning("%s contains misaligned lumps\n", mod->name);
offs = (offs + 3) & ~3;
if (offs + sizeof(*bspxheader) > filelen)
return; /*no space for it*/
@ -527,6 +532,8 @@ static void Q1BSPX_Setup(qmodel_t *mod, char *filebase, unsigned int filelen, lu
{
h->lumps[i].fileofs = LittleLong(h->lumps[i].fileofs);
h->lumps[i].filelen = LittleLong(h->lumps[i].filelen);
if (h->lumps[i].fileofs & 3)
Con_Warning("%s contains misaligned bspx limp %s\n", mod->name, h->lumps[i].lumpname);
if ((unsigned int)h->lumps[i].fileofs + (unsigned int)h->lumps[i].filelen > filelen)
return;
}