Fix misaligned pointers
This commit is contained in:
parent
7a770fa63c
commit
ceb8d298c2
24
src/r_data.c
24
src/r_data.c
|
@ -459,7 +459,7 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
int x, x1, x2, i, width, height;
|
int x, x1, x2, i, width, height;
|
||||||
size_t blocksize;
|
size_t blocksize;
|
||||||
column_t *patchcol;
|
column_t *patchcol;
|
||||||
UINT32 *colofs;
|
UINT8 *colofs;
|
||||||
|
|
||||||
UINT16 wadnum;
|
UINT16 wadnum;
|
||||||
lumpnum_t lumpnum;
|
lumpnum_t lumpnum;
|
||||||
|
@ -496,10 +496,10 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
// Check the patch for holes.
|
// Check the patch for holes.
|
||||||
if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height))
|
if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height))
|
||||||
holey = true;
|
holey = true;
|
||||||
colofs = (UINT32 *)realpatch->columnofs;
|
colofs = (UINT8 *)realpatch->columnofs;
|
||||||
for (x = 0; x < texture->width && !holey; x++)
|
for (x = 0; x < texture->width && !holey; x++)
|
||||||
{
|
{
|
||||||
column_t *col = (column_t *)((UINT8 *)realpatch + LONG(colofs[x]));
|
column_t *col = (column_t *)((UINT8 *)realpatch + LONG(*(UINT32 *)&colofs[x<<2]));
|
||||||
INT32 topdelta, prevdelta = -1, y = 0;
|
INT32 topdelta, prevdelta = -1, y = 0;
|
||||||
while (col->topdelta != 0xff)
|
while (col->topdelta != 0xff)
|
||||||
{
|
{
|
||||||
|
@ -528,19 +528,19 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
texturememory += blocksize;
|
texturememory += blocksize;
|
||||||
|
|
||||||
// use the patch's column lookup
|
// use the patch's column lookup
|
||||||
colofs = (UINT32 *)(void *)(block + 8);
|
colofs = (block + 8);
|
||||||
texturecolumnofs[texnum] = colofs;
|
texturecolumnofs[texnum] = (UINT32 *)colofs;
|
||||||
blocktex = block;
|
blocktex = block;
|
||||||
if (patch->flip & 1) // flip the patch horizontally
|
if (patch->flip & 1) // flip the patch horizontally
|
||||||
{
|
{
|
||||||
UINT32 *realcolofs = (UINT32 *)realpatch->columnofs;
|
UINT8 *realcolofs = (UINT8 *)realpatch->columnofs;
|
||||||
for (x = 0; x < texture->width; x++)
|
for (x = 0; x < texture->width; x++)
|
||||||
colofs[x] = realcolofs[texture->width-1-x]; // swap with the offset of the other side of the texture
|
*(UINT32 *)&colofs[x<<2] = realcolofs[( texture->width-1-x )<<2]; // swap with the offset of the other side of the texture
|
||||||
}
|
}
|
||||||
// we can't as easily flip the patch vertically sadly though,
|
// we can't as easily flip the patch vertically sadly though,
|
||||||
// we have wait until the texture itself is drawn to do that
|
// we have wait until the texture itself is drawn to do that
|
||||||
for (x = 0; x < texture->width; x++)
|
for (x = 0; x < texture->width; x++)
|
||||||
colofs[x] = LONG(LONG(colofs[x]) + 3);
|
*(UINT32 *)&colofs[x<<2] = LONG(LONG(*(UINT32 *)&colofs[x<<2]) + 3);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,8 +560,8 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
memset(block, TRANSPARENTPIXEL, blocksize+1); // Transparency hack
|
memset(block, TRANSPARENTPIXEL, blocksize+1); // Transparency hack
|
||||||
|
|
||||||
// columns lookup table
|
// columns lookup table
|
||||||
colofs = (UINT32 *)(void *)block;
|
colofs = block;
|
||||||
texturecolumnofs[texnum] = colofs;
|
texturecolumnofs[texnum] = (UINT32 *)colofs;
|
||||||
|
|
||||||
// texture data after the lookup table
|
// texture data after the lookup table
|
||||||
blocktex = block + (texture->width*4);
|
blocktex = block + (texture->width*4);
|
||||||
|
@ -616,8 +616,8 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
patchcol = (column_t *)((UINT8 *)realpatch + LONG(realpatch->columnofs[x-x1]));
|
patchcol = (column_t *)((UINT8 *)realpatch + LONG(realpatch->columnofs[x-x1]));
|
||||||
|
|
||||||
// generate column ofset lookup
|
// generate column ofset lookup
|
||||||
colofs[x] = LONG((x * texture->height) + (texture->width*4));
|
*(UINT32 *)&colofs[x<<2] = LONG((x * texture->height) + (texture->width*4));
|
||||||
ColumnDrawerPointer(patchcol, block + LONG(colofs[x]), patch, texture->height, height);
|
ColumnDrawerPointer(patchcol, block + LONG(*(UINT32 *)&colofs[x<<2]), patch, texture->height, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue