]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into martin-t/uncrustify
authorMartin Taibr <taibr.martin@gmail.com>
Sat, 23 Sep 2017 16:03:48 +0000 (18:03 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Sat, 23 Sep 2017 16:03:48 +0000 (18:03 +0200)
83 files changed:
qcsrc/client/announcer.qc
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/hud/panel/modicons.qc
qcsrc/client/hud/panel/physics.qc
qcsrc/client/hud/panel/score.qc
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/miscfunctions.qh
qcsrc/client/view.qc
qcsrc/common/command/rpn.qc
qcsrc/common/effects/effectinfo.qc
qcsrc/common/effects/qc/globalsound.qc
qcsrc/common/effects/qc/globalsound.qh
qcsrc/common/ent_cs.qc
qcsrc/common/gamemodes/sv_rules.qh
qcsrc/common/mapinfo.qc
qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/net_notice.qc
qcsrc/common/notifications/all.qc
qcsrc/common/notifications/all.qh
qcsrc/common/physics/player.qc
qcsrc/common/sounds/sound.qh
qcsrc/common/triggers/func/conveyor.qc
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/door_secret.qc
qcsrc/common/triggers/func/pointparticles.qc
qcsrc/common/triggers/misc/laser.qc
qcsrc/common/triggers/misc/teleport_dest.qc
qcsrc/common/triggers/platforms.qc
qcsrc/common/triggers/target/speaker.qc
qcsrc/common/triggers/trigger/gravity.qc
qcsrc/common/triggers/trigger/impulse.qc
qcsrc/common/triggers/trigger/multivibrator.qc
qcsrc/common/triggers/triggers.qh
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/util.qc
qcsrc/common/viewloc.qc
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/config.qh
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/lib/arraylist.qh
qcsrc/lib/compiler.qh
qcsrc/lib/intrusivelist.qh
qcsrc/lib/iter.qh
qcsrc/lib/json.qc
qcsrc/lib/linkedlist.qh
qcsrc/lib/log.qh
qcsrc/lib/math.qh
qcsrc/lib/misc.qh
qcsrc/lib/net.qh
qcsrc/lib/noise.qh
qcsrc/lib/oo.qh
qcsrc/lib/registry.qh
qcsrc/lib/sort.qh
qcsrc/lib/stats.qh
qcsrc/lib/test.qh
qcsrc/lib/vector.qh
qcsrc/lib/warpzone/mathlib.qc
qcsrc/lib/warpzone/server.qc
qcsrc/lib/yenc.qh
qcsrc/menu/xonotic/keybinder.qc
qcsrc/menu/xonotic/slider_picmip.qc
qcsrc/server/bot/default/aim.qc
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/cheats.qc
qcsrc/server/g_damage.qc
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/scores.qc
qcsrc/server/spawnpoints.qc
qcsrc/server/utils.qh
qcsrc/tools/unc-macro-fix.py [new file with mode: 0755]
qcsrc/tools/uncrustify-unmodified.py [new file with mode: 0755]
qcsrc/uncrustify.cfg

index 62b732bec25034e773801113d86aa9f268bfcbf4..87c8dcc4ea8a41aae43dfdf86d53d239e0d79a9c 100644 (file)
@@ -115,7 +115,7 @@ void Announcer_Gamestart()
        previous_game_starttime = startTime;
 }
 
-#define ANNOUNCER_CHECKMINUTE(minute) MACRO_BEGIN \
+#define ANNOUNCER_CHECKMINUTE(minute) MACRO_BEGIN \
        if(announcer_##minute##min) { \
                if(timeleft > minute * 60) \
                        announcer_##minute##min = false; \
@@ -125,7 +125,7 @@ void Announcer_Gamestart()
                        Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_##minute); \
                } \
        } \
-MACRO_END
+MACRO_END
 
 void Announcer_Time()
 {
index 6499a683e8f4c2cf198be39cb0bee2c9eb9e9a3f..d6effcd84389cee3666ac732bf96278f286ad4fc 100644 (file)
@@ -345,10 +345,10 @@ void CSQCPlayer_FallbackFrame_PostUpdate(entity this, bool isnew)
        // player "pops in"
        if(isnew)
        {
-#define FIX_FRAMETIME(f,ft) MACRO_BEGIN {                                                                                                                                                      \
+#define FIX_FRAMETIME(f,ft) MACRO_BEGIN                                                                                                                                                        \
                if(IS_DEAD_FRAME(this.f) && this.ft != 0 && this.death_time != 0)                                                                                       \
                        this.ft = this.death_time;                                                                                                                                                              \
-MACRO_END
+MACRO_END
                FIX_FRAMETIME(frame, frame1time);
                FIX_FRAMETIME(frame2, frame2time);
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
index d070dce380d3b4877f5ac6457a9993a388717957..4f0ef20e91125a6ebec96ba1bb50a03c0365960b 100644 (file)
@@ -25,7 +25,7 @@ REGISTER_REGISTRY(hud_panels)
 #define HUD_PANEL(NAME) HUD_PANEL_##NAME
 
 // draw the background/borders
-#define HUD_Panel_DrawBg() MACRO_BEGIN \
+#define HUD_Panel_DrawBg() MACRO_BEGIN \
        if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \
                draw_BorderPicture( \
                        HUD_Shift(panel_pos - '1 1 0' * panel_bg_border), \
@@ -34,7 +34,7 @@ REGISTER_REGISTRY(hud_panels)
                        panel_bg_color, panel_bg_alpha, \
                        HUD_Scale('1 1 0' * BORDER_MULTIPLIER * panel_bg_border) \
                ); \
-MACRO_END
+MACRO_END
 
 int panel_order[hud_panels_MAX];
 string hud_panelorder_prev;
@@ -242,7 +242,7 @@ REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    PANEL_CONFIG_NO
 
 // Get value for panel.current_panel_bg: if "" fetch default, else use panel_bg_str
 // comment on last line of macro: // we probably want to see a background in config mode at all times...
-#define HUD_Panel_GetBg() MACRO_BEGIN                                                                             \
+#define HUD_Panel_GetBg() MACRO_BEGIN                                                                             \
        string panel_bg;                                                                                                \
        if (!autocvar__hud_configure && panel_bg_str == "0") {                                                          \
                panel_bg = "0";                                                                                             \
@@ -267,10 +267,10 @@ REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    PANEL_CONFIG_NO
        if (panel.current_panel_bg)                                                                                     \
                strunzone(panel.current_panel_bg);                                                                          \
        panel.current_panel_bg = strzone(panel_bg);                                                                     \
-MACRO_END
+MACRO_END
 
 // Get value for panel_bg_color: if "" fetch default, else use panel_bg_color. Convert pants, shirt or teamcolor into a vector.
-#define HUD_Panel_GetColor() MACRO_BEGIN                                                                          \
+#define HUD_Panel_GetColor() MACRO_BEGIN                                                                          \
        if ((teamplay) && panel_bg_color_team > 0) {                                                                        \
                if (autocvar__hud_configure && myteam == NUM_SPECTATOR)                                                     \
                        panel_bg_color = '1 0 0' * panel_bg_color_team;                                                         \
@@ -291,20 +291,20 @@ REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    PANEL_CONFIG_NO
                        }                                                                                                       \
                }                                                                                                           \
        }                                                                                                               \
-MACRO_END
+MACRO_END
 
 // Get value for panel_bg_color_team: if "" fetch default, else use panel_bg_color_team_str
-#define HUD_Panel_GetColorTeam() MACRO_BEGIN                                                                      \
+#define HUD_Panel_GetColorTeam() MACRO_BEGIN                                                                      \
        if (panel_bg_color_team_str == "") {                                                                            \
                panel_bg_color_team = autocvar_hud_panel_bg_color_team;                                                     \
        } else {                                                                                                        \
                panel_bg_color_team = stof(panel_bg_color_team_str);                                                        \
        }                                                                                                               \
-MACRO_END
+MACRO_END
 
 // Get value for panel_bg_alpha: if "" fetch default, else use panel_bg_alpha. Also do various menu dialog fadeout/in checks, and minalpha checks
 // comment on line 3 of macro: // do not set a minalpha cap when showing the config dialog for this panel
-#define HUD_Panel_GetBgAlpha() MACRO_BEGIN                                                                        \
+#define HUD_Panel_GetBgAlpha() MACRO_BEGIN                                                                        \
        if (panel_bg_alpha_str == "") {                                                                                 \
                panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);                                                     \
        }                                                                                                               \
@@ -317,39 +317,39 @@ REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    PANEL_CONFIG_NO
                else                                                                                                        \
                        panel_bg_alpha = max(cvar("hud_configure_bg_minalpha"), panel_bg_alpha);                                \
        }                                                                                                               \
-MACRO_END
+MACRO_END
 
 // Get value for panel_fg_alpha. Also do various minalpha checks
 // comment on line 2 of macro: // ALWAYS show disabled panels at 0.25 alpha when in config mode
-#define HUD_Panel_GetFgAlpha() MACRO_BEGIN                                                                        \
+#define HUD_Panel_GetFgAlpha() MACRO_BEGIN                                                                        \
        panel_fg_alpha = autocvar_hud_panel_fg_alpha;                                                                   \
        if (autocvar__hud_configure && !panel_enabled)                                                                  \
                panel_fg_alpha = 0.25;                                                                                      \
-MACRO_END
+MACRO_END
 
 // Get border. See comments above, it's similar.
-#define HUD_Panel_GetBorder() MACRO_BEGIN                                                                         \
+#define HUD_Panel_GetBorder() MACRO_BEGIN                                                                         \
        if (panel_bg_border_str == "") {                                                                                \
                panel_bg_border = autocvar_hud_panel_bg_border;                                                             \
        } else {                                                                                                        \
                panel_bg_border = stof(panel_bg_border_str);                                                                \
        }                                                                                                               \
-MACRO_END
+MACRO_END
 
 // Get padding. See comments above, it's similar.
 // last line is a port of the old function, basically always make sure the panel contents are at least 5 pixels tall/wide, to disallow extreme padding values
-#define HUD_Panel_GetPadding() MACRO_BEGIN                                                                        \
+#define HUD_Panel_GetPadding() MACRO_BEGIN                                                                        \
        if (panel_bg_padding_str == "") {                                                                               \
                panel_bg_padding = autocvar_hud_panel_bg_padding;                                                           \
        } else {                                                                                                        \
                panel_bg_padding = stof(panel_bg_padding_str);                                                              \
        }                                                                                                               \
        panel_bg_padding = min(min(panel_size.x, panel_size.y)/2 - 5, panel_bg_padding);                                \
-MACRO_END
+MACRO_END
 
 // return smoothly faded pos and size of given panel when a dialog is active
 // don't center too wide panels, it doesn't work with different resolutions
-#define HUD_Panel_UpdatePosSize_ForMenu() MACRO_BEGIN \
+#define HUD_Panel_UpdatePosSize_ForMenu() MACRO_BEGIN \
        vector new_size = panel_size; \
        float max_panel_width = 0.52 * vid_conwidth; \
        if(panel_size.x > max_panel_width) \
@@ -360,13 +360,13 @@ REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    PANEL_CONFIG_NO
        vector new_pos = vec2(panel_bg_border + 0.5 * max_panel_width, 0.5 * vid_conheight) - 0.5 * new_size; \
        panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * new_pos; \
        panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * new_size; \
-MACRO_END
+MACRO_END
 
 // Scale the pos and size vectors to absolute coordinates
-#define HUD_Panel_ScalePosSize() MACRO_BEGIN                                                                      \
+#define HUD_Panel_ScalePosSize() MACRO_BEGIN                                                                      \
        panel_pos.x *= vid_conwidth;  panel_pos.y *= vid_conheight;                                                     \
        panel_size.x *= vid_conwidth; panel_size.y *= vid_conheight;                                                    \
-MACRO_END
+MACRO_END
 
 float panel_fade_alpha;
 void HUD_Panel_LoadCvars();
@@ -375,7 +375,7 @@ void HUD_Panel_LoadCvars();
        panel_enabled = ((panel.panel_configflags & PANEL_CONFIG_CANBEOFF) \
                                        ? cvar(strcat("hud_panel_", panel.panel_name)) : true)
 
-#define HUD_Panel_UpdatePosSize() MACRO_BEGIN                                                                     \
+#define HUD_Panel_UpdatePosSize() MACRO_BEGIN                                                                     \
        Hud_Panel_GetPanelEnabled(); \
        panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos")));                                  \
        panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size")));                                \
@@ -385,7 +385,7 @@ void HUD_Panel_LoadCvars();
        }                                                                                                               \
        panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border"));                        \
        HUD_Panel_GetBorder();                                                                                          \
-MACRO_END
+MACRO_END
 
 const int NOTIFY_MAX_ENTRIES = 10;
 const float NOTIFY_ICON_MARGIN = 0.02;
index 1e5a0c9f2f293403c18408e3ff0cdae1fc72d649..545da6f3c1c5ff563ea8d1dee1471146440efed9 100644 (file)
@@ -51,10 +51,10 @@ vector InfoMessages_drawstring(string s, vector pos, vector sz, float a, vector
        return pos;
 }
 
-#define InfoMessage(s) MACRO_BEGIN \
+#define InfoMessage(s) MACRO_BEGIN \
        pos = InfoMessages_drawstring(s, pos, mySize, ((img_curr_group >= 0) ? panel_fg_alpha * img_fade[img_curr_group] : panel_fg_alpha), fontsize); \
        img_curr_group = -1; \
-MACRO_END
+MACRO_END
 
 void HUD_InfoMessages()
 {
index 65682b3ec7d27006a653449ad69e7b725ba69516..da3120d81d1df1fe361e6fe765d47129be4bcfea 100644 (file)
@@ -136,14 +136,14 @@ void HUD_Mod_CTF(vector pos, vector mySize)
        }
 
        // when status CHANGES, set old status into prevstatus and current status into status
-       #define X(team) MACRO_BEGIN {                                                                                                   \
+       #define X(team) MACRO_BEGIN                                                                                                     \
                if (team##flag != team##flag_prevframe) {                                                                       \
                team##flag_statuschange_time = time;                                                                    \
                team##flag_prevstatus = team##flag_prevframe;                                                   \
                team##flag_prevframe = team##flag;                                                                              \
        }                                                                                                                                                       \
        team##flag_statuschange_elapsedtime = time - team##flag_statuschange_time;      \
-    MACRO_END
+    MACRO_END
        X(red);
        X(blue);
        X(yellow);
@@ -164,7 +164,7 @@ void HUD_Mod_CTF(vector pos, vector mySize)
        string team##_icon = string_null, team##_icon_prevstatus = string_null; \
        int team##_alpha, team##_alpha_prevstatus; \
        team##_alpha = team##_alpha_prevstatus = 1; \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                switch (team##flag) { \
                        case 1: team##_icon = "flag_" #team "_taken"; break; \
                        case 2: team##_icon = "flag_" #team "_lost"; break; \
@@ -191,7 +191,7 @@ void HUD_Mod_CTF(vector pos, vector mySize)
                                } \
                                break; \
                } \
