diff --git a/docs/rh-log.txt b/docs/rh-log.txt index a43bcc46cc..351f74ff43 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,11 @@ April 8, 2008 (Changes by Graf Zahl) +- Changed P_FindFloorCeiling so that it doesn't need global variables + anymore. I also moved the code to set the calling actor's information + into this function because that's all it is used for. This also fixes + another bug: +- AInventory::BecomePickup called P_FindFloorCeiling to get + proper position values for the item but never set the item's information + to the return value of this call. - Removed the check for Heretic when playing *evillaugh when using the Chaos Device. This sound is not defined by the other games so it won't play by default. diff --git a/src/p_local.h b/src/p_local.h index 22d7bda8f3..7be09824bf 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -314,6 +314,28 @@ AActor *P_RoughMonsterSearch (AActor *mo, int distance); // P_MAP // +struct FCheckPosition +{ + // in + AActor *thing; + fixed_t x; + fixed_t y; + fixed_t z; + + // out + sector_t *sector; + fixed_t floorz; + fixed_t ceilingz; + fixed_t dropoffz; + fixed_t floorpic; + sector_t *floorsector; + fixed_t ceilingpic; + sector_t *ceilingsector; + bool touchmidtex; +}; + + + // If "floatok" true, move would be ok // if within "tmfloorz - tmceilingz". extern bool floatok; @@ -324,15 +346,6 @@ extern AActor *BlockingMobj; extern line_t *BlockingLine; // Used only by P_Move // This is not necessarily a *blocking* line -// For P_FindFloorCeiling -extern fixed_t tmffloorz, tmfceilingz; -extern fixed_t tmfdropoffz; -extern fixed_t tmffloorpic; -extern sector_t *tmffloorsector; -extern fixed_t tmfceilingpic; -extern sector_t *tmfceilingsector; - - //Added by MC: tmsectortype extern fixed_t tmdropoffz; //Needed in b_move.c extern sector_t *tmsector; @@ -360,7 +373,6 @@ bool P_CheckSight (const AActor* t1, const AActor* t2, int flags=0); void P_ResetSightCounters (bool full); void P_UseLines (player_t* player); bool P_UsePuzzleItem (AActor *actor, int itemType); -void PIT_ThrustSpike (AActor *actor); void P_FindFloorCeiling (AActor *actor); bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); diff --git a/src/p_map.cpp b/src/p_map.cpp index 025f466e31..fe891b0eb7 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -95,14 +95,6 @@ int tmceilingpic; sector_t *tmceilingsector; bool tmtouchmidtex; -fixed_t tmffloorz; -fixed_t tmfceilingz; -fixed_t tmfdropoffz; -fixed_t tmffloorpic; -sector_t *tmffloorsector; -fixed_t tmfceilingpic; -sector_t *tmfceilingsector; -bool tmftouchmidtex; //Added by MC: So bot will know what kind of sector it's entering. sector_t* tmsector; @@ -123,9 +115,6 @@ AActor *BlockingMobj; // Temporary holder for thing_sectorlist threads msecnode_t* sector_list = NULL; // phares 3/16/98 -extern sector_t *openbottomsec; -extern sector_t *opentopsec; - bool DoRipping; AActor *LastRipped; @@ -135,7 +124,7 @@ AActor *LastRipped; // //========================================================================== -static bool PIT_FindFloorCeiling (line_t *ld, AActor *tmfthing, const FBoundingBox &box, fixed_t x, fixed_t y) +static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPosition &tmf) { if (box.Right() <= ld->bbox[BOXLEFT] || box.Left() >= ld->bbox[BOXRIGHT] @@ -162,48 +151,46 @@ static bool PIT_FindFloorCeiling (line_t *ld, AActor *tmfthing, const FBoundingB (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) { - P_LineOpening (open, tmfthing, ld, sx=x, sy=y, x, y); + P_LineOpening (open, tmf.thing, ld, sx=tmf.x, sy=tmf.y, tmf.x, tmf.y); } else { // Find the point on the line closest to the actor's center, and use // that to calculate openings float dx = (float)ld->dx; float dy = (float)ld->dy; - fixed_t r = (fixed_t)(((float)(x - ld->v1->x) * dx + - (float)(y - ld->v1->y) * dy) / + fixed_t r = (fixed_t)(((float)(tmf.x - ld->v1->x) * dx + + (float)(tmf.y - ld->v1->y) * dy) / (dx*dx + dy*dy) * 16777216.f); if (r <= 0) { - P_LineOpening (open, tmfthing, ld, sx=ld->v1->x, sy=ld->v1->y, x, y); + P_LineOpening (open, tmf.thing, ld, sx=ld->v1->x, sy=ld->v1->y, tmf.x, tmf.y); } else if (r >= (1<<24)) { - P_LineOpening (open, tmfthing, ld, sx=ld->v2->x, sy=ld->v2->y, tmfthing->x, tmfthing->y); + P_LineOpening (open, tmf.thing, ld, sx=ld->v2->x, sy=ld->v2->y, tmf.thing->x, tmf.thing->y); } else { - P_LineOpening (open, tmfthing, ld, sx=ld->v1->x + MulScale24 (r, ld->dx), - sy=ld->v1->y + MulScale24 (r, ld->dy), x, y); + P_LineOpening (open, tmf.thing, ld, sx=ld->v1->x + MulScale24 (r, ld->dx), + sy=ld->v1->y + MulScale24 (r, ld->dy), tmf.x, tmf.y); } } // adjust floor / ceiling heights - if (open.top < tmfceilingz) + if (open.top < tmf.ceilingz) { - tmfceilingz = open.top; - BlockingLine = ld; + tmf.ceilingz = open.top; } - if (open.bottom > tmffloorz) + if (open.bottom > tmf.floorz) { - tmffloorz = open.bottom; - tmffloorsector = open.bottomsec; - tmftouchmidtex = open.touchmidtex; - BlockingLine = ld; + tmf.floorz = open.bottom; + tmf.floorsector = open.bottomsec; + tmf.touchmidtex = open.touchmidtex; } - if (open.lowfloor < tmfdropoffz) - tmfdropoffz = open.lowfloor; + if (open.lowfloor < tmf.dropoffz) + tmf.dropoffz = open.lowfloor; return true; } @@ -216,21 +203,22 @@ static bool PIT_FindFloorCeiling (line_t *ld, AActor *tmfthing, const FBoundingB void P_FindFloorCeiling (AActor *actor) { - fixed_t x, y; sector_t *sec; + FCheckPosition tmf; - x = actor->x; - y = actor->y; + tmf.x = actor->x; + tmf.y = actor->y; - FBoundingBox box(x, y, actor->radius); + FBoundingBox box(tmf.x, tmf.y, actor->radius); - sec = P_PointInSector (x, y); - tmffloorz = tmfdropoffz = sec->floorplane.ZatPoint (x, y); - tmfceilingz = sec->ceilingplane.ZatPoint (x, y); - tmffloorpic = sec->floorpic; - tmffloorsector = sec; - tmfceilingpic = sec->ceilingpic; - tmfceilingsector = sec; + sec = P_PointInSector (tmf.x, tmf.y); + tmf.thing = actor; + tmf.floorz = tmf.dropoffz = sec->floorplane.ZatPoint (tmf.x, tmf.y); + tmf.ceilingz = sec->ceilingplane.ZatPoint (tmf.x, tmf.y); + tmf.floorpic = sec->floorpic; + tmf.floorsector = sec; + tmf.ceilingpic = sec->ceilingpic; + tmf.ceilingsector = sec; validcount++; FBlockLinesIterator it(box); @@ -238,10 +226,18 @@ void P_FindFloorCeiling (AActor *actor) while ((ld = it.Next())) { - PIT_FindFloorCeiling(ld, actor, box, x, y); + PIT_FindFloorCeiling(ld, box, tmf); } - if (tmftouchmidtex) tmfdropoffz = tmffloorz; + if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; + + actor->floorz = tmf.floorz; + actor->dropoffz = tmf.dropoffz; + actor->ceilingz = tmf.ceilingz; + actor->floorpic = tmf.floorpic; + actor->floorsector = tmf.floorsector; + actor->ceilingpic = tmf.ceilingpic; + actor->ceilingsector = tmf.ceilingsector; } // @@ -259,6 +255,7 @@ void P_FindFloorCeiling (AActor *actor) // was being teleported between two non-overlapping height ranges. bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag) { + FCheckPosition tmf; sector_t* newsec; // kill anything occupying the position @@ -268,12 +265,16 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr // The base floor/ceiling is from the subsector that contains the point. // Any contacted lines the step closer together will adjust them. - tmffloorz = tmfdropoffz = newsec->floorplane.ZatPoint (x, y); - tmfceilingz = newsec->ceilingplane.ZatPoint (x, y); - tmffloorpic = newsec->floorpic; - tmffloorsector = newsec; - tmfceilingpic = newsec->ceilingpic; - tmfceilingsector = newsec; + tmf.thing = thing; + tmf.x = x; + tmf.y = y; + tmf.z = z; + tmf.floorz = tmf.dropoffz = newsec->floorplane.ZatPoint (x, y); + tmf.ceilingz = newsec->ceilingplane.ZatPoint (x, y); + tmf.floorpic = newsec->floorpic; + tmf.floorsector = newsec; + tmf.ceilingpic = newsec->ceilingpic; + tmf.ceilingsector = newsec; spechit.Clear (); @@ -285,18 +286,10 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr while ((ld = it.Next())) { - PIT_FindFloorCeiling(ld, thing, box, x, y); + PIT_FindFloorCeiling(ld, box, tmf); } - if (tmftouchmidtex) tmfdropoffz = tmffloorz; - - fixed_t savefloorz = tmffloorz; - fixed_t saveceilingz = tmfceilingz; - sector_t *savesector = tmffloorsector; - int savepic = tmffloorpic; - sector_t *savecsector = tmffloorsector; - int savecpic = tmffloorpic; - fixed_t savedropoff = tmfdropoffz; + if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; FRadiusThingsIterator it2(x, y, thing->radius); AActor *th; @@ -335,13 +328,14 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr // the move is ok, so link the thing into its new position thing->SetOrigin (x, y, z); - thing->floorz = savefloorz; - thing->ceilingz = saveceilingz; - thing->floorsector = savesector; - thing->floorpic = savepic; - thing->ceilingsector = savecsector; - thing->ceilingpic = savecpic; - thing->dropoffz = savedropoff; // killough 11/98 + thing->floorz = tmf.floorz; + thing->ceilingz = tmf.ceilingz; + thing->floorsector = tmf.floorsector; + thing->floorpic = tmf.floorpic; + thing->ceilingsector = tmf.ceilingsector; + thing->ceilingpic = tmf.ceilingpic; + thing->dropoffz = tmf.dropoffz; // killough 11/98 + BlockingLine = NULL; if (thing->flags2 & MF2_FLOORCLIP) { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 493662c60b..9f1845ac19 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3252,13 +3252,6 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t else if (!(actor->flags5 & MF5_NOINTERACTION)) { P_FindFloorCeiling (actor); - actor->floorz = tmffloorz; - actor->dropoffz = tmfdropoffz; - actor->ceilingz = tmfceilingz; - actor->floorpic = tmffloorpic; - actor->floorsector = tmffloorsector; - actor->ceilingpic = tmfceilingpic; - actor->ceilingsector = tmfceilingsector; } else {