From 228efa5ffc77a8fcefc0bdb28fe9d0a1aec0e72a Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Wed, 29 Dec 2021 15:29:59 +0100 Subject: [PATCH] Add "relative" setting to linedef type 799 and adapt it to UDMF --- extras/conf/SRB2-22.cfg | 1 + extras/conf/udb/Includes/SRB222_linedefs.cfg | 16 +++++++++ src/p_saveg.c | 16 +++++++-- src/p_setup.c | 4 ++- src/p_slopes.c | 35 +++++++++++++------- src/p_slopes.h | 5 ++- 6 files changed, 60 insertions(+), 17 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 9aeada89b..ec568e865 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3253,6 +3253,7 @@ linedeftypes { title = "Set Tagged Dynamic Slope Vertex to Front Sector Height"; prefix = "(799)"; + flags64text = "[6] Use relative heights"; } } diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg index c2bcfa3b3..169709de4 100644 --- a/extras/conf/udb/Includes/SRB222_linedefs.cfg +++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg @@ -5233,5 +5233,21 @@ udmf } } } + + 799 + { + title = "Set Tagged Dynamic Slope Vertex to Front Sector Height"; + prefix = "(799)"; + arg0 + { + title = "Apply height"; + type = 11; + enum + { + 0 = "Absolute"; + 1 = "Relative"; + } + } + } } } diff --git a/src/p_saveg.c b/src/p_saveg.c index ffca42cd3..5e204f9bc 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2294,12 +2294,17 @@ static inline void SaveDynamicLineSlopeThinker(const thinker_t *th, const UINT8 static inline void SaveDynamicVertexSlopeThinker(const thinker_t *th, const UINT8 type) { + size_t i; const dynvertexplanethink_t* ht = (const void*)th; WRITEUINT8(save_p, type); WRITEUINT32(save_p, SaveSlope(ht->slope)); - WRITEMEM(save_p, ht->tags, sizeof(ht->tags)); - WRITEMEM(save_p, ht->vex, sizeof(ht->vex)); + for (i = 0; i < 3; i++) + WRITEUINT32(save_p, SaveSector(ht->secs[i])); + WRITEMEM(save_p, ht->vex, sizeof(ht->vex)); + WRITEMEM(save_p, ht->origsecheights, sizeof(ht->origsecheights)); + WRITEMEM(save_p, ht->origvecheights, sizeof(ht->origvecheights)); + WRITEUINT8(save_p, ht->relative); } static inline void SavePolyrotatetThinker(const thinker_t *th, const UINT8 type) @@ -3468,12 +3473,17 @@ static inline thinker_t* LoadDynamicLineSlopeThinker(actionf_p1 thinker) static inline thinker_t* LoadDynamicVertexSlopeThinker(actionf_p1 thinker) { + size_t i; dynvertexplanethink_t* ht = Z_Malloc(sizeof(*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->slope = LoadSlope(READUINT32(save_p)); - READMEM(save_p, ht->tags, sizeof(ht->tags)); + for (i = 0; i < 3; i++) + ht->secs[i] = LoadSector(READUINT32(save_p)); READMEM(save_p, ht->vex, sizeof(ht->vex)); + READMEM(save_p, ht->origsecheights, sizeof(ht->origsecheights)); + READMEM(save_p, ht->origvecheights, sizeof(ht->origvecheights)); + ht->relative = READUINT8(save_p); return &ht->thinker; } diff --git a/src/p_setup.c b/src/p_setup.c index 9fe4446a6..2f815a228 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4885,7 +4885,9 @@ static void P_ConvertBinaryMap(void) lines[i].args[4] |= TMSC_BACKTOFRONTCEILING; lines[i].special = 720; break; - + case 799: //Set dynamic slope vertex to front sector height + lines[i].args[0] = !!(lines[i].flags & ML_NOCLIMB); + break; case 900: //Translucent wall (10%) case 901: //Translucent wall (20%) case 902: //Translucent wall (30%) diff --git a/src/p_slopes.c b/src/p_slopes.c index 415642abf..b9154b890 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -163,21 +163,17 @@ void T_DynamicSlopeLine (dynlineplanethink_t* th) /// Mapthing-defined void T_DynamicSlopeVert (dynvertexplanethink_t* th) { - pslope_t* slope = th->slope; - size_t i; - INT32 l; - for (i = 0; i < 3; i++) { - l = Tag_FindLineSpecial(799, th->tags[i]); - if (l != -1) { - th->vex[i].z = lines[l].frontsector->floorheight; - } + for (i = 0; i < 3; i++) + { + if (th->relative & (1 << i)) + th->vex[i].z = th->origvecheights[i] + (th->secs[i]->floorheight - th->origsecheights[i]); else - th->vex[i].z = 0; + th->vex[i].z = th->secs[i]->floorheight; } - ReconfigureViaVertexes(slope, th->vex[0], th->vex[1], th->vex[2]); + ReconfigureViaVertexes(th->slope, th->vex[0], th->vex[1], th->vex[2]); } static inline void P_AddDynLineSlopeThinker (pslope_t* slope, dynplanetype_t type, line_t* sourceline, fixed_t extent) @@ -194,10 +190,25 @@ static inline void P_AddDynLineSlopeThinker (pslope_t* slope, dynplanetype_t typ static inline void P_AddDynVertexSlopeThinker (pslope_t* slope, const INT16 tags[3], const vector3_t vx[3]) { dynvertexplanethink_t* th = Z_Calloc(sizeof (*th), PU_LEVSPEC, NULL); + size_t i; + INT32 l; th->thinker.function.acp1 = (actionf_p1)T_DynamicSlopeVert; th->slope = slope; - memcpy(th->tags, tags, sizeof(th->tags)); - memcpy(th->vex, vx, sizeof(th->vex)); + + for (i = 0; i < 3; i++) { + l = Tag_FindLineSpecial(799, tags[i]); + if (l == -1) + { + Z_Free(th); + return; + } + th->secs[i] = lines[l].frontsector; + th->vex[i] = vx[i]; + th->origsecheights[i] = lines[l].frontsector->floorheight; + th->origvecheights[i] = vx[i].z; + if (lines[l].args[0]) + th->relative |= 1<thinker); } diff --git a/src/p_slopes.h b/src/p_slopes.h index 45588d463..0b3e0b517 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -111,8 +111,11 @@ typedef struct { thinker_t thinker; pslope_t *slope; - INT16 tags[3]; + sector_t *secs[3]; vector3_t vex[3]; + fixed_t origsecheights[3]; + fixed_t origvecheights[3]; + UINT8 relative; } dynvertexplanethink_t; void T_DynamicSlopeLine (dynlineplanethink_t* th);