+
+ // update the onground flag if appropriate
+ // when not predicted, cl.onground is only cleared by cl_parse.c, but can
+ // be set forcefully here to hide server inconsistencies in the onground
+ // flag (such as when stepping up stairs, the onground flag tends to turn
+ // off briefly due to precision errors, particularly at high framerates),
+ // such inconsistencies can mess up the gun bobbing and stair smoothing,
+ // so they must be avoided.
+ if (cl.movement_predicted)
+ cl.onground = s.onground;
+ else if (s.onground)
+ cl.onground = true;
+
+ // react to onground state changes (for gun bob)
+ if (cl.onground)
+ {
+ if (!cl.oldonground)
+ cl.hitgroundtime = cl.time;
+ cl.lastongroundtime = cl.time;
+ }
+ cl.oldonground = cl.onground;