瀏覽代碼

Fixed some return value for next parsing

next==-1 to avoid parsing was mistmatchingFIFOSD_CHECK that was using 0
for same purpose.
To avoid all confusion 0 is now used to said to not continue parsing.
Fix 0x2b0e pointing to wrong parser.
lighta 11 年之前
父節點
當前提交
af737790d2
共有 3 個文件被更改,包括 255 次插入262 次删除
  1. 143 145
      src/char/char_clif.c
  2. 54 58
      src/char/char_logif.c
  3. 58 59
      src/char/char_mapif.c

+ 143 - 145
src/char/char_clif.c

@@ -54,13 +54,13 @@ int chclif_parse_moveCharSlot( int fd, struct char_session_data* sd){
 	if( (charserv_config.charmove_config.char_move_enabled)==0
 	|| ( (charserv_config.charmove_config.char_moves_unlimited)==0 && sd->char_moves[from] <= 0 ) ){
 		chclif_moveCharSlotReply( fd, sd, from, 1 );
-		return 0;
+		return 1;
 	}
 
 	// We dont even have a character on the chosen slot?
 	if( sd->found_char[from] <= 0 ){
 		chclif_moveCharSlotReply( fd, sd, from, 1 );
-		return 0;
+		return 1;
 	}
 
 	if( sd->found_char[to] > 0 ){
@@ -75,17 +75,17 @@ int chclif_parse_moveCharSlot( int fd, struct char_session_data* sd){
 				chclif_moveCharSlotReply( fd, sd, from, 1 );
 				Sql_ShowDebug(sql_handle);
 				Sql_QueryStr(sql_handle,"ROLLBACK");
-				return 0;
+				return 1;
 			}
 		}else{
 			// Admin doesnt allow us to
 			chclif_moveCharSlotReply( fd, sd, from, 1 );
-			return 0;
+			return 1;
 		}
 	}else if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d'", schema_config.char_db, to, sd->found_char[from] ) ){
 		Sql_ShowDebug(sql_handle);
 		chclif_moveCharSlotReply( fd, sd, from, 1 );
