]> jfr.im git - irc/gameservirc.git/blame_incremental - gameserv/hash.cpp
Added the asio framework to start developing a GameServ server
[irc/gameservirc.git] / gameserv / hash.cpp
... / ...
CommitLineData
1#include "extern.h"
2#include "aClient.h"
3#include <ctype.h>
4
5unsigned long sHASH(const unsigned char *name);
6unsigned long iHASH(const unsigned char *name);
7list<Player*> players[U_TABLE_SIZE];
8
9unsigned 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
23unsigned 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}