From fc135d64a1ad6b36d807e6b7ab9d804bffe95e48 Mon Sep 17 00:00:00 2001 From: ultramage Date: Tue, 25 Mar 2008 09:56:18 +0000 Subject: Added proper checks to adoption processing (followup to r12428). Cleaned up some code / fixed some typos. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12432 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index ea2270024..e3809ded9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12065,16 +12065,21 @@ void clif_parse_Adopt_request(int fd, struct map_session_data *sd) void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) { - struct map_session_data *p1_sd = map_id2sd(RFIFOL(fd,2)), *p2_sd = map_id2sd(RFIFOL(fd,6)); - int result = RFIFOL(fd,10), pid = sd->adopt_invite; + int p1_id = RFIFOL(fd,2); + int p2_id = RFIFOL(fd,6); + int result = RFIFOL(fd,10); + struct map_session_data* p1_sd = map_id2sd(p1_id); + struct map_session_data* p2_sd = map_id2sd(p2_id); + int pid = sd->adopt_invite; sd->adopt_invite = 0; - if( !p1_sd ) - return; // Parent is not online - - if( pid != p1_sd->status.account_id || !result ) - return; // Not the same sender | Reply No + if( p1_sd == NULL || p2_sd == NULL ) + return; // Both players need to be online + if( pid != p1_sd->status.account_id || p2_id != p1_sd->status.partner_id ) + return; // Incorrect values + if( result == 0 ) + return; // Rejected pc_adoption(p1_sd, p2_sd, sd); } -- cgit v1.2.3-70-g09d2