diff --git a/src/game/shared/tf/tf_weapon_buff_item.cpp b/src/game/shared/tf/tf_weapon_buff_item.cpp index 747a1a6316b..d395067aa6d 100644 --- a/src/game/shared/tf/tf_weapon_buff_item.cpp +++ b/src/game/shared/tf/tf_weapon_buff_item.cpp @@ -306,16 +306,24 @@ void CTFBuffItem::CreateBanner() if ( !pPlayer || !pPlayer->IsAlive() ) return; + int iBuffType = GetBuffType(); + // Prevent Crashes From Invalid Buff Types + if ( iBuffType > ARRAYSIZE(BannerModels) || iBuffType <= 0 ) + { + DevMsg("Invalid buff type %d, Not Creating Banner\n", iBuffType); + return; + } + C_TFBuffBanner* pBanner = new C_TFBuffBanner; if ( !pBanner ) return; - + //Assert( iBuffType > 0 ); //Assert( iBuffType <= ARRAYSIZE(BannerModels) ); pBanner->m_nSkin = 0; - pBanner->InitializeAsClientEntity( BannerModels[GetBuffType()-1], RENDER_GROUP_OPAQUE_ENTITY ); + pBanner->InitializeAsClientEntity( BannerModels[iBuffType-1], RENDER_GROUP_OPAQUE_ENTITY ); pBanner->SetBuffItem( this ); - pBanner->SetBuffType( GetBuffType() ); + pBanner->SetBuffType( iBuffType ); pBanner->ForceClientSideAnimationOn(); SetBanner( pBanner ); int iSpine = pPlayer->LookupBone( "bip_spine_3" );