]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
General cleanup/optimize
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 22 Nov 2015 11:29:15 +0000 (22:29 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 22 Nov 2015 11:29:15 +0000 (22:29 +1100)
43 files changed:
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/hook.qc
qcsrc/client/hud/panel/radar.qc
qcsrc/client/main.qh
qcsrc/client/teamradar.qc
qcsrc/client/view.qc
qcsrc/client/wall.qc
qcsrc/client/weapons/projectile.qc
qcsrc/common/csqcmodel_settings.qh
qcsrc/common/ent_cs.qc
qcsrc/common/minigames/cl_minigames_hud.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/net_notice.qc
qcsrc/common/net_notice.qh
qcsrc/common/physics.qc
qcsrc/common/physics.qh
qcsrc/common/triggers/misc/laser.qc
qcsrc/common/triggers/target/music.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/common/util.qh
qcsrc/common/viewloc.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/lib/csqcmodel/cl_model.qc
qcsrc/lib/csqcmodel/cl_player.qc
qcsrc/lib/csqcmodel/cl_player.qh
qcsrc/lib/csqcmodel/common.qh
qcsrc/lib/csqcmodel/interpolate.qc
qcsrc/lib/csqcmodel/interpolate.qh
qcsrc/lib/defer.qh
qcsrc/lib/linkedlist.qh
qcsrc/lib/vector.qh
qcsrc/lib/warpzone/anglestransform.qc
qcsrc/lib/warpzone/anglestransform.qh
qcsrc/menu/xonotic/dialog_settings_effects.qc
qcsrc/menu/xonotic/dialog_teamselect.qc
qcsrc/menu/xonotic/radiobutton.qc
qcsrc/server/bot/scripting.qc
qcsrc/server/cl_client.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/portals.qc
qcsrc/server/race.qc
qcsrc/server/t_items.qc

index 51b373fb796c490283333dca934cfd22d661147e..506d35c6bb6c02a6a4dc934645c34ec66474878e 100644 (file)
@@ -348,7 +348,7 @@ void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
 }
 void CSQCPlayer_AnimDecide_PostUpdate(bool isnew)
 {SELFPARAM();
 }
 void CSQCPlayer_AnimDecide_PostUpdate(bool isnew)
 {SELFPARAM();
-       self.csqcmodel_isdead = !!(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
+       self.csqcmodel_isdead = boolean(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
 }
 int CSQCPlayer_FallbackFrame(int f)
 {SELFPARAM();
 }
 int CSQCPlayer_FallbackFrame(int f)
 {SELFPARAM();
index cee2a0cd83a1d6e64c8a9eb2b68807bc1bbf3c88..f39e8eaa45d60944cd141001484ad97452931d58 100644 (file)
@@ -41,7 +41,7 @@ void Draw_GrapplingHook(entity this)
                self.teleport_time = 0;
        }
 
                self.teleport_time = 0;
        }
 
-       InterpolateOrigin_Do();
+       InterpolateOrigin_Do(this);
 
        int s = W_GetGunAlignment(world);
 
 
        int s = W_GetGunAlignment(world);
 
@@ -171,7 +171,7 @@ NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
        self.HookSilent = (sf & 0x80);
        self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
 
        self.HookSilent = (sf & 0x80);
        self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
 
-       InterpolateOrigin_Undo();
+       InterpolateOrigin_Undo(self);
 
        if(sf & 1)
        {
 
        if(sf & 1)
        {
@@ -203,7 +203,7 @@ NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
                self.velocity_z = ReadCoord();
        }
 
                self.velocity_z = ReadCoord();
        }
 
-       InterpolateOrigin_Note();
+       InterpolateOrigin_Note(this);
 
        if(bIsNew || !self.teleport_time)
        {
 
        if(bIsNew || !self.teleport_time)
        {
index c06fcdbfe218e87ad282ac0fbec2093ec6d96ce7..1982686c9df3c54d90564942ed356858d599e239 100644 (file)
@@ -294,7 +294,7 @@ void HUD_Radar()
        if((hud_panel_radar_rotation == 0 && !hud_panel_radar_maximized) || (hud_panel_radar_maximized_rotation == 0 && hud_panel_radar_maximized))
        {
                // max-min distance must fit the radar in any rotation
        if((hud_panel_radar_rotation == 0 && !hud_panel_radar_maximized) || (hud_panel_radar_maximized_rotation == 0 && hud_panel_radar_maximized))
        {
                // max-min distance must fit the radar in any rotation
-               bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
+               bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen(vec2(mi_scale)));
        }
        else
        {
        }
        else
        {
index 9229b718a5dbe33b5a27e059e7f7feb2745f7f10..a6aebc61c64cfa608f4367e68d11137962734c70 100644 (file)
@@ -90,9 +90,9 @@ entity teamslots[17];    // 17 teams (including "spectator team")
 float drawframetime;
 vector view_origin, view_forward, view_right, view_up;
 
 float drawframetime;
 vector view_origin, view_forward, view_right, view_up;
 
-float button_zoom;
-float spectatorbutton_zoom;
-float button_attack2;
+bool button_zoom;
+bool spectatorbutton_zoom;
+bool button_attack2;
 
 int activeweapon;
 int switchingweapon;
 
 int activeweapon;
 int switchingweapon;
index af43dae0373f125aa37d7856b65667dbb4880281..2664354110b0631ee7617d99fe0d73b210cef44c 100644 (file)
@@ -198,7 +198,7 @@ NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew)
 {
        int sendflags = ReadByte();
 
 {
        int sendflags = ReadByte();
 
-       InterpolateOrigin_Undo();
+       InterpolateOrigin_Undo(self);
 
        self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
        self.classname = "radarlink";
 
        self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
        self.classname = "radarlink";
@@ -225,5 +225,5 @@ NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew)
 
        return = true;
 
 
        return = true;
 
-       InterpolateOrigin_Note();
+       InterpolateOrigin_Note(this);
 }
 }
index 41822f54bca29bc7b2c3ed35e30818d9196d95d4..d2f8714adf04852b09a8371a2532dec12d045254 100644 (file)
@@ -13,6 +13,7 @@
 #include "../common/debug.qh"
 #include "../common/mapinfo.qh"
 #include "../common/gamemodes/all.qh"
 #include "../common/debug.qh"
 #include "../common/mapinfo.qh"
 #include "../common/gamemodes/all.qh"
+#include "../common/physics.qh"
 #include "../common/stats.qh"
 #include "../common/triggers/target/music.qh"
 #include "../common/teams.qh"
 #include "../common/stats.qh"
 #include "../common/triggers/target/music.qh"
 #include "../common/teams.qh"
@@ -975,7 +976,7 @@ void HUD_Crosshair()
                                        wcross_color = stov(autocvar_crosshair_dot_color);
 
                                CROSSHAIR_DRAW(wcross_resolution * autocvar_crosshair_dot_size, "gfx/crosshairdot.tga", f * autocvar_crosshair_dot_alpha);
                                        wcross_color = stov(autocvar_crosshair_dot_color);
 
                                CROSSHAIR_DRAW(wcross_resolution * autocvar_crosshair_dot_size, "gfx/crosshairdot.tga", f * autocvar_crosshair_dot_alpha);
-                               // FIXME why don't we use wcross_alpha here?cl_notice_run();
+                               // FIXME why don't we use wcross_alpha here?
                                wcross_color = wcross_color_old;
                        }
                }
                                wcross_color = wcross_color_old;
                        }
                }
@@ -1052,9 +1053,7 @@ float oldr_novis;
 float oldr_useportalculling;
 float oldr_useinfinitefarclip;
 
 float oldr_useportalculling;
 float oldr_useinfinitefarclip;
 
-const int BUTTON_3 = 4;
-const int BUTTON_4 = 8;
-float cl_notice_run();
+void cl_notice_run();
 float prev_myteam;
 int lasthud;
 float vh_notice_time;
 float prev_myteam;
 int lasthud;
 float vh_notice_time;
@@ -1091,8 +1090,8 @@ void CSQC_UpdateView(float w, float h)
        else
                view_quality = 1;
 
        else
                view_quality = 1;
 
-       button_attack2 = (input_buttons & BUTTON_3);
-       button_zoom = (input_buttons & BUTTON_4);
+       button_attack2 = PHYS_INPUT_BUTTON_ATCK2(self);
+       button_zoom = PHYS_INPUT_BUTTON_ZOOM(self);
 
        vf_size = getpropertyvec(VF_SIZE);
        vf_min = getpropertyvec(VF_MIN);
 
        vf_size = getpropertyvec(VF_SIZE);
        vf_min = getpropertyvec(VF_MIN);
index 2623470c16db54e52fdd8552f86ab6a5ff0fcd37..f83c70c227ea6fd18553813db5319841eec9da9c 100644 (file)
@@ -85,7 +85,7 @@ void Ent_Wall_Draw(entity this)
                }
        }
 
                }
        }
 
-       InterpolateOrigin_Do();
+       InterpolateOrigin_Do(self);
 
        self.saved = self.(fld);
 
 
        self.saved = self.(fld);
 
@@ -119,7 +119,7 @@ NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
        int f;
        var .vector fld;
 
        int f;
        var .vector fld;
 
-       InterpolateOrigin_Undo();
+       InterpolateOrigin_Undo(self);
        self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
 
        if(self.bgmscriptangular)
        self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
 
        if(self.bgmscriptangular)
@@ -224,7 +224,7 @@ NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
 
        return = true;
 
 
        return = true;
 
-       InterpolateOrigin_Note();
+       InterpolateOrigin_Note(this);
 
        self.saved = self.(fld);
 
 
        self.saved = self.(fld);
 
index 9609760c4a43ab168f465395bca180ec7cc45478..e0244d4bf982d4b927b5a4386a8d6d65f0081745 100644 (file)
@@ -79,7 +79,7 @@ void Projectile_Draw(entity this)
        }
        else
        {
        }
        else
        {
-               InterpolateOrigin_Do();
+               InterpolateOrigin_Do(self);
        }
 
        if (self.count & 0x80)
        }
 
        if (self.count & 0x80)
@@ -227,7 +227,7 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
        }
 
        if (!(self.count & 0x80))
        }
 
        if (!(self.count & 0x80))
-               InterpolateOrigin_Undo();
+               InterpolateOrigin_Undo(self);
 
        if (f & 1)
        {
 
        if (f & 1)
        {
@@ -475,7 +475,7 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
        }
 
        if (!(self.count & 0x80))
        }
 
        if (!(self.count & 0x80))
-               InterpolateOrigin_Note();
+               InterpolateOrigin_Note(this);
 
        self.classname = "csqcprojectile";
        self.draw = Projectile_Draw;
 
        self.classname = "csqcprojectile";
        self.draw = Projectile_Draw;
index 29a0bf44a599f909796953c9937e41caec87fdc0..066f48517eff63b64d31b4c4fda8aa7e2e64403e 100644 (file)
@@ -72,8 +72,8 @@
        CSQCModel_Hook_PostUpdate(isnew, isplayer, islocalplayer);
 #define CSQCMODEL_HOOK_PREDRAW \
        CSQCModel_Hook_PreDraw(isplayer);
        CSQCModel_Hook_PostUpdate(isnew, isplayer, islocalplayer);
 #define CSQCMODEL_HOOK_PREDRAW \
        CSQCModel_Hook_PreDraw(isplayer);
-#define CSQCPLAYER_HOOK_POSTCAMERASETUP \
-       CSQCPlayer_SetViewLocation();
+#define CSQCPLAYER_HOOK_POSTCAMERASETUP() \
+       CSQCPlayer_SetViewLocation()
 
 // force updates of player entities that often even if unchanged
 #ifndef CSQCPLAYER_FORCE_UPDATES
 
 // force updates of player entities that often even if unchanged
 #ifndef CSQCPLAYER_FORCE_UPDATES
index f90ddddea5742fb0f2ff4bd4ee1a3be5ed77c307..c30e52af6d628d0f25ed527a540d3354fc956f07 100644 (file)
                SELFPARAM();
                this.nextthink = time;
                entity e = CSQCModel_server2csqc(this.sv_entnum + 1);
                SELFPARAM();
                this.nextthink = time;
                entity e = CSQCModel_server2csqc(this.sv_entnum + 1);
-               bool exists = !!e;
+               bool exists = e != NULL;
                if (exists)
                {
                        this.has_origin = true;
                if (exists)
                {
                        this.has_origin = true;
                        this.think = entcs_think;
                        this.nextthink = time;
                }
                        this.think = entcs_think;
                        this.nextthink = time;
                }
-               InterpolateOrigin_Undo();
+               InterpolateOrigin_Undo(this);
                int sf = ReadShort();
                this.has_sv_origin = false;
                this.m_entcs_private = boolean(sf & 1);
                int sf = ReadShort();
                this.has_sv_origin = false;
                this.m_entcs_private = boolean(sf & 1);
        #undef X
                entcs_receiver[this.sv_entnum] = this;
                this.iflags |= IFLAG_ORIGIN;
        #undef X
                entcs_receiver[this.sv_entnum] = this;
                this.iflags |= IFLAG_ORIGIN;
-               InterpolateOrigin_Note();
+               InterpolateOrigin_Note(this);
                return true;
        }
 
                return true;
        }
 
index 5cb21de80f3df78a54c0fcbdab8d60f9ebea50f7..822aff3fad4439a129a97ea3413f239d52dcf417 100644 (file)
@@ -332,7 +332,7 @@ void HUD_MinigameMenu_ClickCurrentGame()
 // Whether the minigame menu panel is open
 bool HUD_MinigameMenu_IsOpened()
 {
 // Whether the minigame menu panel is open
 bool HUD_MinigameMenu_IsOpened()
 {
-       return !!HUD_MinigameMenu_entries;
+       return HUD_MinigameMenu_entries != NULL;
 }
 
 // Close the minigame menu panel
 }
 
 // Close the minigame menu panel
index a11feab9eceac5b1947e22290cd6177cc8df5c17..a66a92993355ca8f3873a100837a06366fa1b71b 100644 (file)
@@ -122,7 +122,7 @@ void Ent_WaypointSprite()
 
     self.draw2d = Draw_WaypointSprite;
 
 
     self.draw2d = Draw_WaypointSprite;
 
-    InterpolateOrigin_Undo();
+    InterpolateOrigin_Undo(self);
     self.iflags |= IFLAG_ORIGIN;
 
     if (sendflags & 0x80)
     self.iflags |= IFLAG_ORIGIN;
 
     if (sendflags & 0x80)
@@ -211,7 +211,7 @@ void Ent_WaypointSprite()
             self.helpme += servertime;
     }
 
             self.helpme += servertime;
     }
 
