mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-01-31 13:00:52 +00:00
Use memcmp instead of self-built while loop
This commit is contained in:
parent
9541fca878
commit
797d127dfc
1 changed files with 4 additions and 17 deletions
|
@ -389,7 +389,6 @@ Compare without port, and up to the bit number given in netmask.
|
||||||
*/
|
*/
|
||||||
qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask)
|
qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask)
|
||||||
{
|
{
|
||||||
qboolean differed;
|
|
||||||
byte cmpmask, *addra, *addrb;
|
byte cmpmask, *addra, *addrb;
|
||||||
int curbyte;
|
int curbyte;
|
||||||
|
|
||||||
|
@ -421,24 +420,12 @@ qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask)
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
differed = qfalse;
|
curbyte = netmask >> 3;
|
||||||
curbyte = 0;
|
|
||||||
|
|
||||||
while(netmask > 7)
|
if(curbyte && memcmp(addra, addrb, curbyte))
|
||||||
{
|
return qfalse;
|
||||||
if(addra[curbyte] != addrb[curbyte])
|
|
||||||
{
|
|
||||||
differed = qtrue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
curbyte++;
|
|
||||||
netmask -= 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(differed)
|
|
||||||
return qfalse;
|
|
||||||
|
|
||||||
|
netmask &= ~0x07;
|
||||||
if(netmask)
|
if(netmask)
|
||||||
{
|
{
|
||||||
cmpmask = (1 << netmask) - 1;
|
cmpmask = (1 << netmask) - 1;
|
||||||
|
|
Loading…
Reference in a new issue