diff options
-rw-r--r-- | Changelog-Trunk.txt | 2 | ||||
-rw-r--r-- | src/char/char.c | 81 | ||||
-rw-r--r-- | src/char_sql/char.c | 82 |
3 files changed, 69 insertions, 96 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 90858fc6d..7406583cb 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,7 +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. 2007/02/16 - * Fixed the structure of packet 0x67 (new char info). It's the same as the + * Fixed the structure of packet 0x6d (new char info). It's the same as the one used for packet 0x6b (chars info). [FlavioJS] * Updated script commands startnpctimer, stopnpctimer, initnpctimer so you can attach a player to them, this is done because the attach/detach diff --git a/src/char/char.c b/src/char/char.c index 6f9c01cf5..e2a29a8ad 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1660,12 +1660,12 @@ int count_users(void) { } /// Writes char data to the buffer in the format used by the client. -/// Used in packets 0x6b (chars info) and 0x67 (new char info) -/// size = 104 -int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p) +/// Used in packets 0x6b (chars info) and 0x6d (new char info) +/// Returns the size (106 or 108) +int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p, int new_charscreen) { - if( p == NULL || buf == NULL ) - return 1;// Fail + if( buf == NULL || p == NULL ) + return 0; WBUFL(buf,0) = p->char_id; WBUFL(buf,4) = p->base_exp>LONG_MAX?LONG_MAX:p->base_exp; @@ -1707,7 +1707,14 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p) WBUFB(buf,102) = (p->dex > UCHAR_MAX) ? UCHAR_MAX : p->dex; WBUFB(buf,103) = (p->luk > UCHAR_MAX) ? UCHAR_MAX : p->luk; - return 0; + //Updated packet structure with rename-button included. Credits to Sara-chan + WBUFW(buf,104) = p->char_num; + if( new_charscreen ) + { + WBUFW(buf,106) = 1;// Rename bit (0=rename,1=no rename) + return 108; + } + return 106; } //---------------------------------------- @@ -1715,54 +1722,39 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p) //---------------------------------------- int mmo_char_send006b(int fd, struct char_session_data *sd) { int i, j, found_num; - struct mmo_charstatus *p; - const int offset = 24; - WFIFOHEAD(fd, offset + 9*108); - set_char_online(-1, 99,sd->account_id); + set_char_online(-1, 99, sd->account_id); found_num = 0; for(i = 0; i < char_num; i++) { if (char_dat[i].status.account_id == sd->account_id) { sd->found_char[found_num] = i; - found_num++; - if (found_num == 9) + if( ++found_num == 9 ) break; } } for(i = found_num; i < 9; i++) sd->found_char[i] = -1; -#if PACKETVER > 7 - //Updated packet structure with rename-button included. Credits to Sara-chan - memset(WFIFOP(fd,0), 0, offset + found_num * 108); - WFIFOW(fd,2) = offset + found_num * 108; -#else - memset(WFIFOP(fd,0), 0, offset + found_num * 106); - WFIFOW(fd,2) = offset + found_num * 106; -#endif - WFIFOW(fd,0) = 0x6b; - - for(i = 0; i < found_num; i++) { - p = &char_dat[sd->found_char[i]].status; -#if PACKETVER > 7 - j = offset + (i * 108); // increase speed of code -#else - j = offset + (i * 106); // increase speed of code -#endif - mmo_char_tobuf(WFIFOP(fd,j), p); + j = 24;// offset + { + WFIFOHEAD(fd, j + found_num*108); + WFIFOW(fd,0) = 0x6b; + memset(WFIFOP(fd,4), 0, 20);// unknown bytes -#if PACKETVER > 7 - WFIFOW(fd,j+104) = p->char_num; - WFIFOW(fd,j+106) = 1; //TODO: Handle this rename bit: 0 to enable renaming + for(i = 0; i < found_num; i++) + { +#if PACKETVER > 7 + j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat[sd->found_char[i]].status, 1); #else - WFIFOB(fd,j+104) = p->char_num; + j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat[sd->found_char[i]].status, 0); #endif + } + WFIFOW(fd,2) = j;// packet len + WFIFOSET(fd,j); } - WFIFOSET(fd,WFIFOW(fd,2)); - return 0; } @@ -3642,21 +3634,16 @@ int parse_char(int fd) { break; } { //Send to player. + int len; WFIFOHEAD(fd, 110); WFIFOW(fd,0) = 0x6d; - memset(WFIFOP(fd,2), 0, 108); - - mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status); - #if PACKETVER > 7 - //Updated packet structure with rename-button included. Credits to Sara-chan - WFIFOW(fd,2+104) = char_dat[i].status.char_num; - WFIFOB(fd,2+106) = 1; //Rename bit. - WFIFOSET(fd,110); + len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status, 1); #else - WFIFOB(fd,2+104) = char_dat[i].status.char_num; - WFIFOSET(fd,108); -#endif + len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status, 0); +#endif + WFIFOSET(fd,len); + RFIFOSKIP(fd,37); } for(ch = 0; ch < 9; ch++) { diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 12e1e0324..4361db586 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -1683,12 +1683,12 @@ int count_users(void) { } /// Writes char data to the buffer in the format used by the client. -/// Used in packets 0x6b (chars info) and 0x67 (new char info) -/// size = 104 -int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p) +/// Used in packets 0x6b (chars info) and 0x6d (new char info) +/// Returns the size (106 or 108) +int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p, int new_charscreen) { - if( p == NULL || buf == NULL ) - return 1;// Fail + if( buf == NULL || p == NULL ) + return 0; WBUFL(buf,0) = p->char_id; WBUFL(buf,4) = p->base_exp>LONG_MAX?LONG_MAX:p->base_exp; @@ -1730,15 +1730,20 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p) WBUFB(buf,102) = (p->dex > UCHAR_MAX) ? UCHAR_MAX : p->dex; WBUFB(buf,103) = (p->luk > UCHAR_MAX) ? UCHAR_MAX : p->luk; - return 0; + //Updated packet structure with rename-button included. Credits to Sara-chan + WBUFW(buf,104) = p->char_num; + if( new_charscreen ) + { + WBUFW(buf,106) = 1;// Rename bit (0=rename,1=no rename) + return 108; + } + return 106; } int mmo_char_send006b(int fd, struct char_session_data *sd) { int i, j, found_num = 0; struct mmo_charstatus *p = NULL; - const int offset = 24; - WFIFOHEAD(fd, offset +9*108); - + set_char_online(-1, 99,sd->account_id); //search char. @@ -1762,42 +1767,29 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { for(i = found_num; i < 9; i++) sd->found_char[i] = -1; -#if PACKETVER > 7 - //Updated packet structure with rename-button included. Credits to Sara-chan - memset(WFIFOP(fd, 0), 0, offset + found_num * 108); - WFIFOW(fd, 2) = offset + found_num * 108; -#else - memset(WFIFOP(fd, 0), 0, offset + found_num * 106); - WFIFOW(fd, 2) = offset + found_num * 106; -#endif - WFIFOW(fd, 0) = 0x6b; - if (save_log) ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id); - for(i = 0; i < found_num; i++) { - mmo_char_fromsql_short(sd->found_char[i], &char_dat); - - p = &char_dat; - -#if PACKETVER > 7 - j = offset + (i * 108); -#else - j = offset + (i * 106); // increase speed of code -#endif - mmo_char_tobuf(WFIFOP(fd,j), p); + j = 24;// offset + { + WFIFOHEAD(fd, j + found_num*108); + WFIFOW(fd,0) = 0x6b; + memset(WFIFOP(fd,4), 0, 20);// unknown bytes -#if PACKETVER > 7 - //Updated packet structure with rename-button included. Credits to Sara-chan - WFIFOW(fd,j+104) = p->char_num; - WFIFOW(fd,j+106) = 1; //TODO: Handle this rename bit: 0 to enable renaming + for(i = 0; i < found_num; i++) + { + mmo_char_fromsql_short(sd->found_char[i], &char_dat); +#if PACKETVER > 7 + j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat, 1); #else - WFIFOB(fd,j+104) = p->char_num; + j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat, 0); #endif + } + WFIFOW(fd,2) = j;// packet len + WFIFOSET(fd,j); } - WFIFOSET(fd,WFIFOW(fd,2)); -// printf("mmo_char_send006b end..\n"); + return 0; } @@ -3450,23 +3442,17 @@ int parse_char(int fd) { break; } { //Send data. + int len; WFIFOHEAD(fd, 110); WFIFOW(fd, 0) = 0x6d; - memset(WFIFOP(fd, 2), 0x00, 108); - mmo_char_fromsql_short(i, &char_dat); //Only the short data is needed. - - mmo_char_tobuf(WFIFOP(fd,2), &char_dat); - #if PACKETVER > 7 - //Updated packet structure with rename-button included. Credits to Sara-chan - WFIFOW(fd,2+104) = char_dat.char_num; - WFIFOB(fd,2+106) = 1; //Rename bit. - WFIFOSET(fd, 110); + len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat, 1); #else - WFIFOB(fd,2+104) = char_dat.char_num; - WFIFOSET(fd, 108); + len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat, 0); #endif + WFIFOSET(fd, len); + RFIFOSKIP(fd, 37); } //to do |