]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
More BITs (and less variables)
authorterencehill <piuntn@gmail.com>
Wed, 6 Sep 2017 15:17:22 +0000 (17:17 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 6 Sep 2017 15:17:22 +0000 (17:17 +0200)
qcsrc/client/main.qc
qcsrc/client/mapvoting.qc
qcsrc/server/command/vote.qc
qcsrc/server/scores.qc

index 9fc26c5648f5fa9add1b877e97b6fa8114749e0e..988cdf35e07294a78239bf81188660a1244c8ef0 100644 (file)
@@ -471,11 +471,10 @@ NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
        int sf = ReadShort();
        int lf = ReadShort();
 #endif
-       int p;
-       for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
-               if(sf & p)
+       for(i = 0; i < MAX_TEAMSCORE; ++i)
+               if(sf & BIT(i))
                {
-                       if(lf & p)
+                       if(lf & BIT(i))
                                o.(teamscores(i)) = ReadInt24_t();
                        else
                                o.(teamscores(i)) = ReadChar();
@@ -587,7 +586,7 @@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
                for(i = 1; i <= maxclients; i += 8)
                {
                        f = ReadByte();
-                       for(j = i-1, b = 1; b < 256; b *= 2, ++j)
+                       for(j = i-1, b = BIT(0); b < BIT(8); b <<= 1, ++j)
                                if (!(f & b))
                                        if(playerslots[j])
                                                playerslots[j].ready = 0;
index b34bd0f3a1476b9fda20e2da89b0c7249c648a03..87b6d585b38c769cd8d20d65d0be24ad3303d52d 100644 (file)
@@ -563,7 +563,7 @@ void MapVote_ReadMask()
        int i;
        if ( mv_num_maps < 24 )
        {
-               int mask, power;
+               int mask;
                if(mv_num_maps < 8)
                        mask = ReadByte();
                else if(mv_num_maps < 16)
@@ -571,9 +571,9 @@ void MapVote_ReadMask()
                else
                        mask = ReadLong();
 
-               for(i = 0, power = 1; i < mv_num_maps; ++i, power *= 2)
+               for(i = 0; i < mv_num_maps; ++i)
                {
-                       if ( mask & power )
+                       if (mask & BIT(i))
                                mv_flags[i] |= GTV_AVAILABLE;
                        else
                                mv_flags[i] &= ~GTV_AVAILABLE;
index 8cfed5bae4bb06e1c15e15ead247605aaa08481f..1a786cc7fe7891631c567af18cc817345105853c 100644 (file)
@@ -81,8 +81,9 @@ bool Nagger_SendEntity(entity this, entity to, float sendflags)
        {
                for (i = 1; i <= maxclients; i += 8)
                {
-                       for (f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
-                               if (!IS_REAL_CLIENT(e) || e.ready) f |= b;
+                       for (f = 0, e = edict_num(i), b = BIT(0); b < BIT(8); b <<= 1, e = nextent(e))
+                               if (!IS_REAL_CLIENT(e) || e.ready)
+                                       f |= b;
                        WriteByte(MSG_ENTITY, f);
                }
        }
index 266f7734b660bae45bad90f29514a869ef182b46..11bc60238252bb071cbade6518384a3ac8cbb47c 100644 (file)
@@ -54,7 +54,7 @@ vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags,
 
 bool TeamScore_SendEntity(entity this, entity to, float sendflags)
 {
-       float i, p, longflags;
+       float i, longflags;
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_TEAMSCORES);
        int t = this.team - 1;
@@ -62,9 +62,9 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags)
        WriteByte(MSG_ENTITY, t);
 
        longflags = 0;
-       for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
+       for(i = 0; i < MAX_TEAMSCORE; ++i)
                if(this.(teamscores(i)) > 127 || this.(teamscores(i)) <= -128)
-                       longflags |= p;
+                       longflags |= BIT(i);
 
 #if MAX_TEAMSCORE <= 8
        WriteByte(MSG_ENTITY, sendflags);
@@ -73,10 +73,10 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags)
        WriteShort(MSG_ENTITY, sendflags);
        WriteShort(MSG_ENTITY, longflags);
 #endif
-       for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
-               if(sendflags & p)
+       for(i = 0; i < MAX_TEAMSCORE; ++i)
+               if(sendflags & BIT(i))
                {
-                       if(longflags & p)
+                       if(longflags & BIT(i))
                                WriteInt24_t(MSG_ENTITY, this.(teamscores(i)));
                        else
                                WriteChar(MSG_ENTITY, this.(teamscores(i)));