Sound fixes... again. Also fixes SPINNINGNUKEICON visible in the upper left corner in widescreen.

git-svn-id: https://svn.eduke32.com/eduke32@1667 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2010-07-05 04:37:28 +00:00
parent 7be36ebcd4
commit d62c6117fe
2 changed files with 51 additions and 35 deletions

View File

@ -144,6 +144,8 @@ static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n)
if (probey >= n)
probey = 0;
if (x || y)
{
if (centre)
{
// rotatesprite(((320>>1)+(centre)+54)<<16,(y+(probey*i)-4)<<16,65536L,0,SPINNINGNUKEICON+6-((6+(totalclock>>3))%7),sh,0,10,0,0,xdim-1,ydim-1);
@ -154,6 +156,7 @@ static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n)
}
else
rotatesprite((x<<16)-((tilesizx[BIGFNTCURSOR]-4)<<(16-type)),(y+(probey*i)-(4>>type))<<16,65536L>>type,0,SPINNINGNUKEICON+(((totalclock>>3))%7),sh,0,10,0,0,xdim-1,ydim-1);
}
if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Enter) || (LMB && !onbar))
{

View File

@ -322,6 +322,7 @@ void S_Cleanup(void)
{
uint32_t num = ldq[--ldnum];
// num + 65536 is a sound played globally for which there was no open slot to keep track of the voice
if (num >= 65536)
{
g_soundlocks[num-65536]--;
@ -413,7 +414,10 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
if (g_sounds[num].m&128)
{
while (j < MAXSOUNDINSTANCES && g_sounds[num].SoundOwner[j].voice > 0)
if ((voice = S_PlaySound(num)) <= FX_Ok)
return -1;
while (j < MAXSOUNDINSTANCES && g_sounds[num].SoundOwner[j].voice != voice)
j++;
if (j >= MAXSOUNDINSTANCES)
@ -422,18 +426,8 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
return -1;
}
if ((voice = S_PlaySound(num)) <= FX_Ok)
return -1;
if (FX_SetVoiceCallback(voice, (num * MAXSOUNDINSTANCES) + j))
{
OSD_Printf(OSD_ERROR "S_PlaySound3D(): error setting callback!\n");
return -1;
}
g_sounds[num].SoundOwner[j].i = i;
g_sounds[num].num++;
g_sounds[num].SoundOwner[j].voice = voice;
return voice;
}
@ -564,6 +558,7 @@ int32_t S_PlaySound(int32_t num)
{
int32_t pitch, cx;
int32_t voice, j;
int32_t doretry = 0;
if (ud.config.FXDevice < 0) return -1;
if (ud.config.SoundToggle==0) return -1;
@ -597,16 +592,13 @@ int32_t S_PlaySound(int32_t num)
while (j < MAXSOUNDINSTANCES && g_sounds[num].SoundOwner[j].voice > 0)
j++;
if (j >= MAXSOUNDINSTANCES)
{
g_soundlocks[num]--;
return -1;
}
if (j >= MAXSOUNDINSTANCES) // no slots available, so let's see if one opens up after multivoc kills a voice
doretry = 1;
voice = (g_sounds[num].m&1) ?
FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].soundsiz, 65536 + num) :
FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, 65536 + num);
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].soundsiz, (num * MAXSOUNDINSTANCES) + j) :
FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, (num * MAXSOUNDINSTANCES) + j);
if (voice <= FX_Ok)
{
@ -614,6 +606,24 @@ int32_t S_PlaySound(int32_t num)
return -1;
}
if (doretry)
{
S_Cleanup();
j = 0;
while (j < MAXSOUNDINSTANCES && g_sounds[num].SoundOwner[j].voice > 0)
j++;
if (j >= MAXSOUNDINSTANCES) // still no slots available
{
FX_SetVoiceCallback(voice, num + 65536);
return voice;
}
FX_SetVoiceCallback(voice, (num * MAXSOUNDINSTANCES) + j);
}
g_sounds[num].num++;
g_sounds[num].SoundOwner[j].i = -1;
g_sounds[num].SoundOwner[j].voice = voice;
@ -646,11 +656,11 @@ void S_StopEnvSound(int32_t num, int32_t i)
for (j=MAXSOUNDINSTANCES-1; j>=0; j--)
{
if (i == -1 || g_sounds[num].SoundOwner[j].i == i)
if ((i == -1 && g_sounds[num].SoundOwner[j].voice > FX_Ok) || (i != -1 && g_sounds[num].SoundOwner[j].i == i))
{
if (g_sounds[num].SoundOwner[j].voice <= FX_Ok || g_sounds[num].SoundOwner[j].voice > ud.config.NumVoices)
if (i >= 0 && g_sounds[num].SoundOwner[j].voice <= FX_Ok)
initprintf(OSD_ERROR "S_StopEnvSound(): bad voice %d for sound ID %d index %d!\n", g_sounds[num].SoundOwner[j].voice, num, j);
else if (FX_SoundActive(g_sounds[num].SoundOwner[j].voice))
else if (g_sounds[num].SoundOwner[j].voice > FX_Ok && FX_SoundActive(g_sounds[num].SoundOwner[j].voice))
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
// FX_SoundActive returning false could mean one of two things: we asked to stop the sound
@ -675,6 +685,9 @@ void S_Update(void)
S_Cleanup();
if ((g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO)) == 0)
return;
g_numEnvSoundsPlaying = 0;
if (ud.camerasprite == -1)