From df0a324108cd8b6ee7ac984700efed80044ed7c3 Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 3 Sep 2013 05:42:43 +0200 Subject: Fixed several packet errors with pre-renewal clients from 2006-2008 Thanks to Beret for reporting the issues, Ind for his great help with research, suggestions and the necessary tools to fix this. Signed-off-by: Haru --- src/char/char.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/char/char.c') diff --git a/src/char/char.c b/src/char/char.c index e6e8732db..943d1f52e 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1811,8 +1811,7 @@ int count_users(void) // Used in packets 0x6b (chars info) and 0x6d (new char info) // Returns the size #define MAX_CHAR_BUF 144 //Max size (for WFIFOHEAD calls) -int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) -{ +int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { unsigned short offset = 0; uint8* buf; @@ -1831,10 +1830,15 @@ int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) WBUFL(buf,32) = p->karma; WBUFL(buf,36) = p->manner; WBUFW(buf,40) = min(p->status_point, INT16_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, INT16_MAX); + WBUFW(buf,44) = min(p->max_hp, INT16_MAX); +#endif WBUFW(buf,46) = min(p->sp, INT16_MAX); WBUFW(buf,48) = min(p->max_sp, INT16_MAX); WBUFW(buf,50) = DEFAULT_WALK_SPEED; // p->speed; @@ -1860,8 +1864,10 @@ int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) WBUFB(buf,102) = min(p->dex, UINT8_MAX); WBUFB(buf,103) = min(p->luk, UINT8_MAX); WBUFW(buf,104) = p->slot; +#if PACKETVER >= 20061023 WBUFW(buf,106) = ( p->rename > 0 ) ? 0 : 1; offset += 2; +#endif #if (PACKETVER >= 20100720 && PACKETVER <= 20100727) || PACKETVER >= 20100803 mapindex_getmapname_ext(mapindex_id2name(p->last_point.map), (char*)WBUFP(buf,108)); offset += MAP_NAME_LENGTH_EXT; -- cgit v1.2.3-60-g2f50