]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/hud_fixes
authorterencehill <piuntn@gmail.com>
Sun, 13 Mar 2016 15:18:28 +0000 (16:18 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 13 Mar 2016 15:18:28 +0000 (16:18 +0100)
Conflicts:
qcsrc/common/mutators/mutator/damagetext/damagetext.qc

76 files changed:
.gitlab-ci.yml
mutators.cfg
qcsrc/client/commands/cl_cmd.qc
qcsrc/client/commands/cl_cmd.qh
qcsrc/client/hud/panel/radar.qc
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/main.qc
qcsrc/client/scoreboard.qc
qcsrc/client/shownames.qc
qcsrc/client/view.qc
qcsrc/common/_all.inc
qcsrc/common/animdecide.qc
qcsrc/common/command/all.qh
qcsrc/common/command/generic.qc
qcsrc/common/command/generic.qh
qcsrc/common/debug.qh
qcsrc/common/effects/all.qc
qcsrc/common/effects/qc/damageeffects.qc
qcsrc/common/effects/qc/gibs.qc
qcsrc/common/effects/qc/globalsound.qc
qcsrc/common/effects/qc/globalsound.qh
qcsrc/common/ent_cs.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/impulses/all.qh
qcsrc/common/items/all.qc
qcsrc/common/items/all.qh
qcsrc/common/items/inventory.qh
qcsrc/common/mapinfo.qc
qcsrc/common/minigames/cl_minigames_hud.qc
qcsrc/common/minigames/minigames.qc
qcsrc/common/minigames/sv_minigames.qc
qcsrc/common/models/all.qh
qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/damagetext/damagetext.qc
qcsrc/common/mutators/mutator/multijump/multijump.qc
qcsrc/common/net_notice.qc
qcsrc/common/notifications/all.qc
qcsrc/common/notifications/all.qh
qcsrc/common/physics/movetypes/movetypes.qc
qcsrc/common/physics/movetypes/push.qc
qcsrc/common/playerstats.qc
qcsrc/common/sounds/all.qc
qcsrc/common/sounds/all.qh
qcsrc/common/state.qc [new file with mode: 0644]
qcsrc/common/state.qh
qcsrc/common/t_items.qc
qcsrc/common/triggers/target/changelevel.qc
qcsrc/common/triggers/target/music.qc
qcsrc/common/triggers/teleporters.qc
qcsrc/common/triggers/trigger/teleport.qc
qcsrc/common/turrets/config.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/config.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/lib/iter.qh
qcsrc/lib/log.qh
qcsrc/lib/net.qh
qcsrc/lib/registry.qh
qcsrc/lib/stats.qh
qcsrc/lib/vector.qh
qcsrc/lib/warpzone/common.qc
qcsrc/server/_all.qh
qcsrc/server/anticheat.qc
qcsrc/server/anticheat.qh
qcsrc/server/antilag.qc
qcsrc/server/cl_client.qc
qcsrc/server/mutators/mutator/gamemode_ca.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc
qcsrc/server/pathlib/_all.inc
qcsrc/server/pathlib/main.qc
qcsrc/server/pathlib/pathlib.qh
qcsrc/server/weapons/tracing.qc

index 973156efa7cf098d707869486d414e58b197a30c..d638b6e0081c663f1bae59f9fd2e08d341c6f016 100644 (file)
@@ -27,7 +27,7 @@ test_sv_game:
   script:
     - wget -O data/g-23.pk3 http://beta.xonotic.org/autobuild-bsp/latest/g-23.pk3
     - make
-    - EXPECT=e53fb00597ea9a38aa31230e4edfbd54
+    - EXPECT=44a15d27dcfb0bccddc73284e6d968e7
     - HASH=$(${ENGINE} -noconfig -nohome +exec serverbench.cfg
       | tee /dev/stderr
       | grep '^:'
index c6bbb4ef0c5b7aa05226c90b13680db9e3cf96ce..7e60304ccdda5588029cb08df125085b3e7d3ffc 100644 (file)
@@ -406,7 +406,7 @@ set g_breakablehook_owner 0 "allow owner to break their own hook"
 // ===========
 //  multijump
 // ===========
-seta cl_multijump 0 "allow multijump mutator"
+seta cl_multijump 1 "allow multijump mutator"
 set g_multijump 0      "Number of multiple jumps to allow (jumping again in the air), -1 allows for infinite jumps"
 set g_multijump_add 0  "0 = make the current z velocity equal to jumpvelocity, 1 = add jumpvelocity to the current z velocity"
 set g_multijump_speed -999999  "Minimum vertical speed a player must have in order to jump again"
index 873cef25893d66ac2c5feb726027189c8002d398..b512ba53abfd5515483b41f1a8e8df21aedd489e 100644 (file)
@@ -395,29 +395,6 @@ void LocalCommand_mv_download(int request, int argc)
        }
 }
 
-void LocalCommand_find(int request, int argc)
-{
-       switch (request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       FOREACH_ENTITY_CLASS(argv(1), true, LAMBDA(LOG_INFO(etos(it), "\n")));
-                       return;
-               }
-
-               default:
-               {
-                       LOG_INFO("Incorrect parameters for ^2find^7\n");
-               }
-               case CMD_REQUEST_USAGE:
-               {
-                       LOG_INFO("\nUsage:^3 cl_cmd find classname\n");
-                       LOG_INFO("  Where 'classname' is the classname to search for.\n");
-                       return;
-               }
-       }
-}
-
 void LocalCommand_sendcvar(int request, int argc)
 {
        switch (request)
@@ -490,38 +467,37 @@ CLIENT_COMMAND(debugmodel, "Spawn a debug model manually") { LocalCommand_debugm
 CLIENT_COMMAND(handlevote, "System to handle selecting a vote or option") { LocalCommand_handlevote(request, arguments); }
 CLIENT_COMMAND(hud, "Commands regarding/controlling the HUD system") { LocalCommand_hud(request, arguments); }
 CLIENT_COMMAND(localprint, "Create your own centerprint sent to yourself") { LocalCommand_localprint(request, arguments); }
-CLIENT_COMMAND(find, "Search through entities for matching classname") { LocalCommand_find(request, arguments); }
 CLIENT_COMMAND(mv_download, "Retrieve mapshot picture from the server") { LocalCommand_mv_download(request, arguments); }
 CLIENT_COMMAND(sendcvar, "Send a cvar to the server (like weaponpriority)") { LocalCommand_sendcvar(request, arguments); }
 
 void LocalCommand_macro_help()
 {
-       FOREACH(CLIENT_COMMANDS, true, LAMBDA(LOG_INFOF("  ^2%s^7: %s\n", it.m_name, it.m_description)));
+       FOREACH(CLIENT_COMMANDS, true, LOG_INFOF("  ^2%s^7: %s\n", it.m_name, it.m_description));
 }
 
 bool LocalCommand_macro_command(int argc, string command)
 {
        string c = strtolower(argv(0));
-       FOREACH(CLIENT_COMMANDS, it.m_name == c, LAMBDA(
+       FOREACH(CLIENT_COMMANDS, it.m_name == c, {
                it.m_invokecmd(CMD_REQUEST_COMMAND, NULL, argc, command);
                return true;
-       ));
+       });
        return false;
 }
 
 bool LocalCommand_macro_usage(int argc)
 {
        string c = strtolower(argv(1));
-       FOREACH(CLIENT_COMMANDS, it.m_name == c, LAMBDA(
+       FOREACH(CLIENT_COMMANDS, it.m_name == c, {
                it.m_invokecmd(CMD_REQUEST_USAGE, NULL, argc, "");
                return true;
-       ));
+       });
        return false;
 }
 
 void LocalCommand_macro_write_aliases(int fh)
 {
-       FOREACH(CLIENT_COMMANDS, true, LAMBDA(CMD_Write_Alias("qc_cmd_cl", it.m_name, it.m_description)));
+       FOREACH(CLIENT_COMMANDS, true, CMD_Write_Alias("qc_cmd_cl", it.m_name, it.m_description));
 }
 
 
index 23d72ff60e9020eab24806688f32e80c08d1d96e..d53d1b6a6e671ee0c752b0deb534c4ba309f7b7a 100644 (file)
@@ -21,7 +21,7 @@ REGISTRY_SORT(CLIENT_COMMANDS)
        METHOD(clientcommand_##id, m_invokecmd, void(int request, entity caller, int arguments, string command))
 
 STATIC_INIT(CLIENT_COMMANDS_aliases) {
-       FOREACH(CLIENT_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_cl"))));
+       FOREACH(CLIENT_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_cl")));
 }
 
 #endif
index 4e4f90126a43f7e1326dce264ae4efa303707afc..b4986e5e3e1376f867af2085c7ff70510e27eec7 100644 (file)
@@ -332,11 +332,9 @@ void HUD_Radar()
 
        draw_teamradar_background(hud_panel_radar_foreground_alpha);
 
-       FOREACH_ENTITY_CLASS("radarlink", true, LAMBDA(
-               draw_teamradar_link(it.origin, it.velocity, it.team);
-       ));
+       FOREACH_ENTITY_CLASS("radarlink", true, draw_teamradar_link(it.origin, it.velocity, it.team));
 
-       FOREACH_ENTITY_FLAGS(teamradar_icon, 0xFFFFFF, LAMBDA(
+       FOREACH_ENTITY_FLAGS(teamradar_icon, 0xFFFFFF, {
                if ( hud_panel_radar_mouse )
                if ( it.health > 0 )
                if ( it.team == myteam+1 || gametype == MAPINFO_TYPE_RACE )
@@ -353,13 +351,13 @@ void HUD_Radar()
                }
                entity icon = RadarIcons_from(it.teamradar_icon);
                draw_teamradar_icon(it.origin, icon, it, spritelookupcolor(it, icon.netname, it.teamradar_color), panel_fg_alpha);
-       ));
-       AL_EACH(_entcs, e, it != NULL, LAMBDA(
+       });
+       AL_EACH(_entcs, e, it != NULL, {
                if (!it.m_entcs_private) continue;
                if (entcs_is_self(it)) continue;
                color2 = entcs_GetTeam(it.sv_entnum);
                draw_teamradar_player(it.origin, it.angles, Team_ColorRGB(color2));
-       ));
+       });
        draw_teamradar_player(view_origin, view_angles, '1 1 1');
 
        drawresetcliparea();
index 19cfb551c6f35931babb9cb9f11bd61520977527..6e9f13dac10cada4c1b604fdf43821eab94a91a6 100644 (file)
@@ -76,7 +76,7 @@ void HUD_Weapons()
                weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
 
                weapon_cnt = 0;
-               FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, LAMBDA(weaponorder[weapon_cnt++] = it));
+               FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, weaponorder[weapon_cnt++] = it);
                for(i = weapon_cnt; i < Weapons_MAX; ++i)
                        weaponorder[i] = NULL;
                heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, NULL);
@@ -131,10 +131,10 @@ void HUD_Weapons()
                // get the all-weapons layout
                int nHidden = 0;
                WepSet weapons_stat = WepSet_GetFromStat();
-               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               FOREACH(Weapons, it != WEP_Null, {
                        if (weapons_stat & it.m_wepset) continue;
                        if (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
-               ));
+               });
                vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, padded_panel_size, aspect);
                columns = table_size.x;
                rows = table_size.y;
index c52b3cd569ab96e63fa6637625eb1cdec2f6a2c1..ded6d5b32a9f2d1d4321dbea3b8b37254533684b 100644 (file)
@@ -127,7 +127,7 @@ void CSQC_Init()
        registercvar("cl_jumpspeedcap_min", "");
        registercvar("cl_jumpspeedcap_max", "");
 
-       registercvar("cl_multijump", "0");
+       registercvar("cl_multijump", "1");
 
        registercvar("cl_spawn_near_teammate", "1");
 
@@ -332,7 +332,6 @@ void Playerchecker_Think()
        this.nextthink = time + 0.2;
 }
 
-void Porto_Init();
 void TrueAim_Init();
 void PostInit()
 {
@@ -340,7 +339,6 @@ void PostInit()
        playerchecker.think = Playerchecker_Think;
        playerchecker.nextthink = time + 0.2;
 
-       Porto_Init();
        TrueAim_Init();
 
        postinit = true;
@@ -834,13 +832,13 @@ void CSQC_Ent_Update(bool isnew)
 #endif
        this.enttype = t;
        bool done = false;
-       FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
+       FOREACH(LinkedEntities, it.m_id == t, {
                if (isnew) this.classname = it.netname;
                if (autocvar_developer_csqcentities)
             LOG_INFOF("CSQC_Ent_Update(%d) at %f with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", isnew, savetime, this, this.entnum, this.enttype, this.classname, t);
                done = it.m_read(this, NULL, isnew);
                break;
-       ));
+       });
        time = savetime;
        if (!done)
        {
@@ -924,11 +922,11 @@ bool CSQC_Parse_TempEntity()
        // Acquire TE ID
        int nTEID = ReadByte();
 
-       FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
+       FOREACH(TempEntities, it.m_id == nTEID, {
                if (autocvar_developer_csqcentities)
                        LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
                return it.m_read(NULL, NULL, true);
-       ));
+       });
 
        if (autocvar_developer_csqcentities)
                LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
index cd8df72f66cfa7f2699645d76a8f824f7aa80687..3204af9f0815de1c819f035c66f44859a1b6d145 100644 (file)
@@ -1001,13 +1001,13 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        WepSet weapons_inmap = WepSet_GetFromStat_InMap();
        float initial_posx = pos.x;
        int disownedcnt = 0;
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+       FOREACH(Weapons, it != WEP_Null, {
                int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
                WepSet set = it.m_wepset;
                if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
                        ++disownedcnt;
-       ));
+       });
 
        int weapon_cnt = (Weapons_COUNT - 1) - disownedcnt;
        if (weapon_cnt <= 0) return pos;
@@ -1061,7 +1061,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        vector tmpos = pos;
 
        int column = 0;
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+       FOREACH(Weapons, it != WEP_Null, {
                int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
                WepSet set = it.m_wepset;
@@ -1100,7 +1100,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                        pos.y += height;
                }
                ++column;
-       ));
+       });
 
        if (weapons_with_stats)
                average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
index 7ed13b3e9f105435d53d704e7351e80a6e718bb3..fc36c47274d6ebeefbd7a23d1aef31036ac289f1 100644 (file)
@@ -53,7 +53,7 @@ void Draw_ShowNames(entity this)
        if (autocvar_hud_shownames_antioverlap)
        {
                // fade tag out if another tag that is closer to you overlaps
-               LL_EACH(shownames_ent, it != this && entcs_receiver(i), LAMBDA(
+               LL_EACH(shownames_ent, it != this && entcs_receiver(i), {
                        vector eo = project_3d_to_2d(it.origin);
                        if (eo.z < 0 || eo.x < 0 || eo.y < 0 || eo.x > vid_conwidth || eo.y > vid_conheight) continue;
                        eo.z = 0;
@@ -63,7 +63,7 @@ void Draw_ShowNames(entity this)
                                overlap = true;
                                break;
                        }
-               ));
+               });
        }
        bool onscreen = (o.z >= 0 && o.x >= 0 && o.y >= 0 && o.x <= vid_conwidth && o.y <= vid_conheight);
        if (autocvar_hud_shownames_crosshairdistance)
