summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2019-07-17 02:42:49 +0300
committerAndrei Karas <akaras@inbox.ru>2019-07-24 23:54:31 +0300
commit99f1db754f40e42af9402157acc9f1d0cbbaa64e (patch)
tree110d3fbdf91c3d37a9ae69e73d68eb2e7da72739
parentcdd5789d8fff14572df1e6d801ba9e2afa7b505e (diff)
downloadhercules-99f1db754f40e42af9402157acc9f1d0cbbaa64e.tar.gz
hercules-99f1db754f40e42af9402157acc9f1d0cbbaa64e.tar.bz2
hercules-99f1db754f40e42af9402157acc9f1d0cbbaa64e.tar.xz
hercules-99f1db754f40e42af9402157acc9f1d0cbbaa64e.zip
Convert packet ZC_HAT_EFFECT into struct and fix allowed packet versions
-rw-r--r--src/map/clif.c54
-rw-r--r--src/map/packets_struct.h11
2 files changed, 35 insertions, 30 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 310bbebff..6656d12f6 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -21983,53 +21983,47 @@ static void clif_skill_scale(struct block_list *bl, int src_id, int x, int y, ui
/// 0A3B <Length>.W <AID>.L <Status>.B { <HatEffectId>.W }
static void clif_hat_effect(struct block_list *bl, struct block_list *tbl, enum send_target target)
{
-#if PACKETVER >= 20150422
- unsigned char *buf;
- int len, i;
- struct map_session_data *sd;
-
+#if PACKETVER_MAIN_NUM >= 20150507 || PACKETVER_RE_NUM >= 20150429 || defined(PACKETVER_ZERO)
nullpo_retv(bl);
-
- sd = BL_CAST(BL_PC, bl);
-
+ struct map_session_data *sd = BL_CAST(BL_PC, bl);
nullpo_retv(sd);
- len = 9 + VECTOR_LENGTH(sd->hatEffectId) * 2;
+ const int len = sizeof(struct PACKET_ZC_HAT_EFFECT) + VECTOR_LENGTH(sd->hatEffectId) * 2;
+ struct PACKET_ZC_HAT_EFFECT *p = aMalloc(len);
- buf = (unsigned char*)aMalloc(len);
-
- WBUFW(buf, 0) = 0xa3b;
- WBUFW(buf, 2) = len;
- WBUFL(buf, 4) = bl->id;
- WBUFB(buf, 8) = 1;
+ p->packetType = HEADER_ZC_HAT_EFFECT;
+ p->packetLength = len;
+ p->aid = bl->id;
+ p->status = 1;
- for( i = 0; i < VECTOR_LENGTH(sd->hatEffectId); i++ ){
- WBUFW(buf, 9 + i * 2) = VECTOR_INDEX(sd->hatEffectId, i);
+ for (int i = 0; i < VECTOR_LENGTH(sd->hatEffectId); i++) {
+ p->effects[i] = VECTOR_INDEX(sd->hatEffectId, i);
}
if (tbl != NULL) {
- clif->send(buf, len, tbl, target);
+ clif->send(p, len, tbl, target);
} else {
- clif->send(buf, len, bl, target);
+ clif->send(p, len, bl, target);
}
-
- aFree(buf);
+ aFree(p);
#endif
}
static void clif_hat_effect_single(struct block_list *bl, uint16 effectId, bool enable){
-#if PACKETVER >= 20150422
- unsigned char buf[13];
-
+#if PACKETVER_MAIN_NUM >= 20150507 || PACKETVER_RE_NUM >= 20150429 || defined(PACKETVER_ZERO)
nullpo_retv(bl);
- WBUFW(buf,0) = 0xa3b;
- WBUFW(buf,2) = 13;
- WBUFL(buf,4) = bl->id;
- WBUFB(buf,8) = enable;
- WBUFL(buf,9) = effectId;
+ const int len = sizeof(struct PACKET_ZC_HAT_EFFECT) + 2;
+ struct PACKET_ZC_HAT_EFFECT *p = aMalloc(len);
+
+ p->packetType = HEADER_ZC_HAT_EFFECT;
+ p->packetLength = len;
+ p->aid = bl->id;
+ p->status = enable;
+ p->effects[0] = effectId;
- clif->send(buf, 13, bl, AREA);
+ clif->send(p, len, bl, AREA);
+ aFree(p);
#endif
}
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index aeb57bdc4..f41008889 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -3522,6 +3522,17 @@ struct PACKET_ZC_STATUS_CHANGE_ACK {
} __attribute__((packed));
DEFINE_PACKET_HEADER(ZC_STATUS_CHANGE_ACK, 0x00bc);
+#if PACKETVER_MAIN_NUM >= 20150507 || PACKETVER_RE_NUM >= 20150429 || defined(PACKETVER_ZERO)
+struct PACKET_ZC_HAT_EFFECT {
+ int16 packetType;
+ int16 packetLength;
+ uint32 aid;
+ int8 status;
+ uint16 effects[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(ZC_HAT_EFFECT, 0x0a3b);
+#endif
+
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(pop)
#endif // not NetBSD < 6 / Solaris