Changeset 11071 for code/trunk/src/orxonox
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 209 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/CameraManager.cc
r10624 r11071 60 60 return this->cameraList_.front(); 61 61 else 62 return 0;62 return nullptr; 63 63 } 64 64 … … 93 93 this->cameraList_.front()->setFocus(); 94 94 else 95 this->useCamera( NULL);95 this->useCamera(nullptr); 96 96 } 97 97 else -
code/trunk/src/orxonox/CameraManager.h
r9667 r11071 59 59 60 60 private: 61 CameraManager(const CameraManager&); // don't use 61 // non-copyable: 62 CameraManager(const CameraManager&) = delete; 63 CameraManager& operator=(const CameraManager&) = delete; 62 64 63 65 std::list<Camera*> cameraList_; -
code/trunk/src/orxonox/Level.cc
r10624 r11071 30 30 31 31 #include "util/Math.h" 32 #include "util/SubString.h" 32 33 #include "core/CoreIncludes.h" 33 34 #include "core/Loader.h" … … 54 55 this->registerVariables(); 55 56 this->xmlfilename_ = this->getFilename(); 56 this->xmlfile_ = 0;57 this->xmlfile_ = nullptr; 57 58 } 58 59 … … 105 106 void Level::networkCallbackTemplatesChanged() 106 107 { 107 for( std::set<std::string>::iterator it = this->networkTemplateNames_.begin(); it!=this->networkTemplateNames_.end(); ++it)108 { 109 assert(Template::getTemplate( *it));110 Template::getTemplate( *it)->applyOn(this);108 for(const std::string& name : this->networkTemplateNames_) 109 { 110 assert(Template::getTemplate(name)); 111 Template::getTemplate(name)->applyOn(this); 111 112 } 112 113 } … … 134 135 // objects alive when ~Level is called. This is the reason why we cannot directly destroy() the Plugins - instead we need 135 136 // to call destroyLater() to ensure that no instances from this plugin exist anymore. 136 for ( std::list<PluginReference*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)137 (*it)->destroyLater();137 for (PluginReference* plugin : this->plugins_) 138 plugin->destroyLater(); 138 139 this->plugins_.clear(); 139 140 } … … 172 173 { 173 174 unsigned int i = 0; 174 for ( std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)175 for (BaseObject* object : this->objects_) 175 176 { 176 177 if (i == index) 177 return (*it);178 return object; 178 179 ++i; 179 180 } 180 return 0;181 return nullptr; 181 182 } 182 183 … … 195 196 return this->lodInformation_.find(meshName)->second; 196 197 197 return 0;198 return nullptr; 198 199 } 199 200 … … 207 208 { 208 209 orxout(internal_info) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl; 209 player->switchGametype( 0);210 player->switchGametype(nullptr); 210 211 } 211 212 } -
code/trunk/src/orxonox/Level.h
r10624 r11071 37 37 #include "core/BaseObject.h" 38 38 #include "network/synchronisable/Synchronisable.h" 39 #include "core/object/Context.h" 39 40 #include "graphics/MeshLodInformation.h" 40 41 … … 47 48 virtual ~Level(); 48 49 49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 50 51 51 52 void playerEntered(PlayerInfo* player); -
code/trunk/src/orxonox/LevelInfo.cc
r9667 r11071 106 106 { 107 107 SubString substr = SubString(tags, ",", " "); // Split the string into tags. 108 const std::vector<std::string>& strings = substr.getAllStrings();109 for ( std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)110 this->addTag( *it, false);108 const std::vector<std::string>& tokens = substr.getAllStrings(); 109 for (const std::string& token : tokens) 110 this->addTag(token, false); 111 111 112 112 this->tagsUpdated(); … … 121 121 { 122 122 SubString substr = SubString(ships, ",", " "); // Split the string into tags. 123 const std::vector<std::string>& strings = substr.getAllStrings();124 for( std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)125 this->addStartingShip( *it, false);123 const std::vector<std::string>& tokens = substr.getAllStrings(); 124 for(const std::string& token : tokens) 125 this->addStartingShip(token, false); 126 126 127 127 this->startingshipsUpdated(); -
code/trunk/src/orxonox/LevelInfo.h
r9667 r11071 207 207 virtual ~LevelInfo(); 208 208 209 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Creates a LevelInfo object through XML.209 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Creates a LevelInfo object through XML. 210 210 211 211 /** -
code/trunk/src/orxonox/LevelManager.cc
r11020 r11071 78 78 { 79 79 // Delete all the LevelInfoItem objects because the LevelManager created them 80 std::set<LevelInfoItem*, LevelInfoCompare>::iterator it = availableLevels_.begin(); 81 for (; it != availableLevels_.end(); ++it) 82 (*it)->destroy(); 80 for (LevelInfoItem* info : availableLevels_) 81 info->destroy(); 83 82 } 84 83 … … 154 153 Get the currently active Level. 155 154 @return 156 Returns a pointer to the currently active level or NULLif there currently are no active Levels.155 Returns a pointer to the currently active level or nullptr if there currently are no active Levels. 157 156 */ 158 157 Level* LevelManager::getActiveLevel() … … 161 160 return this->levels_.front(); 162 161 else 163 return 0;162 return nullptr; 164 163 } 165 164 … … 175 174 this->levels_.front()->setActive(true); 176 175 // Make every player enter the newly activated level. 177 for ( std::map<unsigned int, PlayerInfo*>::const_iterator it = PlayerManager::getInstance().getClients().begin(); it != PlayerManager::getInstance().getClients().end(); ++it)178 this->levels_.front()->playerEntered( it->second);176 for (const auto& mapEntry : PlayerManager::getInstance().getClients()) 177 this->levels_.front()->playerEntered(mapEntry.second); 179 178 } 180 179 } … … 218 217 { 219 218 if(index >= this->availableLevels_.size()) 220 return NULL;219 return nullptr; 221 220 222 221 // If this index directly follows the last we can optimize a lot. … … 272 271 if (it->find("old/") != 0) 273 272 { 274 LevelInfoItem* info = NULL;273 LevelInfoItem* info = nullptr; 275 274 276 275 // Load the LevelInfo object from the level file. … … 279 278 280 279 // Find the LevelInfo object we've just loaded (if there was one) 281 for( ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item)282 if( item->getXMLFilename() == *it)283 info = item->copy();280 for(LevelInfo* levelInfo : ObjectList<LevelInfo>()) 281 if(levelInfo->getXMLFilename() == *it) 282 info = levelInfo->copy(); 284 283 285 284 // We don't need the loaded stuff anymore 286 285 Loader::getInstance().unload(&file); 287 286 288 if(info == NULL)287 if(info == nullptr) 289 288 { 290 289 // Create a default LevelInfoItem object that merely contains the name -
code/trunk/src/orxonox/LevelManager.h
r10258 r11071 109 109 110 110 private: 111 LevelManager(const LevelManager&); 111 // non-copyable: 112 LevelManager(const LevelManager&) = delete; 113 LevelManager& operator=(const LevelManager&) = delete; 112 114 113 115 void activateNextLevel(); //!< Activate the next level. -
code/trunk/src/orxonox/Main.h
r5693 r11071 33 33 #include "OrxonoxPrereqs.h" 34 34 35 #include <string> 36 35 37 namespace orxonox 36 38 { -
code/trunk/src/orxonox/MoodManager.cc
r10624 r11071 103 103 /*static*/ void MoodListener::changedMood(const std::string& mood) 104 104 { 105 for ( ObjectList<MoodListener>::iterator it = ObjectList<MoodListener>::begin(); it; ++it)106 it->moodChanged(mood);105 for (MoodListener* listener : ObjectList<MoodListener>()) 106 listener->moodChanged(mood); 107 107 } 108 108 } -
code/trunk/src/orxonox/PlayerManager.cc
r10624 r11071 62 62 63 63 // create new HumanPlayer instance 64 HumanPlayer* player = new HumanPlayer( 0);64 HumanPlayer* player = new HumanPlayer(nullptr); 65 65 player->setClientID(clientID); 66 66 … … 111 111 else 112 112 { 113 for ( ObjectList<PlayerInfo>::iterator it = ObjectList<PlayerInfo>::begin(); it != ObjectList<PlayerInfo>::end(); ++it)114 if (i t->getClientID() == clientID)115 return (*it);113 for (PlayerInfo* info : ObjectList<PlayerInfo>()) 114 if (info->getClientID() == clientID) 115 return info; 116 116 } 117 return 0;117 return nullptr; 118 118 } 119 119 } -
code/trunk/src/orxonox/PlayerManager.h
r5966 r11071 50 50 { return this->clients_; } 51 51 52 v oid clientConnected(unsigned int clientID);53 v oid clientDisconnected(unsigned int clientID);52 virtual void clientConnected(unsigned int clientID) override; 53 virtual void clientDisconnected(unsigned int clientID) override; 54 54 void disconnectAllClients(); 55 55 -
code/trunk/src/orxonox/Radar.cc
r10624 r11071 49 49 50 50 Radar::Radar() 51 : itFocus_( 0)52 , focus_( 0)51 : itFocus_(nullptr) 52 , focus_(nullptr) 53 53 , objectTypeCounter_(0) 54 54 { 55 55 // TODO: make this mapping configurable. Maybe there's a possibility with self configured 56 56 // configValues.. 57 this->objectTypes_["Asteroid"] = RadarViewable:: Dot;58 this->objectTypes_["SpaceShip"] = RadarViewable::S quare;59 this->objectTypes_["AsdfQwerty"] = RadarViewable:: Triangle;57 this->objectTypes_["Asteroid"] = RadarViewable::Shape::Dot; 58 this->objectTypes_["SpaceShip"] = RadarViewable::Shape::Square; 59 this->objectTypes_["AsdfQwerty"] = RadarViewable::Shape::Triangle; 60 60 61 61 /*WorldEntity* object; … … 84 84 this->radarObjects_.insert(rv); 85 85 // iterate through all radarlisteners and notify them 86 for ( ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)87 { 88 (*itListener)->addObject(rv);86 for (RadarListener* listener : ObjectList<RadarListener>()) 87 { 88 listener->addObject(rv); 89 89 } 90 90 } … … 95 95 this->radarObjects_.erase(rv); 96 96 // iterate through all radarlisteners and notify them 97 for ( ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)98 { 99 (*itListener)->removeObject(rv);97 for (RadarListener* listener : ObjectList<RadarListener>()) 98 { 99 listener->removeObject(rv); 100 100 } 101 101 } … … 106 106 return *(this->itFocus_); 107 107 else 108 return 0;108 return nullptr; 109 109 } 110 110 … … 113 113 std::map<std::string, RadarViewable::Shape>::iterator it = this->objectTypes_.find(name); 114 114 if (it == this->objectTypes_.end()) 115 return this->objectTypes_[name] = RadarViewable::S quare; // default, configure!!115 return this->objectTypes_[name] = RadarViewable::Shape::Square; // default, configure!! 116 116 else 117 117 return this->objectTypes_[name]; … … 126 126 { 127 127 // focus object was deleted, release focus 128 this->focus_ = 0;129 this->itFocus_ = 0;130 } 131 132 for ( ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)133 { 134 (*itListener)->radarTick(dt);128 this->focus_ = nullptr; 129 this->itFocus_ = nullptr; 130 } 131 132 for (RadarListener* listener : ObjectList<RadarListener>()) 133 { 134 listener->radarTick(dt); 135 135 } 136 136 } … … 138 138 void Radar::cycleFocus() 139 139 { 140 if (ObjectList<RadarViewable>::begin() == ObjectList<RadarViewable>::end()) 140 ObjectList<RadarViewable> listRadarViewable; 141 if (listRadarViewable.size() == 0) 141 142 { 142 143 // list is empty 143 this->itFocus_ = 0;144 this->focus_ = 0;144 this->itFocus_ = nullptr; 145 this->focus_ = nullptr; 145 146 } 146 147 … … 156 157 float nextDistance = FLT_MAX; 157 158 float minimumDistance = FLT_MAX; 158 ObjectList<RadarViewable>::iterator itFallback = 0;159 160 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)159 ObjectList<RadarViewable>::iterator itFallback = nullptr; 160 161 for (ObjectList<RadarViewable>::iterator it = listRadarViewable.begin(); it; ++it) 161 162 { 162 163 if (*it == static_cast<RadarViewable*>(HumanController::getLocalControllerEntityAsPawn())) … … 191 192 void Radar::releaseFocus() 192 193 { 193 this->itFocus_ = 0;194 this->focus_ = 0;194 this->itFocus_ = nullptr; 195 this->focus_ = nullptr; 195 196 } 196 197 … … 200 201 // iterate through all Radar Objects 201 202 unsigned int i = 0; 202 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i) 203 { 204 orxout(debug_output) << i++ << ": " << (*it)->getRVWorldPosition() << endl; 203 for (RadarViewable* viewable : ObjectList<RadarViewable>()) 204 { 205 orxout(debug_output) << i++ << ": " << viewable->getRVWorldPosition() << endl; 206 ++i; 205 207 } 206 208 } … … 208 210 void Radar::radarObjectChanged(RadarViewable* rv) 209 211 { 210 for ( ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)211 { 212 (*itListener)->objectChanged(rv);212 for (RadarListener* listener : ObjectList<RadarListener>()) 213 { 214 listener->objectChanged(rv); 213 215 } 214 216 } -
code/trunk/src/orxonox/Radar.h
r9667 r11071 54 54 virtual ~Radar(); 55 55 56 virtual void tick(float dt) ;56 virtual void tick(float dt) override; 57 57 58 58 const RadarViewable* getFocus(); -
code/trunk/src/orxonox/Scene.cc
r10727 r11071 66 66 this->bShadows_ = true; 67 67 this->bDebugDrawPhysics_ = false; 68 this->debugDrawer_ = NULL;68 this->debugDrawer_ = nullptr; 69 69 this->soundReferenceDistance_ = 20.0; 70 70 this->bIsUpdatingPhysics_ = false; … … 84 84 this->rootSceneNode_ = this->sceneManager_->getRootSceneNode(); 85 85 86 this->radar_ = 0;86 this->radar_ = nullptr; 87 87 } 88 88 … … 92 92 this->positiveWorldRange_ = Vector3::UNIT_SCALE * defaultMaxWorldSize; 93 93 this->gravity_ = Vector3::ZERO; 94 this->physicalWorld_ = 0;95 this->solver_ = 0;96 this->dispatcher_ = 0;97 this->collisionConfig_ = 0;98 this->broadphase_ = 0;94 this->physicalWorld_ = nullptr; 95 this->solver_ = nullptr; 96 this->dispatcher_ = nullptr; 97 this->collisionConfig_ = nullptr; 98 this->broadphase_ = nullptr; 99 99 100 100 this->registerVariables(); … … 220 220 { 221 221 // Remove all WorldEntities and shove them to the queue since they would still like to be in a physical world. 222 for (std::set<WorldEntity*>::const_iterator it = this->physicalObjects_.begin(); 223 it != this->physicalObjects_.end(); ++it) 222 for (WorldEntity* object : this->physicalObjects_) 224 223 { 225 this->physicalWorld_->removeRigidBody( (*it)->physicalBody_);226 this->physicalObjectQueue_.insert( *it);224 this->physicalWorld_->removeRigidBody(object->physicalBody_); 225 this->physicalObjectQueue_.insert(object); 227 226 } 228 227 this->physicalObjects_.clear(); … … 234 233 delete this->collisionConfig_; 235 234 delete this->broadphase_; 236 this->physicalWorld_ = 0;237 this->solver_ = 0;238 this->dispatcher_ = 0;239 this->collisionConfig_ = 0;240 this->broadphase_ = 0;235 this->physicalWorld_ = nullptr; 236 this->solver_ = nullptr; 237 this->dispatcher_ = nullptr; 238 this->collisionConfig_ = nullptr; 239 this->broadphase_ = nullptr; 241 240 } 242 241 } … … 256 255 { 257 256 // Add all scheduled WorldEntities 258 for (std::set<WorldEntity*>::const_iterator it = this->physicalObjectQueue_.begin(); 259 it != this->physicalObjectQueue_.end(); ++it) 257 for (WorldEntity* object : this->physicalObjectQueue_) 260 258 { 261 this->physicalWorld_->addRigidBody( (*it)->physicalBody_);262 this->physicalObjects_.insert( *it);259 this->physicalWorld_->addRigidBody(object->physicalBody_); 260 this->physicalObjects_.insert(object); 263 261 } 264 262 this->physicalObjectQueue_.clear(); … … 321 319 { 322 320 unsigned int i = 0; 323 for ( std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)321 for (BaseObject* object : this->objects_) 324 322 { 325 323 if (i == index) 326 return (*it);324 return object; 327 325 ++i; 328 326 } 329 return 0;327 return nullptr; 330 328 } 331 329 … … 391 389 /*static*/ void Scene::consoleCommand_debugDrawPhysics(bool bDraw, bool bFill, float fillAlpha) 392 390 { 393 for ( ObjectListIterator<Scene> it = ObjectList<Scene>::begin(); it != ObjectList<Scene>::end(); ++it)394 it->setDebugDrawPhysics(bDraw, bFill, fillAlpha);391 for (Scene* scene : ObjectList<Scene>()) 392 scene->setDebugDrawPhysics(bDraw, bFill, fillAlpha); 395 393 } 396 394 } -
code/trunk/src/orxonox/Scene.h
r10624 r11071 40 40 #include "util/OgreForwardRefs.h" 41 41 #include "core/BaseObject.h" 42 #include "core/object/Context.h" 42 43 #include "network/synchronisable/Synchronisable.h" 43 44 #include "tools/interfaces/Tickable.h" … … 51 52 virtual ~Scene(); 52 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 54 55 void registerVariables(); 55 56 … … 79 80 { return this->radar_; } 80 81 81 inline virtual uint32_t getSceneID() const{ return this->getObjectID(); }82 virtual inline uint32_t getSceneID() const override { return this->getObjectID(); } 82 83 83 virtual void tick(float dt) ;84 virtual void tick(float dt) override; 84 85 85 86 private: … … 111 112 public: 112 113 inline bool hasPhysics() const 113 { return this->physicalWorld_ != 0; }114 { return this->physicalWorld_ != nullptr; } 114 115 void setPhysicalWorld(bool wantsPhysics); 115 116 -
code/trunk/src/orxonox/Test.cc
r10624 r11071 54 54 registerMemberNetworkFunction( Test, printBlaBla ); 55 55 56 Test* Test::instance_ = 0;56 Test* Test::instance_ = nullptr; 57 57 58 58 Test::Test(Context* context) : BaseObject(context), Synchronisable(context) 59 59 { 60 assert(instance_== 0);60 assert(instance_==nullptr); 61 61 instance_=this; 62 62 RegisterObject ( Test ); … … 64 64 registerVariables(); 65 65 setSyncMode(0x3); 66 this->pointer_ = 0;66 this->pointer_ = nullptr; 67 67 } 68 68 69 69 Test::~Test() 70 70 { 71 instance_= 0;71 instance_=nullptr; 72 72 } 73 73 -
code/trunk/src/orxonox/chat/ChatHistory.cc
r10624 r11071 30 30 #include "core/singleton/ScopedSingletonIncludes.h" 31 31 #include "core/ConfigurablePaths.h" 32 #include "core/CoreIncludes.h" 32 33 33 34 #ifndef CHATTEST … … 159 160 void ChatHistory::debug_printhist() 160 161 { 161 /* create deque iterator */162 std::deque<std::string>::iterator it;163 164 162 /* output all the strings */ 165 for( it = this->hist_buffer.begin(); it != this->hist_buffer.end(); 166 ++it ) 167 orxout(debug_output) << *it << endl; 163 for( const std::string& hist : this->hist_buffer ) 164 orxout(debug_output) << hist << endl; 168 165 169 166 /* output size */ -
code/trunk/src/orxonox/chat/ChatHistory.h
r10624 r11071 82 82 * \param senderID Identification number of the sender 83 83 */ 84 virtual void incomingChat(const std::string& message, const std::string& name) ;84 virtual void incomingChat(const std::string& message, const std::string& name) override; 85 85 86 86 /** Synchronize logfile onto the hard drive -
code/trunk/src/orxonox/chat/ChatInputHandler.cc
r10624 r11071 79 79 this->inpbuf = new InputBuffer(); 80 80 this->disp_offset = 0; 81 assert( this->inpbuf != NULL);81 assert( this->inpbuf != nullptr ); 82 82 83 83 /* generate chatbox ui and chatbox-inputonly ui */ -
code/trunk/src/orxonox/chat/ChatInputHandler.h
r9675 r11071 125 125 * history window of the full chat window) 126 126 */ 127 v oid incomingChat(const std::string& message, const std::string& name);127 virtual void incomingChat(const std::string& message, const std::string& name) override; 128 128 129 129 /** \param full true means show full chat window with history, -
code/trunk/src/orxonox/chat/ChatManager.cc
r10624 r11071 107 107 108 108 // notify all listeners 109 for ( ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)110 it->incomingChat(text, name);109 for (ChatListener* listener : ObjectList<ChatListener>()) 110 listener->incomingChat(text, name); 111 111 } 112 112 -
code/trunk/src/orxonox/chat/ChatManager.h
r8858 r11071 47 47 public: 48 48 ChatManager(); 49 virtual ~ChatManager() {}49 virtual ~ChatManager() = default; 50 50 51 51 static void message(const std::string& message, unsigned int targetID = NETWORK_PEER_ID_BROADCAST); … … 53 53 54 54 protected: 55 ChatManager(const ChatManager&); 55 // non-copyable: 56 ChatManager(const ChatManager&) = delete; 57 ChatManager& operator=(const ChatManager&) = delete; 56 58 57 virtual void incomingChat(const std::string& message, unsigned int sourceID) ;59 virtual void incomingChat(const std::string& message, unsigned int sourceID) override; 58 60 59 61 static ChatManager* singletonPtr_s; -
code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
r10624 r11071 57 57 RegisterObject(CollisionShape); 58 58 59 this->parent_ = 0;59 this->parent_ = nullptr; 60 60 this->parentID_ = OBJECTID_UNKNOWN; 61 this->collisionShape_ = 0;61 this->collisionShape_ = nullptr; 62 62 this->position_ = Vector3::ZERO; 63 63 this->orientation_ = Quaternion::IDENTITY; … … 154 154 void CollisionShape::notifyDetached() 155 155 { 156 this->parent_ = 0;156 this->parent_ = nullptr; 157 157 this->parentID_ = OBJECTID_UNKNOWN; 158 158 } -
code/trunk/src/orxonox/collisionshapes/CollisionShape.h
r9667 r11071 61 61 virtual ~CollisionShape(); 62 62 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 64 64 65 65 /** … … 181 181 182 182 btCollisionShape* collisionShape_; //!< The bullet collision shape of this CollisionShape. 183 CompoundCollisionShape* parent_; //!< The CompoundCollisionShape this CollisionShape belongs to, NULLif it doesn't belong to one.183 CompoundCollisionShape* parent_; //!< The CompoundCollisionShape this CollisionShape belongs to, nullptr if it doesn't belong to one. 184 184 unsigned int parentID_; //!< The objectID of the parent of this CollisionShape, which can either be a CompoundCollisionShape or a WorldEntity. 185 185 -
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
r10624 r11071 65 65 { 66 66 // Delete all children 67 for (std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); 68 it != this->attachedShapes_.end(); ++it) 67 for (const auto& mapEntry : this->attachedShapes_) 69 68 { 70 69 // make sure that the child doesn't want to detach itself --> speedup because of the missing update 71 it->first->notifyDetached();72 it->first->destroy();73 if (this->collisionShape_ == it->second)74 this->collisionShape_ = NULL; // don't destroy it twice70 mapEntry.first->notifyDetached(); 71 mapEntry.first->destroy(); 72 if (this->collisionShape_ == mapEntry.second) 73 this->collisionShape_ = nullptr; // don't destroy it twice 75 74 } 76 75 77 76 delete this->compoundShape_; 78 77 if (this->collisionShape_ == this->compoundShape_) 79 this->collisionShape_ = NULL; // don't destroy it twice78 this->collisionShape_ = nullptr; // don't destroy it twice 80 79 } 81 80 } … … 96 95 void CompoundCollisionShape::attach(CollisionShape* shape) 97 96 { 98 // If either the input shape is NULLor we try to attach the CollisionShape to itself.97 // If either the input shape is nullptr or we try to attach the CollisionShape to itself. 99 98 if (!shape || static_cast<CollisionShape*>(this) == shape) 100 99 return; … … 197 196 void CompoundCollisionShape::updatePublicShape() 198 197 { 199 btCollisionShape* primitive = 0; // The primitive shape, if there is one.198 btCollisionShape* primitive = nullptr; // The primitive shape, if there is one. 200 199 bool bPrimitive = true; // Whether the CompoundCollisionShape has just one non-empty CollisionShape. And that shape also has no transformation. 201 200 bool bEmpty = true; // Whether the CompoundCollisionShape is empty. 202 201 // Iterate over all CollisionShapes that belong to this CompoundCollisionShape. 203 for ( std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)202 for (const auto& mapEntry : this->attachedShapes_) 204 203 { 205 204 // TODO: Make sure this is correct. 206 if ( it->second)205 if (mapEntry.second) 207 206 { 208 207 bEmpty = false; 209 if (! it->first->hasTransform() && bPrimitive)210 primitive = it->second;208 if (!mapEntry.first->hasTransform() && bPrimitive) 209 primitive = mapEntry.second; 211 210 else 212 211 { … … 221 220 { 222 221 // If there was none all along, nothing needs to be changed. 223 if (this->collisionShape_ == 0)222 if (this->collisionShape_ == nullptr) 224 223 return; 225 this->collisionShape_ = 0;224 this->collisionShape_ = nullptr; 226 225 } 227 226 // If the CompoundCollisionShape is just a primitive. … … 247 246 { 248 247 unsigned int i = 0; 249 for ( std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)248 for (const auto& mapEntry : this->attachedShapes_) 250 249 { 251 250 if (i == index) 252 return it->first;251 return mapEntry.first; 253 252 ++i; 254 253 } 255 return 0;254 return nullptr; 256 255 } 257 256 … … 267 266 std::vector<CollisionShape*> shapes; 268 267 // Iterate through all attached CollisionShapes and add them to the list of shapes. 269 for( std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)270 shapes.push_back( it->first);268 for(const auto& mapEntry : this->attachedShapes_) 269 shapes.push_back(mapEntry.first); 271 270 272 271 // Delete the compound shape and create a new one. … … 275 274 276 275 // Re-attach all CollisionShapes. 277 for(std::vector<CollisionShape*>::iterator it = shapes.begin(); it != shapes.end(); it++) 278 { 279 CollisionShape* shape = *it; 276 for(CollisionShape* shape : shapes) 277 { 280 278 shape->setScale3D(this->getScale3D()); 281 279 // Only actually attach if we didn't pick a CompoundCollisionShape with no content. -
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.h
r9667 r11071 61 61 virtual ~CompoundCollisionShape(); 62 62 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 64 64 65 65 void attach(CollisionShape* shape); … … 70 70 void updateAttachedShape(CollisionShape* shape); 71 71 72 virtual void changedScale() ;72 virtual void changedScale() override; 73 73 74 74 private: 75 75 void updatePublicShape(); 76 inline virtual btCollisionShape* createNewShape() const77 { assert(false); return 0; }76 virtual inline btCollisionShape* createNewShape() const override 77 { assert(false); return nullptr; } 78 78 79 79 btCompoundShape* compoundShape_; -
code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
r10624 r11071 43 43 RegisterObject(WorldEntityCollisionShape); 44 44 45 this->worldEntityOwner_ = NULL;45 this->worldEntityOwner_ = nullptr; 46 46 // suppress synchronisation 47 47 this->setSyncMode(ObjectDirection::None); … … 54 54 CollisionShape::updateParent(); 55 55 56 assert(this->worldEntityOwner_ != 0);56 assert(this->worldEntityOwner_ != nullptr); 57 57 this->worldEntityOwner_->notifyCollisionShapeChanged(); 58 58 } -
code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h
r10624 r11071 46 46 47 47 protected: 48 virtual void updateParent() ;48 virtual void updateParent() override; 49 49 50 50 private: 51 v oid parentChanged();51 virtual void parentChanged() override; 52 52 53 53 WorldEntity* worldEntityOwner_; -
code/trunk/src/orxonox/controllers/AIController.cc
r9667 r11071 249 249 } 250 250 else 251 this->setPreviousMode();//If bot dies -> getControllableEntity == NULL-> get out of ROCKET mode251 this->setPreviousMode();//If bot dies -> getControllableEntity == nullptr -> get out of ROCKET mode 252 252 }//END_OF ROCKET MODE 253 253 -
code/trunk/src/orxonox/controllers/AIController.h
r9667 r11071 44 44 virtual ~AIController(); 45 45 46 virtual void tick(float dt) ; //<! Carrying out the targets set in action().46 virtual void tick(float dt) override; //<! Carrying out the targets set in action(). 47 47 48 48 protected: -
code/trunk/src/orxonox/controllers/ActionpointController.cc
r11052 r11071 339 339 inLoop = this->bInLoop_; 340 340 341 Action ::Valuevalue;341 Action value; 342 342 343 343 if ( actionName == "FIGHT" ) … … 371 371 return this->actionpoints_[index]; 372 372 else 373 return 0;373 return nullptr; 374 374 } 375 375 //XML method 376 Action ::ValueActionpointController::getAction ()376 Action ActionpointController::getAction () 377 377 { 378 378 return this->action_; … … 401 401 } 402 402 //XML method 403 void ActionpointController::setAction (Action ::Valueaction)403 void ActionpointController::setAction (Action action) 404 404 { 405 405 this->action_ = action; 406 406 } 407 407 //set action and target/protect 408 void ActionpointController::setAction (Action ::Valueaction, ControllableEntity* target)408 void ActionpointController::setAction (Action action, ControllableEntity* target) 409 409 { 410 410 if (!this || !this->getControllableEntity()) … … 423 423 } 424 424 //set action and target position 425 void ActionpointController::setAction (Action ::Valueaction, const Vector3& target)425 void ActionpointController::setAction (Action action, const Vector3& target) 426 426 { 427 427 if (!this || !this->getControllableEntity()) … … 434 434 } 435 435 //set action and target position and orientation 436 void ActionpointController::setAction (Action ::Valueaction, const Vector3& target, const Quaternion& orient )436 void ActionpointController::setAction (Action action, const Vector3& target, const Quaternion& orient ) 437 437 { 438 438 if (!this || !this->getControllableEntity()) … … 476 476 return; 477 477 478 this->setTarget( 0);478 this->setTarget(nullptr); 479 479 this->setTargetPosition(this->getControllableEntity()->getWorldPosition()); 480 480 this->action_ = Action::NONE; … … 506 506 if (targetName == "") 507 507 break; 508 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)509 { 510 if (!this || !this->getControllableEntity()) 511 return; 512 if (CommonController::getName( *itP) == targetName)508 for (Pawn* pawn : ObjectList<Pawn>()) 509 { 510 if (!this || !this->getControllableEntity()) 511 return; 512 if (CommonController::getName(pawn) == targetName) 513 513 { 514 this->setTarget (static_cast<ControllableEntity*>( *itP));514 this->setTarget (static_cast<ControllableEntity*>(pawn)); 515 515 } 516 516 } … … 541 541 if (protectName == "reservedKeyword:human") 542 542 { 543 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)543 for (Pawn* pawn : ObjectList<Pawn>()) 544 544 { 545 if (orxonox_cast<ControllableEntity*>( *itP) && ((*itP)->getController()) && ((*itP)->getController()->getIdentifier()->getName() == "NewHumanController"))545 if (orxonox_cast<ControllableEntity*>(pawn) && (pawn->getController()) && (pawn->getController()->getIdentifier()->getName() == "NewHumanController")) 546 546 { 547 this->setProtect (static_cast<ControllableEntity*>( *itP));547 this->setProtect (static_cast<ControllableEntity*>(pawn)); 548 548 } 549 549 } … … 551 551 else 552 552 { 553 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)553 for (Pawn* pawn : ObjectList<Pawn>()) 554 554 { 555 if (CommonController::getName( *itP) == protectName)555 if (CommonController::getName(pawn) == protectName) 556 556 { 557 this->setProtect (static_cast<ControllableEntity*>( *itP));557 this->setProtect (static_cast<ControllableEntity*>(pawn)); 558 558 } 559 559 } … … 578 578 std::string targetName = p.name; 579 579 580 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)581 { 582 if (CommonController::getName( *itP) == targetName)580 for (Pawn* pawn : ObjectList<Pawn>()) 581 { 582 if (CommonController::getName(pawn) == targetName) 583 583 { 584 584 if (!this || !this->getControllableEntity()) 585 585 return; 586 this->setTarget (static_cast<ControllableEntity*>( *itP));586 this->setTarget (static_cast<ControllableEntity*>(pawn)); 587 587 } 588 588 } … … 702 702 { 703 703 if (!this || !this->getControllableEntity()) 704 return 0;705 706 Pawn* closestTarget = 0;704 return nullptr; 705 706 Pawn* closestTarget = nullptr; 707 707 float minDistance = std::numeric_limits<float>::infinity(); 708 708 Gametype* gt = this->getGametype(); 709 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)709 for (Pawn* pawn : ObjectList<Pawn>()) 710 710 { 711 711 if (!this || !this->getControllableEntity()) 712 return 0;713 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>( *itP), gt) )712 return nullptr; 713 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) ) 714 714 continue; 715 715 716 float distance = CommonController::distance ( *itP, this->getControllableEntity());716 float distance = CommonController::distance (pawn, this->getControllableEntity()); 717 717 if (distance < minDistance) 718 718 { 719 closestTarget = *itP;719 closestTarget = pawn; 720 720 minDistance = distance; 721 721 } … … 725 725 return closestTarget; 726 726 } 727 return 0;727 return nullptr; 728 728 } 729 729 //push action FIGHT to the stack and set target to the closest enemy -
code/trunk/src/orxonox/controllers/ActionpointController.h
r11052 r11071 65 65 All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level. 66 66 */ 67 namespaceAction67 enum class Action 68 68 { 69 enum Value 70 { 71 NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK 72 }; 73 74 } 69 NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK 70 }; 75 71 76 72 struct Point { 77 Action ::Valueaction;73 Action action; 78 74 std::string name; 79 75 Vector3 position; 80 76 bool inLoop; 81 } ; 82 namespace PickupType 83 { 84 enum Value 85 { 86 NONE, DAMAGE, HEALTH, SPEED, PORTAL 87 }; 88 } 77 }; 89 78 90 79 class _OrxonoxExport ActionpointController : public FightingController, public Tickable … … 94 83 ActionpointController(Context* context); 95 84 virtual ~ActionpointController(); 96 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;85 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 97 86 98 87 /** … … 101 90 In tick ship flies and fires. 102 91 */ 103 virtual void tick(float dt) ;92 virtual void tick(float dt) override; 104 93 /** 105 94 @brief … … 186 175 virtual void takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b); 187 176 188 virtual Action ::ValuegetAction ();177 virtual Action getAction (); 189 178 virtual std::string getActionName(); 190 179 191 void setAction (Action ::Valueaction);192 void setAction (Action ::Valueaction, ControllableEntity* target);193 void setAction (Action ::Valueaction, const Vector3& target);194 void setAction (Action ::Valueaction, const Vector3& target, const Quaternion& orient );180 void setAction (Action action); 181 void setAction (Action action, ControllableEntity* target); 182 void setAction (Action action, const Vector3& target); 183 void setAction (Action action, const Vector3& target, const Quaternion& orient ); 195 184 196 185 virtual bool setWingman(ActionpointController* wingman) … … 210 199 WeakPtr<ActionpointController> myDivisionLeader_; 211 200 //----[Actionpoint information]---- 212 Action ::Valueaction_;201 Action action_; 213 202 std::string protectName_; 214 203 std::string targetName_; 215 std::vector<WeakPtr<WorldEntity> 204 std::vector<WeakPtr<WorldEntity>> actionpoints_; 216 205 float squaredaccuracy_; 217 std::vector<Point > parsedActionpoints_;//<! actionpoints as they are stored here after being parsed from XML218 std::vector<Point > loopActionpoints_;//<! actionpoints that are to be looped206 std::vector<Point> parsedActionpoints_; //<! actionpoints as they are stored here after being parsed from XML 207 std::vector<Point> loopActionpoints_; //<! actionpoints that are to be looped 219 208 bool bInLoop_; //<! variable for addActionpoint method 220 209 bool bLoop_; //<! is state machine looping? -
code/trunk/src/orxonox/controllers/ArtificialController.cc
r11052 r11071 56 56 this->currentWaypoint_ = 0; 57 57 this->setAccuracy(5); 58 this->defaultWaypoint_ = NULL;58 this->defaultWaypoint_ = nullptr; 59 59 this->mode_ = DEFAULT;//Vector-implementation: mode_.push_back(DEFAULT); 60 60 } … … 177 177 { 178 178 this->weaponModes_.clear(); // reset previous weapon information 179 WeaponSlot* wSlot = 0;179 WeaponSlot* wSlot = nullptr; 180 180 for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++) 181 181 { 182 WeaponMode* wMode = 0;182 WeaponMode* wMode = nullptr; 183 183 for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++) 184 184 { … … 207 207 void ArtificialController::setAllBotLevel(float level) 208 208 { 209 for ( ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it)210 it->setBotLevel(level);209 for (ArtificialController* controller : ObjectList<ArtificialController>()) 210 controller->setBotLevel(level); 211 211 } 212 212 … … 222 222 { 223 223 SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity()); 224 if(ship == NULL) return;224 if(ship == nullptr) return; 225 225 if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost 226 226 this->getControllableEntity()->boost(true); … … 231 231 int ArtificialController::getFiremode(std::string name) 232 232 { 233 for ( std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it)234 { 235 if ( it->first == name)236 return it->second;233 for (const auto& mapEntry : this->weaponModes_) 234 { 235 if (mapEntry.first == name) 236 return mapEntry.second; 237 237 } 238 238 return -1; … … 249 249 return this->waypoints_[index]; 250 250 else 251 return 0;251 return nullptr; 252 252 } 253 253 … … 258 258 void ArtificialController::updatePointsOfInterest(std::string name, float searchDistance) 259 259 { 260 WorldEntity* waypoint = NULL;261 for ( ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)262 { 263 if( (*it)->getIdentifier() == ClassByString(name))260 WorldEntity* waypoint = nullptr; 261 for (WorldEntity* we : ObjectList<WorldEntity>()) 262 { 263 if(we->getIdentifier() == ClassByString(name)) 264 264 { 265 265 ControllableEntity* controllable = this->getControllableEntity(); 266 266 if(!controllable) continue; 267 float actualDistance = ( (*it)->getPosition() - controllable->getPosition() ).length();267 float actualDistance = ( we->getPosition() - controllable->getPosition() ).length(); 268 268 if(actualDistance > searchDistance || actualDistance < 5.0f) continue; 269 269 // TODO: PickupSpawner: adjust waypoint accuracy to PickupSpawner's triggerdistance … … 271 271 else 272 272 { 273 waypoint = *it;273 waypoint = we; 274 274 break; 275 275 } -
code/trunk/src/orxonox/controllers/ArtificialController.h
r9667 r11071 42 42 virtual ~ArtificialController(); 43 43 44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 45 45 46 46 void abandonTarget(Pawn* target); 47 47 48 virtual void changedControllableEntity() ;48 virtual void changedControllableEntity() override; 49 49 50 50 virtual void doFire(); … … 89 89 90 90 //WAYPOINT DATA 91 std::vector<WeakPtr<WorldEntity> 91 std::vector<WeakPtr<WorldEntity>> waypoints_; 92 92 size_t currentWaypoint_; 93 93 float squaredaccuracy_; -
code/trunk/src/orxonox/controllers/CommonController.cc
r11052 r11071 83 83 int team2 = entity2->getTeam(); 84 84 85 Controller* controller = 0;85 Controller* controller = nullptr; 86 86 if (entity1->getController()) 87 87 controller = entity1->getController(); … … 120 120 } 121 121 122 TeamBaseMatchBase* base = 0;122 TeamBaseMatchBase* base = nullptr; 123 123 base = orxonox_cast<TeamBaseMatchBase*>(entity1); 124 124 if (base) … … 154 154 } 155 155 156 DroneController* droneController = 0;156 DroneController* droneController = nullptr; 157 157 droneController = orxonox_cast<DroneController*>(entity1->getController()); 158 158 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2) -
code/trunk/src/orxonox/controllers/Controller.cc
r9797 r11071 40 40 RegisterObject(Controller); 41 41 42 this->player_ = 0;43 this->controllableEntity_ = 0;42 this->player_ = nullptr; 43 this->controllableEntity_ = nullptr; 44 44 this->bGodMode_ = false; 45 45 this->team_=-1; -
code/trunk/src/orxonox/controllers/Controller.h
r9797 r11071 45 45 Controller(Context* context); 46 46 virtual ~Controller(); 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 48 48 inline void setPlayer(PlayerInfo* player) 49 49 { this->player_ = player; } -
code/trunk/src/orxonox/controllers/ControllerDirector.cc
r10622 r11071 32 32 33 33 // Initialize member variables 34 this->player_ = NULL;35 this->entity_ = NULL;36 this->pTrigger_ = NULL;34 this->player_ = nullptr; 35 this->entity_ = nullptr; 36 this->pTrigger_ = nullptr; 37 37 this->context_ = context; 38 38 } … … 110 110 { 111 111 this->pTrigger_ = orxonox_cast<PlayerTrigger*>(trigger); 112 this->player_ = NULL;112 this->player_ = nullptr; 113 113 114 114 orxout(verbose) << "Preparation to take Control!" << endl; 115 115 116 116 // Check whether it is a player trigger and extract pawn from it 117 if(this->pTrigger_ != NULL)117 if(this->pTrigger_ != nullptr) 118 118 { 119 119 // Get the object which triggered the event. … … 121 121 122 122 // Check if there actually was a player returned. 123 if( this->player_ == NULL) return false;123 if( this->player_ == nullptr) return false; 124 124 } 125 125 else -
code/trunk/src/orxonox/controllers/ControllerDirector.h
r10622 r11071 43 43 virtual ~ControllerDirector() { } 44 44 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 46 46 bool party(bool bTriggered, BaseObject* trigger); 47 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) ;47 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; 48 48 49 49 inline void setScriptName(const std::string& name) { this->scriptname_ = name; } -
code/trunk/src/orxonox/controllers/DivisionController.cc
r11052 r11071 40 40 RegisterObject(DivisionController); 41 41 this->setFormationMode(FormationMode::DIAMOND); 42 this->target_ = 0;43 this->myFollower_ = 0;44 this->myWingman_ = 0;42 this->target_ = nullptr; 43 this->myFollower_ = nullptr; 44 this->myWingman_ = nullptr; 45 45 } 46 46 47 47 DivisionController::~DivisionController() 48 48 { 49 for ( size_t i = 0; i < this->actionpoints_.size(); ++i)49 for (WorldEntity* actionpoint : this->actionpoints_) 50 50 { 51 if (this->actionpoints_[i])52 this->actionpoints_[i]->destroy();51 if (actionpoint) 52 actionpoint->destroy(); 53 53 } 54 54 this->parsedActionpoints_.clear(); 55 55 this->actionpoints_.clear(); 56 56 } 57 58 void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)59 {60 SUPER(DivisionController, XMLPort, xmlelement, mode);61 62 }63 void DivisionController::tick(float dt)64 {65 if (!this->isActive())66 return;67 68 SUPER(DivisionController, tick, dt);69 70 }71 57 void DivisionController::action() 72 58 { -
code/trunk/src/orxonox/controllers/DivisionController.h
r11052 r11071 50 50 //----[/language demanded functions]---- 51 51 52 //----[orxonox demanded functions]----53 virtual void tick(float dt);54 55 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);56 //----[orxonox demanded functions]----57 58 52 //----[own functions]---- 59 virtual bool setFollower(ActionpointController* newFollower) ;60 virtual bool setWingman(ActionpointController* newWingman) ;61 virtual bool hasWingman() ;62 virtual bool hasFollower() ;53 virtual bool setFollower(ActionpointController* newFollower) override; 54 virtual bool setWingman(ActionpointController* newWingman) override; 55 virtual bool hasWingman() override; 56 virtual bool hasFollower() override; 63 57 64 58 //----[/own functions]---- 65 virtual void stayNearProtect() ;59 virtual void stayNearProtect() override; 66 60 67 61 protected: 68 62 //----action must only be managed by this---- 69 virtual void action() ; //<! action() is called in regular intervals managing the bot's behaviour.63 virtual void action() override; //<! action() is called in regular intervals managing the bot's behaviour. 70 64 71 65 private: -
code/trunk/src/orxonox/controllers/DroneController.cc
r9667 r11071 49 49 RegisterObject(DroneController); 50 50 51 this->owner_ = 0;52 this->drone_ = 0;51 this->owner_ = nullptr; 52 this->drone_ = nullptr; 53 53 this->isShooting_ = false; 54 54 this->setAccuracy(10); -
code/trunk/src/orxonox/controllers/DroneController.h
r9667 r11071 53 53 virtual ~DroneController(); 54 54 55 virtual void tick(float dt) ; //!< The controlling happens here. This method defines what the controller has to do each tick.55 virtual void tick(float dt) override; //!< The controlling happens here. This method defines what the controller has to do each tick. 56 56 57 57 void setOwner(Pawn* owner); -
code/trunk/src/orxonox/controllers/FightingController.cc
r11052 r11071 27 27 */ 28 28 #include "controllers/FightingController.h" 29 #include "core/XMLPort.h"30 29 #include "util/Math.h" 31 30 … … 56 55 { 57 56 58 }59 void FightingController::XMLPort( Element& xmlelement, XMLPort::Mode mode )60 {61 SUPER( FightingController, XMLPort, xmlelement, mode );62 57 } 63 58 void FightingController::lookAtTarget(float dt) … … 243 238 { 244 239 if (!this || !this->getControllableEntity()) 245 return 0;246 247 Pawn* closestTarget = 0;240 return nullptr; 241 242 Pawn* closestTarget = nullptr; 248 243 float minDistance = std::numeric_limits<float>::infinity(); 249 244 Gametype* gt = this->getGametype(); 250 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)251 { 252 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>( *itP), gt) )245 for (Pawn* pawn : ObjectList<Pawn>()) 246 { 247 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) ) 253 248 continue; 254 249 255 float distance = CommonController::distance ( *itP, this->getControllableEntity());250 float distance = CommonController::distance (pawn, this->getControllableEntity()); 256 251 if (distance < minDistance) 257 252 { 258 closestTarget = *itP;253 closestTarget = pawn; 259 254 minDistance = distance; 260 255 } … … 264 259 return closestTarget; 265 260 } 266 return 0;261 return nullptr; 267 262 } 268 263 //I checked it out, rockets DO NOT cause any problems! this->getControllableEntity() is always a SpaceShip … … 340 335 { 341 336 this->weaponModes_.clear(); // reset previous weapon information 342 WeaponSlot* wSlot = 0;337 WeaponSlot* wSlot = nullptr; 343 338 for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++) 344 339 { 345 WeaponMode* wMode = 0;340 WeaponMode* wMode = nullptr; 346 341 for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++) 347 342 { … … 361 356 } 362 357 363 int FightingController::getFiremode( std::stringname)364 { 365 for ( std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it)366 { 367 if ( it->first == name)368 return it->second;358 int FightingController::getFiremode(const std::string& name) 359 { 360 for (const auto& mapEntry : this->weaponModes_) 361 { 362 if (mapEntry.first == name) 363 return mapEntry.second; 369 364 } 370 365 return -1; -
code/trunk/src/orxonox/controllers/FightingController.h
r11052 r11071 50 50 virtual ~FightingController(); 51 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);53 54 52 float squaredDistanceToTarget() const; 55 53 bool isLookingAtTarget(float angle) const; … … 74 72 //<! this and target_ plus or minus some amount in difference vector direction, 75 73 //<! depending on whether it is better to close up or survive. 76 void dodgeTowards (Vector3& position); //fly towards position and awoid being hit77 74 void doFire(); //<! choose weapon, set aim at target_ and fire 78 75 WeakPtr<ControllableEntity> target_; … … 99 96 void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed. 100 97 bool bSetupWorked; //<! If false, setupWeapons() is called. 101 int getFiremode( std::stringname);98 int getFiremode(const std::string& name); 102 99 103 100 }; -
code/trunk/src/orxonox/controllers/FlyingController.cc
r11052 r11071 61 61 } 62 62 63 void FlyingController::setFormationModeXML( std::stringval)63 void FlyingController::setFormationModeXML(const std::string& val) 64 64 { 65 65 const std::string valUpper = getUppercase(val); 66 FormationMode ::Valuevalue;66 FormationMode value; 67 67 68 68 if (valUpper == "WALL") … … 233 233 return; 234 234 SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity()); 235 if(ship == NULL) return;235 if(ship == nullptr) return; 236 236 if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower()) //upper limit ->boost 237 237 { -
code/trunk/src/orxonox/controllers/FlyingController.h
r11052 r11071 41 41 42 42 //Formation mode for the divisions 43 namespaceFormationMode43 enum class FormationMode 44 44 { 45 enum Value 46 { 47 FINGER4, DIAMOND, WALL 48 }; 49 } 45 FINGER4, DIAMOND, WALL 46 }; 50 47 51 48 class _OrxonoxExport FlyingController : public CommonController … … 58 55 FlyingController(Context* context); 59 56 virtual ~FlyingController(); 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;57 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 61 58 62 59 void setSpread (int spread) //<! spread is a multiplier for formation flight, should be bigger than 100 … … 65 62 { return this->spread_; } 66 63 67 void setFormationModeXML( std::stringval);64 void setFormationModeXML(const std::string& val); 68 65 std::string getFormationModeXML() const; 69 66 70 void setFormationMode(FormationMode ::Valueval)67 void setFormationMode(FormationMode val) 71 68 { this->formationMode_ = val; } 72 FormationMode ::ValuegetFormationMode() const69 FormationMode getFormationMode() const 73 70 { return this->formationMode_; } 74 71 bool bCopyOrientation_; //<! set to true by default, MasterController sets it in its tick(), … … 91 88 //<! this stays in a certain position relative to leader 92 89 93 FormationMode ::ValueformationMode_;90 FormationMode formationMode_; 94 91 95 92 float rotationProgress_; //<! for slerping -
code/trunk/src/orxonox/controllers/FormationController.cc
r11052 r11071 58 58 RegisterClass(FormationController); 59 59 60 static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;61 static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;62 static const float FORMATION_LENGTH = 110;63 static const float FORMATION_WIDTH = 110;64 static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy65 static const float SPEED_MASTER = 0.6f;66 static const float ROTATEFACTOR_MASTER = 0.2f;67 static const float SPEED_FREE = 0.8f;68 static const float ROTATEFACTOR_FREE = 0.8f;60 static constexpr unsigned int STANDARD_MAX_FORMATION_SIZE = 9; 61 static constexpr int RADIUS_TO_SEARCH_FOR_MASTERS = 5000; 62 static constexpr float FORMATION_LENGTH = 110; 63 static constexpr float FORMATION_WIDTH = 110; 64 static constexpr int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy 65 static constexpr float SPEED_MASTER = 0.6f; 66 static constexpr float ROTATEFACTOR_MASTER = 0.2f; 67 static constexpr float SPEED_FREE = 0.8f; 68 static constexpr float ROTATEFACTOR_FREE = 0.8f; 69 69 70 70 FormationController::FormationController(Context* context) : Controller(context) … … 72 72 RegisterObject(FormationController); 73 73 74 this->target_ = 0;74 this->target_ = nullptr; 75 75 this->formationFlight_ = false; 76 76 this->passive_ = false; 77 77 this->maxFormationSize_ = STANDARD_MAX_FORMATION_SIZE; 78 this->myMaster_ = 0;78 this->myMaster_ = nullptr; 79 79 this->freedomCount_ = 0; 80 80 … … 97 97 this->removeFromFormation(); 98 98 99 for ( ObjectList<FormationController>::iterator it = ObjectList<FormationController>::begin(); it; ++it)100 { 101 if ( *it!= this)99 for (FormationController* controller : ObjectList<FormationController>()) 100 { 101 if (controller != this) 102 102 { 103 if ( it->myMaster_ == this)103 if (controller->myMaster_ == this) 104 104 { 105 orxout(internal_error) << this << " is still master in " << (*it)<< endl;106 it->myMaster_ = 0;105 orxout(internal_error) << this << " is still master in " << controller << endl; 106 controller->myMaster_ = nullptr; 107 107 } 108 108 109 109 while (true) 110 110 { 111 std::vector<FormationController*>::iterator it2 = std::find( it->slaves_.begin(), it->slaves_.end(), this);112 if (it2 != it->slaves_.end())111 std::vector<FormationController*>::iterator it2 = std::find(controller->slaves_.begin(), controller->slaves_.end(), this); 112 if (it2 != controller->slaves_.end()) 113 113 { 114 orxout(internal_error) << this << " is still slave in " << (*it)<< endl;115 it->slaves_.erase(it2);114 orxout(internal_error) << this << " is still slave in " << controller << endl; 115 controller->slaves_.erase(it2); 116 116 } 117 117 else … … 140 140 void FormationController::formationflight(const bool form) 141 141 { 142 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)143 { 144 Controller* controller = 0;145 146 if ( it->getController())147 controller = it->getController();148 else if ( it->getXMLController())149 controller = it->getXMLController();142 for (Pawn* pawn : ObjectList<Pawn>()) 143 { 144 Controller* controller = nullptr; 145 146 if (pawn->getController()) 147 controller = pawn->getController(); 148 else if (pawn->getXMLController()) 149 controller = pawn->getXMLController(); 150 150 151 151 if (!controller) … … 171 171 void FormationController::masteraction(const int action) 172 172 { 173 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)174 { 175 Controller* controller = 0;176 177 if ( it->getController())178 controller = it->getController();179 else if ( it->getXMLController())180 controller = it->getXMLController();173 for (Pawn* pawn : ObjectList<Pawn>()) 174 { 175 Controller* controller = nullptr; 176 177 if (pawn->getController()) 178 controller = pawn->getController(); 179 else if (pawn->getXMLController()) 180 controller = pawn->getXMLController(); 181 181 182 182 if (!controller) … … 201 201 void FormationController::passivebehaviour(const bool passive) 202 202 { 203 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)204 { 205 Controller* controller = 0;206 207 if ( it->getController())208 controller = it->getController();209 else if ( it->getXMLController())210 controller = it->getXMLController();203 for (Pawn* pawn : ObjectList<Pawn>()) 204 { 205 Controller* controller = nullptr; 206 207 if (pawn->getController()) 208 controller = pawn->getController(); 209 else if (pawn->getXMLController()) 210 controller = pawn->getXMLController(); 211 211 212 212 if (!controller) … … 228 228 void FormationController::formationsize(const int size) 229 229 { 230 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)231 { 232 Controller* controller = 0;233 234 if ( it->getController())235 controller = it->getController();236 else if ( it->getXMLController())237 controller = it->getXMLController();230 for (Pawn* pawn : ObjectList<Pawn>()) 231 { 232 Controller* controller = nullptr; 233 234 if (pawn->getController()) 235 controller = pawn->getController(); 236 else if (pawn->getXMLController()) 237 controller = pawn->getXMLController(); 238 238 239 239 if (!controller) … … 383 383 } 384 384 385 this->myMaster_ = 0;385 this->myMaster_ = nullptr; 386 386 this->state_ = FREE; 387 387 } … … 398 398 int teamSize = 0; 399 399 //go through all pawns 400 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)400 for (Pawn* pawn : ObjectList<Pawn>()) 401 401 { 402 402 … … 405 405 if (!gt) 406 406 { 407 gt= it->getGametype();408 } 409 if (!FormationController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>( *it),gt))407 gt=pawn->getGametype(); 408 } 409 if (!FormationController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(pawn),gt)) 410 410 continue; 411 411 412 412 //has it an FormationController? 413 Controller* controller = 0;414 415 if ( it->getController())416 controller = it->getController();417 else if ( it->getXMLController())418 controller = it->getXMLController();413 Controller* controller = nullptr; 414 415 if (pawn->getController()) 416 controller = pawn->getController(); 417 else if (pawn->getXMLController()) 418 controller = pawn->getXMLController(); 419 419 420 420 if (!controller) … … 422 422 423 423 //is pawn oneself? 424 if (orxonox_cast<ControllableEntity*>( *it) == this->getControllableEntity())424 if (orxonox_cast<ControllableEntity*>(pawn) == this->getControllableEntity()) 425 425 continue; 426 426 … … 433 433 continue; 434 434 435 float distance = ( it->getPosition() - this->getControllableEntity()->getPosition()).length();435 float distance = (pawn->getPosition() - this->getControllableEntity()->getPosition()).length(); 436 436 437 437 // is pawn in range? … … 440 440 if(newMaster->slaves_.size() > this->maxFormationSize_) continue; 441 441 442 for( std::vector<FormationController*>::iterator itSlave = this->slaves_.begin(); itSlave != this->slaves_.end(); itSlave++)442 for(FormationController* slave : this->slaves_) 443 443 { 444 (*itSlave)->myMaster_ = newMaster;445 newMaster->slaves_.push_back( *itSlave);444 slave->myMaster_ = newMaster; 445 newMaster->slaves_.push_back(slave); 446 446 } 447 447 this->slaves_.clear(); … … 458 458 { 459 459 this->state_ = MASTER; 460 this->myMaster_ = 0;460 this->myMaster_ = nullptr; 461 461 } 462 462 } … … 486 486 int i = 1; 487 487 488 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)488 for(FormationController* slave : slaves_) 489 489 { 490 490 pos = Vector3::ZERO; … … 497 497 dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK); 498 498 } 499 (*it)->setTargetOrientation(orient);500 (*it)->setTargetPosition(pos);499 slave->setTargetOrientation(orient); 500 slave->setTargetPosition(pos); 501 501 left=!left; 502 502 } … … 518 518 newMaster->state_ = MASTER; 519 519 newMaster->slaves_ = this->slaves_; 520 newMaster->myMaster_ = 0;521 522 for( std::vector<FormationController*>::iterator it = newMaster->slaves_.begin(); it != newMaster->slaves_.end(); it++)523 { 524 (*it)->myMaster_ = newMaster;520 newMaster->myMaster_ = nullptr; 521 522 for(FormationController* slave : newMaster->slaves_) 523 { 524 slave->myMaster_ = newMaster; 525 525 } 526 526 } … … 547 547 newMaster->state_ = MASTER; 548 548 newMaster->slaves_ = this->slaves_; 549 newMaster->myMaster_ = 0;550 551 for( std::vector<FormationController*>::iterator it = newMaster->slaves_.begin(); it != newMaster->slaves_.end(); it++)549 newMaster->myMaster_ = nullptr; 550 551 for(FormationController* slave : newMaster->slaves_) 552 552 { 553 (*it)->myMaster_ = newMaster;553 slave->myMaster_ = newMaster; 554 554 } 555 555 } … … 569 569 if(this->state_ != MASTER) return; 570 570 571 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)572 { 573 (*it)->state_ = FREE;574 (*it)->myMaster_ = 0;571 for(FormationController* slave : slaves_) 572 { 573 slave->state_ = FREE; 574 slave->myMaster_ = nullptr; 575 575 } 576 576 this->slaves_.clear(); … … 584 584 if(this->state_ != MASTER) return; 585 585 586 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)587 { 588 (*it)->state_ = FREE;589 (*it)->forceFreedom();590 (*it)->targetPosition_ = this->targetPosition_;591 (*it)->bShooting_ = true;586 for(FormationController* slave : slaves_) 587 { 588 slave->state_ = FREE; 589 slave->forceFreedom(); 590 slave->targetPosition_ = this->targetPosition_; 591 slave->bShooting_ = true; 592 592 // (*it)->getControllableEntity()->fire(0);// fire once for fun 593 593 } … … 629 629 630 630 //search new Master, then take lead 631 if (this->state_==FREE && this->myMaster_== 0)631 if (this->state_==FREE && this->myMaster_==nullptr) 632 632 { 633 633 searchNewMaster(); … … 650 650 this->slaves_.push_back(this->myMaster_); 651 651 //set this as new master 652 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)653 { 654 (*it)->myMaster_=this;655 } 656 this->myMaster_= 0;652 for(FormationController* slave : slaves_) 653 { 654 slave->myMaster_=this; 655 } 656 this->myMaster_=nullptr; 657 657 this->state_=MASTER; 658 658 } … … 694 694 if (this->state_ == MASTER) 695 695 { 696 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)697 { 698 (*it)->formationMode_ = val;696 for(FormationController* slave : slaves_) 697 { 698 slave->formationMode_ = val; 699 699 if (val == ATTACK) 700 (*it)->forgetTarget();700 slave->forgetTarget(); 701 701 } 702 702 } … … 773 773 { 774 774 775 Pawn *humanPawn = NULL;776 NewHumanController *currentHumanController = NULL;775 Pawn *humanPawn = nullptr; 776 NewHumanController *currentHumanController = nullptr; 777 777 std::vector<FormationController*> allMasters; 778 778 779 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)780 { 781 Controller* controller = 0;782 783 if ( it->getController())784 controller = it->getController();785 else if ( it->getXMLController())786 controller = it->getXMLController();779 for (Pawn* pawn : ObjectList<Pawn>()) 780 { 781 Controller* controller = nullptr; 782 783 if (pawn->getController()) 784 controller = pawn->getController(); 785 else if (pawn->getXMLController()) 786 controller = pawn->getXMLController(); 787 787 788 788 if (!controller) … … 791 791 currentHumanController = orxonox_cast<NewHumanController*>(controller); 792 792 793 if(currentHumanController) humanPawn = *it;793 if(currentHumanController) humanPawn = pawn; 794 794 795 795 FormationController *aiController = orxonox_cast<FormationController*>(controller); … … 800 800 } 801 801 802 if((humanPawn != NULL) && (allMasters.size() != 0))802 if((humanPawn != nullptr) && (allMasters.size() != 0)) 803 803 { 804 804 float posHuman = humanPawn->getPosition().length(); … … 808 808 int i = 0; 809 809 810 for( std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++)811 { 812 if (!FormationController::sameTeam( (*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue;813 distance = posHuman - (*it)->getControllableEntity()->getPosition().length();810 for(FormationController* master : allMasters) 811 { 812 if (!FormationController::sameTeam(master->getControllableEntity(), humanPawn, master->getGametype())) continue; 813 distance = posHuman - master->getControllableEntity()->getPosition().length(); 814 814 if(distance < minDistance) index = i; 815 i++; 815 816 } 816 817 allMasters[index]->followInit(humanPawn); … … 826 827 void FormationController::followInit(Pawn* pawn, const bool always, const int secondsToFollow) 827 828 { 828 if (pawn == NULL|| this->state_ != MASTER)829 if (pawn == nullptr || this->state_ != MASTER) 829 830 return; 830 831 this->specificMasterAction_ = FOLLOW; … … 844 845 { 845 846 846 Pawn *humanPawn = NULL;847 NewHumanController *currentHumanController = NULL;848 849 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)850 { 851 if (! it->getController())847 Pawn *humanPawn = nullptr; 848 NewHumanController *currentHumanController = nullptr; 849 850 for (Pawn* pawn : ObjectList<Pawn>()) 851 { 852 if (!pawn->getController()) 852 853 continue; 853 854 854 currentHumanController = orxonox_cast<NewHumanController*>( it->getController());855 currentHumanController = orxonox_cast<NewHumanController*>(pawn->getController()); 855 856 if(currentHumanController) 856 857 { 857 if (!FormationController::sameTeam(this->getControllableEntity(), *it, this->getGametype())) continue;858 humanPawn = *it;858 if (!FormationController::sameTeam(this->getControllableEntity(), pawn, this->getGametype())) continue; 859 humanPawn = pawn; 859 860 break; 860 861 } 861 862 } 862 863 863 if((humanPawn != NULL))864 if((humanPawn != nullptr)) 864 865 this->followInit(humanPawn); 865 866 } … … 918 919 this->forgetTarget(); 919 920 920 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)921 { 922 if (FormationController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>( *it), this->getGametype()))921 for (Pawn* pawn : ObjectList<Pawn>()) 922 { 923 if (FormationController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), this->getGametype())) 923 924 continue; 924 925 925 926 /* So AI won't choose invisible Spaceships as target */ 926 if (! it->getRadarVisibility())927 if (!pawn->getRadarVisibility()) 927 928 continue; 928 929 929 if (static_cast<ControllableEntity*>( *it) != this->getControllableEntity())930 if (static_cast<ControllableEntity*>(pawn) != this->getControllableEntity()) 930 931 { 931 932 float speed = this->getControllableEntity()->getVelocity().length(); 932 933 Vector3 distanceCurrent = this->targetPosition_ - this->getControllableEntity()->getPosition(); 933 Vector3 distanceNew = it->getPosition() - this->getControllableEntity()->getPosition();934 if (!this->target_ || it->getPosition().squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceNew) / speed / distanceNew.length()) / math::twoPi)934 Vector3 distanceNew = pawn->getPosition() - this->getControllableEntity()->getPosition(); 935 if (!this->target_ || pawn->getPosition().squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceNew) / speed / distanceNew.length()) / math::twoPi) 935 936 < this->targetPosition_.squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / math::twoPi) + rnd(-250, 250)) 936 937 { 937 this->setTarget( *it);938 this->setTarget(pawn); 938 939 } 939 940 } … … 943 944 void FormationController::forgetTarget() 944 945 { 945 this->target_ = 0;946 this->target_ = nullptr; 946 947 this->bShooting_ = false; 947 948 } … … 963 964 int team2 = entity2->getTeam(); 964 965 965 Controller* controller = 0;966 Controller* controller = nullptr; 966 967 if (entity1->getController()) 967 968 controller = entity1->getController(); … … 1000 1001 } 1001 1002 1002 TeamBaseMatchBase* base = 0;1003 TeamBaseMatchBase* base = nullptr; 1003 1004 base = orxonox_cast<TeamBaseMatchBase*>(entity1); 1004 1005 if (base) … … 1034 1035 } 1035 1036 1036 DroneController* droneController = 0;1037 DroneController* droneController = nullptr; 1037 1038 droneController = orxonox_cast<DroneController*>(entity1->getController()); 1038 1039 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2) -
code/trunk/src/orxonox/controllers/FormationController.h
r10631 r11071 50 50 virtual ~FormationController(); 51 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 53 53 54 54 … … 93 93 { return this->formationMode_; } 94 94 95 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) ;95 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) override; 96 96 97 97 FormationController* getMaster( void ) { return myMaster_; } … … 99 99 FormationController* getSlave( void ) { return this->slaves_.back(); } 100 100 101 virtual void changedControllableEntity() ;101 virtual void changedControllableEntity() override; 102 102 103 103 protected: -
code/trunk/src/orxonox/controllers/HumanController.cc
r11052 r11071 65 65 RegisterUnloadableClass(HumanController); 66 66 67 HumanController* HumanController::localController_s = 0;67 HumanController* HumanController::localController_s = nullptr; 68 68 69 69 HumanController::HumanController(Context* context) : FormationController(context) … … 81 81 HumanController::localController_s->removeFromFormation(); 82 82 } 83 HumanController::localController_s = 0;83 HumanController::localController_s = nullptr; 84 84 } 85 85 … … 321 321 return orxonox_cast<Pawn*>(HumanController::localController_s->getControllableEntity()); 322 322 else 323 return NULL;323 return nullptr; 324 324 } 325 325 -
code/trunk/src/orxonox/controllers/HumanController.h
r10624 r11071 47 47 virtual ~HumanController(); 48 48 49 virtual void tick(float dt) ;49 virtual void tick(float dt) override; 50 50 51 51 static void moveFrontBack(const Vector2& value); -
code/trunk/src/orxonox/controllers/MasterController.cc
r11052 r11071 58 58 { 59 59 //fill the vector in the first tick 60 for ( ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)60 for (ActionpointController* controller : ObjectList<ActionpointController>()) 61 61 { 62 62 //----0ptr?---- 63 if (! it)63 if (!controller) 64 64 continue; 65 this->controllers_.push_back( *it);65 this->controllers_.push_back(controller); 66 66 } 67 67 } -
code/trunk/src/orxonox/controllers/MasterController.h
r11052 r11071 61 61 62 62 //----[orxonox demanded functions]---- 63 virtual void tick(float dt) ;63 virtual void tick(float dt) override; 64 64 65 65 //----[orxonox demanded functions]---- … … 68 68 69 69 private: 70 std::vector<WeakPtr<ActionpointController> > controllers_;//<! vector of controllers, which action(), canFire() and maneuver() methods are to be called70 std::vector<WeakPtr<ActionpointController>> controllers_;//<! vector of controllers, which action(), canFire() and maneuver() methods are to be called 71 71 size_t indexOfCurrentController_; //<! index of current controller 72 72 unsigned int numberOfTicksPassedSinceLastActionCall_; -
code/trunk/src/orxonox/controllers/NewHumanController.cc
r10631 r11071 58 58 RegisterUnloadableClass(NewHumanController); 59 59 60 NewHumanController* NewHumanController::localController_s = 0;60 NewHumanController* NewHumanController::localController_s = nullptr; 61 61 62 62 NewHumanController::NewHumanController(Context* context) 63 63 : HumanController(context) 64 , crossHairOverlay_( NULL)65 , centerOverlay_( NULL)66 , damageOverlayTop_( NULL)67 , damageOverlayRight_( NULL)68 , damageOverlayBottom_( NULL)69 , damageOverlayLeft_( NULL)64 , crossHairOverlay_(nullptr) 65 , centerOverlay_(nullptr) 66 , damageOverlayTop_(nullptr) 67 , damageOverlayRight_(nullptr) 68 , damageOverlayBottom_(nullptr) 69 , damageOverlayLeft_(nullptr) 70 70 , damageOverlayTT_(0) 71 71 , damageOverlayTR_(0) 72 72 , damageOverlayTB_(0) 73 73 , damageOverlayTL_(0) 74 , arrowsOverlay1_( NULL)75 , arrowsOverlay2_( NULL)76 , arrowsOverlay3_( NULL)77 , arrowsOverlay4_( NULL)74 , arrowsOverlay1_(nullptr) 75 , arrowsOverlay2_(nullptr) 76 , arrowsOverlay3_(nullptr) 77 , arrowsOverlay4_(nullptr) 78 78 { 79 79 RegisterObject(NewHumanController); … … 445 445 pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 3000 ); 446 446 447 if( this->getControllableEntity() && this->getControllableEntity()->getTarget() != 0)448 this->getControllableEntity()->setTarget( 0);447 if( this->getControllableEntity() && this->getControllableEntity()->getTarget() != nullptr ) 448 this->getControllableEntity()->setTarget( nullptr ); 449 449 450 450 //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000); -
code/trunk/src/orxonox/controllers/NewHumanController.h
r9667 r11071 45 45 virtual ~NewHumanController(); 46 46 47 virtual void tick(float dt) ;47 virtual void tick(float dt) override; 48 48 49 virtual void frontback(const Vector2& value) ;50 virtual void yaw(const Vector2& value) ;51 virtual void pitch(const Vector2& value) ;49 virtual void frontback(const Vector2& value) override; 50 virtual void yaw(const Vector2& value) override; 51 virtual void pitch(const Vector2& value) override; 52 52 53 53 static void accelerate(); 54 54 static void decelerate(); 55 55 56 virtual void doFire(unsigned int firemode) ;56 virtual void doFire(unsigned int firemode) override; 57 57 58 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) ;58 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) override; 59 59 60 60 static void unfire(); … … 65 65 static void changeMode(); 66 66 67 virtual void changedControllableEntity() ;68 virtual void doPauseControl() ;69 virtual void doResumeControl() ;67 virtual void changedControllableEntity() override; 68 virtual void doPauseControl() override; 69 virtual void doResumeControl() override; 70 70 71 71 float getCurrentYaw(){ return this->currentYaw_; } -
code/trunk/src/orxonox/controllers/ScriptController.cc
r10622 r11071 64 64 /* Set default values for all variables */ 65 65 /* - pointers to zero */ 66 this->player_ = NULL;67 this->entity_ = NULL;66 this->player_ = nullptr; 67 this->entity_ = nullptr; 68 68 69 69 /* - times */ … … 121 121 122 122 /* Debugging: print all the scriptcontroller object pointers */ 123 for(ObjectList<ScriptController>::iterator it = 124 ObjectList<ScriptController>::begin(); 125 it != ObjectList<ScriptController>::end(); ++it) 126 { orxout(verbose) << "Have object in list: " << *it << endl; } 123 for(ScriptController* controller : ObjectList<ScriptController>()) 124 { orxout(verbose) << "Have object in list: " << controller << endl; } 127 125 128 126 /* Find the first one with a nonzero ID */ 129 for(ObjectList<ScriptController>::iterator it = 130 ObjectList<ScriptController>::begin(); 131 it != ObjectList<ScriptController>::end(); ++it) 127 for(ScriptController* controller : ObjectList<ScriptController>()) 132 128 { 133 129 // TODO: do some selection here. Currently just returns the first one 134 if( (*it)->getID() > 0 )135 { orxout(verbose) << "Controller to return: " << *it<< endl;136 return *it;130 if( controller->getID() > 0 ) 131 { orxout(verbose) << "Controller to return: " << controller << endl; 132 return controller; 137 133 } 138 134 139 135 } 140 return NULL;136 return nullptr; 141 137 } 142 138 -
code/trunk/src/orxonox/controllers/ScriptController.h
r10622 r11071 71 71 void setPlayer(PlayerInfo* player) { this->player_ = player; } 72 72 73 virtual void tick(float dt) ;73 virtual void tick(float dt) override; 74 74 75 75 // LUA interface -
code/trunk/src/orxonox/controllers/SectionController.cc
r11052 r11071 40 40 this->setFormationMode(FormationMode::FINGER4); 41 41 42 this->myWingman_ = 0;43 this->myDivisionLeader_ = 0;42 this->myWingman_ = nullptr; 43 this->myDivisionLeader_ = nullptr; 44 44 this->bFirstAction_ = true; 45 45 … … 48 48 SectionController::~SectionController() 49 49 { 50 for (size_t i = 0; i < this->actionpoints_.size(); ++i)51 { 52 if (this->actionpoints_[i])53 this->actionpoints_[i]->destroy();50 for (WorldEntity* actionpoint : this->actionpoints_) 51 { 52 if (actionpoint) 53 actionpoint->destroy(); 54 54 } 55 55 this->parsedActionpoints_.clear(); 56 56 this->actionpoints_.clear(); 57 }58 void SectionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)59 {60 SUPER(SectionController, XMLPort, xmlelement, mode);61 }62 63 //----in tick, move (or look) and shoot----64 void SectionController::tick(float dt)65 {66 if (!this->isActive())67 return;68 69 SUPER(SectionController, tick, dt);70 71 57 } 72 58 … … 131 117 { 132 118 //----If division leader fights, cover him by fighting emenies close to his target---- 133 Action ::Valueaction = this->myDivisionLeader_->getAction();119 Action action = this->myDivisionLeader_->getAction(); 134 120 135 121 if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK) … … 147 133 Vector3 divisionTargetPosition = this->myDivisionLeader_->getTarget()->getWorldPosition(); 148 134 Gametype* gt = this->getGametype(); 149 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)135 for (Pawn* pawn : ObjectList<Pawn>()) 150 136 { 151 137 //----is enemy?---- 152 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>( *itP), gt) )138 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) ) 153 139 continue; 154 140 //----in range?---- 155 if (( (*itP)->getWorldPosition() - divisionTargetPosition).length() < 3000 &&156 (*itP)!= this->myDivisionLeader_->getTarget())141 if ((pawn->getWorldPosition() - divisionTargetPosition).length() < 3000 && 142 pawn != this->myDivisionLeader_->getTarget()) 157 143 { 158 144 foundTarget = true; 159 target = (*itP);145 target = pawn; 160 146 break; 161 147 } … … 188 174 this->setFormationMode( this->myDivisionLeader_->getFormationMode() ); 189 175 this->spread_ = this->myDivisionLeader_->getSpread(); 190 Vector3* targetRelativePosition;191 176 switch (this->formationMode_){ 192 177 case FormationMode::WALL: 193 { 194 targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 0); 195 break; 196 } 178 return Vector3 (-2.0f*this->spread_, 0, 0); 179 197 180 case FormationMode::FINGER4: 198 { 199 targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_); 200 break; 201 } 181 return Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_); 202 182 203 183 case FormationMode::DIAMOND: 204 { 205 targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_); 206 break; 207 } 208 } 209 Vector3 result = *targetRelativePosition; 210 delete targetRelativePosition; 211 return result; 184 return Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_); 185 186 default: 187 return Vector3::ZERO; 188 } 212 189 } 213 190 … … 226 203 227 204 if (!this->getControllableEntity()) 228 return 0;229 230 ActionpointController* closestLeader = 0;205 return nullptr; 206 207 ActionpointController* closestLeader = nullptr; 231 208 float minDistance = std::numeric_limits<float>::infinity(); 232 209 //go through all pawns 233 for ( ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)210 for (ActionpointController* controller : ObjectList<ActionpointController>()) 234 211 { 235 212 //0ptr or not DivisionController? 236 if (! (it) || !((it)->getIdentifier()->getName() == "DivisionController") || !(it->getControllableEntity()))213 if (!controller || !(controller->getIdentifier()->getName() == "DivisionController") || !(controller->getControllableEntity())) 237 214 continue; 238 215 //same team? 239 if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()))216 if ((this->getControllableEntity()->getTeam() != controller->getControllableEntity()->getTeam())) 240 217 continue; 241 218 242 219 //is equal to this? 243 if (orxonox_cast<ControllableEntity*>( *it) == this->getControllableEntity())220 if (orxonox_cast<ControllableEntity*>(controller) == this->getControllableEntity()) 244 221 continue; 245 222 246 float distance = CommonController::distance ( it->getControllableEntity(), this->getControllableEntity());223 float distance = CommonController::distance (controller->getControllableEntity(), this->getControllableEntity()); 247 224 248 if (distance < minDistance && !( it->hasFollower()))249 { 250 closestLeader = *it;225 if (distance < minDistance && !(controller->hasFollower())) 226 { 227 closestLeader = controller; 251 228 minDistance = distance; 252 229 } … … 258 235 return closestLeader; 259 236 } 260 return 0;237 return nullptr; 261 238 } 262 239 -
code/trunk/src/orxonox/controllers/SectionController.h
r11052 r11071 49 49 //----[/language demanded functions]---- 50 50 51 //----[orxonox demanded functions]----52 virtual void tick(float dt);53 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);55 //----[/orxonox demanded functions]----56 57 51 //----[own functions]---- 58 52 ActionpointController* findNewDivisionLeader(); 59 53 60 virtual bool setWingman(ActionpointController* newWingman) ;61 virtual bool hasWingman() ;62 virtual bool hasFollower() 54 virtual bool setWingman(ActionpointController* newWingman) override; 55 virtual bool hasWingman() override; 56 virtual bool hasFollower() override 63 57 { return false; } 64 58 void chooseTarget(); … … 67 61 protected: 68 62 //----action must only be managed by this---- 69 virtual void action() ; //<! action() is called in regular intervals by MasterController managing the bot's behaviour.63 virtual void action() override; //<! action() is called in regular intervals by MasterController managing the bot's behaviour. 70 64 Vector3 getFormationPosition (); 71 65 void keepFormation(); -
code/trunk/src/orxonox/controllers/WaypointController.cc
r9667 r11071 44 44 WaypointController::~WaypointController() 45 45 { 46 for ( size_t i = 0; i < this->waypoints_.size(); ++i)46 for (WorldEntity* waypoint : this->waypoints_) 47 47 { 48 if( this->waypoints_[i])49 this->waypoints_[i]->destroy();48 if(waypoint) 49 waypoint->destroy(); 50 50 } 51 51 } -
code/trunk/src/orxonox/controllers/WaypointController.h
r9667 r11071 44 44 virtual ~WaypointController(); 45 45 46 virtual void tick(float dt) ;46 virtual void tick(float dt) override; 47 47 48 48 protected: -
code/trunk/src/orxonox/controllers/WaypointPatrolController.cc
r9716 r11071 87 87 float shortestsqdistance = (float)static_cast<unsigned int>(-1); 88 88 89 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)89 for (Pawn* pawn : ObjectList<Pawn>()) 90 90 { 91 if (ArtificialController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>( *it), this->getGametype()))91 if (ArtificialController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), this->getGametype())) 92 92 continue; 93 93 94 float sqdistance = it->getPosition().squaredDistance(myposition);94 float sqdistance = pawn->getPosition().squaredDistance(myposition); 95 95 if (sqdistance < shortestsqdistance) 96 96 { 97 97 shortestsqdistance = sqdistance; 98 this->target_ = (*it);98 this->target_ = pawn; 99 99 } 100 100 } 101 101 102 102 if (shortestsqdistance > (this->alertnessradius_ * this->alertnessradius_)) 103 this->target_ = 0;103 this->target_ = nullptr; 104 104 } 105 105 } -
code/trunk/src/orxonox/controllers/WaypointPatrolController.h
r9716 r11071 43 43 virtual ~WaypointPatrolController() {} 44 44 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;46 virtual void tick(float dt) ;45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 46 virtual void tick(float dt) override; 47 47 48 48 inline void setAlertnessRadius(float radius) -
code/trunk/src/orxonox/controllers/WingmanController.cc
r11052 r11071 39 39 { 40 40 RegisterObject(WingmanController); 41 this->myLeader_ = 0;41 this->myLeader_ = nullptr; 42 42 this->bFirstAction_ = true; 43 43 … … 46 46 WingmanController::~WingmanController() 47 47 { 48 for ( size_t i = 0; i < this->actionpoints_.size(); ++i)48 for (WorldEntity* actionpoint : this->actionpoints_) 49 49 { 50 if (this->actionpoints_[i])51 this->actionpoints_[i]->destroy();50 if (actionpoint) 51 actionpoint->destroy(); 52 52 } 53 53 this->parsedActionpoints_.clear(); 54 54 this->actionpoints_.clear(); 55 }56 57 void WingmanController::XMLPort(Element& xmlelement, XMLPort::Mode mode)58 {59 SUPER(WingmanController, XMLPort, xmlelement, mode);60 }61 62 //----in tick, move (or look) and shoot----63 void WingmanController::tick(float dt)64 {65 if (!this->isActive())66 return;67 68 SUPER(WingmanController, tick, dt);69 70 55 } 71 56 … … 122 107 Vector3 WingmanController::getFormationPosition () 123 108 { 124 125 126 109 this->setFormationMode( this->myLeader_->getFormationMode() ); 127 Vector3* targetRelativePosition;128 110 this->spread_ = this->myLeader_->getSpread(); 129 111 if (this->myLeader_->getIdentifier()->getName() == "DivisionController") … … 131 113 switch (this->formationMode_){ 132 114 case FormationMode::WALL: 133 { 134 targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_); 135 break; 136 } 115 return Vector3 (2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_); 137 116 case FormationMode::FINGER4: 138 { 139 targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_); 140 break; 141 } 117 return Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_); 142 118 case FormationMode::DIAMOND: 143 { 144 targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_); 145 break; 146 } 119 return Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_); 120 default: 121 return Vector3::ZERO; 147 122 } 148 123 } … … 151 126 switch (this->formationMode_){ 152 127 case FormationMode::WALL: 153 { 154 targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_); 155 break; 156 } 128 return Vector3 (-2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_); 157 129 case FormationMode::FINGER4: 158 { 159 targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_); 160 break; 161 } 130 return Vector3 (-2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_); 162 131 case FormationMode::DIAMOND: 163 { 164 targetRelativePosition = new Vector3 (2.0f*this->spread_, -1.0f*this->spread_, 0 - 1.0f*this->tolerance_); 165 break; 166 } 132 return Vector3 (2.0f*this->spread_, -1.0f*this->spread_, 0 - 1.0f*this->tolerance_); 133 default: 134 return Vector3::ZERO; 167 135 } 168 136 } 169 Vector3 result = *targetRelativePosition;170 delete targetRelativePosition;171 return result;172 137 } 173 138 void WingmanController::keepFormation() … … 185 150 186 151 if (!this->getControllableEntity()) 187 return 0;152 return nullptr; 188 153 189 154 //----vars for finding the closest leader---- 190 ActionpointController* closestLeader = 0;155 ActionpointController* closestLeader = nullptr; 191 156 float minDistance = std::numeric_limits<float>::infinity(); 192 157 Gametype* gt = this->getGametype(); 193 158 194 for ( ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)159 for (ActionpointController* controller : ObjectList<ActionpointController>()) 195 160 { 196 161 //----0ptr or not a leader or dead?---- 197 if (! it ||198 ( it->getIdentifier()->getName() != "SectionController" && it->getIdentifier()->getName() != "DivisionController") ||199 !( it->getControllableEntity()))162 if (!controller || 163 (controller->getIdentifier()->getName() != "SectionController" && controller->getIdentifier()->getName() != "DivisionController") || 164 !(controller->getControllableEntity())) 200 165 continue; 201 166 202 167 //----same team?---- 203 if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity(), gt) )168 if ( !CommonController::sameTeam (this->getControllableEntity(), controller->getControllableEntity(), gt) ) 204 169 continue; 205 170 206 171 //----check distance---- 207 float distance = CommonController::distance ( it->getControllableEntity(), this->getControllableEntity());208 if (distance < minDistance && !( it->hasWingman()))172 float distance = CommonController::distance (controller->getControllableEntity(), this->getControllableEntity()); 173 if (distance < minDistance && !(controller->hasWingman())) 209 174 { 210 closestLeader = *it;175 closestLeader = controller; 211 176 minDistance = distance; 212 177 } … … 222 187 } 223 188 } 224 return 0;189 return nullptr; 225 190 } 226 191 -
code/trunk/src/orxonox/controllers/WingmanController.h
r11052 r11071 51 51 52 52 //----[orxonox demanded functions]---- 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 55 virtual void tick(float dt); 56 virtual bool hasWingman() 53 virtual bool hasWingman() override 57 54 { return false; } 58 virtual bool hasFollower() 55 virtual bool hasFollower() override 59 56 { return false; } 60 57 //----[/orxonox demanded functions]---- … … 66 63 protected: 67 64 //----action must only be managed by this---- 68 virtual void action() ; //<! action() is called in regular intervals managing the bot's behaviour.65 virtual void action() override; //<! action() is called in regular intervals managing the bot's behaviour. 69 66 Vector3 getFormationPosition (); 70 67 void keepFormation(); -
code/trunk/src/orxonox/gamestates/GSClient.h
r7163 r11071 43 43 ~GSClient(); 44 44 45 v oid activate();46 v oid deactivate();47 v oid update(const Clock& time);45 virtual void activate() override; 46 virtual void deactivate() override; 47 virtual void update(const Clock& time) override; 48 48 }; 49 49 } -
code/trunk/src/orxonox/gamestates/GSGraphics.h
r6417 r11071 53 53 ~GSGraphics(); 54 54 55 v oid activate();56 v oid deactivate();57 v oid update(const Clock& time);55 virtual void activate() override; 56 virtual void deactivate() override; 57 virtual void update(const Clock& time) override; 58 58 59 59 private: -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r10624 r11071 65 65 GSLevel::GSLevel(const GameStateInfo& info) 66 66 : GameState(info) 67 , gameInputState_( 0)68 , guiMouseOnlyInputState_( 0)69 , guiKeysOnlyInputState_( 0)70 , startFile_( 0)67 , gameInputState_(nullptr) 68 , guiMouseOnlyInputState_(nullptr) 69 , guiKeysOnlyInputState_(nullptr) 70 , startFile_(nullptr) 71 71 , bShowIngameGUI_(false) 72 72 { … … 143 143 #endif 144 144 145 gameInputState_->setHandler( 0);146 guiMouseOnlyInputState_->setHandler( 0);147 guiKeysOnlyInputState_->setHandler( 0);145 gameInputState_->setHandler(nullptr); 146 guiMouseOnlyInputState_->setHandler(nullptr); 147 guiKeysOnlyInputState_->setHandler(nullptr); 148 148 InputManager::getInstance().destroyState("game"); 149 149 InputManager::getInstance().destroyState("guiKeysOnly"); … … 156 156 { 157 157 ModifyConsoleCommand(__CC_changeGame_name).deactivate(); 158 ModifyConsoleCommand(__CC_reloadLevel_name).setObject( NULL).deactivate();158 ModifyConsoleCommand(__CC_reloadLevel_name).setObject(nullptr).deactivate(); 159 159 } 160 160 } … … 164 164 // Note: Temporarily moved to GSRoot. 165 165 //// Call the scene objects 166 //for ( ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)167 // it->tick(time.getDeltaTime() * this->timeFactor_);166 //for (Tickable* tickable : ObjectList<Tickable>()) 167 // tickable->tick(time.getDeltaTime() * this->timeFactor_); 168 168 } 169 169 170 170 void GSLevel::prepareObjectTracking() 171 171 { 172 for ( ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)173 this->staticObjects_.insert( *it);172 for (BaseObject* baseObject : ObjectList<BaseObject>()) 173 this->staticObjects_.insert(baseObject); 174 174 } 175 175 … … 178 178 orxout(internal_info) << "Remaining objects:" << endl; 179 179 unsigned int i = 0; 180 for ( ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)181 { 182 std::set<BaseObject*>::const_iterator find = this->staticObjects_.find( *it);180 for (BaseObject* baseObject : ObjectList<BaseObject>()) 181 { 182 std::set<BaseObject*>::const_iterator find = this->staticObjects_.find(baseObject); 183 183 if (find == this->staticObjects_.end()) 184 184 { 185 orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;185 orxout(internal_warning) << ++i << ": " << baseObject->getIdentifier()->getName() << " (" << baseObject << "), references: " << baseObject->getReferenceCount() << endl; 186 186 } 187 187 } … … 215 215 void GSLevel::unloadLevelAsClient() 216 216 { 217 for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); ) 217 ObjectList<Level> listLevel; 218 for (ObjectList<Level>::iterator it = listLevel.begin(); it != listLevel.end(); ) 218 219 { 219 220 StrongPtr<Level> level = *(it++); // StrongPtr prevents that the Level gets destroyed while we loop over it 220 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(level); it != ObjectList<BaseObject>::end(level); ) 221 ObjectList<BaseObject> listBaseObject(level); 222 for (ObjectList<BaseObject>::iterator it = listBaseObject.begin(); it != listBaseObject.end(); ) 221 223 (it++)->destroy(); 222 224 } 223 225 224 for (ObjectList<Synchronisable>::iterator it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ) 226 ObjectList<Synchronisable> listSynchronisable; 227 for (ObjectList<Synchronisable>::iterator it = listSynchronisable.begin(); it != listSynchronisable.end(); ) 225 228 { 226 229 if (it->getSyncMode() != 0x0) … … 235 238 // export all states 236 239 std::vector<GSLevelMementoState*> states; 237 for ( ObjectList<GSLevelMemento>::iterator it = ObjectList<GSLevelMemento>::begin(); it != ObjectList<GSLevelMemento>::end(); ++it)238 { 239 GSLevelMementoState* state = it->exportMementoState();240 for (GSLevelMemento* memento : ObjectList<GSLevelMemento>()) 241 { 242 GSLevelMementoState* state = memento->exportMementoState(); 240 243 if (state) 241 244 states.push_back(state); … … 247 250 248 251 // import all states 249 for ( ObjectList<GSLevelMemento>::iterator it = ObjectList<GSLevelMemento>::begin(); it != ObjectList<GSLevelMemento>::end(); ++it)250 it->importMementoState(states);252 for (GSLevelMemento* memento : ObjectList<GSLevelMemento>()) 253 memento->importMementoState(states); 251 254 252 255 // delete states 253 for ( size_t i = 0; i < states.size(); ++i)254 delete state s[i];256 for (GSLevelMementoState* state : states) 257 delete state; 255 258 } 256 259 -
code/trunk/src/orxonox/gamestates/GSLevel.h
r10624 r11071 44 44 ~GSLevel(); 45 45 46 v oid activate();47 v oid deactivate();48 v oid update(const Clock& time);46 virtual void activate() override; 47 virtual void deactivate() override; 48 virtual void update(const Clock& time) override; 49 49 50 50 static void startMainMenu(void); //!< Starts the MainMenu -
code/trunk/src/orxonox/gamestates/GSLevelMemento.h
r10281 r11071 48 48 protected: 49 49 /** 50 * Returns the state of this memento. Returns NULLif no state needed to persist.50 * Returns the state of this memento. Returns nullptr if no state needed to persist. 51 51 */ 52 52 virtual GSLevelMementoState* exportMementoState() = 0; -
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
r10624 r11071 73 73 74 74 // create an empty Scene 75 this->scene_ = new Scene( NULL);75 this->scene_ = new Scene(nullptr); 76 76 this->scene_->setSyncMode( 0x0 ); 77 77 // and a Camera … … 132 132 InputManager::getInstance().leaveState("MainMenuHackery"); 133 133 134 GraphicsManager::getInstance().setCamera( 0);134 GraphicsManager::getInstance().setCamera(nullptr); 135 135 GUIManager::getInstance().setBackgroundImage(""); 136 136 GUIManager::hideGUI("MainMenu"); … … 140 140 ModifyConsoleCommand(__CC_startClient_name ).deactivate(); 141 141 ModifyConsoleCommand(__CC_startDedicated_name ).deactivate(); 142 ModifyConsoleCommand(__CC_setMainMenuSoundPath_name).setObject( 0);142 ModifyConsoleCommand(__CC_setMainMenuSoundPath_name).setObject(nullptr); 143 143 } 144 144 -
code/trunk/src/orxonox/gamestates/GSMainMenu.h
r9667 r11071 44 44 ~GSMainMenu(); 45 45 46 v oid activate();47 v oid deactivate();48 v oid update(const Clock& time);46 virtual void activate() override; 47 virtual void deactivate() override; 48 virtual void update(const Clock& time) override; 49 49 50 50 void setConfigValues(); -
code/trunk/src/orxonox/gamestates/GSMasterServer.h
r7801 r11071 45 45 ~GSMasterServer(); 46 46 47 v oid activate();48 v oid deactivate();49 v oid update(const Clock& time);47 virtual void activate() override; 48 virtual void deactivate() override; 49 virtual void update(const Clock& time) override; 50 50 51 51 private: -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r10624 r11071 34 34 #include "core/GameMode.h" 35 35 #include "core/command/ConsoleCommandIncludes.h" 36 #include "core/object/ObjectList.h" 36 37 #include "network/NetworkFunctionIncludes.h" 37 38 #include "tools/Timer.h" … … 73 74 { 74 75 unsigned int nr=0; 75 for ( ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it)76 { 77 Synchronisable* synchronisable = orxonox_cast<Synchronisable*>( *it);76 for (BaseObject* baseObject : ObjectList<BaseObject>()) 77 { 78 Synchronisable* synchronisable = orxonox_cast<Synchronisable*>(baseObject); 78 79 if (synchronisable) 79 orxout(debug_output) << "object: " << it->getIdentifier()->getName() << " id: " << synchronisable->getObjectID() << endl;80 orxout(debug_output) << "object: " << baseObject->getIdentifier()->getName() << " id: " << synchronisable->getObjectID() << endl; 80 81 else 81 orxout(debug_output) << "object: " << it->getIdentifier()->getName() << endl;82 orxout(debug_output) << "object: " << baseObject->getIdentifier()->getName() << endl; 82 83 nr++; 83 84 } … … 98 99 void GSRoot::deactivate() 99 100 { 100 ModifyConsoleCommand(__CC_setTimeFactor_name).setObject( 0);101 ModifyConsoleCommand(__CC_getTimeFactor_name).setObject( 0);102 ModifyConsoleCommand(__CC_setPause_name).setObject( 0);103 ModifyConsoleCommand(__CC_pause_name).setObject( 0);101 ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(nullptr); 102 ModifyConsoleCommand(__CC_getTimeFactor_name).setObject(nullptr); 103 ModifyConsoleCommand(__CC_setPause_name).setObject(nullptr); 104 ModifyConsoleCommand(__CC_pause_name).setObject(nullptr); 104 105 } 105 106 … … 112 113 } 113 114 114 for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; ) 115 ObjectList<Timer> listTimer; 116 for (ObjectList<Timer>::iterator it = listTimer.begin(); it; ) 115 117 { 116 118 Timer* object = *it; … … 128 130 } 129 131 float realdt = leveldt * TimeFactorListener::getTimeFactor(); 130 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ) 132 ObjectList<Tickable> listTickable; 133 for (ObjectList<Tickable>::iterator it = listTickable.begin(); it; ) 131 134 { 132 135 Tickable* object = *it; -
code/trunk/src/orxonox/gamestates/GSRoot.h
r8706 r11071 44 44 static void printObjects(); 45 45 46 v oid activate();47 v oid deactivate();48 v oid update(const Clock& time);46 virtual void activate() override; 47 virtual void deactivate() override; 48 virtual void update(const Clock& time) override; 49 49 50 50 // this has to be public because proteced triggers a bug in msvc … … 59 59 60 60 protected: 61 virtual void changedTimeFactor(float factor_new, float factor_old) ;61 virtual void changedTimeFactor(float factor_new, float factor_old) override; 62 62 63 63 private: -
code/trunk/src/orxonox/gamestates/GSServer.cc
r10624 r11071 44 44 GSServer::GSServer(const GameStateInfo& info) 45 45 : GameState(info) 46 , server_( 0)46 , server_(nullptr) 47 47 { 48 48 } -
code/trunk/src/orxonox/gamestates/GSServer.h
r5929 r11071 43 43 ~GSServer(); 44 44 45 v oid activate();46 v oid deactivate();47 v oid update(const Clock& time);45 virtual void activate() override; 46 virtual void deactivate() override; 47 virtual void update(const Clock& time) override; 48 48 49 49 private: -
code/trunk/src/orxonox/gamestates/GSStandalone.h
r5929 r11071 41 41 ~GSStandalone(); 42 42 43 v oid activate();44 v oid deactivate();45 v oid update(const Clock& time);43 virtual void activate() override; 44 virtual void deactivate() override; 45 virtual void update(const Clock& time) override; 46 46 47 47 private: -
code/trunk/src/orxonox/gametypes/Asteroids.h
r9667 r11071 41 41 virtual ~Asteroids() {} 42 42 43 virtual void tick(float dt) ;43 virtual void tick(float dt) override; 44 44 45 virtual void start() ;46 virtual void end() ;45 virtual void start() override; 46 virtual void end() override; 47 47 48 48 inline void firstCheckpointReached(bool reached) … … 50 50 51 51 protected: 52 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);52 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override; 53 53 54 54 private: -
code/trunk/src/orxonox/gametypes/Deathmatch.h
r9667 r11071 41 41 virtual ~Deathmatch() {} 42 42 43 virtual void start() ;44 virtual void end() ;45 virtual void playerEntered(PlayerInfo* player) ;46 virtual bool playerLeft(PlayerInfo* player) ;47 virtual bool playerChangedName(PlayerInfo* player) ;43 virtual void start() override; 44 virtual void end() override; 45 virtual void playerEntered(PlayerInfo* player) override; 46 virtual bool playerLeft(PlayerInfo* player) override; 47 virtual bool playerChangedName(PlayerInfo* player) override; 48 48 49 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);50 virtual void playerScored(PlayerInfo* player, int score = 1) ;49 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override; 50 virtual void playerScored(PlayerInfo* player, int score = 1) override; 51 51 }; 52 52 } -
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
r11052 r11071 88 88 Dynamicmatch::~Dynamicmatch() 89 89 { 90 for ( std::set<Timer*>::iterator it = this->piggyTimers_.begin(); it != this->piggyTimers_.end(); ++it)91 delete (*it);90 for (Timer* timer : this->piggyTimers_) 91 delete timer; 92 92 } 93 93 … … 413 413 void Dynamicmatch::rewardPig() 414 414 { 415 for ( std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden416 { 417 if ( it->second==piggy)//Spieler mit der Pig-party frags++418 { 419 this->playerScored( it->first);415 for (const auto& mapEntry : this->playerParty_) //durch alle Spieler iterieren und alle piggys finden 416 { 417 if (mapEntry.second==piggy)//Spieler mit der Pig-party frags++ 418 { 419 this->playerScored(mapEntry.first); 420 420 } 421 421 } … … 430 430 431 431 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); 432 for ( std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)433 { 434 if ( (*it)->isA(Class(TeamColourable)))432 for (WorldEntity* pawnAttachment : pawnAttachments) 433 { 434 if (pawnAttachment->isA(Class(TeamColourable))) 435 435 { 436 TeamColourable* tc = orxonox_cast<TeamColourable*>( *it);436 TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment); 437 437 tc->setTeamColour(this->partyColours_[it_player->second]); 438 438 } … … 449 449 if (tutorial) // Announce selectionphase 450 450 { 451 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)452 { 453 if (! it->first)//in order to catch nullpointer451 for (const auto& mapEntry : this->playerParty_) 452 { 453 if (!mapEntry.first)//in order to catch nullpointer 454 454 continue; 455 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)455 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 456 456 continue; 457 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));457 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 458 458 } 459 459 } … … 464 464 if(tutorial&&(!notEnoughKillers)&&(!notEnoughChasers)) //Selection phase over 465 465 { 466 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)466 for (const auto& mapEntry : this->playerParty_) 467 467 { 468 if (! it->first)//in order to catch nullpointer468 if (!mapEntry.first)//in order to catch nullpointer 469 469 continue; 470 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)470 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 471 471 continue; 472 else if ( it->second==chaser)472 else if (mapEntry.second==chaser) 473 473 { 474 474 if (numberOf[killer]>0) 475 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);475 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 476 476 else 477 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);477 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 478 478 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 479 479 } 480 else if ( it->second==piggy)481 { 482 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[chaser]);480 else if (mapEntry.second==piggy) 481 { 482 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[chaser]); 483 483 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 484 484 } 485 else if ( it->second==killer)486 { 487 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[chaser]);485 else if (mapEntry.second==killer) 486 { 487 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.first->getClientID(),partyColours_[chaser]); 488 488 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 489 489 } … … 498 498 if (tutorial) // Announce selectionphase 499 499 { 500 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)501 { 502 if (! it->first)//in order to catch nullpointer500 for (const auto& mapEntry : this->playerParty_) 501 { 502 if (!mapEntry.first)//in order to catch nullpointer 503 503 continue; 504 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)504 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 505 505 continue; 506 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));506 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 507 507 } 508 508 } … … 513 513 if(tutorial&&(!notEnoughPigs)&&(!notEnoughChasers)) //Selection phase over 514 514 { 515 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)515 for (const auto& mapEntry : this->playerParty_) 516 516 { 517 if (! it->first)517 if (!mapEntry.first) 518 518 continue; 519 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)519 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 520 520 continue; 521 else if ( it->second==chaser)521 else if (mapEntry.second==chaser) 522 522 { 523 523 if (numberOf[killer]>0) 524 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);524 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 525 525 else 526 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);526 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 527 527 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 528 528 } 529 else if ( it->second==piggy)530 { 531 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[piggy]);529 else if (mapEntry.second==piggy) 530 { 531 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[piggy]); 532 532 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 533 533 } 534 else if ( it->second==killer)535 { 536 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[piggy]);534 else if (mapEntry.second==killer) 535 { 536 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.first->getClientID(),partyColours_[piggy]); 537 537 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 538 538 } … … 548 548 if (tutorial) // Announce selectionphase 549 549 { 550 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)551 { 552 if (! it->first)//in order to catch nullpointer550 for (const auto& mapEntry : this->playerParty_) 551 { 552 if (!mapEntry.first)//in order to catch nullpointer 553 553 continue; 554 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)554 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 555 555 continue; 556 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));556 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 557 557 } 558 558 } … … 563 563 if(tutorial&&(!notEnoughPigs)&&(!notEnoughKillers)) //Selection phase over 564 564 { 565 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)565 for (const auto& mapEntry : this->playerParty_) 566 566 { 567 if (! it->first)567 if (!mapEntry.first) 568 568 continue; 569 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)569 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 570 570 continue; 571 else if ( it->second==chaser)571 else if (mapEntry.second==chaser) 572 572 { 573 573 if (numberOf[killer]>0) 574 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);574 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 575 575 else 576 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);576 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 577 577 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 578 578 } 579 else if ( it->second==piggy)580 { 581 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[chaser]);579 else if (mapEntry.second==piggy) 580 { 581 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[chaser]); 582 582 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 583 583 } 584 else if ( it->second==killer)585 { 586 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[chaser]);584 else if (mapEntry.second==killer) 585 { 586 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.first->getClientID(),partyColours_[chaser]); 587 587 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 588 588 } … … 631 631 else if(tutorial) // Announce selectionphase 632 632 { 633 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)634 { 635 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)633 for (const auto& mapEntry : this->playerParty_) 634 { 635 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 636 636 continue; 637 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));637 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 638 638 } 639 639 } … … 687 687 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size()))); 688 688 unsigned int index = 0; 689 for ( std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)689 for (SpawnPoint* teamSpawnPoint : teamSpawnPoints) 690 690 { 691 691 if (index == randomspawn) 692 return (*it);692 return teamSpawnPoint; 693 693 694 694 ++index; … … 696 696 } 697 697 698 return 0;698 return nullptr; 699 699 } 700 700 -
code/trunk/src/orxonox/gametypes/Dynamicmatch.h
r11052 r11071 65 65 bool tutorial; //goal: new players receive messages how the new gametype works - later it can be switched off. 66 66 67 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //ok - score function and management of parties68 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //ok - simple69 virtual void start() ;70 virtual void end() ; //Wie geht das mit der Punkteausgabe aendern? Z.B: Persoenliche Nachricht?71 virtual void playerEntered(PlayerInfo* player) ;72 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) ;//is used to initialize the player's party and colour73 virtual bool playerLeft(PlayerInfo* player) ;74 virtual bool playerChangedName(PlayerInfo* player) ;//unchanged67 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; //ok - score function and management of parties 68 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; //ok - simple 69 virtual void start() override; 70 virtual void end() override; //Wie geht das mit der Punkteausgabe aendern? Z.B: Persoenliche Nachricht? 71 virtual void playerEntered(PlayerInfo* player) override; 72 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override;//is used to initialize the player's party and colour 73 virtual bool playerLeft(PlayerInfo* player) override; 74 virtual bool playerChangedName(PlayerInfo* player) override;//unchanged 75 75 76 76 /*virtual void instructions(); … … 79 79 void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost. 80 80 void resetSpeedFactor(SpaceShip* spaceship, Timer* timer); 81 v oid tick (float dt);// used to end the game82 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;81 virtual void tick (float dt) override;// used to end the game 82 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const override; 83 83 84 84 -
code/trunk/src/orxonox/gametypes/Gametype.cc
r10624 r11071 66 66 67 67 this->defaultControllableEntity_ = Class(Spectator); 68 this->scoreboard_ = 0;68 this->scoreboard_ = nullptr; 69 69 70 70 this->bAutoStart_ = false; … … 92 92 this->gtinfo_->destroy(); 93 93 94 ModifyConsoleCommand(__CC_addBots_name).setObject( NULL);95 ModifyConsoleCommand(__CC_killBots_name).setObject( NULL);94 ModifyConsoleCommand(__CC_addBots_name).setObject(nullptr); 95 ModifyConsoleCommand(__CC_killBots_name).setObject(nullptr); 96 96 } 97 97 } … … 139 139 if (!this->gtinfo_->hasStarted()) 140 140 { 141 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)141 for (const auto& mapEntry : this->players_) 142 142 { 143 143 // Inform the GametypeInfo that the player is ready to spawn. 144 if( it->first->isHumanPlayer() && it->first->isReadyToSpawn())145 this->gtinfo_->playerReadyToSpawn( it->first);144 if(mapEntry.first->isHumanPlayer() && mapEntry.first->isReadyToSpawn()) 145 this->gtinfo_->playerReadyToSpawn(mapEntry.first); 146 146 } 147 147 … … 169 169 } 170 170 171 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)172 { 173 if ( it->first->getControllableEntity())174 { 175 ControllableEntity* oldentity = it->first->getControllableEntity();171 for (const auto& mapEntry : this->players_) 172 { 173 if (mapEntry.first->getControllableEntity()) 174 { 175 ControllableEntity* oldentity = mapEntry.first->getControllableEntity(); 176 176 177 177 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getContext()); … … 186 186 entity->setOrientation(oldentity->getWorldOrientation()); 187 187 } 188 it->first->startControl(entity);188 mapEntry.first->startControl(entity); 189 189 } 190 190 else 191 this->spawnPlayerAsDefaultPawn( it->first);191 this->spawnPlayerAsDefaultPawn(mapEntry.first); 192 192 } 193 193 } … … 337 337 { 338 338 // Fallback spawn point if there is no active one, choose a random one. 339 SpawnPoint* fallbackSpawnPoint = NULL;339 SpawnPoint* fallbackSpawnPoint = nullptr; 340 340 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 341 341 unsigned int index = 0; 342 342 std::vector<SpawnPoint*> activeSpawnPoints; 343 for ( std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)343 for (SpawnPoint* spawnpoint : this->spawnpoints_) 344 344 { 345 345 if (index == randomspawn) 346 fallbackSpawnPoint = (*it);347 348 if ( *it != NULL && (*it)->isActive())349 activeSpawnPoints.push_back( *it);346 fallbackSpawnPoint = spawnpoint; 347 348 if (spawnpoint != nullptr && spawnpoint->isActive()) 349 activeSpawnPoints.push_back(spawnpoint); 350 350 351 351 ++index; … … 361 361 return fallbackSpawnPoint; 362 362 } 363 return 0;363 return nullptr; 364 364 } 365 365 366 366 void Gametype::assignDefaultPawnsIfNeeded() 367 367 { 368 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)369 { 370 if (! it->first->getControllableEntity())371 { 372 it->second.state_ = PlayerState::Dead;373 374 if (! it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted())375 { 376 this->spawnPlayerAsDefaultPawn( it->first);377 it->second.state_ = PlayerState::Dead;368 for (auto& mapEntry : this->players_) 369 { 370 if (!mapEntry.first->getControllableEntity()) 371 { 372 mapEntry.second.state_ = PlayerState::Dead; 373 374 if (!mapEntry.first->isReadyToSpawn() || !this->gtinfo_->hasStarted()) 375 { 376 this->spawnPlayerAsDefaultPawn(mapEntry.first); 377 mapEntry.second.state_ = PlayerState::Dead; 378 378 } 379 379 } … … 404 404 bool allplayersready = true; 405 405 bool hashumanplayers = false; 406 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)406 for (const auto& mapEntry : this->players_) 407 407 { 408 if (! it->first->isReadyToSpawn())408 if (!mapEntry.first->isReadyToSpawn()) 409 409 allplayersready = false; 410 if ( it->first->isHumanPlayer())410 if (mapEntry.first->isHumanPlayer()) 411 411 hashumanplayers = true; 412 412 } … … 430 430 void Gametype::spawnPlayersIfRequested() 431 431 { 432 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)433 { 434 if ( it->first->isReadyToSpawn() || this->bForceSpawn_)435 this->spawnPlayer( it->first);432 for (const auto& mapEntry : this->players_) 433 { 434 if (mapEntry.first->isReadyToSpawn() || this->bForceSpawn_) 435 this->spawnPlayer(mapEntry.first); 436 436 } 437 437 } … … 439 439 void Gametype::spawnDeadPlayersIfRequested() 440 440 { 441 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)442 if ( it->second.state_ == PlayerState::Dead)443 if ( it->first->isReadyToSpawn() || this->bForceSpawn_)444 this->spawnPlayer( it->first);441 for (const auto& mapEntry : this->players_) 442 if (mapEntry.second.state_ == PlayerState::Dead) 443 if (mapEntry.first->isReadyToSpawn() || this->bForceSpawn_) 444 this->spawnPlayer(mapEntry.first); 445 445 } 446 446 … … 492 492 { 493 493 unsigned int i = 0; 494 for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); ) 494 ObjectList<Bot> list; 495 for (ObjectList<Bot>::iterator it = list.begin(); (it != list.end()) && ((amount == 0) || (i < amount)); ) 495 496 { 496 497 if (it->getGametype() == this) … … 538 539 GSLevelMementoState* Gametype::exportMementoState() 539 540 { 540 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)541 { 542 if ( it->first->isHumanPlayer() && it->first->getControllableEntity() && it->first->getControllableEntity()->getCamera())543 { 544 Camera* camera = it->first->getControllableEntity()->getCamera();541 for (const auto& mapEntry : this->players_) 542 { 543 if (mapEntry.first->isHumanPlayer() && mapEntry.first->getControllableEntity() && mapEntry.first->getControllableEntity()->getCamera()) 544 { 545 Camera* camera = mapEntry.first->getControllableEntity()->getCamera(); 545 546 546 547 GametypeMementoState* state = new GametypeMementoState(); … … 552 553 } 553 554 554 return NULL;555 return nullptr; 555 556 } 556 557 … … 558 559 { 559 560 // find correct memento state 560 GametypeMementoState* state = NULL;561 for ( size_t i = 0; i < states.size(); ++i)562 { 563 state = dynamic_cast<GametypeMementoState*>( states[i]);561 GametypeMementoState* state = nullptr; 562 for (GSLevelMementoState* temp : states) 563 { 564 state = dynamic_cast<GametypeMementoState*>(temp); 564 565 if (state) 565 566 break; … … 570 571 571 572 // find correct scene 572 Scene* scene = NULL;573 for ( ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); it != ObjectList<Scene>::end(); ++it)574 { 575 if ( it->getName() == state->sceneName_)576 { 577 scene = *it;573 Scene* scene = nullptr; 574 for (Scene* someScene : ObjectList<Scene>()) 575 { 576 if (someScene->getName() == state->sceneName_) 577 { 578 scene = someScene; 578 579 break; 579 580 } … … 587 588 588 589 // find correct player and assign default entity with original position & orientation 589 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)590 { 591 if ( it->first->isHumanPlayer())590 for (const auto& mapEntry : this->players_) 591 { 592 if (mapEntry.first->isHumanPlayer()) 592 593 { 593 594 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(scene->getContext()); 594 595 entity->setPosition(state->cameraPosition_); 595 596 entity->setOrientation(state->cameraOrientation_); 596 it->first->startControl(entity);597 mapEntry.first->startControl(entity); 597 598 break; 598 599 } -
code/trunk/src/orxonox/gametypes/Gametype.h
r10624 r11071 45 45 namespace orxonox 46 46 { 47 namespace PlayerState 48 { 49 enum Value 50 { 51 Uninitialized, 52 Joined, 53 Alive, 54 Dead 55 }; 56 } 47 enum class PlayerState 48 { 49 Uninitialized, 50 Joined, 51 Alive, 52 Dead 53 }; 57 54 58 55 struct Player 59 56 { 60 57 PlayerInfo* info_; 61 PlayerState ::Valuestate_;58 PlayerState state_; 62 59 int frags_; 63 60 int killed_; … … 76 73 void setConfigValues(); 77 74 78 virtual void tick(float dt) ;75 virtual void tick(float dt) override; 79 76 80 77 inline const GametypeInfo* getGametypeInfo() const … … 96 93 virtual void playerScored(PlayerInfo* player, int score = 1); 97 94 98 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);99 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);100 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);101 102 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);95 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = nullptr); 96 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr); 97 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr); 98 99 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr); 103 100 virtual void pawnPreSpawn(Pawn* pawn); 104 101 virtual void pawnPostSpawn(Pawn* pawn); … … 175 172 virtual void spawnDeadPlayersIfRequested(); 176 173 177 virtual GSLevelMementoState* exportMementoState() ;178 virtual void importMementoState(const std::vector<GSLevelMementoState*>& states) ;174 virtual GSLevelMementoState* exportMementoState() override; 175 virtual void importMementoState(const std::vector<GSLevelMementoState*>& states) override; 179 176 180 177 WeakPtr<GametypeInfo> gtinfo_; -
code/trunk/src/orxonox/gametypes/LastManStanding.cc
r9667 r11071 56 56 void LastManStanding::spawnDeadPlayersIfRequested() 57 57 { 58 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)59 if ( it->second.state_ == PlayerState::Dead)60 { 61 bool alive = (0<playerLives_[ it->first]&&(inGame_[it->first]));62 if (alive&&( it->first->isReadyToSpawn() || this->bForceSpawn_))63 { 64 this->spawnPlayer( it->first);58 for (const auto& mapEntry : this->players_) 59 if (mapEntry.second.state_ == PlayerState::Dead) 60 { 61 bool alive = (0<playerLives_[mapEntry.first]&&(inGame_[mapEntry.first])); 62 if (alive&&(mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 63 { 64 this->spawnPlayer(mapEntry.first); 65 65 } 66 66 } … … 114 114 { 115 115 int min=lives; 116 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)117 { 118 if ( it->second<=0)116 for (const auto& mapEntry : this->playerLives_) 117 { 118 if (mapEntry.second<=0) 119 119 continue; 120 if ( it->second<lives)121 min= it->second;120 if (mapEntry.second<lives) 121 min=mapEntry.second; 122 122 } 123 123 return min; … … 128 128 Gametype::end(); 129 129 130 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)131 { 132 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)130 for (const auto& mapEntry : this->playerLives_) 131 { 132 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 133 133 continue; 134 134 135 if ( it->second > 0)136 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());135 if (mapEntry.second > 0) 136 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 137 137 else 138 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());138 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 139 139 } 140 140 } … … 237 237 this->end(); 238 238 } 239 for ( std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)240 { 241 if (playerGetLives( it->first)<=0)//Players without lives shouldn't be affected by time.239 for (auto& mapEntry : this->timeToAct_) 240 { 241 if (playerGetLives(mapEntry.first)<=0)//Players without lives shouldn't be affected by time. 242 242 continue; 243 it->second-=dt;//Decreases punishment time.244 if (!inGame_[ it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.245 { 246 playerDelayTime_[ it->first]-=dt;247 if (playerDelayTime_[ it->first]<=0)248 this->inGame_[ it->first]=true;249 250 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)243 mapEntry.second-=dt;//Decreases punishment time. 244 if (!inGame_[mapEntry.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 245 { 246 playerDelayTime_[mapEntry.first]-=dt; 247 if (playerDelayTime_[mapEntry.first]<=0) 248 this->inGame_[mapEntry.first]=true; 249 250 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 251 251 continue; 252 int output=1+(int)playerDelayTime_[ it->first];252 int output=1+(int)playerDelayTime_[mapEntry.first]; 253 253 const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown 254 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());255 } 256 else if ( it->second<0.0f)257 { 258 it->second=timeRemaining+3.0f;//reset punishment-timer259 if (playerGetLives( it->first)>0)254 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 255 } 256 else if (mapEntry.second<0.0f) 257 { 258 mapEntry.second=timeRemaining+3.0f;//reset punishment-timer 259 if (playerGetLives(mapEntry.first)>0) 260 260 { 261 this->punishPlayer( it->first);262 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)261 this->punishPlayer(mapEntry.first); 262 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 263 263 return; 264 264 const std::string& message = ""; // resets Camper-Warning-message 265 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());265 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 266 266 } 267 267 } 268 else if ( it->second<timeRemaining/5)//Warning message269 { 270 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)268 else if (mapEntry.second<timeRemaining/5)//Warning message 269 { 270 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 271 271 continue; 272 272 const std::string& message = "Camper Warning! Don't forget to shoot."; 273 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());273 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 274 274 } 275 275 } -
code/trunk/src/orxonox/gametypes/LastManStanding.h
r9667 r11071 61 61 bool bHardPunishment; //!< Switches between damage and death as punishment. 62 62 float punishDamageRate; //!< Makes Damage adjustable. 63 virtual void spawnDeadPlayersIfRequested() ; //!< Prevents dead players to respawn.63 virtual void spawnDeadPlayersIfRequested() override; //!< Prevents dead players to respawn. 64 64 virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped; 65 65 … … 69 69 void setConfigValues(); //!< Makes values configurable. 70 70 71 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponent, his punishment countdown will be resetted.72 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each players lives.71 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; //!< If a player shoot's an opponent, his punishment countdown will be resetted. 72 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; //!< Manages each players lives. 73 73 74 virtual void end() ; //!< Sends an end message.74 virtual void end() override; //!< Sends an end message. 75 75 int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_". 76 76 int getNumPlayersAlive() const; //!< Returns the number of players that are still alive. 77 virtual void playerEntered(PlayerInfo* player) ; //!< Initializes values.78 virtual bool playerLeft(PlayerInfo* player) ; //!< Manages all local variables.79 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) ; //!< Resets punishment time and respawn delay.77 virtual void playerEntered(PlayerInfo* player) override; //!< Initializes values. 78 virtual bool playerLeft(PlayerInfo* player) override; //!< Manages all local variables. 79 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override; //!< Resets punishment time and respawn delay. 80 80 81 81 void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining". 82 v oid tick (float dt); //!< used to end the game82 virtual void tick (float dt) override; //!< used to end the game 83 83 }; 84 84 } -
code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
r9941 r11071 145 145 void LastTeamStanding::spawnDeadPlayersIfRequested() 146 146 { 147 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)148 if ( it->second.state_ == PlayerState::Dead)149 { 150 bool alive = (0 < playerLives_[ it->first]&&(inGame_[it->first]));151 if (alive&&( it->first->isReadyToSpawn() || this->bForceSpawn_))152 { 153 this->spawnPlayer( it->first);147 for (const auto& mapEntry : this->players_) 148 if (mapEntry.second.state_ == PlayerState::Dead) 149 { 150 bool alive = (0 < playerLives_[mapEntry.first]&&(inGame_[mapEntry.first])); 151 if (alive&&(mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 152 { 153 this->spawnPlayer(mapEntry.first); 154 154 } 155 155 } … … 184 184 this->end(); 185 185 } 186 for ( std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)187 { 188 if (playerGetLives( it->first) <= 0)//Players without lives shouldn't be affected by time.186 for (auto& mapEntry : this->timeToAct_) 187 { 188 if (playerGetLives(mapEntry.first) <= 0)//Players without lives shouldn't be affected by time. 189 189 continue; 190 it->second -= dt;//Decreases punishment time.191 if (!inGame_[ it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.192 { 193 playerDelayTime_[ it->first] -= dt;194 if (playerDelayTime_[ it->first] <= 0)195 this->inGame_[ it->first] = true;196 197 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)190 mapEntry.second -= dt;//Decreases punishment time. 191 if (!inGame_[mapEntry.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 192 { 193 playerDelayTime_[mapEntry.first] -= dt; 194 if (playerDelayTime_[mapEntry.first] <= 0) 195 this->inGame_[mapEntry.first] = true; 196 197 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 198 198 continue; 199 int output = 1 + (int)playerDelayTime_[ it->first];199 int output = 1 + (int)playerDelayTime_[mapEntry.first]; 200 200 const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown 201 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());202 } 203 else if ( it->second < 0.0f)204 { 205 it->second = timeRemaining + 3.0f;//reset punishment-timer206 if (playerGetLives( it->first) > 0)201 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 202 } 203 else if (mapEntry.second < 0.0f) 204 { 205 mapEntry.second = timeRemaining + 3.0f;//reset punishment-timer 206 if (playerGetLives(mapEntry.first) > 0) 207 207 { 208 this->punishPlayer( it->first);209 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)208 this->punishPlayer(mapEntry.first); 209 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 210 210 return; 211 211 const std::string& message = ""; // resets Camper-Warning-message 212 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());212 this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID()); 213 213 } 214 214 } 215 else if ( it->second < timeRemaining/5)//Warning message216 { 217 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)215 else if (mapEntry.second < timeRemaining/5)//Warning message 216 { 217 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 218 218 continue; 219 219 const std::string& message = "Camper Warning! Don't forget to shoot."; 220 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());220 this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID()); 221 221 } 222 222 } … … 229 229 int party = -1; 230 230 //find a player who survived 231 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)232 { 233 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)231 for (const auto& mapEntry : this->playerLives_) 232 { 233 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 234 234 continue; 235 235 236 if ( it->second > 0)//a player that is alive236 if (mapEntry.second > 0)//a player that is alive 237 237 { 238 238 //which party has survived? 239 std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find( it->first);239 std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(mapEntry.first); 240 240 if (it2 != this->teamnumbers_.end()) 241 241 { … … 255 255 { 256 256 int min = lives; 257 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)258 { 259 if ( it->second <= 0)257 for (const auto& mapEntry : this->playerLives_) 258 { 259 if (mapEntry.second <= 0) 260 260 continue; 261 if ( it->second < lives)262 min = it->second;261 if (mapEntry.second < lives) 262 min = mapEntry.second; 263 263 } 264 264 return min; -
code/trunk/src/orxonox/gametypes/LastTeamStanding.h
r9667 r11071 67 67 std::map<PlayerInfo*, bool> inGame_; //!< Indicates each Player's state. 68 68 69 virtual void spawnDeadPlayersIfRequested() ; //!< Prevents dead players to respawn.69 virtual void spawnDeadPlayersIfRequested() override; //!< Prevents dead players to respawn. 70 70 virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped; 71 71 … … 74 74 virtual ~LastTeamStanding(); //!< Default Destructor. 75 75 76 virtual void playerEntered(PlayerInfo* player) ; //!< Initializes values.77 virtual bool playerLeft(PlayerInfo* player) ; //!< Manages all local variables.76 virtual void playerEntered(PlayerInfo* player) override; //!< Initializes values. 77 virtual bool playerLeft(PlayerInfo* player) override; //!< Manages all local variables. 78 78 79 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each player's lost lives.80 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponent, his punishment countdown will be resetted.81 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) ; //!< Resets punishment time and respawn delay.82 v oid tick (float dt); //!< used to end the game83 virtual void end() ; //!< Sends an end message.79 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; //!< Manages each player's lost lives. 80 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; //!< If a player shoot's an opponent, his punishment countdown will be resetted. 81 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override; //!< Resets punishment time and respawn delay. 82 virtual void tick (float dt) override; //!< used to end the game 83 virtual void end() override; //!< Sends an end message. 84 84 void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining". 85 85 int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_". -
code/trunk/src/orxonox/gametypes/Mission.cc
r10624 r11071 101 101 void Mission::setTeams() 102 102 { //Set pawn-colours 103 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)103 for (Pawn* pawn : ObjectList<Pawn>()) 104 104 { 105 Pawn* pawn = static_cast<Pawn*>(*it);106 105 if (!pawn) 107 106 continue; … … 111 110 void Mission::endMission(bool accomplished) 112 111 { 113 for ( ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)112 for (Mission* mission : ObjectList<Mission>()) 114 113 { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions! 115 it->setMissionAccomplished(accomplished);116 it->end();114 mission->setMissionAccomplished(accomplished); 115 mission->end(); 117 116 } 118 117 } … … 120 119 void Mission::setLivesWrapper(unsigned int amount) 121 120 { 122 for ( ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)121 for (Mission* mission : ObjectList<Mission>()) 123 122 { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would affect ALL missions! 124 it->setLives(amount);123 mission->setLives(amount); 125 124 } 126 125 } -
code/trunk/src/orxonox/gametypes/Mission.h
r9729 r11071 42 42 virtual ~Mission() {} 43 43 44 virtual void tick(float dt) ;44 virtual void tick(float dt) override; 45 45 46 virtual void start() ;47 virtual void end() ;46 virtual void start() override; 47 virtual void end() override; 48 48 virtual void setTeams(); 49 virtual void addBots(unsigned int amount) {} //<! overwrite function in order to bypass the addbots command49 virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command 50 50 inline void setLives(unsigned int amount) 51 51 {this->lives_ = amount;} … … 58 58 59 59 protected: 60 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);60 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override; 61 61 bool missionAccomplished_; //<! indicates if player successfully finsihed the mission; 62 62 int lives_; //<! amount of player's lives <-> nr. of retries -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc
r9667 r11071 152 152 int amountControlled2 = 0; 153 153 154 for ( std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)155 { 156 if( (*it)->getState() == BaseState::ControlTeam1)154 for (TeamBaseMatchBase* base : this->bases_) 155 { 156 if(base->getState() == BaseState::ControlTeam1) 157 157 { 158 158 amountControlled++; 159 159 } 160 if( (*it)->getState() == BaseState::ControlTeam2)160 if(base->getState() == BaseState::ControlTeam2) 161 161 { 162 162 amountControlled2++; … … 187 187 } 188 188 189 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)190 { 191 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)189 for (const auto& mapEntry : this->teamnumbers_) 190 { 191 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 192 192 continue; 193 193 194 if ( it->second == winningteam)195 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());194 if (mapEntry.second == winningteam) 195 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 196 196 else 197 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());197 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 198 198 } 199 199 … … 238 238 int count = 0; 239 239 240 for ( std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)241 { 242 if ( (*it)->getState() == BaseState::ControlTeam1 && team == 0)240 for (TeamBaseMatchBase* base : this->bases_) 241 { 242 if (base->getState() == BaseState::ControlTeam1 && team == 0) 243 243 count++; 244 if ( (*it)->getState() == BaseState::ControlTeam2 && team == 1)244 if (base->getState() == BaseState::ControlTeam2 && team == 1) 245 245 count++; 246 246 } … … 258 258 { 259 259 unsigned int i = 0; 260 for ( std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)260 for (TeamBaseMatchBase* base : this->bases_) 261 261 { 262 262 i++; 263 263 if (i > index) 264 return (*it);265 } 266 return 0;264 return base; 265 } 266 return nullptr; 267 267 } 268 268 -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.h
r9667 r11071 44 44 virtual ~TeamBaseMatch() {} 45 45 46 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);47 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator) ;46 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; 47 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator) override; 48 48 49 virtual void playerScored(PlayerInfo* player, int score = 1) ;49 virtual void playerScored(PlayerInfo* player, int score = 1) override; 50 50 virtual void showPoints(); 51 51 virtual void endGame(); -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
r9941 r11071 69 69 int winnerTeam = 0; 70 70 int highestScore = 0; 71 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)71 for (const auto& mapEntry : this->players_) 72 72 { 73 if ( this->getTeamScore( it->first) > highestScore )73 if ( this->getTeamScore(mapEntry.first) > highestScore ) 74 74 { 75 winnerTeam = this->getTeam( it->first);76 highestScore = this->getTeamScore( it->first);75 winnerTeam = this->getTeam(mapEntry.first); 76 highestScore = this->getTeamScore(mapEntry.first); 77 77 } 78 78 } -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.h
r9941 r11071 42 42 43 43 void setConfigValues(); 44 virtual void start() ;45 virtual void end() ;46 virtual void playerEntered(PlayerInfo* player) ;47 virtual bool playerLeft(PlayerInfo* player) ;48 virtual bool playerChangedName(PlayerInfo* player) ;44 virtual void start() override; 45 virtual void end() override; 46 virtual void playerEntered(PlayerInfo* player) override; 47 virtual bool playerLeft(PlayerInfo* player) override; 48 virtual bool playerChangedName(PlayerInfo* player) override; 49 49 50 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);51 virtual void playerScored(PlayerInfo* player, int score = 1) ;50 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override; 51 virtual void playerScored(PlayerInfo* player, int score = 1) override; 52 52 protected: 53 53 int maxScore_; -
code/trunk/src/orxonox/gametypes/TeamGametype.cc
r9941 r11071 75 75 void TeamGametype::playerEntered(PlayerInfo* player) 76 76 { 77 if(player == NULL) return; // catch null pointers77 if(player == nullptr) return; // catch null pointers 78 78 Gametype::playerEntered(player); 79 79 this->findAndSetTeam(player); … … 96 96 void TeamGametype::findAndSetTeam(PlayerInfo* player) 97 97 { 98 if(player == NULL) return; // catch null pointers98 if(player == nullptr) return; // catch null pointers 99 99 std::vector<unsigned int> playersperteam(this->teams_, 0); 100 100 101 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)102 if ( it->second < static_cast<int>(this->teams_) && it->second >= 0)103 playersperteam[ it->second]++;101 for (const auto& mapEntry : this->teamnumbers_) 102 if (mapEntry.second < static_cast<int>(this->teams_) && mapEntry.second >= 0) 103 playersperteam[mapEntry.second]++; 104 104 105 105 unsigned int minplayers = static_cast<unsigned int>(-1); … … 123 123 if( (this->players_.size() >= maxPlayers_) && (allowedInGame_[player] == true) ) // if there's a "waiting list" 124 124 { 125 for ( std::map<PlayerInfo*, bool>::iterator it = this->allowedInGame_.begin(); it != this->allowedInGame_.end(); ++it)126 { 127 if( it->second == false) // waiting player found128 { it->second = true; break;} // allow player to enter125 for (auto& mapEntry : this->allowedInGame_) 126 { 127 if(mapEntry.second == false) // waiting player found 128 {mapEntry.second = true; break;} // allow player to enter 129 129 } 130 130 } … … 141 141 void TeamGametype::spawnDeadPlayersIfRequested() 142 142 { 143 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)\144 { 145 if(allowedInGame_[ it->first] == false)//check if dead player is allowed to enter143 for (const auto& mapEntry : this->players_)\ 144 { 145 if(allowedInGame_[mapEntry.first] == false)//check if dead player is allowed to enter 146 146 { 147 147 continue; 148 148 } 149 if ( it->second.state_ == PlayerState::Dead)150 { 151 if (( it->first->isReadyToSpawn() || this->bForceSpawn_))149 if (mapEntry.second.state_ == PlayerState::Dead) 150 { 151 if ((mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 152 152 { 153 this->spawnPlayer( it->first);153 this->spawnPlayer(mapEntry.first); 154 154 } 155 155 } … … 178 178 if(!player || this->getTeam(player) == -1) 179 179 return 0; 180 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)181 { 182 if ( this->getTeam( it->first) == this->getTeam(player) )183 { 184 teamscore += it->second.frags_;180 for (const auto& mapEntry : this->players_) 181 { 182 if ( this->getTeam(mapEntry.first) == this->getTeam(player) ) 183 { 184 teamscore += mapEntry.second.frags_; 185 185 } 186 186 } … … 191 191 { 192 192 int teamSize = 0; 193 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)194 { 195 if ( it->second == team)193 for (const auto& mapEntry : this->teamnumbers_) 194 { 195 if (mapEntry.second == team) 196 196 teamSize++; 197 197 } … … 202 202 { 203 203 int teamSize = 0; 204 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)205 { 206 if ( it->second == team && it->first->isHumanPlayer())204 for (const auto& mapEntry : this->teamnumbers_) 205 { 206 if (mapEntry.second == team && mapEntry.first->isHumanPlayer()) 207 207 teamSize++; 208 208 } … … 235 235 } 236 236 237 SpawnPoint* fallbackSpawnPoint = NULL;237 SpawnPoint* fallbackSpawnPoint = nullptr; 238 238 if (teamSpawnPoints.size() > 0) 239 239 { … … 241 241 unsigned int index = 0; 242 242 // Get random fallback spawnpoint in case there is no active SpawnPoint. 243 for ( std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)243 for (SpawnPoint* teamSpawnPoint : teamSpawnPoints) 244 244 { 245 245 if (index == randomspawn) 246 246 { 247 fallbackSpawnPoint = (*it);247 fallbackSpawnPoint = teamSpawnPoint; 248 248 break; 249 249 } … … 266 266 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size()))); 267 267 index = 0; 268 for ( std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)268 for (SpawnPoint* teamSpawnPoint : teamSpawnPoints) 269 269 { 270 270 if (index == randomspawn) 271 return (*it);271 return teamSpawnPoint; 272 272 273 273 ++index; … … 277 277 } 278 278 279 return 0;279 return nullptr; 280 280 } 281 281 … … 328 328 void TeamGametype::setDefaultObjectColour(Pawn* pawn) 329 329 { 330 if(pawn == NULL)330 if(pawn == nullptr) 331 331 return; 332 332 … … 340 340 ControllableEntity* entity = orxonox_cast<ControllableEntity*>(pawn); 341 341 342 Controller* controller = 0;342 Controller* controller = nullptr; 343 343 if (entity->getController()) 344 344 controller = entity->getController(); … … 350 350 ArtificialController* artificial = orxonox_cast<ArtificialController*>(controller); 351 351 //get Teamnumber - get the data 352 if(artificial == NULL)352 if(artificial == nullptr) 353 353 return; 354 354 teamnumber= artificial->getTeam(); … … 360 360 void TeamGametype::colourPawn(Pawn* pawn, int teamNr) 361 361 {// catch: no-colouring-case and wrong input 362 if(teamNr < 0 || teamNr+1 > int(this->teamcolours_.size()) ||pawn == NULL) return;362 if(teamNr < 0 || teamNr+1 > int(this->teamcolours_.size()) ||pawn == nullptr) return; 363 363 pawn->setRadarObjectColour(this->teamcolours_[teamNr]); 364 364 365 365 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); 366 for ( std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)367 { 368 if ( (*it)->isA(Class(TeamColourable)))369 { 370 TeamColourable* tc = orxonox_cast<TeamColourable*>( *it);366 for (WorldEntity* pawnAttachment : pawnAttachments) 367 { 368 if (pawnAttachment->isA(Class(TeamColourable))) 369 { 370 TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment); 371 371 tc->setTeamColour(this->teamcolours_[teamNr]); 372 372 } … … 376 376 void TeamGametype::announceTeamWin(int winnerTeam) 377 377 { 378 for ( std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3)379 { 380 if ( it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)378 for (const auto& mapEntry : this->teamnumbers_) 379 { 380 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 381 381 continue; 382 if ( it3->second == winnerTeam)383 { 384 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", it3->first->getClientID());382 if (mapEntry.second == winnerTeam) 383 { 384 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", mapEntry.first->getClientID()); 385 385 } 386 386 else 387 387 { 388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", it3->first->getClientID());388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", mapEntry.first->getClientID()); 389 389 } 390 390 } -
code/trunk/src/orxonox/gametypes/TeamGametype.h
r9941 r11071 46 46 void setConfigValues(); 47 47 48 virtual void playerEntered(PlayerInfo* player) ;48 virtual void playerEntered(PlayerInfo* player) override; 49 49 virtual void findAndSetTeam(PlayerInfo* player); 50 virtual bool playerLeft(PlayerInfo* player) ;51 virtual void spawnDeadPlayersIfRequested() ; //!< Prevents players to respawn.50 virtual bool playerLeft(PlayerInfo* player) override; 51 virtual void spawnDeadPlayersIfRequested() override; //!< Prevents players to respawn. 52 52 53 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);54 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);55 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);53 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = nullptr) override; 54 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; 55 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; 56 56 57 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) ;57 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override; 58 58 59 59 … … 67 67 68 68 protected: 69 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const ;69 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const override; 70 70 bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2); 71 71 -
code/trunk/src/orxonox/gametypes/UnderAttack.cc
r9941 r11071 48 48 this->gameTime_ = 180; 49 49 this->teams_ = 2; 50 this->destroyer_ = 0;50 this->destroyer_ = nullptr; 51 51 this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this)); 52 52 this->gameEnded_ = false; … … 74 74 this->gameEnded_ = true; 75 75 76 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)77 { 78 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)76 for (const auto& mapEntry : this->teamnumbers_) 77 { 78 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 79 79 continue; 80 80 81 if ( it->second == attacker_)82 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());81 if (mapEntry.second == attacker_) 82 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 83 83 else 84 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());84 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 85 85 } 86 86 } … … 155 155 ChatManager::message(message); 156 156 157 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)158 { 159 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)157 for (const auto& mapEntry : this->teamnumbers_) 158 { 159 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 160 160 continue; 161 161 162 if ( it->second == 1)163 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());162 if (mapEntry.second == 1) 163 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 164 164 else 165 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());165 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 166 166 } 167 167 } … … 202 202 void UnderAttack::setTransporterHealth() 203 203 { 204 if (this->destroyer_ != 0)204 if (this->destroyer_ != nullptr) 205 205 { 206 206 //Calculation: Each attacker deals about 3500 damage. A human attacker deals 1500 damage additionally. -
code/trunk/src/orxonox/gametypes/UnderAttack.h
r9941 r11071 43 43 44 44 void setConfigValues(); 45 v oid tick (float dt);45 virtual void tick (float dt) override; 46 46 void addDestroyer(Destroyer* destroyer); 47 47 inline Destroyer* getDestroyer() const 48 48 { return this->destroyer_; } 49 49 50 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);51 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);52 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);53 virtual void playerEntered(PlayerInfo* player) ;50 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = nullptr) override; 51 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; 52 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; 53 virtual void playerEntered(PlayerInfo* player) override; 54 54 55 55 protected: -
code/trunk/src/orxonox/graphics/AnimatedModel.h
r9667 r11071 44 44 virtual ~AnimatedModel(); 45 45 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 47 47 void registerVariables(); 48 48 … … 51 51 virtual void setAnimEnabled(bool enabled); 52 52 virtual void setAnimLoop(bool loop); 53 virtual void tick(float dt) ;53 virtual void tick(float dt) override; 54 54 virtual void changedMesh(); 55 55 -
code/trunk/src/orxonox/graphics/Backlight.cc
r9667 r11071 51 51 RegisterObject(Backlight); 52 52 53 this->ribbonTrail_ = 0;54 this->ribbonTrailNode_ = 0;53 this->ribbonTrail_ = nullptr; 54 this->ribbonTrailNode_ = nullptr; 55 55 56 56 this->width_ = 0; -
code/trunk/src/orxonox/graphics/Backlight.h
r9667 r11071 44 44 virtual ~Backlight(); 45 45 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 47 47 48 virtual void tick(float dt) ;49 virtual void changedVisibility() ;48 virtual void tick(float dt) override; 49 virtual void changedVisibility() override; 50 50 51 51 inline void setWidth(float width) … … 74 74 { return this->trailmaterial_; } 75 75 76 virtual void changedScale() ;76 virtual void changedScale() override; 77 77 78 78 protected: 79 virtual void changedTimeFactor(float factor_new, float factor_old) ;79 virtual void changedTimeFactor(float factor_new, float factor_old) override; 80 80 81 81 private: 82 82 void registerVariables(); 83 virtual void startturnonoff() ;84 virtual void stopturnonoff() ;85 virtual void poststopturnonoff() ;86 virtual void changedColour() ;83 virtual void startturnonoff() override; 84 virtual void stopturnonoff() override; 85 virtual void poststopturnonoff() override; 86 virtual void changedColour() override; 87 87 void update_width(); 88 88 void update_lifetime(); -
code/trunk/src/orxonox/graphics/Billboard.cc
r9667 r11071 139 139 { 140 140 Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet(); 141 if( bSet != NULL)141 if( bSet != nullptr ) 142 142 { 143 143 bSet->setBillboardType(bbt); … … 148 148 { 149 149 Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet(); 150 if( bSet != NULL)150 if( bSet != nullptr ) 151 151 { 152 152 bSet->setCommonDirection( vec ); … … 157 157 { 158 158 Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet(); 159 if( bSet != NULL)159 if( bSet != nullptr ) 160 160 { 161 161 bSet->setCommonUpVector( vec ); … … 166 166 { 167 167 Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet(); 168 if( bSet != NULL)168 if( bSet != nullptr ) 169 169 { 170 170 bSet->setDefaultDimensions(width, height); -
code/trunk/src/orxonox/graphics/Billboard.h
r9667 r11071 47 47 virtual ~Billboard(); 48 48 49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 50 50 51 virtual void changedVisibility() ;51 virtual void changedVisibility() override; 52 52 53 53 inline const BillboardSet& getBillboardSet() const … … 71 71 72 72 73 virtual void setTeamColour(const ColourValue& colour) 73 virtual void setTeamColour(const ColourValue& colour) override 74 74 { this->setColour(colour); } 75 75 -
code/trunk/src/orxonox/graphics/BlinkingBillboard.h
r9667 r11071 44 44 virtual ~BlinkingBillboard(); 45 45 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 47 47 48 virtual void tick(float dt) ;48 virtual void tick(float dt) override; 49 49 50 50 inline void setAmplitude(float amplitude) -
code/trunk/src/orxonox/graphics/Camera.h
r9667 r11071 50 50 51 51 void setConfigValues(); 52 virtual void tick(float dt) ;52 virtual void tick(float dt) override; 53 53 54 54 void requestFocus(); … … 72 72 void configvaluecallback_changedNearClipDistance(); 73 73 74 v oid windowResized(unsigned int newWidth, unsigned int newHeight);74 virtual void windowResized(unsigned int newWidth, unsigned int newHeight) override; 75 75 76 76 Ogre::Camera* camera_; -
code/trunk/src/orxonox/graphics/FadingBillboard.h
r9667 r11071 45 45 virtual ~FadingBillboard(); 46 46 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 48 48 49 virtual void tick(float dt) ;50 virtual void changedActivity() ;51 virtual void changedVisibility() ;49 virtual void tick(float dt) override; 50 virtual void changedActivity() override; 51 virtual void changedVisibility() override; 52 52 53 53 inline void setTurnOnTime(float turnontime) … … 69 69 virtual void stopturnonoff(); 70 70 virtual void poststopturnonoff(); 71 virtual void changedColour() ;71 virtual void changedColour() override; 72 72 73 73 float turnontime_; -
code/trunk/src/orxonox/graphics/GlobalShader.h
r9667 r11071 44 44 virtual ~GlobalShader(); 45 45 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 47 47 48 virtual void changedVisibility() ;48 virtual void changedVisibility() override; 49 49 50 50 inline const Shader& getShader() const -
code/trunk/src/orxonox/graphics/Light.cc
r9667 r11071 31 31 #include <OgreSceneManager.h> 32 32 #include <OgreLight.h> 33 #include <boost/static_assert.hpp>34 33 35 34 #include "util/StringUtils.h" … … 45 44 46 45 // Be sure we don't do bad conversions 47 BOOST_STATIC_ASSERT((int)Ogre::Light::LT_POINT == (int)Light::Point);48 BOOST_STATIC_ASSERT((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::Directional);49 BOOST_STATIC_ASSERT((int)Ogre::Light::LT_SPOTLIGHT == (int)Light::Spotlight);46 static_assert((int)Ogre::Light::LT_POINT == (int)Light::Type::Point, "check enum"); 47 static_assert((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::Type::Directional, "check enum"); 48 static_assert((int)Ogre::Light::LT_SPOTLIGHT == (int)Light::Type::Spotlight, "check enum"); 50 49 51 50 Light::Light(Context* context) : StaticEntity(context) … … 53 52 RegisterObject(Light); 54 53 55 this->light_ = 0;54 this->light_ = nullptr; 56 55 this->diffuse_ = ColourValue::White; 57 56 this->specular_ = ColourValue::White; 58 this->type_ = Light::Point;57 this->type_ = Type::Point; 59 58 this->attenuation_ = Vector4(100000, 1, 0, 0); 60 59 this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f); … … 106 105 void Light::registerVariables() 107 106 { 108 registerVariable( (int&)this->type_,VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateType));107 registerVariable(this->type_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateType)); 109 108 registerVariable(this->diffuse_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour)); 110 109 registerVariable(this->specular_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateSpecularColour)); … … 127 126 void Light::updateAttenuation() 128 127 { 129 if (this->light_ && this->type_ != Light::Directional)128 if (this->light_ && this->type_ != Type::Directional) 130 129 this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w); 131 130 } … … 133 132 void Light::updateSpotlightRange() 134 133 { 135 if (this->light_ && this->type_ == Light::Spotlight)134 if (this->light_ && this->type_ == Type::Spotlight) 136 135 this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z); 137 136 } … … 140 139 { 141 140 if (type == "point") 142 this->setType( Light::Point);141 this->setType(Type::Point); 143 142 else if (type == "directional") 144 this->setType( Light::Directional);143 this->setType(Type::Directional); 145 144 else if (type == "spotlight") 146 this->setType( Light::Spotlight);145 this->setType(Type::Spotlight); 147 146 else 148 this->setType( Light::Point);147 this->setType(Type::Point); 149 148 } 150 149 … … 153 152 switch (this->type_) 154 153 { 155 case Light::Directional:154 case Type::Directional: 156 155 return "directional"; 157 case Light::Spotlight:156 case Type::Spotlight: 158 157 return "spotlight"; 159 case Light::Point:158 case Type::Point: 160 159 default: 161 160 return "point"; … … 169 168 this->light_->setType(static_cast<Ogre::Light::LightTypes>(this->type_)); 170 169 171 if (this->type_ != Light::Directional)170 if (this->type_ != Type::Directional) 172 171 this->updateAttenuation(); 173 if (this->type_ == Light::Spotlight)172 if (this->type_ == Type::Spotlight) 174 173 this->updateSpotlightRange(); 175 174 } -
code/trunk/src/orxonox/graphics/Light.h
r9667 r11071 42 42 { 43 43 public: 44 enum LightTypes// Copy from the Ogre enum44 enum class Type // Copy from the Ogre enum 45 45 { 46 46 /// Point light sources give off light equally in all directions, so require only position not direction … … 56 56 virtual ~Light(); 57 57 58 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;58 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 59 59 60 virtual void changedVisibility() ;60 virtual void changedVisibility() override; 61 61 62 62 inline Ogre::Light* getLight() 63 63 { return this->light_; } 64 64 65 inline void setType(Light:: LightTypestype)65 inline void setType(Light::Type type) 66 66 { this->type_ = type; this->updateType(); } 67 inline Light:: LightTypesgetType() const67 inline Light::Type getType() const 68 68 { return this->type_; } 69 69 … … 78 78 { return this->specular_; } 79 79 80 virtual void setTeamColour(const ColourValue& colour) 80 virtual void setTeamColour(const ColourValue& colour) override 81 81 { this->setDiffuseColour(colour); this->setSpecularColour(colour); } 82 82 … … 144 144 145 145 Ogre::Light* light_; 146 Light Typestype_;146 Light::Type type_; 147 147 ColourValue diffuse_; 148 148 ColourValue specular_; -
code/trunk/src/orxonox/graphics/MeshLodInformation.h
r9667 r11071 50 50 float getReductionRate(){ return this->reductionRate_; } 51 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 53 53 54 54 private: -
code/trunk/src/orxonox/graphics/Model.cc
r10728 r11071 134 134 Level* level = this->getLevel(); 135 135 136 assert( level != 0);136 assert( level != nullptr ); 137 137 138 138 MeshLodInformation* lodInfo = level->getLodInfo(this->meshSrc_); … … 157 157 BaseObject* creatorPtr = this; 158 158 159 while(creatorPtr!= NULL&&orxonox_cast<WorldEntity*>(creatorPtr))159 while(creatorPtr!=nullptr&&orxonox_cast<WorldEntity*>(creatorPtr)) 160 160 { 161 161 scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D()); -
code/trunk/src/orxonox/graphics/Model.h
r9667 r11071 46 46 void setConfigValues(); 47 47 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 49 49 50 virtual void changedVisibility() ;50 virtual void changedVisibility() override; 51 51 52 52 inline const Mesh& getMesh() const -
code/trunk/src/orxonox/graphics/ParticleEmitter.cc
r9950 r11071 52 52 ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given."); 53 53 54 this->particles_ = 0;54 this->particles_ = nullptr; 55 55 this->LOD_ = LODParticle::Normal; 56 56 … … 102 102 { 103 103 delete this->particles_; 104 this->particles_ = 0;104 this->particles_ = nullptr; 105 105 } 106 106 -
code/trunk/src/orxonox/graphics/ParticleEmitter.h
r9950 r11071 43 43 virtual ~ParticleEmitter(); 44 44 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 46 46 47 virtual void changedVisibility() ;48 virtual void changedActivity() ;47 virtual void changedVisibility() override; 48 virtual void changedActivity() override; 49 49 50 50 inline ParticleInterface* getParticleInterface() const -
code/trunk/src/orxonox/graphics/ParticleSpawner.h
r9667 r11071 43 43 virtual ~ParticleSpawner(); 44 44 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;46 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) ;45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 46 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; 47 47 48 48 inline void stop(bool bDestroy) -
code/trunk/src/orxonox/infos/Bot.h
r9667 r11071 45 45 void setConfigValues(); 46 46 47 inline bool isInitialized() const47 virtual inline bool isInitialized() const override 48 48 { return true; } 49 inline float getPing() const49 virtual inline float getPing() const override 50 50 { return 0; } 51 inline float getPacketLossRatio() const51 virtual inline float getPacketLossRatio() const override 52 52 { return 0; } 53 53 -
code/trunk/src/orxonox/infos/GametypeInfo.cc
r10624 r11071 291 291 if(GameMode::isMaster()) 292 292 { 293 NotificationListener::sendNotification("Press [Fire] to respawn", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());293 NotificationListener::sendNotification("Press [Fire] to respawn", GametypeInfo::NOTIFICATION_SENDER, NotificationMessageType::info, NotificationSendMode::network, player->getClientID()); 294 294 // Remove the player from the list of players that have spawned, since it currently is not. 295 295 this->spawnedPlayers_.erase(player); … … 346 346 // Display "Press [Fire] to start the match" if the game has not yet ended. 347 347 if(!this->hasEnded()) 348 NotificationListener::sendNotification("Press [Fire] to start the match", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());348 NotificationListener::sendNotification("Press [Fire] to start the match", GametypeInfo::NOTIFICATION_SENDER, NotificationMessageType::info, NotificationSendMode::network, player->getClientID()); 349 349 // Else display "Game has ended". 350 350 else 351 NotificationListener::sendNotification("Game has ended", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());351 NotificationListener::sendNotification("Game has ended", GametypeInfo::NOTIFICATION_SENDER, NotificationMessageType::info, NotificationSendMode::network, player->getClientID()); 352 352 } 353 353 } … … 461 461 void GametypeInfo::dispatchAnnounceMessage(const std::string& message) const 462 462 { 463 for ( ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)464 it->announcemessage(this, message);463 for (GametypeMessageListener* listener : ObjectList<GametypeMessageListener>()) 464 listener->announcemessage(this, message); 465 465 } 466 466 467 467 void GametypeInfo::dispatchKillMessage(const std::string& message) const 468 468 { 469 for ( ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)470 it->killmessage(this, message);469 for (GametypeMessageListener* listener : ObjectList<GametypeMessageListener>()) 470 listener->killmessage(this, message); 471 471 } 472 472 473 473 void GametypeInfo::dispatchDeathMessage(const std::string& message) const 474 474 { 475 for ( ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)476 it->deathmessage(this, message);475 for (GametypeMessageListener* listener : ObjectList<GametypeMessageListener>()) 476 listener->deathmessage(this, message); 477 477 } 478 478 479 479 void GametypeInfo::dispatchStaticMessage(const std::string& message, const ColourValue& colour) const 480 480 { 481 for ( ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)482 it->staticmessage(this, message, colour);481 for (GametypeMessageListener* listener : ObjectList<GametypeMessageListener>()) 482 listener->staticmessage(this, message, colour); 483 483 } 484 484 485 485 void GametypeInfo::dispatchFadingMessage(const std::string& message) const 486 486 { 487 for ( ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)488 it->fadingmessage(this, message);487 for (GametypeMessageListener* listener : ObjectList<GametypeMessageListener>()) 488 listener->fadingmessage(this, message); 489 489 } 490 490 } -
code/trunk/src/orxonox/infos/HumanPlayer.cc
r10624 r11071 53 53 this->defaultController_ = Class(NewHumanController); 54 54 55 this->humanHud_ = 0;56 this->gametypeHud_ = 0;55 this->humanHud_ = nullptr; 56 this->gametypeHud_ = nullptr; 57 57 58 58 this->setConfigValues(); … … 178 178 { 179 179 this->humanHud_->destroy(); 180 this->humanHud_ = 0;180 this->humanHud_ = nullptr; 181 181 } 182 182 … … 194 194 { 195 195 this->gametypeHud_->destroy(); 196 this->gametypeHud_ = 0;196 this->gametypeHud_ = nullptr; 197 197 } 198 198 -
code/trunk/src/orxonox/infos/HumanPlayer.h
r10624 r11071 45 45 void setConfigValues(); 46 46 47 bool isInitialized() const;48 float getPing() const;49 float getPacketLossRatio() const;47 virtual bool isInitialized() const override; 48 virtual float getPing() const override; 49 virtual float getPacketLossRatio() const override; 50 50 51 51 void setClientID(unsigned int clientID); 52 52 53 virtual void switchGametype(Gametype* gametype) ;53 virtual void switchGametype(Gametype* gametype) override; 54 54 55 55 inline void setHumanHUDTemplate(const std::string& name) -
code/trunk/src/orxonox/infos/PlayerInfo.cc
r11052 r11071 51 51 this->bReadyToSpawn_ = false; 52 52 this->bSetUnreadyAfterSpawn_ = true; 53 this->controller_ = 0;54 this->controllableEntity_ = 0;53 this->controller_ = nullptr; 54 this->controllableEntity_ = nullptr; 55 55 this->controllableEntityID_ = OBJECTID_UNKNOWN; 56 56 57 this->gtinfo_ = 0;57 this->gtinfo_ = nullptr; 58 58 this->gtinfoID_ = OBJECTID_UNKNOWN; 59 59 this->updateGametypeInfo(this->getGametype()); … … 72 72 { 73 73 this->controller_->destroy(); 74 this->controller_ = 0;74 this->controller_ = nullptr; 75 75 } 76 76 … … 126 126 void PlayerInfo::updateGametypeInfo(Gametype* gametype) 127 127 { 128 this->gtinfo_ = 0;128 this->gtinfo_ = nullptr; 129 129 this->gtinfoID_ = OBJECTID_UNKNOWN; 130 130 … … 141 141 { 142 142 this->controller_->destroy(); 143 this->controller_ = 0;143 this->controller_ = nullptr; 144 144 } 145 145 this->controller_ = this->defaultController_.fabricate(this->getContext()); … … 181 181 182 182 RadarViewable* radarviewable = orxonox_cast<RadarViewable*>(entity); 183 if (radarviewable != NULL)183 if (radarviewable != nullptr) 184 184 radarviewable->setRadarName(this->getName()); 185 185 } … … 218 218 return; 219 219 220 this->controllableEntity_->setController( 0);221 this->controllableEntity_ = 0;220 this->controllableEntity_->setController(nullptr); 221 this->controllableEntity_ = nullptr; 222 222 this->controllableEntityID_ = OBJECTID_UNKNOWN; 223 223 224 224 if (this->controller_) 225 this->controller_->setControllableEntity( 0);225 this->controller_->setControllableEntity(nullptr); 226 226 227 227 if ( GameMode::isMaster() ) … … 239 239 240 240 Controller* tmp =this->controllableEntity_->getController(); 241 if (tmp == NULL)242 { 243 orxout(verbose) << "PlayerInfo: pauseControl, Controller is NULL" << endl;241 if (tmp == nullptr) 242 { 243 orxout(verbose) << "PlayerInfo: pauseControl, Controller is nullptr " << endl; 244 244 return; 245 245 } 246 246 tmp->setActive(false); 247 //this->controllableEntity_->getController()->setControllableEntity( NULL);248 this->controllableEntity_->setController( 0);247 //this->controllableEntity_->getController()->setControllableEntity(nullptr); 248 this->controllableEntity_->setController(nullptr); 249 249 } 250 250 … … 253 253 ControllableEntity* entity = this->controllableEntity_; 254 254 255 assert(this->controllableEntity_ != NULL);255 assert(this->controllableEntity_ != nullptr); 256 256 if( !entity || this->previousControllableEntity_.size() == 0 ) 257 257 return; … … 259 259 entity->destroyHud(); // HACK-ish 260 260 261 this->controllableEntity_->setController( 0);261 this->controllableEntity_->setController(nullptr); 262 262 if(this->isHumanPlayer()) // TODO: Multiplayer? 263 263 this->controllableEntity_->destroyHud(); // HACK-ish … … 266 266 do { 267 267 this->controllableEntity_ = this->previousControllableEntity_.back(); 268 } while(this->controllableEntity_ == NULL&& this->previousControllableEntity_.size() > 0);268 } while(this->controllableEntity_ == nullptr && this->previousControllableEntity_.size() > 0); 269 269 this->controllableEntityID_ = this->controllableEntity_->getObjectID(); 270 270 this->previousControllableEntity_.pop_back(); 271 271 272 if ( this->controllableEntity_ != NULL && this->controller_ != NULL)272 if ( this->controllableEntity_ != nullptr && this->controller_ != nullptr) 273 273 this->controller_->setControllableEntity(this->controllableEntity_); 274 274 275 275 // HACK-ish 276 if(this->controllableEntity_ != NULL&& this->isHumanPlayer())276 if(this->controllableEntity_ != nullptr && this->isHumanPlayer()) 277 277 this->controllableEntity_->createHud(); 278 278 -
code/trunk/src/orxonox/infos/PlayerInfo.h
r10624 r11071 44 44 virtual ~PlayerInfo(); 45 45 46 virtual void changedName() ;46 virtual void changedName() override; 47 47 virtual void switchGametype(Gametype* gametype); 48 48 … … 99 99 Controller* controller_; 100 100 ControllableEntity* controllableEntity_; 101 std::vector< WeakPtr<ControllableEntity>> previousControllableEntity_; //!< List of the previous ControllableEntities if repeatedly startTemporary control was called. The ControllableEntity at the back is the most recent.101 std::vector<WeakPtr<ControllableEntity>> previousControllableEntity_; //!< List of the previous ControllableEntities if repeatedly startTemporary control was called. The ControllableEntity at the back is the most recent. 102 102 unsigned int controllableEntityID_; 103 103 -
code/trunk/src/orxonox/interfaces/NotificationListener.cc
r10624 r11071 74 74 The type of the notification, can be either 'info' or 'important'. 75 75 */ 76 /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand, notificationMessageType::Value messageType)76 /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, NotificationSendMode sendMode, unsigned int clientId, bool isCommand, NotificationMessageType messageType) 77 77 { 78 78 // If we're in standalone mode or we're already no the right client we create and send the notification/command. 79 if(GameMode::isStandalone() || sendMode == notificationSendMode::local || (sendMode == notificationSendMode::network && Host::getPlayerID() == clientId))79 if(GameMode::isStandalone() || sendMode == NotificationSendMode::local || (sendMode == NotificationSendMode::network && Host::getPlayerID() == clientId)) 80 80 { 81 81 sendHelper(message, sender, isCommand, messageType); 82 82 } 83 83 // If we're on the server (and the server is not the intended recipient of the notification/command) we send it over the network. 84 else if(GameMode::isServer() && sendMode == notificationSendMode::network && Host::getPlayerID() != clientId)84 else if(GameMode::isServer() && sendMode == NotificationSendMode::network && Host::getPlayerID() != clientId) 85 85 { 86 callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);86 callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, messageType); 87 87 } 88 else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast)88 else if(GameMode::isServer() && sendMode == NotificationSendMode::broadcast) 89 89 { 90 90 // TODO: Works as intended? 91 callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);91 callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, messageType); 92 92 } 93 93 } … … 105 105 The type of the notification. 106 106 */ 107 /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, unsigned int messageType)107 /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, NotificationMessageType type) 108 108 { 109 109 // Iterate through all NotificationListeners and notify them by calling the method they overloaded. 110 for( ObjectList<NotificationListener>::iterator it = ObjectList<NotificationListener>::begin(); it != ObjectList<NotificationListener>::end(); ++it)110 for(NotificationListener* listener : ObjectList<NotificationListener>()) 111 111 { 112 112 // If the notification is a message. 113 113 if(!isCommand) 114 it->registerNotification(message, sender, notificationMessageType::Value(messageType));114 listener->registerNotification(message, sender, type); 115 115 116 116 // If the notification is a command. 117 117 if(isCommand) 118 118 { 119 notificationCommand::Valuecommand = str2Command(message);120 if(command != notificationCommand::none)121 it->executeCommand(command, sender);119 NotificationCommand command = str2Command(message); 120 if(command != NotificationCommand::none) 121 listener->executeCommand(command, sender); 122 122 } 123 123 } … … 130 130 The string to be converted. 131 131 @return 132 Returns the corresponding enum, notificationCommand::none if the command doesn't exist.132 Returns the corresponding enum, NotificationCommand::none if the command doesn't exist. 133 133 */ 134 /*static*/ notificationCommand::ValueNotificationListener::str2Command(const std::string& string)134 /*static*/ NotificationCommand NotificationListener::str2Command(const std::string& string) 135 135 { 136 notificationCommand::Value command = notificationCommand::none;136 NotificationCommand command = NotificationCommand::none; 137 137 138 138 if(string == NotificationListener::COMMAND_CLEAR) 139 command = notificationCommand::clear;139 command = NotificationCommand::clear; 140 140 141 141 return command; … … 150 150 Returns the corresponding string. 151 151 */ 152 /*static*/ const std::string& NotificationListener::command2Str( notificationCommand::Valuecommand)152 /*static*/ const std::string& NotificationListener::command2Str(NotificationCommand command) 153 153 { 154 154 switch(command) 155 155 { 156 case notificationCommand::clear:156 case NotificationCommand::clear: 157 157 return NotificationListener::COMMAND_CLEAR; 158 158 default: -
code/trunk/src/orxonox/interfaces/NotificationListener.h
r9667 r11071 49 49 { 50 50 // TODO: Document. 51 namespace notificationMessageType 52 { 53 enum Value { 54 info, 55 important 56 }; 57 } 51 enum class NotificationMessageType { 52 info, 53 important 54 }; 58 55 59 namespace notificationSendMode 60 { 61 enum Value { 62 local, 63 network, 64 broadcast 65 }; 66 } 56 enum class NotificationSendMode { 57 local, 58 network, 59 broadcast 60 }; 67 61 68 namespace notificationCommand 69 { 70 enum Value { 71 none, 72 clear 73 }; 74 } 62 enum class NotificationCommand { 63 none, 64 clear 65 }; 75 66 76 67 // TODO: Update doc. … … 101 92 @param sender The sender that sent the notification. Default is 'none'. 102 93 @param messageType The type of the message, can be either 'info' or 'important'. Default is 'info'. 103 @param sendMode The mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts. Default is notificationSendMode::local.94 @param sendMode The mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts. Default is NotificationSendMode::local. 104 95 @param clientId The id of the client the notification should be sent to. Default is 0. 105 96 */ 106 static void sendNotification(const std::string& message, const std::string& sender = NotificationListener::NONE, notificationMessageType::Value messageType = notificationMessageType::info, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)97 static void sendNotification(const std::string& message, const std::string& sender = NotificationListener::NONE, NotificationMessageType messageType = NotificationMessageType::info, NotificationSendMode sendMode = NotificationSendMode::local, unsigned int clientId = 0) 107 98 { NotificationListener::sendNetworkHelper(message, sender, sendMode, clientId, false, messageType); } 108 99 /** … … 110 101 @param command The command that should be sent (and later executed). 111 102 @param sender The sender that sent the notification. Default is 'none'. 112 @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is notificationSendMode::local.103 @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is NotificationSendMode::local. 113 104 @param clientId The id of the client the command should be sent to. Default is 0. 114 105 */ 115 static void sendCommand(const std::string& command, const std::string& sender = NotificationListener::NONE, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)106 static void sendCommand(const std::string& command, const std::string& sender = NotificationListener::NONE, NotificationSendMode sendMode = NotificationSendMode::local, unsigned int clientId = 0) 116 107 { NotificationListener::sendNetworkHelper(command, sender, sendMode, clientId, true); } 117 108 118 static void sendHelper(const std::string& message, const std::string& sender, bool isCommand = false, unsigned int messageMode = 0); // Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network.109 static void sendHelper(const std::string& message, const std::string& sender, bool isCommand, NotificationMessageType type); // Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network. 119 110 120 111 //TODO: Make protected? … … 128 119 @return Returns true if the notification was successfully registered, false if not. 129 120 */ 130 virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type)121 virtual bool registerNotification(const std::string& message, const std::string& sender, NotificationMessageType type) 131 122 { return false; } 132 123 /** … … 137 128 @return Returns true if the command was successfully executed, false if not. 138 129 */ 139 virtual bool executeCommand( notificationCommand::Valuecommand, const std::string& sender) { return false; }130 virtual bool executeCommand(NotificationCommand command, const std::string& sender) { return false; } 140 131 141 132 public: … … 149 140 150 141 protected: 151 static void sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand = false, notificationMessageType::Value messageType = notificationMessageType::info); // Helper method to send both notifications and commands over the network.142 static void sendNetworkHelper(const std::string& message, const std::string& sender, NotificationSendMode sendMode, unsigned int clientId, bool isCommand = false, NotificationMessageType messageType = NotificationMessageType::info); // Helper method to send both notifications and commands over the network. 152 143 153 static notificationCommand::Valuestr2Command(const std::string& string); // Helper method. Converts a string into the enum for a command.154 static const std::string& command2Str( notificationCommand::Valuecommand); // Helper method. Converts a command enum into its corresponding string.144 static NotificationCommand str2Command(const std::string& string); // Helper method. Converts a string into the enum for a command. 145 static const std::string& command2Str(NotificationCommand command); // Helper method. Converts a command enum into its corresponding string. 155 146 }; 156 147 } -
code/trunk/src/orxonox/interfaces/PickupCarrier.cc
r10624 r11071 101 101 // Go recursively through all children to check whether they are a target. 102 102 std::vector<PickupCarrier*>* children = this->getCarrierChildren(); 103 for( std::vector<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)103 for(PickupCarrier* carrier : *children) 104 104 { 105 if( (*it)->isTarget(pickup))105 if(carrier->isTarget(pickup)) 106 106 { 107 107 isTarget = true; … … 127 127 { 128 128 if(!this->isTarget(pickup)) 129 return NULL;129 return nullptr; 130 130 131 131 if(pickup->isTarget(this)) // If the PickupCarrier itself is a target. 132 132 return this; 133 133 134 PickupCarrier* target = NULL;134 PickupCarrier* target = nullptr; 135 135 // Go recursively through all children to check whether they are the target. 136 136 std::vector<PickupCarrier*>* children = this->getCarrierChildren(); 137 for( std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)137 for(PickupCarrier* child : *children) 138 138 { 139 if(pickup->isTarget( *it))139 if(pickup->isTarget(child)) 140 140 { 141 target = *it;141 target = child; 142 142 break; 143 143 } -
code/trunk/src/orxonox/interfaces/PickupCarrier.h
r9667 r11071 59 59 But this structure has to be established first. 60 60 - <b>getCarrierChildren()</b> To this end a PickupCarrier needs to implement getCarrierChildren() which returns a list of its direct PickupCarrier children. If you need an example, have a look at @ref orxonox::Pawn "Pawn" and @ref orxonox::Engine "Engine". 61 - <b>getCarrierParent()</b> This is the method in the other direction. It returns the parent of this PickupCarrier, or NULLif the PickupCarrier is a root node in this hierarchy.61 - <b>getCarrierParent()</b> This is the method in the other direction. It returns the parent of this PickupCarrier, or nullptr if the PickupCarrier is a root node in this hierarchy. 62 62 63 63 @author … … 77 77 PickupCarrier(); //!< Constructor. 78 78 virtual ~PickupCarrier(); //!< Destructor. 79 v oid preDestroy(void); //!< Is called before the PickupCarrier is effectively destroyed.79 virtual void preDestroy(void) override; //!< Is called before the PickupCarrier is effectively destroyed. 80 80 81 81 bool isTarget(const Pickupable* pickup) const; //!< Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable. -
code/trunk/src/orxonox/interfaces/PickupListener.cc
r10624 r11071 74 74 75 75 // Iterate through all PickupListeners and notify them by calling the method they overloaded. 76 for( ObjectList<PickupListener>::iterator it = ObjectList<PickupListener>::begin(); it != ObjectList<PickupListener>::end(); ++it)77 it->pickupChangedUsed(pickup, used);76 for(PickupListener* listener : ObjectList<PickupListener>()) 77 listener->pickupChangedUsed(pickup, used); 78 78 } 79 79 … … 92 92 93 93 // Iterate through all PickupListeners and notify them by calling the method they overloaded. 94 for( ObjectList<PickupListener>::iterator it = ObjectList<PickupListener>::begin(); it != ObjectList<PickupListener>::end(); ++it)95 it->pickupChangedPickedUp(pickup, pickedUp);94 for(PickupListener* listener : ObjectList<PickupListener>()) 95 listener->pickupChangedPickedUp(pickup, pickedUp); 96 96 } 97 97 -
code/trunk/src/orxonox/interfaces/Pickupable.cc
r10624 r11071 56 56 RegisterObject(Pickupable); 57 57 58 this->carrier_ = NULL;58 this->carrier_ = nullptr; 59 59 60 60 this->beingDestroyed_ = false; … … 143 143 bool Pickupable::isTarget(const PickupCarrier* carrier) const 144 144 { 145 if(carrier == NULL)145 if(carrier == nullptr) 146 146 return false; 147 147 … … 160 160 { 161 161 // Iterate through all targets of this Pickupable. 162 for( std::list<Identifier*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)162 for(Identifier* target : this->targets_) 163 163 { 164 if(identifier->isA( *it))164 if(identifier->isA(target)) 165 165 return true; 166 166 } … … 210 210 bool Pickupable::pickup(PickupCarrier* carrier) 211 211 { 212 if(carrier == NULL || this->isPickedUp()) // If carrier is NULLor the Pickupable is already picked up.212 if(carrier == nullptr || this->isPickedUp()) // If carrier is nullptr or the Pickupable is already picked up. 213 213 return false; 214 214 … … 237 237 return false; 238 238 239 assert(this->getCarrier()); // The Carrier cannot be NULLat this point.239 assert(this->getCarrier()); // The Carrier cannot be nullptr at this point. 240 240 if(!this->getCarrier()->removePickup(this)) //TODO Shouldn't this be a little later? 241 241 orxout(internal_warning, context::pickups) << "Pickupable (&" << this << ", " << this->getIdentifier()->getName() << ") is being dropped, but it was not present in the PickupCarriers list of pickups." << endl; … … 249 249 created = this->createSpawner(); 250 250 251 this->setCarrier( NULL);251 this->setCarrier(nullptr); 252 252 253 253 if(!created && createSpawner) // If a PickupSpawner should have been created but wasn't. … … 301 301 orxout(verbose, context::pickups) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << endl; 302 302 303 if(carrier != NULL&& tell)303 if(carrier != nullptr && tell) 304 304 { 305 305 if(!carrier->addPickup(this)) -
code/trunk/src/orxonox/interfaces/Pickupable.h
r10624 r11071 144 144 145 145 protected: 146 virtual void preDestroy(void) ; //!< A method that is called by Destroyable::destroy() before the object is actually destroyed.146 virtual void preDestroy(void) override; //!< A method that is called by Destroyable::destroy() before the object is actually destroyed. 147 147 virtual void destroyPickup(void); //!< Destroys a Pickupable. 148 148 virtual void carrierDestroyed(void); //!< Is called by the PickupCarrier when it is being destroyed. … … 182 182 // For implementing the Rewardable interface: 183 183 public: 184 virtual bool reward(PlayerInfo* player) ; //!< Method to transcribe a Pickupable as a Rewardable to the player.184 virtual bool reward(PlayerInfo* player) override; //!< Method to transcribe a Pickupable as a Rewardable to the player. 185 185 186 186 }; -
code/trunk/src/orxonox/interfaces/RadarViewable.cc
r10624 r11071 49 49 , wePtr_(wePtr) 50 50 , radarObjectCamouflage_(0.0f) 51 , radarObjectShape_( Dot)51 , radarObjectShape_(Shape::Dot) 52 52 , radarObjectDescription_("staticObject") 53 53 , scale_(1.0f) -
code/trunk/src/orxonox/interfaces/RadarViewable.h
r10624 r11071 49 49 { 50 50 public: 51 enum Shape51 enum class Shape 52 52 { 53 53 Square, … … 66 66 if (name == "HIDDEN") 67 67 { 68 this->bVisibility_ = 0;68 this->bVisibility_ = false; 69 69 this->settingsChanged(); 70 70 } -
code/trunk/src/orxonox/items/Engine.cc
r9667 r11071 50 50 RegisterObject(Engine); 51 51 52 this->ship_ = 0;52 this->ship_ = nullptr; 53 53 this->shipID_ = OBJECTID_UNKNOWN; 54 54 this->relativePosition_ = Vector3::ZERO; … … 136 136 void Engine::networkcallback_shipID() 137 137 { 138 this->ship_ = 0;138 this->ship_ = nullptr; 139 139 140 140 if (this->shipID_ != OBJECTID_UNKNOWN) … … 155 155 void Engine::run(float dt) 156 156 { 157 if (this->ship_ == NULL)157 if (this->ship_ == nullptr) 158 158 { 159 159 if (this->shipID_ != 0) … … 161 161 this->networkcallback_shipID(); 162 162 163 if (this->ship_ == NULL)163 if (this->ship_ == nullptr) 164 164 return; 165 165 } -
code/trunk/src/orxonox/items/Engine.h
r9667 r11071 59 59 virtual ~Engine(); 60 60 61 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;61 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 62 62 void setConfigValues(); 63 63 … … 67 67 /** 68 68 @brief Get the SpaceShip this Engine is mounted on. 69 @return Returns a pointer to the SpaceShip. NULLif it isn't mounted on any ship.69 @return Returns a pointer to the SpaceShip. nullptr if it isn't mounted on any ship. 70 70 */ 71 71 inline SpaceShip* getShip() const -
code/trunk/src/orxonox/items/MultiStateEngine.cc
r9939 r11071 67 67 else 68 68 { 69 this->defEngineSndBoost_ = 0;70 this->defEngineSndNormal_ = 0;71 this->lua_ = 0;69 this->defEngineSndBoost_ = nullptr; 70 this->defEngineSndNormal_ = nullptr; 71 this->lua_ = nullptr; 72 72 } 73 73 this->state_ = 0; … … 85 85 { 86 86 // We have no ship, so the effects are not attached and won't be destroyed automatically 87 for ( std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)88 for ( std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsBegin(); ++it2)89 (*it2)->destroy();87 for (EffectContainer* container : this->effectContainers_) 88 for (WorldEntity* effect : container->getEffects()) 89 effect->destroy(); 90 90 if (this->defEngineSndNormal_) 91 91 this->defEngineSndNormal_->destroy(); … … 124 124 this->state_ = 0; 125 125 if (this->getShip()->isBoosting() && forward) 126 this->state_ = Boost;126 this->state_ = EngineState::Boost; 127 127 else if (forward && !this->state_) // this->state_ == Boost 128 this->state_ = Normal;128 this->state_ = EngineState::Normal; 129 129 else if (direction.z > 0.0 && velocity.z < 0.0) 130 this->state_ = Brake;130 this->state_ = EngineState::Brake; 131 131 else 132 this->state_ = Idle;133 134 if (this->state_ == Idle && this->getSpeedAdd() > 0)135 this->state_ = Normal;132 this->state_ = EngineState::Idle; 133 134 if (this->state_ == EngineState::Idle && this->getSpeedAdd() > 0) 135 this->state_ = EngineState::Normal; 136 136 } 137 137 … … 141 141 142 142 float pitch = velocity.length(); 143 if (this->state_ & Normal)143 if (this->state_ & EngineState::Normal) 144 144 defEngineSndNormal_->setPitch(clamp(pitch/MAX_VELOCITY_NORMAL + 1, 0.5f, 2.0f)); 145 if (this->state_ & Boost)145 if (this->state_ & EngineState::Boost) 146 146 defEngineSndBoost_->setPitch(clamp(pitch/MAX_VELOCITY_BOOST + 1, 0.5f, 2.0f)); 147 147 148 if (changes & Idle)149 { 150 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Idle);148 if (changes & EngineState::Idle) 149 { 150 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Idle); 151 151 lua_setglobal(this->lua_->getInternalLuaState(), "idle"); 152 152 } 153 if (changes & Normal)154 { 155 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Normal);153 if (changes & EngineState::Normal) 154 { 155 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Normal); 156 156 lua_setglobal(this->lua_->getInternalLuaState(), "normal"); 157 if (this->state_ & Normal)157 if (this->state_ & EngineState::Normal) 158 158 defEngineSndNormal_->play(); 159 159 else 160 160 defEngineSndNormal_->stop(); 161 161 } 162 if (changes & Brake)163 { 164 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Brake);162 if (changes & EngineState::Brake) 163 { 164 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Brake); 165 165 lua_setglobal(this->lua_->getInternalLuaState(), "brake"); 166 166 } 167 if (changes & Boost)168 { 169 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Boost);167 if (changes & EngineState::Boost) 168 { 169 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Boost); 170 170 lua_setglobal(this->lua_->getInternalLuaState(), "boost"); 171 if (this->state_ & Boost)171 if (this->state_ & EngineState::Boost) 172 172 defEngineSndBoost_->play(); 173 173 else … … 178 178 179 179 // Update all effect conditions 180 for ( std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)181 (*it)->updateCondition();180 for (EffectContainer* container : this->effectContainers_) 181 container->updateCondition(); 182 182 } 183 183 } … … 198 198 this->getShip()->attach(defEngineSndBoost_); 199 199 200 for ( std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)201 for ( std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsEnd(); ++it2)202 this->getShip()->attach( *it2);203 } 204 205 void MultiStateEngine::addEffectContainer(EffectContainer* effect)206 { 207 if ( effect == NULL)200 for (EffectContainer* container : this->effectContainers_) 201 for (WorldEntity* effect : container->getEffects()) 202 this->getShip()->attach(effect); 203 } 204 205 void MultiStateEngine::addEffectContainer(EffectContainer* container) 206 { 207 if (container == nullptr) 208 208 return; 209 effect->setLuaState(this->lua_, 'f' + multi_cast<std::string>(this->effectContainers_.size()));210 this->effectContainers_.push_back( effect);209 container->setLuaState(this->lua_, 'f' + multi_cast<std::string>(this->effectContainers_.size())); 210 this->effectContainers_.push_back(container); 211 211 if (this->getShip()) 212 212 { 213 for ( std::vector<WorldEntity*>::const_iterator it = effect->getEffectsBegin(); it != effect->getEffectsBegin(); ++it)214 this->getShip()->attach( *it);213 for (WorldEntity* effect : container->getEffects()) 214 this->getShip()->attach(effect); 215 215 } 216 216 } … … 219 219 { 220 220 unsigned int i = 0; 221 for ( std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)221 for (EffectContainer* effectContainer : this->effectContainers_) 222 222 { 223 223 if (i == index) 224 return (*it); 225 } 226 return NULL; 224 return effectContainer; 225 i++; 226 } 227 return nullptr; 227 228 } 228 229 -
code/trunk/src/orxonox/items/MultiStateEngine.h
r9667 r11071 41 41 { 42 42 public: 43 enumEngineState43 struct EngineState 44 44 { 45 Idle = 1,46 Normal = 2,47 Brake = 4,48 Boost = 845 static constexpr int Idle = 1; 46 static constexpr int Normal = 2; 47 static constexpr int Brake = 4; 48 static constexpr int Boost = 8; 49 49 }; 50 50 … … 52 52 virtual ~MultiStateEngine(); 53 53 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 55 55 56 virtual void run(float dt) ;56 virtual void run(float dt) override; 57 57 58 virtual void addToSpaceShip(SpaceShip* ship) ;58 virtual void addToSpaceShip(SpaceShip* ship) override; 59 59 60 60 void addEffectContainer(EffectContainer* effect); -
code/trunk/src/orxonox/items/PartDestructionEvent.cc
r10262 r11071 98 98 { 99 99 switch (this->targetParam_) { 100 case shieldhealth:100 case TargetParam::shieldhealth: 101 101 this->parent_->getParent()->setShieldHealth(operate(this->parent_->getParent()->getShieldHealth())); 102 102 break; 103 case boostpower:103 case TargetParam::boostpower: 104 104 this->parent_->getParent()->setInitialBoostPower(operate(this->parent_->getParent()->getInitialBoostPower())); 105 105 break; 106 case boostpowerrate:106 case TargetParam::boostpowerrate: 107 107 this->parent_->getParent()->setBoostPowerRate(operate(this->parent_->getParent()->getBoostPowerRate())); 108 108 break; 109 case rotationthrust:109 case TargetParam::rotationthrust: 110 110 this->parent_->getParent()->setRotationThrust(operate(this->parent_->getParent()->getRotationThrust())); 111 111 break; … … 120 120 { 121 121 switch (this->targetParam_) { 122 case null:122 case TargetParam::null: 123 123 this->parent_->getParent()->getEngineByName(targetName_)->destroy(); 124 124 break; 125 case boostfactor:125 case TargetParam::boostfactor: 126 126 this->parent_->getParent()->getEngineByName(targetName_)->setBoostFactor(operate(this->parent_->getParent()->getEngineByName(targetName_)->getBoostFactor())); 127 127 break; 128 case speedfront:128 case TargetParam::speedfront: 129 129 this->parent_->getParent()->getEngineByName(targetName_)->setMaxSpeedFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getMaxSpeedFront())); 130 130 break; 131 case accelerationfront:131 case TargetParam::accelerationfront: 132 132 this->parent_->getParent()->getEngineByName(targetName_)->setAccelerationFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getAccelerationFront())); 133 133 break; … … 142 142 { 143 143 switch (this->targetParam_) { 144 case null:144 case TargetParam::null: 145 145 if (!this->parent_->getParent()->getShipPartByName(targetName_)) 146 146 return; … … 214 214 if (param == "NULL") 215 215 { 216 this->targetParam_ = null;216 this->targetParam_ = TargetParam::null; 217 217 return; 218 218 } 219 219 if (param == "boostfactor") 220 220 { 221 this->targetParam_ = boostfactor;221 this->targetParam_ = TargetParam::boostfactor; 222 222 return; 223 223 } 224 224 if (param == "speedfront") 225 225 { 226 this->targetParam_ = speedfront;226 this->targetParam_ = TargetParam::speedfront; 227 227 return; 228 228 } 229 229 if (param == "accelerationfront") 230 230 { 231 this->targetParam_ = accelerationfront;231 this->targetParam_ = TargetParam::accelerationfront; 232 232 return; 233 233 } … … 244 244 if (param == "shieldhealth") 245 245 { 246 this->targetParam_ = shieldhealth;246 this->targetParam_ = TargetParam::shieldhealth; 247 247 return; 248 248 } 249 249 if (param == "boostpower") 250 250 { 251 this->targetParam_ = boostpower;251 this->targetParam_ = TargetParam::boostpower; 252 252 return; 253 253 } 254 254 if (param == "boostpowerrate") 255 255 { 256 this->targetParam_ = boostpowerrate;256 this->targetParam_ = TargetParam::boostpowerrate; 257 257 return; 258 258 } 259 259 if (param == "rotationthrust") 260 260 { 261 this->targetParam_ = rotationthrust;261 this->targetParam_ = TargetParam::rotationthrust; 262 262 return; 263 263 } … … 271 271 if (param == "NULL") 272 272 { 273 this->targetParam_ = null;273 this->targetParam_ = TargetParam::null; 274 274 return; 275 275 } -
code/trunk/src/orxonox/items/PartDestructionEvent.h
r10262 r11071 82 82 List of all allowed parameters. 83 83 */ 84 enum TargetParam84 enum class TargetParam 85 85 { 86 86 shieldhealth, … … 100 100 virtual ~PartDestructionEvent(); 101 101 102 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;102 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 103 103 104 104 void execute(); -
code/trunk/src/orxonox/items/ShipPart.cc
r11052 r11071 49 49 50 50 ShipPart::ShipPart(Context* context) 51 : Item(context), parent_( NULL)51 : Item(context), parent_(nullptr) 52 52 { 53 53 RegisterObject(ShipPart); … … 121 121 void ShipPart::addEntity(StaticEntity* entity) 122 122 { 123 OrxAssert(entity != NULL, "The Entity cannot be NULL.");123 OrxAssert(entity != nullptr, "The Entity cannot be nullptr."); 124 124 this->entityList_.push_back(entity); 125 125 } … … 129 129 Get the i-th StaticEntity of the ShipPart. 130 130 @return 131 Returns a pointer to the i-the StaticEntity. NULLif there is no StaticEntity with that index.131 Returns a pointer to the i-the StaticEntity. nullptr if there is no StaticEntity with that index. 132 132 */ 133 133 StaticEntity* ShipPart::getEntity(unsigned int index) 134 134 { 135 135 if(this->entityList_.size() >= index) 136 return NULL;136 return nullptr; 137 137 else 138 138 return this->entityList_[index]; … … 142 142 @brief 143 143 Check whether the ShipPart has a particular Entity. 144 @param engine144 @param search 145 145 A pointer to the Entity to be checked. 146 146 */ 147 bool ShipPart::hasEntity(StaticEntity* entity) const148 { 149 for( unsigned int i = 0; i < this->entityList_.size(); i++)150 { 151 if( this->entityList_[i] == entity)147 bool ShipPart::hasEntity(StaticEntity* search) const 148 { 149 for(StaticEntity* entity : this->entityList_) 150 { 151 if(entity == search) 152 152 return true; 153 153 } … … 163 163 void ShipPart::addDestructionEvent(PartDestructionEvent* event) 164 164 { 165 OrxAssert(event != NULL, "The PartDestructionEvent cannot be NULL.");165 OrxAssert(event != nullptr, "The PartDestructionEvent cannot be nullptr."); 166 166 event->setParent(this); 167 167 this->eventList_.push_back(event); … … 172 172 Get the i-th PartDestructionEvent of the ShipPart. 173 173 @return 174 Returns a pointer to the i-the PartDestructionEvent. NULLif there is no PartDestructionEvent with that index.174 Returns a pointer to the i-the PartDestructionEvent. nullptr if there is no PartDestructionEvent with that index. 175 175 */ 176 176 PartDestructionEvent* ShipPart::getDestructionEvent(unsigned int index) 177 177 { 178 178 if(this->eventList_.size() <= index) 179 return NULL;179 return nullptr; 180 180 else 181 181 return this->eventList_[index]; 182 182 } 183 183 184 void ShipPart::setDamageAbsorption(float value)185 {186 this->damageAbsorption_ = value;187 }188 189 184 void ShipPart::setParent(ModularSpaceShip* ship) 190 185 { 191 186 this->parent_ = ship; 192 }193 194 /**195 @brief196 Sets the health of the ShipPart.197 */198 void ShipPart::setHealth(float health)199 {200 this->health_ = health;201 187 } 202 188 -
code/trunk/src/orxonox/items/ShipPart.h
r10624 r11071 47 47 virtual ~ShipPart(); 48 48 49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 50 50 51 51 virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator); … … 64 64 PartDestructionEvent* getDestructionEvent(unsigned int index); 65 65 66 virtual void setDamageAbsorption(float value); 67 inline float getDamageAbsorption() 66 inline void setDamageAbsorption(float value) 67 { this->damageAbsorption_ = value; } 68 inline float getDamageAbsorption() const 68 69 { return this->damageAbsorption_; } 69 70 70 71 void setParent(ModularSpaceShip* ship); 71 inline ModularSpaceShip* getParent() 72 inline ModularSpaceShip* getParent() const 72 73 { return this->parent_; } 73 74 74 75 inline void setEventExecution(bool var) 75 76 { this->eventExecution_ = var; } 76 inline bool isEventExecution() 77 inline bool isEventExecution() const 77 78 { return this->eventExecution_; } 78 79 79 virtual void setHealth(float health); 80 inline void setHealth(float health) 81 { this->health_ = health; } 80 82 inline void addHealth(float health) 81 83 { this->setHealth(this->health_ + health); } -
code/trunk/src/orxonox/overlays/GUISheet.h
r9667 r11071 44 44 ~GUISheet(); 45 45 46 v oid XMLPort(Element& xmlelement, XMLPort::Mode mode);46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 47 47 48 48 void show(); -
code/trunk/src/orxonox/overlays/InGameConsole.cc
r10624 r11071 75 75 : shell_(new Shell("InGameConsole", true)) 76 76 , bShowCursor_(false) 77 , consoleOverlay_( 0)78 , consoleOverlayContainer_( 0)79 , consoleOverlayNoise_( 0)80 , consoleOverlayCursor_( 0)81 , consoleOverlayBorder_( 0)82 , consoleOverlayTextAreas_( 0)83 , inputState_( 0)77 , consoleOverlay_(nullptr) 78 , consoleOverlayContainer_(nullptr) 79 , consoleOverlayNoise_(nullptr) 80 , consoleOverlayCursor_(nullptr) 81 , consoleOverlayBorder_(nullptr) 82 , consoleOverlayTextAreas_(nullptr) 83 , inputState_(nullptr) 84 84 { 85 85 RegisterObject(InGameConsole); … … 130 130 if (this->consoleOverlayTextAreas_[i]) 131 131 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]); 132 this->consoleOverlayTextAreas_[i] = 0;132 this->consoleOverlayTextAreas_[i] = nullptr; 133 133 } 134 134 … … 140 140 { 141 141 delete[] this->consoleOverlayTextAreas_; 142 this->consoleOverlayTextAreas_ = 0;142 this->consoleOverlayTextAreas_ = nullptr; 143 143 } 144 144 … … 175 175 else 176 176 { 177 inputState_->setMouseHandler( 0);178 inputState_->setJoyStickHandler( 0);177 inputState_->setMouseHandler(nullptr); 178 inputState_->setJoyStickHandler(nullptr); 179 179 } 180 180 } … … 292 292 293 293 for (int i = LINES - 1; i > max; --i) 294 this->print("", Shell:: DebugOutput, i, true);294 this->print("", Shell::LineType::DebugOutput, i, true); 295 295 296 296 for (int i = max; i >= 1; --i) … … 318 318 { 319 319 if (LINES > 0) 320 this->print(this->shell_->getInput(), Shell:: Input, 0);320 this->print(this->shell_->getInput(), Shell::LineType::Input, 0); 321 321 322 322 if (this->shell_->getInput().empty()) … … 342 342 void InGameConsole::executed() 343 343 { 344 this->shell_->addOutput(this->shell_->getInput(), Shell:: Command);344 this->shell_->addOutput(this->shell_->getInput(), Shell::LineType::Command); 345 345 } 346 346 … … 562 562 switch (type) 563 563 { 564 case Shell:: Message:565 case Shell:: DebugOutput: colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;566 567 case Shell:: UserError: colourTop = ColourValue(0.9f, 0.0f, 0.0f); break;568 case Shell:: UserWarning: colourTop = ColourValue(0.9f, 0.5f, 0.0f); break;569 case Shell:: UserStatus: colourTop = ColourValue(0.0f, 0.9f, 0.0f); break;570 case Shell:: UserInfo: colourTop = ColourValue(0.0f, 0.8f, 0.8f); break;571 572 case Shell:: InternalError: colourTop = ColourValue(0.5f, 0.0f, 0.0f); break;573 case Shell:: InternalWarning: colourTop = ColourValue(0.5f, 0.2f, 0.0f); break;574 case Shell:: InternalStatus: colourTop = ColourValue(0.0f, 0.5f, 0.0f); break;575 case Shell:: InternalInfo: colourTop = ColourValue(0.0f, 0.4f, 0.4f); break;576 577 case Shell:: Verbose: colourTop = ColourValue(0.3f, 0.3f, 0.9f); break;578 case Shell:: VerboseMore: colourTop = ColourValue(0.2f, 0.2f, 0.7f); break;579 case Shell:: VerboseUltra: colourTop = ColourValue(0.1f, 0.1f, 0.5f); break;580 581 case Shell:: Command: colourTop = ColourValue(0.8f, 0.2f, 0.8f); break;582 case Shell:: Hint: colourTop = ColourValue(0.4f, 0.0f, 0.4f); break;583 case Shell:: Input: colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;584 585 default: colourTop = ColourValue(0.5f, 0.5f, 0.5f); break;564 case Shell::LineType::Message: 565 case Shell::LineType::DebugOutput: colourTop = ColourValue(0.9f, 0.9f, 0.9f); break; 566 567 case Shell::LineType::UserError: colourTop = ColourValue(0.9f, 0.0f, 0.0f); break; 568 case Shell::LineType::UserWarning: colourTop = ColourValue(0.9f, 0.5f, 0.0f); break; 569 case Shell::LineType::UserStatus: colourTop = ColourValue(0.0f, 0.9f, 0.0f); break; 570 case Shell::LineType::UserInfo: colourTop = ColourValue(0.0f, 0.8f, 0.8f); break; 571 572 case Shell::LineType::InternalError: colourTop = ColourValue(0.5f, 0.0f, 0.0f); break; 573 case Shell::LineType::InternalWarning: colourTop = ColourValue(0.5f, 0.2f, 0.0f); break; 574 case Shell::LineType::InternalStatus: colourTop = ColourValue(0.0f, 0.5f, 0.0f); break; 575 case Shell::LineType::InternalInfo: colourTop = ColourValue(0.0f, 0.4f, 0.4f); break; 576 577 case Shell::LineType::Verbose: colourTop = ColourValue(0.3f, 0.3f, 0.9f); break; 578 case Shell::LineType::VerboseMore: colourTop = ColourValue(0.2f, 0.2f, 0.7f); break; 579 case Shell::LineType::VerboseUltra: colourTop = ColourValue(0.1f, 0.1f, 0.5f); break; 580 581 case Shell::LineType::Command: colourTop = ColourValue(0.8f, 0.2f, 0.8f); break; 582 case Shell::LineType::Hint: colourTop = ColourValue(0.4f, 0.0f, 0.4f); break; 583 case Shell::LineType::Input: colourTop = ColourValue(0.9f, 0.9f, 0.9f); break; 584 585 default: colourTop = ColourValue(0.5f, 0.5f, 0.5f); break; 586 586 } 587 587 -
code/trunk/src/orxonox/overlays/InGameConsole.h
r10624 r11071 53 53 void setConfigValues(); 54 54 55 v oid preUpdate(const Clock& time);56 v oid postUpdate(const Clock& time){ /*no action*/ }55 virtual void preUpdate(const Clock& time) override; 56 virtual void postUpdate(const Clock& time) override { /*no action*/ } 57 57 58 58 static void openConsole(); … … 65 65 void deactivate(); 66 66 67 v oid linesChanged();68 v oid lineAdded();69 v oid inputChanged();70 v oid cursorChanged();71 v oid executed();72 v oid exit();67 virtual void linesChanged() override; 68 virtual void lineAdded() override; 69 virtual void inputChanged() override; 70 virtual void cursorChanged() override; 71 virtual void executed() override; 72 virtual void exit() override; 73 73 74 74 void shiftLines(); … … 77 77 void print(const std::string& text, Shell::LineType type, int index, bool alwaysShift = false); 78 78 79 v oid windowResized(unsigned int newWidth, unsigned int newHeight);79 virtual void windowResized(unsigned int newWidth, unsigned int newHeight) override; 80 80 81 81 // config value related -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r11052 r11071 70 70 RegisterObject(OrxonoxOverlay); 71 71 72 this->owner_ = 0;73 this->group_ = 0;72 this->owner_ = nullptr; 73 this->group_ = nullptr; 74 74 75 75 if (!GameMode::showsGraphics()) … … 94 94 this->angle_ = Degree(0.0); 95 95 this->bCorrectAspect_ = false; 96 this->rotState_ = Horizontal;96 this->rotState_ = RotationState::Horizontal; 97 97 this->angleChanged(); // updates all other values as well 98 98 … … 259 259 { 260 260 tempAspect = 1.0f / this->windowAspectRatio_; 261 rotState_ = Vertical;261 rotState_ = RotationState::Vertical; 262 262 } 263 263 else if (angle > 179 || angle < 1) 264 264 { 265 265 tempAspect = this->windowAspectRatio_; 266 rotState_ = Horizontal;266 rotState_ = RotationState::Horizontal; 267 267 } 268 268 else 269 269 { 270 270 tempAspect = 1.0f; 271 rotState_ = Inbetween;271 rotState_ = RotationState::Inbetween; 272 272 } 273 273 -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r11052 r11071 79 79 and in between is everything else. 80 80 */ 81 enum RotationState81 enum class RotationState 82 82 { 83 83 Horizontal, … … 90 90 virtual ~OrxonoxOverlay(); 91 91 92 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;93 94 virtual void changedName() ;92 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 93 94 virtual void changedName() override; 95 95 96 96 //! Shows the overlay with an detour to BaseObject::visibility_ … … 167 167 void setBackgroundColour(ColourValue colour); 168 168 169 virtual void changedVisibility() ;169 virtual void changedVisibility() override; 170 170 171 171 inline void setOwner(BaseObject* owner) … … 186 186 virtual void changedOverlayGroup() 187 187 { this->changedVisibility(); } 188 v irtual void setZOrder(unsigned short order);188 void setZOrder(unsigned short order); 189 189 190 190 protected: … … 207 207 208 208 private: 209 v oid windowResized(unsigned int newWidth, unsigned int newHeight);209 virtual void windowResized(unsigned int newWidth, unsigned int newHeight) override; 210 210 211 211 static unsigned int hudOverlayCounter_s; //!< Static counter for hud elements -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r11052 r11071 51 51 { 52 52 ArgumentCompletionList names; 53 for (O bjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)54 names.push_back(ArgumentCompletionListElement( it->getName(), getLowercase(it->getName())));53 for (OverlayGroup* overlayGroup : ObjectList<OverlayGroup>()) 54 names.push_back(ArgumentCompletionListElement(overlayGroup->getName(), getLowercase(overlayGroup->getName()))); 55 55 return names; 56 56 } … … 69 69 RegisterObject(OverlayGroup); 70 70 71 this->owner_ = 0;71 this->owner_ = nullptr; 72 72 73 73 setScale(Vector2(1.0, 1.0)); … … 77 77 OverlayGroup::~OverlayGroup() 78 78 { 79 for ( std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)80 (*it)->destroy();79 for (OrxonoxOverlay* hudElement : hudElements_) 80 hudElement->destroy(); 81 81 this->hudElements_.clear(); 82 82 } … … 101 101 void OverlayGroup::setScale(const Vector2& scale) 102 102 { 103 for ( std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)104 (*it)->scale(scale / this->scale_);103 for (OrxonoxOverlay* hudElement : hudElements_) 104 hudElement->scale(scale / this->scale_); 105 105 this->scale_ = scale; 106 106 } … … 109 109 void OverlayGroup::setScroll(const Vector2& scroll) 110 110 { 111 for ( std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)112 (*it)->scroll(scroll - this->scroll_);111 for (OrxonoxOverlay* hudElement : hudElements_) 112 hudElement->scroll(scroll - this->scroll_); 113 113 this->scroll_ = scroll; 114 114 } … … 148 148 if (index < this->hudElements_.size()) 149 149 { 150 std::set< StrongPtr<OrxonoxOverlay>>::const_iterator it = hudElements_.begin();150 std::set<StrongPtr<OrxonoxOverlay>>::const_iterator it = hudElements_.begin(); 151 151 for (unsigned int i = 0; i != index; ++it, ++i) 152 152 ; … … 154 154 } 155 155 else 156 return 0;156 return nullptr; 157 157 } 158 158 … … 162 162 SUPER( OverlayGroup, changedVisibility ); 163 163 164 for ( std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)165 (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed164 for (OrxonoxOverlay* hudElement : hudElements_) 165 hudElement->changedVisibility(); //inform all Child Overlays that our visibility has changed 166 166 } 167 167 … … 170 170 this->owner_ = owner; 171 171 172 for ( std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)173 (*it)->setOwner(owner);172 for (OrxonoxOverlay* hudElement : hudElements_) 173 hudElement->setOwner(owner); 174 174 } 175 175 … … 185 185 /*static*/ void OverlayGroup::toggleVisibility(const std::string& name) 186 186 { 187 for (O bjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)188 { 189 if ( (*it)->getName() == name)190 (*it)->setVisible(!((*it)->isVisible()));187 for (OverlayGroup* group : ObjectList<OverlayGroup>()) 188 { 189 if (group->getName() == name) 190 group->setVisible(!(group->isVisible())); 191 191 } 192 192 } … … 200 200 /*static*/ void OverlayGroup::show(const std::string& name) 201 201 { 202 for (O bjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)203 { 204 if ( (*it)->getName() == name)202 for (OverlayGroup* group : ObjectList<OverlayGroup>()) 203 { 204 if (group->getName() == name) 205 205 { 206 if( (*it)->isVisible())207 (*it)->changedVisibility();206 if(group->isVisible()) 207 group->changedVisibility(); 208 208 else 209 (*it)->setVisible(!((*it)->isVisible()));209 group->setVisible(!(group->isVisible())); 210 210 } 211 211 } … … 223 223 /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale) 224 224 { 225 for (O bjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)226 { 227 if ( (*it)->getName() == name)228 (*it)->scale(Vector2(scale, scale));225 for (OverlayGroup* group : ObjectList<OverlayGroup>()) 226 { 227 if (group->getName() == name) 228 group->scale(Vector2(scale, scale)); 229 229 } 230 230 } … … 241 241 /*static*/ void OverlayGroup::scrollGroup(const std::string& name, const Vector2& scroll) 242 242 { 243 for (O bjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)244 { 245 if ( (*it)->getName() == name)246 (*it)->scroll(scroll);243 for (OverlayGroup* group : ObjectList<OverlayGroup>()) 244 { 245 if (group->getName() == name) 246 group->scroll(scroll); 247 247 } 248 248 } -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r10624 r11071 58 58 ~OverlayGroup(); 59 59 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 61 61 62 62 static void toggleVisibility(const std::string& name); … … 65 65 static void scrollGroup(const std::string& name, const Vector2& scroll); 66 66 67 inline const std::set< StrongPtr<OrxonoxOverlay>>& getOverlays() const67 inline const std::set<StrongPtr<OrxonoxOverlay>>& getOverlays() const 68 68 { return this->hudElements_; } 69 69 70 virtual void changedVisibility() ;70 virtual void changedVisibility() override; 71 71 72 72 void setOwner(BaseObject* owner); … … 91 91 92 92 private: 93 std::set< StrongPtr<OrxonoxOverlay>> hudElements_; //!< Contains all the OrxonoxOverlays of the this group.93 std::set<StrongPtr<OrxonoxOverlay>> hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 94 94 Vector2 scale_; //!< Current scale (independent of the elements). 95 95 Vector2 scroll_; //!< Current scrolling offset. -
code/trunk/src/orxonox/sound/AmbientSound.cc
r10624 r11071 92 92 { 93 93 const std::string& path = "ambient/" + mood + '/' + this->ambientSource_; 94 s hared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path);95 if (fileInfo != NULL)94 std::shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path); 95 if (fileInfo != nullptr) 96 96 { 97 97 orxout(user_info) << "Loading ambient sound " << path << "..." << endl; // TODO: make this output internal if we implement sound streaming -
code/trunk/src/orxonox/sound/AmbientSound.h
r9939 r11071 50 50 AmbientSound(); 51 51 52 v oid play();53 bool stop();54 v oid pause();52 virtual void play() override; 53 virtual bool stop() override; 54 virtual void pause() override; 55 55 56 56 bool setAmbientSource(const std::string& source); … … 66 66 67 67 private: 68 v oid preDestroy();69 float getRealVolume();70 bool moodChanged(const std::string& mood);68 virtual void preDestroy() override; 69 virtual float getRealVolume() override; 70 virtual bool moodChanged(const std::string& mood) override; 71 71 inline void ambientSourceChanged() 72 72 { this->setAmbientSource(this->ambientSource_); } -
code/trunk/src/orxonox/sound/BaseSound.cc
r10624 r11071 49 49 , volume_(0.7) 50 50 , bLooping_(false) 51 , state_(St opped)51 , state_(State::Stopped) 52 52 , pitch_ (1.0) 53 53 { … … 63 63 BaseSound::~BaseSound() 64 64 { 65 if (this->state_ != St opped)65 if (this->state_ != State::Stopped) 66 66 this->stop(); 67 67 // Release buffer 68 if (this->soundBuffer_ != NULL)68 if (this->soundBuffer_ != nullptr) 69 69 { 70 70 assert(GameMode::playsSound()); … … 83 83 void BaseSound::doPlay() 84 84 { 85 this->state_ = Playing;86 if (GameMode::playsSound() && this->getSourceState() != AL_PLAYING && this->soundBuffer_ != NULL)85 this->state_ = State::Playing; 86 if (GameMode::playsSound() && this->getSourceState() != AL_PLAYING && this->soundBuffer_ != nullptr) 87 87 { 88 88 if (!alIsSource(this->audioSource_)) … … 102 102 bool BaseSound::doStop() 103 103 { 104 this->state_ = St opped;104 this->state_ = State::Stopped; 105 105 if (alIsSource(this->audioSource_)) 106 106 { … … 123 123 if (this->isStopped()) 124 124 return; 125 this->state_ = Paused;125 this->state_ = State::Paused; 126 126 if (alIsSource(this->audioSource_)) 127 127 alSourcePause(this->audioSource_); … … 151 151 orxout(internal_warning, context::sound) << "Setting source parameters to 0 failed: " 152 152 << SoundManager::getALErrorString(error) << endl; 153 assert(this->soundBuffer_ != NULL);153 assert(this->soundBuffer_ != nullptr); 154 154 alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer()); 155 155 if (ALuint error = alGetError()) … … 209 209 } 210 210 211 if (this->soundBuffer_ != NULL)211 if (this->soundBuffer_ != nullptr) 212 212 { 213 213 if (this->soundBuffer_->getFilename() == source) … … 233 233 // Get new sound buffer 234 234 this->soundBuffer_ = SoundManager::getInstance().getSoundBuffer(this->source_); 235 if (this->soundBuffer_ == NULL)235 if (this->soundBuffer_ == nullptr) 236 236 return; 237 237 … … 256 256 else // No source acquired so far, but might be set to playing or paused 257 257 { 258 State state = static_cast<State>(this->state_); // save258 State state = this->state_; // save 259 259 if (this->isPlaying() || this->isPaused()) 260 260 doPlay(); 261 if (state == Paused)262 { 263 this->state_ = Paused;261 if (state == State::Paused) 262 { 263 this->state_ = State::Paused; 264 264 doPause(); 265 265 } … … 271 271 switch (this->state_) 272 272 { 273 case Playing:273 case State::Playing: 274 274 this->play(); 275 275 break; 276 case Paused:276 case State::Paused: 277 277 this->pause(); 278 278 break; 279 case St opped:279 case State::Stopped: 280 280 default: 281 281 this->stop(); -
code/trunk/src/orxonox/sound/BaseSound.h
r9667 r11071 33 33 34 34 #include <string> 35 #include < boost/shared_ptr.hpp>35 #include <memory> 36 36 #include <OgreDataStream.h> 37 37 #include "core/object/Listable.h" … … 54 54 virtual void pause() { this->doPause(); } 55 55 56 bool isPlaying() const { return this->state_ == Playing; }57 bool isPaused() const { return this->state_ == Paused; }58 bool isStopped() const { return this->state_ == St opped; }56 bool isPlaying() const { return this->state_ == State::Playing; } 57 bool isPaused() const { return this->state_ == State::Paused; } 58 bool isStopped() const { return this->state_ == State::Stopped; } 59 59 60 60 virtual void setSource(const std::string& source); … … 76 76 77 77 protected: 78 enum State78 enum class State 79 79 { 80 80 Stopped, … … 107 107 ALuint audioSource_; 108 108 bool bPooling_; 109 s hared_ptr<SoundBuffer> soundBuffer_;109 std::shared_ptr<SoundBuffer> soundBuffer_; 110 110 std::string source_; 111 111 float volume_; 112 112 bool bLooping_; 113 uint8_tstate_; // This Variable is actually of type State113 State state_; // This Variable is actually of type State 114 114 float pitch_; 115 115 -
code/trunk/src/orxonox/sound/SoundBuffer.cc
r8858 r11071 39 39 namespace orxonox 40 40 { 41 SoundBuffer::SoundBuffer(const std::string& filename, std::list<s hared_ptr<SoundBuffer>>::iterator poolIterator)41 SoundBuffer::SoundBuffer(const std::string& filename, std::list<std::shared_ptr<SoundBuffer>>::iterator poolIterator) 42 42 : filename_(filename) 43 43 , audioBuffer_(AL_NONE) … … 45 45 { 46 46 if (this->filename_.empty()) 47 ThrowException(General, "SoundBuffer construction: fileInfo was NULL");47 ThrowException(General, "SoundBuffer construction: fileInfo was nullptr"); 48 48 49 49 // Get resource info 50 s hared_ptr<ResourceInfo> fileInfo = Resource::getInfo(filename);51 if (fileInfo == NULL)50 std::shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(filename); 51 if (fileInfo == nullptr) 52 52 { 53 53 orxout(internal_error, context::sound) << "Sound file '" << filename << "' not found" << endl; … … 83 83 } 84 84 85 void SoundBuffer::loadStandard(const s hared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream)85 void SoundBuffer::loadStandard(const std::shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream) 86 86 { 87 87 // Read everything into a temporary buffer … … 127 127 } 128 128 129 void SoundBuffer::loadOgg(const s hared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream)129 void SoundBuffer::loadOgg(const std::shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream) 130 130 { 131 131 char inbuffer[256*1024]; … … 138 138 vorbisCallbacks.seek_func = &seekVorbis; 139 139 vorbisCallbacks.tell_func = &tellVorbis; 140 vorbisCallbacks.close_func = NULL;140 vorbisCallbacks.close_func = nullptr; 141 141 142 142 OggVorbis_File vf; 143 int ret = ov_open_callbacks(dataStream.get(), &vf, NULL, 0, vorbisCallbacks);143 int ret = ov_open_callbacks(dataStream.get(), &vf, nullptr, 0, vorbisCallbacks); 144 144 if (ret < 0) 145 145 { -
code/trunk/src/orxonox/sound/SoundBuffer.h
r10624 r11071 33 33 34 34 #include <list> 35 #include < boost/shared_ptr.hpp>35 #include <memory> 36 36 #include "core/Resource.h" 37 37 … … 45 45 { 46 46 friend class SoundManager; 47 #if !defined(_MSC_VER) || _MSC_VER >= 150048 // Make sure nobody deletes an instance (using strong pointers)49 template <class T>50 friend void boost::checked_delete(T*);51 #endif52 47 53 48 public: 54 #if defined(_MSC_VER) && _MSC_VER < 150055 49 ~SoundBuffer(); 56 #endif57 50 inline ALuint getBuffer() 58 51 { return this->audioBuffer_; } … … 64 57 65 58 private: 66 SoundBuffer(const std::string& filename, std::list<shared_ptr<SoundBuffer> >::iterator poolIterator); 67 #if !defined(_MSC_VER) || _MSC_VER >= 1500 68 ~SoundBuffer(); 69 #endif 70 void loadStandard(const shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream); 71 void loadOgg(const shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream); 59 SoundBuffer(const std::string& filename, std::list<std::shared_ptr<SoundBuffer>>::iterator poolIterator); 60 void loadStandard(const std::shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream); 61 void loadOgg(const std::shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream); 72 62 73 63 std::string filename_; 74 64 ALuint audioBuffer_; 75 std::list<s hared_ptr<SoundBuffer>>::iterator poolIterator_;65 std::list<std::shared_ptr<SoundBuffer>>::iterator poolIterator_; 76 66 }; 77 67 } -
code/trunk/src/orxonox/sound/SoundManager.cc
r10624 r11071 83 83 ThrowException(InitialisationAborted, "Sound: Not loading at all"); 84 84 #if !defined(ORXONOX_PLATFORM_APPLE) 85 if (!alutInitWithoutContext( NULL, NULL))85 if (!alutInitWithoutContext(nullptr, nullptr)) 86 86 ThrowException(InitialisationFailed, "Sound Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError())); 87 87 Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit); … … 90 90 /* 91 91 // Get list of available sound devices and display them 92 const char* devices = alcGetString( NULL, ALC_DEVICE_SPECIFIER);92 const char* devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER); 93 93 char* device = new char[strlen(devices)+1]; 94 94 strcpy(device, devices); … … 110 110 this->device_ = alcOpenDevice(renderDevice.c_str()); 111 111 */ 112 this->device_ = alcOpenDevice( NULL);113 if (this->device_ == NULL)112 this->device_ = alcOpenDevice(nullptr); 113 if (this->device_ == nullptr) 114 114 ThrowException(InitialisationFailed, "Sound Error: Could not open sound device."); 115 115 Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_); 116 116 117 117 // Create sound context and make it the currently used one 118 this->context_ = alcCreateContext(this->device_, NULL);119 if (this->context_ == NULL)118 this->context_ = alcCreateContext(this->device_, nullptr); 119 if (this->context_ == nullptr) 120 120 ThrowException(InitialisationFailed, "Sound Error: Could not create ALC context"); 121 121 Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_); … … 189 189 190 190 // Relieve context to destroy it 191 if (!alcMakeContextCurrent( NULL))191 if (!alcMakeContextCurrent(nullptr)) 192 192 orxout(internal_error, context::sound) << "Could not unset ALC context" << endl; 193 193 alcDestroyContext(this->context_); … … 294 294 { 295 295 case SoundType::All: 296 for ( ObjectList<BaseSound>::iterator it = ObjectList<BaseSound>::begin(); it != ObjectList<BaseSound>::end(); ++it)297 (*it)->updateVolume();296 for (BaseSound* sound : ObjectList<BaseSound>()) 297 sound->updateVolume(); 298 298 break; 299 299 case SoundType::Music: 300 for ( ObjectList<AmbientSound>::iterator it = ObjectList<AmbientSound>::begin(); it != ObjectList<AmbientSound>::end(); ++it)301 (*it)->updateVolume();300 for (AmbientSound* sound : ObjectList<AmbientSound>()) 301 sound->updateVolume(); 302 302 break; 303 303 case SoundType::Effects: 304 for ( ObjectList<WorldSound>::iterator it = ObjectList<WorldSound>::begin(); it != ObjectList<WorldSound>::end(); ++it)305 (*it)->updateVolume();304 for (WorldSound* sound : ObjectList<WorldSound>()) 305 sound->updateVolume(); 306 306 break; 307 307 default: … … 350 350 void SoundManager::registerAmbientSound(AmbientSound* newAmbient) 351 351 { 352 if (newAmbient != NULL&& !this->bDestructorCalled_)352 if (newAmbient != nullptr && !this->bDestructorCalled_) 353 353 { 354 354 for (AmbientList::const_iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it) … … 373 373 void SoundManager::unregisterAmbientSound(AmbientSound* oldAmbient) 374 374 { 375 if (oldAmbient == NULL|| ambientSounds_.empty() || this->bDestructorCalled_)375 if (oldAmbient == nullptr || ambientSounds_.empty() || this->bDestructorCalled_) 376 376 return; 377 377 … … 405 405 void SoundManager::pauseAmbientSound(AmbientSound* ambient) 406 406 { 407 if (ambient != NULL)408 { 409 for ( AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)410 { 411 if ( it->first == ambient)407 if (ambient != nullptr) 408 { 409 for (std::pair<AmbientSound*, bool>& pair : this->ambientSounds_) 410 { 411 if (pair.first == ambient) 412 412 { 413 it->second = true;414 this->fadeOut( it->first);413 pair.second = true; 414 this->fadeOut(pair.first); 415 415 return; 416 416 } … … 422 422 { 423 423 // If we're already fading out --> remove that 424 for (std::list<StrongPtr<AmbientSound> 424 for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++) 425 425 { 426 426 if (*it == sound) … … 438 438 { 439 439 // If we're already fading in --> remove that 440 for (std::list<StrongPtr<AmbientSound> 440 for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++) 441 441 { 442 442 if (*it == sound) … … 461 461 462 462 // FADE IN 463 for (std::list<StrongPtr<AmbientSound> 463 for (std::list<StrongPtr<AmbientSound>>::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); ) 464 464 { 465 465 if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f) … … 476 476 477 477 // FADE OUT 478 for (std::list<StrongPtr<AmbientSound> 478 for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); ) 479 479 { 480 480 if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f) … … 505 505 } 506 506 507 s hared_ptr<SoundBuffer> SoundManager::getSoundBuffer(const std::string& filename)508 { 509 s hared_ptr<SoundBuffer> buffer;507 std::shared_ptr<SoundBuffer> SoundManager::getSoundBuffer(const std::string& filename) 508 { 509 std::shared_ptr<SoundBuffer> buffer; 510 510 // Check active or pooled buffers 511 511 SoundBufferMap::const_iterator it = this->soundBuffers_.find(filename); … … 538 538 } 539 539 540 void SoundManager::releaseSoundBuffer(const s hared_ptr<SoundBuffer>& buffer, bool bPoolBuffer)540 void SoundManager::releaseSoundBuffer(const std::shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer) 541 541 { 542 542 // Check if others are still using the buffer … … 551 551 while (this->effectsPoolSize_ + it->second->getSize() > this->maxEffectsPoolSize_s && !this->effectsPool_.empty()) 552 552 { 553 s hared_ptr<SoundBuffer> bufferDel = this->effectsPool_.back();553 std::shared_ptr<SoundBuffer> bufferDel = this->effectsPool_.back(); 554 554 this->effectsPoolSize_ -= bufferDel->getSize(); 555 555 bufferDel->poolIterator_ = this->effectsPool_.end(); … … 576 576 ALuint source = this->availableSoundSources_.back(); 577 577 this->availableSoundSources_.pop_back(); 578 this->usedSoundSources_. push_back(std::make_pair(source, object));578 this->usedSoundSources_.emplace_back(source, object); 579 579 return source; 580 580 } … … 588 588 if (alIsSource(source) && !alGetError()) 589 589 { 590 this->usedSoundSources_. push_back(std::make_pair(source, object));590 this->usedSoundSources_.emplace_back(source, object); 591 591 return source; 592 592 } … … 606 606 #endif 607 607 this->availableSoundSources_.push_back(source); 608 for (std::vector<std::pair<ALuint, BaseSound*> 608 for (std::vector<std::pair<ALuint, BaseSound*>>::iterator it = this->usedSoundSources_.begin(); 609 609 it != this->usedSoundSources_.end(); ++it) 610 610 { -
code/trunk/src/orxonox/sound/SoundManager.h
r10624 r11071 36 36 #include <map> 37 37 #include <string> 38 #include < boost/shared_ptr.hpp>38 #include <memory> 39 39 40 40 #include "util/Singleton.h" … … 68 68 ~SoundManager(); 69 69 70 v oid preUpdate(const Clock& time);71 v oid postUpdate(const Clock& time){ /*no action*/ }70 virtual void preUpdate(const Clock& time) override; 71 virtual void postUpdate(const Clock& time) override { /*no action*/ } 72 72 void setConfigValues(); 73 73 … … 96 96 // tolua_end 97 97 98 s hared_ptr<SoundBuffer> getSoundBuffer(const std::string& filename);99 void releaseSoundBuffer(const s hared_ptr<SoundBuffer>& buffer, bool bPoolBuffer);98 std::shared_ptr<SoundBuffer> getSoundBuffer(const std::string& filename); 99 void releaseSoundBuffer(const std::shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer); 100 100 101 101 ALuint getSoundSource(BaseSound* object); … … 125 125 126 126 // Ambient sound related 127 typedef std::list<std::pair<AmbientSound*, bool> 127 typedef std::list<std::pair<AmbientSound*, bool>> AmbientList; 128 128 AmbientList ambientSounds_; 129 129 //! Absolute change per second (0.1 means 10% of the nominal volume) for cross fading 130 130 float crossFadeStep_; 131 std::list<StrongPtr<AmbientSound> 132 std::list<StrongPtr<AmbientSound> 131 std::list<StrongPtr<AmbientSound>> fadeInList_; 132 std::list<StrongPtr<AmbientSound>> fadeOutList_; 133 133 134 134 // Volume related … … 139 139 static const unsigned int maxEffectsPoolSize_s = 40 * 1024 * 1024; 140 140 unsigned int effectsPoolSize_; 141 typedef std::list<s hared_ptr<SoundBuffer>> EffectsPoolList;141 typedef std::list<std::shared_ptr<SoundBuffer>> EffectsPoolList; 142 142 EffectsPoolList effectsPool_; 143 typedef std::map<std::string, s hared_ptr<SoundBuffer>> SoundBufferMap;143 typedef std::map<std::string, std::shared_ptr<SoundBuffer>> SoundBufferMap; 144 144 SoundBufferMap soundBuffers_; 145 145 … … 148 148 unsigned int maxSources_; 149 149 std::vector<ALuint> availableSoundSources_; 150 std::vector<std::pair<ALuint, BaseSound*> 150 std::vector<std::pair<ALuint, BaseSound*>> usedSoundSources_; 151 151 152 152 bool bDestructorCalled_; ///< Becomes true if the destructor is called - used to prevent ambient sounds from registering after the lists were cleared -
code/trunk/src/orxonox/sound/SoundStreamer.cc
r8858 r11071 45 45 vorbisCallbacks.seek_func = &seekVorbis; 46 46 vorbisCallbacks.tell_func = &tellVorbis; 47 vorbisCallbacks.close_func = NULL;47 vorbisCallbacks.close_func = nullptr; 48 48 49 49 OggVorbis_File vf; 50 int ret = ov_open_callbacks(dataStream.get(), &vf, NULL, 0, vorbisCallbacks);50 int ret = ov_open_callbacks(dataStream.get(), &vf, nullptr, 0, vorbisCallbacks); 51 51 if (ret < 0) 52 52 { … … 68 68 int current_section; 69 69 70 for( int i = 0; i < 4; i++)70 for(ALuint& initbuffer : initbuffers) 71 71 { 72 72 long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section); … … 82 82 } 83 83 84 alBufferData(initbuffer s[i], format, &inbuffer, ret, vorbisInfo->rate);84 alBufferData(initbuffer, format, &inbuffer, ret, vorbisInfo->rate); 85 85 } 86 86 alSourceQueueBuffers(audioSource, 4, initbuffers); -
code/trunk/src/orxonox/sound/WorldAmbientSound.cc
r10624 r11071 49 49 this->ambientSound_ = new AmbientSound(); 50 50 this->registerVariables(); 51 soundList_. push_back("Earth.ogg");52 soundList_. push_back("Jupiter.ogg");53 soundList_. push_back("Mars.ogg");54 soundList_. push_back("allgorythm-lift_up.ogg");55 soundList_. push_back("allgorythm-resonance_blaster.ogg");56 soundList_. push_back("AlphaCentauri.ogg");57 soundList_. push_back("Asteroid_rocks.ogg");58 soundList_. push_back("Ganymede.ogg");59 soundList_. push_back("luke_grey_-_hypermode.ogg");51 soundList_.emplace_back("Earth.ogg"); 52 soundList_.emplace_back("Jupiter.ogg"); 53 soundList_.emplace_back("Mars.ogg"); 54 soundList_.emplace_back("allgorythm-lift_up.ogg"); 55 soundList_.emplace_back("allgorythm-resonance_blaster.ogg"); 56 soundList_.emplace_back("AlphaCentauri.ogg"); 57 soundList_.emplace_back("Asteroid_rocks.ogg"); 58 soundList_.emplace_back("Ganymede.ogg"); 59 soundList_.emplace_back("luke_grey_-_hypermode.ogg"); 60 60 61 61 } … … 114 114 115 115 //HACK: Assuption - there is only one WorldAmbientSound in a level and only one level is used. 116 for (ObjectList<WorldAmbientSound>::iterator it = ObjectList<WorldAmbientSound>::begin(); 117 it != ObjectList<WorldAmbientSound>::end(); ++it) 116 for (WorldAmbientSound* sound : ObjectList<WorldAmbientSound>()) 118 117 { 119 while( it->ambientSound_->setAmbientSource(WorldAmbientSound::soundList_[WorldAmbientSound::soundNumber_]) == false){118 while(sound->ambientSound_->setAmbientSource(WorldAmbientSound::soundList_[WorldAmbientSound::soundNumber_]) == false){ 120 119 WorldAmbientSound::soundNumber_ = (WorldAmbientSound::soundNumber_ + 1) % WorldAmbientSound::soundList_.size(); 121 120 } -
code/trunk/src/orxonox/sound/WorldAmbientSound.h
r9939 r11071 50 50 virtual ~WorldAmbientSound(); 51 51 52 v oid XMLPort(Element& xmlelement, XMLPort::Mode mode);53 v oid XMLEventPort(Element& xmlelement, XMLPort::Mode mode);52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 53 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; 54 54 55 virtual void changedActivity() ;55 virtual void changedActivity() override; 56 56 57 57 void play(); -
code/trunk/src/orxonox/sound/WorldSound.cc
r9939 r11071 58 58 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::loopingChanged)); 59 59 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::pitchChanged)); 60 registerVariable( (uint8_t&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::stateChanged));60 registerVariable(BaseSound::state_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::stateChanged)); 61 61 } 62 62 -
code/trunk/src/orxonox/sound/WorldSound.h
r9667 r11071 47 47 WorldSound(Context* context); 48 48 49 v oid XMLPort(Element& xmlelement, XMLPort::Mode mode);50 v oid XMLEventPort(Element& xmlelement, XMLPort::Mode mode);51 v oid changedActivity();49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 50 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; 51 virtual void changedActivity() override; 52 52 53 v oid tick(float dt);53 virtual void tick(float dt) override; 54 54 55 55 protected: … … 58 58 private: 59 59 void registerVariables(); 60 v oid initialiseSource();61 float getRealVolume();60 virtual void initialiseSource() override; 61 virtual float getRealVolume() override; 62 62 }; 63 63 } -
code/trunk/src/orxonox/weaponsystem/DefaultWeaponmodeLink.h
r9667 r11071 42 42 virtual ~DefaultWeaponmodeLink(); 43 43 44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 45 45 46 46 inline void setFiremode(const unsigned int firemode) -
code/trunk/src/orxonox/weaponsystem/Munition.cc
r11052 r11071 52 52 this->reloadTime_ = 0.5f; 53 53 54 this->lastFilledWeaponMode_ = NULL;54 this->lastFilledWeaponMode_ = nullptr; 55 55 } 56 56 57 57 Munition::~Munition() 58 58 { 59 for ( std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)60 delete it->second;59 for (const auto& mapEntry : this->assignedMagazines_) 60 delete mapEntry.second; 61 61 } 62 62 … … 76 76 // For separated magazines we definitively need a given user 77 77 if (!user) 78 return 0;78 return nullptr; 79 79 80 80 // Use the map to get the magazine assigned to the given user … … 90 90 } 91 91 92 return 0;92 return nullptr; 93 93 } 94 94 … … 200 200 magazine->munition_ = 0; 201 201 202 if (this->reload( NULL))202 if (this->reload(nullptr)) 203 203 // Successfully reloaded, continue recursively 204 204 return this->takeMunition(amount, 0); … … 262 262 if (deployment_ != MunitionDeployment::Separate) 263 263 { 264 user = NULL;264 user = nullptr; 265 265 } 266 266 … … 271 271 if (it->first == lastFilledWeaponMode_) 272 272 { 273 lastFilledWeaponMode_ = NULL;273 lastFilledWeaponMode_ = nullptr; 274 274 } 275 275 delete it->second; … … 299 299 { 300 300 // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition) 301 for ( std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)302 if ( it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)301 for (const auto& mapEntry : this->assignedMagazines_) 302 if (mapEntry.second->munition_ < this->maxMunitionPerMagazine_ && mapEntry.second->bLoaded_) 303 303 return true; 304 304 } … … 315 315 { 316 316 // Stacking munition means, if a magazine gets full, the munition adds to a new magazine 317 Magazine* magazine = this->getMagazine( NULL);317 Magazine* magazine = this->getMagazine(nullptr); 318 318 if (magazine) 319 319 { … … 345 345 std::map<WeaponMode*, Magazine*>::iterator it; 346 346 347 // If the pointer to the weapon mode whose magazine got munition added to is NULL, then set the iterator to the beginning of the map347 // If the pointer to the weapon mode whose magazine got munition added to is nullptr, then set the iterator to the beginning of the map 348 348 // Otherwise set it to the next weapon mode 349 if (lastFilledWeaponMode_ == NULL)349 if (lastFilledWeaponMode_ == nullptr) 350 350 { 351 351 it = this->assignedMagazines_.begin(); … … 441 441 for (unsigned int i = 0; i < addedMagazines; ++i) 442 442 { 443 for ( std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)444 { 445 if (needReload( it->first))446 { 447 reload( it->first);443 for (const auto& mapEntry : this->assignedMagazines_) 444 { 445 if (needReload(mapEntry.first)) 446 { 447 reload(mapEntry.first); 448 448 break; 449 449 } … … 515 515 // If we don't use separate magazines, set user to 0 516 516 if (deployment_ != MunitionDeployment::Separate) 517 user = NULL;517 user = nullptr; 518 518 519 519 // Remove the current magazine for the given user … … 523 523 if (it->first == lastFilledWeaponMode_) 524 524 { 525 lastFilledWeaponMode_ = NULL;525 lastFilledWeaponMode_ = nullptr; 526 526 } 527 527 delete it->second; -
code/trunk/src/orxonox/weaponsystem/Munition.h
r11052 r11071 39 39 namespace orxonox 40 40 { 41 namespaceMunitionDeployment41 enum class MunitionDeployment 42 42 { 43 enum Value 44 { 45 Separate, // Every comsuming weapon mode has its own magazine. It is possible that one weapon mode is out of ammo while another still has some. 46 Share, // All comsuming weapon modes take their munition from the same magazine. If this magazine is empty a new one is loaded. 47 Stack // There is only one magazine where all the munition is stored. Use this deployment mode for heavy weapons loke rockets, bombs, ... 48 }; 49 } 43 Separate, // Every comsuming weapon mode has its own magazine. It is possible that one weapon mode is out of ammo while another still has some. 44 Share, // All comsuming weapon modes take their munition from the same magazine. If this magazine is empty a new one is loaded. 45 Stack // There is only one magazine where all the munition is stored. Use this deployment mode for heavy weapons loke rockets, bombs, ... 46 }; 50 47 51 48 class _OrxonoxExport Munition : public BaseObject … … 69 66 virtual ~Munition(); 70 67 71 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;68 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 72 69 73 70 unsigned int getNumMunition(WeaponMode* user) const; … … 80 77 inline unsigned int getMaxMunitionPerMagazine() const 81 78 { return this->maxMunitionPerMagazine_; } 82 inline MunitionDeployment ::ValuegetMunitionDeployment() const79 inline MunitionDeployment getMunitionDeployment() const 83 80 { return deployment_; } 84 81 … … 115 112 std::map<WeaponMode*, Magazine*> assignedMagazines_; // Maps weapon modes to magazines that are currently used. 116 113 117 MunitionDeployment ::Valuedeployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.114 MunitionDeployment deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes. 118 115 119 116 bool bAllowMunitionRefilling_; -
code/trunk/src/orxonox/weaponsystem/ReplenishingMunition.h
r11052 r11071 52 52 public: 53 53 ReplenishingMunition(Context* context); 54 virtual ~ReplenishingMunition() {}54 virtual ~ReplenishingMunition() = default; 55 55 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 57 57 58 virtualfloat getProgress();58 float getProgress(); 59 59 inline unsigned int getReplenishAmount() const 60 60 { return replenishAmount_; } -
code/trunk/src/orxonox/weaponsystem/Weapon.cc
r11052 r11071 45 45 RegisterObject(Weapon); 46 46 47 this->weaponPack_ = 0;48 this->weaponSlot_ = 0;47 this->weaponPack_ = nullptr; 48 this->weaponSlot_ = nullptr; 49 49 this->bReloading_ = false; 50 50 this->reloadingWeaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED; … … 61 61 this->weaponPack_->removeWeapon(this); 62 62 63 for ( std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)64 it->second->destroy();63 for (const auto& mapEntry : this->weaponmodes_) 64 mapEntry.second->destroy(); 65 65 } 66 66 } … … 85 85 { 86 86 unsigned int i = 0; 87 for ( std::multimap<unsigned int, WeaponMode*>::const_iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)87 for (const auto& mapEntry : this->weaponmodes_) 88 88 { 89 89 if (i == index) 90 return it->second;90 return mapEntry.second; 91 91 92 92 ++i; 93 93 } 94 return 0;94 return nullptr; 95 95 } 96 96 … … 140 140 void Weapon::reload() 141 141 { 142 for ( std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)143 it->second->reload();142 for (const auto& mapEntry : this->weaponmodes_) 143 mapEntry.second->reload(); 144 144 } 145 145 … … 152 152 void Weapon::notifyWeaponModes() 153 153 { 154 for ( std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)155 it->second->setWeapon(this);154 for (const auto& mapEntry : this->weaponmodes_) 155 mapEntry.second->setWeapon(this); 156 156 } 157 157 158 158 void Weapon::updateMunition() 159 159 { 160 for ( std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)161 it->second->updateMunition();160 for (const auto& mapEnty : this->weaponmodes_) 161 mapEnty.second->updateMunition(); 162 162 } 163 163 } -
code/trunk/src/orxonox/weaponsystem/Weapon.h
r11052 r11071 50 50 virtual ~Weapon(); 51 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 53 53 54 54 void fire(unsigned int mode); … … 57 57 void addWeaponmode(WeaponMode* weaponmode); 58 58 WeaponMode* getWeaponmode(unsigned int index) const; 59 inline std::multimap<unsigned int, WeaponMode*>* getAllWeaponmodes()60 { return &weaponmodes_; }59 inline const std::multimap<unsigned int, WeaponMode*>& getAllWeaponmodes() const 60 { return weaponmodes_; } 61 61 inline int getNumWeaponModes() const 62 62 { return weaponmodes_.size(); } -
code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
r11052 r11071 51 51 RegisterObject(WeaponMode); 52 52 53 this->weapon_ = 0;53 this->weapon_ = nullptr; 54 54 this->mode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED; 55 55 56 this->munition_ = 0;56 this->munition_ = nullptr; 57 57 this->initialMunition_ = 0; 58 58 this->initialMagazines_ = 0; … … 244 244 else 245 245 { 246 this->munition_ = NULL;246 this->munition_ = nullptr; 247 247 } 248 248 } -
code/trunk/src/orxonox/weaponsystem/WeaponMode.h
r11052 r11071 52 52 virtual ~WeaponMode(); 53 53 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 55 55 56 56 bool fire(float* reloadTime); -
code/trunk/src/orxonox/weaponsystem/WeaponPack.cc
r11052 r11071 44 44 RegisterObject(WeaponPack); 45 45 46 this->weaponSystem_ = 0;46 this->weaponSystem_ = nullptr; 47 47 } 48 48 … … 76 76 void WeaponPack::fire(unsigned int weaponmode) 77 77 { 78 for ( std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)79 (*it)->fire(weaponmode);78 for (Weapon* weapon : this->weapons_) 79 weapon->fire(weaponmode); 80 80 } 81 81 … … 86 86 void WeaponPack::reload() 87 87 { 88 for ( std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)89 (*it)->reload();88 for (Weapon* weapon : this->weapons_) 89 weapon->reload(); 90 90 } 91 91 … … 107 107 assert(it != this->weapons_.end()); 108 108 this->weapons_.erase(it); 109 weapon->setWeaponPack( 0);109 weapon->setWeaponPack(nullptr); 110 110 } 111 111 … … 114 114 unsigned int i = 0; 115 115 116 for ( std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)116 for (Weapon* weapon : this->weapons_) 117 117 { 118 118 if (i == index) 119 return (*it);119 return weapon; 120 120 ++i; 121 121 } 122 122 123 return 0;123 return nullptr; 124 124 } 125 126 std::vector<Weapon*>* WeaponPack::getAllWeapons()127 {128 return &weapons_;129 }130 125 131 126 void WeaponPack::addDefaultWeaponmodeLink(DefaultWeaponmodeLink* link) … … 137 132 { 138 133 unsigned int i = 0; 139 for ( std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)134 for (DefaultWeaponmodeLink* link : this->links_) 140 135 { 141 136 if (i == index) 142 return (*it);137 return link; 143 138 144 139 ++i; 145 140 } 146 return 0;141 return nullptr; 147 142 } 148 143 149 144 unsigned int WeaponPack::getDesiredWeaponmode(unsigned int firemode) const 150 145 { 151 for ( std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)152 if ( (*it)->getFiremode() == firemode)153 return (*it)->getWeaponmode();146 for (DefaultWeaponmodeLink* link : this->links_) 147 if (link->getFiremode() == firemode) 148 return link->getWeaponmode(); 154 149 155 150 return WeaponSystem::WEAPON_MODE_UNASSIGNED; … … 158 153 void WeaponPack::notifyWeapons() 159 154 { 160 for ( std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)161 (*it)->setWeaponPack(this);155 for (Weapon* weapon : this->weapons_) 156 weapon->setWeaponPack(this); 162 157 } 163 158 164 159 void WeaponPack::updateMunition() 165 160 { 166 for ( std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)167 (*it)->updateMunition();161 for (Weapon* weapon : this->weapons_) 162 weapon->updateMunition(); 168 163 } 169 164 } -
code/trunk/src/orxonox/weaponsystem/WeaponPack.h
r11052 r11071 44 44 virtual ~WeaponPack(); 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 void fire(unsigned int weaponmode); … … 52 52 void removeWeapon(Weapon * weapon); 53 53 Weapon * getWeapon(unsigned int index) const; 54 std::vector<Weapon*>* getAllWeapons(); 54 inline const std::vector<Weapon*>& getAllWeapons() const 55 { return weapons_; } 55 56 56 57 inline size_t getNumWeapons() const -
code/trunk/src/orxonox/weaponsystem/WeaponSet.cc
r10650 r11071 43 43 RegisterObject(WeaponSet); 44 44 45 this->weaponSystem_ = 0;45 this->weaponSystem_ = nullptr; 46 46 this->desiredFiremode_ = WeaponSystem::FIRE_MODE_UNASSIGNED; 47 47 } … … 63 63 { 64 64 // Fire all WeaponPacks with their defined weaponmode 65 for ( std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)66 if ( it->second != WeaponSystem::WEAPON_MODE_UNASSIGNED)67 it->first->fire(it->second);65 for (const auto& mapEntry : this->weaponpacks_) 66 if (mapEntry.second != WeaponSystem::WEAPON_MODE_UNASSIGNED) 67 mapEntry.first->fire(mapEntry.second); 68 68 } 69 69 … … 71 71 { 72 72 // Reload all WeaponPacks with their defined weaponmode 73 for ( std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)74 it->first->reload();73 for (const auto& mapEntry : this->weaponpacks_) 74 mapEntry.first->reload(); 75 75 } 76 76 -
code/trunk/src/orxonox/weaponsystem/WeaponSet.h
r9667 r11071 44 44 virtual ~WeaponSet(); 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 void fire(); -
code/trunk/src/orxonox/weaponsystem/WeaponSlot.cc
r10648 r11071 43 43 RegisterObject(WeaponSlot); 44 44 45 this->weaponSystem_ = 0;46 this->weapon_ = 0;45 this->weaponSystem_ = nullptr; 46 this->weapon_ = nullptr; 47 47 48 48 this->setSyncMode(ObjectDirection::None); … … 88 88 if (this->weapon_) 89 89 { 90 this->weapon_->setWeaponSlot( 0);91 this->weapon_ = 0;90 this->weapon_->setWeaponSlot(nullptr); 91 this->weapon_ = nullptr; 92 92 } 93 93 } -
code/trunk/src/orxonox/weaponsystem/WeaponSlot.h
r10650 r11071 62 62 virtual ~WeaponSlot(); 63 63 64 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;64 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 65 65 66 66 void attachWeapon(Weapon * weapon); … … 74 74 */ 75 75 inline bool isOccupied() const 76 { return (this->weapon_ != 0); }76 { return (this->weapon_ != nullptr); } 77 77 78 78 inline void setWeaponSystem(WeaponSystem * weaponSystem) -
code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc
r11052 r11071 52 52 RegisterObject(WeaponSystem); 53 53 54 this->pawn_ = 0;54 this->pawn_ = nullptr; 55 55 } 56 56 … … 60 60 { 61 61 if (this->pawn_) 62 this->pawn_->setWeaponSystem( 0);62 this->pawn_->setWeaponSystem(nullptr); 63 63 64 64 while (!this->weaponSets_.empty()) … … 106 106 { 107 107 unsigned int i = 0; 108 for ( std::vector<WeaponSlot*>::const_iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)108 for (WeaponSlot* weaponSlot : this->weaponSlots_) 109 109 { 110 110 ++i; 111 111 if (i > index) 112 return (*it);113 } 114 return 0;112 return weaponSlot; 113 } 114 return nullptr; 115 115 } 116 116 … … 153 153 { 154 154 unsigned int i = 0; 155 for ( std::map<unsigned int, WeaponSet*>::const_iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)155 for (const auto& mapEntry : this->weaponSets_) 156 156 { 157 157 ++i; 158 158 if (i > index) 159 return it->second;160 } 161 return 0;159 return mapEntry.second; 160 } 161 return nullptr; 162 162 } 163 163 … … 168 168 169 169 unsigned int freeSlots = 0; 170 for ( std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)171 { 172 if (! (*it)->isOccupied())170 for (WeaponSlot* weaponSlot : this->weaponSlots_) 171 { 172 if (!weaponSlot->isOccupied()) 173 173 ++freeSlots; 174 174 } … … 184 184 // Attach all weapons to the first free slots (and to the Pawn) 185 185 unsigned int i = 0; 186 for ( std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)187 { 188 if (! (*it)->isOccupied() && i < wPack->getNumWeapons())186 for (WeaponSlot* weaponSlot : this->weaponSlots_) 187 { 188 if (!weaponSlot->isOccupied() && i < wPack->getNumWeapons()) 189 189 { 190 190 Weapon* weapon = wPack->getWeapon(i); 191 (*it)->attachWeapon(weapon);191 weaponSlot->attachWeapon(weapon); 192 192 this->getPawn()->attach(weapon); 193 193 ++i; … … 196 196 197 197 // Assign the desired weaponmode to the firemodes 198 for ( std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)199 { 200 unsigned int weaponmode = wPack->getDesiredWeaponmode( it->first);198 for (const auto& mapEntry : this->weaponSets_) 199 { 200 unsigned int weaponmode = wPack->getDesiredWeaponmode(mapEntry.first); 201 201 if (weaponmode != WeaponSystem::WEAPON_MODE_UNASSIGNED) 202 it->second->setWeaponmodeLink(wPack, weaponmode);202 mapEntry.second->setWeaponmodeLink(wPack, weaponmode); 203 203 } 204 204 … … 213 213 // Remove all weapons from their WeaponSlot 214 214 unsigned int i = 0; 215 Weapon* weapon = 0;215 Weapon* weapon = nullptr; 216 216 while ((weapon = wPack->getWeapon(i++))) 217 217 if (weapon->getWeaponSlot()) … … 219 219 220 220 // Remove all added links from the WeaponSets 221 for ( std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)222 it->second->removeWeaponmodeLink(wPack);221 for (const auto& mapEntry : this->weaponSets_) 222 mapEntry.second->removeWeaponmodeLink(wPack); 223 223 224 224 // Remove the WeaponPack from the WeaponSystem … … 231 231 { 232 232 unsigned int i = 0; 233 for ( std::vector<WeaponPack*>::const_iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)233 for (WeaponPack* weaponPack : this->weaponPacks_) 234 234 { 235 235 ++i; 236 236 if (i > index) 237 return (*it); 238 } 239 return 0; 240 } 241 242 std::vector<WeaponPack *> * WeaponSystem::getAllWeaponPacks() 243 { 244 return &weaponPacks_; 245 } 237 return weaponPack; 238 } 239 return nullptr; 240 } 246 241 247 242 bool WeaponSystem::swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2) … … 273 268 // Check if the WeaponSet belongs to this WeaponSystem 274 269 bool foundWeaponSet = false; 275 for ( std::map<unsigned int, WeaponSet *>::iterator it2 = this->weaponSets_.begin(); it2 != this->weaponSets_.end(); ++it2)276 { 277 if ( it2->second == wSet)270 for (const auto& mapEntry : this->weaponSets_) 271 { 272 if (mapEntry.second == wSet) 278 273 { 279 274 foundWeaponSet = true; … … 301 296 void WeaponSystem::reload() 302 297 { 303 for ( std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)304 it->second->reload();298 for (const auto& mapEntry : this->weaponSets_) 299 mapEntry.second->reload(); 305 300 } 306 301 … … 308 303 { 309 304 if (!identifier || !identifier->getIdentifier()) 310 return 0;305 return nullptr; 311 306 312 307 std::map<Identifier *, Munition *>::iterator it = this->munitions_.find(identifier->getIdentifier()); … … 317 312 else 318 313 { 319 return NULL;314 return nullptr; 320 315 } 321 316 } … … 323 318 void WeaponSystem::addMunition(Munition* munition) 324 319 { 325 if (munition == NULL)320 if (munition == nullptr) 326 321 { 327 322 return; … … 337 332 else 338 333 { 339 orxout(internal_warning) << "Adding munition failed. identifier == NULL" << endl;334 orxout(internal_warning) << "Adding munition failed. identifier == nullptr " << endl; 340 335 } 341 336 } … … 343 338 void WeaponSystem::updateMunition() 344 339 { 345 for ( std::vector<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)346 { 347 (*it)->updateMunition();340 for (WeaponPack* weaponPack : this->weaponPacks_) 341 { 342 weaponPack->updateMunition(); 348 343 } 349 344 } -
code/trunk/src/orxonox/weaponsystem/WeaponSystem.h
r11052 r11071 67 67 void removeWeaponPack(WeaponPack * wPack); 68 68 WeaponPack * getWeaponPack(unsigned int index) const; 69 std::vector<WeaponPack *> * getAllWeaponPacks(); 69 inline const std::vector<WeaponPack *>& getAllWeaponPacks() const 70 { return weaponPacks_; } 70 71 71 72 // configure slots and firemodes -
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.