@@ -167,7 +167,7 @@ void Draw_ShowNames(entity this)
 void Draw_ShowNames_All()
 {
        if (!autocvar_hud_shownames) return;
-       LL_EACH(shownames_ent, true, LAMBDA(
+       LL_EACH(shownames_ent, true, {
                entity entcs = entcs_receiver(i);
                if (!entcs)
                {
@@ -194,5 +194,5 @@ void Draw_ShowNames_All()
                if (!it.csqcmodel_isdead) setorigin(it, entcs.origin);
                it.csqcmodel_isdead = dead;
                Draw_ShowNames(it);
-       ));
+       });
 }
index b374403db6c21327d81a277144f0105a82d74ca5..70a4f2eeb1d579a0f894998cb4b999a902c5b5e2 100644 (file)
@@ -340,90 +340,75 @@ STATIC_INIT(viewmodel) {
     viewmodel = new(viewmodel);
 }
 
-entity porto;
-vector polyline[16];
-void Porto_Draw(entity this)
+void Porto_Draw(entity this);
+STATIC_INIT(Porto)
 {
-       vector p, dir, ang, q, nextdir;
-       float portal_number, portal1_idx;
-
-       if(activeweapon != WEP_PORTO || spectatee_status || gametype == MAPINFO_TYPE_NEXBALL)
-               return;
-       if(WEP_CVAR(porto, secondary))
-               return;
-       if(intermission == 1)
-               return;
-       if(intermission == 2)
-               return;
-       if (STAT(HEALTH) <= 0)
-               return;
+       entity e = new_pure(porto);
+       e.draw = Porto_Draw;
+       e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
+}
 
-       dir = view_forward;
+const int polyline_length = 16;
+vector polyline[polyline_length];
+void Porto_Draw(entity this)
+{
+       if (activeweapon != WEP_PORTO) return;
+       if (spectatee_status) return;
+       if (WEP_CVAR(porto, secondary)) return;
+       if (intermission == 1) return;
+       if (intermission == 2) return;
+       if (STAT(HEALTH) <= 0) return;
 
-       if(angles_held_status)
+       vector pos = view_origin;
+       vector dir = view_forward;
+       if (angles_held_status)
        {
                makevectors(angles_held);
                dir = v_forward;
        }
 
-       p = view_origin;
-
-       polyline[0] = p;
-       int idx = 1;
-       portal_number = 0;
-       nextdir = dir;
+       polyline[0] = pos;
 
-       for (;;)
+       int portal_number = 0, portal1_idx = 1, portal_max = 2;
+       int n = 1 + 2;  // 2 lines == 3 points
+       for (int idx = 0; idx < n && idx < polyline_length - 1; )
        {
-               dir = nextdir;
-               traceline(p, p + 65536 * dir, true, porto);
-               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
-                       return;
-               nextdir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
-               p = trace_endpos;
-               polyline[idx] = p;
-               ++idx;
-               if(idx >= 16)
-                       return;
-               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
-                       continue;
-               ++portal_number;
-               ang = vectoangles2(trace_plane_normal, dir);
-               ang.x = -ang.x;
-               makevectors(ang);
-               if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
-                       return;
-               if(portal_number == 1)
+               traceline(pos, pos + 65536 * dir, true, this);
+               dir = reflect(dir, trace_plane_normal);
+               pos = trace_endpos;
+               polyline[++idx] = pos;
+               if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
                {
-                       portal1_idx = idx;
-                       if(portal_number >= 2)
-                               break;
+                       n += 1;
+                       continue;
                }
-       }
-
-       while(idx >= 2)
-       {
-               p = polyline[idx-2];
-               q = polyline[idx-1];
-               if(idx == 2)
-                       p = p - view_up * 16;
-               if(idx-1 >= portal1_idx)
+               if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
                {
-                       Draw_CylindricLine(p, q, 4, "", 1, 0, '0 0 1', 0.5, DRAWFLAG_NORMAL, view_origin);
+                       n = max(2, idx);
+                       break;
                }
-               else
+               // check size
                {
-                       Draw_CylindricLine(p, q, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL, view_origin);
+                       vector ang = vectoangles2(trace_plane_normal, dir);
+                       ang.x = -ang.x;
+                       makevectors(ang);
+                       if (!CheckWireframeBox(this, pos - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
+                       {
+                               n = max(2, idx);
+                               break;
+                       }
                }
-               --idx;
+               portal_number += 1;
+               if (portal_number >= portal_max) break;
+               if (portal_number == 1) portal1_idx = idx;
+       }
+       for (int idx = 0; idx < n - 1; ++idx)
+       {
+               vector p = polyline[idx], q = polyline[idx + 1];
+               if (idx == 0) p -= view_up * 16;  // line from player
+               vector rgb = (idx < portal1_idx) ? '1 0 0' : '0 0 1';
+               Draw_CylindricLine(p, q, 4, "", 1, 0, rgb, 0.5, DRAWFLAG_NORMAL, view_origin);
        }
-}
-
-void Porto_Init()
-{
-       porto = new_pure(porto);
-       porto.draw = Porto_Draw;
-       porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
 }
 
 float drawtime;
@@ -1414,7 +1399,7 @@ void CSQC_UpdateView(float w, float h)
        if(myteam != prev_myteam)
        {
                myteamcolors = colormapPaletteColor(myteam, 1);
-               FOREACH(hud_panels, true, LAMBDA(it.update_time = time));
+               FOREACH(hud_panels, true, it.update_time = time);
                prev_myteam = myteam;
        }
 
@@ -1460,10 +1445,10 @@ void CSQC_UpdateView(float w, float h)
 
                if(ons_roundlost)
                {
-                       FOREACH_ENTITY_CLASS("onslaught_generator", it.health <= 0, LAMBDA(
+                       FOREACH_ENTITY_CLASS("onslaught_generator", it.health <= 0, {
                                gen = it;
                                break;
-                       ));
+                       });
                        if(!gen)
                                ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
                }
@@ -1829,7 +1814,7 @@ void CSQC_UpdateView(float w, float h)
           mousepos = mousepos*0.5 + getmousepos();
         */
 
-       FOREACH_ENTITY(it.draw, LAMBDA(it.draw(it)));
+       FOREACH_ENTITY(it.draw, it.draw(it));
 
        addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
        renderscene();
@@ -2159,7 +2144,7 @@ void CSQC_UpdateView(float w, float h)
          } else */
 
        // draw 2D entities
-       FOREACH_ENTITY(it.draw2d, LAMBDA(it.draw2d(it)));
+       FOREACH_ENTITY(it.draw2d, it.draw2d(it));
        Draw_ShowNames_All();
        Debug_Draw();
 
index 5ebc52886b59be0e064c117e47cb87ada90c941d..78d2373e2d59e508b7a0d7a175f2a3d976ff027e 100644 (file)
@@ -7,6 +7,9 @@
 
 #include "mapinfo.qc"
 #include "playerstats.qc"
+#ifdef SVQC
+    #include "state.qc"
+#endif
 #include "util.qc"
 
 #ifndef CSQC
index 76921d662db3d9e3c7407a757efe417455945fbc..f5adbe7b77ff655f5d930137a0c3b430bca5924c 100644 (file)
 bool monsters_animoverride(entity this)
 {
        Monster monster_id = NULL;
-       FOREACH(Monsters, it != MON_Null, LAMBDA(
-               if(it.model == this.model)
-               {
-                       monster_id = it;
-                       break;
-               }
-       ));
+       FOREACH(Monsters, it != MON_Null && it.model == this.model, {
+        monster_id = it;
+        break;
+       });
 
        if(!monster_id) { return false; }
 
index efe9f72684f8a554d65eab872dadea820bb1c16d..9bbce5e14a67d6d57474de504b1b696d1c9281f5 100644 (file)
@@ -16,7 +16,7 @@ REGISTRY_SORT(GENERIC_COMMANDS)
        METHOD(genericcommand_##id, m_invokecmd, void(int request, entity caller, int arguments, string command))
 
 STATIC_INIT(GENERIC_COMMANDS_aliases) {
-       FOREACH(GENERIC_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svmenu"))));
+       FOREACH(GENERIC_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svmenu")));
 }
 
 #include "generic.qh"
index a720796ce13821968cbab0722e5ca1d9b141fea5..50cc49076d56b438c5d0d0e5f5df2eda6dd550a1 100644 (file)
 //  Last updated: February 19th, 2012
 // =========================================================
 
-// used by generic commands for better help/usage information
-string GetProgramCommandPrefix()
-{
-       #ifdef SVQC
-       return "sv_cmd";
-       #endif
-       #ifdef CSQC
-       return "cl_cmd";
-       #endif
-       #ifdef MENUQC
-       return "menu_cmd";
-       #endif
-}
 
 // used by curl command
 void Curl_URI_Get_Callback(int id, float status, string data)
@@ -550,32 +537,32 @@ GENERIC_COMMAND(runtest, "Run unit tests") { GenericCommand_runtest(request, arg
 
 void GenericCommand_macro_help()
 {
-       FOREACH(GENERIC_COMMANDS, true, LAMBDA(LOG_INFOF("  ^2%s^7: %s\n", it.m_name, it.m_description)));
+       FOREACH(GENERIC_COMMANDS, true, LOG_INFOF("  ^2%s^7: %s\n", it.m_name, it.m_description));
 }
 
 float GenericCommand_macro_command(float argc, string command)
 {
        string c = strtolower(argv(0));
-       FOREACH(GENERIC_COMMANDS, it.m_name == c, LAMBDA(
+       FOREACH(GENERIC_COMMANDS, it.m_name == c, {
                it.m_invokecmd(CMD_REQUEST_COMMAND, NULL, argc, command);
                return true;
-       ));
+       });
        return false;
 }
 
 float GenericCommand_macro_usage(float argc)
 {
        string c = strtolower(argv(1));
-       FOREACH(GENERIC_COMMANDS, it.m_name == c, LAMBDA(
+       FOREACH(GENERIC_COMMANDS, it.m_name == c, {
                it.m_invokecmd(CMD_REQUEST_USAGE, NULL, argc, "");
                return true;
-       ));
+       });
        return false;
 }
 
 void GenericCommand_macro_write_aliases(float fh)
 {
-       FOREACH(GENERIC_COMMANDS, true, LAMBDA(CMD_Write_Alias("qc_cmd_svmenu", it.m_name, it.m_description)));
+       FOREACH(GENERIC_COMMANDS, true, CMD_Write_Alias("qc_cmd_svmenu", it.m_name, it.m_description));
 }
 
 
index be84c407ca193c3e4316f16d68e7950f4548b082..63e1dce83b9bfbabbf3b0a4aa0a779b622c6dd98 100644 (file)
@@ -22,7 +22,13 @@ void GenericCommand_macro_write_aliases(float fh);
 float GenericCommand(string command);
 
 // Returns command prefix specific for whatever program it is compiled in
-string GetProgramCommandPrefix();
+#ifdef SVQC
+       #define GetProgramCommandPrefix() "sv_cmd"
+#elif defined(CSQC)
+       #define GetProgramCommandPrefix() "cl_cmd"
+#elif defined(MENUQC)
+       #define GetProgramCommandPrefix() "menu_cmd"
+#endif
 
 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
 #define CMD_Write(s) fputs(fh, s)
index 2dab5a9f51337fbf6d0061cdb45a64b8a1cb3974..113019a7c7d125bf69a03b215e67739438220b3a 100644 (file)
@@ -6,12 +6,6 @@
 REGISTER_NET_TEMP(net_debug)
 #endif
 
-#ifdef SVQC
-
-#include <server/command/all.qh>
-
-#endif
-
 #ifdef CSQC
        NET_HANDLE(net_debug, bool isNew)
        {
@@ -72,87 +66,85 @@ bool autocvar_debugdraw;
                static int debugdraw_frame;
                ++debugdraw_frame;
                const int sz = 8;
-               FOREACH_ENTITY(true, LAMBDA(
+               FOREACH_ENTITY(true, {
                        if (it.debugdraw_last == debugdraw_frame) continue;
                        int ofs = 0;
-                       for (entity e = findradius(it.origin, 100); e; e = e.chain)
-                       {
-                               if (e.debugdraw_last == debugdraw_frame) continue;
-                               e.debugdraw_last = debugdraw_frame;
-                               vector rgb = (e.debug) ? '0 0 1' : '1 0 0';
-                               if (autocvar_debugdraw_filterout != "" && strhasword(autocvar_debugdraw_filterout, e.classname)) continue;
-                               if (autocvar_debugdraw_filter != "" && !strhasword(autocvar_debugdraw_filter, e.classname)) continue;
+                       FOREACH_ENTITY_RADIUS(it.origin, 100, it.debugdraw_last != debugdraw_frame, {
+                               it.debugdraw_last = debugdraw_frame;
+                               vector rgb = (it.debug) ? '0 0 1' : '1 0 0';
+                               if (autocvar_debugdraw_filterout != "" && strhasword(autocvar_debugdraw_filterout, it.classname)) continue;
+                               if (autocvar_debugdraw_filter != "" && !strhasword(autocvar_debugdraw_filter, it.classname)) continue;
                                if (autocvar_debugdraw == 3)
                                {
-                                       if (!e.entnum) continue;
+                                       if (!it.entnum) continue;
                                }
                                if (autocvar_debugdraw == 4)
                                {
-                                       if (e.origin) continue;
+                                       if (it.origin) continue;
                                }
                                if (autocvar_debugdraw == 5)
                                {
-                                       if (!e.debug) continue;
+                                       if (!it.debug) continue;
                                }
                                else if (autocvar_debugdraw > 5)
                                {
                                        bool flag = true;
                                        do {
-//                                             if (e.modelindex) break;
-//                                             if (e.absmin) break;
-//                                             if (e.absmax) break;
-//                                             if (e.entnum) break;
-//                                             if (e.drawmask) break;
-//                                             if (e.predraw) break;
-//                                             if (e.movetype) break;
-                                               if (e.solid) break;
-//                                             if (e.origin) break;
-//                                             if (e.oldorigin) break;
-//                                             if (e.velocity) break;
-//                                             if (e.angles) break;
-//                                             if (e.avelocity) break;
-//                                             if (e.classname) break;
-//                                             if (e.model) break;
-//                                             if (e.frame) break;
-//                                             if (e.skin) break;
-//                                             if (e.effects) break;
-//                                             if (e.mins) break;
-//                                             if (e.maxs) break;
-//                                             if (e.size) break;
-//                                             if (e.touch) break;
-//                                             if (e.use) break;
-//                                             if (e.think) break;
-//                                             if (e.blocked) break;
-//                                             if (e.nextthink) break;
-//                                             if (e.chain) break;
-//                                             if (e.netname) break;
-//                                             if (e.enemy) break;
-//                                             if (e.flags) break;
-//                                             if (e.colormap) break;
-//                                             if (e.owner) break;
+//                                             if (it.modelindex) break;
+//                                             if (it.absmin) break;
+//                                             if (it.absmax) break;
+//                                             if (it.entnum) break;
+//                                             if (it.drawmask) break;
+//                                             if (it.predraw) break;
+//                                             if (it.movetype) break;
+                                               if (it.solid) break;
+//                                             if (it.origin) break;
+//                                             if (it.oldorigin) break;
+//                                             if (it.velocity) break;
+//                                             if (it.angles) break;
+//                                             if (it.avelocity) break;
+//                                             if (it.classname) break;
+//                                             if (it.model) break;
+//                                             if (it.frame) break;
+//                                             if (it.skin) break;
+//                                             if (it.effects) break;
+//                                             if (it.mins) break;
+//                                             if (it.maxs) break;
+//                                             if (it.size) break;
+//                                             if (it.touch) break;
+//                                             if (it.use) break;
+//                                             if (it.think) break;
+//                                             if (it.blocked) break;
+//                                             if (it.nextthink) break;
+//                                             if (it.chain) break;
+//                                             if (it.netname) break;
+//                                             if (it.enemy) break;
+//                                             if (it.flags) break;
+//                                             if (it.colormap) break;
+//                                             if (it.owner) break;
                                                flag = false;
                                        } while (0);
                                        if (!flag) continue;
                                }
-                               else if (is_pure(e))
+                               else if (is_pure(it))
                                {
                                        if (autocvar_debugdraw < 2) continue;
                                        rgb.y = 1;
                                }
-                               vector o = e.origin;
-                               if (e.tag_entity)
-                                       o += e.tag_entity.origin;
+                               vector o = it.origin;
+                               if (it.tag_entity)
+                                       o += it.tag_entity.origin;
                                vector pos = project_3d_to_2d(o);
                                if (pos.z < 0) continue;
                                pos.z = 0;
                                pos.y += ofs * sz;
                                drawcolorcodedstring2(pos,
-                                       sprintf("%d: '%s'@%s", (e.debug ? e.sv_entnum : etof(e)),
-                                       e.classname, e.sourceLoc),
+                                       sprintf("%d: '%s'@%s", (it.debug ? it.sv_entnum : etof(it)),
+                                       it.classname, it.sourceLoc),
                                        sz * '1 1 0', rgb, 0.5, DRAWFLAG_NORMAL);
                                ++ofs;
-                       }
-               ));
+            });
+               });
        }
 #endif
 
@@ -282,37 +274,37 @@ STATIC_INIT(TRACE_ENT)
 }
 #endif
 
-#ifdef SVQC
-SERVER_COMMAND(find, "Search through entities for matching classname")
+GENERIC_COMMAND(find, "Search through entities for matching classname")
 {
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       for (entity client = NULL; (client = find(client, classname, argv(1))); )
-                               LOG_INFO(etos(client), "\n");
+                       FOREACH_ENTITY_CLASS_ORDERED(argv(1), true, LOG_INFOF("%i (%s)\n", it, it.classname));
                        return;
                }
 
                default:
+               {
                        LOG_INFO("Incorrect parameters for ^2find^7\n");
+        }
                case CMD_REQUEST_USAGE:
                {
-                       LOG_INFO("\nUsage:^3 sv_cmd find classname\n");
+                       LOG_INFO("\nUsage:^3 " GetProgramCommandPrefix() " find classname\n");
                        LOG_INFO("  Where 'classname' is the classname to search for.\n");
                        return;
                }
        }
 }
 
-SERVER_COMMAND(findat, "Search through entities for matching origin")
+GENERIC_COMMAND(findat, "Search through entities for matching origin")
 {
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                    vector match = stov(argv(1));
-                   FOREACH_ENTITY_ORDERED(it.origin == match, LAMBDA(LOG_INFOF("%i\n", it)));
+                   FOREACH_ENTITY_ORDERED(it.origin == match, LOG_INFOF("%i (%s)\n", it, it.classname));
                        return;
                }
 
@@ -320,9 +312,8 @@ SERVER_COMMAND(findat, "Search through entities for matching origin")
                        LOG_INFO("Incorrect parameters for ^2findat^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       LOG_INFO("\nUsage:^3 sv_cmd findat \"0 0 0\"\n");
+                       LOG_INFO("\nUsage:^3 " GetProgramCommandPrefix() " findat \"0 0 0\"\n");
                        return;
                }
        }
 }
-#endif
index a07228fbdbbf70dbed0a92a7c88d4d6828ae288e..73f1fe65fb4f150da0a5d4108e101535339e9a4c 100644 (file)
@@ -75,17 +75,17 @@ void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
        net_eff.eent_net_count = eff_cnt;
        net_eff.eent_eff_trail = eff.eent_eff_trail;
 
-       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(Net_Write_Effect(net_eff, it, 0)));
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), Net_Write_Effect(net_eff, it, 0));
        remove(net_eff);
 }
 
 void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)
 {
        // problem with this is, we might not have all the available effects for it
-       FOREACH(Effects, it.eent_eff_name == eff_name, LAMBDA(
+       FOREACH(Effects, it.eent_eff_name == eff_name, {
                Send_Effect(it, eff_loc, eff_vel, eff_cnt);
                return;
-       ));
+       });
        // revert to engine handling
        __pointparticles(_particleeffectnum(eff_name), eff_loc, eff_vel, eff_cnt);
 }
index 06f8ea464eaaa8cf6cf878ce14985e63efa9a283..ba60e51bd10cf3c483a24a3c818f52d2ab3ed476 100644 (file)
@@ -223,15 +223,10 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew)
        else
                forcemul = 1;
 
-       for(entity e = findradius(w_org, rad + MAX_DAMAGEEXTRARADIUS); e; e = e.chain)
-       {
-               setself(e);
-               // attached ents suck
-               if(self.tag_entity)
-                       continue;
-
+    FOREACH_ENTITY_RADIUS(w_org, rad + MAX_DAMAGEEXTRARADIUS, !it.tag_entity, {
+               setself(it);
                vector nearest = NearestPointOnBox(self, w_org);
-               if(rad)
+               if (rad)
                {
                        thisdmg = ((vlen (nearest - w_org) - bound(MIN_DAMAGEEXTRARADIUS, self.damageextraradius, MAX_DAMAGEEXTRARADIUS)) / rad);
                        if(thisdmg >= 1)
@@ -275,7 +270,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew)
 
                if(self.isplayermodel)
                        hitplayer = true; // this impact damaged a player
-       }
+       });
        setself(this);
 
        if(DEATH_ISVEHICLE(w_deathtype))
index 3d0da1b35bfe68ea18382052e68a71c8d6cea3c1..aec66403575257b34cc6782e73974bb03bd0099b 100644 (file)
@@ -43,7 +43,7 @@ void Violence_GibSplash_At(vector org, vector dir, float type, float amount, ent
 
        e.oldorigin_x = compressShortVector(e.velocity);
 
-       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(Violence_GibSplash_SendEntity(e, it, 0)));
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), Violence_GibSplash_SendEntity(e, it, 0));
        remove(e);
 }
 
index f13b231042d41fccbd9d265611e6ca04182b38b6..ae1ec74853fdecf3d2224ffbbf025ef2169eed44 100644 (file)
 
        entity GetVoiceMessage(string type)
        {
-               FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == true, LAMBDA(return it));
+               FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == true, return it);
                return NULL;
        }
 
        entity GetPlayerSound(string type)
        {
-               FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == false, LAMBDA(return it));
+               FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == false, return it);
                return NULL;
        }
 
        string allvoicesamples;
        STATIC_INIT(allvoicesamples)
        {
-               FOREACH(PlayerSounds, it.instanceOfVoiceMessage, LAMBDA(
-                       allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr)
-                                                                          ));
+               FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
                allvoicesamples = strzone(substring(allvoicesamples, 1, -1));
        }
 
                                        if (fake) { msg_entity = this; X(); }
                                        else
                                        {
-                                               FOREACH_CLIENT(IS_REAL_CLIENT(it) && (!teamplay || msg_entity.team == this.team), LAMBDA(
+                                               FOREACH_CLIENT(IS_REAL_CLIENT(it) && (!teamplay || msg_entity.team == this.team), {
                                                        msg_entity = it;
                                                        X();
-                                               ));
+                                               });
                                        }
                #undef X
                                        break;
                                        }
                                        else
                                        {
-                                               FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+                                               FOREACH_CLIENT(IS_REAL_CLIENT(it), {
                                                        msg_entity = it;
                                                        X();
-                                               ));
+                                               });
                                        }
                #undef X
                                        break;
