Skip to content

Commit

Permalink
Fixed djb2_hash with proper code.
Browse files Browse the repository at this point in the history
  • Loading branch information
AkrionXxarr committed Mar 1, 2013
1 parent 9ba34d3 commit a8ad03d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ int dice(int number, int sides)
// for world seeding.
int djb2_hash(unsigned char *str){
unsigned long hash = 5381;
int c;
while (c == *str++)
unsigned char c = *str++;
while (c != '\0'){
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
c = *str++;
}
return hash;
}

0 comments on commit a8ad03d

Please sign in to comment.