From f58b5990206eeda5f73d902aefd6123864cecb05 Mon Sep 17 00:00:00 2001 From: Peter Covington Date: Mon, 18 Apr 2022 17:24:41 -0400 Subject: [PATCH] Fixed custom weapon scripts on client --- sp/src/game/client/c_basecombatweapon.cpp | 7 +++++++ sp/src/game/shared/basecombatweapon_shared.cpp | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sp/src/game/client/c_basecombatweapon.cpp b/sp/src/game/client/c_basecombatweapon.cpp index 3ae13cde..bdb71f02 100644 --- a/sp/src/game/client/c_basecombatweapon.cpp +++ b/sp/src/game/client/c_basecombatweapon.cpp @@ -151,6 +151,13 @@ int C_BaseCombatWeapon::GetWorldModelIndex( void ) //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { +#ifdef MAPBASE + if (updateType == DATA_UPDATE_CREATED) + { + Precache(); + } +#endif // MAPBASE + BaseClass::OnDataChanged(updateType); CHandle< C_BaseCombatWeapon > handle = this; diff --git a/sp/src/game/shared/basecombatweapon_shared.cpp b/sp/src/game/shared/basecombatweapon_shared.cpp index 22fe8b97..f505fafc 100644 --- a/sp/src/game/shared/basecombatweapon_shared.cpp +++ b/sp/src/game/shared/basecombatweapon_shared.cpp @@ -164,7 +164,9 @@ void CBaseCombatWeapon::GiveDefaultAmmo( void ) //----------------------------------------------------------------------------- void CBaseCombatWeapon::Spawn( void ) { +#if !defined(CLIENT_DLL) || !defined(MAPBASE) Precache(); +#endif // !defined(CLIENT_DLL) || !defined(MAPBASE) BaseClass::Spawn(); @@ -239,7 +241,7 @@ const unsigned char *CBaseCombatWeapon::GetEncryptionKey( void ) void CBaseCombatWeapon::Precache( void ) { #if defined( CLIENT_DLL ) - Assert( Q_strlen( GetClassname() ) > 0 ); + Assert( Q_strlen(GetWeaponScriptName() ) > 0 ); // Msg( "Client got %s\n", GetClassname() ); #endif m_iPrimaryAmmoType = m_iSecondaryAmmoType = -1; @@ -321,7 +323,7 @@ void CBaseCombatWeapon::Precache( void ) else { // Couldn't read data file, remove myself - Warning( "Error reading weapon data file for: %s\n", GetClassname() ); + Warning( "Error reading weapon data file for: %s\n", GetWeaponScriptName() ); // Remove( ); //don't remove, this gets released soon! } }