-    InterpolateOrigin_Note();
+    InterpolateOrigin_Note(this);
 
     self.entremove = Ent_RemoveWaypointSprite;
 }
 
     self.entremove = Ent_RemoveWaypointSprite;
 }
@@ -467,7 +467,7 @@ void Draw_WaypointSprite(entity this)
         if (autocvar_cl_hidewaypoints)
             return; // fixed waypoint
 
         if (autocvar_cl_hidewaypoints)
             return; // fixed waypoint
 
-    InterpolateOrigin_Do();
+    InterpolateOrigin_Do(self);
 
     float t = GetPlayerColor(player_localnum) + 1;
 
 
     float t = GetPlayerColor(player_localnum) + 1;
 
index 5deb0960e2daadefae90bec456b45510459d0241..c25997b1a3dc75c5a15f3e36e5fce9bc87670472 100644 (file)
@@ -4,28 +4,19 @@ REGISTER_NET_TEMP(TE_CSQC_SVNOTICE)
 
 #ifdef SVQC
 void sv_notice_join_think()
 
 #ifdef SVQC
 void sv_notice_join_think()
-{SELFPARAM();
-    //NextLevel();
-    float argc = tokenizebyseparator(autocvar_sv_join_notices, "|");
-    if(argc > 0)
-    {
-        float i;
-        for(i = argc - 1; i >= 0; --i)
-            sv_notice_to(self.owner, argv(i), autocvar_sv_join_notices_time, false);
-    }
-    remove(self);
+{
+    SELFPARAM();
+    int argc = tokenizebyseparator(autocvar_sv_join_notices, "|");
+    if (argc <= 0) return;
+    for (int i = 0; i < argc; ++i)
+        sv_notice_to(this, argv(i), autocvar_sv_join_notices_time, false);
 }
 
 }
 
-void sv_notice_join()
-{SELFPARAM();
+void sv_notice_join(entity _to)
+{
     // to-do: make sv_join_notices support per-entry times
     // to-do: make sv_join_notices support per-entry times
-    if(autocvar_sv_join_notices == "")
-        return;
-
-    entity n = spawn();
-    n.owner = self;
-    n.think = sv_notice_join_think;
-    n.nextthink = time + 1;
+    if (autocvar_sv_join_notices == "") return;
+    defer(_to, 1, sv_notice_join_think);
 }
 
 void sv_notice_to(entity _to, string _notice, float _howlong, float _modal)
 }
 
 void sv_notice_to(entity _to, string _notice, float _howlong, float _modal)
@@ -53,66 +44,49 @@ NET_HANDLE(TE_CSQC_SVNOTICE, bool isNew)
        cl_notice_read();
        return true;
 }
        cl_notice_read();
        return true;
 }
+entity cl_notices;
+STATIC_INIT(cl_notice)
+{
+    cl_notices = LL_NEW();
+}
 void cl_notice_read()
 {
 void cl_notice_read()
 {
-    //float _done;
-    //float _modal;
     entity _notice = new(sv_notice);
     entity _notice = new(sv_notice);
+    make_pure(_notice);
     _notice.netname = strzone(ReadString());
     _notice.alpha = ReadLong() + time;
     _notice.skin = ReadByte();
     _notice.netname = strzone(ReadString());
     _notice.alpha = ReadLong() + time;
     _notice.skin = ReadByte();
+    LL_PUSH(cl_notices, _notice);
 }
 
 }
 
-float cl_notice_run()
+void cl_notice_run()
 {
 {
-    entity _notes;
-    string _notice;
-    float m = false;
-
-    _notes = findchain(classname, "sv_notice");
-    if(!_notes)
-        return false;
+    bool flag = false;
+    LL_EACH(cl_notices, it.alpha > time, LAMBDA(flag = true; break));
+    if (!flag) return;
     const int M1 = 30;
     const int M2 = 10;
 
     const int M1 = 30;
     const int M2 = 10;
 
-    vector v1, v2 = '0 0 0', v3;
-    v1 = '1 1 0' * M1;
-    v2_x = vid_conwidth - (2 * M1);
-    v2_y = vid_conheight - (2 * M1);
-
+    vector v1 = '1 1 0' * M1;
+    vector v2 = '0 0 0';
+    v2.x = vid_conwidth - (2 * M1);
+    v2.y = vid_conheight - (2 * M1);
     drawfill(v1, v2, '0 0 0', 0.5, DRAWFLAG_NORMAL);
     drawfill(v1, v2, '0 0 0', 0.5, DRAWFLAG_NORMAL);
+
     v1 = '1 1 0' * (M1 + M2);
     v1 = '1 1 0' * (M1 + M2);
-    v2_x = vid_conwidth - (2 * (M1 + M2));
-    v2_y = vid_conheight - (2 * (M1 + M2));
+    v2.x = vid_conwidth - (2 * (M1 + M2));
+    v2.y = vid_conheight - (2 * (M1 + M2));
     drawfill(v1, v2, '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
     drawfill(v1, v2, '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
-    v3 = v1 + '10 10 0';
 
 
-    #define OUT(s,z) drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3_y += z + 4
+    vector v3 = v1 + '10 10 0';
+    #define OUT(s, z) do { drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3.y += z + 4; } while (0)
 
     OUT(_("^1Server notices:"), 32);
 
     OUT(_("^1Server notices:"), 32);
-
-    //drawcolorcodedstring(v1 + '5 5 0', "^1Server notices:", '32 32 0', 1, DRAWFLAG_NORMAL);
-    while(_notes)
-    {
-
-        _notice = sprintf(_("^7%s (^3%d sec left)"), _notes.netname , rint(_notes.alpha - time));
-        OUT(_notice, 16);
-
-        if(_notes.skin)
-            m = true;
-
-        if(_notes.alpha <= time)
-        {
-            _notes.think = SUB_Remove_self;
-            _notes.nextthink = time;
-        }
-
-        _notes = _notes.chain;
-    }
-
+    LL_EACH(cl_notices, it.alpha > time, LAMBDA(
+        string s = sprintf(_("^7%s (^3%d sec left)"), it.netname , rint(it.alpha - time));
+        OUT(s, 16);
+    ));
     #undef OUT
     #undef OUT
-
-    return m;
 }
 
 #endif // CSQC
 }
 
 #endif // CSQC
index ba3b9817b6471dfaf7fe0cd7cfd5cb6a1f9e772d..b36f631fe2a17676c452e272f8176290d09d29eb 100644 (file)
@@ -7,7 +7,7 @@ float  autocvar_sv_join_notices_time;
 
 void sv_notice_to(entity _to, string _notice, float _howlong, float _modal);
 void sv_notice_toall(string _notice, float _howlong, float _modal);
 
 void sv_notice_to(entity _to, string _notice, float _howlong, float _modal);
 void sv_notice_toall(string _notice, float _howlong, float _modal);
-void sv_notice_join();
+void sv_notice_join(entity _to);
 #endif
 
 #ifdef CSQC
 #endif
 
 #ifdef CSQC
index 3417b5ab8c7532ac42f88ebbe81ca907e1c4de35..63e7ae7e91dae4ee1caa28bf8d66ea993c1c2454 100644 (file)
@@ -230,74 +230,70 @@ void PM_ClientMovement_Unstick(entity this)
        #undef X
 }
 
        #undef X
 }
 
-void PM_ClientMovement_UpdateStatus(bool ground)
-{SELFPARAM();
+void PM_ClientMovement_UpdateStatus(entity this, bool ground)
+{
        // make sure player is not stuck
        PM_ClientMovement_Unstick(this);
 
        // set crouched
        // make sure player is not stuck
        PM_ClientMovement_Unstick(this);
 
        // set crouched
-       if (PHYS_INPUT_BUTTON_CROUCH(self))
+       if (PHYS_INPUT_BUTTON_CROUCH(this))
        {
        {
-               // wants to crouch, this always works..
-               if (!IS_DUCKED(self))
-                       SET_DUCKED(self);
+               // wants to crouch, this always works
+               if (!IS_DUCKED(this)) SET_DUCKED(this);
        }
        else
        {
        }
        else
        {
-               // wants to stand, if currently crouching we need to check for a
-               // low ceiling first
-               if (IS_DUCKED(self))
+               // wants to stand, if currently crouching we need to check for a low ceiling first
+               if (IS_DUCKED(this))
                {
                {
-                       tracebox(self.origin, PL_MIN, PL_MAX, self.origin, MOVE_NORMAL, self);
-                       if (!trace_startsolid)
-                               UNSET_DUCKED(self);
+                       tracebox(this.origin, PL_MIN, PL_MAX, this.origin, MOVE_NORMAL, this);
+                       if (!trace_startsolid) UNSET_DUCKED(this);
                }
        }
 
        // set onground
                }
        }
 
        // set onground
-       vector origin1 = self.origin + '0 0 1';
-       vector origin2 = self.origin - '0 0 1';
+       vector origin1 = this.origin + '0 0 1';
+       vector origin2 = this.origin - '0 0 1';
 
 
-       if(ground)
+       if (ground)
        {
        {
-               tracebox(origin1, self.mins, self.maxs, origin2, MOVE_NORMAL, self);
-               if (trace_fraction < 1.0 && trace_plane_normal_z > 0.7)
+               tracebox(origin1, this.mins, this.maxs, origin2, MOVE_NORMAL, this);
+               if (trace_fraction < 1.0 && trace_plane_normal.z > 0.7)
                {
                {
-                       SET_ONGROUND(self);
+                       SET_ONGROUND(this);
 
                        // this code actually "predicts" an impact; so let's clip velocity first
 
                        // this code actually "predicts" an impact; so let's clip velocity first
-                       float f = self.velocity * trace_plane_normal;
-                       self.velocity -= f * trace_plane_normal;
+                       this.velocity -= this.velocity * trace_plane_normal * trace_plane_normal;
                }
                else
                }
                else
-                       UNSET_ONGROUND(self);
+                       UNSET_ONGROUND(this);
        }
 
        // set watertype/waterlevel
        }
 
        // set watertype/waterlevel
-       origin1 = self.origin;
-       origin1_z += self.mins_z + 1;
-       self.waterlevel = WATERLEVEL_NONE;
+       origin1 = this.origin;
+       origin1.z += this.mins_z + 1;
+       this.waterlevel = WATERLEVEL_NONE;
 
        int thepoint = pointcontents(origin1);
 
 
        int thepoint = pointcontents(origin1);
 
-       self.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
+       this.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
 
 
-       if(self.watertype)
+       if (this.watertype)
        {
        {
-               self.waterlevel = WATERLEVEL_WETFEET;
-               origin1_z = self.origin_z + (self.mins_z + self.maxs_z) * 0.5;
+               this.waterlevel = WATERLEVEL_WETFEET;
+               origin1.z = this.origin.z + (this.mins.z + this.maxs.z) * 0.5;
                thepoint = pointcontents(origin1);
                thepoint = pointcontents(origin1);
-               if(thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
+               if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
                {
                {
-                       self.waterlevel = WATERLEVEL_SWIMMING;
-                       origin1_z = self.origin_z + 22;
+                       this.waterlevel = WATERLEVEL_SWIMMING;
+                       origin1.z = this.origin.z + 22;
                        thepoint = pointcontents(origin1);
                        thepoint = pointcontents(origin1);
-                       if(thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
-                               self.waterlevel = WATERLEVEL_SUBMERGED;
+                       if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
+                               this.waterlevel = WATERLEVEL_SUBMERGED;
                }
        }
 
                }
        }
 
-       if(IS_ONGROUND(self) || self.velocity_z <= 0 || pmove_waterjumptime <= 0)
+       if (IS_ONGROUND(this) || this.velocity.z <= 0 || pmove_waterjumptime <= 0)
                pmove_waterjumptime = 0;
 }
 
                pmove_waterjumptime = 0;
 }
 
@@ -323,7 +319,7 @@ void PM_ClientMovement_Move()
        vector trace3_plane_normal = '0 0 0';
 
 
        vector trace3_plane_normal = '0 0 0';
 
 
-       PM_ClientMovement_UpdateStatus(false);
+       PM_ClientMovement_UpdateStatus(this, false);
        primalvelocity = self.velocity;
        for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (self.velocity * self.velocity) > 0; bump++)
        {
        primalvelocity = self.velocity;
        for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (self.velocity * self.velocity) > 0; bump++)
        {
@@ -1414,52 +1410,49 @@ void PM_jetpack(float maxspd_mod)
 #endif
 }
 
 #endif
 }
 
