about summary refs log tree commit diff
path: root/chat.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-09 17:58:29 -0500
committerJune McEnroe <june@causal.agency>2021-01-09 17:58:29 -0500
commita324795b8610b7c3e5626ac72d202ce6207066d7 (patch)
tree4f340e00b8d3e6e637444f645f8b5856b77665df /chat.h
parentCount width of 2 for invalid multibyte with high bit (diff)
downloadcatgirl-a324795b8610b7c3e5626ac72d202ce6207066d7.tar.gz
catgirl-a324795b8610b7c3e5626ac72d202ce6207066d7.zip
Allow configuring the upper bound of the hash function
This allows limiting the nick colors used to the 16-color terminal set
without modifying the TERM environment variable. Produces different
results from just using the default configuration in a 16-color
terminal, but what can you do?
Diffstat (limited to 'chat.h')
-rw-r--r--chat.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/chat.h b/chat.h
index b06d383..8de5d55 100644
--- a/chat.h
+++ b/chat.h
@@ -137,6 +137,7 @@ static inline uint idFor(const char *name) {
 }
 
 extern uint32_t hashInit;
+extern uint32_t hashBound;
 static inline enum Color hash(const char *str) {
 	if (*str == '~') str++;
 	uint32_t hash = hashInit;
@@ -145,7 +146,7 @@ static inline enum Color hash(const char *str) {
 		hash ^= *str;
 		hash *= 0x27220A95;
 	}
-	return Blue + hash % 74;
+	return Blue + hash % (hashBound + 1 - Blue);
 }
 
 extern struct Network {