index 7cb8fdb3e7484fd59f9a02c18738d0f001dd3e12..64ef524ec3d8e71db319ba7f23cbf46d1196cd65 100644 (file)
@@ -19,7 +19,7 @@ REGISTER_REGISTRY(PlayerSounds)
 REGISTRY_SORT(PlayerSounds)
 STATIC_INIT(PlayerSounds_renumber)
 {
-       FOREACH(PlayerSounds, true, LAMBDA(it.m_id = i));
+       FOREACH(PlayerSounds, true, it.m_id = i);
 }
 REGISTRY_CHECK(PlayerSounds)
 
@@ -90,13 +90,13 @@ REGISTER_REGISTRY(GlobalSounds)
 REGISTRY_SORT(GlobalSounds)
 STATIC_INIT(GlobalSounds_renumber)
 {
-       FOREACH(GlobalSounds, true, LAMBDA(it.m_id = i));
+       FOREACH(GlobalSounds, true, it.m_id = i);
 }
 REGISTRY_CHECK(GlobalSounds)
 void PrecacheGlobalSound(string samplestring);
 PRECACHE(GlobalSounds)
 {
-       FOREACH(GlobalSounds, true, LAMBDA(PrecacheGlobalSound(it.m_globalsoundstr)));
+       FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
 }
 
 REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
index 165d94b8966abdda47ea7d0cce707ea6cd371ddf..148d3883f031d436fb9acfff64fca5d496c75496 100644 (file)
                e.nextthink = time;
                Net_LinkEntity(e, false, 0, entcs_send);
                if (!IS_REAL_CLIENT(player)) return;
-               FOREACH_CLIENT(true, LAMBDA(
+               FOREACH_CLIENT(true, {
                        assert(it.entcs);
                        _entcs_send(it.entcs, msg_entity = player, BITS(23), MSG_ONE);
-               ));
+               });
        }
 
        void entcs_detach(entity player)
index 2ce3cf582f33d8a60c62bc61fff023728457b267..0b030b251c8ba648fcb53d7e0fbbe4639b7dcd06 100644 (file)
@@ -571,7 +571,7 @@ void ons_ControlPoint_Icon_Think()
                int _enemy_count = 0;
                int _friendly_count = 0;
 
-               FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), LAMBDA(
+               FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
                        if(vdist(it.origin - self.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
                        {
                                if(SAME_TEAM(it, self))
@@ -579,7 +579,7 @@ void ons_ControlPoint_Icon_Think()
                                else
                                        ++_enemy_count;
                        }
-               ));
+               });
 
                _friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
                _enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
@@ -976,7 +976,7 @@ void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float d
                if (time > this.pain_finished)
                {
                        this.pain_finished = time + 10;
-                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && SAME_TEAM(it, this), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK)));
+                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && SAME_TEAM(it, this), Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK));
                        play2team(this.team, SND(ONS_GENERATOR_UNDERATTACK));
                }
        }
@@ -1043,7 +1043,7 @@ void ons_GeneratorThink()
                if(!self.isshielded && self.wait < time)
                {
                        self.wait = time + 5;
-                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
                                if(SAME_TEAM(it, self))
                                {
                                        Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
@@ -1051,7 +1051,7 @@ void ons_GeneratorThink()
                                }
                                else
                                        Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(self.team, CENTER_ONS_NOTSHIELDED));
-                       ));
+                       });
                }
        }
 }
@@ -1270,12 +1270,12 @@ bool Onslaught_CheckWinner()
 
        round_handler_Init(7, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
 
-       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+       FOREACH_CLIENT(IS_PLAYER(it), {
                it.ons_roundlost = true;
                it.player_blocked = true;
 
                nades_Clear(it);
-       ));
+       });
 
        return 1;
 }
@@ -1288,7 +1288,7 @@ bool Onslaught_CheckPlayers()
 void Onslaught_RoundStart()
 {
        entity tmp_entity;
-       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.player_blocked = false));
+       FOREACH_CLIENT(IS_PLAYER(it), it.player_blocked = false);
 
        for(tmp_entity = ons_worldcplist; tmp_entity; tmp_entity = tmp_entity.ons_worldcpnext)
                tmp_entity.sprite.SendFlags |= 16;
@@ -1316,11 +1316,11 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s
 
        // Needs weapons?
        c = 0;
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+       FOREACH(Weapons, it != WEP_Null, {
                if(self.weapons & (it.m_wepset))
                if(++c >= 4)
                        break;
-       ));
+       });
 
        if(c<4)
                needweapons = true;
@@ -1397,12 +1397,12 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
 
                // Count team mates interested in this control point
                // (easier and cleaner than keeping counters per cp and teams)
-               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+               FOREACH_CLIENT(IS_PLAYER(it), {
                        if(SAME_TEAM(it, self))
                        if(it.havocbot_role_flags & HAVOCBOT_ONS_ROLE_OFFENSE)
                        if(it.havocbot_ons_target == cp2)
                                ++c;
-               ));
+               });
 
                // NOTE: probably decrease the cost of attackable control points
                cp2.wpcost = c;
@@ -1772,11 +1772,11 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe
 
 MUTATOR_HOOKFUNCTION(ons, reset_map_global)
 {SELFPARAM();
-       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+       FOREACH_CLIENT(IS_PLAYER(it), {
                it.ons_roundlost = false;
                it.ons_deathloc = '0 0 0';
                WITH(entity, self, it, PutClientInServer());
-       ));
+       });
        return false;
 }
 
index 433f2318dc4b170c390357fac0328d4a2a5960be..6780ac16d0fa1ddd83c766319d05f2d9289b2c01 100644 (file)
@@ -6,7 +6,7 @@ REGISTER_REGISTRY(IMPULSES)
 REGISTRY_SORT(IMPULSES)
 STATIC_INIT(IMPULSES_renumber)
 {
-       FOREACH(IMPULSES, true, LAMBDA(it.m_id = i));
+       FOREACH(IMPULSES, true, it.m_id = i);
 }
 REGISTRY_CHECK(IMPULSES)
 
index 927b2ece26c1ed5282d9dda604c765a1aac0c281..62dc0fe270be2d48efaf5ab54b3547aa41ed9665 100644 (file)
@@ -6,9 +6,7 @@
 
 void Dump_Items()
 {
-    FOREACH(Items, true, LAMBDA(
-        ITEM_HANDLE(Show, it);
-    ));
+    FOREACH(Items, true, ITEM_HANDLE(Show, it));
 }
 
 string Item_Model(string item_mdl)
index 1bd22f660e52264f488a53390d015045dff5d7cd..eea1de9a4a7e3b1ce75694eafdbdcb9bd274b1ba 100644 (file)
@@ -13,7 +13,7 @@ REGISTER_REGISTRY(Items)
 
 REGISTRY_SORT(Items)
 REGISTRY_CHECK(Items)
-STATIC_INIT(Items) { FOREACH(Items, true, LAMBDA(it.m_id = i)); }
+STATIC_INIT(Items) { FOREACH(Items, true, it.m_id = i); }
 
 void Dump_Items();
 
index 8f2f05fd1b39a14c7ae277000ddf2b4d4f69982b..7780a0054551c59d50150da9d0e6a5c8c90122be 100644 (file)
@@ -18,12 +18,12 @@ NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
 {
     make_pure(this);
     const int bits = ReadInt24_t();
-    FOREACH(Items, bits & BIT(it.m_id), LAMBDA(
+    FOREACH(Items, bits & BIT(it.m_id), {
         .int fld = inv_items[it.m_id];
         int prev = this.(fld);
         int next = this.(fld) = ReadByte();
         LOG_TRACEF("%s: %.0f -> %.0f\n", it.m_name, prev, next);
-    ));
+    });
     return true;
 }
 #endif
@@ -32,14 +32,14 @@ NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
 void Inventory_Write(Inventory data)
 {
     int bits = 0;
-    FOREACH(Items, true, LAMBDA(
+    FOREACH(Items, true, {
         .int fld = inv_items[it.m_id];
         bits = BITSET(bits, BIT(it.m_id), data.inventory.(fld) != (data.inventory.(fld) = data.(fld)));
-    ));
+    });
     WriteInt24_t(MSG_ENTITY, bits);
-    FOREACH(Items, bits & BIT(it.m_id), LAMBDA(
+    FOREACH(Items, bits & BIT(it.m_id), {
         WriteByte(MSG_ENTITY, data.inv_items[it.m_id]);
-    ));
+    });
 }
 #endif
 
index d853eeac3cc2fe690d164226c8757c096f61f280..447e7730e205c9d2ecbff65f102886c41bca8118 100644 (file)
@@ -597,13 +597,13 @@ void _MapInfo_Map_ApplyGametype(string s, int pWantedType, int pThisType, int lo
 
 string _MapInfo_GetDefaultEx(float t)
 {
-       FOREACH(Gametypes, it.items == t, LAMBDA(return it.model2));
+       FOREACH(Gametypes, it.items == t, return it.model2);
        return "";
 }
 
 float _MapInfo_GetTeamPlayBool(float t)
 {
-       FOREACH(Gametypes, it.items == t, LAMBDA(return it.team));
+       FOREACH(Gametypes, it.items == t, return it.team);
        return false;
 }
 
@@ -618,7 +618,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, int pWantedType, int pThisType)
        cvar_set("timelimit", cvar_defstring("timelimit"));
        cvar_set("leadlimit", cvar_defstring("leadlimit"));
        cvar_set("fraglimit", cvar_defstring("fraglimit"));
-       FOREACH(Gametypes, true, LAMBDA(it.m_parse_mapinfo(string_null, string_null)));
+       FOREACH(Gametypes, true, it.m_parse_mapinfo(string_null, string_null));
 
        string fraglimit_normal = string_null;
        string fraglimit_teams = string_null;
@@ -666,7 +666,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, int pWantedType, int pThisType)
                            break;
                        }
                }
-               FOREACH(Gametypes, true, LAMBDA(handled |= it.m_parse_mapinfo(k, v)));
+               FOREACH(Gametypes, true, handled |= it.m_parse_mapinfo(k, v));
                if (!handled)
             LOG_MAPWARNF("Invalid gametype setting in mapinfo for gametype %s: %s\n", MapInfo_Type_ToString(pWantedType), sa);
        }
@@ -685,7 +685,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, int pWantedType, int pThisType)
 
 Gametype MapInfo_Type(int t)
 {
-       FOREACH(Gametypes, it.items == t, LAMBDA(return it));
+       FOREACH(Gametypes, it.items == t, return it);
        return NULL;
 }
 
@@ -705,14 +705,14 @@ int MapInfo_Type_FromString(string t)
        deprecate(assault, as);
        deprecate(race, rc);
        if (t == "all") return MAPINFO_TYPE_ALL;
-       FOREACH(Gametypes, it.mdl == t, LAMBDA(return it.items));
+       FOREACH(Gametypes, it.mdl == t, return it.items);
        return 0;
 #undef deprecate
 }
 
 string MapInfo_Type_Description(float t)
 {
-       FOREACH(Gametypes, it.items == t, LAMBDA(return it.gametype_description));
+       FOREACH(Gametypes, it.items == t, return it.gametype_description);
        return "";
 }
 
@@ -720,13 +720,13 @@ string MapInfo_Type_ToString(float t)
 {
        if(t == MAPINFO_TYPE_ALL)
                return "all";
-       FOREACH(Gametypes, it.items == t, LAMBDA(return it.mdl));
+       FOREACH(Gametypes, it.items == t, return it.mdl);
        return "";
 }
 
 string MapInfo_Type_ToText(float t)
 {
-       FOREACH(Gametypes, it.items == t, LAMBDA(return it.message));
+       FOREACH(Gametypes, it.items == t, return it.message);
        /* xgettext:no-c-format */
        return _("@!#%'n Tuba Throwing");
 }
@@ -1236,7 +1236,7 @@ int MapInfo_CurrentFeatures()
 int MapInfo_CurrentGametype()
 {
        int prev = cvar("gamecfg");
-       FOREACH(Gametypes, cvar(it.netname) && it.items != prev, LAMBDA(return it.items));
+       FOREACH(Gametypes, cvar(it.netname) && it.items != prev, return it.items);
        if (prev) return prev;
        return MAPINFO_TYPE_DEATHMATCH;
 }
@@ -1262,9 +1262,7 @@ float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with th
 
 void MapInfo_SwitchGameType(int t)
 {
-       FOREACH(Gametypes, true, LAMBDA(
-               cvar_set(it.netname, (it.items == t) ? "1" : "0")
-       ));
+       FOREACH(Gametypes, true, cvar_set(it.netname, (it.items == t) ? "1" : "0"));
 }
 
 void MapInfo_LoadMap(string s, float reinit)
index 8b4f9234d04dcf216a3dc35e4c9ea9ebca0e0f42..50fd2bab58660bb0139d594523c6df20631ad87d 100644 (file)
@@ -213,15 +213,13 @@ void HUD_MinigameMenu_ClickCreate()
        {
                entity curr;
                entity prev = self;
-               FOREACH(Minigames, true, LAMBDA(
-               {
-                       curr = HUD_MinigameMenu_SpawnSubEntry(
-                               it.message, HUD_MinigameMenu_ClickCreate_Entry,  self );
+               FOREACH(Minigames, true, {
+                       curr = HUD_MinigameMenu_SpawnSubEntry(it.message, HUD_MinigameMenu_ClickCreate_Entry, self);
                        curr.netname = it.netname;
                        curr.model = strzone(minigame_texture(strcat(it.netname,"/icon")));
                        HUD_MinigameMenu_InsertEntry( curr, prev );
                        prev = curr;
-               }));
+               });
        }
 }
 
index 2a632339c08acbde4928c29122a87168bc56e43b..71cf41a3aa44340d471491aad35b2e893ff19a0c 100644 (file)
@@ -4,12 +4,8 @@ REGISTER_NET_LINKED(ENT_CLIENT_MINIGAME)
 
 entity minigame_get_descriptor(string id)
 {
-       FOREACH(Minigames, true, LAMBDA(
-       {
-               if(it.netname == id)
-                       return it;
-       }));
-       return world;
+       FOREACH(Minigames, it.netname == id, return it);
+       return NULL;
 }
 
 // Get letter index of a tile name
index ca111e6c8cd978dd4bdd69482b0561345096d647..7c19c43dd6f4f2d037ac56dc7c0aa9ee54d601bb 100644 (file)
@@ -337,10 +337,7 @@ void ClientCommand_minigame(int request, int argc, string command)
                }
                else if ( minig_cmd == "list" )
                {
-                       FOREACH(Minigames, true, LAMBDA(
-                       {
-                               sprint(self,it.netname," (",it.message,") ","\n");
-                       }));
+                       FOREACH(Minigames, true, sprint(self, it.netname, " (", it.message, ") ", "\n"));
                        return;
                }
                else if ( minig_cmd == "list-sessions" )
index ac95c2c840a697a2b9e14d0d22277956c71a6416..f3bfd64c7532a833757eed9545782933b72272aa 100644 (file)
@@ -11,10 +11,13 @@ REGISTER_REGISTRY(Models)
     string MDL_##name##_get() { return path; } \
     REGISTER(Models, MDL, name, m_id, NEW(Model, MDL_##name##_get))
 
+STATIC_INIT(NULLMDL)
+{
+    precache_model("null");
+}
+
 PRECACHE(Models) {
-    FOREACH(Models, true, LAMBDA({
-        it.model_precache(it);
-    }));
+    FOREACH(Models, true, it.model_precache(it));
 }
 
 MODEL(Null, "null");
index b5265ec0c6bd51bb97fa160002bfc47ed77c9b3a..79cba7f927948707451f4707b52cb6f4e33975fd 100644 (file)
@@ -184,7 +184,7 @@ void NET_Mutator_Remove(entity this)
 {
     string s = this.netname;
     WITH(bool, mutator_log, true, LAMBDA(
-        FOREACH(Mutators, it.registered_id == s, LAMBDA(Mutator_Remove(it)));
+        FOREACH(Mutators, it.registered_id == s, Mutator_Remove(it));
     ));
 }
 NET_HANDLE(Mutator, bool isNew)
@@ -198,7 +198,7 @@ NET_HANDLE(Mutator, bool isNew)
         this.entremove = NET_Mutator_Remove;
         int added = 0;
         WITH(bool, mutator_log, true, LAMBDA(
-            FOREACH(Mutators, it.registered_id == s, LAMBDA(Mutator_Add(it); ++added));
+            FOREACH(Mutators, it.registered_id == s, { Mutator_Add(it); ++added; });
         ));
         if (added > 1) LOG_WARNINGF("Added more than one mutator for %s\n", s);
     }
@@ -278,7 +278,7 @@ STATIC_INIT(Mutators) {
 }
 
 STATIC_INIT_LATE(Mutators) {
-    FOREACH(Mutators, it.mutatorcheck(), LAMBDA(Mutator_Add(it)));
+    FOREACH(Mutators, it.mutatorcheck(), Mutator_Add(it));
 }
 
 #define MUTATOR_ONADD                   if (mode == MUTATOR_ADDING)
index 10104762d5685ee38cd72e9b41e98f229122214d..70c57485314367a6eda9dfddd58d4336ca4c51c5 100644 (file)
@@ -13,7 +13,7 @@ REGISTER_MUTATOR(damagetext, true);
 #if defined(CSQC) || defined(MENUQC)
 // no translatable cvar description please
 AUTOCVAR_SAVE(cl_damagetext,                    bool,   false,      "Draw damage dealt where you hit the enemy");
-AUTOCVAR_SAVE(cl_damagetext_format,             string, "-%3$d",    "How to format the damage text. 1$ is health, 2$ is armor, 3$ is both");
+AUTOCVAR_SAVE(cl_damagetext_format,             string, "-{total}", "How to format the damage text. {health}, {armor}, {total}");
 AUTOCVAR_SAVE(cl_damagetext_color,              vector, '1 1 0',    "Damage text color");
 AUTOCVAR_SAVE(cl_damagetext_color_per_weapon,   bool,   false,      "Damage text uses weapon color");
 AUTOCVAR_SAVE(cl_damagetext_size,               float,  8,          "Damage text font size");
@@ -51,7 +51,10 @@ CLASS(DamageText, Object)
                 Weapon w = DEATH_WEAPONOF(this.m_deathtype);
                 if (w != WEP_Null) rgb = w.wpcolor;
             }
-            string s = sprintf(autocvar_cl_damagetext_format, this.m_damage, this.m_armordamage, this.m_damage + this.m_armordamage);
+            string s = autocvar_cl_damagetext_format;
+            s = strreplace("{health}", sprintf("%d", this.m_damage), s);
+            s = strreplace("{armor}",  sprintf("%d", this.m_armordamage), s);
+            s = strreplace("{total}",  sprintf("%d", this.m_damage + this.m_armordamage), s);
             drawcolorcodedstring2(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL);
         }
     }
index cd369b87d9b0f62220bfdbb1ddbe4837e41cb2c1..c4a2e40fcd0c55ff9fd8523cb63e3a06e6a8be49 100644 (file)
@@ -21,7 +21,7 @@ REGISTER_MUTATOR(multijump, true);
 .bool multijump_ready;
 
 #ifdef CSQC
-bool autocvar_cl_multijump = false;
+bool autocvar_cl_multijump = true;
 
        #define PHYS_MULTIJUMP_CLIENT(s)        autocvar_cl_multijump
 #elif defined(SVQC)
