From 9a502b2b9be023833212363c9ce74a3471d4b9dc Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 22 Mar 2016 19:15:50 +1100 Subject: [PATCH] Use macros for labels --- qcsrc/client/hud/hud_config.qc | 2 +- qcsrc/client/scoreboard.qc | 4 ++-- qcsrc/client/view.qc | 2 +- qcsrc/common/command/rpn.qc | 4 ++-- qcsrc/common/mutators/mutator/itemstime.qc | 2 +- qcsrc/common/physics/player.qc | 2 +- qcsrc/common/t_items.qc | 6 +++--- qcsrc/lib/compiler.qh | 6 ++++++ qcsrc/lib/warpzone/common.qc | 4 ++-- qcsrc/menu/item/nexposee.qc | 2 +- qcsrc/menu/menu.qc | 2 +- qcsrc/menu/xonotic/campaign.qc | 4 ++-- qcsrc/server/bot/havocbot/havocbot.qc | 2 +- qcsrc/server/bot/waypoints.qc | 2 +- qcsrc/server/ipban.qc | 6 +++--- qcsrc/server/mutators/mutator/gamemode_keyhunt.qc | 2 +- qcsrc/server/sv_main.qc | 2 +- 17 files changed, 30 insertions(+), 24 deletions(-) diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index 8e69a2dec..07166105e 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -774,7 +774,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) vector candidate_pos = '0 0 0'; const float LEVELS_NUM = 4; float level_height = vid_conheight / LEVELS_NUM; -:find_tab_panel +LABEL(find_tab_panel) level = floor(tab_panel_pos.y / level_height) * level_height; //starting level candidate_pos.x = (!tab_backward) ? vid_conwidth : 0; start_posX = tab_panel_pos.x; diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index c49fa65fc..a41c91f77 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -410,7 +410,7 @@ void Cmd_HUD_SetFields(int argc) if(str == strtolower(scores_label[j])) goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code" -:notfound +LABEL(notfound) if(str == "frags") j = SP_FRAGS; else @@ -419,7 +419,7 @@ void Cmd_HUD_SetFields(int argc) LOG_INFOF("^1Error:^7 Unknown score field: '%s'\n", str); continue; } -:found +LABEL(found) hud_field[hud_num_fields] = j; if(j == ps_primary) have_primary = 1; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 6e8487b96..8d001cb59 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -994,7 +994,7 @@ void HUD_Crosshair() wcross_color = rainbow_prev_color; break; } - :normalcolor +LABEL(normalcolor) default: { wcross_color = stov(autocvar_crosshair_color); break; } } diff --git a/qcsrc/common/command/rpn.qc b/qcsrc/common/command/rpn.qc index 1ca075bbb..12bb99d1d 100644 --- a/qcsrc/common/command/rpn.qc +++ b/qcsrc/common/command/rpn.qc @@ -437,7 +437,7 @@ void GenericCommand_rpn(float request, float argc, string command) if(argv(i) == argv(j)) goto skip_union; s = strcat(s, " ", argv(i)); - :skip_union +LABEL(skip_union) } if(substring(s, 0, 1) == " ") s = substring(s, 1, 99999); @@ -480,7 +480,7 @@ void GenericCommand_rpn(float request, float argc, string command) if(argv(i) == argv(j)) goto skip_difference; s = strcat(s, " ", argv(i)); - :skip_difference +LABEL(skip_difference) } if(substring(s, 0, 1) == " ") s = substring(s, 1, 99999); diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc index e6599e614..6c7eb4d76 100644 --- a/qcsrc/common/mutators/mutator/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -367,7 +367,7 @@ void HUD_ItemsTime() id = it.m_id; icon = it.m_icon; - :iteration +LABEL(iteration) float item_time = ItemsTime_time[id]; if (item_time < -1) { diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 253010c0c..545d71a21 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -1532,7 +1532,7 @@ void PM_Main(entity this) else PM_air(this, buttons_prev, maxspeed_mod); -:end +LABEL(end) if (IS_ONGROUND(this)) this.lastground = time; diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index e2bafb82f..a381324f8 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -644,7 +644,7 @@ float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax return false; -:YEAH +LABEL(YEAH) switch(mode) { case ITEM_MODE_FUEL: @@ -740,7 +740,7 @@ float Item_GiveTo(entity item, entity player) player.superweapons_finished = max(player.superweapons_finished, time) + item.superweapons_finished; } -:skip +LABEL(skip) // always eat teamed entities if(item.team) @@ -811,7 +811,7 @@ void Item_Touch() return; } - :pickup +LABEL(pickup) other.last_pickup = time; diff --git a/qcsrc/lib/compiler.qh b/qcsrc/lib/compiler.qh index 14824dc5a..7cd34bc84 100644 --- a/qcsrc/lib/compiler.qh +++ b/qcsrc/lib/compiler.qh @@ -11,3 +11,9 @@ #define QCC_SUPPORT_NIL #endif #endif + +#ifdef GMQCC + #define LABEL(id) :id +#else + #define LABEL(id) id: +#endif diff --git a/qcsrc/lib/warpzone/common.qc b/qcsrc/lib/warpzone/common.qc index e5cd1515a..7309ff79b 100644 --- a/qcsrc/lib/warpzone/common.qc +++ b/qcsrc/lib/warpzone/common.qc @@ -320,7 +320,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end, org = trace_endpos; } WarpZone_MakeAllOther(); -:fail +LABEL(fail) if(contentshack) BITCLR_ASSIGN(WarpZone_trace_forent.dphitcontentsmask, DPCONTENTS_SOLID); trace_startsolid = sol; @@ -438,7 +438,7 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo e.velocity = -e.velocity; } WarpZone_MakeAllOther(); -:fail +LABEL(fail) WarpZone_tracetoss_velocity = e.velocity; v_forward = vf; v_right = vr; diff --git a/qcsrc/menu/item/nexposee.qc b/qcsrc/menu/item/nexposee.qc index 3e3575f4f..c0f18cf85 100644 --- a/qcsrc/menu/item/nexposee.qc +++ b/qcsrc/menu/item/nexposee.qc @@ -67,7 +67,7 @@ } break; - : have_overlap +LABEL(have_overlap) } scale *= 0.95; diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 70c8aedc4..e523a5193 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -399,7 +399,7 @@ void drawBackground(string img, float a, string algn, float force1) draw_Picture_Aligned(v, scalemode, strcat(img, "_l", ftos(l + 1)), a); } ++l; - : nopic +LABEL(nopic) } } diff --git a/qcsrc/menu/xonotic/campaign.qc b/qcsrc/menu/xonotic/campaign.qc index b6dfc60b0..cb418a4e1 100644 --- a/qcsrc/menu/xonotic/campaign.qc +++ b/qcsrc/menu/xonotic/campaign.qc @@ -37,11 +37,11 @@ void rewrapCampaign(float w, float l0, float emptyheight, vector theFontSize) } } goto nottoolong; -:toolong +LABEL(toolong) while(substring(r, strlen(r) - 1, 1) == "\n") r = substring(r, 0, strlen(r) - 1); r = strcat(r, "...\n"); -:nottoolong +LABEL(nottoolong) campaign_longdesc_wrapped[i] = strzone(substring(r, 0, strlen(r) - 1)); } } diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index a2e1372da..e83007d9b 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -917,7 +917,7 @@ void havocbot_chooseenemy() while(true) { scan_secondary_targets = false; - :scan_targets +LABEL(scan_targets) for( ; head; head = head.chain) { if(!scan_secondary_targets) diff --git a/qcsrc/server/bot/waypoints.qc b/qcsrc/server/bot/waypoints.qc index a19b2a095..0abc94a0d 100644 --- a/qcsrc/server/bot/waypoints.qc +++ b/qcsrc/server/bot/waypoints.qc @@ -1109,7 +1109,7 @@ void botframe_deleteuselesswaypoints() goto next; } } -:next +LABEL(next) } } // d) The waypoint is a dead end. Dead end waypoints must be kept as diff --git a/qcsrc/server/ipban.qc b/qcsrc/server/ipban.qc index deffa8e03..d129d994f 100644 --- a/qcsrc/server/ipban.qc +++ b/qcsrc/server/ipban.qc @@ -192,7 +192,7 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data) LOG_INFO("Ban list syncing: accepted ban of ", ip, " by ", serverip, " at ", uri, ": "); LOG_INFO(reason, "\n"); -:skip +LABEL(skip) } } @@ -242,7 +242,7 @@ void OnlineBanList_Think() goto killme; return; -:killme +LABEL(killme) remove(self); } @@ -380,7 +380,7 @@ float Ban_GetClientIP(entity client) ban_ip4 = strcat1(s); // 32 return true; -:ipv6 +LABEL(ipv6) i1 = strstrofs(s, ":", 0); if(i1 < 0) return false; diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index 34ed909b6..d1316d288 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -760,7 +760,7 @@ void kh_Key_Think() // runs all the time if(vlen(key.owner.origin - p) > autocvar_g_balance_keyhunt_maxdist) goto not_winning; kh_WinnerTeam(self.team); -:not_winning +LABEL(not_winning) } if(kh_interferemsg_time && time > kh_interferemsg_time) diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index ad1b4588e..4aa404d75 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -348,7 +348,7 @@ void SV_OnEntityPreSpawnFunction() } } inv = !inv; -:cvar_fail +LABEL(cvar_fail) // now inv is 1 if we want to keep the item, and 0 if we want to get rid of it if (!inv) { -- 2.39.2