diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 25a878884..9865b65c1 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -490,11 +490,25 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) dlu.dy = finesine[user->angle >> ANGLETOFINESHIFT]; inter = P_InterceptVector(&dll, &dlu); - checkx = dll.x + FixedMul(dll.dx, inter); - checky = dll.y + FixedMul(dll.dy, inter); - // one sided line - if (line->sidedef[1] == NULL) + // Polyobjects must test the containing sector, not the one they originate from. + if (line->sidedef[0]->Flags & WALLF_POLYOBJ) + { + // Get a check point slightly inside the polyobject so that this still works + // if the polyobject lies directly on a sector boundary + checkx = dll.x + FixedMul(dll.dx, inter + (FRACUNIT/100)); + checky = dll.y + FixedMul(dll.dy, inter + (FRACUNIT/100)); + front = P_PointInSector(checkx, checky); + } + else + { + checkx = dll.x + FixedMul(dll.dx, inter); + checky = dll.y + FixedMul(dll.dy, inter); + } + + + // one sided line or polyobject + if (line->sidedef[1] == NULL || (line->sidedef[0]->Flags & WALLF_POLYOBJ)) { onesided: fixed_t sectorc = front->ceilingplane.ZatPoint(checkx, checky); diff --git a/src/po_man.cpp b/src/po_man.cpp index 828ea951a..37faf119a 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1545,6 +1545,7 @@ static void TranslateToStartSpot (int tag, int originX, int originY) validcount++; for (i = 0; i < po->numsegs; i++, tempSeg++, tempPt++) { + (*tempSeg)->sidedef->Flags |= WALLF_POLYOBJ; if ((*tempSeg)->linedef->validcount != validcount) { (*tempSeg)->linedef->bbox[BOXTOP] -= deltaY; @@ -1581,14 +1582,6 @@ static void TranslateToStartSpot (int tag, int originX, int originY) I_Error ("PO_TranslateToStartSpot: Multiple polyobjs in a single subsector.\n"); } sub->poly = po; - // Reassign the sides of the polyobj to its new sector. - sector_t *sec = P_PointInSector (avg.x << FRACBITS, avg.y << FRACBITS); - for (i = 0; i < po->numsegs; ++i) - { - po->segs[i]->linedef->frontsector = sec; - po->segs[i]->linedef->sidedef[0]->sector = sec; - po->segs[i]->frontsector = sec; - } } //========================================================================== diff --git a/src/r_defs.h b/src/r_defs.h index 7d02fb4eb..a14a819ce 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -725,6 +725,7 @@ enum WALLF_SMOOTHLIGHTING = 8, // Similar to autocontrast but applies to all angles. WALLF_CLIP_MIDTEX = 16, // Like the line counterpart, but only for this side. WALLF_WRAP_MIDTEX = 32, // Like the line counterpart, but only for this side. + WALLF_POLYOBJ = 64, // This wall belongs to a polyobject. }; struct side_t