summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c67
-rw-r--r--src/map/packets_struct.h21
2 files changed, 54 insertions, 34 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 985e0229f..5f3d5afd0 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7503,44 +7503,43 @@ static void clif_pet_food(struct map_session_data *sd, int foodid, int fail)
/// 01cd { <skill id>.L }*7
static void clif_autospell(struct map_session_data *sd, uint16 skill_lv)
{
- int fd;
-
nullpo_retv(sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len(0x1cd));
- WFIFOW(fd, 0)=0x1cd;
+ int fd = sd->fd;
+#if PACKETVER_RE_NUM >= 20181031
+ // reserve space for 7 skills
+ WFIFOHEAD(fd, sizeof(struct PACKET_ZC_AUTOSPELLLIST) + 4 * 7);
+#else
+ WFIFOHEAD(fd, sizeof(struct PACKET_ZC_AUTOSPELLLIST));
+#endif
+ struct PACKET_ZC_AUTOSPELLLIST *p = WFIFOP(fd, 0);
+ memset(p, 0, sizeof(struct PACKET_ZC_AUTOSPELLLIST));
+ p->packetType = autoSpellList;
+ int index = 0;
- if(skill_lv>0 && pc->checkskill(sd,MG_NAPALMBEAT)>0)
- WFIFOL(fd,2)= MG_NAPALMBEAT;
- else
- WFIFOL(fd,2)= 0x00000000;
- if(skill_lv>1 && pc->checkskill(sd,MG_COLDBOLT)>0)
- WFIFOL(fd,6)= MG_COLDBOLT;
- else
- WFIFOL(fd,6)= 0x00000000;
- if(skill_lv>1 && pc->checkskill(sd,MG_FIREBOLT)>0)
- WFIFOL(fd,10)= MG_FIREBOLT;
- else
- WFIFOL(fd,10)= 0x00000000;
- if(skill_lv>1 && pc->checkskill(sd,MG_LIGHTNINGBOLT)>0)
- WFIFOL(fd,14)= MG_LIGHTNINGBOLT;
- else
- WFIFOL(fd,14)= 0x00000000;
- if(skill_lv>4 && pc->checkskill(sd,MG_SOULSTRIKE)>0)
- WFIFOL(fd,18)= MG_SOULSTRIKE;
- else
- WFIFOL(fd,18)= 0x00000000;
- if(skill_lv>7 && pc->checkskill(sd,MG_FIREBALL)>0)
- WFIFOL(fd,22)= MG_FIREBALL;
- else
- WFIFOL(fd,22)= 0x00000000;
- if(skill_lv>9 && pc->checkskill(sd,MG_FROSTDIVER)>0)
- WFIFOL(fd,26)= MG_FROSTDIVER;
- else
- WFIFOL(fd,26)= 0x00000000;
+ if (skill_lv > 0 && pc->checkskill(sd, MG_NAPALMBEAT) > 0)
+ p->skills[index++] = MG_NAPALMBEAT;
+ if (skill_lv > 1 && pc->checkskill(sd, MG_COLDBOLT) > 0)
+ p->skills[index++] = MG_COLDBOLT;
+ if (skill_lv > 1 && pc->checkskill(sd, MG_FIREBOLT) > 0)
+ p->skills[index++] = MG_FIREBOLT;
+ if (skill_lv > 1 && pc->checkskill(sd, MG_LIGHTNINGBOLT) > 0)
+ p->skills[index++] = MG_LIGHTNINGBOLT;
+ if (skill_lv > 4 && pc->checkskill(sd, MG_SOULSTRIKE) > 0)
+ p->skills[index++] = MG_SOULSTRIKE;
+ if (skill_lv > 7 && pc->checkskill(sd, MG_FIREBALL) > 0)
+ p->skills[index++] = MG_FIREBALL;
+ if (skill_lv > 9 && pc->checkskill(sd, MG_FROSTDIVER) > 0)
+ p->skills[index++] = MG_FROSTDIVER;
+
+#if PACKETVER_RE_NUM >= 20181031
+ const int len = sizeof(struct PACKET_ZC_AUTOSPELLLIST) + index * 4;
+ p->packetLength = len;
+#else
+ const int len = sizeof(struct PACKET_ZC_AUTOSPELLLIST);
+#endif
+ WFIFOSET(fd, len);
- WFIFOSET(fd,packet_len(0x1cd));
sd->menuskill_id = SA_AUTOSPELL;
sd->menuskill_val = skill_lv;
}
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index c2363ce08..374769728 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -456,6 +456,11 @@ enum packet_headers {
#else
itemPreview = 0xab9,
#endif
+#if PACKETVER_RE_NUM >= 20181031
+ autoSpellList = 0xafb,
+#else
+ autoSpellList = 0x1cd,
+#endif
};
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
@@ -2890,6 +2895,22 @@ struct PACKET_ZC_ITEM_PREVIEW {
struct ItemOptions option_data[MAX_ITEM_OPTIONS];
} __attribute__((packed));
+#if PACKETVER_RE_NUM >= 20181031
+#define PACKET_ZC_AUTOSPELLLIST PACKET_ZC_AUTOSPELLLIST2
+#else
+#define PACKET_ZC_AUTOSPELLLIST PACKET_ZC_AUTOSPELLLIST1
+#endif
+
+struct PACKET_ZC_AUTOSPELLLIST1 {
+ int16 packetType;
+ int skills[7];
+} __attribute__((packed));
+
+struct PACKET_ZC_AUTOSPELLLIST2 {
+ int16 packetType;
+ int16 packetLength;
+ int skills[];
+} __attribute__((packed));
#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)