From 7e88db938d715a6f83d8681dd198a9185430ef26 Mon Sep 17 00:00:00 2001 From: MascaraSnake <jonassauer27@gmail.com> Date: Sun, 4 Jul 2021 19:28:14 +0200 Subject: [PATCH] Adapt polyobject translucency fade linedef to UDMF --- extras/conf/udb/Includes/SRB222_linedefs.cfg | 40 +++++++++++++++++--- src/p_polyobj.h | 9 +++++ src/p_setup.c | 22 +++++++++++ src/p_spec.c | 30 +++++---------- 4 files changed, 74 insertions(+), 27 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg index f73d36044..3751d781c 100644 --- a/extras/conf/udb/Includes/SRB222_linedefs.cfg +++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg @@ -2800,13 +2800,9 @@ udmf } arg2 { - title = "Set/add?"; + title = "Set/Add?"; type = 11; - enum - { - 0 = "Set"; - 1 = "Add"; - } + enum = "setadd"; } } } @@ -3012,6 +3008,38 @@ udmf enum = "setadd"; } } + + 492 + { + title = "Fade Translucency"; + prefix = "(492)"; + arg0 + { + title = "PolyObject ID"; + type = 14; + } + arg1 + { + title = "Translucency level"; + } + arg2 + { + title = "Fading speed"; + } + arg3 + { + title = "Flags"; + type = 12; + enum + { + 1 = "Add to current translucency"; + 2 = "Interrupt ongoing fades"; + 4 = "Speed is duration"; + 8 = "Don't change collision"; + 16 = "No collision during fade"; + } + } + } } scrollpush diff --git a/src/p_polyobj.h b/src/p_polyobj.h index b37ffa6ef..411695775 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -349,6 +349,15 @@ typedef struct polyflagdata_s fixed_t momx; } polyflagdata_t; +typedef enum +{ + TMPF_RELATIVE = 1, + TMPF_OVERRIDE = 1<<1, + TMPF_TICBASED = 1<<2, + TMPF_IGNORECOLLISION = 1<<3, + TMPF_GHOSTFADE = 1<<4, +} textmappolyfade_t; + typedef struct polyfadedata_s { INT32 polyObjNum; diff --git a/src/p_setup.c b/src/p_setup.c index 4bcb5c8e1..11e5a385d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3750,6 +3750,28 @@ static void P_ConvertBinaryMap(void) lines[i].args[1] /= 100; lines[i].args[2] = !!(lines[i].flags & ML_EFFECT3); break; + case 492: //Polyobject - fade translucency + lines[i].args[0] = tag; + // If Front X Offset is specified, use that. Else, use floorheight. + lines[i].args[1] = (sides[lines[i].sidenum[0]].textureoffset ? sides[lines[i].sidenum[0]].textureoffset : lines[i].frontsector->floorheight) >> FRACBITS; + // If DONTPEGBOTTOM, specify raw translucency value. Else, take it out of 1000. + if (!(lines[i].flags & ML_DONTPEGBOTTOM)) + lines[i].args[1] /= 100; + // allow Back Y Offset to be consistent with other fade specials + lines[i].args[2] = (lines[i].sidenum[1] != 0xffff && !sides[lines[i].sidenum[0]].rowoffset) ? + abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) + : abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS); + if (lines[i].flags & ML_EFFECT3) + lines[i].args[3] |= TMPF_RELATIVE; + if (lines[i].flags & ML_EFFECT5) + lines[i].args[3] |= TMPF_OVERRIDE; + if (lines[i].flags & ML_EFFECT4) + lines[i].args[3] |= TMPF_TICBASED; + if (lines[i].flags & ML_BOUNCY) + lines[i].args[3] |= TMPF_IGNORECOLLISION; + if (lines[i].flags & ML_EFFECT1) + lines[i].args[3] |= TMPF_GHOSTFADE; + break; case 500: //Scroll front wall left case 501: //Scroll front wall right lines[i].args[0] = 0; diff --git a/src/p_spec.c b/src/p_spec.c index 9862ffa2f..0beac3c78 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1090,10 +1090,9 @@ static void PolyTranslucency(line_t *line) // Makes a polyobject translucency fade and applies tangibility static boolean PolyFade(line_t *line) { - INT32 polyObjNum = Tag_FGet(&line->tags); + INT32 polyObjNum = line->args[0]; polyobj_t *po; polyfadedata_t pfd; - INT32 value; if (!(po = Polyobj_GetForNum(polyObjNum))) { @@ -1106,7 +1105,7 @@ static boolean PolyFade(line_t *line) return 0; // Prevent continuous execs from interfering on an existing fade - if (!(line->flags & ML_EFFECT5) + if (!(line->args[3] & TMPF_OVERRIDE) && po->thinker && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) { @@ -1116,17 +1115,10 @@ static boolean PolyFade(line_t *line) pfd.polyObjNum = polyObjNum; - // If Front X Offset is specified, use that. Else, use floorheight. - value = (sides[line->sidenum[0]].textureoffset ? sides[line->sidenum[0]].textureoffset : line->frontsector->floorheight) >> FRACBITS; - - // If DONTPEGBOTTOM, specify raw translucency value. Else, take it out of 1000. - if (!(line->flags & ML_DONTPEGBOTTOM)) - value /= 100; - - if (line->flags & ML_EFFECT3) // relative calc - pfd.destvalue = po->translucency + value; + if (line->args[3] & TMPF_RELATIVE) // relative calc + pfd.destvalue = po->translucency + line->args[1]; else - pfd.destvalue = value; + pfd.destvalue = line->args[1]; pfd.destvalue = max(min(pfd.destvalue, NUMTRANSMAPS), 0); @@ -1134,15 +1126,11 @@ static boolean PolyFade(line_t *line) if (po->translucency == pfd.destvalue) return 1; - pfd.docollision = !(line->flags & ML_BOUNCY); // do not handle collision flags - pfd.doghostfade = (line->flags & ML_EFFECT1); // do ghost fade (no collision flags during fade) - pfd.ticbased = (line->flags & ML_EFFECT4); // Speed = Tic Duration - - // allow Back Y Offset to be consistent with other fade specials - pfd.speed = (line->sidenum[1] != 0xFFFF && !sides[line->sidenum[0]].rowoffset) ? - abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) - : abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + pfd.docollision = !(line->args[3] & TMPF_IGNORECOLLISION); // do not handle collision flags + pfd.doghostfade = (line->args[3] & TMPF_GHOSTFADE); // do ghost fade (no collision flags during fade) + pfd.ticbased = (line->args[3] & TMPF_TICBASED); // Speed = Tic Duration + pfd.speed = line->args[2]; return EV_DoPolyObjFade(&pfd); }