-void PM_walk(float buttons_prev, float maxspd_mod)
-{SELFPARAM();
-       if (!WAS_ONGROUND(self))
+void PM_walk(entity this, float maxspd_mod)
+{
+       if (!WAS_ONGROUND(this))
        {
 #ifdef SVQC
                if (autocvar_speedmeter)
        {
 #ifdef SVQC
                if (autocvar_speedmeter)
-                       LOG_TRACE(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
+                       LOG_TRACE(strcat("landing velocity: ", vtos(this.velocity), " (abs: ", ftos(vlen(this.velocity)), ")\n"));
 #endif
 #endif
-               if (self.lastground < time - 0.3)
-                       self.velocity *= (1 - PHYS_FRICTION_ONLAND);
+               if (this.lastground < time - 0.3)
+                       this.velocity *= (1 - PHYS_FRICTION_ONLAND);
 #ifdef SVQC
 #ifdef SVQC
-               if (self.jumppadcount > 1)
-                       LOG_TRACE(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
-               self.jumppadcount = 0;
+               if (this.jumppadcount > 1)
+                       LOG_TRACE(strcat(ftos(this.jumppadcount), "x jumppad combo\n"));
+               this.jumppadcount = 0;
 #endif
        }
 
        // walking
 #endif
        }
 
        // walking
-       makevectors(self.v_angle.y * '0 1 0');
-       vector wishvel = v_forward * self.movement.x
-                                       + v_right * self.movement.y;
+       makevectors(this.v_angle.y * '0 1 0');
+       const vector wishvel = v_forward * this.movement.x
+                                               + v_right * this.movement.y;
        // acceleration
        // acceleration
-       vector wishdir = normalize(wishvel);
+       const vector wishdir = normalize(wishvel);
        float wishspeed = vlen(wishvel);
        float wishspeed = vlen(wishvel);
-
-       wishspeed = min(wishspeed, PHYS_MAXSPEED(self) * maxspd_mod);
-       if (IS_DUCKED(self))
-               wishspeed *= 0.5;
+       wishspeed = min(wishspeed, PHYS_MAXSPEED(this) * maxspd_mod);
+       if (IS_DUCKED(this)) wishspeed *= 0.5;
 
        // apply edge friction
 
        // apply edge friction
-       float f = vlen(vec2(self.velocity));
-       if (f > 0)
+       const float f2 = vlen2(vec2(this.velocity));
+       if (f2 > 0)
        {
        {
-               float realfriction;
                trace_dphitq3surfaceflags = 0;
                trace_dphitq3surfaceflags = 0;
-               tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
+               tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
                // TODO: apply edge friction
                // apply ground friction
                // TODO: apply edge friction
                // apply ground friction
-               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
-                       realfriction = PHYS_FRICTION_SLICK;
-               else
-                       realfriction = PHYS_FRICTION;
+               const int realfriction = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
+                       ? PHYS_FRICTION_SLICK
+                       : PHYS_FRICTION;
 
 
+               float f = sqrt(f2);
                f = 1 - PHYS_INPUT_TIMELENGTH * realfriction * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
                f = max(0, f);
                f = 1 - PHYS_INPUT_TIMELENGTH * realfriction * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
                f = max(0, f);
-               self.velocity *= f;
+               this.velocity *= f;
                /*
                   Mathematical analysis time!
 
                /*
                   Mathematical analysis time!
 
@@ -1483,20 +1476,20 @@ void PM_walk(float buttons_prev, float maxspd_mod)
                        v >= PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
                 */
        }
                        v >= PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
                 */
        }
-       float addspeed = wishspeed - self.velocity * wishdir;
+       const float addspeed = wishspeed - this.velocity * wishdir;
        if (addspeed > 0)
        {
        if (addspeed > 0)
        {
-               float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
-               self.velocity += accelspeed * wishdir;
+               const float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
+               this.velocity += accelspeed * wishdir;
        }
        }
-       float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
+       const float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(this) * PHYS_INPUT_TIMELENGTH;
        if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
        if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
-               self.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
-       if (self.velocity * self.velocity)
+               this.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
+       if (vdist(this.velocity, >, 0))
                PM_ClientMovement_Move();
        if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
                PM_ClientMovement_Move();
        if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
-               if (!IS_ONGROUND(self) || !GAMEPLAYFIX_NOGRAVITYONGROUND)
-                       self.velocity_z -= g * 0.5;
+               if (!IS_ONGROUND(this) || !GAMEPLAYFIX_NOGRAVITYONGROUND)
+                       this.velocity_z -= g * 0.5;
 }
 
 void PM_air(float buttons_prev, float maxspd_mod)
 }
 
 void PM_air(float buttons_prev, float maxspd_mod)
@@ -1585,25 +1578,25 @@ bool IsFlying(entity a)
        return true;
 }
 
        return true;
 }
 
-void PM_Main()
-{SELFPARAM();
-       int buttons = PHYS_INPUT_BUTTON_MASK(self);
+void PM_Main(entity this)
+{
+       int buttons = PHYS_INPUT_BUTTON_MASK(this);
 #ifdef CSQC
 #ifdef CSQC
-       self.items = getstati(STAT_ITEMS, 0, 24);
+       this.items = getstati(STAT_ITEMS, 0, 24);
 
 
-       self.movement = PHYS_INPUT_MOVEVALUES(self);
+       this.movement = PHYS_INPUT_MOVEVALUES(this);
 
 
-       vector oldv_angle = self.v_angle;
-       vector oldangles = self.angles; // we need to save these, as they're abused by other code
-       self.v_angle = PHYS_INPUT_ANGLES(self);
-       self.angles = PHYS_WORLD_ANGLES(self);
+       vector oldv_angle = this.v_angle;
+       vector oldangles = this.angles; // we need to save these, as they're abused by other code
+       this.v_angle = PHYS_INPUT_ANGLES(this);
+       this.angles = PHYS_WORLD_ANGLES(this);
 
 
-       self.team = myteam + 1; // is this correct?
-       if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump
-               UNSET_JUMP_HELD(self); // canjump = true
+       this.team = myteam + 1; // is this correct?
+       if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump
+               UNSET_JUMP_HELD(this); // canjump = true
        pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
 
        pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
 
-       PM_ClientMovement_UpdateStatus(true);
+       PM_ClientMovement_UpdateStatus(this, true);
 #endif
 
 
 #endif
 
 
@@ -1616,8 +1609,8 @@ void PM_Main()
 #ifdef SVQC
        Physics_UpdateStats(maxspeed_mod);
 
 #ifdef SVQC
        Physics_UpdateStats(maxspeed_mod);
 
-       if (self.PlayerPhysplug)
-               if (self.PlayerPhysplug())
+       if (this.PlayerPhysplug)
+               if (this.PlayerPhysplug())
                        return;
 #endif
 
                        return;
 #endif
 
@@ -1630,59 +1623,52 @@ void PM_Main()
 #ifdef SVQC
        if (sv_maxidle > 0)
        {
 #ifdef SVQC
        if (sv_maxidle > 0)
        {
-               if (buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old)
-                       self.parm_idlesince = time;
+               if (buttons != this.buttons_old || this.movement != this.movement_old || this.v_angle != this.v_angle_old)
+                       this.parm_idlesince = time;
        }
 #endif
        }
 #endif
-       int buttons_prev = self.buttons_old;
-       self.buttons_old = buttons;
-       self.movement_old = self.movement;
-       self.v_angle_old = self.v_angle;
+       int buttons_prev = this.buttons_old;
+       this.buttons_old = buttons;
+       this.movement_old = this.movement;
+       this.v_angle_old = this.v_angle;
 
        PM_check_nickspam();
 
        PM_check_punch();
 #ifdef SVQC
 
        PM_check_nickspam();
 
        PM_check_punch();
 #ifdef SVQC
-       if (IS_BOT_CLIENT(self))
+       if (IS_BOT_CLIENT(this))
        {
                if (playerdemo_read())
                        return;
                bot_think();
        }
        {
                if (playerdemo_read())
                        return;
                bot_think();
        }
-
-       if (IS_PLAYER(self))
-#endif
-       {
-               bool not_allowed_to_move = false;
-#ifdef SVQC
-               if (time < game_starttime)
-                       not_allowed_to_move = true;
 #endif
 
 #endif
 
-               if (not_allowed_to_move)
-               {
-                       self.velocity = '0 0 0';
-                       self.movetype = MOVETYPE_NONE;
 #ifdef SVQC
 #ifdef SVQC
-                       self.disableclientprediction = 2;
-#endif
+       if (IS_PLAYER(this))
+       {
+               const bool allowed_to_move = (time >= game_starttime);
+               if (!allowed_to_move)
+               {
+                       this.velocity = '0 0 0';
+                       this.movetype = MOVETYPE_NONE;
+                       this.disableclientprediction = 2;
                }
                }
-#ifdef SVQC
-               else if (self.disableclientprediction == 2)
+               else if (this.disableclientprediction == 2)
                {
                {
-                       if (self.movetype == MOVETYPE_NONE)
-                               self.movetype = MOVETYPE_WALK;
-                       self.disableclientprediction = 0;
+                       if (this.movetype == MOVETYPE_NONE)
+                               this.movetype = MOVETYPE_WALK;
+                       this.disableclientprediction = 0;
                }
                }
-#endif
        }
        }
+#endif
 
 #ifdef SVQC
 
 #ifdef SVQC
-       if (self.movetype == MOVETYPE_NONE)
+       if (this.movetype == MOVETYPE_NONE)
                return;
 
        // when we get here, disableclientprediction cannot be 2
                return;
 
        // when we get here, disableclientprediction cannot be 2
-       self.disableclientprediction = 0;
+       this.disableclientprediction = 0;
 #endif
 
        viewloc_PlayerPhysics();
 #endif
 
        viewloc_PlayerPhysics();
@@ -1695,12 +1681,12 @@ void PM_Main()
 
        maxspeed_mod = 1;
 
 
        maxspeed_mod = 1;
 
-       if (self.in_swamp)
-               maxspeed_mod *= self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
+       if (this.in_swamp)
+               maxspeed_mod *= this.swamp_slowdown; //cvar("g_balance_swamp_moverate");
 
        // conveyors: first fix velocity
 
        // conveyors: first fix velocity
-       if (self.conveyor.state)
-               self.velocity -= self.conveyor.movedir;
+       if (this.conveyor.state)
+               this.velocity -= this.conveyor.movedir;
 
 #ifdef SVQC
        MUTATOR_CALLHOOK(PlayerPhysics);
 
 #ifdef SVQC
        MUTATOR_CALLHOOK(PlayerPhysics);
@@ -1720,110 +1706,110 @@ void PM_Main()
 //     }
 
 #ifdef SVQC
 //     }
 
 #ifdef SVQC
-       if (!IS_PLAYER(self))
+       if (!IS_PLAYER(this))
        {
                maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
        {
                maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
-               if (!self.spectatorspeed)
-                       self.spectatorspeed = maxspeed_mod;
-               if (self.impulse && self.impulse <= 19 || (self.impulse >= 200 && self.impulse <= 209) || (self.impulse >= 220 && self.impulse <= 229))
+               if (!this.spectatorspeed)
+                       this.spectatorspeed = maxspeed_mod;
+               if (this.impulse && this.impulse <= 19 || (this.impulse >= 200 && this.impulse <= 209) || (this.impulse >= 220 && this.impulse <= 229))
                {
                {
-                       if (self.lastclassname != "player")
+                       if (this.lastclassname != "player")
                        {
                        {
-                               if (self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209))
-                                       self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
-                               else if (self.impulse == 11)
-                                       self.spectatorspeed = maxspeed_mod;
-                               else if (self.impulse == 12 || self.impulse == 16  || self.impulse == 19 || (self.impulse >= 220 && self.impulse <= 229))
-                                       self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
-                               else if (self.impulse >= 1 && self.impulse <= 9)
-                                       self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
+                               if (this.impulse == 10 || this.impulse == 15 || this.impulse == 18 || (this.impulse >= 200 && this.impulse <= 209))
+                                       this.spectatorspeed = bound(1, this.spectatorspeed + 0.5, 5);
+                               else if (this.impulse == 11)
+                                       this.spectatorspeed = maxspeed_mod;
+                               else if (this.impulse == 12 || this.impulse == 16  || this.impulse == 19 || (this.impulse >= 220 && this.impulse <= 229))
+                                       this.spectatorspeed = bound(1, this.spectatorspeed - 0.5, 5);
+                               else if (this.impulse >= 1 && this.impulse <= 9)
+                                       this.spectatorspeed = 1 + 0.5 * (this.impulse - 1);
                        } // otherwise just clear
                        } // otherwise just clear
-                       self.impulse = 0;
+                       this.impulse = 0;
                }
                }
-               maxspeed_mod = self.spectatorspeed;
+               maxspeed_mod = this.spectatorspeed;
        }
 
        }
 
-       float spd = max(PHYS_MAXSPEED(self), PHYS_MAXAIRSPEED(self)) * maxspeed_mod;
-       if(self.speed != spd)
+       float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
+       if(this.speed != spd)
        {
        {
-               self.speed = spd;
+               this.speed = spd;
                string temps = ftos(spd);
                string temps = ftos(spd);
-               stuffcmd(self, strcat("cl_forwardspeed ", temps, "\n"));
-               stuffcmd(self, strcat("cl_backspeed ", temps, "\n"));
-               stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
-               stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
+               stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
+               stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
+               stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
+               stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
        }
 
        }
 
-       if(self.stat_jumpspeedcap_min != PHYS_JUMPSPEEDCAP_MIN)
+       if(this.stat_jumpspeedcap_min != PHYS_JUMPSPEEDCAP_MIN)
        {
        {
-               self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
-               stuffcmd(self, strcat("cl_jumpspeedcap_min ", PHYS_JUMPSPEEDCAP_MIN, "\n"));
+               this.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
+               stuffcmd(this, strcat("cl_jumpspeedcap_min ", PHYS_JUMPSPEEDCAP_MIN, "\n"));
        }
        }
-       if(self.stat_jumpspeedcap_max != PHYS_JUMPSPEEDCAP_MAX)
+       if(this.stat_jumpspeedcap_max != PHYS_JUMPSPEEDCAP_MAX)
        {
        {
-               self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MAX;
-               stuffcmd(self, strcat("cl_jumpspeedcap_max ", PHYS_JUMPSPEEDCAP_MAX, "\n"));
+               this.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MAX;
+               stuffcmd(this, strcat("cl_jumpspeedcap_max ", PHYS_JUMPSPEEDCAP_MAX, "\n"));
        }
 #endif
 
        }
 #endif
 
-       if(PHYS_DEAD(self))
+       if(PHYS_DEAD(this))
        {
                // handle water here
        {
                // handle water here
-               vector midpoint = ((self.absmin + self.absmax) * 0.5);
+               vector midpoint = ((this.absmin + this.absmax) * 0.5);
                if(pointcontents(midpoint) == CONTENT_WATER)
                {
                if(pointcontents(midpoint) == CONTENT_WATER)
                {
-                       self.velocity = self.velocity * 0.5;
+                       this.velocity = this.velocity * 0.5;
 
                        // do we want this?
                        //if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER)
 
                        // do we want this?
                        //if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER)
-                               //{ self.velocity_z = 70; }
+                               //{ this.velocity_z = 70; }
                }
                goto end;
        }
 
 #ifdef SVQC
                }
                goto end;
        }
 
 #ifdef SVQC
-       if (!self.fixangle && !g_bugrigs)
-               self.angles = '0 1 0' * self.v_angle.y;
+       if (!this.fixangle && !g_bugrigs)
+               this.angles = '0 1 0' * this.v_angle.y;
 #endif
 
        PM_check_hitground();
 
 #endif
 
        PM_check_hitground();
 
-       if(IsFlying(self))
-               self.wasFlying = 1;
+       if(IsFlying(this))
+               this.wasFlying = 1;
 
 
-       if (IS_PLAYER(self))
+       if (IS_PLAYER(this))
                CheckPlayerJump();
 
                CheckPlayerJump();
 
-       if (self.flags & FL_WATERJUMP)
+       if (this.flags & FL_WATERJUMP)
        {
        {
-               self.velocity_x = self.movedir_x;
-               self.velocity_y = self.movedir_y;
-               if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
+               this.velocity_x = this.movedir.x;
+               this.velocity_y = this.movedir.y;
+               if (time > this.teleport_time || this.waterlevel == WATERLEVEL_NONE)
                {
                {
-                       self.flags &= ~FL_WATERJUMP;
-                       self.teleport_time = 0;
+                       this.flags &= ~FL_WATERJUMP;
+                       this.teleport_time = 0;
                }
        }
 
 #ifdef SVQC
                }
        }
 
 #ifdef SVQC
-       else if (g_bugrigs && IS_PLAYER(self))
+       else if (g_bugrigs && IS_PLAYER(this))
                RaceCarPhysics();
 #endif
 
                RaceCarPhysics();
 #endif
 
-       else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, self))
+       else if (this.movetype == MOVETYPE_NOCLIP || this.movetype == MOVETYPE_FLY || this.movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, this))
                PM_fly(maxspeed_mod);
 
                PM_fly(maxspeed_mod);
 
