-/* Copyright (C) 2009-2010, Martin Johansson <martin@fatbob.nu>
- Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com>
+/* Copyright (C) 2009-2011, Martin Johansson <martin@fatbob.nu>
+ Copyright (C) 2005-2011, Thorvald Natvig <thorvald@natvig.com>
All rights reserved.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
#include "log.h"
#include "list.h"
#include "client.h"
int Chan_userJoin(channel_t *ch, client_t *client)
{
int leaving_id;
+
+ /* Do nothing if user already is in this channel */
+ if ((channel_t *)client->channel == ch)
+ return 0;
Log_debug("Add user %s to channel %s", client->username, ch->name);
-
/* Only allowed in one channel at a time */
leaving_id = Chan_userLeave(client);
list_add_tail(&client->chan_node, &ch->clients);