index fa98b2feba5307dda7fe6ee1d921d0a9e439f0dd..d67a1de3d8f7a230d8620f1ffd9b815d834a8ddf 100644 (file)
@@ -30,7 +30,7 @@ void sv_notice_to(entity _to, string _notice, float _howlong, float _modal)
 
 void sv_notice_toall(string _notice, float _howlong, float _modal)
 {
-    FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(sv_notice_to(it, _notice, _howlong, _modal)));
+    FOREACH_CLIENT(IS_REAL_CLIENT(it), sv_notice_to(it, _notice, _howlong, _modal));
 }
 
 #endif // SVQC
@@ -58,7 +58,7 @@ void cl_notice_read()
 void cl_notice_run()
 {
     bool flag = false;
-    LL_EACH(cl_notices, it.alpha > time, LAMBDA(flag = true; break));
+    LL_EACH(cl_notices, it.alpha > time, { flag = true; break; });
     if (!flag) return;
     const int M1 = 30;
     const int M2 = 10;
@@ -78,10 +78,10 @@ void cl_notice_run()
     #define OUT(s, z) MACRO_BEGIN { drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3.y += z + 4; } MACRO_END
 
     OUT(_("^1Server notices:"), 32);
-    LL_EACH(cl_notices, it.alpha > time, LAMBDA(
+    LL_EACH(cl_notices, it.alpha > time, {
         string s = sprintf(_("^7%s (^3%d sec left)"), it.netname , rint(it.alpha - time));
         OUT(s, 16);
-    ));
+    });
     #undef OUT
 }
 
index a23c95f1db39118164b2db5cc84bf7142530e6ac..60fd625992b8de78200b6bf3fea00ee868a664c8 100644 (file)
@@ -1548,6 +1548,7 @@ void Send_Notification(
        MSG net_type, Notification net_name,
        ...count)
 {
+    if (!IS_REAL_CLIENT(client)) return;
        entity notif = net_name;
        string parms = sprintf("%s, '%s', %s, %s",
                Get_Notif_BroadcastName(broadcast),
index ffadf6ec160d38e8245b9ab4eed5b1ea7485fe8b..8f00087c0870a33bd57662a7941fca43045f0091 100644 (file)
@@ -662,7 +662,7 @@ string notif_arg_spree_inf(float type, string input, string player, float spree)
 
 REGISTRY(Notifications, BITS(11))
 REGISTER_REGISTRY(Notifications)
-REGISTRY_SORT(Notifications); STATIC_INIT(Notifications) { FOREACH(Notifications, true, LAMBDA(it.m_id = i)); }
+REGISTRY_SORT(Notifications); STATIC_INIT(Notifications) { FOREACH(Notifications, true, it.m_id = i); }
 REGISTRY_CHECK(Notifications)
 
 const int NOTIF_CHOICE_MAX = 50;
index ce469ed6a0893961c7834cf2813c48e086e6caa9..2c9c5894bfecfdbfefe763562e840cf4f05f0233 100644 (file)
@@ -343,11 +343,10 @@ void _Movetype_LinkEdict_TouchAreaGrid(entity this)  // SV_LinkEdict_TouchAreaGr
 
        entity oldother = other;
 
-       for (entity e = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); e; e = e.chain)
-       {
-               if(e.solid == SOLID_TRIGGER && e != this)
-               if(e.move_nomonsters != MOVE_NOMONSTERS && e.move_nomonsters != MOVE_WORLDONLY)
-               if(e.move_touch && boxesoverlap(e.absmin, e.absmax, this.absmin, this.absmax))
+    FOREACH_ENTITY_RADIUS(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true, {
+               if (it.solid == SOLID_TRIGGER && it != this)
+               if (it.move_nomonsters != MOVE_NOMONSTERS && it.move_nomonsters != MOVE_WORLDONLY)
+               if (it.move_touch && boxesoverlap(it.absmin, it.absmax, this.absmin, this.absmax))
                {
                        other = this;
 
@@ -356,14 +355,14 @@ void _Movetype_LinkEdict_TouchAreaGrid(entity this)  // SV_LinkEdict_TouchAreaGr
                        trace_fraction = 1;
                        trace_inwater = false;
                        trace_inopen = true;
-                       trace_endpos = e.move_origin;
+                       trace_endpos = it.move_origin;
                        trace_plane_normal = '0 0 1';
                        trace_plane_dist = 0;
                        trace_ent = this;
 
-                       WITH(entity, self, e, e.move_touch());
+                       WITH(entity, self, it, it.move_touch());
                }
-       }
+    });
 
        other = oldother;
 }
index dc455944cd86b24cea1f8b9ff5ba33ef267ac270..dd89a4099dfa6e9c3a38d001a49a618ea204932f 100644 (file)
@@ -53,9 +53,8 @@ void _Movetype_PushMove(entity this, float dt)  // SV_PushMove
 
        if (this.move_movetype != MOVETYPE_FAKEPUSH)
        {
-               for (entity check = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); check; check = check.chain)
-               {
-                       switch (check.move_movetype)
+           FOREACH_ENTITY_RADIUS(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true, {
+                       switch (it.move_movetype)
                        {
                                case MOVETYPE_NONE:
                                case MOVETYPE_PUSH:
@@ -67,17 +66,17 @@ void _Movetype_PushMove(entity this, float dt)  // SV_PushMove
                                        break;
                        }
 
-                       if (check.owner == this)
+                       if (it.owner == this)
                                continue;
 
-                       if (this.owner == check)
+                       if (this.owner == it)
                                continue;
 
-                       vector pivot = check.mins + 0.5 * (check.maxs - check.mins);
+                       vector pivot = it.mins + 0.5 * (it.maxs - it.mins);
                        vector move;
                        if (rotated)
                        {
-                               vector org = (check.move_origin - this.move_origin) + pivot;
+                               vector org = (it.move_origin - this.move_origin) + pivot;
                                vector org2;
                                org2.x = org * v_forward;
                                org2.y = org * v_right;
@@ -90,34 +89,34 @@ void _Movetype_PushMove(entity this, float dt)  // SV_PushMove
                        }
 
                        // physics objects need better collisions than this code can do
-                       if (check.move_movetype == 32)  // MOVETYPE_PHYSICS
+                       if (it.move_movetype == 32)  // MOVETYPE_PHYSICS
                        {
-                               check.move_origin = check.move_origin + move;
-                               _Movetype_LinkEdict(check, true);
+                               it.move_origin = it.move_origin + move;
+                               _Movetype_LinkEdict(it, true);
                                continue;
                        }
 
                        // try moving the contacted entity
                        this.solid = SOLID_NOT;
                        bool flag = false;
-                       flag = _Movetype_PushEntity(check, move, true);
+                       flag = _Movetype_PushEntity(it, move, true);
                        if (!flag)
                        {
-                               // entity "check" got teleported
-                               check.move_angles_y += trace_fraction * moveangle.y;
+                               // entity "it" got teleported
+                               it.move_angles_y += trace_fraction * moveangle.y;
                                this.solid = savesolid;
                                continue;  // pushed enough
                        }
                        // FIXME: turn players specially
-                       check.move_angles_y += trace_fraction * moveangle.y;
+                       it.move_angles_y += trace_fraction * moveangle.y;
                        this.solid = savesolid;
 
                        // this trace.fraction < 1 check causes items to fall off of pushers
                        // if they pass under or through a wall
                        // the groundentity check causes items to fall off of ledges
-                       if (check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.move_groundentity != this))
-                               check.move_flags &= ~FL_ONGROUND;
-               }
+                       if (it.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || it.move_groundentity != this))
+                               it.move_flags &= ~FL_ONGROUND;
+        });
        }
 
        this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
index 3d10ca8b5a43eb8ea71133b485edb35f00f9e96e..233762202efda470e23ed15819f2fa2fadf34bd5 100644 (file)
@@ -108,13 +108,13 @@ void PlayerStats_GameReport_Accuracy(entity p)
 {
        #define ACCMAC(suffix, field) \
                PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", it.netname, suffix), p.accuracy.(field[i-1]));
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+       FOREACH(Weapons, it != WEP_Null, {
                ACCMAC("hit", accuracy_hit)
                ACCMAC("fired", accuracy_fired)
                ACCMAC("cnt-hit", accuracy_cnt_hit)
                ACCMAC("cnt-fired", accuracy_cnt_fired)
                ACCMAC("frags", accuracy_frags)
-       ));
+       });
        #undef ACCMAC
 }
 
@@ -163,7 +163,7 @@ void PlayerStats_GameReport(float finished)
        PlayerScore_Sort(scoreboard_pos, 1, 1, 1);
        if(teamplay) { PlayerScore_TeamStats(); }
 
-       FOREACH_CLIENT(true, LAMBDA(
+       FOREACH_CLIENT(true, {
                // add personal score rank
                PS_GR_P_ADDVAL(it, PLAYERSTATS_RANK, it.score_dummyfield);
 
@@ -189,7 +189,7 @@ void PlayerStats_GameReport(float finished)
 
                // collect final player information
                PlayerStats_GameReport_FinalizePlayer(it);
-       ));
+       });
 
        if(autocvar_g_playerstats_gamereport_uri != "")
        {
@@ -231,13 +231,13 @@ void PlayerStats_GameReport_Init() // initiated before InitGameplayMode so that
                PlayerStats_GameReport_AddEvent(PLAYERSTATS_RANK);
 
                // accuracy stats
-               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               FOREACH(Weapons, it != WEP_Null, {
                        PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-hit"));
                        PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-fired"));
                        PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-cnt-hit"));
                        PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-cnt-fired"));
                        PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-frags"));
-               ));
+               });
 
                PlayerStats_GameReport_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_3);
                PlayerStats_GameReport_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_5);
@@ -457,7 +457,7 @@ void PlayerStats_PlayerBasic(entity joiningplayer, float newrequest)
                        db_close(PS_B_IN_DB);
                        PS_B_IN_DB = -1;
 
-                       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(it.playerstats_basicstatus = PS_B_STATUS_IDLE));
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it), it.playerstats_basicstatus = PS_B_STATUS_IDLE);
                }
        }
 }
index c5685df3a43e0adfdeb35ef4cd92c7187af72240..751462498c2a0a4743c998f869a381c8e9da9040 100644 (file)
@@ -128,7 +128,7 @@ float spamsound(entity e, int chan, string samp, float vol, float _atten)
 void play2team(float t, string filename)
 {
        if (autocvar_bot_sound_monopoly) return;
-       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.team == t, LAMBDA(play2(it, filename)));
+       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.team == t, play2(it, filename));
 }
 
 void play2all(string samp)
index 02098e8755dc805eec8e8a4605544ca5df34b719..a7fe25f17d1e324d07069f46e16057efbd22ba96 100644 (file)
@@ -15,9 +15,7 @@ REGISTER_REGISTRY(Sounds)
 #define SND(id) Sound_fixpath(SND_##id)
 
 PRECACHE(Sounds) {
-    FOREACH(Sounds, true, LAMBDA({
-        it.sound_precache(it);
-    }));
+    FOREACH(Sounds, true, it.sound_precache(it));
 }
 
 SOUND(Null, "misc/null");
diff --git a/qcsrc/common/state.qc b/qcsrc/common/state.qc
new file mode 100644 (file)
index 0000000..226ff1b
--- /dev/null
@@ -0,0 +1,83 @@
+#include "state.qh"
+
+void Inventory_new(entity this);
+void Inventory_delete(entity this);
+
+void PlayerState_attach(entity this)
+{
+       this._ps = NEW(PlayerState, this);
+
+       Inventory_new(this);
+}
+
+void PlayerState_detach(entity this)
+{
+       if (!PS(this)) return;  // initial connect
+       FOREACH_CLIENT(PS(it) == PS(this), { PS(it) = NULL; });
+       remove(PS(this));
+       this._ps = NULL;
+
+    Inventory_delete(self);
+}
+
+void GetCvars(int);
+void DecodeLevelParms(entity this);
+void PlayerScore_Attach(entity this);
+void ClientData_Attach(entity this);
+void accuracy_init(entity this);
+void entcs_attach(entity this);
+void playerdemo_init(entity this);
+void anticheat_init(entity this);
+void W_HitPlotOpen(entity this);
+void bot_clientconnect(entity this);
+
+void ClientState_attach(entity this)
+{
+       this._cs = NEW(ClientState, this);
+
+    GetCvars(0);  // get other cvars from player
+
+       // TODO: xonstat elo.txt support, until then just 404s
+       if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
+
+       // TODO: fold all of these into ClientState
+
+       DecodeLevelParms(this);
+
+       PlayerScore_Attach(this);
+       ClientData_Attach(this);
+       accuracy_init(this);
+       entcs_attach(this);
+       playerdemo_init(this);
+       anticheat_init(this);
+       W_HitPlotOpen(this);
+
+       bot_clientconnect(this);
+}
+
+void bot_clientdisconnect();
+void W_HitPlotClose(entity this);
+void anticheat_report();
+void playerdemo_shutdown();
+void entcs_detach(entity this);
+void accuracy_free(entity this);
+void ClientData_Detach(entity this);
+void PlayerScore_Detach(entity this);
+
+void ClientState_detach(entity this)
+{
+       remove(CS(this));
+       this._cs = NULL;
+
+    GetCvars(-1);  // free cvars
+
+    bot_clientdisconnect();
+
+    W_HitPlotClose(this);
+    anticheat_report();
+    playerdemo_shutdown();
+    entcs_detach(this);
+    accuracy_free(self);
+    ClientData_Detach(this);
+    PlayerScore_Detach(self);
+}
index fcc3656b8dcd710c76305925e1868e18bef0777b..64ae3e7fe62f087accb4e01d0cfd65ba428940eb 100644 (file)
@@ -30,26 +30,9 @@ ENDCLASS(PlayerState)
        PlayerState PS(entity this) { assert(IS_CLIENT(this)); return this._ps; }
 #endif
 
-void Inventory_new(entity this);
-void Inventory_delete(entity this);
-
 // TODO: renew on death
