diff --git a/src/r_defs.h b/src/r_defs.h index 2d1dc5ca97..27c578e568 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -832,11 +832,11 @@ struct side_t void SetTextureXScale(int which, fixed_t scale) { - textures[which].xscale = scale <= 0? FRACUNIT : scale; + textures[which].xscale = scale == 0 ? FRACUNIT : scale; } void SetTextureXScale(fixed_t scale) { - textures[top].xscale = textures[mid].xscale = textures[bottom].xscale = scale <= 0? FRACUNIT : scale; + textures[top].xscale = textures[mid].xscale = textures[bottom].xscale = scale == 0 ? FRACUNIT : scale; } fixed_t GetTextureXScale(int which) const { diff --git a/src/r_segs.cpp b/src/r_segs.cpp index a40a2ce351..bfeab506ae 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -2769,6 +2769,7 @@ int WallMost (short *mostbuf, const secplane_t &plane) static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat) { // fix for rounding errors + walxrepeat = abs(walxrepeat); fixed_t fix = (MirrorFlags & RF_XFLIP) ? walxrepeat-1 : 0; int x; @@ -2803,7 +2804,7 @@ static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat) void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat) { // swall = scale, lwall = texturecolumn double top, bot, i; - double xrepeat = walxrepeat; + double xrepeat = fabs((double)walxrepeat); i = WallSX1 - centerx; top = WallUoverZorg + WallUoverZstep * i; @@ -2812,7 +2813,14 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat) for (int x = WallSX1; x < WallSX2; x++) { double frac = top / bot; - lwall[x] = xs_RoundToInt(frac * xrepeat); + if (walxrepeat < 0) + { + lwall[x] = xs_RoundToInt(xrepeat - frac * xrepeat); + } + else + { + lwall[x] = xs_RoundToInt(frac * xrepeat); + } swall[x] = xs_RoundToInt(frac * WallDepthScale + WallDepthOrg); top += WallUoverZstep; bot += WallInvZstep; @@ -2823,7 +2831,7 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat) void PrepLWall (fixed_t *lwall, fixed_t walxrepeat) { // lwall = texturecolumn double top, bot, i; - double xrepeat = walxrepeat; + double xrepeat = fabs((double)walxrepeat); double topstep; i = WallSX1 - centerx; @@ -2835,7 +2843,14 @@ void PrepLWall (fixed_t *lwall, fixed_t walxrepeat) for (int x = WallSX1; x < WallSX2; x++) { - lwall[x] = xs_RoundToInt(top / bot); + if (walxrepeat < 0) + { + lwall[x] = xs_RoundToInt(xrepeat - top / bot); + } + else + { + lwall[x] = xs_RoundToInt(top / bot); + } top += topstep; bot += WallInvZstep; }