diff options
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 119 |
1 files changed, 77 insertions, 42 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 1e9844f14..44cefcd7e 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; } @@ -8872,7 +8871,7 @@ static void clif_specialeffect_value(struct block_list *bl, int effect_id, int n /// @see doc/effect_list.txt static void clif_removeSpecialEffect(struct block_list *bl, int effectId, enum send_target target) { -#if PACKETVER_MAIN_NUM >= 20181002 || PACKETVER_RE_NUM >= 20181002 +#if PACKETVER_MAIN_NUM >= 20181002 || PACKETVER_RE_NUM >= 20181002 || PACKETVER_ZERO_NUM >= 20181010 nullpo_retv(bl); struct PACKET_ZC_REMOVE_EFFECT p; @@ -8891,7 +8890,7 @@ static void clif_removeSpecialEffect(struct block_list *bl, int effectId, enum s static void clif_removeSpecialEffect_single(struct block_list *bl, int effectId, struct block_list *targetBl) { -#if PACKETVER_MAIN_NUM >= 20181002 || PACKETVER_RE_NUM >= 20181002 +#if PACKETVER_MAIN_NUM >= 20181002 || PACKETVER_RE_NUM >= 20181002 || PACKETVER_ZERO_NUM >= 20181010 nullpo_retv(bl); nullpo_retv(targetBl); @@ -9672,7 +9671,9 @@ static void clif_msgtable_str_color(struct map_session_data *sd, enum clif_messa p->PacketType = 0xa6f; p->PacketLength = len; p->messageId = msg_id; +#if PACKETVER >= 20160406 p->color = color; +#endif safestrncpy(p->messageString, value, message_len); p->messageString[message_len] = 0; @@ -12342,7 +12343,7 @@ static void clif_parse_NpcSelectMenu(int fd, struct map_session_data *sd) int npc_id = RFIFOL(fd,2); uint8 select = RFIFOB(fd,6); - if( (select > sd->npc_menu && select != 0xff) || select == 0 ) { + if( (select > sd->npc_menu && select != MAX_MENU_OPTIONS) || select == 0 ) { #ifdef SECURE_NPCTIMEOUT if( sd->npc_idle_timer != INVALID_TIMER ) { #endif @@ -16872,7 +16873,11 @@ static void clif_quest_send_list(struct map_session_data *sd) real_len += sizeof(info->objectives[j]); mob_data = mob->db(qi->objectives[j].mob); -#if PACKETVER >= 20150513 +#if PACKETVER_ZERO_NUM >= 20181010 || PACKETVER >= 20181017 + info->objectives[j].huntIdent = sd->quest_log[i].quest_id; + info->objectives[j].huntIdent2 = j; + info->objectives[j].mobType = 0; // Info Needed +#elif PACKETVER >= 20150513 info->objectives[j].huntIdent = (sd->quest_log[i].quest_id * 1000) + j; info->objectives[j].mobType = 0; // Info Needed #endif @@ -16961,7 +16966,11 @@ static void clif_quest_add(struct map_session_data *sd, struct quest *qd) monster = mob->db(qi->objectives[i].mob); -#if PACKETVER >= 20150513 +#if PACKETVER_ZERO_NUM >= 20181010 || PACKETVER >= 20181017 + packet->objectives[i].huntIdent = qd->quest_id; + packet->objectives[i].huntIdent2 = i; + packet->objectives[i].mobType = 0; // Info Needed +#elif PACKETVER >= 20150513 packet->objectives[i].huntIdent = (qd->quest_id * 1000) + i; packet->objectives[i].mobType = 0; // Info Needed #endif @@ -17022,7 +17031,10 @@ static void clif_quest_update_objective(struct map_session_data *sd, struct ques real_len += sizeof(packet->objectives[i]); packet->objectives[i].questID = qd->quest_id; -#if PACKETVER >= 20150513 +#if PACKETVER_ZERO_NUM >= 20181010 || PACKETVER >= 20181017 + packet->objectives[i].huntIdent = qd->quest_id; + packet->objectives[i].huntIdent2 = i; +#elif PACKETVER >= 20150513 packet->objectives[i].huntIdent = (qd->quest_id * 1000) + i; #else packet->objectives[i].mob_id = qi->objectives[i].mob; @@ -18889,9 +18901,9 @@ static void clif_parse_dull(int fd, struct map_session_data *sd) packet_len = RFIFOW(fd, 2); } if (sd) { - ShowWarning("Unhandled packet 0x%04d (length %d), %s session #%d, %d/%d (AID/CID)\n", cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id); + ShowWarning("Unhandled packet 0x%04X (length %d), %s session #%d, %d/%d (AID/CID)\n", (uint32)cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id); } else { - ShowWarning("Unhandled packet 0x%04d (length %d), session #%d\n", cmd, packet_len, fd); + ShowWarning("Unhandled packet 0x%04X (length %d), session #%d\n", (uint32)cmd, packet_len, fd); } return; } @@ -21925,6 +21937,7 @@ static void clif_parse_memorial_dungeon_command(int fd, struct map_session_data static void clif_camera_showWindow(struct map_session_data *sd) { #if PACKETVER >= 20160525 + nullpo_retv(sd); struct PACKET_ZC_CAMERA_INFO p; p.packetType = 0xa78; p.action = 1; @@ -21938,6 +21951,7 @@ static void clif_camera_showWindow(struct map_session_data *sd) static void clif_camera_change(struct map_session_data *sd, float range, float rotation, float latitude, enum send_target target) { #if PACKETVER >= 20160525 + nullpo_retv(sd); struct PACKET_ZC_CAMERA_INFO p; p.packetType = 0xa78; p.action = 0; @@ -21948,6 +21962,26 @@ static void clif_camera_change(struct map_session_data *sd, float range, float r #endif } +// show item preview in already opened preview window +static void clif_item_preview(struct map_session_data *sd, int n) +{ +#if PACKETVER_MAIN_NUM >= 20170726 || PACKETVER_RE_NUM >= 20170621 || defined(PACKETVER_ZERO) + nullpo_retv(sd); + Assert_retv(n >= 0 && n < MAX_INVENTORY); + + struct PACKET_ZC_ITEM_PREVIEW p; + p.packetType = itemPreview; + p.index = n + 2; +#if PACKETVER_MAIN_NUM >= 20181017 || PACKETVER_RE_NUM >= 20181017 || PACKETVER_ZERO_NUM >= 20181024 + p.isDamaged = (sd->status.inventory[n].attribute & ATTR_BROKEN) != 0 ? 1 : 0; +#endif + p.refiningLevel = sd->status.inventory[n].refine; + clif->addcards(&p.slot, &sd->status.inventory[n]); + clif->add_item_options(&p.option_data[0], &sd->status.inventory[n]); + clif->send(&p, sizeof(p), &sd->bl, SELF); +#endif +} + /*========================================== * Main client packet processing function *------------------------------------------*/ @@ -23114,6 +23148,7 @@ void clif_defaults(void) clif->camera_showWindow = clif_camera_showWindow; clif->camera_change = clif_camera_change; + clif->item_preview = clif_item_preview; // -- Pet Evolution clif->pPetEvolution = clif_parse_pet_evolution; |