- Changed: P_TeleportMove now always sets BlockingLine to NULL and

P_FindFloorCeiling doesn't set it at all. The way it was set in 
  PIT_FindFloorCeiling didn't look correct.
- 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.


SVN r891 (trunk)
This commit is contained in:
Christoph Oelckers 2008-04-08 10:47:28 +00:00
parent 4dc1b9579e
commit 17816dcadd
4 changed files with 88 additions and 82 deletions

View file

@ -1,4 +1,11 @@
April 8, 2008 (Changes by Graf Zahl) 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 - 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 Chaos Device. This sound is not defined by the other games so it won't
play by default. play by default.

View file

@ -314,6 +314,28 @@ AActor *P_RoughMonsterSearch (AActor *mo, int distance);
// P_MAP // 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 "floatok" true, move would be ok
// if within "tmfloorz - tmceilingz". // if within "tmfloorz - tmceilingz".
extern bool floatok; extern bool floatok;
@ -324,15 +346,6 @@ extern AActor *BlockingMobj;
extern line_t *BlockingLine; // Used only by P_Move extern line_t *BlockingLine; // Used only by P_Move
// This is not necessarily a *blocking* line // 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 //Added by MC: tmsectortype
extern fixed_t tmdropoffz; //Needed in b_move.c extern fixed_t tmdropoffz; //Needed in b_move.c
extern sector_t *tmsector; 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_ResetSightCounters (bool full);
void P_UseLines (player_t* player); void P_UseLines (player_t* player);
bool P_UsePuzzleItem (AActor *actor, int itemType); bool P_UsePuzzleItem (AActor *actor, int itemType);
void PIT_ThrustSpike (AActor *actor);
void P_FindFloorCeiling (AActor *actor); void P_FindFloorCeiling (AActor *actor);
bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset);

View file

