extern int mainmenu;
extern int channels[100];
-extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
extern bool showdamagebar;
extern int channels[100];
-extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
flashr=1;
extern int accountcampaignchoicesmade[10];
extern int accountcampaignchoices[10][5000];
-extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
void LOG(const std::string &fmt, ...)
return !strncasecmp(str, pfx, strlen(pfx));
}
-extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
cmd_handlers[i](game, cmd + strlen(cmd_names[i]));
break;
}
- if (i < n_cmds)
- {
- PlaySoundEx(consolesuccesssound, samp[consolesuccesssound], NULL, true);
- OPENAL_SetVolume(channels[consolesuccesssound], 256);
- OPENAL_SetPaused(channels[consolesuccesssound], false);
- }
- else
- {
- PlaySoundEx(consolefailsound, samp[consolefailsound], NULL, true);
- OPENAL_SetVolume(channels[consolefailsound], 256);
- OPENAL_SetPaused(channels[consolefailsound], false);
- }
+ emit_sound_np(i < n_cmds ? consolesuccesssound : consolefailsound);
}
/********************> Tick() <*****/
changedelay=0;
if(console)
{
- PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
- OPENAL_SetVolume(channels[consolesuccesssound], 256);
- OPENAL_SetPaused(channels[consolesuccesssound], false);
+ emit_sound_np(consolesuccesssound);
freeze=0;
console=0;
}
if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown&&tutoriallevel){
if(tutorialstage!=51)
tutorialstagetime=tutorialmaxtime;
- PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
- OPENAL_SetVolume(channels[consolefailsound], 128);
- OPENAL_SetPaused(channels[consolefailsound], false);
+ emit_sound_np(consolefailsound, 128.);
minimaptogglekeydown=1;
}
if(!Input::isKeyDown(SDLK_TAB)){
static int oldwinfreeze;
if(winfreeze&&!oldwinfreeze){
OPENAL_SetFrequency(OPENAL_ALL, 0.001);
- PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
- OPENAL_SetVolume(channels[consolesuccesssound], 256);
- OPENAL_SetPaused(channels[consolesuccesssound], false);
+ emit_sound_np(consolesuccesssound);
}
if(winfreeze==0)oldwinfreeze=winfreeze;
else oldwinfreeze++;
if(tutorialstagetime==tutorialmaxtime-3){
- PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
- OPENAL_SetVolume(channels[consolesuccesssound], 256);
- OPENAL_SetPaused(channels[consolesuccesssound], false);
+ emit_sound_np(consolesuccesssound);
}
if(tutorialsuccess>=1){
if(tutoriallevel!=1){
if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
- PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
- OPENAL_SetVolume(channels[consolesuccesssound], 256);
- OPENAL_SetPaused(channels[consolesuccesssound], false);
+ emit_sound_np(consolesuccesssound);
}
}
else
if(bonustime==0){
- PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
- OPENAL_SetVolume(channels[fireendsound], 256);
- OPENAL_SetPaused(channels[fireendsound], false);
+ emit_sound_np(fireendsound);
}
if(bonustime==0){
if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
if(musictoggle){
if(musictype!=oldmusictype&&musictype==stream_music2){
- static float gLoc[3];
- static float vel[3];
- gLoc[0]=cameraloc.x;
- gLoc[1]=cameraloc.y;
- gLoc[2]=cameraloc.z;
- vel[0]=0;
- vel[1]=0;
- vel[2]=0;
- PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
- OPENAL_SetVolume(channels[alarmsound], 512);
- OPENAL_SetPaused(channels[alarmsound], false);
+ emit_sound_np(alarmsound);
}
}
extern Game * pgame;
extern bool visibleloading;
-extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
void dealloc2(void* param){
free(param);
OPENAL_SetPaused (channels[soundid], false);
}
+void
+emit_sound_np(int soundid, float vol)
+{
+ PlaySoundEx (soundid, samp[soundid], NULL, true);
+ OPENAL_SetVolume (channels[soundid], vol);
+ OPENAL_SetPaused (channels[soundid], false);
+}
+
void
emit_stream_at(int soundid, const XYZ &pos, float vol)
{
extern void loadAllSounds();
extern void emit_sound_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f);
+extern void emit_sound_np(int soundid, float vol = 256.f);
extern void emit_stream_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f);
extern int footstepsound, footstepsound2, footstepsound3, footstepsound4;
extern bool freeze;
extern int tutoriallevel;
extern int numthrowkill;
-extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
void Weapons::DoStuff(){
static int i,whichpatchx,whichpatchz,j,k,whichhit,m;
else velocity[i]+=bounceness*elasticity;
//if (type[i]==knife) printf("velocity of knife %d now %f,%f,%f.\n", i, velocity[i].x, velocity[i].y, velocity[i].z);
if(findLengthfast(&bounceness)>1){
- float gLoc[3];
- float vel[3];
int whichsound;
if(terrain.getOpacity(position[i].x,position[i].z)>.2){
if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
}
else whichsound=footstepsound+abs(Random()%2);
- gLoc[0]=position[i].x;
- gLoc[1]=position[i].y;
- gLoc[2]=position[i].z;
- vel[0]=0;
- vel[1]=0;
- vel[2]=0;
- PlaySoundEx( whichsound, samp[whichsound], NULL, true);
- OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
- if(terrain.getOpacity(position[i].x,position[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
- else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
- OPENAL_SetPaused(channels[whichsound], false);
+ emit_sound_at(whichsound, position[i],
+ findLengthfast(&bounceness)
+ * (terrain.getOpacity(position[i].x,position[i].z) > .2
+ ? 128.
+ : 32.));
if(terrain.getOpacity(position[i].x,position[i].z)<.2){
XYZ terrainlight;
//if (type[i]==knife) printf("tipvelocity of knife %d now %f,%f,%f.\n", i, tipvelocity[i].x, tipvelocity[i].y, tipvelocity[i].z);
if(findLengthfast(&bounceness)>1){
- float gLoc[3];
- float vel[3];
int whichsound;
if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2){
if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
}
else whichsound=footstepsound+abs(Random()%2);
- gLoc[0]=tippoint[i].x;
- gLoc[1]=tippoint[i].y;
- gLoc[2]=tippoint[i].z;
- vel[0]=0;
- vel[1]=0;
- vel[2]=0;
- PlaySoundEx( whichsound, samp[whichsound], NULL, true);
- OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
- if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
- else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
- OPENAL_SetPaused(channels[whichsound], false);
+ emit_sound_at(whichsound, tippoint[i],
+ findLengthfast(&bounceness)
+ * (terrain.getOpacity(tippoint[i].x,tippoint[i].z) > .2
+ ? 128.
+ : 32.));
if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)<.2){
XYZ terrainlight;
else velocity[i]+=bounceness*elasticity;
if(findLengthfast(&bounceness)>1){
- float gLoc[3];
- float vel[3];
int whichsound;
if(terrain.getOpacity(mid.x,mid.z)>.2){
if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
}
else whichsound=footstepsound+abs(Random()%2);
- gLoc[0]=mid.x;
- gLoc[1]=mid.y;
- gLoc[2]=mid.z;
- vel[0]=0;
- vel[1]=0;
- vel[2]=0;
- PlaySoundEx( whichsound, samp[whichsound], NULL, true);
- OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
- if(terrain.getOpacity(position[i].x,position[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
- else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
- OPENAL_SetPaused(channels[whichsound], false);
+ emit_sound_at(whichsound, mid,
+ findLengthfast(&bounceness)
+ * (terrain.getOpacity(position[i].x,position[i].z) > .2
+ ? 128.
+ : 32.));
}
position[i]+=(mid-oldmid)*20;
}
else tipvelocity[i]+=bounceness*elasticity;
if(findLengthfast(&bounceness)>1){
- float gLoc[3];
- float vel[3];
int whichsound;
if(terrain.getOpacity(mid.x,mid.z)>.2){
if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
}
else whichsound=footstepsound+abs(Random()%2);
- gLoc[0]=mid.x;
- gLoc[1]=mid.y;
- gLoc[2]=mid.z;
- vel[0]=0;
- vel[1]=0;
- vel[2]=0;
- PlaySoundEx( whichsound, samp[whichsound], NULL, true);
- OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
- if(terrain.getOpacity(position[i].x,position[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
- else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
- OPENAL_SetPaused(channels[whichsound], false);
+ emit_sound_at(whichsound, mid,
+ findLengthfast(&bounceness)
+ * (terrain.getOpacity(position[i].x,position[i].z) > .2
+ ? 128.
+ : 32.));
}
tippoint[i]+=(mid-oldmid)*20;
}