2006-04-13 20:47:06 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2007-02-08 04:19:39 +00:00
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
|
|
|
Copyright (C) 2004, 2007 - EDuke32 developers
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
This file is part of EDuke32
|
|
|
|
|
|
|
|
EDuke32 is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//#include <conio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "types.h"
|
|
|
|
#include "fx_man.h"
|
|
|
|
#include "music.h"
|
|
|
|
#include "duke3d.h"
|
|
|
|
#include "util_lib.h"
|
2007-08-25 01:05:00 +00:00
|
|
|
#include "osd.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-03-14 21:04:28 +00:00
|
|
|
#ifdef _WIN32
|
2008-03-08 06:51:53 +00:00
|
|
|
#ifdef USE_OPENAL
|
|
|
|
#include "openal.h"
|
|
|
|
#endif
|
2008-03-14 21:04:28 +00:00
|
|
|
#endif
|
2008-03-08 06:51:53 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
#define LOUDESTVOLUME 150
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t backflag,g_numEnvSoundsPlaying;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= SoundStartup
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void S_SoundStartup(void)
|
2006-04-16 03:42:36 +00:00
|
|
|
{
|
2009-02-28 07:44:54 +00:00
|
|
|
int32_t status, err = 0;
|
2006-04-16 03:42:36 +00:00
|
|
|
|
|
|
|
// if they chose None lets return
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.FXDevice < 0) return;
|
2006-04-16 03:42:36 +00:00
|
|
|
|
2009-02-28 07:44:54 +00:00
|
|
|
RETRY:
|
2007-08-27 00:20:15 +00:00
|
|
|
status = FX_Init(ud.config.FXDevice, ud.config.NumVoices, ud.config.NumChannels, ud.config.NumBits, ud.config.MixRate);
|
2006-11-15 01:16:55 +00:00
|
|
|
if (status == FX_Ok)
|
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
FX_SetVolume(ud.config.FXVolume);
|
|
|
|
if (ud.config.ReverseStereo == 1)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2006-04-16 03:42:36 +00:00
|
|
|
FX_SetReverseStereo(!FX_GetReverseStereo());
|
|
|
|
}
|
2008-11-20 14:06:36 +00:00
|
|
|
status = FX_SetCallBack(S_TestSoundCallback);
|
2006-04-16 03:42:36 +00:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (status != FX_Ok)
|
|
|
|
{
|
2009-02-28 07:44:54 +00:00
|
|
|
if (!err)
|
|
|
|
{
|
|
|
|
#if defined(_WIN32)
|
|
|
|
ud.config.MixRate = 44100;
|
|
|
|
#else
|
|
|
|
ud.config.MixRate = 48000;
|
|
|
|
#endif
|
|
|
|
ud.config.NumBits = 16;
|
|
|
|
ud.config.NumChannels = 2;
|
|
|
|
ud.config.NumVoices = 32;
|
|
|
|
ud.config.ReverseStereo = 0;
|
|
|
|
err = 1;
|
|
|
|
goto RETRY;
|
|
|
|
}
|
2009-02-02 01:49:14 +00:00
|
|
|
Bsprintf(tempbuf, "Sound startup error: %s", FX_ErrorString(FX_Error));
|
2008-11-20 14:06:36 +00:00
|
|
|
G_GameExit(tempbuf);
|
2006-04-16 03:42:36 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= SoundShutdown
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void S_SoundShutdown(void)
|
2006-04-16 03:42:36 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t status;
|
2006-04-16 03:42:36 +00:00
|
|
|
|
|
|
|
// if they chose None lets return
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.FXDevice < 0)
|
2006-04-16 03:42:36 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
status = FX_Shutdown();
|
2006-11-15 01:16:55 +00:00
|
|
|
if (status != FX_Ok)
|
|
|
|
{
|
2009-02-02 01:49:14 +00:00
|
|
|
Bsprintf(tempbuf, "Sound shutdown error: %s", FX_ErrorString(FX_Error));
|
2008-11-20 14:06:36 +00:00
|
|
|
G_GameExit(tempbuf);
|
2006-04-16 03:42:36 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= MusicStartup
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void S_MusicStartup(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t status;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
// if they chose None lets return
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.MusicDevice < 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
return;
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
status = MUSIC_Init(ud.config.MusicDevice, 0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if (status == MUSIC_Ok)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
MUSIC_SetVolume(ud.config.MusicVolume);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-28 07:44:54 +00:00
|
|
|
ud.config.MusicDevice = 0;
|
|
|
|
|
|
|
|
status = MUSIC_Init(ud.config.MusicDevice, 0);
|
|
|
|
|
|
|
|
if (status == MUSIC_Ok)
|
|
|
|
{
|
|
|
|
MUSIC_SetVolume(ud.config.MusicVolume);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
initprintf("Couldn't find selected sound card, or, error w/ sound card itself.\n");
|
|
|
|
|
|
|
|
S_SoundShutdown();
|
|
|
|
uninittimer();
|
|
|
|
uninitengine();
|
|
|
|
CONTROL_Shutdown();
|
|
|
|
CONFIG_WriteSetup();
|
|
|
|
KB_Shutdown();
|
|
|
|
uninitgroupfile();
|
|
|
|
//unlink("duke3d.tmp");
|
|
|
|
exit(-1);
|
|
|
|
*/
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= MusicShutdown
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void S_MusicShutdown(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t status;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
// if they chose None lets return
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.MusicDevice < 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
status = MUSIC_Shutdown();
|
2006-11-14 21:35:50 +00:00
|
|
|
if (status != MUSIC_Ok)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-14 21:35:50 +00:00
|
|
|
Error(MUSIC_ErrorString(MUSIC_ErrorCode));
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void S_MenuSound(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t SoundNum=0;
|
|
|
|
static int16_t menusnds[] =
|
2007-08-25 01:05:00 +00:00
|
|
|
{
|
|
|
|
LASERTRIP_EXPLODE,
|
|
|
|
DUKE_GRUNT,
|
|
|
|
DUKE_LAND_HURT,
|
|
|
|
CHAINGUN_FIRE,
|
|
|
|
SQUISHED,
|
|
|
|
KICK_HIT,
|
|
|
|
PISTOL_RICOCHET,
|
|
|
|
PISTOL_BODYHIT,
|
|
|
|
PISTOL_FIRE,
|
|
|
|
SHOTGUN_FIRE,
|
|
|
|
BOS1_WALK,
|
|
|
|
RPG_EXPLODE,
|
|
|
|
PIPEBOMB_BOUNCE,
|
|
|
|
PIPEBOMB_EXPLODE,
|
|
|
|
NITEVISION_ONOFF,
|
|
|
|
RPG_SHOOT,
|
|
|
|
SELECT_WEAPON
|
|
|
|
};
|
2008-11-20 14:06:36 +00:00
|
|
|
S_PlaySound(menusnds[SoundNum++]);
|
2009-02-28 07:44:54 +00:00
|
|
|
SoundNum %= (sizeof(menusnds)/sizeof(menusnds[0]));
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-04-01 09:06:29 +00:00
|
|
|
void _playmusic(const char *fn)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-04-12 21:52:49 +00:00
|
|
|
int32_t fp, l, i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-12-06 23:14:49 +00:00
|
|
|
if (fn == NULL) return;
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.MusicToggle == 0) return;
|
|
|
|
if (ud.config.MusicDevice < 0) return;
|
2008-11-23 03:09:34 +00:00
|
|
|
|
2008-08-20 08:39:07 +00:00
|
|
|
fp = kopen4loadfrommod((char *)fn,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-04-12 21:52:49 +00:00
|
|
|
if (fp == -1)
|
|
|
|
{
|
|
|
|
OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open '%s' for playback!",fn);
|
|
|
|
return;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
l = kfilelength(fp);
|
2008-03-08 05:23:15 +00:00
|
|
|
MUSIC_StopSong();
|
2009-01-05 14:43:12 +00:00
|
|
|
|
2009-04-12 21:52:49 +00:00
|
|
|
MusicPtr = Brealloc(MusicPtr, l);
|
|
|
|
if ((i = kread(fp, (char *)MusicPtr, l)) != l)
|
|
|
|
{
|
|
|
|
OSD_Printf(OSD_ERROR "S_PlayMusic(): error: read %d bytes from '%s', needed %d\n",i, fn, l);
|
|
|
|
kclose(fp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
kclose(fp);
|
2009-01-05 14:43:12 +00:00
|
|
|
|
2008-11-22 11:42:22 +00:00
|
|
|
g_musicSize=l;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-03-01 00:50:59 +00:00
|
|
|
// FIXME: I need this to get the music volume initialized (not sure why) -- Jim Bentler
|
2007-08-27 00:20:15 +00:00
|
|
|
MUSIC_SetVolume(ud.config.MusicVolume);
|
2009-01-09 09:29:17 +00:00
|
|
|
MUSIC_PlaySong((char *)MusicPtr, MUSIC_LoopSong);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t S_PlayMusic(const char *fn, const int32_t sel)
|
2008-04-01 09:06:29 +00:00
|
|
|
{
|
2008-11-22 11:42:22 +00:00
|
|
|
g_musicSize=0;
|
2008-11-20 14:06:36 +00:00
|
|
|
if (MapInfo[sel].musicfn1 != NULL)
|
|
|
|
_playmusic(MapInfo[sel].musicfn1);
|
2008-11-22 11:42:22 +00:00
|
|
|
if (!g_musicSize)
|
2008-04-01 09:06:29 +00:00
|
|
|
{
|
|
|
|
_playmusic(fn);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t S_LoadSound(uint32_t num)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t fp = -1, l;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-10-24 06:48:13 +00:00
|
|
|
if (num >= MAXSOUNDS || ud.config.SoundToggle == 0) return 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.FXDevice < 0) return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-01-26 03:59:34 +00:00
|
|
|
if (g_sounds[num].filename == NULL)
|
|
|
|
{
|
2008-07-27 01:22:17 +00:00
|
|
|
OSD_Printf(OSD_ERROR "Sound (#%d) not defined!\n",num);
|
2008-01-26 03:59:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-28 07:44:54 +00:00
|
|
|
if (g_sounds[num].filename1) fp = kopen4loadfrommod(g_sounds[num].filename1,g_loadFromGroupOnly);
|
2008-11-20 14:06:36 +00:00
|
|
|
if (fp == -1)fp = kopen4loadfrommod(g_sounds[num].filename,g_loadFromGroupOnly);
|
2006-11-13 23:12:47 +00:00
|
|
|
if (fp == -1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
// Bsprintf(ScriptQuotes[113],"g_sounds %s(#%d) not found.",sounds[num],num);
|
|
|
|
// P_DoQuote(113,g_player[myconnectindex].ps);
|
|
|
|
OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);
|
2006-04-13 20:47:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
l = kfilelength(fp);
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].soundsiz = l;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].lock = 200;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-06-05 14:10:18 +00:00
|
|
|
allocache((intptr_t *)&g_sounds[num].ptr,l,(char *)&g_sounds[num].lock);
|
2007-09-11 05:26:38 +00:00
|
|
|
kread(fp, g_sounds[num].ptr , l);
|
2006-11-14 21:35:50 +00:00
|
|
|
kclose(fp);
|
2006-04-13 20:47:06 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:56 +00:00
|
|
|
int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t sndist, cx, cy, cz, j,k;
|
|
|
|
int32_t pitche,pitchs,cs;
|
|
|
|
int32_t voice, sndang, ca, pitch;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
// if(num != 358) return 0;
|
|
|
|
|
2007-10-24 06:48:13 +00:00
|
|
|
if (num >= MAXSOUNDS ||
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.FXDevice < 0 ||
|
2007-09-11 05:26:38 +00:00
|
|
|
((g_sounds[num].m&8) && ud.lockout) ||
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.SoundToggle == 0 ||
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].num > 3 ||
|
|
|
|
FX_VoiceAvailable(g_sounds[num].pr) == 0 ||
|
2007-08-27 06:46:31 +00:00
|
|
|
(g_player[myconnectindex].ps->timebeforeexit > 0 && g_player[myconnectindex].ps->timebeforeexit <= 26*3) ||
|
|
|
|
g_player[myconnectindex].ps->gm&MODE_MENU) return -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].m&128)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
S_PlaySound(num);
|
2006-04-13 20:47:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].m&4)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-07-28 21:23:10 +00:00
|
|
|
if (ud.multimode > 1 && PN == APLAYER && sprite[i].yvel != screenpeek) // other player sound
|
|
|
|
{
|
|
|
|
if (!(ud.config.VoiceToggle&4))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (!(ud.config.VoiceToggle&1))
|
2006-04-16 03:42:36 +00:00
|
|
|
return -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<MAXSOUNDS; j++)
|
|
|
|
for (k=0; k<g_sounds[j].num; k++)
|
2007-09-11 05:26:38 +00:00
|
|
|
if ((g_sounds[j].num > 0) && (g_sounds[j].m&4))
|
2006-04-13 20:47:06 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-08-27 06:46:31 +00:00
|
|
|
cx = g_player[screenpeek].ps->oposx;
|
|
|
|
cy = g_player[screenpeek].ps->oposy;
|
|
|
|
cz = g_player[screenpeek].ps->oposz;
|
|
|
|
cs = g_player[screenpeek].ps->cursectnum;
|
|
|
|
ca = g_player[screenpeek].ps->ang+g_player[screenpeek].ps->look_ang;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 04:40:56 +00:00
|
|
|
sndist = FindDistance3D((cx-pos->x),(cy-pos->y),(cz-pos->z)>>4);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (i >= 0 && (g_sounds[num].m&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9)
|
2006-04-13 20:47:06 +00:00
|
|
|
sndist = divscale14(sndist,(SHT+1));
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
pitchs = g_sounds[num].ps;
|
|
|
|
pitche = g_sounds[num].pe;
|
2006-04-13 20:47:06 +00:00
|
|
|
cx = klabs(pitche-pitchs);
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (cx)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-14 21:35:50 +00:00
|
|
|
if (pitchs < pitche)
|
|
|
|
pitch = pitchs + (rand()%cx);
|
|
|
|
else pitch = pitche + (rand()%cx);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
else pitch = pitchs;
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
sndist += g_sounds[num].vo;
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sndist < 0) sndist = 0;
|
2008-07-29 09:57:09 +00:00
|
|
|
if (cs > -1 && sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX,SY,SZ-(24<<8),SECT))
|
2006-04-13 20:47:06 +00:00
|
|
|
sndist += sndist>>5;
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
switch (num)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case PIPEBOMB_EXPLODE:
|
|
|
|
case LASERTRIP_EXPLODE:
|
|
|
|
case RPG_EXPLODE:
|
|
|
|
if (sndist > (6144))
|
|
|
|
sndist = 6144;
|
2008-07-29 09:57:09 +00:00
|
|
|
if (g_player[screenpeek].ps->cursectnum > -1 && sector[g_player[screenpeek].ps->cursectnum].lotag == 2)
|
2006-11-16 03:02:42 +00:00
|
|
|
pitch -= 1024;
|
|
|
|
break;
|
|
|
|
default:
|
2008-07-29 09:57:09 +00:00
|
|
|
if (g_player[screenpeek].ps->cursectnum > -1 && sector[g_player[screenpeek].ps->cursectnum].lotag == 2 && (g_sounds[num].m&4) == 0)
|
2006-11-16 03:02:42 +00:00
|
|
|
pitch = -768;
|
|
|
|
if (sndist > 31444 && PN != MUSICANDSFX)
|
|
|
|
return -1;
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2007-08-27 06:46:31 +00:00
|
|
|
if (g_player[screenpeek].ps->sound_pitch) pitch += g_player[screenpeek].ps->sound_pitch;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].num > 0 && PN != MUSICANDSFX)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (g_sounds[num].SoundOwner[0].i == i) S_StopSound(num);
|
|
|
|
else if (g_sounds[num].num > 1) S_StopSound(num);
|
|
|
|
else if (A_CheckEnemySprite(&sprite[i]) && sprite[i].extra <= 0) S_StopSound(num);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if (PN == APLAYER && sprite[i].yvel == screenpeek)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
sndang = 0;
|
|
|
|
sndist = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-13 04:40:56 +00:00
|
|
|
sndang = 2048 + ca - getangle(cx-pos->x,cy-pos->y);
|
2006-04-13 20:47:06 +00:00
|
|
|
sndang &= 2047;
|
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].ptr == 0)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (S_LoadSound(num) == 0) return 0;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
else
|
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].lock < 200)
|
|
|
|
g_sounds[num].lock = 200;
|
|
|
|
else g_sounds[num].lock++;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].m&16) sndist = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if (sndist < ((255-LOUDESTVOLUME)<<6))
|
2006-04-13 20:47:06 +00:00
|
|
|
sndist = ((255-LOUDESTVOLUME)<<6);
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].m&1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
uint16_t start;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].num > 0) return -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
start = *(uint16_t *)(g_sounds[num].ptr + 0x14);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (*g_sounds[num].ptr == 'C')
|
|
|
|
voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
|
|
|
|
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
|
2009-02-19 16:47:54 +00:00
|
|
|
else if (*g_sounds[num].ptr == 'O')
|
|
|
|
voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
|
|
|
|
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
|
2008-03-08 07:46:30 +00:00
|
|
|
else
|
2009-02-19 16:47:54 +00:00
|
|
|
voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
|
|
|
|
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
if (*g_sounds[num].ptr == 'C')
|
|
|
|
voice = FX_PlayVOC3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num);
|
2009-02-19 16:47:54 +00:00
|
|
|
else if (*g_sounds[num].ptr == 'O')
|
|
|
|
voice = FX_PlayOGG3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num);
|
2008-03-08 07:46:30 +00:00
|
|
|
else
|
2009-02-19 16:47:54 +00:00
|
|
|
voice = FX_PlayWAV3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if (voice > FX_Ok)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].SoundOwner[g_sounds[num].num].i = i;
|
|
|
|
g_sounds[num].SoundOwner[g_sounds[num].num].voice = voice;
|
|
|
|
g_sounds[num].num++;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2007-09-11 05:26:38 +00:00
|
|
|
else g_sounds[num].lock--;
|
2006-04-13 20:47:06 +00:00
|
|
|
return (voice);
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void S_PlaySound(int32_t num)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t pitch,pitche,pitchs,cx;
|
|
|
|
int32_t voice;
|
|
|
|
int32_t start;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.FXDevice < 0) return;
|
|
|
|
if (ud.config.SoundToggle==0) return;
|
2008-07-28 21:23:10 +00:00
|
|
|
if (!(ud.config.VoiceToggle&1) && (g_sounds[num].m&4)) return;
|
2007-09-11 05:26:38 +00:00
|
|
|
if ((g_sounds[num].m&8) && ud.lockout) return;
|
|
|
|
if (FX_VoiceAvailable(g_sounds[num].pr) == 0) return;
|
2007-10-24 06:48:13 +00:00
|
|
|
if (num > MAXSOUNDS-1 || !g_sounds[num].filename)
|
2007-08-15 03:05:14 +00:00
|
|
|
{
|
2007-08-25 01:05:00 +00:00
|
|
|
OSD_Printf("WARNING: invalid sound #%d\n",num);
|
2007-08-15 03:05:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
pitchs = g_sounds[num].ps;
|
|
|
|
pitche = g_sounds[num].pe;
|
2006-04-13 20:47:06 +00:00
|
|
|
cx = klabs(pitche-pitchs);
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (cx)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-14 21:35:50 +00:00
|
|
|
if (pitchs < pitche)
|
|
|
|
pitch = pitchs + (rand()%cx);
|
|
|
|
else pitch = pitche + (rand()%cx);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
else pitch = pitchs;
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].ptr == 0)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (S_LoadSound(num) == 0) return;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
else
|
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].lock < 200)
|
|
|
|
g_sounds[num].lock = 200;
|
|
|
|
else g_sounds[num].lock++;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].m&1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
if (*g_sounds[num].ptr == 'C')
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
|
2007-09-11 05:26:38 +00:00
|
|
|
voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
|
|
|
|
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
else if (*g_sounds[num].ptr == 'O')
|
|
|
|
{
|
|
|
|
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
|
|
|
|
voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
|
|
|
|
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
|
|
|
|
}
|
2008-03-08 07:46:30 +00:00
|
|
|
else
|
2009-02-19 16:47:54 +00:00
|
|
|
{
|
|
|
|
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
|
|
|
|
voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
|
|
|
|
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
if (*g_sounds[num].ptr == 'C')
|
|
|
|
voice = FX_PlayVOC3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
|
2009-02-19 16:47:54 +00:00
|
|
|
else if (*g_sounds[num].ptr == 'O')
|
|
|
|
voice = FX_PlayOGG3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
|
2008-03-08 07:46:30 +00:00
|
|
|
else
|
2009-02-19 16:47:54 +00:00
|
|
|
voice = FX_PlayWAV3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (voice > FX_Ok) return;
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].lock--;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t A_PlaySound(uint32_t num, int32_t i)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-10-24 06:48:13 +00:00
|
|
|
if (num >= MAXSOUNDS) return -1;
|
2008-06-29 10:40:37 +00:00
|
|
|
if (i < 0)
|
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
S_PlaySound(num);
|
2008-06-29 10:40:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-01-13 04:40:56 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
/*
|
|
|
|
vec3_t davector;
|
|
|
|
Bmemcpy(&davector,&sprite[i],sizeof(intptr_t) * 3); */
|
2009-01-13 04:40:56 +00:00
|
|
|
// OSD_Printf("x: %d y: %d z: %d\n",davector.x,davector.y,davector.z);
|
2009-01-13 12:23:18 +00:00
|
|
|
return S_PlaySoundXYZ(num,i, (vec3_t *)&sprite[i]);
|
2009-01-13 04:40:56 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void A_StopSound(int32_t num, int32_t i)
|
2006-04-16 03:42:36 +00:00
|
|
|
{
|
2008-03-22 10:23:57 +00:00
|
|
|
UNREFERENCED_PARAMETER(i);
|
2008-11-20 14:06:36 +00:00
|
|
|
if (num >= 0 && num < MAXSOUNDS) S_StopSound(num);
|
2006-04-16 03:42:36 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void S_StopSound(int32_t num)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-06-29 10:40:37 +00:00
|
|
|
if (num >= 0 && num < MAXSOUNDS)
|
|
|
|
if (g_sounds[num].num > 0)
|
|
|
|
{
|
|
|
|
FX_StopSound(g_sounds[num].SoundOwner[g_sounds[num].num-1].voice);
|
2008-11-20 14:06:36 +00:00
|
|
|
S_TestSoundCallback(num);
|
2008-06-29 10:40:37 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void S_StopEnvSound(int32_t num,int32_t i)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t j, k;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-06-29 10:40:37 +00:00
|
|
|
if (num >= 0 && num < MAXSOUNDS)
|
|
|
|
if (g_sounds[num].num > 0)
|
|
|
|
{
|
|
|
|
k = g_sounds[num].num;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<k; j++)
|
2008-06-29 10:40:37 +00:00
|
|
|
if (g_sounds[num].SoundOwner[j].i == i)
|
|
|
|
{
|
|
|
|
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-02-28 07:44:54 +00:00
|
|
|
void S_Pan3D(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t sndist, sx, sy, sz, cx, cy, cz;
|
|
|
|
int32_t sndang,ca,j,k,i,cs;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_numEnvSoundsPlaying = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (ud.camerasprite == -1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-08-27 06:46:31 +00:00
|
|
|
cx = g_player[screenpeek].ps->oposx;
|
|
|
|
cy = g_player[screenpeek].ps->oposy;
|
|
|
|
cz = g_player[screenpeek].ps->oposz;
|
|
|
|
cs = g_player[screenpeek].ps->cursectnum;
|
|
|
|
ca = g_player[screenpeek].ps->ang+g_player[screenpeek].ps->look_ang;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cx = sprite[ud.camerasprite].x;
|
|
|
|
cy = sprite[ud.camerasprite].y;
|
|
|
|
cz = sprite[ud.camerasprite].z;
|
|
|
|
cs = sprite[ud.camerasprite].sectnum;
|
|
|
|
ca = sprite[ud.camerasprite].ang;
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<MAXSOUNDS; j++) for (k=0; k<g_sounds[j].num; k++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
i = g_sounds[j].SoundOwner[k].i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
sx = sprite[i].x;
|
|
|
|
sy = sprite[i].y;
|
|
|
|
sz = sprite[i].z;
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if (PN == APLAYER && sprite[i].yvel == screenpeek)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
sndang = 0;
|
|
|
|
sndist = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sndang = 2048 + ca - getangle(cx-sx,cy-sy);
|
|
|
|
sndang &= 2047;
|
|
|
|
sndist = FindDistance3D((cx-sx),(cy-sy),(cz-sz)>>4);
|
2007-09-11 05:26:38 +00:00
|
|
|
if (i >= 0 && (g_sounds[j].m&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9)
|
2006-04-13 20:47:06 +00:00
|
|
|
sndist = divscale14(sndist,(SHT+1));
|
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
sndist += g_sounds[j].vo;
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sndist < 0) sndist = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-07-29 09:57:09 +00:00
|
|
|
if (cs > -1 && sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT))
|
2006-04-13 20:47:06 +00:00
|
|
|
sndist += sndist>>5;
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (PN == MUSICANDSFX && SLT < 999)
|
2008-11-20 14:06:36 +00:00
|
|
|
g_numEnvSoundsPlaying++;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
switch (j)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case PIPEBOMB_EXPLODE:
|
|
|
|
case LASERTRIP_EXPLODE:
|
|
|
|
case RPG_EXPLODE:
|
|
|
|
if (sndist > (6144)) sndist = (6144);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (sndist > 31444 && PN != MUSICANDSFX)
|
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
S_StopSound(j);
|
2006-11-16 03:02:42 +00:00
|
|
|
continue;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (g_sounds[j].ptr == 0 && S_LoadSound(j) == 0) continue;
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[j].m&16) sndist = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if (sndist < ((255-LOUDESTVOLUME)<<6))
|
2006-04-13 20:47:06 +00:00
|
|
|
sndist = ((255-LOUDESTVOLUME)<<6);
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
FX_Pan3D(g_sounds[j].SoundOwner[k].voice,sndang>>6,sndist>>6);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void S_TestSoundCallback(uint32_t num)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t tempi,tempj,tempk;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
if ((int32_t)num < 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-05 11:49:13 +00:00
|
|
|
if (lumplockbyte[num] >= 200)
|
|
|
|
lumplockbyte[num]--;
|
2006-04-13 20:47:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
tempk = g_sounds[num].num;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (tempk > 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
if ((g_sounds[num].m&16) == 0)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (tempj=0; tempj<tempk; tempj++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
tempi = g_sounds[num].SoundOwner[tempj].i;
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sprite[tempi].picnum == MUSICANDSFX && sector[sprite[tempi].sectnum].lotag < 3 && sprite[tempi].lotag < 999)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
ActorExtra[tempi].temp_data[0] = 0;
|
2006-11-14 21:35:50 +00:00
|
|
|
if ((tempj + 1) < tempk)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].SoundOwner[tempj].voice = g_sounds[num].SoundOwner[tempk-1].voice;
|
|
|
|
g_sounds[num].SoundOwner[tempj].i = g_sounds[num].SoundOwner[tempk-1].i;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].num--;
|
|
|
|
g_sounds[num].SoundOwner[tempk-1].i = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].lock--;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void S_ClearSoundLocks(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSOUNDS; i++)
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[i].lock >= 200)
|
|
|
|
g_sounds[i].lock = 199;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<11; i++)
|
2006-11-13 23:12:47 +00:00
|
|
|
if (lumplockbyte[i] >= 200)
|
2006-04-13 20:47:06 +00:00
|
|
|
lumplockbyte[i] = 199;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t A_CheckSoundPlaying(int32_t i, int32_t num)
|
2006-04-16 03:42:36 +00:00
|
|
|
{
|
2008-03-22 10:23:57 +00:00
|
|
|
UNREFERENCED_PARAMETER(i);
|
2006-04-16 03:42:36 +00:00
|
|
|
if (num < 0) num=0; // FIXME
|
2007-09-11 05:26:38 +00:00
|
|
|
return (g_sounds[num].num > 0);
|
2006-04-16 03:42:36 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t S_CheckSoundPlaying(int32_t i, int32_t num)
|
2006-04-16 03:42:36 +00:00
|
|
|
{
|
2006-11-15 01:16:55 +00:00
|
|
|
if (i == -1)
|
|
|
|
{
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].lock == 200)
|
2006-07-01 12:10:29 +00:00
|
|
|
return 1;
|
2006-12-15 01:09:25 +00:00
|
|
|
return 0;
|
2006-07-01 12:10:29 +00:00
|
|
|
}
|
2007-09-11 05:26:38 +00:00
|
|
|
return(g_sounds[num].num);
|
2006-04-16 03:42:36 +00:00
|
|
|
}
|