diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/HPMDataCheck.h | 7 | ||||
-rw-r--r-- | src/common/HPMSymbols.inc.h | 7 | ||||
-rw-r--r-- | src/map/HPMmap.c | 1 | ||||
-rw-r--r-- | src/map/Makefile.in | 4 | ||||
-rw-r--r-- | src/map/clif.c | 192 | ||||
-rw-r--r-- | src/map/clif.h | 21 | ||||
-rw-r--r-- | src/map/itemdb.c | 3 | ||||
-rw-r--r-- | src/map/map.c | 4 | ||||
-rw-r--r-- | src/map/stylist.c | 228 | ||||
-rw-r--r-- | src/map/stylist.h | 69 | ||||
-rw-r--r-- | src/plugins/HPMHooking.c | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Defs.inc | 34 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 65 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 17 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 423 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.sources.inc | 1 |
16 files changed, 638 insertions, 439 deletions
diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index ecbfc9f2c..57b57c345 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -465,7 +465,6 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { { "hCSData", sizeof(struct hCSData), SERVER_TYPE_MAP }, { "merge_item", sizeof(struct merge_item), SERVER_TYPE_MAP }, { "s_packet_db", sizeof(struct s_packet_db), SERVER_TYPE_MAP }, - { "stylist_data_entry", sizeof(struct stylist_data_entry), SERVER_TYPE_MAP }, #else #define MAP_CLIF_H #endif // MAP_CLIF_H @@ -963,6 +962,12 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define MAP_STORAGE_H #endif // MAP_STORAGE_H + #ifdef MAP_STYLIST_H + { "stylist_data_entry", sizeof(struct stylist_data_entry), SERVER_TYPE_MAP }, + { "stylist_interface", sizeof(struct stylist_interface), SERVER_TYPE_MAP }, + #else + #define MAP_STYLIST_H + #endif // MAP_STYLIST_H #ifdef MAP_TRADE_H { "trade_interface", sizeof(struct trade_interface), SERVER_TYPE_MAP }, #else diff --git a/src/common/HPMSymbols.inc.h b/src/common/HPMSymbols.inc.h index 6b02b005a..9410f0586 100644 --- a/src/common/HPMSymbols.inc.h +++ b/src/common/HPMSymbols.inc.h @@ -281,6 +281,9 @@ struct stringbuf_interface *StrBuf; #ifdef COMMON_STRLIB_H /* strlib */ struct strlib_interface *strlib; #endif // COMMON_STRLIB_H +#ifdef MAP_STYLIST_H /* stylist */ +struct stylist_interface *stylist; +#endif // MAP_STYLIST_H #ifdef COMMON_STRLIB_H /* sv */ struct sv_interface *sv; #endif // COMMON_STRLIB_H @@ -646,6 +649,10 @@ HPExport const char *HPM_shared_symbols(int server_type) if ((server_type&(SERVER_TYPE_ALL)) != 0 && !HPM_SYMBOL("strlib", strlib)) return "strlib"; #endif // COMMON_STRLIB_H +#ifdef MAP_STYLIST_H /* stylist */ + if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("stylist", stylist)) + return "stylist"; +#endif // MAP_STYLIST_H #ifdef COMMON_STRLIB_H /* sv */ if ((server_type&(SERVER_TYPE_ALL)) != 0 && !HPM_SYMBOL("sv", sv)) return "sv"; 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 4c8d2df9c..a037d3436 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" @@ -21874,162 +21875,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; } @@ -22040,45 +21902,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 @@ -23460,15 +23303,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 e1fe07dd8..6b501477c 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 @@ -657,16 +653,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; @@ -1578,15 +1564,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 */ diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c index aef09d7a7..f95a3a92d 100644 --- a/src/plugins/HPMHooking.c +++ b/src/plugins/HPMHooking.c @@ -110,6 +110,7 @@ PRAGMA_GCC5(GCC diagnostic ignored "-Wdiscarded-qualifiers") #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 "common/grfio.h" diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index c764d0290..ea9541a40 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -2620,24 +2620,10 @@ typedef void (*HPMHOOK_pre_clif_pPrivateAirshipRequest) (int *fd, struct map_ses typedef void (*HPMHOOK_post_clif_pPrivateAirshipRequest) (int fd, struct map_session_data *sd); typedef void (*HPMHOOK_pre_clif_PrivateAirshipResponse) (struct map_session_data **sd, uint32 *flag); typedef void (*HPMHOOK_post_clif_PrivateAirshipResponse) (struct map_session_data *sd, uint32 flag); -typedef void (*HPMHOOK_pre_clif_stylist_vector_init) (void); -typedef void (*HPMHOOK_post_clif_stylist_vector_init) (void); -typedef void (*HPMHOOK_pre_clif_stylist_vector_clear) (void); -typedef void (*HPMHOOK_post_clif_stylist_vector_clear) (void); -typedef bool (*HPMHOOK_pre_clif_stylist_read_db_libconfig) (void); -typedef bool (*HPMHOOK_post_clif_stylist_read_db_libconfig) (bool retVal___); -typedef bool (*HPMHOOK_pre_clif_stylist_read_db_libconfig_sub) (struct config_setting_t **it, int *idx, const char **source); -typedef bool (*HPMHOOK_post_clif_stylist_read_db_libconfig_sub) (bool retVal___, struct config_setting_t *it, int idx, const char *source); -typedef bool (*HPMHOOK_pre_clif_style_change_validate_requirements) (struct map_session_data **sd, int *type, int16 *idx); -typedef bool (*HPMHOOK_post_clif_style_change_validate_requirements) (bool retVal___, struct map_session_data *sd, int type, int16 idx); -typedef void (*HPMHOOK_pre_clif_stylist_send_rodexitem) (struct map_session_data **sd, int *itemid); -typedef void (*HPMHOOK_post_clif_stylist_send_rodexitem) (struct map_session_data *sd, int itemid); typedef void (*HPMHOOK_pre_clif_pReqStyleChange) (int *fd, struct map_session_data **sd); typedef void (*HPMHOOK_post_clif_pReqStyleChange) (int fd, struct map_session_data *sd); typedef void (*HPMHOOK_pre_clif_pReqStyleChange2) (int *fd, struct map_session_data **sd); typedef void (*HPMHOOK_post_clif_pReqStyleChange2) (int fd, struct map_session_data *sd); -typedef void (*HPMHOOK_pre_clif_cz_req_style_change_sub) (struct map_session_data **sd, int *type, int16 *idx, bool *isitem); -typedef void (*HPMHOOK_post_clif_cz_req_style_change_sub) (struct map_session_data *sd, int type, int16 idx, bool isitem); typedef void (*HPMHOOK_pre_clif_style_change_response) (struct map_session_data **sd, enum stylist_shop *flag); typedef void (*HPMHOOK_post_clif_style_change_response) (struct map_session_data *sd, enum stylist_shop flag); typedef void (*HPMHOOK_pre_clif_pPetEvolution) (int *fd, struct map_session_data **sd); @@ -7971,6 +7957,26 @@ typedef int (*HPMHOOK_post_strlib_strline_) (int retVal___, const char *str, siz typedef bool (*HPMHOOK_pre_strlib_bin2hex_) (char **output, const unsigned char **input, size_t *count); typedef bool (*HPMHOOK_post_strlib_bin2hex_) (bool retVal___, char *output, const unsigned char *input, size_t count); #endif // COMMON_STRLIB_H +#ifdef MAP_STYLIST_H /* stylist */ +typedef void (*HPMHOOK_pre_stylist_init) (bool *minimal); +typedef void (*HPMHOOK_post_stylist_init) (bool minimal); +typedef void (*HPMHOOK_pre_stylist_final) (void); +typedef void (*HPMHOOK_post_stylist_final) (void); +typedef void (*HPMHOOK_pre_stylist_vector_init) (void); +typedef void (*HPMHOOK_post_stylist_vector_init) (void); +typedef void (*HPMHOOK_pre_stylist_vector_clear) (void); +typedef void (*HPMHOOK_post_stylist_vector_clear) (void); +typedef bool (*HPMHOOK_pre_stylist_read_db_libconfig) (void); +typedef bool (*HPMHOOK_post_stylist_read_db_libconfig) (bool retVal___); +typedef bool (*HPMHOOK_pre_stylist_read_db_libconfig_sub) (struct config_setting_t **it, int *idx, const char **source); +typedef bool (*HPMHOOK_post_stylist_read_db_libconfig_sub) (bool retVal___, struct config_setting_t *it, int idx, const char *source); +typedef void (*HPMHOOK_pre_stylist_request_style_change) (struct map_session_data **sd, int *type, int16 *idx, bool *isitem); +typedef void (*HPMHOOK_post_stylist_request_style_change) (struct map_session_data *sd, int type, int16 idx, bool isitem); +typedef bool (*HPMHOOK_pre_stylist_validate_requirements) (struct map_session_data **sd, int *type, int16 *idx); +typedef bool (*HPMHOOK_post_stylist_validate_requirements) (bool retVal___, struct map_session_data *sd, int type, int16 idx); +typedef void (*HPMHOOK_pre_stylist_send_rodexitem) (struct map_session_data **sd, int *itemid); +typedef void (*HPMHOOK_post_stylist_send_rodexitem) (struct map_session_data *sd, int itemid); +#endif // MAP_STYLIST_H #ifdef COMMON_STRLIB_H /* sv */ typedef int (*HPMHOOK_pre_sv_parse_next) (struct s_svstate **svstate); typedef int (*HPMHOOK_post_sv_parse_next) (int retVal___, struct s_svstate *svstate); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 70604ff9e..1a4d5b72a 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -2210,24 +2210,10 @@ struct { struct HPMHookPoint *HP_clif_pPrivateAirshipRequest_post; struct HPMHookPoint *HP_clif_PrivateAirshipResponse_pre; struct HPMHookPoint *HP_clif_PrivateAirshipResponse_post; - struct HPMHookPoint *HP_clif_stylist_vector_init_pre; - struct HPMHookPoint *HP_clif_stylist_vector_init_post; - struct HPMHookPoint *HP_clif_stylist_vector_clear_pre; - struct HPMHookPoint *HP_clif_stylist_vector_clear_post; - struct HPMHookPoint *HP_clif_stylist_read_db_libconfig_pre; - struct HPMHookPoint *HP_clif_stylist_read_db_libconfig_post; - struct HPMHookPoint *HP_clif_stylist_read_db_libconfig_sub_pre; - struct HPMHookPoint *HP_clif_stylist_read_db_libconfig_sub_post; - struct HPMHookPoint *HP_clif_style_change_validate_requirements_pre; - struct HPMHookPoint *HP_clif_style_change_validate_requirements_post; - struct HPMHookPoint *HP_clif_stylist_send_rodexitem_pre; - struct HPMHookPoint *HP_clif_stylist_send_rodexitem_post; struct HPMHookPoint *HP_clif_pReqStyleChange_pre; struct HPMHookPoint *HP_clif_pReqStyleChange_post; struct HPMHookPoint *HP_clif_pReqStyleChange2_pre; struct HPMHookPoint *HP_clif_pReqStyleChange2_post; - struct HPMHookPoint *HP_clif_cz_req_style_change_sub_pre; - struct HPMHookPoint *HP_clif_cz_req_style_change_sub_post; struct HPMHookPoint *HP_clif_style_change_response_pre; struct HPMHookPoint *HP_clif_style_change_response_post; struct HPMHookPoint *HP_clif_pPetEvolution_pre; @@ -6464,6 +6450,24 @@ struct { struct HPMHookPoint *HP_strlib_strline__post; struct HPMHookPoint *HP_strlib_bin2hex__pre; struct HPMHookPoint *HP_strlib_bin2hex__post; + struct HPMHookPoint *HP_stylist_init_pre; + struct HPMHookPoint *HP_stylist_init_post; + struct HPMHookPoint *HP_stylist_final_pre; + struct HPMHookPoint *HP_stylist_final_post; + struct HPMHookPoint *HP_stylist_vector_init_pre; + struct HPMHookPoint *HP_stylist_vector_init_post; + struct HPMHookPoint *HP_stylist_vector_clear_pre; + struct HPMHookPoint *HP_stylist_vector_clear_post; + struct HPMHookPoint *HP_stylist_read_db_libconfig_pre; + struct HPMHookPoint *HP_stylist_read_db_libconfig_post; + struct HPMHookPoint *HP_stylist_read_db_libconfig_sub_pre; + struct HPMHookPoint *HP_stylist_read_db_libconfig_sub_post; + struct HPMHookPoint *HP_stylist_request_style_change_pre; + struct HPMHookPoint *HP_stylist_request_style_change_post; + struct HPMHookPoint *HP_stylist_validate_requirements_pre; + struct HPMHookPoint *HP_stylist_validate_requirements_post; + struct HPMHookPoint *HP_stylist_send_rodexitem_pre; + struct HPMHookPoint *HP_stylist_send_rodexitem_post; struct HPMHookPoint *HP_sv_parse_next_pre; struct HPMHookPoint *HP_sv_parse_next_post; struct HPMHookPoint *HP_sv_parse_pre; @@ -8881,24 +8885,10 @@ struct { int HP_clif_pPrivateAirshipRequest_post; int HP_clif_PrivateAirshipResponse_pre; int HP_clif_PrivateAirshipResponse_post; - int HP_clif_stylist_vector_init_pre; - int HP_clif_stylist_vector_init_post; - int HP_clif_stylist_vector_clear_pre; - int HP_clif_stylist_vector_clear_post; - int HP_clif_stylist_read_db_libconfig_pre; - int HP_clif_stylist_read_db_libconfig_post; - int HP_clif_stylist_read_db_libconfig_sub_pre; - int HP_clif_stylist_read_db_libconfig_sub_post; - int HP_clif_style_change_validate_requirements_pre; - int HP_clif_style_change_validate_requirements_post; - int HP_clif_stylist_send_rodexitem_pre; - int HP_clif_stylist_send_rodexitem_post; int HP_clif_pReqStyleChange_pre; int HP_clif_pReqStyleChange_post; int HP_clif_pReqStyleChange2_pre; int HP_clif_pReqStyleChange2_post; - int HP_clif_cz_req_style_change_sub_pre; - int HP_clif_cz_req_style_change_sub_post; int HP_clif_style_change_response_pre; int HP_clif_style_change_response_post; int HP_clif_pPetEvolution_pre; @@ -13135,6 +13125,24 @@ struct { int HP_strlib_strline__post; int HP_strlib_bin2hex__pre; int HP_strlib_bin2hex__post; + int HP_stylist_init_pre; + int HP_stylist_init_post; + int HP_stylist_final_pre; + int HP_stylist_final_post; + int HP_stylist_vector_init_pre; + int HP_stylist_vector_init_post; + int HP_stylist_vector_clear_pre; + int HP_stylist_vector_clear_post; + int HP_stylist_read_db_libconfig_pre; + int HP_stylist_read_db_libconfig_post; + int HP_stylist_read_db_libconfig_sub_pre; + int HP_stylist_read_db_libconfig_sub_post; + int HP_stylist_request_style_change_pre; + int HP_stylist_request_style_change_post; + int HP_stylist_validate_requirements_pre; + int HP_stylist_validate_requirements_post; + int HP_stylist_send_rodexitem_pre; + int HP_stylist_send_rodexitem_post; int HP_sv_parse_next_pre; int HP_sv_parse_next_post; int HP_sv_parse_pre; @@ -13428,6 +13436,7 @@ struct { struct storage_interface storage; struct stringbuf_interface StrBuf; struct strlib_interface strlib; + struct stylist_interface stylist; struct sv_interface sv; struct sysinfo_interface sysinfo; struct thread_interface thread; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index f081fd520..da93da520 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -1129,15 +1129,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->ui_action, HP_clif_ui_action) }, { HP_POP(clif->pPrivateAirshipRequest, HP_clif_pPrivateAirshipRequest) }, { HP_POP(clif->PrivateAirshipResponse, HP_clif_PrivateAirshipResponse) }, - { HP_POP(clif->stylist_vector_init, HP_clif_stylist_vector_init) }, - { HP_POP(clif->stylist_vector_clear, HP_clif_stylist_vector_clear) }, - { HP_POP(clif->stylist_read_db_libconfig, HP_clif_stylist_read_db_libconfig) }, - { HP_POP(clif->stylist_read_db_libconfig_sub, HP_clif_stylist_read_db_libconfig_sub) }, - { HP_POP(clif->style_change_validate_requirements, HP_clif_style_change_validate_requirements) }, - { HP_POP(clif->stylist_send_rodexitem, HP_clif_stylist_send_rodexitem) }, { HP_POP(clif->pReqStyleChange, HP_clif_pReqStyleChange) }, { HP_POP(clif->pReqStyleChange2, HP_clif_pReqStyleChange2) }, - { HP_POP(clif->cz_req_style_change_sub, HP_clif_cz_req_style_change_sub) }, { HP_POP(clif->style_change_response, HP_clif_style_change_response) }, { HP_POP(clif->pPetEvolution, HP_clif_pPetEvolution) }, { HP_POP(clif->petEvolutionResult, HP_clif_petEvolutionResult) }, @@ -3305,6 +3298,16 @@ struct HookingPointData HookingPoints[] = { { HP_POP(strlib->safestrnlen_, HP_strlib_safestrnlen_) }, { HP_POP(strlib->strline_, HP_strlib_strline_) }, { HP_POP(strlib->bin2hex_, HP_strlib_bin2hex_) }, +/* stylist_interface */ + { HP_POP(stylist->init, HP_stylist_init) }, + { HP_POP(stylist->final, HP_stylist_final) }, + { HP_POP(stylist->vector_init, HP_stylist_vector_init) }, + { HP_POP(stylist->vector_clear, HP_stylist_vector_clear) }, + { HP_POP(stylist->read_db_libconfig, HP_stylist_read_db_libconfig) }, + { HP_POP(stylist->read_db_libconfig_sub, HP_stylist_read_db_libconfig_sub) }, + { HP_POP(stylist->request_style_change, HP_stylist_request_style_change) }, + { HP_POP(stylist->validate_requirements, HP_stylist_validate_requirements) }, + { HP_POP(stylist->send_rodexitem, HP_stylist_send_rodexitem) }, /* sv_interface */ { HP_POP(sv->parse_next, HP_sv_parse_next) }, { HP_POP(sv->parse, HP_sv_parse) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index d18b4f360..42ed2f96f 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -28806,165 +28806,6 @@ void HP_clif_PrivateAirshipResponse(struct map_session_data *sd, uint32 flag) { } return; } -void HP_clif_stylist_vector_init(void) { - int hIndex = 0; - if (HPMHooks.count.HP_clif_stylist_vector_init_pre > 0) { - void (*preHookFunc) (void); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_vector_init_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_clif_stylist_vector_init_pre[hIndex].func; - preHookFunc(); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.clif.stylist_vector_init(); - } - if (HPMHooks.count.HP_clif_stylist_vector_init_post > 0) { - void (*postHookFunc) (void); - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_vector_init_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_clif_stylist_vector_init_post[hIndex].func; - postHookFunc(); - } - } - return; -} -void HP_clif_stylist_vector_clear(void) { - int hIndex = 0; - if (HPMHooks.count.HP_clif_stylist_vector_clear_pre > 0) { - void (*preHookFunc) (void); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_vector_clear_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_clif_stylist_vector_clear_pre[hIndex].func; - preHookFunc(); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.clif.stylist_vector_clear(); - } - if (HPMHooks.count.HP_clif_stylist_vector_clear_post > 0) { - void (*postHookFunc) (void); - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_vector_clear_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_clif_stylist_vector_clear_post[hIndex].func; - postHookFunc(); - } - } - return; -} -bool HP_clif_stylist_read_db_libconfig(void) { - int hIndex = 0; - bool retVal___ = false; - if (HPMHooks.count.HP_clif_stylist_read_db_libconfig_pre > 0) { - bool (*preHookFunc) (void); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_read_db_libconfig_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_clif_stylist_read_db_libconfig_pre[hIndex].func; - retVal___ = preHookFunc(); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return retVal___; - } - } - { - retVal___ = HPMHooks.source.clif.stylist_read_db_libconfig(); - } - if (HPMHooks.count.HP_clif_stylist_read_db_libconfig_post > 0) { - bool (*postHookFunc) (bool retVal___); - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_read_db_libconfig_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_clif_stylist_read_db_libconfig_post[hIndex].func; - retVal___ = postHookFunc(retVal___); - } - } - return retVal___; -} -bool HP_clif_stylist_read_db_libconfig_sub(struct config_setting_t *it, int idx, const char *source) { - int hIndex = 0; - bool retVal___ = false; - if (HPMHooks.count.HP_clif_stylist_read_db_libconfig_sub_pre > 0) { - bool (*preHookFunc) (struct config_setting_t **it, int *idx, const char **source); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_read_db_libconfig_sub_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_clif_stylist_read_db_libconfig_sub_pre[hIndex].func; - retVal___ = preHookFunc(&it, &idx, &source); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return retVal___; - } - } - { - retVal___ = HPMHooks.source.clif.stylist_read_db_libconfig_sub(it, idx, source); - } - if (HPMHooks.count.HP_clif_stylist_read_db_libconfig_sub_post > 0) { - bool (*postHookFunc) (bool retVal___, struct config_setting_t *it, int idx, const char *source); - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_read_db_libconfig_sub_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_clif_stylist_read_db_libconfig_sub_post[hIndex].func; - retVal___ = postHookFunc(retVal___, it, idx, source); - } - } - return retVal___; -} -bool HP_clif_style_change_validate_requirements(struct map_session_data *sd, int type, int16 idx) { - int hIndex = 0; - bool retVal___ = false; - if (HPMHooks.count.HP_clif_style_change_validate_requirements_pre > 0) { - bool (*preHookFunc) (struct map_session_data **sd, int *type, int16 *idx); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_style_change_validate_requirements_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_clif_style_change_validate_requirements_pre[hIndex].func; - retVal___ = preHookFunc(&sd, &type, &idx); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return retVal___; - } - } - { - retVal___ = HPMHooks.source.clif.style_change_validate_requirements(sd, type, idx); - } - if (HPMHooks.count.HP_clif_style_change_validate_requirements_post > 0) { - bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, int type, int16 idx); - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_style_change_validate_requirements_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_clif_style_change_validate_requirements_post[hIndex].func; - retVal___ = postHookFunc(retVal___, sd, type, idx); - } - } - return retVal___; -} -void HP_clif_stylist_send_rodexitem(struct map_session_data *sd, int itemid) { - int hIndex = 0; - if (HPMHooks.count.HP_clif_stylist_send_rodexitem_pre > 0) { - void (*preHookFunc) (struct map_session_data **sd, int *itemid); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_send_rodexitem_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_clif_stylist_send_rodexitem_pre[hIndex].func; - preHookFunc(&sd, &itemid); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.clif.stylist_send_rodexitem(sd, itemid); - } - if (HPMHooks.count.HP_clif_stylist_send_rodexitem_post > 0) { - void (*postHookFunc) (struct map_session_data *sd, int itemid); - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_stylist_send_rodexitem_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_clif_stylist_send_rodexitem_post[hIndex].func; - postHookFunc(sd, itemid); - } - } - return; -} void HP_clif_pReqStyleChange(int fd, struct map_session_data *sd) { int hIndex = 0; if (HPMHooks.count.HP_clif_pReqStyleChange_pre > 0) { @@ -29017,32 +28858,6 @@ void HP_clif_pReqStyleChange2(int fd, struct map_session_data *sd) { } return; } -void HP_clif_cz_req_style_change_sub(struct map_session_data *sd, int type, int16 idx, bool isitem) { - int hIndex = 0; - if (HPMHooks.count.HP_clif_cz_req_style_change_sub_pre > 0) { - void (*preHookFunc) (struct map_session_data **sd, int *type, int16 *idx, bool *isitem); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_cz_req_style_change_sub_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_clif_cz_req_style_change_sub_pre[hIndex].func; - preHookFunc(&sd, &type, &idx, &isitem); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.clif.cz_req_style_change_sub(sd, type, idx, isitem); - } - if (HPMHooks.count.HP_clif_cz_req_style_change_sub_post > 0) { - void (*postHookFunc) (struct map_session_data *sd, int type, int16 idx, bool isitem); - for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_cz_req_style_change_sub_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_clif_cz_req_style_change_sub_post[hIndex].func; - postHookFunc(sd, type, idx, isitem); - } - } - return; -} void HP_clif_style_change_response(struct map_session_data *sd, enum stylist_shop flag) { int hIndex = 0; if (HPMHooks.count.HP_clif_style_change_response_pre > 0) { @@ -86515,6 +86330,244 @@ bool HP_strlib_bin2hex_(char *output, const unsigned char *input, size_t count) } return retVal___; } +/* stylist_interface */ +void HP_stylist_init(bool minimal) { + int hIndex = 0; + if (HPMHooks.count.HP_stylist_init_pre > 0) { + void (*preHookFunc) (bool *minimal); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_init_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_init_pre[hIndex].func; + preHookFunc(&minimal); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.stylist.init(minimal); + } + if (HPMHooks.count.HP_stylist_init_post > 0) { + void (*postHookFunc) (bool minimal); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_init_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_init_post[hIndex].func; + postHookFunc(minimal); + } + } + return; +} +void HP_stylist_final(void) { + int hIndex = 0; + if (HPMHooks.count.HP_stylist_final_pre > 0) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_final_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_final_pre[hIndex].func; + preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.stylist.final(); + } + if (HPMHooks.count.HP_stylist_final_post > 0) { + void (*postHookFunc) (void); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_final_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_stylist_vector_init(void) { + int hIndex = 0; + if (HPMHooks.count.HP_stylist_vector_init_pre > 0) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_vector_init_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_vector_init_pre[hIndex].func; + preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.stylist.vector_init(); + } + if (HPMHooks.count.HP_stylist_vector_init_post > 0) { + void (*postHookFunc) (void); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_vector_init_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_vector_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_stylist_vector_clear(void) { + int hIndex = 0; + if (HPMHooks.count.HP_stylist_vector_clear_pre > 0) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_vector_clear_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_vector_clear_pre[hIndex].func; + preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.stylist.vector_clear(); + } + if (HPMHooks.count.HP_stylist_vector_clear_post > 0) { + void (*postHookFunc) (void); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_vector_clear_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_vector_clear_post[hIndex].func; + postHookFunc(); + } + } + return; +} +bool HP_stylist_read_db_libconfig(void) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_stylist_read_db_libconfig_pre > 0) { + bool (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_read_db_libconfig_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_read_db_libconfig_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.stylist.read_db_libconfig(); + } + if (HPMHooks.count.HP_stylist_read_db_libconfig_post > 0) { + bool (*postHookFunc) (bool retVal___); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_read_db_libconfig_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_read_db_libconfig_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_stylist_read_db_libconfig_sub(struct config_setting_t *it, int idx, const char *source) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_stylist_read_db_libconfig_sub_pre > 0) { + bool (*preHookFunc) (struct config_setting_t **it, int *idx, const char **source); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_read_db_libconfig_sub_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_read_db_libconfig_sub_pre[hIndex].func; + retVal___ = preHookFunc(&it, &idx, &source); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.stylist.read_db_libconfig_sub(it, idx, source); + } + if (HPMHooks.count.HP_stylist_read_db_libconfig_sub_post > 0) { + bool (*postHookFunc) (bool retVal___, struct config_setting_t *it, int idx, const char *source); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_read_db_libconfig_sub_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_read_db_libconfig_sub_post[hIndex].func; + retVal___ = postHookFunc(retVal___, it, idx, source); + } + } + return retVal___; +} +void HP_stylist_request_style_change(struct map_session_data *sd, int type, int16 idx, bool isitem) { + int hIndex = 0; + if (HPMHooks.count.HP_stylist_request_style_change_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, int *type, int16 *idx, bool *isitem); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_request_style_change_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_request_style_change_pre[hIndex].func; + preHookFunc(&sd, &type, &idx, &isitem); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.stylist.request_style_change(sd, type, idx, isitem); + } + if (HPMHooks.count.HP_stylist_request_style_change_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, int type, int16 idx, bool isitem); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_request_style_change_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_request_style_change_post[hIndex].func; + postHookFunc(sd, type, idx, isitem); + } + } + return; +} +bool HP_stylist_validate_requirements(struct map_session_data *sd, int type, int16 idx) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_stylist_validate_requirements_pre > 0) { + bool (*preHookFunc) (struct map_session_data **sd, int *type, int16 *idx); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_validate_requirements_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_validate_requirements_pre[hIndex].func; + retVal___ = preHookFunc(&sd, &type, &idx); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.stylist.validate_requirements(sd, type, idx); + } + if (HPMHooks.count.HP_stylist_validate_requirements_post > 0) { + bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, int type, int16 idx); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_validate_requirements_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_validate_requirements_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd, type, idx); + } + } + return retVal___; +} +void HP_stylist_send_rodexitem(struct map_session_data *sd, int itemid) { + int hIndex = 0; + if (HPMHooks.count.HP_stylist_send_rodexitem_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, int *itemid); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_send_rodexitem_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_stylist_send_rodexitem_pre[hIndex].func; + preHookFunc(&sd, &itemid); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.stylist.send_rodexitem(sd, itemid); + } + if (HPMHooks.count.HP_stylist_send_rodexitem_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, int itemid); + for (hIndex = 0; hIndex < HPMHooks.count.HP_stylist_send_rodexitem_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_stylist_send_rodexitem_post[hIndex].func; + postHookFunc(sd, itemid); + } + } + return; +} /* sv_interface */ int HP_sv_parse_next(struct s_svstate *svstate) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_map.sources.inc b/src/plugins/HPMHooking/HPMHooking_map.sources.inc index 7a3c5b9a7..59ee43ab7 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.sources.inc @@ -85,6 +85,7 @@ HPMHooks.source.status = *status; HPMHooks.source.storage = *storage; HPMHooks.source.StrBuf = *StrBuf; HPMHooks.source.strlib = *strlib; +HPMHooks.source.stylist = *stylist; HPMHooks.source.sv = *sv; HPMHooks.source.sysinfo = *sysinfo; HPMHooks.source.thread = *thread; |