diff --git a/src/actor.h b/src/actor.h index 043f07ae5..be3f28ec6 100644 --- a/src/actor.h +++ b/src/actor.h @@ -401,6 +401,7 @@ enum ActorFlag7 enum ActorFlag8 { MF8_FRIGHTENING = 0x00000001, // for those moments when halloween just won't do + MF8_INSCROLLSEC = 0x00000002, // actor is partially inside a scrolling sector }; // --- mobj.renderflags --- diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 2e16347db..1fb7e259d 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4098,6 +4098,7 @@ void AActor::Tick () CheckPortalTransition(false); LinkToWorld(&ctx); } + flags8 &= MF8_INSCROLLSEC; } else { @@ -4250,12 +4251,16 @@ void AActor::Tick () // [RH] Consider carrying sectors here DVector2 cumm(0, 0); - if ((level.Scrolls.Size() != 0 || player != NULL) && !(flags & MF_NOCLIP) && !(flags & MF_NOSECTOR)) + + if ((((flags8 & MF8_INSCROLLSEC) && level.Scrolls.Size() > 0) || player != NULL) && !(flags & MF_NOCLIP) && !(flags & MF_NOSECTOR)) { double height, waterheight; // killough 4/4/98: add waterheight const msecnode_t *node; int countx, county; + // Clear the flag for the next frame. + flags8 &= MF8_INSCROLLSEC; + // killough 3/7/98: Carry things on floor // killough 3/20/98: use new sector list which reflects true members // killough 3/27/98: fix carrier bug @@ -5079,6 +5084,8 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a { level.total_secrets++; } + // force scroller check in the first tic. + actor->flags8 |= MF8_INSCROLLSEC; return actor; } diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index f2661a2a1..d8666d9a7 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -256,6 +256,11 @@ void DScroller::Tick () case EScroll::sc_carry: level.Scrolls[m_Affectee].X += dx; level.Scrolls[m_Affectee].Y += dy; + // mark all potentially affected things here so that the very expensive calculation loop in AActor::Tick does not need to run for actors which do not touch a scrolling sector. + for (auto n = level.sectors[m_Affectee].touching_thinglist; n; n = n->m_snext) + { + n->m_thing->flags8 |= MF8_INSCROLLSEC; + } break; case EScroll::sc_carry_ceiling: // to be added later