]> jfr.im git - irc/gameservirc.git/blob - gameserv/hash.cpp
updated the Change log w/ new additions
[irc/gameservirc.git] / gameserv / hash.cpp
1 #include "extern.h"
2 #include "aClient.h"
3 #include <ctype.h>
4
5 unsigned long sHASH(const unsigned char *name);
6 unsigned long iHASH(const unsigned char *name);
7 list<Player*> players[U_TABLE_SIZE];
8
9 unsigned long sHASH(const unsigned char *name)
10 {
11 unsigned long h = 0, g;
12
13 while (*name)
14 {
15 h = (h << 4) + (*name++); // Case sensitive for numerics
16 if ((g = (h & 0xF0000000)))
17 h ^= g >> 24;
18 h &= ~g;
19 }
20 return h % U_TABLE_SIZE;
21 }
22
23 unsigned long iHASH(const unsigned char *name)
24 {
25 unsigned long h = 0, g;
26
27 while (*name)
28 {
29 h = (h << 4) + tolower(*name++);
30 if ((g = (h & 0xF0000000)))
31 h ^= g >> 24;
32 h &= ~g;
33 }
34 return h % U_TABLE_SIZE;
35 }