Fixed Vector unary minus operator modifying the instance itself

This commit is contained in:
Blixibon 2021-04-21 15:09:52 -05:00
parent b718f19d45
commit 491b258f70

View File

@ -464,7 +464,12 @@ namespace SQVector
return sq_throwerror(vm, "Expected (Vector)");
}
v1->Negate();
sq_getclass(vm, 1);
sq_createinstance(vm, -1);
SQUserPointer p;
sq_getinstanceup(vm, -1, &p, 0);
new(p) Vector(-v1->x, -v1->y, -v1->z);
sq_remove(vm, -2);
return 1;
}