-
-void PlayerState_attach(entity this)
-{
-       this._ps = NEW(PlayerState, this);
-
-       Inventory_new(this);
-}
-
-void PlayerState_detach(entity this)
-{
-       if (!PS(this)) return;  // initial connect
-       remove(PS(this));
-       this._ps = NULL;
-
-    Inventory_delete(self);
-}
+void PlayerState_attach(entity this);
+void PlayerState_detach(entity this);
 
 /**
  * Purpose: common client state, usable on client and server
@@ -73,64 +56,5 @@ ENDCLASS(ClientState)
        ClientState CS(entity this) { assert(IS_CLIENT(this)); assert(this._cs); return this._cs; }
 #endif
 
-void GetCvars(int);
-void DecodeLevelParms(entity this);
-void PlayerScore_Attach(entity this);
-void ClientData_Attach(entity this);
-void accuracy_init(entity this);
-void entcs_attach(entity this);
-void playerdemo_init(entity this);
-void anticheat_init(entity this);
-void W_HitPlotOpen(entity this);
-void bot_clientconnect(entity this);
-
-void ClientState_attach(entity this)
-{
-       this._cs = NEW(ClientState, this);
-
-    GetCvars(0);  // get other cvars from player
-
-       // TODO: xonstat elo.txt support, until then just 404s
-       if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
-
-       // TODO: fold all of these into ClientState
-
-       DecodeLevelParms(this);
-
-       PlayerScore_Attach(this);
-       ClientData_Attach(this);
-       accuracy_init(this);
-       entcs_attach(this);
-       playerdemo_init(this);
-       anticheat_init(this);
-       W_HitPlotOpen(this);
-
-       bot_clientconnect(this);
-}
-
-void bot_clientdisconnect();
-void W_HitPlotClose(entity this);
-void anticheat_report();
-void playerdemo_shutdown();
-void entcs_detach(entity this);
-void accuracy_free(entity this);
-void ClientData_Detach(entity this);
-void PlayerScore_Detach(entity this);
-
-void ClientState_detach(entity this)
-{
-       remove(CS(this));
-       this._cs = NULL;
-
-    GetCvars(-1);  // free cvars
-
-    bot_clientdisconnect();
-
-    W_HitPlotClose(this);
-    anticheat_report();
-    playerdemo_shutdown();
-    entcs_detach(this);
-    accuracy_free(self);
-    ClientData_Detach(this);
-    PlayerScore_Detach(self);
-}
+void ClientState_attach(entity this);
+void ClientState_detach(entity this);
index ef7438c96a186f8f3e4c42c9ba2c03fc07739a11..e2bafb82fe5d1921eaa363f4f6f0d8a0d344fcd3 100644 (file)
@@ -555,13 +555,13 @@ void Item_RespawnCountdown ()
                if(self.waypointsprite_attached)
                {
                        setself(self.waypointsprite_attached);
-                       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it), {
                                if(self.waypointsprite_visible_for_player(it))
                                {
                                        msg_entity = it;
                                        soundto(MSG_ONE, this, CH_TRIGGER, SND(ITEMRESPAWNCOUNTDOWN), VOL_BASE, ATTEN_NORM);    // play respawn sound
                                }
-                       ));
+                       });
                        setself(this);
 
                        WaypointSprite_Ping(self.waypointsprite_attached);
@@ -698,13 +698,13 @@ float Item_GiveTo(entity item, entity player)
                if (w || (item.spawnshieldtime && item.pickup_anyway > 0))
                {
                        pickedup = true;
-                       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       FOREACH(Weapons, it != WEP_Null, {
                                if(w & (it.m_wepset))
                                {
                                        W_DropEvent(wr_pickup, player, it.m_id, item);
                                        W_GiveWeapon(player, it.m_id);
                                }
-                       ));
+                       });
                }
        }
 
@@ -972,7 +972,7 @@ float commodity_pickupevalfunc(entity player, entity item)
        c = 0;
 
        // Detect needed ammo
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+       FOREACH(Weapons, it != WEP_Null, {
                if(!(player.weapons & (it.m_wepset)))
                        continue;
 
@@ -988,7 +988,7 @@ float commodity_pickupevalfunc(entity player, entity item)
                        need_plasma = true;
                else if(it.items & ITEM_JetpackFuel.m_itemid)
                        need_fuel = true;
-       ));
+       });
 
        // TODO: figure out if the player even has the weapon this ammo is for?
        // may not affect strategy much though...
@@ -1155,16 +1155,12 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
 
                if(autocvar_spawn_debug >= 2)
                {
-                       for(entity otheritem = findradius(this.origin, 3); otheritem; otheritem = otheritem.chain)
-                       {
-                           // why not flags & fl_item?
-                               if(otheritem.is_item)
-                               {
-                                       LOG_TRACE("XXX Found duplicated item: ", itemname, vtos(this.origin));
-                                       LOG_TRACE(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
-                                       error("Mapper sucks.");
-                               }
-                       }
+            // why not flags & fl_item?
+                   FOREACH_ENTITY_RADIUS(this.origin, 3, it.is_item, {
+                LOG_TRACE("XXX Found duplicated item: ", itemname, vtos(this.origin));
+                LOG_TRACE(" vs ", it.netname, vtos(it.origin), "\n");
+                error("Mapper sucks.");
+            });
                        this.is_item = true;
                }
 
@@ -1482,7 +1478,7 @@ spawnfunc(target_items)
                        else if(argv(i) == "fuel_regen")             self.items |= ITEM_JetpackRegen.m_itemid;
                        else
                        {
-                               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                               FOREACH(Weapons, it != WEP_Null, {
                                        s = W_UndeprecateName(argv(i));
                                        if(s == it.netname)
                                        {
@@ -1491,7 +1487,7 @@ spawnfunc(target_items)
                                                        it.wr_init(it);
                                                break;
                                        }
-                               ));
+                               });
                        }
                }
 
@@ -1538,7 +1534,7 @@ spawnfunc(target_items)
                if(self.ammo_fuel != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_fuel), "fuel");
                if(self.health != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "health");
                if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.armorvalue), "armor");
-               FOREACH(Weapons, it != WEP_Null, LAMBDA(self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (it.m_wepset)), it.netname)));
+               FOREACH(Weapons, it != WEP_Null, self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (it.m_wepset)), it.netname));
        }
        self.netname = strzone(self.netname);
        //print(self.netname, "\n");
@@ -1546,13 +1542,10 @@ spawnfunc(target_items)
        n = tokenize_console(self.netname);
        for(i = 0; i < n; ++i)
        {
-               FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                       if(argv(i) == it.netname)
-                       {
-                               it.wr_init(it);
-                               break;
-                       }
-               ));
+               FOREACH(Weapons, it != WEP_Null && argv(i) == it.netname, {
+            it.wr_init(it);
+            break;
+               });
        }
 }
 
@@ -1713,10 +1706,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                                got += GiveValue(e, health, op, val);
                                got += GiveValue(e, armorvalue, op, val);
                        case "allweapons":
-                               FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                                       if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
-                                               got += GiveWeapon(e, it.m_id, op, val);
-                               ));
+                               FOREACH(Weapons, it != WEP_Null && !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), got += GiveWeapon(e, it.m_id, op, val));
                        case "allammo":
                                got += GiveValue(e, ammo_cells, op, val);
                                got += GiveValue(e, ammo_plasma, op, val);
@@ -1775,13 +1765,10 @@ float GiveItems(entity e, float beginarg, float endarg)
                                got += GiveValue(e, ammo_fuel, op, val);
                                break;
                        default:
-                               FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                                       if(cmd == it.netname)
-                                       {
-                                               got += GiveWeapon(e, it.m_id, op, val);
-                                               break;
-                                       }
-                               ));
+                               FOREACH(Weapons, it != WEP_Null && cmd == it.netname, {
+                    got += GiveWeapon(e, it.m_id, op, val);
+                    break;
+                               });
                                break;
                }
                val = 999;
@@ -1792,12 +1779,12 @@ float GiveItems(entity e, float beginarg, float endarg)
        POSTGIVE_BIT(e, items, IT_UNLIMITED_SUPERWEAPONS, SND_POWERUP, SND_POWEROFF);
        POSTGIVE_BIT(e, items, IT_UNLIMITED_WEAPON_AMMO, SND_POWERUP, SND_POWEROFF);
        POSTGIVE_BIT(e, items, ITEM_Jetpack.m_itemid, SND_ITEMPICKUP, SND_Null);
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+       FOREACH(Weapons, it != WEP_Null, {
                POSTGIVE_WEAPON(e, it, SND_WEAPONPICKUP, SND_Null);
                if(!(save_weapons & (it.m_wepset)))
                        if(e.weapons & (it.m_wepset))
                                it.wr_init(it);
-       ));
+       });
        POSTGIVE_VALUE(e, strength_finished, 1, SND_POWERUP, SND_POWEROFF);
        POSTGIVE_VALUE(e, invincible_finished, 1, SND_Shield, SND_POWEROFF);
        POSTGIVE_VALUE(e, ammo_nails, 0, SND_ITEMPICKUP, SND_Null);
index dc227f17633b50c2da19ee18062e31686e0e1f59..69f444073f16ce31432628d63cc95fa05dfb24fb 100644 (file)
@@ -16,11 +16,11 @@ void target_changelevel_use()
                int plnum = 0;
                int realplnum = 0;
                // let's not count bots
-               FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+               FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
                        ++realplnum;
                        if(it.chlevel_targ == self)
                                ++plnum;
-               ));
+               });
                if(plnum < ceil(realplnum * min(1, self.count))) // 70% of players
                        return;
        }
index 3e0cca2a7ceab58d2e707911700e95d26702580b..52f1fca0e27a723ecf5804b40700ee42074a9394 100644 (file)
@@ -54,10 +54,10 @@ void target_music_use()
                msg_entity = activator;
                target_music_sendto(MSG_ONE, 1);
        }
-       FOREACH_CLIENT(IS_SPEC(it) && it.enemy == activator, LAMBDA(
+       FOREACH_CLIENT(IS_SPEC(it) && it.enemy == activator, {
                msg_entity = it;
                target_music_sendto(MSG_ONE, 1);
-       ));
+       });
 }
 spawnfunc(target_music)
 {
@@ -168,7 +168,7 @@ void TargetMusic_Advance()
        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(
+       LL_EACH(TargetMusic_list, it.noise, {
                const float vol0 = (getsoundtime(it, CH_BGM_SINGLE) >= 0) ? it.lastvol : -1;
                if (it == best)
                {
@@ -189,7 +189,7 @@ void TargetMusic_Advance()
                                _sound(it, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
                        it.lastvol = vol;
                }
-       ));
+       });
        music_trigger = world;
        bgmtime = (best) ? getsoundtime(best, CH_BGM_SINGLE) : gettime(GETTIME_CDTRACK);
 }
@@ -210,7 +210,7 @@ void Net_TargetMusic()
        const string noi = ReadString();
 
        entity e = NULL;
-       LL_EACH(TargetMusic_list, it.count == id, LAMBDA(e = it; break));
+       LL_EACH(TargetMusic_list, it.count == id, { e = it; break; });
        if (!e)
        {
                LL_PUSH(TargetMusic_list, e = new_pure(TargetMusic));
index 801776857a808423b39c30e9b6645209eace97eb..40ba61f6519bb96ff5a9f87d6815f154a959a4c7 100644 (file)
@@ -304,9 +304,7 @@ void WarpZone_PostTeleportPlayer_Callback(entity pl)
        Reset_ArcBeam(pl, v_forward);
        UpdateCSQCProjectileAfterTeleport(pl);
        UpdateItemAfterTeleport(pl);
-       {
-               WITH(entity, self, pl, anticheat_fixangle());
-       }
+    if (IS_PLAYER(pl)) anticheat_fixangle(pl);
 #endif
        // "disown" projectiles after teleport
        if(pl.owner)
index 3b4dbb489a7b31455c1b2d29b6dc12f1dfb1b277..be8040079b91f36670492816498228debff65bfa 100644 (file)
@@ -88,7 +88,7 @@ spawnfunc(trigger_teleport)
        self.use = trigger_teleport_use;
 
        if(self.noise != "")
-               FOREACH_WORD(self.noise, true, LAMBDA(precache_sound(it)));
+               FOREACH_WORD(self.noise, true, precache_sound(it));
 
        // this must be called to spawn the teleport waypoints for bots
        InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
index 34cf50eacc3d5f632d2ff4726232fe137344c050..022e73c5e3e2581756acb5cfa4e0f954a295b389 100644 (file)
@@ -28,7 +28,7 @@ float T_Config_Queue_Compare(float root, float child, entity pass)
 void Dump_Turret_Settings()
 {
        float x, totalsettings = 0;
-       FOREACH(Turrets, it != TUR_Null, LAMBDA({
+       FOREACH(Turrets, it != TUR_Null, {
                // step 1: clear the queue
                TUR_CONFIG_COUNT = 0;
                for(x = 0; x <= MAX_TUR_CONFIG; ++x)
@@ -49,7 +49,7 @@ void Dump_Turret_Settings()
                // step 5: debug info
                LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.turret_name, TUR_CONFIG_COUNT));
                totalsettings += TUR_CONFIG_COUNT;
-       }));
+       });
 
        // clear queue now that we're finished
        TUR_CONFIG_COUNT = 0;
index a06fbcbb96392c24fdc53b5b07573a4c48167318..fec1e885f1e0cce7d1b5c3fac6ad2fdb48372336 100644 (file)
@@ -1206,11 +1206,11 @@ void turrets_manager_think()
 
        if (autocvar_g_turrets_reloadcvars == 1)
        {
-               FOREACH_ENTITY(IS_TURRET(it), LAMBDA(
+               FOREACH_ENTITY(IS_TURRET(it), {
                        load_unit_settings(it, true);
                        Turret tur = get_turretinfo(it.m_id);
                        tur.tr_think(tur, it);
-               ));
+               });
                cvar_set("g_turrets_reloadcvars", "0");
        }
 }
index 9ee9d1dc49ba719bf5bf93e00040a63459f62917..3e75ae53016281ffd724fd85325d2499b3b5a60d 100644 (file)
@@ -1007,7 +1007,7 @@ void vehicles_enter(entity pl, entity veh)
        if(DIFF_TEAM(pl, veh))
        if(autocvar_g_vehicles_steal)
        {
-               FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL)));
+               FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL));
 
                Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
 
@@ -1164,7 +1164,7 @@ void vehicles_spawn()
        if(self.vehicle_controller)
                self.team = self.vehicle_controller.team;
 
-       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, LAMBDA(RemoveGrapplingHook(it)));
+       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, RemoveGrapplingHook(it));
 
        vehicles_reset_colors();
 
index def5003c60eed223477a5b80b618af20ac743e8b..b126005eb0e3c93fd6dedf367b561303d54aaa86 100644 (file)
@@ -134,7 +134,7 @@ string W_NumberWeaponOrder_MapFunc(string s)
 {
        if (s == "0" || stof(s)) return s;
        s = W_UndeprecateName(s);
-       FOREACH(Weapons, it != WEP_Null && it.netname == s, LAMBDA(return ftos(i)));
+       FOREACH(Weapons, it != WEP_Null && it.netname == s, return ftos(i));
        return s;
 }
 string W_NumberWeaponOrder(string order)
@@ -202,10 +202,10 @@ void W_RandomWeapons(entity e, float n)
        for (i = 0; i < n; ++i)
        {
                RandomSelection_Init();
-               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               FOREACH(Weapons, it != WEP_Null, {
                        if (remaining & (it.m_wepset))
                                RandomSelection_Add(it, 0, string_null, 1, 1);
-               ));
+               });
                Weapon w = RandomSelection_chosen_ent;
                result |= WepSet_FromWeapon(w);
                remaining &= ~WepSet_FromWeapon(w);
index 0e1b5439f7e8cb06a2b9eddd186bb48e7c41cb90..5e87a3c3a9cbe4ee132921a0d25fcc1698edbf0e 100644 (file)
@@ -33,7 +33,7 @@ WepSet ReadWepSet();
 REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
 #define Weapons_from(i) _Weapons_from(i, WEP_Null)
 REGISTER_REGISTRY(Weapons)
-STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); }
+STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPickup, it)); }
 
 .WepSet m_wepset;
 #define WEPSET(id) (WEP_##id.m_wepset)
@@ -298,7 +298,7 @@ REGISTRY_CHECK(Weapons)
 
 STATIC_INIT(register_weapons_done)
 {
-    FOREACH(Weapons, true, LAMBDA(
+    FOREACH(Weapons, true, {
         WepSet set = it.m_wepset = _WepSet_FromWeapon(it.m_id = i);
         WEPSET_ALL |= set;
         if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
@@ -309,9 +309,9 @@ STATIC_INIT(register_weapons_done)
             localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", it.netname, imp));
         else
             LOG_TRACEF("Impulse limit exceeded, weapon will not be directly accessible: %s\n", it.netname);
-    ));
+    });
     #ifdef CSQC
-    FOREACH(Weapons, true, LAMBDA(it.wr_init(it)));
+    FOREACH(Weapons, true, it.wr_init(it));
     #endif
     weaponorder_byid = "";
     for (int i = Weapons_MAX - 1; i >= 1; --i)
index ad90baa6fe3eb399445421a0a239c8d25ad4e52a..34031a208b830082211296cdb3661f7d7c1bdb05 100644 (file)
@@ -25,7 +25,7 @@ float W_Config_Queue_Compare(int root, int child, entity pass)
 void Dump_Weapon_Settings()
 {
        int totalweapons = 0, totalsettings = 0;
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+       FOREACH(Weapons, it != WEP_Null, {
                // step 1: clear the queue
                WEP_CONFIG_COUNT = 0;
                for (int x = 0; x <= MAX_WEP_CONFIG; ++x)
@@ -51,7 +51,7 @@ void Dump_Weapon_Settings()
                LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.m_name, WEP_CONFIG_COUNT));
                totalweapons += 1;
                totalsettings += WEP_CONFIG_COUNT;
-       ));
+       });
 
        // clear queue now that we're finished
        WEP_CONFIG_COUNT = 0;
index be4387347ab1dbde10fd6fda7c2b1510405bfa0b..0e667419d009503e88029ce4d8d55cf6a66e65aa 100644 (file)
@@ -50,7 +50,7 @@ spawnfunc(weapon_porto) { weapon_defaultspawnfunc(this, WEP_PORTO); }
 
 REGISTER_MUTATOR(porto_ticker, true);
 MUTATOR_HOOKFUNCTION(porto_ticker, SV_StartFrame) {
-       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.porto_forbidden = max(0, it.porto_forbidden - 1)));
+       FOREACH_CLIENT(IS_PLAYER(it), it.porto_forbidden = max(0, it.porto_forbidden - 1));
 }
 
 void W_Porto_Success()
index 24b2f69982c0b3faa4639f5922fb981be032efa3..593af851828da87d95b3935c533cc3d725edcbdf 100644 (file)
@@ -287,7 +287,7 @@ void W_Tuba_NoteThink()
        }
        self.nextthink = time;
        dist_mult = WEP_CVAR(tuba, attenuation) / autocvar_snd_soundradius;
-       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != self.realowner, LAMBDA(
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != self.realowner, {
                v = self.origin - (it.origin + it.view_ofs);
                vol0 = max(0, 1 - vlen(v) * dist_mult);
                dir0 = normalize(v);
@@ -306,7 +306,7 @@ void W_Tuba_NoteThink()
                        self.SendFlags |= 2;
                        break;
                }
-       ));
+       });
 }
 
 void W_Tuba_NoteOn(float hittype)
index f5200a41a4523f2ec9f40faca668e6df770321d8..89b455ab56f9f6ea3d25a6850a36d0f8fb961b5e 100644 (file)
@@ -107,6 +107,21 @@ noref string _FOREACH_ENTITY_mutex;
        } MACRO_END
 
 
+#ifndef MENUQC
+entity(vector org, float rad, .entity tofield) _findradius_tofield = #22;
+#define FOREACH_ENTITY_RADIUS(org, dist, cond, body) FOREACH_ENTITY_RADIUS_UNORDERED(org, dist, cond, body)
+.entity _FOREACH_ENTITY_RADIUS_next;
+noref string _FOREACH_ENTITY_RADIUS_mutex;
+#define FOREACH_ENTITY_RADIUS_UNORDERED(org, dist, cond, body) \
+       MACRO_BEGIN { \
+               if (_FOREACH_ENTITY_RADIUS_mutex) LOG_SEVEREF("Loop mutex held by %s", _FOREACH_ENTITY_RADIUS_mutex); \
+               _FOREACH_ENTITY_RADIUS_mutex = __FUNC__; \
+               entity _foundchain_first = _findradius_tofield(org, dist, _FOREACH_ENTITY_RADIUS_next); \
+               FOREACH_LIST(_foundchain, _FOREACH_ENTITY_RADIUS_next, cond, body); \
+               _FOREACH_ENTITY_RADIUS_mutex = string_null; \
+       } MACRO_END
+#endif
+
 
 #define FOREACH_ENTITY_CLASS(class, cond, body) ORDERED(FOREACH_ENTITY_CLASS)(class, cond, body)
 #define FOREACH_ENTITY_CLASS_ORDERED(class, cond, body) FOREACH_ENTITY_ORDERED(it.classname == class && (cond), body)
index 01dc645f5630e131ae77f857bba0087c9137a85d..68c974dc31adc66faf5728c455fbaed42f8f1d1b 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "progname.qh"
+
 #define assert(expr, ...) _assert(LOG_SEVERE, expr, __VA_ARGS__)
 #define devassert(...) MACRO_BEGIN if (autocvar_developer) assert(__VA_ARGS__); MACRO_END
 
@@ -38,7 +40,7 @@ string(string...) strcat0n = #115;
 
 #define _LOG(f, level, s) \
        MACRO_BEGIN { \
-               f(sprintf("^9[::" level "^9] [" __FILE__ "^7:^9%s^7:^9" STR(__LINE__) "] \n^7%s\n", __FUNC__, s)); \
+               f(sprintf("^9[::^7" PROGNAME "^9::" level "^9] [" __FILE__ "^7:^9%s^7:^9" STR(__LINE__) "] \n^7%s\n", __FUNC__, s)); \
        } MACRO_END
 
 #define  LOG_FATAL(...) _LOG_FATAL(strcat0n(__VA_ARGS__))
index 7ac732f8b65b451608897f313fdd996d32b4bcb4..b364ced54fefa584aeb63e014452f5436c03e9c6 100644 (file)
@@ -145,9 +145,7 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
 
        void UncustomizeEntitiesRun()
        {
-               FOREACH_ENTITY_FLOAT(uncustomizeentityforclient_set, true, LAMBDA(
-                       WITH(entity, self, it, it.uncustomizeentityforclient());
-               ));
+               FOREACH_ENTITY_FLOAT(uncustomizeentityforclient_set, true, WITH(entity, self, it, it.uncustomizeentityforclient()));
        }
 
        STRING_ITERATOR(g_buf, string_null, 0);
index fb6cb80e8b9cdc8f0d11690999abf7f3f73edebf..434473a862147d46fc5676fce61631b409106fc7 100644 (file)
@@ -158,7 +158,7 @@ void Registry_send(string id, string hash);
                string algo = "MD4"; \
                string join = ":"; \
                string s = ""; \
-               FOREACH(id, true, LAMBDA(s = strcat(s, join, it.registered_id))); \
+               FOREACH(id, true, s = strcat(s, join, it.registered_id)); \
                s = substring(s, strlen(join), -1); \
                string h = REGISTRY_HASH(id) = strzone(digest_hex(algo, s)); \
                LOG_TRACEF(#id ": %s\n[%s]\n", h, s); \
index ea7671a1cd6a6bb81a77c8112a7e0360b999c568..2d10d9c464ab3f2b9fa9101e4a6d7990b30e00fb 100644 (file)
@@ -107,7 +107,7 @@ REGISTRY_SORT(Stats)
 REGISTRY_CHECK(Stats)
 STATIC_INIT(RegisterStats_renumber)
 {
-       FOREACH(Stats, true, LAMBDA(it.m_id = STATS_ENGINE_RESERVE + i));
+       FOREACH(Stats, true, it.m_id = STATS_ENGINE_RESERVE + i);
 }
 #ifdef SVQC
 STATIC_INIT(stats_add) { stats_add(); }
index 21b931e9319352f663f0773aa5280ac0eeda8e49..def1dae2d489f512a0c677087943814c00f8b8a7 100644 (file)
@@ -87,7 +87,9 @@ float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { ret
 } MACRO_END
 
 noref vector _vec2;
-#define vec2(v) (_vec2 = (v), _vec2.z = 0, _vec2)
+#define vec2(...) EVAL(OVERLOAD(vec2, __VA_ARGS__))
+#define vec2_1(v) (_vec2 = (v), _vec2.z = 0, _vec2)
+#define vec2_2(x, y) (_vec2_x = (x), _vec2_y = (y), _vec2)
 
 noref vector _vec3;
 #define vec3(_x, _y, _z) (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3)
@@ -104,6 +106,16 @@ vector rotate(vector v, float a)
 noref vector _yinvert;
 #define yinvert(v) (_yinvert = (v), _yinvert.y = 1 - _yinvert.y, _yinvert)
 
+/**
+ * @param dir the directional vector
+ * @param norm the normalized normal
+ * @returns dir reflected by norm
+ */
+vector reflect(vector dir, vector norm)
+{
+       return dir - 2 * (dir * norm) * norm;
+}
+
 #ifndef MENUQC
        vector get_corner_position(entity box, int corner)
        {
index b3332f36f464dde5e067a455c8eedc37606ac9e0..99332dba673b649b3862035afd20076bfa0ee48a 100644 (file)
@@ -572,8 +572,8 @@ vector WarpZoneLib_NearestPointOnBox(vector mi, vector ma, vector org)
 
 bool WarpZoneLib_BadEntity(entity e)
 {
-       string s = e.classname;
        if (is_pure(e)) return true;
+       string s = e.classname;
        switch (s)
        {
                // case "net_linked": // actually some real entities are linked without classname, fail
@@ -590,68 +590,62 @@ bool WarpZoneLib_BadEntity(entity e)
 
 .float WarpZone_findradius_hit;
 .entity WarpZone_findradius_next;
-void WarpZone_FindRadius_Recurse(vector org, float rad,        vector org0,               vector transform, vector shift, float needlineofsight)
-//                               blast origin of current search   original blast origin   how to untransform (victim to blast system)
-{
-       vector org_new;
-       vector org0_new;
-       vector shift_new, transform_new;
-       vector p;
-       entity e, e0;
-       entity wz;
-       if(rad <= 0)
-               return;
-       e0 = findradius(org, rad);
-       wz = world;
-
-       for(e = e0; e; e = e.chain)
-       {
-               if(WarpZoneLib_BadEntity(e))
-                       continue;
-               p = WarpZoneLib_NearestPointOnBox(e.origin + e.mins, e.origin + e.maxs, org0);
-               if(needlineofsight)
+void WarpZone_FindRadius_Recurse(
+    /** blast origin of current search */
+    vector org,
+    float rad,
+    /** original blast origin */
+    vector org0,
+    /** how to untransform (victim to blast system) */
+    vector transform,
+    vector shift,
+    bool needlineofsight)
+{
+       if (rad <= 0) return;
+       entity wz = NULL;
+       FOREACH_ENTITY_RADIUS(org, rad, !WarpZoneLib_BadEntity(it), {
+               vector p = WarpZoneLib_NearestPointOnBox(it.origin + it.mins, it.origin + it.maxs, org0);
+               if (needlineofsight)
                {
-                       traceline(org, p, MOVE_NOMONSTERS, e);
-                       if(trace_fraction < 1)
-                               continue;
+                       traceline(org, p, MOVE_NOMONSTERS, it);
+                       if (trace_fraction < 1) continue;
                }
-               if(!e.WarpZone_findradius_hit || vlen2(e.WarpZone_findradius_dist) > vlen2(org0 - p))
+               if (!it.WarpZone_findradius_hit || vlen2(it.WarpZone_findradius_dist) > vlen2(org0 - p))
                {
-                       e.WarpZone_findradius_nearest = p;
-                       e.WarpZone_findradius_dist = org0 - p;
-                       e.WarpZone_findradius_findorigin = org;
-                       e.WarpZone_findradius_findradius = rad;
-                       if(e.classname == "warpzone_refsys")
+                       it.WarpZone_findradius_nearest = p;
+                       it.WarpZone_findradius_dist = org0 - p;
+                       it.WarpZone_findradius_findorigin = org;
+                       it.WarpZone_findradius_findradius = rad;
+                       if (it.classname == "warpzone_refsys")
                        {
                                // ignore, especially: do not overwrite the refsys parameters
                        }
-                       else if(e.classname == "trigger_warpzone")
+                       else if (it.classname == "trigger_warpzone")
                        {
-                               e.WarpZone_findradius_next = wz;
-                               wz = e;
-                               e.WarpZone_findradius_hit = 1;
-                               e.enemy.WarpZone_findradius_dist = '0 0 0'; // we don't want to go through this zone ever again
-                               e.enemy.WarpZone_findradius_hit = 1;
+                               it.WarpZone_findradius_next = wz;
+                               wz = it;
+                               it.WarpZone_findradius_hit = 1;
+                               it.enemy.WarpZone_findradius_dist = '0 0 0'; // we don't want to go through this zone ever again
+                               it.enemy.WarpZone_findradius_hit = 1;
                        }
                        else
                        {
-                               e.warpzone_transform = transform;
-                               e.warpzone_shift = shift;
-                               e.WarpZone_findradius_hit = 1;
+                               it.warpzone_transform = transform;
+                               it.warpzone_shift = shift;
+                               it.WarpZone_findradius_hit = 1;
                        }
                }
-       }
-       for(e = wz; e; e = e.WarpZone_findradius_next)
+    });
+       for(entity e = wz; e; e = e.WarpZone_findradius_next)
        {
-               if(WarpZoneLib_BadEntity(e))
-                       continue;
+               if (WarpZoneLib_BadEntity(e)) continue;
 
-               org0_new = WarpZone_TransformOrigin(e, org);
+               vector org0_new = WarpZone_TransformOrigin(e, org);
                traceline(e.warpzone_targetorigin, org0_new, MOVE_NOMONSTERS, e);
-               org_new = trace_endpos;
+               vector org_new = trace_endpos;
 
-               transform_new = AnglesTransform_Multiply(e.warpzone_transform, transform);
-               shift_new = AnglesTransform_Multiply_GetPostShift(e.warpzone_transform, e.warpzone_shift, transform, shift);
+               vector transform_new = AnglesTransform_Multiply(e.warpzone_transform, transform);
+               vector shift_new = AnglesTransform_Multiply_GetPostShift(e.warpzone_transform, e.warpzone_shift, transform, shift);
                WarpZone_FindRadius_Recurse(
                        org_new,
                        bound(0, rad - vlen(org_new - org0_new), rad - 8),
@@ -662,14 +656,13 @@ void WarpZone_FindRadius_Recurse(vector org, float rad,        vector org0,
                e.enemy.WarpZone_findradius_hit = 0;
        }
 }
-entity WarpZone_FindRadius(vector org, float rad, float needlineofsight)
+entity WarpZone_FindRadius(vector org, float rad, bool needlineofsight)
 {
-       entity e0, e;
+    if (!warpzone_warpzones_exist && !needlineofsight) return findradius(org, rad);
        WarpZone_FindRadius_Recurse(org, rad, org, '0 0 0', '0 0 0', needlineofsight);
-       e0 = findchainfloat(WarpZone_findradius_hit, 1);
-       for(e = e0; e; e = e.chain)
-               e.WarpZone_findradius_hit = 0;
-       return e0;
+       entity list_first = findchainfloat(WarpZone_findradius_hit, 1);
+       FOREACH_LIST(list, chain, true, it.WarpZone_findradius_hit = 0);
+       return list_first;
 }
 
 .entity WarpZone_refsys;
index 47a562fe74226c3c484e3fcc047e357203da23f8..6a78f5320860405d9de73aa018f83b9bd3dffe46 100644 (file)
@@ -20,14 +20,14 @@ const string STR_OBSERVER = "observer";
 #define IS_VEHICLE(v) (v.vehicle_flags & VHF_ISVEHICLE)
 #define IS_TURRET(v) (v.turret_flags & TUR_FLAG_ISTURRET)
 
-// NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, LAMBDA(yourcode));
-// NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, LAMBDA(yourcode));
-// NOTE: FOR_EACH_REALCLIENT deprecated! Use the following instead: FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(yourcode));
+// NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, { code; });
+// NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, { code; });
+// NOTE: FOR_EACH_REALCLIENT deprecated! Use the following instead: FOREACH_CLIENT(IS_REAL_CLIENT(it), { code; });
 
-// NOTE: FOR_EACH_PLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(yourcode));
-// NOTE: FOR_EACH_SPEC deprecated! Use the following instead: FOREACH_CLIENT(IS_SPEC(it), LAMBDA(yourcode));
-// NOTE: FOR_EACH_OBSERVER deprecated! Use the following instead: FOREACH_CLIENT(IS_OBSERVER(it), LAMBDA(yourcode));
-// NOTE: FOR_EACH_REALPLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(yourcode));
+// NOTE: FOR_EACH_PLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it), { code; });
+// NOTE: FOR_EACH_SPEC deprecated! Use the following instead: FOREACH_CLIENT(IS_SPEC(it), { code; });
+// NOTE: FOR_EACH_OBSERVER deprecated! Use the following instead: FOREACH_CLIENT(IS_OBSERVER(it), { code; });
+// NOTE: FOR_EACH_REALPLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { code; });
 
 #define FOREACH_CLIENTSLOT(cond, body) \
        MACRO_BEGIN { \
@@ -41,7 +41,7 @@ const string STR_OBSERVER = "observer";
 
 #define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
 
-// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(yourcode));
+// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, { code; });
 
 #include <common/effects/all.qh>
 #include <common/models/all.qh>
index 982a426068517c811b6b91ad03bb3be4b3e3d3db..0e0121db67aae70f0460bd53679ff0f712618dbf 100644 (file)
@@ -5,9 +5,8 @@
 #include "defs.qh"
 #include "miscfunctions.qh"
 
-
-
 #include "command/common.qh"
+#include <common/state.qh>
 
 .float anticheat_jointime;
 
@@ -66,33 +65,33 @@ void anticheat_physics(entity this)
 
        // div0_evade -> SPECTATORS
        makevectors(this.v_angle);
-       if(this.anticheat_div0_evade_offset == 0)
+       if(CS(this).anticheat_div0_evade_offset == 0)
        {
                f = fabs(anticheat_div0_evade_evasion_delta - floor(anticheat_div0_evade_evasion_delta) - 0.5) * 2; // triangle function
-               this.anticheat_div0_evade_offset = servertime + sys_frametime * (3 * f - 1);
-               this.anticheat_div0_evade_v_angle = this.v_angle;
-               this.anticheat_div0_evade_forward_initial = v_forward;
-               MEAN_ACCUMULATE(this, anticheat_div0_evade, 0, 1);
+               CS(this).anticheat_div0_evade_offset = servertime + sys_frametime * (3 * f - 1);
+               CS(this).anticheat_div0_evade_v_angle = this.v_angle;
+               CS(this).anticheat_div0_evade_forward_initial = v_forward;
+               MEAN_ACCUMULATE(CS(this), anticheat_div0_evade, 0, 1);
        }
        else
        {
-               if(time < this.anticheat_div0_evade_offset)
-                       this.anticheat_div0_evade_v_angle = this.v_angle;
-               MEAN_ACCUMULATE(this, anticheat_div0_evade, 0.5 - 0.5 * (this.anticheat_div0_evade_forward_initial * v_forward), 1);
+               if(time < CS(this).anticheat_div0_evade_offset)
+                       CS(this).anticheat_div0_evade_v_angle = this.v_angle;
+               MEAN_ACCUMULATE(CS(this), anticheat_div0_evade, 0.5 - 0.5 * (CS(this).anticheat_div0_evade_forward_initial * v_forward), 1);
        }
 
-       MEAN_ACCUMULATE(this, anticheat_div0_strafebot_old, movement_oddity(this.movement, this.anticheat_div0_strafebot_movement_prev), 1);
-       this.anticheat_div0_strafebot_movement_prev = this.movement;
+       MEAN_ACCUMULATE(CS(this), anticheat_div0_strafebot_old, movement_oddity(this.movement, CS(this).anticheat_div0_strafebot_movement_prev), 1);
+       CS(this).anticheat_div0_strafebot_movement_prev = this.movement;
 
        // Note: this actually tries to detect snap-aim.
-       if(this.anticheat_div0_strafebot_forward_prev && time > this.anticheat_fixangle_endtime) {
-               float cosangle = this.anticheat_div0_strafebot_forward_prev * v_forward;
+       if(CS(this).anticheat_div0_strafebot_forward_prev && time > CS(this).anticheat_fixangle_endtime) {
+               float cosangle = CS(this).anticheat_div0_strafebot_forward_prev * v_forward;
                float angle = cosangle < -1 ? M_PI : cosangle > 1 ? 0 : acos(cosangle);
                /*
                if (angle >= 10 * M_PI / 180)
-                       printf("SNAP %s: %f for %f, %f since fixangle\n", this.netname, angle * 180 / M_PI, cosangle, time - this.anticheat_fixangle_endtime);
+                       printf("SNAP %s: %f for %f, %f since fixangle\n", this.netname, angle * 180 / M_PI, cosangle, time - CS(this).anticheat_fixangle_endtime);
                */
-               MEAN_ACCUMULATE(this, anticheat_div0_strafebot_new, angle / M_PI, 1);
+               MEAN_ACCUMULATE(CS(this), anticheat_div0_strafebot_new, angle / M_PI, 1);
 
                if (autocvar_slowmo > 0) {
                        // Technically this is a NOP, as the engine should be ensuring
@@ -101,62 +100,63 @@ void anticheat_physics(entity this)
                        float dt = max(0.001, frametime) / autocvar_slowmo;
 
                        float anglespeed = angle / dt;
-                       MEAN_ACCUMULATE(this, anticheat_idle_snapaim_signal, anglespeed, dt);
-                       MEAN_ACCUMULATE(this, anticheat_idle_snapaim_noise, anglespeed, dt);
-                       MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m2, anglespeed, dt);
-                       MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m3, anglespeed, dt);
-                       MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m4, anglespeed, dt);
-                       MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m7, anglespeed, dt);
-                       MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m10, anglespeed, dt);
+                       MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_signal, anglespeed, dt);
+                       MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_noise, anglespeed, dt);
+                       MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m2, anglespeed, dt);
+                       MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m3, anglespeed, dt);
+                       MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m4, anglespeed, dt);
+                       MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m7, anglespeed, dt);
+                       MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m10, anglespeed, dt);
                }
        }
