Final round (I hope!) of sound fixes. Should also fix the crash on exit on Windows and the REACTOR sprite size bug.

git-svn-id: https://svn.eduke32.com/eduke32@1662 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2010-06-26 08:51:42 +00:00
parent 1905a1cf02
commit 0b5de0800a
14 changed files with 111 additions and 86 deletions

View file

@ -2269,6 +2269,7 @@ static void md3free(md3model_t *m)
if (s->shaders) Bfree(s->shaders);
if (s->uv) Bfree(s->uv);
if (s->xyzn) Bfree(s->xyzn);
if (s->geometry) Bfree(s->geometry);
}
}
Bfree(m->head.surfs);
@ -3191,7 +3192,7 @@ int32_t mddraw(spritetype *tspr)
void mdfree(mdmodel_t *vm)
{
if (vm->mdnum == 1) { voxfree((voxmodel_t *)vm); return; }
if (vm->mdnum == 3) { md3free((md3model_t *)vm); return; }
if (vm->mdnum == 2 || vm->mdnum == 3) { md3free((md3model_t *)vm); return; }
}
#endif

View file

@ -99,6 +99,7 @@
<ClInclude Include="build\include\polymer.h" />
<ClInclude Include="build\include\polymost.h" />
<ClInclude Include="build\include\pragmas.h" />
<ClInclude Include="build\include\prlights.h" />
<ClInclude Include="build\include\quicklz.h" />
<ClInclude Include="build\include\rawinput.h" />
<ClInclude Include="build\include\scriptfile.h" />

View file

@ -318,6 +318,9 @@
<ClInclude Include="build\src\engine_priv.h">
<Filter>build\headers</Filter>
</ClInclude>
<ClInclude Include="build\include\prlights.h">
<Filter>build\headers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="build\src\a-c.c">

View file

