summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-07-31 11:46:12 -0300
committershennetsind <ind@henn.et>2013-07-31 11:46:12 -0300
commit298f02f380d4de88129f0a296456d461cbc6505e (patch)
tree156d79a8237d6e5553a0249d4c8b8035f6c420e0
parent2d916eb9db83b67983f8135d2806f2c6fc726a2c (diff)
downloadhercules-298f02f380d4de88129f0a296456d461cbc6505e.tar.gz
hercules-298f02f380d4de88129f0a296456d461cbc6505e.tar.bz2
hercules-298f02f380d4de88129f0a296456d461cbc6505e.tar.xz
hercules-298f02f380d4de88129f0a296456d461cbc6505e.zip
Fixed Bug #7605
For packetver 2009 and below. http://hercules.ws/board/tracker/issue-7605-problem-with-old-client-versions/ Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r--src/map/clif.c207
-rw-r--r--src/map/clif.h5
-rw-r--r--src/map/packets_struct.h31
3 files changed, 79 insertions, 164 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 3657d0e43..5110ca76b 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -924,7 +924,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target);
if( disguised(bl) ) {
-#if PACKETVER >= 20071106
+#if PACKETVER >= 20091103
p.objecttype = pcdb_checkid(iStatus->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
p.GID = -bl->id;
#else
@@ -934,171 +934,46 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
}
}
-/* todo for packetver 20091103 0x7c non-pc-looking unit handling */
-int clif_spawn_unit2(struct block_list* bl, enum send_target target) {
- return 0;
- /*struct map_session_data* sd;
+#if PACKETVER < 20091103
+/* for 'packetver < 20091103' 0x7c non-pc-looking unit handling */
+void clif_spawn_unit2(struct block_list* bl, enum send_target target) {
+ struct map_session_data* sd;
struct status_change* sc = iStatus->get_sc(bl);
struct view_data* vd = iStatus->get_viewdata(bl);
- unsigned char *buf = WBUFP(buffer,0);
-#if PACKETVER < 20091103
- bool type = !pcdb_checkid(vd->class_);
-#endif
- unsigned short offset = 0;
-#if PACKETVER >= 20091103
- const char *name;
-#endif
+ struct packet_spawn_unit2 p;
+ int g_id = iStatus->get_guild_id(bl);
+
sd = BL_CAST(BL_PC, bl);
-#if PACKETVER < 20091103
- if(type)
- WBUFW(buf,0) = 0x7c;
- else
-#endif
-#if PACKETVER < 4
- WBUFW(buf,0) = 0x79;
-#elif PACKETVER < 7
- WBUFW(buf,0) = 0x1d9;
-#elif PACKETVER < 20080102
- WBUFW(buf,0) = 0x22b;
-#elif PACKETVER < 20091103
- WBUFW(buf,0) = 0x2ed;
-#elif PACKETVER < 20101124
- WBUFW(buf,0) = 0x7f8;
-#else
- WBUFW(buf,0) = 0x858;
-#endif
-
-#if PACKETVER >= 20091103
- name = iStatus->get_name(bl);
-#if PACKETVER < 20110111
- WBUFW(buf,2) = (spawn?62:63)+strlen(name);
-#else
- WBUFW(buf,2) = (spawn?64:65)+strlen(name);
-#endif
- WBUFB(buf,4) = clif_bl_type(bl);
- offset+=3;
- buf = WBUFP(buffer,offset);
-#elif PACKETVER >= 20071106
- if (type) { //Non-player packets
- WBUFB(buf,2) = clif_bl_type(bl);
- offset++;
- buf = WBUFP(buffer,offset);
- }
-#endif
- WBUFL(buf, 2) = bl->id;
- WBUFW(buf, 6) = iStatus->get_speed(bl);
- WBUFW(buf, 8) = (sc)? sc->opt1 : 0;
- WBUFW(buf,10) = (sc)? sc->opt2 : 0;
-#if PACKETVER < 20091103
- if (type&&spawn) { //uses an older and different packet structure
- WBUFW(buf,12) = (sc)? sc->option : 0;
- WBUFW(buf,14) = vd->hair_style;
- WBUFW(buf,16) = vd->weapon;
- WBUFW(buf,18) = vd->head_bottom;
- WBUFW(buf,20) = vd->class_; //Pet armor (ignored by client)
- WBUFW(buf,22) = vd->shield;
- } else {
-#endif
-#if PACKETVER >= 20091103
- WBUFL(buf,12) = (sc)? sc->option : 0;
- offset+=2;
- buf = WBUFP(buffer,offset);
-#elif PACKETVER >= 7
- if (!type) {
- WBUFL(buf,12) = (sc)? sc->option : 0;
- offset+=2;
- buf = WBUFP(buffer,offset);
- } else
- WBUFW(buf,12) = (sc)? sc->option : 0;
-#else
- WBUFW(buf,12) = (sc)? sc->option : 0;
-#endif
- WBUFW(buf,14) = vd->class_;
- WBUFW(buf,16) = vd->hair_style;
- WBUFW(buf,18) = vd->weapon;
-#if PACKETVER < 4
- WBUFW(buf,20) = vd->head_bottom;
- WBUFW(buf,22) = vd->shield;
-#else
- WBUFW(buf,20) = vd->shield;
- WBUFW(buf,22) = vd->head_bottom;
-#endif
-#if PACKETVER < 20091103
- }
-#endif
- WBUFW(buf,24) = vd->head_top;
- WBUFW(buf,26) = vd->head_mid;
-
- if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS )
- { //The hell, why flags work like this?
- WBUFW(buf,22) = iStatus->get_emblem_id(bl);
- WBUFW(buf,24) = GetWord(iStatus->get_guild_id(bl), 1);
- WBUFW(buf,26) = GetWord(iStatus->get_guild_id(bl), 0);
- }
-
- WBUFW(buf,28) = vd->hair_color;
- WBUFW(buf,30) = vd->cloth_color;
- WBUFW(buf,32) = (sd)? sd->head_dir : 0;
-#if PACKETVER < 20091103
- if (type&&spawn) { //End of packet 0x7c
- WBUFB(buf,34) = (sd)?sd->status.karma:0; // karma
- WBUFB(buf,35) = vd->sex;
- WBUFPOS(buf,36,bl->x,bl->y,unit_getdir(bl));
- WBUFB(buf,39) = 0;
- WBUFB(buf,40) = 0;
- return packet_len(0x7c);
+ p.PacketType = spawn_unit2Type;
+ p.objecttype = clif_bl_type(bl);
+ p.GID = bl->id;
+ p.speed = iStatus->get_speed(bl);
+ p.bodyState = (sc) ? sc->opt1 : 0;
+ p.healthState = (sc) ? sc->opt2 : 0;
+ p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0;
+ p.head = vd->hair_style;
+ p.weapon = vd->weapon;
+ p.accessory = vd->head_bottom;
+ p.job = vd->class_;
+ p.shield = vd->shield;
+ p.accessory2 = vd->head_top;
+ p.accessory3 = vd->head_mid;
+ if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this?
+ p.accessory = g_id;
+ p.accessory2 = GetWord(g_id, 1);
+ p.accessory3 = GetWord(g_id, 0);
}
-#endif
-#if PACKETVER >= 20110111
- WBUFW(buf,34) = vd->robe;
- offset+= 2;
- buf = WBUFP(buffer,offset);
-#endif
- WBUFL(buf,34) = iStatus->get_guild_id(bl);
- WBUFW(buf,38) = iStatus->get_emblem_id(bl);
- WBUFW(buf,40) = (sd)? sd->status.manner : 0;
-#if PACKETVER >= 20091103
- WBUFL(buf,42) = (sc)? sc->opt3 : 0;
- offset+=2;
- buf = WBUFP(buffer,offset);
-#elif PACKETVER >= 7
- if (!type) {
- WBUFL(buf,42) = (sc)? sc->opt3 : 0;
- offset+=2;
- buf = WBUFP(buffer,offset);
- } else
- WBUFW(buf,42) = (sc)? sc->opt3 : 0;
-#else
- WBUFW(buf,42) = (sc)? sc->opt3 : 0;
-#endif
- WBUFB(buf,44) = (sd)? sd->status.karma : 0;
- WBUFB(buf,45) = vd->sex;
- WBUFPOS(buf,46,bl->x,bl->y,unit_getdir(bl));
- WBUFB(buf,49) = (sd)? 5 : 0;
- WBUFB(buf,50) = (sd)? 5 : 0;
- if (!spawn) {
- WBUFB(buf,51) = vd->dead_sit;
- offset++;
- buf = WBUFP(buffer,offset);
- }
- WBUFW(buf,51) = clif_setlevel(bl);
-#if PACKETVER < 20091103
- if (type) //End for non-player packet
- return packet_len(WBUFW(buffer,0));
-#endif
-#if PACKETVER >= 20080102
- WBUFW(buf,53) = sd?sd->user_font:0;
-#endif
-#if PACKETVER >= 20091103
- memcpy((char*)WBUFP(buf,55), name, NAME_LENGTH);
- return WBUFW(buffer,2);
-#else
- return packet_len(WBUFW(buffer,0));
-#endif
- */
+ p.headpalette = vd->hair_color;
+ p.bodypalette = vd->cloth_color;
+ p.headDir = (sd)? sd->head_dir : 0;
+ p.isPKModeON = (sd) ? sd->status.karma : 0;
+ p.sex = vd->sex;
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ p.xSize = p.ySize = (sd) ? 5 : 0;
+ p.clevel = clif_setlevel(bl);
}
-
+#endif
void clif_spawn_unit(struct block_list* bl, enum send_target target) {
struct map_session_data* sd;
struct status_change* sc = iStatus->get_sc(bl);
@@ -1106,6 +981,11 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
struct packet_spawn_unit p;
int g_id = iStatus->get_guild_id(bl);
+#if PACKETVER < 20091103
+ if( !pcdb_checkid(vd->class_) )
+ return clif->spawn_unit2(bl,target);
+#endif
+
sd = BL_CAST(BL_PC, bl);
p.PacketType = spawn_unitType;
@@ -1164,7 +1044,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
if( disguised(bl) ) {
if( sd->status.class_ != sd->disguise )
clif->send(&p,sizeof(p),bl,target);
-#if PACKETVER >= 20071106
+#if PACKETVER >= 20091103
p.objecttype = pcdb_checkid(iStatus->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
p.GID = -bl->id;
#else
@@ -1241,7 +1121,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target);
if( disguised(bl) ) {
-#if PACKETVER >= 20071106
+#if PACKETVER >= 20091103
p.objecttype = pcdb_checkid(iStatus->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
p.GID = -bl->id;
#else
@@ -17957,6 +17837,9 @@ void clif_defaults(void) {
clif->clearunit_delayed_sub = clif_clearunit_delayed_sub;
clif->set_unit_idle = clif_set_unit_idle;
clif->spawn_unit = clif_spawn_unit;
+#if PACKETVER < 20091103
+ clif->spawn_unit2 = clif_spawn_unit2;
+#endif
clif->set_unit_walking = clif_set_unit_walking;
clif->calc_walkdelay = clif_calc_walkdelay;
clif->getareachar_skillunit = clif_getareachar_skillunit;
diff --git a/src/map/clif.h b/src/map/clif.h
index f931e41e7..9bb5f25e7 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -523,7 +523,10 @@ struct clif_interface {
void (*skillunit_update) (struct block_list* bl);
int (*clearunit_delayed_sub) (int tid, unsigned int tick, int id, intptr_t data);
void (*set_unit_idle) (struct block_list* bl, struct map_session_data *tsd,enum send_target target);
- void (*spawn_unit) (struct block_list* bl,enum send_target target);
+ void (*spawn_unit) (struct block_list* bl, enum send_target target);
+#if PACKETVER < 20091103
+ void (*spawn_unit2) (struct block_list* bl, enum send_target target);
+#endif
void (*set_unit_walking) (struct block_list* bl, struct map_session_data *tsd,struct unit_data* ud, enum send_target target);
int (*calc_walkdelay) (struct block_list *bl,int delay, int type, int damage, int div_);
void (*getareachar_skillunit) (struct map_session_data *sd, struct skill_unit *unit);
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index d56e9ce01..b514ab8df 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -53,6 +53,9 @@ enum packet_headers {
#endif
status_change2Type = 0x43f,
status_change_endType = 0x196,
+#if PACKETVER < 20091103
+ spawn_unit2Type = 0x7c,
+#endif
#if PACKETVER < 4
spawn_unitType = 0x79,
#elif PACKETVER < 7
@@ -173,7 +176,33 @@ struct packet_dropflooritem {
unsigned char subY;
short count;
} __attribute__((packed));
-
+#if PACKETVER < 20091103
+struct packet_spawn_unit2 {
+ short PacketType;
+ unsigned char objecttype;
+ unsigned int GID;
+ short speed;
+ short bodyState;
+ short healthState;
+ short effectState;
+ short head;
+ short weapon;
+ short accessory;
+ short job;
+ short shield;
+ short accessory2;
+ short accessory3;
+ short headpalette;
+ short bodypalette;
+ short headDir;
+ bool isPKModeON;
+ unsigned char sex;
+ unsigned char PosDir[3];
+ unsigned char xSize;
+ unsigned char ySize;
+ short clevel;
+} __attribute__((packed));
+#endif
struct packet_spawn_unit {
short PacketType;
#if PACKETVER >= 20091103