]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
get overlapping matches, manually fix edge cases with comments
authorMartin Taibr <taibr.martin@gmail.com>
Sat, 28 Oct 2017 16:13:05 +0000 (18:13 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Sat, 28 Oct 2017 16:13:05 +0000 (18:13 +0200)
qcsrc/client/hud/panel/infomessages.qc
qcsrc/server/player.qc
qcsrc/tools/unc-chained-if-fix.py

index 545da6f3c1c5ff563ea8d1dee1471146440efed9..f21af442cf88f5f24b55060aae138b44d2b11d87 100644 (file)
@@ -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)
index d9226f3437e351bec049ea26b5747b333f2530ad..95ee0152ef76483aadab5ce41cf0558822cb1097 100644 (file)
@@ -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);
index 9dc6e8fb69464183921374ac49b5f77d68f24988..45e81cfac86b1eb9bbee8c6203dcca802442998b 100755 (executable)
@@ -54,51 +54,49 @@ if(?<ws>[\t ]*)                     # the first if
     )
     \n
 )+
-(?<then_indent>
-    [\t ]*
-)
-(?<then>
-    [^{}\n].*\n
-|
-    \{
-        (?<block>           # the more options here and inside, the fewer results because some overlap
-            [^{}]*
-        |
-            [^{}]*
-            \{
-                (?&block)*
-            \}
-            [^{}]*
-        |
-            (?:
+(?=
+    (?<then_indent>
+        [\t ]*
+    )
+    (?<then>
+        [^{}\n].*\n
+    |
+        \{
+            (?<block>
                 [^{}]*
-                \{
+            |
                 [^{}]*
+                \{
+                    (?&block)*
                 \}
                 [^{}]*
+            |
+                (?:
+                    [^{}]*
+                    \{
+                    [^{}]*
+                    \}
+                    [^{}]*
+                )+
             )+
-        )+
-    \}
+        \}
+    )
 )
 """, regex.VERBOSE)
 
-# TODO remove <then> 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