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); + } } //============================================================================