Changeset 11071 for code/trunk/src/orxonox/worldentities
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/worldentities/Actionpoint.h
r11052 r11071 92 92 public: 93 93 Actionpoint(Context* context); 94 virtual ~Actionpoint() {}94 virtual ~Actionpoint() = default; 95 95 96 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;96 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 97 97 98 98 /** @brief Decides what AI will do. @param val action to execute */ -
code/trunk/src/orxonox/worldentities/CameraPosition.h
r9667 r11071 41 41 virtual ~CameraPosition(); 42 42 43 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;43 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 44 44 45 45 inline void setDrag(bool bDrag) -
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
r10624 r11071 61 61 this->server_overwrite_ = 0; 62 62 this->client_overwrite_ = 0; 63 this->player_ = 0;64 this->formerPlayer_ = NULL;63 this->player_ = nullptr; 64 this->formerPlayer_ = nullptr; 65 65 this->playerID_ = OBJECTID_UNKNOWN; 66 this->hud_ = 0;67 this->camera_ = 0;68 this->xmlcontroller_ = 0;69 //this->controller_ = 0;70 this->reverseCamera_ = 0;66 this->hud_ = nullptr; 67 this->camera_ = nullptr; 68 this->xmlcontroller_ = nullptr; 69 //this->controller_ = nullptr; 70 this->reverseCamera_ = nullptr; 71 71 this->bDestroyWhenPlayerLeft_ = false; 72 72 this->cameraPositionRootNode_ = this->node_->createChildSceneNode(); 73 this->currentCameraPosition_ = 0;73 this->currentCameraPosition_ = nullptr; 74 74 this->bMouseLook_ = false; 75 75 this->mouseLookSpeed_ = 200; … … 108 108 this->camera_->destroy(); 109 109 110 for ( std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)111 (*it)->destroy();110 for (CameraPosition* cameraPosition : this->cameraPositions_) 111 cameraPosition->destroy(); 112 112 113 113 if (this->getScene()->getSceneManager()) … … 165 165 { 166 166 unsigned int i = 0; 167 for ( std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)167 for (CameraPosition* cameraPosition : this->cameraPositions_) 168 168 { 169 169 if (i == index) 170 return (*it);170 return cameraPosition; 171 171 ++i; 172 172 } 173 return 0;173 return nullptr; 174 174 } 175 175 … … 180 180 181 181 unsigned int counter = 0; 182 for ( std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)183 { 184 if ( (*it)== this->currentCameraPosition_)182 for (CameraPosition* cameraPosition : this->cameraPositions_) 183 { 184 if (cameraPosition == this->currentCameraPosition_) 185 185 break; 186 186 counter++; … … 194 194 bool ControllableEntity::setCameraPosition(unsigned int index) 195 195 { 196 if(this->camera_ != NULL&& this->cameraPositions_.size() > 0)196 if(this->camera_ != nullptr && this->cameraPositions_.size() > 0) 197 197 { 198 198 if(index >= this->cameraPositions_.size()) … … 219 219 else if (this->cameraPositions_.size() > 0) 220 220 { 221 for (std::list<StrongPtr<CameraPosition> 221 for (std::list<StrongPtr<CameraPosition>>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 222 222 { 223 223 if ((*it) == this->camera_->getParent()) … … 241 241 { 242 242 this->camera_->attachToNode(this->cameraPositionRootNode_); 243 this->currentCameraPosition_ = 0;243 this->currentCameraPosition_ = nullptr; 244 244 } 245 245 … … 321 321 if ( !GameMode::isMaster() ) 322 322 { 323 if ( target != 0)323 if ( target != nullptr ) 324 324 { 325 325 callMemberNetworkFunction(&ControllableEntity::setTargetInternal, this->getObjectID(), 0, target->getObjectID() ); … … 350 350 this->bHasLocalController_ = player->isLocalPlayer(); 351 351 this->bHasHumanController_ = player->isHumanPlayer(); 352 if(controller_ != NULL)352 if(controller_ != nullptr) 353 353 this->team_ = controller_->getTeam(); // forward controller team number 354 354 … … 372 372 this->stopLocalHumanControl(); 373 373 374 this->player_ = 0;374 this->player_ = nullptr; 375 375 this->playerID_ = OBJECTID_UNKNOWN; 376 376 this->bHasLocalController_ = false; … … 411 411 { 412 412 this->camera_->attachToNode(this->cameraPositionRootNode_); 413 this->currentCameraPosition_ = 0;413 this->currentCameraPosition_ = nullptr; 414 414 } 415 415 } … … 434 434 void ControllableEntity::destroyHud(void) 435 435 { 436 if (this->hud_ != NULL)436 if (this->hud_ != nullptr) 437 437 { 438 438 this->hud_->destroy(); 439 this->hud_ = NULL;439 this->hud_ = nullptr; 440 440 } 441 441 } … … 447 447 this->camera_->detachFromParent(); 448 448 this->camera_->destroy(); 449 this->camera_ = 0;449 this->camera_ = nullptr; 450 450 } 451 451 … … 453 453 { 454 454 this->hud_->destroy(); 455 this->hud_ = 0;455 this->hud_ = nullptr; 456 456 } 457 457 } … … 477 477 if (parent) 478 478 { 479 for ( std::list<StrongPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)480 if ( (*it)->getIsAbsolute())481 parent->attach( (*it));479 for (CameraPosition* cameraPosition : this->cameraPositions_) 480 if (cameraPosition->getIsAbsolute()) 481 parent->attach(cameraPosition); 482 482 } 483 483 } -
code/trunk/src/orxonox/worldentities/ControllableEntity.h
r10624 r11071 54 54 virtual ~ControllableEntity(); 55 55 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;57 virtual void tick(float dt) ;56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 57 virtual void tick(float dt) override; 58 58 void setConfigValues(); 59 59 … … 121 121 void addCameraPosition(CameraPosition* position); 122 122 CameraPosition* getCameraPosition(unsigned int index) const; 123 inline const std::list<StrongPtr<CameraPosition> 123 inline const std::list<StrongPtr<CameraPosition>>& getCameraPositions() const 124 124 { return this->cameraPositions_; } 125 125 unsigned int getCurrentCameraIndex() const; … … 141 141 using MobileEntity::setAngularVelocity; 142 142 143 v oid setPosition(const Vector3& position);144 v oid setOrientation(const Quaternion& orientation);145 v oid setVelocity(const Vector3& velocity);146 v oid setAngularVelocity(const Vector3& velocity);143 virtual void setPosition(const Vector3& position) override; 144 virtual void setOrientation(const Quaternion& orientation) override; 145 virtual void setVelocity(const Vector3& velocity) override; 146 virtual void setAngularVelocity(const Vector3& velocity) override; 147 147 148 148 inline bool hasLocalController() const … … 177 177 178 178 protected: 179 virtual void preDestroy() ;179 virtual void preDestroy() override; 180 180 181 181 virtual void setPlayer(PlayerInfo* player); // don't call this directly, use friend class PlayerInfo instead … … 184 184 virtual void startLocalHumanControl(); 185 185 virtual void stopLocalHumanControl(); 186 virtual void parentChanged() ;186 virtual void parentChanged() override; 187 187 188 188 inline void setHudTemplate(const std::string& name) … … 214 214 215 215 // Bullet btMotionState related 216 v oid setWorldTransform(const btTransform& worldTrans);216 virtual void setWorldTransform(const btTransform& worldTrans) override; 217 217 218 218 unsigned int server_overwrite_; … … 242 242 bool bMouseLook_; 243 243 float mouseLookSpeed_; 244 std::list<StrongPtr<CameraPosition> 244 std::list<StrongPtr<CameraPosition>> cameraPositions_; 245 245 CameraPosition* currentCameraPosition_; 246 246 std::string cameraPositionTemplate_; -
code/trunk/src/orxonox/worldentities/Drone.cc
r9667 r11071 30 30 31 31 #include "core/XMLPort.h" 32 #include "core/CoreIncludes.h" 32 33 #include "BulletDynamics/Dynamics/btRigidBody.h" 33 34 … … 43 44 RegisterObject(Drone); 44 45 45 this->myController_ = 0;46 this->myController_ = nullptr; 46 47 47 48 this->localLinearAcceleration_.setValue(0, 0, 0); 48 49 this->localAngularAcceleration_.setValue(0, 0, 0); 49 50 this->setRadarVisibility(false); 50 this->setCollisionType(WorldEntity:: Dynamic);51 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 51 52 52 53 myController_ = new DroneController(this->getContext()); //!< Creates a new controller and passes our this pointer to it as creator. -
code/trunk/src/orxonox/worldentities/Drone.h
r9667 r11071 50 50 virtual ~Drone(); 51 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Method for creating a Drone through XML.53 virtual void tick(float dt) ; //!< Defines which actions the Drone has to take in each tick.52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method for creating a Drone through XML. 53 virtual void tick(float dt) override; //!< Defines which actions the Drone has to take in each tick. 54 54 55 55 56 virtual void moveFrontBack(const Vector2& value) ;57 virtual void moveRightLeft(const Vector2& value) ;58 virtual void moveUpDown(const Vector2& value) ;56 virtual void moveFrontBack(const Vector2& value) override; 57 virtual void moveRightLeft(const Vector2& value) override; 58 virtual void moveUpDown(const Vector2& value) override; 59 59 60 virtual void rotateYaw(const Vector2& value) ;61 virtual void rotatePitch(const Vector2& value) ;62 virtual void rotateRoll(const Vector2& value) ;60 virtual void rotateYaw(const Vector2& value) override; 61 virtual void rotatePitch(const Vector2& value) override; 62 virtual void rotateRoll(const Vector2& value) override; 63 63 64 64 /** -
code/trunk/src/orxonox/worldentities/EffectContainer.cc
r9667 r11071 44 44 EffectContainer::EffectContainer(Context* context) 45 45 : BaseObject(context) 46 , lua_( NULL)46 , lua_(nullptr) 47 47 { 48 48 RegisterObject(EffectContainer); … … 89 89 { 90 90 unsigned int i = 0; 91 for ( std::vector<WorldEntity*>::const_iterator it = this->effects_.begin(); it != this->effects_.end(); ++it)91 for (WorldEntity* effect : this->effects_) 92 92 if (i == index) 93 return (*it);94 return NULL;93 return effect; 94 return nullptr; 95 95 } 96 96 … … 103 103 bool result = (bool)lua_toboolean(this->lua_->getInternalLuaState(), -1); 104 104 lua_pop(this->lua_->getInternalLuaState(), 1); 105 for ( std::vector<WorldEntity*>::const_iterator it = this->effects_.begin(); it != this->effects_.end(); ++it)105 for (WorldEntity* effect : this->effects_) 106 106 { 107 (*it)->setMainState(result);107 effect->setMainState(result); 108 108 } 109 109 } -
code/trunk/src/orxonox/worldentities/EffectContainer.h
r9667 r11071 43 43 virtual ~EffectContainer(); 44 44 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 46 46 47 47 void setLuaState(LuaState* state, const std::string& functionName); … … 54 54 WorldEntity* getEffect(unsigned int index) const; 55 55 56 inline std::vector<WorldEntity*>::const_iterator getEffectsBegin() 57 { return this->effects_.begin(); } 58 inline std::vector<WorldEntity*>::const_iterator getEffectsEnd() 59 { return this->effects_.end(); } 56 inline const std::vector<WorldEntity*>& getEffects() const 57 { return this->effects_; } 60 58 61 59 void updateCondition(); -
code/trunk/src/orxonox/worldentities/ExplosionChunk.cc
r9667 r11071 62 62 { 63 63 orxout(internal_error) << "Couldn't load particle effect in ExplosionChunk: " << ex.what() << endl; 64 this->fire_ = 0;65 this->smoke_ = 0;64 this->fire_ = nullptr; 65 this->smoke_ = nullptr; 66 66 } 67 67 } 68 68 else 69 69 { 70 this->fire_ = 0;71 this->smoke_ = 0;70 this->fire_ = nullptr; 71 this->smoke_ = nullptr; 72 72 } 73 73 -
code/trunk/src/orxonox/worldentities/ExplosionChunk.h
r9667 r11071 43 43 virtual ~ExplosionChunk(); 44 44 45 virtual void tick(float dt) ;45 virtual void tick(float dt) override; 46 46 47 47 inline void setLOD(LODParticle::Value level) -
code/trunk/src/orxonox/worldentities/ExplosionPart.cc
r11052 r11071 47 47 this->effect2_ = ""; 48 48 this->model_= new Model(this->getContext()); 49 this->effect1Particle_= NULL;50 this->effect2Particle_= NULL;49 this->effect1Particle_= nullptr; 50 this->effect2Particle_= nullptr; 51 51 this->explosionEntity_ = new MovableEntity(this->getContext()); 52 52 this->posOffset_ = Vector3::ZERO; -
code/trunk/src/orxonox/worldentities/ExplosionPart.h
r11052 r11071 51 51 ExplosionPart(Context* context); 52 52 ~ExplosionPart(); 53 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 54 54 55 void Explode(); 55 56 void stop(); -
code/trunk/src/orxonox/worldentities/MobileEntity.cc
r9667 r11071 189 189 bool MobileEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const 190 190 { 191 if (type == WorldEntity:: Static)191 if (type == WorldEntity::CollisionType::Static) 192 192 { 193 193 orxout(internal_warning) << "Cannot tell a MobileEntity to have static collision type! Ignoring." << endl; -
code/trunk/src/orxonox/worldentities/MobileEntity.h
r11052 r11071 57 57 virtual ~MobileEntity(); 58 58 59 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;60 virtual void tick(float dt) ;59 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 60 virtual void tick(float dt) override; 61 61 62 virtual void setPosition(const Vector3& position) ;63 virtual void setOrientation(const Quaternion& orientation) ;62 virtual void setPosition(const Vector3& position) override; 63 virtual void setOrientation(const Quaternion& orientation) override; 64 64 65 65 virtual void setVelocity(const Vector3& velocity); 66 66 inline void setVelocity(float x, float y, float z) 67 67 { this->setVelocity(Vector3(x, y, z)); } 68 inline const Vector3& getVelocity() const68 virtual inline const Vector3& getVelocity() const override 69 69 { return this->linearVelocity_; } 70 70 /** … … 110 110 protected: 111 111 // Bullet btMotionState related 112 virtual void setWorldTransform(const btTransform& worldTrans) ;113 v oid getWorldTransform(btTransform& worldTrans) const;112 virtual void setWorldTransform(const btTransform& worldTrans) override; 113 virtual void getWorldTransform(btTransform& worldTrans) const override; 114 114 115 115 Vector3 linearAcceleration_; … … 119 119 120 120 private: 121 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const ;121 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const override; 122 122 }; 123 123 } -
code/trunk/src/orxonox/worldentities/MovableEntity.cc
r11018 r11071 50 50 this->overwrite_orientation_ = Quaternion::IDENTITY; 51 51 52 this->continuousResynchroTimer_ = 0;52 this->continuousResynchroTimer_ = nullptr; 53 53 54 54 this->setPriority(Priority::Low); … … 80 80 { 81 81 float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length(); 82 victim->hit( 0, contactPoint, ownCollisionShape, damage);82 victim->hit(nullptr, contactPoint, ownCollisionShape, damage); 83 83 } 84 84 } -
code/trunk/src/orxonox/worldentities/MovableEntity.h
r10216 r11071 46 46 virtual ~MovableEntity(); 47 47 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;49 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) ;48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 49 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) override; 50 50 51 51 using WorldEntity::setPosition; 52 52 using WorldEntity::setOrientation; 53 53 54 inline void setPosition(const Vector3& position)54 virtual inline void setPosition(const Vector3& position) override 55 55 { MobileEntity::setPosition(position); this->overwrite_position_ = this->getPosition(); } 56 inline void setOrientation(const Quaternion& orientation)56 virtual inline void setOrientation(const Quaternion& orientation) override 57 57 { MobileEntity::setOrientation(orientation); this->overwrite_orientation_ = this->getOrientation(); } 58 58 … … 79 79 private: 80 80 void registerVariables(); 81 v oid clientConnected(unsigned int clientID);82 v oid clientDisconnected(unsigned int clientID);81 virtual void clientConnected(unsigned int clientID) override; 82 virtual void clientDisconnected(unsigned int clientID) override; 83 83 void resynchronize(); 84 84 -
code/trunk/src/orxonox/worldentities/SpawnPoint.cc
r9667 r11071 43 43 RegisterObject(SpawnPoint); 44 44 45 this->template_ = 0;45 this->template_ = nullptr; 46 46 47 47 if (this->getGametype()) -
code/trunk/src/orxonox/worldentities/SpawnPoint.h
r11052 r11071 44 44 virtual ~SpawnPoint() {} 45 45 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 47 47 48 48 inline void setSpawnClass(Identifier* identifier) -
code/trunk/src/orxonox/worldentities/StaticEntity.cc
r9667 r11071 95 95 bool StaticEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const 96 96 { 97 if (type == WorldEntity:: Kinematic || type == WorldEntity::Dynamic)97 if (type == WorldEntity::CollisionType::Kinematic || type == WorldEntity::CollisionType::Dynamic) 98 98 { 99 99 orxout(internal_warning) << "Cannot tell a StaticEntity to have kinematic or dynamic collision type! Ignoring." << endl; -
code/trunk/src/orxonox/worldentities/StaticEntity.h
r11052 r11071 57 57 using WorldEntity::setOrientation; 58 58 59 v oid setPosition(const Vector3& position);60 v oid setOrientation(const Quaternion& orientation);59 virtual void setPosition(const Vector3& position) override; 60 virtual void setOrientation(const Quaternion& orientation) override; 61 61 62 62 private: 63 63 void registerVariables(); 64 bool isCollisionTypeLegal(CollisionType type) const;64 virtual bool isCollisionTypeLegal(CollisionType type) const override; 65 65 66 66 // network callbacks … … 71 71 72 72 // Bullet btMotionState related 73 v oid setWorldTransform(const btTransform& worldTrans);74 v oid getWorldTransform(btTransform& worldTrans) const;73 virtual void setWorldTransform(const btTransform& worldTrans) override; 74 virtual void getWorldTransform(btTransform& worldTrans) const override; 75 75 }; 76 76 } -
code/trunk/src/orxonox/worldentities/TeamSpawnPoint.h
r11052 r11071 43 43 virtual ~TeamSpawnPoint() {} 44 44 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 46 46 47 47 void setTeamNumber(unsigned int team) … … 49 49 unsigned int getTeamNumber() const 50 50 { return this->teamNumber_; } 51 virtual Pawn* spawn() ;51 virtual Pawn* spawn() override; 52 52 53 53 private: -
code/trunk/src/orxonox/worldentities/WorldEntity.cc
r10624 r11071 37 37 #include <OgreSceneNode.h> 38 38 #include <BulletDynamics/Dynamics/btRigidBody.h> 39 #include <boost/static_assert.hpp>40 39 41 40 #include "util/OrxAssert.h" … … 57 56 58 57 // Be sure we don't do bad conversions 59 BOOST_STATIC_ASSERT((int)Ogre::Node::TS_LOCAL == (int)WorldEntity::Local);60 BOOST_STATIC_ASSERT((int)Ogre::Node::TS_PARENT == (int)WorldEntity::Parent);61 BOOST_STATIC_ASSERT((int)Ogre::Node::TS_WORLD == (int)WorldEntity::World);58 static_assert((int)Ogre::Node::TS_LOCAL == (int)WorldEntity::TransformSpace::Local, "check enum"); 59 static_assert((int)Ogre::Node::TS_PARENT == (int)WorldEntity::TransformSpace::Parent, "check enum"); 60 static_assert((int)Ogre::Node::TS_WORLD == (int)WorldEntity::TransformSpace::World, "check enum"); 62 61 63 62 RegisterAbstractClass(WorldEntity).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>(); … … 77 76 this->node_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 78 77 79 this->parent_ = 0;78 this->parent_ = nullptr; 80 79 this->parentID_ = OBJECTID_UNKNOWN; 81 80 this->bDeleteWithParent_ = true; … … 90 89 91 90 // Default behaviour does not include physics 92 this->physicalBody_ = 0;91 this->physicalBody_ = nullptr; 93 92 this->bPhysicsActive_ = false; 94 93 this->bPhysicsActiveSynchronised_ = false; … … 96 95 this->collisionShape_ = new WorldEntityCollisionShape(this->getContext()); 97 96 this->collisionShape_->setWorldEntityOwner(this); 98 this->collisionType_ = None;99 this->collisionTypeSynchronised_ = None;97 this->collisionType_ = CollisionType::None; 98 this->collisionTypeSynchronised_ = CollisionType::None; 100 99 this->mass_ = 1.0f; 101 100 this->childrenMass_ = 0; … … 208 207 registerVariable(this->bCollisionResponseActive_, 209 208 VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged)); 210 registerVariable( (int&)this->collisionTypeSynchronised_,209 registerVariable(this->collisionTypeSynchronised_, 211 210 VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged)); 212 211 registerVariable(this->bPhysicsActiveSynchronised_, … … 234 233 235 234 // iterate over all children and change their activity as well 236 for ( std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)235 for (WorldEntity* object : this->getAttachedObjects()) 237 236 { 238 237 if(!this->isActive()) 239 238 { 240 (*it)->bActiveMem_ = (*it)->isActive();241 (*it)->setActive(this->isActive());239 object->bActiveMem_ = object->isActive(); 240 object->setActive(this->isActive()); 242 241 } 243 242 else 244 243 { 245 (*it)->setActive((*it)->bActiveMem_);244 object->setActive(object->bActiveMem_); 246 245 } 247 246 } … … 260 259 { 261 260 // iterate over all children and change their visibility as well 262 for ( std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)261 for (WorldEntity* object : this->getAttachedObjects()) 263 262 { 264 263 if(!this->isVisible()) 265 264 { 266 (*it)->bVisibleMem_ = (*it)->isVisible();267 (*it)->setVisible(this->isVisible());265 object->bVisibleMem_ = object->isVisible(); 266 object->setVisible(this->isVisible()); 268 267 } 269 268 else 270 269 { 271 (*it)->setVisible((*it)->bVisibleMem_);270 object->setVisible(object->bVisibleMem_); 272 271 } 273 272 } … … 323 322 void WorldEntity::collisionTypeChanged() 324 323 { 325 if (this->collisionTypeSynchronised_ != Dynamic &&326 this->collisionTypeSynchronised_ != Kinematic &&327 this->collisionTypeSynchronised_ != Static &&328 this->collisionTypeSynchronised_ != None)324 if (this->collisionTypeSynchronised_ != CollisionType::Dynamic && 325 this->collisionTypeSynchronised_ != CollisionType::Kinematic && 326 this->collisionTypeSynchronised_ != CollisionType::Static && 327 this->collisionTypeSynchronised_ != CollisionType::None) 329 328 { 330 329 orxout(internal_error) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << endl; … … 498 497 void WorldEntity::notifyDetached() 499 498 { 500 this->parent_ = 0;499 this->parent_ = nullptr; 501 500 this->parentID_ = OBJECTID_UNKNOWN; 502 501 … … 519 518 { 520 519 unsigned int i = 0; 521 for ( std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)520 for (WorldEntity* child : this->children_) 522 521 { 523 522 if (i == index) 524 return (*it);523 return child; 525 524 ++i; 526 525 } 527 return 0;526 return nullptr; 528 527 } 529 528 … … 563 562 void WorldEntity::detachOgreObject(Ogre::MovableObject* object) 564 563 { 565 object->setUserAny(Ogre::Any(static_cast<OrxonoxClass*>( NULL)));564 object->setUserAny(Ogre::Any(static_cast<OrxonoxClass*>(nullptr))); 566 565 this->node_->detachObject(object); 567 566 } … … 660 659 { 661 660 // If physics is enabled scale the attached CollisionShape. 662 /*if (this->hasPhysics() && this->collisionShape_ != NULL)661 /*if (this->hasPhysics() && this->collisionShape_ != nullptr) 663 662 { 664 663 this->collisionShape_->setScale3D(scale); … … 682 681 switch (relativeTo) 683 682 { 684 case WorldEntity::Local:683 case TransformSpace::Local: 685 684 // position is relative to parent so transform downwards 686 685 this->setPosition(this->getPosition() + this->getOrientation() * distance); 687 686 break; 688 case WorldEntity::Parent:687 case TransformSpace::Parent: 689 688 this->setPosition(this->getPosition() + distance); 690 689 break; 691 case WorldEntity::World:690 case TransformSpace::World: 692 691 // position is relative to parent so transform upwards 693 692 if (this->node_->getParent()) … … 712 711 switch(relativeTo) 713 712 { 714 case WorldEntity::Local:713 case TransformSpace::Local: 715 714 this->setOrientation(this->getOrientation() * rotation); 716 715 break; 717 case WorldEntity::Parent:716 case TransformSpace::Parent: 718 717 // Rotations are normally relative to local axes, transform up 719 718 this->setOrientation(rotation * this->getOrientation()); 720 719 break; 721 case WorldEntity::World:720 case TransformSpace::World: 722 721 // Rotations are normally relative to local axes, transform up 723 722 this->setOrientation(this->getOrientation() * this->getWorldOrientation().Inverse() … … 742 741 switch (relativeTo) 743 742 { 744 case WorldEntity::Local:743 case TransformSpace::Local: 745 744 origin = Vector3::ZERO; 746 745 break; 747 case WorldEntity::Parent:746 case TransformSpace::Parent: 748 747 origin = this->getPosition(); 749 748 break; 750 case WorldEntity::World:749 case TransformSpace::World: 751 750 origin = this->getWorldPosition(); 752 751 break; … … 832 831 833 832 // Check whether we have to create or destroy. 834 if (type != None && this->collisionType_ ==None)833 if (type != CollisionType::None && this->collisionType_ == CollisionType::None) 835 834 { 836 835 /* … … 850 849 this->physicalBody_->setActivationState(DISABLE_DEACTIVATION); 851 850 } 852 else if (type == None && this->collisionType_ !=None)851 else if (type == CollisionType::None && this->collisionType_ != CollisionType::None) 853 852 { 854 853 // Destroy rigid body … … 856 855 deactivatePhysics(); 857 856 delete this->physicalBody_; 858 this->physicalBody_ = 0;859 this->collisionType_ = None;860 this->collisionTypeSynchronised_ = None;857 this->physicalBody_ = nullptr; 858 this->collisionType_ = CollisionType::None; 859 this->collisionTypeSynchronised_ = CollisionType::None; 861 860 return; 862 861 } … … 865 864 switch (type) 866 865 { 867 case Dynamic:866 case CollisionType::Dynamic: 868 867 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT & !btCollisionObject::CF_KINEMATIC_OBJECT); 869 868 break; 870 case Kinematic:869 case CollisionType::Kinematic: 871 870 this->physicalBody_->setCollisionFlags((this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT) | btCollisionObject::CF_KINEMATIC_OBJECT); 872 871 break; 873 case Static:872 case CollisionType::Static: 874 873 this->physicalBody_->setCollisionFlags((this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_KINEMATIC_OBJECT) | btCollisionObject::CF_STATIC_OBJECT); 875 874 break; 876 case None:875 case CollisionType::None: 877 876 assert(false); // Doesn't happen 878 877 return; … … 896 895 CollisionType type; 897 896 if (typeStrLower == "dynamic") 898 type = Dynamic;897 type = CollisionType::Dynamic; 899 898 else if (typeStrLower == "static") 900 type = Static;899 type = CollisionType::Static; 901 900 else if (typeStrLower == "kinematic") 902 type = Kinematic;901 type = CollisionType::Kinematic; 903 902 else if (typeStrLower == "none") 904 type = None;903 type = CollisionType::None; 905 904 else 906 905 ThrowException(ParseError, std::string("Attempting to set an unknown collision type: '") + typeStr + "'."); … … 913 912 switch (this->getCollisionType()) 914 913 { 915 case Dynamic:914 case CollisionType::Dynamic: 916 915 return "dynamic"; 917 case Kinematic:916 case CollisionType::Kinematic: 918 917 return "kinematic"; 919 case Static:918 case CollisionType::Static: 920 919 return "static"; 921 case None:920 case CollisionType::None: 922 921 return "none"; 923 922 default: … … 939 938 // Recalculate mass 940 939 this->childrenMass_ = 0.0f; 941 for ( std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)942 this->childrenMass_ += (*it)->getMass();940 for (WorldEntity* child : this->children_) 941 this->childrenMass_ += child->getMass(); 943 942 recalculateMassProps(); 944 943 // Notify parent WE -
code/trunk/src/orxonox/worldentities/WorldEntity.h
r10726 r11071 82 82 Enumeration denoting the spaces which a transform can be relative to. 83 83 */ 84 enum TransformSpace84 enum class TransformSpace 85 85 { 86 86 //! Transform is relative to the local space … … 96 96 virtual ~WorldEntity(); 97 97 98 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;98 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 99 99 100 100 inline const Ogre::SceneNode* getNode() const … … 108 108 static const Vector3 UP; 109 109 110 virtual void changedActivity(void) ;111 virtual void changedVisibility(void) ;110 virtual void changedActivity(void) override; 111 virtual void changedVisibility(void) override; 112 112 113 113 virtual void setPosition(const Vector3& position) = 0; … … 117 117 const Vector3& getWorldPosition() const; 118 118 119 void translate(const Vector3& distance, TransformSpace relativeTo = WorldEntity::Parent);120 inline void translate(float x, float y, float z, TransformSpace relativeTo = WorldEntity::Parent)119 void translate(const Vector3& distance, TransformSpace relativeTo = TransformSpace::Parent); 120 inline void translate(float x, float y, float z, TransformSpace relativeTo = TransformSpace::Parent) 121 121 { this->translate(Vector3(x, y, z), relativeTo); } 122 122 … … 134 134 const Quaternion& getWorldOrientation() const; 135 135 136 void rotate(const Quaternion& rotation, TransformSpace relativeTo = WorldEntity::Local);137 inline void rotate(const Vector3& axis, const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)136 void rotate(const Quaternion& rotation, TransformSpace relativeTo = TransformSpace::Local); 137 inline void rotate(const Vector3& axis, const Degree& angle, TransformSpace relativeTo = TransformSpace::Local) 138 138 { this->rotate(Quaternion(angle, axis), relativeTo); } 139 139 140 inline void yaw(const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)140 inline void yaw(const Degree& angle, TransformSpace relativeTo = TransformSpace::Local) 141 141 { this->rotate(Quaternion(angle, Vector3::UNIT_Y), relativeTo); } 142 inline void pitch(const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)142 inline void pitch(const Degree& angle, TransformSpace relativeTo = TransformSpace::Local) 143 143 { this->rotate(Quaternion(angle, Vector3::UNIT_X), relativeTo); } 144 inline void roll(const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)144 inline void roll(const Degree& angle, TransformSpace relativeTo = TransformSpace::Local) 145 145 { this->rotate(Quaternion(angle, Vector3::UNIT_Z), relativeTo); } 146 146 147 void lookAt(const Vector3& target, TransformSpace relativeTo = WorldEntity::Parent, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);148 void setDirection(const Vector3& direction, TransformSpace relativeTo = WorldEntity::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);149 inline void setDirection(float x, float y, float z, TransformSpace relativeTo = WorldEntity::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)147 void lookAt(const Vector3& target, TransformSpace relativeTo = TransformSpace::Parent, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); 148 void setDirection(const Vector3& direction, TransformSpace relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); 149 inline void setDirection(float x, float y, float z, TransformSpace relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) 150 150 { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); } 151 151 … … 257 257 None: The object has no physics at all. 258 258 */ 259 enum CollisionType259 enum class CollisionType 260 260 { 261 261 Dynamic, … … 266 266 267 267 //! Tells whether the object has any connection to the Bullet physics engine. If hasPhysics() is false, the object may still have a velocity. 268 bool hasPhysics() const { return getCollisionType() != None ; }268 bool hasPhysics() const { return getCollisionType() != CollisionType::None ; } 269 269 //! @see CollisionType 270 bool isStatic() const { return getCollisionType() == Static ; }270 bool isStatic() const { return getCollisionType() == CollisionType::Static ; } 271 271 //! @see CollisionType 272 bool isKinematic() const { return getCollisionType() == Kinematic; }272 bool isKinematic() const { return getCollisionType() == CollisionType::Kinematic; } 273 273 //! @see CollisionType 274 bool isDynamic() const { return getCollisionType() == Dynamic ; }274 bool isDynamic() const { return getCollisionType() == CollisionType::Dynamic ; } 275 275 //! Tells whether physics has been activated (you can temporarily deactivate it) 276 276 bool isPhysicsActive() const { return this->bPhysicsActive_; } -
code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc
r9667 r11071 79 79 // FpsPlayer is always a physical object per default 80 80 // Be aware of this call: The collision type legality check will not reach derived classes! 81 this->setCollisionType(WorldEntity:: Dynamic);81 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 82 82 // Get notification about collisions 83 83 this->enableCollisionCallback(); … … 130 130 bool FpsPlayer::isCollisionTypeLegal(WorldEntity::CollisionType type) const 131 131 { 132 if (type != WorldEntity:: Dynamic)132 if (type != WorldEntity::CollisionType::Dynamic) 133 133 { 134 134 orxout(internal_warning) << "Cannot tell a FpsPlayer not to be dynamic! Ignoring." << endl; … … 168 168 if (!this->isInMouseLook()) 169 169 { 170 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity:: Parent);170 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::TransformSpace::Parent); 171 171 172 172 Radian pitch = this->cameraPositionRootNode_->getOrientation().getPitch(); … … 282 282 } 283 283 284 bool FpsPlayer::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)284 bool FpsPlayer::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 285 285 { 286 286 if (contactPoint.m_normalWorldOnB.y() > 0.6) -
code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.h
r9667 r11071 69 69 virtual void fire(); 70 70 71 bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);71 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 72 72 73 73 virtual void addedWeaponPack(WeaponPack* wPack); -
code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10624 r11071 53 53 RegisterClass(ModularSpaceShip); 54 54 55 std::map<StaticEntity*, ShipPart*>* ModularSpaceShip::partMap_s = 0;55 std::map<StaticEntity*, ShipPart*>* ModularSpaceShip::partMap_s = nullptr; 56 56 57 57 ModularSpaceShip::ModularSpaceShip(Context* context) : SpaceShip(context) … … 94 94 for (unsigned int i=0; i < this->getAttachedObjects().size(); i++) 95 95 { 96 if (this->getAttachedObject(i) == NULL)96 if (this->getAttachedObject(i) == nullptr) 97 97 { 98 98 break; 99 99 } 100 100 // iterate through all attached parts 101 for( unsigned int j = 0; j < this->partList_.size(); j++)101 for(ShipPart* part : this->partList_) 102 102 { 103 103 // if the name of the part matches the name of the object, add the object to that parts entitylist (unless it was already done). 104 if(( this->partList_[j]->getName() == this->getAttachedObject(i)->getName()) && !this->partList_[j]->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))))104 if((part->getName() == this->getAttachedObject(i)->getName()) && !part->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)))) 105 105 { 106 106 // The Entity is added to the part's entityList_ 107 this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));107 part->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))); 108 108 // An entry in the partMap_ is created, assigning the part to the entity. 109 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]);109 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), part); 110 110 } 111 111 } … … 146 146 ShipPart* ModularSpaceShip::getPartOfEntity(StaticEntity* entity) const 147 147 { 148 for ( std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it)149 { 150 if ( it->first == entity)151 return it->second;152 } 153 return NULL;148 for (const auto& mapEntry : this->partMap_) 149 { 150 if (mapEntry.first == entity) 151 return mapEntry.second; 152 } 153 return nullptr; 154 154 } 155 155 … … 160 160 void ModularSpaceShip::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) 161 161 { 162 if (cs != NULL && this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL)162 if (cs != nullptr && this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != nullptr) 163 163 this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator); 164 164 else … … 174 174 void ModularSpaceShip::killShipPartStatic(std::string name) 175 175 { 176 for ( std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_s->begin(); it != ModularSpaceShip::partMap_s->end(); ++it)177 { 178 if ( it->second->getName() == name)179 { 180 it->second->death();176 for (const auto& mapEntry : *ModularSpaceShip::partMap_s) 177 { 178 if (mapEntry.second->getName() == name) 179 { 180 mapEntry.second->death(); 181 181 return; 182 182 } … … 193 193 void ModularSpaceShip::killShipPart(std::string name) 194 194 { 195 for ( std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_.begin(); it != ModularSpaceShip::partMap_.end(); ++it)196 { 197 if ( it->second->getName() == name)198 { 199 it->second->death();195 for (const auto& mapEntry : ModularSpaceShip::partMap_) 196 { 197 if (mapEntry.second->getName() == name) 198 { 199 mapEntry.second->death(); 200 200 return; 201 201 } … … 212 212 void ModularSpaceShip::addShipPart(ShipPart* part) 213 213 { 214 OrxAssert(part != NULL, "The ShipPart cannot be NULL.");214 OrxAssert(part != nullptr, "The ShipPart cannot be nullptr."); 215 215 this->partList_.push_back(part); 216 216 part->setParent(this); … … 222 222 Get the i-th ShipPart of the SpaceShip. 223 223 @return 224 Returns a pointer to the i-the ShipPart. NULLif there is no ShipPart with that index.224 Returns a pointer to the i-the ShipPart. nullptr if there is no ShipPart with that index. 225 225 */ 226 226 ShipPart* ModularSpaceShip::getShipPart(unsigned int index) 227 227 { 228 228 if(this->partList_.size() <= index) 229 return NULL;229 return nullptr; 230 230 else 231 231 return this->partList_[index]; … … 238 238 The name of the ShipPart to be returned. 239 239 @return 240 Pointer to the ShipPart with the given name, or NULLif not found.240 Pointer to the ShipPart with the given name, or nullptr if not found. 241 241 */ 242 242 ShipPart* ModularSpaceShip::getShipPartByName(std::string name) 243 243 { 244 for( std::vector<ShipPart*>::iterator it = this->partList_.begin(); it != this->partList_.end(); ++it)245 { 246 if(orxonox_cast<ShipPart*>( *it)->getName() == name)247 { 248 return orxonox_cast<ShipPart*>( *it);244 for(ShipPart* part : this->partList_) 245 { 246 if(orxonox_cast<ShipPart*>(part)->getName() == name) 247 { 248 return orxonox_cast<ShipPart*>(part); 249 249 } 250 250 } 251 251 orxout(internal_warning) << "Couldn't find ShipPart with name \"" << name << "\"." << endl; 252 return NULL;252 return nullptr; 253 253 } 254 254 … … 256 256 @brief 257 257 Check whether the SpaceShip has a particular Engine. 258 @param engine258 @param search 259 259 A pointer to the Engine to be checked. 260 260 */ 261 bool ModularSpaceShip::hasShipPart(ShipPart* part) const262 { 263 for( unsigned int i = 0; i < this->partList_.size(); i++)264 { 265 if( this->partList_[i] == part)261 bool ModularSpaceShip::hasShipPart(ShipPart* search) const 262 { 263 for(ShipPart* part : this->partList_) 264 { 265 if(part == search) 266 266 return true; 267 267 } -
code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.h
r10262 r11071 109 109 ShipPart* getPartOfEntity(StaticEntity* entity) const; 110 110 111 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);111 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = nullptr, const btCollisionShape* cs = nullptr); 112 112 113 113 static void killShipPartStatic(std::string name); -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r11052 r11071 77 77 this->shieldRechargeWaitCountdown_ = 0; 78 78 79 this->lastHitOriginator_ = 0;79 this->lastHitOriginator_ = nullptr; 80 80 81 81 // set damage multiplier to default value 1, meaning nominal damage … … 86 86 this->aimPosition_ = Vector3::ZERO; 87 87 88 //this->explosionPartList_ = NULL;88 //this->explosionPartList_ = nullptr; 89 89 90 90 if (GameMode::isMaster()) … … 94 94 } 95 95 else 96 this->weaponSystem_ = 0;96 this->weaponSystem_ = nullptr; 97 97 98 98 this->setRadarObjectColour(ColourValue::Red); 99 this->setRadarObjectShape(RadarViewable:: Dot);99 this->setRadarObjectShape(RadarViewable::Shape::Dot); 100 100 101 101 this->registerVariables(); … … 112 112 else 113 113 { 114 this->explosionSound_ = 0;114 this->explosionSound_ = nullptr; 115 115 } 116 116 } … … 373 373 { 374 374 // delete the AIController // <-- TODO: delete? nothing is deleted here... should we delete the controller? 375 slave->setControllableEntity( 0);375 slave->setControllableEntity(nullptr); 376 376 377 377 // set a new master within the formation … … 468 468 return this->weaponSystem_->getWeaponSlot(index); 469 469 else 470 return 0;470 return nullptr; 471 471 } 472 472 … … 482 482 return this->weaponSystem_->getWeaponSet(index); 483 483 else 484 return 0;484 return nullptr; 485 485 } 486 486 … … 510 510 return this->weaponSystem_->getWeaponPack(index); 511 511 else 512 return 0; 513 } 514 515 std::vector<WeaponPack *> * Pawn::getAllWeaponPacks() 516 { 517 if (this->weaponSystem_) 518 return this->weaponSystem_->getAllWeaponPacks(); 519 else 520 return 0; 512 return nullptr; 521 513 } 522 514 … … 531 523 Munition* Pawn::getMunitionXML() const 532 524 { 533 return NULL;525 return nullptr; 534 526 } 535 527 … … 541 533 } 542 534 543 return NULL;535 return nullptr; 544 536 } 545 537 … … 564 556 bool Pawn::hasSlaves() 565 557 { 566 for (ObjectList<FormationController>::iterator it = 567 ObjectList<FormationController>::begin(); 568 it != ObjectList<FormationController>::end(); ++it ) 558 for (FormationController* controller : ObjectList<FormationController>()) 569 559 { 570 560 // checks if the pawn's controller has a slave 571 if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController())561 if (this->hasHumanController() && controller->getMaster() == this->getPlayer()->getController()) 572 562 return true; 573 563 } … … 577 567 // A function that returns a slave of the pawn's controller 578 568 Controller* Pawn::getSlave(){ 579 for (ObjectList<FormationController>::iterator it = 580 ObjectList<FormationController>::begin(); 581 it != ObjectList<FormationController>::end(); ++it ) 582 { 583 if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController()) 584 return it->getController(); 585 } 586 return 0; 569 for (FormationController* controller : ObjectList<FormationController>()) 570 { 571 if (this->hasHumanController() && controller->getMaster() == this->getPlayer()->getController()) 572 return controller->getController(); 573 } 574 return nullptr; 587 575 } 588 576 -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r11052 r11071 63 63 virtual ~Pawn(); 64 64 65 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;66 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) ;67 virtual void tick(float dt) ;65 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 66 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; 67 virtual void tick(float dt) override; 68 68 69 69 inline bool isAlive() const … … 71 71 72 72 73 v irtual void setHealth(float health);73 void setHealth(float health); 74 74 inline void addHealth(float health) 75 75 { this->setHealth(this->health_ + health); } … … 89 89 { return this->initialHealth_; } 90 90 91 v irtual void setShieldHealth(float shieldHealth);91 void setShieldHealth(float shieldHealth); 92 92 93 93 inline float getShieldHealth() … … 100 100 { return (this->getShieldHealth() > 0); } 101 101 102 v irtual void setMaxShieldHealth(float maxshieldhealth);102 void setMaxShieldHealth(float maxshieldhealth); 103 103 inline float getMaxShieldHealth() const 104 104 { return this->maxShieldHealth_; } … … 119 119 { return this->shieldAbsorption_; } 120 120 121 v irtual void setShieldRechargeRate(float shieldRechargeRate);121 void setShieldRechargeRate(float shieldRechargeRate); 122 122 inline float getShieldRechargeRate() const 123 123 { return this->shieldRechargeRate_; } 124 124 125 v irtual void setShieldRechargeWaitTime(float shieldRechargeWaitTime);125 void setShieldRechargeWaitTime(float shieldRechargeWaitTime); 126 126 inline float getShieldRechargeWaitTime() const 127 127 { return this->shieldRechargeWaitTime_; } … … 133 133 { this->shieldRechargeWaitCountdown_ = this->getShieldRechargeWaitTime(); } // TODO: Implement in Projectile.cc 134 134 135 v irtual void decreaseShieldRechargeCountdownTime(float dt);135 void decreaseShieldRechargeCountdownTime(float dt); 136 136 137 137 /** @brief Sets the state of the pawns vulnerability. @param bVulnerable */ … … 157 157 virtual void kill(); 158 158 159 virtual void fired(unsigned int firemode) ;159 virtual void fired(unsigned int firemode) override; 160 160 virtual void postSpawn(); 161 161 … … 170 170 void addWeaponPackXML(WeaponPack * wPack); 171 171 WeaponPack * getWeaponPack(unsigned int index) const; 172 std::vector<WeaponPack *> * getAllWeaponPacks();173 172 174 173 void addMunitionXML(Munition* munition); … … 201 200 202 201 203 virtual void startLocalHumanControl() ;202 virtual void startLocalHumanControl() override; 204 203 205 204 void setAimPosition( Vector3 position ) … … 208 207 { return this->aimPosition_; } 209 208 210 virtual const Vector3& getCarrierPosition(void) const 209 virtual const Vector3& getCarrierPosition(void) const override 211 210 { return this->getWorldPosition(); }; 212 211 213 virtual void changedVisibility() ;212 virtual void changedVisibility() override; 214 213 215 214 void setExplosionSound(const std::string& engineSound); 216 215 const std::string& getExplosionSound(); 217 216 218 virtualconst WeaponSystem* getWeaponSystem() const217 inline const WeaponSystem* getWeaponSystem() const 219 218 { return this->weaponSystem_; } 220 219 221 220 protected: 222 virtual void preDestroy() ;223 224 virtual void setPlayer(PlayerInfo* player) ;225 virtual void removePlayer() ;221 virtual void preDestroy() override; 222 223 virtual void setPlayer(PlayerInfo* player) override; 224 virtual void removePlayer() override; 226 225 227 226 virtual void death(); … … 231 230 virtual void spawneffect(); 232 231 233 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);232 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = nullptr, const btCollisionShape* cs = nullptr); 234 233 235 234 bool bAlive_; 236 235 bool bVulnerable_; ///< If false the pawn may not ged damaged 237 236 238 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const 237 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const override 239 238 { return new std::vector<PickupCarrier*>(); } 240 virtual PickupCarrier* getCarrierParent(void) const 241 { return NULL; }239 virtual PickupCarrier* getCarrierParent(void) const override 240 { return nullptr; } 242 241 243 242 -
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; -
code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
r10624 r11071 58 58 this->localVelocity_ = Vector3::ZERO; 59 59 this->setHudTemplate("spectatorhud"); 60 this->greetingFlare_ = 0;60 this->greetingFlare_ = nullptr; 61 61 62 62 this->setDestroyWhenPlayerLeft(true); -
code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r10624 r11071 51 51 } 52 52 53 this->setRadarObjectShape(RadarViewable:: Triangle);53 this->setRadarObjectShape(RadarViewable::Shape::Triangle); 54 54 } 55 55 … … 80 80 81 81 std::set<WorldEntity*> attachments = this->getAttachedObjects(); 82 for ( std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)82 for (WorldEntity* attachment : attachments) 83 83 { 84 if ( (*it)->isA(Class(TeamColourable)))84 if (attachment->isA(Class(TeamColourable))) 85 85 { 86 TeamColourable* tc = orxonox_cast<TeamColourable*>( *it);86 TeamColourable* tc = orxonox_cast<TeamColourable*>(attachment); 87 87 tc->setTeamColour(colour); 88 88 } … … 92 92 93 93 // Call this so bots stop shooting at the base after they converted it 94 for ( ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it)95 it->abandonTarget(this);94 for (ArtificialController* controller : ObjectList<ArtificialController>()) 95 controller->abandonTarget(this); 96 96 } 97 97 } -
code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.h
r9667 r11071 36 36 namespace orxonox 37 37 { 38 namespaceBaseState38 enum class BaseState 39 39 { 40 enum Value 41 { 42 Uncontrolled, 43 ControlTeam1, 44 ControlTeam2, 45 }; 46 } 40 Uncontrolled, 41 ControlTeam1, 42 ControlTeam2, 43 }; 47 44 48 45 … … 58 55 59 56 // Set the state of a base to whatever the argument of the function is 60 void setState(BaseState ::Valuestate)57 void setState(BaseState state) 61 58 { 62 59 this->state_ = state; … … 66 63 67 64 // Get the state of a base as a return value 68 BaseState ::ValuegetState() const65 BaseState getState() const 69 66 { 70 67 return this->state_; … … 75 72 void changeTeamColour(); 76 73 77 BaseState ::Valuestate_;74 BaseState state_; 78 75 }; 79 76 }
Note: See TracChangeset
for help on using the changeset viewer.