Removing a friend will also remove you from your friends friendlist, bugreport:2977

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15119 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
shennetsind 2011-12-14 22:45:33 +00:00
parent bc87e05c2d
commit a45c020f36
4 changed files with 62 additions and 2 deletions

View File

@ -2758,6 +2758,22 @@ int parse_frommap(int fd)
} }
break; break;
case 0x2b07: // Remove RFIFOL(fd,6) (friend_id) from RFIFOL(fd,2) (char_id) friend list [Ind]
if (RFIFOREST(fd) < 6)
return 0;
{
int char_id, friend_id;
char_id = RFIFOL(fd,2);
friend_id = RFIFOL(fd,6);
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1",
friend_db, char_id, friend_id) ) {
Sql_ShowDebug(sql_handle);
break;
}
RFIFOSKIP(fd,10);
}
break;
case 0x2b08: // char name request case 0x2b08: // char name request
if (RFIFOREST(fd) < 6) if (RFIFOREST(fd) < 6)
return 0; return 0;

View File

@ -38,7 +38,7 @@ static DBMap* auth_db; // int id -> struct auth_node*
static const int packet_len_table[0x3d] = { // U - used, F - free static const int packet_len_table[0x3d] = { // U - used, F - free
60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff 60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff
6,-1,18, 7,-1,35,30, 0, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, F->2b07 6,-1,18, 7,-1,35,30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, F->2b07
6,30, 0, 0,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, F->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f 6,30, 0, 0,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, F->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f
11,10,10, 0,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17 11,10,10, 0,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17
2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f 2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f
@ -61,7 +61,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free
//2b04: Incoming, chrif_recvmap -> 'getting maps from charserver of other mapserver's' //2b04: Incoming, chrif_recvmap -> 'getting maps from charserver of other mapserver's'
//2b05: Outgoing, chrif_changemapserver -> 'Tell the charserver the mapchange / quest for ok...' //2b05: Outgoing, chrif_changemapserver -> 'Tell the charserver the mapchange / quest for ok...'
//2b06: Incoming, chrif_changemapserverack -> 'awnser of 2b05, ok/fail, data: dunno^^' //2b06: Incoming, chrif_changemapserverack -> 'awnser of 2b05, ok/fail, data: dunno^^'
//2b07: FREE //2b07: Outgoing, chrif_removefriend -> 'Tell charserver to remove friend_id from char_id friend list'
//2b08: Outgoing, chrif_searchcharid -> '...' //2b08: Outgoing, chrif_searchcharid -> '...'
//2b09: Incoming, map_addchariddb -> 'Adds a name to the nick db' //2b09: Incoming, map_addchariddb -> 'Adds a name to the nick db'
//2b0a: FREE //2b0a: FREE
@ -1555,6 +1555,23 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_
return 0; return 0;
} }
/*==========================================
* Asks char server to remove friend_id from the friend list of char_id
*------------------------------------------*/
int chrif_removefriend(int char_id, int friend_id) {
#ifndef TXT_ONLY
chrif_check(-1);
WFIFOHEAD(char_fd,10);
WFIFOW(char_fd,0) = 0x2b07;
WFIFOL(char_fd,2) = char_id;
WFIFOL(char_fd,6) = friend_id;
WFIFOSET(char_fd,10);
#endif
return 0;
}
int auth_db_final(DBKey k,void *d,va_list ap) int auth_db_final(DBKey k,void *d,va_list ap)
{ {
struct auth_node *node=(struct auth_node*)d; struct auth_node *node=(struct auth_node*)d;

View File

@ -57,6 +57,10 @@ int chrif_char_online(struct map_session_data *sd);
int chrif_changesex(struct map_session_data *sd); int chrif_changesex(struct map_session_data *sd);
int chrif_chardisconnect(struct map_session_data *sd); int chrif_chardisconnect(struct map_session_data *sd);
int chrif_divorce(int partner_id1, int partner_id2); int chrif_divorce(int partner_id1, int partner_id2);
/**
* rAthena
**/
int chrif_removefriend(int char_id, int friend_id);
int do_final_chrif(void); int do_final_chrif(void);
int do_init_chrif(void); int do_init_chrif(void);

View File

@ -12358,6 +12358,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd)
void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
{ {
// 0x203 </o> <ID to be removed W 4B> // 0x203 </o> <ID to be removed W 4B>
struct map_session_data *f_sd = NULL;
int account_id, char_id; int account_id, char_id;
int i, j; int i, j;
@ -12380,6 +12381,28 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
memset(&sd->status.friends[MAX_FRIENDS-1], 0, sizeof(sd->status.friends[MAX_FRIENDS-1])); memset(&sd->status.friends[MAX_FRIENDS-1], 0, sizeof(sd->status.friends[MAX_FRIENDS-1]));
clif_displaymessage(fd, "Friend removed"); clif_displaymessage(fd, "Friend removed");
//remove from friends list
if( (f_sd = map_id2sd(account_id)) ) {
for (i = 0; i < MAX_FRIENDS &&
(f_sd->status.friends[i].char_id != sd->status.char_id || f_sd->status.friends[i].account_id != sd->status.account_id); i++);
if (i != MAX_FRIENDS) {
// move all chars down
for(j = i + 1; j < MAX_FRIENDS; j++)
memcpy(&f_sd->status.friends[j-1], &f_sd->status.friends[j], sizeof(f_sd->status.friends[0]));
memset(&f_sd->status.friends[MAX_FRIENDS-1], 0, sizeof(f_sd->status.friends[MAX_FRIENDS-1]));
//should the guy be notified of some message? we should add it here if so
WFIFOHEAD(f_sd->fd,packet_len(0x20a));
WFIFOW(f_sd->fd,0) = 0x20a;
WFIFOL(f_sd->fd,2) = sd->status.account_id;
WFIFOL(f_sd->fd,6) = sd->status.char_id;
WFIFOSET(f_sd->fd, packet_len(0x20a));
}
} else { //friend not online -- ask char server to delete from his friendlist
chrif_removefriend(char_id,sd->status.char_id);
}
WFIFOHEAD(fd,packet_len(0x20a)); WFIFOHEAD(fd,packet_len(0x20a));
WFIFOW(fd,0) = 0x20a; WFIFOW(fd,0) = 0x20a;
WFIFOL(fd,2) = account_id; WFIFOL(fd,2) = account_id;