From dcba011cf3adcb64972ba690b7d7b741e229a4d6 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Thu, 1 Jul 2021 20:35:13 +0200 Subject: [PATCH] Adapt wind/current linedefs to UDMF --- src/p_setup.c | 26 ++++++++++++++++++++++++++ src/p_spec.c | 35 +++++++++++------------------------ src/p_spec.h | 6 ++++++ 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 575998d20..1dd172f1a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3745,6 +3745,32 @@ static void P_ConvertBinaryMap(void) lines[i].args[4] |= TMST_NONEXCLUSIVE; lines[i].special = 510; break; + case 541: //Wind + case 542: //Upwards wind + case 543: //Downwards wind + case 544: //Current + case 545: //Upwards current + case 546: //Downwards current + lines[i].args[0] = tag; + switch ((lines[i].special - 541) % 3) + { + case 0: + lines[i].args[1] = R_PointToDist2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y) >> FRACBITS; + break; + case 1: + lines[i].args[2] = R_PointToDist2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y) >> FRACBITS; + break; + case 2: + lines[i].args[2] = -R_PointToDist2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y) >> FRACBITS; + break; + } + lines[i].args[3] = (lines[i].special >= 544) ? p_current : p_wind; + if (lines[i].flags & ML_EFFECT4) + lines[i].args[4] |= TMPF_SLIDE; + if (!(lines[i].flags & ML_NOCLIMB)) + lines[i].args[4] |= TMPF_NONEXCLUSIVE; + lines[i].special = 541; + break; case 606: //Colormap lines[i].args[0] = Tag_FGet(&lines[i].tags); break; diff --git a/src/p_spec.c b/src/p_spec.c index 232e1d0e7..c200bb6dd 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -8883,7 +8883,7 @@ void T_Pusher(pusher_t *p) thing->momx += xspeed; thing->momy += yspeed; - thing->momz += xspeed; + thing->momz += zspeed; if (thing->player) { thing->player->cmomx += xspeed; @@ -8974,14 +8974,17 @@ static void P_SpawnPushers(void) tag = Tag_FGet(&l->tags); switch (l->special) { - case 541: // wind - TAG_ITER_SECTORS(tag, s) - Add_Pusher(p_wind, l->dx, l->dy, 0, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; - case 544: // current - TAG_ITER_SECTORS(tag, s) - Add_Pusher(p_current, l->dx, l->dy, 0, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); + case 541: // wind/current + { + fixed_t length = R_PointToDist2(l->v2->x, l->v2->y, l->v1->x, l->v1->y); + fixed_t hspeed = l->args[1] << FRACBITS; + fixed_t dx = FixedMul(FixedDiv(l->dx, length), hspeed); + fixed_t dy = FixedMul(FixedDiv(l->dy, length), hspeed); + + TAG_ITER_SECTORS(l->args[0], s) + Add_Pusher(l->args[3], dx, dy, l->args[2] << FRACBITS, s, -1, !(l->args[4] & TMPF_NONEXCLUSIVE), !!(l->args[4] & TMPF_SLIDE)); break; + } case 547: // push/pull TAG_ITER_SECTORS(tag, s) { @@ -8990,22 +8993,6 @@ static void P_SpawnPushers(void) Add_PointPusher(P_AproxDistance(l->dx >> FRACBITS, l->dy >> FRACBITS), thing, s, l->flags & ML_NOCLIMB); } break; - case 545: // current up - TAG_ITER_SECTORS(tag, s) - Add_Pusher(p_current, 0, 0, P_AproxDistance(l->dx, l->dy), s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; - case 546: // current down - TAG_ITER_SECTORS(tag, s) - Add_Pusher(p_current, 0, 0, -P_AproxDistance(l->dx, l->dy), s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; - case 542: // wind up - TAG_ITER_SECTORS(tag, s) - Add_Pusher(p_wind, 0, 0, P_AproxDistance(l->dx, l->dy), s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; - case 543: // wind down - TAG_ITER_SECTORS(tag, s) - Add_Pusher(p_wind, 0, 0, -P_AproxDistance(l->dx, l->dy), s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; } } } diff --git a/src/p_spec.h b/src/p_spec.h index 98cb68161..f08ee2f1f 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -135,6 +135,12 @@ typedef enum TMST_NONEXCLUSIVE = 4, } textmapscrolltype_t; +typedef enum +{ + TMPF_SLIDE = 1, + TMPF_NONEXCLUSIVE = 1<<1, +} textmappusherflags_t; + // GETSECSPECIAL (specialval, section) // // Pulls out the special # from a particular section.