Fix misaligned pointers

(cherry picked from commit ceb8d298c2ae9a6000fa4d22e381085c6bf77cd6)
This commit is contained in:
James R 2019-11-07 16:29:58 -08:00
parent da2a640c6c
commit 437f7aa16d
1 changed files with 10 additions and 10 deletions

View File

@ -198,7 +198,7 @@ static UINT8 *R_GenerateTexture(size_t texnum)
int x, x1, x2, i;
size_t blocksize;
column_t *patchcol;
UINT32 *colofs;
UINT8 *colofs;
I_Assert(texnum <= (size_t)numtextures);
texture = textures[texnum];
@ -219,10 +219,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)
{
@ -250,11 +250,11 @@ 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;
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;
}
@ -270,8 +270,8 @@ static UINT8 *R_GenerateTexture(size_t texnum)
memset(block, 0xF7, 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);
@ -296,8 +296,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));
R_DrawColumnInCache(patchcol, block + LONG(colofs[x]), patch->originy, texture->height);
*(UINT32 *)&colofs[x<<2] = LONG((x * texture->height) + (texture->width*4));
R_DrawColumnInCache(patchcol, block + LONG(*(UINT32 *)&colofs[x<<2]), patch->originy, texture->height);
}
}