diff --git a/src/r_things.c b/src/r_things.c index ca9d570c0..a3d8b500f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -865,6 +865,7 @@ static void R_DrawVisSprite(vissprite_t *vis) localcolfunc = (vis->vflip) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn; lengthcol = SHORT(patch->height); + pwidth = SHORT(patch->width); // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) @@ -872,8 +873,6 @@ static void R_DrawVisSprite(vissprite_t *vis) fixed_t horzscale = FixedMul(vis->spritexscale, this_scale); fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); - pwidth = SHORT(patch->width); - // Papersprite drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) { @@ -897,9 +896,9 @@ static void R_DrawVisSprite(vissprite_t *vis) else { // Non-paper drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2 && (frac>>FRACBITS) < patch->width; dc_x++, frac += vis->xiscale) + for (dc_x = vis->x1; dc_x <= vis->x2 && (frac>>FRACBITS) < pwidth; dc_x++, frac += vis->xiscale) { - texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); + texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); localcolfunc (column);