]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Uncrustify TimePath/ecs
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 27 Apr 2016 22:31:26 +0000 (08:31 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 27 Apr 2016 22:31:26 +0000 (08:31 +1000)
qcsrc/ecs/cl_main.qc
qcsrc/ecs/components/physics.qh
qcsrc/ecs/sv_main.qc
qcsrc/ecs/systems/physics.qc

index c1d87524bc4c07631bea99663f720585408a84a8..dd9a9fbbda8efd02bccb5dc59fcc798b75a8fe86 100644 (file)
@@ -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()
        {
 
        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)
index 09685a7d190b81c46629e8162da85f042101c3af..4d4e63b5f3643376a0b7a9f8f0bc5a2e36e3cd9a 100644 (file)
@@ -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;
 
index e3a36e4e6832dea2c5d3e6f729e31ecaf3b21c8f..05ccda11a8a0b016829de49b28161f6704e748f8 100644 (file)
@@ -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");
index 1eb12fbfda900302e3d66fa6a90023133ebd267e..f7777f01ef93d178a2e94f792c09c1bcd278f5f2 100644 (file)
@@ -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)
                {