From 88c8e0681f195b8dcf90fcfe281cef2d2ee7aee8 Mon Sep 17 00:00:00 2001 From: hnt_ts Date: Wed, 18 Jun 2008 08:46:20 +0000 Subject: [PATCH] Fixed crash that happened with WW2GI. Thanks to supergoofy for helping me to find the problem. The problem was there(GAME.CON) // loading screen onevent EVENT_GETLOADTILE { sound AAVE // uses spritesound and crashes } endevent Note: the sound was supposed to be played once but with my approach it plays several sounds simultaneously and that's bad. I have chosen not to limit the sound command usage for WW2GI compatibility. I doubt whether I should commit this and decided that it's better to do after all. If you have a better approach, you're welcome. git-svn-id: https://svn.eduke32.com/eduke32@805 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/sounds.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index fa3d2497f..07fdfdfd8 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -512,17 +512,23 @@ void sound(int num) int spritesound(unsigned int num, int i) { if (num >= MAXSOUNDS) return -1; + if (i < 0) + { + sound(num); + return 0; + } return xyzsound(num,i,SX,SY,SZ); } void stopspritesound(int num, int i) { UNREFERENCED_PARAMETER(i); - stopsound(num); + if (num >= 0 && num < MAXSOUNDS) stopsound(num); } void stopsound(int num) { + if (num >= 0 && num < MAXSOUNDS) if (g_sounds[num].num > 0) { FX_StopSound(g_sounds[num].SoundOwner[g_sounds[num].num-1].voice); @@ -534,6 +540,7 @@ void stopenvsound(int num,int i) { int j, k; + if (num >= 0 && num < MAXSOUNDS) if (g_sounds[num].num > 0) { k = g_sounds[num].num;