From dac5dae255cdb904fa79487faf1c03059e0639b8 Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Sat, 28 Oct 2017 18:13:05 +0200 Subject: [PATCH] get overlapping matches, manually fix edge cases with comments --- qcsrc/client/hud/panel/infomessages.qc | 4 +- qcsrc/server/player.qc | 8 ++-- qcsrc/tools/unc-chained-if-fix.py | 54 +++++++++++++------------- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index 545da6f3c..f21af442c 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -205,9 +205,7 @@ void HUD_InfoMessages() } } - if(autocvar_cl_showspectators) - if(num_spectators) - //if(spectatee_status != -1) + if(autocvar_cl_showspectators && num_spectators /*&& spectatee_status != -1*/) { s = ((spectatee_status) ? _("^1Spectating this player:") : _("^1Spectating you:")); // InfoMessage(s) diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index d9226f343..95ee0152e 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -436,10 +436,10 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, } } - if(sound_allowed(MSG_BROADCAST, attacker)) - if(this.health < 25 || !(DEATH_WEAPONOF(deathtype).spawnflags & WEP_FLAG_CANCLIMB) || take > 20 || attacker != this) - if(this.health > 1) - // exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two + if (sound_allowed(MSG_BROADCAST, attacker) + // exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two + && (this.health < 25 || !(DEATH_WEAPONOF(deathtype).spawnflags & WEP_FLAG_CANCLIMB) || take > 20 || attacker != this) + && this.health > 1) { if(deathtype == DEATH_FALL.m_id) PlayerSound(this, playersound_fall, CH_PAIN, VOL_BASE, VOICETYPE_PLAYERSOUND); diff --git a/qcsrc/tools/unc-chained-if-fix.py b/qcsrc/tools/unc-chained-if-fix.py index 9dc6e8fb6..45e81cfac 100755 --- a/qcsrc/tools/unc-chained-if-fix.py +++ b/qcsrc/tools/unc-chained-if-fix.py @@ -54,51 +54,49 @@ if(?[\t ]*) # the first if ) \n )+ -(? - [\t ]* -) -(? - [^{}\n].*\n -| - \{ - (? # the more options here and inside, the fewer results because some overlap - [^{}]* - | - [^{}]* - \{ - (?&block)* - \} - [^{}]* - | - (?: +(?= + (? + [\t ]* + ) + (? + [^{}\n].*\n + | + \{ + (? [^{}]* - \{ + | [^{}]* + \{ + (?&block)* \} [^{}]* + | + (?: + [^{}]* + \{ + [^{}]* + \} + [^{}]* + )+ )+ - )+ - \} + \} + ) ) """, regex.VERBOSE) -# TODO remove and rerun to see overlapping # TODO try removing \n from nested exprs def count_indents(whitespace: str): - print("counting: >{}<".format(whitespace)) - print("type:", type(whitespace)) count = 0.0 for c in whitespace: - print(ord(c)) if c == '\t': count += 1.0 elif c == ' ': count += 0.25 else: - print("WARNING - non whitespace: >{}<".format(c)) + assert False if not count.is_integer(): - print("WARNING - not integer") + print("WARNING - non-integer sized indent") return count @@ -148,9 +146,11 @@ for file_name in all_files: print("first comm:", first_comment) print("other conds:", other_conds) print("other comms:", other_comments) - print("then:", then) # TODO check for comments + print("then:", then) if then.startswith("if"): print("WARNING - then if", count_indents(indent), count_indents(then_indent)) + if then.startswith("//") or then.startswith("/*"): + print("WARNING - then comment", count_indents(indent), count_indents(then_indent)) #print("captures expr1:", match.captures('expr1')) #print("captures expr2:", match.captures('expr2')) #if logical_ops: # TODO per cond -- 2.39.2