Fix DivideByZero crashes in Railgun projectile

This commit is contained in:
reaperrr
2019-05-13 01:07:15 +02:00
committed by reaperrr
parent 90325305d6
commit a2775a5c0f

View File

@@ -153,14 +153,17 @@ namespace OpenRA.Mods.Common.Projectiles
// An easy vector to find which is perpendicular vector to forwardStep, with 0 Z component
LeftVector = new WVec(ForwardStep.Y, -ForwardStep.X, 0);
LeftVector = 1024 * LeftVector / LeftVector.Length;
if (LeftVector.LengthSquared != 0)
LeftVector = 1024 * LeftVector / LeftVector.Length;
// Vector that is pointing upwards from the ground
UpVector = new WVec(
-ForwardStep.X * ForwardStep.Z,
-ForwardStep.Z * ForwardStep.Y,
ForwardStep.X * ForwardStep.X + ForwardStep.Y * ForwardStep.Y);
UpVector = 1024 * UpVector / UpVector.Length;
if (UpVector.LengthSquared != 0)
UpVector = 1024 * UpVector / UpVector.Length;
//// LeftVector and UpVector are unit vectors of size 1024.