diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 3 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 79 | ||||
-rw-r--r-- | src/plugins/constdb2doc.c | 197 |
4 files changed, 291 insertions, 0 deletions
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index e0c5a4df3..f5ac1e70a 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -1848,6 +1848,8 @@ struct { struct HPMHookPoint *HP_clif_pHotkeyRowShift_post; struct HPMHookPoint *HP_clif_dressroom_open_pre; struct HPMHookPoint *HP_clif_dressroom_open_post; + struct HPMHookPoint *HP_clif_pOneClick_ItemIdentify_pre; + struct HPMHookPoint *HP_clif_pOneClick_ItemIdentify_post; struct HPMHookPoint *HP_clif_selectcart_pre; struct HPMHookPoint *HP_clif_selectcart_post; struct HPMHookPoint *HP_clif_pSelectCart_pre; @@ -4322,6 +4324,8 @@ struct { struct HPMHookPoint *HP_pc_check_job_name_post; struct HPMHookPoint *HP_pc_update_idle_time_pre; struct HPMHookPoint *HP_pc_update_idle_time_post; + struct HPMHookPoint *HP_pc_have_magnifier_pre; + struct HPMHookPoint *HP_pc_have_magnifier_post; struct HPMHookPoint *HP_libpcre_compile_pre; struct HPMHookPoint *HP_libpcre_compile_post; struct HPMHookPoint *HP_libpcre_study_pre; @@ -4624,6 +4628,8 @@ struct { struct HPMHookPoint *HP_script_parse_line_post; struct HPMHookPoint *HP_script_read_constdb_pre; struct HPMHookPoint *HP_script_read_constdb_post; + struct HPMHookPoint *HP_script_constdb_comment_pre; + struct HPMHookPoint *HP_script_constdb_comment_post; struct HPMHookPoint *HP_script_print_line_pre; struct HPMHookPoint *HP_script_print_line_post; struct HPMHookPoint *HP_script_errorwarning_sub_pre; @@ -7689,6 +7695,8 @@ struct { int HP_clif_pHotkeyRowShift_post; int HP_clif_dressroom_open_pre; int HP_clif_dressroom_open_post; + int HP_clif_pOneClick_ItemIdentify_pre; + int HP_clif_pOneClick_ItemIdentify_post; int HP_clif_selectcart_pre; int HP_clif_selectcart_post; int HP_clif_pSelectCart_pre; @@ -10163,6 +10171,8 @@ struct { int HP_pc_check_job_name_post; int HP_pc_update_idle_time_pre; int HP_pc_update_idle_time_post; + int HP_pc_have_magnifier_pre; + int HP_pc_have_magnifier_post; int HP_libpcre_compile_pre; int HP_libpcre_compile_post; int HP_libpcre_study_pre; @@ -10465,6 +10475,8 @@ struct { int HP_script_parse_line_post; int HP_script_read_constdb_pre; int HP_script_read_constdb_post; + int HP_script_constdb_comment_pre; + int HP_script_constdb_comment_post; int HP_script_print_line_pre; int HP_script_print_line_post; int HP_script_errorwarning_sub_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 5bbad878a..f7ee233c3 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -944,6 +944,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->add_random_options, HP_clif_add_random_options) }, { HP_POP(clif->pHotkeyRowShift, HP_clif_pHotkeyRowShift) }, { HP_POP(clif->dressroom_open, HP_clif_dressroom_open) }, + { HP_POP(clif->pOneClick_ItemIdentify, HP_clif_pOneClick_ItemIdentify) }, { HP_POP(clif->selectcart, HP_clif_selectcart) }, { HP_POP(clif->pSelectCart, HP_clif_pSelectCart) }, /* cmdline */ @@ -2211,6 +2212,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pc->autotrade_final, HP_pc_autotrade_final) }, { HP_POP(pc->check_job_name, HP_pc_check_job_name) }, { HP_POP(pc->update_idle_time, HP_pc_update_idle_time) }, + { HP_POP(pc->have_magnifier, HP_pc_have_magnifier) }, /* libpcre */ { HP_POP(libpcre->compile, HP_libpcre_compile) }, { HP_POP(libpcre->study, HP_libpcre_study) }, @@ -2366,6 +2368,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(script->parse_expr, HP_script_parse_expr) }, { HP_POP(script->parse_line, HP_script_parse_line) }, { HP_POP(script->read_constdb, HP_script_read_constdb) }, + { HP_POP(script->constdb_comment, HP_script_constdb_comment) }, { HP_POP(script->print_line, HP_script_print_line) }, { HP_POP(script->errorwarning_sub, HP_script_errorwarning_sub) }, { HP_POP(script->set_reg, HP_script_set_reg) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 87d85cc6c..5dfdb8c2a 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -24067,6 +24067,32 @@ void HP_clif_dressroom_open(struct map_session_data *sd, int view) { } return; } +void HP_clif_pOneClick_ItemIdentify(int fd, struct map_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_clif_pOneClick_ItemIdentify_pre ) { + void (*preHookFunc) (int *fd, struct map_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pOneClick_ItemIdentify_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_pOneClick_ItemIdentify_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.pOneClick_ItemIdentify(fd, sd); + } + if( HPMHooks.count.HP_clif_pOneClick_ItemIdentify_post ) { + void (*postHookFunc) (int *fd, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pOneClick_ItemIdentify_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_pOneClick_ItemIdentify_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} void HP_clif_selectcart(struct map_session_data *sd) { int hIndex = 0; if( HPMHooks.count.HP_clif_selectcart_pre ) { @@ -57623,6 +57649,33 @@ void HP_pc_update_idle_time(struct map_session_data *sd, enum e_battle_config_id } return; } +int HP_pc_have_magnifier(struct map_session_data *sd) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_pc_have_magnifier_pre ) { + int (*preHookFunc) (struct map_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_have_magnifier_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_pc_have_magnifier_pre[hIndex].func; + retVal___ = preHookFunc(sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.pc.have_magnifier(sd); + } + if( HPMHooks.count.HP_pc_have_magnifier_post ) { + int (*postHookFunc) (int retVal___, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_have_magnifier_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_pc_have_magnifier_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd); + } + } + return retVal___; +} /* libpcre */ pcre* HP_libpcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, const unsigned char *tableptr) { int hIndex = 0; @@ -61678,6 +61731,32 @@ void HP_script_read_constdb(void) { } return; } +void HP_script_constdb_comment(const char *comment) { + int hIndex = 0; + if( HPMHooks.count.HP_script_constdb_comment_pre ) { + void (*preHookFunc) (const char *comment); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_constdb_comment_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_constdb_comment_pre[hIndex].func; + preHookFunc(comment); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.script.constdb_comment(comment); + } + if( HPMHooks.count.HP_script_constdb_comment_post ) { + void (*postHookFunc) (const char *comment); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_constdb_comment_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_constdb_comment_post[hIndex].func; + postHookFunc(comment); + } + } + return; +} const char* HP_script_print_line(StringBuf *buf, const char *p, const char *mark, int line) { int hIndex = 0; const char* retVal___ = NULL; diff --git a/src/plugins/constdb2doc.c b/src/plugins/constdb2doc.c new file mode 100644 index 000000000..1d5f37ad5 --- /dev/null +++ b/src/plugins/constdb2doc.c @@ -0,0 +1,197 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2016 Hercules Dev Team + * Copyright (C) 2016 Haru <haru@dotalux.com> + * + * 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/>. + */ + +/// db/constants.conf -> doc/constants.md generator plugin + +#include "common/hercules.h" +//#include "common/memmgr.h" +#include "common/nullpo.h" +#include "common/strlib.h" +#include "map/itemdb.h" +#include "map/mob.h" +#include "map/script.h" +#include "map/skill.h" + +#include "common/HPMDataCheck.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <sys/stat.h> + +#define OUTPUTFILENAME "doc" PATHSEP_STR "constants.md" + +HPExport struct hplugin_info pinfo = { + "constdb2doc", // Plugin name + SERVER_TYPE_MAP, // Which server types this plugin works with? + "0.1", // Plugin version + HPM_VERSION, // HPM Version (don't change, macro is automatically updated) +}; + +FILE *out_fp; +bool torun = false; + +/// To override script_constdb_comment +void constdb2doc_constdb_comment(const char *comment) +{ + nullpo_retv(out_fp); + if (comment == NULL) + fprintf(out_fp, "\n"); + else + fprintf(out_fp, "\n### %s\n\n", comment); +} + +/// To override script_set_constant, called by script_read_constdb +void constdb2doc_script_set_constant(const char *name, int value, bool is_parameter, bool is_deprecated) +{ + nullpo_retv(out_fp); + + if (is_parameter) + fprintf(out_fp, "- `%s`: [param]%s\n", name, is_deprecated ? " **(DEPRECATED)**" : ""); + else + fprintf(out_fp, "- `%s`: %d%s\n", name, value, is_deprecated ? " **(DEPRECATED)**" : ""); +} + +void constdb2doc_constdb(void) +{ + void (*script_set_constant) (const char* name, int value, bool is_parameter, bool is_deprecated) = NULL; + void (*script_constdb_comment) (const char *comment) = NULL; + + nullpo_retv(out_fp); + + /* Link */ + script_set_constant = script->set_constant; + script->set_constant = constdb2doc_script_set_constant; + script_constdb_comment = script->constdb_comment; + script->constdb_comment = constdb2doc_constdb_comment; + + /* Run */ + fprintf(out_fp, "## Constants (db/constants.conf)\n\n"); + script->read_constdb(); + fprintf(out_fp, "\n"); + + fprintf(out_fp, "## Hardcoded Constants (source)\n\n"); + script->hardcoded_constants(); + fprintf(out_fp, "\n"); + + /* Unlink */ + script->set_constant = script_set_constant; + script->constdb_comment = script_constdb_comment; +} + +void constdb2doc_skilldb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Skills (db/"DBPATH"skill_db.txt)\n\n"); + for (i = 1; i < MAX_SKILL_DB; i++) { + if (skill->dbs->db[i].name[0] != '\0') + fprintf(out_fp, "- `%s`: %d\n", skill->dbs->db[i].name, skill->dbs->db[i].nameid); + } + fprintf(out_fp, "\n"); +} + +void constdb2doc_mobdb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Mobs (db/"DBPATH"mob_db.txt)\n\n"); + for (i = 0; i < MAX_MOB_DB; i++) { + struct mob_db *md = mob->db(i); + if (md == mob->dummy || md->sprite[0] == '\0') + continue; + fprintf(out_fp, "- `%s`: %d\n", md->sprite, i); + } + fprintf(out_fp, "\n"); +} + +/// Cloned from itemdb_search +struct item_data *constdb2doc_itemdb_search(int nameid) +{ + if (nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array)) + return itemdb->array[nameid]; + + return idb_get(itemdb->other, nameid); +} + +void constdb2doc_itemdb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Items (db/"DBPATH"item_db.conf)\n"); + for (i = 0; i < ARRAYLENGTH(itemdb->array); i++) { + struct item_data *id = constdb2doc_itemdb_search(i); + if (id == NULL || id->name[0] == '\0') + continue; + fprintf(out_fp, "- `%s`: %d\n", id->name, id->nameid); + } + fprintf(out_fp, "\n"); +} + +void do_constdb2doc(void) +{ + /* File Type Detector */ + if ((out_fp = fopen(OUTPUTFILENAME, "wt+")) == NULL) { + ShowError("do_constdb2doc: Unable to open output file.\n"); + return; + } + + fprintf(out_fp, + "# Constants\n\n" + "> This document contains all the constants available to the script engine.\n\n"); + + constdb2doc_constdb(); + + constdb2doc_skilldb(); + + constdb2doc_mobdb(); + + constdb2doc_itemdb(); + + fprintf(out_fp, "> End of list\n"); + + fclose(out_fp); +} +CPCMD(constdb2doc) { + do_constdb2doc(); +} +CMDLINEARG(constdb2doc) +{ + map->minimal = torun = true; + return true; +} +HPExport void server_preinit(void) { + addArg("--constdb2doc", false, constdb2doc, NULL); +} +HPExport void plugin_init(void) { + addCPCommand("server:tools:constdb2doc", constdb2doc); +} +HPExport void server_online(void) { + if (torun) + do_constdb2doc(); +} |