+typedef enum waterlevel_e
+{
+ WATERLEVEL_NONE,
+ WATERLEVEL_WETFEET,
+ WATERLEVEL_SWIMMING,
+ WATERLEVEL_SUBMERGED
+}
+waterlevel_t;
+
+typedef struct cl_clientmovement_state_s
+{
+ // position
+ vec3_t origin;
+ vec3_t velocity;
+ // current bounding box (different if crouched vs standing)
+ vec3_t mins;
+ vec3_t maxs;
+ // currently on the ground
+ qboolean onground;
+ // currently crouching
+ qboolean crouched;
+ // whether jump button has been released since last jump
+ qboolean canjump;
+ // what kind of water (SUPERCONTENTS_LAVA for instance)
+ int watertype;
+ // how deep
+ waterlevel_t waterlevel;
+ // weird hacks when jumping out of water
+ // (this is in seconds and counts down to 0)
+ float waterjumptime;
+
+ // movement parameters for physics code
+ float movevars_gravity;
+ float movevars_stopspeed;
+ float movevars_maxspeed;
+ float movevars_spectatormaxspeed;
+ float movevars_accelerate;
+ float movevars_airaccelerate;
+ float movevars_wateraccelerate;
+ float movevars_friction;
+ float movevars_waterfriction;
+ float movevars_entgravity;
+ float movevars_jumpvelocity;
+ float movevars_edgefriction;
+ float movevars_maxairspeed;
+ float movevars_stepheight;
+
+ // user command
+ client_movementqueue_t q;
+}
+cl_clientmovement_state_t;
+
+#define NUMOFFSETS 27
+static vec3_t offsets[NUMOFFSETS] =
+{
+// 1 no nudge (just return the original if this test passes)
+ { 0.000, 0.000, 0.000},
+// 6 simple nudges
+ { 0.000, 0.000, 0.125}, { 0.000, 0.000, -0.125},
+ {-0.125, 0.000, 0.000}, { 0.125, 0.000, 0.000},
+ { 0.000, -0.125, 0.000}, { 0.000, 0.125, 0.000},
+// 4 diagonal flat nudges
+ {-0.125, -0.125, 0.000}, { 0.125, -0.125, 0.000},
+ {-0.125, 0.125, 0.000}, { 0.125, 0.125, 0.000},
+// 8 diagonal upward nudges
+ {-0.125, 0.000, 0.125}, { 0.125, 0.000, 0.125},
+ { 0.000, -0.125, 0.125}, { 0.000, 0.125, 0.125},
+ {-0.125, -0.125, 0.125}, { 0.125, -0.125, 0.125},
+ {-0.125, 0.125, 0.125}, { 0.125, 0.125, 0.125},
+// 8 diagonal downward nudges
+ {-0.125, 0.000, -0.125}, { 0.125, 0.000, -0.125},
+ { 0.000, -0.125, -0.125}, { 0.000, 0.125, -0.125},
+ {-0.125, -0.125, -0.125}, { 0.125, -0.125, -0.125},
+ {-0.125, 0.125, -0.125}, { 0.125, 0.125, -0.125},
+};
+
+qboolean CL_ClientMovement_Unstick(cl_clientmovement_state_t *s)