diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 5ddded3d3..51761d31b 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -90,7 +90,7 @@ struct F3DFloor fixed_t delta; - int flags; + unsigned int flags; line_t* master; sector_t * model; diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 3338956f3..5d5ba56d8 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -228,7 +228,7 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f FTexture * tex= TexMan(texnum); if (!tex) return false; - fixed_t totalscale = FixedMul(side->GetTextureYScale(side_t::mid), tex->yScale); + fixed_t totalscale = abs(FixedMul(side->GetTextureYScale(side_t::mid), tex->yScale)); fixed_t y_offset = side->GetTextureYOffset(side_t::mid); fixed_t textureheight = tex->GetScaledHeight(totalscale) << FRACBITS; if (totalscale != FRACUNIT && !tex->bWorldPanning) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 259b3baa8..b007410c8 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -56,7 +56,7 @@ class SightCheck fixed_t topslope, bottomslope; // slopes to top and bottom of target int Flags; divline_t trace; - int myseethrough; + unsigned int myseethrough; bool PTR_SightTraverse (intercept_t *in); bool P_SightCheckLine (line_t *ld); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 30738e657..b738b1c10 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -171,31 +171,30 @@ fixed_t MaskedScaleY; static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FTexture::Span *spans), FTexture *tex) { - if (maskedtexturecol[dc_x] != FIXED_MAX) + // calculate lighting + if (fixedcolormap == NULL && fixedlightlev < 0) { - // calculate lighting - if (fixedcolormap == NULL && fixedlightlev < 0) - { - dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); - } - - dc_iscale = MulScale18 (MaskedSWall[dc_x], MaskedScaleY); - sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale); - - // killough 1/25/98: here's where Medusa came in, because - // it implicitly assumed that the column was all one patch. - // Originally, Doom did not construct complete columns for - // multipatched textures, so there were no header or trailer - // bytes in the column referred to below, which explains - // the Medusa effect. The fix is to construct true columns - // when forming multipatched textures (see r_data.c). - - // draw the texture - const FTexture::Span *spans; - const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); - blastfunc (pixels, spans); -// maskedtexturecol[dc_x] = FIXED_MAX; // kg3D - seems to be useless + dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } + + dc_iscale = MulScale18 (MaskedSWall[dc_x], MaskedScaleY); + if (sprflipvert) + sprtopscreen = centeryfrac + FixedMul(dc_texturemid, spryscale); + else + sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); + + // killough 1/25/98: here's where Medusa came in, because + // it implicitly assumed that the column was all one patch. + // Originally, Doom did not construct complete columns for + // multipatched textures, so there were no header or trailer + // bytes in the column referred to below, which explains + // the Medusa effect. The fix is to construct true columns + // when forming multipatched textures (see r_data.c). + + // draw the texture + const FTexture::Span *spans; + const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); + blastfunc (pixels, spans); rw_light += rw_lightstep; spryscale += rw_scalestep; } @@ -226,7 +225,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) FTexture *tex; int i; sector_t tempsec; // killough 4/13/98 - fixed_t texheight, textop, texheightscale; + fixed_t texheight, texheightscale; bool notrelevant = false; const sector_t *sec; @@ -308,9 +307,14 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1); rw_scalestep = ds->iscalestep; + if (fixedlightlev >= 0) + dc_colormap = basecolormap->Maps + fixedlightlev; + else if (fixedcolormap != NULL) + dc_colormap = fixedcolormap; + // find positioning texheight = tex->GetScaledHeight() << FRACBITS; - texheightscale = curline->sidedef->GetTextureYScale(side_t::mid); + texheightscale = abs(curline->sidedef->GetTextureYScale(side_t::mid)); if (texheightscale != FRACUNIT) { texheight = FixedDiv(texheight, texheightscale); @@ -324,8 +328,18 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) dc_texturemid = MIN (frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); } - { // encapsulate the lifetime of rowoffset - fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid); + fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid); + + if (!(curline->linedef->flags & ML_WRAP_MIDTEX) && + !(curline->sidedef->Flags & WALLF_WRAP_MIDTEX)) + { // Texture does not wrap vertically. + fixed_t textop; + + if (MaskedScaleY < 0) + { + MaskedScaleY = -MaskedScaleY; + sprflipvert = true; + } if (tex->bWorldPanning) { // rowoffset is added before the MulScale3 so that the masked texture will @@ -341,16 +355,11 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) textop = dc_texturemid - viewz + SafeDivScale16 (rowoffset, MaskedScaleY); dc_texturemid = MulScale16 (dc_texturemid - viewz, MaskedScaleY) + rowoffset; } - } - - if (fixedlightlev >= 0) - dc_colormap = basecolormap->Maps + fixedlightlev; - else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; - - if (!(curline->linedef->flags & ML_WRAP_MIDTEX) && - !(curline->sidedef->Flags & WALLF_WRAP_MIDTEX)) - { // Texture does not wrap vertically. + if (sprflipvert) + { + MaskedScaleY = -MaskedScaleY; + dc_texturemid -= tex->GetHeight() << FRACBITS; + } // [RH] Don't bother drawing segs that are completely offscreen if (MulScale12 (globaldclip, ds->sz1) < -textop && @@ -467,6 +476,20 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } else { // Texture does wrap vertically. + if (tex->bWorldPanning) + { + // rowoffset is added before the MulScale3 so that the masked texture will + // still be positioned in world units rather than texels. + dc_texturemid += rowoffset - viewz; + dc_texturemid = MulScale16 (dc_texturemid, MaskedScaleY); + } + else + { + // rowoffset is added outside the multiply so that it positions the texture + // by texels instead of world units. + dc_texturemid = MulScale16 (dc_texturemid - viewz, MaskedScaleY) + rowoffset; + } + WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; WallC.sx1 = ds->sx1; @@ -576,7 +599,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } xscale = FixedMul(rw_pic->xScale, scaledside->GetTextureXScale(scaledpart)); yscale = FixedMul(rw_pic->yScale, scaledside->GetTextureYScale(scaledpart)); - // encapsulate the lifetime of rowoffset + fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureYOffset(side_t::mid); dc_texturemid = rover->model->GetPlaneTexZ(sector_t::ceiling); rw_offset = curline->sidedef->GetTextureXOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureXOffset(side_t::mid); @@ -2508,9 +2531,9 @@ void R_StoreWallRange (int start, int stop) iend = DivScale32 (1, iend); ds_p->yrepeat = yrepeat; ds_p->iscale = istart; - if (stop - start > 1) + if (stop - start > 0) { - ds_p->iscalestep = (iend - istart) / (stop - start - 1); + ds_p->iscalestep = (iend - istart) / (stop - start); } else { diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index 5a3ae960a..6a7370fac 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -276,9 +276,9 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename lump.Read (trans, len); HaveTrans = true; // Save for colortype 2 - NonPaletteTrans[0] = BigShort(((WORD *)trans)[0]); - NonPaletteTrans[1] = BigShort(((WORD *)trans)[1]); - NonPaletteTrans[2] = BigShort(((WORD *)trans)[2]); + NonPaletteTrans[0] = WORD(trans[0] * 256 + trans[1]); + NonPaletteTrans[1] = WORD(trans[2] * 256 + trans[3]); + NonPaletteTrans[2] = WORD(trans[4] * 256 + trans[5]); break; case MAKE_ID('a','l','P','h'):