From a2468bb18488d171ea8e73af7626af8c1e315db1 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 6 Jun 2023 00:53:05 +0200 Subject: [PATCH] Normalize view angles in client's usercmd Must be normalized, bad values (NAN or FLT_MAX) will crash the game. There is more that needs to be clamped, but before we can do this CUserCmd has to be reversed more. --- r5dev/game/shared/usercmd.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/r5dev/game/shared/usercmd.cpp b/r5dev/game/shared/usercmd.cpp index 59d7b8ad..14ca240a 100644 --- a/r5dev/game/shared/usercmd.cpp +++ b/r5dev/game/shared/usercmd.cpp @@ -16,6 +16,12 @@ //----------------------------------------------------------------------------- int ReadUserCmd(bf_read* buf, CUserCmd* move, CUserCmd* from) { + // Normalize angles, bogus values will crash the game.. + from->viewangles.Normalize(); + + // More clamps coming soon... + + const int seed = v_ReadUserCmd(buf, move, from); // On the client, the frame time must be within 'usercmd_frametime_min'