andrei-drexler / ironwail

High-performance QuakeSpasm fork
GNU General Public License v2.0
480 stars 43 forks source link

[bug] `viewpos` - `setpos` inconsistency #271

Closed alexkiri closed 7 months ago

alexkiri commented 7 months ago

Using these console commands has a slight inconsistency, as can be seen below. The commands were entered consecutively, without closing the console image

The 2nd viewpos shows a different position

andrei-drexler commented 7 months ago

There are several issues at play here. setpos is executed on the server, where the pitch gets set to 6 degrees. This value is then sent to the client encoded in a 16-bit integer, which doesn't exactly map to 6, but rather 5.99853515625. viewpos is executed on the client, but the value is printed using truncation, so it outputs 5 in this case and not 6, which would be a much closer representation. I've changed the printing code to use rounding in f1dea3d0aa83b90f7719e598fc86e428be439301. The network protocol does support sending angles as full floats (avoiding precision loss), but that is a global option, it can't be enabled just for player entities.