- added NULL pointer check to portal rotation calculation function.

This commit is contained in:
Christoph Oelckers 2016-03-12 22:37:43 +01:00
parent 0a92138edf
commit 8c027aef8b
1 changed files with 9 additions and 6 deletions

View File

@ -245,12 +245,15 @@ static line_t *FindDestination(line_t *src, int tag)
static void SetRotation(FLinePortal *port) static void SetRotation(FLinePortal *port)
{ {
line_t *dst = port->mDestination; if (port != NULL && port->mDestination != NULL)
line_t *line = port->mOrigin; {
double angle = atan2(dst->dy, dst->dx) - atan2(line->dy, line->dx) + M_PI; line_t *dst = port->mDestination;
port->mSinRot = FLOAT2FIXED(sin(angle)); line_t *line = port->mOrigin;
port->mCosRot = FLOAT2FIXED(cos(angle)); double angle = atan2(dst->dy, dst->dx) - atan2(line->dy, line->dx) + M_PI;
port->mAngleDiff = RAD2ANGLE(angle); port->mSinRot = FLOAT2FIXED(sin(angle));
port->mCosRot = FLOAT2FIXED(cos(angle));
port->mAngleDiff = RAD2ANGLE(angle);
}
} }
//============================================================================ //============================================================================