Skip to content

Commit 741daf1

Browse files
committed
Restored msecnodes to work with polylines, but only partially
It was needed for attached 3dmidtex to work
1 parent 8700a5f commit 741daf1

10 files changed

Lines changed: 54 additions & 28 deletions

File tree

source/e_ttypes.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ ETerrain *E_GetThingFloorType(const Mobj *thing)
739739
fixed_t z = thing->zref.floor;
740740
for(m = thing->touching_sectorlist; m; m = m->m_tnext)
741741
{
742+
if(m->flags & MSN_POLYLINE)
743+
continue;
742744
// Handle sloped floors a bit differently, using the designated floorsector
743745
const auto &mfloor = m->m_sector->srf.floor;
744746
if(mfloor.slope && mfloor.slope == thing->zref.slope.floor)
@@ -1089,7 +1091,7 @@ bool E_HitFloor(Mobj *thing)
10891091

10901092
// determine what touched sector the thing is standing on
10911093
for(m = thing->touching_sectorlist; m; m = m->m_tnext)
1092-
if(E_StandingOnExactly(*m->m_sector, *thing))
1094+
if(!(m->flags & MSN_POLYLINE) && E_StandingOnExactly(*m->m_sector, *thing))
10931095
break;
10941096

10951097
// not on a floor or dealing with deep water, return solid
@@ -1108,7 +1110,7 @@ bool E_WouldHitFloorWater(const Mobj &thing)
11081110
{
11091111
const msecnode_t *m;
11101112
for(m = thing.touching_sectorlist; m; m = m->m_tnext)
1111-
if(E_StandingOnExactly(*m->m_sector, thing))
1113+
if(!(m->flags & MSN_POLYLINE) && E_StandingOnExactly(*m->m_sector, thing))
11121114
break;
11131115

11141116
// NOTE: same conditions as E_HitFloor

source/p_enemy.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,11 @@ static int P_IsUnderDamage(Mobj *actor)
457457

458458
for(seclist = actor->touching_sectorlist; seclist; seclist = seclist->m_tnext)
459459
{
460-
if((cl = thinker_cast<CeilingThinker *>(seclist->m_sector->srf.ceiling.data)) && !cl->inStasis)
460+
if(!(seclist->flags & MSN_POLYLINE) &&
461+
(cl = thinker_cast<CeilingThinker *>(seclist->m_sector->srf.ceiling.data)) && !cl->inStasis)
462+
{
461463
dir |= cl->direction;
464+
}
462465
}
463466

464467
return dir;

source/p_map.cpp

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ int P_GetFriction(const Mobj *mo, int *frictionfactor)
269269
{
270270
for(m = mo->touching_sectorlist; m; m = m->m_tnext)
271271
{
272-
if(!P_SectorTouchesThingVertically(m->m_sector, mo))
272+
if(m->flags & MSN_POLYLINE || !P_SectorTouchesThingVertically(m->m_sector, mo))
273273
continue;
274274
if((sec = m->m_sector)->flags & SECF_FRICTION && (sec->friction < friction || friction == ORIG_FRICTION))
275275
{
@@ -2954,7 +2954,7 @@ bool P_CheckSector(sector_t *sector, int crunch, int amt, CheckSectorPlane plane
29542954

29552955
// Mark all things invalid
29562956
for(n = sector->touching_thinglist; n; n = n->m_snext)
2957-
n->visited = false;
2957+
n->flags &= ~MSN_VISITED;
29582958

29592959
do
29602960
{
@@ -2963,9 +2963,9 @@ bool P_CheckSector(sector_t *sector, int crunch, int amt, CheckSectorPlane plane
29632963
// ioanch 20160115: portal aware
29642964
if(!P_SectorTouchesThingVertically(sector, n->m_thing))
29652965
continue;
2966-
if(!n->visited) // unprocessed thing found
2966+
if(!(n->flags & MSN_VISITED)) // unprocessed thing found
29672967
{
2968-
n->visited = true; // mark thing as processed
2968+
n->flags |= MSN_VISITED; // mark thing as processed
29692969
if(!(n->m_thing->flags & MF_NOBLOCKMAP)) // jff 4/7/98 don't do these
29702970
PIT_ChangeSector(n->m_thing, nullptr); // process it
29712971
break; // exit and start over
@@ -3039,6 +3039,12 @@ static void P_PutSecnode(msecnode_t *node)
30393039
headsecnode = node;
30403040
}
30413041

3042+
enum class SecnodeType
3043+
{
3044+
normal,
3045+
polyline
3046+
};
3047+
30423048
//
30433049
// P_AddSecnode
30443050
//
@@ -3050,7 +3056,7 @@ static void P_PutSecnode(msecnode_t *node)
30503056
//
30513057
// killough 11/98: reformatted
30523058
//
3053-
static msecnode_t *P_AddSecnode(sector_t *s, msecnode_t *sector_t::*which_thinglist, Mobj *thing, msecnode_t *nextnode)
3059+
static msecnode_t *P_AddSecnode(sector_t *s, msecnode_t *sector_t::*which_thinglist, Mobj *thing, msecnode_t *nextnode, SecnodeType type)
30543060
{
30553061
msecnode_t *node;
30563062

@@ -3059,6 +3065,8 @@ static msecnode_t *P_AddSecnode(sector_t *s, msecnode_t *sector_t::*which_thingl
30593065
if(node->m_sector == s) // Already have a node for this sector?
30603066
{
30613067
node->m_thing = thing; // Yes. Setting m_thing says 'keep it'.
3068+
if(type == SecnodeType::normal)
3069+
node->flags &= ~MSN_POLYLINE;
30623070
return nextnode;
30633071
}
30643072
}
@@ -3068,7 +3076,8 @@ static msecnode_t *P_AddSecnode(sector_t *s, msecnode_t *sector_t::*which_thingl
30683076

30693077
node = P_GetSecnode();
30703078

3071-
node->visited = 0; // killough 4/4/98, 4/7/98: mark new nodes unvisited.
3079+
// killough 4/4/98, 4/7/98: mark new nodes unvisited.
3080+
node->flags = type == SecnodeType::polyline ? MSN_POLYLINE : 0;
30723081

30733082
node->m_sector = s; // sector
30743083
node->m_thing = thing; // mobj
@@ -3187,10 +3196,9 @@ static bool PIT_GetSectors(line_t *ld, polyobj_t *po, void *vcontext)
31873196
bbox[BOXTOP] = pClip->bbox[BOXTOP] + link->y;
31883197
bbox[BOXBOTTOM] = pClip->bbox[BOXBOTTOM] + link->y;
31893198

3190-
// Polyobject lines don't contribute with sector information (even with portals)
3191-
bool polyline = demo_version >= 406 && Polyobj_IsLine(*ld);
3192-
if(polyline && !(ld->intflags & MLI_1SPORTALLINE))
3193-
return true;
3199+
const bool polyline = Polyobj_IsLine(*ld);
3200+
const SecnodeType type =
3201+
polyline && !(ld->intflags & MLI_1SPORTALLINE) ? SecnodeType::polyline : SecnodeType::normal;
31943202

31953203
if(bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] ||
31963204
bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP])
@@ -3227,7 +3235,8 @@ static bool PIT_GetSectors(line_t *ld, polyobj_t *po, void *vcontext)
32273235
pClip->thing->groupid, frontsector, pClip->thing->z) ||
32283236
(context->master->linegroups && context->master->linegroups[ld->frontsector->groupid]))
32293237
{
3230-
pClip->sector_list = P_AddSecnode(frontsector, context->which_thinglist, pClip->thing, pClip->sector_list);
3238+
pClip->sector_list =
3239+
P_AddSecnode(frontsector, context->which_thinglist, pClip->thing, pClip->sector_list, type);
32313240
}
32323241

32333242
if(!(ld->pflags & PS_PASSABLE) && ld->backsector && ld->backsector != frontsector)
@@ -3240,7 +3249,7 @@ static bool PIT_GetSectors(line_t *ld, polyobj_t *po, void *vcontext)
32403249
pClip->thing->groupid, ld->backsector, pClip->thing->z))
32413250
{
32423251
pClip->sector_list =
3243-
P_AddSecnode(ld->backsector, context->which_thinglist, pClip->thing, pClip->sector_list);
3252+
P_AddSecnode(ld->backsector, context->which_thinglist, pClip->thing, pClip->sector_list, type);
32443253
}
32453254
}
32463255
}
@@ -3254,7 +3263,7 @@ static bool PIT_GetSectors(line_t *ld, polyobj_t *po, void *vcontext)
32543263
}
32553264
else
32563265
frontsector = ld->frontsector;
3257-
pClip->sector_list = P_AddSecnode(frontsector, context->which_thinglist, pClip->thing, pClip->sector_list);
3266+
pClip->sector_list = P_AddSecnode(frontsector, context->which_thinglist, pClip->thing, pClip->sector_list, type);
32583267

32593268
if(ld->pflags & PS_PASSABLE && context->master)
32603269
{
@@ -3273,7 +3282,7 @@ static bool PIT_GetSectors(line_t *ld, polyobj_t *po, void *vcontext)
32733282

32743283
if(!(ld->pflags & PS_PASSABLE) && ld->backsector && ld->backsector != frontsector)
32753284
pClip->sector_list =
3276-
P_AddSecnode(ld->backsector, context->which_thinglist, pClip->thing, pClip->sector_list);
3285+
P_AddSecnode(ld->backsector, context->which_thinglist, pClip->thing, pClip->sector_list, type);
32773286
}
32783287

32793288
return true;
@@ -3295,8 +3304,8 @@ static bool PIT_transPortalGetSectors(int x, int y, int groupid, void *data)
32953304
// Get the offset from thing's position to the PREVIOUS groupid
32963305
if(groupid == inter.thing->groupid)
32973306
{
3298-
inter.sector_list =
3299-
P_AddSecnode(inter.thing->subsector->sector, context->which_thinglist, inter.thing, inter.sector_list);
3307+
inter.sector_list = P_AddSecnode(inter.thing->subsector->sector, context->which_thinglist, inter.thing,
3308+
inter.sector_list, SecnodeType::normal);
33003309
}
33013310
else
33023311
{
@@ -3305,7 +3314,8 @@ static bool PIT_transPortalGetSectors(int x, int y, int groupid, void *data)
33053314
if(sector)
33063315
{
33073316
// Add it
3308-
inter.sector_list = P_AddSecnode(sector, context->which_thinglist, inter.thing, inter.sector_list);
3317+
inter.sector_list =
3318+
P_AddSecnode(sector, context->which_thinglist, inter.thing, inter.sector_list, SecnodeType::normal);
33093319
}
33103320
}
33113321
}
@@ -3403,7 +3413,7 @@ msecnode_t *P_CreateSecNodeList(Mobj *thing, fixed_t x, fixed_t y, fixed_t radiu
34033413
}
34043414

