ref: e81e9d80c45f6ec0698adfbc77b10e37df8c4c26
parent: 725090a6ac3b526560082681e3329effd800bd5b
author: James Haley <[email protected]>
date: Fri Feb 4 20:23:54 EST 2011
Finished second passes through p_map and p_maputl - modules are largely finalized. Fixes/additions include adjusted dropoff height in P_TryMove, order-of-evaluation fix in PIT_ChangeSector, proper spechit overrun emulation, and Rogue's fix which prevents intercepts overflows. Subversion-branch: /branches/strife-branch Subversion-revision: 2247
--- a/src/strife/p_map.c
+++ b/src/strife/p_map.c
@@ -123,7 +123,7 @@
//
boolean PIT_StompThing (mobj_t* thing)
{
- fixed_t blockdist;
+ fixed_t blockdist;
if (!(thing->flags & MF_SHOOTABLE) )
return true;
@@ -146,7 +146,7 @@
// Monsters can telefrag players, and players can telefrag monsters, but
// monsters cannot telefrag other monsters.
if (!(tmthing->player || thing->player))
- return false;
+ return false;
P_DamageMobj (thing, tmthing, tmthing, 10000);
@@ -212,7 +212,7 @@
P_UnsetThingPosition (thing);
thing->floorz = tmfloorz;
- thing->ceilingz = tmceilingz;
+ thing->ceilingz = tmceilingz;
thing->x = x;
thing->y = y;
thing->z = tmfloorz; // haleyjd 09/15/10: [STRIFE] Rogue added a z-set here
@@ -451,17 +451,17 @@
//
boolean
P_CheckPosition
-( mobj_t* thing,
- fixed_t x,
- fixed_t y )
+( mobj_t* thing,
+ fixed_t x,
+ fixed_t y )
{
- int xl;
- int xh;
- int yl;
- int yh;
- int bx;
- int by;
- subsector_t* newsubsec;
+ int xl;
+ int xh;
+ int yl;
+ int yh;
+ int bx;
+ int by;
+ subsector_t* newsubsec;
tmthing = thing;
tmflags = thing->flags;
@@ -534,26 +534,26 @@
fixed_t x,
fixed_t y )
{
- fixed_t oldx;
- fixed_t oldy;
- int side;
- int oldside;
- line_t* ld;
+ fixed_t oldx;
+ fixed_t oldy;
+ int side;
+ int oldside;
+ line_t* ld;
floatok = false;
if (!P_CheckPosition (thing, x, y))
- return false; // solid wall or thing
+ return false; // solid wall or thing
if ( !(thing->flags & MF_NOCLIP) )
{
if (tmceilingz - tmfloorz < thing->height)
- return false; // doesn't fit
+ return false; // doesn't fit
floatok = true;
// villsa [STRIFE] Removed MF_TELEPORT
if (tmceilingz - thing->z < thing->height)
- return false; // mobj must lower itself to fit
+ return false; // mobj must lower itself to fit
// villsa [STRIFE] non-robots are limited to 16 unit step height
if ((thing->flags & MF_NOBLOOD) == 0 && tmfloorz - thing->z > (16*FRACUNIT))
@@ -562,12 +562,13 @@
return false; // too big a step up
// villsa [STRIFE] special case for missiles
- if(thing->flags & MF_MISSILE && tmfloorz - thing->z > (4*FRACUNIT))
+ if((thing->flags & MF_MISSILE) && tmfloorz - thing->z > 4*FRACUNIT)
return false;
+ // haleyjd 20110204 [STRIFE]: dropoff height changed 24 -> 32
if ( !(thing->flags&(MF_DROPOFF|MF_FLOAT))
- && tmfloorz - tmdropoffz > 24*FRACUNIT )
- return false; // don't stand over a dropoff
+ && tmfloorz - tmdropoffz > 32*FRACUNIT )
+ return false; // don't stand over a dropoff
}
// the move is ok,
@@ -577,7 +578,7 @@
oldx = thing->x;
oldy = thing->y;
thing->floorz = tmfloorz;
- thing->ceilingz = tmceilingz;
+ thing->ceilingz = tmceilingz;
thing->x = x;
thing->y = y;
@@ -605,10 +606,10 @@
//
// P_CheckPositionZ
+//
// villsa [STRIFE] new function
-// Check colliding things on top of one another
+// Check colliding things on top of one another; ie., 3D Object Clipping
//
-
boolean P_CheckPositionZ(mobj_t* thing, fixed_t height)
{
fixed_t x;
@@ -665,12 +666,12 @@
for(bx = xl; bx <= xh; bx++)
{
- for(by = yl; by <= yh; by++)
+ for(by = yl; by <= yh; by++)
{
- if(!P_BlockThingsIterator(bx, by,PIT_CheckThing))
+ if(!P_BlockThingsIterator(bx, by, PIT_CheckThing))
{
tmthing->z = z;
- return false;
+ return false;
}
}
}
@@ -689,33 +690,35 @@
// the z will be set to the lowest value
// and false will be returned.
//
+// [STRIFE] Verified unmodified
+//
boolean P_ThingHeightClip (mobj_t* thing)
{
- boolean onfloor;
-
+ boolean onfloor;
+
onfloor = (thing->z == thing->floorz);
-
- P_CheckPosition (thing, thing->x, thing->y);
+
+ P_CheckPosition (thing, thing->x, thing->y);
// what about stranding a monster partially off an edge?
-
+
thing->floorz = tmfloorz;
thing->ceilingz = tmceilingz;
-
+
if (onfloor)
{
- // walking monsters rise and fall with the floor
- thing->z = thing->floorz;
+ // walking monsters rise and fall with the floor
+ thing->z = thing->floorz;
}
else
{
- // don't adjust a floating monster unless forced to
- if (thing->z+thing->height > thing->ceilingz)
- thing->z = thing->ceilingz - thing->height;
+ // don't adjust a floating monster unless forced to
+ if (thing->z+thing->height > thing->ceilingz)
+ thing->z = thing->ceilingz - thing->height;
}
-
+
if (thing->ceilingz - thing->floorz < thing->height)
- return false;
-
+ return false;
+
return true;
}
@@ -743,47 +746,49 @@
// Adjusts the xmove / ymove
// so that the next move will slide along the wall.
//
+// [STRIFE] Verified unmodified
+//
void P_HitSlideLine (line_t* ld)
{
- int side;
+ int side;
- angle_t lineangle;
- angle_t moveangle;
- angle_t deltaangle;
-
- fixed_t movelen;
- fixed_t newlen;
-
-
+ angle_t lineangle;
+ angle_t moveangle;
+ angle_t deltaangle;
+
+ fixed_t movelen;
+ fixed_t newlen;
+
+
if (ld->slopetype == ST_HORIZONTAL)
{
- tmymove = 0;
- return;
+ tmymove = 0;
+ return;
}
-
+
if (ld->slopetype == ST_VERTICAL)
{
- tmxmove = 0;
- return;
+ tmxmove = 0;
+ return;
}
-
+
side = P_PointOnLineSide (slidemo->x, slidemo->y, ld);
-
+
lineangle = R_PointToAngle2 (0,0, ld->dx, ld->dy);
if (side == 1)
- lineangle += ANG180;
+ lineangle += ANG180;
moveangle = R_PointToAngle2 (0,0, tmxmove, tmymove);
deltaangle = moveangle-lineangle;
if (deltaangle > ANG180)
- deltaangle += ANG180;
- // I_Error ("SlideLine: ang>ANG180");
+ deltaangle += ANG180;
+ // I_Error ("SlideLine: ang>ANG180");
lineangle >>= ANGLETOFINESHIFT;
deltaangle >>= ANGLETOFINESHIFT;
-
+
movelen = P_AproxDistance (tmxmove, tmymove);
newlen = FixedMul (movelen, finecosine[deltaangle]);
@@ -795,53 +800,55 @@
//
// PTR_SlideTraverse
//
+// [STRIFE] Modified for smaller step-up height
+//
boolean PTR_SlideTraverse (intercept_t* in)
{
- line_t* li;
-
+ line_t* li;
+
if (!in->isaline)
- I_Error ("PTR_SlideTraverse: not a line?");
-
+ I_Error ("PTR_SlideTraverse: not a line?");
+
li = in->d.line;
-
+
if ( ! (li->flags & ML_TWOSIDED) )
{
- if (P_PointOnLineSide (slidemo->x, slidemo->y, li))
- {
- // don't hit the back side
- return true;
- }
- goto isblocking;
+ if (P_PointOnLineSide (slidemo->x, slidemo->y, li))
+ {
+ // don't hit the back side
+ return true;
+ }
+ goto isblocking;
}
// set openrange, opentop, openbottom
P_LineOpening (li);
-
+
if (openrange < slidemo->height)
- goto isblocking; // doesn't fit
-
+ goto isblocking; // doesn't fit
+
if (opentop - slidemo->z < slidemo->height)
- goto isblocking; // mobj is too high
+ goto isblocking; // mobj is too high
// villsa [STRIFE] change from 24 to 16
if (openbottom - slidemo->z > 16*FRACUNIT )
- goto isblocking; // too big a step up
+ goto isblocking; // too big a step up
// this line doesn't block movement
- return true;
-
+ return true;
+
// the line does block movement,
// see if it is closer than best so far
- isblocking:
+isblocking:
if (in->frac < bestslidefrac)
{
- secondslidefrac = bestslidefrac;
- secondslideline = bestslideline;
- bestslidefrac = in->frac;
- bestslideline = li;
+ secondslidefrac = bestslidefrac;
+ secondslideline = bestslideline;
+ bestslidefrac = in->frac;
+ bestslideline = li;
}
-
- return false; // stop
+
+ return false; // stop
}
@@ -855,98 +862,99 @@
//
// This is a kludgy mess.
//
+// [STRIFE] Verified unmodified
+//
void P_SlideMove (mobj_t* mo)
{
- fixed_t leadx;
- fixed_t leady;
- fixed_t trailx;
- fixed_t traily;
- fixed_t newx;
- fixed_t newy;
- int hitcount;
-
+ fixed_t leadx;
+ fixed_t leady;
+ fixed_t trailx;
+ fixed_t traily;
+ fixed_t newx;
+ fixed_t newy;
+ int hitcount;
+
slidemo = mo;
hitcount = 0;
- retry:
+retry:
if (++hitcount == 3)
- goto stairstep; // don't loop forever
+ goto stairstep; // don't loop forever
-
// trace along the three leading corners
if (mo->momx > 0)
{
- leadx = mo->x + mo->radius;
- trailx = mo->x - mo->radius;
+ leadx = mo->x + mo->radius;
+ trailx = mo->x - mo->radius;
}
else
{
- leadx = mo->x - mo->radius;
- trailx = mo->x + mo->radius;
+ leadx = mo->x - mo->radius;
+ trailx = mo->x + mo->radius;
}
-
+
if (mo->momy > 0)
{
- leady = mo->y + mo->radius;
- traily = mo->y - mo->radius;
+ leady = mo->y + mo->radius;
+ traily = mo->y - mo->radius;
}
else
{
- leady = mo->y - mo->radius;
- traily = mo->y + mo->radius;
+ leady = mo->y - mo->radius;
+ traily = mo->y + mo->radius;
}
-
+
bestslidefrac = FRACUNIT+1;
-
+
P_PathTraverse ( leadx, leady, leadx+mo->momx, leady+mo->momy,
- PT_ADDLINES, PTR_SlideTraverse );
+ PT_ADDLINES, PTR_SlideTraverse );
P_PathTraverse ( trailx, leady, trailx+mo->momx, leady+mo->momy,
- PT_ADDLINES, PTR_SlideTraverse );
+ PT_ADDLINES, PTR_SlideTraverse );
P_PathTraverse ( leadx, traily, leadx+mo->momx, traily+mo->momy,
- PT_ADDLINES, PTR_SlideTraverse );
+ PT_ADDLINES, PTR_SlideTraverse );
// move up to the wall
if (bestslidefrac == FRACUNIT+1)
{
- // the move most have hit the middle, so stairstep
- stairstep:
- if (!P_TryMove (mo, mo->x, mo->y + mo->momy))
- P_TryMove (mo, mo->x + mo->momx, mo->y);
- return;
+ // the move most have hit the middle, so stairstep
+stairstep:
+ if (!P_TryMove (mo, mo->x, mo->y + mo->momy))
+ P_TryMove (mo, mo->x + mo->momx, mo->y);
+ return;
}
// fudge a bit to make sure it doesn't hit
- bestslidefrac -= 0x800;
+ bestslidefrac -= 0x800;
if (bestslidefrac > 0)
{
- newx = FixedMul (mo->momx, bestslidefrac);
- newy = FixedMul (mo->momy, bestslidefrac);
-
- if (!P_TryMove (mo, mo->x+newx, mo->y+newy))
- goto stairstep;
+ newx = FixedMul (mo->momx, bestslidefrac);
+ newy = FixedMul (mo->momy, bestslidefrac);
+
+ if (!P_TryMove (mo, mo->x+newx, mo->y+newy))
+ goto stairstep;
}
// Now continue along the wall.
// First calculate remainder.
bestslidefrac = FRACUNIT-(bestslidefrac+0x800);
-
+
if (bestslidefrac > FRACUNIT)
- bestslidefrac = FRACUNIT;
-
+ bestslidefrac = FRACUNIT;
+
if (bestslidefrac <= 0)
- return;
-
+ return;
+
tmxmove = FixedMul (mo->momx, bestslidefrac);
tmymove = FixedMul (mo->momy, bestslidefrac);
- P_HitSlideLine (bestslideline); // clip the moves
+ P_HitSlideLine (bestslideline); // clip the moves
mo->momx = tmxmove;
mo->momy = tmymove;
-
+
if (!P_TryMove (mo, mo->x+tmxmove, mo->y+tmymove))
{
- goto retry;
+ goto retry;
}
}
@@ -975,33 +983,35 @@
// PTR_AimTraverse
// Sets linetaget and aimslope when a target is aimed at.
//
+// [STRIFE] Verified unmodified
+//
boolean
PTR_AimTraverse (intercept_t* in)
{
- line_t* li;
- mobj_t* th;
- fixed_t slope;
- fixed_t thingtopslope;
- fixed_t thingbottomslope;
- fixed_t dist;
-
+ line_t* li;
+ mobj_t* th;
+ fixed_t slope;
+ fixed_t thingtopslope;
+ fixed_t thingbottomslope;
+ fixed_t dist;
+
if (in->isaline)
{
- li = in->d.line;
-
- if ( !(li->flags & ML_TWOSIDED) )
- return false; // stop
-
- // Crosses a two sided line.
- // A two sided line will restrict
- // the possible target ranges.
- P_LineOpening (li);
-
- if (openbottom >= opentop)
- return false; // stop
-
- dist = FixedMul (attackrange, in->frac);
+ li = in->d.line;
+ if ( !(li->flags & ML_TWOSIDED) )
+ return false; // stop
+
+ // Crosses a two sided line.
+ // A two sided line will restrict
+ // the possible target ranges.
+ P_LineOpening (li);
+
+ if (openbottom >= opentop)
+ return false; // stop
+
+ dist = FixedMul (attackrange, in->frac);
+
// Return false if there is no back sector. This should never
// be the case if the line is two-sided; however, some WADs
// (eg. ottawau.wad) use this as an "impassible glass" trick
@@ -1013,32 +1023,32 @@
}
if (li->frontsector->floorheight != li->backsector->floorheight)
- {
- slope = FixedDiv (openbottom - shootz , dist);
- if (slope > bottomslope)
- bottomslope = slope;
- }
-
- if (li->frontsector->ceilingheight != li->backsector->ceilingheight)
- {
- slope = FixedDiv (opentop - shootz , dist);
- if (slope < topslope)
- topslope = slope;
- }
-
- if (topslope <= bottomslope)
- return false; // stop
-
- return true; // shot continues
+ {
+ slope = FixedDiv (openbottom - shootz , dist);
+ if (slope > bottomslope)
+ bottomslope = slope;
+ }
+
+ if (li->frontsector->ceilingheight != li->backsector->ceilingheight)
+ {
+ slope = FixedDiv (opentop - shootz , dist);
+ if (slope < topslope)
+ topslope = slope;
+ }
+
+ if (topslope <= bottomslope)
+ return false; // stop
+
+ return true; // shot continues
}
-
+
// shoot a thing
th = in->d.thing;
if (th == shootthing)
- return true; // can't shoot self
-
+ return true; // can't shoot self
+
if (!(th->flags&MF_SHOOTABLE))
- return true; // corpse or something
+ return true; // corpse or something
// check angles to see if the thing can be aimed at
dist = FixedMul (attackrange, in->frac);
@@ -1045,24 +1055,24 @@
thingtopslope = FixedDiv (th->z+th->height - shootz , dist);
if (thingtopslope < bottomslope)
- return true; // shot over the thing
+ return true; // shot over the thing
thingbottomslope = FixedDiv (th->z - shootz, dist);
if (thingbottomslope > topslope)
- return true; // shot under the thing
-
+ return true; // shot under the thing
+
// this thing can be hit!
if (thingtopslope > topslope)
- thingtopslope = topslope;
-
+ thingtopslope = topslope;
+
if (thingbottomslope < bottomslope)
- thingbottomslope = bottomslope;
+ thingbottomslope = bottomslope;
aimslope = (thingtopslope+thingbottomslope)/2;
linetarget = th;
- return false; // don't go any farther
+ return false; // don't go any farther
}
@@ -1069,6 +1079,8 @@
//
// PTR_ShootTraverse
//
+// [STRIFE] Changes for Spectres and Mauler puff/damage inflictor
+//
boolean PTR_ShootTraverse (intercept_t* in)
{
fixed_t x;
@@ -1142,7 +1154,7 @@
// it's a sky hack wall
if (li->backsector && li->backsector->ceilingpic == skyflatnum)
- return false;
+ return false;
}
// villsa [STRIFE]
@@ -1149,7 +1161,7 @@
if(la_damage > 0)
{
// villsa [STRIFE] Test against Mauler attack range
- if(attackrange != (2112*FRACUNIT))
+ if(attackrange != 2112*FRACUNIT)
P_SpawnPuff(x, y, z); // Spawn bullet puffs.
else
P_SpawnMobj(x, y, z, MT_STRIFEPUFF3);
@@ -1162,14 +1174,14 @@
// shoot a thing
th = in->d.thing;
if (th == shootthing)
- return true; // can't shoot self
+ return true; // can't shoot self
if (!(th->flags&MF_SHOOTABLE))
- return true; // corpse or something
+ return true; // corpse or something
// haleyjd 09/18/10: [STRIFE] Corrected - not MVIS, but SPECTRAL.
if(th->flags & MF_SPECTRAL)
- return true;
+ return true; // is a spectral entity
// check angles to see if the thing can be aimed at
dist = FixedMul (attackrange, in->frac);
@@ -1176,14 +1188,13 @@
thingtopslope = FixedDiv (th->z+th->height - shootz , dist);
if (thingtopslope < aimslope)
- return true; // shot over the thing
+ return true; // shot over the thing
thingbottomslope = FixedDiv (th->z - shootz, dist);
if (thingbottomslope > aimslope)
- return true; // shot under the thing
+ return true; // shot under the thing
-
// hit thing
// position a bit closer
frac = in->frac - FixedDiv (10*FRACUNIT,attackrange);
@@ -1192,8 +1203,8 @@
y = trace.y + FixedMul (trace.dy, frac);
z = shootz + FixedMul (aimslope, FixedMul(frac, attackrange));
- // villsa [STRIFE] TODO - verify purpose of this
- if(attackrange == (2112*FRACUNIT))
+ // villsa [STRIFE] Check for Mauler attack range
+ if(attackrange == 2112*FRACUNIT)
{
th2 = P_SpawnMobj(x, y, z, MT_STRIFEPUFF3);
th2->momz = -FRACUNIT;
@@ -1201,7 +1212,7 @@
return false;
}
- // villsa [STRIFE] TODO - verify disabled check for damage?
+ // villsa [STRIFE] disabled check for damage
//if (la_damage)
P_DamageMobj (th, shootthing, shootthing, la_damage);
@@ -1221,6 +1232,8 @@
//
// P_AimLineAttack
//
+// [STRIFE] Modified to support player->pitch
+//
fixed_t
P_AimLineAttack
( mobj_t* t1,
@@ -1268,6 +1281,8 @@
// If damage == 0, it is just a test trace
// that will leave linetarget set.
//
+// [STRIFE] Modified to check lines only if damage <= 0 (see P_RadiusAttack)
+//
void
P_LineAttack
( mobj_t* t1,
@@ -1279,7 +1294,7 @@
fixed_t x2;
fixed_t y2;
int traverseflags;
-
+
angle >>= ANGLETOFINESHIFT;
shootthing = t1;
la_damage = damage;
@@ -1306,32 +1321,34 @@
//
// USE LINES
//
-mobj_t* usething;
+// [STRIFE] Verified unmodified
+//
+mobj_t* usething;
-boolean PTR_UseTraverse (intercept_t* in)
+boolean PTR_UseTraverse (intercept_t* in)
{
- int side;
-
+ int side;
+
if (!in->d.line->special)
{
- P_LineOpening (in->d.line);
- if (openrange <= 0)
- {
- S_StartSound (usething, sfx_noway);
-
- // can't use through a wall
- return false;
- }
- // not a special line, but keep checking
- return true ;
+ P_LineOpening (in->d.line);
+ if (openrange <= 0)
+ {
+ S_StartSound (usething, sfx_noway);
+
+ // can't use through a wall
+ return false;
+ }
+ // not a special line, but keep checking
+ return true ;
}
-
+
side = 0;
if (P_PointOnLineSide (usething->x, usething->y, in->d.line) == 1)
- side = 1;
-
- // return false; // don't use back side
-
+ side = 1;
+
+ // return false; // don't use back side
+
P_UseSpecialLine (usething, in->d.line, side);
// can't use for than one special line in a row
@@ -1343,16 +1360,18 @@
// P_UseLines
// Looks for special lines in front of the player to activate.
//
-void P_UseLines (player_t* player)
+// [STRIFE] Verified unmodified
+//
+void P_UseLines (player_t* player)
{
- int angle;
- fixed_t x1;
- fixed_t y1;
- fixed_t x2;
- fixed_t y2;
-
+ int angle;
+ fixed_t x1;
+ fixed_t y1;
+ fixed_t x2;
+ fixed_t y2;
+
usething = player->mo;
-
+
angle = player->mo->angle >> ANGLETOFINESHIFT;
x1 = player->mo->x;
@@ -1359,7 +1378,7 @@
y1 = player->mo->y;
x2 = x1 + (USERANGE>>FRACBITS)*finecosine[angle];
y2 = y1 + (USERANGE>>FRACBITS)*finesine[angle];
-
+
P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse );
}
@@ -1367,9 +1386,9 @@
//
// RADIUS ATTACK
//
-mobj_t* bombsource;
-mobj_t* bombspot;
-int bombdamage;
+mobj_t* bombsource;
+mobj_t* bombspot;
+int bombdamage;
//
@@ -1377,11 +1396,13 @@
// "bombsource" is the creature
// that caused the explosion at "bombspot".
//
+// [STRIFE] Modified for Spectral and Inquisitor exclusions
+//
boolean PIT_RadiusAttack (mobj_t* thing)
{
- fixed_t dx;
- fixed_t dy;
- fixed_t dist;
+ fixed_t dx;
+ fixed_t dy;
+ fixed_t dist;
if (!(thing->flags & MF_SHOOTABLE))
return true;
@@ -1408,7 +1429,7 @@
dist = 0;
if (dist >= bombdamage)
- return true; // out of range
+ return true; // out of range
if ( P_CheckSight (thing, bombspot) )
{
@@ -1424,6 +1445,9 @@
// P_RadiusAttack
// Source is the creature that caused the explosion at spot.
//
+// [STRIFE] Modified to emit "test" tracers which can shatter glass screens
+// and windows.
+//
void
P_RadiusAttack
( mobj_t* spot,
@@ -1484,7 +1508,9 @@
//
// PIT_ChangeSector
//
-boolean PIT_ChangeSector (mobj_t* thing)
+// [STRIFE] Changes to crushing behavior
+//
+boolean PIT_ChangeSector (mobj_t* thing)
{
mobj_t* mo;
@@ -1494,7 +1520,6 @@
return true;
}
-
// crunch bodies to giblets
if (thing->health <= 0)
{
@@ -1521,7 +1546,7 @@
P_RemoveMobj (thing);
// keep checking
- return true;
+ return true;
}
if (! (thing->flags & MF_SHOOTABLE) )
@@ -1534,6 +1559,7 @@
if (crushchange && !(leveltime&3) )
{
+ int t;
S_StartSound(thing, sfx_pcrush); // villsa [STRIFE]
P_DamageMobj(thing,NULL,NULL,10);
@@ -1542,11 +1568,13 @@
thing->y,
thing->z + thing->height/2, MT_BLOOD_DEATH);
- mo->momx = (P_Random() - P_Random ())<<12;
- mo->momy = (P_Random() - P_Random ())<<12;
+ t = P_Random();
+ mo->momx = (t - P_Random ()) << 12;
+ t = P_Random();
+ mo->momy = (t - P_Random ()) << 12;
}
- // keep checking (crush other things)
+ // keep checking (crush other things)
return true;
}
@@ -1555,23 +1583,24 @@
//
// P_ChangeSector
//
+// [STRIFE] Verified unmodified
+//
boolean
P_ChangeSector
-( sector_t* sector,
- boolean crunch )
+( sector_t* sector,
+ boolean crunch )
{
- int x;
- int y;
-
+ int x;
+ int y;
+
nofit = false;
crushchange = crunch;
-
+
// re-check heights for all things near the moving sector
for (x=sector->blockbox[BOXLEFT] ; x<= sector->blockbox[BOXRIGHT] ; x++)
- for (y=sector->blockbox[BOXBOTTOM];y<= sector->blockbox[BOXTOP] ; y++)
- P_BlockThingsIterator (x, y, PIT_ChangeSector);
-
-
+ for (y=sector->blockbox[BOXBOTTOM];y<= sector->blockbox[BOXTOP] ; y++)
+ P_BlockThingsIterator (x, y, PIT_ChangeSector);
+
return nofit;
}
@@ -1624,10 +1653,10 @@
tmbbox[numspechit-9] = addr;
break;
case 13:
- crushchange = addr;
- break;
+ nofit = addr; // haleyjd 20110204: nofit/crushchange are in opposite
+ break; // order in the Strife binary.
case 14:
- nofit = addr;
+ crushchange = addr;
break;
default:
fprintf(stderr, "SpechitOverrun: Warning: unable to emulate"
--- a/src/strife/p_maputl.c
+++ b/src/strife/p_maputl.c
@@ -47,7 +47,8 @@
// P_AproxDistance
// Gives an estimation of distance (not exact)
//
-
+// [STRIFE] Verified unmodified
+//
fixed_t
P_AproxDistance
( fixed_t dx,
@@ -56,7 +57,7 @@
dx = abs(dx);
dy = abs(dy);
if (dx < dy)
- return dx+dy-(dx>>1);
+ return dx+dy-(dx>>1);
return dx+dy-(dy>>1);
}
@@ -65,6 +66,8 @@
// P_PointOnLineSide
// Returns 0 or 1
//
+// [STRIFE] Verified unmodified
+//
int
P_PointOnLineSide
( fixed_t x,
@@ -71,35 +74,35 @@
fixed_t y,
line_t* line )
{
- fixed_t dx;
- fixed_t dy;
- fixed_t left;
- fixed_t right;
-
+ fixed_t dx;
+ fixed_t dy;
+ fixed_t left;
+ fixed_t right;
+
if (!line->dx)
{
- if (x <= line->v1->x)
- return line->dy > 0;
-
- return line->dy < 0;
+ if (x <= line->v1->x)
+ return line->dy > 0;
+
+ return line->dy < 0;
}
if (!line->dy)
{
- if (y <= line->v1->y)
- return line->dx < 0;
-
- return line->dx > 0;
+ if (y <= line->v1->y)
+ return line->dx < 0;
+
+ return line->dx > 0;
}
-
+
dx = (x - line->v1->x);
dy = (y - line->v1->y);
-
+
left = FixedMul ( line->dy>>FRACBITS , dx );
right = FixedMul ( dy , line->dx>>FRACBITS );
-
+
if (right < left)
- return 0; // front side
- return 1; // back side
+ return 0; // front side
+ return 1; // back side
}
@@ -109,49 +112,51 @@
// Considers the line to be infinite
// Returns side 0 or 1, -1 if box crosses the line.
//
+// [STRIFE] Verified unmodified
+//
int
P_BoxOnLineSide
-( fixed_t* tmbox,
- line_t* ld )
+( fixed_t* tmbox,
+ line_t* ld )
{
- int p1 = 0;
- int p2 = 0;
-
+ int p1 = 0;
+ int p2 = 0;
+
switch (ld->slopetype)
{
- case ST_HORIZONTAL:
- p1 = tmbox[BOXTOP] > ld->v1->y;
- p2 = tmbox[BOXBOTTOM] > ld->v1->y;
- if (ld->dx < 0)
- {
- p1 ^= 1;
- p2 ^= 1;
- }
- break;
-
- case ST_VERTICAL:
- p1 = tmbox[BOXRIGHT] < ld->v1->x;
- p2 = tmbox[BOXLEFT] < ld->v1->x;
- if (ld->dy < 0)
- {
- p1 ^= 1;
- p2 ^= 1;
- }
- break;
-
- case ST_POSITIVE:
- p1 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXTOP], ld);
- p2 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld);
- break;
-
- case ST_NEGATIVE:
- p1 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXTOP], ld);
- p2 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld);
- break;
+ case ST_HORIZONTAL:
+ p1 = tmbox[BOXTOP] > ld->v1->y;
+ p2 = tmbox[BOXBOTTOM] > ld->v1->y;
+ if (ld->dx < 0)
+ {
+ p1 ^= 1;
+ p2 ^= 1;
+ }
+ break;
+
+ case ST_VERTICAL:
+ p1 = tmbox[BOXRIGHT] < ld->v1->x;
+ p2 = tmbox[BOXLEFT] < ld->v1->x;
+ if (ld->dy < 0)
+ {
+ p1 ^= 1;
+ p2 ^= 1;
+ }
+ break;
+
+ case ST_POSITIVE:
+ p1 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXTOP], ld);
+ p2 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld);
+ break;
+
+ case ST_NEGATIVE:
+ p1 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXTOP], ld);
+ p2 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld);
+ break;
}
if (p1 == p2)
- return p1;
+ return p1;
return -1;
}
@@ -160,48 +165,50 @@
// P_PointOnDivlineSide
// Returns 0 or 1.
//
+// [STRIFE] Verified unmodified
+//
int
P_PointOnDivlineSide
-( fixed_t x,
- fixed_t y,
- divline_t* line )
+( fixed_t x,
+ fixed_t y,
+ divline_t* line )
{
- fixed_t dx;
- fixed_t dy;
- fixed_t left;
- fixed_t right;
-
+ fixed_t dx;
+ fixed_t dy;
+ fixed_t left;
+ fixed_t right;
+
if (!line->dx)
{
- if (x <= line->x)
- return line->dy > 0;
-
- return line->dy < 0;
+ if (x <= line->x)
+ return line->dy > 0;
+
+ return line->dy < 0;
}
if (!line->dy)
{
- if (y <= line->y)
- return line->dx < 0;
+ if (y <= line->y)
+ return line->dx < 0;
- return line->dx > 0;
+ return line->dx > 0;
}
-
+
dx = (x - line->x);
dy = (y - line->y);
-
+
// try to quickly decide by looking at sign bits
if ( (line->dy ^ line->dx ^ dx ^ dy)&0x80000000 )
{
- if ( (line->dy ^ dx) & 0x80000000 )
- return 1; // (left is negative)
- return 0;
+ if ( (line->dy ^ dx) & 0x80000000 )
+ return 1; // (left is negative)
+ return 0;
}
-
+
left = FixedMul ( line->dy>>8, dx>>8 );
right = FixedMul ( dy>>8 , line->dx>>8 );
-
+
if (right < left)
- return 0; // front side
+ return 0; // front side
return 1; // back side
}
@@ -230,25 +237,27 @@
// This is only called by the addthings
// and addlines traversers.
//
+// [STRIFE] Verified unmodified
+//
fixed_t
P_InterceptVector
-( divline_t* v2,
- divline_t* v1 )
+( divline_t* v2,
+ divline_t* v1 )
{
#if 1
- fixed_t frac;
- fixed_t num;
- fixed_t den;
-
+ fixed_t frac;
+ fixed_t num;
+ fixed_t den;
+
den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy);
if (den == 0)
- return 0;
- // I_Error ("P_InterceptVector: parallel");
-
+ return 0;
+ // I_Error ("P_InterceptVector: parallel");
+
num =
- FixedMul ( (v1->x - v2->x)>>8 ,v1->dy )
- +FixedMul ( (v2->y - v1->y)>>8, v1->dx );
+ FixedMul ( (v1->x - v2->x)>>8 ,v1->dy )
+ +FixedMul ( (v2->y - v1->y)>>8, v1->dx );
frac = FixedDiv (num , den);
@@ -294,6 +303,8 @@
// through a two sided line.
// OPTIMIZE: keep this precalculated
//
+// [STRIFE] Verified unmodified
+//
fixed_t opentop;
fixed_t openbottom;
fixed_t openrange;
@@ -302,35 +313,35 @@
void P_LineOpening (line_t* linedef)
{
- sector_t* front;
- sector_t* back;
-
+ sector_t* front;
+ sector_t* back;
+
if (linedef->sidenum[1] == -1)
{
- // single sided line
- openrange = 0;
- return;
+ // single sided line
+ openrange = 0;
+ return;
}
-
+
front = linedef->frontsector;
back = linedef->backsector;
-
+
if (front->ceilingheight < back->ceilingheight)
- opentop = front->ceilingheight;
+ opentop = front->ceilingheight;
else
- opentop = back->ceilingheight;
+ opentop = back->ceilingheight;
if (front->floorheight > back->floorheight)
{
- openbottom = front->floorheight;
- lowfloor = back->floorheight;
+ openbottom = front->floorheight;
+ lowfloor = back->floorheight;
}
else
{
- openbottom = back->floorheight;
- lowfloor = front->floorheight;
+ openbottom = back->floorheight;
+ lowfloor = front->floorheight;
}
-
+
openrange = opentop - openbottom;
}
@@ -347,44 +358,46 @@
// lookups maintaining lists ot things inside
// these structures need to be updated.
//
+// [STRIFE] Verified unmodified
+//
void P_UnsetThingPosition (mobj_t* thing)
{
- int blockx;
- int blocky;
+ int blockx;
+ int blocky;
if ( ! (thing->flags & MF_NOSECTOR) )
{
- // inert things don't need to be in blockmap?
- // unlink from subsector
- if (thing->snext)
- thing->snext->sprev = thing->sprev;
+ // inert things don't need to be in blockmap?
+ // unlink from subsector
+ if (thing->snext)
+ thing->snext->sprev = thing->sprev;
- if (thing->sprev)
- thing->sprev->snext = thing->snext;
- else
- thing->subsector->sector->thinglist = thing->snext;
+ if (thing->sprev)
+ thing->sprev->snext = thing->snext;
+ else
+ thing->subsector->sector->thinglist = thing->snext;
}
-
+
if ( ! (thing->flags & MF_NOBLOCKMAP) )
{
- // inert things don't need to be in blockmap
- // unlink from block map
- if (thing->bnext)
- thing->bnext->bprev = thing->bprev;
-
- if (thing->bprev)
- thing->bprev->bnext = thing->bnext;
- else
- {
- blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT;
- blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT;
+ // inert things don't need to be in blockmap
+ // unlink from block map
+ if (thing->bnext)
+ thing->bnext->bprev = thing->bprev;
- if (blockx>=0 && blockx < bmapwidth
- && blocky>=0 && blocky <bmapheight)
- {
- blocklinks[blocky*bmapwidth+blockx] = thing->bnext;
- }
- }
+ if (thing->bprev)
+ thing->bprev->bnext = thing->bnext;
+ else
+ {
+ blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT;
+ blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT;
+
+ if (blockx>=0 && blockx < bmapwidth
+ && blocky>=0 && blocky <bmapheight)
+ {
+ blocklinks[blocky*bmapwidth+blockx] = thing->bnext;
+ }
+ }
}
}
@@ -395,60 +408,62 @@
// based on it's x y.
// Sets thing->subsector properly
//
+// [STRIFE] Verified unmodified
+//
void
P_SetThingPosition (mobj_t* thing)
{
- subsector_t* ss;
- sector_t* sec;
- int blockx;
- int blocky;
- mobj_t** link;
+ subsector_t* ss;
+ sector_t* sec;
+ int blockx;
+ int blocky;
+ mobj_t** link;
-
+
// link into subsector
ss = R_PointInSubsector (thing->x,thing->y);
thing->subsector = ss;
-
+
if ( ! (thing->flags & MF_NOSECTOR) )
{
- // invisible things don't go into the sector links
- sec = ss->sector;
-
- thing->sprev = NULL;
- thing->snext = sec->thinglist;
+ // invisible things don't go into the sector links
+ sec = ss->sector;
- if (sec->thinglist)
- sec->thinglist->sprev = thing;
+ thing->sprev = NULL;
+ thing->snext = sec->thinglist;
- sec->thinglist = thing;
+ if (sec->thinglist)
+ sec->thinglist->sprev = thing;
+
+ sec->thinglist = thing;
}
-
+
// link into blockmap
if ( ! (thing->flags & MF_NOBLOCKMAP) )
{
- // inert things don't need to be in blockmap
- blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT;
- blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT;
+ // inert things don't need to be in blockmap
+ blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT;
+ blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT;
- if (blockx>=0
- && blockx < bmapwidth
- && blocky>=0
- && blocky < bmapheight)
- {
- link = &blocklinks[blocky*bmapwidth+blockx];
- thing->bprev = NULL;
- thing->bnext = *link;
- if (*link)
- (*link)->bprev = thing;
+ if (blockx>=0
+ && blockx < bmapwidth
+ && blocky>=0
+ && blocky < bmapheight)
+ {
+ link = &blocklinks[blocky*bmapwidth+blockx];
+ thing->bprev = NULL;
+ thing->bnext = *link;
+ if (*link)
+ (*link)->bprev = thing;
- *link = thing;
- }
- else
- {
- // thing is off the map
- thing->bnext = thing->bprev = NULL;
- }
+ *link = thing;
+ }
+ else
+ {
+ // thing is off the map
+ thing->bnext = thing->bprev = NULL;
+ }
}
}
@@ -485,9 +500,9 @@
line_t* ld;
if (x<0
- || y<0
- || x>=bmapwidth
- || y>=bmapheight)
+ || y<0
+ || x>=bmapwidth
+ || y>=bmapheight)
{
return true;
}
@@ -518,29 +533,31 @@
//
// P_BlockThingsIterator
//
+// [STRIFE] Verified unmodified
+//
boolean
P_BlockThingsIterator
-( int x,
- int y,
+( int x,
+ int y,
boolean(*func)(mobj_t*) )
{
- mobj_t* mobj;
-
+ mobj_t* mobj;
+
if ( x<0
- || y<0
- || x>=bmapwidth
- || y>=bmapheight)
+ || y<0
+ || x>=bmapwidth
+ || y>=bmapheight)
{
- return true;
+ return true;
}
-
+
for (mobj = blocklinks[y*bmapwidth+x] ;
- mobj ;
- mobj = mobj->bnext)
+ mobj ;
+ mobj = mobj->bnext)
{
- if (!func( mobj ) )
- return false;
+ if (!func( mobj ) )
+ return false;
}
return true;
}
@@ -569,55 +586,66 @@
// are on opposite sides of the trace.
// Returns true if earlyout and a solid line hit.
//
+// haleyjd 20110204 [STRIFE]: Added Rogue's fix for intercepts overflows
+//
boolean
PIT_AddLineIntercepts (line_t* ld)
{
- int s1;
- int s2;
- fixed_t frac;
- divline_t dl;
-
+ int s1;
+ int s2;
+ fixed_t frac;
+ divline_t dl;
+
// avoid precision problems with two routines
if ( trace.dx > FRACUNIT*16
- || trace.dy > FRACUNIT*16
- || trace.dx < -FRACUNIT*16
- || trace.dy < -FRACUNIT*16)
+ || trace.dy > FRACUNIT*16
+ || trace.dx < -FRACUNIT*16
+ || trace.dy < -FRACUNIT*16)
{
- s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace);
- s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace);
+ s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace);
+ s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace);
}
else
{
- s1 = P_PointOnLineSide (trace.x, trace.y, ld);
- s2 = P_PointOnLineSide (trace.x+trace.dx, trace.y+trace.dy, ld);
+ s1 = P_PointOnLineSide (trace.x, trace.y, ld);
+ s2 = P_PointOnLineSide (trace.x+trace.dx, trace.y+trace.dy, ld);
}
-
+
if (s1 == s2)
- return true; // line isn't crossed
-
+ return true; // line isn't crossed
+
// hit the line
P_MakeDivline (ld, &dl);
frac = P_InterceptVector (&trace, &dl);
if (frac < 0)
- return true; // behind source
-
+ return true; // behind source
+
// try to early out the check
if (earlyout
- && frac < FRACUNIT
- && !ld->backsector)
+ && frac < FRACUNIT
+ && !ld->backsector)
{
- return false; // stop checking
+ return false; // stop checking
}
-
-
+
+
intercept_p->frac = frac;
intercept_p->isaline = true;
intercept_p->d.line = ld;
- InterceptsOverrun(intercept_p - intercepts, intercept_p);
intercept_p++;
- return true; // continue
+ // haleyjd 20110204 [STRIFE]
+ // Evidently Rogue had trouble with intercepts overflows during
+ // development, as they added this check here which will stop adding
+ // intercepts if the array would be overflown.
+ if(intercept_p <= &intercepts[MAXINTERCEPTS_ORIGINAL-2])
+ return true; // continue
+ else
+ return false;
+
+ // [STRIFE] Not needed?
+ //InterceptsOverrun(intercept_p - intercepts, intercept_p);
}
@@ -627,63 +655,71 @@
//
boolean PIT_AddThingIntercepts (mobj_t* thing)
{
- fixed_t x1;
- fixed_t y1;
- fixed_t x2;
- fixed_t y2;
-
- int s1;
- int s2;
-
- boolean tracepositive;
+ fixed_t x1;
+ fixed_t y1;
+ fixed_t x2;
+ fixed_t y2;
- divline_t dl;
-
- fixed_t frac;
-
+ int s1;
+ int s2;
+
+ boolean tracepositive;
+
+ divline_t dl;
+
+ fixed_t frac;
+
tracepositive = (trace.dx ^ trace.dy)>0;
-
+
// check a corner to corner crossection for hit
if (tracepositive)
{
- x1 = thing->x - thing->radius;
- y1 = thing->y + thing->radius;
-
- x2 = thing->x + thing->radius;
- y2 = thing->y - thing->radius;
+ x1 = thing->x - thing->radius;
+ y1 = thing->y + thing->radius;
+
+ x2 = thing->x + thing->radius;
+ y2 = thing->y - thing->radius;
}
else
{
- x1 = thing->x - thing->radius;
- y1 = thing->y - thing->radius;
-
- x2 = thing->x + thing->radius;
- y2 = thing->y + thing->radius;
+ x1 = thing->x - thing->radius;
+ y1 = thing->y - thing->radius;
+
+ x2 = thing->x + thing->radius;
+ y2 = thing->y + thing->radius;
}
-
+
s1 = P_PointOnDivlineSide (x1, y1, &trace);
s2 = P_PointOnDivlineSide (x2, y2, &trace);
if (s1 == s2)
- return true; // line isn't crossed
-
+ return true; // line isn't crossed
+
dl.x = x1;
dl.y = y1;
dl.dx = x2-x1;
dl.dy = y2-y1;
-
+
frac = P_InterceptVector (&trace, &dl);
if (frac < 0)
- return true; // behind source
+ return true; // behind source
intercept_p->frac = frac;
intercept_p->isaline = false;
intercept_p->d.thing = thing;
- InterceptsOverrun(intercept_p - intercepts, intercept_p);
+
intercept_p++;
+
+ // haleyjd 20110204 [STRIFE]: As above, protection against intercepts
+ // overflows, courtesy of Rogue Software.
+ if(intercept_p <= &intercepts[MAXINTERCEPTS_ORIGINAL-2])
+ return true; // keep going
+ else
+ return false;
- return true; // keep going
+ // haleyjd [STRIFE]: Not needed?
+ //InterceptsOverrun(intercept_p - intercepts, intercept_p);
}
@@ -699,49 +735,49 @@
( traverser_t func,
fixed_t maxfrac )
{
- int count;
- fixed_t dist;
- intercept_t* scan;
- intercept_t* in;
-
+ int count;
+ fixed_t dist;
+ intercept_t* scan;
+ intercept_t* in;
+
count = intercept_p - intercepts;
-
- in = 0; // shut up compiler warning
-
+
+ in = 0; // shut up compiler warning
+
while (count--)
{
- dist = INT_MAX;
- for (scan = intercepts ; scan<intercept_p ; scan++)
- {
- if (scan->frac < dist)
- {
- dist = scan->frac;
- in = scan;
- }
- }
-
- if (dist > maxfrac)
- return true; // checked everything in range
+ dist = INT_MAX;
+ for (scan = intercepts ; scan<intercept_p ; scan++)
+ {
+ if (scan->frac < dist)
+ {
+ dist = scan->frac;
+ in = scan;
+ }
+ }
+ if (dist > maxfrac)
+ return true; // checked everything in range
+
#if 0 // UNUSED
- {
- // don't check these yet, there may be others inserted
- in = scan = intercepts;
- for ( scan = intercepts ; scan<intercept_p ; scan++)
- if (scan->frac > maxfrac)
- *in++ = *scan;
- intercept_p = in;
- return false;
- }
+ {
+ // don't check these yet, there may be others inserted
+ in = scan = intercepts;
+ for ( scan = intercepts ; scan<intercept_p ; scan++)
+ if (scan->frac > maxfrac)
+ *in++ = *scan;
+ intercept_p = in;
+ return false;
+ }
#endif
if ( !func (in) )
- return false; // don't bother going farther
+ return false; // don't bother going farther
- in->frac = INT_MAX;
+ in->frac = INT_MAX;
}
-
- return true; // everything was traversed
+
+ return true; // everything was traversed
}
extern fixed_t bulletslope;
@@ -766,6 +802,12 @@
// playerstarts, which is effectively an array of 16-bit integers and
// must be treated differently.
+// haleyjd 20110204: NB: This array has *not* been updated for Strife,
+// because Strife has protection against intercepts overflows. The memory
+// layout of the 1.2 and 1.31 EXEs is radically different with respect
+// to this area of the BSS segment, so it would have to be redone entirely
+// if it were needed.
+
static intercepts_overrun_t intercepts_overrun[] =
{
{4, NULL, false},
@@ -873,46 +915,48 @@
// Returns true if the traverser function returns true
// for all lines.
//
+// [STRIFE] Verified unmodified
+//
boolean
P_PathTraverse
-( fixed_t x1,
- fixed_t y1,
- fixed_t x2,
- fixed_t y2,
- int flags,
+( fixed_t x1,
+ fixed_t y1,
+ fixed_t x2,
+ fixed_t y2,
+ int flags,
boolean (*trav) (intercept_t *))
{
- fixed_t xt1;
- fixed_t yt1;
- fixed_t xt2;
- fixed_t yt2;
+ fixed_t xt1;
+ fixed_t yt1;
+ fixed_t xt2;
+ fixed_t yt2;
- fixed_t xstep;
- fixed_t ystep;
+ fixed_t xstep;
+ fixed_t ystep;
- fixed_t partial;
+ fixed_t partial;
- fixed_t xintercept;
- fixed_t yintercept;
+ fixed_t xintercept;
+ fixed_t yintercept;
- int mapx;
- int mapy;
+ int mapx;
+ int mapy;
- int mapxstep;
- int mapystep;
+ int mapxstep;
+ int mapystep;
- int count;
-
+ int count;
+
earlyout = flags & PT_EARLYOUT;
-
+
validcount++;
intercept_p = intercepts;
-
+
if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0)
- x1 += FRACUNIT; // don't side exactly on a line
-
+ x1 += FRACUNIT; // don't side exactly on a line
+
if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0)
- y1 += FRACUNIT; // don't side exactly on a line
+ y1 += FRACUNIT; // don't side exactly on a line
trace.x = x1;
trace.y = y1;
@@ -931,83 +975,83 @@
if (xt2 > xt1)
{
- mapxstep = 1;
- partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1));
- ystep = FixedDiv (y2-y1,abs(x2-x1));
+ mapxstep = 1;
+ partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1));
+ ystep = FixedDiv (y2-y1,abs(x2-x1));
}
else if (xt2 < xt1)
{
- mapxstep = -1;
- partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1);
- ystep = FixedDiv (y2-y1,abs(x2-x1));
+ mapxstep = -1;
+ partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1);
+ ystep = FixedDiv (y2-y1,abs(x2-x1));
}
else
{
- mapxstep = 0;
- partial = FRACUNIT;
- ystep = 256*FRACUNIT;
+ mapxstep = 0;
+ partial = FRACUNIT;
+ ystep = 256*FRACUNIT;
}
yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep);
-
+
if (yt2 > yt1)
{
- mapystep = 1;
- partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1));
- xstep = FixedDiv (x2-x1,abs(y2-y1));
+ mapystep = 1;
+ partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1));
+ xstep = FixedDiv (x2-x1,abs(y2-y1));
}
else if (yt2 < yt1)
{
- mapystep = -1;
- partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1);
- xstep = FixedDiv (x2-x1,abs(y2-y1));
+ mapystep = -1;
+ partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1);
+ xstep = FixedDiv (x2-x1,abs(y2-y1));
}
else
{
- mapystep = 0;
- partial = FRACUNIT;
- xstep = 256*FRACUNIT;
+ mapystep = 0;
+ partial = FRACUNIT;
+ xstep = 256*FRACUNIT;
}
xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep);
-
+
// Step through map blocks.
// Count is present to prevent a round off error
// from skipping the break.
mapx = xt1;
mapy = yt1;
-
+
for (count = 0 ; count < 64 ; count++)
{
- if (flags & PT_ADDLINES)
- {
- if (!P_BlockLinesIterator (mapx, mapy,PIT_AddLineIntercepts))
- return false; // early out
- }
-
- if (flags & PT_ADDTHINGS)
- {
- if (!P_BlockThingsIterator (mapx, mapy,PIT_AddThingIntercepts))
- return false; // early out
- }
-
- if (mapx == xt2
- && mapy == yt2)
- {
- break;
- }
-
- if ( (yintercept >> FRACBITS) == mapy)
- {
- yintercept += ystep;
- mapx += mapxstep;
- }
- else if ( (xintercept >> FRACBITS) == mapx)
- {
- xintercept += xstep;
- mapy += mapystep;
- }
-
+ if (flags & PT_ADDLINES)
+ {
+ if (!P_BlockLinesIterator (mapx, mapy,PIT_AddLineIntercepts))
+ return false; // early out
+ }
+
+ if (flags & PT_ADDTHINGS)
+ {
+ if (!P_BlockThingsIterator (mapx, mapy,PIT_AddThingIntercepts))
+ return false; // early out
+ }
+
+ if (mapx == xt2
+ && mapy == yt2)
+ {
+ break;
+ }
+
+ if ( (yintercept >> FRACBITS) == mapy)
+ {
+ yintercept += ystep;
+ mapx += mapxstep;
+ }
+ else if ( (xintercept >> FRACBITS) == mapx)
+ {
+ xintercept += xstep;
+ mapy += mapystep;
+ }
+
}
// go through the sorted list
return P_TraverseIntercepts ( trav, FRACUNIT );