summaryrefslogtreecommitdiff
path: root/src/map/refine.c
diff options
context:
space:
mode:
authorIbrahim Zidan <brahem@aotsw.com>2019-04-27 23:14:09 +0200
committerIbrahim Zidan <brahem@aotsw.com>2019-05-05 23:40:43 +0200
commit8598e0cbf421eded6943d416f7da8881997c960a (patch)
tree35c1c6c6af1efddba2c91c1f5ca867f7c6b62f26 /src/map/refine.c
parentfdcd121237eb03cc264dbd8ad1371603bd6622c7 (diff)
downloadhercules-8598e0cbf421eded6943d416f7da8881997c960a.tar.gz
hercules-8598e0cbf421eded6943d416f7da8881997c960a.tar.bz2
hercules-8598e0cbf421eded6943d416f7da8881997c960a.tar.xz
hercules-8598e0cbf421eded6943d416f7da8881997c960a.zip
Implement Refine success/failure announcement feature
Currently as far as we know kRO only sends this on success in refining an item through the refinery ui, from level 10 all the way to 20. Signed-off-by: Ibrahim Zidan <brahem@aotsw.com>
Diffstat (limited to 'src/map/refine.c')
-rw-r--r--src/map/refine.c33
1 files changed, 33 insertions, 0 deletions
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;