34053415
// Add the sector of the (x,y) point to sector_list.
3406-
list = P_AddSecnode(thing->subsector->sector, which_thinglist, thing, pClip->sector_list);
3416+
list = P_AddSecnode(thing->subsector->sector, which_thinglist, thing, pClip->sector_list, SecnodeType::normal);
34073417
}
34083418

34093419
// Now delete any nodes that won't be used. These are the ones where

source/p_map3d.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ bool P_ChangeSector3D(sector_t *sector, int crunch, int amt, CheckSectorPlane pl
11731173
// Mark all things invalid
11741174

11751175
for(n = sector->touching_thinglist; n; n = n->m_snext)
1176-
n->visited = false;
1176+
n->flags &= ~MSN_VISITED;
11771177

11781178
do
11791179
{
@@ -1182,9 +1182,9 @@ bool P_ChangeSector3D(sector_t *sector, int crunch, int amt, CheckSectorPlane pl
11821182
// ioanch 20160115: portal aware
11831183
if(!P_SectorTouchesThingVertically(sector, n->m_thing))
11841184
continue;
1185-
if(!n->visited) // unprocessed thing found
1185+
if(!(n->flags & MSN_VISITED)) // unprocessed thing found
11861186
{
1187-
n->visited = true; // mark thing as processed
1187+
n->flags |= MSN_VISITED; // mark thing as processed
11881188
if(!(n->m_thing->flags & MF_NOBLOCKMAP)) // jff 4/7/98 don't do these
11891189
{
11901190
iterator(n->m_thing); // process it

source/p_mobj.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4080,6 +4080,8 @@ void P_AdjustFloorClip(Mobj *thing)
40804080
// involved (it does its own clipping)
40814081
for(m = thing->touching_sectorlist; m; m = m->m_tnext)
40824082
{
4083+
if(m->flags & MSN_POLYLINE)
4084+
continue;
40834085
if(m->m_sector->heightsec == -1 &&
40844086
((!m->m_sector->srf.floor.slope && thing->z == m->m_sector->srf.floor.height) ||
40854087
(m->m_sector->srf.floor.slope && P_SlopesEqual(thing->zref.sector.floor, m->m_sector, surf_floor) &&

source/p_pushers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void PushThinker::Think()
250250
for(; node; node = node->m_snext)
251251
{
252252
// ioanch 20160115: portal aware
253-
if(!P_SectorTouchesThingVertically(sec, node->m_thing))
253+
if(!P_SectorTouchesThingVertically(sec, node->m_thing) || node->flags & MSN_POLYLINE)
254254
continue;
255255

256256
thing = node->m_thing;

source/p_scroll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void ScrollThinker::Think()
181181
for(node = sec->touching_thinglist; node; node = node->m_snext)
182182
{
183183
// ioanch 20160115: portal aware
184-
if(!P_SectorTouchesThingVertically(sec, node->m_thing))
184+
if(!P_SectorTouchesThingVertically(sec, node->m_thing) || node->flags & MSN_POLYLINE)
185185
continue;
186186
if(!((thing = node->m_thing)->flags & MF_NOCLIP) && !(thing->flags2 & MF2_NOTHRUST) &&
187187
(!(thing->flags & MF_NOGRAVITY || !P_RestingOnGround(*thing, sec->srf.floor)) ||

source/p_spec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ void FrictionThinker::Think()
18461846
while(node)
18471847
{
18481848
// ioanch 20160115: portal aware
1849-
if(!P_SectorTouchesThingVertically(sec, node->m_thing))
1849+
if(!P_SectorTouchesThingVertically(sec, node->m_thing) || node->flags & MSN_POLYLINE)
18501850
{
18511851
node = node->m_snext;
18521852
continue;

source/p_user.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ static void P_HereticCurrent(player_t *player)
503503
// determine what touched sector the player is standing on
504504
for(m = thing->touching_sectorlist; m; m = m->m_tnext)
505505
{
506+
if(m->flags & MSN_POLYLINE)
507+
continue;
506508
if(E_StandingOnExactly(*m->m_sector, *thing))
507509
break;
508510
}

source/r_defs.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,13 @@ struct subsector_t
564564
//
565565
// For the links, nullptr means top or end of list.
566566

567+
// msecnode_t flags
568+
enum
569+
{
570+
MSN_VISITED = 1, // killough 4/4/98, 4/7/98: used in search algorithms
571+
MSN_POLYLINE = 2,
572+
};
573+
567574
struct msecnode_t
568575
{
569576
sector_t *m_sector; // a sector containing this object
@@ -572,7 +579,7 @@ struct msecnode_t
572579
msecnode_t *m_tnext; // next msecnode_t for this thing
573580
msecnode_t *m_sprev; // prev msecnode_t for this sector
574581
msecnode_t *m_snext; // next msecnode_t for this sector
575-
bool visited; // killough 4/4/98, 4/7/98: used in search algorithms
582+
unsigned flags;
576583
};
577584

578585
//

0 commit comments

Comments
 (0)