From 6fd70ff32018bdd8c1e1182954390a312f7bf705 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Dec 2014 18:46:50 +0100 Subject: [PATCH] - fixed: Trying to rotate a polyobject into its actual position during loading of a savegame still inflicted damage on all touching actors - including incomplete player pawns - and also got blocked by them. Similar code already existed for the MovePolyobj function but apparently was overlooked here. --- src/p_saveg.cpp | 2 +- src/po_man.cpp | 30 +++++++++++++++++------------- src/po_man.h | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index a677420f5b..67297d800d 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -566,7 +566,7 @@ void P_SerializePolyobjs (FArchive &arc) I_Error ("UnarchivePolyobjs: Invalid polyobj tag"); } arc << angle; - po->RotatePolyobj (angle); + po->RotatePolyobj (angle, false); arc << deltaX << deltaY << po->interpolation; deltaX -= po->StartSpot.x; deltaY -= po->StartSpot.y; diff --git a/src/po_man.cpp b/src/po_man.cpp index e19acc53ab..c6e273a0f8 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1051,7 +1051,7 @@ static void RotatePt (int an, fixed_t *x, fixed_t *y, fixed_t startSpotX, fixed_ // //========================================================================== -bool FPolyObj::RotatePolyobj (angle_t angle) +bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave) { int an; bool blocked; @@ -1073,23 +1073,27 @@ bool FPolyObj::RotatePolyobj (angle_t angle) validcount++; UpdateBBox(); - for(unsigned i=0;i < Sidedefs.Size(); i++) + // If we are loading a savegame we do not really want to damage actors and be blocked by them. This can also cause crashes when trying to damage incompletely deserialized player pawns. + if (!fromsave) { - if (CheckMobjBlocking(Sidedefs[i])) + for (unsigned i = 0; i < Sidedefs.Size(); i++) { - blocked = true; + if (CheckMobjBlocking(Sidedefs[i])) + { + blocked = true; + } } - } - if (blocked) - { - for(unsigned i=0;i < Vertices.Size(); i++) + if (blocked) { - Vertices[i]->x = PrevPts[i].x; - Vertices[i]->y = PrevPts[i].y; + for(unsigned i=0;i < Vertices.Size(); i++) + { + Vertices[i]->x = PrevPts[i].x; + Vertices[i]->y = PrevPts[i].y; + } + UpdateBBox(); + LinkPolyobj(); + return false; } - UpdateBBox(); - LinkPolyobj(); - return false; } this->angle += angle; LinkPolyobj(); diff --git a/src/po_man.h b/src/po_man.h index 70ab9d3602..9e81cc2666 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -74,7 +74,7 @@ struct FPolyObj int GetMirror(); bool MovePolyobj (int x, int y, bool force = false); - bool RotatePolyobj (angle_t angle); + bool RotatePolyobj (angle_t angle, bool fromsave = false); void ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, side_t **side) const; void LinkPolyobj (); void RecalcActorFloorCeil(FBoundingBox bounds) const;