From 165d542813201a21cb6152ea5d22454e43e117c7 Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 30 Jan 2015 16:09:41 +1100 Subject: [PATCH] Remove for-loop workaround --- qcsrc/client/bgmscript.qc | 2 +- qcsrc/client/hud.qc | 2 +- qcsrc/client/sortlist.qc | 2 +- qcsrc/client/view.qc | 2 +- qcsrc/common/mapinfo.qc | 8 ++++---- qcsrc/common/notifications.qc | 2 +- qcsrc/common/util.qc | 2 +- qcsrc/menu/item/listbox.qc | 6 +++--- qcsrc/menu/xonotic/colorpicker.qc | 2 +- qcsrc/server/bot/havocbot/role_onslaught.qc | 4 ++-- qcsrc/server/bot/navigation.qc | 6 +++--- qcsrc/server/bot/scripting.qc | 2 +- qcsrc/server/bot/waypoints.qc | 2 +- qcsrc/server/command/sv_cmd.qc | 12 ++++++------ qcsrc/server/command/vote.qc | 2 +- qcsrc/server/g_subs.qc | 2 +- qcsrc/server/g_tetris.qc | 2 +- qcsrc/server/g_world.qc | 2 +- qcsrc/server/miscfunctions.qc | 4 ++-- qcsrc/server/mutators/gamemode_assault.qc | 2 +- qcsrc/server/mutators/sandbox.qc | 2 +- qcsrc/server/scores.qc | 2 +- qcsrc/server/weapons/tracing.qc | 2 +- qcsrc/warpzonelib/common.qc | 4 ++-- qcsrc/warpzonelib/server.qc | 2 +- 25 files changed, 40 insertions(+), 40 deletions(-) diff --git a/qcsrc/client/bgmscript.qc b/qcsrc/client/bgmscript.qc index fe6a1c14a..b567190ca 100644 --- a/qcsrc/client/bgmscript.qc +++ b/qcsrc/client/bgmscript.qc @@ -206,7 +206,7 @@ float BGMScript(entity e) } // find the CURRENT line - for(0;;) + for (;;) { tokenize_console(bufstr_get(bgmscriptbuf, e.bgmscriptline)); if(stof(argv(1)) >= bgmtime || argv(0) != e.bgmscript) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 492b0d435..e33b9b020 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -3779,7 +3779,7 @@ void HUD_InfoMessages(void) tm = teams.sort_next; if (tm) { - for(0; tm.sort_next; tm = tm.sort_next) + for (; tm.sort_next; tm = tm.sort_next) { if(!tm.team_size || tm.team == NUM_SPECTATOR) continue; diff --git a/qcsrc/client/sortlist.qc b/qcsrc/client/sortlist.qc index 7093ee07d..4d05d2c5f 100644 --- a/qcsrc/client/sortlist.qc +++ b/qcsrc/client/sortlist.qc @@ -91,7 +91,7 @@ void Sort_Finish(entity sort) entity Sort_Get(entity sort, float i) { - for(0; sort.sort_next && i > 0; --i) + for (; sort.sort_next && i > 0; --i) sort = sort.sort_next; return sort; } diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index da621ebff..bc84c6e66 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -54,7 +54,7 @@ void Porto_Draw() portal_number = 0; nextdir = dir; - for(0;;) + for (;;) { dir = nextdir; traceline(p, p + 65536 * dir, true, porto); diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 43e81cbf9..366f35ed6 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -272,7 +272,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp mapMins = '0 0 0'; mapMaxs = '0 0 0'; - for(0;;) + for (;;) { if (!((s = fgets(fh)))) break; @@ -806,7 +806,7 @@ void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, print("Map ", pFilename, " references not existing config file ", s, "\n"); else { - for(0;;) + for (;;) { if (!((s = fgets(fh)))) break; @@ -949,7 +949,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, int p { n = tokenize_console(cvar_string("g_cdtracks_remaplist")); s = strcat(" ", cvar_string("g_cdtracks_dontusebydefault"), " "); - for(0;;) + for (;;) { i = floor(random() * n); if(strstrofs(s, strcat(" ", argv(i), " "), 0) < 0) @@ -997,7 +997,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, int p } _MapInfo_Map_Reset(); - for(0;;) + for (;;) { if (!((s = fgets(fh)))) break; diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 356039bb6..9e98c61d5 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -322,7 +322,7 @@ string Process_Notif_Args( string selected, remaining = args; float sel_num = 0; - for(0;(remaining != "");) + for (;(remaining != "");) { selected = car(remaining); remaining = cdr(remaining); diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 1bbf648a6..64813f2f4 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -2556,7 +2556,7 @@ void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t queue_end.FindConnectedComponent_processing = 1; // for each queued item: - for(0; queue_start; queue_start = queue_start.fld) + for (; queue_start; queue_start = queue_start.fld) { // find all neighbors of queue_start entity t; diff --git a/qcsrc/menu/item/listbox.qc b/qcsrc/menu/item/listbox.qc index 5eb945e39..2f2979509 100644 --- a/qcsrc/menu/item/listbox.qc +++ b/qcsrc/menu/item/listbox.qc @@ -131,7 +131,7 @@ float ListBox_keyDown(entity me, float key, float ascii, float shift) { float i = me.selectedItem; float a = me.getItemHeight(me, i); - for(0;;) + for (;;) { --i; if (i < 0) @@ -146,7 +146,7 @@ float ListBox_keyDown(entity me, float key, float ascii, float shift) { float i = me.selectedItem; float a = me.getItemHeight(me, i); - for(0;;) + for (;;) { ++i; if (i >= me.nItems) @@ -369,7 +369,7 @@ void ListBox_draw(entity me) float y; i = me.getItemAtPos(me, me.scrollPos); y = me.getItemStart(me, i) - me.scrollPos; - for(0; i < me.nItems && y < 1; ++i) + for (; i < me.nItems && y < 1; ++i) { draw_shift = boxToGlobal(eY * y, oldshift, oldscale); vector relSize = eX * (1 - me.controlWidth) + eY * me.getItemHeight(me, i); diff --git a/qcsrc/menu/xonotic/colorpicker.qc b/qcsrc/menu/xonotic/colorpicker.qc index 36d779744..6634728f3 100644 --- a/qcsrc/menu/xonotic/colorpicker.qc +++ b/qcsrc/menu/xonotic/colorpicker.qc @@ -73,7 +73,7 @@ vector color_hslimage(vector v, vector margin) float XonoticColorpicker_mouseDrag(entity me, vector coords) { float i, carets; - for(0;;) + for (;;) { i = me.controlledTextbox.cursorPos; if(i >= 2) diff --git a/qcsrc/server/bot/havocbot/role_onslaught.qc b/qcsrc/server/bot/havocbot/role_onslaught.qc index 55da31783..119ea83c8 100644 --- a/qcsrc/server/bot/havocbot/role_onslaught.qc +++ b/qcsrc/server/bot/havocbot/role_onslaught.qc @@ -118,7 +118,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale) cp1 = cp2 = findchain(classname, "onslaught_controlpoint"); // Filter control points - for(0; cp2; cp2 = cp2.chain) + for (; cp2; cp2 = cp2.chain) { cp2.wpcost = c = 0; cp2.wpconsidered = false; @@ -154,7 +154,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale) // We'll consider only the best case bestvalue = 99999999999; cp = world; - for(0; cp1; cp1 = cp1.chain) + for (; cp1; cp1 = cp1.chain) { if (!cp1.wpconsidered) continue; diff --git a/qcsrc/server/bot/navigation.qc b/qcsrc/server/bot/navigation.qc index e1c667972..d80f8336c 100644 --- a/qcsrc/server/bot/navigation.qc +++ b/qcsrc/server/bot/navigation.qc @@ -64,7 +64,7 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float // Movement loop yaw = vectoyaw(move); move = end - org; - for(0;;) + for (;;) { if (boxesoverlap(end, end, org + m1 + '-1 -1 -1', org + m2 + '1 1 1')) { @@ -108,7 +108,7 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float { swimming = true; org = trace_endpos - normalize(org - trace_endpos) * stepdist; - for(0; org.z < end.z + self.maxs.z; org.z += stepdist) + for (; org.z < end.z + self.maxs.z; org.z += stepdist) { if(autocvar_bot_debug_tracewalk) debugnode(org); @@ -880,7 +880,7 @@ float navigation_routetogoal(entity e, vector startposition) if(e == world) return false; - for(0;;) + for (;;) { // add the spawnfunc_waypoint to the path navigation_pushroute(e); diff --git a/qcsrc/server/bot/scripting.qc b/qcsrc/server/bot/scripting.qc index 16a015c8d..ead8ceac9 100644 --- a/qcsrc/server/bot/scripting.qc +++ b/qcsrc/server/bot/scripting.qc @@ -39,7 +39,7 @@ void bot_queuecommand(entity bot, string cmdstring) if(cmdstr == "sound") { // find the LAST word - for(0;;) + for (;;) { sp = strstrofs(parm, " ", 0); if(sp < 0) diff --git a/qcsrc/server/bot/waypoints.qc b/qcsrc/server/bot/waypoints.qc index 3ce236c22..23e7af3f9 100644 --- a/qcsrc/server/bot/waypoints.qc +++ b/qcsrc/server/bot/waypoints.qc @@ -985,7 +985,7 @@ float botframe_autowaypoints_fix_from(entity p, float walkfromwp, entity wp, .en tmin = 0; tmax = 1; - for(0;;) + for (;;) { if(tmax - tmin < 0.001) { diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 3825e6553..7166ab7cf 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -108,7 +108,7 @@ void GameCommand_adminmsg(float request, float argc) if((targets) && (admin_message)) { - for(0;targets;) + for (;targets;) { t = car(targets); targets = cdr(targets); @@ -1047,7 +1047,7 @@ void GameCommand_moveplayer(float request, float argc) // lets see if the target(s) even actually exist. if((targets) && (destination)) { - for(0;targets;) + for (;targets;) { t = car(targets); targets = cdr(targets); @@ -1400,7 +1400,7 @@ void GameCommand_shuffleteams(float request) // build a list of the players in a random order FOR_EACH_PLAYER(tmp_player) { - for(0;;) + for (;;) { i = bound(1, floor(random() * maxclients) + 1, maxclients); @@ -1542,7 +1542,7 @@ void GameCommand_trace(float request, float argc) float hitcount = 0; print("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.\n"); float worst_endpos_bug = 0; - for(0;;) + for (;;) { org = world.mins; delta = world.maxs - world.mins; @@ -1571,7 +1571,7 @@ void GameCommand_trace(float request, float argc) // how much do we need to back off? safe = 1; unsafe = 0; - for(0;;) + for (;;) { pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5); tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world); @@ -1605,7 +1605,7 @@ void GameCommand_trace(float request, float argc) q0 = p; dq = 0; dqf = 1; - for(0;;) + for (;;) { q = p + normalize(end - p) * (dq + dqf); if(q == q0) diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index a0b3fec6e..4238f2828 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -637,7 +637,7 @@ float VoteCommand_checkargs(float startpos, float argc) p = strstrofs(cmdrestriction, ";", 0); // find first semicolon - for(0;;) + for (;;) { // we know that at any time, startpos <= argc - minargs // so this means: argc-minargs >= startpos >= argc, thus diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index a7cedc807..74a8cf7f9 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -543,7 +543,7 @@ float tracebox_inverted (vector v1, vector mi, vector ma, vector v2, float nomon float c; c = 0; - for(0;;) + for (;;) { if(pos * dir >= v2 * dir) { diff --git a/qcsrc/server/g_tetris.qc b/qcsrc/server/g_tetris.qc index bbfd2fbc6..63e498bfc 100644 --- a/qcsrc/server/g_tetris.qc +++ b/qcsrc/server/g_tetris.qc @@ -901,7 +901,7 @@ void CompletedLines() cleared = 0; y = TET_LINES; - for(0;;) + for (;;) { ln = GetLine(y); if(strstrofs(ln, "0", 0) < 0) diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 65d43baa2..0a2708340 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -476,7 +476,7 @@ void detect_maptype() vector o, v; float i; - for(0;;) + for (;;) { o = world.mins; o.x += random() * (world.maxs.x - world.mins.x); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 7196b94f0..bcbae77ea 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -522,7 +522,7 @@ vector randompos(vector m1, vector m2) float sound_allowed(float _dest, entity e) { // sounds from world may always pass - for(0;;) + for (;;) { if (e.classname == "body") e = e.enemy; @@ -944,7 +944,7 @@ void InitializeEntity(entity e, void(void) func, float order) cur = initialize_entity_first; prev = world; - for(0;;) + for (;;) { if (!cur || cur.initialize_entity_order > order) { diff --git a/qcsrc/server/mutators/gamemode_assault.qc b/qcsrc/server/mutators/gamemode_assault.qc index b64219ddf..49deac0e8 100644 --- a/qcsrc/server/mutators/gamemode_assault.qc +++ b/qcsrc/server/mutators/gamemode_assault.qc @@ -338,7 +338,7 @@ void havocbot_goalrating_ast_targets(float ratingscale) ad = findchain(classname, "func_assault_destructible"); - for(0; ad; ad = ad.chain) + for (; ad; ad = ad.chain) { if (ad.target == "") continue; diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 776ba42e7..f66b5019a 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -393,7 +393,7 @@ void sandbox_Database_Load() } else { - for(0;;) + for (;;) { file_read = fgets(file_get); if(file_read == "") diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 0b5d0ee8c..8f9da8b06 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -835,7 +835,7 @@ void Score_NicePrint_Player(entity to, entity p, float w) sk = p.scorekeeper; s = strcat(s, p.netname); - for(0;;) + for (;;) { i = strlennocol(s) - NAMEWIDTH; if(i > 0) diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 3085af120..c3532d3d6 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -378,7 +378,7 @@ void fireBullet(vector start, vector dir, float spread, float max_solid_penetrat WarpZone_trace_forent = self; - for(0;;) + for (;;) { // TODO also show effect while tracing WarpZone_TraceBox_ThroughZone(start, '0 0 0', '0 0 0', end, false, WarpZone_trace_forent, world, fireBullet_trace_callback); diff --git a/qcsrc/warpzonelib/common.qc b/qcsrc/warpzonelib/common.qc index c36ca5c62..aa0de9119 100644 --- a/qcsrc/warpzonelib/common.qc +++ b/qcsrc/warpzonelib/common.qc @@ -272,7 +272,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end, sol = -1; frac = 0; i = 16; - for(0;;) + for (;;) { if(--i < 1) { @@ -395,7 +395,7 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo } WarpZone_MakeAllSolid(); i = 16; - for(0;;) + for (;;) { if(--i < 1) { diff --git a/qcsrc/warpzonelib/server.qc b/qcsrc/warpzonelib/server.qc index 090db021b..5d529c12e 100644 --- a/qcsrc/warpzonelib/server.qc +++ b/qcsrc/warpzonelib/server.qc @@ -847,7 +847,7 @@ void WarpZone_StartFrame() if(IS_NOT_A_CLIENT(e)) { if(warpzone_warpzones_exist) - for(0; (e = nextent(e)); ) + for (; (e = nextent(e)); ) WarpZone_StoreProjectileData(e); break; } -- 2.39.2