From 1e2b5c2747fbb4fa528da24471253d84d2bf5e35 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 29 Jun 2023 18:28:16 +0200 Subject: [PATCH] - added missing range checks to PlaySpriteSound. This can be called with attr_none! --- source/games/sw/src/ai.h | 3 ++- source/games/sw/src/sounds.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/games/sw/src/ai.h b/source/games/sw/src/ai.h index 5df57cebf..8f889affa 100644 --- a/source/games/sw/src/ai.h +++ b/source/games/sw/src/ai.h @@ -62,7 +62,8 @@ enum ActorStates { SLOW_SPEED, NORM_SPEED, MID_SPEED, FAST_SPEED, MAX_SPEED}; enum ATTRIB_SNDS { - attr_ambient = 1, attr_alert, attr_attack, attr_pain, attr_die, + attr_none = 0, + attr_ambient, attr_alert, attr_attack, attr_pain, attr_die, attr_extra1, attr_extra2, attr_extra3,attr_extra4,attr_extra5, attr_extra6, MAXATTRIBSNDS }; diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index 8f2e1684c..ecc23bcf1 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -718,7 +718,7 @@ void Terminate3DSounds(void) void PlaySpriteSound(DSWActor* actor, int attrib_ndx, int flags) { - if (actor->hasU()) + if (actor->hasU() && attrib_ndx > attr_none && attrib_ndx < MAXATTRIBSNDS) PlaySound(actor->user.__legacyState.Attrib->Sounds[attrib_ndx - 1], actor, flags); }