-       this.anticheat_div0_strafebot_forward_prev = v_forward;
+       CS(this).anticheat_div0_strafebot_forward_prev = v_forward;
 
        // generic speedhack detection: correlate anticheat_speedhack_movetime (UPDATED BEFORE THIS) and server time
-       this.anticheat_speedhack_movetime_frac += frametime;
-       f = floor(this.anticheat_speedhack_movetime_frac);
-       this.anticheat_speedhack_movetime_frac -= f;
-       this.anticheat_speedhack_movetime_count += f;
-       this.anticheat_speedhack_movetime = this.anticheat_speedhack_movetime_frac + this.anticheat_speedhack_movetime_count;
-       f = this.anticheat_speedhack_movetime - servertime;
-       if(this.anticheat_speedhack_offset == 0)
-               this.anticheat_speedhack_offset = f;
+       CS(this).anticheat_speedhack_movetime_frac += frametime;
+       f = floor(CS(this).anticheat_speedhack_movetime_frac);
+       CS(this).anticheat_speedhack_movetime_frac -= f;
+       CS(this).anticheat_speedhack_movetime_count += f;
+       CS(this).anticheat_speedhack_movetime = CS(this).anticheat_speedhack_movetime_frac + CS(this).anticheat_speedhack_movetime_count;
+       f = CS(this).anticheat_speedhack_movetime - servertime;
+       if(CS(this).anticheat_speedhack_offset == 0)
+               CS(this).anticheat_speedhack_offset = f;
        else
        {
-               MEAN_ACCUMULATE(this, anticheat_speedhack, max(0, f - this.anticheat_speedhack_offset), 1);
-               this.anticheat_speedhack_offset += (f - this.anticheat_speedhack_offset) * frametime * 0.1;
+               MEAN_ACCUMULATE(CS(this), anticheat_speedhack, max(0, f - CS(this).anticheat_speedhack_offset), 1);
+               CS(this).anticheat_speedhack_offset += (f - CS(this).anticheat_speedhack_offset) * frametime * 0.1;
        }
 
        // new generic speedhack detection
-       if (this.anticheat_speedhack_lasttime > 0) {
-               float dt = servertime - this.anticheat_speedhack_lasttime;
+       if (CS(this).anticheat_speedhack_lasttime > 0) {
+               float dt = servertime - CS(this).anticheat_speedhack_lasttime;
                const float falloff = 0.2;
-               this.anticheat_speedhack_accu *= exp(-dt * falloff);
-               this.anticheat_speedhack_accu += frametime * falloff;
+               CS(this).anticheat_speedhack_accu *= exp(-dt * falloff);
+               CS(this).anticheat_speedhack_accu += frametime * falloff;
                // NOTE: at cl_netfps x, this actually averages not to 1, but to 1/x * falloff / (1 - exp(-1/x * falloff))
                // For 15 netfps (absolute minimum bearable), and 0.2 falloff, this is: 1.0067
-               this.anticheat_speedhack_lasttime = servertime;
-               MEAN_ACCUMULATE(this, anticheat_speedhack_m1, this.anticheat_speedhack_accu, frametime);
-               MEAN_ACCUMULATE(this, anticheat_speedhack_m2, this.anticheat_speedhack_accu, frametime);
-               MEAN_ACCUMULATE(this, anticheat_speedhack_m3, this.anticheat_speedhack_accu, frametime);
-               MEAN_ACCUMULATE(this, anticheat_speedhack_m4, this.anticheat_speedhack_accu, frametime);
-               MEAN_ACCUMULATE(this, anticheat_speedhack_m5, this.anticheat_speedhack_accu, frametime);
+               CS(this).anticheat_speedhack_lasttime = servertime;
+               MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m1, CS(this).anticheat_speedhack_accu, frametime);
+               MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m2, CS(this).anticheat_speedhack_accu, frametime);
+               MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m3, CS(this).anticheat_speedhack_accu, frametime);
+               MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m4, CS(this).anticheat_speedhack_accu, frametime);
+               MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m5, CS(this).anticheat_speedhack_accu, frametime);
        } else {
-               this.anticheat_speedhack_accu = 1;
-               this.anticheat_speedhack_lasttime = servertime;
+               CS(this).anticheat_speedhack_accu = 1;
+               CS(this).anticheat_speedhack_lasttime = servertime;
        }
 }
 
 void anticheat_spectatecopy(entity spectatee)
 {SELFPARAM();
        // div0_evade -> SPECTATORS
-       self.angles = spectatee.anticheat_div0_evade_v_angle;
+       self.angles = CS(spectatee).anticheat_div0_evade_v_angle;
 }
 
 void anticheat_prethink()
