summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c18
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/refine.c33
-rw-r--r--src/map/refine.h2
-rw-r--r--src/map/refine.p.h15
5 files changed, 69 insertions, 0 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index b8a54166a..462991510 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -22574,6 +22574,23 @@ static void clif_parse_RefineryUIClose(int fd, struct map_session_data *sd)
#endif
}
+static void clif_announce_refine_status(struct map_session_data *sd, int item_id, int refine_level, bool success, enum send_target target)
+{
+#if PACKETVER_MAIN_NUM >= 20170906 || PACKETVER_RE_NUM >= 20170830 || defined(PACKETVER_ZERO)
+ nullpo_retv(sd);
+
+ Assert_retv(refine_level > 0 && refine_level <= INT8_MAX);
+
+ struct PACKET_ZC_REFINE_STATUS p;
+ p.packetType = HEADER_ZC_REFINE_STATUS;
+ safestrncpy(p.name, sd->status.name, NAME_LENGTH);
+ p.itemId = item_id;
+ p.refine_level = refine_level;
+ p.status = (success) ? true : false;
+ clif->send(&p, sizeof(p), &sd->bl, target);
+#endif
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
@@ -23792,4 +23809,5 @@ void clif_defaults(void)
clif->AddItemRefineryUIAck = clif_AddItemRefineryUIAck;
clif->pRefineryUIClose = clif_parse_RefineryUIClose;
clif->pRefineryUIRefine = clif_parse_RefineryUIRefine;
+ clif->announce_refine_status = clif_announce_refine_status;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index 0515fbd05..19c321ed3 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -1617,6 +1617,7 @@ struct clif_interface {
void (*AddItemRefineryUIAck) (struct map_session_data *sd, int item_index, struct s_refine_requirement *req);
void (*pRefineryUIClose) (int fd, struct map_session_data *sd);
void (*pRefineryUIRefine) (int fd, struct map_session_data *sd);
+ void (*announce_refine_status) (struct map_session_data *sd, int item_id, int refine_level, bool success, enum send_target target);
};
#ifdef HERCULES_CORE
diff --git a/src/map/refine.c b/src/map/refine.c
index 58e006012..1ff893c56 100644
--- a/src/map/refine.c
+++ b/src/map/refine.c
@@ -131,6 +131,9 @@ static void refine_refinery_refine_request(struct map_session_data *sd, int item
pc->delitem(sd, item_index, 1, 0, DELITEM_FAILREFINE, LOG_TYPE_REFINE);
break;
}
+
+ if ((req->announce & REFINE_ANNOUNCE_FAILURE) != 0)
+ clif->announce_refine_status(sd, sd->status.inventory[item_index].nameid, sd->status.inventory[item_index].refine, false, ALL_CLIENT);
} else {
sd->status.inventory[item_index].refine += 1;
sd->status.inventory[item_index].refine = cap_value(sd->status.inventory[item_index].refine, 0, MAX_REFINE);
@@ -139,6 +142,9 @@ static void refine_refinery_refine_request(struct map_session_data *sd, int item
clif->refine(sd->fd, 0, item_index, sd->status.inventory[item_index].refine);
logs->pick_pc(sd, LOG_TYPE_REFINE, 1, &sd->status.inventory[item_index], sd->inventory_data[item_index]);
refine->refinery_add_item(sd, item_index);
+
+ if ((req->announce & REFINE_ANNOUNCE_SUCCESS) != 0)
+ clif->announce_refine_status(sd, sd->status.inventory[item_index].nameid, sd->status.inventory[item_index].refine, true, ALL_CLIENT);
}
}
@@ -222,6 +228,24 @@ static int refine_get_refine_chance(enum refine_type wlv, int refine_level, enum
return refine->p->dbs->refine_info[wlv].chance[type][refine_level];
}
+/// @copydoc refine_interface_private::announce_behavior_string2enum()
+static bool refine_announce_behavior_string2enum(const char *str, unsigned int *result)
+{
+ nullpo_retr(false, str);
+ nullpo_retr(false, result);
+
+ if (strcasecmp(str, "Success") == 0)
+ *result = REFINE_ANNOUNCE_SUCCESS;
+ else if (strcasecmp(str, "Failure") == 0)
+ *result = REFINE_ANNOUNCE_FAILURE;
+ else if (strcasecmp(str, "Always") == 0)
+ *result = REFINE_ANNOUNCE_ALWAYS;
+ else
+ return false;
+
+ return true;
+}
+
/// @copydoc refine_interface_private::failure_behavior_string2enum()
static bool refine_failure_behavior_string2enum(const char *str, enum refine_ui_failure_behavior *result)
{
@@ -373,6 +397,14 @@ static bool refine_readdb_refinery_ui_settings_sub(const struct config_setting_t
}
}
+ req.announce = 0;
+ const char *announce_behavior = NULL;
+ if (libconfig->setting_lookup_string(elem, "Announce", &announce_behavior) != CONFIG_FALSE) {
+ if (!refine->p->announce_behavior_string2enum(announce_behavior, &req.announce)) {
+ ShowWarning("refine_readdb_requirements_sub: invalid announce behavior value '%s' in entry '%s' in \"%s\" defaulting to not announce...\n", announce_behavior, name, source);
+ }
+ }
+
struct config_setting_t *items_t;
if ((items_t = libconfig->setting_get_member(elem, "Items")) == NULL) {
ShowWarning("refine_readdb_requirements_sub: a requirements element missing Items element for entry '%s' in \"%s\" skipping...\n", name, source);
@@ -620,6 +652,7 @@ void refine_defaults(void)
refine->p->readdb_refine_libconfig = refine_readdb_refine_libconfig;
refine->p->readdb_refine_libconfig_sub = refine_readdb_refine_libconfig_sub;
+ refine->p->announce_behavior_string2enum = refine_announce_behavior_string2enum;
refine->p->failure_behavior_string2enum = refine_failure_behavior_string2enum;
refine->p->readdb_refinery_ui_settings_items = refine_readdb_refinery_ui_settings_items;
refine->p->readdb_refinery_ui_settings_sub = refine_readdb_refinery_ui_settings_sub;
diff --git a/src/map/refine.h b/src/map/refine.h
index 100d2c6b2..410811e06 100644
--- a/src/map/refine.h
+++ b/src/map/refine.h
@@ -71,6 +71,8 @@ enum refine_ui_failure_behavior {
struct s_refine_requirement {
int blacksmith_blessing;
int req_count;
+ unsigned int announce;
+
struct {
int nameid;
int cost;
diff --git a/src/map/refine.p.h b/src/map/refine.p.h
index e1a24f6b7..3247d15c9 100644
--- a/src/map/refine.p.h
+++ b/src/map/refine.p.h
@@ -27,7 +27,14 @@
#include "refine.h"
#include "common/conf.h"
+/* Enums */
+enum refine_announce_condition {
+ REFINE_ANNOUNCE_SUCCESS = 0x1,
+ REFINE_ANNOUNCE_FAILURE = 0x2,
+ REFINE_ANNOUNCE_ALWAYS = REFINE_ANNOUNCE_SUCCESS | REFINE_ANNOUNCE_FAILURE,
+};
+/* Structures */
struct s_refine_info {
int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; //< success chance
int bonus[MAX_REFINE]; //< cumulative fixed bonus damage
@@ -68,6 +75,14 @@ struct refine_interface_private {
int (*readdb_refine_libconfig) (const char *filename);
/**
+ * Converts refine database announce behvaior string to enum refine_announce_condition
+ * @param str the string to convert
+ * @param result pointer to where the converted value will be held
+ * @return true on success, false otherwise.
+ **/
+ bool (*announce_behavior_string2enum) (const char *str, unsigned int *result);
+
+ /**
* Converts refine database failure behvaior string to enum refine_ui_failure_behavior
* @param str the string to convert
* @param result pointer to where the converted value will be held