Changeset 11071 for code/trunk/src/modules/objects
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/objects/Attacher.cc
r9667 r11071 40 40 RegisterObject(Attacher); 41 41 42 this->target_ = 0;42 this->target_ = nullptr; 43 43 } 44 44 … … 61 61 SUPER(Attacher, changedActivity); 62 62 63 for ( std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)64 (*it)->setActive(this->isActive());63 for (WorldEntity* object : this->objects_) 64 object->setActive(this->isActive()); 65 65 } 66 66 … … 69 69 SUPER(Attacher, changedVisibility); 70 70 71 for ( std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)72 (*it)->setVisible(this->isVisible());71 for (WorldEntity* object : this->objects_) 72 object->setVisible(this->isVisible()); 73 73 } 74 74 … … 83 83 { 84 84 unsigned int i = 0; 85 for ( std::list<WorldEntity*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)85 for (WorldEntity* object : this->objects_) 86 86 { 87 87 if (i == index) 88 return (*it);88 return object; 89 89 90 90 ++i; 91 91 } 92 return 0;92 return nullptr; 93 93 } 94 94 … … 96 96 { 97 97 this->targetname_ = target; 98 this->target_ = 0;98 this->target_ = nullptr; 99 99 100 100 if (this->targetname_.empty()) 101 101 return; 102 102 103 for ( ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)103 for (WorldEntity* worldEntity : ObjectList<WorldEntity>()) 104 104 { 105 if ( it->getName() == this->targetname_)105 if (worldEntity->getName() == this->targetname_) 106 106 { 107 this->target_ = *it;108 this->attachToParent( *it);107 this->target_ = worldEntity; 108 this->attachToParent(worldEntity); 109 109 } 110 110 } -
code/trunk/src/modules/objects/Attacher.h
r9667 r11071 51 51 virtual ~Attacher() {} 52 52 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 54 54 55 virtual void processEvent(Event& event) ;56 virtual void changedActivity() ;57 virtual void changedVisibility() ;55 virtual void processEvent(Event& event) override; 56 virtual void changedActivity() override; 57 virtual void changedVisibility() override; 58 58 59 59 void addObject(WorldEntity* object); … … 64 64 { return this->targetname_; } 65 65 66 v oid loadedNewXMLName(BaseObject* object);66 virtual void loadedNewXMLName(BaseObject* object) override; 67 67 68 68 private: -
code/trunk/src/modules/objects/ForceField.cc
r9945 r11071 67 67 this->setMassDiameter(0); //! We allow point-masses 68 68 this->setLength(2000); 69 this->mode_ = forceFieldMode::tube;69 this->mode_ = ForceFieldMode::tube; 70 70 71 71 this->registerVariables(); … … 115 115 void ForceField::tick(float dt) 116 116 { 117 if(this->mode_ == forceFieldMode::tube)118 { 119 // Iterate over all objects that could possibly be affected by the ForceField. 120 for ( ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)117 if(this->mode_ == ForceFieldMode::tube) 118 { 119 // Iterate over all objects that could possibly be affected by the ForceField. 120 for (MobileEntity* mobileEntity : ObjectList<MobileEntity>()) 121 121 { 122 122 // The direction of the orientation of the force field. … … 125 125 126 126 // Vector from the center of the force field to the object its acting on. 127 Vector3 distanceVector = it->getWorldPosition() - (this->getWorldPosition() + (this->halfLength_ * direction));127 Vector3 distanceVector = mobileEntity->getWorldPosition() - (this->getWorldPosition() + (this->halfLength_ * direction)); 128 128 129 129 // The object is outside a ball around the center with radius length/2 of the ForceField. … … 132 132 133 133 // The distance of the object form the orientation vector. (Or rather the smallest distance from the orientation vector) 134 float distanceFromDirectionVector = (( it->getWorldPosition() - this->getWorldPosition()).crossProduct(direction)).length();134 float distanceFromDirectionVector = ((mobileEntity->getWorldPosition() - this->getWorldPosition()).crossProduct(direction)).length(); 135 135 136 136 // If the object in a tube of radius 'radius' around the direction of orientation. … … 140 140 // Apply a force to the object in the direction of the orientation. 141 141 // The force is highest when the object is directly on the direction vector, with a linear decrease, finally reaching zero, when distanceFromDirectionVector = radius. 142 it->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction);143 } 144 } 145 else if(this->mode_ == forceFieldMode::sphere)146 { 147 // Iterate over all objects that could possibly be affected by the ForceField. 148 for ( ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)149 { 150 Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();142 mobileEntity->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction); 143 } 144 } 145 else if(this->mode_ == ForceFieldMode::sphere) 146 { 147 // Iterate over all objects that could possibly be affected by the ForceField. 148 for (MobileEntity* mobileEntity : ObjectList<MobileEntity>()) 149 { 150 Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition(); 151 151 float distance = distanceVector.length(); 152 152 // If the object is within 'radius' distance. … … 155 155 distanceVector.normalise(); 156 156 // Apply a force proportional to the velocity, with highest force at the origin of the sphere, linear decreasing until reaching a distance of 'radius' from the origin, where the force reaches zero. 157 it->applyCentralForce((this->radius_ - distance)/this->radius_ * this->velocity_ * distanceVector);158 } 159 } 160 } 161 else if(this->mode_ == forceFieldMode::invertedSphere)162 { 163 // Iterate over all objects that could possibly be affected by the ForceField. 164 for ( ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)165 { 166 Vector3 distanceVector = this->getWorldPosition() - it->getWorldPosition();157 mobileEntity->applyCentralForce((this->radius_ - distance)/this->radius_ * this->velocity_ * distanceVector); 158 } 159 } 160 } 161 else if(this->mode_ == ForceFieldMode::invertedSphere) 162 { 163 // Iterate over all objects that could possibly be affected by the ForceField. 164 for (MobileEntity* mobileEntity : ObjectList<MobileEntity>()) 165 { 166 Vector3 distanceVector = this->getWorldPosition() - mobileEntity->getWorldPosition(); 167 167 float distance = distanceVector.length(); 168 168 // If the object is within 'radius' distance and no more than 'length' away from the boundary of the sphere. … … 172 172 distanceVector.normalise(); 173 173 // Apply a force proportional to the velocity, with highest force at the boundary of the sphere, linear decreasing until reaching a distance of 'radius-length' from the origin, where the force reaches zero. 174 it->applyCentralForce((distance-range)/range * this->velocity_ * distanceVector);175 } 176 } 177 } 178 else if(this->mode_ == forceFieldMode::newtonianGravity)179 { 180 // Iterate over all objects that could possibly be affected by the ForceField. 181 for ( ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)182 { 183 Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();174 mobileEntity->applyCentralForce((distance-range)/range * this->velocity_ * distanceVector); 175 } 176 } 177 } 178 else if(this->mode_ == ForceFieldMode::newtonianGravity) 179 { 180 // Iterate over all objects that could possibly be affected by the ForceField. 181 for (MobileEntity* mobileEntity : ObjectList<MobileEntity>()) 182 { 183 Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition(); 184 184 float distance = distanceVector.length(); 185 185 // If the object is within 'radius' distance and especially further away than massRadius_ … … 197 197 198 198 // Note: this so called force is actually an acceleration! 199 it->applyCentralForce((-1) * (ForceField::attenFactor_ * ForceField::gravConstant_ * this->getMass()) / (distance * distance) * distanceVector);200 } 201 } 202 } 203 else if(this->mode_ == forceFieldMode::homogen)204 { 205 // Iterate over all objects that could possibly be affected by the ForceField. 206 for ( ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)207 { 208 Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();199 mobileEntity->applyCentralForce((-1) * (ForceField::attenFactor_ * ForceField::gravConstant_ * this->getMass()) / (distance * distance) * distanceVector); 200 } 201 } 202 } 203 else if(this->mode_ == ForceFieldMode::homogen) 204 { 205 // Iterate over all objects that could possibly be affected by the ForceField. 206 for (MobileEntity* mobileEntity : ObjectList<MobileEntity>()) 207 { 208 Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition(); 209 209 float distance = distanceVector.length(); 210 210 if (distance < this->radius_ && distance > this->massRadius_) … … 212 212 // Add a Acceleration in forceDirection_. 213 213 // Vector3(0,0,0) is the direction, where the force should work. 214 it->addAcceleration(forceDirection_ , Vector3(0,0,0));214 mobileEntity->addAcceleration(forceDirection_ , Vector3(0,0,0)); 215 215 } 216 216 } … … 227 227 { 228 228 if(mode == ForceField::modeTube_s) 229 this->mode_ = forceFieldMode::tube;229 this->mode_ = ForceFieldMode::tube; 230 230 else if(mode == ForceField::modeSphere_s) 231 this->mode_ = forceFieldMode::sphere;231 this->mode_ = ForceFieldMode::sphere; 232 232 else if(mode == ForceField::modeInvertedSphere_s) 233 this->mode_ = forceFieldMode::invertedSphere;233 this->mode_ = ForceFieldMode::invertedSphere; 234 234 else if(mode == ForceField::modeNewtonianGravity_s) 235 this->mode_ = forceFieldMode::newtonianGravity;235 this->mode_ = ForceFieldMode::newtonianGravity; 236 236 237 237 else if(mode == ForceField::modeHomogen_s) 238 this->mode_ = forceFieldMode::homogen;238 this->mode_ = ForceFieldMode::homogen; 239 239 240 240 else 241 241 { 242 242 orxout(internal_warning) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << endl; 243 this->mode_ = forceFieldMode::tube;243 this->mode_ = ForceFieldMode::tube; 244 244 } 245 245 } … … 255 255 switch(this->mode_) 256 256 { 257 case forceFieldMode::tube:257 case ForceFieldMode::tube: 258 258 return ForceField::modeTube_s; 259 case forceFieldMode::sphere:259 case ForceFieldMode::sphere: 260 260 return ForceField::modeSphere_s; 261 case forceFieldMode::invertedSphere:261 case ForceFieldMode::invertedSphere: 262 262 return ForceField::modeInvertedSphere_s; 263 case forceFieldMode::newtonianGravity:263 case ForceFieldMode::newtonianGravity: 264 264 return ForceField::modeNewtonianGravity_s; 265 265 266 case forceFieldMode::homogen:266 case ForceFieldMode::homogen: 267 267 return ForceField::modeHomogen_s; 268 268 -
code/trunk/src/modules/objects/ForceField.h
r10622 r11071 52 52 @ingroup Objects 53 53 */ 54 namespace forceFieldMode 55 { 56 enum Value { 57 tube, //!< The ForceField has a tube shape. 58 sphere, //!< The ForceField has a spherical shape. 59 invertedSphere, //!< The ForceField has a spherical shape but "inverted" behavior. 60 newtonianGravity, //!< The ForceField imitates Newtonian gravitation for use in stellar bodies. 61 homogen //!< Local homogenous Force field with changeable direction for the Space Station 62 }; 63 } 54 enum class ForceFieldMode { 55 tube, //!< The ForceField has a tube shape. 56 sphere, //!< The ForceField has a spherical shape. 57 invertedSphere, //!< The ForceField has a spherical shape but "inverted" behavior. 58 newtonianGravity, //!< The ForceField imitates Newtonian gravitation for use in stellar bodies. 59 homogen //!< Local homogenous Force field with changeable direction for the Space Station 60 }; 64 61 65 62 /** … … 92 89 virtual ~ForceField(); 93 90 94 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Creates a ForceField object through XML.91 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Creates a ForceField object through XML. 95 92 void registerVariables(); //!< Registers the variables that should get synchronised over the network 96 virtual void tick(float dt) ; //!< A method that is called every tick.93 virtual void tick(float dt) override; //!< A method that is called every tick. 97 94 98 95 … … 172 169 float massRadius_; //!< The radius of the stellar body for the Newtonian ForceField. 173 170 float halfLength_; //!< Half of the length of the ForceField. 174 intmode_; //!< The mode of the ForceField.171 ForceFieldMode mode_; //!< The mode of the ForceField. 175 172 176 173 //! Gravitational constant for Newtonian ForceFields. -
code/trunk/src/modules/objects/Planet.h
r10624 r11071 52 52 virtual ~Planet(); 53 53 54 virtual void tick(float dt) ;54 virtual void tick(float dt) override; 55 55 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 57 57 58 virtual void changedVisibility() ;58 virtual void changedVisibility() override; 59 59 60 60 inline void setMeshSource(const std::string& meshname) -
code/trunk/src/modules/objects/Script.cc
r10624 r11071 140 140 141 141 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 142 PlayerInfo* player = NULL;142 PlayerInfo* player = nullptr; 143 143 144 144 // If the trigger is a PlayerTrigger. 145 if(pTrigger != NULL)145 if(pTrigger != nullptr) 146 146 { 147 147 if(!pTrigger->isForPlayer()) // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one. … … 153 153 return false; 154 154 155 if(player == NULL) //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.155 if(player == nullptr) //TODO: Will this ever happen? If not, change in NotificationDispatcher as well. 156 156 { 157 157 orxout(internal_warning) << "The Script was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << endl; … … 196 196 { 197 197 const std::map<unsigned int, PlayerInfo*> clients = PlayerManager::getInstance().getClients(); 198 for( std::map<unsigned int, PlayerInfo*>::const_iterator it = clients.begin(); it != clients.end(); it++)198 for(const auto& mapEntry : clients) 199 199 { 200 callStaticNetworkFunction(&Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());200 callStaticNetworkFunction(&Script::executeHelper, mapEntry.first, this->getCode(), this->getMode(), this->getNeedsGraphics()); 201 201 if(this->times_ != Script::INF) // Decrement the number of remaining executions. 202 202 { -
code/trunk/src/modules/objects/Script.h
r9667 r11071 51 51 @brief The mode a specific @ref orxonox::Script "Script" is in. 52 52 */ 53 namespaceScriptMode53 enum class ScriptMode 54 54 { 55 enum Value 56 { 57 normal, //!< The @ref orxonox::Script "Scripts'" code is executed through the @ref orxonox::CommandExecutor "CommandExecutor". 58 lua //!< The @ref orxonox::Script "Scripts'" code is executed through lua. 59 }; 60 } 55 normal, //!< The @ref orxonox::Script "Scripts'" code is executed through the @ref orxonox::CommandExecutor "CommandExecutor". 56 lua //!< The @ref orxonox::Script "Scripts'" code is executed through lua. 57 }; 61 58 62 59 /** … … 98 95 virtual ~Script(); 99 96 100 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Method for creating a Script object through XML.101 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Creates a port that can be used to channel events and react to them.97 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method for creating a Script object through XML. 98 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Creates a port that can be used to channel events and react to them. 102 99 103 100 bool trigger(bool triggered, BaseObject* trigger); //!< Is called when an event comes in trough the event port. … … 168 165 { return this->forAll_; } 169 166 170 virtual void clientConnected(unsigned int clientId) ; //!< Callback that is called when a new client has connected.171 virtual void clientDisconnected(unsigned int clientid) {}167 virtual void clientConnected(unsigned int clientId) override; //!< Callback that is called when a new client has connected. 168 virtual void clientDisconnected(unsigned int clientid) override {} 172 169 173 170 private: … … 178 175 179 176 std::string code_; //!< The code that is executed by this Script. 180 ScriptMode ::Valuemode_; //!< The mode the Script is in. Determines whether the code is executed the normal way or in lua.177 ScriptMode mode_; //!< The mode the Script is in. Determines whether the code is executed the normal way or in lua. 181 178 std::string modeStr_; //!< The mode the Script is in, as a string. Is used for networking purposes. 182 179 bool onLoad_; //!< Whether the Scripts code is executed upon loading (creation) of this Script. … … 193 190 @param mode The mode of the Script. 194 191 */ 195 inline void setMode(ScriptMode ::Valuemode)192 inline void setMode(ScriptMode mode) 196 193 { this->mode_ = mode; } 197 194 }; -
code/trunk/src/modules/objects/SpaceBoundaries.cc
r10624 r11071 59 59 this->pawnsIn_.clear(); 60 60 61 for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)61 for(BillboardAdministration& billboard : this->billboards_) 62 62 { 63 if( current->billy != NULL)64 { 65 delete current->billy;63 if( billboard.billy != nullptr) 64 { 65 delete billboard.billy; 66 66 } 67 67 } … … 73 73 { 74 74 pawnsIn_.clear(); 75 for(ObjectList<Pawn>::iterator current = ObjectList<Pawn>::begin(); current != ObjectList<Pawn>::end(); ++current) 76 { 77 Pawn* currentPawn = *current; 75 for(Pawn* currentPawn : ObjectList<Pawn>()) 76 { 78 77 if( this->reaction_ == 0 ) 79 78 { … … 127 126 void SpaceBoundaries::setBillboardOptions(Billboard *billy) 128 127 { 129 if(billy != NULL)128 if(billy != nullptr) 130 129 { 131 130 billy->setMaterial("Grid"); … … 138 137 void SpaceBoundaries::removeAllBillboards() 139 138 { 140 for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)141 { 142 current->usedYet = false;143 current->billy->setVisible(false);139 for(BillboardAdministration& billboard : this->billboards_) 140 { 141 billboard.usedYet = false; 142 billboard.billy->setVisible(false); 144 143 } 145 144 } … … 208 207 float distance; 209 208 bool humanItem; 210 for( std::list<WeakPtr<Pawn> >::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ ) 211 { 212 Pawn* currentPawn = *current; 209 for(Pawn* currentPawn : pawnsIn_) 210 { 213 211 if( currentPawn && currentPawn->getNode() ) 214 212 { … … 250 248 float SpaceBoundaries::computeDistance(WorldEntity *item) 251 249 { 252 if(item != NULL)250 if(item != nullptr) 253 251 { 254 252 Vector3 itemPosition = item->getWorldPosition(); … … 310 308 bool SpaceBoundaries::isHumanPlayer(Pawn *item) 311 309 { 312 if(item != NULL)310 if(item != nullptr) 313 311 { 314 312 if(item->getPlayer()) -
code/trunk/src/modules/objects/SpaceBoundaries.h
r9667 r11071 93 93 int getReaction(); 94 94 95 v oid XMLPort(Element& xmlelement, XMLPort::Mode mode);95 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 96 96 97 v oid tick(float dt);97 virtual void tick(float dt) override; 98 98 99 99 private: … … 101 101 102 102 // Variabeln:: 103 std::list<WeakPtr<Pawn> 103 std::list<WeakPtr<Pawn>> pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle. 104 104 105 105 std::vector<BillboardAdministration> billboards_; -
code/trunk/src/modules/objects/Turret.cc
r10622 r11071 278 278 //slower the closer it is to the destination 279 279 Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_); 280 this->rotate(drot, WorldEntity:: World);280 this->rotate(drot, WorldEntity::TransformSpace::World); 281 281 this->rotation_ = Quaternion::IDENTITY; 282 282 } -
code/trunk/src/modules/objects/Turret.h
r11052 r11071 61 61 virtual ~Turret(); 62 62 63 virtual void rotatePitch(const Vector2& value) ;64 virtual void rotateYaw(const Vector2& value) ;65 virtual void rotateRoll(const Vector2& value) ;63 virtual void rotatePitch(const Vector2& value) override; 64 virtual void rotateYaw(const Vector2& value) override; 65 virtual void rotateRoll(const Vector2& value) override; 66 66 virtual float isInRange(const WorldEntity* target); 67 67 virtual void aimAtPosition(const Vector3 &position); 68 68 69 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;70 virtual void tick(float dt) ;69 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 70 virtual void tick(float dt) override; 71 71 72 72 /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/ -
code/trunk/src/modules/objects/controllers/TeamTargetProxy.cc
r10262 r11071 28 28 29 29 #include "TeamTargetProxy.h" 30 #include "core/CoreIncludes.h" 30 31 #include "worldentities/ControllableEntity.h" 31 32 #include "worldentities/pawns/Pawn.h" -
code/trunk/src/modules/objects/controllers/TurretController.cc
r10622 r11071 30 30 #include "worldentities/pawns/Pawn.h" 31 31 #include "objects/Turret.h" 32 #include "core/object/ObjectList.h" 33 #include "core/CoreIncludes.h" 32 34 33 35 namespace orxonox … … 81 83 { 82 84 this->forgetTarget(); 83 turret->setTarget( 0);85 turret->setTarget(nullptr); 84 86 } 85 87 … … 99 101 float minScore = FLT_MAX; 100 102 float tempScore; 101 Pawn* minScorePawn = 0; 102 103 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 104 { 105 Pawn* entity = orxonox_cast<Pawn*>(*it); 106 if (!entity || FormationController::sameTeam(turret, entity, this->getGametype())) 103 Pawn* minScorePawn = nullptr; 104 105 for (Pawn* pawn : ObjectList<Pawn>()) 106 { 107 if (!pawn || FormationController::sameTeam(turret, pawn, this->getGametype())) 107 108 continue; 108 tempScore = turret->isInRange( entity);109 tempScore = turret->isInRange(pawn); 109 110 if(tempScore != -1.f) 110 111 { … … 112 113 { 113 114 minScore = tempScore; 114 minScorePawn = entity;115 minScorePawn = pawn; 115 116 } 116 117 } -
code/trunk/src/modules/objects/eventsystem/EventDispatcher.cc
r9667 r11071 45 45 { 46 46 if (this->isInitialized()) 47 for ( std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)48 (*it)->destroy();47 for (BaseObject* target : this->targets_) 48 target->destroy(); 49 49 } 50 50 … … 61 61 void EventDispatcher::processEvent(Event& event) 62 62 { 63 for ( std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)64 (*it)->processEvent(event);63 for (BaseObject* target : this->targets_) 64 target->processEvent(event); 65 65 } 66 66 … … 73 73 { 74 74 unsigned int i = 0; 75 for ( std::list<BaseObject*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)75 for (BaseObject* target : this->targets_) 76 76 { 77 77 if (i == index) 78 return (*it);78 return target; 79 79 ++i; 80 80 } 81 return 0;81 return nullptr; 82 82 } 83 83 } -
code/trunk/src/modules/objects/eventsystem/EventFilter.cc
r9667 r11071 70 70 { 71 71 bool success = false; 72 for ( std::list<EventName*>::const_iterator it = this->names_.begin(); it != this->names_.end(); ++it)72 for (EventName* name : this->names_) 73 73 { 74 if ( (*it)->getName() == event.name_)74 if (name->getName() == event.name_) 75 75 { 76 76 success = true; … … 96 96 { 97 97 unsigned int i = 0; 98 for ( std::list<BaseObject*>::const_iterator it = this->sources_.begin(); it != this->sources_.end(); ++it)98 for (BaseObject* source : this->sources_) 99 99 { 100 100 if (i == index) 101 return (*it);101 return source; 102 102 ++i; 103 103 } 104 return 0;104 return nullptr; 105 105 } 106 106 … … 113 113 { 114 114 unsigned int i = 0; 115 for ( std::list<EventName*>::const_iterator it = this->names_.begin(); it != this->names_.end(); ++it)115 for (EventName* name : this->names_) 116 116 { 117 117 if (i == index) 118 return (*it);118 return name; 119 119 ++i; 120 120 } 121 return 0;121 return nullptr; 122 122 } 123 123 } -
code/trunk/src/modules/objects/eventsystem/EventListener.cc
r9667 r11071 78 78 return; 79 79 80 for ( ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)81 if ( it->getName() == this->eventName_)82 this->addEventSource( *it, "");80 for (BaseObject* object : ObjectList<BaseObject>()) 81 if (object->getName() == this->eventName_) 82 this->addEventSource(object, ""); 83 83 } 84 84 -
code/trunk/src/modules/objects/eventsystem/EventTarget.cc
r9667 r11071 73 73 this->target_ = name; 74 74 75 for ( ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)76 if ( it->getName() == this->target_)77 this->addEventTarget( *it);75 for (BaseObject* object : ObjectList<BaseObject>()) 76 if (object->getName() == this->target_) 77 this->addEventTarget(object); 78 78 } 79 79 -
code/trunk/src/modules/objects/triggers/CheckPoint.cc
r10624 r11071 56 56 57 57 this->setRadarObjectColour(ColourValue::Green); 58 this->setRadarObjectShape(RadarViewable:: Dot);58 this->setRadarObjectShape(RadarViewable::Shape::Dot); 59 59 this->setRadarVisibility(false); 60 60 -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
r10624 r11071 58 58 59 59 this->distance_ = 100.0f; 60 this->setBeaconModeDirect( distanceMultiTriggerBeaconMode::off);60 this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::off); 61 61 this->targetName_ = ""; 62 62 this->beaconMask_.exclude(Class(BaseObject)); … … 97 97 { 98 98 99 std::queue<MultiTriggerState*>* queue = NULL;99 std::queue<MultiTriggerState*>* queue = nullptr; 100 100 101 101 // Check for objects that were in range but no longer are. Iterate through all objects, that are in range. 102 for(std::set<WeakPtr<WorldEntity> 102 for(std::set<WeakPtr<WorldEntity>>::iterator it = this->range_.begin(); it != this->range_.end(); ) 103 103 { 104 104 WorldEntity* entity = *it; 105 105 106 106 // If the entity no longer exists. 107 if(entity == NULL)107 if(entity == nullptr) 108 108 { 109 109 this->range_.erase(it++); … … 118 118 119 119 // If no queue has been created, yet. 120 if(queue == NULL)120 if(queue == nullptr) 121 121 queue = new std::queue<MultiTriggerState*>(); 122 122 … … 136 136 ClassTreeMask targetMask = this->getTargetMask(); 137 137 // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons. 138 if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)138 if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify) 139 139 targetMask = this->beaconMask_; 140 140 … … 145 145 146 146 // If the DistanceMultiTrigger is in identify-mode and the DistanceTriggerBeacon attached to the object has the wrong name we ignore it. 147 if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)147 if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify) 148 148 { 149 149 if(entity->getName() != this->targetName_) … … 155 155 156 156 // If the DistanceMultiTrigger is in exclude mode and the DistanceTriggerBeacon attached to the object has the right name, we ignore it. 157 if(this->beaconMode_ == distanceMultiTriggerBeaconMode::exclude)157 if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::exclude) 158 158 { 159 159 160 const std::set<WorldEntity*> attached = entity->getAttachedObjects();160 const std::set<WorldEntity*> attachedObjects = entity->getAttachedObjects(); 161 161 bool found = false; 162 for( std::set<WorldEntity*>::const_iterator it = attached.begin(); it != attached.end(); it++)162 for(WorldEntity* attachedObject : attachedObjects) 163 163 { 164 if( (*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(*it)->getName() == this->targetName_)164 if(attachedObject->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(attachedObject)->getName() == this->targetName_) 165 165 { 166 166 found = true; … … 182 182 183 183 // Change the entity to the parent of the DistanceTriggerBeacon (if in identify-mode), which is the entity to which the beacon is attached. 184 if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)184 if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify) 185 185 entity = entity->getParent(); 186 186 187 187 // If no queue has been created, yet. 188 if(queue == NULL)188 if(queue == nullptr) 189 189 queue = new std::queue<MultiTriggerState*>(); 190 190 … … 206 206 The mode as an enum. 207 207 */ 208 void DistanceMultiTrigger::setBeaconModeDirect( distanceMultiTriggerBeaconMode::Value mode)208 void DistanceMultiTrigger::setBeaconModeDirect(DistanceMultiTriggerBeaconMode mode) 209 209 { 210 210 this->beaconMode_ = mode; … … 221 221 switch(this->getBeaconModeDirect()) 222 222 { 223 case distanceMultiTriggerBeaconMode::off :223 case DistanceMultiTriggerBeaconMode::off : 224 224 return DistanceMultiTrigger::beaconModeOff_s; 225 case distanceMultiTriggerBeaconMode::identify:225 case DistanceMultiTriggerBeaconMode::identify: 226 226 return DistanceMultiTrigger::beaconModeIdentify_s; 227 case distanceMultiTriggerBeaconMode::exclude:227 case DistanceMultiTriggerBeaconMode::exclude: 228 228 return DistanceMultiTrigger::beaconModeExlcude_s; 229 229 default : … … 242 242 { 243 243 if(mode == DistanceMultiTrigger::beaconModeOff_s) 244 this->setBeaconModeDirect( distanceMultiTriggerBeaconMode::off);244 this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::off); 245 245 else if(mode == DistanceMultiTrigger::beaconModeIdentify_s) 246 this->setBeaconModeDirect( distanceMultiTriggerBeaconMode::identify);246 this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::identify); 247 247 else if(mode == DistanceMultiTrigger::beaconModeExlcude_s) 248 this->setBeaconModeDirect( distanceMultiTriggerBeaconMode::exclude);248 this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::exclude); 249 249 else 250 250 orxout(internal_error, context::triggers) << "Invalid beacon mode in DistanceMultiTrigger." << endl; … … 261 261 bool DistanceMultiTrigger::addToRange(WorldEntity* entity) 262 262 { 263 std::pair<std::set<WeakPtr<WorldEntity> 263 std::pair<std::set<WeakPtr<WorldEntity>>::iterator, bool> pair = this->range_.insert(entity); 264 264 return pair.second; 265 265 } -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
r10624 r11071 55 55 @ingroup MultiTrigger 56 56 */ 57 namespace distanceMultiTriggerBeaconMode 58 { 59 enum Value { 60 off, //!< The DistanceMultiTrigger is not in <em>beacon-mode</em>. 61 identify, //!< The DistanceTrigger is in <em>identify-mode</em>. 62 exclude //!< The DistanceTrigger is in <em>exclude-mode</em>. 63 }; 64 } 57 enum class DistanceMultiTriggerBeaconMode { 58 off, //!< The DistanceMultiTrigger is not in <em>beacon-mode</em>. 59 identify, //!< The DistanceTrigger is in <em>identify-mode</em>. 60 exclude //!< The DistanceTrigger is in <em>exclude-mode</em>. 61 }; 65 62 66 63 /** … … 113 110 { return this->distance_; } 114 111 115 void setBeaconModeDirect( distanceMultiTriggerBeaconMode::Value mode); // Set the beacon mode.112 void setBeaconModeDirect(DistanceMultiTriggerBeaconMode mode); // Set the beacon mode. 116 113 /** 117 114 @brief Get the beacon mode. 118 115 @return Returns the mode as an enum. 119 116 */ 120 inline distanceMultiTriggerBeaconMode::Value getBeaconModeDirect(void) const117 inline DistanceMultiTriggerBeaconMode getBeaconModeDirect(void) const 121 118 { return this->beaconMode_; } 122 119 void setBeaconMode(const std::string& mode); // Set the beacon mode. … … 149 146 float distance_; //!< The distance at which the DistanceMultiTrigger triggers. 150 147 151 distanceMultiTriggerBeaconMode::Value beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in.148 DistanceMultiTriggerBeaconMode beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in. 152 149 std::string targetName_; //!< The target name, used in <em>single-target</em> mode. 153 150 ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons. 154 151 155 std::set<WeakPtr<WorldEntity> 152 std::set<WeakPtr<WorldEntity>> range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger. 156 153 157 154 }; -
code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
r10624 r11071 106 106 this->setForPlayer(true); 107 107 108 if (targetId == NULL)108 if (targetId == nullptr) 109 109 { 110 110 orxout(internal_error, context::triggers) << "\"" << targetStr << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ')' << endl; … … 147 147 { 148 148 // Check whether there is a cached object, it still exists and whether it is still in range, if so nothing further needs to be done. 149 if(this->cache_ != NULL)149 if(this->cache_ != nullptr) 150 150 { 151 151 if((this->cache_->getWorldPosition() - this->getWorldPosition()).length() < this->distance_) … … 158 158 ClassTreeMask targetMask = this->targetMask_; 159 159 // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons. 160 if(this->beaconMode_ == distanceTriggerBeaconMode::identify)160 if(this->beaconMode_ == DistanceTriggerBeaconMode::identify) 161 161 targetMask = this->beaconMask_; 162 162 … … 167 167 168 168 // If the DistanceTrigger is in identify-mode and the DistanceTriggerBeacon attached to the object has the wrong name we ignore it. 169 if(this->beaconMode_ == distanceTriggerBeaconMode::identify)169 if(this->beaconMode_ == DistanceTriggerBeaconMode::identify) 170 170 { 171 171 if(entity->getName() != this->targetName_) … … 177 177 178 178 // If the DistanceTrigger is in exclude mode and the DistanceTriggerBeacon attached to the object has the right name, we ignore it. 179 if(this->beaconMode_ == distanceTriggerBeaconMode::exclude)179 if(this->beaconMode_ == DistanceTriggerBeaconMode::exclude) 180 180 { 181 181 182 const std::set<WorldEntity*> attached = entity->getAttachedObjects();182 const std::set<WorldEntity*> attachedObjects = entity->getAttachedObjects(); 183 183 bool found = false; 184 for( std::set<WorldEntity*>::const_iterator it = attached.begin(); it != attached.end(); it++)184 for(WorldEntity* attachedObject : attachedObjects) 185 185 { 186 if( (*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(*it)->getName() == this->targetName_)186 if(attachedObject->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(attachedObject)->getName() == this->targetName_) 187 187 { 188 188 found = true; … … 202 202 { 203 203 // Change the entity to the parent of the DistanceTriggerBeacon (if in identify-mode), which is the entity to which the beacon is attached. 204 if(this->beaconMode_ == distanceTriggerBeaconMode::identify)204 if(this->beaconMode_ == DistanceTriggerBeaconMode::identify) 205 205 entity = entity->getParent(); 206 206 207 207 Pawn* pawn = orxonox_cast<Pawn*>(entity); 208 if(pawn != NULL)208 if(pawn != nullptr) 209 209 this->setTriggeringPawn(pawn); 210 210 else 211 orxout(internal_warning, context::triggers) << "Pawn was NULL." << endl;211 orxout(internal_warning, context::triggers) << "Pawn was nullptr." << endl; 212 212 } 213 213 … … 228 228 The mode as an enum. 229 229 */ 230 void DistanceTrigger::setBeaconModeDirect( distanceTriggerBeaconMode::Value mode)230 void DistanceTrigger::setBeaconModeDirect(DistanceTriggerBeaconMode mode) 231 231 { 232 232 this->beaconMode_ = mode; … … 243 243 switch(this->getBeaconModeDirect()) 244 244 { 245 case distanceTriggerBeaconMode::off :245 case DistanceTriggerBeaconMode::off : 246 246 return DistanceTrigger::beaconModeOff_s; 247 case distanceTriggerBeaconMode::identify:247 case DistanceTriggerBeaconMode::identify: 248 248 return DistanceTrigger::beaconModeIdentify_s; 249 case distanceTriggerBeaconMode::exclude:249 case DistanceTriggerBeaconMode::exclude: 250 250 return DistanceTrigger::beaconModeExlcude_s; 251 251 default : … … 264 264 { 265 265 if(mode == DistanceTrigger::beaconModeOff_s) 266 this->setBeaconModeDirect( distanceTriggerBeaconMode::off);266 this->setBeaconModeDirect(DistanceTriggerBeaconMode::off); 267 267 else if(mode == DistanceTrigger::beaconModeIdentify_s) 268 this->setBeaconModeDirect( distanceTriggerBeaconMode::identify);268 this->setBeaconModeDirect(DistanceTriggerBeaconMode::identify); 269 269 else if(mode == DistanceTrigger::beaconModeExlcude_s) 270 this->setBeaconModeDirect( distanceTriggerBeaconMode::exclude);270 this->setBeaconModeDirect(DistanceTriggerBeaconMode::exclude); 271 271 else 272 272 orxout(internal_error, context::triggers) << "Invalid beacon mode in DistanceTrigger." << endl; … … 282 282 Returns true if it is triggered ,false if not. 283 283 */ 284 bool DistanceTrigger::isTriggered(TriggerMode ::Valuemode)284 bool DistanceTrigger::isTriggered(TriggerMode mode) 285 285 { 286 286 if (Trigger::isTriggered(mode)) -
code/trunk/src/modules/objects/triggers/DistanceTrigger.h
r9667 r11071 55 55 @ingroup NormalTrigger 56 56 */ 57 namespace distanceTriggerBeaconMode 58 { 59 enum Value { 60 off, 61 identify, 62 exclude 63 }; 64 } 57 enum class DistanceTriggerBeaconMode { 58 off, 59 identify, 60 exclude 61 }; 65 62 66 63 /** … … 118 115 { return this->distance_; } 119 116 120 void setBeaconModeDirect( distanceTriggerBeaconMode::Value mode); // Set the beacon mode.117 void setBeaconModeDirect(DistanceTriggerBeaconMode mode); // Set the beacon mode. 121 118 /** 122 119 @brief Get the beacon mode. 123 120 @return Returns the mode as an enum. 124 121 */ 125 inline distanceTriggerBeaconMode::Value getBeaconModeDirect(void) const122 inline DistanceTriggerBeaconMode getBeaconModeDirect(void) const 126 123 { return this->beaconMode_; } 127 124 void setBeaconMode(const std::string& mode); // Set the beacon mode. … … 144 141 145 142 protected: 146 virtual bool isTriggered(TriggerMode ::Value mode); // Check whether the DistanceTrigger is triggered.143 virtual bool isTriggered(TriggerMode mode) override; // Check whether the DistanceTrigger is triggered. 147 144 /** 148 145 @brief Notifies interested parties about a change of the DistanceTrigger's target mask. … … 160 157 float distance_; //!< The range of the DistanceTrigger. 161 158 162 distanceTriggerBeaconMode::Value beaconMode_; //!< The beacon mode.159 DistanceTriggerBeaconMode beaconMode_; //!< The beacon mode. 163 160 std::string targetName_; //!< The name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-mode. 164 161 ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons. -
code/trunk/src/modules/objects/triggers/EventMultiTrigger.cc
r9667 r11071 96 96 { 97 97 // If the originator is a MultiTriggerContainer, the event originates from a MultiTrigger and thus the event only triggers the EventMultiTrigger for the originator that caused the MultiTrigger to trigger. 98 if(originator != NULL&& originator->isA(ClassIdentifier<MultiTriggerContainer>::getIdentifier()))98 if(originator != nullptr && originator->isA(ClassIdentifier<MultiTriggerContainer>::getIdentifier())) 99 99 { 100 100 MultiTriggerContainer* container = static_cast<MultiTriggerContainer*>(originator); -
code/trunk/src/modules/objects/triggers/EventTrigger.cc
r9667 r11071 79 79 It should be triggered if it is triggered according just to its sub-triggers and if the last event that came in was an event that changed from not triggered to triggered. 80 80 */ 81 bool EventTrigger::isTriggered(TriggerMode ::Valuemode)81 bool EventTrigger::isTriggered(TriggerMode mode) 82 82 { 83 83 if (Trigger::isTriggered(mode)) -
code/trunk/src/modules/objects/triggers/EventTrigger.h
r9667 r11071 84 84 85 85 protected: 86 virtual bool isTriggered(TriggerMode ::Value mode); // Check whether the EventTrigger should be triggered.86 virtual bool isTriggered(TriggerMode mode) override; // Check whether the EventTrigger should be triggered. 87 87 88 88 private: -
code/trunk/src/modules/objects/triggers/MultiTrigger.cc
r11020 r11071 124 124 // Let the MultiTrigger return the states that trigger and process the new states if there are any. 125 125 std::queue<MultiTriggerState*>* queue = this->letTrigger(); 126 if(queue != NULL)126 if(queue != nullptr) 127 127 { 128 128 while(queue->size() > 0) 129 129 { 130 130 MultiTriggerState* state = queue->front(); 131 // If the state is NULL. (This really shouldn't happen)132 if(state == NULL)131 // If the state is nullptr. (This really shouldn't happen) 132 if(state == nullptr) 133 133 { 134 orxout(internal_error, context::triggers) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was NULL. State ignored." << endl;134 orxout(internal_error, context::triggers) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was nullptr. State ignored." << endl; 135 135 queue->pop(); 136 136 continue; … … 227 227 { 228 228 // If the MultiTrigger is set to broadcast and has no originator a boradcast is fired. 229 if(this->getBroadcast() && state->originator == NULL)229 if(this->getBroadcast() && state->originator == nullptr) 230 230 this->broadcast(bActive); 231 231 // Else a normal event is fired. … … 240 240 { 241 241 // Print some debug output if the state has changed. 242 if(state->originator != NULL)242 if(state->originator != nullptr) 243 243 orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: " << state->originator->getIdentifier()->getName() << " (&" << state->originator << "), active: " << bActive << ", triggered: " << state->bTriggered << "." << endl; 244 244 else 245 orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: NULL, active: " << bActive << ", triggered: " << state->bTriggered << "." << endl;245 orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: nullptr, active: " << bActive << ", triggered: " << state->bTriggered << "." << endl; 246 246 247 247 // If the MultiTrigger has a parent trigger, that is itself a MultiTrigger, it needs to call a method to notify him, that its activity has changed. 248 if(this->parent_ != NULL&& this->parent_->isMultiTrigger())248 if(this->parent_ != nullptr && this->parent_->isMultiTrigger()) 249 249 static_cast<MultiTrigger*>(this->parent_)->childActivityChanged(state->originator); 250 250 } … … 265 265 else 266 266 { 267 this->stateQueue_. push_back(std::pair<float, MultiTriggerState*>(timeRemaining-dt, state));267 this->stateQueue_.emplace_back(timeRemaining-dt, state); 268 268 this->stateQueue_.pop_front(); 269 269 } … … 299 299 300 300 // If the target is not a valid class name display an error. 301 if (target == NULL)301 if (target == nullptr) 302 302 { 303 303 orxout(internal_error, context::triggers) << "'" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << endl; … … 327 327 328 328 // If the target is not a valid class name display an error. 329 if (target == NULL)329 if (target == nullptr) 330 330 { 331 331 orxout(internal_error, context::triggers) << "'" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << endl; … … 346 346 std::queue<MultiTriggerState*>* MultiTrigger::letTrigger(void) 347 347 { 348 return NULL;348 return nullptr; 349 349 } 350 350 … … 443 443 void MultiTrigger::fire(bool status, BaseObject* originator) 444 444 { 445 // If the originator is NULL, a normal event without MultiTriggerContainer is sent.446 if(originator == NULL)445 // If the originator is nullptr, a normal event without MultiTriggerContainer is sent. 446 if(originator == nullptr) 447 447 { 448 448 this->fireEvent(status); … … 479 479 bool MultiTrigger::addState(MultiTriggerState* state) 480 480 { 481 assert(state); // The state really shouldn't be NULL.481 assert(state); // The state really shouldn't be nullptr. 482 482 483 483 // If the originator is no target of this MultiTrigger. … … 489 489 490 490 // Add it ot the state queue with the delay specified for the MultiTrigger. 491 this->stateQueue_. push_back(std::pair<float, MultiTriggerState*>(this->getDelay(), state));491 this->stateQueue_.emplace_back(this->getDelay(), state); 492 492 493 493 return true; … … 504 504 bool MultiTrigger::checkAnd(BaseObject* triggerer) 505 505 { 506 for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it) 507 { 508 TriggerBase* trigger = *it; 506 for(TriggerBase* trigger : this->children_) 507 { 509 508 if(trigger->isMultiTrigger()) 510 509 { … … 531 530 bool MultiTrigger::checkOr(BaseObject* triggerer) 532 531 { 533 for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it) 534 { 535 TriggerBase* trigger = *it; 532 for(TriggerBase* trigger : this->children_) 533 { 536 534 if(trigger->isMultiTrigger()) 537 535 { … … 559 557 { 560 558 bool triggered = false; 561 for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it) 562 { 563 TriggerBase* trigger = *it; 559 for(TriggerBase* trigger : this->children_) 560 { 564 561 if(triggered) 565 562 { -
code/trunk/src/modules/objects/triggers/MultiTrigger.h
r9667 r11071 76 76 - @b simultaneousTriggerers The number of simultaneous triggerers limits the number of objects that are allowed to trigger the MultiTrigger at the same time. Or more precisely, the number of distinct objects the MultiTrigger has <em>triggered</em> states for, at each point in time. The default is <code>-1</code>, which denotes infinity. 77 77 - @b mode The mode describes how the MultiTrigger acts in relation to all the triggers, that are appended to it. There are 3 modes: <em>and</em>, meaning that the MultiTrigger can only be triggered if all the appended triggers are active. <em>or</em>, meaning that the MultiTrigger can only triggered if at least one of the appended triggers is active. And <em>xor</em>, meaning that the MultiTrigger can only be triggered if one and only one appended trigger is active. Note, that I wrote <em>can only be active</em>, that implies, that there is an additional condition to the <em>activity</em> of the MultiTrigger and that is the fulfillment of the triggering condition (the MultiTrigger itself doesn't have one, but all derived classes should). Also bear in mind, that the <em>activity</em> of a MultiTrigger is still coupled to the object that triggered it. The default is <em>and</em>. 78 - @b broadcast Broadcast is a boolean, if true the MutliTrigger is in <em>broadcast-mode</em>, meaning, that all trigger events that are caused by no originator (originator is NULL) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger. The default is false.78 - @b broadcast Broadcast is a boolean, if true the MutliTrigger is in <em>broadcast-mode</em>, meaning, that all trigger events that are caused by no originator (originator is nullptr) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger. The default is false. 79 79 - @b target The target describes the kind of objects that are allowed to trigger this MultiTrigger. The default is @ref orxonox::Pawn "Pawn". 80 80 - Also there is the possibility of appending triggers (as long as they inherit from TriggerBase) to the MultiTrigger just by adding them as children in the XML description of your MultiTrigger. … … 110 110 */ 111 111 inline bool isActive(void) const 112 { return this->isActive( NULL); }113 bool isActive(BaseObject* triggerer = NULL) const; //!< Check whether the MultiTrigger is active for a given object.112 { return this->isActive(nullptr); } 113 bool isActive(BaseObject* triggerer = nullptr) const; //!< Check whether the MultiTrigger is active for a given object. 114 114 115 115 /** … … 145 145 */ 146 146 inline bool isTarget(BaseObject* target) 147 { if(target == NULL) return true; else return targetMask_.isIncluded(target->getIdentifier()); }147 { if(target == nullptr) return true; else return targetMask_.isIncluded(target->getIdentifier()); } 148 148 149 149 void addTarget(const std::string& targets); //!< Add some target to the MultiTrigger. … … 152 152 virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at. 153 153 154 void changeTriggered(BaseObject* originator = NULL); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator.155 156 bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whether the MultiTrigger is triggered concerning it's children.157 bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object.158 159 virtual void fire(bool status, BaseObject* originator = NULL); //!< Helper method. Creates an Event for the given status and originator and fires it.154 void changeTriggered(BaseObject* originator = nullptr); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator. 155 156 bool isModeTriggered(BaseObject* triggerer = nullptr); //!< Checks whether the MultiTrigger is triggered concerning it's children. 157 bool isTriggered(BaseObject* triggerer = nullptr); //!< Get whether the MultiTrigger is triggered for a given object. 158 159 virtual void fire(bool status, BaseObject* originator = nullptr); //!< Helper method. Creates an Event for the given status and originator and fires it. 160 160 void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target. 161 161 … … 192 192 std::set<BaseObject*> triggered_; //!< The set of all objects the MultiTrigger is triggered for. 193 193 194 std::deque< std::pair<float, MultiTriggerState*>> stateQueue_; //!< The queue of states waiting to become active.194 std::deque<std::pair<float, MultiTriggerState*>> stateQueue_; //!< The queue of states waiting to become active. 195 195 196 196 ClassTreeMask targetMask_; //!< The target mask, masking all objects that can trigger this MultiTrigger. -
code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc
r9667 r11071 50 50 The creator. 51 51 */ 52 MultiTriggerContainer::MultiTriggerContainer(Context* context) : BaseObject(context), originator_( NULL), data_(NULL)52 MultiTriggerContainer::MultiTriggerContainer(Context* context) : BaseObject(context), originator_(nullptr), data_(nullptr) 53 53 { 54 54 RegisterObject(MultiTriggerContainer); … … 70 70 71 71 Pawn* pawn = orxonox_cast<Pawn*>(data); 72 if(pawn != NULL)72 if(pawn != nullptr) 73 73 { 74 74 this->setForPlayer(true); -
code/trunk/src/modules/objects/triggers/Trigger.cc
r10624 r11071 37 37 #include "core/CoreIncludes.h" 38 38 #include "core/GameMode.h" 39 #include "core/XMLPort.h"40 39 #include "core/command/ConsoleCommandIncludes.h" 41 40 … … 86 85 { 87 86 88 }89 90 /**91 @brief92 Method for creating a Trigger object through XML.93 */94 void Trigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)95 {96 SUPER(Trigger, XMLPort, xmlelement, mode);97 87 } 98 88 … … 203 193 Returns true if the Trigger should be triggered and false if not. 204 194 */ 205 bool Trigger::isTriggered(TriggerMode ::Valuemode)195 bool Trigger::isTriggered(TriggerMode mode) 206 196 { 207 197 // If the trigger has sub-triggers. … … 234 224 { 235 225 // Iterate over all sub-triggers. 236 for ( std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)237 { 238 if (! (*it)->isActive())226 for (TriggerBase* child : this->children_) 227 { 228 if (!child->isActive()) 239 229 return false; 240 230 } … … 252 242 { 253 243 // Iterate over all sub-triggers. 254 for ( std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)255 { 256 if ( (*it)->isActive())244 for (TriggerBase* child : this->children_) 245 { 246 if (child->isActive()) 257 247 return true; 258 248 } … … 270 260 { 271 261 bool test = false; 272 for ( std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)273 { 274 if (test && (*it)->isActive())262 for (TriggerBase* child : this->children_) 263 { 264 if (test && child->isActive()) 275 265 return false; 276 if ( (*it)->isActive())266 if (child->isActive()) 277 267 test = true; 278 268 } … … 346 336 { 347 337 // Iterate over all Triggers. 348 for ( ObjectList<Trigger>::iterator it = ObjectList<Trigger>::begin(); it != ObjectList<Trigger>::end(); ++it)349 it->setVisible(bVisible);338 for (Trigger* trigger : ObjectList<Trigger>()) 339 trigger->setVisible(bVisible); 350 340 } 351 341 -
code/trunk/src/modules/objects/triggers/Trigger.h
r9667 r11071 83 83 virtual ~Trigger(); 84 84 85 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); // Method for creating a Trigger object through XML.86 85 virtual void tick(float dt); 87 86 … … 105 104 inline bool isTriggered() 106 105 { return this->isTriggered(this->mode_); } 107 virtual bool isTriggered(TriggerMode ::Valuemode); // Check whether the Trigger should be triggered, given only its sub-triggers, given a specific mode.106 virtual bool isTriggered(TriggerMode mode); // Check whether the Trigger should be triggered, given only its sub-triggers, given a specific mode. 108 107 virtual void triggered(bool bIsTriggered); // Fires an event with the input triggered state. 109 108 … … 127 126 BillboardSet debugBillboard_; //!< A set of debug billboards to visualize the state of the trigger. 128 127 129 std::queue<std::pair<float, char> 128 std::queue<std::pair<float, char>> stateChanges_; //!< A queue of state changes (in the same format as latestState_) paired with the time they will take effect since the last state change took effect. 130 129 }; 131 130 -
code/trunk/src/modules/objects/triggers/TriggerBase.cc
r9667 r11071 67 67 this->mode_ = TriggerMode::EventTriggerAND; 68 68 69 this->parent_ = NULL;69 this->parent_ = nullptr; 70 70 71 71 this->bMultiTrigger_ = false; … … 100 100 101 101 XMLPortObject(TriggerBase, TriggerBase, "", addTrigger, getTrigger, xmlelement, mode); 102 }103 104 /**105 @brief106 A method that is executed each tick.107 @param dt108 The duration of the last tick.109 */110 void TriggerBase::tick(float dt)111 {112 SUPER(TriggerBase, tick, dt);113 102 } 114 103 … … 170 159 The index. 171 160 @return 172 Returns a pointer ot the trigger. NULLif no such trigger exists.161 Returns a pointer ot the trigger. nullptr if no such trigger exists. 173 162 */ 174 163 const TriggerBase* TriggerBase::getTrigger(unsigned int index) const … … 176 165 // If the index is greater than the number of children. 177 166 if (this->children_.size() <= index) 178 return NULL;167 return nullptr; 179 168 180 169 std::set<TriggerBase*>::const_iterator it; -
code/trunk/src/modules/objects/triggers/TriggerBase.h
r9667 r11071 52 52 @ingroup Triggers 53 53 */ 54 namespaceTriggerMode54 enum class TriggerMode 55 55 { 56 enum Value 57 { 58 EventTriggerAND, //!< The <em>and</em> mode. The trigger can only trigger if all the children are active. 59 EventTriggerOR, //!< The <em>or</em> mode. The trigger can only trigger if at least one child is active. 60 EventTriggerXOR, //!< The <em>xor</em> mode. The trigger can only trigger if exactly one child is active. 61 }; 62 } 56 EventTriggerAND, //!< The <em>and</em> mode. The trigger can only trigger if all the children are active. 57 EventTriggerOR, //!< The <em>or</em> mode. The trigger can only trigger if at least one child is active. 58 EventTriggerXOR, //!< The <em>xor</em> mode. The trigger can only trigger if exactly one child is active. 59 }; 63 60 64 61 /** … … 78 75 79 76 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a TriggerBase object through XML. 80 virtual void tick(float dt); //!< A method that is executed each tick.81 77 82 78 /** … … 158 154 @param mode The mode of the trigger. 159 155 */ 160 inline void setMode(TriggerMode ::Valuemode) //!< Get the mode of the trigger.156 inline void setMode(TriggerMode mode) //!< Get the mode of the trigger. 161 157 { this->mode_ = mode; } 162 158 const std::string& getModeString(void) const; … … 165 161 @return Returns and Enum for the mode of the trigger. 166 162 */ 167 inline TriggerMode ::ValuegetMode(void) const163 inline TriggerMode getMode(void) const 168 164 { return mode_; } 169 165 … … 211 207 212 208 bool bInvertMode_; //!< Bool for the invert-mode, if true the trigger is inverted. 213 TriggerMode ::Valuemode_; //!< The mode of the trigger.209 TriggerMode mode_; //!< The mode of the trigger. 214 210 215 211 TriggerBase* parent_; //!< The parent of this trigger.
Note: See TracChangeset
for help on using the changeset viewer.