-{SELFPARAM();
+{
+    SELFPARAM();
        // div0_evade -> SPECTATORS
-       self.anticheat_div0_evade_offset = 0;
+       CS(this).anticheat_div0_evade_offset = 0;
 }
 
 string anticheat_display(float f, float tmin, float mi, float ma)
@@ -175,47 +175,47 @@ void anticheat_report()
        if(!autocvar_sv_eventlog)
                return;
        // TODO(divVerent): Use xonstat to acquire good thresholds.
-       GameLogEcho(strcat(":anticheat:_time:", ftos(self.playerid), ":", ftos(servertime - self.anticheat_jointime)));
-       GameLogEcho(strcat(":anticheat:speedhack:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack), 240, 0, 9999))); // Actually this one seems broken.
-       GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m1), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m2), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m3), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m4), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m5), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_div0_strafebot_old), 120, 0.15, 0.4)));
-       GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_div0_strafebot_new), 120, 0.25, 0.8)));
-       GameLogEcho(strcat(":anticheat:div0_evade:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_div0_evade), 120, 0.2, 0.5)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_signal) - MEAN_EVALUATE(self, anticheat_idle_snapaim_noise), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_signal), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_noise), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m2), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m3), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m4), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m7), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m10), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:_time:", ftos(self.playerid), ":", ftos(servertime - CS(self).anticheat_jointime)));
+       GameLogEcho(strcat(":anticheat:speedhack:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack), 240, 0, 9999))); // Actually this one seems broken.
+       GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m1), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m2), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m3), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m4), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m5), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_old), 120, 0.15, 0.4)));
+       GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_new), 120, 0.25, 0.8)));
+       GameLogEcho(strcat(":anticheat:div0_evade:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_evade), 120, 0.2, 0.5)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m2), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m3), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m4), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m7), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m10), 120, 0, 9999)));
 }
 
 float anticheat_getvalue(string id)
 {SELFPARAM();
        switch(id) {
-               case "_time": return servertime - self.anticheat_jointime;
-               case "speedhack": return MEAN_EVALUATE(self, anticheat_speedhack);
-               case "speedhack_m1": return MEAN_EVALUATE(self, anticheat_speedhack_m1);
-               case "speedhack_m2": return MEAN_EVALUATE(self, anticheat_speedhack_m2);
-               case "speedhack_m3": return MEAN_EVALUATE(self, anticheat_speedhack_m3);
-               case "speedhack_m4": return MEAN_EVALUATE(self, anticheat_speedhack_m4);
-               case "speedhack_m5": return MEAN_EVALUATE(self, anticheat_speedhack_m5);
-               case "div0_strafebot_old": return MEAN_EVALUATE(self, anticheat_div0_strafebot_old);
-               case "div0_strafebot_new": return MEAN_EVALUATE(self, anticheat_div0_strafebot_new);
-               case "div0_evade": return MEAN_EVALUATE(self, anticheat_div0_evade);
-               case "idle_snapaim": return MEAN_EVALUATE(self, anticheat_idle_snapaim_signal) - MEAN_EVALUATE(self, anticheat_idle_snapaim_noise);
-               case "idle_snapaim_signal": return MEAN_EVALUATE(self, anticheat_idle_snapaim_signal);
-               case "idle_snapaim_noise": return MEAN_EVALUATE(self, anticheat_idle_snapaim_noise);
-               case "idle_snapaim_m2": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m2);
-               case "idle_snapaim_m3": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m3);
-               case "idle_snapaim_m4": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m4);
-               case "idle_snapaim_m7": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m7);
-               case "idle_snapaim_m10": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m10);
+               case "_time": return servertime - CS(self).anticheat_jointime;
+               case "speedhack": return MEAN_EVALUATE(CS(self), anticheat_speedhack);
+               case "speedhack_m1": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m1);
+               case "speedhack_m2": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m2);
+               case "speedhack_m3": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m3);
+               case "speedhack_m4": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m4);
+               case "speedhack_m5": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m5);
+               case "div0_strafebot_old": return MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_old);
+               case "div0_strafebot_new": return MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_new);
+               case "div0_evade": return MEAN_EVALUATE(CS(self), anticheat_div0_evade);
+               case "idle_snapaim": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise);
+               case "idle_snapaim_signal": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal);
+               case "idle_snapaim_noise": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise);
+               case "idle_snapaim_m2": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m2);
+               case "idle_snapaim_m3": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m3);
+               case "idle_snapaim_m4": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m4);
+               case "idle_snapaim_m7": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m7);
+               case "idle_snapaim_m10": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m10);
        }
        return -1;
 }
@@ -225,22 +225,19 @@ void anticheat_startframe()
        anticheat_div0_evade_evasion_delta += frametime * (0.5 + random());
 }
 
-void anticheat_fixangle()
-{SELFPARAM();
-       self.anticheat_fixangle_endtime = servertime + ANTILAG_LATENCY(self) + 0.2;
+void anticheat_fixangle(entity this)
+{
+       CS(this).anticheat_fixangle_endtime = servertime + ANTILAG_LATENCY(this) + 0.2;
 }
 
 void anticheat_endframe()
 {SELFPARAM();
-       FOREACH_CLIENT(true, LAMBDA(
-               if(it.fixangle)
-                       WITH(entity, self, it, anticheat_fixangle());
-       ));
+       FOREACH_CLIENT(it.fixangle, anticheat_fixangle(it));
        anticheat_div0_evade_evasion_delta += frametime * (0.5 + random());
 }
 
 void anticheat_init(entity this)
 {
-       this.anticheat_speedhack_offset = 0;
-       this.anticheat_jointime = servertime;
+       CS(this).anticheat_speedhack_offset = 0;
+       CS(this).anticheat_jointime = servertime;
 }
index 3bb5d251e95c1765ad20d0a6623ae578fbf03160..e1055ac44e95f2f96951d7b535dba9cd77882f3a 100644 (file)
@@ -13,5 +13,5 @@ float anticheat_getvalue(string name);
 void anticheat_startframe();
 void anticheat_endframe();
 
-void anticheat_fixangle();
+void anticheat_fixangle(entity this);
 #endif
index 36734976c4c058e4c0bd0218bef674df624eeb03..02cdc20285470d16ab6d0f5a92a9395c806d2e60 100644 (file)
@@ -1,7 +1,8 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
-    #include "../common/vehicles/all.qh"
+    #include <common/state.qh>
+    #include <common/vehicles/all.qh>
     #include "antilag.qh"
 #endif
 
@@ -22,34 +23,34 @@ void antilag_record(entity e, float t)
     if(e.vehicle)
         antilag_record(e.vehicle, t);
 
-       if(time < e.(antilag_times[e.antilag_index]))
+       if(time < CS(e).antilag_times[CS(e).antilag_index])
                return;
-       e.antilag_index = e.antilag_index + 1;
-       if(e.antilag_index >= ANTILAG_MAX_ORIGINS)
-               e.antilag_index = 0;
-       e.(antilag_times[e.antilag_index]) = t;
-       e.(antilag_origins[e.antilag_index]) = e.origin;
+       CS(e).antilag_index += 1;
+       if(CS(e).antilag_index >= ANTILAG_MAX_ORIGINS)
+               CS(e).antilag_index = 0;
+       CS(e).antilag_times[CS(e).antilag_index] = t;
+       CS(e).antilag_origins[CS(e).antilag_index] = e.origin;
 
-       if(e.antilag_debug)
-               te_spark(antilag_takebackorigin(e, t - e.antilag_debug), '0 0 0', 32);
+       if(CS(e).antilag_debug)
+               te_spark(antilag_takebackorigin(e, t - CS(e).antilag_debug), '0 0 0', 32);
 
 }
 
 // finds the index BEFORE t
 float antilag_find(entity e, float t)
 {
-       for(int i = e.antilag_index; i > 0; --i)
-               if(e.(antilag_times[i]) >= t)
-                       if(e.(antilag_times[i - 1]) < t)
+       for(int i = CS(e).antilag_index; i > 0; --i)
+               if(CS(e).antilag_times[i] >= t)
+                       if(CS(e).antilag_times[i - 1] < t)
                                return i - 1;
 
-       if(e.(antilag_times[0]) >= t)
-               if(e.(antilag_times[ANTILAG_MAX_ORIGINS - 1]) < t)
+       if(CS(e).antilag_times[0] >= t)
+               if(CS(e).antilag_times[ANTILAG_MAX_ORIGINS - 1] < t)
                        return ANTILAG_MAX_ORIGINS - 1;
 
-       for(int i = ANTILAG_MAX_ORIGINS - 1; i > e.antilag_index + 1; --i)
-               if(e.(antilag_times[i]) >= t)
-                       if(e.(antilag_times[i - 1]) < t)
+       for(int i = ANTILAG_MAX_ORIGINS - 1; i > CS(e).antilag_index + 1; --i)
+               if(CS(e).antilag_times[i] >= t)
+                       if(CS(e).antilag_times[i - 1] < t)
                                return i - 1;
 
        // if we get here, t is sandwiched nowhere, so let's assume it's in the present
@@ -62,8 +63,8 @@ vector antilag_takebackorigin(entity e, float t)
        if (i0 < 0)
        {
                // IN THE PRESENT
-               if(e.antilag_takenback)
-                       return e.antilag_saved_origin;
+               if(CS(e).antilag_takenback)
+                       return CS(e).antilag_saved_origin;
                else
                        return e.origin;
        }
@@ -71,7 +72,7 @@ vector antilag_takebackorigin(entity e, float t)
        if (i1 >= ANTILAG_MAX_ORIGINS)
                i1 = 0;
 
-       return lerpv(e.(antilag_times[i0]), e.(antilag_origins[i0]), e.(antilag_times[i1]), e.(antilag_origins[i1]), t);
+       return lerpv(CS(e).antilag_times[i0], CS(e).antilag_origins[i0], CS(e).antilag_times[i1], CS(e).antilag_origins[i1], t);
 }
 
 vector antilag_takebackavgvelocity(entity e, float t0, float t1)
@@ -94,12 +95,12 @@ void antilag_takeback(entity e, float t)
        if(e.vehicle)
                antilag_takeback(e.vehicle, t);
 
-       if(!e.antilag_takenback)
-               e.antilag_saved_origin = e.origin;
+       if(!CS(e).antilag_takenback)
+               CS(e).antilag_saved_origin = e.origin;
 
        vector org = antilag_takebackorigin(e, t);
        setorigin(e, org);
-       e.antilag_takenback = true;
+       CS(e).antilag_takenback = true;
 }
 
 void antilag_restore(entity e)
@@ -110,11 +111,11 @@ void antilag_restore(entity e)
        if(e.vehicle)
                antilag_restore(e.vehicle);
 
-       if(!e.antilag_takenback)
+       if(!CS(e).antilag_takenback)
                return;
 
-       setorigin(e, e.antilag_saved_origin);
-       e.antilag_takenback = false;
+       setorigin(e, CS(e).antilag_saved_origin);
+       CS(e).antilag_takenback = false;
 }
 
 void antilag_clear(entity e)
@@ -122,8 +123,8 @@ void antilag_clear(entity e)
        antilag_restore(e);
        for (int i = 0; i < ANTILAG_MAX_ORIGINS; ++i)
        {
-               e.(antilag_times[i]) = -2342;
-               e.(antilag_origins[i]) = e.origin;
+               CS(e).antilag_times[i] = -2342;
+               CS(e).antilag_origins[i] = e.origin;
        }
-       e.antilag_index = ANTILAG_MAX_ORIGINS - 1; // next one is 0
+       CS(e).antilag_index = ANTILAG_MAX_ORIGINS - 1; // next one is 0
 }
index f2e075c4da2ceba2eca0ece4204f166868723a5a..6d5a4641a77e5dfec786c35c6cc12b75c1ef597b 100644 (file)
@@ -23,7 +23,7 @@
 #include "bot/navigation.qh"
 
 #include "../common/ent_cs.qh"
-#include "../common/state.qh"
+#include <common/state.qh>
 
 #include "../common/triggers/teleporters.qh"
 
@@ -168,7 +168,10 @@ void PutObserverInServer()
     bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver);
        PlayerState_detach(this);
 
-       if (IS_PLAYER(this)) Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
+       if (IS_PLAYER(this) && this.health >= 1) {
+        // despawn effect
+               Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
+    }
 
     {
         entity spot = SelectSpawnPoint(true);
@@ -187,6 +190,7 @@ void PutObserverInServer()
         }
         // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
         // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
+        setmodel(this, MDL_Null);
         setsize(this, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL));
         this.view_ofs = '0 0 0';
     }
@@ -206,8 +210,13 @@ void PutObserverInServer()
 
        WaypointSprite_PlayerDead(this);
 
-       if (!mutator_returnvalue)  // mutator prevents resetting teams
+       if (mutator_returnvalue) {
+           // mutator prevents resetting teams+score
+       } else {
                this.team = -1;  // move this as it is needed to log the player spectating in eventlog
+        this.frags = FRAGS_SPECTATOR;
+        PlayerScore_Clear(this);  // clear scores when needed
+    }
 
        if (this.killcount != FRAGS_SPECTATOR)
        {
@@ -222,12 +231,9 @@ void PutObserverInServer()
                        this.just_joined = false;
        }
 
-       PlayerScore_Clear(this); // clear scores when needed
-
        accuracy_resend(this);
 
        this.spectatortime = time;
-    this.frags = FRAGS_SPECTATOR;
        this.bot_attack = false;
     this.hud = HUD_NORMAL;
        this.classname = STR_OBSERVER;
@@ -269,9 +275,6 @@ void PutObserverInServer()
 
        this.items = 0;
        this.weapons = '0 0 0';
-       this.model = "";
-       FixPlayermodel(this);
-       setmodel(this, MDL_Null);
        this.drawonlytoclient = this;
 
        this.weaponname = "";
@@ -1525,66 +1528,64 @@ spectate mode routines
 
 void SpectateCopy(entity this, entity spectatee)
 {
-       MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
-       self.armortype = spectatee.armortype;
-       self.armorvalue = spectatee.armorvalue;
-       self.ammo_cells = spectatee.ammo_cells;
-       self.ammo_plasma = spectatee.ammo_plasma;
-       self.ammo_shells = spectatee.ammo_shells;
-       self.ammo_nails = spectatee.ammo_nails;
-       self.ammo_rockets = spectatee.ammo_rockets;
-       self.ammo_fuel = spectatee.ammo_fuel;
-       self.clip_load = spectatee.clip_load;
-       self.clip_size = spectatee.clip_size;
-       self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
-       self.health = spectatee.health;
-       self.impulse = 0;
-       self.items = spectatee.items;
-       self.last_pickup = spectatee.last_pickup;
-       self.hit_time = spectatee.hit_time;
-       self.strength_finished = spectatee.strength_finished;
-       self.invincible_finished = spectatee.invincible_finished;
-       self.pressedkeys = spectatee.pressedkeys;
-       self.weapons = spectatee.weapons;
-       PS(self).m_switchweapon = PS(spectatee).m_switchweapon;
-       PS(self).m_switchingweapon = PS(spectatee).m_switchingweapon;
-       PS(self).m_weapon = PS(spectatee).m_weapon;
-       self.vortex_charge = spectatee.vortex_charge;
-       self.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
-       self.hagar_load = spectatee.hagar_load;
-       self.arc_heat_percent = spectatee.arc_heat_percent;
-       self.minelayer_mines = spectatee.minelayer_mines;
-       self.punchangle = spectatee.punchangle;
-       self.view_ofs = spectatee.view_ofs;
-       self.velocity = spectatee.velocity;
-       self.dmg_take = spectatee.dmg_take;
-       self.dmg_save = spectatee.dmg_save;
-       self.dmg_inflictor = spectatee.dmg_inflictor;
-       self.v_angle = spectatee.v_angle;
-       self.angles = spectatee.v_angle;
-       STAT(FROZEN, self) = STAT(FROZEN, spectatee);
-       self.revive_progress = spectatee.revive_progress;
-       if(!PHYS_INPUT_BUTTON_USE(self))
-               self.fixangle = true;
-       setorigin(self, spectatee.origin);
-       setsize(self, spectatee.mins, spectatee.maxs);
+       MUTATOR_CALLHOOK(SpectateCopy, spectatee, this);
+       PS(this) = PS(spectatee);
+       this.armortype = spectatee.armortype;
+       this.armorvalue = spectatee.armorvalue;
+       this.ammo_cells = spectatee.ammo_cells;
+       this.ammo_plasma = spectatee.ammo_plasma;
+       this.ammo_shells = spectatee.ammo_shells;
+       this.ammo_nails = spectatee.ammo_nails;
+       this.ammo_rockets = spectatee.ammo_rockets;
+       this.ammo_fuel = spectatee.ammo_fuel;
+       this.clip_load = spectatee.clip_load;
+       this.clip_size = spectatee.clip_size;
+       this.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
+       this.health = spectatee.health;
+       this.impulse = 0;
+       this.items = spectatee.items;
+       this.last_pickup = spectatee.last_pickup;
+       this.hit_time = spectatee.hit_time;
+       this.strength_finished = spectatee.strength_finished;
+       this.invincible_finished = spectatee.invincible_finished;
+       this.pressedkeys = spectatee.pressedkeys;
+       this.weapons = spectatee.weapons;
+       this.vortex_charge = spectatee.vortex_charge;
+       this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
+       this.hagar_load = spectatee.hagar_load;
+       this.arc_heat_percent = spectatee.arc_heat_percent;
+       this.minelayer_mines = spectatee.minelayer_mines;
+       this.punchangle = spectatee.punchangle;
+       this.view_ofs = spectatee.view_ofs;
+       this.velocity = spectatee.velocity;
+       this.dmg_take = spectatee.dmg_take;
+       this.dmg_save = spectatee.dmg_save;
+       this.dmg_inflictor = spectatee.dmg_inflictor;
+       this.v_angle = spectatee.v_angle;
+       this.angles = spectatee.v_angle;
+       STAT(FROZEN, this) = STAT(FROZEN, spectatee);
+       this.revive_progress = spectatee.revive_progress;
+       if(!PHYS_INPUT_BUTTON_USE(this))
+               this.fixangle = true;
+       setorigin(this, spectatee.origin);
+       setsize(this, spectatee.mins, spectatee.maxs);
        SetZoomState(spectatee.zoomstate);
 
     anticheat_spectatecopy(spectatee);
-       self.hud = spectatee.hud;
+       this.hud = spectatee.hud;
        if(spectatee.vehicle)
     {
-        self.fixangle = false;
-        //self.velocity = spectatee.vehicle.velocity;
-        self.vehicle_health = spectatee.vehicle_health;
-        self.vehicle_shield = spectatee.vehicle_shield;
-        self.vehicle_energy = spectatee.vehicle_energy;
-        self.vehicle_ammo1 = spectatee.vehicle_ammo1;
-        self.vehicle_ammo2 = spectatee.vehicle_ammo2;
-        self.vehicle_reload1 = spectatee.vehicle_reload1;
-        self.vehicle_reload2 = spectatee.vehicle_reload2;
-
-        msg_entity = self;
+        this.fixangle = false;
+        //this.velocity = spectatee.vehicle.velocity;
+        this.vehicle_health = spectatee.vehicle_health;
+        this.vehicle_shield = spectatee.vehicle_shield;
+        this.vehicle_energy = spectatee.vehicle_energy;
+        this.vehicle_ammo1 = spectatee.vehicle_ammo1;
+        this.vehicle_ammo2 = spectatee.vehicle_ammo2;
+        this.vehicle_reload1 = spectatee.vehicle_reload1;
+        this.vehicle_reload2 = spectatee.vehicle_reload2;
+
+        msg_entity = this;
 
         WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
             WriteAngle(MSG_ONE,  spectatee.v_angle.x);
@@ -1592,9 +1593,9 @@ void SpectateCopy(entity this, entity spectatee)
             WriteAngle(MSG_ONE,  spectatee.v_angle.z);
 
         //WriteByte (MSG_ONE, SVC_SETVIEW);
-        //    WriteEntity(MSG_ONE, self);
+        //    WriteEntity(MSG_ONE, this);
         //makevectors(spectatee.v_angle);
-        //setorigin(self, spectatee.origin - v_forward * 400 + v_up * 300);*/
+        //setorigin(this, spectatee.origin - v_forward * 400 + v_up * 300);*/
     }
 }
 
