viewing paste Unknown #7533 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Hooking:
 
Server-boot, battle->check_target points to battle_check_target.
HPM stores the original address of battle->check_target.
Plugins initialise, hooking to battle->check_target causes the address of battle->check_target to change from battle_check_target to HP_battle_check_target, so calling battle->check_target gets to HP_battle_check_target.
 
HP_battle_check_target triggers the pre plugin (if any), runs the original address (battle_check_target), triggers post plugins (if any), and returns.
--
int HP_battle_check_target( struct block_list *src, struct block_list *target,int flag) {
        int retVal;
        int i;
       
        /* hooks.battle_check_target_pre -> int */
        if( HPMHooks.count.HP_battle_check_target_pre ) {
                for(i = 0; i < HPMHooks.count.HP_battle_check_target_pre; i++ ) {
                        retVal = (HPMHooks.list.HP_battle_check_target_pre[i])(src,target,&flag);
                }
        }
       
        retVal = HPMHooks.source.battle.check_target(src,target,flag);
       
        if( HPMHooks.count.HP_battle_check_target_post ) {
                for(i = 0; i < HPMHooks.count.HP_battle_check_target_post; i++ ) {
                        retVal = (HPMHooks.list.HP_battle_check_target_post[i])(src,target,&flag,retVal);                      
                }
        }
       
        return retVal;
}
--
Viewed 310 times, submitted by unknown.