From a8ad03d67777e31a3080f11882e28f3adce327c8 Mon Sep 17 00:00:00 2001 From: AkrionXxarr Date: Thu, 28 Feb 2013 19:28:33 -0800 Subject: [PATCH] Fixed djb2_hash with proper code. --- rng.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rng.cpp b/rng.cpp index 932f2a3040b69..f2435b76caa97 100644 --- a/rng.cpp +++ b/rng.cpp @@ -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; }