index 5e74d18bbc4f9d25882b9b311439f76ebf4aabe2..57e96abf92d6a45c114e4001762df3bb26f63daa 100644 (file)
@@ -3,17 +3,45 @@
 
 int autocvar_g_ca_point_limit;
 int autocvar_g_ca_point_leadlimit;
+float autocvar_g_ca_round_timelimit;
 bool autocvar_g_ca_team_spawns;
+int autocvar_g_ca_teams;
+int autocvar_g_ca_teams_override;
+float autocvar_g_ca_warmup;
 
-void ca_Initialize();
+
+int ca_teams;
+bool allowed_to_spawn;
+
+const int ST_CA_ROUNDS = 1;
+
+bool CA_CheckTeams();
+bool CA_CheckWinner();
+void CA_RoundStart();
+bool ca_isEliminated(entity e);
 
 REGISTER_MUTATOR(ca, false)
 {
        MUTATOR_ONADD
        {
-               if (time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               ca_Initialize();
+               // game loads at time 1
+               if (time > 1) error("This is a game type and it cannot be added at runtime.");
+
+               allowed_to_spawn = true;
+
+               ca_teams = autocvar_g_ca_teams_override;
+               if (ca_teams < 2) ca_teams = autocvar_g_ca_teams;
+               ca_teams = bound(2, ca_teams, 4);
+               ret_float = ca_teams;
+
+        ScoreRules_basics(ca_teams, SFL_SORT_PRIO_PRIMARY, 0, true);
+        ScoreInfo_SetLabel_TeamScore(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
+        ScoreRules_basics_end();
+
+               round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart);
+               round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
+
+               EliminatedPlayers_Init(ca_isEliminated);
 
                ActivateTeamplay();
                SetLimits(autocvar_g_ca_point_limit, autocvar_g_ca_point_leadlimit, -1, -1);
@@ -37,22 +65,7 @@ REGISTER_MUTATOR(ca, false)
 
 #ifdef IMPLEMENTATION
 float autocvar_g_ca_damage2score_multiplier;
-float autocvar_g_ca_round_timelimit;
 bool autocvar_g_ca_spectate_enemies;
-int autocvar_g_ca_teams;
-int autocvar_g_ca_teams_override;
-float autocvar_g_ca_warmup;
-
-float ca_teams;
-float allowed_to_spawn;
-
-const float ST_CA_ROUNDS = 1;
-void ca_ScoreRules(float teams)
-{
-       ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true);
-       ScoreInfo_SetLabel_TeamScore(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
-       ScoreRules_basics_end();
-}
 
 void CA_count_alive_players()
 {
@@ -140,10 +153,7 @@ float CA_CheckWinner()
 
 void CA_RoundStart()
 {
-       if(warmup_stage)
-               allowed_to_spawn = true;
-       else
-               allowed_to_spawn = false;
+    allowed_to_spawn = boolean(warmup_stage);
 }
 
 bool CA_CheckTeams()
@@ -188,7 +198,7 @@ bool ca_isEliminated(entity e)
 /** Returns next available player to spectate if g_ca_spectate_enemies == 0 */
 entity CA_SpectateNext(entity player, entity start)
 {
-    if (SAME_TEAM(start, player)) return start;
+       if (SAME_TEAM(start, player)) return start;
        // continue from current player
        for (entity e = start; (e = find(e, classname, STR_PLAYER)); )
        {
@@ -204,60 +214,57 @@ entity CA_SpectateNext(entity player, entity start)
 
 
 MUTATOR_HOOKFUNCTION(ca, PlayerSpawn)
-{SELFPARAM();
-       self.caplayer = 1;
-       if(!warmup_stage)
+{
+    SELFPARAM();
+       this.caplayer = 1;
+       if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
-       return 1;
 }
 
 MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
-{SELFPARAM();
-       if(!allowed_to_spawn)
-       if(IS_PLAYER(self)) // this is true even when player is trying to join
+{
+    SELFPARAM();
+       if (!allowed_to_spawn && IS_PLAYER(this)) // this is true even when player is trying to join
        {
-               self.classname = STR_OBSERVER;
-               if(self.jointime != time) //not when connecting
-               if(!self.caplayer)
+               this.classname = STR_OBSERVER;
+               if (this.jointime != time && !this.caplayer) // not when connecting
                {
-                       self.caplayer = 0.5;
-                       if(IS_REAL_CLIENT(self))
-                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_JOIN_LATE);
+                       this.caplayer = 0.5;
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CA_JOIN_LATE);
                }
        }
-       return 1;
 }
 
 MUTATOR_HOOKFUNCTION(ca, reset_map_players)
-{SELFPARAM();
-       FOREACH_CLIENT(true, LAMBDA(
-               setself(it);
-               self.killcount = 0;
-               if(!self.caplayer && IS_BOT_CLIENT(self))
+{
+       FOREACH_CLIENT(true, {
+               it.killcount = 0;
+               if (!it.caplayer && IS_BOT_CLIENT(it))
                {
-                       self.team = -1;
-                       self.caplayer = 1;
+                       it.team = -1;
+                       it.caplayer = 1;
                }
-               if(self.caplayer)
+               if (it.caplayer)
                {
-                       self.classname = STR_PLAYER;
-                       self.caplayer = 1;
-                       PutClientInServer();
+                       it.classname = STR_PLAYER;
+                       it.caplayer = 1;
+                       WITH(entity, self, it, PutClientInServer());
                }
-       ));
-       return 1;
+       });
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(ca, ClientConnect)
-{SELFPARAM();
-       self.classname = STR_OBSERVER;
-       return 1;
+{
+    SELFPARAM();
+       this.classname = STR_OBSERVER;
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(ca, reset_map_global)
 {
        allowed_to_spawn = true;
-       return 1;
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(ca, GetTeamCount, CBC_ORDER_EXCLUSIVE)
@@ -267,26 +274,27 @@ MUTATOR_HOOKFUNCTION(ca, GetTeamCount, CBC_ORDER_EXCLUSIVE)
 }
 
 entity ca_LastPlayerForTeam()
-{SELFPARAM();
-       entity last_pl = world;
-       FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
-               if(!IS_DEAD(it))
-               if(SAME_TEAM(self, it))
-               if(!last_pl)
+{
+    SELFPARAM();
+       entity last_pl = NULL;
+       FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
+               if (!IS_DEAD(it))
+               if (SAME_TEAM(this, it))
+               if (!last_pl)
                        last_pl = it;
                else
-                       return world;
-       ));
+                       return NULL;
+       });
        return last_pl;
 }
 
 void ca_LastPlayerForTeam_Notify()
 {
-       if(round_handler_IsActive())
-       if(round_handler_IsRoundStarted())
+       if (round_handler_IsActive())
+       if (round_handler_IsRoundStarted())
        {
                entity pl = ca_LastPlayerForTeam();
-               if(pl)
+               if (pl)
                        Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
        }
 }
@@ -294,16 +302,17 @@ void ca_LastPlayerForTeam_Notify()
 MUTATOR_HOOKFUNCTION(ca, PlayerDies)
 {
        ca_LastPlayerForTeam_Notify();
-       if(!allowed_to_spawn)
+       if (!allowed_to_spawn)
                frag_target.respawn_flags =  RESPAWN_SILENT;
-       if(!warmup_stage)
+       if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
        return 1;
 }
 
 MUTATOR_HOOKFUNCTION(ca, ClientDisconnect)
-{SELFPARAM();
-       if(self.caplayer == 1)
+{
+    SELFPARAM();
+       if (this.caplayer == 1)
                ca_LastPlayerForTeam_Notify();
        return 1;
 }
@@ -314,16 +323,17 @@ MUTATOR_HOOKFUNCTION(ca, ForbidPlayerScore_Clear)
 }
 
 MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver)
-{SELFPARAM();
-       if(self.caplayer == 1)
+{
+    SELFPARAM();
+       if (this.caplayer == 1)
                ca_LastPlayerForTeam_Notify();
-       if(self.killindicator_teamchange == -2)
-               self.caplayer = 0;
-       if(self.caplayer)
-               self.frags = FRAGS_LMS_LOSER;
-       if(!warmup_stage)
+       if (this.killindicator_teamchange == -2)
+               this.caplayer = 0;
+       if (this.caplayer)
+               this.frags = FRAGS_LMS_LOSER;
+       if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
-       return true;
+       return true;  // prevent team reset
 }
 
 MUTATOR_HOOKFUNCTION(ca, ForbidThrowCurrentWeapon)
@@ -339,7 +349,7 @@ MUTATOR_HOOKFUNCTION(ca, GiveFragsForKill, CBC_ORDER_FIRST)
 
 MUTATOR_HOOKFUNCTION(ca, SetStartItems)
 {
-       start_items &= ~IT_UNLIMITED_AMMO;
+       start_items       &= ~IT_UNLIMITED_AMMO;
        start_health       = warmup_start_health       = cvar("g_lms_start_health");
        start_armorvalue   = warmup_start_armorvalue   = cvar("g_lms_start_armor");
        start_ammo_shells  = warmup_start_ammo_shells  = cvar("g_lms_start_ammo_shells");
@@ -354,9 +364,9 @@ MUTATOR_HOOKFUNCTION(ca, SetStartItems)
 
 MUTATOR_HOOKFUNCTION(ca, PlayerDamage_Calculate)
 {
-       if(IS_PLAYER(frag_target))
-       if(!IS_DEAD(frag_target))
-       if(frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
+       if (IS_PLAYER(frag_target))
+       if (!IS_DEAD(frag_target))
+       if (frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
                frag_damage = 0;
 
        frag_mirrordamage = 0;
@@ -365,12 +375,13 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDamage_Calculate)
 }
 
 MUTATOR_HOOKFUNCTION(ca, FilterItem)
-{SELFPARAM();
-       if(autocvar_g_powerups <= 0)
-       if(self.flags & FL_POWERUP)
+{
+    SELFPARAM();
+       if (autocvar_g_powerups <= 0)
+       if (this.flags & FL_POWERUP)
                return true;
 
-       if(autocvar_g_pickup_items <= 0)
+       if (autocvar_g_pickup_items <= 0)
                return true;
 
        return false;
@@ -380,7 +391,7 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDamage_SplitHealthArmor)
 {
        float excess = max(0, frag_damage - damage_take - damage_save);
 
-       if(frag_target != frag_attacker && IS_PLAYER(frag_attacker))
+       if (frag_target != frag_attacker && IS_PLAYER(frag_attacker))
                PlayerTeamScore_Add(frag_attacker, SP_SCORE, ST_SCORE, (frag_damage - excess) * autocvar_g_ca_damage2score_multiplier);
 
        return false;
@@ -400,35 +411,37 @@ MUTATOR_HOOKFUNCTION(ca, Scores_CountFragsRemaining)
 
 MUTATOR_HOOKFUNCTION(ca, SpectateSet)
 {
-       if(!autocvar_g_ca_spectate_enemies && self.caplayer)
-       if(DIFF_TEAM(spec_player, self))
+    SELFPARAM();
+       if (!autocvar_g_ca_spectate_enemies && this.caplayer)
+       if (DIFF_TEAM(spec_player, this))
                return true;
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ca, SpectateNext)
-{SELFPARAM();
-       if(!autocvar_g_ca_spectate_enemies && self.caplayer)
+{
+    SELFPARAM();
+       if (!autocvar_g_ca_spectate_enemies && this.caplayer)
        {
-               spec_player = CA_SpectateNext(self, spec_player);
+               spec_player = CA_SpectateNext(this, spec_player);
                return true;
        }
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
-{SELFPARAM();
-       if(!autocvar_g_ca_spectate_enemies && self.caplayer)
+{
+    SELFPARAM();
+       if (!autocvar_g_ca_spectate_enemies && this.caplayer)
        {
                do { spec_player = spec_player.chain; }
-               while(spec_player && DIFF_TEAM(spec_player, self));
+               while(spec_player && DIFF_TEAM(spec_player, this));
 
                if (!spec_player)
                {
-                       spec_player = spec_first;
-                       while(spec_player && DIFF_TEAM(spec_player, self))
-                               spec_player = spec_player.chain;
-                       if(spec_player == self.enemy)
+                       for (spec_player = spec_first; spec_player && DIFF_TEAM(spec_player, this); spec_player = spec_player.chain);
+
+                       if (spec_player == this.enemy)
                                return MUT_SPECPREV_RETURN;
                }
        }
@@ -438,22 +451,22 @@ MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
 
 MUTATOR_HOOKFUNCTION(ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
 {
-       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
-               if(IS_PLAYER(it) || it.caplayer == 1)
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), {
+               if (IS_PLAYER(it) || it.caplayer == 1)
                        ++bot_activerealplayers;
                ++bot_realplayers;
-       ));
-
+       });
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate)
 {
-       if(self.caplayer)
+    SELFPARAM();
+       if (this.caplayer)
        {
                // they're going to spec, we can do other checks
-               if(autocvar_sv_spectate && (IS_SPEC(self) || IS_OBSERVER(self)))
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_LEAVE);
+               if (autocvar_sv_spectate && (IS_SPEC(this) || IS_OBSERVER(this)))
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CA_LEAVE);
                return MUT_SPECCMD_FORCE;
        }
 
@@ -468,34 +481,13 @@ MUTATOR_HOOKFUNCTION(ca, WantWeapon)
 
 MUTATOR_HOOKFUNCTION(ca, GetPlayerStatus)
 {
-       if(set_player.caplayer == 1)
-               return true;
-       return false;
+       return set_player.caplayer == 1;
 }
 
 MUTATOR_HOOKFUNCTION(ca, SetWeaponArena)
 {
        // most weapons arena
-       if(ret_string == "0" || ret_string == "")
-               ret_string = "most";
-       return false;
-}
-
-void ca_Initialize()
-{
-       allowed_to_spawn = true;
-
-       ca_teams = autocvar_g_ca_teams_override;
-       if(ca_teams < 2)
-               ca_teams = autocvar_g_ca_teams;
-       ca_teams = bound(2, ca_teams, 4);
-       ret_float = ca_teams;
-       ca_ScoreRules(ca_teams);
-
-       round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart);
-       round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
-
-       EliminatedPlayers_Init(ca_isEliminated);
+       if (ret_string == "0" || ret_string == "") ret_string = "most";
 }
 
 #endif
index 77f6b6ca80ee20e22cc19c19a208c1eff2c87514..cbca46300258e03725240f7a6fdaf2941620228d 100644 (file)
@@ -172,8 +172,6 @@ MUTATOR_HOOKFUNCTION(lms, PutClientInServer)
                self.classname = STR_OBSERVER;
                Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_NOLIVES);
        }
-
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(lms, PlayerDies)
@@ -204,9 +202,10 @@ MUTATOR_HOOKFUNCTION(lms, ClientDisconnect)
 }
 
 MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver)
-{SELFPARAM();
-       lms_RemovePlayer(self);
-       return false;
+{
+    SELFPARAM();
+       lms_RemovePlayer(this);
+       return true;  // prevent team reset
 }
 
 MUTATOR_HOOKFUNCTION(lms, ClientConnect)
index 1b15654e4a8dceba366ab6730a7a8b4c6ba90f2f..7a06615bf34111960753aa2d0a24ad1163cf5265 100644 (file)
@@ -1,4 +1,6 @@
-#define DEBUGPATHING
+#ifndef DEBUGPATHING
+       #define DEBUGPATHING 0
+#endif
 
 #include "costs.qc"
 #include "expandnode.qc"
@@ -6,6 +8,6 @@
 #include "movenode.qc"
 #include "path_waypoint.qc"
 #include "utility.qc"
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
        #include "debug.qc"
 #endif
index c78fc9320d771ec58357013d9920ea646dacd082..f2534805764968c5e2ba2ba215a9f2372274fd56 100644 (file)
@@ -26,13 +26,12 @@ void dumpnode(entity n)
     n.nextthink    = time;
 }
 
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
 void pathlib_showpath(entity start);
 void pathlib_showpath2(entity path);
+void pathlib_showsquare(vector where,float goodsquare,float _lifetime);
 #endif
 
-void pathlib_showsquare(vector where,float goodsquare,float _lifetime);
-void pathlib_showsquare2(entity node ,vector ncolor,float align);
 
 entity pathlib_mknode(vector where,entity parent)
 {
@@ -60,8 +59,9 @@ entity pathlib_mknode(vector where,entity parent)
 
     setorigin(node, where);
     node.medium = pointcontents(where);
+#if DEBUGPATHING
     pathlib_showsquare(where, 1 ,15);
-
+#endif
     ++pathlib_made_cnt;
     ++pathlib_open_cnt;
 
@@ -157,7 +157,9 @@ float pathlib_makenode_adaptive(entity parent,vector start, vector to, vector go
         if (!tile_check(where))
         {
             LOG_TRACE("tile_check fail\n");
+#if DEBUGPATHING
             pathlib_showsquare(where, 0 ,30);
+#endif
             return 0;
         }
 
@@ -545,7 +547,7 @@ entity pathlib_astar(vector from,vector to)
             ctime = gettime(GETTIME_REALTIME) - ctime;
 
 
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
             pathlib_showpath2(start);
 
             LOG_TRACE("Time used -      pathfinding: ", ftos(ptime),"\n");
index 765fe2a7f201b6bfa6b1e1da7e70c0cac3284d31..5c331d4b404fc035ba83bbb14497e4b952e347b7 100644 (file)
@@ -13,7 +13,7 @@ const vector PLIB_FORWARD = '0 1 0';
 const vector PLIB_RIGHT = '1 0 0';
 //#define PLIB_LEFT    '-1 0 0'
 
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
 void pathlib_showpath(entity start);
 void pathlib_showpath2(entity path);
 #endif
index 3e3b441bffb634f2f8d38f66a27283e40f7dac9f..e924805fd9a7e749eb4929c1659722aefa2d29cc 100644 (file)
@@ -69,8 +69,8 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        // now move the shotorg forward as much as requested if possible
        if(antilag)
        {
-               if(ent.antilag_debug)
-                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent, ent.antilag_debug);
+               if(CS(ent).antilag_debug)
+                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent, CS(ent).antilag_debug);
                else
                        tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
        }
@@ -227,8 +227,8 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
        o = self;
        while (1)
        {
-               if(self.antilag_debug)
-                       WarpZone_traceline_antilag (self, start, end, false, o, self.antilag_debug);
+               if(CS(self).antilag_debug)
+                       WarpZone_traceline_antilag (self, start, end, false, o, CS(self).antilag_debug);
                else
                        WarpZone_traceline_antilag (self, start, end, false, o, ANTILAG_LATENCY(self));
                if(o && WarpZone_trace_firstzone)