From 8c027aef8b51903860c8fd44f8776c23447b6576 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Mar 2016 22:37:43 +0100 Subject: [PATCH] - added NULL pointer check to portal rotation calculation function. --- src/portal.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/portal.cpp b/src/portal.cpp index 013403ba5..a9dd40487 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -245,12 +245,15 @@ static line_t *FindDestination(line_t *src, int tag) static void SetRotation(FLinePortal *port) { - line_t *dst = port->mDestination; - line_t *line = port->mOrigin; - double angle = atan2(dst->dy, dst->dx) - atan2(line->dy, line->dx) + M_PI; - port->mSinRot = FLOAT2FIXED(sin(angle)); - port->mCosRot = FLOAT2FIXED(cos(angle)); - port->mAngleDiff = RAD2ANGLE(angle); + if (port != NULL && port->mDestination != NULL) + { + line_t *dst = port->mDestination; + line_t *line = port->mOrigin; + double angle = atan2(dst->dy, dst->dx) - atan2(line->dy, line->dx) + M_PI; + port->mSinRot = FLOAT2FIXED(sin(angle)); + port->mCosRot = FLOAT2FIXED(cos(angle)); + port->mAngleDiff = RAD2ANGLE(angle); + } } //============================================================================