Skip to content

Commit ada2d3b

Browse files
committed
Fixed segfault when haptics.json can't be found and a plasma pistol is fired
1 parent a2a293b commit ada2d3b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

HaloCEVR/WeaponHapticsConfig.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ WeaponHaptic WeaponHapticsConfigManager::GetWeaponHaptics(WeaponType Weapon)
181181
haptic.TwoHand.Dominant = defaultHaptics;
182182
haptic.TwoHand.Nondominant = defaultHaptics;
183183

184-
for (WeaponHaptic currentHaptic : hapticList)
184+
for (WeaponHaptic& currentHaptic : hapticList)
185185
{
186186
if (currentHaptic.Weapon == Weapon)
187187
{
@@ -198,7 +198,7 @@ WeaponHaptic WeaponHapticsConfigManager::GetWeaponHaptics(WeaponType Weapon)
198198
plasmaPistolSettings.RampUpTimer = 0;
199199
}
200200

201-
double percentage = plasmaPistolSettings.RampUpTimer / plasmaPistolSettings.RampUpTicks;
201+
double percentage = plasmaPistolSettings.RampUpTimer / std::max(1, plasmaPistolSettings.RampUpTicks);
202202

203203
double percentageOfChange = std::max(.2, percentage);
204204

0 commit comments

Comments
 (0)