Skip to content

Commit

Permalink
FIX: Reloading animation bug while holding weapon with altered Maxc…
Browse files Browse the repository at this point in the history
…lip (#861)

* Add functions for default weaponinfo array
* Whitespace cleaning and pointer safety check
* Added reload condition to enhance conditions
  • Loading branch information
dystopm authored Sep 28, 2023
1 parent 8a52b7e commit 67e7d87
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4822,6 +4822,16 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info)
item->fuser2 = weapon->m_flStartThrow;
item->fuser3 = weapon->m_flReleaseThrow;
item->iuser1 = weapon->m_iSwing;

#ifdef REGAMEDLL_FIXES
if (pPlayerItem == pPlayer->m_pActiveItem && !weapon->m_fInReload && weapon->m_iClip == II.iMaxClip)
{
const WeaponInfoStruct *wpnInfo = GetDefaultWeaponInfo(II.iId);

if (wpnInfo && wpnInfo->gunClipSize != II.iMaxClip)
item->m_iClip = wpnInfo->gunClipSize;
}
#endif
}
}

Expand Down
11 changes: 11 additions & 0 deletions regamedll/dlls/weapontype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,17 @@ WeaponInfoStruct *GetWeaponInfo(const char *weaponName)
return nullptr;
}

WeaponInfoStruct *GetDefaultWeaponInfo(int weaponID)
{
for (auto& info : g_weaponInfo_default) {
if (info.id == weaponID) {
return &info;
}
}

return nullptr;
}

AmmoInfoStruct *GetAmmoInfo(const char *ammoName)
{
for (auto& info : g_ammoInfo) {
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/weapontype.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ void WeaponInfoReset();
WeaponInfoStruct *GetWeaponInfo(int weaponID);
WeaponInfoStruct *GetWeaponInfo(const char *weaponName);

WeaponInfoStruct *GetDefaultWeaponInfo(int weaponID);

AmmoInfoStruct *GetAmmoInfo(AmmoType ammoID);
AmmoInfoStruct *GetAmmoInfo(const char *ammoName);

Expand Down

0 comments on commit 67e7d87

Please sign in to comment.