summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/HPMmap.c1
-rw-r--r--src/map/Makefile.in4
-rw-r--r--src/map/clif.c192
-rw-r--r--src/map/clif.h21
-rw-r--r--src/map/itemdb.c3
-rw-r--r--src/map/map.c4
-rw-r--r--src/map/stylist.c228
-rw-r--r--src/map/stylist.h69
8 files changed, 318 insertions, 204 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index 6eff37df8..cbfa8e8c4 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -86,6 +86,7 @@
#include "map/skill.h"
#include "map/status.h"
#include "map/storage.h"
+#include "map/stylist.h"
#include "map/trade.h"
#include "map/unit.h"
#include "map/vending.h"
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index 3705fda0e..edb3fdaad 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -45,7 +45,7 @@ MAP_C = achievement.c atcommand.c battle.c battleground.c buyingstore.c channel.
instance.c intif.c irc-bot.c itemdb.c log.c mail.c map.c mapreg_sql.c \
mercenary.c mob.c npc.c npc_chat.c party.c path.c pc.c pc_groups.c \
pet.c quest.c rodex.c script.c searchstore.c skill.c status.c storage.c \
- trade.c unit.c vending.c
+ stylist.c trade.c unit.c vending.c
MAP_OBJ = $(addprefix obj_sql/, $(patsubst %c,%o,$(MAP_C)))
MAP_H = achievement.h atcommand.h battle.h battleground.h buyingstore.h channel.h chat.h \
chrif.h clan.h clif.h date.h duel.h elemental.h guild.h homunculus.h HPMmap.h \
@@ -55,7 +55,7 @@ MAP_H = achievement.h atcommand.h battle.h battleground.h buyingstore.h channel.
packets_keys_zero.h packets_shuffle_main.h packets_shuffle_re.h \
packets_shuffle_zero.h packets_struct.h party.h path.h pc.h pc_groups.h \
pet.h quest.h rodex.h script.h searchstore.h skill.h status.h storage.h \
- trade.h unit.h vending.h
+ stylist.h trade.h unit.h vending.h
MAP_PH =
HAVE_MYSQL=@HAVE_MYSQL@
diff --git a/src/map/clif.c b/src/map/clif.c
index 86b130e88..3a2b7f8f3 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"
@@ -21873,162 +21874,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,45 +21901,26 @@ 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)
-{
- 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);
- }
- }
-}
-
static void clif_style_change_response(struct map_session_data *sd, enum stylist_shop flag)
{
#if PACKETVER >= 20151104
@@ -23459,15 +23302,8 @@ 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->style_change_response = clif_style_change_response;
clif->camera_showWindow = clif_camera_showWindow;
diff --git a/src/map/clif.h b/src/map/clif.h
index a7573b56e..23ac7f250 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -71,10 +71,6 @@ enum rodex_get_items;
#define MAX_ROULETTE_COLUMNS 9 /** client-defined value **/
#define RGB2BGR(c) (((c) & 0x0000FF) << 16 | ((c) & 0x00FF00) | ((c) & 0xFF0000) >> 16)
-#ifndef MAX_STYLIST_TYPE
-#define MAX_STYLIST_TYPE LOOK_MAX
-#endif
-
#define COLOR_CYAN 0x00ffffU
#define COLOR_RED 0xff0000U
#define COLOR_GREEN 0x00ff00U
@@ -655,16 +651,6 @@ struct attendance_entry {
int qty;
};
-/* Stylist data [Asheraf/Hercules]*/
-struct stylist_data_entry {
- int16 id;
- int32 zeny;
- int itemid;
- int boxid;
- bool allow_doram;
-};
-VECTOR_DECL(struct stylist_data_entry) stylist_data[MAX_STYLIST_TYPE];
-
struct barter_itemlist_entry {
int addId;
int addAmount;
@@ -1576,15 +1562,8 @@ struct clif_interface {
void (*pPrivateAirshipRequest) (int fd, struct map_session_data *sd);
void (*PrivateAirshipResponse) (struct map_session_data *sd, uint32 flag);
- void (*stylist_vector_init) (void);
- void (*stylist_vector_clear) (void);
- bool (*stylist_read_db_libconfig) (void);
- bool (*stylist_read_db_libconfig_sub) (struct config_setting_t *it, int idx, const char *source);
- bool (*style_change_validate_requirements) (struct map_session_data *sd, int type, int16 idx);
- void (*stylist_send_rodexitem) (struct map_session_data *sd, int itemid);
void (*pReqStyleChange) (int fd, struct map_session_data *sd);
void (*pReqStyleChange2) (int fd, struct map_session_data *sd);
- void (*cz_req_style_change_sub) (struct map_session_data *sd, int type, int16 idx, bool isitem);
void (*style_change_response) (struct map_session_data *sd, enum stylist_shop flag);
void (*pPetEvolution) (int fd, struct map_session_data *sd);
void (*petEvolutionResult) (int fd, enum pet_evolution_result result);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 03f0fdc06..a61bbd008 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -2458,7 +2458,6 @@ static void itemdb_read(bool minimal)
itemdb->read_chains();
itemdb->read_packages();
itemdb->read_options();
- clif->stylist_read_db_libconfig();
}
/**
@@ -2707,7 +2706,6 @@ static void do_final_itemdb(void)
itemdb->destroy_item_data(&itemdb->dummy, 0);
db_destroy(itemdb->names);
VECTOR_CLEAR(clif->attendance_data);
- clif->stylist_vector_clear();
}
static void do_init_itemdb(bool minimal)
@@ -2717,7 +2715,6 @@ static void do_init_itemdb(bool minimal)
itemdb->options = idb_alloc(DB_OPT_RELEASE_DATA);
itemdb->names = strdb_alloc(DB_OPT_BASE,ITEM_NAME_LENGTH);
itemdb->create_dummy_data(); //Dummy data item.
- clif->stylist_vector_init();
itemdb->read(minimal);
if (minimal)
diff --git a/src/map/map.c b/src/map/map.c
index 6212493c8..7d2cc87d4 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -56,6 +56,7 @@
#include "map/skill.h"
#include "map/status.h"
#include "map/storage.h"
+#include "map/stylist.h"
#include "map/rodex.h"
#include "map/trade.h"
#include "map/unit.h"
@@ -6197,6 +6198,7 @@ int do_final(void)
vending->final();
rodex->final();
achievement->final();
+ stylist->final();
HPM_map_do_final();
@@ -6404,6 +6406,7 @@ static void map_load_defaults(void)
achievement_defaults();
npc_chat_defaults();
rodex_defaults();
+ stylist_defaults();
}
/**
* --run-once handler
@@ -6724,6 +6727,7 @@ int do_init(int argc, char *argv[])
duel->init(minimal);
vending->init(minimal);
rodex->init(minimal);
+ stylist->init(minimal);
if (map->scriptcheck) {
bool failed = map->extra_scripts_count > 0 ? false : true;
diff --git a/src/map/stylist.c b/src/map/stylist.c
new file mode 100644
index 000000000..7e7c13bf7
--- /dev/null
+++ b/src/map/stylist.c
@@ -0,0 +1,228 @@
+/**
+* This file is part of Hercules.
+* http://herc.ws - http://github.com/HerculesWS/Hercules
+*
+* Copyright (C) 2018-2019 Hercules Dev Team
+*
+* Hercules is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#define HERCULES_CORE
+
+#include "map/stylist.h"
+
+#include "common/conf.h"
+#include "common/db.h"
+#include "common/memmgr.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+
+#include "map/clif.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/pc.h"
+#include "map/script.h"
+
+static struct stylist_interface stylist_s;
+struct stylist_interface *stylist;
+
+static bool stylist_read_db_libconfig(void)
+{
+ struct config_t stylist_conf;
+ struct config_setting_t *stylist_db = 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_db = libconfig->setting_get_member(stylist_conf.root, "stylist_db")) == NULL) {
+ ShowError("can't read %s\n", config_filename);
+ return false;
+ }
+
+ stylist->vector_clear();
+
+ while ((it = libconfig->setting_get_elem(stylist_db, i++))) {
+ 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 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("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("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("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 stylist_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 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 stylist_request_style_change(struct map_session_data *sd, int type, int16 idx, bool isitem)
+{
+ 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 (stylist->validate_requirements(sd, type, idx - 1)) {
+ if (isitem == false)
+ pc->changelook(sd, type, entry->id);
+ else
+ stylist->send_rodexitem(sd, entry->id);
+ }
+ }
+}
+
+static void stylist_vector_init(void)
+{
+ for (int i = 0; i < MAX_STYLIST_TYPE; i++)
+ VECTOR_INIT(stylist->data[i]);
+}
+static void stylist_vector_clear(void)
+{
+ for (int i = 0; i < MAX_STYLIST_TYPE; i++)
+ VECTOR_CLEAR(stylist->data[i]);
+}
+
+static void do_init_stylist(bool minimal)
+{
+ if (minimal)
+ return;
+
+ // Initialize the db
+ stylist->vector_init();
+
+ // Load the db
+ stylist->read_db_libconfig();
+}
+
+static void do_final_stylist(void)
+{
+ // Clear the db
+ stylist->vector_clear();
+}
+
+void stylist_defaults(void)
+{
+ stylist = &stylist_s;
+
+ /* core */
+ stylist->init = do_init_stylist;
+ stylist->final = do_final_stylist;
+ /* */
+ stylist->vector_init = stylist_vector_init;
+ stylist->vector_clear = stylist_vector_clear;
+ /* database */
+ stylist->read_db_libconfig = stylist_read_db_libconfig;
+ stylist->read_db_libconfig_sub = stylist_read_db_libconfig_sub;
+ /* */
+ stylist->request_style_change = stylist_request_style_change;
+ stylist->validate_requirements = stylist_validate_requirements;
+ stylist->send_rodexitem = stylist_send_rodexitem;
+}
diff --git a/src/map/stylist.h b/src/map/stylist.h
new file mode 100644
index 000000000..5bedfefc7
--- /dev/null
+++ b/src/map/stylist.h
@@ -0,0 +1,69 @@
+/**
+ * This file is part of Hercules.
+ * http://herc.ws - http://github.com/HerculesWS/Hercules
+ *
+ * Copyright (C) 2018-2019 Hercules Dev Team
+ *
+ * Hercules is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef MAP_STYLIST_H
+#define MAP_STYLIST_H
+
+#include "common/hercules.h"
+#include "map/map.h" // LOOK_MAX
+
+struct map_session_data;
+
+/* Maximum available types for stylist */
+#ifndef MAX_STYLIST_TYPE
+#define MAX_STYLIST_TYPE LOOK_MAX
+#endif
+
+/* Stylist data [Asheraf/Hercules]*/
+struct stylist_data_entry {
+ int16 id;
+ int32 zeny;
+ int itemid;
+ int boxid;
+ bool allow_doram;
+};
+
+/**
+ * stylist.c Interface
+ **/
+struct stylist_interface {
+ VECTOR_DECL(struct stylist_data_entry) data[MAX_STYLIST_TYPE];
+
+ void (*init) (bool minimal);
+ void (*final) (void);
+
+ void (*vector_init) (void);
+ void (*vector_clear) (void);
+
+ bool (*read_db_libconfig) (void);
+ bool (*read_db_libconfig_sub) (struct config_setting_t *it, int idx, const char *source);
+
+ void (*request_style_change) (struct map_session_data *sd, int type, int16 idx, bool isitem);
+ bool (*validate_requirements) (struct map_session_data *sd, int type, int16 idx);
+ void (*send_rodexitem) (struct map_session_data *sd, int itemid);
+
+};
+
+#ifdef HERCULES_CORE
+void stylist_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct stylist_interface *stylist; ///< Pointer to the stylist interface.
+
+#endif /* MAP_STYLIST_H */