Skip to content

Commit

Permalink
Don't call HasRestrictItem with type touch when that item is buying
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jun 25, 2020
1 parent c56f00f commit 0cd233d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ static entity_field_alias_t custom_entity_field_alias[] =
};

bool g_bServerActive = false;
bool g_bItemCreatedByBuying = false;
PLAYERPVSSTATUS g_PVSStatus[MAX_CLIENTS];
unsigned short m_usResetDecals;
unsigned short g_iShadowSprite;
Expand Down Expand Up @@ -1493,7 +1494,10 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot)

if (pszItem)
{
g_bItemCreatedByBuying = true;
pPlayer->GiveNamedItem(pszItem);
g_bItemCreatedByBuying = false;

pPlayer->AddAccount(-iItemPrice, RT_PLAYER_BOUGHT_SOMETHING);
}

Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ C_DLLEXPORT int CountTeams();
C_DLLEXPORT int CountTeamPlayers(int iTeam);

extern bool g_bServerActive;
extern bool g_bItemCreatedByBuying;
extern bool g_skipCareerInitialSpawn;

extern unsigned short m_usResetDecals;
Expand Down
8 changes: 6 additions & 2 deletions regamedll/dlls/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,10 @@ void CItemKevlar::Precache()
BOOL CItemKevlar::MyTouch(CBasePlayer *pPlayer)
{
#ifdef REGAMEDLL_ADD
if (pPlayer->HasRestrictItem(ITEM_KEVLAR, ITEM_TYPE_TOUCHED))
if (!g_bItemCreatedByBuying && pPlayer->HasRestrictItem(ITEM_KEVLAR, ITEM_TYPE_TOUCHED))
return FALSE;

g_bItemCreatedByBuying = false;
#endif

#ifdef REGAMEDLL_FIXES
Expand Down Expand Up @@ -423,8 +425,10 @@ void CItemAssaultSuit::Precache()
BOOL CItemAssaultSuit::MyTouch(CBasePlayer *pPlayer)
{
#ifdef REGAMEDLL_ADD
if (pPlayer->HasRestrictItem(ITEM_ASSAULT, ITEM_TYPE_TOUCHED))
if (!g_bItemCreatedByBuying && pPlayer->HasRestrictItem(ITEM_ASSAULT, ITEM_TYPE_TOUCHED))
return FALSE;

g_bItemCreatedByBuying = false;
#endif

#ifdef REGAMEDLL_FIXES
Expand Down

0 comments on commit 0cd233d

Please sign in to comment.