diff options
Diffstat (limited to 'src/plugins/HPMHooking')
13 files changed, 789 insertions, 0 deletions
diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 852a2c122..cbf15fa7e 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -5699,6 +5699,24 @@ typedef int (*HPMHOOK_post_quest_read_db) (int retVal___); typedef struct quest_db* (*HPMHOOK_pre_quest_read_db_sub) (struct config_setting_t **cs, int *n, const char **source); typedef struct quest_db* (*HPMHOOK_post_quest_read_db_sub) (struct quest_db* retVal___, struct config_setting_t *cs, int n, const char *source); #endif // MAP_QUEST_H +#ifdef COMMON_RANDOM_H /* rnd */ +typedef void (*HPMHOOK_pre_rnd_init) (void); +typedef void (*HPMHOOK_post_rnd_init) (void); +typedef void (*HPMHOOK_pre_rnd_final) (void); +typedef void (*HPMHOOK_post_rnd_final) (void); +typedef void (*HPMHOOK_pre_rnd_seed) (uint32 *seed); +typedef void (*HPMHOOK_post_rnd_seed) (uint32 seed); +typedef int32 (*HPMHOOK_pre_rnd_random) (void); +typedef int32 (*HPMHOOK_post_rnd_random) (int32 retVal___); +typedef uint32 (*HPMHOOK_pre_rnd_roll) (uint32 *dice_faces); +typedef uint32 (*HPMHOOK_post_rnd_roll) (uint32 retVal___, uint32 dice_faces); +typedef int32 (*HPMHOOK_pre_rnd_value) (int32 *min, int32 *max); +typedef int32 (*HPMHOOK_post_rnd_value) (int32 retVal___, int32 min, int32 max); +typedef double (*HPMHOOK_pre_rnd_uniform) (void); +typedef double (*HPMHOOK_post_rnd_uniform) (double retVal___); +typedef double (*HPMHOOK_pre_rnd_uniform53) (void); +typedef double (*HPMHOOK_post_rnd_uniform53) (double retVal___); +#endif // COMMON_RANDOM_H #ifdef MAP_SCRIPT_H /* script */ typedef void (*HPMHOOK_pre_script_init) (bool *minimal); typedef void (*HPMHOOK_post_script_init) (bool minimal); diff --git a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc index 78066d26e..2162fad57 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc @@ -1204,6 +1204,22 @@ struct { struct HPMHookPoint *HP_pincode_check_post; struct HPMHookPoint *HP_pincode_config_read_pre; struct HPMHookPoint *HP_pincode_config_read_post; + struct HPMHookPoint *HP_rnd_init_pre; + struct HPMHookPoint *HP_rnd_init_post; + struct HPMHookPoint *HP_rnd_final_pre; + struct HPMHookPoint *HP_rnd_final_post; + struct HPMHookPoint *HP_rnd_seed_pre; + struct HPMHookPoint *HP_rnd_seed_post; + struct HPMHookPoint *HP_rnd_random_pre; + struct HPMHookPoint *HP_rnd_random_post; + struct HPMHookPoint *HP_rnd_roll_pre; + struct HPMHookPoint *HP_rnd_roll_post; + struct HPMHookPoint *HP_rnd_value_pre; + struct HPMHookPoint *HP_rnd_value_post; + struct HPMHookPoint *HP_rnd_uniform_pre; + struct HPMHookPoint *HP_rnd_uniform_post; + struct HPMHookPoint *HP_rnd_uniform53_pre; + struct HPMHookPoint *HP_rnd_uniform53_post; struct HPMHookPoint *HP_showmsg_init_pre; struct HPMHookPoint *HP_showmsg_init_post; struct HPMHookPoint *HP_showmsg_final_pre; @@ -2639,6 +2655,22 @@ struct { int HP_pincode_check_post; int HP_pincode_config_read_pre; int HP_pincode_config_read_post; + int HP_rnd_init_pre; + int HP_rnd_init_post; + int HP_rnd_final_pre; + int HP_rnd_final_post; + int HP_rnd_seed_pre; + int HP_rnd_seed_post; + int HP_rnd_random_pre; + int HP_rnd_random_post; + int HP_rnd_roll_pre; + int HP_rnd_roll_post; + int HP_rnd_value_pre; + int HP_rnd_value_post; + int HP_rnd_uniform_pre; + int HP_rnd_uniform_post; + int HP_rnd_uniform53_pre; + int HP_rnd_uniform53_post; int HP_showmsg_init_pre; int HP_showmsg_init_post; int HP_showmsg_final_pre; @@ -2924,6 +2956,7 @@ struct { struct mutex_interface mutex; struct nullpo_interface nullpo; struct pincode_interface pincode; + struct rnd_interface rnd; struct showmsg_interface showmsg; struct socket_interface sockt; struct sql_interface SQL; diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc index 405dd4a91..d9021e906 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc @@ -643,6 +643,15 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pincode->compare, HP_pincode_compare) }, { HP_POP(pincode->check, HP_pincode_check) }, { HP_POP(pincode->config_read, HP_pincode_config_read) }, +/* rnd_interface */ + { HP_POP(rnd->init, HP_rnd_init) }, + { HP_POP(rnd->final, HP_rnd_final) }, + { HP_POP(rnd->seed, HP_rnd_seed) }, + { HP_POP(rnd->random, HP_rnd_random) }, + { HP_POP(rnd->roll, HP_rnd_roll) }, + { HP_POP(rnd->value, HP_rnd_value) }, + { HP_POP(rnd->uniform, HP_rnd_uniform) }, + { HP_POP(rnd->uniform53, HP_rnd_uniform53) }, /* showmsg_interface */ { HP_POP(showmsg->init, HP_showmsg_init) }, { HP_POP(showmsg->final, HP_showmsg_final) }, diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index 4ec1abcd1..958724065 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -15753,6 +15753,220 @@ bool HP_pincode_config_read(char *w1, char *w2) { } return retVal___; } +/* rnd_interface */ +void HP_rnd_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.init(); + } + if( HPMHooks.count.HP_rnd_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.final(); + } + if( HPMHooks.count.HP_rnd_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_seed(uint32 seed) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_seed_pre ) { + void (*preHookFunc) (uint32 *seed); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func; + preHookFunc(&seed); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.seed(seed); + } + if( HPMHooks.count.HP_rnd_seed_post ) { + void (*postHookFunc) (uint32 seed); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func; + postHookFunc(seed); + } + } + return; +} +int32 HP_rnd_random(void) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_random_pre ) { + int32 (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.random(); + } + if( HPMHooks.count.HP_rnd_random_post ) { + int32 (*postHookFunc) (int32 retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +uint32 HP_rnd_roll(uint32 dice_faces) { + int hIndex = 0; + uint32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_roll_pre ) { + uint32 (*preHookFunc) (uint32 *dice_faces); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func; + retVal___ = preHookFunc(&dice_faces); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.roll(dice_faces); + } + if( HPMHooks.count.HP_rnd_roll_post ) { + uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func; + retVal___ = postHookFunc(retVal___, dice_faces); + } + } + return retVal___; +} +int32 HP_rnd_value(int32 min, int32 max) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_value_pre ) { + int32 (*preHookFunc) (int32 *min, int32 *max); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func; + retVal___ = preHookFunc(&min, &max); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.value(min, max); + } + if( HPMHooks.count.HP_rnd_value_post ) { + int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func; + retVal___ = postHookFunc(retVal___, min, max); + } + } + return retVal___; +} +double HP_rnd_uniform(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform(); + } + if( HPMHooks.count.HP_rnd_uniform_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +double HP_rnd_uniform53(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform53_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform53(); + } + if( HPMHooks.count.HP_rnd_uniform53_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} /* showmsg_interface */ void HP_showmsg_init(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_char.sources.inc b/src/plugins/HPMHooking/HPMHooking_char.sources.inc index c17c0313d..f1180dea8 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.sources.inc @@ -53,6 +53,7 @@ memcpy(&HPMHooks.source.md5, md5, sizeof(struct md5_interface)); memcpy(&HPMHooks.source.mutex, mutex, sizeof(struct mutex_interface)); memcpy(&HPMHooks.source.nullpo, nullpo, sizeof(struct nullpo_interface)); memcpy(&HPMHooks.source.pincode, pincode, sizeof(struct pincode_interface)); +memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface)); memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface)); memcpy(&HPMHooks.source.sockt, sockt, sizeof(struct socket_interface)); memcpy(&HPMHooks.source.SQL, SQL, sizeof(struct sql_interface)); diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index e6d43c833..91d2304d8 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -432,6 +432,22 @@ struct { struct HPMHookPoint *HP_mutex_cond_broadcast_post; struct HPMHookPoint *HP_nullpo_assert_report_pre; struct HPMHookPoint *HP_nullpo_assert_report_post; + struct HPMHookPoint *HP_rnd_init_pre; + struct HPMHookPoint *HP_rnd_init_post; + struct HPMHookPoint *HP_rnd_final_pre; + struct HPMHookPoint *HP_rnd_final_post; + struct HPMHookPoint *HP_rnd_seed_pre; + struct HPMHookPoint *HP_rnd_seed_post; + struct HPMHookPoint *HP_rnd_random_pre; + struct HPMHookPoint *HP_rnd_random_post; + struct HPMHookPoint *HP_rnd_roll_pre; + struct HPMHookPoint *HP_rnd_roll_post; + struct HPMHookPoint *HP_rnd_value_pre; + struct HPMHookPoint *HP_rnd_value_post; + struct HPMHookPoint *HP_rnd_uniform_pre; + struct HPMHookPoint *HP_rnd_uniform_post; + struct HPMHookPoint *HP_rnd_uniform53_pre; + struct HPMHookPoint *HP_rnd_uniform53_post; struct HPMHookPoint *HP_showmsg_init_pre; struct HPMHookPoint *HP_showmsg_init_post; struct HPMHookPoint *HP_showmsg_final_pre; @@ -1095,6 +1111,22 @@ struct { int HP_mutex_cond_broadcast_post; int HP_nullpo_assert_report_pre; int HP_nullpo_assert_report_post; + int HP_rnd_init_pre; + int HP_rnd_init_post; + int HP_rnd_final_pre; + int HP_rnd_final_post; + int HP_rnd_seed_pre; + int HP_rnd_seed_post; + int HP_rnd_random_pre; + int HP_rnd_random_post; + int HP_rnd_roll_pre; + int HP_rnd_roll_post; + int HP_rnd_value_pre; + int HP_rnd_value_post; + int HP_rnd_uniform_pre; + int HP_rnd_uniform_post; + int HP_rnd_uniform53_pre; + int HP_rnd_uniform53_post; int HP_showmsg_init_pre; int HP_showmsg_init_post; int HP_showmsg_final_pre; @@ -1366,6 +1398,7 @@ struct { struct md5_interface md5; struct mutex_interface mutex; struct nullpo_interface nullpo; + struct rnd_interface rnd; struct showmsg_interface showmsg; struct socket_interface sockt; struct sql_interface SQL; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index ce9a112f7..48e376287 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -243,6 +243,15 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mutex->cond_broadcast, HP_mutex_cond_broadcast) }, /* nullpo_interface */ { HP_POP(nullpo->assert_report, HP_nullpo_assert_report) }, +/* rnd_interface */ + { HP_POP(rnd->init, HP_rnd_init) }, + { HP_POP(rnd->final, HP_rnd_final) }, + { HP_POP(rnd->seed, HP_rnd_seed) }, + { HP_POP(rnd->random, HP_rnd_random) }, + { HP_POP(rnd->roll, HP_rnd_roll) }, + { HP_POP(rnd->value, HP_rnd_value) }, + { HP_POP(rnd->uniform, HP_rnd_uniform) }, + { HP_POP(rnd->uniform53, HP_rnd_uniform53) }, /* showmsg_interface */ { HP_POP(showmsg->init, HP_showmsg_init) }, { HP_POP(showmsg->final, HP_showmsg_final) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index dc0ed4a17..e176c8488 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -5459,6 +5459,220 @@ void HP_nullpo_assert_report(const char *file, int line, const char *func, const } return; } +/* rnd_interface */ +void HP_rnd_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.init(); + } + if( HPMHooks.count.HP_rnd_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.final(); + } + if( HPMHooks.count.HP_rnd_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_seed(uint32 seed) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_seed_pre ) { + void (*preHookFunc) (uint32 *seed); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func; + preHookFunc(&seed); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.seed(seed); + } + if( HPMHooks.count.HP_rnd_seed_post ) { + void (*postHookFunc) (uint32 seed); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func; + postHookFunc(seed); + } + } + return; +} +int32 HP_rnd_random(void) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_random_pre ) { + int32 (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.random(); + } + if( HPMHooks.count.HP_rnd_random_post ) { + int32 (*postHookFunc) (int32 retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +uint32 HP_rnd_roll(uint32 dice_faces) { + int hIndex = 0; + uint32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_roll_pre ) { + uint32 (*preHookFunc) (uint32 *dice_faces); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func; + retVal___ = preHookFunc(&dice_faces); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.roll(dice_faces); + } + if( HPMHooks.count.HP_rnd_roll_post ) { + uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func; + retVal___ = postHookFunc(retVal___, dice_faces); + } + } + return retVal___; +} +int32 HP_rnd_value(int32 min, int32 max) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_value_pre ) { + int32 (*preHookFunc) (int32 *min, int32 *max); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func; + retVal___ = preHookFunc(&min, &max); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.value(min, max); + } + if( HPMHooks.count.HP_rnd_value_post ) { + int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func; + retVal___ = postHookFunc(retVal___, min, max); + } + } + return retVal___; +} +double HP_rnd_uniform(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform(); + } + if( HPMHooks.count.HP_rnd_uniform_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +double HP_rnd_uniform53(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform53_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform53(); + } + if( HPMHooks.count.HP_rnd_uniform53_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} /* showmsg_interface */ void HP_showmsg_init(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc index fc530bcbf..ddd1206ca 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc @@ -39,6 +39,7 @@ memcpy(&HPMHooks.source.iMalloc, iMalloc, sizeof(struct malloc_interface)); memcpy(&HPMHooks.source.md5, md5, sizeof(struct md5_interface)); memcpy(&HPMHooks.source.mutex, mutex, sizeof(struct mutex_interface)); memcpy(&HPMHooks.source.nullpo, nullpo, sizeof(struct nullpo_interface)); +memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface)); memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface)); memcpy(&HPMHooks.source.sockt, sockt, sizeof(struct socket_interface)); memcpy(&HPMHooks.source.SQL, SQL, sizeof(struct sql_interface)); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index d85e64eb2..e3276fdf6 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -4530,6 +4530,22 @@ struct { struct HPMHookPoint *HP_quest_read_db_post; struct HPMHookPoint *HP_quest_read_db_sub_pre; struct HPMHookPoint *HP_quest_read_db_sub_post; + struct HPMHookPoint *HP_rnd_init_pre; + struct HPMHookPoint *HP_rnd_init_post; + struct HPMHookPoint *HP_rnd_final_pre; + struct HPMHookPoint *HP_rnd_final_post; + struct HPMHookPoint *HP_rnd_seed_pre; + struct HPMHookPoint *HP_rnd_seed_post; + struct HPMHookPoint *HP_rnd_random_pre; + struct HPMHookPoint *HP_rnd_random_post; + struct HPMHookPoint *HP_rnd_roll_pre; + struct HPMHookPoint *HP_rnd_roll_post; + struct HPMHookPoint *HP_rnd_value_pre; + struct HPMHookPoint *HP_rnd_value_post; + struct HPMHookPoint *HP_rnd_uniform_pre; + struct HPMHookPoint *HP_rnd_uniform_post; + struct HPMHookPoint *HP_rnd_uniform53_pre; + struct HPMHookPoint *HP_rnd_uniform53_post; struct HPMHookPoint *HP_script_init_pre; struct HPMHookPoint *HP_script_init_post; struct HPMHookPoint *HP_script_final_pre; @@ -10517,6 +10533,22 @@ struct { int HP_quest_read_db_post; int HP_quest_read_db_sub_pre; int HP_quest_read_db_sub_post; + int HP_rnd_init_pre; + int HP_rnd_init_post; + int HP_rnd_final_pre; + int HP_rnd_final_post; + int HP_rnd_seed_pre; + int HP_rnd_seed_post; + int HP_rnd_random_pre; + int HP_rnd_random_post; + int HP_rnd_roll_pre; + int HP_rnd_roll_post; + int HP_rnd_value_pre; + int HP_rnd_value_post; + int HP_rnd_uniform_pre; + int HP_rnd_uniform_post; + int HP_rnd_uniform53_pre; + int HP_rnd_uniform53_post; int HP_script_init_pre; int HP_script_init_post; int HP_script_final_pre; @@ -12045,6 +12077,7 @@ struct { struct pcre_interface libpcre; struct pet_interface pet; struct quest_interface quest; + struct rnd_interface rnd; struct script_interface script; struct searchstore_interface searchstore; struct showmsg_interface showmsg; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 59949c536..4f103df81 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -2323,6 +2323,15 @@ struct HookingPointData HookingPoints[] = { { HP_POP(quest->clear, HP_quest_clear) }, { HP_POP(quest->read_db, HP_quest_read_db) }, { HP_POP(quest->read_db_sub, HP_quest_read_db_sub) }, +/* rnd_interface */ + { HP_POP(rnd->init, HP_rnd_init) }, + { HP_POP(rnd->final, HP_rnd_final) }, + { HP_POP(rnd->seed, HP_rnd_seed) }, + { HP_POP(rnd->random, HP_rnd_random) }, + { HP_POP(rnd->roll, HP_rnd_roll) }, + { HP_POP(rnd->value, HP_rnd_value) }, + { HP_POP(rnd->uniform, HP_rnd_uniform) }, + { HP_POP(rnd->uniform53, HP_rnd_uniform53) }, /* script_interface */ { HP_POP(script->init, HP_script_init) }, { HP_POP(script->final, HP_script_final) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index f46a5e7d0..949928058 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -60384,6 +60384,220 @@ struct quest_db* HP_quest_read_db_sub(struct config_setting_t *cs, int n, const } return retVal___; } +/* rnd_interface */ +void HP_rnd_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.init(); + } + if( HPMHooks.count.HP_rnd_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.final(); + } + if( HPMHooks.count.HP_rnd_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_seed(uint32 seed) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_seed_pre ) { + void (*preHookFunc) (uint32 *seed); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func; + preHookFunc(&seed); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.seed(seed); + } + if( HPMHooks.count.HP_rnd_seed_post ) { + void (*postHookFunc) (uint32 seed); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func; + postHookFunc(seed); + } + } + return; +} +int32 HP_rnd_random(void) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_random_pre ) { + int32 (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.random(); + } + if( HPMHooks.count.HP_rnd_random_post ) { + int32 (*postHookFunc) (int32 retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +uint32 HP_rnd_roll(uint32 dice_faces) { + int hIndex = 0; + uint32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_roll_pre ) { + uint32 (*preHookFunc) (uint32 *dice_faces); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func; + retVal___ = preHookFunc(&dice_faces); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.roll(dice_faces); + } + if( HPMHooks.count.HP_rnd_roll_post ) { + uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func; + retVal___ = postHookFunc(retVal___, dice_faces); + } + } + return retVal___; +} +int32 HP_rnd_value(int32 min, int32 max) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_value_pre ) { + int32 (*preHookFunc) (int32 *min, int32 *max); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func; + retVal___ = preHookFunc(&min, &max); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.value(min, max); + } + if( HPMHooks.count.HP_rnd_value_post ) { + int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func; + retVal___ = postHookFunc(retVal___, min, max); + } + } + return retVal___; +} +double HP_rnd_uniform(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform(); + } + if( HPMHooks.count.HP_rnd_uniform_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +double HP_rnd_uniform53(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform53_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform53(); + } + if( HPMHooks.count.HP_rnd_uniform53_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} /* script_interface */ void HP_script_init(bool minimal) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_map.sources.inc b/src/plugins/HPMHooking/HPMHooking_map.sources.inc index a835e0a03..87cf0c3ed 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.sources.inc @@ -70,6 +70,7 @@ memcpy(&HPMHooks.source.pc, pc, sizeof(struct pc_interface)); memcpy(&HPMHooks.source.libpcre, libpcre, sizeof(struct pcre_interface)); memcpy(&HPMHooks.source.pet, pet, sizeof(struct pet_interface)); memcpy(&HPMHooks.source.quest, quest, sizeof(struct quest_interface)); +memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface)); memcpy(&HPMHooks.source.script, script, sizeof(struct script_interface)); memcpy(&HPMHooks.source.searchstore, searchstore, sizeof(struct searchstore_interface)); memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface)); |