Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2009, 10:09:27 PM (15 years ago)
Author:
scheusso
Message:

Approach to make sounds synchronisable (not yet working)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc

    r6265 r6307  
    7171        this->muzzleOrientation_ = Quaternion::IDENTITY;
    7272
    73         this->defSndWpnFire_ = new WorldSound(this);
    74         this->defSndWpnFire_->setLooping(false);
    75         this->bSoundAttached_ = false;
     73        if( GameMode::isMaster() )
     74        {
     75            this->defSndWpnFire_ = new WorldSound(this);
     76            this->defSndWpnFire_->setLooping(false);
     77            this->bSoundAttached_ = false;
     78        }
     79        else
     80            this->defSndWpnFire_ = 0;
    7681    }
    7782
     
    8085        if(this->isInitialized())
    8186        {
    82             delete this->defSndWpnFire_;
     87            if( this->defSndWpnFire_ )
     88                delete this->defSndWpnFire_;
    8389        }
    8490    }
     
    106112    {
    107113        (*reloadTime) = this->reloadTime_;
    108         if( !this->bSoundAttached_ )
     114        if( !this->bSoundAttached_ && GameMode::isMaster() )
    109115        {
    110116            assert(this->getWeapon() && this->getWeapon()->getWeaponSlot());
     
    130136            this->reloadTimer_.startTimer();
    131137
    132             if(!(this->defSndWpnFire_->isPlaying()))
     138            if( this->defSndWpnFire_ && !(this->defSndWpnFire_->isPlaying()))
    133139            {
    134140                this->defSndWpnFire_->play();
     
    222228    void WeaponMode::reloaded()
    223229    {
    224         if(this->defSndWpnFire_->isPlaying())
     230        if( this->defSndWpnFire_ && this->defSndWpnFire_->isPlaying())
    225231        {
    226232            this->defSndWpnFire_->stop();
     
    257263    void WeaponMode::setDefaultSound(const std::string& soundPath)
    258264    {
    259         this->defSndWpnFire_->setSource(soundPath);
     265        if( this->defSndWpnFire_ )
     266            this->defSndWpnFire_->setSource(soundPath);
    260267    }
    261268
    262269    const std::string& WeaponMode::getDefaultSound()
    263270    {
    264         return this->defSndWpnFire_->getSource();
     271        if( this->defSndWpnFire_ )
     272            return this->defSndWpnFire_->getSource();
     273        else
     274            return std::string();
    265275    }
    266276}
Note: See TracChangeset for help on using the changeset viewer.