From 89e0550e4dee7a5076f7b12d335468fd3bb4f26d Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 28 Feb 2016 02:48:47 +0100 Subject: Added one level of indirection to all variables in pre-hook functions - Previously, only scalar variables had their indirection level increased. Now pointers do as well (this allows users to override const pointers) Signed-off-by: Haru --- src/plugins/sample.c | 5 +++-- tools/HPMHookGen/HPMHookGen.pl | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/sample.c b/src/plugins/sample.c index 991e03e4c..b1ff4b39f 100644 --- a/src/plugins/sample.c +++ b/src/plugins/sample.c @@ -114,9 +114,10 @@ void sample_packet0f3(int fd) { } int my_pc_dropitem_storage;/* storage var */ /* my custom prehook for pc_dropitem, checks if amount of item being dropped is higher than 1 and if so cap it to 1 and store the value of how much it was */ -int my_pc_dropitem_pre(struct map_session_data *sd,int *n,int *amount) { +int my_pc_dropitem_pre(struct map_session_data **sd, int *n, int *amount) +{ my_pc_dropitem_storage = 0; - if( *amount > 1 ) { + if (*amount > 1) { my_pc_dropitem_storage = *amount; *amount = 1; } diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl index c357d0dbd..577536313 100755 --- a/tools/HPMHookGen/HPMHookGen.pl +++ b/tools/HPMHookGen/HPMHookGen.pl @@ -187,7 +187,7 @@ sub parse($$) { $post_code = "va_end(${callvar});"; $var = ''; $variadic = 1; - } elsif (!$indirectionlvl) { # Increase indirection level when necessary + } else { # Increase indirection level when necessary $dereference = '*'; $addressof = '&'; } -- cgit v1.2.3-60-g2f50