summaryrefslogtreecommitdiff
path: root/src/randtiles.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/randtiles.cpp22
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;
+}