diff options
-rw-r--r-- | Changelog-Trunk.txt | 1 | ||||
-rw-r--r-- | src/char/char.c | 139 | ||||
-rw-r--r-- | src/char_sql/char.c | 38 |
3 files changed, 77 insertions, 101 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 2ad9e9ae0..2fd2d4f8b 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/12/21 + * Some cleaning to the character deletion code. * Changed a certain snprintf to strncpy, which should fix the problems with parsing switches in the script engine. * Added back cropping the attack delay to attack motion for those weird mobs diff --git a/src/char/char.c b/src/char/char.c index f3bc477d8..ac70d3046 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3684,9 +3684,12 @@ int parse_char(int fd) { case 0x68: // delete char //Yor's Fix FIFOSD_CHECK(46); { + int cid = RFIFOL(fd,2); + struct mmo_charstatus *cs = NULL; WFIFOHEAD(fd, 46); WFIFOHEAD(login_fd,46); memcpy(email, RFIFOP(fd,6), 40); + RFIFOSKIP(fd,46); if (e_mail_check(email) == 0) strncpy(email, "a@a.com", 40); // default e-mail @@ -3697,90 +3700,78 @@ int parse_char(int fd) { WFIFOW(fd, 0) = 0x70; WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address WFIFOSET(fd, 3); - RFIFOSKIP(fd,46); - // we act like we have selected a character - } else { - // we change the packet to set it like selection. - for (i = 0; i < 9; i++) - if (char_dat[sd->found_char[i]].status.char_id == RFIFOL(fd,2)) { - // we save new e-mail - memcpy(sd->email, email, 40); - // we send new e-mail to login-server ('online' login-server is checked before) - WFIFOW(login_fd,0) = 0x2715; - WFIFOL(login_fd,2) = sd->account_id; - memcpy(WFIFOP(login_fd, 6), email, 40); - WFIFOSET(login_fd,46); - // skip part of the packet! (46, but leave the size of select packet: 3) - RFIFOSKIP(fd,43); - // change value to put new packet (char selection) - RFIFOW(fd, 0) = 0x66; - RFIFOB(fd, 2) = char_dat[sd->found_char[i]].status.char_num; - // not send packet, it's modify of actual packet - break; - } - if (i == 9) { - WFIFOW(fd, 0) = 0x70; - WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address - WFIFOSET(fd, 3); - RFIFOSKIP(fd,46); - } + break; } - - // otherwise, we delete the character - } else { - if (strcmpi(email, sd->email) != 0) { // if it's an invalid email + // we change the packet to set it like selection. + for (i = 0; i < 9; i++) + if (sd->found_char[i] != -1 && char_dat[sd->found_char[i]].status.char_id == cid) { + // we save new e-mail + memcpy(sd->email, email, 40); + // we send new e-mail to login-server ('online' login-server is checked before) + WFIFOW(login_fd,0) = 0x2715; + WFIFOL(login_fd,2) = sd->account_id; + memcpy(WFIFOP(login_fd, 6), email, 40); + WFIFOSET(login_fd,46); + // change value to put new packet (char selection) + RFIFOSKIP(fd,-3); //FIXME: Will this work? Messing with the received buffer is ugly anyway... + RFIFOW(fd, 0) = 0x66; + RFIFOB(fd, 2) = char_dat[sd->found_char[i]].status.char_num; + // not send packet, it's modify of actual packet + break; + } + if (i == 9) { WFIFOW(fd, 0) = 0x70; WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address WFIFOSET(fd, 3); - // if mail is correct - } else { - for (i = 0; i < 9; i++) { - struct mmo_charstatus *cs = NULL; - if ((cs = &char_dat[sd->found_char[i]].status)->char_id == RFIFOL(fd,2)) { - char_delete(cs); // deletion process - - if (sd->found_char[i] != char_num - 1) { - memcpy(&char_dat[sd->found_char[i]], &char_dat[char_num-1], sizeof(struct mmo_charstatus)); - // Correct moved character reference in the character's owner - { - int j, k; - struct char_session_data *sd2; - for (j = 0; j < fd_max; j++) { - if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) && - sd2->account_id == char_dat[char_num-1].status.account_id) { - for (k = 0; k < 9; k++) { - if (sd2->found_char[k] == char_num-1) { - sd2->found_char[k] = sd->found_char[i]; - break; - } - } - break; - } - } - } + } + break; + } + // otherwise, we delete the character + if (strcmpi(email, sd->email) != 0) { // if it's an invalid email + WFIFOW(fd, 0) = 0x70; + WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address + WFIFOSET(fd, 3); + break; + } + for (i = 0; i < 9; i++) { + if (sd->found_char[i] == -1) continue; + if (char_dat[sd->found_char[i]].status.char_id == cid) break; + } + if (i == 9) { + WFIFOW(fd,0) = 0x70; + WFIFOB(fd,2) = 0; + WFIFOSET(fd,3); + break; + } + // deletion process + cs = &char_dat[sd->found_char[i]].status; + char_delete(cs); + if (sd->found_char[i] != char_num - 1) { + int j, k; + struct char_session_data *sd2; + memcpy(&char_dat[sd->found_char[i]], &char_dat[char_num-1], sizeof(struct mmo_charstatus)); + // Correct moved character reference in the character's owner + for (j = 0; j < fd_max; j++) { + if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) && + sd2->account_id == char_dat[char_num-1].status.account_id) { + for (k = 0; k < 9; k++) { + if (sd2->found_char[k] == char_num-1) { + sd2->found_char[k] = sd->found_char[i]; + break; } - - char_num--; - for(ch = i; ch < 9-1; ch++) - sd->found_char[ch] = sd->found_char[ch+1]; - sd->found_char[8] = -1; - WFIFOW(fd,0) = 0x6f; - WFIFOSET(fd,2); - break; } - } - - if (i == 9) { - WFIFOW(fd,0) = 0x70; - WFIFOB(fd,2) = 0; - WFIFOSET(fd,3); + break; } } - RFIFOSKIP(fd,46); } - } + char_num--; + for(ch = i; ch < 9-1; ch++) + sd->found_char[ch] = sd->found_char[ch+1]; + sd->found_char[8] = -1; + WFIFOW(fd,0) = 0x6f; + WFIFOSET(fd,2); break; - + } case 0x2af8: // マップサーバーログイン if (RFIFOREST(fd) < 60) return 0; diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 2a42ecc7f..77e72805d 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -3494,34 +3494,21 @@ int parse_char(int fd) { WFIFOHEAD(fd, 46); ShowInfo(CL_RED" Request Char Deletion:"CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid); memcpy(email, RFIFOP(fd,6), 40); + RFIFOSKIP(fd, 46); /* Check if e-mail is correct */ - if(strcmpi(email, sd->email)){ - if(strcmp("a@a.com", sd->email) == 0){ - if(strcmp("a@a.com", email) == 0 || strcmp("", email) == 0){ - //ignore - }else{ - //del fail - WFIFOW(fd, 0) = 0x70; - WFIFOB(fd, 2) = 0; - WFIFOSET(fd, 3); - RFIFOSKIP(fd, 46); - break; - } - }else{ - //del fail - WFIFOW(fd, 0) = 0x70; - WFIFOB(fd, 2) = 0; - WFIFOSET(fd, 3); - RFIFOSKIP(fd, 46); - break; - } + if(strcmpi(email, sd->email) && //email does not matches and + ( + strcmp("a@a.com", sd->email) || //it is not default email, or + (strcmp("a@a.com", email) && strcmp("", email)) //email sent does not matches default + )) { //Fail + WFIFOW(fd, 0) = 0x70; + WFIFOB(fd, 2) = 0; + WFIFOSET(fd, 3); + break; } for(i = 0; i < 9; i++) { - /* Debug: - printf("Checking if char to be deleted: %d - %d (%d)\n", sd->found_char[i], RFIFOL(fd, 2), sd->account_id); - */ if (sd->found_char[i] == cid) { for(ch = i; ch < 9-1; ch++) sd->found_char[ch] = sd->found_char[ch+1]; @@ -3564,13 +3551,12 @@ int parse_char(int fd) { WFIFOW(fd, 0) = 0x70; WFIFOB(fd, 2) = 0; WFIFOSET(fd, 3); - RFIFOSKIP(fd, 46); break; } if (char_pid != 0) { /* If there is partner, tell map server to do divorce */ WBUFW(buf,0) = 0x2b12; - WBUFL(buf,2) = RFIFOL(fd,2); + WBUFL(buf,2) = cid; WBUFL(buf,6) = char_pid; mapif_sendall(buf,10); } @@ -3578,8 +3564,6 @@ int parse_char(int fd) { /* Char successfully deleted.*/ WFIFOW(fd, 0) = 0x6f; WFIFOSET(fd, 2); - - RFIFOSKIP(fd, 46); break; } case 0x2af8: // login as map-server |