added "checkmobjs" boolean to both Polyobj_moveXY and Polyobj_rotate, so we can disable interaction with mobjs for netgames

This commit is contained in:
Monster Iestyn 2019-04-05 12:03:03 +01:00
parent 1d401d8481
commit 212be85655

View file

@ -1154,7 +1154,7 @@ static INT32 Polyobj_clipThings(polyobj_t *po, line_t *line)
// //
// Moves a polyobject on the x-y plane. // Moves a polyobject on the x-y plane.
// //
static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y) static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y, boolean checkmobjs)
{ {
size_t i; size_t i;
vertex_t vec; vertex_t vec;
@ -1175,9 +1175,12 @@ static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y)
for (i = 0; i < po->numLines; ++i) for (i = 0; i < po->numLines; ++i)
Polyobj_bboxAdd(po->lines[i]->bbox, &vec); Polyobj_bboxAdd(po->lines[i]->bbox, &vec);
// check for blocking things (yes, it needs to be done separately) if (checkmobjs)
for (i = 0; i < po->numLines; ++i) {
hitflags |= Polyobj_clipThings(po, po->lines[i]); // check for blocking things (yes, it needs to be done separately)
for (i = 0; i < po->numLines; ++i)
hitflags |= Polyobj_clipThings(po, po->lines[i]);
}
if (hitflags & 2) if (hitflags & 2)
{ {
@ -1195,7 +1198,8 @@ static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y)
po->spawnSpot.x += vec.x; po->spawnSpot.x += vec.x;
po->spawnSpot.y += vec.y; po->spawnSpot.y += vec.y;
Polyobj_carryThings(po, x, y); if (checkmobjs)
Polyobj_carryThings(po, x, y);
Polyobj_removeFromBlockmap(po); // unlink it from the blockmap Polyobj_removeFromBlockmap(po); // unlink it from the blockmap
Polyobj_removeFromSubsec(po); // unlink it from its subsector Polyobj_removeFromSubsec(po); // unlink it from its subsector
Polyobj_linkToBlockmap(po); // relink to blockmap Polyobj_linkToBlockmap(po); // relink to blockmap
@ -1362,7 +1366,7 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta,
// //
// Rotates a polyobject around its start point. // Rotates a polyobject around its start point.
// //
static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings) static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings, boolean checkmobjs)
{ {
size_t i; size_t i;
angle_t angle; angle_t angle;
@ -1394,11 +1398,14 @@ static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings)
for (i = 0; i < po->numLines; ++i) for (i = 0; i < po->numLines; ++i)
Polyobj_rotateLine(po->lines[i]); Polyobj_rotateLine(po->lines[i]);
// check for blocking things if (checkmobjs)
for (i = 0; i < po->numLines; ++i) {
hitflags |= Polyobj_clipThings(po, po->lines[i]); // check for blocking things
for (i = 0; i < po->numLines; ++i)
hitflags |= Polyobj_clipThings(po, po->lines[i]);
Polyobj_rotateThings(po, origin, delta, turnthings); Polyobj_rotateThings(po, origin, delta, turnthings);
}
if (hitflags & 2) if (hitflags & 2)
{ {
@ -1614,19 +1621,23 @@ void Polyobj_InitLevel(void)
// Called when a savegame is being loaded. Rotates and translates an // Called when a savegame is being loaded. Rotates and translates an
// existing polyobject to its position when the game was saved. // existing polyobject to its position when the game was saved.
// //
// Monster Iestyn 05/04/19: Please do not interact with mobjs! You
// can cause I_Error crashes that way, and all the important mobjs are
// going to be deleted afterwards anyway.
//
void Polyobj_MoveOnLoad(polyobj_t *po, angle_t angle, fixed_t x, fixed_t y) void Polyobj_MoveOnLoad(polyobj_t *po, angle_t angle, fixed_t x, fixed_t y)
{ {
fixed_t dx, dy; fixed_t dx, dy;
// first, rotate to the saved angle // first, rotate to the saved angle
Polyobj_rotate(po, angle, false); Polyobj_rotate(po, angle, false, false);
// determine component distances to translate // determine component distances to translate
dx = x - po->spawnSpot.x; dx = x - po->spawnSpot.x;
dy = y - po->spawnSpot.y; dy = y - po->spawnSpot.y;
// translate // translate
Polyobj_moveXY(po, dx, dy); Polyobj_moveXY(po, dx, dy, false);
} }
// Thinker Functions // Thinker Functions
@ -1666,7 +1677,7 @@ void T_PolyObjRotate(polyrotate_t *th)
// rotate by 'speed' angle per frame // rotate by 'speed' angle per frame
// if distance == -1, this polyobject rotates perpetually // if distance == -1, this polyobject rotates perpetually
if (Polyobj_rotate(po, th->speed, th->turnobjs) && th->distance != -1) if (Polyobj_rotate(po, th->speed, th->turnobjs, true) && th->distance != -1)
{ {
INT32 avel = abs(th->speed); INT32 avel = abs(th->speed);
@ -1750,7 +1761,7 @@ void T_PolyObjMove(polymove_t *th)
} }
// move the polyobject one step along its movement angle // move the polyobject one step along its movement angle
if (Polyobj_moveXY(po, th->momx, th->momy)) if (Polyobj_moveXY(po, th->momx, th->momy, true))
{ {
INT32 avel = abs(th->speed); INT32 avel = abs(th->speed);
@ -1864,7 +1875,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
fixed_t diffz; fixed_t diffz;
amtx = (target->x - th->diffx) - po->centerPt.x; amtx = (target->x - th->diffx) - po->centerPt.x;
amty = (target->y - th->diffy) - po->centerPt.y; amty = (target->y - th->diffy) - po->centerPt.y;
Polyobj_moveXY(po, amtx, amty); Polyobj_moveXY(po, amtx, amty, true);
// TODO: use T_MovePlane // TODO: use T_MovePlane
amtz = (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2; amtz = (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2;
diffz = po->lines[0]->backsector->floorheight - (target->z - amtz); diffz = po->lines[0]->backsector->floorheight - (target->z - amtz);
@ -1880,7 +1891,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
if (po->isBad) if (po->isBad)
continue; continue;
Polyobj_moveXY(po, amtx, amty); Polyobj_moveXY(po, amtx, amty, true);
// TODO: use T_MovePlane // TODO: use T_MovePlane
po->lines[0]->backsector->floorheight += diffz; // move up/down by same amount as the parent did po->lines[0]->backsector->floorheight += diffz; // move up/down by same amount as the parent did
po->lines[0]->backsector->ceilingheight += diffz; po->lines[0]->backsector->ceilingheight += diffz;
@ -2043,7 +2054,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
} }
// Move the polyobject // Move the polyobject
Polyobj_moveXY(po, momx, momy); Polyobj_moveXY(po, momx, momy, true);
// TODO: use T_MovePlane // TODO: use T_MovePlane
po->lines[0]->backsector->floorheight += momz; po->lines[0]->backsector->floorheight += momz;
po->lines[0]->backsector->ceilingheight += momz; po->lines[0]->backsector->ceilingheight += momz;
@ -2058,7 +2069,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
if (po->isBad) if (po->isBad)
continue; continue;
Polyobj_moveXY(po, momx, momy); Polyobj_moveXY(po, momx, momy, true);
// TODO: use T_MovePlane // TODO: use T_MovePlane
po->lines[0]->backsector->floorheight += momz; po->lines[0]->backsector->floorheight += momz;
po->lines[0]->backsector->ceilingheight += momz; po->lines[0]->backsector->ceilingheight += momz;
@ -2107,7 +2118,7 @@ void T_PolyDoorSlide(polyslidedoor_t *th)
} }
// move the polyobject one step along its movement angle // move the polyobject one step along its movement angle
if (Polyobj_moveXY(po, th->momx, th->momy)) if (Polyobj_moveXY(po, th->momx, th->momy, true))
{ {
INT32 avel = abs(th->speed); INT32 avel = abs(th->speed);
@ -2213,7 +2224,7 @@ void T_PolyDoorSwing(polyswingdoor_t *th)
// rotate by 'speed' angle per frame // rotate by 'speed' angle per frame
// if distance == -1, this polyobject rotates perpetually // if distance == -1, this polyobject rotates perpetually
if (Polyobj_rotate(po, th->speed, false) && th->distance != -1) if (Polyobj_rotate(po, th->speed, false, true) && th->distance != -1)
{ {
INT32 avel = abs(th->speed); INT32 avel = abs(th->speed);
@ -2305,7 +2316,7 @@ void T_PolyObjDisplace(polydisplace_t *th)
dx = FixedMul(th->dx, delta); dx = FixedMul(th->dx, delta);
dy = FixedMul(th->dy, delta); dy = FixedMul(th->dy, delta);
if (Polyobj_moveXY(po, dx, dy)) if (Polyobj_moveXY(po, dx, dy, true))
th->oldHeights = newheights; th->oldHeights = newheights;
} }
@ -2344,7 +2355,7 @@ void T_PolyObjRotDisplace(polyrotdisplace_t *th)
rotangle = FixedMul(th->rotscale, delta); rotangle = FixedMul(th->rotscale, delta);
if (Polyobj_rotate(po, FixedAngle(rotangle), th->turnobjs)) if (Polyobj_rotate(po, FixedAngle(rotangle), th->turnobjs, true))
th->oldHeights = newheights; th->oldHeights = newheights;
} }