From 56079c92c3647299c74ffc0d1271fe1135a86b9d Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Mon, 25 Nov 2013 19:01:13 +0100 Subject: [PATCH] Mimic more exactly what delpeer() does in the callback. If the deleted peer wasn't last, send a name-change update for the overwritten peer. --- toxcore/group_chats.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/toxcore/group_chats.c b/toxcore/group_chats.c index a20ec555..8c3fe210 100644 --- a/toxcore/group_chats.c +++ b/toxcore/group_chats.c @@ -254,8 +254,12 @@ static int delpeer(Group_Chat *chat, int peernum) chat->group = temp; - if (chat->peer_namelistchange != NULL) - (*chat->peer_namelistchange)(chat, peernum, CHAT_CHANGE_PEER_DEL, chat->group_namelistchange_userdata); + if (chat->peer_namelistchange != NULL) { + (*chat->peer_namelistchange)(chat, chat->numpeers, CHAT_CHANGE_PEER_DEL, chat->group_namelistchange_userdata); + + if (chat->numpeers != (uint32_t)peernum) + (*chat->peer_namelistchange)(chat, peernum, CHAT_CHANGE_PEER_NAME, chat->group_namelistchange_userdata); + } return 0; } @@ -290,6 +294,7 @@ static void setnick(Group_Chat *chat, int peernum, uint8_t *contents, uint16_t c /* Force null termination */ chat->group[peernum].nick[contents_len - 1] = 0; chat->group[peernum].nick_len = contents_len; + if (chat->peer_namelistchange != NULL) (*chat->peer_namelistchange)(chat, peernum, CHAT_CHANGE_PEER_NAME, chat->group_namelistchange_userdata); }