Skip to content

Commit bf46ce7

Browse files
finger563Copilot
andauthored
Update components/doom/src/doom.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent bc1f6dc commit bf46ce7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

components/doom/src/doom.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,14 @@ extern "C" {
125125
void R_PlayerFire(player_t *player) {
126126
static auto& box = BoxEmu::get();
127127
int weapon_fired = player->readyweapon;
128-
int haptic_effect_index = WeaponHapticLookup[weapon_fired];
129-
box.play_haptic_effect(haptic_effect_index);
128+
if (weapon_fired >= 0 && weapon_fired < sizeof(WeaponHapticLookup) / sizeof(WeaponHapticLookup[0])) {
129+
int haptic_effect_index = WeaponHapticLookup[weapon_fired];
130+
box.play_haptic_effect(haptic_effect_index);
131+
} else {
132+
// Handle invalid weapon index (e.g., log an error or use a default effect)
133+
// For now, we skip playing the haptic effect.
134+
// Example: box.play_haptic_effect(DEFAULT_HAPTIC_EFFECT);
135+
}
130136
}
131137

132138
void R_PlayerHurt(player_t *player, int damage, int saved) {

0 commit comments

Comments
 (0)