]> jfr.im git - irc/gameservirc.git/blame - gameserv/hash.cpp
Added code for the start of the DataLayer format as well as a basic FilePlayerDAO...
[irc/gameservirc.git] / gameserv / hash.cpp
CommitLineData
c260a8d7 1#include "extern.h"
c10b78ac 2#include "aClient.h"
821ea0a0 3#include <ctype.h>
c260a8d7 4
5unsigned long sHASH(const unsigned char *name);
6unsigned long iHASH(const unsigned char *name);
d61f68e3 7list<Player*> players[U_TABLE_SIZE];
c260a8d7 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}