summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-09-03 05:42:43 +0200
committerHaru <haru@dotalux.com>2013-09-03 19:46:44 +0200
commitdf0a324108cd8b6ee7ac984700efed80044ed7c3 (patch)
treedf98a2e51a2a86df68b5dc9c1fffef253a150187 /src
parent51b7f5c6f6af53c3fc6a71ede9aea6b760a91491 (diff)
downloadhercules-df0a324108cd8b6ee7ac984700efed80044ed7c3.tar.gz
hercules-df0a324108cd8b6ee7ac984700efed80044ed7c3.tar.bz2
hercules-df0a324108cd8b6ee7ac984700efed80044ed7c3.tar.xz
hercules-df0a324108cd8b6ee7ac984700efed80044ed7c3.zip
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 <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c10
-rw-r--r--src/common/mmo.h6
-rw-r--r--src/map/clif.c6
-rw-r--r--src/map/packets_struct.h6
4 files changed, 22 insertions, 6 deletions
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;
diff --git a/src/common/mmo.h b/src/common/mmo.h
index a297d94d9..17a01ff95 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -64,6 +64,7 @@
// Comment the following line to disable sc_data saving. [Skotlex]
#define ENABLE_SC_SAVING
+#if PACKETVER >= 20070227
// Comment the following like to disable server-side hot-key saving support. [Skotlex]
// Note that newer clients no longer save hotkeys in the registry!
#define HOTKEY_SAVING
@@ -74,10 +75,11 @@
#elif PACKETVER < 20090617
// (36 = 9 skills x 4 bars) (0x07d9,254)
#define MAX_HOTKEYS 36
-#else
+#else // >= 20090617
// (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268)
#define MAX_HOTKEYS 38
-#endif
+#endif // 20090603
+#endif // 20070227
#define MAX_INVENTORY 100
//Max number of characters per account. Note that changing this setting alone is not enough if the client is not hexed to support more characters as well.
diff --git a/src/map/clif.c b/src/map/clif.c
index fad10be92..306a83082 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -873,7 +873,9 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en
sd = BL_CAST(BL_PC, bl);
p.PacketType = idle_unit2Type;
+#if PACKETVER >= 20071106
p.objecttype = clif_bl_type(bl);
+#endif
p.GID = bl->id;
p.speed = iStatus->get_speed(bl);
p.bodyState = (sc) ? sc->opt1 : 0;
@@ -1005,7 +1007,9 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) {
sd = BL_CAST(BL_PC, bl);
p.PacketType = spawn_unit2Type;
+#if PACKETVER >= 20071106
p.objecttype = clif_bl_type(bl);
+#endif
p.GID = bl->id;
p.speed = iStatus->get_speed(bl);
p.bodyState = (sc) ? sc->opt1 : 0;
@@ -1133,7 +1137,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
#if PACKETVER >= 20091103
p.PacketLength = sizeof(p);
#endif
-#if PACKETVER > 7
+#if PACKETVER >= 20071106
p.objecttype = clif_bl_type(bl);
#endif
p.GID = bl->id;
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index 053cd96b8..0e04756ec 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -180,7 +180,9 @@ struct packet_dropflooritem {
#if PACKETVER < 20091103
struct packet_idle_unit2 {
short PacketType;
+#if PACKETVER >= 20071106
unsigned char objecttype;
+#endif
unsigned int GID;
short speed;
short bodyState;
@@ -210,7 +212,9 @@ struct packet_idle_unit2 {
} __attribute__((packed));
struct packet_spawn_unit2 {
short PacketType;
+#if PACKETVER >= 20071106
unsigned char objecttype;
+#endif
unsigned int GID;
short speed;
short bodyState;
@@ -297,7 +301,7 @@ struct packet_unit_walking {
#if PACKETVER >= 20091103
short PacketLength;
#endif
-#if PACKETVER > 7
+#if PACKETVER > 20071106
unsigned char objecttype;
#endif
unsigned int GID;