@ -1090,6 +1090,7 @@ extern hashtable_t h_gamevars;
extern hashtable_t h_arrays;
extern hashtable_t h_keywords;
extern hashtable_t h_gamefuncs;
extern hashtable_t h_labels;
enum DukePacket_t
{

View file

@ -3664,10 +3664,6 @@ void G_GameExit(const char *t)
if (*t != 0)
{
//setvmode(0x3); // JBF
//binscreen();
// if(*t == ' ' && *(t+1) == 0) *t = 0;
//printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
if (!(t[0] == ' ' && t[1] == 0))
{
char titlebuf[256];
@ -3678,8 +3674,6 @@ void G_GameExit(const char *t)
uninitgroupfile();
//unlink("duke3d.tmp");
exit(0);
}
@ -6589,6 +6583,13 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case REACTOR2__STATIC:
case REACTOR__STATIC:
sp->extra = g_impactDamage;
CS |= 257;
sp->pal = 0;
SS = -17;
changespritestat(i, STAT_ZOMBIEACTOR);
break;
case HEAVYHBOMB__STATIC:
if (j >= 0)
sp->owner = j;
@ -6612,22 +6613,22 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case RECON__STATIC:
if (sp->lotag > ud.player_skill)
{
sp->xrepeat = sp->yrepeat = 0;
changespritestat(i,5);
goto SPAWN_END;
}
g_player[myconnectindex].ps->max_actors_killed++;
actor[i].t_data[5] = 0;
if (ud.monsters_off == 1)
{
sp->xrepeat = sp->yrepeat = 0;
changespritestat(i,5);
break;
}
sp->extra = 130;
CS |= 256; // Make it hitable
if (sp->lotag > ud.player_skill)
{
sp->xrepeat = sp->yrepeat = 0;
changespritestat(i,5);
goto SPAWN_END;
}
g_player[myconnectindex].ps->max_actors_killed++;
actor[i].t_data[5] = 0;
if (ud.monsters_off == 1)
{
sp->xrepeat = sp->yrepeat = 0;
changespritestat(i,5);
break;
}
sp->extra = 130;
CS |= 256; // Make it hitable
if ((!g_netServer && ud.multimode < 2) && sp->pal != 0)
{
@ -10637,24 +10638,7 @@ static void G_DisplayLogo(void)
clearview(0L);
}
/*
static void loadtmb(void)
{
char tmb[8000];
int32_t fil, l;
fil = kopen4load("d3dtimbr.tmb",0);
if (fil == -1) return;
l = kfilelength(fil);
kread(fil,(char *)tmb,l);
MUSIC_RegisterTimbreBank(tmb);
kclose(fil);
}
*/
extern void C_FreeHashes();
static void G_FreeMemory(void)
static void G_Cleanup(void)
{
int32_t i;
extern char *bitptr;
@ -10693,7 +10677,9 @@ static void G_FreeMemory(void)
// if (MusicPtr != NULL) Bfree(MusicPtr);
// C_FreeHashes();
hash_free(&h_gamevars);
hash_free(&h_arrays);
hash_free(&h_labels);
hash_free(&h_gamefuncs);
}
@ -10707,14 +10693,13 @@ static void G_FreeMemory(void)
void G_Shutdown(void)
{
CONFIG_WriteSetup();
S_SoundShutdown();
S_MusicShutdown();
uninittimer();
CONTROL_Shutdown();
CONFIG_WriteSetup();
KB_Shutdown();
G_FreeMemory();
uninitengine();
G_Cleanup();
}
/*
@ -10871,7 +10856,7 @@ static void G_Startup(void)
{
wm_msgbox("Build Engine Initialization Error",
"There was a problem initializing the Build engine: %s", engineerrstr);
G_FreeMemory();
G_Cleanup();
exit(1);
}

View file

@ -1005,13 +1005,6 @@ void C_InitHashes()
for (i=0; TsprLabels[i].lId >= 0; i++) hash_add(&tspriteH,TsprLabels[i].name,i);
}
void C_FreeHashes(void)
{
hash_free(&h_gamevars);
hash_free(&h_arrays);
hash_free(&h_labels);
}
// "magic" number for { and }, overrides line number in compiled code for later detection
#define IFELSE_MAGIC 31337
static int32_t g_ifElseAborted;

View file

@ -85,7 +85,7 @@ void MUSIC_GetSongLength( songposition *pos );
int32_t MUSIC_FadeVolume( int32_t tovolume, int32_t milliseconds );
int32_t MUSIC_FadeActive( void );
void MUSIC_StopFade( void );
void MUSIC_RerouteMidiChannel( int32_t channel, int32_t ( *function )( int32_t event, int32_t c1, int32_t c2 ) );
void MUSIC_RerouteMidiChannel( int32_t channel, int32_t ( *function )( int32_t, int32_t, int32_t ) );
void MUSIC_RegisterTimbreBank( char *timbres );
void MUSIC_Update(void);

View file

@ -307,7 +307,7 @@ void MV_16BitReverb( char *src, char *dest, VOLUME16 *volume, int32_t count )
input++;
output++;
} while (count-- > 0);
} while (--count > 0);
}
void MV_8BitReverb( int8_t *src, int8_t *dest, VOLUME16 *volume, int32_t count )
@ -320,7 +320,7 @@ void MV_8BitReverb( int8_t *src, int8_t *dest, VOLUME16 *volume, int32_t count )
input++;
output++;
} while (count-- > 0);
} while (--count > 0);
}
void MV_16BitReverbFast( char *src, char *dest, int32_t count, int32_t shift )
@ -333,7 +333,7 @@ void MV_16BitReverbFast( char *src, char *dest, int32_t count, int32_t shift )
input++;
output++;
} while (count-- > 0);
} while (--count > 0);
}
void MV_8BitReverbFast( int8_t *src, int8_t *dest, int32_t count, int32_t shift )
@ -348,6 +348,6 @@ void MV_8BitReverbFast( int8_t *src, int8_t *dest, int32_t count, int32_t shift
src++;
dest++;
} while (count-- > 0);
} while (--count > 0);
}

View file

@ -2634,8 +2634,7 @@ int32_t MV_Init
{
status = MV_ErrorCode;
if (MV_Voices)
free(MV_Voices);
free(MV_Voices);
MV_Voices = NULL;
MV_HarshClipTable = NULL;
MV_TotalMemory = 0;
@ -2714,8 +2713,7 @@ int32_t MV_Shutdown
SoundDriver_Shutdown();
// Free any voices we allocated
if (MV_Voices)
free(MV_Voices);
free(MV_Voices);
MV_Voices = NULL;
MV_TotalMemory = 0;

View file

@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define GTFLAGS(x) (GametypeFlags[ud.coop] & x)
#define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = nextspritesect[o], (o) != -1; (o) = (n))
#define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = nextspritestat[o], (o) != -1; (o) = (n))
#define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); ((o) != -1) && ((n) = nextspritesect[o]); (o) = (n))
#define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); ((o) != -1) && ((n) = nextspritestat[o]); (o) = (n))
#define TRAVERSE_CONNECT(i) for (i = 0; i != -1; i = connectpoint2[i])
#define TEST(flags,mask) ((flags) & (mask))

View file

@ -50,7 +50,7 @@ static const int32_t _MIDI_CommandLengths[ NUM_MIDI_CHANNELS ] =
0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 2, 0
};
static int32_t (*_MIDI_RerouteFunctions[ NUM_MIDI_CHANNELS ])(int32_t event, int32_t c1, int32_t c2);
static int32_t (*_MIDI_RerouteFunctions[ NUM_MIDI_CHANNELS ])(int32_t, int32_t, int32_t);
static track *_MIDI_TrackPtr = NULL;
static int32_t _MIDI_TrackMemSize;
@ -736,7 +736,7 @@ static int32_t _MIDI_SendControlChange
void MIDI_RerouteMidiChannel
(
int32_t channel,
int32_t(*function)(int32_t event, int32_t c1, int32_t c2)
int32_t(*function)(int32_t, int32_t, int32_t)
)
{

View file

@ -566,7 +566,7 @@ void MUSIC_StopFade
void MUSIC_RerouteMidiChannel
(
int32_t channel,
int32_t(*function)(int32_t event, int32_t c1, int32_t c2)
int32_t(*function)(int32_t, int32_t, int32_t)
)
{

View file

@ -349,7 +349,7 @@ void MUSIC_StopFade(void)
} // MUSIC_StopFade
void MUSIC_RerouteMidiChannel(int32_t channel, int32_t (*function)(int32_t event, int32_t c1, int32_t c2))
void MUSIC_RerouteMidiChannel(int32_t channel, int32_t (*function)(int32_t, int32_t, int32_t))
{
UNREFERENCED_PARAMETER(channel);
UNREFERENCED_PARAMETER(function);

View file

@ -613,25 +613,34 @@ int32_t A_PlaySound(uint32_t num, int32_t i)
void S_StopSound(int32_t num)
{
int32_t iter = 0;
if (num < 0 || num > g_maxSoundPos || g_sounds[num].num <= 0)
return;
retry:
retry:
if (iter > MAXSOUNDINSTANCES)
{
int32_t j=MAXSOUNDINSTANCES-1;
initprintf(OSD_ERROR "S_StopSound(): too many iterations! The following IDs are still active for sound %d:\n", num);
for (; j>=0; j--)
if (g_sounds[num].SoundOwner[j].voice)
initprintf("slot %d, voice %d, sprite %d\n", j, g_sounds[num].SoundOwner[j].voice, g_sounds[num].SoundOwner[j].i);
return;
}
{
int32_t j=MAXSOUNDINSTANCES-1;
iter++;
for (; j>=0; j--)
{
if (g_sounds[num].SoundOwner[j].voice)
{
if (g_sounds[num].SoundOwner[j].voice > FX_Ok && g_sounds[num].SoundOwner[j].voice <= ud.config.NumVoices)
{
if (FX_SoundActive(g_sounds[num].SoundOwner[j].voice))
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
S_Cleanup();
goto retry;
}
else
if (g_sounds[num].SoundOwner[j].voice <= FX_Ok || g_sounds[num].SoundOwner[j].voice > ud.config.NumVoices)
{
initprintf(OSD_ERROR "S_StopSound(): bad voice %d for sound ID %d index %d!\n", g_sounds[num].SoundOwner[j].voice, num, j);
mutex_lock(&s_mutex);
@ -640,6 +649,17 @@ void S_StopSound(int32_t num)
S_Cleanup();
goto retry;
}
if (FX_SoundActive(g_sounds[num].SoundOwner[j].voice))
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
else
{
mutex_lock(&s_mutex);
dq[dnum++] = (num * MAXSOUNDINSTANCES) + j;
mutex_unlock(&s_mutex);
}
S_Cleanup();
goto retry;
}
}
}
@ -647,25 +667,33 @@ void S_StopSound(int32_t num)
void S_StopEnvSound(int32_t num,int32_t i)
{
int32_t iter = 0;
if (num < 0 || num > g_maxSoundPos || g_sounds[num].num <= 0)
return;
retry:
retry:
if (iter > MAXSOUNDINSTANCES)
{
int32_t j=MAXSOUNDINSTANCES-1;
initprintf(OSD_ERROR "S_StopEnvSound(): too many iterations! The following IDs are still active for sound %d:\n", num);
for (; j>=0; j--)
if (g_sounds[num].SoundOwner[j].i == i)
initprintf("slot %d, voice %d, sprite %d\n", j, g_sounds[num].SoundOwner[j].voice, g_sounds[num].SoundOwner[j].i);
return;
}
{
int32_t j=MAXSOUNDINSTANCES-1;
iter++;
for (; j>=0; j--)
{
if (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 (FX_SoundActive(g_sounds[num].SoundOwner[j].voice))
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
S_Cleanup();
goto retry;
}
else
if (g_sounds[num].SoundOwner[j].voice <= FX_Ok || g_sounds[num].SoundOwner[j].voice > ud.config.NumVoices)
{
initprintf(OSD_ERROR "S_StopEnvSound(): bad voice %d for sound ID %d index %d!\n", g_sounds[num].SoundOwner[j].voice, num, j);
mutex_lock(&s_mutex);
@ -674,6 +702,21 @@ void S_StopEnvSound(int32_t num,int32_t i)
S_Cleanup();
goto retry;
}
if (FX_SoundActive(g_sounds[num].SoundOwner[j].voice))
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
else
{
// FX_SoundActive returning false could mean one of two things: we asked to stop the sound
// right when it was done playing, or we lost track of a voice somewhere (didn't get the callback)
// the first scenario resolves itself, and this addresses the second
mutex_lock(&s_mutex);
dq[dnum++] = (num * MAXSOUNDINSTANCES) + j;
mutex_unlock(&s_mutex);
}
S_Cleanup();
goto retry;
}
}
}