MUC nickname colors depend on nicknames now
authorMaxim Vuets <maxim.vuets@gmail.com>
Sun, 31 Aug 2008 17:40:00 +0200
changeset 1509 f6d4e20b9caa
parent 1508 86620c83123b
child 1510 e1c34d251e39
MUC nickname colors depend on nicknames now MUC nick colors were chosen randomly before. Now they are generated using the simplest algorithm: the sum of all nickname letters % total colors count.
mcabber/src/screen.c
--- a/mcabber/src/screen.c	Sun Aug 31 12:20:54 2008 +0200
+++ b/mcabber/src/screen.c	Sun Aug 31 17:40:00 2008 +0200
@@ -1101,16 +1101,20 @@
             type = *typetmp;
         }
         g_free(mucjid);
-        // Need to generate some random color?
+        // Need to generate a color for the specified nick?
         if ((type == MC_ALL) && (!nickcolors ||
             !g_hash_table_lookup(nickcolors, line->text))) {
           char *snick, *mnick;
           nickcolor *nc;
+          const char *p = line->text;
+          unsigned int nicksum = 0;
           snick = g_strdup(line->text);
           mnick = g_strdup(line->text);
           nc = g_new(nickcolor, 1);
           ensure_string_htable(&nickcolors, NULL);
-          nc->color = nickcols[random() % nickcolcount];
+          while (*p)
+            nicksum += *p++;
+          nc->color = nickcols[nicksum % nickcolcount];
           nc->manual = FALSE;
           *snick = '<';
           snick[strlen(snick)-1] = '>';