reapi icon indicating copy to clipboard operation
reapi copied to clipboard

`API`: Implement `RG_PM_LadderMove` hook

Open ShadowsAdi opened this issue 2 years ago • 1 comments

Related to https://github.com/s1lentq/reapi/issues/82

ShadowsAdi avatar Mar 20 '22 19:03 ShadowsAdi

useful to create plugins like this: https://dev-cs.ru/threads/19404/

RauliTop avatar Mar 21 '22 20:03 RauliTop

@s1lentq merge it, please :)

WaLkZa avatar Nov 18 '22 14:11 WaLkZa

@s1lentq orpheu example https://forums.alliedmods.net/showpost.php?p=1290113&postcount=2

WaLkZa avatar Mar 31 '23 21:03 WaLkZa

@ShadowsAdi @s1lentq I think this hook should keep the schema of PM_AirMove implementation, keeping physent parameter and an additional player index parameter

dystopm avatar Jul 15 '23 19:07 dystopm

@s1lentq CAPI_Impl.h

// PM_LadderMove hook
typedef IHookChainImpl<void, physent_t *, int> CReGameHook_PM_LadderMove;
typedef IHookChainRegistryImpl<void, physent_t *, int> CReGameHookRegistry_PM_LadderMove;

pm_shared.cpp

LINK_HOOK_VOID_CHAIN(PM_LadderMove, (physent_t *pLadder, int playerIndex = 0), pLadder, pmove->player_index + 1);

void EXT_FUNC __API_HOOK(PM_LadderMove)(physent_t *pLadder, int playerIndex)
{
	PM_LadderMove_internal(pLadder);
}

void PM_LadderMove_internal(physent_t *pLadder)
{
        // ...
}

regamedll_api.h

// PM_LadderMove hook
typedef IHookChain<void, physent_t *, int> IReGameHook_PM_LadderMove;
typedef IHookChainRegistry<void, physent_t *, int> IReGameHookRegistry_PM_LadderMove;

dystopm avatar Jul 15 '23 19:07 dystopm

@dystopm I thought I took a hasty merge, but this isn't the case, in my opinion, AirMove actually isn't a very good scheme, especially for modules where have a easy access to pmove. I think it's better to use the wrapper with custom arguments for AMXX rather than doing it in the API. Moreover, there are already a couple of such functions like PM_Move, PM_UpdateStepSound etc. Don't you think?

I agree about the physent argument.

s1lentq avatar Jul 15 '23 20:07 s1lentq

@s1lentq

I see you ended adding the physent argument which I think is fine guessing we can add logic in future to change physent structure values, so it's a yes, I agree with you.

In that case, shouldn't PM_AirMove be modified?

PD: there's a few of functions which I coded in my own fork which I find useful to be added, I'll be doing a commit taking advantage of you are merging

dystopm avatar Jul 15 '23 20:07 dystopm

In that case, shouldn't PM_AirMove be modified?

No, we should keep API compatibility at least until we update the major version

s1lentq avatar Jul 15 '23 20:07 s1lentq