- added a P_PointInSector function and replaced all calls to retrieve an

actor's sector in the game engine code with it. This way there's a clear
  distinction between renderer-specific and game-specific calls.


SVN r638 (trunk)
This commit is contained in:
Christoph Oelckers 2007-12-25 10:07:58 +00:00
parent 2e11d31bb5
commit faa9cc4302
11 changed files with 47 additions and 30 deletions

View file

@ -1,4 +1,7 @@
December 25, 2007 (Changes by Graf Zahl) December 25, 2007 (Changes by Graf Zahl)
- added a P_PointInSector function and replaced all calls to retrieve an
actor's sector in the game engine code with it. This way there's a clear
distinction between renderer-specific and game-specific calls.
- added UseInventory/UseActorInventory ACS functions. - added UseInventory/UseActorInventory ACS functions.
December 24, 2007 (Changes by Graf Zahl) December 24, 2007 (Changes by Graf Zahl)

View file

@ -1247,7 +1247,7 @@ bool G_CheckSpot (int playernum, mapthing2_t *mthing)
y = mthing->y << FRACBITS; y = mthing->y << FRACBITS;
z = mthing->z << FRACBITS; z = mthing->z << FRACBITS;
z += R_PointInSubsector (x, y)->sector->floorplane.ZatPoint (x, y); z += P_PointInSector (x, y)->floorplane.ZatPoint (x, y);
if (!players[playernum].mo) if (!players[playernum].mo)
{ // first spawn of level, before corpses { // first spawn of level, before corpses

View file

@ -330,6 +330,18 @@ bool Check_Sides(AActor *, int, int); // phares
// [RH] // [RH]
bool P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymove); bool P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymove);
//----------------------------------------------------------------------------------
//
// Added so that in the source there's a clear distinction between
// game engine and renderer specific calls.
// (For ZDoom itself this doesn't make any difference here but for GZDoom it does.)
//
//----------------------------------------------------------------------------------
inline sector_t *P_PointInSector(fixed_t x, fixed_t y)
{
return R_PointInSubsector(x,y)->sector;
}
// //
// P_SETUP // P_SETUP
// //

View file

@ -229,7 +229,7 @@ void P_FindFloorCeiling (AActor *actor)
tmfbbox[BOXRIGHT] = x + actor->radius; tmfbbox[BOXRIGHT] = x + actor->radius;
tmfbbox[BOXLEFT] = x - actor->radius; tmfbbox[BOXLEFT] = x - actor->radius;
sec = R_PointInSubsector (x, y)->sector; sec = P_PointInSector (x, y);
tmffloorz = tmfdropoffz = sec->floorplane.ZatPoint (x, y); tmffloorz = tmfdropoffz = sec->floorplane.ZatPoint (x, y);
tmfceilingz = sec->ceilingplane.ZatPoint (x, y); tmfceilingz = sec->ceilingplane.ZatPoint (x, y);
tmffloorpic = sec->floorpic; tmffloorpic = sec->floorpic;
@ -322,7 +322,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr
int bx; int bx;
int by; int by;
subsector_t* newsubsec; sector_t* newsec;
// kill anything occupying the position // kill anything occupying the position
tmthing = thing; tmthing = thing;
@ -337,17 +337,17 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr
tmfbbox[BOXRIGHT] = tmbbox[BOXRIGHT] = x + tmthing->radius; tmfbbox[BOXRIGHT] = tmbbox[BOXRIGHT] = x + tmthing->radius;
tmfbbox[BOXLEFT] = tmbbox[BOXLEFT] = x - tmthing->radius; tmfbbox[BOXLEFT] = tmbbox[BOXLEFT] = x - tmthing->radius;
newsubsec = R_PointInSubsector (x,y); newsec = P_PointInSector (x,y);
ceilingline = NULL; ceilingline = NULL;
// 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 = newsubsec->sector->floorplane.ZatPoint (x, y); tmffloorz = tmfdropoffz = newsec->floorplane.ZatPoint (x, y);
tmfceilingz = newsubsec->sector->ceilingplane.ZatPoint (x, y); tmfceilingz = newsec->ceilingplane.ZatPoint (x, y);
tmffloorpic = newsubsec->sector->floorpic; tmffloorpic = newsec->floorpic;
tmffloorsector = newsubsec->sector; tmffloorsector = newsec;
tmfceilingpic = newsubsec->sector->ceilingpic; tmfceilingpic = newsec->ceilingpic;
tmfceilingsector = newsubsec->sector; tmfceilingsector = newsec;
tmfthing = tmthing; tmfthing = tmthing;
validcount++; validcount++;
@ -1263,7 +1263,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y)
int xl, xh; int xl, xh;
int yl, yh; int yl, yh;
int bx, by; int bx, by;
subsector_t *newsubsec; sector_t *newsec;
AActor *thingblocker; AActor *thingblocker;
AActor *fakedblocker; AActor *fakedblocker;
fixed_t realheight = thing->height; fixed_t realheight = thing->height;
@ -1279,20 +1279,21 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y)
tmbbox[BOXRIGHT] = x + thing->radius; tmbbox[BOXRIGHT] = x + thing->radius;
tmbbox[BOXLEFT] = x - thing->radius; tmbbox[BOXLEFT] = x - thing->radius;
newsubsec = R_PointInSubsector (x,y); newsec = P_PointInSector (x,y);
ceilingline = BlockingLine = NULL; ceilingline = BlockingLine = NULL;
// 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.
tmfloorz = tmdropoffz = newsubsec->sector->floorplane.ZatPoint (x, y); tmfloorz = tmdropoffz = newsec->floorplane.ZatPoint (x, y);
tmceilingz = newsubsec->sector->ceilingplane.ZatPoint (x, y); tmceilingz = newsec->ceilingplane.ZatPoint (x, y);
tmfloorpic = newsubsec->sector->floorpic; tmfloorpic = newsec->floorpic;
tmfloorsector = newsubsec->sector; tmfloorsector = newsec;
tmceilingpic = newsubsec->sector->ceilingpic; tmceilingpic = newsec->ceilingpic;
tmceilingsector = newsubsec->sector; tmceilingsector = newsec;
//Added by MC: Fill the tmsector. //Added by MC: Fill the tmsector.
tmsector = newsubsec->sector; tmsector = newsec;
validcount++; validcount++;
spechit.Clear (); spechit.Clear ();