-       else if (self.waterlevel >= WATERLEVEL_SWIMMING)
+       else if (this.waterlevel >= WATERLEVEL_SWIMMING)
                PM_swim(maxspeed_mod);
 
                PM_swim(maxspeed_mod);
 
-       else if (time < self.ladder_time)
+       else if (time < this.ladder_time)
                PM_ladder(maxspeed_mod);
 
                PM_ladder(maxspeed_mod);
 
-       else if (ITEMS_STAT(self) & IT_USING_JETPACK)
+       else if (ITEMS_STAT(this) & IT_USING_JETPACK)
                PM_jetpack(maxspeed_mod);
 
                PM_jetpack(maxspeed_mod);
 
-       else if (IS_ONGROUND(self))
-               PM_walk(buttons_prev, maxspeed_mod);
+       else if (IS_ONGROUND(this))
+               PM_walk(this, maxspeed_mod);
 
        else
                PM_air(buttons_prev, maxspeed_mod);
 
        else
                PM_air(buttons_prev, maxspeed_mod);
@@ -1831,35 +1817,37 @@ void PM_Main()
        PM_check_vortex();
 
 :end
        PM_check_vortex();
 
 :end
-       if (IS_ONGROUND(self))
-               self.lastground = time;
+       if (IS_ONGROUND(this))
+               this.lastground = time;
 
        // conveyors: then break velocity again
 
        // conveyors: then break velocity again
-       if(self.conveyor.state)
-               self.velocity += self.conveyor.movedir;
+       if(this.conveyor.state)
+               this.velocity += this.conveyor.movedir;
 
 
-       self.lastflags = self.flags;
+       this.lastflags = this.flags;
 
 
-       self.lastclassname = self.classname;
+       this.lastclassname = this.classname;
 
 #ifdef CSQC
 
 #ifdef CSQC
-       self.v_angle = oldv_angle;
-       self.angles = oldangles;
+       this.v_angle = oldv_angle;
+       this.angles = oldangles;
 #endif
 }
 
 #endif
 }
 
-#ifdef SVQC
+#if defined(SVQC)
 void SV_PlayerPhysics()
 #elif defined(CSQC)
 void SV_PlayerPhysics()
 #elif defined(CSQC)
-void CSQC_ClientMovement_PlayerMove_Frame()
+void CSQC_ClientMovement_PlayerMove_Frame(entity this)
 #endif
 #endif