-		return 0;
+		return 1;
 	}
 
 	if( (charserv_config.charmove_config.char_moves_unlimited)==0 ){
@@ -147,7 +147,7 @@ int chclif_parse_pincode_check( int fd, struct char_session_data* sd ){
 	if( RFIFOREST(fd) < 10 )
 		return 0;
 	if( charserv_config.pincode_config.pincode_enabled==0 || RFIFOL(fd,2) != sd->account_id )
-		return 0;
+		return 1;
 
 	memset(pin,0,PINCODE_LENGTH+1);
 	strncpy((char*)pin, (char*)RFIFOP(fd, 6), PINCODE_LENGTH);
@@ -167,7 +167,7 @@ int chclif_parse_pincode_change( int fd, struct char_session_data* sd ){
 	if( RFIFOREST(fd) < 14 )
 		return 0;
 	if( charserv_config.pincode_config.pincode_enabled==0 || RFIFOL(fd,2) != sd->account_id )
-		return 0;
+		return 1;
         else {
             char oldpin[PINCODE_LENGTH+1];
             char newpin[PINCODE_LENGTH+1];
@@ -180,7 +180,7 @@ int chclif_parse_pincode_change( int fd, struct char_session_data* sd ){
 
             char_pincode_decrypt(sd->pincode_seed,oldpin);
             if( !char_pincode_compare( fd, sd, oldpin ) )
-                    return 0;
+                    return 1;
             char_pincode_decrypt(sd->pincode_seed,newpin);
 
             chlogif_pincode_notifyLoginPinUpdate( sd->account_id, newpin );
@@ -199,7 +199,7 @@ int chclif_parse_pincode_setnew( int fd, struct char_session_data* sd ){
 		return 0;
 
 	if( charserv_config.pincode_config.pincode_enabled==0 || RFIFOL(fd,2) != sd->account_id )
-		return 0;
+		return 1;
         else {
             char newpin[PINCODE_LENGTH+1];
             memset(newpin,0,PINCODE_LENGTH+1);
@@ -362,60 +362,60 @@ int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd) {
     FIFOSD_CHECK(6)
     {
         int char_id, i;
-	char* data;
-	time_t delete_date;
-        
-	char_id = RFIFOL(fd,2);
-	RFIFOSKIP(fd,6);
+		char* data;
+		time_t delete_date;
 
-	ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
-	if( i == MAX_CHARS )
-	{// character not found
-		chclif_char_delete2_ack(fd, char_id, 3, 0);
-		return 0;
-	}
+		char_id = RFIFOL(fd,2);
+		RFIFOSKIP(fd,6);
 
-	if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `delete_date` FROM `%s` WHERE `char_id`='%d'", schema_config.char_db, char_id) || SQL_SUCCESS != Sql_NextRow(sql_handle) )
-	{
-		Sql_ShowDebug(sql_handle);
-		chclif_char_delete2_ack(fd, char_id, 3, 0);
-		return 0;
-	}
+		ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
+		if( i == MAX_CHARS )
+		{// character not found
+			chclif_char_delete2_ack(fd, char_id, 3, 0);
+			return 1;
+		}
 
-	Sql_GetData(sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
+		if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `delete_date` FROM `%s` WHERE `char_id`='%d'", schema_config.char_db, char_id) || SQL_SUCCESS != Sql_NextRow(sql_handle) )
+		{
+			Sql_ShowDebug(sql_handle);
+			chclif_char_delete2_ack(fd, char_id, 3, 0);
+			return 1;
+		}
 
-	if( delete_date ) {// character already queued for deletion
-		chclif_char_delete2_ack(fd, char_id, 0, 0);
-		return 0;
-	}
+		Sql_GetData(sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
 
-/*
-	// Aegis imposes these checks probably to avoid dead member
-	// entries in guilds/parties, otherwise they are not required.
-	// TODO: Figure out how these are enforced during waiting.
-	if( guild_id )
-	{// character in guild
-		char_delete2_ack(fd, char_id, 4, 0);
-		return;
-	}
+		if( delete_date ) {// character already queued for deletion
+			chclif_char_delete2_ack(fd, char_id, 0, 0);
+			return 1;
+		}
 
-	if( party_id )
-	{// character in party
-		char_delete2_ack(fd, char_id, 5, 0);
-		return;
-	}
-*/
-	// success
-	delete_date = time(NULL)+(charserv_config.char_config.char_del_delay);
+	/*
+		// Aegis imposes these checks probably to avoid dead member
+		// entries in guilds/parties, otherwise they are not required.
+		// TODO: Figure out how these are enforced during waiting.
+		if( guild_id )
+		{// character in guild
+			chclif_char_delete2_ack(fd, char_id, 4, 0);
+			return 1;
+		}
 
-	if( SQL_SUCCESS != Sql_Query(sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", schema_config.char_db, (unsigned long)delete_date, char_id) )
-	{
-		Sql_ShowDebug(sql_handle);
-		chclif_char_delete2_ack(fd, char_id, 3, 0);
-		return 0;
-	}
+		if( party_id )
+		{// character in party
+			chclif_char_delete2_ack(fd, char_id, 5, 0);
+			return 1;
+		}
+	*/
+		// success
+		delete_date = time(NULL)+(charserv_config.char_config.char_del_delay);
+
+		if( SQL_SUCCESS != Sql_Query(sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", schema_config.char_db, (unsigned long)delete_date, char_id) )
+		{
+			Sql_ShowDebug(sql_handle);
+			chclif_char_delete2_ack(fd, char_id, 3, 0);
+			return 1;
+		}
 
-	chclif_char_delete2_ack(fd, char_id, 1, delete_date);
+		chclif_char_delete2_ack(fd, char_id, 1, delete_date);
     }
     return 1;
 }
@@ -425,77 +425,75 @@ int chclif_parse_char_delete2_accept(int fd, struct char_session_data* sd) {
     FIFOSD_CHECK(12)
     {
         char birthdate[8+1];
-	int char_id, i, k;
-	unsigned int base_level;
-	char* data;
-	time_t delete_date;
-	char_id = RFIFOL(fd,2);
-
-	ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, char_id);
-
-	// construct "YY-MM-DD"
-	birthdate[0] = RFIFOB(fd,6);
-	birthdate[1] = RFIFOB(fd,7);
-	birthdate[2] = '-';
-	birthdate[3] = RFIFOB(fd,8);
-	birthdate[4] = RFIFOB(fd,9);
-	birthdate[5] = '-';
-	birthdate[6] = RFIFOB(fd,10);
-	birthdate[7] = RFIFOB(fd,11);
-	birthdate[8] = 0;
-	RFIFOSKIP(fd,12);
-
-	ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
-	if( i == MAX_CHARS )
-	{// character not found
-		chclif_char_delete2_accept_ack(fd, char_id, 3);
-		return 0;
-	}
+		int char_id, i, k;
+		unsigned int base_level;
+		char* data;
+		time_t delete_date;
+		char_id = RFIFOL(fd,2);
+
+		ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, char_id);
+
+		// construct "YY-MM-DD"
+		birthdate[0] = RFIFOB(fd,6);
+		birthdate[1] = RFIFOB(fd,7);
+		birthdate[2] = '-';
+		birthdate[3] = RFIFOB(fd,8);
+		birthdate[4] = RFIFOB(fd,9);
+		birthdate[5] = '-';
+		birthdate[6] = RFIFOB(fd,10);
+		birthdate[7] = RFIFOB(fd,11);
+		birthdate[8] = 0;
+		RFIFOSKIP(fd,12);
+
+		ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
+		if( i == MAX_CHARS )
+		{// character not found
+			chclif_char_delete2_accept_ack(fd, char_id, 3);
+			return 1;
+		}
 
-	if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", schema_config.char_db, char_id) || SQL_SUCCESS != Sql_NextRow(sql_handle) )
-	{// data error
-		Sql_ShowDebug(sql_handle);
-		chclif_char_delete2_accept_ack(fd, char_id, 3);
-		return 0;
-	}
+		if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", schema_config.char_db, char_id) || SQL_SUCCESS != Sql_NextRow(sql_handle) )
+		{// data error
+			Sql_ShowDebug(sql_handle);
+			chclif_char_delete2_accept_ack(fd, char_id, 3);
+			return 1;
+		}
 
-	Sql_GetData(sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10);
-	Sql_GetData(sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10);
+		Sql_GetData(sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10);
+		Sql_GetData(sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10);
 
-	if( !delete_date || delete_date>time(NULL) )
-	{// not queued or delay not yet passed
-		chclif_char_delete2_accept_ack(fd, char_id, 4);
-		return 0;
-	}
+		if( !delete_date || delete_date>time(NULL) )
+		{// not queued or delay not yet passed
+			chclif_char_delete2_accept_ack(fd, char_id, 4);
+			return 1;
+		}
 
-	if( strcmp(sd->birthdate+2, birthdate) )  // +2 to cut off the century
-	{// birth date is wrong
-		chclif_char_delete2_accept_ack(fd, char_id, 5);
-		return 0;
-	}
+		if( strcmp(sd->birthdate+2, birthdate) )  // +2 to cut off the century
+		{// birth date is wrong
+			chclif_char_delete2_accept_ack(fd, char_id, 5);
+			return 1;
+		}
 
-	if( ( charserv_config.char_config.char_del_level > 0 && base_level >= (unsigned int)charserv_config.char_config.char_del_level )
-	|| ( charserv_config.char_config.char_del_level < 0 && base_level <= (unsigned int)(-charserv_config.char_config.char_del_level) ) )
-	{// character level config restriction
-		chclif_char_delete2_accept_ack(fd, char_id, 2);
-		return 0;
-	}
+		if( ( charserv_config.char_config.char_del_level > 0 && base_level >= (unsigned int)charserv_config.char_config.char_del_level )
+		|| ( charserv_config.char_config.char_del_level < 0 && base_level <= (unsigned int)(-charserv_config.char_config.char_del_level) ) )
+		{// character level config restriction
+			chclif_char_delete2_accept_ack(fd, char_id, 2);
+			return 1;
+		}
 
-	// success
-	if( char_delete_char_sql(char_id) < 0 )
-	{
-		chclif_char_delete2_accept_ack(fd, char_id, 3);
-		return 0;
-	}
+		// success
+		if( char_delete_char_sql(char_id) < 0 ){
+			chclif_char_delete2_accept_ack(fd, char_id, 3);
+			return 1;
+		}
 
-	// refresh character list cache
-	for(k = i; k < MAX_CHARS-1; k++)
-	{
-		sd->found_char[k] = sd->found_char[k+1];
-	}
-	sd->found_char[MAX_CHARS-1] = -1;
+		// refresh character list cache
+		for(k = i; k < MAX_CHARS-1; k++){
+			sd->found_char[k] = sd->found_char[k+1];
+		}
+		sd->found_char[MAX_CHARS-1] = -1;
 
-	chclif_char_delete2_accept_ack(fd, char_id, 1);
+		chclif_char_delete2_accept_ack(fd, char_id, 1);
     }
     return 1;
 }
@@ -513,7 +511,7 @@ int chclif_parse_char_delete2_cancel(int fd, struct char_session_data* sd) {
 	if( i == MAX_CHARS )
 	{// character not found
 		chclif_char_delete2_cancel_ack(fd, char_id, 2);
-		return 0;
+		return 1;
 	}
 
 	// there is no need to check, whether or not the character was
@@ -523,7 +521,7 @@ int chclif_parse_char_delete2_cancel(int fd, struct char_session_data* sd) {
 	{
 		Sql_ShowDebug(sql_handle);
 		chclif_char_delete2_cancel_ack(fd, char_id, 2);
-		return 0;
+		return 1;
 	}
 
 	chclif_char_delete2_cancel_ack(fd, char_id, 1);
@@ -572,7 +570,7 @@ int chclif_parse_maplogin(int fd){
 		}
 		RFIFOSKIP(fd,60);
 	}
-	return 1;
+	return 0;
 }
 
 // 0065 <account id>.L <login id1>.L <login id2>.L <???>.W <sex>.B
@@ -596,7 +594,7 @@ int chclif_parse_reqtoconnect(int fd, struct char_session_data* sd,uint32 ipl){
 			//TODO: Perhaps log this as a hack attempt?
 			//TODO: and perhaps send back a reply?
 			ShowInfo("Already registered break\n");
-			return 0; // @CHEKME this was break
+			return 1;
 		}
 
 		CREATE(session[fd]->session_data, struct char_session_data, 1);
@@ -618,7 +616,7 @@ int chclif_parse_reqtoconnect(int fd, struct char_session_data* sd,uint32 ipl){
 			WFIFOW(fd,0) = 0x6c;
 			WFIFOB(fd,2) = 0;// rejected from server
 			WFIFOSET(fd,3);
-			return 0;
+			return 1;
 		}
 
 		// search authentification
@@ -691,20 +689,20 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
 			WFIFOW(fd,0) = 0x6c;
 			WFIFOB(fd,2) = 0; // rejected from server
 			WFIFOSET(fd,3);
-			return 0;
+			return 1;
 		}
 
 		char_id = atoi(data);
 		Sql_FreeResult(sql_handle);
 
-                /* client doesn't let it get to this point if you're banned, so its a forged packet */
-                if( sd->found_char[slot] == char_id && sd->unban_time[slot] > time(NULL) ) {
-                        WFIFOHEAD(fd,3);
-                        WFIFOW(fd,0) = 0x6c;
-                        WFIFOB(fd,2) = 0; // rejected from server
-                        WFIFOSET(fd,3);
-                        return 0;
-                }
+		/* client doesn't let it get to this point if you're banned, so its a forged packet */
+		if( sd->found_char[slot] == char_id && sd->unban_time[slot] > time(NULL) ) {
+			WFIFOHEAD(fd,3);
+			WFIFOW(fd,0) = 0x6c;
+			WFIFOB(fd,2) = 0; // rejected from server
+			WFIFOSET(fd,3);
+			return 1;
+		}
                 
 		/* set char as online prior to loading its data so 3rd party applications will realise the sql data is not reliable */
 		char_set_char_online(-2,char_id,sd->account_id);
@@ -715,7 +713,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
 			WFIFOW(fd,0) = 0x6c;
 			WFIFOB(fd,2) = 0;
 			WFIFOSET(fd,3);
-			return 0;/* jump off this boat */
+			return 1;/* jump off this boat */
 		}
 
 		//Have to switch over to the DB instance otherwise data won't propagate [Kevin]
@@ -743,7 +741,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
 			if (j == ARRAYLENGTH(map_server)) {
 				ShowInfo("Connection Closed. No map servers available.\n");
 				chclif_send_auth_result(fd,1); // 01 = Server closed
-				return 0;
+				return 1;
 			}
 			if ((i = char_search_mapserver((j=mapindex_name2id(MAP_PRONTERA)),-1,-1)) >= 0) {
 				cd->last_point.x = 273;
@@ -766,7 +764,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
 			} else {
 				ShowInfo("Connection Closed. No map server available that has a major city, and unable to find map-server for '%s'.\n", mapindex_id2name(cd->last_point.map));
 				chclif_send_auth_result(fd,1); // 01 = Server closed
-				return 0;
+				return 1;
 			}
 			ShowWarning("Unable to find map-server for '%s', sending to major city '%s'.\n", mapindex_id2name(cd->last_point.map), mapindex_id2name(j));
 			cd->last_point.map = j;
@@ -780,7 +778,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
 			map_server[i].fd = -1;
 			memset(&map_server[i], 0, sizeof(struct mmo_map_server));
 			chclif_send_auth_result(fd,1);  //Send server closed.
-			return 0;
+			return 1;
 		}
 
 		//Send player to map
@@ -890,7 +888,7 @@ int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd){
                 WFIFOW(fd,0) = 0x70;
                 WFIFOB(fd,2) = 0; // 00 = Incorrect Email address
                 WFIFOSET(fd,3);
-                return 0;
+                return 1;
         }
 
         // check if this char exists
@@ -901,7 +899,7 @@ int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd){
                 WFIFOW(fd,0) = 0x70;
                 WFIFOB(fd,2) = 0;
                 WFIFOSET(fd,3);
-                return 0;
+                return 1;
         }
 
         // remove char from list and compact it
@@ -918,7 +916,7 @@ int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd){
                 WFIFOW(fd, 0) = 0x70;
                 WFIFOB(fd, 2) = 0;
                 WFIFOSET(fd, 3);
-                return 0;
+                return 1;
         }
         /* Char successfully deleted.*/
         WFIFOHEAD(fd,2);
@@ -957,12 +955,12 @@ int chclif_parse_reqrename(int fd, struct char_session_data* sd, int cmd){
             safestrncpy(name, (char *)RFIFOP(fd,10), NAME_LENGTH);
             RFIFOSKIP(fd,34);
             if( aid != sd->account_id )
-                    return 0;
+                    return 1;
     }
 
     ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
     if( i == MAX_CHARS )
-            return 0;
+            return 1;
 
     normalize_name(name,TRIM_CHARS);
     Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
@@ -1055,7 +1053,7 @@ int chclif_parse_ackrename(int fd, struct char_session_data* sd){
 
         ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
         if( i == MAX_CHARS )
-                return 0;
+                return 1;
         i = char_rename_char_sql(sd, cid);
 
         WFIFOHEAD(fd, 4);
@@ -1100,8 +1098,7 @@ int chclif_parse(int fd) {
 	unsigned short cmd;
 	struct char_session_data* sd = (struct char_session_data*)session[fd]->session_data;
 	uint32 ipl = session[fd]->client_addr;
-        int next=0;
-
+    
 	// disconnect any player if no login-server.
 	if(login_fd < 0)
 		set_eof(fd);
@@ -1123,8 +1120,8 @@ int chclif_parse(int fd) {
 
 	while( RFIFOREST(fd) >= 2 )
 	{
+		int next=1;
 		cmd = RFIFOW(fd,0);
-                if(next==-1) return 0; // avoid processing of followup packets (prev was probably incomplete)
 		switch( cmd )
 		{
 		case 0x65: next=chclif_parse_reqtoconnect(fd,sd,ipl); break;
@@ -1167,6 +1164,7 @@ int chclif_parse(int fd) {
 			set_eof(fd);
 			return 0;
 		}
+		if(next==0) return 0; // avoid processing of followup packets (prev was probably incomplete)
 	}
 
 	RFIFOFLUSH(fd);

+ 54 - 58
src/char/char_logif.c

@@ -269,9 +269,9 @@ int chlogif_parse_ackaccreq(int fd, struct char_session_data* sd){
 			int client_fd = request_id;
 			sd->version = version;
 			sd->clienttype = clienttype;
-                        if(sd->version != date2version(PACKETVER))
-                            ShowWarning("s aid=%d has an incorect version=%d in clientinfo. Server compiled for %d\n",
-                                sd->account_id,sd->version,date2version(PACKETVER));
+			if(sd->version != date2version(PACKETVER))
+				ShowWarning("s aid=%d has an incorect version=%d in clientinfo. Server compiled for %d\n",
+					sd->account_id,sd->version,date2version(PACKETVER));
 
 			switch( result )
 			{
@@ -498,33 +498,29 @@ int chlogif_parse_askkick(int fd, struct char_session_data* sd){
 }
 
 int chlogif_parse_updip(int fd, struct char_session_data* sd){
-	if (RFIFOREST(fd) < 2)
-		return 0;
-	{
-		unsigned char buf[2];
-		uint32 new_ip = 0;
-
-		WBUFW(buf,0) = 0x2b1e;
-		chmapif_sendall(buf, 2);
-
-		new_ip = host2ip(charserv_config.login_ip_str);
-		if (new_ip && new_ip != charserv_config.login_ip)
-			charserv_config.login_ip = new_ip; //Update login ip, too.
-
-		new_ip = host2ip(charserv_config.char_ip_str);
-		if (new_ip && new_ip != charserv_config.char_ip)
-		{	//Update ip.
-			charserv_config.char_ip = new_ip;
-			ShowInfo("Updating IP for [%s].\n", charserv_config.char_ip_str);
-			// notify login server about the change
-			WFIFOHEAD(fd,6);
-			WFIFOW(fd,0) = 0x2736;
-			WFIFOL(fd,2) = htonl(charserv_config.char_ip);
-			WFIFOSET(fd,6);
-		}
-
-		RFIFOSKIP(fd,2);
+	unsigned char buf[2];
+	uint32 new_ip = 0;
+
+	WBUFW(buf,0) = 0x2b1e;
+	chmapif_sendall(buf, 2);
+
+	new_ip = host2ip(charserv_config.login_ip_str);
+	if (new_ip && new_ip != charserv_config.login_ip)
+		charserv_config.login_ip = new_ip; //Update login ip, too.
+
+	new_ip = host2ip(charserv_config.char_ip_str);
+	if (new_ip && new_ip != charserv_config.char_ip)
+	{	//Update ip.
+		charserv_config.char_ip = new_ip;
+		ShowInfo("Updating IP for [%s].\n", charserv_config.char_ip_str);
+		// notify login server about the change
+		WFIFOHEAD(fd,6);
+		WFIFOW(fd,0) = 0x2736;
+		WFIFOL(fd,2) = htonl(charserv_config.char_ip);
+		WFIFOSET(fd,6);
 	}
+
+	RFIFOSKIP(fd,2);
 	return 1;
 }
 
@@ -555,7 +551,7 @@ int chlogif_BankingReq(int32 account_id, int8 type, int32 data){
  */
 int chlogif_parse_BankingAck(int fd){
 	if (RFIFOREST(fd) < 11)
-            return -1;
+            return 0;
 	else {
 		uint32 aid = RFIFOL(fd,2);
 		int32 bank_vault = RFIFOL(fd,6);
@@ -574,7 +570,7 @@ int chlogif_parse_BankingAck(int fd){
 int chlogif_parse_vipack(int fd) {
 #ifdef VIP_ENABLE
 	if (RFIFOREST(fd) < 20)
-		return -1;
+		return 0;
 	else {
 		uint32 aid = RFIFOL(fd,2); //aid
 		uint32 vip_time = RFIFOL(fd,6); //vip_time
@@ -615,7 +611,7 @@ int chlogif_reqvipdata(uint32 aid, uint8 type, int32 timediff, int mapfd) {
 
 int chlogif_parse(int fd) {
 	struct char_session_data* sd = NULL;
-        int next=0;
+        
 	// only process data from the login-server
 	if( fd != login_fd ) {
 		ShowDebug("parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd);
@@ -644,36 +640,36 @@ int chlogif_parse(int fd) {
 	sd = (struct char_session_data*)session[fd]->session_data;
 
 	while(RFIFOREST(fd) >= 2) {
+		int next=1;
 		uint16 command = RFIFOW(fd,0);
-                if(next==-1) return 0; //do not parse next data
-
 		switch( command )
 		{
-                case 0x2741: next=chlogif_parse_BankingAck(fd); break;
-		case 0x2743: next=chlogif_parse_vipack(fd); break;
-		// acknowledgement of connect-to-loginserver request
-		case 0x2711: next=chlogif_parse_ackconnect(fd,sd); break;
-		// acknowledgement of account authentication request
-		case 0x2713: next=chlogif_parse_ackaccreq(fd, sd); break;
-		// account data
-		case 0x2717: next=chlogif_parse_reqaccdata(fd, sd); break;
-		// login-server alive packet
-		case 0x2718: next=chlogif_parse_keepalive(fd, sd); break;
-		// changesex reply
-		case 0x2723: next=chlogif_parse_ackchangesex(fd, sd); break;
-		// reply to an account_reg2 registry request
-		case 0x2729: next=chlogif_parse_ackacc2req(fd, sd); break;
-		// State change of account/ban notification (from login-server)
-		case 0x2731: next=chlogif_parse_accbannotification(fd, sd); break;
-		// Login server request to kick a character out. [Skotlex]
-		case 0x2734: next=chlogif_parse_askkick(fd,sd); break;
-		// ip address update signal from login server
-		case 0x2735: next=chlogif_parse_updip(fd,sd); break;
-		default:
-			ShowError("Unknown packet 0x%04x received from login-server, disconnecting.\n", command);
-			set_eof(fd);
-			return 0;
+			case 0x2741: next=chlogif_parse_BankingAck(fd); break;
+			case 0x2743: next=chlogif_parse_vipack(fd); break;
+			// acknowledgement of connect-to-loginserver request
+			case 0x2711: next=chlogif_parse_ackconnect(fd,sd); break;
+			// acknowledgement of account authentication request
+			case 0x2713: next=chlogif_parse_ackaccreq(fd, sd); break;
+			// account data
+			case 0x2717: next=chlogif_parse_reqaccdata(fd, sd); break;
+			// login-server alive packet
+			case 0x2718: next=chlogif_parse_keepalive(fd, sd); break;
+			// changesex reply
+			case 0x2723: next=chlogif_parse_ackchangesex(fd, sd); break;
+			// reply to an account_reg2 registry request
+			case 0x2729: next=chlogif_parse_ackacc2req(fd, sd); break;
+			// State change of account/ban notification (from login-server)
+			case 0x2731: next=chlogif_parse_accbannotification(fd, sd); break;
+			// Login server request to kick a character out. [Skotlex]
+			case 0x2734: next=chlogif_parse_askkick(fd,sd); break;
+			// ip address update signal from login server
+			case 0x2735: next=chlogif_parse_updip(fd,sd); break;
+			default:
+				ShowError("Unknown packet 0x%04x received from login-server, disconnecting.\n", command);
+				set_eof(fd);
+				return 0;
 		}
+		if(next==0) return 0; //do not parse next data
 	}
 
 	RFIFOFLUSH(fd);

+ 58 - 59
src/char/char_mapif.c

@@ -175,7 +175,7 @@ void chmapif_sendall_playercount(int users){
 int chmapif_parse_getmapname(int fd, int id){
 	int j = 0, i = 0;
 	if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
-		return -1;
+		return 0;
 
 	//Retain what map-index that map-serv contains
 	memset(map_server[id].map, 0, sizeof(map_server[id].map));
@@ -202,7 +202,7 @@ int chmapif_parse_getmapname(int fd, int id){
 		if (j == 0) {
 			ShowWarning("Map-server %d has NO maps.\n", id);
 		} else {
-                        unsigned char buf[16384];
+			unsigned char buf[16384];
 			// Transmitting maps information to the other map-servers
 			WBUFW(buf,0) = 0x2b04;
 			WBUFW(buf,2) = j * 4 + 10;
@@ -241,7 +241,7 @@ int chmapif_parse_getmapname(int fd, int id){
  */
 int chmapif_parse_askscdata(int fd){
 	if (RFIFOREST(fd) < 10)
-		return -1;
+		return 0;
 	{
 #ifdef ENABLE_SC_SAVING
 		int aid, cid;
@@ -251,7 +251,7 @@ int chmapif_parse_askscdata(int fd){
 			schema_config.scdata_db, aid, cid) )
 		{
 			Sql_ShowDebug(sql_handle);
-			return 0;
+			return 1;
 		}
 		if( Sql_NumRows(sql_handle) > 0 )
 		{
@@ -297,7 +297,7 @@ int chmapif_parse_askscdata(int fd){
  */
 int chmapif_parse_getusercount(int fd, int id){
 	if (RFIFOREST(fd) < 4)
-		return -1;
+		return 0;
 	if (RFIFOW(fd,2) != map_server[id].users) {
 		map_server[id].users = RFIFOW(fd,2);
 		ShowInfo("User Count: %d (Server: %d)\n", map_server[id].users, id);
@@ -313,12 +313,11 @@ int chmapif_parse_getusercount(int fd, int id){
  * @return : 0 not enough data received, 1 success
  */
 int chmapif_parse_regmapuser(int fd, int id){
-	int i;
 	if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,2))
-		return -1;
+		return 0;
 	{
 		//TODO: When data mismatches memory, update guild/party online/offline states.
-		int aid, cid;
+		int aid, cid, i;
 		struct online_char_data* character;
 		DBMap* online_char_db = char_get_onlinedb();
 
@@ -352,7 +351,7 @@ int chmapif_parse_regmapuser(int fd, int id){
  */
 int chmapif_parse_reqsavechar(int fd, int id){
 	if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
-            return -1;
+            return 0;
 	{
 		int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2);
 		struct online_char_data* character;
@@ -362,7 +361,7 @@ int chmapif_parse_reqsavechar(int fd, int id){
 		{
 			ShowError("parse_from_map (save-char): Size mismatch! %d != %d\n", size-13, sizeof(struct mmo_charstatus));
 			RFIFOSKIP(fd,size);
-			return 0;
+			return 1;
 		}
 		//Check account only if this ain't final save. Final-save goes through because of the char-map reconnect
 		if (RFIFOB(fd,12) || RFIFOB(fd,13) || (
@@ -398,7 +397,7 @@ int chmapif_parse_reqsavechar(int fd, int id){
  */
 int chmapif_parse_authok(int fd){
 	if( RFIFOREST(fd) < 19 )
-		return -1;
+		return 0;
 	else{
 		int account_id = RFIFOL(fd,2);
 		uint32 login_id1 = RFIFOL(fd,6);
@@ -426,7 +425,7 @@ int chmapif_parse_authok(int fd){
 			node->login_id2 = login_id2;
 			//node->sex = 0;
 			node->ip = ntohl(ip);
-                        node->version = version; //upd version for mapserv
+			node->version = version; //upd version for mapserv
 			//node->expiration_time = 0; // unlimited/unknown time by default (not display in map-server)
 			//node->gmlevel = 0;
 			idb_put(auth_db, account_id, node);
@@ -453,7 +452,7 @@ int chmapif_parse_authok(int fd){
 //Request to save skill cooldown data
 int chmapif_parse_req_saveskillcooldown(int fd){
 	if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) )
-            return -1;
+            return 0;
 	else {
 		int count, aid, cid;
 		aid = RFIFOL(fd,4);
@@ -486,16 +485,17 @@ int chmapif_parse_req_saveskillcooldown(int fd){
 //Request skillcooldown data 0x2b0a
 int chmapif_parse_req_skillcooldown(int fd){
 	if (RFIFOREST(fd) < 10)
-		return -1;
+		return 0;
 	else {
 		int aid, cid;
 		aid = RFIFOL(fd,2);
 		cid = RFIFOL(fd,6);
+		RFIFOSKIP(fd, 10);
 		if( SQL_ERROR == Sql_Query(sql_handle, "SELECT skill, tick FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
 			schema_config.skillcooldown_db, aid, cid) )
 		{
 			Sql_ShowDebug(sql_handle);
-			return 0;
+			return 1;
 		}
 		if( Sql_NumRows(sql_handle) > 0 )
 		{
@@ -526,7 +526,6 @@ int chmapif_parse_req_skillcooldown(int fd){
 			}
 		}
 		Sql_FreeResult(sql_handle);
-		RFIFOSKIP(fd, 10);
 	}
 	return 1;
 }
@@ -538,7 +537,7 @@ int chmapif_parse_req_skillcooldown(int fd){
  */
 int chmapif_parse_reqchangemapserv(int fd){
 	if (RFIFOREST(fd) < 39)
-		return -1;
+		return 0;
 	{
 		int map_id, map_fd = -1;
 		struct mmo_charstatus* char_data;
@@ -615,7 +614,7 @@ int chmapif_parse_reqchangemapserv(int fd){
  */
 int chmapif_parse_askrmfriend(int fd){
 	if (RFIFOREST(fd) < 10)
-		return -1;
+		return 0;
 	{
 		int char_id, friend_id;
 		char_id = RFIFOL(fd,2);
@@ -623,7 +622,7 @@ int chmapif_parse_askrmfriend(int fd){
 		if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1",
 			schema_config.friend_db, char_id, friend_id) ) {
 			Sql_ShowDebug(sql_handle);
-			return 0;
+			return 1;
 		}
 		RFIFOSKIP(fd,10);
 	}
@@ -638,7 +637,7 @@ int chmapif_parse_askrmfriend(int fd){
  */
 int chmapif_parse_reqcharname(int fd){
 	if (RFIFOREST(fd) < 6)
-		return -1;
+		return 0;
 
 	WFIFOHEAD(fd,30);
 	WFIFOW(fd,0) = 0x2b09;
@@ -658,7 +657,7 @@ int chmapif_parse_reqcharname(int fd){
  */
 int chmapif_parse_reqnewemail(int fd){
 	if (RFIFOREST(fd) < 86)
-		return -1;
+		return 0;
 	if (chlogif_isconnected()) { // don't send request if no login-server
 		WFIFOHEAD(login_fd,86);
 		memcpy(WFIFOP(login_fd,0), RFIFOP(fd,0),86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
@@ -676,7 +675,7 @@ int chmapif_parse_reqnewemail(int fd){
  */
 int chmapif_parse_fwlog_changestatus(int fd){
 	if (RFIFOREST(fd) < 44)
-		return -1;
+		return 0;
 	else {
 		int result = 0; // 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline, 4-current group level > VIP group level
 		char esc_name[NAME_LENGTH*2+1];
@@ -783,7 +782,7 @@ int chmapif_parse_fwlog_changestatus(int fd){
  */
 int chmapif_parse_req_alter_acc(int fd){
 	if (RFIFOREST(fd) < 11)
-		return -1;
+		return 0;
 	{
 		int cid = RFIFOL(fd, 2);
 		int fame = RFIFOL(fd, 6);
@@ -856,7 +855,7 @@ void chmapif_send_ackdivorce(int partner_id1, int partner_id2){
  */
 int chmapif_parse_reqdivorce(int fd){
 	if( RFIFOREST(fd) < 10 )
-		return -1;
+		return 0;
 	char_divorce_char_sql(RFIFOL(fd,2), RFIFOL(fd,6));
 	RFIFOSKIP(fd,10);
 	return 1;
@@ -870,7 +869,7 @@ int chmapif_parse_reqdivorce(int fd){
  */
 int chmapif_parse_updmapinfo(int fd){
 	if( RFIFOREST(fd) < 14 )
-		return -1;
+		return 0;
 	{
 		char esc_server_name[sizeof(charserv_config.server_name)*2+1];
 		Sql_EscapeString(sql_handle, esc_server_name, charserv_config.server_name);
@@ -890,7 +889,7 @@ int chmapif_parse_updmapinfo(int fd){
  */
 int chmapif_parse_setcharoffline(int fd){
 	if (RFIFOREST(fd) < 6)
-		return -1;
+		return 0;
 	char_set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6));
 	RFIFOSKIP(fd,10);
 	return 1;
@@ -919,7 +918,7 @@ int chmapif_parse_setalloffline(int fd, int id){
  */
 int chmapif_parse_setcharonline(int fd, int id){
 	if (RFIFOREST(fd) < 10)
-		return -1;
+		return 0;
 	char_set_char_online(id, RFIFOL(fd,2),RFIFOL(fd,6));
 	RFIFOSKIP(fd,10);
 	return 1;
@@ -934,7 +933,7 @@ int chmapif_parse_setcharonline(int fd, int id){
  */
 int chmapif_parse_reqfamelist(int fd){
 	if (RFIFOREST(fd) < 2)
-		return -1;
+		return 0;
 	char_read_fame_list();
 	chmapif_send_fame_list(-1);
 	RFIFOSKIP(fd,2);
@@ -949,7 +948,7 @@ int chmapif_parse_reqfamelist(int fd){
  */
 int chmapif_parse_save_scdata(int fd){
 	if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
-		return -1;
+		return 0;
 	{
 #ifdef ENABLE_SC_SAVING
 		int count, aid, cid;
@@ -958,10 +957,10 @@ int chmapif_parse_save_scdata(int fd){
 		cid = RFIFOL(fd, 8);
 		count = RFIFOW(fd, 12);
 
-                // Whatever comes from the mapserver, now is the time to drop previous entries
-                if( Sql_Query( sql_handle, "DELETE FROM `%s` where `account_id` = %d and `char_id` = %d;", schema_config.scdata_db, aid, cid ) != SQL_SUCCESS ){
-                        Sql_ShowDebug( sql_handle );
-                }
+		// Whatever comes from the mapserver, now is the time to drop previous entries
+		if( Sql_Query( sql_handle, "DELETE FROM `%s` where `account_id` = %d and `char_id` = %d;", schema_config.scdata_db, aid, cid ) != SQL_SUCCESS ){
+				Sql_ShowDebug( sql_handle );
+		}
 		else if( count > 0 )
 		{
 			struct status_change_data data;
@@ -1008,7 +1007,7 @@ int chmapif_parse_keepalive(int fd){
  */
 int chmapif_parse_reqauth(int fd, int id){
     if (RFIFOREST(fd) < 20)
-            return -1;
+            return 0;
 
     {
         int account_id;
@@ -1019,7 +1018,7 @@ int chmapif_parse_reqauth(int fd, int id){
         struct auth_node* node;
         struct mmo_charstatus* cd;
         struct mmo_charstatus char_dat;
-        bool autotrade;
+        bool autotrade = false;
 
         DBMap*  auth_db = char_get_authdb();
         DBMap* char_db_ = char_get_chardb();
@@ -1104,7 +1103,7 @@ int chmapif_parse_reqauth(int fd, int id){
  */
 int chmapif_parse_updmapip(int fd, int id){
 	if (RFIFOREST(fd) < 6) 
-            return -1;
+            return 0;
 	map_server[id].ip = ntohl(RFIFOL(fd, 2));
 	ShowInfo("Updated IP address of map-server #%d to %d.%d.%d.%d.\n", id, CONVIP(map_server[id].ip));
 	RFIFOSKIP(fd,6);
@@ -1118,7 +1117,7 @@ int chmapif_parse_updmapip(int fd, int id){
  */
 int chmapif_parse_fw_configstats(int fd){
 	if( RFIFOREST(fd) < RFIFOW(fd,4) )
-		return -1;/* packet wasn't fully received yet (still fragmented) */
+		return 0;/* packet wasn't fully received yet (still fragmented) */
 	else {
 		int sfd;/* stat server fd */
 		RFIFOSKIP(fd, 2);/* we skip first 2 bytes which are the 0x3008, so we end up with a buffer equal to the one we send */
@@ -1141,7 +1140,7 @@ int chmapif_parse_fw_configstats(int fd){
 
 int chmapif_parse_updfamelist(int fd){
     if (RFIFOREST(fd) < 11)
-        return -1;
+        return 0;
     {
             int cid = RFIFOL(fd, 2);
             int fame = RFIFOL(fd, 6);
@@ -1224,7 +1223,7 @@ int chmapif_vipack(int mapfd, uint32 aid, uint32 vip_time, uint8 isvip, uint8 is
 
 int chmapif_parse_reqcharban(int fd){
 	if (RFIFOREST(fd) < 10+NAME_LENGTH)
-		return -1;
+		return 0;
 	else {
 		//int aid = RFIFOL(fd,2); aid of player who as requested the ban
 		int timediff = RFIFOL(fd,6);
@@ -1234,12 +1233,12 @@ int chmapif_parse_reqcharban(int fd){
 		if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`unban_time` FROM `%s` WHERE `name` = '%s'", schema_config.char_db, name) )
 			Sql_ShowDebug(sql_handle);
 		else if( Sql_NumRows(sql_handle) == 0 ){
-			return -1; // 1-player not found
+			return 1; // 1-player not found
 		}
 		else if( SQL_SUCCESS != Sql_NextRow(sql_handle) ){
 			Sql_ShowDebug(sql_handle);
 			Sql_FreeResult(sql_handle);
-			return -1;
+			return 1;
 		} else {
 			int t_cid=0,t_aid=0;
 			char* data;
@@ -1252,7 +1251,8 @@ int chmapif_parse_reqcharban(int fd){
 			Sql_GetData(sql_handle, 2, &data, NULL); unban_time = atol(data);
 			Sql_FreeResult(sql_handle);
 
-			if(timediff<0 && unban_time==0) return 0; //attemp to reduce time of a non banned account ?!?
+			if(timediff<0 && unban_time==0) 
+				return 1; //attemp to reduce time of a non banned account ?!?
 			else if(unban_time<now) unban_time=now; //new entry
 			unban_time += timediff; //alterate the time
 			if( unban_time < now ) unban_time=0; //we have totally reduce the time
@@ -1267,7 +1267,7 @@ int chmapif_parse_reqcharban(int fd){
 				) {
 				SqlStmt_ShowDebug(stmt);
 				SqlStmt_Free(stmt);
-				return -1;
+				return 1;
 			}
 			SqlStmt_Free(stmt);
 
@@ -1284,22 +1284,22 @@ int chmapif_parse_reqcharban(int fd){
 			}
 		}
 	}
-	return 0;
+	return 1;
 }
 
 int chmapif_parse_reqcharunban(int fd){
 	if (RFIFOREST(fd) < 6)
-            return -1;
+            return 0;
 	else {
 		int cid = RFIFOL(fd,2);
 		RFIFOSKIP(fd,6);
 
 		if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `unban_time` = '0' WHERE `char_id` = '%d' LIMIT 1", schema_config.char_db, cid) ) {
 			Sql_ShowDebug(sql_handle);
-			return -1;
+			return 1;
 		}
 	}
-	return 0;
+	return 1;
 }
 
 /** [Cydh]
@@ -1308,7 +1308,7 @@ int chmapif_parse_reqcharunban(int fd){
 */
 int chmapif_bonus_script_get(int fd) {
 	if (RFIFOREST(fd) < 6)
-            return -1;
+            return 0;
 	else {
 		int cid;
 		cid = RFIFOL(fd,2);
@@ -1318,7 +1318,7 @@ int chmapif_bonus_script_get(int fd) {
 			schema_config.bonus_script_db,cid))
 		{
 			Sql_ShowDebug(sql_handle);
-			return 0;
+			return 1;
 		}
 		if (Sql_NumRows(sql_handle) > 0) {
 			struct bonus_script_data bsdata;
@@ -1351,7 +1351,7 @@ int chmapif_bonus_script_get(int fd) {
 		}
 		Sql_FreeResult(sql_handle);
 	}
-        return 1;
+	return 1;
 }
 
 /** [Cydh]
@@ -1360,7 +1360,7 @@ int chmapif_bonus_script_get(int fd) {
 */
 int chmapif_bonus_script_save(int fd) {
 	if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
-            return -1;
+            return 0;
 	else {
 		int count, cid;
 
@@ -1389,7 +1389,7 @@ int chmapif_bonus_script_save(int fd) {
 		}
 		RFIFOSKIP(fd,RFIFOW(fd,2));
 	}
-        return 1;
+	return 1;
 }
 
 /**
@@ -1401,7 +1401,7 @@ int chmapif_bonus_script_save(int fd) {
  */
 int chmapif_parse(int fd){
 	int id; //mapserv id
-        int next=0;
+        
 	ARR_FIND( 0, ARRAYLENGTH(map_server), id, map_server[id].fd == fd );
 	if( id == ARRAYLENGTH(map_server) )
 	{// not a map server
@@ -1418,9 +1418,8 @@ int chmapif_parse(int fd){
 	}
 
 	while(RFIFOREST(fd) >= 2){
-            if(next==-1) return 0; //avoid processing rest of packet
-            
-            switch(RFIFOW(fd,0)){
+		int next=1;
+		switch(RFIFOW(fd,0)){
             case 0x2736: next=chmapif_parse_updmapip(fd,id); break;
             case 0x2afa: next=chmapif_parse_getmapname(fd,id); break;
             case 0x2afc: next=chmapif_parse_askscdata(fd); break;
@@ -1433,7 +1432,7 @@ int chmapif_parse(int fd){
             case 0x2b08: next=chmapif_parse_reqcharname(fd); break;
             case 0x2b0a: next=chmapif_parse_req_skillcooldown(fd); break;
             case 0x2b0c: next=chmapif_parse_reqnewemail(fd); break;
-            case 0x2b0e: next=chmapif_parse_req_alter_acc(fd); break;
+            case 0x2b0e: next=chmapif_parse_fwlog_changestatus(fd); break;
             case 0x2b10: next=chmapif_parse_updfamelist(fd); break;
             case 0x2b11: next=chmapif_parse_reqdivorce(fd); break;
             case 0x2b15: next=chmapif_parse_req_saveskillcooldown(fd); break;
@@ -1462,9 +1461,9 @@ int chmapif_parse(int fd){
                     set_eof(fd);
                     return 0;
             }
-            } // switch
+		} // switch
+		if(next==0) return 0; //avoid processing rest of packet
 	} // while
-
 	return 1;
 }