Mercurial > hg
changeset 1510:f6d4e20b9caa
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.
author | Maxim Vuets <maxim.vuets@gmail.com> |
---|---|
date | Sun, 31 Aug 2008 17:40:00 +0200 |
parents | 86620c83123b |
children | e1c34d251e39 |
files | mcabber/src/screen.c |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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] = '>';