-{SELFPARAM();
-       PM_Main();
-
+{
+#ifdef SVQC
+       SELFPARAM();
+#endif
+       PM_Main(this);
 #ifdef CSQC
 #ifdef CSQC
-       self.pmove_flags =
-                       ((self.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
-                       (!(self.flags & FL_JUMPRELEASED) ? 0 : PMF_JUMP_HELD) |
-                       ((self.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
+       this.pmove_flags =
+                       ((this.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
+                       (!(this.flags & FL_JUMPRELEASED) ? PMF_JUMP_HELD : 0) |
+                       ((this.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
 #endif
 }
 #endif
 }
index 5ee8954d0c1bd9cbdeb8232f0aef5692672d7b7d..639776593c1cece2ed3bc6ba1ec07af3588785c8 100644 (file)
@@ -56,23 +56,23 @@ bool IsFlying(entity a);
 
        #define PHYS_INPUT_MOVEVALUES(s)                        input_movevalues
 
 
        #define PHYS_INPUT_MOVEVALUES(s)                        input_movevalues
 
-       #define PHYS_INPUT_BUTTON_MASK(s)               (input_buttons | 128 * (input_movevalues_x < 0) | 256 * (input_movevalues_x > 0) | 512 * (input_movevalues_y < 0) | 1024 * (input_movevalues_y > 0))
-       #define PHYS_INPUT_BUTTON_ATCK(s)                       !!(input_buttons & 1)
-       #define PHYS_INPUT_BUTTON_JUMP(s)                       !!(input_buttons & 2)
-       #define PHYS_INPUT_BUTTON_ATCK2(s)                      !!(input_buttons & 4)
-       #define PHYS_INPUT_BUTTON_ZOOM(s)                       !!(input_buttons & 8)
-       #define PHYS_INPUT_BUTTON_CROUCH(s)                     !!(input_buttons & 16)
-       #define PHYS_INPUT_BUTTON_HOOK(s)                       !!(input_buttons & 32)
-       #define PHYS_INPUT_BUTTON_USE(s)                        !!(input_buttons & 64)
-       #define PHYS_INPUT_BUTTON_BACKWARD(s)           !!(input_buttons & 128)
-       #define PHYS_INPUT_BUTTON_FORWARD(s)            !!(input_buttons & 256)
-       #define PHYS_INPUT_BUTTON_LEFT(s)                       !!(input_buttons & 512)
-       #define PHYS_INPUT_BUTTON_RIGHT(s)                      !!(input_buttons & 1024)
-       #define PHYS_INPUT_BUTTON_JETPACK(s)            !!(input_buttons & 4096)
+       #define PHYS_INPUT_BUTTON_MASK(s)               (input_buttons | BIT(7) * (input_movevalues.x < 0) | BIT(8) * (input_movevalues.x > 0) | BIT(9) * (input_movevalues.y < 0) | BIT(10) * (input_movevalues.y > 0))
+       #define PHYS_INPUT_BUTTON_ATCK(s)                       boolean(input_buttons & BIT(0))
+       #define PHYS_INPUT_BUTTON_JUMP(s)                       boolean(input_buttons & BIT(1))
+       #define PHYS_INPUT_BUTTON_ATCK2(s)                      boolean(input_buttons & BIT(2))
+       #define PHYS_INPUT_BUTTON_ZOOM(s)                       boolean(input_buttons & BIT(3))
+       #define PHYS_INPUT_BUTTON_CROUCH(s)                     boolean(input_buttons & BIT(4))
+       #define PHYS_INPUT_BUTTON_HOOK(s)                       boolean(input_buttons & BIT(5))
+       #define PHYS_INPUT_BUTTON_USE(s)                        boolean(input_buttons & BIT(6))
+       #define PHYS_INPUT_BUTTON_BACKWARD(s)           boolean(input_buttons & BIT(7))
+       #define PHYS_INPUT_BUTTON_FORWARD(s)            boolean(input_buttons & BIT(8))
+       #define PHYS_INPUT_BUTTON_LEFT(s)                       boolean(input_buttons & BIT(9))
+       #define PHYS_INPUT_BUTTON_RIGHT(s)                      boolean(input_buttons & BIT(10))
+       #define PHYS_INPUT_BUTTON_JETPACK(s)            boolean(input_buttons & BIT(12))
 
        #define PHYS_DEAD(s)                                            s.csqcmodel_isdead
 
 
        #define PHYS_DEAD(s)                                            s.csqcmodel_isdead
 
-       #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  !!(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
+       #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
        #define GAMEPLAYFIX_NOGRAVITYONGROUND                   cvar("sv_gameplayfix_nogravityonground")
        #define GAMEPLAYFIX_Q2AIRACCELERATE                             cvar("sv_gameplayfix_q2airaccelerate")
        #define GAMEPLAYFIX_EASIERWATERJUMP                     getstati(STAT_GAMEPLAYFIX_EASIERWATERJUMP)
        #define GAMEPLAYFIX_NOGRAVITYONGROUND                   cvar("sv_gameplayfix_nogravityonground")
        #define GAMEPLAYFIX_Q2AIRACCELERATE                             cvar("sv_gameplayfix_q2airaccelerate")
        #define GAMEPLAYFIX_EASIERWATERJUMP                     getstati(STAT_GAMEPLAYFIX_EASIERWATERJUMP)
@@ -81,7 +81,7 @@ bool IsFlying(entity a);
        #define GAMEPLAYFIX_UNSTICKPLAYERS                              getstati(STAT_GAMEPLAYFIX_UNSTICKPLAYERS)
        #define GAMEPLAYFIX_STEPDOWN                                    getstati(STAT_GAMEPLAYFIX_STEPDOWN)
 
        #define GAMEPLAYFIX_UNSTICKPLAYERS                              getstati(STAT_GAMEPLAYFIX_UNSTICKPLAYERS)
        #define GAMEPLAYFIX_STEPDOWN                                    getstati(STAT_GAMEPLAYFIX_STEPDOWN)
 
-       #define IS_DUCKED(s)                                            !!(s.flags & FL_DUCKED)
+       #define IS_DUCKED(s)                                            boolean(s.flags & FL_DUCKED)
        #define SET_DUCKED(s)                                           s.flags |= FL_DUCKED
        #define UNSET_DUCKED(s)                                         s.flags &= ~FL_DUCKED
 
        #define SET_DUCKED(s)                                           s.flags |= FL_DUCKED
        #define UNSET_DUCKED(s)                                         s.flags &= ~FL_DUCKED
 
@@ -89,11 +89,11 @@ bool IsFlying(entity a);
        #define SET_JUMP_HELD(s)                                        s.flags &= ~FL_JUMPRELEASED
        #define UNSET_JUMP_HELD(s)                                      s.flags |= FL_JUMPRELEASED
 
        #define SET_JUMP_HELD(s)                                        s.flags &= ~FL_JUMPRELEASED
        #define UNSET_JUMP_HELD(s)                                      s.flags |= FL_JUMPRELEASED
 
-       #define IS_ONGROUND(s)                                          !!(s.flags & FL_ONGROUND)
+       #define IS_ONGROUND(s)                                          boolean(s.flags & FL_ONGROUND)
        #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
        #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
 
        #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
        #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
 
-       #define WAS_ONGROUND(s)                                         !!(s.lastflags & FL_ONGROUND)
+       #define WAS_ONGROUND(s)                                         boolean(s.lastflags & FL_ONGROUND)
 
        #define ITEMS_STAT(s)                                           (s).items
        #define BUFFS_STAT(s)                                           getstati(STAT_BUFFS)
 
        #define ITEMS_STAT(s)                                           (s).items
        #define BUFFS_STAT(s)                                           getstati(STAT_BUFFS)
@@ -292,11 +292,11 @@ bool IsFlying(entity a);
        #define SET_JUMP_HELD(s)                                        s.flags &= ~FL_JUMPRELEASED
        #define UNSET_JUMP_HELD(s)                                      s.flags |= FL_JUMPRELEASED
 
        #define SET_JUMP_HELD(s)                                        s.flags &= ~FL_JUMPRELEASED
        #define UNSET_JUMP_HELD(s)                                      s.flags |= FL_JUMPRELEASED
 
-       #define IS_ONGROUND(s)                                          !!(s.flags & FL_ONGROUND)
+       #define IS_ONGROUND(s)                                          boolean(s.flags & FL_ONGROUND)
        #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
        #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
 
        #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
        #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
 
-       #define WAS_ONGROUND(s)                                         !!((s).lastflags & FL_ONGROUND)
+       #define WAS_ONGROUND(s)                                         boolean((s).lastflags & FL_ONGROUND)
 
        #define ITEMS_STAT(s)                                           s.items
        #define BUFFS_STAT(s)                                           (s).buffs
 
        #define ITEMS_STAT(s)                                           s.items
        #define BUFFS_STAT(s)                                           (s).buffs
index 8fe240f6f7db278d5fb322a95e67731f7f6d78e6..89c659530b607bef5c7b9c4316f64b9c045da995 100644 (file)
@@ -270,7 +270,7 @@ void Draw_Laser(entity this)
 {
        if(!self.state)
                return;
 {
        if(!self.state)
                return;
-       InterpolateOrigin_Do();
+       InterpolateOrigin_Do(self);
        if(self.count & 0x80)
        {
                if(self.count & 0x10)
        if(self.count & 0x80)
        {
                if(self.count & 0x10)
@@ -319,7 +319,7 @@ void Draw_Laser(entity this)
 
 NET_HANDLE(ENT_CLIENT_LASER, bool isnew)
 {
 
 NET_HANDLE(ENT_CLIENT_LASER, bool isnew)
 {
-       InterpolateOrigin_Undo();
+       InterpolateOrigin_Undo(self);
 
        // 30 bytes, or 13 bytes for just moving
        int f = ReadByte();
 
        // 30 bytes, or 13 bytes for just moving
        int f = ReadByte();
@@ -377,7 +377,7 @@ NET_HANDLE(ENT_CLIENT_LASER, bool isnew)
 
        return = true;
 
 
        return = true;
 
-       InterpolateOrigin_Note();
+       InterpolateOrigin_Note(this);
        self.draw = Draw_Laser;
 }
 #endif
        self.draw = Draw_Laser;
 }
 #endif
index 3f38914f472b9405c3ed8bae978a655531614581..7f97668c88dfbaac8ffd0a4ebf2537f394270e9b 100644 (file)
@@ -154,55 +154,42 @@ spawnfunc(trigger_music)
 }
 #elif defined(CSQC)
 
 }
 #elif defined(CSQC)
 
+entity TargetMusic_list;
+STATIC_INIT(TargetMusic_list)
+{
+       TargetMusic_list = LL_NEW();
+}
+
 void TargetMusic_Advance()
 {
        // run AFTER all the thinks!
 void TargetMusic_Advance()
 {
        // run AFTER all the thinks!
-       entity best, e;
-       float vol, vol0;
-       best = music_default;
-       if(music_target && time < music_target.lifetime)
-               best = music_target;
-       if(music_trigger)
-               best = music_trigger;
-       for(e = world; (e = findfloat(e, enttype, NET_ENT_CLIENT_TRIGGER_MUSIC.m_id)); ) if(e.noise)
-       {
-               vol0 = e.lastvol;
-               if(getsoundtime(e, CH_BGM_SINGLE) < 0)
-               {
-                       vol0 = -1;
-               }
-               if(e == best)
+       entity best = music_default;
+       if (music_target && time < music_target.lifetime) best = music_target;
+       if (music_trigger) best = music_trigger;
+       LL_EACH(TargetMusic_list, it.noise, LAMBDA(
+               const float vol0 = (getsoundtime(it, CH_BGM_SINGLE) >= 0) ? it.lastvol : -1;
+               if (it == best)
                {
                        // increase volume
                {
                        // increase volume
-                       if(e.fade_time > 0)
-                               e.state = bound(0, e.state + frametime / e.fade_time, 1);
-                       else
-                               e.state = 1;
+                       it.state = (it.fade_time > 0) ? bound(0, it.state + frametime / it.fade_time, 1) : 1;
                }
                else
                {
                        // decrease volume
                }
                else
                {
                        // decrease volume
-                       if(e.fade_rate > 0)
-                               e.state = bound(0, e.state - frametime / e.fade_rate, 1);
-                       else
-                               e.state = 0;
+                       it.state = (it.fade_rate > 0) ? bound(0, it.state - frametime / it.fade_rate, 1) : 0;
                }
                }
-               vol = e.state * e.volume * autocvar_bgmvolume;
-               if(vol != vol0)
+               const float vol = it.state * it.volume * autocvar_bgmvolume;
+               if (vol != vol0)
                {
                        if(vol0 < 0)
                {
                        if(vol0 < 0)
-                               _sound(e, CH_BGM_SINGLE, e.noise, vol, ATTEN_NONE); // restart
+                               _sound(it, CH_BGM_SINGLE, it.noise, vol, ATTEN_NONE); // restart
                        else
                        else
-                               _sound(e, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
-                       e.lastvol = vol;
+                               _sound(it, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
+                       it.lastvol = vol;
                }
                }
-       }
+       ));
        music_trigger = world;
        music_trigger = world;
-
-       if(best)
-               bgmtime = getsoundtime(best, CH_BGM_SINGLE);
-       else
-               bgmtime = gettime(GETTIME_CDTRACK);
+       bgmtime = (best) ? getsoundtime(best, CH_BGM_SINGLE) : gettime(GETTIME_CDTRACK);
 }
 
 NET_HANDLE(TE_CSQC_TARGET_MUSIC, bool isNew)
 }
 
 NET_HANDLE(TE_CSQC_TARGET_MUSIC, bool isNew)
@@ -213,23 +200,19 @@ NET_HANDLE(TE_CSQC_TARGET_MUSIC, bool isNew)
 
 void Net_TargetMusic()
 {
 
 void Net_TargetMusic()
 {
-       int id = ReadShort();
-       float vol = ReadByte() / 255.0;
-       float fai = ReadByte() / 16.0;
-       float fao = ReadByte() / 16.0;
-       float tim = ReadByte();
-       string noi = ReadString();
+       const int id = ReadShort();
+       const float vol = ReadByte() / 255.0;
+       const float fai = ReadByte() / 16.0;
+       const float fao = ReadByte() / 16.0;
+       const float tim = ReadByte();
+       const string noi = ReadString();
 
 
-       entity e;
-       for(e = world; (e = findfloat(e, enttype, NET_ENT_CLIENT_TRIGGER_MUSIC.m_id)); )
-       {
-               if(e.count == id)
-                       break;
-       }
-       if(!e)
+       entity e = NULL;
+       LL_EACH(TargetMusic_list, it.count == id, LAMBDA(e = it; break));
+       if (!e)
        {
        {
-               e = spawn();
-               e.enttype = NET_ENT_CLIENT_TRIGGER_MUSIC.m_id;
+               LL_PUSH(TargetMusic_list, e = new(TargetMusic));
+               make_pure(e);
                e.count = id;
        }
        if(e.noise != noi)
                e.count = id;
        }
        if(e.noise != noi)
index c124a064531f71cb131cda502b977b8c1db2150c..8c521e7dd899c1af1319585faf049e8b778c9422 100644 (file)
@@ -313,7 +313,7 @@ void trigger_push_findtarget()
        }
 
        trigger_push_link();
        }
 
        trigger_push_link();
-       defer(0.1, trigger_push_updatelink);
+       defer(self, 0.1, trigger_push_updatelink);
 #endif
 }
 
 #endif
 }
 
index eac40d22094eea782c12fdde95eced356a505469..f7c5e48f6c45929fb5b144873c1c4de4cc1cb6d9 100644 (file)
@@ -507,15 +507,15 @@ spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(self); }
 
                     case ANIM_PAIN:
                         if(self.frame != ANIM_PAIN)
 
                     case ANIM_PAIN:
                         if(self.frame != ANIM_PAIN)
-                            defer(0.25, walker_setnoanim);
+                            defer(self, 0.25, walker_setnoanim);
 
                         break;
 
                     case ANIM_MELEE:
                         if(self.frame != ANIM_MELEE)
                         {
 
                         break;
 
                     case ANIM_MELEE:
                         if(self.frame != ANIM_MELEE)
                         {
-                            defer(0.41, walker_setnoanim);
-                            defer(0.21, walker_melee_do_dmg);
+                            defer(self, 0.41, walker_setnoanim);
+                            defer(self, 0.21, walker_melee_do_dmg);
                         }
 
                         movelib_beak_simple((autocvar_g_turrets_unit_walker_speed_stop));
                         }
 
                         movelib_beak_simple((autocvar_g_turrets_unit_walker_speed_stop));
index f0d180dad1d0bdb868baea5767806ab52208c75f..a9f3a9ffaad2de6267e5f7bf82c7bec733c0b3da 100644 (file)
@@ -189,8 +189,6 @@ float get_model_parameters_fixbone;
 string get_model_parameters_desc;
 float get_model_parameters(string mod, float skn); // call with string_null to clear; skin -1 means mod is the filename of the txt file and is to be split
 
 string get_model_parameters_desc;
 float get_model_parameters(string mod, float skn); // call with string_null to clear; skin -1 means mod is the filename of the txt file and is to be split
 
-vector vec2(vector v);
-
 #ifndef MENUQC
 vector NearestPointOnBox(entity box, vector org);
 #endif
 #ifndef MENUQC
 vector NearestPointOnBox(entity box, vector org);
 #endif
@@ -269,8 +267,6 @@ string CCR(string input);
        #define normal_or_gentle(normal, gentle) (GENTLE ? ((gentle != "") ? gentle : normal) : normal)
 #endif
 
        #define normal_or_gentle(normal, gentle) (GENTLE ? ((gentle != "") ? gentle : normal) : normal)
 #endif
 
-vector vec3(float x, float y, float z);
-
 #ifndef MENUQC
 vector animfixfps(entity e, vector a, vector b);
 #endif
 #ifndef MENUQC
 vector animfixfps(entity e, vector a, vector b);
 #endif
index e992c4ddaa6a2c4b4da2df9900d7ed2182e0a446..9e3e2489128cc60e2fe7db31e2ed6982e642d244 100644 (file)
@@ -46,10 +46,15 @@ void viewloc_PlayerPhysics()
                //if(!PHYS_INPUT_BUTTON_CROUCH(self) && !IS_DUCKED(self))
 #ifdef SVQC
                        //self.BUTTON_CROUCH = (oldmovement_x < 0);
                //if(!PHYS_INPUT_BUTTON_CROUCH(self) && !IS_DUCKED(self))
 #ifdef SVQC
                        //self.BUTTON_CROUCH = (oldmovement_x < 0);
-                       if(oldmovement_x < 0)
+                       if (oldmovement.x < 0)
                                self.BUTTON_CROUCH = true;
 #elif defined(CSQC)
                                self.BUTTON_CROUCH = true;
 #elif defined(CSQC)
-                       if(oldmovement_x < 0) { input_buttons |= 16; self.flags |= FL_DUCKED; } //else { input_buttons &= ~16; self.flags &= ~FL_DUCKED; }
+                       if (oldmovement.x < 0)
+                       {
+                               input_buttons |= BIT(4);
+                               self.flags |= FL_DUCKED;
+                       }
+                       //else { input_buttons &= ~16; self.flags &= ~FL_DUCKED; }
 #endif
        }
 }
 #endif
        }
 }
@@ -72,7 +77,7 @@ vector old_camera_angle = '0 0 0';
 void viewloc_SetViewLocation()
 {
        entity view = CSQCModel_server2csqc(player_localentnum);
 void viewloc_SetViewLocation()
 {
        entity view = CSQCModel_server2csqc(player_localentnum);
-       if(!view) { return; }
+       if (!view) return;
        //NOTE: the "cam_" cvars sould probably be changed out with a spawnflag or an entity key. I have it like this for my testing -- Player_2
        if(view.viewloc && !wasfreed(view.viewloc) && view.viewloc.enemy && view.viewloc.goalentity)
        {
        //NOTE: the "cam_" cvars sould probably be changed out with a spawnflag or an entity key. I have it like this for my testing -- Player_2
        if(view.viewloc && !wasfreed(view.viewloc) && view.viewloc.enemy && view.viewloc.goalentity)
        {
index 749237fa311b9c70c6c6e97714d946e908536926..78aaa942501b1bab7abfb87b4e92de7adf76ca2d 100644 (file)
@@ -857,7 +857,7 @@ void Draw_ArcBeam(entity this)
 
        if(!self.beam_usevieworigin)
        {
 
        if(!self.beam_usevieworigin)
        {
-               InterpolateOrigin_Do();
+               InterpolateOrigin_Do(self);
        }
 
        // origin = beam starting origin
        }
 
        // origin = beam starting origin
@@ -1208,7 +1208,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
                // self.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
                self.iflags = IFLAG_ORIGIN;
 
                // self.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
                self.iflags = IFLAG_ORIGIN;
 
-               InterpolateOrigin_Undo();
+               InterpolateOrigin_Undo(self);
        }
 
        if(sf & ARC_SF_START) // starting location
        }
 
        if(sf & ARC_SF_START) // starting location
@@ -1492,7 +1492,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
 
        if(!self.beam_usevieworigin)
        {
 
        if(!self.beam_usevieworigin)
        {
-               InterpolateOrigin_Note();
+               InterpolateOrigin_Note(this);
        }
        return true;
 }
        }
        return true;
 }
index 2057c881e53bacef2128325dffb6a76be2c5ec5c..f9c23485e5d8e0206735b9310e965e00f535c68a 100644 (file)
@@ -188,8 +188,7 @@ void CSQCModel_Draw()
 
        // we don't do this for the local player as that one is already handled
        // by CSQCPlayer_SetCamera()
 
        // we don't do this for the local player as that one is already handled
        // by CSQCPlayer_SetCamera()
-       if(!CSQCPlayer_IsLocalPlayer())
-               InterpolateOrigin_Do();
+       if (!CSQCPlayer_IsLocalPlayer(this)) InterpolateOrigin_Do(this);
 
        CSQCModel_InterpolateAnimation_Do();
 
 
        CSQCModel_InterpolateAnimation_Do();
 
@@ -238,8 +237,8 @@ NET_HANDLE(ENT_CLIENT_MODEL, bool isnew)
 
        { CSQCMODEL_HOOK_PREUPDATE }
 
 
        { CSQCMODEL_HOOK_PREUPDATE }
 
-       CSQCPlayer_PreUpdate();
-       InterpolateOrigin_Undo();
+       CSQCPlayer_PreUpdate(this);
+       InterpolateOrigin_Undo(this);
        CSQCModel_InterpolateAnimation_PreNote(sf);
 
 #define CSQCMODEL_IF(cond) if(cond) {
        CSQCModel_InterpolateAnimation_PreNote(sf);
 
 #define CSQCMODEL_IF(cond) if(cond) {
@@ -270,13 +269,13 @@ NET_HANDLE(ENT_CLIENT_MODEL, bool isnew)
        }
 
        CSQCModel_InterpolateAnimation_Note(sf);
        }
 
        CSQCModel_InterpolateAnimation_Note(sf);
-       InterpolateOrigin_Note();
-       CSQCPlayer_PostUpdate();
+       InterpolateOrigin_Note(this);
+       CSQCPlayer_PostUpdate(this);
 
        { CSQCMODEL_HOOK_POSTUPDATE }
 
 #ifdef CSQCMODEL_SUPPORT_GETTAGINFO_BEFORE_DRAW
 
        { CSQCMODEL_HOOK_POSTUPDATE }
 
 #ifdef CSQCMODEL_SUPPORT_GETTAGINFO_BEFORE_DRAW
-       InterpolateOrigin_Do();
+       InterpolateOrigin_Do(this);
        CSQCModel_InterpolateAnimation_Do();
 #endif
 
        CSQCModel_InterpolateAnimation_Do();
 #endif
 
index 155ad7f9229103526c52881c4a42106aa8827d2a..49011fd64a70ab94ce76cade461ad9352107d722 100644 (file)
@@ -51,15 +51,13 @@ float csqcplayer_predictionerrorfactor;
 
 vector CSQCPlayer_GetPredictionErrorO()
 {
 
 vector CSQCPlayer_GetPredictionErrorO()
 {
-       if(time >= csqcplayer_predictionerrortime)
-               return '0 0 0';
+       if (time >= csqcplayer_predictionerrortime) return '0 0 0';
        return csqcplayer_predictionerroro * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor;
 }
 
 vector CSQCPlayer_GetPredictionErrorV()
 {
        return csqcplayer_predictionerroro * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor;
 }
 
 vector CSQCPlayer_GetPredictionErrorV()
 {
-       if(time >= csqcplayer_predictionerrortime)
-               return '0 0 0';
+       if (time >= csqcplayer_predictionerrortime) return '0 0 0';
        return csqcplayer_predictionerrorv * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor;
 }
 
        return csqcplayer_predictionerrorv * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor;
 }
 
@@ -96,74 +94,72 @@ void CSQCPlayer_SetPredictionError(vector o, vector v, float onground_diff)
        csqcplayer_predictionerrortime = time + 1.0 / csqcplayer_predictionerrorfactor;
 }
 
        csqcplayer_predictionerrortime = time + 1.0 / csqcplayer_predictionerrorfactor;
 }
 
-void CSQCPlayer_Unpredict()
-{SELFPARAM();
-       if(csqcplayer_status == CSQCPLAYERSTATUS_UNPREDICTED)
-               return;
-       if(csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED)
-               error("Cannot unpredict in current status");
-       self.origin = csqcplayer_origin;
-       self.velocity = csqcplayer_velocity;
-       csqcplayer_moveframe = csqcplayer_sequence+1; //+1 because the recieved frame has the move already done (server side)
-       self.flags = player_pmflags;
+void CSQCPlayer_Unpredict(entity this)
+{
+       if (csqcplayer_status == CSQCPLAYERSTATUS_UNPREDICTED) return;
+       if (csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED) LOG_FATALF("Cannot unpredict in current status (%d)\n", csqcplayer_status);
+       this.origin = csqcplayer_origin;
+       this.velocity = csqcplayer_velocity;
+       csqcplayer_moveframe = csqcplayer_sequence + 1; // + 1 because the recieved frame has the move already done (server side)
+       this.flags = player_pmflags;
 }
 
 }
 
-void CSQCPlayer_SetMinsMaxs()
-{SELFPARAM();
-       if(self.flags & FL_DUCKED)
+void CSQCPlayer_SetMinsMaxs(entity this)
+{
+       if (this.flags & FL_DUCKED)
        {
        {
-               self.mins = PL_CROUCH_MIN;
-               self.maxs = PL_CROUCH_MAX;
-               self.view_ofs = PL_CROUCH_VIEW_OFS;
+               this.mins = PL_CROUCH_MIN;
+               this.maxs = PL_CROUCH_MAX;
+               this.view_ofs = PL_CROUCH_VIEW_OFS;
        }
        else
        {
        }
        else
        {
-               self.mins = PL_MIN;
-               self.maxs = PL_MAX;
-               self.view_ofs = PL_VIEW_OFS;
+               this.mins = PL_MIN;
+               this.maxs = PL_MAX;
+               this.view_ofs = PL_VIEW_OFS;
        }
 }
 
        }
 }
 
-void CSQCPlayer_SavePrediction()
-{SELFPARAM();
-       player_pmflags = self.flags;
-       csqcplayer_origin = self.origin;
-       csqcplayer_velocity = self.velocity;
+void CSQCPlayer_SavePrediction(entity this)
+{
+       player_pmflags = this.flags;
+       csqcplayer_origin = this.origin;
+       csqcplayer_velocity = this.velocity;
        csqcplayer_sequence = servercommandframe;
        csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
 }
 
        csqcplayer_sequence = servercommandframe;
        csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
 }
 
-void CSQC_ClientMovement_PlayerMove_Frame();
+void CSQC_ClientMovement_PlayerMove_Frame(entity this);
 
 
-void PM_Movement_Move()
-{SELFPARAM();
-       runstandardplayerphysics(self);
+void PM_Movement_Move(entity this)
+{
+       runstandardplayerphysics(this);
 #ifdef CSQC
 #ifdef CSQC
-       self.flags =
-                       ((self.pmove_flags & PMF_DUCKED) ? FL_DUCKED : 0) |
-                       (!(self.pmove_flags & PMF_JUMP_HELD) ? FL_JUMPRELEASED : 0) |
-                       ((self.pmove_flags & PMF_ONGROUND) ? FL_ONGROUND : 0);
+       this.flags =
+                       ((this.pmove_flags & PMF_DUCKED) ? FL_DUCKED : 0) |
+                       (!(this.pmove_flags & PMF_JUMP_HELD) ? FL_JUMPRELEASED : 0) |
+                       ((this.pmove_flags & PMF_ONGROUND) ? FL_ONGROUND : 0);
 #endif
 }
 
 #endif
 }
 
-void CSQCPlayer_Physics()
+void CSQCPlayer_Physics(entity this)
 {
 {
-       switch(autocvar_cl_movement)
+       switch (autocvar_cl_movement)
        {
        {
-               case 1: CSQC_ClientMovement_PlayerMove_Frame(); break;
-               case 2: PM_Movement_Move(); break;
+               case 1: CSQC_ClientMovement_PlayerMove_Frame(this); break;
+               case 2: PM_Movement_Move(this); break;
        }
 }
 
        }
 }
 
-void CSQCPlayer_PredictTo(float endframe, float apply_error)
-{SELFPARAM();
-       CSQCPlayer_Unpredict();
-       if(apply_error)
+void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error)
+{
+       CSQCPlayer_Unpredict(this);
+       if (apply_error)
        {
        {
-               self.origin += CSQCPlayer_GetPredictionErrorO();
-               self.velocity += CSQCPlayer_GetPredictionErrorV();
+               this.origin += CSQCPlayer_GetPredictionErrorO();
+               this.velocity += CSQCPlayer_GetPredictionErrorV();
        }
        }
-       CSQCPlayer_SetMinsMaxs();
+       CSQCPlayer_SetMinsMaxs(this);
 
        csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
 
 
        csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
 
@@ -179,7 +175,7 @@ void CSQCPlayer_PredictTo(float endframe, float apply_error)
        }
 #endif
 
        }
 #endif
 
