Skip to content
Permalink
Browse files

Trans_Rotate: disallow rotation around null vector (#1908)

Trans_Rotate will now raise at runtime if the user tries to generate a
rotation matrix around a null vector instead of crashing with #DE.
  • Loading branch information...
isilkor committed Apr 29, 2017
1 parent 3b1ebdc commit 33a0b4117955a4828bbe2c1cd70c069ecad2708f
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/script/C4Script.cpp
@@ -178,6 +178,11 @@ static C4ValueArray *FnTrans_Rotate(C4PropList * _this, long angle, long rx, lon
long n = long(sqrt(double(sqrt_val)));
if (n * n < sqrt_val) n++;
else if (n * n > sqrt_val) n--;

if (n == 0)
{
throw C4AulExecError("cannot rotate around a null vector");
}

rx = (1000 * rx) / n;
ry = (1000 * ry) / n;

0 comments on commit 33a0b41

Please sign in to comment.
You can’t perform that action at this time.