mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-30 21:20:54 +00:00
Fix misaligned pointers
This commit is contained in:
parent
7a770fa63c
commit
ceb8d298c2
1 changed files with 12 additions and 12 deletions
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;
|
||||
size_t blocksize;
|
||||
column_t *patchcol;
|
||||
UINT32 *colofs;
|
||||
UINT8 *colofs;
|
||||
|
||||
UINT16 wadnum;
|
||||
lumpnum_t lumpnum;
|
||||
|
@ -496,10 +496,10 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
|||
// Check the patch for holes.
|
||||
if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height))
|
||||
holey = true;
|
||||
colofs = (UINT32 *)realpatch->columnofs;
|
||||
colofs = (UINT8 *)realpatch->columnofs;
|
||||
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;
|
||||
while (col->topdelta != 0xff)
|
||||
{
|
||||
|
@ -528,19 +528,19 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
|||
texturememory += blocksize;
|
||||
|
||||
// use the patch's column lookup
|
||||
colofs = (UINT32 *)(void *)(block + 8);
|
||||
texturecolumnofs[texnum] = colofs;
|
||||
colofs = (block + 8);
|
||||
texturecolumnofs[texnum] = (UINT32 *)colofs;
|
||||
blocktex = block;
|
||||
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++)
|
||||
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 have wait until the texture itself is drawn to do that
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -560,8 +560,8 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
|||
memset(block, TRANSPARENTPIXEL, blocksize+1); // Transparency hack
|
||||
|
||||
// columns lookup table
|
||||
colofs = (UINT32 *)(void *)block;
|
||||
texturecolumnofs[texnum] = colofs;
|
||||
colofs = block;
|
||||
texturecolumnofs[texnum] = (UINT32 *)colofs;
|
||||
|
||||
// texture data after the lookup table
|
||||
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]));
|
||||
|
||||
// generate column ofset lookup
|
||||
colofs[x] = LONG((x * texture->height) + (texture->width*4));
|
||||
ColumnDrawerPointer(patchcol, block + LONG(colofs[x]), patch, texture->height, height);
|
||||
*(UINT32 *)&colofs[x<<2] = LONG((x * texture->height) + (texture->width*4));
|
||||
ColumnDrawerPointer(patchcol, block + LONG(*(UINT32 *)&colofs[x<<2]), patch, texture->height, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue