- p_maputl.cpp done.

This commit is contained in:
Christoph Oelckers 2016-01-20 14:04:47 +01:00
parent 25107ed421
commit 4d8070927d

View file

@ -344,7 +344,7 @@ void AActor::LinkToWorld (sector_t *sec)
return; return;
} }
Sector = sec; Sector = sec;
subsector = R_PointInSubsector(x, y); // this is from the rendering nodes, not the gameplay nodes! subsector = R_PointInSubsector(X(), Y()); // this is from the rendering nodes, not the gameplay nodes!
if ( !(flags & MF_NOSECTOR) ) if ( !(flags & MF_NOSECTOR) )
{ {
@ -371,7 +371,7 @@ void AActor::LinkToWorld (sector_t *sec)
// When a node is deleted, its sector links (the links starting // When a node is deleted, its sector links (the links starting
// at sector_t->touching_thinglist) are broken. When a node is // at sector_t->touching_thinglist) are broken. When a node is
// added, new sector links are created. // added, new sector links are created.
P_CreateSecNodeList (this, x, y); P_CreateSecNodeList (this, X(), Y());
touching_sectorlist = sector_list; // Attach to thing touching_sectorlist = sector_list; // Attach to thing
sector_list = NULL; // clear for next time sector_list = NULL; // clear for next time
} }
@ -380,10 +380,10 @@ void AActor::LinkToWorld (sector_t *sec)
// link into blockmap (inert things don't need to be in the blockmap) // link into blockmap (inert things don't need to be in the blockmap)
if ( !(flags & MF_NOBLOCKMAP) ) if ( !(flags & MF_NOBLOCKMAP) )
{ {
int x1 = GetSafeBlockX(x - radius - bmaporgx); int x1 = GetSafeBlockX(X() - radius - bmaporgx);
int x2 = GetSafeBlockX(x + radius - bmaporgx); int x2 = GetSafeBlockX(X() + radius - bmaporgx);
int y1 = GetSafeBlockY(y - radius - bmaporgy); int y1 = GetSafeBlockY(Y() - radius - bmaporgy);
int y2 = GetSafeBlockY(y + radius - bmaporgy); int y2 = GetSafeBlockY(Y() + radius - bmaporgy);
if (x1 >= bmapwidth || x2 < 0 || y1 >= bmapheight || y2 < 0) if (x1 >= bmapwidth || x2 < 0 || y1 >= bmapheight || y2 < 0)
{ // thing is off the map { // thing is off the map
@ -496,7 +496,7 @@ sector_t *AActor::LinkToWorldForMapThing ()
// that lies directly on a line should always be // that lies directly on a line should always be
// considered as "in front" of the line. The orientation // considered as "in front" of the line. The orientation
// of the line should be irrelevant. // of the line should be irrelevant.
node = (node_t *)node->children[R_PointOnSideSlow (x, y, node)]; node = (node_t *)node->children[R_PointOnSideSlow (X(), Y(), node)];
} }
while (!((size_t)node & 1)); while (!((size_t)node & 1));
@ -510,8 +510,8 @@ sector_t *AActor::LinkToWorldForMapThing ()
// one-sided line might go into a subsector behind the line, so // one-sided line might go into a subsector behind the line, so
// the line would not be included as one of its subsector's segs. // the line would not be included as one of its subsector's segs.
int blockx = GetSafeBlockX(x - bmaporgx); int blockx = GetSafeBlockX(X() - bmaporgx);
int blocky = GetSafeBlockY(y - bmaporgy); int blocky = GetSafeBlockY(Y() - bmaporgy);
if ((unsigned int)blockx < (unsigned int)bmapwidth && if ((unsigned int)blockx < (unsigned int)bmapwidth &&
(unsigned int)blocky < (unsigned int)bmapheight) (unsigned int)blocky < (unsigned int)bmapheight)
@ -536,10 +536,10 @@ sector_t *AActor::LinkToWorldForMapThing ()
} }
// Not inside the line's bounding box // Not inside the line's bounding box
if (x + radius <= ldef->bbox[BOXLEFT] if (X() + radius <= ldef->bbox[BOXLEFT]
|| x - radius >= ldef->bbox[BOXRIGHT] || X() - radius >= ldef->bbox[BOXRIGHT]
|| y + radius <= ldef->bbox[BOXBOTTOM] || Y() + radius <= ldef->bbox[BOXBOTTOM]
|| y - radius >= ldef->bbox[BOXTOP] ) || Y() - radius >= ldef->bbox[BOXTOP] )
continue; continue;
// Get the exact distance to the line // Get the exact distance to the line
@ -548,8 +548,8 @@ sector_t *AActor::LinkToWorldForMapThing ()
P_MakeDivline (ldef, &dll); P_MakeDivline (ldef, &dll);
dlv.x = x; dlv.x = X();
dlv.y = y; dlv.y = Y();
dlv.dx = FixedDiv(dll.dy, linelen); dlv.dx = FixedDiv(dll.dy, linelen);
dlv.dy = -FixedDiv(dll.dx, linelen); dlv.dy = -FixedDiv(dll.dx, linelen);
@ -558,7 +558,7 @@ sector_t *AActor::LinkToWorldForMapThing ()
if (distance < radius) if (distance < radius)
{ {
DPrintf ("%s at (%d,%d) lies on %s line %td, distance = %f\n", DPrintf ("%s at (%d,%d) lies on %s line %td, distance = %f\n",
this->GetClass()->TypeName.GetChars(), x>>FRACBITS, y>>FRACBITS, this->GetClass()->TypeName.GetChars(), X()>>FRACBITS, Y()>>FRACBITS,
ldef->dx == 0? "vertical" : ldef->dy == 0? "horizontal" : "diagonal", ldef->dx == 0? "vertical" : ldef->dy == 0? "horizontal" : "diagonal",
ldef-lines, FIXED2FLOAT(distance)); ldef-lines, FIXED2FLOAT(distance));
angle_t finean = R_PointToAngle2 (0, 0, ldef->dx, ldef->dy); angle_t finean = R_PointToAngle2 (0, 0, ldef->dx, ldef->dy);
@ -574,9 +574,8 @@ sector_t *AActor::LinkToWorldForMapThing ()
// Get the distance we have to move the object away from the wall // Get the distance we have to move the object away from the wall
distance = radius - distance; distance = radius - distance;
x += FixedMul(distance, finecosine[finean]); SetXY(X() + FixedMul(distance, finecosine[finean]), Y() + FixedMul(distance, finesine[finean]));
y += FixedMul(distance, finesine[finean]); return P_PointInSector (X(), Y());
return P_PointInSector (x, y);
} }
} }
} }
@ -588,9 +587,8 @@ sector_t *AActor::LinkToWorldForMapThing ()
void AActor::SetOrigin (fixed_t ix, fixed_t iy, fixed_t iz, bool moving) void AActor::SetOrigin (fixed_t ix, fixed_t iy, fixed_t iz, bool moving)
{ {
UnlinkFromWorld (); UnlinkFromWorld ();
x = ix; SetXYZ(ix, iy, iz);
y = iy; if (moving) SetMovement(ix - X(), iy - Y(), iz - Z());
z = iz;
LinkToWorld (); LinkToWorld ();
floorz = Sector->floorplane.ZatPoint (ix, iy); floorz = Sector->floorplane.ZatPoint (ix, iy);
ceilingz = Sector->ceilingplane.ZatPoint (ix, iy); ceilingz = Sector->ceilingplane.ZatPoint (ix, iy);
@ -878,8 +876,8 @@ AActor *FBlockThingsIterator::Next(bool centeronly)
fixed_t blocktop = blockbottom + MAPBLOCKSIZE; fixed_t blocktop = blockbottom + MAPBLOCKSIZE;
// only return actors with the center in this block // only return actors with the center in this block
if (me->x >= blockleft && me->x < blockright && if (me->X() >= blockleft && me->X() < blockright &&
me->y >= blockbottom && me->y < blocktop) me->Y() >= blockbottom && me->Y() < blocktop)
{ {
return me; return me;
} }
@ -1028,29 +1026,29 @@ void FPathTraverse::AddThingIntercepts (int bx, int by, FBlockThingsIterator &it
switch (i) switch (i)
{ {
case 0: // Top edge case 0: // Top edge
line.x = thing->x + thing->radius; line.x = thing->X() + thing->radius;
line.y = thing->y + thing->radius; line.y = thing->Y() + thing->radius;
line.dx = -thing->radius * 2; line.dx = -thing->radius * 2;
line.dy = 0; line.dy = 0;
break; break;
case 1: // Right edge case 1: // Right edge
line.x = thing->x + thing->radius; line.x = thing->X() + thing->radius;
line.y = thing->y - thing->radius; line.y = thing->Y() - thing->radius;
line.dx = 0; line.dx = 0;
line.dy = thing->radius * 2; line.dy = thing->radius * 2;
break; break;
case 2: // Bottom edge case 2: // Bottom edge
line.x = thing->x - thing->radius; line.x = thing->X() - thing->radius;
line.y = thing->y - thing->radius; line.y = thing->Y() - thing->radius;
line.dx = thing->radius * 2; line.dx = thing->radius * 2;
line.dy = 0; line.dy = 0;
break; break;
case 3: // Left edge case 3: // Left edge
line.x = thing->x - thing->radius; line.x = thing->X() - thing->radius;
line.y = thing->y + thing->radius; line.y = thing->Y() + thing->radius;
line.dx = 0; line.dx = 0;
line.dy = thing->radius * -2; line.dy = thing->radius * -2;
break; break;
@ -1107,19 +1105,19 @@ void FPathTraverse::AddThingIntercepts (int bx, int by, FBlockThingsIterator &it
// check a corner to corner crossection for hit // check a corner to corner crossection for hit
if (tracepositive) if (tracepositive)
{ {
x1 = thing->x - thing->radius; x1 = thing->X() - thing->radius;
y1 = thing->y + thing->radius; y1 = thing->Y() + thing->radius;
x2 = thing->x + thing->radius; x2 = thing->X() + thing->radius;
y2 = thing->y - thing->radius; y2 = thing->Y() - thing->radius;
} }
else else
{ {
x1 = thing->x - thing->radius; x1 = thing->X() - thing->radius;
y1 = thing->y - thing->radius; y1 = thing->Y() - thing->radius;
x2 = thing->x + thing->radius; x2 = thing->X() + thing->radius;
y2 = thing->y + thing->radius; y2 = thing->Y() + thing->radius;
} }
s1 = P_PointOnDivlineSide (x1, y1, &trace); s1 = P_PointOnDivlineSide (x1, y1, &trace);
@ -1422,8 +1420,8 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in
int count; int count;
AActor *target; AActor *target;
startX = GetSafeBlockX(mo->x-bmaporgx); startX = GetSafeBlockX(mo->X()-bmaporgx);
startY = GetSafeBlockY(mo->y-bmaporgy); startY = GetSafeBlockY(mo->Y()-bmaporgy);
validcount++; validcount++;
if (startX >= 0 && startX < bmapwidth && startY >= 0 && startY < bmapheight) if (startX >= 0 && startX < bmapwidth && startY >= 0 && startY < bmapheight)