From 5e9970311fd52bc3015ef5b90dfef31a15bdc940 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 10 Feb 2025 18:09:29 -0500 Subject: [PATCH] repair 'Change scroller direction' --- src/p_setup.c | 1 + src/p_spec.c | 38 +++++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 6afb8d5ae..cf621d0dd 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -6167,6 +6167,7 @@ static void P_ConvertBinaryLinedefTypes(void) case 435: //Change plane scroller direction lines[i].args[0] = tag; lines[i].args[1] = R_PointToDist2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y) >> FRACBITS; + lines[i].args[2] = AngleFixed(R_PointToAngle2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y)) >> FRACBITS; break; case 436: //Shatter FOF lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; diff --git a/src/p_spec.c b/src/p_spec.c index 20c4fdc68..0899066be 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3172,10 +3172,15 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha scroll_t *scroller; thinker_t *th; - fixed_t length = R_PointToDist2(line->v2->x, line->v2->y, line->v1->x, line->v1->y); - fixed_t speed = args[1] << FRACBITS; - fixed_t dx = FixedMul(FixedMul(FixedDiv(line->dx, length), speed) >> SCROLL_SHIFT, CARRYFACTOR); - fixed_t dy = FixedMul(FixedMul(FixedDiv(line->dy, length), speed) >> SCROLL_SHIFT, CARRYFACTOR); + fixed_t speed; + angle_t angle; + fixed_t dx; + fixed_t dy; + + speed = args[1] << FRACBITS; + angle = FixedAngle(args[2] << FRACBITS) >> ANGLETOFINESHIFT; + dx = FixedMul(FINECOSINE(angle), speed) >> SCROLL_SHIFT; + dy = FixedMul( FINESINE(angle), speed) >> SCROLL_SHIFT; for (th = thlist[THINK_MAIN].next; th != &thlist[THINK_MAIN]; th = th->next) { @@ -3183,11 +3188,30 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha continue; scroller = (scroll_t *)th; - if (!Tag_Find(§ors[scroller->affectee].tags, args[0])) + + const taglist_t* taglist = (scroller->type == sc_side) + ? &sides[scroller->affectee].line->tags + : §ors[scroller->affectee].tags; + + if (!Tag_Find(taglist, args[0])) continue; - scroller->dx = dx; - scroller->dy = dy; + switch (scroller->type) + { + case sc_carry: + case sc_carry_ceiling: + { + scroller->dx = FixedMul(-dx, CARRYFACTOR); + scroller->dy = FixedMul(dy, CARRYFACTOR); + break; + } + default: + { + scroller->dx = dx; + scroller->dy = dy; + break; + } + } } } break;