Changeset 6313 for code/branches/presentation2/src/orxonox/items
- Timestamp:
- Dec 10, 2009, 8:49:33 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/orxonox/items/MultiStateEngine.cc
r6222 r6313 55 55 RegisterObject(MultiStateEngine); 56 56 57 this->defEngineSndNormal_ = new WorldSound(this); 58 this->defEngineSndBoost_ = new WorldSound(this); 59 this->defEngineSndNormal_->setLooping(true); 60 this->defEngineSndBoost_->setLooping(true); 57 if( GameMode::isMaster() ) 58 { 59 this->defEngineSndNormal_ = new WorldSound(this); 60 this->defEngineSndBoost_ = new WorldSound(this); 61 this->defEngineSndNormal_->setLooping(true); 62 this->defEngineSndBoost_->setLooping(true); 63 } 64 else 65 { 66 this->defEngineSndBoost_ = 0; 67 this->defEngineSndNormal_ = 0; 68 } 61 69 62 70 this->lua_ = new LuaState(); … … 74 82 for (std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsBegin(); ++it2) 75 83 (*it2)->destroy(); 76 delete this->defEngineSndNormal_; 77 delete this->defEngineSndBoost_; 84 if( this->defEngineSndNormal_ ) 85 delete this->defEngineSndNormal_; 86 if( this->defEngineSndBoost_ ) 87 delete this->defEngineSndBoost_; 78 88 delete this->lua_; 79 89 } … … 97 107 if (this->getShip()) 98 108 { 99 if (this->getShip()->hasLocalController()) 109 // if (this->getShip()->hasLocalController()) 110 if (GameMode::isMaster() && this->getShip()->hasLocalController()) 100 111 { 101 112 this->setSyncMode(ObjectDirection::Bidirectional); … … 192 203 return; 193 204 194 this->getShip()->attach(defEngineSndNormal_); 195 this->getShip()->attach(defEngineSndBoost_); 205 if( this->defEngineSndNormal_ ) 206 this->getShip()->attach(defEngineSndNormal_); 207 if( this->defEngineSndBoost_ ) 208 this->getShip()->attach(defEngineSndBoost_); 196 209 197 210 for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it) … … 226 239 void MultiStateEngine::setDefEngSndNormal(const std::string &engineSound) 227 240 { 228 defEngineSndNormal_->setSource(engineSound); 241 if( defEngineSndNormal_ ) 242 defEngineSndNormal_->setSource(engineSound); 243 else 244 assert(0); // This should never happen, because soundpointer is only available on master 229 245 } 230 246 231 247 const std::string& MultiStateEngine::getDefEngSndNormal() 232 248 { 233 return defEngineSndNormal_->getSource(); 249 if( defEngineSndNormal_ ) 250 return defEngineSndNormal_->getSource(); 251 else 252 assert(0); 253 return std::string(); 234 254 } 235 255 236 256 void MultiStateEngine::setDefEngSndBoost(const std::string &engineSound) 237 257 { 238 defEngineSndBoost_->setSource(engineSound); 258 if( defEngineSndBoost_ ) 259 defEngineSndBoost_->setSource(engineSound); 260 else 261 assert(0); 239 262 } 240 263 241 264 const std::string& MultiStateEngine::getDefEngSndBoost() 242 265 { 243 return defEngineSndBoost_->getSource(); 266 if( this->defEngineSndBoost_ ) 267 return defEngineSndBoost_->getSource(); 268 else 269 assert(0); 270 return std::string(); 244 271 } 245 272 }
Note: See TracChangeset
for help on using the changeset viewer.