Skip to content

Commit ed7ca89

Browse files
committed
Update packet ZC_USESKILL_ACK
1 parent 97da757 commit ed7ca89

File tree

2 files changed

+61
-21
lines changed

2 files changed

+61
-21
lines changed

src/map/clif.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5417,32 +5417,31 @@ static void clif_skillinfo(struct map_session_data *sd, int skill_id, int inf)
54175417
/// 1 = no text
54185418
static void clif_useskill(struct block_list *bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, uint16 skill_lv, int casttime)
54195419
{
5420-
#if PACKETVER < 20091124
5421-
const int cmd = 0x13e;
5422-
#else
5423-
const int cmd = 0x7fb;
5424-
#endif
5425-
unsigned char buf[32];
5426-
int property = skill->get_ele(skill_id, skill_lv);
5420+
nullpo_retv(bl);
54275421

5428-
WBUFW(buf,0) = cmd;
5429-
WBUFL(buf,2) = src_id;
5430-
WBUFL(buf,6) = dst_id;
5431-
WBUFW(buf,10) = dst_x;
5432-
WBUFW(buf,12) = dst_y;
5433-
WBUFW(buf,14) = skill_id;
5434-
WBUFL(buf,16) = property<0?0:property; //Avoid sending negatives as element [Skotlex]
5435-
WBUFL(buf,20) = casttime;
5436-
#if PACKETVER >= 20091124
5437-
WBUFB(buf,24) = 0; // isDisposable
5422+
const int element = skill->get_ele(skill_id, skill_lv);
5423+
struct PACKET_ZC_USESKILL_ACK p;
5424+
p.packetType = HEADER_ZC_USESKILL_ACK;
5425+
p.srcId = src_id;
5426+
p.dstId = dst_id;
5427+
p.x = dst_x;
5428+
p.y = dst_y;
5429+
p.skillId = skill_id;
5430+
p.element = element < 0 ? 0 : element; //Avoid sending negatives as element [Skotlex]
5431+
p.delayTime = casttime;
5432+
#if PACKETVER_MAIN_NUM >= 20091124 || PACKETVER_RE_NUM >= 20091124 || defined(PACKETVER_ZERO)
5433+
p.disposable = 0;
5434+
#endif
5435+
#if PACKETVER_ZERO_NUM >= 20190130
5436+
p.unknown = 0;
54385437
#endif
54395438

54405439
if (clif->isdisguised(bl)) {
5441-
clif->send(buf,packet_len(cmd), bl, AREA_WOS);
5442-
WBUFL(buf,2) = -src_id;
5443-
clif->send(buf,packet_len(cmd), bl, SELF);
5440+
clif->send(&p, sizeof(p), bl, AREA_WOS);
5441+
p.srcId = -src_id;
5442+
clif->send(&p, sizeof(p), bl, SELF);
54445443
} else {
5445-
clif->send(buf,packet_len(cmd), bl, AREA);
5444+
clif->send(&p, sizeof(p), bl, AREA);
54465445
}
54475446
#if PACKETVER >= 20151223
54485447
if ((skill->get_inf2(skill_id) & INF2_SHOW_SKILL_SCALE) != 0)

src/map/packets_struct.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,6 +3111,47 @@ struct PACKET_CZ_NPC_BARTER_PURCHASE {
31113111
DEFINE_PACKET_HEADER(CZ_NPC_BARTER_PURCHASE, 0x0b0f);
31123112
#endif
31133113

3114+
#if PACKETVER_ZERO_NUM >= 20190130
3115+
struct PACKET_ZC_USESKILL_ACK {
3116+
int16 packetType;
3117+
uint32 srcId;
3118+
uint32 dstId;
3119+
uint16 x;
3120+
uint16 y;
3121+
uint16 skillId;
3122+
uint32 element;
3123+
uint32 delayTime;
3124+
uint8 disposable;
3125+
uint32 unknown;
3126+
} __attribute__((packed));
3127+
DEFINE_PACKET_HEADER(ZC_USESKILL_ACK, 0x0b1a);
3128+
#elif PACKETVER_MAIN_NUM >= 20091124 || PACKETVER_RE_NUM >= 20091124 || defined(PACKETVER_ZERO)
3129+
struct PACKET_ZC_USESKILL_ACK {
3130+
int16 packetType;
3131+
uint32 srcId;
3132+
uint32 dstId;
3133+
uint16 x;
3134+
uint16 y;
3135+
uint16 skillId;
3136+
uint32 element;
3137+
uint32 delayTime;
3138+
uint8 disposable;
3139+
} __attribute__((packed));
3140+
DEFINE_PACKET_HEADER(ZC_USESKILL_ACK, 0x07fb);
3141+
#elif PACKETVER_MAIN_NUM >= 20090406 || PACKETVER_SAK_NUM >= 20080618 || PACKETVER_RE_NUM >= 20080827 || defined(PACKETVER_ZERO)
3142+
struct PACKET_ZC_USESKILL_ACK {
3143+
int16 packetType;
3144+
uint32 srcId;
3145+
uint32 dstId;
3146+
uint16 x;
3147+
uint16 y;
3148+
uint16 skillId;
3149+
uint32 element;
3150+
uint32 delayTime;
3151+
} __attribute__((packed));
3152+
DEFINE_PACKET_HEADER(ZC_USESKILL_ACK, 0x013e);
3153+
#endif
3154+
31143155
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
31153156
#pragma pack(pop)
31163157
#endif // not NetBSD < 6 / Solaris

0 commit comments

Comments
 (0)