# HG changeset patch # User Sean Egan # Date 1097777710 0 # Node ID c49cc5b818cf0f8a9d1fa4dea999a85fa47cc16f # Parent fb4216714dac94a1a900165db81d83e805cf52ea [gaim-migrate @ 11122] Luke got me thinking of a better way to do screename coloring in chats. I came up with a two-step solution. This is step 1: use a decent hashing algorithm with much fewer collisions than the simple one I used. g_str_hash does the trick. committer: Tailor Script diff -r fb4216714dac -r c49cc5b818cf src/gtkconv.c --- a/src/gtkconv.c Thu Oct 14 03:59:00 2004 +0000 +++ b/src/gtkconv.c Thu Oct 14 18:15:10 2004 +0000 @@ -5224,17 +5224,8 @@ if (flags & GAIM_MESSAGE_NICK) strcpy(color, "#AF7F00"); else if (flags & GAIM_MESSAGE_RECV) { - if (flags & GAIM_MESSAGE_COLORIZE) { - const char *u; - int m = 0; - - for (u = who; *u != '\0'; u++) - m += *u; - - m = m % NUM_NICK_COLORS; - - strcpy(color, nick_colors[m]); - } + if (flags & GAIM_MESSAGE_COLORIZE) + strcpy(color, g_str_hash(who) % NUM_NICK_COLORS); else strcpy(color, RECV_COLOR); }