• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

PC ScriptWarning Log spam when using Pulverizer explosive attack

Insert Name Here

Grizzled Veteran
Oct 3, 2015
205
57
Category: Code

Reproducibility: Always

Summary: When using the Pulverizer's explosive attack, the log gets spammed with 'Accessed array out of bounds' ScriptWarnings.

Description: For one example of this:
Code:
[0116.48] ScriptWarning: Accessed array 'KFWeap_Blunt_Pulverizer_0.UpgradeFireModes' out of bounds (6/6)
    KFWeap_Blunt_Pulverizer kf-sometestmap.TheWorld:PersistentLevel.KFWeap_Blunt_Pulverizer_0
    Function KFGame.KFWeapon:GetUpgradedAfflictionPower:00B7
The issue is between KFGame.KFWeapon and KFGame.KFWeap_MeleeBase. KFWeapon has UpgradeFireModes[] defined at about line 944 (v1075 SDK), with 6 elements (note that this is a static array for whatever reason). However, KFWeap_MeleeBase has a CUSTOM_FIREMODE const set at 6 (which is used for the Pulverizer explosive attack). Because of this, the log gets spammed with the above ScriptWarning when using this attack.

To fix this, either make UpgradeFireModes[] a dynamic array and add UpgradeFireModes[CUSTOM_FIREMODE] to KFWeap_MeleeBase, or just give UpgradeFireModes[] a length of 7.

Online/Offline: Both