force playing important sounds

see issue #144
This commit is contained in:
titiger 2017-02-02 02:54:29 +01:00
parent 9cc5a7566a
commit f3c436b67f
8 changed files with 17 additions and 11 deletions

View File

@ -490,7 +490,7 @@ void ChatManager::updateNetwork() {
if(msg.chatText.find(playerName) != string::npos){
CoreData &coreData= CoreData::getInstance();
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.playFx(coreData.getHighlightSound());
soundRenderer.playFx(coreData.getHighlightSound(),true);
}
console->addLine(msg.chatText.substr(1,msg.chatText.size()), true, msg.chatPlayerIndex,Vec3f(1.f, 1.f, 1.f),teamMode);
}

View File

@ -3097,7 +3097,7 @@ void Game::addOrReplaceInHighlightedCells(MarkedCell mc){
//printf("faction [%p][%s]\n",faction,(faction != NULL ? faction->getType()->getName().c_str() : ""));
if((faction == NULL) ||
(faction->getTeam() == getWorld()->getThisFaction()->getTeam())) {
soundRenderer.playFx(coreData.getMarkerSound());
soundRenderer.playFx(coreData.getMarkerSound(),true);
}
}
}

View File

@ -203,7 +203,7 @@ void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPo
}
}
void SoundRenderer::playFx(StaticSound *staticSound) {
void SoundRenderer::playFx(StaticSound *staticSound, bool force) {
if(staticSound!=NULL){
staticSound->setVolume(fxVolume);
if(soundPlayer != NULL) {
@ -213,7 +213,7 @@ void SoundRenderer::playFx(StaticSound *staticSound) {
}
if(soundPlayer) {
soundPlayer->play(staticSound);
soundPlayer->play(staticSound, force);
}
}
}

View File

@ -75,7 +75,7 @@ public:
//fx
void playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPos);
void playFx(StaticSound *staticSound);
void playFx(StaticSound *staticSound, bool force=false);
//ambient
void playAmbient(StrSound *strSound);

View File

@ -3127,7 +3127,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
if(world->getAttackWarningsEnabled() == true) {
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound(),true);
world->addAttackEffects(enemyUnit);
}
}

View File

@ -97,7 +97,7 @@ public:
virtual ~SoundPlayerOpenAL();
virtual bool init(const SoundPlayerParams *params);
virtual void end();
virtual void play(StaticSound *staticSound);
virtual void play(StaticSound *staticSound, bool force=false);
virtual void play(StrSound *strSound, int64 fadeOn=0);
virtual void stop(StrSound *strSound, int64 fadeOff=0);
virtual void stopAllSounds(int64 fadeOff=0);

View File

@ -51,7 +51,7 @@ public:
};
virtual bool init(const SoundPlayerParams *params)= 0;
virtual void end()= 0;
virtual void play(StaticSound *staticSound)= 0;
virtual void play(StaticSound *staticSound, bool force=false)= 0;
virtual void play(StrSound *strSound, int64 fadeOn=0)= 0; //delay and fade in miliseconds
virtual void stop(StrSound *strSound, int64 fadeOff=0)= 0;
virtual void stopAllSounds(int64 fadeOff=0)= 0;

View File

@ -516,7 +516,7 @@ void SoundPlayerOpenAL::end() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
void SoundPlayerOpenAL::play(StaticSound* staticSound) {
void SoundPlayerOpenAL::play(StaticSound* staticSound, bool force ) {
assert(staticSound != 0);
if(initOk == false) return;
@ -524,8 +524,14 @@ void SoundPlayerOpenAL::play(StaticSound* staticSound) {
try {
StaticSoundSource* source = findStaticSoundSource();
if(source == 0) {
return;
if(source == 0 ) {
if( force == false )
return;
else {
// force usage of first StaticSoundSource
source = staticSources.front();
source->stop();
}
}
source->play(staticSound);
}