+/* UserNode.c - NeonServ v5.2
+ * Copyright (C) 2011 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "UserNode.h"
#include "ChanUser.h"
#include "tools.h"
user->realname[0] = 0;
user->flags = 0;
user->channel = NULL;
+ user->last_who = 0;
user->next = userList[userListIndex];
userList[userListIndex] = user;
return user;
user->realname[0] = 0;
user->flags = 0;
user->channel = NULL;
+ user->last_who = 0;
ii = i+1;
} else if(cmask[i] == '.' && !user) {
//it's a server
user->realname[0] = 0;
user->flags = USERFLAG_ISSERVER;
user->channel = NULL;
+ user->last_who = 0;
return user;
} else if(cmask[i] == '@') {
if(user == NULL) return NULL;
user->realname[0] = 0;
user->flags = 0;
user->channel = NULL;
+ user->last_who = 0;
return user;
}
strcpy(user->host, &cmask[ii]);
strcpy(user->nick, new_nick);
return 1;
}
- int userListIndex = get_nicklist_entry(*new_nick);
- delUser(user, 0);
+ //delUser(user, 0); //EPIC FAIL! This deletes the user from the channel Userlist -.-
+ //manually remove the user from the old userList
+ int userListIndex = get_nicklist_entry(user->nick[0]);
+ if(userListIndex != -1) {
+ struct UserNode *cuser, *last_user = NULL;
+ for(cuser = userList[userListIndex]; cuser; cuser = cuser->next) {
+ if(cuser == user) {
+ if(last_user)
+ last_user->next = user->next;
+ else
+ userList[userListIndex] = user->next;
+ break;
+ } else
+ last_user = cuser;
+ }
+ }
+ userListIndex = get_nicklist_entry(*new_nick);
strcpy(user->nick, new_nick);
user->next = userList[userListIndex];
userList[userListIndex] = user;