#if !XONOTIC
entity me;
- /** 6 bits provides up to 64 remembered states */
- const int SNAP_BITS = 13;
- .int snap;
- .float times[1 << SNAP_BITS];
+ /** 6 bits provides up to 64 remembered states */
+ const int SNAP_BITS = 13;
+ .int snap;
+ .float times[1 << SNAP_BITS];
void CSQC_Init()
{
void CSQC_Ent_Update(bool isnew)
{
- SELFPARAM();
- int id = ReadByte();
- entity recv = LinkedEntities_from(id);
- if (isnew) this.classname = recv.netname;
- if (recv) recv.m_read(this, NULL, isnew);
+ SELFPARAM();
+ int id = ReadByte();
+ entity recv = LinkedEntities_from(id);
+ if (isnew) this.classname = recv.netname;
+ if (recv) recv.m_read(this, NULL, isnew);
}
void rec()
{
- me.ARRAY_INDEX(float, times, me.snap) = time;
- // me.times[me.snap] = time;
- me.snap = (me.snap + 1) & BITS(SNAP_BITS);
+ me.ARRAY_INDEX(float, times, me.snap) = time;
+ // me.times[me.snap] = time;
+ me.snap = (me.snap + 1) & BITS(SNAP_BITS);
}
NET_HANDLE(ENT_OBJECT, bool isnew)
{
- if (isnew)
- {
- this.com_phys = true;
- precache_model("models/player/erebus.iqm");
- _setmodel(this, "models/player/erebus.iqm");
- this.drawmask = MASK_NORMAL;
- }
- this.com_phys_pos_prev = this.com_phys_pos;
- this.com_phys_ang_prev = this.com_phys_ang;
- serialize(ENT_OBJECT, 0, this);
- this.com_phys_pos = this.origin;
- this.com_phys_ang = this.angles;
- return true;
+ if (isnew)
+ {
+ this.com_phys = true;
+ precache_model("models/player/erebus.iqm");
+ _setmodel(this, "models/player/erebus.iqm");
+ this.drawmask = MASK_NORMAL;
+ }
+ this.com_phys_pos_prev = this.com_phys_pos;
+ this.com_phys_ang_prev = this.com_phys_ang;
+ serialize(ENT_OBJECT, 0, this);
+ this.com_phys_pos = this.origin;
+ this.com_phys_ang = this.angles;
+ return true;
}
void CSQC_UpdateView(float w, float h)
float friction = this.com_phys_friction;
float gravity = this.com_phys_gravity;
bool noclip = this.com_phys_noclip;
- if (noclip) {
- jump = false;
- nogravityonground = false;
+ if (noclip)
+ {
+ jump = false;
+ nogravityonground = false;
}
vector g = upvec * -gravity;
{
if (nogravityonground)
{
- g = '0 0 0';
- if (vel * upvec < 0) vel = vec_reflect(vel, upvec, 0); // kill downward velocity
+ g = '0 0 0';
+ if (vel * upvec < 0) vel = vec_reflect(vel, upvec, 0); // kill downward velocity
}
if (jump)
{
bool foundground = false; // assume until proven otherwise
if (nogravityonground) foundground = true; // override
bool steplimit = 1;
- if (noclip) pass = true; else
- for (int i = 0; i < PHYSICS_TRACE_PLANE_MAX; ++i)
+ if (noclip)
+ {
+ pass = true;
+ }
+ else
{
- vector p0 = pos;
- vector p1 = p0 + step;
- tracebox(p0, mn, mx, p1, MOVE_NORMAL, this);
- float frac = trace_fraction;
- vector norm = trace_plane_normal;
- if (frac == 1)
+ for (int i = 0; i < PHYSICS_TRACE_PLANE_MAX; ++i)
{
- // all clear
- if (steplimit > 0 && onground && vel * upvec <= 0)
+ vector p0 = pos;
+ vector p1 = p0 + step;
+ tracebox(p0, mn, mx, p1, MOVE_NORMAL, this);
+ float frac = trace_fraction;
+ vector norm = trace_plane_normal;
+ if (frac == 1)
{
- // can we step down?
- tracebox(p1, mn, mx, p1 + upvec * stepdownheight, MOVE_NORMAL, this);
- if (trace_fraction == 1)
+ // all clear
+ if (steplimit > 0 && onground && vel * upvec <= 0)
{
- // no stairs here
- }
- else if (trace_plane_normal * upvec >= maxstepdot)
- {
- // step down
- step += upvec * (stepdownheight * trace_fraction);
+ // can we step down?
+ tracebox(p1, mn, mx, p1 + upvec * stepdownheight, MOVE_NORMAL, this);
+ if (trace_fraction == 1)
+ {
+ // no stairs here
+ }
+ else if (trace_plane_normal * upvec >= maxstepdot)
+ {
+ // step down
+ step += upvec * (stepdownheight * trace_fraction);
+ }
}
+ pass = true;
+ break;
}
- pass = true;
- break;
- }
- // hit something
- if (norm * upvec >= maxgrounddot) foundground = true;
- if (steplimit > 0 && (jumpstep || onground)) // try: vel * upvec >= 0
- {
- // can we step up?
- vector slide = vec_reflect(step, upvec, 0); // remove fall component
- vector p1 = p0 + slide; // step is here
- tracebox(p1 + upvec * stepheight, mn, mx, p1, MOVE_NORMAL, this);
- if (trace_fraction < 1 && trace_plane_normal * upvec >= maxstepdot)
+ // hit something
+ if (norm * upvec >= maxgrounddot) foundground = true;
+ if (steplimit > 0 && (jumpstep || onground)) // try: vel * upvec >= 0
{
- // there is a step in front of us, get above it
- // TODO: not if it's slippery (slick)
- vector stepup = upvec * (1 - trace_fraction) * stepheight;
- tracebox(p0, mn, mx, p0 + stepup, MOVE_NORMAL, this);
- if (trace_fraction == 1)
+ // can we step up?
+ vector slide = vec_reflect(step, upvec, 0); // remove fall component
+ vector p1 = p0 + slide; // step is here
+ tracebox(p1 + upvec * stepheight, mn, mx, p1, MOVE_NORMAL, this);
+ if (trace_fraction < 1 && trace_plane_normal * upvec >= maxstepdot)
{
- // go over
- tracebox(p0 + stepup, mn, mx, p1 + stepup, MOVE_NORMAL, this);
+ // there is a step in front of us, get above it
+ // TODO: not if it's slippery (slick)
+ vector stepup = upvec * (1 - trace_fraction) * stepheight;
+ tracebox(p0, mn, mx, p0 + stepup, MOVE_NORMAL, this);
if (trace_fraction == 1)
{
- // all clear
- steplimit -= 1;
- pos += stepup;
- if (vel * upvec < 0) vel = vec_reflect(vel, upvec, 0); // kill downward velocity
- step = p1 - p0;
- pass = true;
- break;
+ // go over
+ tracebox(p0 + stepup, mn, mx, p1 + stepup, MOVE_NORMAL, this);
+ if (trace_fraction == 1)
+ {
+ // all clear
+ steplimit -= 1;
+ pos += stepup;
+ if (vel * upvec < 0) vel = vec_reflect(vel, upvec, 0); // kill downward velocity
+ step = p1 - p0;
+ pass = true;
+ break;
+ }
}
}
}
+ // no stairs here
+ pos += frac * step;
+ vel = vec_reflect(vel, norm, bounce);
+ step = (1 - frac) * vel * dt;
+ continue;
}
- // no stairs here
- pos += frac * step;
- vel = vec_reflect(vel, norm, bounce);
- step = (1 - frac) * vel * dt;
- continue;
}
if (nogravityonground)
{