From faa9cc43023af53c64bfb491e29a64282fa7f34f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 25 Dec 2007 10:07:58 +0000 Subject: [PATCH] - 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) --- docs/rh-log.txt | 3 +++ src/g_game.cpp | 2 +- src/p_local.h | 12 ++++++++++++ src/p_map.cpp | 37 +++++++++++++++++++------------------ src/p_maputl.cpp | 5 ++--- src/p_mobj.cpp | 8 ++++---- src/p_setup.cpp | 4 ++-- src/p_teleport.cpp | 2 +- src/r_things.cpp | 1 + src/r_things.h | 1 + src/thingdef_codeptr.cpp | 2 +- 11 files changed, 47 insertions(+), 30 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 7f396de02..b85015776 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ 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. December 24, 2007 (Changes by Graf Zahl) diff --git a/src/g_game.cpp b/src/g_game.cpp index b9d4ad6c3..2711c006c 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1247,7 +1247,7 @@ bool G_CheckSpot (int playernum, mapthing2_t *mthing) y = mthing->y << 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) { // first spawn of level, before corpses diff --git a/src/p_local.h b/src/p_local.h index 2250a4e01..4d752b79c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -330,6 +330,18 @@ bool Check_Sides(AActor *, int, int); // phares // [RH] 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 // diff --git a/src/p_map.cpp b/src/p_map.cpp index 26dc0d4d2..c6e7441f6 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -229,7 +229,7 @@ void P_FindFloorCeiling (AActor *actor) tmfbbox[BOXRIGHT] = 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); tmfceilingz = sec->ceilingplane.ZatPoint (x, y); 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 by; - subsector_t* newsubsec; + sector_t* newsec; // kill anything occupying the position 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[BOXLEFT] = tmbbox[BOXLEFT] = x - tmthing->radius; - newsubsec = R_PointInSubsector (x,y); + newsec = P_PointInSector (x,y); ceilingline = NULL; // The base floor/ceiling is from the subsector that contains the point. // Any contacted lines the step closer together will adjust them. - tmffloorz = tmfdropoffz = newsubsec->sector->floorplane.ZatPoint (x, y); - tmfceilingz = newsubsec->sector->ceilingplane.ZatPoint (x, y); - tmffloorpic = newsubsec->sector->floorpic; - tmffloorsector = newsubsec->sector; - tmfceilingpic = newsubsec->sector->ceilingpic; - tmfceilingsector = newsubsec->sector; + tmffloorz = tmfdropoffz = newsec->floorplane.ZatPoint (x, y); + tmfceilingz = newsec->ceilingplane.ZatPoint (x, y); + tmffloorpic = newsec->floorpic; + tmffloorsector = newsec; + tmfceilingpic = newsec->ceilingpic; + tmfceilingsector = newsec; tmfthing = tmthing; validcount++; @@ -1263,7 +1263,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y) int xl, xh; int yl, yh; int bx, by; - subsector_t *newsubsec; + sector_t *newsec; AActor *thingblocker; AActor *fakedblocker; 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[BOXLEFT] = x - thing->radius; - newsubsec = R_PointInSubsector (x,y); + newsec = P_PointInSector (x,y); ceilingline = BlockingLine = NULL; // The base floor / ceiling is from the subsector that contains the point. // Any contacted lines the step closer together will adjust them. - tmfloorz = tmdropoffz = newsubsec->sector->floorplane.ZatPoint (x, y); - tmceilingz = newsubsec->sector->ceilingplane.ZatPoint (x, y); - tmfloorpic = newsubsec->sector->floorpic; - tmfloorsector = newsubsec->sector; - tmceilingpic = newsubsec->sector->ceilingpic; - tmceilingsector = newsubsec->sector; + tmfloorz = tmdropoffz = newsec->floorplane.ZatPoint (x, y); + tmceilingz = newsec->ceilingplane.ZatPoint (x, y); + tmfloorpic = newsec->floorpic; + tmfloorsector = newsec; + tmceilingpic = newsec->ceilingpic; + tmceilingsector = newsec; //Added by MC: Fill the tmsector. - tmsector = newsubsec->sector; + tmsector = newsec; + validcount++; spechit.Clear (); diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 14b4983c7..bbebba40e 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -336,7 +336,7 @@ void AActor::LinkToWorld (bool buggy) if (!buggy || numnodes == 0) { - sec = R_PointInSubsector (x, y)->sector; + sec = P_PointInSector (x, y); } else { @@ -582,8 +582,7 @@ sector_t *AActor::LinkToWorldForMapThing () distance = radius - distance; x += FixedMul(distance, finecosine[finean]); y += FixedMul(distance, finesine[finean]); - ssec = R_PointInSubsector (x, y); - break; + return P_PointInSector (x, y); } #else if (DMulScale32 (y - ldef->v1->y, ldef->dx, ldef->v1->x - x, ldef->dy) == 0) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 5a9f26b97..03e9ea268 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3779,8 +3779,8 @@ void P_SpawnMapThing (mapthing2_t *mthing, int position) // [RH] sound sequence overriders if (mthing->type >= 1400 && mthing->type < 1410) { - R_PointInSubsector (mthing->x<y<sector->seqType = mthing->type - 1400; + P_PointInSector (mthing->x<y<seqType = mthing->type - 1400; return; } else if (mthing->type == 1411) @@ -3798,8 +3798,8 @@ void P_SpawnMapThing (mapthing2_t *mthing, int position) } else { - R_PointInSubsector (mthing->x << FRACBITS, - mthing->y << FRACBITS)->sector->seqType = type; + P_PointInSector (mthing->x << FRACBITS, + mthing->y << FRACBITS)->seqType = type; } return; } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 358cf9f89..e58f7036e 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -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) { - sector_t *dest = R_PointInSubsector (x, y)->sector; + sector_t *dest = P_PointInSector (x, y); sector_t *source; int secnum; size_t planeofs; @@ -1506,7 +1506,7 @@ static void P_SpawnSlopeMakers (mapthing2_t *firstmt, mapthing2_t *lastmt) x = mt->x << FRACBITS; y = mt->y << FRACBITS; - sec = R_PointInSubsector (x, y)->sector; + sec = P_PointInSector (x, y); if (mt->type & 1) { refplane = &sec->ceilingplane; diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 272ea630f..f0086c27f 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -223,7 +223,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, oldy = thing->y; oldz = thing->z; aboveFloor = thing->z - thing->floorz; - destsect = R_PointInSubsector (x, y)->sector; + destsect = P_PointInSector (x, y); // killough 5/12/98: exclude voodoo dolls: player = thing->player; if (player && player->mo != thing) diff --git a/src/r_things.cpp b/src/r_things.cpp index 8bd5420cf..019b4ede2 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2204,6 +2204,7 @@ void R_FindParticleSubsectors () { subsector_t *ssec = R_PointInSubsector (Particles[i].x, Particles[i].y); int ssnum = ssec-subsectors; + Particles[i].subsector = ssec; Particles[i].snext = ParticlesInSubsec[ssnum]; ParticlesInSubsec[ssnum] = i; } diff --git a/src/r_things.h b/src/r_things.h index 27a845676..a3614c063 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -36,6 +36,7 @@ struct particle_t int color; WORD tnext; WORD snext; + subsector_t * subsector; }; extern WORD NumParticles; diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index 3058521e5..341363959 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -2024,7 +2024,7 @@ void A_Respawn (AActor *actor) sector_t *sec; 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->height = actor->GetDefault()->height; if (P_TestMobjLocation (actor))