From 35cc39f0944d3d31d542f34fcf5ed1d30454f721 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 7 Jan 2009 18:45:39 +0000 Subject: [PATCH] - copied some 3D floor fixes from GZDoom. - fixed: Crushing polyobject did incomplete checks for blocked moves. SVN r1355 (trunk) --- docs/rh-log.txt | 4 ++ src/d_main.cpp | 28 ++++++------- src/p_local.h | 1 + src/p_map.cpp | 91 ++++++++++++++++++++++++++++++++++++++++--- src/po_man.cpp | 2 +- src/r_interpolate.cpp | 2 + 6 files changed, 108 insertions(+), 20 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index b2269ee37..3324bd0ab 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +January 7, 2009 (Changes by Graf Zahl) +- copied some 3D floor fixes from GZDoom. +- fixed: Crushing polyobject did incomplete checks for blocked moves. + January 5, 2009 (Changes by Graf Zahl) - fixed: Parsing of color strings with 6 characters and spaces did not work. - fixed: State labels must be evaluated for the state's owner, not the calling actor. diff --git a/src/d_main.cpp b/src/d_main.cpp index 5cf9692d5..fd6a22085 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1562,7 +1562,20 @@ static EIWADType ScanIWAD (const char *iwad) } else if (lumpsfound[Check_map01]) { - if (lumpsfound[Check_redtnt2]) + if (lumpsfound[Check_FreeDoom]) + { + // Is there a 100% reliable way to tell FreeDoom and FreeDM + // apart based solely on the lump names? + if (strstr(iwad, "freedm.wad") || strstr(iwad, "FREEDM.WAD")) + { + return IWAD_FreeDM; + } + else + { + return IWAD_FreeDoom; + } + } + else if (lumpsfound[Check_redtnt2]) { return IWAD_Doom2TNT; } @@ -1583,19 +1596,6 @@ static EIWADType ScanIWAD (const char *iwad) return IWAD_HexenDemo; } } - else if (lumpsfound[Check_FreeDoom]) - { - // Is there a 100% reliable way to tell FreeDoom and FreeDM - // apart based solely on the lump names? - if (strstr(iwad, "freedm.wad") || strstr(iwad, "FREEDM.WAD")) - { - return IWAD_FreeDM; - } - else - { - return IWAD_FreeDoom; - } - } else { return IWAD_Doom2; diff --git a/src/p_local.h b/src/p_local.h index 31d5ee79e..4624fd012 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -368,6 +368,7 @@ AActor *P_CheckOnmobj (AActor *thing); void P_FakeZMovement (AActor *mo); bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, bool dropoff, const secplane_t * onfloor, FCheckPosition &tm); bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, bool dropoff, const secplane_t * onfloor = NULL); +bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y); bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag); // [RH] Added z and telefrag parameters void P_PlayerStartStomp (AActor *actor); // [RH] Stomp on things for a newly spawned player void P_SlideMove (AActor* mo, fixed_t tryx, fixed_t tryy, int numsteps); diff --git a/src/p_map.cpp b/src/p_map.cpp index 9e3b79dae..9db494b6f 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -220,12 +220,9 @@ void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos) fixed_t ff_bottom=rover->bottom.plane->ZatPoint(actor->x, actor->y); fixed_t ff_top=rover->top.plane->ZatPoint(actor->x, actor->y); - - fixed_t delta1 = actor->z - (ff_bottom + ((ff_top-ff_bottom)/2)); - fixed_t delta2 = actor->z + (actor->height? actor->height:1) - (ff_bottom + ((ff_top-ff_bottom)/2)); - if (ff_top > actor->floorz && abs(delta1) < abs(delta2)) actor->floorz = ff_top; - if (ff_bottom < actor->ceilingz && abs(delta1) >= abs(delta2)) actor->ceilingz = ff_bottom; + if (ff_top > actor->floorz && ff_top < actor->z) actor->floorz = ff_top; + if (ff_bottom < actor->ceilingz && ff_bottom > actor->z + actor->height) actor->ceilingz = ff_bottom; } } #endif @@ -1773,6 +1770,90 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, +// +// P_CheckMove +// Similar to P_TryMove but doesn't actually move the actor. Used for polyobject crushing +// + +bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) +{ + FCheckPosition tm; + fixed_t newz = thing->z; + int side; + int oldside; + line_t* ld; + sector_t* oldsec = thing->Sector; // [RH] for sector actions + sector_t* newsec; + + if (!P_CheckPosition (thing, x, y, tm)) + { + return false; + } + + if (thing->flags3 & MF3_FLOORHUGGER) + { + newz = tm.floorz; + } + else if (thing->flags3 & MF3_CEILINGHUGGER) + { + newz = tm.ceilingz - thing->height; + } + + if (!(thing->flags & MF_NOCLIP)) + { + if (tm.ceilingz - tm.floorz < thing->height) + { + return false; + } + + if (!(thing->flags & MF_TELEPORT) + && tm.ceilingz - newz < thing->height + && !(thing->flags3 & MF3_CEILINGHUGGER) + && (!(thing->flags2 & MF2_FLY) || !(thing->flags & MF_NOGRAVITY))) + { + return false; + } + if (thing->flags2 & MF2_FLY && thing->flags & MF_NOGRAVITY) + { + if (thing->z+thing->height > tm.ceilingz) + return false; + } + if (!(thing->flags & MF_TELEPORT) && !(thing->flags3 & MF3_FLOORHUGGER)) + { + if (tm.floorz-newz > thing->MaxStepHeight) + { // too big a step up + return false; + } + else if ((thing->flags & MF_MISSILE) && tm.floorz > newz) + { // [RH] Don't let normal missiles climb steps + return false; + } + else if (newz < tm.floorz) + { // [RH] Check to make sure there's nothing in the way for the step up + fixed_t savedz = thing->z; + thing->z = newz = tm.floorz; + bool good = P_TestMobjZ (thing); + thing->z = savedz; + if (!good) + { + return false; + } + } + } + + if (thing->flags2 & MF2_CANTLEAVEFLOORPIC + && (tm.floorpic != thing->floorpic + || tm.floorz - newz != 0)) + { // must stay within a sector of a certain floor type + return false; + } + } + + return true; +} + + + // // SLIDE MOVE // Allows the player to slide along any angled walls. diff --git a/src/po_man.cpp b/src/po_man.cpp index 6a090b475..5277fc8bd 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -774,7 +774,7 @@ void ThrustMobj (AActor *actor, seg_t *seg, FPolyObj *po) actor->momy += thrustY; if (po->crush) { - if (po->bHurtOnTouch || !P_CheckPosition (actor, actor->x + thrustX, actor->y + thrustY)) + if (po->bHurtOnTouch || !P_CheckMove (actor, actor->x + thrustX, actor->y + thrustY)) { P_DamageMobj (actor, NULL, NULL, po->crush, NAME_Crush); P_TraceBleed (po->crush, actor); diff --git a/src/r_interpolate.cpp b/src/r_interpolate.cpp index 532737c91..238793981 100644 --- a/src/r_interpolate.cpp +++ b/src/r_interpolate.cpp @@ -456,6 +456,7 @@ void DSectorPlaneInterpolation::Restore() sector->ceilingplane.d = bakheight; sector->SetPlaneTexZ(sector_t::ceiling, baktexz); } + P_RecalculateAttached3DFloors(sector); } //========================================================================== @@ -485,6 +486,7 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio) *pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio); sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio)); + P_RecalculateAttached3DFloors(sector); } //==========================================================================