summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--user.c7
-rw-r--r--user.h4
2 files changed, 6 insertions, 5 deletions
diff --git a/user.c b/user.c
index 4fa0174..dc4b5ed 100644
--- a/user.c
+++ b/user.c
@@ -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() {
diff --git a/user.h b/user.h
index 27953ce..d2cb180 100644
--- a/user.h
+++ b/user.h
@@ -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;