diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 39186ae9f4..b1f14e0b2e 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -256,10 +256,11 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f // //============================================================================ -bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, fixed_t &opentop, fixed_t &openbottom) +bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, fixed_t &opentop, fixed_t &openbottom, bool *above) { fixed_t tt, tb; + *above = false; if (P_GetMidTexturePosition(linedef, 0, &tt, &tb)) { if (thing->z + (thing->height/2) < (tt + tb)/2) @@ -268,8 +269,11 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, fixed_t &opent } else { - if(tt > openbottom) openbottom = tt; - + if(tt > openbottom) + { + openbottom = tt; + *above = true; + } // returns true if it touches the midtexture return (abs(thing->z - tt) <= thing->MaxStepHeight); } diff --git a/src/p_3dmidtex.h b/src/p_3dmidtex.h index 278a191771..c06c51601f 100644 --- a/src/p_3dmidtex.h +++ b/src/p_3dmidtex.h @@ -14,7 +14,7 @@ void P_Start3dMidtexInterpolations(TArray &list, sector_t *sec void P_Attach3dMidtexLinesToSector(sector_t *dest, int lineid, int tag, bool ceiling); bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, fixed_t *ptexbot); bool P_Check3dMidSwitch(AActor *actor, line_t *line, int side); -bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, fixed_t &opentop, fixed_t &openbottom); +bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, fixed_t &opentop, fixed_t &openbottom, bool *above); bool P_MoveLinkedSectors(sector_t *sector, int crush, fixed_t move, bool ceiling); void P_StartLinkedSectorInterpolations(TArray &list, sector_t *sector, bool ceiling); diff --git a/src/p_local.h b/src/p_local.h index 2997f31216..7d3c3d14ce 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -232,6 +232,7 @@ struct FLineOpening FTextureID ceilingpic; FTextureID floorpic; bool touchmidtex; + bool abovemidtex; }; void P_LineOpening (FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx=FIXED_MIN, fixed_t refy=0); @@ -348,6 +349,7 @@ struct FCheckPosition FTextureID ceilingpic; sector_t *ceilingsector; bool touchmidtex; + bool abovemidtex; bool floatok; bool FromPMove; line_t *ceilingline; diff --git a/src/p_map.cpp b/src/p_map.cpp index 725d65824d..2acb718c77 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -148,10 +148,12 @@ static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPos tmf.floorz = open.bottom; tmf.floorsector = open.bottomsec; tmf.touchmidtex = open.touchmidtex; + tmf.abovemidtex = open.abovemidtex; } else if (open.bottom == tmf.floorz) { tmf.touchmidtex |= open.touchmidtex; + tmf.abovemidtex |= open.abovemidtex; } if (open.lowfloor < tmf.dropoffz) @@ -250,6 +252,7 @@ void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos) FBoundingBox box(tmf.x, tmf.y, actor->radius); tmf.touchmidtex = false; + tmf.abovemidtex = false; validcount++; FBlockLinesIterator it(box); @@ -262,7 +265,7 @@ void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos) if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; - if (!onlyspawnpos || (tmf.touchmidtex && (tmf.floorz <= actor->z))) + if (!onlyspawnpos || (tmf.abovemidtex && (tmf.floorz <= actor->z))) { actor->floorz = tmf.floorz; actor->dropoffz = tmf.dropoffz; @@ -314,6 +317,8 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr tmf.x = x; tmf.y = y; tmf.z = z; + tmf.touchmidtex = false; + tmf.abovemidtex = false; P_GetFloorCeilingZ(tmf, true); spechit.Clear (); @@ -325,10 +330,14 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr FBlockLinesIterator it(box); line_t *ld; + // P_LineOpening requires the thing's z to be the destination ín order to work. + fixed_t savedz = thing->z; + thing->z = z; while ((ld = it.Next())) { PIT_FindFloorCeiling(ld, box, tmf); } + thing->z = savedz; if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; @@ -768,11 +777,13 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) tm.floorsector = open.bottomsec; tm.floorpic = open.floorpic; tm.touchmidtex = open.touchmidtex; + tm.abovemidtex = open.abovemidtex; tm.thing->BlockingLine = ld; } else if (open.bottom == tm.floorz) { tm.touchmidtex |= open.touchmidtex; + tm.abovemidtex |= open.abovemidtex; } if (open.lowfloor < tm.dropoffz) @@ -1258,6 +1269,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm) tm.ceilingpic = newsec->GetTexture(sector_t::ceiling); tm.ceilingsector = newsec; tm.touchmidtex = false; + tm.abovemidtex = false; //Added by MC: Fill the tmsector. tm.sector = newsec; @@ -2864,7 +2876,8 @@ bool aim_t::AimTraverse3DFloors(const divline_t &trace, intercept_t * in) nextsector=NULL; nexttopplane=nextbottomplane=NULL; - if(li->frontsector->e->XFloor.ffloors.Size() || li->backsector->e->XFloor.ffloors.Size()) + if (li->backsector == NULL) return true; // shouldn't really happen but crashed once for me... + if (li->frontsector->e->XFloor.ffloors.Size() || li->backsector->e->XFloor.ffloors.Size()) { int frontflag; F3DFloor* rover; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 9f4ddb39a0..187de226d7 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -212,9 +212,9 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, if (actor != NULL && linedef->frontsector != NULL && linedef->backsector != NULL && linedef->flags & ML_3DMIDTEX) { - open.touchmidtex = P_LineOpening_3dMidtex(actor, linedef, open.top, open.bottom); + open.touchmidtex = P_LineOpening_3dMidtex(actor, linedef, open.top, open.bottom, &open.abovemidtex); } - else open.touchmidtex = false; + else open.abovemidtex = open.touchmidtex = false; open.range = open.top - open.bottom; }