From a204b95c51affe05f3e6cab2506e703a35680d69 Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Tue, 26 Nov 2013 18:55:06 +0100 Subject: [PATCH] Print a more detailed message on CHAT_CHANGE_PEER_DEL, so a user isn't confounded by the change of peer numbers. On deleting the last peer, it's just a delete. On deleting any other peer, the last peer is moved into that space, gaining a different number. Print that detail where appropriate. --- testing/nTox.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index 24054f5e..27875a96 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -1068,9 +1068,27 @@ void print_groupnamelistchange(Tox *m, int groupnumber, int peernumber, uint8_t sprintf(msg, "[g] #%i: New peer %i.", groupnumber, peernumber); new_lines(msg); } else if (change == TOX_CHAT_CHANGE_PEER_DEL) { - sprintf(msg, "[g] #%i: Peer %i left. Name list is now:", groupnumber, peernumber); - new_lines(msg); - print_groupchatpeers(m, groupnumber); + /* if peer was the last in list, it simply dropped, + * otherwise it was overwritten by the last peer + * + * adjust output + */ + int peers_total = tox_group_number_peers(m, groupnumber); + + if (peers_total == peernumber) { + sprintf(msg, "[g] #%i: Peer %i left.", groupnumber, peernumber); + new_lines(msg); + } else { + uint8_t peername[TOX_MAX_NAME_LENGTH]; + int len = tox_group_peername(m, groupnumber, peernumber, peername); + + if (len <= 0) + peername[0] = 0; + + sprintf(msg, "[g] #%i: Peer %i left. Former peer [%i: <%s>] is now peer %i.", groupnumber, peernumber, + peers_total, peername, peernumber); + new_lines(msg); + } } else if (change == TOX_CHAT_CHANGE_PEER_NAME) { uint8_t peername[TOX_MAX_NAME_LENGTH]; int len = tox_group_peername(m, groupnumber, peernumber, peername);