-       if(csqcplayer_moveframe >= endframe)
+       if (csqcplayer_moveframe >= endframe)
        {
                getinputstate(csqcplayer_moveframe - 1);
        }
        {
                getinputstate(csqcplayer_moveframe - 1);
        }
@@ -187,22 +183,21 @@ void CSQCPlayer_PredictTo(float endframe, float apply_error)
        {
                do
                {
        {
                do
                {
-                       if (!getinputstate(csqcplayer_moveframe))
-                               break;
-                       CSQCPlayer_Physics();
-                       CSQCPlayer_SetMinsMaxs();
-                       csqcplayer_moveframe++;
+                       if (!getinputstate(csqcplayer_moveframe)) break;
+                       CSQCPlayer_Physics(this);
+                       CSQCPlayer_SetMinsMaxs(this);
+                       ++csqcplayer_moveframe;
                }
                }
-               while(csqcplayer_moveframe < endframe);
+               while (csqcplayer_moveframe < endframe);
        }
 
        }
 
-       //add in anything that was applied after (for low packet rate protocols)
+       // add in anything that was applied after (for low packet rate protocols)
        input_angles = view_angles;
 }
 
        input_angles = view_angles;
 }
 
-bool CSQCPlayer_IsLocalPlayer()
-{SELFPARAM();
-       return (self == csqcplayer);
+bool CSQCPlayer_IsLocalPlayer(entity this)
+{
+       return (this == csqcplayer);
 }
 
 void CSQCPlayer_SetViewLocation()
 }
 
 void CSQCPlayer_SetViewLocation()
@@ -210,118 +205,90 @@ void CSQCPlayer_SetViewLocation()
        viewloc_SetViewLocation();
 }
 
        viewloc_SetViewLocation();
 }
 
+/** Called once per CSQC_UpdateView() */
 void CSQCPlayer_SetCamera()
 void CSQCPlayer_SetCamera()
-{SELFPARAM();
-       vector v0;
-       v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
-
-       if(csqcplayer)
+{
+       const vector v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
+       const float vh = getstati(STAT_VIEWHEIGHT);
+       const vector pl_viewofs = PL_VIEW_OFS;
+       const vector pl_viewofs_crouch = PL_CROUCH_VIEW_OFS;
+       const entity e = csqcplayer;
+       if (e)
        {
        {
-               setself(csqcplayer);
-
-               if(servercommandframe == 0 || clientcommandframe == 0)
+               if (servercommandframe == 0 || clientcommandframe == 0)
                {
                {
-                       InterpolateOrigin_Do();
-                       self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+                       InterpolateOrigin_Do(e);
+                       e.view_ofs = '0 0 1' * vh;
 
                        // get crouch state from the server
 
                        // get crouch state from the server
-                       if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z)
-                               self.flags &= ~FL_DUCKED;
-                       else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z)
-                               self.flags |= FL_DUCKED;
+                       if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
+                       else if (vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
 
                        // get onground state from the server
 
                        // get onground state from the server
-                       if(pmove_onground)
-                               self.flags |= FL_ONGROUND;
-                       else
-                               self.flags &= ~FL_ONGROUND;
+                       e.flags = BITSET(e.flags, FL_ONGROUND, pmove_onground);
 
 
-                       CSQCPlayer_SetMinsMaxs();
+                       CSQCPlayer_SetMinsMaxs(e);
 
                        // override it back just in case
 
                        // override it back just in case
-                       self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+                       e.view_ofs = '0 0 1' * vh;
 
                        // set velocity
 
                        // set velocity
-                       self.velocity = v0;
+                       e.velocity = v0;
                }
                else
                {
                }
                else
                {
-                       float flg = self.iflags;
-                       self.iflags &= ~(IFLAG_ORIGIN | IFLAG_ANGLES);
-                       InterpolateOrigin_Do();
-                       self.iflags = flg;
+                       const int flg = e.iflags; e.iflags &= ~(IFLAG_ORIGIN | IFLAG_ANGLES);
+                       InterpolateOrigin_Do(e);
+                       e.iflags = flg;
 
 
-                       if(csqcplayer_status == CSQCPLAYERSTATUS_FROMSERVER)
+                       if (csqcplayer_status == CSQCPLAYERSTATUS_FROMSERVER)
                        {
                        {
-                               vector o, v;
-                               o = self.origin;
-                               v = v0;
+                               const vector o = e.origin;
                                csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
                                csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
-                               CSQCPlayer_PredictTo(servercommandframe + 1, false);
-                               CSQCPlayer_SetPredictionError(self.origin - o, self.velocity - v, pmove_onground - !!(self.flags & FL_ONGROUND));
-                               self.origin = o;
-                               self.velocity = v;
+                               CSQCPlayer_PredictTo(e, servercommandframe + 1, false);
+                               CSQCPlayer_SetPredictionError(e.origin - o, e.velocity - v0, pmove_onground - boolean(e.flags & FL_ONGROUND));
+                               e.origin = o;
+                               e.velocity = v0;
 
                                // get crouch state from the server
 
                                // get crouch state from the server
-                               if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z)
-                                       self.flags &= ~FL_DUCKED;
-                               else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z)
-                                       self.flags |= FL_DUCKED;
+                               if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
+                               else if(vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
 
                                // get onground state from the server
 
                                // get onground state from the server
-                               if(pmove_onground)
-                                       self.flags |= FL_ONGROUND;
-                               else
-                                       self.flags &= ~FL_ONGROUND;
+                               e.flags = BITSET(e.flags, FL_ONGROUND, pmove_onground);
 
 
-                               CSQCPlayer_SavePrediction();
+                               CSQCPlayer_SavePrediction(e);
                        }
                        }
-                       CSQCPlayer_PredictTo(clientcommandframe + 1, true);
+                       CSQCPlayer_PredictTo(e, clientcommandframe + 1, true);
 
 #ifdef CSQCMODEL_SERVERSIDE_CROUCH
                        // get crouch state from the server (LAG)
 
 #ifdef CSQCMODEL_SERVERSIDE_CROUCH
                        // get crouch state from the server (LAG)
-                       if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z)
-                               self.flags &= ~FL_DUCKED;
-                       else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z)
-                               self.flags |= FL_DUCKED;
+                       if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
+                       else if (vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
 #endif
 #endif
+                       CSQCPlayer_SetMinsMaxs(e);
 
 
-                       CSQCPlayer_SetMinsMaxs();
-
-                       self.angles_y = input_angles.y;
+                       e.angles_y = input_angles.y;
                }
 
                // relink
                }
 
                // relink
-               setorigin(self, self.origin);
-
-               setself(this);
-       }
-
-       entity view = CSQCModel_server2csqc(player_localentnum);
-
-       if(view && view != csqcplayer)
-       {
-               WITH(entity, self, view, InterpolateOrigin_Do());
-               view.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+               setorigin(e, e.origin);
        }
 
        }
 
-       if(view)
+       const entity view = CSQCModel_server2csqc(player_localentnum);
+       if (view)
        {
        {
+               if (view != csqcplayer)
+               {
+                       InterpolateOrigin_Do(view);
+                       view.view_ofs = '0 0 1' * vh;
+               }
                int refdefflags = 0;
                int refdefflags = 0;
-
-               if(view.csqcmodel_teleported)
-                       refdefflags |= REFDEFFLAG_TELEPORTED;
-
-               if(input_buttons & 4)
-                       refdefflags |= REFDEFFLAG_JUMPING;
-
+               if (view.csqcmodel_teleported) refdefflags |= REFDEFFLAG_TELEPORTED;
+               if (input_buttons & BIT(1)) refdefflags |= REFDEFFLAG_JUMPING;
                // note: these two only work in WIP2, but are harmless in WIP1
                // note: these two only work in WIP2, but are harmless in WIP1
-               if(getstati(STAT_HEALTH) <= 0)
-                       refdefflags |= REFDEFFLAG_DEAD;
-
-               if(intermission)
-                       refdefflags |= REFDEFFLAG_INTERMISSION;
-
+               if (getstati(STAT_HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD;
+               if (intermission) refdefflags |= REFDEFFLAG_INTERMISSION;
                V_CalcRefdef(view, refdefflags);
        }
        else
                V_CalcRefdef(view, refdefflags);
        }
        else
@@ -329,36 +296,32 @@ void CSQCPlayer_SetCamera()
                // FIXME by CSQC spec we have to do this:
                // but it breaks chase cam
                /*
                // FIXME by CSQC spec we have to do this:
                // but it breaks chase cam
                /*
-               setproperty(VF_ORIGIN, pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT));
+               setproperty(VF_ORIGIN, pmove_org + '0 0 1' * vh);
                setproperty(VF_ANGLES, view_angles);
                */
        }
                setproperty(VF_ANGLES, view_angles);
                */
        }
-
-       { CSQCPLAYER_HOOK_POSTCAMERASETUP }
+       CSQCPLAYER_HOOK_POSTCAMERASETUP();
 }
 
 void CSQCPlayer_Remove()
 {
 }
 
 void CSQCPlayer_Remove()
 {
-       csqcplayer = world;
+       csqcplayer = NULL;
        cvar_settemp("cl_movement_replay", "1");
 }
 
        cvar_settemp("cl_movement_replay", "1");
 }
 
-float CSQCPlayer_PreUpdate()
-{SELFPARAM();
-       if(self != csqcplayer)
-               return 0;
-       if(csqcplayer_status != CSQCPLAYERSTATUS_FROMSERVER)
-               CSQCPlayer_Unpredict();
-       return 1;
+bool CSQCPlayer_PreUpdate(entity this)
+{
+       if (this != csqcplayer) return false;
+       if (csqcplayer_status != CSQCPLAYERSTATUS_FROMSERVER) CSQCPlayer_Unpredict(this);
+       return true;
 }
 
 }
 
-float CSQCPlayer_PostUpdate()
-{SELFPARAM();
-       if(self.entnum != player_localnum + 1)
-               return 0;
-       csqcplayer = self;
+bool CSQCPlayer_PostUpdate(entity this)
+{
+       if (this.entnum != player_localnum + 1) return false;
+       csqcplayer = this;
        csqcplayer_status = CSQCPLAYERSTATUS_FROMSERVER;
        cvar_settemp("cl_movement_replay", "0");
        csqcplayer_status = CSQCPLAYERSTATUS_FROMSERVER;
        cvar_settemp("cl_movement_replay", "0");
-       self.entremove = CSQCPlayer_Remove;
-       return 1;
+       this.entremove = CSQCPlayer_Remove;
+       return true;
 }
 }
index c9598c8807dbf33e7de091d615c1cc9712c9dd7f..5b12dfa12cf7b60bbb6da8039c9057c58fbcefc2 100644 (file)
@@ -37,7 +37,7 @@ const int PMF_JUMP_HELD = 1;
 const int FL_DUCKED = 524288;
 
 void CSQCPlayer_SetCamera();
 const int FL_DUCKED = 524288;
 
 void CSQCPlayer_SetCamera();
-float CSQCPlayer_PreUpdate();
-float CSQCPlayer_PostUpdate();
-float CSQCPlayer_IsLocalPlayer();
+float CSQCPlayer_PreUpdate(entity this);
+float CSQCPlayer_PostUpdate(entity this);
+float CSQCPlayer_IsLocalPlayer(entity this);
 #endif
 #endif
