1
0
Fork 0

Properly construct a string from another string and an integer, use a relative path for sound construction, allow enable/disable aimodel sounds using /sim/sound/aimodels/enabled

This commit is contained in:
Erik Hofman 2011-12-03 14:40:48 +01:00
parent 4845037bd7
commit 831f81d97c
2 changed files with 24 additions and 9 deletions

View file

@ -147,7 +147,10 @@ FGAIBase::~FGAIBase() {
if (_refID != 0 && _refID != 1) {
SGSoundMgr *smgr = globals->get_soundmgr();
smgr->remove("aifx:"+_refID);
stringstream name;
name << "aifx:";
name << _refID;
smgr->remove(name.str());
}
delete fp;
@ -221,7 +224,8 @@ void FGAIBase::update(double dt) {
_fx->set_orientation( orient );
SGVec3d velocity;
velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec, pitch*speed );
velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec,
pitch*speed );
_fx->set_velocity( velocity );
}
else if (_aimodel)
@ -234,7 +238,10 @@ void FGAIBase::update(double dt) {
// initialize the sound configuration
SGSoundMgr *smgr = globals->get_soundmgr();
_fx = new FGFX(smgr, "aifx:"+_refID, props);
stringstream name;
name << "aifx:";
name << _refID;
_fx = new FGFX(smgr, name.str(), props);
_fx->init();
}
}

View file

@ -40,11 +40,19 @@
#include <simgear/sound/xmlsound.hxx>
FGFX::FGFX ( SGSoundMgr *smgr, const string &refname, SGPropertyNode *props ) :
_props( props ),
_enabled( fgGetNode("/sim/sound/effects/enabled", true) ),
_volume( fgGetNode("/sim/sound/effects/volume", true) )
_props( props )
{
if (!props) _props = globals->get_props();
if (!props) {
_props = globals->get_props();
_enabled = fgGetNode("/sim/sound/effects/enabled", true);
_volume = fgGetNode("/sim/sound/effects/volume", true);
} else {
_enabled = _props->getNode("/sim/sound/aimodels/enabled", true);
_enabled->setBoolValue(fgGetBool("/sim/sound/effects/enabled"));
_volume = _props->getNode("/sim/sound/aimodels/volume", true);
_volume->setFloatValue(fgGetFloat("/sim/sound/effects/volume"));
_volume->setFloatValue(0.1f);
}
_avionics_enabled = _props->getNode("sim/sound/avionics/enabled", true);
_avionics_volume = _props->getNode("sim/sound/avionics/volume", true);
@ -102,9 +110,9 @@ FGFX::init()
SGXmlSound *sound = new SGXmlSound();
try {
sound->init(globals->get_props(), node->getChild(i), this,
// sound->init(globals->get_props(), node->getChild(i), this,
sound->init(_props, node->getChild(i), this,
_avionics, path.dir());
_sound.push_back(sound);
} catch ( sg_exception &e ) {
SG_LOG(SG_SOUND, SG_ALERT, e.getFormattedMessage());