Changeset 11071 for code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r11052 r11071 48 48 RegisterClass(SpaceShip); 49 49 50 SpaceShip::SpaceShip(Context* context) : Pawn(context), boostBlur_( NULL)50 SpaceShip::SpaceShip(Context* context) : Pawn(context), boostBlur_(nullptr) 51 51 { 52 52 RegisterObject(SpaceShip); … … 80 80 // SpaceShip is always a physical object per default 81 81 // Be aware of this call: The collision type legality check will not reach derived classes! 82 this->setCollisionType(WorldEntity:: Dynamic);82 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 83 83 // Get notification about collisions 84 84 this->enableCollisionCallback(); … … 145 145 bool SpaceShip::isCollisionTypeLegal(WorldEntity::CollisionType type) const 146 146 { 147 if (type != WorldEntity:: Dynamic)147 if (type != WorldEntity::CollisionType::Dynamic) 148 148 { 149 149 orxout(internal_warning) << "Cannot tell a SpaceShip not to be dynamic! Ignoring." << endl; … … 160 160 161 161 // Run the engines 162 for( std::vector<Engine*>::iterator it = this->engineList_.begin(); it != this->engineList_.end(); it++)163 (*it)->run(dt);162 for(Engine* engine : this->engineList_) 163 engine->run(dt); 164 164 165 165 if (this->hasLocalController()) … … 198 198 if(this->bEnableMotionBlur_) 199 199 { 200 if (this->boostBlur_ == NULL&& this->hasLocalController() && this->hasHumanController())200 if (this->boostBlur_ == nullptr && this->hasLocalController() && this->hasHumanController()) 201 201 { 202 202 this->boostBlur_ = new Shader(this->getScene()->getSceneManager()); … … 325 325 void SpaceShip::addEngine(orxonox::Engine* engine) 326 326 { 327 OrxAssert(engine != NULL, "The engine cannot be NULL.");327 OrxAssert(engine != nullptr, "The engine cannot be nullptr."); 328 328 this->engineList_.push_back(engine); 329 329 engine->addToSpaceShip(this); … … 333 333 @brief 334 334 Check whether the SpaceShip has a particular Engine. 335 @param engine335 @param search 336 336 A pointer to the Engine to be checked. 337 337 */ 338 bool SpaceShip::hasEngine(Engine* engine) const339 { 340 for( unsigned int i = 0; i < this->engineList_.size(); i++)341 { 342 if( this->engineList_[i] == engine)338 bool SpaceShip::hasEngine(Engine* search) const 339 { 340 for(Engine* engine : this->engineList_) 341 { 342 if(engine == search) 343 343 return true; 344 344 } … … 350 350 Get the i-th Engine of the SpaceShip. 351 351 @return 352 Returns a pointer to the i-the Engine. NULLif there is no Engine with that index.352 Returns a pointer to the i-the Engine. nullptr if there is no Engine with that index. 353 353 */ 354 354 Engine* SpaceShip::getEngine(unsigned int i) 355 355 { 356 356 if(this->engineList_.size() >= i) 357 return NULL;357 return nullptr; 358 358 else 359 359 return this->engineList_[i]; … … 366 366 The name of the engine to be returned. 367 367 @return 368 Pointer to the engine with the given name, or NULLif not found.368 Pointer to the engine with the given name, or nullptr if not found. 369 369 */ 370 370 Engine* SpaceShip::getEngineByName(const std::string& name) 371 371 { 372 for( size_t i = 0; i < this->engineList_.size(); ++i)373 if( this->engineList_[i]->getName() == name)374 return this->engineList_[i];372 for(Engine* engine : this->engineList_) 373 if(engine->getName() == name) 374 return engine; 375 375 376 376 orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl; 377 return NULL;377 return nullptr; 378 378 } 379 379 … … 416 416 void SpaceShip::addSpeedFactor(float factor) 417 417 { 418 for( unsigned int i=0; i<this->engineList_.size(); i++)419 this->engineList_[i]->addSpeedMultiply(factor);418 for(Engine* engine : this->engineList_) 419 engine->addSpeedMultiply(factor); 420 420 } 421 421 … … 428 428 void SpaceShip::addSpeed(float speed) 429 429 { 430 for( unsigned int i=0; i<this->engineList_.size(); i++)431 this->engineList_[i]->addSpeedAdd(speed);430 for(Engine* engine : this->engineList_) 431 engine->addSpeedAdd(speed); 432 432 } 433 433 … … 456 456 { 457 457 float speed=0; 458 for( unsigned int i=0; i<this->engineList_.size(); i++)459 { 460 if( this->engineList_[i]->getMaxSpeedFront() > speed)461 speed = this->engineList_[i]->getMaxSpeedFront();458 for(Engine* engine : this->engineList_) 459 { 460 if(engine->getMaxSpeedFront() > speed) 461 speed = engine->getMaxSpeedFront(); 462 462 } 463 463 return speed; … … 485 485 void SpaceShip::changedEnableMotionBlur() 486 486 { 487 if (!this->bEnableMotionBlur_ && this->boostBlur_ != NULL)487 if (!this->bEnableMotionBlur_ && this->boostBlur_ != nullptr) 488 488 { 489 489 delete this->boostBlur_; 490 this->boostBlur_ = NULL;490 this->boostBlur_ = nullptr; 491 491 } 492 492 } … … 514 514 Camera* camera = this->getCamera(); 515 515 //Shaking Camera effect 516 if (camera != 0)516 if (camera != nullptr) 517 517 camera->setOrientation(Vector3::UNIT_X, angle); 518 518 … … 530 530 { 531 531 Camera* camera = CameraManager::getInstance().getActiveCamera(); 532 if(camera != NULL)532 if(camera != nullptr) 533 533 { 534 534 this->cameraOriginalPosition_ = camera->getPosition(); … … 546 546 { 547 547 Camera *camera = this->getCamera(); 548 if (camera == 0)548 if (camera == nullptr) 549 549 { 550 550 orxout(internal_warning) << "Failed to reset camera!" << endl;
Note: See TracChangeset
for help on using the changeset viewer.