diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Defs.inc | 14 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.Hooks.inc | 12 | ||||
-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 | 90 | ||||
-rw-r--r-- | src/plugins/mapcache.c | 106 |
6 files changed, 221 insertions, 16 deletions
diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 9b4b88f17..da70abc12 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -1692,6 +1692,8 @@ typedef void (*HPMHOOK_pre_clif_quest_update_status) (struct map_session_data ** typedef void (*HPMHOOK_post_clif_quest_update_status) (struct map_session_data *sd, int quest_id, bool active); typedef void (*HPMHOOK_pre_clif_quest_update_objective) (struct map_session_data **sd, struct quest **qd); typedef void (*HPMHOOK_post_clif_quest_update_objective) (struct map_session_data *sd, struct quest *qd); +typedef void (*HPMHOOK_pre_clif_quest_notify_objective) (struct map_session_data **sd, struct quest **qd); +typedef void (*HPMHOOK_post_clif_quest_notify_objective) (struct map_session_data *sd, struct quest *qd); typedef void (*HPMHOOK_pre_clif_quest_show_event) (struct map_session_data **sd, struct block_list **bl, short *state, short *color); typedef void (*HPMHOOK_post_clif_quest_show_event) (struct map_session_data *sd, struct block_list *bl, short state, short color); typedef void (*HPMHOOK_pre_clif_mail_window) (int *fd, int *flag); @@ -2358,8 +2360,8 @@ typedef void (*HPMHOOK_pre_clif_rodex_send_maillist) (int *fd, struct map_sessio typedef void (*HPMHOOK_post_clif_rodex_send_maillist) (int fd, struct map_session_data *sd, int8 open_type, int64 page_start); typedef void (*HPMHOOK_pre_clif_rodex_send_refresh) (int *fd, struct map_session_data **sd, int8 *open_type, int *count); typedef void (*HPMHOOK_post_clif_rodex_send_refresh) (int fd, struct map_session_data *sd, int8 open_type, int count); -typedef void (*HPMHOOK_pre_clif_rodex_send_mails_all) (int *fd, struct map_session_data **sd); -typedef void (*HPMHOOK_post_clif_rodex_send_mails_all) (int fd, struct map_session_data *sd); +typedef void (*HPMHOOK_pre_clif_rodex_send_mails_all) (int *fd, struct map_session_data **sd, int64 *mail_id); +typedef void (*HPMHOOK_post_clif_rodex_send_mails_all) (int fd, struct map_session_data *sd, int64 mail_id); typedef void (*HPMHOOK_pre_clif_pRodexReadMail) (int *fd, struct map_session_data **sd); typedef void (*HPMHOOK_post_clif_pRodexReadMail) (int fd, struct map_session_data *sd); typedef void (*HPMHOOK_pre_clif_rodex_read_mail) (struct map_session_data **sd, int8 *opentype, struct rodex_message **msg); @@ -2404,6 +2406,10 @@ typedef void (*HPMHOOK_pre_clif_clan_message) (struct clan **c, const char **mes typedef void (*HPMHOOK_post_clif_clan_message) (struct clan *c, const char *mes, int len); typedef void (*HPMHOOK_pre_clif_pClanMessage) (int *fd, struct map_session_data **sd); typedef void (*HPMHOOK_post_clif_pClanMessage) (int fd, struct map_session_data *sd); +typedef void (*HPMHOOK_pre_clif_hat_effect) (struct block_list **bl, struct block_list **tbl, enum send_target *target); +typedef void (*HPMHOOK_post_clif_hat_effect) (struct block_list *bl, struct block_list *tbl, enum send_target target); +typedef void (*HPMHOOK_pre_clif_hat_effect_single) (struct block_list **bl, uint16 *effectId, bool *enable); +typedef void (*HPMHOOK_post_clif_hat_effect_single) (struct block_list *bl, uint16 effectId, bool enable); #endif // MAP_CLIF_H #ifdef COMMON_CORE_H /* cmdline */ typedef void (*HPMHOOK_pre_cmdline_init) (void); @@ -4662,8 +4668,8 @@ typedef int (*HPMHOOK_pre_mapif_parse_quest_load) (int *fd); typedef int (*HPMHOOK_post_mapif_parse_quest_load) (int retVal___, int fd); typedef int (*HPMHOOK_pre_mapif_parse_rodex_requestinbox) (int *fd); typedef int (*HPMHOOK_post_mapif_parse_rodex_requestinbox) (int retVal___, int fd); -typedef void (*HPMHOOK_pre_mapif_rodex_sendinbox) (int *fd, int *char_id, int8 *opentype, int8 *flag, int *count, struct rodex_maillist **mails); -typedef void (*HPMHOOK_post_mapif_rodex_sendinbox) (int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails); +typedef void (*HPMHOOK_pre_mapif_rodex_sendinbox) (int *fd, int *char_id, int8 *opentype, int8 *flag, int *count, int64 *mail_id, struct rodex_maillist **mails); +typedef void (*HPMHOOK_post_mapif_rodex_sendinbox) (int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails); typedef int (*HPMHOOK_pre_mapif_parse_rodex_checkhasnew) (int *fd); typedef int (*HPMHOOK_post_mapif_parse_rodex_checkhasnew) (int retVal___, int fd); typedef void (*HPMHOOK_pre_mapif_rodex_sendhasnew) (int *fd, int *char_id, bool *has_new); diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index cfd6caee1..6ea10f78f 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -14647,14 +14647,14 @@ int HP_mapif_parse_rodex_requestinbox(int fd) { } return retVal___; } -void HP_mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails) { +void HP_mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails) { int hIndex = 0; if (HPMHooks.count.HP_mapif_rodex_sendinbox_pre > 0) { - void (*preHookFunc) (int *fd, int *char_id, int8 *opentype, int8 *flag, int *count, struct rodex_maillist **mails); + void (*preHookFunc) (int *fd, int *char_id, int8 *opentype, int8 *flag, int *count, int64 *mail_id, struct rodex_maillist **mails); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_mapif_rodex_sendinbox_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_mapif_rodex_sendinbox_pre[hIndex].func; - preHookFunc(&fd, &char_id, &opentype, &flag, &count, &mails); + preHookFunc(&fd, &char_id, &opentype, &flag, &count, &mail_id, &mails); } if (*HPMforce_return) { *HPMforce_return = false; @@ -14662,13 +14662,13 @@ void HP_mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int } } { - HPMHooks.source.mapif.rodex_sendinbox(fd, char_id, opentype, flag, count, mails); + HPMHooks.source.mapif.rodex_sendinbox(fd, char_id, opentype, flag, count, mail_id, mails); } if (HPMHooks.count.HP_mapif_rodex_sendinbox_post > 0) { - void (*postHookFunc) (int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails); + void (*postHookFunc) (int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails); for (hIndex = 0; hIndex < HPMHooks.count.HP_mapif_rodex_sendinbox_post; hIndex++) { postHookFunc = HPMHooks.list.HP_mapif_rodex_sendinbox_post[hIndex].func; - postHookFunc(fd, char_id, opentype, flag, count, mails); + postHookFunc(fd, char_id, opentype, flag, count, mail_id, mails); } } return; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 9d531e370..d799b8693 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -1286,6 +1286,8 @@ struct { struct HPMHookPoint *HP_clif_quest_update_status_post; struct HPMHookPoint *HP_clif_quest_update_objective_pre; struct HPMHookPoint *HP_clif_quest_update_objective_post; + struct HPMHookPoint *HP_clif_quest_notify_objective_pre; + struct HPMHookPoint *HP_clif_quest_notify_objective_post; struct HPMHookPoint *HP_clif_quest_show_event_pre; struct HPMHookPoint *HP_clif_quest_show_event_post; struct HPMHookPoint *HP_clif_mail_window_pre; @@ -1998,6 +2000,10 @@ struct { struct HPMHookPoint *HP_clif_clan_message_post; struct HPMHookPoint *HP_clif_pClanMessage_pre; struct HPMHookPoint *HP_clif_pClanMessage_post; + struct HPMHookPoint *HP_clif_hat_effect_pre; + struct HPMHookPoint *HP_clif_hat_effect_post; + struct HPMHookPoint *HP_clif_hat_effect_single_pre; + struct HPMHookPoint *HP_clif_hat_effect_single_post; struct HPMHookPoint *HP_cmdline_init_pre; struct HPMHookPoint *HP_cmdline_init_post; struct HPMHookPoint *HP_cmdline_final_pre; @@ -7567,6 +7573,8 @@ struct { int HP_clif_quest_update_status_post; int HP_clif_quest_update_objective_pre; int HP_clif_quest_update_objective_post; + int HP_clif_quest_notify_objective_pre; + int HP_clif_quest_notify_objective_post; int HP_clif_quest_show_event_pre; int HP_clif_quest_show_event_post; int HP_clif_mail_window_pre; @@ -8279,6 +8287,10 @@ struct { int HP_clif_clan_message_post; int HP_clif_pClanMessage_pre; int HP_clif_pClanMessage_post; + int HP_clif_hat_effect_pre; + int HP_clif_hat_effect_post; + int HP_clif_hat_effect_single_pre; + int HP_clif_hat_effect_single_post; int HP_cmdline_init_pre; int HP_cmdline_init_post; int HP_cmdline_final_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 5551668d2..045c8a087 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -666,6 +666,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->quest_delete, HP_clif_quest_delete) }, { HP_POP(clif->quest_update_status, HP_clif_quest_update_status) }, { HP_POP(clif->quest_update_objective, HP_clif_quest_update_objective) }, + { HP_POP(clif->quest_notify_objective, HP_clif_quest_notify_objective) }, { HP_POP(clif->quest_show_event, HP_clif_quest_show_event) }, { HP_POP(clif->mail_window, HP_clif_mail_window) }, { HP_POP(clif->mail_read, HP_clif_mail_read) }, @@ -1022,6 +1023,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->clan_leave, HP_clif_clan_leave) }, { HP_POP(clif->clan_message, HP_clif_clan_message) }, { HP_POP(clif->pClanMessage, HP_clif_pClanMessage) }, + { HP_POP(clif->hat_effect, HP_clif_hat_effect) }, + { HP_POP(clif->hat_effect_single, HP_clif_hat_effect_single) }, /* cmdline_interface */ { HP_POP(cmdline->init, HP_cmdline_init) }, { HP_POP(cmdline->final, HP_cmdline_final) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 0d10eb6fe..22129c026 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -16753,6 +16753,32 @@ void HP_clif_quest_update_objective(struct map_session_data *sd, struct quest *q } return; } +void HP_clif_quest_notify_objective(struct map_session_data *sd, struct quest *qd) { + int hIndex = 0; + if (HPMHooks.count.HP_clif_quest_notify_objective_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, struct quest **qd); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_quest_notify_objective_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clif_quest_notify_objective_pre[hIndex].func; + preHookFunc(&sd, &qd); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.quest_notify_objective(sd, qd); + } + if (HPMHooks.count.HP_clif_quest_notify_objective_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, struct quest *qd); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_quest_notify_objective_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clif_quest_notify_objective_post[hIndex].func; + postHookFunc(sd, qd); + } + } + return; +} void HP_clif_quest_show_event(struct map_session_data *sd, struct block_list *bl, short state, short color) { int hIndex = 0; if (HPMHooks.count.HP_clif_quest_show_event_pre > 0) { @@ -25420,14 +25446,14 @@ void HP_clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_t } return; } -void HP_clif_rodex_send_mails_all(int fd, struct map_session_data *sd) { +void HP_clif_rodex_send_mails_all(int fd, struct map_session_data *sd, int64 mail_id) { int hIndex = 0; if (HPMHooks.count.HP_clif_rodex_send_mails_all_pre > 0) { - void (*preHookFunc) (int *fd, struct map_session_data **sd); + void (*preHookFunc) (int *fd, struct map_session_data **sd, int64 *mail_id); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_rodex_send_mails_all_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_clif_rodex_send_mails_all_pre[hIndex].func; - preHookFunc(&fd, &sd); + preHookFunc(&fd, &sd, &mail_id); } if (*HPMforce_return) { *HPMforce_return = false; @@ -25435,13 +25461,13 @@ void HP_clif_rodex_send_mails_all(int fd, struct map_session_data *sd) { } } { - HPMHooks.source.clif.rodex_send_mails_all(fd, sd); + HPMHooks.source.clif.rodex_send_mails_all(fd, sd, mail_id); } if (HPMHooks.count.HP_clif_rodex_send_mails_all_post > 0) { - void (*postHookFunc) (int fd, struct map_session_data *sd); + void (*postHookFunc) (int fd, struct map_session_data *sd, int64 mail_id); for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_rodex_send_mails_all_post; hIndex++) { postHookFunc = HPMHooks.list.HP_clif_rodex_send_mails_all_post[hIndex].func; - postHookFunc(fd, sd); + postHookFunc(fd, sd, mail_id); } } return; @@ -26018,6 +26044,58 @@ void HP_clif_pClanMessage(int fd, struct map_session_data *sd) { } return; } +void HP_clif_hat_effect(struct block_list *bl, struct block_list *tbl, enum send_target target) { + int hIndex = 0; + if (HPMHooks.count.HP_clif_hat_effect_pre > 0) { + void (*preHookFunc) (struct block_list **bl, struct block_list **tbl, enum send_target *target); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_hat_effect_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clif_hat_effect_pre[hIndex].func; + preHookFunc(&bl, &tbl, &target); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.hat_effect(bl, tbl, target); + } + if (HPMHooks.count.HP_clif_hat_effect_post > 0) { + void (*postHookFunc) (struct block_list *bl, struct block_list *tbl, enum send_target target); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_hat_effect_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clif_hat_effect_post[hIndex].func; + postHookFunc(bl, tbl, target); + } + } + return; +} +void HP_clif_hat_effect_single(struct block_list *bl, uint16 effectId, bool enable) { + int hIndex = 0; + if (HPMHooks.count.HP_clif_hat_effect_single_pre > 0) { + void (*preHookFunc) (struct block_list **bl, uint16 *effectId, bool *enable); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_hat_effect_single_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clif_hat_effect_single_pre[hIndex].func; + preHookFunc(&bl, &effectId, &enable); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.hat_effect_single(bl, effectId, enable); + } + if (HPMHooks.count.HP_clif_hat_effect_single_post > 0) { + void (*postHookFunc) (struct block_list *bl, uint16 effectId, bool enable); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_hat_effect_single_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clif_hat_effect_single_post[hIndex].func; + postHookFunc(bl, effectId, enable); + } + } + return; +} /* cmdline_interface */ void HP_cmdline_init(void) { int hIndex = 0; diff --git a/src/plugins/mapcache.c b/src/plugins/mapcache.c index f1dab97c1..5e44492f6 100644 --- a/src/plugins/mapcache.c +++ b/src/plugins/mapcache.c @@ -341,6 +341,100 @@ bool mapcache_rebuild(void) return true; } +bool fix_md5_truncation_sub(FILE *fp, const char *map_name) +{ + unsigned int file_size; + struct map_cache_header mheader = { 0 }; + uint8 *buf = NULL; + + nullpo_retr(false, fp); + nullpo_retr(false, map_name); + + fseek(fp, 0, SEEK_END); + file_size = (unsigned int)ftell(fp); + fseek(fp, 0, SEEK_SET); // Rewind file pointer before passing it to the read function. + + if (file_size <= sizeof(mheader) || fread(&mheader, sizeof(mheader), 1, fp) < 1) { + ShowError("fix_md5_truncation: Failed to read cache header for map '%s'.\n", map_name); + return false; + } + + if (mheader.len <= 0) { + ShowError("fix_md5_truncation: A file with negative or zero compressed length passed '%d'.\n", mheader.len); + return false; + } + + if (file_size < sizeof(mheader) + mheader.len) { + ShowError("fix_md5_truncation: An incomplete file passed for map '%s'.\n", map_name); + return false; + } + + CREATE(buf, uint8, mheader.len); + if (fread(buf, mheader.len, 1, fp) < 1) { + ShowError("fix_md5_truncation: Could not load the compressed cell data for map '%s'.\n", map_name); + aFree(buf); + return false; + } + + md5->binary(buf, mheader.len, mheader.md5_checksum); + aFree(buf); + + fseek(fp, 0, SEEK_SET); + fwrite(&mheader, sizeof(mheader), 1, fp); + fclose(fp); + + return true; +} + +bool fix_md5_truncation(void) +{ + int i; + bool retval = true; + + if (mapcache_read_maplist("db/map_index.txt") == false) { + ShowError("mapcache_rebuild: Could not read maplist, aborting\n"); + return false; + } + + for (i = 0; i < VECTOR_LENGTH(maplist); ++i) { + const char *map_name = VECTOR_INDEX(maplist, i); + char file_path[255]; + FILE *fp = NULL; + int16 version; + + snprintf(file_path, sizeof(file_path), "%s%s%s.%s", "maps/", DBPATH, map_name, "mcache"); + + fp = fopen(file_path, "r+b"); + + if (fp == NULL) { + ShowWarning("fix_md5_truncation: Could not open the mapcache file for map '%s' at path '%s'.\n", map_name, file_path); + retval = false; + continue; + } + + if (fread(&version, sizeof(version), 1, fp) < 1) { + ShowError("fix_md5_truncation: Could not read file version for map '%s'.\n", map_name); + fclose(fp); + retval = false; + continue; + } + + if (version != 1) { + ShowError("fix_md5_truncation: Mapcache for map '%s' has version %d. The update is only applied to version 1.\n", map_name, version); + fclose(fp); + continue; + } + + ShowStatus("Updating mapcache: %s'\n", map_name); + if (!fix_md5_truncation_sub(fp, map_name)) + retval = false; + + fclose(fp); + } + + return retval; +} + CMDLINEARG(convertmapcache) { map->minimal = true; @@ -363,6 +457,12 @@ CMDLINEARG(cachemap) return mapcache_cache_map(params); } +CMDLINEARG(fixmd5) +{ + map->minimal = true; + return fix_md5_truncation(); +} + HPExport void server_preinit(void) { addArg("--convert-old-mapcache", false, convertmapcache, @@ -371,6 +471,8 @@ HPExport void server_preinit(void) "Rebuilds the entire mapcache folder (maps/"DBPATH"), using db/map_index.txt as index."); addArg("--map", true, cachemap, "Rebuilds an individual map's cache into maps/"DBPATH" (usage: --map <map_name_without_extension>)."); + addArg("--fix-md5", false, fixmd5, + "Updates the checksum for the files in maps/"DBPATH", using db/map_index.txt as index (see PR #1981)."); needs_grfio = false; VECTOR_INIT(maplist); @@ -378,6 +480,10 @@ HPExport void server_preinit(void) HPExport void plugin_final(void) { + while (VECTOR_LENGTH(maplist) > 0) { + char *name = VECTOR_POP(maplist); + aFree(name); + } VECTOR_CLEAR(maplist); if (needs_grfio) grfio->final(); |