- tests: fix undefined float-to-short conversion in testClampRad
  c1dea15fa0f1c1beb593133fc4061f9c684f6a15

Index: test/engine/System/testClampRad.cpp
--- test/engine/System/testClampRad.cpp.orig
+++ test/engine/System/testClampRad.cpp
@@ -8,6 +8,19 @@
 
 #include <catch_amalgamated.hpp>
 
+// COB scripts encode angles as TA units where a full turn is COBSCALE (65536),
+// so any angle past a half turn exceeds the range of a signed short and is meant
+// to wrap around (it is a circular 16-bit angle). Truncating the scaled value to
+// int first is well defined for the bounded angles the sim feeds in, and the
+// following int->short narrowing performs that modular wrap deterministically.
+// Converting straight from float to short would be undefined behaviour once the
+// value leaves short's range, and produced different results on arm64 vs x86,
+// desyncing multiplayer.
+static inline short RadAngleToCobShort(float radAngle)
+{
+	return static_cast<short>(static_cast<int>(radAngle * RAD2TAANG));
+}
+
 InitSpringTime ist;
 
 TEST_CASE("ClampRad")
@@ -43,10 +56,10 @@ TEST_CASE("ClampRad")
 	CHECK_FALSE(std::signbit(ClampRad(0.0f)));
 
 	// Test TAANG2RAD conversion to short for [0, 2pi)
-	CHECK(static_cast<short>(ClampRad(0.0f) * RAD2TAANG) == short(0));
-	CHECK(static_cast<short>(ClampRad(+std::nextafterf(math::TWOPI, -std::numeric_limits<float>::infinity())) * RAD2TAANG) == short(-1));
-	CHECK(static_cast<short>(ClampRad(+std::nextafterf(       0.0f, +std::numeric_limits<float>::infinity())) * RAD2TAANG) == short( 0));
-	CHECK(static_cast<short>(ClampRad(+std::nextafterf(TAANG2RAD  , +std::numeric_limits<float>::infinity())) * RAD2TAANG) == short(+1));
+	CHECK(RadAngleToCobShort(ClampRad(0.0f)) == short(0));
+	CHECK(RadAngleToCobShort(ClampRad(+std::nextafterf(math::TWOPI, -std::numeric_limits<float>::infinity()))) == short(-1));
+	CHECK(RadAngleToCobShort(ClampRad(+std::nextafterf(       0.0f, +std::numeric_limits<float>::infinity()))) == short( 0));
+	CHECK(RadAngleToCobShort(ClampRad(+std::nextafterf(TAANG2RAD  , +std::numeric_limits<float>::infinity()))) == short(+1));
 }
 
 TEST_CASE("ClampRadPi")