-       MACRO_END
+       MACRO_END
        X(red, myteam != NUM_TEAM_1 && (nteams & BIT(0)));
        X(blue, myteam != NUM_TEAM_2 && (nteams & BIT(1)));
        X(yellow, myteam != NUM_TEAM_3 && (nteams & BIT(2)));
@@ -262,7 +262,7 @@ void HUD_Mod_CTF(vector pos, vector mySize)
        neutralflag_pos = pos;
        flag_size = e1 * fs * size1 + e2 * size2;
 
-       #define X(team) MACRO_BEGIN \
+       #define X(team) MACRO_BEGIN \
                f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \
                if (team##_icon && ctf_stalemate) \
                        drawpic_aspect_skin(team##flag_pos, "flag_stalemate", flag_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); \
@@ -270,7 +270,7 @@ void HUD_Mod_CTF(vector pos, vector mySize)
                        drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \
                if (team##_icon) \
                        drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \
-       MACRO_END
+       MACRO_END
        X(red);
        X(blue);
        X(yellow);
index e1fffb59f34e52684ee1ac0ec2191322e61e8c59..f58b442bcf8e7f34dd65e010dc2c7c7841484a8a 100644 (file)
@@ -89,7 +89,7 @@ void HUD_Physics()
        if(time > physics_update_time)
        {
                // workaround for ftos_decimals returning a negative 0
-               if(discrete_acceleration > -1 / (10 ** acc_decimals) && discrete_acceleration < 0)
+               if(discrete_acceleration > -1 / POW(10, acc_decimals) && discrete_acceleration < 0)
                        discrete_acceleration = 0;
                discrete_acceleration = acceleration;
                discrete_speed = speed;
index 56fa5867c240f33484f9495d4818bde4b5197e51..d4abbe0c55752ea4a7b94cde006a818fda75145f 100644 (file)
@@ -184,7 +184,7 @@ void HUD_Score()
                        // distribution display
                        distribution = me.(scores(ps_primary)) - pl.(scores(ps_primary));
 
-                       distrtimer = ftos_decimals(fabs(distribution/(10 ** TIME_DECIMALS)), TIME_DECIMALS);
+                       distrtimer = ftos_decimals(fabs(distribution/POW(10, TIME_DECIMALS)), TIME_DECIMALS);
 
                        if (distribution <= 0) {
                                distribution_color = '0 1 0';
index cebd8f5d65c162b6e3d15d90a5e7a496bbbc0858..eaf0986540e2b5abc88de002ece2948d648a75f4 100644 (file)
@@ -26,7 +26,7 @@ int weaponorder_cmp(int i, int j, entity pass)
        return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
 }
 
-#define HUD_WEAPONS_GET_FULL_LAYOUT() MACRO_BEGIN \
+#define HUD_WEAPONS_GET_FULL_LAYOUT() MACRO_BEGIN \
        int nHidden = 0; \
        FOREACH(Weapons, it != WEP_Null, { \
                if (weapons_stat & WepSet_FromWeapon(it)) continue; \
@@ -37,7 +37,7 @@ int weaponorder_cmp(int i, int j, entity pass)
        rows = table_size.y; \
        weapon_size.x = panel_size.x / columns; \
        weapon_size.y = panel_size.y / rows; \
-MACRO_END
+MACRO_END
 
 void HUD_Weapons()
 {
index f23a3976b55c6fcaba36a0ec2d5301f80ab0ba8f..aca49e122dcf676fdd524507a86a9443f00d6c80 100644 (file)
@@ -110,7 +110,7 @@ vector _drawpic_sz;
 float _drawpic_oldsz;
 string _drawpic_picpath;
 #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
-       MACRO_BEGIN {\
+       MACRO_BEGIN\
                _drawpic_imgsize = draw_getimagesize(pic);\
                if(_drawpic_imgsize != '0 0 0') {\
                        _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
@@ -127,35 +127,35 @@ string _drawpic_picpath;
                                        drawpic(pos + eY * 0.5 * (_drawpic_oldsz - _drawpic_sz.y), pic, _drawpic_sz, color, theAlpha, drawflag);\
                        }\
                }\
-       MACRO_END
+       MACRO_END
 
 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
 #define drawpic_aspect_skin(pos,pic,sz,color,theAlpha,drawflag)\
-       MACRO_BEGIN {\
+       MACRO_BEGIN\
                _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
                if(precache_pic(_drawpic_picpath) == "") {\
                        _drawpic_picpath = strcat("gfx/hud/default/", pic);\
                }\
                drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
                _drawpic_picpath = string_null;\
-       MACRO_END
+       MACRO_END
 
 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
 #define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\
-       MACRO_BEGIN {\
+       MACRO_BEGIN\
                _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
                if(precache_pic(_drawpic_picpath) == "") {\
                        _drawpic_picpath = strcat("gfx/hud/default/", pic);\
                }\
                drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
                _drawpic_picpath = string_null;\
-       MACRO_END
+       MACRO_END
 
 void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
 
 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
 
-#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN {                                                                                                                    \
+#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN                                                                                                                      \
        float textaspect, oldsz;                                                                                                                                                                                \
        vector dfs = drawfontscale; \
        drawfontscale = '1 1 0'; \
@@ -170,7 +170,7 @@ void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theSc
                sz.y = sz.x / textaspect;                                                                                                                                                                       \
                pos.y += (oldsz - sz.y) * 0.5;                                                                                                                                                          \
        }                                                                                                                                                                                                                               \
-MACRO_END
+MACRO_END
 
 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
 void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag);
index 7a054606313f1e64d90b61105c2ae98683a909b9..cf5d4569ee3c944425cbcd45255e8f8e69cf0809 100644 (file)
@@ -70,54 +70,46 @@ float autocvar_cl_leanmodel_lowpass = 0.05;
        ret = ref_store = ref_store * (1 - frac) + (value) * frac;
 
 #define lowpass_limited(value, frac, limit, ref_store, ret) MACRO_BEGIN \
-{ \
        float __ignore; lowpass(value, frac, ref_store, __ignore); \
        ret = ref_store = bound((value) - (limit), ref_store, (value) + (limit)); \
-MACRO_END
+MACRO_END
 
 #define highpass(value, frac, ref_store, ret) MACRO_BEGIN \
-{ \
        float __f = 0; lowpass(value, frac, ref_store, __f); \
        ret = (value) - __f; \
-MACRO_END
+MACRO_END
 
 #define highpass_limited(value, frac, limit, ref_store, ret) MACRO_BEGIN \
-{ \
        float __f = 0; lowpass_limited(value, frac, limit, ref_store, __f); \
        ret = (value) - __f; \
-MACRO_END
+MACRO_END
 
 #define lowpass2(value, frac, ref_store, ref_out) MACRO_BEGIN \
-{ \
        lowpass(value.x, frac, ref_store.x, ref_out.x); \
        lowpass(value.y, frac, ref_store.y, ref_out.y); \
-MACRO_END
+MACRO_END
 
 #define highpass2(value, frac, ref_store, ref_out) MACRO_BEGIN \
-{ \
        highpass(value.x, frac, ref_store.x, ref_out.x); \
        highpass(value.y, frac, ref_store.y, ref_out.y); \
-MACRO_END
+MACRO_END
 
 #define highpass2_limited(value, frac, limit, ref_store, ref_out) MACRO_BEGIN \
-{ \
        highpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
        highpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
-MACRO_END
+MACRO_END
 
 #define lowpass3(value, frac, ref_store, ref_out) MACRO_BEGIN \
-{ \
        lowpass(value.x, frac, ref_store.x, ref_out.x); \
        lowpass(value.y, frac, ref_store.y, ref_out.y); \
        lowpass(value.z, frac, ref_store.z, ref_out.z); \
-MACRO_END
+MACRO_END
 
 #define highpass3(value, frac, ref_store, ref_out) MACRO_BEGIN \
-{ \
        highpass(value.x, frac, ref_store.x, ref_out.x); \
        highpass(value.y, frac, ref_store.y, ref_out.y); \
        highpass(value.z, frac, ref_store.z, ref_out.z); \
-MACRO_END
+MACRO_END
 
 void calc_followmodel_ofs(entity view)
 {
@@ -526,7 +518,7 @@ vector GetCurrentFov(float fov)
                current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
 
        if(zoomsensitivity < 1)
-               setsensitivityscale(current_viewzoom ** (1 - zoomsensitivity));
+               setsensitivityscale(POW(current_viewzoom, (1 - zoomsensitivity)));
        else
                setsensitivityscale(1);
 
@@ -1280,7 +1272,7 @@ void HUD_Crosshair(entity this)
                        }
 
 #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
-                       MACRO_BEGIN \
+                       MACRO_BEGIN \
                                if(wcross_blur > 0) \
                                { \
                                        for(i = -2; i <= 2; ++i) \
@@ -1291,7 +1283,7 @@ void HUD_Crosshair(entity this)
                                { \
                                        M(0,0,sz,wcross_name,wcross_alpha); \
                                } \
-                       MACRO_END
+                       MACRO_END
 
 #define CROSSHAIR_DRAW_SINGLE(i,j,sz,wcross_name,wcross_alpha) \
                        drawpic(wcross_origin - ('0.5 0 0' * (sz * wcross_size.x + i * wcross_blur) + '0 0.5 0' * (sz * wcross_size.y + j * wcross_blur)), wcross_name, sz * wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL)
@@ -1824,7 +1816,7 @@ void CSQC_UpdateView(entity this, float w, float h)
 
                t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0);
                r = t * blurtest_radius;
-               f = 1 / (t ** blurtest_power) - 1;
+               f = 1 / POW(t, blurtest_power) - 1;
 
                cvar_set("r_glsl_postprocess", "1");
                cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0"));
index 7e1c4f52eb2879e58f47328c9402f33879398cd5..c02b7cf5afc372c4492e6e1a639ebba8b94877bd 100644 (file)
@@ -164,7 +164,7 @@ void GenericCommand_rpn(float request, float argc, string command)
                                                rpn_setf(f2 - f * floor(f2 / f));
                                        } else if(rpncmd == "pow" || rpncmd == "**") {
                                                f = rpn_popf();
-                                               rpn_setf(rpn_getf() ** f);
+                                               rpn_setf(POW(rpn_getf(), f));
                                        } else if(rpncmd == "bitand" || rpncmd == "&") {
                                                f = rpn_popf();
                                                rpn_setf(rpn_getf() & f);
index 71260eb3d04fa49ae2ffaeaca9c5b001ec8f8070..89f2bc42a7ad8b1898bac3d18d0906588858a973 100644 (file)
@@ -263,10 +263,10 @@ void effectinfo_read()
 
 void effectinfo_dump(int fh, bool alsoprint)
 {
-    #define WRITE(s) MACRO_BEGIN \
+    #define WRITE(s) MACRO_BEGIN \
         fputs(fh, s); \
         if (alsoprint) LOG_INFO(s); \
-    MACRO_END
+    MACRO_END
     WRITE("// ********************************************** //\n");
     WRITE("// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n");
     WRITE("// **                                          ** //\n");
index edf995a0f6ccf453f64aa49ff175608aa3c6205f..911e79bf20ab14993a234a068ace6bb201d134f8 100644 (file)
                                {
                                        #define X() \
                                                MACRO_BEGIN \
-                                               { \
                                                        float atten = (CS(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; \
                                                        if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten); \
                                                        else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); \
                                                        else soundto(MSG_ONE, this, chan, sample, vol, atten); \
-                                               MACRO_END
+                                               MACRO_END
 
                                        if (fake) { msg_entity = this; X(); }
                                        else
                                        if (voicetype == VOICETYPE_AUTOTAUNT) tauntrand = random();
                                        #define X() \
                                                MACRO_BEGIN \
-                                               { \
                                                        if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < CS(msg_entity).cvar_cl_autotaunt) \
                                                        { \
                                                                float atten = (CS(msg_entity).cvar_cl_voice_directional >= 1) \
                                                                else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); \
                                                                else soundto(MSG_ONE, this, chan, sample, vol, atten); \
                                                        } \
-                                               MACRO_END
+                                               MACRO_END
                                        if (fake)
                                        {
                                                msg_entity = this;
index 1df0b1a42b1145eeeea104092fec1a98d5b5b25d..77dd4479fdc020d013246692be7f5cbb1ce0158e 100644 (file)
@@ -127,7 +127,6 @@ entity GetVoiceMessage(string type);
        #define PlayerSound(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, def, string_null, chan, vol, voicetype, false)
        #define VoiceMessage(this, def, msg) \
                MACRO_BEGIN \
-               { \
                        entity VM = def; \
                        int voicetype = VM.m_playersoundvt; \
                        bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
@@ -137,7 +136,7 @@ entity GetVoiceMessage(string type);
                        else if (flood > 0) fake = false; \
                        else break; \
                        _GlobalSound(this, NULL, VM, string_null, CH_VOICE, VOL_BASEVOICE, voicetype, fake); \
-               MACRO_END
+               MACRO_END
 
 #endif
 
index 12abc21b18a255a29821912a00f8968ac1588ff9..b376bd74ad40979a8d0fc86ffc5171d796d873d9 100644 (file)
@@ -1,5 +1,7 @@
 #include "ent_cs.qh"
 
+// *INDENT-OFF* uncrustify is too dumb to handle all the macros
+
 REGISTRY(EntCSProps, BITS(16) - 1)
 #define EntCSProps_from(i) _EntCSProps_from(i, NULL)
 REGISTER_REGISTRY(EntCSProps)
index 35a643d53b0eac3dde0e9d317f63667c0c7e5687..7a4e44cfbde46f1bce58df18096bb82fa8ca39ba 100644 (file)
@@ -28,14 +28,14 @@ void GameRules_limit_fallbacks();
  * @param spprio player score priority (if frags aren't enabled)
  * @param stprio team score priority (if frags aren't enabled)
  */
-#define GameRules_scoring(teams, spprio, stprio, fields) MACRO_BEGIN \
+#define GameRules_scoring(teams, spprio, stprio, fields) MACRO_BEGIN \
     _GameRules_scoring_begin((teams), (spprio), (stprio)); \
     noref void(entity, string, float) field = _GameRules_scoring_field; \
     /* todo: just have the one `field` function */ \
     noref void(int, string, float) field_team = _GameRules_scoring_field_team; \
     LAMBDA(fields); \
     _GameRules_scoring_end(); \
-MACRO_END
+MACRO_END
 
 void _GameRules_scoring_begin(int teams, float spprio, float stprio);
 void _GameRules_scoring_field(entity i, string label, int scoreflags);
index 62600a9c4b07fec9deb809985b6c88df86aab09b..afe6a88a6476274035206e4ea1b77c6c1de9f193 100644 (file)
@@ -604,14 +604,14 @@ void _MapInfo_Map_ApplyGametypeEx(string s, Gametype pWantedType, Gametype pThis
 
 Gametype MapInfo_Type_FromString(string t)
 {
-#define deprecate(from, to) MACRO_BEGIN \
+#define deprecate(from, to) MACRO_BEGIN \
        if (t == #from) { \
                string replacement = #to; \
                if(!autocvar_g_mapinfo_ignore_warnings) \
                        LOG_WARNF("MapInfo_Type_FromString (probably %s): using deprecated name '%s'. Should use '%s'.", MapInfo_Map_bspname, t, replacement); \
                t = replacement; \
        } \
-MACRO_END
+MACRO_END
        deprecate(nexball, nb);
        deprecate(freezetag, ft);
        deprecate(keepaway, ka);
index 4f940c42b3c016f3e9131e0c6d3b213bc4d5497a..a2b62781955d25fc30e5ef24d68ac8f5cc764c85 100644 (file)
@@ -281,7 +281,7 @@ STATIC_INIT_LATE(Mutators) {
 #define MUTATOR_ONREMOVE                if (mode == MUTATOR_REMOVING)
 #define MUTATOR_ONROLLBACK_OR_REMOVE    if (mode == MUTATOR_REMOVING || mode == MUTATOR_ROLLING_BACK)
 
-#define MUTATOR_STATIC() MACRO_BEGIN \
+#define MUTATOR_STATIC() MACRO_BEGIN \
     MUTATOR_ONADD { \
         /* game loads at time 1 */ \
         if (time > 1) { \
@@ -292,7 +292,7 @@ STATIC_INIT_LATE(Mutators) {
                LOG_INFO("This is a game type and it cannot be removed at runtime."); \
                return -1; \
        } \
-MACRO_END
+MACRO_END
 
 #define MUTATOR_ADD(name)               Mutator_Add(MUTATOR_##name)
 #define MUTATOR_REMOVE(name)            Mutator_Remove(MUTATOR_##name)
@@ -316,7 +316,7 @@ STATIC_INIT_LATE(Mutators) {
     bool mut##_##cb() { return = false; } \
     [[accumulate]] bool mut##_##cb()
 
-#define MUTATOR_HOOK(cb, func, order) MACRO_BEGIN                     \
+#define MUTATOR_HOOK(cb, func, order) MACRO_BEGIN                     \
     MUTATOR_ONADD {                                                     \
         if (!CallbackChain_Add(HOOK_##cb, CALLBACK_##func, order)) {    \
             LOG_INFO("HOOK FAILED: ", #cb, ":", #func);                 \
@@ -326,6 +326,6 @@ STATIC_INIT_LATE(Mutators) {
     MUTATOR_ONROLLBACK_OR_REMOVE {                                      \
         CallbackChain_Remove(HOOK_##cb, CALLBACK_##func);               \
     }                                                                   \
-MACRO_END
+MACRO_END
 
 #include "events.qh"
index 40f19d6b1770bc88fa1fded89aa345397f2f3812..83d8be1011e4caa09072f9534e6b8f08f01bc591 100644 (file)
@@ -115,7 +115,7 @@ void RaceCarPhysics(entity this, float dt)
                float upspeed = this.velocity * v_up;
 
                // responsiveness factor for steering and acceleration
-               float f = 1 / (1 + ((max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF(this)) ** PHYS_BUGRIGS_SPEED_POW(this)));
+               float f = 1 / (1 + POW((max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF(this)), PHYS_BUGRIGS_SPEED_POW(this)));
                //MAXIMA: f(v) := 1 / (1 + (v / PHYS_BUGRIGS_SPEED_REF(this)) ^ PHYS_BUGRIGS_SPEED_POW(this));
 
                float steerfactor;
@@ -172,7 +172,7 @@ void RaceCarPhysics(entity this, float dt)
                float myspeed = vlen(this.velocity);
 
                // responsiveness factor for steering and acceleration
-               float f = 1 / (1 + (max(0, myspeed / PHYS_BUGRIGS_SPEED_REF(this)) ** PHYS_BUGRIGS_SPEED_POW(this)));
+               float f = 1 / (1 + POW(max(0, myspeed / PHYS_BUGRIGS_SPEED_REF(this)), PHYS_BUGRIGS_SPEED_POW(this)));
                float steerfactor = -myspeed * f;
                this.angles_y += steer * dt * steerfactor; // apply steering
 
index 92e16b48d22e04bc65a49f33b12dbdacbf17eee3..c0f0fc2804f084a45688b440a2b19212b478d28c 100644 (file)
@@ -577,7 +577,7 @@ void nade_entrap_touch(entity this, entity toucher)
                if(!pushdeltatime) return;
 
                // div0: ticrate independent, 1 = identity (not 20)
-               toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
+               toucher.velocity = toucher.velocity * POW(autocvar_g_nades_entrap_strength, pushdeltatime);
 
        #ifdef SVQC
                UpdateCSQCProjectile(toucher);
index 6dec163fa237c97f0492f9dfc83a32fadb79f425..69b82bf26ec682e6dd807150420a8eaebbfb7317 100644 (file)
@@ -460,7 +460,7 @@ vector fixrgbexcess(vector rgb)
 void Draw_WaypointSprite(entity this)
 {
     if (this.lifetime > 0)
-        this.alpha = (bound(0, (this.fadetime - time) / this.lifetime, 1) ** waypointsprite_timealphaexponent);
+        this.alpha = POW(bound(0, (this.fadetime - time) / this.lifetime, 1), waypointsprite_timealphaexponent);
     else
         this.alpha = 1;
 
@@ -522,9 +522,9 @@ void Draw_WaypointSprite(entity this)
     float a = this.alpha * autocvar_hud_panel_fg_alpha;
 
     if (this.maxdistance > waypointsprite_normdistance)
-        a *= (bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1) ** waypointsprite_distancealphaexponent);
+        a *= POW(bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
     else if (this.maxdistance > 0)
-        a *= (bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1) ** waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
+        a *= POW(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
 
     vector rgb = spritelookupcolor(this, spriteimage, this.teamradar_color);
     if (rgb == '0 0 0')
@@ -611,7 +611,7 @@ void Draw_WaypointSprite(entity this)
     (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o.x,
     (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o.y);
 
-    float crosshairdistance = sqrt( ((o.x - vid_conwidth/2) ** 2) + ((o.y - vid_conheight/2) ** 2) );
+    float crosshairdistance = sqrt(POW((o.x - vid_conwidth/2), 2) + POW((o.y - vid_conheight/2), 2) );
 
     t = waypointsprite_scale;
     a *= waypointsprite_alpha;
index 20d1351ebcae9475043db8b86de15a2df2df370d..6f6a17c400d1738862b1cc8ae47c8adee69a3371 100644 (file)
@@ -80,7 +80,7 @@ void cl_notice_run()
     drawfill(v1, v2, '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
 
     vector v3 = v1 + '10 10 0';
-    #define OUT(s, z) MACRO_BEGIN { drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3.y += z + 4; } MACRO_END
+    #define OUT(s, z) MACRO_BEGIN drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3.y += z + 4; MACRO_END
 
     float cur_time = 0;
     float time_width = 48;
index b9350758a115fb6ab3558c86e867a5e62d549c73..5cce358852d1d37a023bd838449949568becfab1 100644 (file)
@@ -608,7 +608,7 @@ void Create_Notification_Entity_InfoCenter(entity notif,
                                // ======================
                                //  Process Notif String
                                // ======================
-                               #define SET_NOTIF_STRING(string,stringname) MACRO_BEGIN \
+                               #define SET_NOTIF_STRING(string,stringname) MACRO_BEGIN \
                                        notif.nent_string = strzone(CCR( \
                                                Process_Notif_Line( \
                                                        typeId, \
@@ -619,7 +619,7 @@ void Create_Notification_Entity_InfoCenter(entity notif,
                                                        stringname \
                                                )) \
                                        ); \
-                               MACRO_END
+                               MACRO_END
 
                                if(GENTLE)
                                {
@@ -777,20 +777,20 @@ void Notification_GetCvars(entity this)
 /** used to output notifications.cfg file */
 void Dump_Notifications(int fh, bool alsoprint)
 {
-       #define NOTIF_WRITE(a) MACRO_BEGIN \
+       #define NOTIF_WRITE(a) MACRO_BEGIN \
                fputs(fh, a); \
                if (alsoprint) LOG_INFO(a); \
-       MACRO_END
+       MACRO_END
 
-       #define NOTIF_WRITE_ENTITY(e, description) MACRO_BEGIN \
+       #define NOTIF_WRITE_ENTITY(e, description) MACRO_BEGIN \
                string notif_msg = sprintf( \
                        "seta notification_%s \"%d\" \"%s\"\n", \
                        Get_Notif_CvarName(e), e.nent_default, description \
                ); \
                NOTIF_WRITE(notif_msg); \
-       MACRO_END
+       MACRO_END
 
-       #define NOTIF_WRITE_ENTITY_CHOICE(e, descriptiona, descriptionb) MACRO_BEGIN \
+       #define NOTIF_WRITE_ENTITY_CHOICE(e, descriptiona, descriptionb) MACRO_BEGIN \
                string notif_msg = sprintf( \
                        "seta notification_%s \"%d\" \"%s\"\n" \
                        "seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \
@@ -798,15 +798,15 @@ void Dump_Notifications(int fh, bool alsoprint)
                        Get_Notif_CvarName(e), e.nent_challow_def, descriptionb \
                ); \
                NOTIF_WRITE(notif_msg); \
-       MACRO_END
+       MACRO_END
 
-       #define NOTIF_WRITE_HARDCODED(cvar, default, description) MACRO_BEGIN \
+       #define NOTIF_WRITE_HARDCODED(cvar, default, description) MACRO_BEGIN \
                string notif_msg = sprintf( \
                        "seta notification_%s \"%s\" \"%s\"\n", \
                        cvar, default, description \
                ); \
                NOTIF_WRITE(notif_msg); \
-       MACRO_END
+       MACRO_END
 
        // Note: This warning only applies to the notifications.cfg file that is output...
        // You ARE supposed to manually edit this function to add i.e. hard coded
@@ -1604,7 +1604,7 @@ void Send_Notification(
                //   2. Manually handling each separate call on per-usage basis (See old CTF usage of verbose)
                entity found_choice;
 
-               #define RECURSE_FROM_CHOICE(ent,action) MACRO_BEGIN \
+               #define RECURSE_FROM_CHOICE(ent,action) MACRO_BEGIN \
                        if (notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) { \
                                switch (CS(ent).msg_choice_choices[net_name.nent_choice_idx]) \
                                { \
@@ -1624,7 +1624,7 @@ void Send_Notification(
                                found_choice.nent_floatcount, \
                                s1, s2, s3, s4, \
                                f1, f2, f3, f4); \
-               MACRO_END
+               MACRO_END
 
                switch (broadcast)
                {
index 1721303ab526a6d2fc93d5a406d99b5ad1973d43..d1f8991cf0bcc584f428bba5703c39a28f7d7a66 100644 (file)
@@ -439,9 +439,9 @@ string BUFF_NAME(int i);
        ARG_CASE(ARG_CS_SV_HA,  "minigame1_name",find(NULL,netname,s1).descriptor.message) \
        ARG_CASE(ARG_CS_SV_HA,  "minigame1_d",   find(NULL,netname,s1).descriptor.netname)
 
-#define NOTIF_HIT_MAX(count,funcname) MACRO_BEGIN \
+#define NOTIF_HIT_MAX(count,funcname) MACRO_BEGIN \
        if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; } \
-MACRO_END
+MACRO_END
 #define NOTIF_HIT_UNKNOWN(token,funcname) { backtrace(sprintf("%s: Hit unknown token in selected string! '%s'\n", funcname, selected)); break; }
 
 #define KILL_SPREE_LIST \
index 20e2d4cc32f16d0b736e421d0a1172262492ff7c..9b6157ccad47b6361b943667526878a8c43784a4 100644 (file)
@@ -92,7 +92,7 @@ float GeomLerp(float a, float _lerp, float b)
 {
        return a == 0 ? (_lerp < 1 ? 0 : b)
                : b == 0 ? (_lerp > 0 ? 0 : a)
-               : a * (fabs(b / a) ** _lerp);
+               : a * POW(fabs(b / a), _lerp);
 }
 
 void PM_ClientMovement_UpdateStatus(entity this)
@@ -165,7 +165,7 @@ void CPM_PM_Aircontrol(entity this, float dt, vector wishdir, float wishspeed)
 
        if (dot > 0) // we can't change direction while slowing down
        {
-               k *= (dot ** PHYS_AIRCONTROL_POWER(this)) * dt;
+               k *= POW(dot, PHYS_AIRCONTROL_POWER(this)) * dt;
                xyspeed = max(0, xyspeed - PHYS_AIRCONTROL_PENALTY(this) * sqrt(max(0, 1 - dot*dot)) * k/32);
                k *= PHYS_AIRCONTROL(this);
                this.velocity = normalize(this.velocity * xyspeed + wishdir * k);
index 8c4aecbda029829c753e9b1641ceeb490cc04259..0ff10a9ae5f528340ae058b446ba5ddce70bb1b4 100644 (file)
@@ -41,11 +41,10 @@ const float VOL_MUFFLED = 0.35;
 #ifdef SVQC
        #define _sound(e, c, s, v, a) \
                MACRO_BEGIN \
-               { \
                        entity __e = e; \
                        if (sound_allowed(MSG_BROADCAST, __e)) \
                                sound7(__e, c, s, v, a, 0, 0); \
-               MACRO_END
+               MACRO_END
 #else
        #define _sound(e, c, s, v, a) sound7(e, c, s, v, a, 0, 0)
 #endif
@@ -65,7 +64,6 @@ const float VOL_MUFFLED = 0.35;
  */
 #define sound8(e, o, chan, samp, vol, atten, speed, sf) \
        MACRO_BEGIN \
-       { \
                entity __e; \
                int __chan = chan; \
                string __samp = samp; \
@@ -90,7 +88,7 @@ const float VOL_MUFFLED = 0.35;
                        setorigin(__e, old_origin); \
                        setsize(__e, old_mins, old_maxs); \
                } \
-       MACRO_END
+       MACRO_END
 
 CLASS(Sound, Object)
        ATTRIB(Sound, m_id, int, 0);
index 6adbcc65f4fa4d7dc2564b466f473008f8d90042..960ee2150d6e666f6434e392d5a0a6f3ad02c3b7 100644 (file)
@@ -119,7 +119,7 @@ void conveyor_init(entity this)
        this.movedir *= this.speed;
        setthink(this, conveyor_think);
        this.nextthink = time;
-       IFTARGETED
+       if(THIS_TARGETED)
        {
                this.use = conveyor_use;
                this.reset = conveyor_reset;
index dc0be6ae24a9822b67865e2c4a2cb0c6b0b32c6b..1f9b6239e3863480f5b269de0278604b99943f4e 100644 (file)
@@ -420,20 +420,24 @@ Spawned if a door lacks a real activator
 
 void door_trigger_touch(entity this, entity toucher)
 {
-       if (toucher.health < 1)
+       if (toucher.health < 1){
 #ifdef SVQC
-               if (!((toucher.iscreature || (toucher.flags & FL_PROJECTILE)) && !IS_DEAD(toucher)))
+               if (!((toucher.iscreature || (toucher.flags & FL_PROJECTILE)) && !IS_DEAD(toucher))){
 #elif defined(CSQC)
-               if(!((IS_CLIENT(toucher) || toucher.classname == "csqcprojectile") && !IS_DEAD(toucher)))
+               if(!((IS_CLIENT(toucher) || toucher.classname == "csqcprojectile") && !IS_DEAD(toucher))){
 #endif
                        return;
+               }
+       }
 
-       if (time < this.door_finished)
+       if (time < this.door_finished){
                return;
+       }
 
        // check if door is locked
-       if (!door_check_keys(this, toucher))
+       if (!door_check_keys(this, toucher)){
                return;
+       }
 
        this.door_finished = time + 1;
 
@@ -498,15 +502,16 @@ void LinkDoors(entity this)
        door_link();
 #endif
 
-       if (this.enemy)
+       if (this.enemy){
                return;         // already linked by another door
+       }
        if (this.spawnflags & 4)
        {
                this.owner = this.enemy = this;
 
                if (this.health)
                        return;
-               IFTARGETED
+               if(THIS_TARGETED)
                        return;
                if (this.items)
                        return;
@@ -537,26 +542,36 @@ void LinkDoors(entity this)
        cmaxs = this.absmax;
        for(t = this; ; t = t.enemy)
        {
-               if(t.health && !this.health)
+               if(t.health && !this.health){
                        this.health = t.health;
-               if((t.targetname != "") && (this.targetname == ""))
+               }
+               if((t.targetname != "") && (this.targetname == "")){
                        this.targetname = t.targetname;
-               if((t.message != "") && (this.message == ""))
+               }
+               if((t.message != "") && (this.message == "")){
                        this.message = t.message;
-               if (t.absmin_x < cmins_x)
+               }
+               if (t.absmin_x < cmins_x){
                        cmins_x = t.absmin_x;
-               if (t.absmin_y < cmins_y)
+               }
+               if (t.absmin_y < cmins_y){
                        cmins_y = t.absmin_y;
-               if (t.absmin_z < cmins_z)
+               }
+               if (t.absmin_z < cmins_z){
                        cmins_z = t.absmin_z;
-               if (t.absmax_x > cmaxs_x)
+               }
+               if (t.absmax_x > cmaxs_x){
                        cmaxs_x = t.absmax_x;
-               if (t.absmax_y > cmaxs_y)
+               }
+               if (t.absmax_y > cmaxs_y){
                        cmaxs_y = t.absmax_y;
-               if (t.absmax_z > cmaxs_z)
+               }
+               if (t.absmax_z > cmaxs_z){
                        cmaxs_z = t.absmax_z;
-               if(t.enemy == this)
+               }
+               if(t.enemy == this){
                        break;
+               }
        }
 
        // distribute health, targetname, message
@@ -572,12 +587,15 @@ void LinkDoors(entity this)
        // shootable, or triggered doors just needed the owner/enemy links,
        // they don't spawn a field
 
-       if (this.health)
+       if (this.health) {
                return;
-       IFTARGETED
+       }
+       if(THIS_TARGETED) {
                return;
-       if (this.items)
+       }
+       if (this.items) {
                return;
+       }
 
        door_spawnfield(this, cmins, cmaxs);
 }
@@ -706,36 +724,42 @@ void door_reset(entity this)
 spawnfunc(func_door)
 {
        // Quake 1 keys compatibility
-       if (this.spawnflags & SPAWNFLAGS_GOLD_KEY)
+       if (this.spawnflags & SPAWNFLAGS_GOLD_KEY) {
                this.itemkeys |= ITEM_KEY_BIT(0);
-       if (this.spawnflags & SPAWNFLAGS_SILVER_KEY)
+       }
+       if (this.spawnflags & SPAWNFLAGS_SILVER_KEY) {
                this.itemkeys |= ITEM_KEY_BIT(1);
+       }
 
        SetMovedir(this);
 
        this.max_health = this.health;
-       if (!InitMovingBrushTrigger(this))
+       if (!InitMovingBrushTrigger(this)) {
                return;
+       }
        this.effects |= EF_LOWPRECISION;
        this.classname = "door";
 
-       if(this.noise == "")
+       if(this.noise == "") {
                this.noise = "misc/talk.wav";
-       if(this.noise3 == "")
+       }
+       if(this.noise3 == "") {
                this.noise3 = "misc/talk.wav";
+       }
        precache_sound(this.noise);
        precache_sound(this.noise3);
 
        setblocked(this, door_blocked);
        this.use = door_use;
 
-       if(this.dmg && (this.message == ""))
+       if(this.dmg && (this.message == "")) {
                this.message = "was squished";
-       if(this.dmg && (this.message2 == ""))
+       }
+       if(this.dmg && (this.message2 == "")) {
                this.message2 = "was squished by";
+       }
 
-       if (this.sounds > 0)
-       {
+       if (this.sounds > 0) {
                this.noise2 = "plats/medplat1.wav";
                this.noise1 = "plats/medplat2.wav";
        }
@@ -743,39 +767,44 @@ spawnfunc(func_door)
        if(this.noise1 && this.noise1 != "") { precache_sound(this.noise1); }
        if(this.noise2 && this.noise2 != "") { precache_sound(this.noise2); }
 
-       if (!this.speed)
+       if (!this.speed) {
                this.speed = 100;
-       if (!this.wait)
+       }
+       if (!this.wait) {
                this.wait = 3;
-       if (!this.lip)
+       }
+       if (!this.lip) {
                this.lip = 8;
+       }
 
        this.pos1 = this.origin;
        this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
 
-       if(this.spawnflags & DOOR_NONSOLID)
+       if(this.spawnflags & DOOR_NONSOLID) {
                this.solid = SOLID_NOT;
+       }
 
-// DOOR_START_OPEN is to allow an entity to be lighted in the closed position
-// but spawn in the open position
-       if (this.spawnflags & DOOR_START_OPEN)
+       // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
+       // but spawn in the open position
+       if (this.spawnflags & DOOR_START_OPEN) {
                InitializeEntity(this, door_init_startopen, INITPRIO_SETLOCATION);
+       }
 
        this.state = STATE_BOTTOM;
 
-       if (this.health)
-       {
+       if (this.health) {
                this.takedamage = DAMAGE_YES;
                this.event_damage = door_damage;
        }
 
-       if (this.items)
+       if (this.items) {
                this.wait = -1;
+       }
 
        settouch(this, door_touch);
 
-// LinkDoors can't be done until all of the doors have been spawned, so
-// the sizes can be detected properly.
+       // LinkDoors can't be done until all of the doors have been spawned, so
+       // the sizes can be detected properly.
        InitializeEntity(this, LinkDoors, INITPRIO_LINKDOORS);
 
        this.reset = door_reset;
index 0bad196abf3a57a79a4fbac2637170f35321bdf6..671f7048aab18bac8e0eaff61f6265dff4489117 100644 (file)
@@ -220,7 +220,7 @@ spawnfunc(func_door_secret)
        setblocked(this, secret_blocked);
        this.speed = 50;
        this.use = fd_secret_use;
-       IFTARGETED
+       if(THIS_TARGETED)
        {
        }
        else
index a0773f249a82ccfe6bc52f0fac17cb063381cbd6..3676550d61703311978ec43a10ef8e9c6e5697c6 100644 (file)
@@ -136,7 +136,7 @@ spawnfunc(func_pointparticles)
 
        Net_LinkEntity(this, (this.spawnflags & 4), 0, pointparticles_SendEntity);
 
-       IFTARGETED
+       if(THIS_TARGETED)
        {
                this.use = pointparticles_use;
                this.reset = pointparticles_reset;
index 2059a8126d53101672aec3410e6560e8812d2891..e4fd43c1a20d33dd41f49bf723a8f673a64db68c 100644 (file)
@@ -241,7 +241,7 @@ spawnfunc(misc_laser)
 
        Net_LinkEntity(this, false, 0, laser_SendEntity);
 
-       IFTARGETED
+       if(THIS_TARGETED)
        {
                this.reset = laser_reset;
                this.reset(this);
index fc3cec863a26920d0547df1143e75af283631f88..6e23a88bab31fecf6f10f284f230de2781e4381d 100644 (file)
@@ -41,7 +41,7 @@ spawnfunc(info_teleport_destination)
        //setorigin(this, this.origin + '0 0 27');      // To fix a mappers' habit as old as Quake
        setorigin(this, this.origin);
 
-       IFTARGETED
+       if(THIS_TARGETED)
        {
        }
        else
index 09e733000f21dc4582627f670a766af704545de8..703f1d05cc85cfab637ed976ef0b1878e8f75f4d 100644 (file)
@@ -177,7 +177,7 @@ void plat_use(entity this, entity actor, entity trigger)
 
 void plat_reset(entity this)
 {
-       IFTARGETED
+       if(THIS_TARGETED)
        {
                setorigin(this, this.pos1);
                this.state = 4;
index af327b443bc21febb1c8494829bfd10e1fb4543a..355ba16c9ec83e0cf45ab6861ff785de2c26f70b 100644 (file)
@@ -85,7 +85,7 @@ spawnfunc(target_speaker)
 
        if(!this.atten && !(this.spawnflags & 4))
        {
-               IFTARGETED
+               if(THIS_TARGETED)
                        this.atten = ATTEN_NORM;
                else
                        this.atten = ATTEN_STATIC;
@@ -96,7 +96,7 @@ spawnfunc(target_speaker)
        if(!this.volume)
                this.volume = 1;
 
-       IFTARGETED
+       if(THIS_TARGETED)
        {
                if(this.spawnflags & 8) // ACTIVATOR
                        this.use = target_speaker_use_activator;
index 3ea1562f084a93e4c73b7fdb0c9a26ac64dad90e..4112dbdb158b7f31c2e148b5c65aaa1e7abf8b5c 100644 (file)
@@ -97,7 +97,7 @@ spawnfunc(trigger_gravity)
                precache_sound(this.noise);
 
        this.state = true;
-       IFTARGETED
+       if(THIS_TARGETED)
        {
                this.use = trigger_gravity_use;
                if(this.spawnflags & 2)
index 4be6e86bca66c6c02fcf2adbd3c7141721292647..62793e4707f79eb900859cd2905597dbf5612460 100644 (file)
@@ -74,7 +74,7 @@ void trigger_impulse_touch2(entity this, entity toucher)
        if(!pushdeltatime) return;
 
        // div0: ticrate independent, 1 = identity (not 20)
-       toucher.velocity = toucher.velocity * (this.strength ** pushdeltatime);
+       toucher.velocity = toucher.velocity * POW(this.strength, pushdeltatime);
 
 #ifdef SVQC
        UpdateCSQCProjectile(toucher);
@@ -181,7 +181,7 @@ spawnfunc(trigger_impulse)
                else
                {
                        if(!this.strength) this.strength = 0.9;
-                       this.strength = (this.strength ** autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
+                       this.strength = POW(this.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
                        settouch(this, trigger_impulse_touch2);
                }
        }
index d946efe5f17cc533c2b104b52fb1dc2c2e37ba82..6bf0557f2203dc4c49da9ce6741de8368792e10e 100644 (file)
@@ -72,7 +72,7 @@ spawnfunc(trigger_multivibrator)
        setthink(this, multivibrator_send_think);
        this.nextthink = max(1, time);
 
-       IFTARGETED
+       if(THIS_TARGETED)
                multivibrator_reset(this);
 }
 #endif
index 2b8274f4b890aa473b5432de2415bb1719e925a1..56ebb0c381e91750f35e719a60c7c00c8524297e 100644 (file)
@@ -14,8 +14,10 @@ const float  SPAWNFLAG_NOTOUCH = 1;
 
 .float height;
 
+// we love double negation around here
+// TODO check why grep doesn't find any assignments to it
 .float nottargeted;
-#define IFTARGETED if(!this.nottargeted && this.targetname != "")
+#define THIS_TARGETED !this.nottargeted && this.targetname != ""
 
 .float lip;
 
index d75e4a925ce0bf30c781a40f825cdc5b4ffa82f0..5dd9ed9018e24425a893ac87f81ceeb282a9b7d4 100644 (file)
@@ -105,9 +105,9 @@ void turret_draw2d(entity this)
 
 
        if(this.maxdistance > waypointsprite_normdistance)
-               a *= (bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1) ** waypointsprite_distancealphaexponent);
+               a *= POW(bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
        else if(this.maxdistance > 0)
-               a *= (bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1) ** waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
+               a *= POW(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
 
        if(rgb == '0 0 0')
        {
@@ -161,7 +161,7 @@ void turret_draw2d(entity this)
        (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x,
        (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y);
 
-       float crosshairdistance = sqrt( ((o.x - vid_conwidth/2) ** 2) + ((o.y - vid_conheight/2) ** 2) );
+       float crosshairdistance = sqrt( POW((o.x - vid_conwidth/2), 2) + POW((o.y - vid_conheight/2), 2) );
 
        t = waypointsprite_scale;
        a *= waypointsprite_alpha;
index deba86c289dc8f4966407fa6dd6f7c4f9e308ed8..33835748fca1386d84df363412a2243478ef8fba 100644 (file)
@@ -326,7 +326,7 @@ float compressShortVector(vector vec)
 STATIC_INIT(compressShortVector)
 {
        float l = 1;
-       float f = (2 ** (1/8));
+       float f = POW(2, (1/8));
        int i;
        for(i = 0; i < 128; ++i)
        {
index d6d7d9facfb2edc3f7f32c39138119723a47f5b0..e20b660e57dd773a3cf3b2d98a6c276fbfbfd8ad 100644 (file)
@@ -36,25 +36,26 @@ void viewloc_PlayerPhysics(entity this)
                if(PHYS_CS(this).movement_x > 0) // right
                        this.angles_y = forward_y;
 
-               if(old_movement_x > 0)
+               if(old_movement_x > 0) {
 #ifdef CSQC
                        input_angles_x =
 #endif
                        this.v_angle_x = this.angles_x = -50;
-               else if(old_movement_x < 0)
+               } else if(old_movement_x < 0) {
 #ifdef CSQC
                        input_angles_x =
 #endif
                        this.v_angle_x = this.angles_x = 50;
+               }
 
                //if(!PHYS_INPUT_BUTTON_CROUCH(this) && !IS_DUCKED(this))
 #ifdef SVQC
                        //PHYS_INPUT_BUTTON_CROUCH(this) = (old_movement_x < 0);
-                       if (old_movement.x < 0)
+                       if (old_movement.x < 0) {
                                PHYS_INPUT_BUTTON_CROUCH(this) = true;
+                       }
 #elif defined(CSQC)
-                       if (old_movement.x < 0)
-                       {
+                       if (old_movement.x < 0) {
                                input_buttons |= BIT(4);
                                this.flags |= FL_DUCKED;
                        }
index e430ec2e78c252dea99cfc5c8fdfcc1a874bce8a..1b2dce6001ccd3e181b4d8b04314a0b8725184b2 100644 (file)
@@ -67,11 +67,11 @@ WepSet _WepSet_FromWeapon(int a)
                                if (a >= 24)
                                {
                                        a -= 24;
-                                       return '0 0 1' * (2 ** a);
+                                       return '0 0 1' * POW(2, a);
                                }
-                       return '0 1 0' * (2 ** a);
+                       return '0 1 0' * POW(2, a);
                }
-       return '1 0 0' * (2 ** a);
+       return '1 0 0' * POW(2, a);
 }
 #ifdef SVQC
        void WriteWepSet(float dst, WepSet w)
index 9489843654f89db445a844973a14b6cd270f8e65..883082c97d02ed22df2c6910c1123542f2d09818 100644 (file)
@@ -14,10 +14,10 @@ int WEP_CONFIG_COUNT;
        config_queue[WEP_CONFIG_COUNT] = a; \
        ++WEP_CONFIG_COUNT; }
 
-#define WEP_CONFIG_WRITETOFILE(a) MACRO_BEGIN \
+#define WEP_CONFIG_WRITETOFILE(a) MACRO_BEGIN \
        fputs(wep_config_file, a); \
        if(wep_config_alsoprint) { LOG_INFO(a); } \
-MACRO_END
+MACRO_END
 
 
 #define WEP_CONFIG_WRITE_CVARS(wepname, name, T) WEP_CONFIG_WRITE_PROPS_##T(wepname, name)
index 2e2cb519af644ad83fa9133dc6f711227542b72f..cf8c17036cd28ab9b9e2b2aa872cfa8a0d782da5 100644 (file)
@@ -110,9 +110,9 @@ vector W_Crylink_LinkJoin(entity e, float jspeed)
                return avg_origin; // nothing to do
 
        // yes, mathematically we can do this in ONE step, but beware of 32bit floats...
-       avg_dist = (vlen(e.origin - avg_origin) ** 2);
+       avg_dist = POW(vlen(e.origin - avg_origin), 2);
        for(p = e; (p = p.queuenext) != e; )
-               avg_dist += (vlen(WarpZone_RefSys_TransformOrigin(p, e, p.origin) - avg_origin) ** 2);
+               avg_dist += POW(vlen(WarpZone_RefSys_TransformOrigin(p, e, p.origin) - avg_origin), 2);
        avg_dist *= (1.0 / n);
        avg_dist = sqrt(avg_dist);
 
index d92e0caa8538b4c9ec4ccc5c0bc79a3fef41e7f4..04383716addb57fa1a9de811db2557aee8a40722 100644 (file)
@@ -9,7 +9,7 @@ void W_Hook_ExplodeThink(entity this)
        float dt, dmg_remaining_next, f;
 
        dt = time - this.teleport_time;
-       dmg_remaining_next = (bound(0, 1 - dt / this.dmg_duration, 1) ** this.dmg_power);
+       dmg_remaining_next = POW(bound(0, 1 - dt / this.dmg_duration, 1), this.dmg_power);
 
        f = this.dmg_last - dmg_remaining_next;
        this.dmg_last = dmg_remaining_next;
index a5ae87c36b392256205cc47dd79aa879c628ae7a..7d46d6d188c33aa8d08cbf694e25ec7d414a656a 100644 (file)
@@ -450,23 +450,23 @@ void tubasound(entity e, bool restart)
                                if (restart) {
                                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep);
                                }
-                               speed1 = (2.0 ** ((m - Tuba_PitchStep) / 12.0));
+                               speed1 = POW(2.0, ((m - Tuba_PitchStep) / 12.0));
                        } else if (e.note - m + Tuba_PitchStep > TUBA_MAX) {
                                if (restart) {
                                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m);
                                }
-                               speed1 = (2.0 ** (m / 12.0));
+                               speed1 = POW(2.0, (m / 12.0));
                        } else {
                                if (restart) {
                                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m);
                                }
                                vol1 = cos(M_PI_2 * m / Tuba_PitchStep);
-                               speed1 = (2.0 ** (m / 12.0));
+                               speed1 = POW(2.0, (m / 12.0));
                                if (restart) {
                                        snd2 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep);
                                }
                                vol2 = sin(M_PI_2 * m / Tuba_PitchStep);
-                               speed2 = (2.0 ** ((m - Tuba_PitchStep) / 12.0));
+                               speed2 = POW(2.0, ((m - Tuba_PitchStep) / 12.0));
                        }
                } else if (restart) {
                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note);
index 18305177bf8a266261e1be9ad143dfde695fcace..a10dcaa7b919b0c60299393c715bdfb6d1130b5f 100644 (file)
@@ -6,7 +6,6 @@ USING(ArrayList, entity);
 
 #define AL_NEW(this, n, default, T) \
        MACRO_BEGIN \
-       { \
                ArrayList _al = this = new_pure(ArrayList); \
                _al.al_buf = buf_create(); \
                for (int i = 0, _n = _al.al_len = n; i < _n; ++i) \
@@ -14,15 +13,14 @@ USING(ArrayList, entity);
                        const _AL_type__##T() it = default; \
                        AL_set##T(this, i, it); \
                } \
-       MACRO_END
+       MACRO_END
 
 #define AL_DELETE(this) \
        MACRO_BEGIN \
-       { \
                buf_del(this.al_buf); \
                delete(this); \
                this = NULL; \
-       MACRO_END
+       MACRO_END
 
 #define _AL_type__s() string
 #define AL_gets(this, idx) bufstr_get(this.al_buf, idx)
@@ -60,11 +58,10 @@ entity al_ftoe(int i) = #80;
 
 #define AL_EACH(this, T, cond, body) \
        MACRO_BEGIN \
-       { \
                const noref ArrayList _al = this; \
                for (int i = 0, n = _al.al_len; i < n; ++i) \
                { \
                        const noref _AL_type__##T() it = AL_get##T(_al, i); \
                        if (cond) { body } \
                } \
-       MACRO_END
+       MACRO_END
index d1bdc4fe5b55e609bc4d02b32dc0f55b0761f21a..fc5fa0fe65993c837ebd833457cc287634ac8d64 100644 (file)
        #endif
 #endif
 
+// uncrustify segfaults on this
+// *INDENT-OFF*
 #ifdef GMQCC
-    #define LABEL(id) :id
+       #define LABEL(id) :id
 #else
-    #define LABEL(id) id:
+       #define LABEL(id) id:
 #endif
+// *INDENT_ON*
index fc0e080eae32fa103333559653d439a403895cb2..05021d5343e9e662a75a9af835d0cb677a4e2c6e 100644 (file)
@@ -146,27 +146,24 @@ void IL_REMOVE(IntrusiveList this, entity it)
  */
 #define IL_CLEAR(this) \
        MACRO_BEGIN \
-       { \
                IntrusiveList __il = this; \
                assert(__il); \
                .entity il_prev = __il.il_prevfld; \
                IL_EACH(__il, true, it.(il_next) = it.(il_prev) = NULL); \
                __il.il_head = __il.il_tail = NULL; \
-       MACRO_END
+       MACRO_END
 
 /**
  * Delete the list
  */
 #define IL_DELETE(this) \
        MACRO_BEGIN \
-       { \
                delete(this); \
                this = NULL; \
-       MACRO_END
+       MACRO_END
 
 #define IL_EACH(this, cond, body) \
        MACRO_BEGIN \
-       { \
                IntrusiveList _il = this; \
                assert(_il); \
                .entity il_next = _il.il_nextfld; \
@@ -175,9 +172,9 @@ void IL_REMOVE(IntrusiveList this, entity it)
                { \
                        const noref entity it = _it; \
                        _next = it.(il_next); \
-                       if (cond) { LAMBDA(body) } \
+                       if (cond) { LAMBDA(body); } \
                } \
-       MACRO_END
+       MACRO_END
 
 .int il_id;
 IntrusiveList il_links[IL_MAX];
index e3cf7410fba38b7177f6d6ee6c928c5f9e7ce122..7a284e2de1ae3e69b67aa65aa836ea930124d7cf 100644 (file)
@@ -8,71 +8,67 @@
 
 #define FOREACH_ARRAY(arr, start, end, cond, body) \
        MACRO_BEGIN \
-       { \
                for (int _i = start; _i < end; ++_i) \
                { \
                        const noref int i = _i; \
                        ITER_CONST noref entity it = arr[i]; \
-                       if (cond) { LAMBDA(body) } \
+                       if (cond) { LAMBDA(body); } \
                } \
-       MACRO_END
+       MACRO_END
 
 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)
 
 #define FOREACH_LIST(list, next, cond, body) \
        MACRO_BEGIN \
-       { \
                int _i = 0; \
                for (entity _it = list##_first, _next = NULL; _it; (_it = _next, ++_i)) \
                { \
                        const noref int i = _i; \
                        ITER_CONST noref entity it = _it; \
                        _next = _it.next; \
-                       if (cond) { LAMBDA(body) } \
+                       if (cond) { LAMBDA(body); } \
                } \
-       MACRO_END
+       MACRO_END
 
 #define FOREACH_WORD(words, cond, body) \
        MACRO_BEGIN \
-       { \
                string _words = words; \
                int _i = 0; \
                for (string _it; (_it = car(_words)); (_words = cdr(_words), ++_i)) \
                { \
                        const noref int i = _i; \
                        const noref string it = _it; \
-                       if (cond) { LAMBDA(body) } \
+                       if (cond) { LAMBDA(body); } \
                } \
-       MACRO_END
+       MACRO_END
 
 #define STRING_ITERATOR(this, s, i) \
        string this##_s = s; \
        int this##_i = i
 
 #define STRING_ITERATOR_SET(this, s, i) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                this##_s = s; \
                this##_i = i; \
-       MACRO_END
+       MACRO_END
 
 #define STRING_ITERATOR_GET(this) str2chr(this##_s, this##_i++)
 #define STRING_ITERATOR_PEEK(this) str2chr(this##_s, this##_i)
-#define STRING_ITERATOR_NEXT(this) MACRO_BEGIN ++this##_i; MACRO_END
-#define STRING_ITERATOR_UNGET(this) MACRO_BEGIN --this##_i; MACRO_END
+#define STRING_ITERATOR_NEXT(this) MACRO_BEGIN { ++this##_i; } MACRO_END
+#define STRING_ITERATOR_UNGET(this) MACRO_BEGIN { --this##_i; } MACRO_END
 #define STRING_ITERATOR_SAVE(this) this##_i
 #define STRING_ITERATOR_LOAD(this, n) MACRO_BEGIN this##_i = n; MACRO_END
 
 #define FOREACH_CHAR(s, cond, body) \
        MACRO_BEGIN \
-       { \
                STRING_ITERATOR(iter, s, 0); \
                int _it; \
                while ((_it = STRING_ITERATOR_GET(iter)) > 0) \
                { \
                        const noref int it = _it; \
-                       if (cond) { LAMBDA(body) } \
+                       if (cond) { LAMBDA(body); } \
                } \
-       MACRO_END
+       MACRO_END
 
 #if defined(CSQC)
     entity(entity start, .string fld, string match) _findstring = #18;
 
 #define ORDERED(F) F##_UNORDERED
 #define _FOREACH_ENTITY_FIND_ORDERED(T, fld, match, cond, body) \
-    MACRO_BEGIN \
+    MACRO_BEGIN \
         int _i = 0; \
         for (entity _it = NULL; (_it = _find##T(_it, fld, match)); ++_i) \
         { \
             const noref int i = _i; \
             ITER_CONST noref entity it = _it; \
-            if (cond) LAMBDA(body) \
+            if (cond) LAMBDA(body); \
         } \
-    MACRO_END
+    MACRO_END
 #define MUTEX_LOCK(this) MACRO_BEGIN \
        if (this) LOG_SEVEREF("Loop mutex held by %s", this); \
        this = __FUNC__; \
@@ -131,24 +127,24 @@ MACRO_END
        this = string_null; \
 MACRO_END
 #define _FOREACH_ENTITY_FIND_UNORDERED(id, T, fld, match, cond, body) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                MUTEX_LOCK(_FOREACH_ENTITY_FIND_##T##_##id##mutex); \
                entity _foundchain_first = _findchain##T##_tofield(fld, match, _FOREACH_ENTITY_FIND_##T##_next##id); \
                FOREACH_LIST(_foundchain, _FOREACH_ENTITY_FIND_##T##_next##id, cond, body); \
                MUTEX_UNLOCK(_FOREACH_ENTITY_FIND_##T##_##id##mutex); \
-       MACRO_END
+       MACRO_END
 
 #define FOREACH_ENTITY(cond, body) ORDERED(FOREACH_ENTITY)(cond, body)
 #define FOREACH_ENTITY_ORDERED(cond, body) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                int _i = 0; \
                for (entity _it = NULL; (_it = nextent(_it)); ++_i) \
                { \
                        const noref int i = _i; \
                        ITER_CONST noref entity it = _it; \
-                       if (cond) LAMBDA(body) \
+                       if (cond) LAMBDA(body); \
                } \
-       MACRO_END
+       MACRO_END
 /** marker field, always NULL */
 .entity _FOREACH_ENTITY_fld;
 .entity _FOREACH_ENTITY_FIND_entity_nextall; noref string _FOREACH_ENTITY_FIND_entity_allmutex;
index b477fe15e59124924662e4c463030ff7016ca94e..241b537aaa329a70d544e0a8d7a367462ba9e0cc 100644 (file)
@@ -24,7 +24,7 @@ bool _json_parse_number();
 #define JSON_FAIL(reason) goto fail
 #define JSON_END() \
    return true; \
-:fail \
+LABEL(fail) \
    STRING_ITERATOR_LOAD(_json, __i); \
    return false;
 // Current namespace
index 0dd430722f755218f5f796883a5dcf4317caf885..e2194f574c39a4e41235633ceaaa61ef2e49729f 100644 (file)
@@ -49,7 +49,6 @@ entity LL_POP(LinkedList this)
 #define LL_CLEAR_1(this) LL_CLEAR_2(this, LAMBDA())
 #define LL_CLEAR_2(this, dtor) \
        MACRO_BEGIN \
-       { \
                LinkedList _ll = this; \
                assert(_ll); \
                while (_ll.ll_tail) \
@@ -59,26 +58,24 @@ entity LL_POP(LinkedList this)
                        dtor \
                        delete(it); \
                } \
-       MACRO_END
+       MACRO_END
 
 #define LL_DELETE(...) EVAL_LL_DELETE(OVERLOAD(LL_DELETE, __VA_ARGS__))
 #define EVAL_LL_DELETE(...) __VA_ARGS__
 #define LL_DELETE_1(this) LL_DELETE_2(this, LAMBDA())
 #define LL_DELETE_2(this, dtor) \
        MACRO_BEGIN \
-       { \
                LL_CLEAR_2(this, dtor); \
                delete(this); \
                this = NULL; \
-       MACRO_END
+       MACRO_END
 
 #define LL_EACH(list, cond, body) \
-       MACRO_BEGIN                                                         \
-       {                                                                   \
+       MACRO_BEGIN                                                                   \
                noref int i = 0;                                                \
                for (entity _it = list.ll_head; _it; (_it = _it.ll_next, ++i))  \
                {                                                               \
                        ITER_CONST noref entity it = _it.ll_data;                   \
                        if (cond) { body }                                          \
                }                                                               \
-       MACRO_END
+       MACRO_END
index 7491818b24ad309e7f0564efd5fb228326aa032c..b751bfb2a836e8eb298e2201d50fd33f202f9386 100644 (file)
@@ -6,14 +6,14 @@
 #define devassert(...) MACRO_BEGIN if (autocvar_developer) assert(__VA_ARGS__); MACRO_END
 
 #define assert_once(expr, ...) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                static bool __once; \
                if (!__once) \
                { \
                        assert(expr, __VA_ARGS__); \
                        __once = true; \
                } \
-       MACRO_END
+       MACRO_END
 #define devassert_once(...) MACRO_BEGIN if (autocvar_developer) assert_once(__VA_ARGS__); MACRO_END
 
 #define demand(expr, ...) _assert(LOG_FATAL, expr, __VA_ARGS__)
 
 #define _assert(f, expr, then) \
        MACRO_BEGIN \
-       { \
                if (!(expr)) \
                { \
                        f("assertion failed: `" #expr "`\n"); \
                        then; \
                } \
-       MACRO_END
+       MACRO_END
 
 #define ASSERT_LESS(name, var, const) noref int name[(const - var + 1)];
 
@@ -48,9 +47,9 @@ string(string, string...) strcat1n = #115;
 
 #define _LOG_HEADER(level) "^9[::" "^7"PROGNAME"^9" "::" level"^9" "] ", __SOURCELOC__
 #define _LOG(f, level, s) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                f(strcat1n(_LOG_HEADER(level), "\n^7", s, "\n")); \
-       MACRO_END
+       MACRO_END
 
 #define  LOG_FATAL(...) _LOG_FATAL(strcat1n(__VA_ARGS__))
 #define  LOG_FATALF(...) _LOG_FATAL(sprintf(__VA_ARGS__))
@@ -67,13 +66,13 @@ string(string, string...) strcat1n = #115;
 #define  LOG_INFO(...) _LOG_INFO(strcat1n(__VA_ARGS__))
 #define  LOG_INFOF(...) _LOG_INFO(sprintf(__VA_ARGS__))
 #define _LOG_INFO(s) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                dprint(_LOG_HEADER("^5INFO")); \
                string __s = s; \
                print("\n^7", __s); \
                /* TODO: unconditionally add a newline when possible */ \
                if (str2chr(__s, strlen(__s) - 1) != '\n') { print("\n"); } \
-       MACRO_END
+       MACRO_END
 
 #define  LOG_TRACE(...) _LOG_TRACE(strcat1n(__VA_ARGS__))
 #define  LOG_TRACEF(...) _LOG_TRACE(sprintf(__VA_ARGS__))
@@ -84,9 +83,9 @@ string(string, string...) strcat1n = #115;
 #define _LOG_DEBUG(s) _LOG(dprint2, "^2DEBUG", s)
 
 #define dprint2(msg) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                if (autocvar_developer > 1) dprint(msg); \
-       MACRO_END
+       MACRO_END
 
 // TODO: this sucks, lets find a better way to do backtraces?
 #define _backtrace() builtin_remove(NULL)
@@ -102,7 +101,6 @@ noref bool autocvar_prvm_backtraceforwarnings;
 
 #define backtrace(msg) \
        MACRO_BEGIN \
-       { \
                int dev = autocvar_developer; \
                bool war = autocvar_prvm_backtraceforwarnings; \
                bt_cvar_set("developer", "1"); \
@@ -112,4 +110,4 @@ noref bool autocvar_prvm_backtraceforwarnings;
                print("\n--- CUT UNTIL HERE ---\n"); \
                bt_cvar_set("developer", ftos(dev)); \
                bt_cvar_set("prvm_backtraceforwarnings", ftos(war)); \
-       MACRO_END
+       MACRO_END
index f20b1c66e5bf120be7748737dabe8b9e8dec9f88..00d08bdcd35304bcb9013610c7826d0cc6dfc3d3 100644 (file)
@@ -2,12 +2,17 @@
 
 #include "lib/float.qh"
 
+// uncrustify doesn't like the ** operator so let's wrap it in this wonderful macro
+// *INDENT-OFF*
+#define POW(a, e) ((a) ** (e))
+// *INDENT-ON*
+
 ERASEABLE
 void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight)
 {
        if (weight == 0) return;
-       if (mean == 0) e.(a) *= (value ** weight);
-       else e.(a) += (value ** mean) * weight;
+       if (mean == 0) e.(a) *= POW(value, weight);
+       else e.(a) += POW(value, mean) * weight;
        e.(c) += weight;
 }
 
@@ -15,8 +20,8 @@ ERASEABLE
 float mean_evaluate(entity e, .float a, .float c, float mean)
 {
        if (e.(c) == 0) return 0;
-       if (mean == 0) return (e.(a) ** (1.0 / e.(c)));
-       else return ((e.(a) / e.(c)) ** (1.0 / mean));
+       if (mean == 0) return POW(e.(a), (1.0 / e.(c)));
+       else return POW((e.(a) / e.(c)), (1.0 / mean));
 }
 
 #define MEAN_ACCUMULATE(s, prefix, v, w) mean_accumulate(s, prefix##_accumulator, prefix##_count, prefix##_mean, v, w)
@@ -210,12 +215,12 @@ float almost_in_bounds(float a, float b, float c)
 ERASEABLE
 float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
 {
-       if (halflifedist > 0) return (0.5 ** ((bound(mindist, d, maxdist) - mindist) / halflifedist));
-       else if (halflifedist < 0) return (0.5 ** ((bound(mindist, d, maxdist) - maxdist) / halflifedist));
+       if (halflifedist > 0) return POW(0.5, ((bound(mindist, d, maxdist) - mindist) / halflifedist));
+       else if (halflifedist < 0) return POW(0.5, ((bound(mindist, d, maxdist) - maxdist) / halflifedist));
        else return 1;
 }
 
-#define power2of(e) (2 ** e)
+#define power2of(e) POW(2, e)
 
 ERASEABLE
 float log2of(float e)
index 6c29a4b88dd100f74ded51a0fe91ad82179c7d25..2825d7ddf2137e2485873f9d95d546791bc96fbe 100644 (file)
@@ -37,9 +37,8 @@
 // With block may not contain continue or break
 #define WITH(type, name, value, block) \
        MACRO_BEGIN \
-       { \
                type __with_save = (name); \
                name = (value); \
                LAMBDA(block) \
                name = __with_save; \
-       MACRO_END
+       MACRO_END
index b1f5326a9bb5a441b5094de347cfe973086d5bd6..bc253eb209b9372a521e06db9eb10fc1a1b551b6 100644 (file)
@@ -188,13 +188,13 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
        const int MSG_C2S = 0;
 
        #define Net_Accept(classname) \
-               MACRO_BEGIN \
+               MACRO_BEGIN \
                        if (!this)    this = new(classname); \
-               MACRO_END
+               MACRO_END
        #define Net_Reject() \
-               MACRO_BEGIN \
+               MACRO_BEGIN \
                        if (this)     delete(this); \
-               MACRO_END
+               MACRO_END
 
        string g_buf;
 
@@ -209,16 +209,16 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
 
 #if defined(CSQC)
        #define WriteHeader(to, id) \
-               MACRO_BEGIN \
+               MACRO_BEGIN \
                        WriteByte(to, NET_##id.m_id); \
-               MACRO_END
+               MACRO_END
 #elif defined(SVQC)
        #define WriteHeader(to, id) \
-               MACRO_BEGIN \
+               MACRO_BEGIN \
                        if (NET_##id##_istemp) WriteByte(to, SVC_TEMPENTITY); \
                        WriteByte(to, NET_##id.m_id); \
                        bool _net_valid = false; serialize_marker(to, _net_valid); \
-               MACRO_END
+               MACRO_END
 #endif
 
 // serialization: new style
@@ -381,8 +381,8 @@ MACRO_END
                }
 
         #define WriteFloat(to, f) WriteCoord(to, f)
-               #define WriteVector(to, v) MACRO_BEGIN { WriteFloat(to, v.x); WriteFloat(to, v.y); WriteFloat(to, v.z); } MACRO_END
-        #define WriteVector2D(to, v) MACRO_BEGIN { WriteFloat(to, v.x); WriteFloat(to, v.y); } MACRO_END
+               #define WriteVector(to, v) MACRO_BEGIN WriteFloat(to, v.x); WriteFloat(to, v.y); WriteFloat(to, v.z); MACRO_END
+        #define WriteVector2D(to, v) MACRO_BEGIN WriteFloat(to, v.x); WriteFloat(to, v.y); MACRO_END
 
                // this will use the value:
                //   128
@@ -407,7 +407,7 @@ MACRO_END
                }
 
                // allow writing to also pass through to spectators (like so spectators see the same centerprints as players for example)
-               #define WRITESPECTATABLE_MSG_ONE(to, statement) MACRO_BEGIN \
+               #define WRITESPECTATABLE_MSG_ONE(to, statement) MACRO_BEGIN \
                        entity prev = msg_entity; \
                        entity dst = to; \
                        FOREACH_CLIENT(IS_REAL_CLIENT(it), { \
@@ -418,6 +418,6 @@ MACRO_END
                                } \
                        }); \
                        msg_entity = prev; \
-               MACRO_END
+               MACRO_END
        #endif
 #endif
index 782798c9fe5c492799d0892f4f1f5cc3f155731d..53026be4d279ca0b7360426a30d3fafb2d2c22af 100644 (file)
@@ -20,9 +20,9 @@ float Noise_Pink(entity e, float dt)
        float f;
        f = dt * 60;
        // http://home.earthlink.net/~ltrammell/tech/pinkalg.htm
-       if (random() > (0.3190 ** f)) e.noise_paccum = 0.34848 * (2 * random() - 1);
-       if (random() > (0.7756 ** f)) e.noise_paccum2 = 0.28768 * (2 * random() - 1);
-       if (random() > (0.9613 ** f)) e.noise_paccum3 = 0.43488 * (2 * random() - 1);
+       if (random() > POW(0.3190, f)) e.noise_paccum = 0.34848 * (2 * random() - 1);
+       if (random() > POW(0.7756, f)) e.noise_paccum2 = 0.28768 * (2 * random() - 1);
+       if (random() > POW(0.9613, f)) e.noise_paccum3 = 0.43488 * (2 * random() - 1);
        return e.noise_paccum + e.noise_paccum2 + e.noise_paccum3;
 }
 ERASEABLE
@@ -34,6 +34,6 @@ float Noise_White(entity e, float dt)
 ERASEABLE
 float Noise_Burst(entity e, float dt, float p)
 {
-       if (random() > (p ** dt)) e.noise_bstate = !e.noise_bstate;
+       if (random() > POW(p, dt)) e.noise_bstate = !e.noise_bstate;
        return 2 * e.noise_bstate - 1;
 }
index f57bf8e909c4e7d1a594a0e36f2415b715483fda..51ff00c30f3d983bfbb21fc0375f18a5ff3814cf 100644 (file)
@@ -9,14 +9,12 @@
 /** @deprecated use new_pure or NEW(class) */
 #define make_pure(e) \
        MACRO_BEGIN \
-       { \
                (e).pure_data = true; \
-       MACRO_END
+       MACRO_END
 #define make_impure(e) \
        MACRO_BEGIN \
-       { \
                (e).pure_data = false; \
-       MACRO_END
+       MACRO_END
 #define is_pure(e) ((e).pure_data)
 
 .string classname;
@@ -77,13 +75,13 @@ entity __spawn(string _classname, string _sourceLoc, bool pure)
        #define delete_fn builtin_remove
 #endif
 
-#define delete(this) MACRO_BEGIN \
+#define delete(this) MACRO_BEGIN \
     entity _this = (this); \
     void(entity) _dtor = _this.dtor; \
     ONREMOVE(this); \
     if (_dtor) _dtor(_this); else delete_fn(_this); \
     /* this = NULL; */  \
-MACRO_END
+MACRO_END
 
 entity _clearentity_ent;
 STATIC_INIT(clearentity)
index 2d41e5d431b3ba9c7b63ccbb87268a4b96615267..100f82b673c3e45fdec5dfc5df4f8f055c1d9811 100644 (file)
@@ -89,20 +89,20 @@ REGISTRY(Registries, BITS(8))
        ACCUMULATE_FUNCTION(_Register##registry, Register_##id) \
        REGISTER_INIT(id)
 
-#define REGISTRY_PUSH(registry, fld, it) MACRO_BEGIN \
+#define REGISTRY_PUSH(registry, fld, it) MACRO_BEGIN \
        it.fld = registry##_COUNT; \
        _R_SET(_##registry, registry##_COUNT, it); \
        ++registry##_COUNT; \
        if (!registry##_first) registry##_first = it; \
        if (registry##_last)   registry##_last.REGISTRY_NEXT = it; \
        registry##_last = it; \
-MACRO_END
+MACRO_END
 
-#define REGISTRY_RESERVE(registry, fld, id, suffix) MACRO_BEGIN \
+#define REGISTRY_RESERVE(registry, fld, id, suffix) MACRO_BEGIN \
        entity e = new_pure(registry_reserved); \
        e.registered_id = #id "/" #suffix; \
        REGISTRY_PUSH(registry, fld, e); \
-MACRO_END
+MACRO_END
 
 #define REGISTER_INIT(id) [[accumulate]] void Register_##id##_init(entity this)
 
index 565ebb29c81513276a8f49334cfebd2589cb0986..cd0000912dfcfb65b715bcfabebf889d29144adc 100644 (file)
@@ -10,16 +10,14 @@ void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
 {
        #define heapify(_count) \
                MACRO_BEGIN \
-               { \
                        for (int start = floor(((_count) - 2) / 2); start >= 0; --start) \
                        { \
                                siftdown(start, (_count) - 1); \
                        } \
-               MACRO_END
+               MACRO_END
 
        #define siftdown(_start, _end) \
                MACRO_BEGIN \
-               { \
                        for (int root = (_start); root * 2 + 1 <= (_end); ) \
                        { \
                                int child = root * 2 + 1; \
@@ -28,7 +26,7 @@ void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
                                swap(root, child, pass); \
                                root = child; \
                        } \
-               MACRO_END
+               MACRO_END
 
        heapify(n);
        int end = n - 1;
index 1100c474cb9eb49074cd85d08431fd0f0ba61012..1273a26191d241992c5aacfc1f21165bb1a2e80c 100644 (file)
@@ -73,16 +73,16 @@ int g_magic_stats_hole = 0;
        #define addstat_int(id, fld) addstat(id, AS_INT, fld)
        #define addstat_bool(id, fld) addstat(id, AS_INT, fld)
        #define addstat_float(id, fld) addstat(id, AS_FLOAT, fld)
-       #define addstat_vector(id, fld) MACRO_BEGIN \
+       #define addstat_vector(id, fld) MACRO_BEGIN \
                addstat_float(id + 0, fld##_x); \
                addstat_float(id + 1, fld##_y); \
                addstat_float(id + 2, fld##_z); \
-       MACRO_END
-       #define addstat_vectori(id, fld) MACRO_BEGIN \
+       MACRO_END
+       #define addstat_vectori(id, fld) MACRO_BEGIN \
                addstat_int(id + 0, fld##_x); \
                addstat_int(id + 1, fld##_y); \
                addstat_int(id + 2, fld##_z); \
-       MACRO_END
+       MACRO_END
        const int AS_STRING = 1;
        const int AS_INT = 2;
        const int AS_FLOAT = 8;
index ff6f2d23d5b52f1e00d75ba699c6552031ba8f5b..f0fef90c84d0070e9337115efdfb2dc677635f62 100644 (file)
@@ -26,7 +26,7 @@ bool RUN_ALL_TESTS();
 
 // difference between expect/assert: assert returns early
 
-#define EXPECT_EQ(expected_, actual_) MACRO_BEGIN \
+#define EXPECT_EQ(expected_, actual_) MACRO_BEGIN \
        int expected = expected_; \
        int actual = actual_; \
        if ((expected) != (actual)) { \
@@ -37,7 +37,7 @@ bool RUN_ALL_TESTS();
                        actual, expected \
                )); \
        } \
-MACRO_END
+MACRO_END
 #define ASSERT_EQ(expected, actual) _TEST_ASSERT(EXPECT_EQ(expected, actual))
 
 #define EXPECT_TRUE(condition) EXPECT_EQ(true, condition)
@@ -72,18 +72,18 @@ bool TEST_ok;
 int TEST_failed;
 
 #define _TEST_ASSERT(statement) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                LAMBDA(statement); \
                ++TEST_fatal; return; \
-       MACRO_END
+       MACRO_END
 
 #define EXPECT_NO_FATAL_FAILURE__(statement, then) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                int TEST_prevfatal = TEST_fatal; \
                LAMBDA(statement); \
                if (TEST_fatal != TEST_prevfatal) \
                        LAMBDA(then); \
-       MACRO_END
+       MACRO_END
 
 #define EXPECT_NO_FATAL_FAILURE_(statement, then) \
        EXPECT_NO_FATAL_FAILURE__(statement, { \
index 8340381bab3aff467e543a1fdf1d1c19eacf1463..0d09ea8e6a50767bf181376b671423a9b7918070 100644 (file)
@@ -93,12 +93,12 @@ float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { ret
 #define YAW(v) ((v).y)
 #define ROLL(v) ((v).z)
 
-#define MAKEVECTORS(f, angles, forward, right, up) MACRO_BEGIN \
+#define MAKEVECTORS(f, angles, forward, right, up) MACRO_BEGIN \
        f(angles); \
        forward = v_forward; \
        right = v_right; \
        up = v_up; \
-MACRO_END
+MACRO_END
 
 //pseudo prototypes:
 // vector vec2(vector v); // returns a vector with just the x and y components of the given vector
index acbc1c61d4dda0f69cb0d256467f16bc2808cb07..71fc258581f20163fcf4f73f2ece934103d3f2c8 100644 (file)
@@ -1,8 +1,6 @@
 #include "mathlib.qh"
-#if defined(CSQC)
-#elif defined(MENUQC)
-#elif defined(SVQC)
-#endif
+
+#include <lib/math.qh>
 
 int fpclassify(float e)
 {
@@ -63,11 +61,11 @@ float tanh(float e)
 
 float exp(float e)
 {
-       return (M_E ** e);
+       return POW(M_E, e);
 }
 float exp2(float e)
 {
-       return (2 ** e);
+       return POW(2, e);
 }
 float expm1(float e)
 {
@@ -79,7 +77,7 @@ vector frexp(float e)
        vector v;
        v.z = 0;
        v.y = ilogb(e) + 1;
-       v.x = e / (2 ** v.y);
+       v.x = e / POW(2, v.y);
        return v;
 }
 int ilogb(float e)
@@ -88,7 +86,7 @@ int ilogb(float e)
 }
 float ldexp(float e, int e)
 {
-       return e * (2 ** e);
+       return e * POW(2, e);
 }
 float logn(float e, float base)
 {
@@ -117,12 +115,12 @@ vector modf(float f)
 
 float scalbn(float e, int n)
 {
-       return e * (2 ** n);
+       return e * POW(2, n);
 }
 
 float cbrt(float e)
 {
-       return copysign((fabs(e) ** (1.0/3.0)), e);
+       return copysign(POW(fabs(e), (1.0/3.0)), e);
 }
 float hypot(float e, float f)
 {
index 6db6122352511d9640ac75baf603103a4e96ce65..e15fd4707e14ff27fd1a48509f99cf15b13d1bab 100644 (file)
 .float warpzone_teleport_finishtime;
 .entity warpzone_teleport_zone;
 
-#define WarpZone_StoreProjectileData(e_) MACRO_BEGIN \
+#define WarpZone_StoreProjectileData(e_) MACRO_BEGIN \
        entity e = e_; \
        e.warpzone_oldorigin = e.origin; \
        e.warpzone_oldvelocity = e.velocity; \
        e.warpzone_oldangles = e.angles; \
-       MACRO_END
+       MACRO_END
 
 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
 {
index a8389e240f4e9ec0041ae5609a75c2ee9baae84a..29338666ec064a4d61817b85e47b7e58a9afc97a 100644 (file)
@@ -3,7 +3,7 @@
 #include "test.qh"
 
 #define yenc_single(c, ret) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                int conv = c; \
                conv += 42; \
                if (conv >= 256) conv -= 256; \
                                break; \
                        } \
                } \
-       MACRO_END
+       MACRO_END
 
 #define ydec_single(stringiter, ret) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                int conv = STRING_ITERATOR_GET(stringiter); \
                if (conv <= 0) { \
                        ret = -1; \
@@ -44,7 +44,7 @@
                        conv -= 42; \
                        ret = conv; \
                } \
-       MACRO_END
+       MACRO_END
 
 TEST(yEnc, EncodeDecode)
 {
index 1f28a1bdfede23aa181f110ca297596457a85976..0ebf03965cc62be63e4e35bf6bbcb198d2bd92db 100644 (file)
@@ -18,13 +18,13 @@ void Xonotic_KeyBinds_Read()
 {
        Xonotic_KeyBinds_Count = 0;
 
-       #define KEYBIND_DEF(func, desc) MACRO_BEGIN \
+       #define KEYBIND_DEF(func, desc) MACRO_BEGIN \
                if((Xonotic_KeyBinds_Count < MAX_KEYBINDS)) { \
                        Xonotic_KeyBinds_Functions[Xonotic_KeyBinds_Count] = strzone(func); \
                        Xonotic_KeyBinds_Descriptions[Xonotic_KeyBinds_Count] = strzone(desc); \
                        ++Xonotic_KeyBinds_Count; \
                } \
-       MACRO_END
+       MACRO_END
 
        KEYBIND_DEF(""                                      , _("Moving"));
        KEYBIND_DEF("+forward"                              , _("forward"));
index c6b7c1e8cc7b5cbaaace86d9bb4cd5fedd8b4e06..5611079335c5930ceaf50e07180d0eb71a6464aa 100644 (file)
@@ -18,8 +18,8 @@ float texmemsize(float s3tc)
 {
        return
        (
-                 2500 * (0.25 ** max(0, cvar("gl_picmip") + cvar("gl_picmip_other")))
-               + 1500 * (0.25 ** max(0, cvar("gl_picmip") + cvar("gl_picmip_world")))
+                 2500 * POW(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_other")))
+               + 1500 * POW(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_world")))
        ) * ((s3tc && (cvar("r_texture_dds_load") || cvar("gl_texturecompression"))) ? 0.2 : 1.0); // TC: normalmaps 50%, other 25%, few incompressible, guessing 40% as conservative average
 }
 void XonoticPicmipSlider_autofix(entity me)
index 8f2abb3f824b5745448a5fb4c16ab21545e5451b..ddd0afa826103e65e94cffb8becb94caa8b38a4a 100644 (file)
@@ -283,7 +283,7 @@ float bot_aimdir(entity this, vector v, float maxfiredeviation)
        blendrate = autocvar_bot_ai_aimskill_blendrate;
        r = max(fixedrate, blendrate);
        //this.v_angle = this.v_angle + diffang * bound(frametime, r * frametime * (2+skill*skill*0.05-random()*0.05*(10-skill)), 1);
-       this.v_angle = this.v_angle + diffang * bound(delta_t, r * delta_t * (2 + ((skill + this.bot_mouseskill) ** 3) * 0.005 - random()), 1);
+       this.v_angle = this.v_angle + diffang * bound(delta_t, r * delta_t * (2 + POW((skill + this.bot_mouseskill), 3) * 0.005 - random()), 1);
        this.v_angle = this.v_angle * bound(0,autocvar_bot_ai_aimskill_mouse,1) + desiredang * bound(0,(1-autocvar_bot_ai_aimskill_mouse),1);
        //this.v_angle = this.v_angle + diffang * bound(0, r * frametime * (skill * 0.5 + 2), 1);
        //this.v_angle = this.v_angle + diffang * (1/ blendrate);
index f8ddd0c637576d81efb058e330c11922d9438a56..bbf35b4f7d8300f3b563f5baed6716507d3a75f5 100644 (file)
@@ -72,7 +72,7 @@ void bot_think(entity this)
        if(autocvar_bot_god)
                this.flags |= FL_GODMODE;
 
-       this.bot_nextthink = max(time, this.bot_nextthink) + max(0.01, autocvar_bot_ai_thinkinterval * (0.5 ** this.bot_aiskill) * min(14 / (skill + 14), 1));
+       this.bot_nextthink = max(time, this.bot_nextthink) + max(0.01, autocvar_bot_ai_thinkinterval * POW(0.5, this.bot_aiskill) * min(14 / (skill + 14), 1));
 
        //if (this.bot_painintensity > 0)
        //      this.bot_painintensity = this.bot_painintensity - (skill + 1) * 40 * frametime;
@@ -216,13 +216,13 @@ void bot_setnameandstuff(entity this)
 
        prio = 6;
 
-       #define READSKILL(f, w, r) MACRO_BEGIN \
+       #define READSKILL(f, w, r) MACRO_BEGIN \
                if(argv(prio) != "") \
                        this.f = stof(argv(prio)) * w; \
                else \
                        this.f = (!autocvar_g_campaign) * (2 * random() - 1) * r * w; \
                prio++; \
-       MACRO_END
+       MACRO_END
        //print(bot_name, ": ping=", argv(9), "\n");
 
        READSKILL(havocbot_keyboardskill, 0.5, 0.5); // keyboard skill
index 46acf8828774324f3790596ce465576f6c6c7b77..9c17ce01145c0200931db301770fc97108b390d2 100644 (file)
@@ -471,7 +471,7 @@ void havocbot_movetogoal(entity this)
                        dxy = this.origin - ( ( this.goalcurrent.absmin + this.goalcurrent.absmax ) * 0.5 ); dxy.z = 0;
                        d = vlen(dxy);
                        v = vlen(this.velocity -  this.velocity.z * '0 0 1');
-                       db = ((v ** 2) / (autocvar_g_jetpack_acceleration_side * 2)) + 100;
+                       db = (POW(v, 2) / (autocvar_g_jetpack_acceleration_side * 2)) + 100;
                //      dprint("distance ", ftos(ceil(d)), " velocity ", ftos(ceil(v)), " brake at ", ftos(ceil(db)), "\n");
                        if(d < db || d < 500)
                        {
@@ -1143,7 +1143,7 @@ void havocbot_chooseweapon(entity this, .entity weaponentity)
                this.lastcombotime = time;
        }
 
-       distance *= (2 ** this.bot_rangepreference);
+       distance *= POW(2, this.bot_rangepreference);
 
        // Custom weapon list based on distance to the enemy
        if(bot_custom_weapon){
index e69050beb84d16e438e12f5849184139f792195c..3d9aa50d356d4fb02bd0a7fc0207b0f1121330cc 100644 (file)
@@ -896,7 +896,7 @@ float bot_cmd_keypress_handler(entity this, string key, float enabled)
        {
                case "all":
                        if(enabled)
-                               this.bot_cmd_keys = (2 ** 20) - 1; // >:)
+                               this.bot_cmd_keys = POW(2, 20) - 1; // >:)
                        else
                                this.bot_cmd_keys = BOT_CMD_KEY_NONE;
                case "forward":
index 3233a141dd9e1b14b71437c49e016ed77d6acf2e..bed06f190317378b24d072a46e1fecfc5bfc05f1 100644 (file)
@@ -886,7 +886,7 @@ void Drag_Begin(entity dragger, entity draggee, vector touchpoint)
        dragger.dragdistance = vlen(touchpoint - dragger.origin - dragger.view_ofs);
        dragger.draglocalangle = draggee.angles.y - dragger.v_angle.y;
        touchpoint = touchpoint - gettaginfo(draggee, 0);
-       tagscale = (vlen(v_forward) ** -2);
+       tagscale = POW(vlen(v_forward), -2);
        dragger.draglocalvector_x = touchpoint * v_forward * tagscale;
        dragger.draglocalvector_y = touchpoint * v_right * tagscale;
        dragger.draglocalvector_z = touchpoint * v_up * tagscale;
@@ -968,7 +968,7 @@ void Drag_MoveForward(entity dragger)
 
 void Drag_SetSpeed(entity dragger, float s)
 {
-       dragger.dragspeed = (2 ** s);
+       dragger.dragspeed = POW(2, s);
 }
 
 void Drag_MoveBackward(entity dragger)
index 02704629612f32eaec198bca03857447a7ba337f..2fd4679846a5d45eb163428dc772bc7f5c1ee156 100644 (file)
@@ -1026,7 +1026,7 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
                                                        LOG_INFOF("THROUGHFLOOR: D=%f F=%f max(dD)=1/%f max(dF)=1/%f", finaldmg, vlen(force), mininv_d, mininv_f);
 
 
-                                               total = 0.25 * (max(mininv_f, mininv_d) ** 2);
+                                               total = 0.25 * POW(max(mininv_f, mininv_d), 2);
 
                                                if(autocvar_g_throughfloor_debug)
                                                        LOG_INFOF(" steps=%f", total);
index ce25dfa522772b08e3f1dfb41dcc2a536a2f4902..a669bf61471286864921cda3834ba87e75cc49d8 100644 (file)
@@ -910,7 +910,7 @@ spawnfunc(worldspawn)
                        s = cons(s, pkg);
                }
                // add automatically managed files to the list
-               #define X(match) MACRO_BEGIN \
+               #define X(match) MACRO_BEGIN \
                        int fd = search_begin(match, true, false); \
                        if (fd >= 0) \
                        { \
@@ -920,7 +920,7 @@ spawnfunc(worldspawn)
                                } \
                                search_end(fd); \
                        } \
-               MACRO_END
+               MACRO_END
                X("*-serverpackage.txt");
                X("*.serverpackage");
                #undef X
@@ -1157,7 +1157,7 @@ float(float exponent) MaplistMethod_Shuffle = // more clever shuffling
                string newlist;
 
                // now reinsert this at another position
-               insertpos = (random() ** (1 / exponent));       // ]0, 1]
+               insertpos = POW(random(), (1 / exponent));       // ]0, 1]
                insertpos = insertpos * (Map_Count - 1);       // ]0, Map_Count - 1]
                insertpos = ceil(insertpos) + 1;               // {2, 3, 4, ..., Map_Count}
                LOG_TRACE("SHUFFLE: insert pos = ", ftos(insertpos));
index 479e608b73697b25845d9c522e1fa05e4948c7af..4416e3cf1ca6b549fda43866d3a27a0d5e0f5f4a 100644 (file)
@@ -1289,7 +1289,7 @@ void attach_sameorigin(entity e, entity to, string tag)
     float tagscale;
 
     org = e.origin - gettaginfo(to, gettagindex(to, tag));
-    tagscale = (vlen(v_forward) ** -2); // undo a scale on the tag
+    tagscale = POW(vlen(v_forward), -2); // undo a scale on the tag
     t_forward = v_forward * tagscale;
     t_left = v_right * -tagscale;
     t_up = v_up * tagscale;
index 15b6e0f4a6251d81a94d9501858abca0ee0ae602..443c8feec2a2b49bc945037e5134d314fc20a926 100644 (file)
@@ -130,7 +130,7 @@ void kh_update_state()
                        f = key.team;
                else
                        f = 30;
-               s |= (32 ** key.count) * f;
+               s |= POW(32, key.count) * f;
        }
 
        FOREACH_CLIENT(true, { it.kh_state = s; });
@@ -138,7 +138,7 @@ void kh_update_state()
        FOR_EACH_KH_KEY(key)
        {
                if(key.owner)
-                       key.owner.kh_state |= (32 ** key.count) * 31;
+                       key.owner.kh_state |= POW(32, key.count) * 31;
        }
        //print(ftos((nextent(NULL)).kh_state), "\n");
 }
@@ -863,7 +863,7 @@ int kh_GetMissingTeams()
                                ++players;
                });
                if (!players)
-                       missing_teams |= (2 ** i);
+                       missing_teams |= POW(2, i);
        }
        return missing_teams;
 }
index b25a65f1a7c127f348e897c392d4db2f00fb6734..7951a12e8d2c125d3687b76ae4d728bae51652d2 100644 (file)
@@ -119,7 +119,7 @@ float TeamScore_AddToTeam(float t, float scorefield, float score)
        }
        if(score)
                if(teamscores_label(scorefield) != "")
-                       s.SendFlags |= (2 ** scorefield);
+                       s.SendFlags |= POW(2, scorefield);
        return (s.(teamscores(scorefield)) += score);
 }
 
@@ -266,7 +266,7 @@ float PlayerScore_Clear(entity player)
        FOREACH(Scores, true, {
                if(sk.(scores(it)) != 0)
                        if(scores_label(it) != "")
-                               sk.SendFlags |= (2 ** (i % 16));
+                               sk.SendFlags |= POW(2, (i % 16));
                if(i != SP_ELO.m_id)
                        sk.(scores(it)) = 0;
        });
@@ -284,7 +284,7 @@ void Score_ClearAll()
                FOREACH(Scores, true, {
                        if(sk.(scores(it)) != 0)
                                if(scores_label(it) != "")
-                                       sk.SendFlags |= (2 ** (i % 16));
+                                       sk.SendFlags |= POW(2, (i % 16));
                        if(i != SP_ELO.m_id)
                                sk.(scores(it)) = 0;
                });
@@ -298,7 +298,7 @@ void Score_ClearAll()
                {
                        if(sk.(teamscores(j)) != 0)
                                if(teamscores_label(j) != "")
-                                       sk.SendFlags |= (2 ** j);
+                                       sk.SendFlags |= POW(2, j);
                        sk.(teamscores(j)) = 0;
                }
        }
@@ -345,7 +345,7 @@ float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
                return s.(scores(scorefield));
        }
        if(scores_label(scorefield) != "")
-               s.SendFlags |= (2 ** (scorefield.m_id % 16));
+               s.SendFlags |= POW(2, (scorefield.m_id % 16));
        if(!warmup_stage)
                PS_GR_P_ADDVAL(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score);
        s.(scores(scorefield)) += score;
index cd393b64196a1cbab9f0128623f3ef8be7adc612..220cb551f965f2d21545cb61bbb03ed26bd35af8 100644 (file)
@@ -320,7 +320,7 @@ entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exp
 
        RandomSelection_Init();
        for(spot = firstspot; spot; spot = spot.chain)
-               RandomSelection_AddEnt(spot, (bound(lower, spot.spawnpoint_score.y, upper) ** exponent) * spot.cnt, (spot.spawnpoint_score.y >= lower) * 0.5 + spot.spawnpoint_score.x);
+               RandomSelection_AddEnt(spot, POW(bound(lower, spot.spawnpoint_score.y, upper), exponent) * spot.cnt, (spot.spawnpoint_score.y >= lower) * 0.5 + spot.spawnpoint_score.x);
 
        return RandomSelection_chosen_ent;
 }
index 4a603c02256d244dd69fca54040a80b9f4faeed1..abc156ae0942de8f82b6747b8daa2a8d05ce9ffb 100644 (file)
@@ -32,14 +32,14 @@ const string STR_OBSERVER = "observer";
 // 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 \
+       MACRO_BEGIN \
                for(int _i = 1; _i <= maxclients; ++_i) \
                { \
                        const noref int i = _i; \
                        ITER_CONST noref entity it = ftoe(i); \
-                       if(cond) { LAMBDA(body) } \
+                       if(cond) { LAMBDA(body); } \
                } \
-       MACRO_END
+       MACRO_END
 
 #define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), LAMBDA(body))
 
@@ -48,7 +48,7 @@ const string STR_OBSERVER = "observer";
 entity _FCR_clients[255];
 bool _FCR_entered = false;
 #define FOREACH_CLIENT_RANDOM(cond, body) \
-       MACRO_BEGIN \
+       MACRO_BEGIN \
                if (_FCR_entered) LOG_FATAL("FOREACH_CLIENT_RANDOM must not be nested"); \
                _FCR_entered = true; \
                int _cnt = 0; \
@@ -69,9 +69,9 @@ bool _FCR_entered = false;
                { \
                        const noref int i = _i; \
                        ITER_CONST noref entity it = _FCR_clients[i]; \
-                       if (cond) { LAMBDA(body) } \
+                       if (cond) { LAMBDA(body); } \
                } \
                _FCR_entered = false; \
-       MACRO_END
+       MACRO_END
 
 // NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: IL_EACH(g_monsters, true, { code; });
diff --git a/qcsrc/tools/unc-macro-fix.py b/qcsrc/tools/unc-macro-fix.py
new file mode 100755 (executable)
index 0000000..898583b
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+# Removes redundant { and } from macros because uncrustify is too dumb to indent them properly (or even not touch them).
+# Actually, after running this, you might wanna put some back, for cases like `MACRO_BEGIN { ++this##_i; } MACRO_END`,
+# otherwise it ends up like MACRO_BEGIN++ ... sigh'
+
+# all those fancy unix utilities like grep, sed and awk are either woefully inadequate for this or just completely
+# unreadable with their arcane syntaxes - and yes, the plural is intentional because why extend existing tools
+# when you can write your own with incompatible flags, commands and regex flavors, pass strings between them
+# and call it the unix "philosophy"
+
+import re
+import glob
+
+all_files = set(glob.glob("**/*.qc", recursive=True) + glob.glob("**/*.qh", recursive=True))
+all_files = {f for f in all_files if not f.startswith('qcsrc/dpdefs')}
+
+for file_name in all_files:
+       with open(file_name, "r+") as f:
+               s = f.read()
+               s = re.sub(r"MACRO_BEGIN *(?:\\\s*)?{((?:.|\n)*?)} *(?:\\\s*)?MACRO_END", r"MACRO_BEGIN\1MACRO_END", s)
+               f.seek(0)
+               f.truncate()
+               f.write(s)
diff --git a/qcsrc/tools/uncrustify-unmodified.py b/qcsrc/tools/uncrustify-unmodified.py
new file mode 100755 (executable)
index 0000000..c9c5584
--- /dev/null
@@ -0,0 +1,92 @@
+#!/usr/bin/env python3
+
+# Finds files that are not modified on any branch and formats them.
+
+# You should be on master or a branch that just merged master since we want to avoid conflicts when merging other branches into master.
+
+# If you're on Windows, you probably wanna fix path separators and maybe other tihngs, I am not touching that.
+
+from datetime import datetime, timedelta, timezone
+from dateutil import parser
+import glob
+import os.path
+import shlex
+import subprocess
+
+def main():
+       if not os.path.exists("qcsrc"):
+               # otherwise the files reported by different commands would have different prefixes
+               print("Must be run in data repo root (xonotic-data.pk3dir)")
+               return
+
+       # get the latest changes on all branches
+       run('git fetch')
+
+       # get all remote branches - those would potentially get merge conflicts if we formatted everything
+       branches = run('git branch --list --remotes')
+       # strip the leading spaces and ignore branches that are presumably used for debugging uncrustify
+       branches = [b.strip() for b in branches if "uncrustify" not in b]
+       branches.remove('origin/HEAD -> origin/master')
+       branches.remove('origin/master')
+
+       all_files = set(glob.glob("**/*.qc", recursive=True) + glob.glob("**/*.qh", recursive=True))
+       all_files = {f for f in all_files if not f.startswith('qcsrc/dpdefs')}
+       modified_files = set()
+
+       for branch in branches:
+               print(branch)
+
+               # getting this info is a bit slow
+               last_change_str = run(r'git show --pretty=format:"%ci" {}'.format(branch))[0]
+               print("\t last change:", last_change_str)
+
+               last_change = parser.parse(last_change_str)
+               if datetime.now(timezone.utc) - last_change > timedelta(days=365*2):  # who cares about leap years
+                       print("\t ignoring")
+                       continue
+
+               # If some complex branching and merging happens, there can be multiple merge bases.
+               # The diff between each of them and the tip of the branch can contain changes that are not in master
+               # and could cause conflicts.
+               merge_bases = run('git merge-base --all origin/master {}'.format(branch))
+               for base in merge_bases:
+                       print("\t", base)
+
+                       # with --name-only it shows only the new name when renaming so the order matters
+                       # i guess diff from branch to base should be enough but let's be sure
+                       files1 = set(run('git diff --name-only {} {}'.format(base, branch)))
+                       files2 = set(run('git diff --name-only {} {}'.format(branch, base)))
+                       files = {f for f in files1.union(files2) if f.endswith(".qc") or f.endswith(".qh")}
+
+                       for f in sorted(files):
+                               print("\t\t", f)
+
+                       modified_files = modified_files.union(files)
+
+       # modified files contain newly added files so the number of remaining files will be larger than all - modified
+       remaining_files = all_files - modified_files
+       nonexistent_files = modified_files - all_files
+
+       print("all on master ({}):".format(len(all_files)))
+       for f in sorted(all_files):
+               print("\t", f)
+
+       print("modified on branches ({}):".format(len(modified_files)))
+       for f in sorted(modified_files):
+               print("\t", f)
+
+       print("modified files that don't exist on master ({}):".format(len(nonexistent_files)))
+       for f in sorted(nonexistent_files):
+               print("\t", f)
+
+       print("formatting on master ({}):".format(len(remaining_files)))
+       for f in sorted(remaining_files):
+               print("\t", f)
+               run("bash qcsrc/tools/uncrustify.sh {}".format(shlex.quote(f)))
+
+def run(cmd: str) -> [str]:
+       process = subprocess.Popen(shlex.split(cmd), stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+       stdout, stderr = process.communicate()
+       return stdout.decode().splitlines()
+
+main()
index b598727223ee7321209bbc9360e9d32cd833a565..0bcab10d6109a90597b0fd5544f465ca2e9df4a7 100644 (file)
@@ -51,7 +51,7 @@ indent_continue                          = indent_columns # number
 # 0=spaces only
 # 1=indent with tabs to brace level, align with spaces
 # 2=indent and align with tabs, using spaces when not on a tabstop
-indent_with_tabs                         = 1        # number #force
+indent_with_tabs                         = 2        # number #force
 
 # Comments that are not a brace level are indented with tabs on a tabstop.
 # Requires indent_with_tabs=2. If false, will use spaces.
@@ -217,7 +217,9 @@ indent_paren_nl                          = false    # false/true #force
 # 0: Indent to body level
 # 1: Align under the open paren
 # 2: Indent to the brace level
-indent_paren_close                       = 1        # number #force
+# note: i think option 2 is still buggy but it results in the fewest changes
+# so presumably it aligns well with what we already use
+indent_paren_close                       = 2        # number #force
 
 # Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren
 # WARNING: Code doesn't seem to use this feature - delete from the config?
@@ -809,7 +811,7 @@ sp_after_new                             = ignore   # ignore/add/remove/force
 sp_before_tr_emb_cmt                     = force    # ignore/add/remove/force #force
 
 # Number of spaces before a trailing or embedded comment
-sp_num_before_tr_emb_cmt                 = 2        # number #force
+sp_num_before_tr_emb_cmt                 = 1        # number #force
 
 # Control space between a Java annotation and the open paren.
 # WARNING: Code doesn't seem to use this feature - delete from the config?
@@ -1185,14 +1187,14 @@ nl_brace_brace                           = remove   # ignore/add/remove/force
 
 # Add or remove newline between 'do' and '{'
 # NOTE: is 3 worse than ignore
-nl_do_brace                              = add      # ignore/add/remove/force
+nl_do_brace                              = remove   # ignore/add/remove/force
 
 # Add or remove newline between '}' and 'while' of 'do' statement
-nl_brace_while                           = add      # ignore/add/remove/force #force
+nl_brace_while                           = remove   # ignore/add/remove/force #force
 
 # Add or remove newline between 'switch' and '{'
 # NOTE: is 24 worse than ignore
-nl_switch_brace                          = add      # ignore/add/remove/force
+nl_switch_brace                          = remove      # ignore/add/remove/force
 
 # Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc.
 # Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace.
@@ -1436,7 +1438,9 @@ pos_class_colon                          = ignore   # ignore/join/lead/lead_brea
 #
 
 # Try to limit code width to N number of columns
-code_width                               = 120      # number
+# I think a human makes a better call here than uncrustify, with 120 everything just ends up wrapped randomly and it's harder to read
+# old code that was written by clearly insane people will just have to be fixed manually
+code_width                               = 1200      # number
 
 # Whether to fully split long 'for' statements at semi-colons
 # WARNING: Code doesn't seem to use this feature - delete from the config?
@@ -1748,7 +1752,7 @@ cmt_insert_before_preproc                = false    # false/true
 
 # Control indent of preprocessors inside #if blocks at brace level 0
 # WARNING: Indifferent... please decide manually.
-pp_indent                                = force    # ignore/add/remove/force
+pp_indent                                = ignore    # ignore/add/remove/force
 
 # Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false)
 pp_indent_at_level                       = false    # false/true
@@ -1778,10 +1782,10 @@ pp_region_indent_code                    = true    # false/true
 pp_indent_if                             = 4        # number
 
 # Control whether to indent the code between #if, #else and #endif when not at file-level
-pp_if_indent_code                        = true    # false/true
+pp_if_indent_code                        = false    # false/true
 
 # Whether to indent '#define' at the brace level (true) or from column 1 (false)
-pp_define_at_level                       = true     # false/true
+pp_define_at_level                       = false     # false/true
 
 # You can force a token to be a type with the 'type' option.
 # Example:
@@ -1817,6 +1821,9 @@ type .string
 macro-open CLASS
 macro-close ENDCLASS
 
+macro-open MACRO_BEGIN
+macro-close MACRO_END
+
 # translations
 set func_call_user _