diff options
-rw-r--r-- | user.c | 7 | ||||
-rw-r--r-- | user.h | 4 |
2 files changed, 6 insertions, 5 deletions
@@ -12,8 +12,7 @@ void user_init() { memset(users, 0, sizeof(struct user_t) * USERS_MAX); } -struct user_t *user_get(char *_nick) { - char *nick = nick_get(_nick); +struct user_t *user_get(char *nick) { unsigned long hash = sdbm(nick); int index = hash % USERS_MAX; @@ -35,9 +34,11 @@ struct user_t *user_get(char *_nick) { memset(user->lines, 0, 24*4 * sizeof(unsigned long)); user->words = user->characters = user->kicks = user->kicked = 0; user->next = NULL; + char *_nick = nick_get(nick); + user->real_user = strcmp(nick, _nick) ? user_get(_nick) : NULL; } - return user; + return (user->real_user ? user->real_user : user); } void user_free() { @@ -8,11 +8,11 @@ struct user_t { char *nick; unsigned long lines[24*4]; unsigned long long words, characters, kicks, kicked; - struct user_t *next; + struct user_t *real_user, *next; }; void user_init(); -struct user_t *user_get(char *_nick); +struct user_t *user_get(char *nick); void user_free(); extern struct user_t *users; |