index 6da742a04e34944d814827d1e7618ce74f006682..c4ec135e8a789b5ae2d7ef505272768c897867fc 100644 (file)
@@ -44,7 +44,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\
 IN THE SOFTWARE.\
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\
 IN THE SOFTWARE.\
-";
+"; // "
 
 .vector glowmod;
 .vector view_ofs;
 
 .vector glowmod;
 .vector view_ofs;
index ca846da0f15c932a15b76ea0c84ef137747df7fd..311a289d6b6aa74d9f06ed4907f64498c1673248 100644 (file)
  */
 #include "interpolate.qh"
 
  */
 #include "interpolate.qh"
 
-#if defined(CSQC)
-//     #include "../../client/defs.qh"
-//     #include "../warpzone/anglestransform.qh"
-//     #include "../../client/autocvars.qh"
-//     #include "cl_model.qh"
-#elif defined(MENUQC)
-#elif defined(SVQC)
-#endif
-
+// 1 = old, 2 = new
 .vector iorigin1, iorigin2;
 .vector ivelocity1, ivelocity2;
 .vector iforward1, iforward2;
 .vector iorigin1, iorigin2;
 .vector ivelocity1, ivelocity2;
 .vector iforward1, iforward2;
 .vector ivup1, ivup2;
 .float itime1, itime2;
 void InterpolateOrigin_Reset()
 .vector ivup1, ivup2;
 .float itime1, itime2;
 void InterpolateOrigin_Reset()
-{SELFPARAM();
+{
+       SELFPARAM();
        self.iflags &= ~IFLAG_INTERNALMASK;
        self.itime1 = self.itime2 = 0;
 }
        self.iflags &= ~IFLAG_INTERNALMASK;
        self.itime1 = self.itime2 = 0;
 }
-void InterpolateOrigin_Note()
-{SELFPARAM();
-       float dt;
-       int f0;
-
-       dt = time - self.itime2;
+void InterpolateOrigin_Note(entity this)
+{
+       float dt = time - this.itime2;
 
 
-       f0 = self.iflags;
-       if(self.iflags & IFLAG_PREVALID)
-               self.iflags |= IFLAG_VALID;
-       else
-               self.iflags |= IFLAG_PREVALID;
+       int f0 = this.iflags;
+       if (this.iflags & IFLAG_PREVALID) this.iflags |= IFLAG_VALID;
+       else this.iflags |= IFLAG_PREVALID;
 
 
-       if(self.iflags & IFLAG_ORIGIN)
+       if (this.iflags & IFLAG_ORIGIN)
        {
        {
-               self.iorigin1 = self.iorigin2;
-               self.iorigin2 = self.origin;
+               this.iorigin1 = this.iorigin2;
+               this.iorigin2 = this.origin;
        }
 
        }
 
-       if(self.iflags & IFLAG_AUTOANGLES)
-               if(self.iorigin2 != self.iorigin1)
-                       self.angles = vectoangles(self.iorigin2 - self.iorigin1);
+       if (this.iflags & IFLAG_AUTOANGLES
+           && this.iorigin2
+           != this.iorigin1) this.angles = vectoangles(this.iorigin2 - this.iorigin1);
 
 
-       if(self.iflags & IFLAG_AUTOVELOCITY)
-               if(self.itime2 != self.itime1)
-                       self.velocity = (self.iorigin2 - self.iorigin1) * (1.0 / (self.itime2 - self.itime1));
+       if (this.iflags & IFLAG_AUTOVELOCITY
+           && this.itime2
+           != this.itime1) this.velocity = (this.iorigin2 - this.iorigin1) * (1.0 / (this.itime2 - this.itime1));
 
 
-       if(self.iflags & IFLAG_ANGLES)
+       if (this.iflags & IFLAG_ANGLES)
        {
        {
-               fixedmakevectors(self.angles);
-               if(f0 & IFLAG_VALID)
+               fixedmakevectors(this.angles);
+               if (f0 & IFLAG_VALID)
                {
                {
-                       self.iforward1 = self.iforward2;
-                       self.iup1 = self.iup2;
+                       this.iforward1 = this.iforward2;
+                       this.iup1 = this.iup2;
                }
                else
                {
                }
                else
                {
-                       self.iforward1 = v_forward;
-                       self.iup1 = v_up;
+                       this.iforward1 = v_forward;
+                       this.iup1 = v_up;
                }
                }
-               self.iforward2 = v_forward;
-               self.iup2 = v_up;
+               this.iforward2 = v_forward;
+               this.iup2 = v_up;
        }
 
        }
 
-       if(self.iflags & IFLAG_V_ANGLE)
+       if (this.iflags & IFLAG_V_ANGLE)
        {
        {
-               fixedmakevectors(self.v_angle);
-               if(f0 & IFLAG_VALID)
+               fixedmakevectors(this.v_angle);
+               if (f0 & IFLAG_VALID)
                {
                {
-                       self.ivforward1 = self.ivforward2;
-                       self.ivup1 = self.ivup2;
+                       this.ivforward1 = this.ivforward2;
+                       this.ivup1 = this.ivup2;
                }
                else
                {
                }
                else
                {
-                       self.ivforward1 = v_forward;
-                       self.ivup1 = v_up;
+                       this.ivforward1 = v_forward;
+                       this.ivup1 = v_up;
                }
                }
-               self.ivforward2 = v_forward;
-               self.ivup2 = v_up;
+               this.ivforward2 = v_forward;
+               this.ivup2 = v_up;
        }
        }
-       else if(self.iflags & IFLAG_V_ANGLE_X)
+       else if (this.iflags & IFLAG_V_ANGLE_X)
        {
        {
-               self.ivforward1_x = self.ivforward2_x;
-               self.ivforward2_x = self.v_angle.x;
+               this.ivforward1_x = this.ivforward2_x;
+               this.ivforward2_x = this.v_angle.x;
        }
 
        }
 
-       if(self.iflags & IFLAG_VELOCITY)
+       if (this.iflags & IFLAG_VELOCITY)
        {
        {
-               self.ivelocity1 = self.ivelocity2;
-               self.ivelocity2 = self.velocity;
+               this.ivelocity1 = this.ivelocity2;
+               this.ivelocity2 = this.velocity;
        }
 
        }
 
-       if(self.iflags & IFLAG_TELEPORTED)
+       if (this.iflags & IFLAG_TELEPORTED)
        {
        {
-               self.iflags &= ~IFLAG_TELEPORTED;
-               self.itime1 = self.itime2 = time; // don't lerp
+               this.iflags &= ~IFLAG_TELEPORTED;
+               this.itime1 = this.itime2 = time;  // don't lerp
        }
        }
-       else if(vlen(self.iorigin2 - self.iorigin1) > 1000)
+       else if (vdist(this.iorigin2 - this.iorigin1, >, 1000))
        {
        {
-               self.itime1 = self.itime2 = time; // don't lerp
+               this.itime1 = this.itime2 = time;  // don't lerp
        }
        }
-       else if((self.iflags & IFLAG_VELOCITY) && (vlen(self.ivelocity2 - self.ivelocity1) > 1000))
+       else if ((this.iflags & IFLAG_VELOCITY) && vdist(this.ivelocity2 - this.ivelocity1, >, 1000))
        {
        {
-               self.itime1 = self.itime2 = time; // don't lerp
+               this.itime1 = this.itime2 = time;  // don't lerp
        }
        }
-       else if(dt >= 0.2)
+       else if (dt >= 0.2)
        {
        {
-               self.itime1 = self.itime2 = time;
+               this.itime1 = this.itime2 = time;
        }
        else
        {
        }
        else
        {
-               self.itime1 = serverprevtime;
-               self.itime2 = time;
+               this.itime1 = serverprevtime;
+               this.itime2 = time;
        }
 }
        }
 }
-void InterpolateOrigin_Do()
-{SELFPARAM();
-       vector forward, up;
-       if(self.itime1 && self.itime2 && self.itime1 != self.itime2)
+
+/** set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time */
+void InterpolateOrigin_Do(entity this)
+{
+       if (this.itime1 && this.itime2 && this.itime1 != this.itime2)
        {
        {
-               float f;
-               f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1 + autocvar_cl_lerpexcess);
-               if(self.iflags & IFLAG_ORIGIN)
-                       setorigin(self, (1 - f) * self.iorigin1 + f * self.iorigin2);
-               if(self.iflags & IFLAG_ANGLES)
+               float f = bound(0, (time - this.itime1) / (this.itime2 - this.itime1), 1 + autocvar_cl_lerpexcess);
+               float f_1 = 1 - f;
+               if (this.iflags & IFLAG_ORIGIN) setorigin(this, f_1 * this.iorigin1 + f * this.iorigin2);
+               if (this.iflags & IFLAG_ANGLES)
                {
                {
-                       forward = (1 - f) * self.iforward1 + f * self.iforward2;
-                       up = (1 - f) * self.iup1 + f * self.iup2;
-                       self.angles = fixedvectoangles2(forward, up);
+                       vector forward = f_1 * this.iforward1 + f * this.iforward2;
+                       vector up = f_1 * this.iup1 + f * this.iup2;
+                       this.angles = fixedvectoangles2(forward, up);
                }
                }
-               if(self.iflags & IFLAG_V_ANGLE)
+               if (this.iflags & IFLAG_V_ANGLE)
                {
                {
-                       forward = (1 - f) * self.ivforward1 + f * self.ivforward2;
-                       up = (1 - f) * self.ivup1 + f * self.ivup2;
-                       self.v_angle = fixedvectoangles2(forward, up);
+                       vector forward = f_1 * this.ivforward1 + f * this.ivforward2;
+                       vector up = f_1 * this.ivup1 + f * this.ivup2;
+                       this.v_angle = fixedvectoangles2(forward, up);
                }
                }
-               else if(self.iflags & IFLAG_V_ANGLE_X)
-                       self.v_angle_x = (1 - f) * self.ivforward1_x + f * self.ivforward2_x;
-               if(self.iflags & IFLAG_VELOCITY)
-                       self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2;
+               else if (this.iflags & IFLAG_V_ANGLE_X)
+               {
+                       this.v_angle_x = f_1 * this.ivforward1.x + f * this.ivforward2.x;
+               }
+               if (this.iflags & IFLAG_VELOCITY) this.velocity = f_1 * this.ivelocity1 + f * this.ivelocity2;
        }
 }
        }
 }
-void InterpolateOrigin_Undo()
-{SELFPARAM();
-       if(self.iflags & IFLAG_ORIGIN)
-               setorigin(self, self.iorigin2);
-       if(self.iflags & IFLAG_ANGLES)
-               self.angles = fixedvectoangles2(self.iforward2, self.iup2);
-       if(self.iflags & IFLAG_V_ANGLE)
-               self.v_angle = fixedvectoangles2(self.ivforward2, self.ivup2);
-       else if(self.iflags & IFLAG_V_ANGLE_X)
-               self.v_angle_x = self.ivforward2_x;
-       if(self.iflags & IFLAG_VELOCITY)
-               self.velocity = self.ivelocity2;
-}
 
 
+/** snap origin to iorigin2 (actual origin) */
+void InterpolateOrigin_Undo(entity this)
+{
+       if (this.iflags & IFLAG_ORIGIN) setorigin(this, this.iorigin2);
+       if (this.iflags & IFLAG_ANGLES) this.angles = fixedvectoangles2(this.iforward2, this.iup2);
+       if (this.iflags & IFLAG_V_ANGLE) this.v_angle = fixedvectoangles2(this.ivforward2, this.ivup2);
+       else if (this.iflags & IFLAG_V_ANGLE_X) this.v_angle_x = this.ivforward2_x;
+       if (this.iflags & IFLAG_VELOCITY) this.velocity = this.ivelocity2;
+}
index 92ec58f0b4ff7048445a0ef2fbb1ffff8dc8815f..fb2f3d3294f1b105f19cc7120d551ab4813cc4cd 100644 (file)
@@ -36,16 +36,16 @@ const int IFLAG_ORIGIN = BIT(9);
 const int IFLAG_INTERNALMASK = IFLAG_VALID | IFLAG_PREVALID;
 
 // call this BEFORE reading an entity update
 const int IFLAG_INTERNALMASK = IFLAG_VALID | IFLAG_PREVALID;
 
 // call this BEFORE reading an entity update
-void InterpolateOrigin_Undo();
+void InterpolateOrigin_Undo(entity this);
 
 // call this AFTER receiving an entity update
 
 // call this AFTER receiving an entity update
-void InterpolateOrigin_Note();
+void InterpolateOrigin_Note(entity this);
 
 // call this when the entity got teleported, before InterpolateOrigin_Note
 void InterpolateOrigin_Reset();
 
 // call this BEFORE drawing
 
 // call this when the entity got teleported, before InterpolateOrigin_Note
 void InterpolateOrigin_Reset();
 
 // call this BEFORE drawing
-void InterpolateOrigin_Do();
+void InterpolateOrigin_Do(entity this);
 
 // in case we interpolate that:
 .vector v_angle;
 
 // in case we interpolate that:
 .vector v_angle;
index 0fa29747543a8aa0da3fd74935e7dfd1a5971b0c..91782e56c129c4df904f92e72eb025560765cb6a 100644 (file)
        void defer_think()
        {
                SELFPARAM();
        void defer_think()
        {
                SELFPARAM();
-               self.think     = SUB_Remove_self;
-               self.nextthink = time;
-               WITH(entity, self, self.owner, self.use());
+               this.think     = SUB_Remove_self;
+               this.nextthink = time;
+               WITH(entity, self, this.owner, this.use());
        }
 
 /*
     Execute func() after time + fdelay.
     self when func is executed = self when defer is called
 */
        }
 
 /*
     Execute func() after time + fdelay.
     self when func is executed = self when defer is called
 */
