From 5b147176f24ab32c6b5c6109eb7542820b5e51f9 Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 28 Apr 2016 08:31:26 +1000 Subject: [PATCH] Uncrustify --- qcsrc/ecs/cl_main.qc | 50 +++++++------- qcsrc/ecs/components/physics.qh | 6 +- qcsrc/ecs/sv_main.qc | 15 ++-- qcsrc/ecs/systems/physics.qc | 117 +++++++++++++++++--------------- 4 files changed, 99 insertions(+), 89 deletions(-) diff --git a/qcsrc/ecs/cl_main.qc b/qcsrc/ecs/cl_main.qc index c1d87524b..dd9a9fbbd 100644 --- a/qcsrc/ecs/cl_main.qc +++ b/qcsrc/ecs/cl_main.qc @@ -3,10 +3,10 @@ #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() { @@ -26,35 +26,35 @@ 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) diff --git a/qcsrc/ecs/components/physics.qh b/qcsrc/ecs/components/physics.qh index 09685a7d1..4d4e63b5f 100644 --- a/qcsrc/ecs/components/physics.qh +++ b/qcsrc/ecs/components/physics.qh @@ -2,8 +2,10 @@ // TODO: store more frames for interpolation COMPONENT(phys); -.vector com_phys_pos; .vector com_phys_pos_prev; -.vector com_phys_ang; .vector com_phys_ang_prev; +.vector com_phys_pos; +.vector com_phys_pos_prev; +.vector com_phys_ang; +.vector com_phys_ang_prev; .vector com_phys_vel; .vector com_phys_acc; diff --git a/qcsrc/ecs/sv_main.qc b/qcsrc/ecs/sv_main.qc index e3a36e4e6..05ccda11a 100644 --- a/qcsrc/ecs/sv_main.qc +++ b/qcsrc/ecs/sv_main.qc @@ -5,17 +5,18 @@ entity testent; -bool net_object_send(entity this, entity to, int sendflags) { - WriteHeader(MSG_ENTITY, ENT_OBJECT); - serialize(ENT_OBJECT, MSG_ENTITY, this); - return true; +bool net_object_send(entity this, entity to, int sendflags) +{ + WriteHeader(MSG_ENTITY, ENT_OBJECT); + serialize(ENT_OBJECT, MSG_ENTITY, this); + return true; } void spawnfunc_worldspawn() { - static_init(); - static_init_late(); - // static_init_precache(); + static_init(); + static_init_late(); + // static_init_precache(); entity it = testent = spawn(); precache_model("models/player/erebus.iqm"); diff --git a/qcsrc/ecs/systems/physics.qc b/qcsrc/ecs/systems/physics.qc index 1eb12fbfd..f7777f01e 100644 --- a/qcsrc/ecs/systems/physics.qc +++ b/qcsrc/ecs/systems/physics.qc @@ -30,9 +30,10 @@ void sys_phys_update(entity this, float dt) 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; @@ -45,8 +46,8 @@ void sys_phys_update(entity this, float dt) { 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) { @@ -67,70 +68,76 @@ void sys_phys_update(entity this, float dt) 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) { -- 2.39.2