Bug in vecmat.cpp:
Comment mentions the third paramter can be NULL, but never checks for it and always tries to normalize it.
If this function is used with the third paramter being NULL, the game crashes.
I'll ask Backslash to commit this fix so no need for someone else to do it. Just wanted to mention this here, in case someone
might find out that this was actually causing some crashes that haven't been explained yet...
//computes the delta angle between two vectors.
//vectors need not be normalized. if they are, call vm_vec_delta_ang_norm()
//the forward vector (third parameter) can be NULL, in which case the absolute
//value of the angle in returned. Otherwise the angle around that vector is
//returned.
float vm_vec_delta_ang(vec3d *v0,vec3d *v1,vec3d *fvec)
{
float t;
vec3d t0,t1,t2;
vm_vec_copy_normalize(&t0,v0);
vm_vec_copy_normalize(&t1,v1);
// This test here is new and was missing. Function tried to always normalize fvec which used to cause a crash.
if (NULL == fvec) {
t = vm_vec_delta_ang_norm(&t0, &t1, NULL);
} else {
vm_vec_copy_normalize(&t2,fvec);
t = vm_vec_delta_ang_norm(&t0,&t1,&t2);
}
return t;
}