View file

@ -336,7 +336,7 @@ void AActor::LinkToWorld (bool buggy)
if (!buggy || numnodes == 0) if (!buggy || numnodes == 0)
{ {
sec = R_PointInSubsector (x, y)->sector; sec = P_PointInSector (x, y);
} }
else else
{ {
@ -582,8 +582,7 @@ sector_t *AActor::LinkToWorldForMapThing ()
distance = radius - distance; distance = radius - distance;
x += FixedMul(distance, finecosine[finean]); x += FixedMul(distance, finecosine[finean]);
y += FixedMul(distance, finesine[finean]); y += FixedMul(distance, finesine[finean]);
ssec = R_PointInSubsector (x, y); return P_PointInSector (x, y);
break;
} }
#else #else
if (DMulScale32 (y - ldef->v1->y, ldef->dx, ldef->v1->x - x, ldef->dy) == 0) if (DMulScale32 (y - ldef->v1->y, ldef->dx, ldef->v1->x - x, ldef->dy) == 0)

View file

@ -3779,8 +3779,8 @@ void P_SpawnMapThing (mapthing2_t *mthing, int position)
// [RH] sound sequence overriders // [RH] sound sequence overriders
if (mthing->type >= 1400 && mthing->type < 1410) if (mthing->type >= 1400 && mthing->type < 1410)
{ {
R_PointInSubsector (mthing->x<<FRACBITS, P_PointInSector (mthing->x<<FRACBITS,
mthing->y<<FRACBITS)->sector->seqType = mthing->type - 1400; mthing->y<<FRACBITS)->seqType = mthing->type - 1400;
return; return;
} }
else if (mthing->type == 1411) else if (mthing->type == 1411)
@ -3798,8 +3798,8 @@ void P_SpawnMapThing (mapthing2_t *mthing, int position)
} }
else else
{ {
R_PointInSubsector (mthing->x << FRACBITS, P_PointInSector (mthing->x << FRACBITS,
mthing->y << FRACBITS)->sector->seqType = type; mthing->y << FRACBITS)->seqType = type;
} }
return; return;
} }

View file

@ -1344,7 +1344,7 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo
static void P_CopyPlane (int tag, fixed_t x, fixed_t y, bool copyCeil) static void P_CopyPlane (int tag, fixed_t x, fixed_t y, bool copyCeil)
{ {
sector_t *dest = R_PointInSubsector (x, y)->sector; sector_t *dest = P_PointInSector (x, y);
sector_t *source; sector_t *source;
int secnum; int secnum;
size_t planeofs; size_t planeofs;
@ -1506,7 +1506,7 @@ static void P_SpawnSlopeMakers (mapthing2_t *firstmt, mapthing2_t *lastmt)
x = mt->x << FRACBITS; x = mt->x << FRACBITS;
y = mt->y << FRACBITS; y = mt->y << FRACBITS;
sec = R_PointInSubsector (x, y)->sector; sec = P_PointInSector (x, y);
if (mt->type & 1) if (mt->type & 1)
{ {
refplane = &sec->ceilingplane; refplane = &sec->ceilingplane;

View file

@ -223,7 +223,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
oldy = thing->y; oldy = thing->y;
oldz = thing->z; oldz = thing->z;
aboveFloor = thing->z - thing->floorz; aboveFloor = thing->z - thing->floorz;
destsect = R_PointInSubsector (x, y)->sector; destsect = P_PointInSector (x, y);
// killough 5/12/98: exclude voodoo dolls: // killough 5/12/98: exclude voodoo dolls:
player = thing->player; player = thing->player;
if (player && player->mo != thing) if (player && player->mo != thing)

View file

@ -2204,6 +2204,7 @@ void R_FindParticleSubsectors ()
{ {
subsector_t *ssec = R_PointInSubsector (Particles[i].x, Particles[i].y); subsector_t *ssec = R_PointInSubsector (Particles[i].x, Particles[i].y);
int ssnum = ssec-subsectors; int ssnum = ssec-subsectors;
Particles[i].subsector = ssec;
Particles[i].snext = ParticlesInSubsec[ssnum]; Particles[i].snext = ParticlesInSubsec[ssnum];
ParticlesInSubsec[ssnum] = i; ParticlesInSubsec[ssnum] = i;
} }

View file

@ -36,6 +36,7 @@ struct particle_t
int color; int color;
WORD tnext; WORD tnext;
WORD snext; WORD snext;
subsector_t * subsector;
}; };
extern WORD NumParticles; extern WORD NumParticles;

View file

@ -2024,7 +2024,7 @@ void A_Respawn (AActor *actor)
sector_t *sec; sector_t *sec;
actor->flags |= MF_SOLID; actor->flags |= MF_SOLID;
sec = R_PointInSubsector (x, y)->sector; sec = P_PointInSector (x, y);
actor->SetOrigin (x, y, sec->floorplane.ZatPoint (x, y)); actor->SetOrigin (x, y, sec->floorplane.ZatPoint (x, y));
actor->height = actor->GetDefault()->height; actor->height = actor->GetDefault()->height;
if (P_TestMobjLocation (actor)) if (P_TestMobjLocation (actor))