diff options
author | Treeki <treeki@gmail.com> | 2011-03-12 23:17:12 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-03-12 23:17:12 +0100 |
commit | 7d4e4c0b34a613dd3c0220475ae4e448197522c1 (patch) | |
tree | 4f5cee367de3fdef4f9a7c84af59ffe76a2bb1c3 /src/randtiles.cpp | |
download | kamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.tar.gz kamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.zip |
initial commit. now I can start playing with stuff!
Diffstat (limited to '')
-rw-r--r-- | src/randtiles.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/randtiles.cpp b/src/randtiles.cpp new file mode 100644 index 0000000..c7388dd --- /dev/null +++ b/src/randtiles.cpp @@ -0,0 +1,22 @@ +#include "randtiles.h"
+
+u32 djb2(u8 *str) {
+ u32 hash = 5381;
+ int c;
+
+ while (c = *str++)
+ hash = ((hash << 5) + hash) + c;
+
+ return hash;
+}
+
+RandTiles_Section *RandTiles_Search(void *file, u32 nameHash) {
+ for (int i = 0; i < RandTiles_GetSectionCount(file); i++) {
+ RandTiles_Section *sect = RandTiles_GetSection(file, i);
+
+ if (sect->nameHash == nameHash)
+ return sect;
+ }
+
+ return 0;
+}
|