}
-int Chan_playerJoin(channel_t *ch, client_t *client)
+int Chan_playerLeave(client_t *client)
{
channel_t *leaving = NULL;
int leaving_id = -1;
- /* Only allowed in one channel at a time */
- Log_debug("Add player %s to channel %s", client->playerName, ch->name);
-
if (client->channel) {
list_del(&client->chan_node);
leaving = (channel_t *)client->channel;
Chan_freeChannel(leaving);
}
}
+ return leaving_id;
+}
+
+int Chan_playerJoin(channel_t *ch, client_t *client)
+{
+ int leaving_id;
+
+ Log_debug("Add player %s to channel %s", client->playerName, ch->name);
+
+ /* Only allowed in one channel at a time */
+ leaving_id = Chan_playerLeave(client);
list_add_tail(&client->chan_node, &ch->clients);
client->channel = (void *)ch;
return leaving_id;
void Chan_removeClient(channel_t *c, client_t *client);
int Chan_playerJoin(channel_t *ch, client_t *client);
int Chan_playerJoin_id(int channelid, client_t *client);
+int Chan_playerLeave(client_t *client);
bool_t Chan_playerJoin_id_test(int channelid);
channel_t *Chan_iterate(channel_t **channelpptr);
channel_t *Chan_iterate_siblings(channel_t *parent, channel_t **channelpptr);
ntohs(client->remote_tcp.sin_port));
if (client->authenticated) {
+ int leave_id;
+ leave_id = Chan_playerLeave(client);
+ if (leave_id > 0) { /* Remove temp channel */
+ sendmsg = Msg_create(ChannelRemove);
+ sendmsg->payload.channelRemove->channel_id = leave_id;
+ Client_send_message_except(client, sendmsg);
+ }
sendmsg = Msg_create(UserRemove);
sendmsg->payload.userRemove->session = client->sessionId;
Client_send_message_except(client, sendmsg);
Voicetarget_free_all(client);
list_del(&client->node);
- list_del(&client->chan_node);
if (client->ssl)
SSL_free(client->ssl);
close(client->tcpfd);