@ -95,14 +95,6 @@ int tmceilingpic;
sector_t *tmceilingsector; sector_t *tmceilingsector;
bool tmtouchmidtex; 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. //Added by MC: So bot will know what kind of sector it's entering.
sector_t* tmsector; sector_t* tmsector;
@ -123,9 +115,6 @@ AActor *BlockingMobj;
// Temporary holder for thing_sectorlist threads // Temporary holder for thing_sectorlist threads
msecnode_t* sector_list = NULL; // phares 3/16/98 msecnode_t* sector_list = NULL; // phares 3/16/98
extern sector_t *openbottomsec;
extern sector_t *opentopsec;
bool DoRipping; bool DoRipping;
AActor *LastRipped; 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] if (box.Right() <= ld->bbox[BOXLEFT]
|| box.Left() >= ld->bbox[BOXRIGHT] || 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->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) |
(ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) (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 else
{ // Find the point on the line closest to the actor's center, and use { // Find the point on the line closest to the actor's center, and use
// that to calculate openings // that to calculate openings
float dx = (float)ld->dx; float dx = (float)ld->dx;
float dy = (float)ld->dy; float dy = (float)ld->dy;
fixed_t r = (fixed_t)(((float)(x - ld->v1->x) * dx + fixed_t r = (fixed_t)(((float)(tmf.x - ld->v1->x) * dx +
(float)(y - ld->v1->y) * dy) / (float)(tmf.y - ld->v1->y) * dy) /
(dx*dx + dy*dy) * 16777216.f); (dx*dx + dy*dy) * 16777216.f);
if (r <= 0) 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)) 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 else
{ {
P_LineOpening (open, tmfthing, ld, sx=ld->v1->x + MulScale24 (r, ld->dx), P_LineOpening (open, tmf.thing, ld, sx=ld->v1->x + MulScale24 (r, ld->dx),
sy=ld->v1->y + MulScale24 (r, ld->dy), x, y); sy=ld->v1->y + MulScale24 (r, ld->dy), tmf.x, tmf.y);
} }
} }
// adjust floor / ceiling heights // adjust floor / ceiling heights
if (open.top < tmfceilingz) if (open.top < tmf.ceilingz)
{ {
tmfceilingz = open.top; tmf.ceilingz = open.top;
BlockingLine = ld;
} }
if (open.bottom > tmffloorz) if (open.bottom > tmf.floorz)
{ {
tmffloorz = open.bottom; tmf.floorz = open.bottom;
tmffloorsector = open.bottomsec; tmf.floorsector = open.bottomsec;
tmftouchmidtex = open.touchmidtex; tmf.touchmidtex = open.touchmidtex;
BlockingLine = ld;
} }
if (open.lowfloor < tmfdropoffz) if (open.lowfloor < tmf.dropoffz)
tmfdropoffz = open.lowfloor; tmf.dropoffz = open.lowfloor;
return true; return true;
} }
@ -216,21 +203,22 @@ static bool PIT_FindFloorCeiling (line_t *ld, AActor *tmfthing, const FBoundingB
void P_FindFloorCeiling (AActor *actor) void P_FindFloorCeiling (AActor *actor)
{ {
fixed_t x, y;
sector_t *sec; sector_t *sec;
FCheckPosition tmf;
x = actor->x; tmf.x = actor->x;
y = actor->y; tmf.y = actor->y;
FBoundingBox box(x, y, actor->radius); FBoundingBox box(tmf.x, tmf.y, actor->radius);
sec = P_PointInSector (x, y); sec = P_PointInSector (tmf.x, tmf.y);
tmffloorz = tmfdropoffz = sec->floorplane.ZatPoint (x, y); tmf.thing = actor;
tmfceilingz = sec->ceilingplane.ZatPoint (x, y); tmf.floorz = tmf.dropoffz = sec->floorplane.ZatPoint (tmf.x, tmf.y);
tmffloorpic = sec->floorpic; tmf.ceilingz = sec->ceilingplane.ZatPoint (tmf.x, tmf.y);
tmffloorsector = sec; tmf.floorpic = sec->floorpic;
tmfceilingpic = sec->ceilingpic; tmf.floorsector = sec;
tmfceilingsector = sec; tmf.ceilingpic = sec->ceilingpic;
tmf.ceilingsector = sec;
validcount++; validcount++;
FBlockLinesIterator it(box); FBlockLinesIterator it(box);
@ -238,10 +226,18 @@ void P_FindFloorCeiling (AActor *actor)
while ((ld = it.Next())) 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. // 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) bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag)
{ {
FCheckPosition tmf;
sector_t* newsec; sector_t* newsec;
// kill anything occupying the position // 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. // The base floor/ceiling is from the subsector that contains the point.
// Any contacted lines the step closer together will adjust them. // Any contacted lines the step closer together will adjust them.
tmffloorz = tmfdropoffz = newsec->floorplane.ZatPoint (x, y); tmf.thing = thing;
tmfceilingz = newsec->ceilingplane.ZatPoint (x, y); tmf.x = x;
tmffloorpic = newsec->floorpic; tmf.y = y;
tmffloorsector = newsec; tmf.z = z;
tmfceilingpic = newsec->ceilingpic; tmf.floorz = tmf.dropoffz = newsec->floorplane.ZatPoint (x, y);
tmfceilingsector = newsec; tmf.ceilingz = newsec->ceilingplane.ZatPoint (x, y);
tmf.floorpic = newsec->floorpic;
tmf.floorsector = newsec;
tmf.ceilingpic = newsec->ceilingpic;
tmf.ceilingsector = newsec;
spechit.Clear (); 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())) while ((ld = it.Next()))
{ {
PIT_FindFloorCeiling(ld, thing, box, x, y); PIT_FindFloorCeiling(ld, box, tmf);
} }
if (tmftouchmidtex) tmfdropoffz = tmffloorz; if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz;
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;
FRadiusThingsIterator it2(x, y, thing->radius); FRadiusThingsIterator it2(x, y, thing->radius);
AActor *th; 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 // the move is ok, so link the thing into its new position
thing->SetOrigin (x, y, z); thing->SetOrigin (x, y, z);
thing->floorz = savefloorz; thing->floorz = tmf.floorz;
thing->ceilingz = saveceilingz; thing->ceilingz = tmf.ceilingz;
thing->floorsector = savesector; thing->floorsector = tmf.floorsector;
thing->floorpic = savepic; thing->floorpic = tmf.floorpic;
thing->ceilingsector = savecsector; thing->ceilingsector = tmf.ceilingsector;
thing->ceilingpic = savecpic; thing->ceilingpic = tmf.ceilingpic;
thing->dropoffz = savedropoff; // killough 11/98 thing->dropoffz = tmf.dropoffz; // killough 11/98
BlockingLine = NULL;
if (thing->flags2 & MF2_FLOORCLIP) if (thing->flags2 & MF2_FLOORCLIP)
{ {

View file

@ -3252,13 +3252,6 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t
else if (!(actor->flags5 & MF5_NOINTERACTION)) else if (!(actor->flags5 & MF5_NOINTERACTION))
{ {
P_FindFloorCeiling (actor); 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 else
{ {