Skip to content

Commit

Permalink
Fix GiveC4 hook callback return type (#295)
Browse files Browse the repository at this point in the history
* Fix GiveC4 hook callback return type
  • Loading branch information
dystopm authored Nov 26, 2023
1 parent 5c38e6f commit bf8b9bd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ enum GamedllFunc_CSGameRules

/*
* Description: -
* Return type: CBasePlayer * (Entity index of player)
* Params: ()
*/
RG_CSGameRules_GiveC4,
Expand Down
4 changes: 2 additions & 2 deletions reapi/include/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ typedef IHookChain<void> IReGameHook_CSGameRules_RemoveGuns;
typedef IHookChainRegistry<void> IReGameHookRegistry_CSGameRules_RemoveGuns;

// CHalfLifeMultiplay::GiveC4 hook
typedef IHookChain<void> IReGameHook_CSGameRules_GiveC4;
typedef IHookChainRegistry<void> IReGameHookRegistry_CSGameRules_GiveC4;
typedef IHookChain<CBasePlayer *> IReGameHook_CSGameRules_GiveC4;
typedef IHookChainRegistry<CBasePlayer *> IReGameHookRegistry_CSGameRules_GiveC4;

// CHalfLifeMultiplay::ChangeLevel hook
typedef IHookChain<void> IReGameHook_CSGameRules_ChangeLevel;
Expand Down
6 changes: 3 additions & 3 deletions reapi/src/hook_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,14 +972,14 @@ void CSGameRules_RemoveGuns(IReGameHook_CSGameRules_RemoveGuns *chain)
callVoidForward(RG_CSGameRules_RemoveGuns, original);
}

void CSGameRules_GiveC4(IReGameHook_CSGameRules_GiveC4 *chain)
CBasePlayer *CSGameRules_GiveC4(IReGameHook_CSGameRules_GiveC4 *chain)
{
auto original = [chain]()
{
chain->callNext();
return indexOfPDataAmx(chain->callNext());
};

callVoidForward(RG_CSGameRules_GiveC4, original);
return getPrivate<CBasePlayer>(callForward<size_t>(RG_CSGameRules_GiveC4, original));
}

void CSGameRules_ChangeLevel(IReGameHook_CSGameRules_ChangeLevel *chain)
Expand Down
2 changes: 1 addition & 1 deletion reapi/src/hook_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void CSGameRules_CleanUpMap(IReGameHook_CSGameRules_CleanUpMap *chain);
void CSGameRules_RestartRound(IReGameHook_CSGameRules_RestartRound *chain);
void CSGameRules_CheckWinConditions(IReGameHook_CSGameRules_CheckWinConditions *chain);
void CSGameRules_RemoveGuns(IReGameHook_CSGameRules_RemoveGuns *chain);
void CSGameRules_GiveC4(IReGameHook_CSGameRules_GiveC4 *chain);
CBasePlayer *CSGameRules_GiveC4(IReGameHook_CSGameRules_GiveC4 *chain);
void CSGameRules_ChangeLevel(IReGameHook_CSGameRules_ChangeLevel *chain);
void CSGameRules_GoToIntermission(IReGameHook_CSGameRules_GoToIntermission *chain);
void CSGameRules_BalanceTeams(IReGameHook_CSGameRules_BalanceTeams *chain);
Expand Down

0 comments on commit bf8b9bd

Please sign in to comment.