From 30c8d7704026aa450b64997c2996ee8d9d4f2cec Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 19 Nov 2009 18:19:09 +0000 Subject: - Applied the renewal client support patch from Diablo (eA forum topic 222623) - Added support for strcharinfo(3) to retrieve the player's map - Added script command "searchitem" for name item searches. - Moved PACKETVER to src/common/mmo.h as it's needed by the char-server now - Changed the status valX from int to long so that it won't break for pointer-storage in other architectures. - Moved the change party leader code to party.c - A few bugfixes or packet field completions based on my past experience messing around with my server. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14155 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/char/char.c | 53 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'src/char/char.c') diff --git a/src/char/char.c b/src/char/char.c index 200257584..f2910751f 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1675,16 +1675,19 @@ int count_users(void) return users; } -/// Writes char data to the buffer in the format used by the client. -/// 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) +// Writes char data to the buffer in the format used by the client. +// Used in packets 0x6b (chars info) and 0x6d (new char info) +// Returns the size +#define MAX_CHAR_BUF 110 //Max size (for WFIFOHEAD calls) +int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { - int size = 106; + unsigned short offset = 0; + uint8* buf; - if( buf == NULL || p == NULL ) + if( buffer == NULL || p == NULL ) return 0; + buf = WBUFP(buffer,0); WBUFL(buf,0) = p->char_id; WBUFL(buf,4) = min(p->base_exp, LONG_MAX); WBUFL(buf,8) = p->zeny; @@ -1696,8 +1699,15 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p) WBUFL(buf,32) = p->karma; WBUFL(buf,36) = p->manner; WBUFW(buf,40) = min(p->status_point, SHRT_MAX); +#if PACKETVER > 20081217 + WBUFL(buf,42) = p->hp; + WBUFL(buf,46) = p->max_hp; + offset+=4; + buf = WBUFP(buffer,offset); +#else WBUFW(buf,42) = min(p->hp, SHRT_MAX); WBUFW(buf,44) = min(p->max_hp, SHRT_MAX); +#endif WBUFW(buf,46) = min(p->sp, SHRT_MAX); WBUFW(buf,48) = min(p->max_sp, SHRT_MAX); WBUFW(buf,50) = DEFAULT_WALK_SPEED; // p->speed; @@ -1722,10 +1732,9 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p) WBUFW(buf,104) = p->slot; #if PACKETVER >= 20061023 WBUFW(buf,106) = ( p->rename > 0 ) ? 0 : 1; - size += 2; + offset += 2; #endif - - return size; + return 106+offset; } //---------------------------------------- @@ -1747,7 +1756,7 @@ int mmo_char_send006b(int fd, struct char_session_data* sd) sd->found_char[i] = -1; j = 24; // offset - WFIFOHEAD(fd,j + found_num*108); // or 106(!) + WFIFOHEAD(fd,j + found_num*MAX_CHAR_BUF); WFIFOW(fd,0) = 0x6b; memset(WFIFOP(fd,4), 0, 20); // unknown bytes for(i = 0; i < found_num; i++) @@ -3473,7 +3482,7 @@ int parse_char(int fd) { int len; // send to player - WFIFOHEAD(fd,110); + WFIFOHEAD(fd,MAX_CHAR_BUF+2); WFIFOW(fd,0) = 0x6d; len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status); WFIFOSET(fd,len); @@ -3613,6 +3622,28 @@ int parse_char(int fd) RFIFOSKIP(fd,34); break; + // captcha code request (not implemented) + // R 07e5 .w .l + case 0x7e5: + WFIFOHEAD(fd,5); + WFIFOW(fd,0) = 0x7e9; + WFIFOW(fd,2) = 5; + WFIFOB(fd,4) = 1; + WFIFOSET(fd,5); + RFIFOSKIP(fd,8); + break; + + // captcha code check (not implemented) + // R 07e7 .w .l .b10 .b14 + case 0x7e7: + WFIFOHEAD(fd,5); + WFIFOW(fd,0) = 0x7e9; + WFIFOW(fd,2) = 5; + WFIFOB(fd,4) = 1; + WFIFOSET(fd,5); + RFIFOSKIP(fd,32); + break; + // login as map-server case 0x2af8: if (RFIFOREST(fd) < 60) -- cgit v1.2.3-70-g09d2