round off the offsets/sizes again

This commit is contained in:
Bill Currie 2002-09-19 15:28:16 +00:00
parent d8a38ae648
commit e8d74f3a26

View file

@ -235,25 +235,27 @@ WriteBSPFile (bsp_t *bsp, QFile *file)
dheader_t *header; dheader_t *header;
byte *data; byte *data;
size = sizeof (dheader_t); #define ROUND(x) (((x) + 3) & ~3)
size += bsp->nummodels * sizeof (dmodel_t);
size += bsp->visdatasize; size = ROUND (sizeof (dheader_t));
size += bsp->lightdatasize; size += ROUND (bsp->nummodels * sizeof (dmodel_t));
size += bsp->texdatasize; size += ROUND (bsp->visdatasize);
size += bsp->entdatasize; size += ROUND (bsp->lightdatasize);
size += bsp->numleafs * sizeof (dleaf_t); size += ROUND (bsp->texdatasize);
size += bsp->numplanes * sizeof (dplane_t); size += ROUND (bsp->entdatasize);
size += bsp->numvertexes * sizeof (dvertex_t); size += ROUND (bsp->numleafs * sizeof (dleaf_t));
size += bsp->numnodes * sizeof (dnode_t); size += ROUND (bsp->numplanes * sizeof (dplane_t));
size += bsp->numtexinfo * sizeof (texinfo_t); size += ROUND (bsp->numvertexes * sizeof (dvertex_t));
size += bsp->numfaces * sizeof (dface_t); size += ROUND (bsp->numnodes * sizeof (dnode_t));
size += bsp->numclipnodes * sizeof (dclipnode_t); size += ROUND (bsp->numtexinfo * sizeof (texinfo_t));
size += bsp->numedges * sizeof (dedge_t); size += ROUND (bsp->numfaces * sizeof (dface_t));
size += bsp->nummarksurfaces * sizeof (unsigned short); size += ROUND (bsp->numclipnodes * sizeof (dclipnode_t));
size += bsp->numsurfedges * sizeof (int); size += ROUND (bsp->numedges * sizeof (dedge_t));
size += ROUND (bsp->nummarksurfaces * sizeof (unsigned short));
size += ROUND (bsp->numsurfedges * sizeof (int));
header = malloc (size); header = malloc (size);
memset (header, 0, sizeof (dheader_t)); memset (header, 0, size);
swap_bsp (bsp, 1); swap_bsp (bsp, 1);
@ -264,7 +266,7 @@ do { \
header->lumps[l].fileofs = LittleLong (data - (byte *) header); \ header->lumps[l].fileofs = LittleLong (data - (byte *) header); \
header->lumps[l].filelen = LittleLong (bsp->num##n); \ header->lumps[l].filelen = LittleLong (bsp->num##n); \
memcpy (data, bsp->n, bsp->num##n); \ memcpy (data, bsp->n, bsp->num##n); \
data += bsp->num##n; \ data += ROUND (bsp->num##n); \
} while (0) } while (0)
header->version = LittleLong (BSPVERSION); header->version = LittleLong (BSPVERSION);
@ -289,7 +291,7 @@ do { \
header->lumps[l].fileofs = LittleLong (data - (byte *) header); \ header->lumps[l].fileofs = LittleLong (data - (byte *) header); \
header->lumps[l].filelen = LittleLong (bsp->n##size); \ header->lumps[l].filelen = LittleLong (bsp->n##size); \
memcpy (data, bsp->n, bsp->n##size); \ memcpy (data, bsp->n, bsp->n##size); \
data += bsp->n##size; \ data += ROUND (bsp->n##size); \
} while (0) } while (0)
SET_LUMP (LUMP_LIGHTING, lightdata); SET_LUMP (LUMP_LIGHTING, lightdata);