summaryrefslogtreecommitdiff
path: root/src/randtiles.cpp
blob: 0bc2ede92f22c7bd503f7f2b7867f5f7cdc79f67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
}