From 441470decb97f738ea4c854cbf5138e8eeac2bb4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 9 May 2019 02:34:00 +0300 Subject: Update packet ZC_SHORTCUT_KEY_LIST --- src/common/mmo.h | 29 +++++++++++++++----------- src/map/clif.c | 44 +++++++++++++++++++++++++++++----------- src/map/clif.h | 3 ++- src/map/packets_struct.h | 53 +++++++++++++++++++++++++++++++++++------------- 4 files changed, 90 insertions(+), 39 deletions(-) diff --git a/src/common/mmo.h b/src/common/mmo.h index c62fd31d0..3af414fdb 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -134,22 +134,27 @@ // Comment the following line to disable sc_data saving. [Skotlex] #define ENABLE_SC_SAVING -#if PACKETVER >= 20070227 +#if PACKETVER_MAIN_NUM >= 20070711 || PACKETVER_RE_NUM >= 20080827 || PACKETVER_AD_NUM >= 20070711 || PACKETVER_SAK_NUM >= 20070628 || defined(PACKETVER_ZERO) // 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 -#if PACKETVER < 20090603 - // (27 = 9 skills x 3 bars) (0x02b9,191) - #define MAX_HOTKEYS 27 -#elif PACKETVER < 20090617 - // (36 = 9 skills x 4 bars) (0x07d9,254) - #define MAX_HOTKEYS 36 -#else // >= 20090617 - // (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268) - #define MAX_HOTKEYS 38 -#endif // 20090603 -#endif // 20070227 +#if PACKETVER_RE_NUM >= 20190508 +#define MAX_HOTKEYS 38 +#elif PACKETVER_MAIN_NUM >= 20141022 || PACKETVER_RE_NUM >= 20141015 || defined(PACKETVER_ZERO) +// (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268) +#define MAX_HOTKEYS 38 +#elif PACKETVER_MAIN_NUM >= 20090617 || PACKETVER_RE_NUM >= 20090617 || PACKETVER_SAK_NUM >= 20090617 +// (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268) +#define MAX_HOTKEYS 38 +#elif PACKETVER_MAIN_NUM >= 20090603 || PACKETVER_RE_NUM >= 20090603 || PACKETVER_SAK_NUM >= 20090603 +// (36 = 9 skills x 4 bars) (0x07d9,254) +#define MAX_HOTKEYS 36 +#elif PACKETVER_MAIN_NUM >= 20070711 || PACKETVER_RE_NUM >= 20080827 || PACKETVER_AD_NUM >= 20070711 || PACKETVER_SAK_NUM >= 20070628 +// (27 = 9 skills x 3 bars) (0x02b9,191) +#define MAX_HOTKEYS 27 +#endif +#endif // PACKETVER_MAIN_NUM >= 20070711 || PACKETVER_RE_NUM >= 20080827 || PACKETVER_AD_NUM >= 20070711 || PACKETVER_SAK_NUM >= 20070628 || defined(PACKETVER_ZERO) #if PACKETVER_RE_NUM >= 20190508 #define MAX_HOTKEYS_DB ((MAX_HOTKEYS) * 2) diff --git a/src/map/clif.c b/src/map/clif.c index b93274d3d..b04637ebc 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10608,7 +10608,7 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) first_time = true; sd->state.connect_new = 0; clif->skillinfoblock(sd); - clif->hotkeys(sd); + clif->hotkeysAll(sd); clif->updatestatus(sd,SP_BASEEXP); clif->updatestatus(sd,SP_NEXTBASEEXP); clif->updatestatus(sd,SP_JOBEXP); @@ -10821,27 +10821,46 @@ static void clif_parse_TickSend(int fd, struct map_session_data *sd) clif->notify_time(sd, timer->gettick()); } +static void clif_hotkeysAll_send(struct map_session_data *sd) +{ +#ifdef HOTKEY_SAVING + clif->hotkeys(sd, 0); +#if PACKETVER_RE_NUM >= 20190508 + // send second tab only if data exists + for (int i = MAX_HOTKEYS; i < MAX_HOTKEYS * 2; i++) { + if (sd->status.hotkeys[i].type != 0 || sd->status.hotkeys[i].id != 0 || sd->status.hotkeys[i].lv != 0) { + clif->hotkeys(sd, 1); + return; + } + } +#endif +#endif +} + /// Sends hotkey bar. /// 02b9 { .B .L .W }*27 (ZC_SHORTCUT_KEY_LIST) /// 07d9 { .B .L .W }*36 (ZC_SHORTCUT_KEY_LIST_V2, PACKETVER >= 20090603) /// 07d9 { .B .L .W }*38 (ZC_SHORTCUT_KEY_LIST_V2, PACKETVER >= 20090617) /// 0a00 .B { .B .L .W }*38 (ZC_SHORTCUT_KEY_LIST_V3, PACKETVER >= 20141022) -static void clif_hotkeys_send(struct map_session_data *sd) +static void clif_hotkeys_send(struct map_session_data *sd, int tab) { #ifdef HOTKEY_SAVING - struct packet_hotkey p; - int i; nullpo_retv(sd); - p.PacketType = hotkeyType; -#if PACKETVER >= 20141022 - p.Rotate = sd->status.hotkey_rowshift; + struct PACKET_ZC_SHORTCUT_KEY_LIST p; + p.packetType = HEADER_ZC_SHORTCUT_KEY_LIST; +#if PACKETVER_MAIN_NUM >= 20141022 || PACKETVER_RE_NUM >= 20141015 || defined(PACKETVER_ZERO) + p.rotate = sd->status.hotkey_rowshift; +#endif +#if PACKETVER_RE_NUM >= 20190508 + p.tab = tab; #endif - for(i = 0; i < ARRAYLENGTH(p.hotkey); i++) { - p.hotkey[i].isSkill = sd->status.hotkeys[i].type; - p.hotkey[i].ID = sd->status.hotkeys[i].id; - p.hotkey[i].count = sd->status.hotkeys[i].lv; + const int offset = tab * MAX_HOTKEYS; + for (int i = 0; i < MAX_HOTKEYS_PACKET; i++) { + p.hotkey[i].isSkill = sd->status.hotkeys[i + offset].type; + p.hotkey[i].id = sd->status.hotkeys[i + offset].id; + p.hotkey[i].count = sd->status.hotkeys[i + offset].lv; } - clif->send(&p, sizeof(p), &sd->bl, SELF); + clif->send(&p, sizeof(struct PACKET_ZC_SHORTCUT_KEY_LIST), &sd->bl, SELF); #endif } @@ -23070,6 +23089,7 @@ void clif_defaults(void) clif->pRanklist = clif_parse_ranklist; clif->update_rankingpoint = clif_update_rankingpoint; clif->hotkeys = clif_hotkeys_send; + clif->hotkeysAll = clif_hotkeysAll_send; clif->insight = clif_insight; clif->outsight = clif_outsight; clif->skillcastcancel = clif_skillcastcancel; diff --git a/src/map/clif.h b/src/map/clif.h index 19c321ed3..1e49e50a2 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -851,7 +851,8 @@ struct clif_interface { void (*ranklist) (struct map_session_data *sd, enum fame_list_type type); void (*update_rankingpoint) (struct map_session_data *sd, enum fame_list_type type, int points); void (*pRanklist) (int fd, struct map_session_data *sd); - void (*hotkeys) (struct map_session_data *sd); + void (*hotkeys) (struct map_session_data *sd, int tab); + void (*hotkeysAll) (struct map_session_data *sd); int (*insight) (struct block_list *bl,va_list ap); int (*outsight) (struct block_list *bl,va_list ap); void (*skillcastcancel) (struct block_list* bl); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index d90d6dc97..4e3d7de84 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -39,13 +39,6 @@ enum packet_headers { banking_checkType = 0x9a6, cart_additem_ackType = 0x12c, sc_notickType = 0x196, -#if PACKETVER >= 20141022 - hotkeyType = 0xa00, -#elif PACKETVER >= 20090603 - hotkeyType = 0x7d9, -#else - hotkeyType = 0x2b9, -#endif #if PACKETVER >= 20150226 cartaddType = 0xa0b, #elif PACKETVER >= 5 @@ -1426,17 +1419,49 @@ struct packet_party_leader_changed { #ifdef HOTKEY_SAVING struct hotkey_data { int8 isSkill; // 0: Item, 1:Skill - uint32 ID; // Item/Skill ID + uint32 id; // Item/Skill ID int16 count; // Item Quantity/Skill Level } __attribute__((packed)); -struct packet_hotkey { - int16 PacketType; -#if PACKETVER >= 20141022 - int8 Rotate; -#endif - struct hotkey_data hotkey[MAX_HOTKEYS]; +#if PACKETVER_RE_NUM >= 20190508 +#define MAX_HOTKEYS_PACKET 38 +struct PACKET_ZC_SHORTCUT_KEY_LIST { + int16 packetType; + int8 rotate; + int16 tab; + struct hotkey_data hotkey[MAX_HOTKEYS_PACKET]; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_SHORTCUT_KEY_LIST, 0x0b20); +#elif PACKETVER_MAIN_NUM >= 20141022 || PACKETVER_RE_NUM >= 20141015 || defined(PACKETVER_ZERO) +#define MAX_HOTKEYS_PACKET 38 +struct PACKET_ZC_SHORTCUT_KEY_LIST { + int16 packetType; + int8 rotate; + struct hotkey_data hotkey[MAX_HOTKEYS_PACKET]; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_SHORTCUT_KEY_LIST, 0x0a00); +#elif PACKETVER_MAIN_NUM >= 20090617 || PACKETVER_RE_NUM >= 20090617 || PACKETVER_SAK_NUM >= 20090617 +#define MAX_HOTKEYS_PACKET 38 +struct PACKET_ZC_SHORTCUT_KEY_LIST { + int16 packetType; + struct hotkey_data hotkey[MAX_HOTKEYS_PACKET]; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_SHORTCUT_KEY_LIST, 0x07d9); +#elif PACKETVER_MAIN_NUM >= 20090603 || PACKETVER_RE_NUM >= 20090603 || PACKETVER_SAK_NUM >= 20090603 +#define MAX_HOTKEYS_PACKET 36 +struct PACKET_ZC_SHORTCUT_KEY_LIST { + int16 packetType; + struct hotkey_data hotkey[MAX_HOTKEYS_PACKET]; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_SHORTCUT_KEY_LIST, 0x07d9); +#elif PACKETVER_MAIN_NUM >= 20070711 || PACKETVER_RE_NUM >= 20080827 || PACKETVER_AD_NUM >= 20070711 || PACKETVER_SAK_NUM >= 20070628 +#define MAX_HOTKEYS_PACKET 27 +struct PACKET_ZC_SHORTCUT_KEY_LIST { + int16 packetType; + struct hotkey_data hotkey[MAX_HOTKEYS_PACKET]; } __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_SHORTCUT_KEY_LIST, 0x02b9); +#endif #endif // HOTKEY_SAVING /** -- cgit v1.2.3-60-g2f50