From 111da04b078bb727ed0e874d94a511012efbf872 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 18 Apr 2020 16:55:56 +0200 Subject: [PATCH 1/2] Add enums to encapsulate the textmap slope settings --- src/p_setup.c | 20 ++++++++++---------- src/p_slopes.c | 32 ++++++++++++++++---------------- src/p_slopes.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index ab4c87f99..268d90690 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2705,13 +2705,13 @@ static void P_ConvertBinaryMap(void) boolean frontceil = (lines[i].special == 701 || lines[i].special == 702 || lines[i].special == 713); boolean backceil = (lines[i].special == 711 || lines[i].special == 712 || lines[i].special == 703); - lines[i].args[0] = backfloor ? 2 : (frontfloor ? 1 : 0); - lines[i].args[1] = backceil ? 2 : (frontceil ? 1 : 0); + lines[i].args[0] = backfloor ? TMS_BACK : (frontfloor ? TMS_FRONT : TMS_NONE); + lines[i].args[1] = backceil ? TMS_BACK : (frontceil ? TMS_FRONT : TMS_NONE); if (lines[i].flags & ML_NETONLY) - lines[i].args[2] |= SL_NOPHYSICS; + lines[i].args[2] |= TMSL_NOPHYSICS; if (lines[i].flags & ML_NONET) - lines[i].args[2] |= SL_DYNAMIC; + lines[i].args[2] |= TMSL_DYNAMIC; lines[i].special = 700; break; @@ -2722,13 +2722,13 @@ static void P_ConvertBinaryMap(void) case 715: //Slope back sector ceiling by 3 tagged vertices { if (lines[i].special == 704) - lines[i].args[0] = 0; + lines[i].args[0] = TMSP_FRONTFLOOR; else if (lines[i].special == 705) - lines[i].args[0] = 1; + lines[i].args[0] = TMSP_FRONTCEILING; else if (lines[i].special == 714) - lines[i].args[0] = 2; + lines[i].args[0] = TMSP_BACKFLOOR; else if (lines[i].special == 715) - lines[i].args[0] = 3; + lines[i].args[0] = TMSP_BACKCEILING; lines[i].args[1] = lines[i].tag; @@ -2751,9 +2751,9 @@ static void P_ConvertBinaryMap(void) } if (lines[i].flags & ML_NETONLY) - lines[i].args[4] |= SL_NOPHYSICS; + lines[i].args[4] |= TMSL_NOPHYSICS; if (lines[i].flags & ML_NONET) - lines[i].args[4] |= SL_DYNAMIC; + lines[i].args[4] |= TMSL_DYNAMIC; lines[i].special = 704; break; diff --git a/src/p_slopes.c b/src/p_slopes.c index c4ef28666..9f18fe111 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -250,14 +250,14 @@ static void line_SpawnViaLine(const int linenum, const boolean spawnthinker) vector2_t direction; fixed_t nx, ny, dz, extent; - boolean frontfloor = line->args[0] == 1; - boolean backfloor = line->args[0] == 2; - boolean frontceil = line->args[1] == 1; - boolean backceil = line->args[1] == 2; + boolean frontfloor = line->args[0] == TMS_FRONT; + boolean backfloor = line->args[0] == TMS_BACK; + boolean frontceil = line->args[1] == TMS_FRONT; + boolean backceil = line->args[1] == TMS_BACK; UINT8 flags = 0; // Slope flags - if (line->args[2] & 1) + if (line->args[2] & TMSL_NOPHYSICS) flags |= SL_NOPHYSICS; - if (line->args[2] & 2) + if (line->args[2] & TMSL_DYNAMIC) flags |= SL_DYNAMIC; if(!frontfloor && !backfloor && !frontceil && !backceil) @@ -464,26 +464,26 @@ static void line_SpawnViaMapthingVertexes(const int linenum, const boolean spawn UINT16 tag2 = line->args[2]; UINT16 tag3 = line->args[3]; UINT8 flags = 0; // Slope flags - if (line->args[4] & 1) + if (line->args[4] & TMSL_NOPHYSICS) flags |= SL_NOPHYSICS; - if (line->args[4] & 2) + if (line->args[4] & TMSL_DYNAMIC) flags |= SL_DYNAMIC; switch(line->args[0]) { - case 0: + case TMSP_FRONTFLOOR: slopetoset = &line->frontsector->f_slope; side = &sides[line->sidenum[0]]; break; - case 1: + case TMSP_FRONTCEILING: slopetoset = &line->frontsector->c_slope; side = &sides[line->sidenum[0]]; break; - case 2: + case TMSP_BACKFLOOR: slopetoset = &line->backsector->f_slope; side = &sides[line->sidenum[1]]; break; - case 3: + case TMSP_BACKCEILING: slopetoset = &line->backsector->c_slope; side = &sides[line->sidenum[1]]; default: @@ -605,13 +605,13 @@ void P_CopySectorSlope(line_t *line) setback |= P_SetSlopeFromTag(bsec, line->args[2], false); setback |= P_SetSlopeFromTag(bsec, line->args[3], true); - if (line->args[4] & 1) + if (line->args[4] & TMSC_FRONTTOBACKFLOOR) setback |= P_CopySlope(&bsec->f_slope, fsec->f_slope); - if (line->args[4] & 2) + if (line->args[4] & TMSC_BACKTOFRONTFLOOR) setfront |= P_CopySlope(&fsec->f_slope, bsec->f_slope); - if (line->args[4] & 4) + if (line->args[4] & TMSC_FRONTTOBACKCEILING) setback |= P_CopySlope(&bsec->c_slope, fsec->c_slope); - if (line->args[4] & 8) + if (line->args[4] & TMSC_BACKTOFRONTCEILING) setfront |= P_CopySlope(&fsec->c_slope, bsec->c_slope); } diff --git a/src/p_slopes.h b/src/p_slopes.h index e7c850ab8..17c885fb2 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -18,6 +18,35 @@ extern pslope_t *slopelist; extern UINT16 slopecount; +typedef enum +{ + TMSP_FRONTFLOOR, + TMSP_FRONTCEILING, + TMSP_BACKFLOOR, + TMSP_BACKCEILING, +} textmapslopeplane_t; + +typedef enum +{ + TMSC_FRONTTOBACKFLOOR = 1, + TMSC_BACKTOFRONTFLOOR = 1<<1, + TMSC_FRONTTOBACKCEILING = 1<<2, + TMSC_BACKTOFRONTCEILING = 1<<3, +} textmapslopecopy_t; + +typedef enum +{ + TMS_NONE, + TMS_FRONT, + TMS_BACK, +} textmapside_t; + +typedef enum +{ + TMSL_NOPHYSICS = 1, + TMSL_DYNAMIC = 2, +} textmapslopeflags_t; + void P_LinkSlopeThinkers (void); void P_CalculateSlopeNormal(pslope_t *slope); From 09506112d79695ab5638ca5ff10462fa0e610f6a Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 18 Apr 2020 17:15:25 +0200 Subject: [PATCH 2/2] Add enums to encapsulate the textmap colormap settings --- extras/conf/udb/Includes/SRB222_linedefs.cfg | 4 +- src/p_setup.c | 24 ++++----- src/p_spec.c | 52 ++++++++++---------- src/r_data.h | 18 +++++++ 4 files changed, 58 insertions(+), 40 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg index 707396078..bc1f43e57 100644 --- a/extras/conf/udb/Includes/SRB222_linedefs.cfg +++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg @@ -1630,7 +1630,7 @@ udmf 4 = "Subtract light G"; 8 = "Subtract light B"; 16 = "Subtract light A"; - 32 = "Subtract light R"; + 32 = "Subtract fade R"; 64 = "Subtract fade G"; 128 = "Subtract fade B"; 256 = "Subtract fade A"; @@ -1670,7 +1670,7 @@ udmf 4 = "Subtract light G"; 8 = "Subtract light B"; 16 = "Subtract light A"; - 32 = "Subtract light R"; + 32 = "Subtract fade R"; 64 = "Subtract fade G"; 128 = "Subtract fade B"; 256 = "Subtract fade A"; diff --git a/src/p_setup.c b/src/p_setup.c index f896a1fd4..9014062bb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1825,12 +1825,12 @@ static void P_ProcessLinedefsAfterSidedefs(void) if (alpha < 0) { alpha *= -1; - ld->args[2] |= 16; + ld->args[2] |= TMCF_SUBLIGHTA; } if (fadealpha < 0) { fadealpha *= -1; - ld->args[2] |= 256; + ld->args[2] |= TMCF_SUBFADEA; } exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(alpha); @@ -2812,13 +2812,13 @@ static void P_ConvertBinaryMap(void) case 447: //Change colormap lines[i].args[0] = lines[i].tag; if (lines[i].flags & ML_EFFECT3) - lines[i].args[2] |= 1; + lines[i].args[2] |= TMCF_RELATIVE; if (lines[i].flags & ML_EFFECT1) - lines[i].args[2] |= 34; + lines[i].args[2] |= TMCF_SUBLIGHTR|TMCF_SUBFADER; if (lines[i].flags & ML_NOCLIMB) - lines[i].args[2] |= 68; + lines[i].args[2] |= TMCF_SUBLIGHTG|TMCF_SUBFADEG; if (lines[i].flags & ML_EFFECT2) - lines[i].args[2] |= 136; + lines[i].args[2] |= TMCF_SUBLIGHTB|TMCF_SUBFADEB; break; case 455: //Fade colormap { @@ -2832,17 +2832,17 @@ static void P_ConvertBinaryMap(void) else lines[i].args[2] = (256 + speed - 1)/speed; if (lines[i].flags & ML_EFFECT3) - lines[i].args[3] |= 1; + lines[i].args[3] |= TMCF_RELATIVE; if (lines[i].flags & ML_EFFECT1) - lines[i].args[3] |= 34; + lines[i].args[3] |= TMCF_SUBLIGHTR|TMCF_SUBFADER; if (lines[i].flags & ML_NOCLIMB) - lines[i].args[3] |= 68; + lines[i].args[3] |= TMCF_SUBLIGHTG|TMCF_SUBFADEG; if (lines[i].flags & ML_EFFECT2) - lines[i].args[3] |= 136; + lines[i].args[3] |= TMCF_SUBLIGHTB|TMCF_SUBFADEB; if (lines[i].flags & ML_BOUNCY) - lines[i].args[3] |= 4096; + lines[i].args[3] |= TMCF_FROMBLACK; if (lines[i].flags & ML_EFFECT5) - lines[i].args[3] |= 8192; + lines[i].args[3] |= TMCF_OVERRIDE; break; } case 456: //Stop fading colormap diff --git a/src/p_spec.c b/src/p_spec.c index 642f10bf3..266c444c2 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3532,7 +3532,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_ResetColormapFader(§ors[secnum]); - if (line->args[2] & 1) // relative calc + if (line->args[2] & TMCF_RELATIVE) { extracolormap_t *target = (!udmf && (line->flags & ML_TFERLINE) && line->sidenum[1] != 0xFFFF) ? sides[line->sidenum[1]].colormap_data : sectors[secnum].extra_colormap; // use back colormap instead of target sector @@ -3540,17 +3540,17 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) extracolormap_t *exc = R_AddColormaps( target, source, - line->args[2] & 2, // subtract R - line->args[2] & 4, // subtract G - line->args[2] & 8, // subtract B - line->args[2] & 16, // subtract A - line->args[2] & 32, // subtract FadeR - line->args[2] & 64, // subtract FadeG - line->args[2] & 128, // subtract FadeB - line->args[2] & 256, // subtract FadeA - line->args[2] & 512, // subtract FadeStart - line->args[2] & 1024, // subtract FadeEnd - line->args[2] & 2048, // ignore Flags + line->args[2] & TMCF_SUBLIGHTR, + line->args[2] & TMCF_SUBLIGHTG, + line->args[2] & TMCF_SUBLIGHTB, + line->args[2] & TMCF_SUBLIGHTA, + line->args[2] & TMCF_SUBFADER, + line->args[2] & TMCF_SUBFADEG, + line->args[2] & TMCF_SUBFADEB, + line->args[2] & TMCF_SUBFADEA, + line->args[2] & TMCF_SUBFADESTART, + line->args[2] & TMCF_SUBFADEEND, + line->args[2] & TMCF_IGNOREFLAGS, false); if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) @@ -3868,7 +3868,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) continue; // Don't interrupt ongoing fade - if (!(line->args[3] & 8192) + if (!(line->args[3] & TMCF_OVERRIDE) && sectors[secnum].fadecolormapdata) //&& ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer > (ticbased ? 2 : speed*2)) { @@ -3882,7 +3882,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) exc = sectors[secnum].extra_colormap; - if (!(line->args[3] & 4096) // Override fade from default rgba + if (!(line->args[3] & TMCF_FROMBLACK) // Override fade from default rgba && !R_CheckDefaultColormap(dest, true, false, false) && R_CheckDefaultColormap(exc, true, false, false)) { @@ -3904,22 +3904,22 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else source_exc = exc ? exc : R_GetDefaultColormap(); - if (line->args[3] & 1) // relative calc + if (line->args[3] & TMCF_RELATIVE) { exc = R_AddColormaps( source_exc, dest, - line->args[3] & 2, // subtract R - line->args[3] & 4, // subtract G - line->args[3] & 8, // subtract B - line->args[3] & 16, // subtract A - line->args[3] & 32, // subtract FadeR - line->args[3] & 64, // subtract FadeG - line->args[3] & 128, // subtract FadeB - line->args[3] & 256, // subtract FadeA - line->args[3] & 512, // subtract FadeStart - line->args[3] & 1024, // subtract FadeEnd - line->args[3] & 2048, // ignore Flags + line->args[3] & TMCF_SUBLIGHTR, + line->args[3] & TMCF_SUBLIGHTG, + line->args[3] & TMCF_SUBLIGHTB, + line->args[3] & TMCF_SUBLIGHTA, + line->args[3] & TMCF_SUBFADER, + line->args[3] & TMCF_SUBFADEG, + line->args[3] & TMCF_SUBFADEB, + line->args[3] & TMCF_SUBFADEA, + line->args[3] & TMCF_SUBFADESTART, + line->args[3] & TMCF_SUBFADEEND, + line->args[3] & TMCF_IGNOREFLAGS, false); } else diff --git a/src/r_data.h b/src/r_data.h index 87e2a05bc..c9e4115ee 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -146,6 +146,24 @@ boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgb boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); +typedef enum +{ + TMCF_RELATIVE = 1, + TMCF_SUBLIGHTR = 1<<1, + TMCF_SUBLIGHTG = 1<<2, + TMCF_SUBLIGHTB = 1<<3, + TMCF_SUBLIGHTA = 1<<4, + TMCF_SUBFADER = 1<<5, + TMCF_SUBFADEG = 1<<6, + TMCF_SUBFADEB = 1<<7, + TMCF_SUBFADEA = 1<<8, + TMCF_SUBFADESTART = 1<<9, + TMCF_SUBFADEEND = 1<<10, + TMCF_IGNOREFLAGS = 1<<11, + TMCF_FROMBLACK = 1<<12, + TMCF_OVERRIDE = 1<<13, +} textmapcolormapflags_t; + lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t * R_CreateColormapFromLinedef(char *p1, char *p2, char *p3); extracolormap_t* R_CreateColormap(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags);