diff options
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 145 |
1 files changed, 105 insertions, 40 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 088c92ea8..7edc1ec5a 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -293,7 +293,11 @@ unsigned char clif_bl_type(struct block_list *bl) case BL_NPC: vd = status->get_viewdata(bl); nullpo_retr(CLUT_NPC, vd); +#if PACKETVER >= 20170726 + return CLUT_EVENT; +#else return pc->db_checkid(vd->class) ? CLUT_PC : CLUT_EVENT; +#endif case BL_PET: vd = status->get_viewdata(bl); nullpo_retr(CLUT_NPC, vd); @@ -732,6 +736,8 @@ void clif_authrefuse(int fd, uint8 error_code) /// 108 = BAN_IP_BLOCK /// 109 = BAN_INVALID_PWD_CNT /// 110 = BAN_NOT_ALLOWED_JOBCLASS +/// 113 = access is restricted between the hours of midnight to 6:00am. +/// 115 = You are in game connection ban period. /// ? = disconnected -> MsgStringTable[3] // TODO: type enum void clif_authfail_fd(int fd, int type) @@ -1067,14 +1073,17 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu #endif #if PACKETVER >= 20120221 if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) { - const struct mob_data *md = BL_UCCAST(BL_MOB, bl); p.maxHP = status_get_max_hp(bl); p.HP = status_get_hp(bl); - p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0; } else { p.maxHP = -1; p.HP = -1; - p.isBoss = 0; + } + if (bl->type == BL_MOB) { + const struct mob_data *md = BL_UCCAST(BL_MOB, bl); + p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE; + } else { + p.isBoss = BTYPE_NONE; } #endif #if PACKETVER >= 20150513 @@ -1216,14 +1225,17 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { #endif #if PACKETVER >= 20120221 if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) { - const struct mob_data *md = BL_UCCAST(BL_MOB, bl); p.maxHP = status_get_max_hp(bl); p.HP = status_get_hp(bl); - p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0; } else { p.maxHP = -1; p.HP = -1; - p.isBoss = 0; + } + if (bl->type == BL_MOB) { + const struct mob_data *md = BL_UCCAST(BL_MOB, bl); + p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE; + } else { + p.isBoss = BTYPE_NONE; } #endif #if PACKETVER >= 20150513 @@ -1315,14 +1327,17 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, #endif #if PACKETVER >= 20120221 if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) { - const struct mob_data *md = BL_UCCAST(BL_MOB, bl); p.maxHP = status_get_max_hp(bl); p.HP = status_get_hp(bl); - p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0; } else { p.maxHP = -1; p.HP = -1; - p.isBoss = 0; + } + if (bl->type == BL_MOB) { + const struct mob_data *md = BL_UCCAST(BL_MOB, bl); + p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE; + } else { + p.isBoss = BTYPE_NONE; } #endif #if PACKETVER >= 20150513 @@ -1666,8 +1681,7 @@ void clif_homskillinfoblock(struct map_session_data *sd) { if ( id != 0 ) { j = id - HM_SKILLBASE; WFIFOW(fd, len) = id; - WFIFOW(fd, len + 2) = skill->get_inf(id); - WFIFOW(fd, len + 4) = 0; + WFIFOL(fd, len + 2) = skill->get_inf(id); WFIFOW(fd, len + 6) = hd->homunculus.hskill[j].lv; if ( hd->homunculus.hskill[j].lv ) { WFIFOW(fd, len + 8) = skill->get_sp(id, hd->homunculus.hskill[j].lv); @@ -2286,6 +2300,7 @@ void clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, in /// 2 = bottom right corner /// 3 = middle of screen, inside a movable window /// 4 = middle of screen, movable with a close button, chrome-less +/// 255 = hide void clif_cutin(struct map_session_data* sd, const char* image, int type) { int fd; @@ -3332,17 +3347,22 @@ void clif_changelook(struct block_list *bl,int type,int val) #if PACKETVER < 4 clif->sendlook(bl, bl->id, type, val, 0, target); #else - if(type == LOOK_WEAPON || type == LOOK_SHIELD) { - nullpo_retv(vd); - type = LOOK_WEAPON; - val = vd->weapon; - val2 = vd->shield; - } - if (clif->isdisguised(bl)) { - clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS); - clif->sendlook(bl, -bl->id, type, val, val2, SELF); + if (bl->type != BL_NPC) { + if(type == LOOK_WEAPON || type == LOOK_SHIELD) { + nullpo_retv(vd); + type = LOOK_WEAPON; + val = vd->weapon; + val2 = vd->shield; + } + if (clif->isdisguised(bl)) { + clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS); + clif->sendlook(bl, -bl->id, type, val, val2, SELF); + } else { + clif->sendlook(bl, bl->id, type, val, val2, target); + } } else { - clif->sendlook(bl, bl->id, type, val, val2, target); + struct npc_data *nd = BL_UCAST(BL_NPC, bl); + npc->refresh(nd); } #endif } @@ -4848,9 +4868,9 @@ void clif_skillinfoblock(struct map_session_data *sd) fd=sd->fd; if (!fd) return; - WFIFOHEAD(fd, MAX_SKILL * 37 + 4); + WFIFOHEAD(fd, MAX_SKILL_DB * 37 + 4); WFIFOW(fd,0) = 0x10f; - for ( i = 0, len = 4; i < MAX_SKILL; i++) { + for ( i = 0, len = 4; i < MAX_SKILL_DB; i++) { if( (id = sd->status.skill[i].id) != 0 ) { int level; // workaround for bugreport:5348 @@ -4881,7 +4901,7 @@ void clif_skillinfoblock(struct map_session_data *sd) WFIFOSET(fd,len); // workaround for bugreport:5348; send the remaining skills one by one to bypass packet size limit - for ( ; i < MAX_SKILL; i++) { + for ( ; i < MAX_SKILL_DB; i++) { if( (id = sd->status.skill[i].id) != 0 ) { clif->addskill(sd, id); clif->skillinfo(sd, id, 0); @@ -4983,7 +5003,7 @@ void clif_skillinfo(struct map_session_data *sd,int skill_id, int inf) int skill_lv; nullpo_retv(sd); - Assert_retv(idx >= 0 && idx < MAX_SKILL); + Assert_retv(idx >= 0 && idx < MAX_SKILL_DB); skill_lv = sd->status.skill[idx].lv; @@ -5050,6 +5070,10 @@ void clif_useskill(struct block_list* bl, int src_id, int dst_id, int dst_x, int } else { clif->send(buf,packet_len(cmd), bl, AREA); } +#if PACKETVER >= 20151223 + if ((skill->get_inf2(skill_id) & INF2_SHOW_SKILL_SCALE) != 0) + clif->skill_scale(bl, src_id, bl->x, bl->y, skill_id, skill_lv, casttime); +#endif } /// Notifies clients in area, that an object canceled casting (ZC_DISPEL). @@ -6248,8 +6272,7 @@ void clif_item_skill(struct map_session_data *sd,uint16 skill_id,uint16 skill_lv WFIFOHEAD(fd,packet_len(0x147)); WFIFOW(fd, 0)=0x147; WFIFOW(fd, 2)=skill_id; - WFIFOW(fd, 4)=skill->get_inf(skill_id); - WFIFOW(fd, 6)=0; + WFIFOL(fd, 4)=skill->get_inf(skill_id); WFIFOW(fd, 8)=skill_lv; WFIFOW(fd,10)=skill->get_sp(skill_id,skill_lv); WFIFOW(fd,12)=skill->get_range2(&sd->bl, skill_id,skill_lv); @@ -9021,14 +9044,15 @@ void clif_feel_hate_reset(struct map_session_data *sd) clif->starskill(sd, "", 0, 0, 30); } -/// Equip window (un)tick ack (ZC_CONFIG). +/// Send configurations (ZC_CONFIG). /// 02d9 <type>.L <value>.L /// type: /// 0 = open equip window +/// 3 = homunculus autofeeding /// value: /// 0 = disabled /// 1 = enabled -void clif_equiptickack(struct map_session_data* sd, int flag) +void clif_zc_config(struct map_session_data* sd, int type, int flag) { int fd; nullpo_retv(sd); @@ -9036,7 +9060,7 @@ void clif_equiptickack(struct map_session_data* sd, int flag) WFIFOHEAD(fd, packet_len(0x2d9)); WFIFOW(fd, 0) = 0x2d9; - WFIFOL(fd, 2) = 0; + WFIFOL(fd, 2) = type; WFIFOL(fd, 6) = flag; WFIFOSET(fd, packet_len(0x2d9)); } @@ -15920,19 +15944,32 @@ void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) { clif->msgtable(sd, MSG_EQUIP_NOT_PUBLIC); } -void clif_parse_EquipTick(int fd, struct map_session_data* sd) __attribute__((nonnull (2))); -/// Request to change equip window tick (CZ_CONFIG). +void clif_parse_cz_config(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); +/// Receive configurations (CZ_CONFIG). /// 02d8 <type>.L <value>.L /// type: /// 0 = open equip window +/// 3 = homunculus autofeeding /// value: /// 0 = disabled /// 1 = enabled -void clif_parse_EquipTick(int fd, struct map_session_data* sd) -{ - bool flag = (RFIFOL(fd,6) != 0) ? true : false; - sd->status.show_equip = flag; - clif->equiptickack(sd, flag); +void clif_parse_cz_config(int fd, struct map_session_data *sd) +{ + int type = RFIFOL(fd, 2); + int flag = RFIFOL(fd, 6); + + if (type == CZ_CONFIG_OPEN_EQUIPMENT_WINDOW) { + sd->status.show_equip = flag; + } else if (type == CZ_CONFIG_HOMUNCULUS_AUTOFEEDING) { + struct homun_data *hd; + hd = sd->hd; + nullpo_retv(hd); + hd->homunculus.autofeed = flag; + } else { + ShowWarning("clif_parse_cz_config: Unsupported type has been received (%d).", type); + return; + } + clif->zc_config(sd, type, flag); } void clif_parse_PartyTick(int fd, struct map_session_data* sd) __attribute__((nonnull (2))); @@ -17624,7 +17661,7 @@ int clif_autoshadowspell_list(struct map_session_data *sd) { WFIFOHEAD(fd, 2 * 6 + 4); WFIFOW(fd,0) = 0x442; - for( i = 0, c = 0; i < MAX_SKILL; i++ ) + for (i = 0, c = 0; i < MAX_SKILL_DB; i++) if( sd->status.skill[i].flag == SKILL_FLAG_PLAGIARIZED && sd->status.skill[i].id > 0 && sd->status.skill[i].id < GS_GLITTERING && skill->get_type(sd->status.skill[i].id) == BF_MAGIC ) { // Can't auto cast both Extended class and 3rd class skills. @@ -19842,6 +19879,32 @@ void clif_parse_rodex_cancel_write_mail(int fd, struct map_session_data *sd) rodex->clean(sd, 1); } +void clif_skill_scale(struct block_list *bl, int src_id, int x, int y, uint16 skill_id, uint16 skill_lv, int casttime) +{ +#if PACKETVER >= 20151223 + struct PACKET_ZC_SKILL_SCALE p; + + p.PacketType = skillscale; + p.AID = src_id; + p.skill_id = skill_id; + p.skill_lv = skill_lv; + p.x = x; + p.y = y; + p.casttime = casttime; + + if (clif->isdisguised(bl)) { + clif->send(&p, sizeof(p), bl, AREA_WOS); + p.AID = -src_id; + clif->send(&p, sizeof(p), bl, SELF); + } else { + clif->send(&p, sizeof(p), bl, AREA); + } +#else + ShowWarning("clif_skill_scale: showing skill scale available only for clients >= 20151223."); + return; +#endif +} + /*========================================== * Main client packet processing function *------------------------------------------*/ @@ -20054,6 +20117,7 @@ void packetdb_loaddb(void) { #define packet(id, size, ...) packetdb_addpacket((id), (size), ##__VA_ARGS__, 0xFFFF) #include "packets.h" /* load structure data */ +#include "packets_shuffle.h" #undef packet #define packetKeys(a,b,c) do { clif->cryptKey[0] = (a); clif->cryptKey[1] = (b); clif->cryptKey[2] = (c); } while(0) #include "packets_keys.h" @@ -20296,7 +20360,7 @@ void clif_defaults(void) { clif->mission_info = clif_mission_info; clif->feel_hate_reset = clif_feel_hate_reset; clif->partytickack = clif_partytickack; - clif->equiptickack = clif_equiptickack; + clif->zc_config = clif_zc_config; clif->viewequip_ack = clif_viewequip_ack; clif->equpcheckbox = clif_equpcheckbox; clif->displayexp = clif_displayexp; @@ -20821,7 +20885,7 @@ void clif_defaults(void) { clif->pAdopt_request = clif_parse_Adopt_request; clif->pAdopt_reply = clif_parse_Adopt_reply; clif->pViewPlayerEquip = clif_parse_ViewPlayerEquip; - clif->pEquipTick = clif_parse_EquipTick; + clif->p_cz_config = clif_parse_cz_config; clif->pquestStateAck = clif_parse_questStateAck; clif->pmercenary_action = clif_parse_mercenary_action; clif->pBattleChat = clif_parse_BattleChat; @@ -20911,4 +20975,5 @@ void clif_defaults(void) { clif->rodex_request_items = clif_rodex_request_items; clif->rodex_icon = clif_rodex_icon; clif->rodex_send_mails_all = clif_rodex_send_mails_all; + clif->skill_scale = clif_skill_scale; } |