-       void defer(float fdelay, void() func)
+       void defer(entity this, float fdelay, void() func)
        {
        {
-               SELFPARAM();
-
                entity e    = new(deferred);
                make_pure(e);
                e.owner     = this;
                entity e    = new(deferred);
                make_pure(e);
                e.owner     = this;
index 2d07527c87169fb7fd3422fb922f48c9eb68fbdf..4946daddee31ab90b326390d07ea43964ddc3e5c 100644 (file)
@@ -14,6 +14,8 @@ ENDCLASS(LinkedList)
 
 #define LL_NEW() NEW(LinkedList)
 
 
 #define LL_NEW() NEW(LinkedList)
 
+#define LL_EMPTY(ll) (ll.ll_head == NULL)
+
 /**
  * Push to tail
  */
 /**
  * Push to tail
  */
index 0cda013c0e8238ba26e259c0a232befd690ee9de..d6eee7aceae92104220446b7ee56659daa79c9b0 100644 (file)
@@ -1,6 +1,20 @@
 #ifndef VECTOR_H
 #define VECTOR_H
 
 #ifndef VECTOR_H
 #define VECTOR_H
 
+noref vector _vlen2;
+#define vlen2(v) \
+       (_vlen2 = (v), \
+         _vlen2.x * _vlen2.x \
+       + _vlen2.y * _vlen2.y \
+       + _vlen2.z * _vlen2.z)
+
+noref float _vdist_f;
+/** Vector distance comparison, avoids sqrt() */
+#define vdist(v, cmp, f) (vlen2(v) cmp (_vdist_f = (f), _vdist_f * _vdist_f))
+/*
+#define vdist(v, cmp, f) (vlen(v) cmp (f))
+*/
+
 #define cross(a, b) ((a) >< (b))
 /*
 vector cross(vector a, vector b)
 #define cross(a, b) ((a) >< (b))
 /*
 vector cross(vector a, vector b)
@@ -26,11 +40,6 @@ vector randompos(vector m1, vector m2)
        return v;
 }
 
        return v;
 }
 
-float vlen2d(vector v)
-{
-       return sqrt(v.x * v.x + v.y * v.y);
-}
-
 float vlen_maxnorm2d(vector v)
 {
        return max(v.x, v.y, -v.x, -v.y);
 float vlen_maxnorm2d(vector v)
 {
        return max(v.x, v.y, -v.x, -v.y);
@@ -59,20 +68,11 @@ float boxesoverlap(vector m1, vector m2, vector m3, vector m4) { return m2_x >=
 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { return smins.x >= bmins.x && smaxs.x <= bmaxs.x && smins.y >= bmins.y && smaxs.y <= bmaxs.y && smins.z >= bmins.z && smaxs.z <= bmaxs.z; }
 
 
 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { return smins.x >= bmins.x && smaxs.x <= bmaxs.x && smins.y >= bmins.y && smaxs.y <= bmaxs.y && smins.z >= bmins.z && smaxs.z <= bmaxs.z; }
 
 
-vector vec2(vector v)
-{
-       v.z = 0;
-       return v;
-}
+noref vector _vec2;
+#define vec2(v) (_vec2 = (v), _vec2.z = 0, _vec2)
 
 
-vector vec3(float x, float y, float z)
-{
-       vector v;
-       v.x = x;
-       v.y = y;
-       v.z = z;
-       return v;
-}
+noref vector _vec3;
+#define vec3(x, y, z) (_vec3_x = (x), _vec3_y = (y), _vec3_z = (z), _vec3)
 
 vector rotate(vector v, float a)
 {
 
 vector rotate(vector v, float a)
 {
@@ -83,11 +83,8 @@ vector rotate(vector v, float a)
        return r;
 }
 
        return r;
 }
 
-vector yinvert(vector v)
-{
-       v.y = 1 - v.y;
-       return v;
-}
+noref vector _yinvert;
+#define yinvert(v) (_yinvert = (v), _yinvert.y = 1 - _yinvert.y, _yinvert)
 
 #ifndef MENUQC
        vector get_corner_position(entity box, int corner)
 
 #ifndef MENUQC
        vector get_corner_position(entity box, int corner)
index d6423f1773a150e066dd3d23675f267b18026e0e..9e98199f34be62fcd74fd742dc329f900c169d32 100644 (file)
@@ -1,29 +1,5 @@
 #include "anglestransform.qh"
 
 #include "anglestransform.qh"
 
-#ifdef POSITIVE_PITCH_IS_DOWN
-vector fixedvectoangles(vector a)
-{
-       vector ang;
-       ang = vectoangles(a);
-       ang.x = -ang.x;
-       return ang;
-}
-vector fixedvectoangles2(vector a, vector b)
-{
-       vector ang;
-       ang = vectoangles2(a, b);
-       ang.x = -ang.x;
-       return ang;
-}
-#else
-void fixedmakevectors(vector a)
-{
-       // a makevectors that actually inverts vectoangles
-       a.x = -a.x;
-       makevectors(a);
-}
-#endif
-
 // angles transforms
 // angles in fixedmakevectors/fixedvectoangles space
 vector AnglesTransform_Apply(vector transform, vector v)
 // angles transforms
 // angles in fixedmakevectors/fixedvectoangles space
 vector AnglesTransform_Apply(vector transform, vector v)
@@ -148,7 +124,7 @@ vector AnglesTransform_CancelRoll(vector t)
        return t;
 }
 
        return t;
 }
 
-#ifdef POSITIVE_PITCH_IS_DOWN
+#if POSITIVE_PITCH_IS_DOWN
 vector AnglesTransform_ApplyToAngles(vector transform, vector v)
 {
        v.x = -v.x;
 vector AnglesTransform_ApplyToAngles(vector transform, vector v)
 {
        v.x = -v.x;
index 5c356ea7ffa889489e99fe93d4ee397736ddf5e1..0a10843c0087872de9ed0a0046747331d438543f 100644 (file)
@@ -1,16 +1,25 @@
 #ifndef LIB_WARPZONE_ANGLETRANSFORM_H
 #define LIB_WARPZONE_ANGLETRANSFORM_H
 
 #ifndef LIB_WARPZONE_ANGLETRANSFORM_H
 #define LIB_WARPZONE_ANGLETRANSFORM_H
 
-#define POSITIVE_PITCH_IS_DOWN
+#ifndef POSITIVE_PITCH_IS_DOWN
+#define POSITIVE_PITCH_IS_DOWN 1
+#endif
 
 
-#ifdef POSITIVE_PITCH_IS_DOWN
-#define fixedmakevectors makevectors
-vector fixedvectoangles(vector a);
-vector fixedvectoangles2(vector a, vector b);
+#if POSITIVE_PITCH_IS_DOWN
+    #define fixedmakevectors makevectors
+    noref vector _fixedvectoangles;
+    #define fixedvectoangles(a) (_fixedvectoangles = vectoangles(a), _fixedvectoangles.x *= -1, _fixedvectoangles)
+    noref vector _fixedvectoangles2;
+    #define fixedvectoangles2(a, b) (_fixedvectoangles2 = vectoangles2(a, b), _fixedvectoangles2.x *= -1, _fixedvectoangles2)
 #else
 #else
-void fixedmakevectors(vector a);
-#define fixedvectoangles2 vectoangles2
-#define fixedvectoangles vectoangles
+    void fixedmakevectors(vector a)
+    {
+        // a makevectors that actually inverts vectoangles
+        a.x = -a.x;
+        makevectors(a);
+    }
+    #define fixedvectoangles2 vectoangles2
+    #define fixedvectoangles vectoangles
 #endif
 
 vector AnglesTransform_Apply(vector transform, vector v);
 #endif
 
 vector AnglesTransform_Apply(vector transform, vector v);
index 5dd2a813779e7ec1aae8c5ca5c062d18b2f41feb..2fa622e041a1ee3069878f19efd3ce09b9b1b19a 100644 (file)
@@ -36,7 +36,7 @@ void XonoticEffectsSettingsTab_fill(entity me)
        float n;
        me.TR(me);
                me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Quality preset:")));
        float n;
        me.TR(me);
                me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Quality preset:")));
-               n = 5 + 2 * !!cvar("developer");
+               n = 5 + 2 * boolean(cvar("developer"));
                if(cvar("developer"))
                        me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^OMG!")), '1 0 1', "exec effects-omg.cfg", 0));
                me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^Low")), '0 0 0', "exec effects-low.cfg", 0));
                if(cvar("developer"))
                        me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^OMG!")), '1 0 1', "exec effects-omg.cfg", 0));
                me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^Low")), '0 0 0', "exec effects-low.cfg", 0));
index a47e2c21113bb1119dfdcda2f19e0991f239e9b0..3b624e2ad0bda58ed7e1c39a053569fd02d06327 100644 (file)
@@ -35,10 +35,10 @@ void XonoticTeamSelectDialog_showNotify(entity me)
        float teams, nTeams;
        teams = cvar("_teams_available");
        nTeams = 0;
        float teams, nTeams;
        teams = cvar("_teams_available");
        nTeams = 0;
-       me.team1.disabled = !(teams & 1); nTeams += !!(teams & 1);
-       me.team2.disabled = !(teams & 2); nTeams += !!(teams & 2);
-       me.team3.disabled = !(teams & 4); nTeams += !!(teams & 4);
-       me.team4.disabled = !(teams & 8); nTeams += !!(teams & 8);
+       me.team1.disabled = !(teams & 1); nTeams += boolean(teams & 1);
+       me.team2.disabled = !(teams & 2); nTeams += boolean(teams & 2);
+       me.team3.disabled = !(teams & 4); nTeams += boolean(teams & 4);
+       me.team4.disabled = !(teams & 8); nTeams += boolean(teams & 8);
 }
 
 void XonoticTeamSelectDialog_fill(entity me)
 }
 
 void XonoticTeamSelectDialog_fill(entity me)
index ceeae22ea060f06fd39b071852cfa2cd4263ff5c..1a0ffd55f87cd61fa9e13371f9d942e82d745f8a 100644 (file)
@@ -70,7 +70,7 @@ void XonoticRadioButton_loadCvars(entity me)
        {
                if(me.cvarName)
                {
        {
                if(me.cvarName)
                {
-                       me.checked = !!cvar(me.cvarName);
+                       me.checked = boolean(cvar(me.cvarName));
                }
                else
                {
                }
                else
                {
index ea3a74fd54bea15d9bcac46c065f1d2a9ffee54f..b0348125e6cbb9a0ee05d573f045cd0e93bbaad4 100644 (file)
@@ -1198,7 +1198,7 @@ float bot_execute_commands_once()
        }
 
        // Keep pressing keys raised by the "presskey" command
        }
 
        // Keep pressing keys raised by the "presskey" command
-       ispressingkey = !!bot_presskeys();
+       ispressingkey = boolean(bot_presskeys());
 
        // Handle conditions
        if (!(bot_cmd.bot_cmd_type==BOT_CMD_FI||bot_cmd.bot_cmd_type==BOT_CMD_ELSE))
 
        // Handle conditions
        if (!(bot_cmd.bot_cmd_type==BOT_CMD_FI||bot_cmd.bot_cmd_type==BOT_CMD_ELSE))
index 26d089245f4822a15966f7505dc68bc3a54ccf74..47aff4a0b0c4dacad39a7263b960b63cc0984c06 100644 (file)
@@ -1218,7 +1218,7 @@ void ClientConnect ()
        self.model_randomizer = random();
 
        if(IS_REAL_CLIENT(self))
        self.model_randomizer = random();
 
        if(IS_REAL_CLIENT(self))
-               sv_notice_join();
+               sv_notice_join(self);
 
        for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
                WITH(entity, self, e, e.init_for_player(this));
 
        for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
                WITH(entity, self, e, e.init_for_player(this));
index cbfc8f814f5bd1b65a12fe604fe3219a3c0b6247..e985ee5c0020242f6d9d5fc3f3512e1ce1d3d038 100644 (file)
@@ -974,9 +974,9 @@ void kh_WaitForPlayers()  // delay start of the round until enough players are p
                }
                else
                {
                }
                else
                {
-                       float missing_teams_mask = (!!p1) + (!!p2) * 2;
-                       if(kh_teams >= 3) missing_teams_mask += (!!p3) * 4;
-                       if(kh_teams >= 4) missing_teams_mask += (!!p4) * 8;
+                       float missing_teams_mask = boolean(p1) + boolean(p2) * 2;
+                       if(kh_teams >= 3) missing_teams_mask += boolean(p3) * 4;
+                       if(kh_teams >= 4) missing_teams_mask += boolean(p4) * 8;
                        if(prev_missing_teams_mask != missing_teams_mask)
                        {
                                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
                        if(prev_missing_teams_mask != missing_teams_mask)
                        {
                                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
index 18600463741fc20bb88e1fd5baf07b7a9ddb47bc..8d6f9dc70ea760fc45c7a27bdb97b6d8e5af5a04 100644 (file)
@@ -53,7 +53,7 @@ vector Portal_ApplyTransformToPlayerAngle(vector transform, vector vangle)
         */
 
        // PLAYERS use different math
         */
 
        // PLAYERS use different math
-#ifndef POSITIVE_PITCH_IS_DOWN
+#if !(POSITIVE_PITCH_IS_DOWN)
        ang.x = -ang.x;
 #endif
 
        ang.x = -ang.x;
 #endif
 
@@ -94,7 +94,7 @@ vector Portal_ApplyTransformToPlayerAngle(vector transform, vector vangle)
                //print("GOOD path: ", vtos(ang), "\n");
        }
 
                //print("GOOD path: ", vtos(ang), "\n");
        }
 
-#ifndef POSITIVE_PITCH_IS_DOWN
+#if !(POSITIVE_PITCH_IS_DOWN)
        ang.x = -ang.x;
 #endif
        ang.z = vangle.z;
        ang.x = -ang.x;
 #endif
        ang.z = vangle.z;
index bc9fafc4c293f821ef6e3f36e951e123946cf39b..093946d97e7fbb7ec96d709231925a5d41ccc5a4 100644 (file)
@@ -661,7 +661,7 @@ void checkpoint_passed()
                other.race_checkpoint = race_NextCheckpoint(self.race_checkpoint);
                other.race_started = 1;
 
                other.race_checkpoint = race_NextCheckpoint(self.race_checkpoint);
                other.race_started = 1;
 
-               race_SendTime(other, self.race_checkpoint, other.race_movetime, !!other.race_laptime);
+               race_SendTime(other, self.race_checkpoint, other.race_movetime, boolean(other.race_laptime));
 
                if(!self.race_checkpoint) // start line
                {
 
                if(!self.race_checkpoint) // start line
                {
index f55402f0ecf54124cf39dbfa657bde045dec596e..4eec262ce8db4b5a87b2433fb3bb0f352611126d 100644 (file)
@@ -1478,13 +1478,13 @@ spawnfunc(target_items)
                }
 
                self.netname = "";
                }
 
                self.netname = "";
-               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
-               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
-               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * !!(self.items & ITEM_Strength.m_itemid), "strength");
-               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * !!(self.items & ITEM_Shield.m_itemid), "invincible");
-               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * !!(self.items & IT_SUPERWEAPON), "superweapons");
-               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & ITEM_Jetpack.m_itemid), "jetpack");
-               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
+               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
+               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
+               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * boolean(self.items & ITEM_Strength.m_itemid), "strength");
+               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * boolean(self.items & ITEM_Shield.m_itemid), "invincible");
+               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * boolean(self.items & IT_SUPERWEAPON), "superweapons");
+               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_Jetpack.m_itemid), "jetpack");
+               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
                if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
                if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
                if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");
                if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
                if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
                if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");