From a324795b8610b7c3e5626ac72d202ce6207066d7 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 9 Jan 2021 17:58:29 -0500 Subject: 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? --- chat.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'chat.h') 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 { -- cgit 1.4.0