From 139253a8c2e88a3b421a9b92f1bb1e067d1c6d17 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 16 Oct 2020 16:40:57 -0700 Subject: [PATCH 01/22] Offset slope anchors from regular slopes --- src/slope_anchors.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/slope_anchors.c b/src/slope_anchors.c index 51a567f19..69dc504a6 100644 --- a/src/slope_anchors.c +++ b/src/slope_anchors.c @@ -118,13 +118,16 @@ anchor_height const mapthing_t * a, const sector_t * s ){ + const fixed_t x = a->x << FRACBITS; + const fixed_t y = a->y << FRACBITS; + if (a->options & MTF_OBJECTFLIP) { - return ( s->ceilingheight >> FRACBITS ) - a->z; + return ( P_GetSectorCeilingZAt(s, x, y) >> FRACBITS ) - a->z; } else { - return ( s->floorheight >> FRACBITS ) + a->z; + return ( P_GetSectorFloorZAt(s, x, y) >> FRACBITS ) + a->z; } } @@ -144,13 +147,13 @@ set_anchor fixed_t closeness; - a->z = anchor_height(a, sub->sector); - v = nearest_point(&closeness, a, sub->sector); a->x = ( v->x >> FRACBITS ); a->y = ( v->y >> FRACBITS ); + a->z = anchor_height(a, sub->sector); + list->anchors [list->count] = a; list->points [list->count] = v; list->closeness[list->count] = closeness; From 5558fb073ac92ebd1e3c3dc2a632a20542d6f580 Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 18 Oct 2020 19:10:19 +0100 Subject: [PATCH 02/22] Basic additive transmap/blend support Can currently be used on sprites only added to flames by default because it makes sense --- src/dehacked.c | 4 ++++ src/hardware/hw_main.c | 1 + src/info.c | 14 +++++++------- src/p_mobj.h | 1 + src/p_pspr.h | 2 ++ src/r_draw.c | 3 ++- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 2d7b58ac9..b57d52c7f 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11123,6 +11123,7 @@ struct { {"FF_TRANS70",FF_TRANS70}, {"FF_TRANS80",FF_TRANS80}, {"FF_TRANS90",FF_TRANS90}, + {"FF_TRANSADD",FF_TRANSADD}, // compatibility // Transparency for SOCs is pre-shifted {"TR_TRANS10",tr_trans10<PolyColor.s.alpha = 0x4c;return PF_Translucent; case tr_trans80 : pSurf->PolyColor.s.alpha = 0x33;return PF_Translucent; case tr_trans90 : pSurf->PolyColor.s.alpha = 0x19;return PF_Translucent; + case tr_transadd : pSurf->PolyColor.s.alpha = 0xFF;return PF_Additive; } return PF_Translucent; } diff --git a/src/info.c b/src/info.c index 6d5bac1ea..cfa51f9cd 100644 --- a/src/info.c +++ b/src/info.c @@ -2231,9 +2231,9 @@ state_t states[NUMSTATES] = {SPR_CHAN, 0, -1, {NULL}, 0, 0, S_NULL}, // S_CEZCHAIN // Flame - {SPR_FLAM, FF_FULLBRIGHT|FF_ANIMATE, 3*8, {A_FlameParticle}, 7, 3, S_FLAME}, // S_FLAME - {SPR_FLAM, FF_FULLBRIGHT|FF_ANIMATE|8, TICRATE, {NULL}, 3, 3, S_NULL}, // S_FLAMEPARTICLE - {SPR_FLAM, FF_FULLBRIGHT|FF_ANIMATE, -1, {NULL}, 7, 3, S_NULL}, // S_FLAMEREST + {SPR_FLAM, FF_FULLBRIGHT|FF_ANIMATE|FF_TRANSADD, 3*8, {A_FlameParticle}, 7, 3, S_FLAME}, // S_FLAME + {SPR_FLAM, FF_FULLBRIGHT|FF_ANIMATE|FF_TRANSADD|8, TICRATE, {NULL}, 3, 3, S_NULL}, // S_FLAMEPARTICLE + {SPR_FLAM, FF_FULLBRIGHT|FF_ANIMATE|FF_TRANSADD, -1, {NULL}, 7, 3, S_NULL}, // S_FLAMEREST // Eggman statue {SPR_ESTA, 0, -1, {NULL}, 0, 0, S_NULL}, // S_EGGSTATUE1 @@ -4383,10 +4383,10 @@ state_t states[NUMSTATES] = {SPR_AUDI, 4|FF_ANIMATE, -1, {NULL}, 1, 17, S_NULL}, // S_AUDIENCE_CHAO_LOSE - {SPR_FLAM, 0, 3, {NULL}, 0, 0, S_FLAYM2}, // S_FLAYM1, - {SPR_FLAM, 1, 3, {NULL}, 0, 0, S_FLAYM3}, // S_FLAYM2, - {SPR_FLAM, 2, 3, {NULL}, 0, 0, S_FLAYM4}, // S_FLAYM3, - {SPR_FLAM, 3, 3, {NULL}, 0, 0, S_FLAYM1}, // S_FLAYM4, + {SPR_FLAM, FF_FULLBRIGHT|FF_TRANSADD|0, 3, {NULL}, 0, 0, S_FLAYM2}, // S_FLAYM1, + {SPR_FLAM, FF_FULLBRIGHT|FF_TRANSADD|1, 3, {NULL}, 0, 0, S_FLAYM3}, // S_FLAYM2, + {SPR_FLAM, FF_FULLBRIGHT|FF_TRANSADD|2, 3, {NULL}, 0, 0, S_FLAYM4}, // S_FLAYM3, + {SPR_FLAM, FF_FULLBRIGHT|FF_TRANSADD|3, 3, {NULL}, 0, 0, S_FLAYM1}, // S_FLAYM4, {SPR_DECO, 0, -1, {NULL}, 0, 0, S_NULL}, // S_DEVIL, {SPR_DECO, 1, -1, {NULL}, 0, 0, S_NULL}, // S_ANGEL, diff --git a/src/p_mobj.h b/src/p_mobj.h index cd0cc3bc7..04a75c85e 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -268,6 +268,7 @@ typedef enum MFD_TRANS70 = 0x0070, MFD_TRANS80 = 0x0080, MFD_TRANS90 = 0x0090, + MFD_TRANSADD = 0x00A0, MFD_TRANSMASK = 0x00F0, // Brightness override flags MFD_FULLBRIGHT = 0x0100, diff --git a/src/p_pspr.h b/src/p_pspr.h index 6eaf33279..eaa469cd7 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -59,6 +59,7 @@ #define FF_TRANS70 (tr_trans70< Date: Mon, 19 Oct 2020 11:57:12 +0100 Subject: [PATCH 03/22] Subtractive translation map --- src/dehacked.c | 3 +++ src/hardware/hw_main.c | 1 + src/p_mobj.h | 1 + src/p_pspr.h | 2 ++ src/r_draw.c | 3 ++- 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index b57d52c7f..c564174c2 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11124,6 +11124,7 @@ struct { {"FF_TRANS80",FF_TRANS80}, {"FF_TRANS90",FF_TRANS90}, {"FF_TRANSADD",FF_TRANSADD}, + {"FF_TRANSSUB",FF_TRANSSUB}, // compatibility // Transparency for SOCs is pre-shifted {"TR_TRANS10",tr_trans10<PolyColor.s.alpha = 0x33;return PF_Translucent; case tr_trans90 : pSurf->PolyColor.s.alpha = 0x19;return PF_Translucent; case tr_transadd : pSurf->PolyColor.s.alpha = 0xFF;return PF_Additive; + case tr_transsub : pSurf->PolyColor.s.alpha = 0xFF;return PF_Substractive; } return PF_Translucent; } diff --git a/src/p_mobj.h b/src/p_mobj.h index 04a75c85e..6ffa393aa 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -269,6 +269,7 @@ typedef enum MFD_TRANS80 = 0x0080, MFD_TRANS90 = 0x0090, MFD_TRANSADD = 0x00A0, + MFD_TRANSSUB = 0x00B0, MFD_TRANSMASK = 0x00F0, // Brightness override flags MFD_FULLBRIGHT = 0x0100, diff --git a/src/p_pspr.h b/src/p_pspr.h index eaa469cd7..cbc1a845f 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -60,6 +60,7 @@ #define FF_TRANS80 (tr_trans80< Date: Thu, 22 Oct 2020 22:27:14 +0100 Subject: [PATCH 04/22] Additive/Subtractive translation map support on midtextures --- src/hardware/hw_main.c | 7 +++++-- src/r_segs.c | 24 ++++++++++++++++++++---- src/r_segs.h | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4d5b136cf..9d0dc91b0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1466,11 +1466,14 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode = PF_Translucent; break; default: - if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) - blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), &Surf); + { + transnum_t transtable = R_GetLinedefTransTable(gl_linedef); + if (transtable != NUMTRANSMAPS) + blendmode = HWR_TranstableToAlpha(transtable, &Surf); else blendmode = PF_Masked; break; + } } if (gl_curline->polyseg && gl_curline->polyseg->translucency > 0) diff --git a/src/r_segs.c b/src/r_segs.c index a848dd884..a646ff440 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -270,9 +270,23 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) } } -transnum_t R_GetLinedefTransTable(fixed_t alpha) +transnum_t R_GetLinedefTransTable(line_t *ldef) { - return (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1); + transnum_t transnum = NUMTRANSMAPS; // Send back NUMTRANSMAPS for none + fixed_t alpha = ldef->alpha; + if (alpha > 0 && alpha < FRACUNIT) + transnum = (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1); + else + { + switch (ldef->special) + { + case 910: transnum = tr_transadd; break; + case 911: transnum = tr_transsub; break; + default: transnum = NUMTRANSMAPS; break; + } + } + + return transnum; } void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) @@ -289,6 +303,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) INT32 times, repeats; INT64 overflow_test; INT32 range; + transnum_t transtable = NUMTRANSMAPS; // Calculate light table. // Use different light tables @@ -305,9 +320,10 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (!ldef->alpha) return; - if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) + transtable = R_GetLinedefTransTable(ldef); + if (transtable != NUMTRANSMAPS) { - dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT); + dc_transmap = transtables + ((transtable - 1) << FF_TRANSSHIFT); colfunc = colfuncs[COLDRAWFUNC_FUZZY]; } diff --git a/src/r_segs.h b/src/r_segs.h index ace5711d4..6a79047e0 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -18,7 +18,7 @@ #pragma interface #endif -transnum_t R_GetLinedefTransTable(fixed_t alpha); +transnum_t R_GetLinedefTransTable(line_t *line); void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2); void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pffloor); void R_StoreWallRange(INT32 start, INT32 stop); From d311242a6e226c367c3f0c0e5f2f62a57a709f4d Mon Sep 17 00:00:00 2001 From: Sryder Date: Thu, 22 Oct 2020 23:13:51 +0100 Subject: [PATCH 05/22] Support for additive/subtractive translation maps on FOFs and Polyobjects Polyobjects set translucency to 11 for additive, and 12 for subtractive FOFs using the regular translucency settings set the top texture to #900 for additive, and #901 for subtractive --- src/hardware/hw_main.c | 50 +++++++++++++++++++++++++++++++++--------- src/p_polyobj.c | 2 +- src/r_defs.h | 3 +++ src/r_plane.c | 6 ++++- src/r_segs.c | 4 ++++ 5 files changed, 53 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9d0dc91b0..0e0c83f9f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1735,10 +1735,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { FBITFIELD blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if (rover->flags & FF_TRANSLUCENT) { - blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; + if (rover->alpha < 256) + { + blendmode = PF_Translucent; + Surf.PolyColor.s.alpha = (UINT8)(rover->alpha-1 > 255 ? 255 : rover->alpha-1); + } + else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE) + blendmode = PF_Additive; + else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE) + blendmode = PF_Substractive; } if (gl_frontsector->numlights) @@ -1835,10 +1842,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { FBITFIELD blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if (rover->flags & FF_TRANSLUCENT) { - blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; + if (rover->alpha < 256) + { + blendmode = PF_Translucent; + Surf.PolyColor.s.alpha = (UINT8)(rover->alpha-1 > 255 ? 255 : rover->alpha-1); + } + else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE) + blendmode = PF_Additive; + else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE) + blendmode = PF_Substractive; } if (gl_backsector->numlights) @@ -3098,8 +3112,16 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient + else if (rover->flags & FF_TRANSLUCENT + && (rover->alpha < 256 + || rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE || rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)) // SoM: Flags are more efficient { + FBITFIELD blendmode = PF_Translucent; + if (rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE) + blendmode = PF_Additive; + else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE) + blendmode = PF_Substractive; + light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_AddTransparentFloor(&levelflats[*rover->bottompic], @@ -3107,7 +3129,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gl_frontsector->lightlist[light].lightlevel, - rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|blendmode, false, *gl_frontsector->lightlist[light].extra_colormap); } else @@ -3143,8 +3165,16 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + else if (rover->flags & FF_TRANSLUCENT + && (rover->alpha < 256 + || rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE || rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)) // SoM: Flags are more efficient { + FBITFIELD blendmode = PF_Translucent; + if (rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE) + blendmode = PF_Additive; + else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE) + blendmode = PF_Substractive; + light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_AddTransparentFloor(&levelflats[*rover->toppic], @@ -3152,7 +3182,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, - rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|blendmode, false, *gl_frontsector->lightlist[light].extra_colormap); } else diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 5ec8fe007..645cf010d 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2563,7 +2563,7 @@ void T_PolyObjFade(polyfade_t *th) { if (po->translucency >= NUMTRANSMAPS) // HACK: OpenGL renders fully opaque when >= NUMTRANSMAPS - po->translucency = NUMTRANSMAPS-1; + po->translucency = tr_trans90; po->flags |= (po->spawnflags & POF_RENDERALL); diff --git a/src/r_defs.h b/src/r_defs.h index 715067176..8372a5ae5 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -152,6 +152,9 @@ typedef enum FF_GOOWATER = FF_SHATTERBOTTOM, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. } ffloortype_e; +#define FFLOOR_ALPHA_SPECIAL_ADDITIVE (901) +#define FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE (902) + typedef struct ffloor_s { fixed_t *topheight; diff --git a/src/r_plane.c b/src/r_plane.c index 3e6f30235..7439886d7 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -952,7 +952,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->polyobj) { // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) - if (pl->polyobj->translucency >= 10) + if (pl->polyobj->translucency >= NUMTRANSMAPS) return; // Don't even draw it else if (pl->polyobj->translucency > 0) { @@ -1013,6 +1013,10 @@ void R_DrawSinglePlane(visplane_t *pl) ds_transmap = transtables + ((tr_trans20-1)<ffloor->alpha < 243) ds_transmap = transtables + ((tr_trans10-1)<ffloor->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE) + dc_transmap = transtables + ((tr_transadd-1)<ffloor->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE) + dc_transmap = transtables + ((tr_transsub-1)<alpha < 243) dc_transmap = transtables + ((tr_trans10-1)<alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE) + dc_transmap = transtables + ((tr_transadd-1)<alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE) + dc_transmap = transtables + ((tr_transsub-1)< Date: Sat, 24 Oct 2020 00:50:58 +0100 Subject: [PATCH 06/22] Fix dumb copy paste error that caused software to crash --- src/r_plane.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 7439886d7..0f11bcb02 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -1014,9 +1014,9 @@ void R_DrawSinglePlane(visplane_t *pl) else if (pl->ffloor->alpha < 243) ds_transmap = transtables + ((tr_trans10-1)<ffloor->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE) - dc_transmap = transtables + ((tr_transadd-1)<ffloor->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE) - dc_transmap = transtables + ((tr_transsub-1)< Date: Sat, 24 Oct 2020 01:02:01 +0100 Subject: [PATCH 07/22] Fix the additive/subtractive floors not working in OpenGL. --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0e0c83f9f..22f1e0b0a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -551,7 +551,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool HWR_Lighting(&Surf, lightlevel, planecolormap); - if (PolyFlags & (PF_Translucent|PF_Fog)) + if (PolyFlags & (PF_Translucent|PF_Additive|PF_Substractive|PF_Fog)) { Surf.PolyColor.s.alpha = (UINT8)alpha; PolyFlags |= PF_Modulated; From b16a16027d8b65550d9e0f45f8b390c9b18faf4e Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 25 Oct 2020 00:27:28 +0100 Subject: [PATCH 08/22] Fix additive/subtractive walls not working when sectors have multiple lights in OpenGL This is a change that could have broken other areas so should be checked too for other areas --- src/hardware/hw_main.c | 90 ++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 35 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 22f1e0b0a..c7886c4a2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -850,7 +850,7 @@ static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) // // HWR_SplitWall // -static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor) +static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD blendmode) { /* SoM: split up and light walls according to the lightlist. This may also include leaving out parts @@ -987,12 +987,12 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, wallVerts[0].y = bot; wallVerts[1].y = endbot; - if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent, false, lightnum, colormap); + if (blendmode & PF_Fog) + HWR_AddTransparentWall(wallVerts, Surf, texnum, blendmode, true, lightnum, colormap); + else if (blendmode & (PF_Translucent|PF_Additive|PF_Substractive|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, blendmode, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); + HWR_ProjectWall(wallVerts, Surf, blendmode, lightnum, colormap); top = bot; endtop = endbot; @@ -1016,12 +1016,12 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, wallVerts[0].y = bot; wallVerts[1].y = endbot; - if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent, false, lightnum, colormap); + if (blendmode & PF_Fog) + HWR_AddTransparentWall(wallVerts, Surf, texnum, blendmode, true, lightnum, colormap); + else if (blendmode & (PF_Translucent|PF_Additive|PF_Substractive|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, blendmode, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); + HWR_ProjectWall(wallVerts, Surf, blendmode, lightnum, colormap); } // HWR_DrawSkyWall @@ -1201,12 +1201,19 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); - if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, &Surf, FF_CUTLEVEL, NULL); - else if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, PF_Environment, false, lightnum, colormap); - else - HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); + { + FBITFIELD blendmode = PF_Masked; + + if (grTex->mipmap.flags & TF_TRANSPARENT) + blendmode = PF_Environment; + + if (gl_frontsector->numlights) + HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, &Surf, FF_CUTLEVEL, NULL, blendmode); + else if (grTex->mipmap.flags & TF_TRANSPARENT) + HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, blendmode, false, lightnum, colormap); + else + HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); + } } // check BOTTOM TEXTURE @@ -1267,12 +1274,19 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); - if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, &Surf, FF_CUTLEVEL, NULL); - else if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, PF_Environment, false, lightnum, colormap); - else - HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); + { + FBITFIELD blendmode = PF_Masked; + + if (grTex->mipmap.flags & TF_TRANSPARENT) + blendmode = PF_Environment; + + if (gl_frontsector->numlights) + HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, &Surf, FF_CUTLEVEL, NULL, blendmode); + else if (grTex->mipmap.flags & TF_TRANSPARENT) + HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, blendmode, false, lightnum, colormap); + else + HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); + } } gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); if (gl_midtexture) @@ -1490,10 +1504,10 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gl_frontsector->numlights) { if (!(blendmode & PF_Masked)) - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL, blendmode); else { - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL, blendmode); } } else if (!(blendmode & PF_Masked)) @@ -1574,15 +1588,21 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); - // I don't think that solid walls can use translucent linedef types... - if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL); - else { + FBITFIELD blendmode = PF_Masked; if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, PF_Environment, false, lightnum, colormap); + blendmode = PF_Environment; + + // I don't think that solid walls can use translucent linedef types... + if (gl_frontsector->numlights) + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL, blendmode); else - HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); + { + if (grTex->mipmap.flags & TF_TRANSPARENT) + HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap); + else + HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); + } } } @@ -1727,7 +1747,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover); + HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1749,7 +1769,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover); + HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -1834,7 +1854,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover); + HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1856,7 +1876,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover); + HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) From dc453fbbda15f6a40bdac3f9455dad44f8f0bfbd Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 25 Oct 2020 23:19:20 +0000 Subject: [PATCH 09/22] Fix various things that used NUMTRANSMAPS for the number of translucent trans maps --- src/dehacked.c | 1 + src/hu_stuff.c | 10 +++++----- src/k_battle.c | 4 ++-- src/p_mobj.c | 22 +++++++++++----------- src/p_polyobj.c | 16 ++++++++-------- src/p_pspr.h | 3 ++- src/p_setup.c | 2 +- src/p_spec.c | 2 +- src/s_sound.c | 2 +- 9 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 9bd84fdbc..6268aca86 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11148,6 +11148,7 @@ struct { {"tr_trans70",tr_trans70}, {"tr_trans80",tr_trans80}, {"tr_trans90",tr_trans90}, + {"NUMTRANSLUCENTTRANSMAPS",NUMTRANSLUCENTTRANSMAPS}, {"tr_transadd",tr_transadd}, {"tr_transsub",tr_transsub}, {"NUMTRANSMAPS",NUMTRANSMAPS}, diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 35f977bd6..93192d796 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -703,7 +703,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) } else if (target == -1) // say team { - if (players[playernum].ctfteam == 1) + if (players[playernum].ctfteam == 1) { // red text cstart = textcolor = "\x85"; @@ -1934,7 +1934,7 @@ void HU_DrawSongCredits(void) } else { - if (cursongcredit.trans < NUMTRANSMAPS) + if (cursongcredit.trans < NUMTRANSLUCENTTRANSMAPS) cursongcredit.trans++; if (cursongcredit.x > 0) cursongcredit.x /= 2; @@ -1942,10 +1942,10 @@ void HU_DrawSongCredits(void) cursongcredit.x = 0; } - bgt = (NUMTRANSMAPS/2)+(cursongcredit.trans/2); - if (bgt < NUMTRANSMAPS) + bgt = (NUMTRANSLUCENTTRANSMAPS/2)+(cursongcredit.trans/2); + if (bgt < NUMTRANSLUCENTTRANSMAPS) V_DrawScaledPatch(cursongcredit.x, y-2, V_SNAPTOLEFT|(bgt<x, battleovertime.y-players[displayplayers[0]].mo->y); - transparency = max(0, NUMTRANSMAPS - ((256 + (dist>>FRACBITS)) / 256)); + transparency = max(0, NUMTRANSLUCENTTRANSMAPS - ((256 + (dist>>FRACBITS)) / 256)); } - if (transparency < NUMTRANSMAPS) + if (transparency < NUMTRANSLUCENTTRANSMAPS) { mobj_t *beam = P_SpawnMobj(battleovertime.x, battleovertime.y, battleovertime.z + (mobjinfo[MT_RANDOMITEM].height/2), MT_OVERTIMEBEAM); P_SetScale(beam, beam->scale*2); diff --git a/src/p_mobj.c b/src/p_mobj.c index be907321e..25cb1bf8c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6442,7 +6442,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->color = K_RainbowColor( (SKINCOLOR_PURPLE - SKINCOLOR_PINK) // Smoothly transition into the other state + ((mobj->fuse - 32) * 2) // Make the color flashing slow down while it runs out - ); + ); switch (mobj->extravalue1) { @@ -6674,12 +6674,12 @@ static boolean P_MobjRegularThink(mobj_t *mobj) const angle_t off = FixedAngle(40*FRACUNIT); angle_t ang = mobj->target->angle; fixed_t z; - UINT8 trans = (mobj->target->player->kartstuff[k_tiregrease] * (NUMTRANSMAPS+1)) / greasetics; + UINT8 trans = (mobj->target->player->kartstuff[k_tiregrease] * (NUMTRANSLUCENTTRANSMAPS+1)) / greasetics; - if (trans > NUMTRANSMAPS) - trans = NUMTRANSMAPS; + if (trans > NUMTRANSLUCENTTRANSMAPS) + trans = NUMTRANSLUCENTTRANSMAPS; - trans = NUMTRANSMAPS - trans; + trans = NUMTRANSLUCENTTRANSMAPS - trans; z = mobj->target->z; if (mobj->eflags & MFE_VERTICALFLIP) @@ -6702,7 +6702,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (leveltime & 1) mobj->drawflags |= MFD_DONTDRAW; - if (trans >= NUMTRANSMAPS) + if (trans >= NUMTRANSLUCENTTRANSMAPS) mobj->drawflags |= MFD_DONTDRAW; else if (trans == 0) mobj->drawflags = (mobj->drawflags & ~MFD_TRANSMASK); @@ -8437,15 +8437,15 @@ void P_MobjThinker(mobj_t *mobj) { if (mobj->flags2 & MF2_BOSSNOTRAP) // "fast" flag { - if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSMAPS-1) - (2*mobj->fuse)/3) + if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSLUCENTTRANSMAPS-1) - (2*mobj->fuse)/3) // fade out when nearing the end of fuse... - mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSMAPS-1) - (2*mobj->fuse)/3) << FF_TRANSSHIFT); + mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSLUCENTTRANSMAPS-1) - (2*mobj->fuse)/3) << FF_TRANSSHIFT); } else { - if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSMAPS-1) - mobj->fuse / 2) + if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSLUCENTTRANSMAPS-1) - mobj->fuse / 2) // fade out when nearing the end of fuse... - mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSMAPS-1) - mobj->fuse / 2) << FF_TRANSSHIFT); + mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSLUCENTTRANSMAPS-1) - mobj->fuse / 2) << FF_TRANSSHIFT); } } @@ -10048,7 +10048,7 @@ void P_SpawnPlayer(INT32 playernum) /* if (bonusgame || specialstage) { - // Bots should avoid + // Bots should avoid p->spectator = true; } */ diff --git a/src/p_polyobj.c b/src/p_polyobj.c index eff28e21d..6b6d7d588 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2515,7 +2515,7 @@ void T_PolyObjFade(polyfade_t *th) if (th->timer <= 0) { - po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); + po->translucency = max(min(th->destvalue, NUMTRANSLUCENTTRANSMAPS), 0); // remove thinker if (po->thinker == &th->thinker) @@ -2526,8 +2526,8 @@ void T_PolyObjFade(polyfade_t *th) { INT16 delta = abs(th->destvalue - th->sourcevalue); INT32 duration = th->ticbased ? th->duration - : abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) - - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // speed-based internal counter duration: delta in 256 scale + : abs(FixedMul(FixedDiv(256, NUMTRANSLUCENTTRANSMAPS), NUMTRANSLUCENTTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSLUCENTTRANSMAPS), NUMTRANSLUCENTTRANSMAPS - th->sourcevalue)); // speed-based internal counter duration: delta in 256 scale fixed_t factor = min(FixedDiv(duration - th->timer, duration), 1*FRACUNIT); if (th->destvalue < th->sourcevalue) po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); @@ -2538,7 +2538,7 @@ void T_PolyObjFade(polyfade_t *th) if (!stillfading) { // set render flags - if (po->translucency >= NUMTRANSMAPS) // invisible + if (po->translucency >= NUMTRANSLUCENTTRANSMAPS) // invisible po->flags &= ~POF_RENDERALL; else po->flags |= (po->spawnflags & POF_RENDERALL); @@ -2561,8 +2561,8 @@ void T_PolyObjFade(polyfade_t *th) } else { - if (po->translucency >= NUMTRANSMAPS) - // HACK: OpenGL renders fully opaque when >= NUMTRANSMAPS + if (po->translucency >= NUMTRANSLUCENTTRANSMAPS) + // HACK: OpenGL renders add/sub.opaque when >= NUMTRANSLUCENTTRANSMAPS po->translucency = tr_trans90; po->flags |= (po->spawnflags & POF_RENDERALL); @@ -2630,8 +2630,8 @@ boolean EV_DoPolyObjFade(polyfadedata_t *pfdata) else { th->ticbased = false; - th->timer = abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) - - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // delta converted to 256 scale, use as internal counter + th->timer = abs(FixedMul(FixedDiv(256, NUMTRANSLUCENTTRANSMAPS), NUMTRANSLUCENTTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSLUCENTTRANSMAPS), NUMTRANSLUCENTTRANSMAPS - th->sourcevalue)); // delta converted to 256 scale, use as internal counter th->duration = abs(pfdata->speed); // use th->duration as speed decrement } diff --git a/src/p_pspr.h b/src/p_pspr.h index cbc1a845f..ee82ade6a 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -101,7 +101,8 @@ typedef enum tr_trans70, tr_trans80, tr_trans90, - tr_transadd, + NUMTRANSLUCENTTRANSMAPS, + tr_transadd = NUMTRANSLUCENTTRANSMAPS, tr_transsub, NUMTRANSMAPS } transnum_t; diff --git a/src/p_setup.c b/src/p_setup.c index 50f39c5fa..df4fec9c8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3381,7 +3381,7 @@ static void P_InitLevelSettings(void) // song credit init memset(&cursongcredit,0,sizeof(struct cursongcredit)); - cursongcredit.trans = NUMTRANSMAPS; + cursongcredit.trans = NUMTRANSLUCENTTRANSMAPS; for (i = 0; i < MAXPLAYERS; i++) { diff --git a/src/p_spec.c b/src/p_spec.c index 34a962975..2435e964d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1257,7 +1257,7 @@ static boolean PolyFade(line_t *line) else pfd.destvalue = value; - pfd.destvalue = max(min(pfd.destvalue, NUMTRANSMAPS), 0); + pfd.destvalue = max(min(pfd.destvalue, NUMTRANSLUCENTTRANSMAPS), 0); // already equal, nothing to do if (po->translucency == pfd.destvalue) diff --git a/src/s_sound.c b/src/s_sound.c index 197e65e57..302a352a7 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1800,7 +1800,7 @@ void S_ShowMusicCredit(void) cursongcredit.def = def; cursongcredit.anim = 5*TICRATE; cursongcredit.x = 0; - cursongcredit.trans = NUMTRANSMAPS; + cursongcredit.trans = NUMTRANSLUCENTTRANSMAPS; return; } else From a585d3c9d1b6e4ce514afbf2bce33f6f853c007e Mon Sep 17 00:00:00 2001 From: Sryder Date: Mon, 26 Oct 2020 11:07:17 +0000 Subject: [PATCH 10/22] Revert "Fix various things that used NUMTRANSMAPS for the number of translucent trans maps" This reverts commit dc453fbbda15f6a40bdac3f9455dad44f8f0bfbd. --- src/dehacked.c | 1 - src/hu_stuff.c | 10 +++++----- src/k_battle.c | 4 ++-- src/p_mobj.c | 22 +++++++++++----------- src/p_polyobj.c | 16 ++++++++-------- src/p_pspr.h | 3 +-- src/p_setup.c | 2 +- src/p_spec.c | 2 +- src/s_sound.c | 2 +- 9 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 6268aca86..9bd84fdbc 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11148,7 +11148,6 @@ struct { {"tr_trans70",tr_trans70}, {"tr_trans80",tr_trans80}, {"tr_trans90",tr_trans90}, - {"NUMTRANSLUCENTTRANSMAPS",NUMTRANSLUCENTTRANSMAPS}, {"tr_transadd",tr_transadd}, {"tr_transsub",tr_transsub}, {"NUMTRANSMAPS",NUMTRANSMAPS}, diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 93192d796..35f977bd6 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -703,7 +703,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) } else if (target == -1) // say team { - if (players[playernum].ctfteam == 1) + if (players[playernum].ctfteam == 1) { // red text cstart = textcolor = "\x85"; @@ -1934,7 +1934,7 @@ void HU_DrawSongCredits(void) } else { - if (cursongcredit.trans < NUMTRANSLUCENTTRANSMAPS) + if (cursongcredit.trans < NUMTRANSMAPS) cursongcredit.trans++; if (cursongcredit.x > 0) cursongcredit.x /= 2; @@ -1942,10 +1942,10 @@ void HU_DrawSongCredits(void) cursongcredit.x = 0; } - bgt = (NUMTRANSLUCENTTRANSMAPS/2)+(cursongcredit.trans/2); - if (bgt < NUMTRANSLUCENTTRANSMAPS) + bgt = (NUMTRANSMAPS/2)+(cursongcredit.trans/2); + if (bgt < NUMTRANSMAPS) V_DrawScaledPatch(cursongcredit.x, y-2, V_SNAPTOLEFT|(bgt<x, battleovertime.y-players[displayplayers[0]].mo->y); - transparency = max(0, NUMTRANSLUCENTTRANSMAPS - ((256 + (dist>>FRACBITS)) / 256)); + transparency = max(0, NUMTRANSMAPS - ((256 + (dist>>FRACBITS)) / 256)); } - if (transparency < NUMTRANSLUCENTTRANSMAPS) + if (transparency < NUMTRANSMAPS) { mobj_t *beam = P_SpawnMobj(battleovertime.x, battleovertime.y, battleovertime.z + (mobjinfo[MT_RANDOMITEM].height/2), MT_OVERTIMEBEAM); P_SetScale(beam, beam->scale*2); diff --git a/src/p_mobj.c b/src/p_mobj.c index 25cb1bf8c..be907321e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6442,7 +6442,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->color = K_RainbowColor( (SKINCOLOR_PURPLE - SKINCOLOR_PINK) // Smoothly transition into the other state + ((mobj->fuse - 32) * 2) // Make the color flashing slow down while it runs out - ); + ); switch (mobj->extravalue1) { @@ -6674,12 +6674,12 @@ static boolean P_MobjRegularThink(mobj_t *mobj) const angle_t off = FixedAngle(40*FRACUNIT); angle_t ang = mobj->target->angle; fixed_t z; - UINT8 trans = (mobj->target->player->kartstuff[k_tiregrease] * (NUMTRANSLUCENTTRANSMAPS+1)) / greasetics; + UINT8 trans = (mobj->target->player->kartstuff[k_tiregrease] * (NUMTRANSMAPS+1)) / greasetics; - if (trans > NUMTRANSLUCENTTRANSMAPS) - trans = NUMTRANSLUCENTTRANSMAPS; + if (trans > NUMTRANSMAPS) + trans = NUMTRANSMAPS; - trans = NUMTRANSLUCENTTRANSMAPS - trans; + trans = NUMTRANSMAPS - trans; z = mobj->target->z; if (mobj->eflags & MFE_VERTICALFLIP) @@ -6702,7 +6702,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (leveltime & 1) mobj->drawflags |= MFD_DONTDRAW; - if (trans >= NUMTRANSLUCENTTRANSMAPS) + if (trans >= NUMTRANSMAPS) mobj->drawflags |= MFD_DONTDRAW; else if (trans == 0) mobj->drawflags = (mobj->drawflags & ~MFD_TRANSMASK); @@ -8437,15 +8437,15 @@ void P_MobjThinker(mobj_t *mobj) { if (mobj->flags2 & MF2_BOSSNOTRAP) // "fast" flag { - if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSLUCENTTRANSMAPS-1) - (2*mobj->fuse)/3) + if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSMAPS-1) - (2*mobj->fuse)/3) // fade out when nearing the end of fuse... - mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSLUCENTTRANSMAPS-1) - (2*mobj->fuse)/3) << FF_TRANSSHIFT); + mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSMAPS-1) - (2*mobj->fuse)/3) << FF_TRANSSHIFT); } else { - if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSLUCENTTRANSMAPS-1) - mobj->fuse / 2) + if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSMAPS-1) - mobj->fuse / 2) // fade out when nearing the end of fuse... - mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSLUCENTTRANSMAPS-1) - mobj->fuse / 2) << FF_TRANSSHIFT); + mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSMAPS-1) - mobj->fuse / 2) << FF_TRANSSHIFT); } } @@ -10048,7 +10048,7 @@ void P_SpawnPlayer(INT32 playernum) /* if (bonusgame || specialstage) { - // Bots should avoid + // Bots should avoid p->spectator = true; } */ diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 6b6d7d588..eff28e21d 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2515,7 +2515,7 @@ void T_PolyObjFade(polyfade_t *th) if (th->timer <= 0) { - po->translucency = max(min(th->destvalue, NUMTRANSLUCENTTRANSMAPS), 0); + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); // remove thinker if (po->thinker == &th->thinker) @@ -2526,8 +2526,8 @@ void T_PolyObjFade(polyfade_t *th) { INT16 delta = abs(th->destvalue - th->sourcevalue); INT32 duration = th->ticbased ? th->duration - : abs(FixedMul(FixedDiv(256, NUMTRANSLUCENTTRANSMAPS), NUMTRANSLUCENTTRANSMAPS - th->destvalue) - - FixedMul(FixedDiv(256, NUMTRANSLUCENTTRANSMAPS), NUMTRANSLUCENTTRANSMAPS - th->sourcevalue)); // speed-based internal counter duration: delta in 256 scale + : abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // speed-based internal counter duration: delta in 256 scale fixed_t factor = min(FixedDiv(duration - th->timer, duration), 1*FRACUNIT); if (th->destvalue < th->sourcevalue) po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); @@ -2538,7 +2538,7 @@ void T_PolyObjFade(polyfade_t *th) if (!stillfading) { // set render flags - if (po->translucency >= NUMTRANSLUCENTTRANSMAPS) // invisible + if (po->translucency >= NUMTRANSMAPS) // invisible po->flags &= ~POF_RENDERALL; else po->flags |= (po->spawnflags & POF_RENDERALL); @@ -2561,8 +2561,8 @@ void T_PolyObjFade(polyfade_t *th) } else { - if (po->translucency >= NUMTRANSLUCENTTRANSMAPS) - // HACK: OpenGL renders add/sub.opaque when >= NUMTRANSLUCENTTRANSMAPS + if (po->translucency >= NUMTRANSMAPS) + // HACK: OpenGL renders fully opaque when >= NUMTRANSMAPS po->translucency = tr_trans90; po->flags |= (po->spawnflags & POF_RENDERALL); @@ -2630,8 +2630,8 @@ boolean EV_DoPolyObjFade(polyfadedata_t *pfdata) else { th->ticbased = false; - th->timer = abs(FixedMul(FixedDiv(256, NUMTRANSLUCENTTRANSMAPS), NUMTRANSLUCENTTRANSMAPS - th->destvalue) - - FixedMul(FixedDiv(256, NUMTRANSLUCENTTRANSMAPS), NUMTRANSLUCENTTRANSMAPS - th->sourcevalue)); // delta converted to 256 scale, use as internal counter + th->timer = abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // delta converted to 256 scale, use as internal counter th->duration = abs(pfdata->speed); // use th->duration as speed decrement } diff --git a/src/p_pspr.h b/src/p_pspr.h index ee82ade6a..cbc1a845f 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -101,8 +101,7 @@ typedef enum tr_trans70, tr_trans80, tr_trans90, - NUMTRANSLUCENTTRANSMAPS, - tr_transadd = NUMTRANSLUCENTTRANSMAPS, + tr_transadd, tr_transsub, NUMTRANSMAPS } transnum_t; diff --git a/src/p_setup.c b/src/p_setup.c index df4fec9c8..50f39c5fa 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3381,7 +3381,7 @@ static void P_InitLevelSettings(void) // song credit init memset(&cursongcredit,0,sizeof(struct cursongcredit)); - cursongcredit.trans = NUMTRANSLUCENTTRANSMAPS; + cursongcredit.trans = NUMTRANSMAPS; for (i = 0; i < MAXPLAYERS; i++) { diff --git a/src/p_spec.c b/src/p_spec.c index 2435e964d..34a962975 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1257,7 +1257,7 @@ static boolean PolyFade(line_t *line) else pfd.destvalue = value; - pfd.destvalue = max(min(pfd.destvalue, NUMTRANSLUCENTTRANSMAPS), 0); + pfd.destvalue = max(min(pfd.destvalue, NUMTRANSMAPS), 0); // already equal, nothing to do if (po->translucency == pfd.destvalue) diff --git a/src/s_sound.c b/src/s_sound.c index 302a352a7..197e65e57 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1800,7 +1800,7 @@ void S_ShowMusicCredit(void) cursongcredit.def = def; cursongcredit.anim = 5*TICRATE; cursongcredit.x = 0; - cursongcredit.trans = NUMTRANSLUCENTTRANSMAPS; + cursongcredit.trans = NUMTRANSMAPS; return; } else From 11386e12bade4630e6ee267c43afb38dd0935b14 Mon Sep 17 00:00:00 2001 From: Sryder Date: Mon, 26 Oct 2020 11:18:53 +0000 Subject: [PATCH 11/22] Keep NUMTRANSMAPS what it was, instead add NUMEFFECTMAPS to end of enum Should have easier merging and be less likely to break current effects. --- src/dehacked.c | 3 ++- src/hardware/hw_main.c | 6 +++--- src/p_polyobj.c | 2 +- src/p_pspr.h | 5 +++-- src/p_spec.c | 2 +- src/r_plane.c | 2 +- src/r_segs.c | 10 +++++----- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 9bd84fdbc..88af5757b 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11148,9 +11148,10 @@ struct { {"tr_trans70",tr_trans70}, {"tr_trans80",tr_trans80}, {"tr_trans90",tr_trans90}, + {"NUMTRANSMAPS",NUMTRANSMAPS}, {"tr_transadd",tr_transadd}, {"tr_transsub",tr_transsub}, - {"NUMTRANSMAPS",NUMTRANSMAPS}, + {"NUMEFFECTMAPS",NUMEFFECTMAPS}, // Type of levels {"TOL_RACE",TOL_RACE}, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 24f7a124d..68077ce95 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1488,7 +1488,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom default: { transnum_t transtable = R_GetLinedefTransTable(gl_linedef); - if (transtable != NUMTRANSMAPS) + if (transtable != NUMEFFECTMAPS) blendmode = HWR_TranstableToAlpha(transtable, &Surf); else blendmode = PF_Masked; @@ -1498,7 +1498,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gl_curline->polyseg && gl_curline->polyseg->translucency > 0) { - if (gl_curline->polyseg->translucency >= NUMTRANSMAPS) // wall not drawn + if (gl_curline->polyseg->translucency >= NUMEFFECTMAPS) // wall not drawn { Surf.PolyColor.s.alpha = 0x00; // This shouldn't draw anything regardless of blendmode blendmode = PF_Masked; @@ -2902,7 +2902,7 @@ static void HWR_AddPolyObjectPlanes(void) if (!(po_ptrs[i]->flags & POF_RENDERPLANES)) // Only render planes when you should continue; - if (po_ptrs[i]->translucency >= NUMTRANSMAPS) + if (po_ptrs[i]->translucency >= NUMEFFECTMAPS) continue; if (polyobjsector->floorheight <= gl_frontsector->ceilingheight diff --git a/src/p_polyobj.c b/src/p_polyobj.c index eff28e21d..6733fca79 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -212,7 +212,7 @@ static void Polyobj_GetInfo(polyobj_t *po, line_t *line) if (po->parent == po->id) // do not allow a self-reference po->parent = -1; - po->translucency = max(min(line->args[2], NUMTRANSMAPS), 0); + po->translucency = max(min(line->args[2], NUMEFFECTMAPS), 0); po->flags = POF_SOLID|POF_TESTHEIGHT|POF_RENDERSIDES|POF_RENDERPLANES; diff --git a/src/p_pspr.h b/src/p_pspr.h index cbc1a845f..aa49f0306 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -101,9 +101,10 @@ typedef enum tr_trans70, tr_trans80, tr_trans90, - tr_transadd, + NUMTRANSMAPS, + tr_transadd = NUMTRANSMAPS, tr_transsub, - NUMTRANSMAPS + NUMEFFECTMAPS, } transnum_t; #endif diff --git a/src/p_spec.c b/src/p_spec.c index 34a962975..a86c54c07 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1213,7 +1213,7 @@ static void PolyTranslucency(line_t *line) else po->translucency = value; - po->translucency = max(min(po->translucency, NUMTRANSMAPS), 0); + po->translucency = max(min(po->translucency, NUMEFFECTMAPS), 0); } // Makes a polyobject translucency fade and applies tangibility diff --git a/src/r_plane.c b/src/r_plane.c index 723a388d6..7770d2d12 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -780,7 +780,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->polyobj) { // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) - if (pl->polyobj->translucency >= NUMTRANSMAPS) + if (pl->polyobj->translucency >= NUMEFFECTMAPS) return; // Don't even draw it else if (pl->polyobj->translucency > 0) { diff --git a/src/r_segs.c b/src/r_segs.c index 9998c51ca..8dcb61992 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -281,7 +281,7 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) transnum_t R_GetLinedefTransTable(line_t *ldef) { - transnum_t transnum = NUMTRANSMAPS; // Send back NUMTRANSMAPS for none + transnum_t transnum = NUMEFFECTMAPS; // Send back NUMEFFECTMAPS for none fixed_t alpha = ldef->alpha; if (alpha > 0 && alpha < FRACUNIT) transnum = (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1); @@ -291,7 +291,7 @@ transnum_t R_GetLinedefTransTable(line_t *ldef) { case 910: transnum = tr_transadd; break; case 911: transnum = tr_transsub; break; - default: transnum = NUMTRANSMAPS; break; + default: transnum = NUMEFFECTMAPS; break; } } @@ -312,7 +312,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) INT32 times, repeats; INT64 overflow_test; INT32 range; - transnum_t transtable = NUMTRANSMAPS; + transnum_t transtable = NUMEFFECTMAPS; // Calculate light table. // Use different light tables @@ -330,7 +330,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) return; transtable = R_GetLinedefTransTable(ldef); - if (transtable != NUMTRANSMAPS) + if (transtable != NUMEFFECTMAPS) { dc_transmap = transtables + ((transtable - 1) << FF_TRANSSHIFT); colfunc = colfuncs[COLDRAWFUNC_FUZZY]; @@ -347,7 +347,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (curline->polyseg && curline->polyseg->translucency > 0) { - if (curline->polyseg->translucency >= NUMTRANSMAPS) + if (curline->polyseg->translucency >= NUMEFFECTMAPS) return; dc_transmap = transtables + ((curline->polyseg->translucency-1)< Date: Mon, 26 Oct 2020 11:22:27 +0000 Subject: [PATCH 12/22] Add missing MFD_TRANSSUB to dehacked --- src/dehacked.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dehacked.c b/src/dehacked.c index 88af5757b..a467543e9 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11661,6 +11661,7 @@ struct { {"MFD_TRANS80",MFD_TRANS80}, {"MFD_TRANS90",MFD_TRANS90}, {"MFD_TRANSADD",MFD_TRANSADD}, + {"MFD_TRANSSUB",MFD_TRANSSUB}, {"MFD_TRANSMASK",MFD_TRANSMASK}, {"MFD_FULLBRIGHT",MFD_FULLBRIGHT}, {"MFD_SEMIBRIGHT",MFD_SEMIBRIGHT}, From 2ae394b8e37a55acefb2151d3edb9a5aedbb39ce Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 26 Oct 2020 19:51:42 -0700 Subject: [PATCH 13/22] Fix opengl splitscreen --- src/hardware/hw_main.c | 67 ++++++++++++++++++-------------- src/hardware/r_opengl/r_opengl.c | 2 +- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 24159345f..f09a793a6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -107,8 +107,10 @@ static angle_t gl_xtoviewangle[MAXVIDWIDTH+1]; // base values set at SetViewSize static float gl_basecentery; +static float gl_basecenterx; float gl_baseviewwindowy, gl_basewindowcentery; +float gl_baseviewwindowx, gl_basewindowcenterx; float gl_viewwidth, gl_viewheight; // viewport clipping boundaries (screen coords) float gl_viewwindowx; @@ -5597,21 +5599,14 @@ void HWR_SetViewSize(void) } } - gl_centerx = gl_viewwidth / 2; - gl_basecentery = gl_viewheight / 2; //note: this is (gl_centerx * gl_viewheight / gl_viewwidth) + gl_basecenterx = gl_viewwidth / 2; + gl_basecentery = gl_viewheight / 2; - gl_viewwindowx = (vid.width - gl_viewwidth) / 2; - gl_windowcenterx = (float)(vid.width / 2); - if (fabsf(gl_viewwidth - vid.width) < 1.0E-36f) - { - gl_baseviewwindowy = 0; - gl_basewindowcentery = gl_viewheight / 2; // window top left corner at 0,0 - } - else - { - gl_baseviewwindowy = (vid.height-gl_viewheight) / 2; - gl_basewindowcentery = (float)(vid.height / 2); - } + gl_baseviewwindowx = 0; + gl_basewindowcenterx = gl_viewwidth / 2; + + gl_baseviewwindowy = 0; + gl_basewindowcentery = gl_viewheight / 2; gl_pspritexscale = gl_viewwidth / BASEVIDWIDTH; gl_pspriteyscale = ((vid.height*gl_pspritexscale*BASEVIDWIDTH)/BASEVIDHEIGHT)/vid.width; @@ -5619,6 +5614,32 @@ void HWR_SetViewSize(void) HWD.pfnFlushScreenTextures(); } +// -------------------+ +// HWR_ShiftViewPort : offset viewport according to current split +// -------------------+ +static void HWR_ShiftViewPort(void) +{ + gl_centerx = gl_basecenterx; + gl_viewwindowx = gl_baseviewwindowx; + gl_windowcenterx = gl_basewindowcenterx; + + gl_centery = gl_basecentery; + gl_viewwindowy = gl_baseviewwindowy; + gl_windowcentery = gl_basewindowcentery; + + if (viewssnum > ( r_splitscreen > 1 )) + { + gl_viewwindowy += gl_viewheight; + gl_windowcentery += gl_viewheight; + } + + if (r_splitscreen > 1 && viewssnum & 1) + { + gl_viewwindowx += gl_viewwidth; + gl_windowcenterx += gl_viewwidth; + } +} + // Set view aiming, for the sky dome, the skybox, // and the normal view, all with a single function. static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox) @@ -5670,14 +5691,7 @@ void HWR_RenderSkyboxView(player_t *player) dup_viewangle = viewangle; // set window position - gl_centery = gl_basecentery; - gl_viewwindowy = gl_baseviewwindowy; - gl_windowcentery = gl_basewindowcentery; - if (viewssnum == 1) - { - gl_viewwindowy += (vid.height/2); - gl_windowcentery += (vid.height/2); - } + HWR_ShiftViewPort(); // check for new console commands. NetUpdate(); @@ -5878,14 +5892,7 @@ void HWR_RenderPlayerView(void) dup_viewangle = viewangle; // set window position - gl_centery = gl_basecentery; - gl_viewwindowy = gl_baseviewwindowy; - gl_windowcentery = gl_basewindowcentery; - if (viewssnum == 1) - { - gl_viewwindowy += (vid.height/2); - gl_windowcentery += (vid.height/2); - } + HWR_ShiftViewPort(); // check for new console commands. NetUpdate(); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 343a916e9..942d3d3de 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2848,7 +2848,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f); pglTranslatef(-stransform->x, -stransform->z, -stransform->y); - special_splitscreen = stransform->splitscreen; + special_splitscreen = (stransform->splitscreen == 1); shearing = stransform->shearing; } else From d19c96ee171e518117f19a27f7170e14981f4af9 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 26 Oct 2020 20:20:04 -0700 Subject: [PATCH 14/22] Revert step down changes --- src/p_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 47faf63bf..b8d9820dd 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2561,14 +2561,14 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS // step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more. - if (thingtop == thing->ceilingz && tmceilingz > thingtop && thing->ceilingdrop <= maxstep) + if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { thing->z = (thing->ceilingz = tmceilingz) - thing->height; thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->ceilingdrop = 0; } - else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->floordrop <= maxstep) + else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) { thing->z = thing->floorz = tmfloorz; thing->floorrover = tmfloorrover; From de936f4c7f32ef26238f8423dc0b2bf4fc9edaca Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 26 Oct 2020 20:49:39 -0700 Subject: [PATCH 15/22] Don't reset drift off springs Hopefully nothing requires drift reset from here. --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 6fb7ee4bc..cdaa24123 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -484,7 +484,7 @@ void P_ResetPlayer(player_t *player) player->powers[pw_carry] = CR_NONE; player->onconveyor = 0; - player->kartstuff[k_drift] = player->kartstuff[k_driftcharge] = 0; + //player->kartstuff[k_drift] = player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_pogospring] = 0; } From e7051737d70f3c253db4ded9bd71e46d002da404 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 27 Oct 2020 15:00:31 -0700 Subject: [PATCH 16/22] Use 2.2's musicdef parser --- src/s_sound.c | 269 ++++++++++++++++++++++++++++---------------------- 1 file changed, 149 insertions(+), 120 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index ce62cb3e2..481eb6822 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1598,11 +1598,6 @@ static tic_t pause_starttic; /// Music Definitions /// ------------------------ -enum -{ - MUSICDEF_20, -}; - musicdef_t *musicdefstart = NULL; struct cursongcredit cursongcredit; // Currently displayed song credit info int musicdef_volume; @@ -1623,147 +1618,181 @@ static UINT16 W_CheckForMusicDefInPwad(UINT16 wadid) return INT16_MAX; // not found } -void S_LoadMusicDefs(UINT16 wadnum) +static boolean +ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) { - UINT16 lump; - char *buf; - char *buf2; - char *stoken; + musicdef_t *def; + char *value; - size_t size; - musicdef_t *def, *prev; - UINT16 line = 1; // for better error msgs + char *textline; - lump = W_CheckForMusicDefInPwad(wadnum); - if (lump == INT16_MAX) - return; - - buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); - size = W_LumpLengthPwad(wadnum, lump); - - // for strtok - buf2 = malloc(size+1); - if (!buf2) - I_Error("S_LoadMusicDefs: No more free memory\n"); - M_Memcpy(buf2,buf,size); - buf2[size] = '\0'; - - def = prev = NULL; - - stoken = strtok (buf2, "\r\n "); - // Find music def - while (stoken) + if (!stricmp(stoken, "lump")) { - /*if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#')) // skip comments + value = strtok(NULL, " "); + if (!value) { - stoken = strtok(NULL, "\r\n"); // skip end of line - if (def) - stoken = strtok(NULL, "\r\n= "); - else - stoken = strtok(NULL, "\r\n "); - line++; - } - else*/ if (!stricmp(stoken, "lump")) - { - value = strtok(NULL, "\r\n "); - - if (!value) - { - CONS_Alert(CONS_WARNING, "MUSICDEF: Lump '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); - stoken = strtok(NULL, "\r\n"); // skip end of line - goto skip_lump; - } - - // No existing musicdefs - if (!musicdefstart) - { - musicdefstart = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL); - STRBUFCPY(musicdefstart->name, value); - strlwr(musicdefstart->name); - def = musicdefstart; - //CONS_Printf("S_LoadMusicDefs: Initialized musicdef w/ song '%s'\n", def->name); - } - else - { - def = musicdefstart; - - // Search if this is a replacement - //CONS_Printf("S_LoadMusicDefs: Searching for song replacement...\n"); - while (def) - { - if (!stricmp(def->name, value)) - { - //CONS_Printf("S_LoadMusicDefs: Found song replacement '%s'\n", def->name); - break; - } - - prev = def; - def = def->next; - } - - // Nothing found, add to the end. - if (!def) - { - def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL); - STRBUFCPY(def->name, value); - strlwr(def->name); - if (prev != NULL) - prev->next = def; - //CONS_Printf("S_LoadMusicDefs: Added song '%s'\n", def->name); - } - } - - def->volume = DEFAULT_MUSICDEF_VOLUME; - -skip_lump: - stoken = strtok(NULL, "\r\n "); - line++; + CONS_Alert(CONS_WARNING, + "MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); + return false; } else { - value = strtok(NULL, "\r\n= "); + musicdef_t **tail = &musicdefstart; - if (!value) + // Search if this is a replacement + while (*tail) { - CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); - stoken = strtok(NULL, "\r\n"); // skip end of line - goto skip_field; + if (!stricmp((*tail)->name, value)) + { + break; + } + + tail = &(*tail)->next; } + // Nothing found, add to the end. + if (!(*tail)) + { + def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL); + + STRBUFCPY(def->name, value); + strlwr(def->name); + def->volume = DEFAULT_MUSICDEF_VOLUME; + + (*tail) = def; + } + + (*defp) = (*tail); + } + } + else + { + value = strtok(NULL, ""); + + if (value) + { + // Find the equals sign. + value = strchr(value, '='); + } + + if (!value) + { + CONS_Alert(CONS_WARNING, + "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); + return false; + } + else + { + def = (*defp); + if (!def) { - CONS_Alert(CONS_ERROR, "MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); - free(buf2); - return; + CONS_Alert(CONS_ERROR, + "MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); + return false; } + // Skip the equals sign. + value++; + + // Now skip funny whitespace. + value += strspn(value, "\t "); + + textline = value; + + /* based ignored lumps */ if (!stricmp(stoken, "usage")) { #if 0 // Ignore for now - STRBUFCPY(def->usage, value); - for (value = def->usage; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - //CONS_Printf("S_LoadMusicDefs: Set usage to '%s'\n", def->usage); + STRBUFCPY(def->usage, textline); #endif } else if (!stricmp(stoken, "source")) { - STRBUFCPY(def->source, value); - for (value = def->source; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); + STRBUFCPY(def->source, textline); } else if (!stricmp(stoken, "volume")) { - def->volume = atoi(value); + def->volume = atoi(textline); } else { - CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); + CONS_Alert(CONS_WARNING, + "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); } - -skip_field: - stoken = strtok(NULL, "\r\n= "); - line++; } } - free(buf2); - return; + return true; +} + +void S_LoadMusicDefs(UINT16 wadnum) +{ + UINT16 lumpnum; + char *lump; + char *musdeftext; + size_t size; + + char *lf; + char *stoken; + + size_t nlf; + size_t ncr; + + musicdef_t *def = NULL; + int line = 1; // for better error msgs + + lumpnum = W_CheckForMusicDefInPwad(wadnum); + if (lumpnum == INT16_MAX) + return; + + lump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + size = W_LumpLengthPwad(wadnum, lumpnum); + + // Null-terminated MUSICDEF lump. + musdeftext = malloc(size+1); + if (!musdeftext) + I_Error("S_LoadMusicDefs: No more free memory for the parser\n"); + M_Memcpy(musdeftext, lump, size); + musdeftext[size] = '\0'; + + // Find music def + stoken = musdeftext; + for (;;) + { + lf = strpbrk(stoken, "\r\n"); + if (lf) + { + if (*lf == '\n') + nlf = 1; + else + nlf = 0; + *lf++ = '\0';/* now we can delimit to here */ + } + + stoken = strtok(stoken, " "); + if (stoken) + { + if (! ReadMusicDefFields(wadnum, line, stoken, &def)) + break; + } + + if (lf) + { + do + { + line += nlf; + ncr = strspn(lf, "\r");/* skip CR */ + lf += ncr; + nlf = strspn(lf, "\n"); + lf += nlf; + } + while (nlf || ncr) ; + + stoken = lf;/* now the next nonempty line */ + } + else + break;/* EOF */ + } + + free(musdeftext); } // From d896fee2e501aa547c2a6a4cc9a7e7d339fd423f Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 27 Oct 2020 15:45:10 -0700 Subject: [PATCH 17/22] Load multiple musicdef lumps from a single wad --- src/s_sound.c | 94 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 481eb6822..a7d45e160 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1602,25 +1602,37 @@ musicdef_t *musicdefstart = NULL; struct cursongcredit cursongcredit; // Currently displayed song credit info int musicdef_volume; -// -// search for music definition in wad -// -static UINT16 W_CheckForMusicDefInPwad(UINT16 wadid) -{ - UINT16 i; - lumpinfo_t *lump_p; +static boolean +MusicDefError +( + alerttype_t level, + const char * description, + const char * field, + lumpnum_t lumpnum, + int line +){ + const wadfile_t * wad = wadfiles[WADFILENUM (lumpnum)]; + const lumpinfo_t * lump = &wad->lumpinfo[LUMPNUM (lumpnum)]; - lump_p = wadfiles[wadid]->lumpinfo; - for (i = 0; i < wadfiles[wadid]->numlumps; i++, lump_p++) - if (memcmp(lump_p->name, "MUSICDEF", 8) == 0) - return i; + CONS_Alert(level, + va("%%s|%%s: %s (line %%d)\n", description), + wad->filename, + lump->fullname, + field, + line + ); - return INT16_MAX; // not found + return false; } static boolean -ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) -{ +ReadMusicDefFields +( + lumpnum_t lumpnum, + int line, + char * stoken, + musicdef_t ** defp +){ musicdef_t *def; char *value; @@ -1631,10 +1643,9 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) value = strtok(NULL, " "); if (!value) { - CONS_Alert(CONS_WARNING, - "MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n", - stoken, wadfiles[wadnum]->filename, line); - return false; + return MusicDefError(CONS_WARNING, + "Field '%'s is missing name.", + stoken, lumpnum, line); } else { @@ -1678,10 +1689,9 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) if (!value) { - CONS_Alert(CONS_WARNING, - "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", - stoken, wadfiles[wadnum]->filename, line); - return false; + return MusicDefError(CONS_WARNING, + "Field '%s' is missing value.", + stoken, lumpnum, line); } else { @@ -1689,10 +1699,9 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) if (!def) { - CONS_Alert(CONS_ERROR, - "MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n", - stoken, wadfiles[wadnum]->filename, line); - return false; + return MusicDefError(CONS_ERROR, + "No music definition before field '%s'.", + stoken, lumpnum, line); } // Skip the equals sign. @@ -1713,9 +1722,9 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) } else if (!stricmp(stoken, "volume")) { def->volume = atoi(textline); } else { - CONS_Alert(CONS_WARNING, - "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", - stoken, wadfiles[wadnum]->filename, line); + MusicDefError(CONS_WARNING, + "Unknown field '%s'.", + stoken, lumpnum, line); } } } @@ -1723,9 +1732,8 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) return true; } -void S_LoadMusicDefs(UINT16 wadnum) +static void S_LoadMusicDefLump(lumpnum_t lumpnum) { - UINT16 lumpnum; char *lump; char *musdeftext; size_t size; @@ -1739,12 +1747,8 @@ void S_LoadMusicDefs(UINT16 wadnum) musicdef_t *def = NULL; int line = 1; // for better error msgs - lumpnum = W_CheckForMusicDefInPwad(wadnum); - if (lumpnum == INT16_MAX) - return; - - lump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); - size = W_LumpLengthPwad(wadnum, lumpnum); + lump = W_CacheLumpNum(lumpnum, PU_CACHE); + size = W_LumpLength(lumpnum); // Null-terminated MUSICDEF lump. musdeftext = malloc(size+1); @@ -1770,7 +1774,7 @@ void S_LoadMusicDefs(UINT16 wadnum) stoken = strtok(stoken, " "); if (stoken) { - if (! ReadMusicDefFields(wadnum, line, stoken, &def)) + if (! ReadMusicDefFields(lumpnum, line, stoken, &def)) break; } @@ -1795,6 +1799,20 @@ void S_LoadMusicDefs(UINT16 wadnum) free(musdeftext); } +void S_LoadMusicDefs(UINT16 wad) +{ + const lumpnum_t wadnum = wad << 16; + + UINT16 lump = 0; + + while (( lump = W_CheckNumForNamePwad("MUSICDEF", wad, lump) ) != INT16_MAX) + { + S_LoadMusicDefLump(wadnum | lump); + + lump++; + } +} + // // S_InitMusicDefs // From 7199bba3b201269a9efe4f92a3e7ed16f49ad9ac Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 27 Oct 2020 15:51:36 -0700 Subject: [PATCH 18/22] Update musicdef conversion utility --- tools/musicdef-2.2.1/musicdef-2.2.1.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/musicdef-2.2.1/musicdef-2.2.1.c b/tools/musicdef-2.2.1/musicdef-2.2.1.c index 65d434c8a..92a999da8 100644 --- a/tools/musicdef-2.2.1/musicdef-2.2.1.c +++ b/tools/musicdef-2.2.1/musicdef-2.2.1.c @@ -54,9 +54,8 @@ main (int ac, char **av) if (( var = strtok(buf, " =") )) { if (!( - strcasecmp(var, "TITLE") && - strcasecmp(var, "ALTTITLE") && - strcasecmp(var, "AUTHORS") + strcasecmp(var, "USAGE") && + strcasecmp(var, "SOURCE") )){ if (( val = strtok(0, "") )) { From f5329f25bf94a8f8bc3d56e8e4ea3bcd68814309 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 27 Oct 2020 17:20:57 -0700 Subject: [PATCH 19/22] Use music.pk3 --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index bf15d5bd7..db0f74fb2 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1116,7 +1116,7 @@ static void IdentifyVersion(void) } MUSICTEST("sounds.wad") - MUSICTEST("music.wad") + MUSICTEST("music.pk3") #undef MUSICTEST From 646fd15b02e498b1701440176399e1e6f68764ae Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 28 Oct 2020 15:16:05 -0400 Subject: [PATCH 20/22] Remove these 2 calls to HWR_UnlockCachedPatch From what I can tell, this is not in SRB2 master or next. I'm uncertain about this, but Jeck has had zero crashes with this. --- src/hardware/hw_md2.c | 2 -- src/z_zone.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index fe0d1fc99..3d00252e7 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -419,7 +419,6 @@ static void md2_loadTexture(md2_t *model) } HWD.pfnSetTexture(grpatch->mipmap); - HWR_UnlockCachedPatch(grpatch); } // -----------------+ @@ -470,7 +469,6 @@ static void md2_loadBlendTexture(md2_t *model) } HWD.pfnSetTexture(grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary - HWR_UnlockCachedPatch(grpatch); Z_Free(filename); } diff --git a/src/z_zone.h b/src/z_zone.h index 5cbcc6655..dfb2f6c71 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -62,7 +62,7 @@ enum PU_CACHE_UNLOCKED = 101, // Note: unused PU_HWRCACHE_UNLOCKED = 102, // 'unlocked' PU_HWRCACHE memory: // 'second-level' cache for graphics - // stored in hardware format and downloaded as needed + // stored in hardware format and downloaded as needed PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRPATCHINFO memory PU_HWRMODELTEXTURE_UNLOCKED = 104, // 'unlocked' PU_HWRMODELTEXTURE memory }; From a253a6cedd71270bc930b22d1c3dd95df2433f0e Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 28 Oct 2020 15:41:32 -0400 Subject: [PATCH 21/22] Remove rogue line making this function do nothing --- src/hardware/hw_md2.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 3d00252e7..c5958de78 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -607,9 +607,6 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup } } - // Check for any MD2s that match the names of sprite names! - while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) - // length of the player model prefix prefixlen = strlen(PLAYERMODELPREFIX); From 01d5c9a95b4d7c37e7c8dbf99ff2edad9d11c282 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 28 Oct 2020 16:20:11 -0400 Subject: [PATCH 22/22] Put back in the improvements to HWR_CreateBlendedTexture Fixes colors being darker, and creates blend textures faster --- src/hardware/hw_md2.c | 109 +++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 44 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index c5958de78..9896eb458 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -698,10 +698,12 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; RGBA_t *image, *blendimage, *cur, blendcolor; - UINT16 translation[16]; // First the color index + UINT8 translation[16]; // First the color index UINT8 cutoff[16]; // Brightness cutoff before using the next color UINT8 translen = 0; UINT8 i; + UINT8 colorbrightnesses[16]; + UINT8 color_match_lookup[256]; // optimization attempt blendcolor = V_GetColor(0); // initialize memset(translation, 0, sizeof(translation)); @@ -737,6 +739,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, if (color != SKINCOLOR_NONE && color < numskincolors) { UINT8 numdupes = 1; + UINT8 prevdupes = numdupes; translation[translen] = skincolors[color].ramp[0]; cutoff[translen] = 255; @@ -751,18 +754,56 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, if (translen > 0) { - cutoff[translen] = cutoff[translen-1] - (256 / (16 / numdupes)); + INT16 newcutoff = cutoff[translen-1] - (255 / (16 / prevdupes)); + + if (newcutoff < 0) + newcutoff = 0; + + cutoff[translen] = (UINT8)newcutoff; } + prevdupes = numdupes; numdupes = 1; translen++; - translation[translen] = (UINT16)skincolors[color].ramp[i]; + translation[translen] = (UINT8)skincolors[color].ramp[i]; } translen++; } + if (skinnum == TC_RAINBOW && translen > 0) + { + UINT16 b; + INT32 compare; + + for (i = 0; i < translen; i++) // moved from inside the loop to here + { + RGBA_t tempc = V_GetColor(translation[i]); + colorbrightnesses[i] = K_ColorRelativeLuminance(tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison + } + // generate lookup table for color brightness matching + for (b = 0; b < 256; b++) + { + UINT16 brightdif = 256; + + color_match_lookup[i] = 0; + for (i = 0; i < translen; i++) + { + if (b > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is) + continue; + + compare = abs((INT16)(colorbrightnesses[i]) - (INT16)(b)); + + if (compare < brightdif) + { + brightdif = (UINT16)compare; + color_match_lookup[b] = i; // best matching color that's equal brightness or darker + } + } + } + } + while (size--) { if (skinnum == TC_BOSS) @@ -834,7 +875,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, else { // All settings that use skincolors! - UINT8 brightness; + UINT16 brightness; if (translen <= 0) { @@ -852,8 +893,11 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, } else { - UINT8 imagebright = K_ColorRelativeLuminance(image->s.red, image->s.green, image->s.blue); - UINT8 blendbright = K_ColorRelativeLuminance(blendimage->s.red, blendimage->s.green, blendimage->s.blue); + UINT16 imagebright, blendbright; + + imagebright = K_ColorRelativeLuminance(image->s.red, image->s.green, image->s.blue); + blendbright = K_ColorRelativeLuminance(blendimage->s.red, blendimage->s.green, blendimage->s.blue); + // slightly dumb average between the blend image color and base image colour, usually one or the other will be fully opaque anyway brightness = (imagebright*(255-blendimage->s.alpha))/255 + (blendbright*blendimage->s.alpha)/255; } @@ -882,9 +926,8 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, // Ensue horrible mess. if (skinnum == TC_RAINBOW) { - UINT16 brightdif = 256; - UINT8 colorbrightnesses[16]; - INT32 compare, m, d; + //UINT16 brightdif = 256; + INT32 /*compare,*/ m, d; // Ignore pure white & pitch black if (brightness > 253 || brightness < 2) @@ -898,13 +941,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, mul = 0; mulmax = 1; - for (i = 0; i < translen; i++) - { - RGBA_t tempc = V_GetColor(translation[i]); - colorbrightnesses[i] = K_ColorRelativeLuminance(tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison - } - - for (i = 0; i < translen; i++) + /*for (i = 0; i < translen; i++) { if (brightness > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is) continue; @@ -916,19 +953,13 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, brightdif = (UINT16)compare; firsti = i; // best matching color that's equal brightness or darker } - } + }*/ + firsti = color_match_lookup[brightness]; secondi = firsti+1; // next color in line - if (secondi >= translen) - { - m = (INT16)brightness; // - 0; - d = (INT16)colorbrightnesses[firsti]; // - 0; - } - else - { - m = (INT16)brightness - (INT16)colorbrightnesses[secondi]; - d = (INT16)colorbrightnesses[firsti] - (INT16)colorbrightnesses[secondi]; - } + + m = (INT16)brightness - (INT16)colorbrightnesses[secondi]; + d = (INT16)colorbrightnesses[firsti] - (INT16)colorbrightnesses[secondi]; if (m >= d) m = d-1; @@ -955,29 +986,15 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, secondi = firsti+1; - mulmax = cutoff[firsti]; - if (secondi < translen) - mulmax -= cutoff[secondi]; - + mulmax = cutoff[firsti] - cutoff[secondi]; mul = cutoff[firsti] - brightness; } blendcolor = V_GetColor(translation[firsti]); - if (secondi >= translen) - mul = 0; - if (mul > 0) // If it's 0, then we only need the first color. { -#if 0 - if (secondi >= translen) - { - // blend to black - nextcolor = V_GetColor(31); - } - else -#endif - nextcolor = V_GetColor(translation[secondi]); + nextcolor = V_GetColor(translation[secondi]); // Find difference between points r = (INT32)(nextcolor.s.red - blendcolor.s.red); @@ -999,10 +1016,14 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, if (skinnum == TC_RAINBOW) { UINT32 tempcolor; - UINT8 colorbright = K_ColorRelativeLuminance(blendcolor.s.red, blendcolor.s.green, blendcolor.s.blue); + UINT16 colorbright; + + colorbright = K_ColorRelativeLuminance(blendcolor.s.red, blendcolor.s.green, blendcolor.s.blue); if (colorbright == 0) + { colorbright = 1; // no dividing by 0 please + } tempcolor = (brightness * blendcolor.s.red) / colorbright; tempcolor = min(255, tempcolor);