diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index 23371c28..3123946b 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -251,7 +251,7 @@ public: virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) {} virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) { return FALSE; } virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) { return FALSE; } - virtual int GiveAmmo(int iAmount, char *szName, int iMax = -1) { return -1; } + virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1) { return -1; } virtual float GetDelay() { return 0.0f; } virtual int IsMoving() { return (pev->velocity != g_vecZero); } virtual void OverrideReset() {} diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 3b6731a1..fd638f11 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1585,12 +1585,20 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() { RemoveAllItems(FALSE); -// NOTE: NOTE: It is already does reset inside RemoveAllItems +// NOTE: It is already does reset inside RemoveAllItems #ifndef REGAMEDLL_FIXES m_bHasPrimary = false; #endif #ifdef REGAMEDLL_ADD + auto GiveWeapon = [&](int ammo, char* pszWeaponName) { + GiveNamedItem(pszWeaponName); + const WeaponInfoStruct *info = GetWeaponInfo(pszWeaponName); + if (info) { + GiveAmmo(refill_bpammo_weapons.value != 0.0f ? info->maxRounds : ammo, info->ammoName + 5/*ammo_*/); + } + }; + switch (m_iTeam) { case CT: @@ -1599,8 +1607,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() GiveNamedItem("weapon_knife"); } if (!HasRestrictItem(ITEM_USP, ITEM_TYPE_EQUIPPED)) { - GiveNamedItem("weapon_usp"); - GiveAmmo(m_bIsVIP ? 12 : 24, "45acp"); + GiveWeapon(m_bIsVIP ? 12 : 24, "weapon_usp"); } break; @@ -1611,8 +1618,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() GiveNamedItem("weapon_knife"); } if (!HasRestrictItem(ITEM_GLOCK18, ITEM_TYPE_EQUIPPED)) { - GiveNamedItem("weapon_glock18"); - GiveAmmo(40, "9mm"); + GiveWeapon(40, "weapon_glock18"); } break; @@ -6561,10 +6567,10 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(RemovePlayerItem)(CBasePlayerItem *pItem) return FALSE; } -LINK_HOOK_CLASS_CHAIN(int, CBasePlayer, GiveAmmo, (int iCount, char *szName, int iMax), iCount, szName, iMax) +LINK_HOOK_CLASS_CHAIN(int, CBasePlayer, GiveAmmo, (int iCount, const char *szName, int iMax), iCount, szName, iMax) // Returns the unique ID for the ammo, or -1 if error -int EXT_FUNC CBasePlayer::__API_HOOK(GiveAmmo)(int iCount, char *szName, int iMax) +int EXT_FUNC CBasePlayer::__API_HOOK(GiveAmmo)(int iCount, const char *szName, int iMax) { if (pev->flags & FL_SPECTATOR) return -1; diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index c1e2916b..748d18da 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -336,7 +336,7 @@ public: virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore); virtual BOOL AddPlayerItem(CBasePlayerItem *pItem); virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem); - virtual int GiveAmmo(int iAmount, char *szName, int iMax = -1); + virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1); virtual void StartSneaking() { m_tSneaking = gpGlobals->time - 1; } #ifndef REGAMEDLL_FIXES @@ -381,7 +381,7 @@ public: void AddPointsToTeam_OrigFunc(int score, BOOL bAllowNegativeScore); BOOL AddPlayerItem_OrigFunc(CBasePlayerItem *pItem); BOOL RemovePlayerItem_OrigFunc(CBasePlayerItem *pItem); - int GiveAmmo_OrigFunc(int iAmount, char *szName, int iMax); + int GiveAmmo_OrigFunc(int iAmount, const char *szName, int iMax); void ResetMaxSpeed_OrigFunc(); void Jump_OrigFunc(); void Duck_OrigFunc(); diff --git a/regamedll/extra/cssdk/dlls/cbase.h b/regamedll/extra/cssdk/dlls/cbase.h index af0bed8f..33e57329 100644 --- a/regamedll/extra/cssdk/dlls/cbase.h +++ b/regamedll/extra/cssdk/dlls/cbase.h @@ -81,7 +81,7 @@ public: virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) = 0; virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) = 0; virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) = 0; - virtual int GiveAmmo(int iAmount, char *szName, int iMax = -1) = 0; + virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1) = 0; virtual float GetDelay() = 0; virtual int IsMoving() = 0; virtual void OverrideReset() = 0; diff --git a/regamedll/extra/cssdk/dlls/player.h b/regamedll/extra/cssdk/dlls/player.h index 365d6635..49ecf400 100644 --- a/regamedll/extra/cssdk/dlls/player.h +++ b/regamedll/extra/cssdk/dlls/player.h @@ -320,7 +320,7 @@ public: virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) = 0; virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) = 0; virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) = 0; - virtual int GiveAmmo(int iAmount, char *szName, int iMax = -1) = 0; + virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1) = 0; virtual void StartSneaking() = 0; virtual void UpdateOnRemove() = 0; virtual BOOL IsSneaking() = 0; diff --git a/regamedll/extra/cssdk/dlls/regamedll_api.h b/regamedll/extra/cssdk/dlls/regamedll_api.h index 9ae67a77..5cefdd5a 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_api.h +++ b/regamedll/extra/cssdk/dlls/regamedll_api.h @@ -87,8 +87,8 @@ typedef IHookChainClass IReGam typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RemovePlayerItem; // CBasePlayer::GiveAmmo hook -typedef IHookChainClass IReGameHook_CBasePlayer_GiveAmmo; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveAmmo; +typedef IHookChainClass IReGameHook_CBasePlayer_GiveAmmo; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveAmmo; // CBasePlayer::ResetMaxSpeed hook typedef IVoidHookChainClass IReGameHook_CBasePlayer_ResetMaxSpeed; diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 9c3ee1d0..6424b6ca 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -87,8 +87,8 @@ typedef IHookChainClass IReGam typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RemovePlayerItem; // CBasePlayer::GiveAmmo hook -typedef IHookChainClass IReGameHook_CBasePlayer_GiveAmmo; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveAmmo; +typedef IHookChainClass IReGameHook_CBasePlayer_GiveAmmo; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveAmmo; // CBasePlayer::ResetMaxSpeed hook typedef IHookChainClass IReGameHook_CBasePlayer_ResetMaxSpeed; diff --git a/regamedll/regamedll/regamedll_api_impl.h b/regamedll/regamedll/regamedll_api_impl.h index 128defe9..283c543b 100644 --- a/regamedll/regamedll/regamedll_api_impl.h +++ b/regamedll/regamedll/regamedll_api_impl.h @@ -83,8 +83,8 @@ typedef IHookChainClassImpl CReGameHook_CB typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_RemovePlayerItem; // CBasePlayer::GiveAmmo hook -typedef IHookChainClassImpl CReGameHook_CBasePlayer_GiveAmmo; -typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_GiveAmmo; +typedef IHookChainClassImpl CReGameHook_CBasePlayer_GiveAmmo; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_GiveAmmo; // CBasePlayer::ResetMaxSpeed hook typedef IHookChainClassImpl CReGameHook_CBasePlayer_ResetMaxSpeed;