diff options
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 304 |
1 files changed, 117 insertions, 187 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 86b130e88..109f78553 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -52,6 +52,7 @@ #include "map/script.h" #include "map/skill.h" #include "map/status.h" +#include "map/stylist.h" #include "map/storage.h" #include "map/trade.h" #include "map/unit.h" @@ -5432,7 +5433,7 @@ static void clif_useskill(struct block_list *bl, int src_id, int dst_id, int dst #if PACKETVER_MAIN_NUM >= 20091124 || PACKETVER_RE_NUM >= 20091124 || defined(PACKETVER_ZERO) p.disposable = 0; #endif -#if PACKETVER_ZERO_NUM >= 20190130 +#if PACKETVER_MAIN_NUM >= 20181212 || PACKETVER_RE_NUM >= 20181212 || PACKETVER_ZERO_NUM >= 20190130 p.unknown = 0; #endif @@ -7738,17 +7739,27 @@ static void clif_devotion(struct block_list *src, struct map_session_data *tsd) static void clif_spiritball(struct block_list *bl) { unsigned char buf[16]; - struct map_session_data *sd = BL_CAST(BL_PC,bl); - struct homun_data *hd = BL_CAST(BL_HOM,bl); nullpo_retv(bl); WBUFW(buf, 0) = 0x1d0; WBUFL(buf, 2) = bl->id; WBUFW(buf, 6) = 0; //init to 0 - switch(bl->type){ - case BL_PC: WBUFW(buf, 6) = sd->spiritball; break; - case BL_HOM: WBUFW(buf, 6) = hd->homunculus.spiritball; break; + switch (bl->type) { + case BL_PC: + { + struct map_session_data *sd = BL_CAST(BL_PC, bl); + nullpo_retv(sd); + WBUFW(buf, 6) = sd->spiritball; + break; + } + case BL_HOM: + { + struct homun_data *hd = BL_CAST(BL_HOM, bl); + nullpo_retv(hd); + WBUFW(buf, 6) = hd->homunculus.spiritball; + break; + } } clif->send(buf, packet_len(0x1d0), bl, AREA); } @@ -9227,7 +9238,7 @@ static void clif_refresh(struct map_session_data *sd) /// 0095 <id>.L <char name>.24B (ZC_ACK_REQNAME) /// 0195 <id>.L <char name>.24B <party name>.24B <guild name>.24B <position name>.24B (ZC_ACK_REQNAMEALL) /// 0A30 <id>.L <char name>.24B <party name>.24B <guild name>.24B <position name>.24B <title id>.L (ZC_ACK_REQNAMEALL2) -static void clif_charnameack(int fd, struct block_list *bl) +static void clif_blname_ack(int fd, struct block_list *bl) { struct packet_reqnameall_ack packet = { 0 }; int len = sizeof(struct packet_reqnameall_ack); @@ -9348,7 +9359,7 @@ static void clif_charnameack(int fd, struct block_list *bl) memcpy(packet.name, BL_UCCAST(BL_ELEM, bl)->db->name, NAME_LENGTH); break; default: - ShowError("clif_charnameack: bad type %u(%d)\n", bl->type, bl->id); + ShowError("clif_blname_ack: bad type %u(%d)\n", bl->type, bl->id); return; } @@ -10783,7 +10794,7 @@ static void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) } #endif // 0 - clif->charnameack(fd, bl); + clif->blname_ack(fd, bl); } static int clif_undisguise_timer(int tid, int64 tick, int id, intptr_t data) { @@ -15661,6 +15672,7 @@ static void clif_parse_FeelSaveOk(int fd, struct map_session_data *sd) /// 0 = sun /// 1 = moon /// 2 = star +/// 10 = Do you agree to cast the magic spell that consumes 1 Black Gemstone and 1,000,000 Zeny? static void clif_feel_req(int fd, struct map_session_data *sd, uint16 skill_lv) { nullpo_retv(sd); @@ -17009,6 +17021,9 @@ static void clif_parse_cz_config(int fd, struct map_session_data *sd) hd->homunculus.autofeed = flag; break; } + case CZ_CONFIG_CALL: + sd->status.allow_call = flag; + break; default: ShowWarning("clif_parse_cz_config: Unsupported type has been received (%u).\n", type); return; @@ -18580,6 +18595,7 @@ static void clif_search_store_info_ack(struct map_session_data *sd) /// 2 = "You cannot search anymore." (0x706) /// 3 = "You cannot search yet." (0x708) /// 4 = "No sale (purchase) information available." (0x705) +/// 362 = silent error static void clif_search_store_info_failed(struct map_session_data *sd, unsigned char reason) { #if PACKETVER >= 20100601 @@ -20947,8 +20963,8 @@ static void clif_change_title_ack(int fd, struct map_session_data *sd, int title WFIFOSET(fd, packet_len(0xa2f)); // Update names - clif->charnameack(fd, &sd->bl); - clif->charnameack(0, &sd->bl); + clif->blname_ack(fd, &sd->bl); + clif->blname_ack(0, &sd->bl); #endif } // End of Achievement System @@ -21729,6 +21745,18 @@ static void clif_open_ui(struct map_session_data *sd, enum cz_ui_types uiType) p.data = 0; #endif break; + case CZ_MACRO_REGISTER_UI: + p.UIType = ZC_CAPTCHA_UI; +#if PACKETVER >= 20171122 + p.data = 0; +#endif + break; + case CZ_MACRO_DETECTOR_UI: + p.UIType = ZC_MACRO_UI; +#if PACKETVER >= 20171122 + p.data = 0; +#endif + break; case CZ_ATTENDANCE_UI: { if (clif->attendance_getendtime() < time(NULL)) { @@ -21873,162 +21901,23 @@ static void clif_private_airship_response(struct map_session_data *sd, uint32 fl #endif } -static void clif_stylist_vector_init(void) -{ - int i; - for (i = 0; i < MAX_STYLIST_TYPE; i++) { - VECTOR_INIT(stylist_data[i]); - } -} - -static void clif_stylist_vector_clear(void) -{ - int i; - for (i = 0; i < MAX_STYLIST_TYPE; i++) { - VECTOR_CLEAR(stylist_data[i]); - } -} - -static bool clif_stylist_read_db_libconfig(void) -{ - struct config_t stylist_conf; - struct config_setting_t *stylist = NULL, *it = NULL; - const char *config_filename = "db/stylist_db.conf"; // FIXME hardcoded name - int i = 0; - - if (!libconfig->load_file(&stylist_conf, config_filename)) - return false; - - if ((stylist = libconfig->setting_get_member(stylist_conf.root, "stylist_db")) == NULL) { - ShowError("can't read %s\n", config_filename); - return false; - } - - clif->stylist_vector_clear(); - - while ((it = libconfig->setting_get_elem(stylist, i++))) { - clif->stylist_read_db_libconfig_sub(it, i - 1, config_filename); - } - - libconfig->destroy(&stylist_conf); - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, config_filename); - return true; -} - -static bool clif_stylist_read_db_libconfig_sub(struct config_setting_t *it, int idx, const char *source) -{ - struct stylist_data_entry entry = { 0 }; - int i32 = 0, type = 0; - int64 i64 = 0; - - nullpo_ret(it); - nullpo_ret(source); - - if (!itemdb->lookup_const(it, "Type", &type) || type >= MAX_STYLIST_TYPE || type < 0) { - ShowWarning("clif_stylist_read_db_libconfig_sub: Invalid or missing Type (%d) in \"%s\", entry #%d, skipping.\n", type, source, idx); - return false; - } - if (!itemdb->lookup_const(it, "Id", &i32) || i32 < 0) { - ShowWarning("clif_stylist_read_db_libconfig_sub: Invalid or missing Id (%d) in \"%s\", entry #%d, skipping.\n", i32, source, idx); - return false; - } - entry.id = i32; - - if (libconfig->setting_lookup_int64(it, "Zeny", &i64)) { - if (i64 > MAX_ZENY) { - ShowWarning("clif_stylist_read_db_libconfig_sub: zeny is too big in \"%s\", entry #%d, capping to MAX_ZENY.\n", source, idx); - entry.zeny = MAX_ZENY; - } else { - entry.zeny = (int)i64; - } - } - - if (itemdb->lookup_const(it, "ItemID", &i32)) - entry.itemid = i32; - - if (itemdb->lookup_const(it, "BoxItemID", &i32)) - entry.boxid = i32; - - if (libconfig->setting_lookup_bool(it, "AllowDoram", &i32)) - entry.allow_doram = (i32 == 0) ? false : true; - - VECTOR_ENSURE(stylist_data[type], 1, 1); - VECTOR_PUSH(stylist_data[type], entry); - return true; -} - -static bool clif_style_change_validate_requirements(struct map_session_data *sd, int type, int16 idx) -{ - struct item it; - struct stylist_data_entry *entry; - - nullpo_retr(false, sd); - Assert_retr(false, type >= 0 && type < MAX_STYLIST_TYPE); - Assert_retr(false, idx >= 0 && idx < VECTOR_LENGTH(stylist_data[type])); - - entry = &VECTOR_INDEX(stylist_data[type], idx); - - if (sd->status.class == JOB_SUMMONER && (entry->allow_doram == false)) - return false; - - if (entry->id >= 0) { - if (entry->zeny != 0) { - if (sd->status.zeny < entry->zeny) - return false; - - sd->status.zeny -= entry->zeny; - clif->updatestatus(sd, SP_ZENY); - } else if (entry->itemid != 0) { - it.nameid = entry->itemid; - it.amount = 1; - return script->buildin_delitem_search(sd, &it, false); - } else if (entry->boxid != 0) { - it.nameid = entry->boxid; - it.amount = 1; - return script->buildin_delitem_search(sd, &it, false); - } - return true; - } - return false; -} -static void clif_stylist_send_rodexitem(struct map_session_data *sd, int itemid) -{ - struct rodex_message msg = { 0 }; - - nullpo_retv(sd); - - msg.receiver_id = sd->status.char_id; - msg.items[0].item.nameid = itemid; - msg.items[0].item.amount = 1; - msg.items[0].item.identify = 1; - msg.type = MAIL_TYPE_NPC | MAIL_TYPE_ITEM; - - safestrncpy(msg.sender_name, msg_txt(366), NAME_LENGTH); - safestrncpy(msg.title, msg_txt(367), RODEX_TITLE_LENGTH); - safestrncpy(msg.body, msg_txt(368), MAIL_BODY_LENGTH); - msg.send_date = (int)time(NULL); - msg.expire_date = (int)time(NULL) + RODEX_EXPIRE; - - intif->rodex_sendmail(&msg); -} - static void clif_parse_cz_req_style_change(int fd, struct map_session_data *sd) __attribute__((nonnull(2))); static void clif_parse_cz_req_style_change(int fd, struct map_session_data *sd) { const struct PACKET_CZ_REQ_STYLE_CHANGE *p = RP2PTR(fd); if (p->HeadStyle > 0) - clif->cz_req_style_change_sub(sd, LOOK_HAIR, p->HeadStyle, false); + stylist->request_style_change(sd, LOOK_HAIR, p->HeadStyle, false); if (p->HeadPalette > 0) - clif->cz_req_style_change_sub(sd, LOOK_HAIR_COLOR, p->HeadPalette, false); + stylist->request_style_change(sd, LOOK_HAIR_COLOR, p->HeadPalette, false); if (p->BodyPalette > 0) - clif->cz_req_style_change_sub(sd, LOOK_CLOTHES_COLOR, p->BodyPalette, false); + stylist->request_style_change(sd, LOOK_CLOTHES_COLOR, p->BodyPalette, false); if (p->TopAccessory > 0) - clif->cz_req_style_change_sub(sd, LOOK_HEAD_TOP, p->TopAccessory, true); + stylist->request_style_change(sd, LOOK_HEAD_TOP, p->TopAccessory, true); if (p->MidAccessory > 0) - clif->cz_req_style_change_sub(sd, LOOK_HEAD_MID, p->MidAccessory, true); + stylist->request_style_change(sd, LOOK_HEAD_MID, p->MidAccessory, true); if (p->BottomAccessory > 0) - clif->cz_req_style_change_sub(sd, LOOK_HEAD_BOTTOM, p->BottomAccessory, true); + stylist->request_style_change(sd, LOOK_HEAD_BOTTOM, p->BottomAccessory, true); clif->style_change_response(sd, STYLIST_SHOP_SUCCESS); return; } @@ -22039,43 +21928,30 @@ static void clif_parse_cz_req_style_change2(int fd, struct map_session_data *sd) const struct PACKET_CZ_REQ_STYLE_CHANGE2 *p = RP2PTR(fd); if (p->HeadStyle > 0) - clif->cz_req_style_change_sub(sd, LOOK_HAIR, p->HeadStyle, false); + stylist->request_style_change(sd, LOOK_HAIR, p->HeadStyle, false); if (p->HeadPalette > 0) - clif->cz_req_style_change_sub(sd, LOOK_HAIR_COLOR, p->HeadPalette, false); + stylist->request_style_change(sd, LOOK_HAIR_COLOR, p->HeadPalette, false); if (p->BodyPalette > 0) - clif->cz_req_style_change_sub(sd, LOOK_CLOTHES_COLOR, p->BodyPalette, false); + stylist->request_style_change(sd, LOOK_CLOTHES_COLOR, p->BodyPalette, false); if (p->TopAccessory > 0) - clif->cz_req_style_change_sub(sd, LOOK_HEAD_TOP, p->TopAccessory, true); + stylist->request_style_change(sd, LOOK_HEAD_TOP, p->TopAccessory, true); if (p->MidAccessory > 0) - clif->cz_req_style_change_sub(sd, LOOK_HEAD_MID, p->MidAccessory, true); + stylist->request_style_change(sd, LOOK_HEAD_MID, p->MidAccessory, true); if (p->BottomAccessory > 0) - clif->cz_req_style_change_sub(sd, LOOK_HEAD_BOTTOM, p->BottomAccessory, true); + stylist->request_style_change(sd, LOOK_HEAD_BOTTOM, p->BottomAccessory, true); if (p->BodyStyle > 0) { if (pc->has_second_costume(sd)) { - clif->cz_req_style_change_sub(sd, LOOK_BODY2, p->BodyStyle, false); + stylist->request_style_change(sd, LOOK_BODY2, p->BodyStyle, false); } } clif->style_change_response(sd, STYLIST_SHOP_SUCCESS); return; } -static void clif_cz_req_style_change_sub(struct map_session_data *sd, int type, int16 idx, bool isitem) +static void clif_parse_cz_style_close(int fd, struct map_session_data *sd) __attribute__((nonnull(2))); +static void clif_parse_cz_style_close(int fd, struct map_session_data *sd) { - struct stylist_data_entry *entry; - - nullpo_retv(sd); - Assert_retv(idx > 0); - Assert_retv(type >= 0 && type < MAX_STYLIST_TYPE); - - if ((idx - 1) < VECTOR_LENGTH(stylist_data[type])) { - entry = &VECTOR_INDEX(stylist_data[type], idx - 1); - if (clif->style_change_validate_requirements(sd, type, idx - 1)) { - if (isitem == false) - pc->changelook(sd, type, entry->id); - else - clif->stylist_send_rodexitem(sd, entry->id); - } - } + // do nothing } static void clif_style_change_response(struct map_session_data *sd, enum stylist_shop flag) @@ -22297,6 +22173,55 @@ static void clif_parse_clientVersion(int fd, struct map_session_data *sd) #endif } +static void clif_parse_ping(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); +static void clif_parse_ping(int fd, struct map_session_data *sd) +{ + // do nothing, any packet update client tick +} + +static void clif_ping(struct map_session_data *sd) +{ +#if PACKETVER_MAIN_NUM >= 20190213 || PACKETVER_RE_NUM >= 20190213 || PACKETVER_ZERO_NUM >= 20190130 + nullpo_retv(sd); + struct PACKET_ZC_PING p; + p.packetType = HEADER_ZC_PING; + clif->send(&p, sizeof(p), &sd->bl, SELF); +#endif +} + +static int clif_pingTimer(int tid, int64 tick, int id, intptr_t data) +{ + map->foreachpc(clif->pingTimerSub, time(NULL)); + return 0; +} + +static int clif_pingTimerSub(struct map_session_data *sd, va_list ap) +{ + nullpo_ret(sd); + const int fd = sd->fd; + + if (!sockt->session_is_active(fd)) + { + return 0; + } + + time_t tick = va_arg(ap, time_t); + + if (sockt->session[fd]->wdata_tick + battle_config.ping_time < tick) + { + clif->ping(sd); + } + return 0; +} + +static void clif_parse_ResetCooldown(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); +static void clif_parse_ResetCooldown(int fd, struct map_session_data *sd) +{ + char cmd[15]; + sprintf(cmd,"%ccddebug reset", atcommand->at_symbol); + atcommand->exec(fd, sd, cmd, true); +} + /*========================================== * Main client packet processing function *------------------------------------------*/ @@ -22578,6 +22503,12 @@ static int do_init_clif(bool minimal) clif->delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR); clif->delayed_damage_ers = ers_new(sizeof(struct cdelayed_damage),"clif.c::delayed_damage_ers",ERS_OPT_CLEAR); +#if PACKETVER_MAIN_NUM >= 20190403 || PACKETVER_RE_NUM >= 20190320 + timer->add_func_list(clif->pingTimer, "clif_pingTimer"); + if (battle_config.ping_timer_interval != 0) + timer->add_interval(timer->gettick() + battle_config.ping_timer_interval * 1000, clif->pingTimer, 0, 0, battle_config.ping_timer_interval * 1000); +#endif + return 0; } @@ -22775,7 +22706,7 @@ void clif_defaults(void) clif->mvp_exp = clif_mvp_exp; clif->mvp_noitem = clif_mvp_noitem; clif->changed_dir = clif_changed_dir; - clif->charnameack = clif_charnameack; + clif->blname_ack = clif_blname_ack; clif->monster_hp_bar = clif_monster_hp_bar; clif->hpmeter = clif_hpmeter; clif->hpmeter_single = clif_hpmeter_single; @@ -23459,15 +23390,9 @@ void clif_defaults(void) clif->pPrivateAirshipRequest = clif_parse_private_airship_request; clif->PrivateAirshipResponse = clif_private_airship_response; - clif->stylist_vector_init = clif_stylist_vector_init; - clif->stylist_vector_clear = clif_stylist_vector_clear; - clif->stylist_read_db_libconfig = clif_stylist_read_db_libconfig; - clif->stylist_read_db_libconfig_sub = clif_stylist_read_db_libconfig_sub; - clif->style_change_validate_requirements = clif_style_change_validate_requirements; - clif->stylist_send_rodexitem = clif_stylist_send_rodexitem; clif->pReqStyleChange = clif_parse_cz_req_style_change; clif->pReqStyleChange2 = clif_parse_cz_req_style_change2; - clif->cz_req_style_change_sub = clif_cz_req_style_change_sub; + clif->pStyleClose = clif_parse_cz_style_close; clif->style_change_response = clif_style_change_response; clif->camera_showWindow = clif_camera_showWindow; @@ -23487,4 +23412,9 @@ void clif_defaults(void) clif->pNPCBarterClosed = clif_parse_NPCBarterClosed; clif->pNPCBarterPurchase = clif_parse_NPCBarterPurchase; clif->pClientVersion = clif_parse_clientVersion; + clif->pPing = clif_parse_ping; + clif->ping = clif_ping; + clif->pingTimer = clif_pingTimer; + clif->pingTimerSub = clif_pingTimerSub; + clif->pResetCooldown = clif_parse_ResetCooldown; } |