Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new natives RG_CBasePlayerItem_Materialize, RG_CBasePlayerItem_CheckRespawn #330

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion reapi/extra/amxmodx/scripting/include/reapi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum hooks_tables_e
ht_weapon,
ht_gib,
ht_cbaseentity,
ht_botmanager
ht_botmanager,
ht_cbaseplayeritem
};

enum members_tables_e
Expand Down
18 changes: 18 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,24 @@ enum GamedllFunc_CBasePlayer
RG_CBasePlayer_RemoveAllItems,
};

/**
* GamedllFunc CBasePlayerItem
*/
enum GamedllFunc_CBasePlayerItem
{
/*
* Description: -
* Params: (const this)
*/
RG_CBasePlayerItem_Materialize = BEGIN_FUNC_REGION(cbaseplayeritem),

/*
* Description: -
* Params: (const this)
*/
RG_CBasePlayerItem_CheckRespawn,
}

/**
* GamedllFunc CBasePlayer
*/
Expand Down
12 changes: 12 additions & 0 deletions reapi/include/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,15 @@ typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBa
typedef IHookChainClass<void, class CBasePlayer, BOOL> IReGameHook_CBasePlayer_RemoveAllItems;
typedef IHookChainRegistryClass<void, class CBasePlayer, BOOL> IReGameHookRegistry_CBasePlayer_RemoveAllItems;

// CBasePlayerItem::Materialize hook
typedef IHookChainClass<void, class CBasePlayerItem> IReGameHook_CBasePlayerItem_Materialize;
typedef IHookChainRegistryClass<void, class CBasePlayerItem> IReGameHookRegistry_CBasePlayerItem_Materialize;

// CBasePlayerItem::CheckRespawn hook
typedef IHookChainClass<void, class CBasePlayerItem> IReGameHook_CBasePlayerItem_CheckRespawn;
typedef IHookChainRegistryClass<void, class CBasePlayerItem> IReGameHookRegistry_CBasePlayerItem_CheckRespawn;


class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
Expand Down Expand Up @@ -792,6 +801,9 @@ class IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0;
virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems() = 0;

virtual IReGameHookRegistry_CBasePlayerItem_Materialize *CBasePlayerItem_Materialize() = 0;
virtual IReGameHookRegistry_CBasePlayerItem_CheckRespawn *CBasePlayerItem_CheckRespawn() = 0;
};

struct ReGameFuncs_t {
Expand Down
22 changes: 22 additions & 0 deletions reapi/src/hook_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,28 @@ void CSGameRules_SendDeathMessage(IReGameHook_CSGameRules_SendDeathMessage *chai
callVoidForward(RG_CSGameRules_SendDeathMessage, original, indexOfPDataAmx(pKiller), indexOfEdict(pVictim->pev), indexOfPDataAmx(pAssister), indexOfEdictAmx(pevInflictor), killerWeaponName, iDeathMessageFlags, iRarityOfKill);
}

void CBasePlayerItem_Materialize(IReGameHook_CBasePlayerItem_Materialize *chain, CBasePlayerItem *pthis)
{
auto original = [chain](int _pthis)
{
chain->callNext(getPrivate<CBasePlayerItem>(_pthis));
};

callVoidForward(RG_CBasePlayerItem_Materialize, original, indexOfEdict(pthis->pev));
}


void CBasePlayerItem_CheckRespawn(IReGameHook_CBasePlayerItem_CheckRespawn *chain, CBasePlayerItem *pthis)
{
auto original = [chain](int _pthis)
{
chain->callNext(getPrivate<CBasePlayerItem>(_pthis));
};

callVoidForward(RG_CBasePlayerItem_CheckRespawn, original, indexOfEdict(pthis->pev));
}


/*
* VTC functions
*/
Expand Down
2 changes: 2 additions & 0 deletions reapi/src/hook_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ void CBasePlayer_PlayerDeathThink(IReGameHook_CBasePlayer_PlayerDeathThink *chai
void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, CBasePlayer *pthis);
void CBasePlayer_RemoveAllItems(IReGameHook_CBasePlayer_RemoveAllItems *chain, CBasePlayer *pthis, BOOL removeSuit);
void CSGameRules_SendDeathMessage(IReGameHook_CSGameRules_SendDeathMessage *chain, CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, entvars_t *pevInflictor, const char *killerWeaponName, int iDeathMessageFlags, int iRarityOfKill);
void CBasePlayerItem_Materialize(IReGameHook_CBasePlayerItem_Materialize *chain, CBasePlayerItem *pthis);
void CBasePlayerItem_CheckRespawn(IReGameHook_CBasePlayerItem_CheckRespawn *chain, CBasePlayerItem *pthis);

/*
* VTC functions
Expand Down
11 changes: 11 additions & 0 deletions reapi/src/hook_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ hook_t hooklist_player[] = {
DLL(CBasePlayer_PlayerDeathThink),
DLL(CBasePlayer_Observer_Think),
DLL(CBasePlayer_RemoveAllItems),

};

hook_t hooklist_gamerules[] = {
Expand Down Expand Up @@ -289,6 +290,14 @@ hook_t hooklist_botmanager[] = {
DLL(CBotManager_OnEvent),
};

hook_t hooklist_cbaseplayeritem[] = {
DLL(CBasePlayerItem_Materialize),
DLL(CBasePlayerItem_CheckRespawn),
};




#define RCHECK(h,...) { {}, {}, #h, "ReChecker", [](){ return api_cfg.hasRechecker(); }, ((!(RC_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RC_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RecheckerHookchains->h()->registerHook(&h); }, [](){ g_RecheckerHookchains->h()->unregisterHook(&h); }, false}
hook_t hooklist_rechecker[] = {
RCHECK(FileConsistencyProcess, _AMXX),
Expand Down Expand Up @@ -316,6 +325,7 @@ hook_t* hooklist_t::getHookSafe(size_t hook)
CASE(gib)
CASE(cbaseentity)
CASE(botmanager)
CASE(cbaseplayeritem)
}

return nullptr;
Expand All @@ -337,6 +347,7 @@ void hooklist_t::clear()
FOREACH_CLEAR(gib);
FOREACH_CLEAR(cbaseentity);
FOREACH_CLEAR(botmanager);
FOREACH_CLEAR(cbaseplayeritem);
}

void hook_t::clear()
Expand Down
12 changes: 12 additions & 0 deletions reapi/src/hook_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern hook_t hooklist_weapon[];
extern hook_t hooklist_gib[];
extern hook_t hooklist_cbaseentity[];
extern hook_t hooklist_botmanager[];
extern hook_t hooklist_cbaseplayeritem[];

enum
{
Expand Down Expand Up @@ -67,6 +68,7 @@ struct hooklist_t
CASE(gib)
CASE(cbaseentity)
CASE(botmanager)
CASE(cbaseplayeritem)
}

#undef CASE
Expand All @@ -91,6 +93,7 @@ struct hooklist_t
ht_gib,
ht_cbaseentity,
ht_botmanager,
ht_cbaseplayeritem,
};
};

Expand Down Expand Up @@ -345,3 +348,12 @@ enum ReCheckerFunc

// [...]
};


enum GamedllFunc_CBasePlayerItem
{
RG_CBasePlayerItem_Materialize = BEGIN_FUNC_REGION(cbaseplayeritem),
RG_CBasePlayerItem_CheckRespawn,

// [...]
};