[Orxonox-commit 6163] r10821 - in code/branches/cpp11_v2/src: libraries/core libraries/core/class libraries/core/command libraries/core/commandline libraries/core/config libraries/core/input libraries/core/module libraries/core/object libraries/core/singleton libraries/network libraries/network/synchronisable libraries/tools libraries/util libraries/util/output modules/docking modules/gametypes modules/jump modules/mini4dgame modules/notifications modules/objects modules/objects/eventsystem modules/objects/triggers modules/overlays/hud modules/overlays/stats modules/pickup modules/pickup/items modules/pong modules/questsystem modules/questsystem/effects modules/tetris modules/towerdefense orxonox orxonox/collisionshapes orxonox/controllers orxonox/gamestates orxonox/gametypes orxonox/interfaces orxonox/items orxonox/overlays orxonox/sound orxonox/weaponsystem orxonox/worldentities orxonox/worldentities/pawns
muemart at orxonox.net
muemart at orxonox.net
Sat Nov 21 19:05:55 CET 2015
Author: muemart
Date: 2015-11-21 19:05:53 +0100 (Sat, 21 Nov 2015)
New Revision: 10821
Modified:
code/branches/cpp11_v2/src/libraries/core/BaseObject.cc
code/branches/cpp11_v2/src/libraries/core/ClassTreeMask.cc
code/branches/cpp11_v2/src/libraries/core/Core.cc
code/branches/cpp11_v2/src/libraries/core/CoreStaticInitializationHandler.cc
code/branches/cpp11_v2/src/libraries/core/Game.cc
code/branches/cpp11_v2/src/libraries/core/Language.cc
code/branches/cpp11_v2/src/libraries/core/Loader.cc
code/branches/cpp11_v2/src/libraries/core/LuaState.cc
code/branches/cpp11_v2/src/libraries/core/Namespace.cc
code/branches/cpp11_v2/src/libraries/core/NamespaceNode.cc
code/branches/cpp11_v2/src/libraries/core/Resource.cc
code/branches/cpp11_v2/src/libraries/core/class/Identifier.cc
code/branches/cpp11_v2/src/libraries/core/class/Identifier.h
code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.cc
code/branches/cpp11_v2/src/libraries/core/command/ArgumentCompletionFunctions.cc
code/branches/cpp11_v2/src/libraries/core/command/CommandEvaluation.cc
code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc
code/branches/cpp11_v2/src/libraries/core/command/Shell.cc
code/branches/cpp11_v2/src/libraries/core/command/TclThreadList.h
code/branches/cpp11_v2/src/libraries/core/command/TclThreadManager.cc
code/branches/cpp11_v2/src/libraries/core/commandline/CommandLineParser.cc
code/branches/cpp11_v2/src/libraries/core/config/ConfigFile.cc
code/branches/cpp11_v2/src/libraries/core/config/ConfigFileManager.cc
code/branches/cpp11_v2/src/libraries/core/config/ConfigFileSection.cc
code/branches/cpp11_v2/src/libraries/core/config/ConfigValueContainer.h
code/branches/cpp11_v2/src/libraries/core/input/Button.cc
code/branches/cpp11_v2/src/libraries/core/input/InputBuffer.cc
code/branches/cpp11_v2/src/libraries/core/input/InputDevice.h
code/branches/cpp11_v2/src/libraries/core/input/InputManager.cc
code/branches/cpp11_v2/src/libraries/core/input/JoyStick.cc
code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc
code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.h
code/branches/cpp11_v2/src/libraries/core/input/Mouse.cc
code/branches/cpp11_v2/src/libraries/core/module/DynLibManager.cc
code/branches/cpp11_v2/src/libraries/core/module/ModuleInstance.cc
code/branches/cpp11_v2/src/libraries/core/module/PluginManager.cc
code/branches/cpp11_v2/src/libraries/core/module/StaticInitializationManager.cc
code/branches/cpp11_v2/src/libraries/core/object/Context.cc
code/branches/cpp11_v2/src/libraries/core/object/Listable.cc
code/branches/cpp11_v2/src/libraries/core/object/ObjectListBase.cc
code/branches/cpp11_v2/src/libraries/core/singleton/ScopeManager.cc
code/branches/cpp11_v2/src/libraries/network/FunctionCall.cc
code/branches/cpp11_v2/src/libraries/network/Host.cc
code/branches/cpp11_v2/src/libraries/network/synchronisable/Synchronisable.cc
code/branches/cpp11_v2/src/libraries/tools/DebugDrawer.cc
code/branches/cpp11_v2/src/libraries/tools/IcoSphere.cc
code/branches/cpp11_v2/src/libraries/tools/Shader.cc
code/branches/cpp11_v2/src/libraries/util/DisplayStringConversions.h
code/branches/cpp11_v2/src/libraries/util/Serialise.h
code/branches/cpp11_v2/src/libraries/util/SignalHandler.cc
code/branches/cpp11_v2/src/libraries/util/SmallObjectAllocator.cc
code/branches/cpp11_v2/src/libraries/util/StringUtils.cc
code/branches/cpp11_v2/src/libraries/util/output/BaseWriter.cc
code/branches/cpp11_v2/src/libraries/util/output/MemoryWriter.cc
code/branches/cpp11_v2/src/libraries/util/output/OutputListener.cc
code/branches/cpp11_v2/src/libraries/util/output/OutputManager.cc
code/branches/cpp11_v2/src/libraries/util/output/SubcontextOutputListener.cc
code/branches/cpp11_v2/src/modules/docking/Dock.cc
code/branches/cpp11_v2/src/modules/docking/DockingAnimation.cc
code/branches/cpp11_v2/src/modules/docking/DockingEffect.cc
code/branches/cpp11_v2/src/modules/gametypes/RaceCheckPoint.cc
code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceController.cc
code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceManager.cc
code/branches/cpp11_v2/src/modules/jump/Jump.cc
code/branches/cpp11_v2/src/modules/mini4dgame/Mini4Dgame.cc
code/branches/cpp11_v2/src/modules/notifications/NotificationManager.cc
code/branches/cpp11_v2/src/modules/notifications/NotificationQueue.cc
code/branches/cpp11_v2/src/modules/objects/Attacher.cc
code/branches/cpp11_v2/src/modules/objects/Script.cc
code/branches/cpp11_v2/src/modules/objects/SpaceBoundaries.cc
code/branches/cpp11_v2/src/modules/objects/eventsystem/EventDispatcher.cc
code/branches/cpp11_v2/src/modules/objects/eventsystem/EventFilter.cc
code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc
code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc
code/branches/cpp11_v2/src/modules/objects/triggers/MultiTrigger.cc
code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc
code/branches/cpp11_v2/src/modules/overlays/hud/ChatOverlay.cc
code/branches/cpp11_v2/src/modules/overlays/hud/HUDNavigation.cc
code/branches/cpp11_v2/src/modules/overlays/hud/HUDRadar.cc
code/branches/cpp11_v2/src/modules/overlays/stats/Scoreboard.cc
code/branches/cpp11_v2/src/modules/pickup/PickupCollection.cc
code/branches/cpp11_v2/src/modules/pickup/PickupManager.cc
code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc
code/branches/cpp11_v2/src/modules/pong/Pong.cc
code/branches/cpp11_v2/src/modules/pong/PongAI.cc
code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc
code/branches/cpp11_v2/src/modules/questsystem/Quest.cc
code/branches/cpp11_v2/src/modules/questsystem/QuestEffect.cc
code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.cc
code/branches/cpp11_v2/src/modules/questsystem/QuestListener.cc
code/branches/cpp11_v2/src/modules/questsystem/QuestManager.cc
code/branches/cpp11_v2/src/modules/questsystem/effects/AddReward.cc
code/branches/cpp11_v2/src/modules/tetris/Tetris.cc
code/branches/cpp11_v2/src/modules/tetris/TetrisBrick.cc
code/branches/cpp11_v2/src/modules/towerdefense/TowerDefense.cc
code/branches/cpp11_v2/src/orxonox/Level.cc
code/branches/cpp11_v2/src/orxonox/LevelInfo.cc
code/branches/cpp11_v2/src/orxonox/LevelManager.cc
code/branches/cpp11_v2/src/orxonox/Scene.cc
code/branches/cpp11_v2/src/orxonox/collisionshapes/CompoundCollisionShape.cc
code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc
code/branches/cpp11_v2/src/orxonox/controllers/WaypointController.cc
code/branches/cpp11_v2/src/orxonox/gamestates/GSLevel.cc
code/branches/cpp11_v2/src/orxonox/gametypes/Dynamicmatch.cc
code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.cc
code/branches/cpp11_v2/src/orxonox/gametypes/LastManStanding.cc
code/branches/cpp11_v2/src/orxonox/gametypes/LastTeamStanding.cc
code/branches/cpp11_v2/src/orxonox/gametypes/TeamBaseMatch.cc
code/branches/cpp11_v2/src/orxonox/gametypes/TeamDeathmatch.cc
code/branches/cpp11_v2/src/orxonox/gametypes/TeamGametype.cc
code/branches/cpp11_v2/src/orxonox/gametypes/UnderAttack.cc
code/branches/cpp11_v2/src/orxonox/interfaces/PickupCarrier.cc
code/branches/cpp11_v2/src/orxonox/interfaces/Pickupable.cc
code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc
code/branches/cpp11_v2/src/orxonox/items/ShipPart.cc
code/branches/cpp11_v2/src/orxonox/overlays/OverlayGroup.cc
code/branches/cpp11_v2/src/orxonox/sound/SoundManager.cc
code/branches/cpp11_v2/src/orxonox/sound/SoundStreamer.cc
code/branches/cpp11_v2/src/orxonox/weaponsystem/Munition.cc
code/branches/cpp11_v2/src/orxonox/weaponsystem/Weapon.cc
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSet.cc
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSystem.cc
code/branches/cpp11_v2/src/orxonox/worldentities/ControllableEntity.cc
code/branches/cpp11_v2/src/orxonox/worldentities/EffectContainer.cc
code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.cc
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
Log:
Run clang-modernize -loop-convert
- Again, not all possible loops were converted
- It can do pretty cool transformations, but I had to fix a few compile errors, so there might be some runtime errors lurking around too
Modified: code/branches/cpp11_v2/src/libraries/core/BaseObject.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/BaseObject.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/BaseObject.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -233,10 +233,10 @@
Template* BaseObject::getTemplate(unsigned int index) const
{
unsigned int i = 0;
- for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)
+ for (const auto & elem : this->templates_)
{
if (i == index)
- return (*it);
+ return (elem);
i++;
}
return nullptr;
@@ -268,13 +268,13 @@
BaseObject* BaseObject::getEventSource(unsigned int index, const std::string& state) const
{
unsigned int i = 0;
- for (std::map<BaseObject*, std::string>::const_iterator it = this->eventSources_.begin(); it != this->eventSources_.end(); ++it)
+ for (const auto & elem : this->eventSources_)
{
- if (it->second != state)
+ if (elem.second != state)
continue;
if (i == index)
- return it->first;
+ return elem.first;
++i;
}
return nullptr;
@@ -295,10 +295,10 @@
BaseObject* BaseObject::getEventListener(unsigned int index) const
{
unsigned int i = 0;
- for (std::set<BaseObject*>::const_iterator it = this->eventListenersXML_.begin(); it != this->eventListenersXML_.end(); ++it)
+ for (const auto & elem : this->eventListenersXML_)
{
if (i == index)
- return *it;
+ return elem;
++i;
}
return nullptr;
@@ -357,10 +357,10 @@
{
Event event(activate, originator, name);
- for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
+ for (const auto & elem : this->eventListeners_)
{
- event.statename_ = (*it)->eventSources_[this];
- (*it)->processEvent(event);
+ event.statename_ = (elem)->eventSources_[this];
+ (elem)->processEvent(event);
}
}
@@ -369,8 +369,8 @@
*/
void BaseObject::fireEvent(Event& event)
{
- for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
- (*it)->processEvent(event);
+ for (const auto & elem : this->eventListeners_)
+ (elem)->processEvent(event);
}
/**
@@ -473,9 +473,9 @@
}
// iterate through all states and get the event sources
- for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
+ for (auto & statename : eventnames)
{
- const std::string& statename = (*it);
+
// if the event state is already known, continue with the next state
orxonox::EventState* eventstate = object->getEventState(statename);
Modified: code/branches/cpp11_v2/src/libraries/core/ClassTreeMask.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/ClassTreeMask.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/ClassTreeMask.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -292,10 +292,10 @@
else
{
// No it's not: Search for classes inheriting from the given class and add the rules for them
- for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it)
- if ((*it)->isA(this->root_->getClass()))
- if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist
- this->add(this->root_, *it, bInclude, overwrite);
+ for (const auto & elem : subclass->getDirectChildren())
+ if ((elem)->isA(this->root_->getClass()))
+ if (overwrite || (!this->nodeExists(elem))) // If we don't want to overwrite, only add nodes that don't already exist
+ this->add(this->root_, elem, bInclude, overwrite);
}
// Clean the rule-tree
@@ -324,12 +324,12 @@
else if (subclass->isA(node->getClass()))
{
// Search for an already existing node, containing the subclass we want to add
- for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)
+ for (auto & elem : node->subnodes_)
{
- if (subclass->isA((*it)->getClass()))
+ if (subclass->isA((elem)->getClass()))
{
// We've found an existing node -> delegate the work with a recursive function-call and return
- this->add(*it, subclass, bInclude, overwrite);
+ this->add(elem, subclass, bInclude, overwrite);
return;
}
}
@@ -391,8 +391,8 @@
{
if (!subclass)
return;
- for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it)
- this->add(*it, this->isIncluded(*it), false, false);
+ for (const auto & elem : subclass->getDirectChildren())
+ this->add(elem, this->isIncluded(elem), false, false);
this->add(subclass, bInclude, false, clean);
}
@@ -434,9 +434,9 @@
return node->isIncluded();
// Go through the list of subnodes and look for a node containing the searched subclass and delegate the request by a recursive function-call.
- for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)
- if (subclass->isA((*it)->getClass()))
- return isIncluded(*it, subclass);
+ for (auto & elem : node->subnodes_)
+ if (subclass->isA((elem)->getClass()))
+ return isIncluded(elem, subclass);
// There is no subnode containing our class -> the rule of the current node takes in effect
return node->isIncluded();
@@ -956,8 +956,8 @@
// Now add all directChildren which don't have subnodes on their own to the subclass-list
// The bool is "false", meaning they have no subnodes and therefore need no further checks
if (node->isIncluded())
- for (std::set<const Identifier*>::iterator it = directChildren.begin(); it != directChildren.end(); ++it)
- this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(*it, false));
+ for (const auto & elem : directChildren)
+ this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(elem, false));
}
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/Core.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/Core.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/Core.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -278,9 +278,9 @@
orxout(internal_info) << "Loading modules:" << endl;
const std::vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths();
- for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
+ for (const auto & modulePath : modulePaths)
{
- ModuleInstance* module = new ModuleInstance(*it);
+ ModuleInstance* module = new ModuleInstance(modulePath);
this->loadModule(module);
this->modules_.push_back(module);
}
@@ -308,9 +308,9 @@
void Core::unloadModules()
{
- for (std::list<ModuleInstance*>::iterator it = this->modules_.begin(); it != this->modules_.end(); ++it)
+ for (auto module : this->modules_)
{
- ModuleInstance* module = (*it);
+
this->unloadModule(module);
delete module;
}
Modified: code/branches/cpp11_v2/src/libraries/core/CoreStaticInitializationHandler.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/CoreStaticInitializationHandler.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/CoreStaticInitializationHandler.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -98,38 +98,38 @@
// collect all identifiers that are about to be unloaded
std::set<Identifier*> identifiers;
const std::set<StaticallyInitializedInstance*>& instances = module->getInstances(StaticInitialization::IDENTIFIER);
- for (std::set<StaticallyInitializedInstance*>::const_iterator it = instances.begin(); it != instances.end(); ++it)
- identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(*it)->getIdentifier());
+ for (const auto & instance : instances)
+ identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(instance)->getIdentifier());
// destroy objects. some objects may survive this at first because they still have strong pointers pointing at them. this is
// ok as long as those strong pointers are held by objects that are also about to be destroyed in the same loop. this means
// that objects within one module may reference each other by strong pointers. but it is not allowed that objects from another
// module (which is not unloaded) uses strong pointers to point at objects inside the unloaded module. this will lead to a crash.
- for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)
- (*it)->destroyObjects();
+ for (const auto & identifier : identifiers)
+ (identifier)->destroyObjects();
// check if all objects were really destroyed. this is not the case if an object is referenced by a strong pointer from another
// module (or if two objects inside this module reference each other). this will lead to a crash and must be fixed (e.g. by
// changing object dependencies; or by changing the logic that allows modules to be unloaded).
- for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)
+ for (const auto & identifier : identifiers)
{
- ObjectListBase* objectList = Context::getRootContext()->getObjectList(*it);
+ ObjectListBase* objectList = Context::getRootContext()->getObjectList(identifier);
if (objectList->size() > 0)
{
- orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << (*it)->getName()
+ orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << (identifier)->getName()
<< " after unloading the Identifier. This may lead to a crash" << endl;
}
}
// destroy object-lists in all contexts
- for (std::set<Identifier*>::iterator it_identifier = identifiers.begin(); it_identifier != identifiers.end(); ++it_identifier)
+ for (const auto & identifier : identifiers)
{
// only do this if the Identifier is not a Context itself; otherwise we delete the list we're iterating over
- if (!(*it_identifier)->isExactlyA(Class(Context)))
+ if (!(identifier)->isExactlyA(Class(Context)))
{
// iterate over all contexts
for (ObjectList<Context>::iterator it_context = ObjectList<Context>::begin(); it_context != ObjectList<Context>::end(); ++it_context)
- it_context->destroyObjectList((*it_identifier));
+ it_context->destroyObjectList((identifier));
}
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/Game.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/Game.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/Game.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -611,8 +611,8 @@
}
// Check if graphics is still required
bool graphicsRequired = false;
- for (unsigned i = 0; i < loadedStates_.size(); ++i)
- graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
+ for (auto & elem : loadedStates_)
+ graphicsRequired |= elem->getInfo().bGraphicsMode;
if (!graphicsRequired)
this->unloadGraphics(!this->bAbort_); // if abort is false, that means the game is still running while unloading graphics. in this case we load a graphics manager without renderer (to keep all necessary ogre instances alive)
this->bChangingState_ = false;
Modified: code/branches/cpp11_v2/src/libraries/core/Language.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/Language.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/Language.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -106,8 +106,8 @@
*/
Language::~Language()
{
- for (std::map<std::string, LanguageEntry*>::iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
- delete (it->second);
+ for (auto & elem : this->languageEntries_)
+ delete (elem.second);
}
/**
@@ -318,9 +318,9 @@
}
// Iterate through the list an write the lines into the file
- for (std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
+ for (const auto & elem : this->languageEntries_)
{
- file << it->second->getLabel() << '=' << it->second->getDefault() << endl;
+ file << elem.second->getLabel() << '=' << elem.second->getDefault() << endl;
}
file.close();
Modified: code/branches/cpp11_v2/src/libraries/core/Loader.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/Loader.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/Loader.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -164,9 +164,9 @@
std::vector<std::pair<std::string, size_t>> linesources = lineTrace->at(line - 1);
std::ostringstream message;
message << "Possible sources of error:" << endl;
- for (std::vector<std::pair<std::string, size_t>>::iterator it = linesources.begin(); it != linesources.end(); ++it)
+ for (auto & linesource : linesources)
{
- message << it->first << ", Line " << it->second << endl;
+ message << linesource.first << ", Line " << linesource.second << endl;
}
orxout(user_error, context::loader) << message.str() << endl;
}
@@ -260,9 +260,9 @@
// check whether on every opening <?lua tag a closing ?> tag follows
{
bool expectedValue = true;
- for (std::map<size_t, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)
+ for (auto & luaTag : luaTags)
{
- if (it->second == expectedValue)
+ if (luaTag.second == expectedValue)
expectedValue = !expectedValue;
else
{
Modified: code/branches/cpp11_v2/src/libraries/core/LuaState.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/LuaState.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/LuaState.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -325,9 +325,9 @@
/*static*/ bool LuaState::addToluaInterface(int (*function)(lua_State*), const std::string& name)
{
- for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
+ for (const auto & interface : getToluaInterfaces())
{
- if (it->first == name || it->second == function)
+ if (interface.first == name || interface.second == function)
{
orxout(internal_warning, context::lua) << "Trying to add a Tolua interface with the same name or function." << endl;
return true;
@@ -336,8 +336,8 @@
getToluaInterfaces()[name] = function;
// Open interface in all LuaStates
- for (std::vector<LuaState*>::const_iterator it = getInstances().begin(); it != getInstances().end(); ++it)
- (*function)((*it)->luaState_);
+ for (const auto & state : getInstances())
+ (*function)(state->luaState_);
// Return dummy bool
return true;
@@ -353,10 +353,10 @@
}
// Close interface in all LuaStates
- for (std::vector<LuaState*>::const_iterator itState = getInstances().begin(); itState != getInstances().end(); ++itState)
+ for (const auto & state : getInstances())
{
- lua_pushnil((*itState)->luaState_);
- lua_setglobal((*itState)->luaState_, it->first.c_str());
+ lua_pushnil(state->luaState_);
+ lua_setglobal(state->luaState_, it->first.c_str());
}
// Remove entry
@@ -368,16 +368,16 @@
/*static*/ void LuaState::openToluaInterfaces(lua_State* state)
{
- for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
- (*it->second)(state);
+ for (const auto & interface : getToluaInterfaces())
+ (interface.second)(state);
}
/*static*/ void LuaState::closeToluaInterfaces(lua_State* state)
{
- for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
+ for (const auto & interface : getToluaInterfaces())
{
lua_pushnil(state);
- lua_setglobal(state, it->first.c_str());
+ lua_setglobal(state, interface.first.c_str());
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/Namespace.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/Namespace.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/Namespace.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -52,8 +52,8 @@
Namespace::~Namespace()
{
if (this->bRoot_)
- for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
- delete (*it);
+ for (auto & elem : this->representingNamespaces_)
+ delete elem;
}
void Namespace::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -79,9 +79,9 @@
{
for (unsigned int i = 0; i < tokens.size(); i++)
{
- for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it)
+ for (auto & elem : this->getNamespace()->representingNamespaces_)
{
- std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]);
+ std::set<NamespaceNode*> temp = elem->getNodeRelative(tokens[i]);
this->representingNamespaces_.insert(temp.begin(), temp.end());
}
}
@@ -92,10 +92,10 @@
if (this->bAutogeneratedFileRootNamespace_)
{
- for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
+ for (auto & elem : this->representingNamespaces_)
{
- (*it)->setRoot(true);
- (*it)->setHidden(true);
+ elem->setRoot(true);
+ elem->setHidden(true);
}
}
@@ -113,11 +113,11 @@
bool Namespace::includes(const Namespace* ns) const
{
- for (std::set<NamespaceNode*>::const_iterator it1 = this->representingNamespaces_.begin(); it1 != this->representingNamespaces_.end(); ++it1)
+ for (const auto & elem1 : this->representingNamespaces_)
{
- for (std::set<NamespaceNode*>::const_iterator it2 = ns->representingNamespaces_.begin(); it2 != ns->representingNamespaces_.end(); ++it2)
+ for (const auto & elem2 : ns->representingNamespaces_)
{
- if ((*it1)->includes(*it2))
+ if (elem1->includes(elem2))
{
if (this->operator_ == "or")
return true;
@@ -148,12 +148,13 @@
std::string output;
int i = 0;
- for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
+ for (const auto & elem : this->representingNamespaces_)
{
if (i > 0)
output += " / ";
- output += (*it)->toString();
+ output += elem->toString();
+ i++;
}
return output;
@@ -164,12 +165,13 @@
std::string output;
int i = 0;
- for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
+ for (const auto & elem : this->representingNamespaces_)
{
if (i > 0)
output += '\n';
- output += (*it)->toString(indentation);
+ output += elem->toString(indentation);
+ i++;
}
return output;
Modified: code/branches/cpp11_v2/src/libraries/core/NamespaceNode.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/NamespaceNode.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/NamespaceNode.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -102,11 +102,11 @@
{
bool bFoundMatchingNamespace = false;
- for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
+ for (auto & elem : this->subnodes_)
{
- if (it->first.find(firstPart) == (it->first.size() - firstPart.size()))
+ if (elem.first.find(firstPart) == (elem.first.size() - firstPart.size()))
{
- std::set<NamespaceNode*> temp2 = it->second->getNodeRelative(secondPart);
+ std::set<NamespaceNode*> temp2 = elem.second->getNodeRelative(secondPart);
nodes.insert(temp2.begin(), temp2.end());
bFoundMatchingNamespace = true;
}
@@ -131,8 +131,8 @@
}
else
{
- for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
- if (it->second->includes(ns))
+ for (const auto & elem : this->subnodes_)
+ if (elem.second->includes(ns))
return true;
}
@@ -166,8 +166,8 @@
{
std::string output = (indentation + this->name_ + '\n');
- for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
- output += it->second->toString(indentation + " ");
+ for (const auto & elem : this->subnodes_)
+ output += elem.second->toString(indentation + " ");
return output;
}
Modified: code/branches/cpp11_v2/src/libraries/core/Resource.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/Resource.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/Resource.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -57,9 +57,9 @@
{
DataStreamListPtr resources(new Ogre::DataStreamList());
const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
- for (Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it)
+ for (const auto & group : groups)
{
- DataStreamListPtr temp = Ogre::ResourceGroupManager::getSingleton().openResources(pattern, *it);
+ DataStreamListPtr temp = Ogre::ResourceGroupManager::getSingleton().openResources(pattern, group);
resources->insert(resources->end(), temp->begin(), temp->end());
}
return resources;
@@ -120,9 +120,9 @@
{
StringVectorPtr resourceNames(new Ogre::StringVector());
const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
- for (Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it)
+ for (const auto & group : groups)
{
- StringVectorPtr temp = Ogre::ResourceGroupManager::getSingleton().findResourceNames(*it, pattern);
+ StringVectorPtr temp = Ogre::ResourceGroupManager::getSingleton().findResourceNames(group, pattern);
resourceNames->insert(resourceNames->end(), temp->begin(), temp->end());
}
return resourceNames;
Modified: code/branches/cpp11_v2/src/libraries/core/class/Identifier.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/class/Identifier.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/class/Identifier.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -86,17 +86,17 @@
const_cast<Identifier*>(*it)->children_.erase(this);
for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
const_cast<Identifier*>(*it)->directChildren_.erase(this);
- for (std::set<const Identifier*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
- const_cast<Identifier*>(*it)->parents_.remove(this);
- for (std::set<const Identifier*>::const_iterator it = this->directChildren_.begin(); it != this->directChildren_.end(); ++it)
- const_cast<Identifier*>(*it)->directParents_.remove(this);
+ for (const auto & elem : this->children_)
+ const_cast<Identifier*>(elem)->parents_.remove(this);
+ for (const auto & elem : this->directChildren_)
+ const_cast<Identifier*>(elem)->directParents_.remove(this);
- for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
- delete (it->second);
- for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)
- delete (it->second);
- for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
- delete (it->second);
+ for (auto & elem : this->configValues_)
+ delete (elem.second);
+ for (auto & elem : this->xmlportParamContainers_)
+ delete (elem.second);
+ for (auto & elem : this->xmlportObjectContainers_)
+ delete (elem.second);
}
@@ -156,9 +156,9 @@
if (this->directParents_.empty())
{
- for (std::list<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it)
- if (*it != this)
- this->parents_.push_back(*it);
+ for (const auto & elem : initializationTrace)
+ if (elem != this)
+ this->parents_.push_back(elem);
}
else
orxout(internal_error) << "Trying to add parents to " << this->getName() << " after it was already initialized with manual calls to inheritsFrom<Class>()." << endl;
@@ -260,22 +260,22 @@
std::list<const Identifier*> expectedIdentifierTrace;
// if any parent class is virtual, it will be instantiated first, so we need to add them first.
- for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
+ for (const auto & elem : this->parents_)
{
- if ((*it_parent)->isVirtualBase())
+ if ((elem)->isVirtualBase())
{
- for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+ for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(elem)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(elem)->parents_.end(); ++it_parent_parent)
this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);
- this->addIfNotExists(expectedIdentifierTrace, *it_parent);
+ this->addIfNotExists(expectedIdentifierTrace, elem);
}
}
// now all direct parents get created recursively. already added identifiers (e.g. virtual base classes) are not added again.
- for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)
+ for (const auto & elem : this->directParents_)
{
- for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+ for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(elem)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(elem)->parents_.end(); ++it_parent_parent)
this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);
- this->addIfNotExists(expectedIdentifierTrace, *it_parent);
+ this->addIfNotExists(expectedIdentifierTrace, elem);
}
// check if the expected trace matches the actual trace (which was defined by creating a sample instance)
@@ -284,8 +284,8 @@
orxout(internal_warning) << this->getName() << " has an unexpected initialization trace:" << endl;
orxout(internal_warning) << " Actual trace (after creating a sample instance):" << endl << " ";
- for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
- orxout(internal_warning) << " " << (*it_parent)->getName();
+ for (const auto & elem : this->parents_)
+ orxout(internal_warning) << " " << (elem)->getName();
orxout(internal_warning) << endl;
orxout(internal_warning) << " Expected trace (according to class hierarchy definitions):" << endl << " ";
@@ -294,8 +294,8 @@
orxout(internal_warning) << endl;
orxout(internal_warning) << " Direct parents (according to class hierarchy definitions):" << endl << " ";
- for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)
- orxout(internal_warning) << " " << (*it_parent)->getName();
+ for (const auto & elem : this->directParents_)
+ orxout(internal_warning) << " " << (elem)->getName();
orxout(internal_warning) << endl;
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/class/Identifier.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/class/Identifier.h 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/class/Identifier.h 2015-11-21 18:05:53 UTC (rev 10821)
@@ -461,8 +461,8 @@
this->setConfigValues(*it, *it);
if (updateChildren)
- for (std::set<const Identifier*>::const_iterator it = this->getChildren().begin(); it != this->getChildren().end(); ++it)
- (*it)->updateConfigValues(false);
+ for (const auto & elem : this->getChildren())
+ (elem)->updateConfigValues(false);
}
template <class T>
Modified: code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -92,9 +92,9 @@
// iterate over all identifiers, create one instance of each class and initialize the identifiers
{
Context temporaryContext(nullptr);
- for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
+ for (auto identifier : this->identifiers_)
{
- Identifier* identifier = (*it);
+
if (identifier->isInitialized())
continue;
@@ -126,8 +126,8 @@
}
// finish the initialization of all identifiers
- for (std::set<Identifier*>::const_iterator it = initializedIdentifiers.begin(); it != initializedIdentifiers.end(); ++it)
- (*it)->finishInitialization();
+ for (const auto & initializedIdentifier : initializedIdentifiers)
+ (initializedIdentifier)->finishInitialization();
// only check class hierarchy in dev mode because it's an expensive operation and it requires a developer to fix detected problems anyway.
if (!Core::exists() || Core::getInstance().getConfig()->inDevMode())
@@ -143,28 +143,28 @@
void IdentifierManager::verifyClassHierarchy(const std::set<Identifier*>& initializedIdentifiers)
{
// check if there are any uninitialized identifiers remaining
- for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
- if (!(*it)->isInitialized())
- orxout(internal_error) << "Identifier was registered late and is not initialized: " << (*it)->getName() << " / " << (*it)->getTypeInfo().name() << endl;
+ for (const auto & elem : this->identifiers_)
+ if (!(elem)->isInitialized())
+ orxout(internal_error) << "Identifier was registered late and is not initialized: " << (elem)->getName() << " / " << (elem)->getTypeInfo().name() << endl;
// for all initialized identifiers, check if a sample instance behaves as expected according to the class hierarchy
Context temporaryContext(nullptr);
- for (std::set<Identifier*>::const_iterator it1 = initializedIdentifiers.begin(); it1 != initializedIdentifiers.end(); ++it1)
+ for (const auto & initializedIdentifier : initializedIdentifiers)
{
- if (!(*it1)->hasFactory())
+ if (!(initializedIdentifier)->hasFactory())
continue;
- Identifiable* temp = (*it1)->fabricate(&temporaryContext);
+ Identifiable* temp = (initializedIdentifier)->fabricate(&temporaryContext);
- for (std::set<Identifier*>::const_iterator it2 = this->identifiers_.begin(); it2 != this->identifiers_.end(); ++it2)
+ for (const auto & elem : this->identifiers_)
{
- bool isA_AccordingToRtti = (*it2)->canDynamicCastObjectToIdentifierClass(temp);
- bool isA_AccordingToClassHierarchy = temp->isA((*it2));
+ bool isA_AccordingToRtti = (elem)->canDynamicCastObjectToIdentifierClass(temp);
+ bool isA_AccordingToClassHierarchy = temp->isA((elem));
if (isA_AccordingToRtti != isA_AccordingToClassHierarchy)
{
- orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (*it1)->getName() <<
- (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (*it2)->getName() << " but RTTI says the opposite." << endl;
+ orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (initializedIdentifier)->getName() <<
+ (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (elem)->getName() << " but RTTI says the opposite." << endl;
}
}
@@ -183,8 +183,8 @@
void IdentifierManager::destroyClassHierarchy()
{
orxout(internal_status) << "Destroy class-hierarchy" << endl;
- for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
- (*it)->reset();
+ for (const auto & elem : this->identifiers_)
+ (elem)->reset();
}
/**
@@ -259,9 +259,9 @@
Identifier* IdentifierManager::getIdentifierByTypeInfo(const std::type_info& typeInfo)
{
// TODO: use std::type_index and a map to find identifiers by type_info (only with c++11)
- for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
- if ((*it)->getTypeInfo() == typeInfo)
- return (*it);
+ for (const auto & elem : this->identifiers_)
+ if ((elem)->getTypeInfo() == typeInfo)
+ return (elem);
return nullptr;
}
Modified: code/branches/cpp11_v2/src/libraries/core/command/ArgumentCompletionFunctions.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/ArgumentCompletionFunctions.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/command/ArgumentCompletionFunctions.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -76,8 +76,8 @@
*/
bool groupIsVisible(const std::map<std::string, ConsoleCommand*>& group, bool bOnlyShowHidden)
{
- for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = group.begin(); it_command != group.end(); ++it_command)
- if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)
+ for (const auto & elem : group)
+ if (elem.second->isActive() && elem.second->hasAccess() && (!elem.second->isHidden())^bOnlyShowHidden)
return true;
return false;
@@ -99,9 +99,9 @@
// get all the groups that are visible (except the shortcut group "")
const std::map<std::string, std::map<std::string, ConsoleCommand*>>& commands = ConsoleCommandManager::getInstance().getCommands();
- for (std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
- if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find(fragmentLC) == 0))
- groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
+ for (const auto & command : commands)
+ if (groupIsVisible(command.second, bOnlyShowHidden) && command.first != "" && (fragmentLC == "" || getLowercase(command.first).find(fragmentLC) == 0))
+ groupList.push_back(ArgumentCompletionListElement(command.first, getLowercase(command.first)));
// now add all shortcuts (in group "")
std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = commands.find("");
@@ -112,9 +112,9 @@
groupList.push_back(ArgumentCompletionListElement("", "", "\n"));
// add the shortcuts
- for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
- if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find(fragmentLC) == 0))
- groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
+ for (const auto & elem : it_group->second)
+ if (elem.second->isActive() && elem.second->hasAccess() && (!elem.second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(elem.first).find(fragmentLC) == 0))
+ groupList.push_back(ArgumentCompletionListElement(elem.first, getLowercase(elem.first)));
}
// if no shortcut was added, remove the line-break again
@@ -145,9 +145,9 @@
// add all commands in the group to the list
if (it_group != ConsoleCommandManager::getInstance().getCommands().end())
{
- for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
- if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)
- commandList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
+ for (const auto & elem : it_group->second)
+ if (elem.second->isActive() && elem.second->hasAccess() && (!elem.second->isHidden())^bOnlyShowHidden)
+ commandList.push_back(ArgumentCompletionListElement(elem.first, getLowercase(elem.first)));
}
return commandList;
@@ -280,8 +280,8 @@
ArgumentCompletionList sectionList;
const std::set<std::string>& names = SettingsConfigFile::getInstance().getSectionNames();
- for (std::set<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
- sectionList.push_back(ArgumentCompletionListElement(*it, getLowercase(*it)));
+ for (const auto & name : names)
+ sectionList.push_back(ArgumentCompletionListElement(name, getLowercase(name)));
return sectionList;
}
Modified: code/branches/cpp11_v2/src/libraries/core/command/CommandEvaluation.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/CommandEvaluation.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/command/CommandEvaluation.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -305,8 +305,8 @@
{
// the user typed 1-2 arguments, check what he tried to type and print a suitable error
std::string groupLC = getLowercase(this->getToken(0));
- for (std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)
- if (it_group->first == groupLC)
+ for (const auto & elem : ConsoleCommandManager::getInstance().getCommandsLC())
+ if (elem.first == groupLC)
return std::string("Error: There is no command in group \"") + this->getToken(0) + "\" starting with \"" + this->getToken(1) + "\".";
return std::string("Error: There is no command starting with \"") + this->getToken(0) + "\".";
@@ -327,13 +327,13 @@
unsigned int nearestDistance = (unsigned int)-1;
// iterate through all groups and their commands and calculate the distance to the current command. keep the best.
- for (std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)
+ for (const auto & elem : ConsoleCommandManager::getInstance().getCommandsLC())
{
- if (it_group->first != "")
+ if (elem.first != "")
{
- for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)
+ for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = elem.second.begin(); it_name != elem.second.end(); ++it_name)
{
- std::string command = it_group->first + " " + it_name->first;
+ std::string command = elem.first + " " + it_name->first;
unsigned int distance = getLevenshteinDistance(command, token0_LC + " " + token1_LC);
if (distance < nearestDistance)
{
@@ -348,9 +348,9 @@
std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().find("");
if (it_group != ConsoleCommandManager::getInstance().getCommandsLC().end())
{
- for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)
+ for (const auto & elem : it_group->second)
{
- std::string command = it_name->first;
+ std::string command = elem.first;
unsigned int distance = getLevenshteinDistance(command, token0_LC);
if (distance < nearestDistance)
{
@@ -428,8 +428,8 @@
/* static */ size_t CommandEvaluation::getSize(const ArgumentCompletionList& list)
{
size_t count = 0;
- for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
- if (it->getComparable() != "")
+ for (const auto & elem : list)
+ if (elem.getComparable() != "")
++count;
return count;
}
@@ -494,15 +494,15 @@
else if (CommandEvaluation::getSize(list) == 1)
{
// only one (non-empty) value in the list - search it and return it
- for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+ for (const auto & elem : list)
{
- if (it->getComparable() != "")
+ if (elem.getComparable() != "")
{
// arguments that have a separate string to be displayed need a little more care - just return them without modification. add a space character to the others.
- if (it->hasDisplay())
- return (it->getString());
+ if (elem.hasDisplay())
+ return (elem.getString());
else
- return (it->getString() + ' ');
+ return (elem.getString() + ' ');
}
}
@@ -516,10 +516,10 @@
{
char tempComparable = '\0';
char temp = '\0';
- for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+ for (const auto & elem : list)
{
- const std::string& argumentComparable = it->getComparable();
- const std::string& argument = it->getString();
+ const std::string& argumentComparable = elem.getComparable();
+ const std::string& argument = elem.getString();
// ignore empty arguments
if (argumentComparable == "")
@@ -559,12 +559,12 @@
/* static */ std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
{
std::string output;
- for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+ for (const auto & elem : list)
{
- output += it->getDisplay();
+ output += elem.getDisplay();
// add a space character between two elements for all non-empty arguments
- if (it->getComparable() != "")
+ if (elem.getComparable() != "")
output += ' ';
}
return output;
Modified: code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -74,8 +74,8 @@
this->baseName_ = name;
this->baseFunctor_ = executor->getFunctor();
- for (size_t i = 0; i < MAX_FUNCTOR_ARGUMENTS; ++i)
- this->argumentCompleter_[i] = nullptr;
+ for (auto & elem : this->argumentCompleter_)
+ elem = nullptr;
this->keybindMode_ = KeybindMode::OnPress;
this->inputConfiguredParam_ = -1;
Modified: code/branches/cpp11_v2/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/Shell.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/command/Shell.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -257,8 +257,8 @@
std::vector<std::string> lines;
vectorize(text, '\n', &lines);
- for (size_t i = 0; i < lines.size(); ++i)
- this->addLine(lines[i], type);
+ for (auto & line : lines)
+ this->addLine(line, type);
}
/**
Modified: code/branches/cpp11_v2/src/libraries/core/command/TclThreadList.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/TclThreadList.h 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/command/TclThreadList.h 2015-11-21 18:05:53 UTC (rev 10821)
@@ -261,8 +261,8 @@
{
boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
- for (typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)
- if (*it == value)
+ for (const auto & elem : this->list_)
+ if (elem == value)
return true;
return false;
Modified: code/branches/cpp11_v2/src/libraries/core/command/TclThreadManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/TclThreadManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/command/TclThreadManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -550,9 +550,9 @@
boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
std::list<unsigned int> threads;
- for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
- if (it->first > 0 && it->first <= this->numInterpreterBundles_) // only list autonumbered interpreters (created with create()) - exclude the default interpreter 0 and all manually numbered interpreters)
- threads.push_back(it->first);
+ for (const auto & elem : this->interpreterBundles_)
+ if (elem.first > 0 && elem.first <= this->numInterpreterBundles_) // only list autonumbered interpreters (created with create()) - exclude the default interpreter 0 and all manually numbered interpreters)
+ threads.push_back(elem.first);
return threads;
}
Modified: code/branches/cpp11_v2/src/libraries/core/commandline/CommandLineParser.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/commandline/CommandLineParser.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/commandline/CommandLineParser.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -123,23 +123,23 @@
std::string name;
std::string shortcut;
std::string value;
- for (unsigned int i = 0; i < arguments.size(); ++i)
+ for (auto & argument : arguments)
{
- if (arguments[i].size() != 0)
+ if (argument.size() != 0)
{
// sure not ""
- if (arguments[i][0] == '-')
+ if (argument[0] == '-')
{
// start with "-"
- if (arguments[i].size() == 1)
+ if (argument.size() == 1)
{
// argument[i] is "-", probably a minus sign
value += "- ";
}
- else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
+ else if (argument[1] <= 57 && argument[1] >= 48)
{
// negative number as a value
- value += arguments[i] + ' ';
+ value += argument + ' ';
}
else
{
@@ -160,15 +160,15 @@
assert(name.empty());
}
- if (arguments[i][1] == '-')
+ if (argument[1] == '-')
{
// full name argument with "--name"
- name = arguments[i].substr(2);
+ name = argument.substr(2);
}
else
{
// shortcut with "-s"
- shortcut = arguments[i].substr(1);
+ shortcut = argument.substr(1);
}
// reset value string
@@ -185,7 +185,7 @@
}
// Concatenate strings as long as there's no new argument by "-" or "--"
- value += arguments[i] + ' ';
+ value += argument + ' ';
}
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/config/ConfigFile.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/config/ConfigFile.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/config/ConfigFile.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -233,11 +233,11 @@
return;
}
- for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+ for (const auto & elem : this->sections_)
{
- file << (*it)->getFileEntry() << endl;
+ file << (elem)->getFileEntry() << endl;
- for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)
+ for (std::list<ConfigFileEntry*>::const_iterator it_entries = (elem)->getEntriesBegin(); it_entries != (elem)->getEntriesEnd(); ++it_entries)
file << (*it_entries)->getFileEntry() << endl;
file << endl;
@@ -279,9 +279,9 @@
*/
ConfigFileSection* ConfigFile::getSection(const std::string& section) const
{
- for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
- if ((*it)->getName() == section)
- return (*it);
+ for (const auto & elem : this->sections_)
+ if ((elem)->getName() == section)
+ return (elem);
return nullptr;
}
@@ -290,9 +290,9 @@
*/
ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& section)
{
- for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
- if ((*it)->getName() == section)
- return (*it);
+ for (auto & elem : this->sections_)
+ if ((elem)->getName() == section)
+ return (elem);
this->bUpdated_ = true;
@@ -306,12 +306,12 @@
{
bool sectionsUpdated = false;
- for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+ for (auto & elem : this->sections_)
{
- if ((*it)->bUpdated_)
+ if ((elem)->bUpdated_)
{
sectionsUpdated = true;
- (*it)->bUpdated_ = false;
+ (elem)->bUpdated_ = false;
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/config/ConfigFileManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/config/ConfigFileManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/config/ConfigFileManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -52,9 +52,9 @@
/// Destructor: Deletes the config files.
ConfigFileManager::~ConfigFileManager()
{
- for (std::array<ConfigFile*, 3>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
- if (*it)
- delete (*it);
+ for (const auto & elem : this->configFiles_)
+ if (elem)
+ delete (elem);
}
/// Defines the file-name for the config file of a given type (settings, calibration, etc.).
Modified: code/branches/cpp11_v2/src/libraries/core/config/ConfigFileSection.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/config/ConfigFileSection.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/config/ConfigFileSection.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -79,10 +79,10 @@
unsigned int ConfigFileSection::getVectorSize(const std::string& name) const
{
unsigned int size = 0;
- for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
- if ((*it)->getName() == name)
- if ((*it)->getIndex() >= size)
- size = (*it)->getIndex() + 1;
+ for (const auto & elem : this->entries_)
+ if ((elem)->getName() == name)
+ if ((elem)->getIndex() >= size)
+ size = (elem)->getIndex() + 1;
return size;
}
@@ -104,10 +104,10 @@
*/
ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name) const
{
- for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+ for (const auto & elem : this->entries_)
{
- if ((*it)->getName() == name)
- return *it;
+ if ((elem)->getName() == name)
+ return elem;
}
return nullptr;
}
@@ -120,10 +120,10 @@
*/
ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name, unsigned int index) const
{
- for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+ for (const auto & elem : this->entries_)
{
- if (((*it)->getName() == name) && ((*it)->getIndex() == index))
- return *it;
+ if (((elem)->getName() == name) && ((elem)->getIndex() == index))
+ return elem;
}
return nullptr;
}
Modified: code/branches/cpp11_v2/src/libraries/core/config/ConfigValueContainer.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/config/ConfigValueContainer.h 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/config/ConfigValueContainer.h 2015-11-21 18:05:53 UTC (rev 10821)
@@ -129,8 +129,8 @@
this->init(type, identifier, sectionname, varname);
this->value_ = V();
- for (unsigned int i = 0; i < defvalue.size(); i++)
- this->valueVector_.push_back(MultiType(defvalue[i]));
+ for (auto & elem : defvalue)
+ this->valueVector_.push_back(MultiType(elem));
this->initVector();
}
@@ -182,8 +182,8 @@
std::vector<T> temp = *value;
value->clear();
- for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
- value->push_back(this->valueVector_[i]);
+ for (auto & elem : this->valueVector_)
+ value->push_back(elem);
if (value->size() != temp.size())
{
@@ -210,8 +210,8 @@
else
{
value->clear();
- for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
- value->push_back(this->valueVector_[i]);
+ for (auto & elem : this->valueVector_)
+ value->push_back(elem);
}
return *this;
}
Modified: code/branches/cpp11_v2/src/libraries/core/input/Button.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/Button.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/input/Button.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -195,13 +195,13 @@
cmd->scale_ = paramModifier;
// add command to the buffer if not yet existing
- for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer_->size(); iParamCmd++)
+ for (auto & elem : *paramCommandBuffer_)
{
- if ((*paramCommandBuffer_)[iParamCmd]->evaluation_.getConsoleCommand()
+ if (elem->evaluation_.getConsoleCommand()
== eval.getConsoleCommand())
{
// already in list
- cmd->paramCommand_ = (*paramCommandBuffer_)[iParamCmd];
+ cmd->paramCommand_ = elem;
break;
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/input/InputBuffer.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/InputBuffer.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/input/InputBuffer.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -109,12 +109,12 @@
void InputBuffer::insert(const std::string& input, bool update)
{
- for (unsigned int i = 0; i < input.size(); ++i)
+ for (auto & elem : input)
{
- this->insert(input[i], false);
+ this->insert(elem, false);
if (update)
- this->updated(input[i], false);
+ this->updated(elem, false);
}
if (update)
@@ -169,19 +169,19 @@
void InputBuffer::updated()
{
- for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+ for (auto & elem : this->listeners_)
{
- if ((*it)->bListenToAllChanges_)
- (*it)->callFunction();
+ if ((elem)->bListenToAllChanges_)
+ (elem)->callFunction();
}
}
void InputBuffer::updated(const char& update, bool bSingleInput)
{
- for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+ for (auto & elem : this->listeners_)
{
- if ((!(*it)->trueKeyFalseChar_) && ((*it)->bListenToAllChanges_ || ((*it)->char_ == update)) && (!(*it)->bOnlySingleInput_ || bSingleInput))
- (*it)->callFunction();
+ if ((!(elem)->trueKeyFalseChar_) && ((elem)->bListenToAllChanges_ || ((elem)->char_ == update)) && (!(elem)->bOnlySingleInput_ || bSingleInput))
+ (elem)->callFunction();
}
}
@@ -200,10 +200,10 @@
if (evt.isModifierDown(KeyboardModifier::Alt) && evt.getKeyCode() == KeyCode::Tab)
return;
- for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+ for (auto & elem : this->listeners_)
{
- if ((*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.getKeyCode()))
- (*it)->callFunction();
+ if ((elem)->trueKeyFalseChar_ && ((elem)->key_ == evt.getKeyCode()))
+ (elem)->callFunction();
}
if (evt.isModifierDown(KeyboardModifier::Ctrl))
Modified: code/branches/cpp11_v2/src/libraries/core/input/InputDevice.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/InputDevice.h 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/input/InputDevice.h 2015-11-21 18:05:53 UTC (rev 10821)
@@ -157,14 +157,14 @@
oisDevice_->capture();
// Call all the states with the held button event
- for (unsigned int iB = 0; iB < pressedButtons_.size(); ++iB)
- for (unsigned int iS = 0; iS < inputStates_.size(); ++iS)
- inputStates_[iS]->template buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>(
- this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(pressedButtons_[iB]));
+ for (auto & button : pressedButtons_)
+ for (auto & state : inputStates_)
+ state->template buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>(
+ this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
// Call states with device update events
- for (unsigned int i = 0; i < inputStates_.size(); ++i)
- inputStates_[i]->update(time.getDeltaTime(), this->getDeviceID());
+ for (auto & elem : inputStates_)
+ elem->update(time.getDeltaTime(), this->getDeviceID());
static_cast<DeviceClass*>(this)->updateImpl(time);
}
@@ -195,8 +195,8 @@
return; // Button already pressed
// Call states
- for (unsigned int i = 0; i < inputStates_.size(); ++i)
- inputStates_[i]->template buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
+ for (auto & elem : inputStates_)
+ elem->template buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
}
//! Common code for all button released events (updates pressed buttons list and calls the input states)
@@ -217,8 +217,8 @@
return; // We ignore release strokes when the press was not captured
// Call states
- for (unsigned int i = 0; i < inputStates_.size(); ++i)
- inputStates_[i]->template buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
+ for (auto & elem : inputStates_)
+ elem->template buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
}
//! Managed pointer to the OIS device
Modified: code/branches/cpp11_v2/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/InputManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/input/InputManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -372,11 +372,11 @@
// check whether a state has changed its EMPTY situation
bool bUpdateRequired = false;
- for (std::map<int, InputState*>::iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)
+ for (auto & elem : activeStates_)
{
- if (it->second->hasExpired())
+ if (elem.second->hasExpired())
{
- it->second->resetExpiration();
+ elem.second->resetExpiration();
bUpdateRequired = true;
}
}
@@ -390,8 +390,8 @@
device->update(time);
// Collect function calls for the update
- for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
- activeStatesTicked_[i]->update(time.getDeltaTime());
+ for (auto & elem : activeStatesTicked_)
+ elem->update(time.getDeltaTime());
// Execute all cached function calls in order
// Why so complicated? The problem is that an InputHandler could trigger
@@ -400,8 +400,8 @@
// violations.
// If we delay the calls, then OIS and and the InputStates are not anymore
// in the call stack and can therefore be edited.
- for (size_t i = 0; i < this->callBuffer_.size(); ++i)
- this->callBuffer_[i]();
+ for (auto & elem : this->callBuffer_)
+ elem();
this->callBuffer_.clear();
}
@@ -436,15 +436,15 @@
// See that we only update each InputState once for each device
// Using an std::set to avoid duplicates
std::set<InputState*> tempSet;
- for (unsigned int i = 0; i < devices_.size(); ++i)
- if (devices_[i] != nullptr)
- for (unsigned int iState = 0; iState < devices_[i]->getStateListRef().size(); ++iState)
- tempSet.insert(devices_[i]->getStateListRef()[iState]);
+ for (auto & elem : devices_)
+ if (elem != nullptr)
+ for (unsigned int iState = 0; iState < elem->getStateListRef().size(); ++iState)
+ tempSet.insert(elem->getStateListRef()[iState]);
// Copy the content of the std::set back to the actual vector
activeStatesTicked_.clear();
- for (std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)
- activeStatesTicked_.push_back(*it);
+ for (const auto & elem : tempSet)
+ activeStatesTicked_.push_back(elem);
// Check whether we have to change the mouse mode
tribool requestedMode = dontcare;
Modified: code/branches/cpp11_v2/src/libraries/core/input/JoyStick.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/JoyStick.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/input/JoyStick.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -185,8 +185,8 @@
//! Resets the pov states
void JoyStick::clearBuffersImpl()
{
- for (int j = 0; j < 4; ++j)
- povStates_[j] = 0;
+ for (auto & elem : povStates_)
+ elem = 0;
}
//! Generic method to forward axis events
Modified: code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -152,9 +152,9 @@
void KeyBinder::buttonThresholdChanged()
{
- for (unsigned int i = 0; i < allHalfAxes_.size(); i++)
- if (!allHalfAxes_[i]->bButtonThresholdUser_)
- allHalfAxes_[i]->buttonThreshold_ = this->buttonThreshold_;
+ for (auto & elem : allHalfAxes_)
+ if (!elem->bButtonThresholdUser_)
+ elem->buttonThreshold_ = this->buttonThreshold_;
}
void KeyBinder::JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList)
@@ -382,8 +382,8 @@
for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
it->second->clear();
- for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
- delete paramCommandBuffer_[i];
+ for (auto & elem : paramCommandBuffer_)
+ delete elem;
paramCommandBuffer_.clear();
}
@@ -393,9 +393,9 @@
void KeyBinder::changeMode(ConsoleCommand* command, KeybindMode::Value new_mode)
{
// iterate over all buttons
- for (std::map<std::string, Button*>::iterator it = this->allButtons_.begin(); it != this->allButtons_.end(); ++it)
+ for (const auto & elem : this->allButtons_)
{
- Button* button = it->second;
+ Button* button = elem.second;
// iterate over all modes
for (int mode_index = 0; mode_index < 3; ++mode_index)
@@ -464,8 +464,8 @@
this->mousePosition_[0] = 0.0f;
this->mousePosition_[1] = 0.0f;
- for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
- mouseAxes_[i].reset();
+ for (auto & elem : mouseAxes_)
+ elem.reset();
}
void KeyBinder::mouseUpdated(float dt)
@@ -504,7 +504,7 @@
deriveTime_ += dt;
}
- for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
+ for (auto & elem : mouseAxes_)
{
// Why dividing relative value by dt? The reason lies in the simple fact, that when you
// press a button that has relative movement, that value has to be multiplied by dt to be
@@ -514,10 +514,10 @@
if (dt != 0.0f)
{
// just ignore if dt == 0.0 because we have multiplied by 0.0 anyway..
- mouseAxes_[i].relVal_ /= dt;
+ elem.relVal_ /= dt;
}
- tickHalfAxis(mouseAxes_[i]);
+ tickHalfAxis(elem);
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.h 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.h 2015-11-21 18:05:53 UTC (rev 10821)
@@ -225,15 +225,15 @@
inline void KeyBinder::allDevicesUpdated(float dt)
{
// execute all buffered bindings (additional parameter)
- for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+ for (auto & elem : paramCommandBuffer_)
{
- paramCommandBuffer_[i]->rel_ *= dt;
- paramCommandBuffer_[i]->execute();
+ elem->rel_ *= dt;
+ elem->execute();
}
// always reset the relative movement of the mouse
- for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
- mouseAxes_[i].relVal_ = 0.0f;
+ for (auto & elem : mouseAxes_)
+ elem.relVal_ = 0.0f;
}
}// tolua_export
Modified: code/branches/cpp11_v2/src/libraries/core/input/Mouse.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/Mouse.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/input/Mouse.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -81,15 +81,15 @@
IntVector2 abs(e.state.X.abs, e.state.Y.abs);
IntVector2 rel(e.state.X.rel, e.state.Y.rel);
IntVector2 clippingSize(e.state.width, e.state.height);
- for (unsigned int i = 0; i < inputStates_.size(); ++i)
- inputStates_[i]->mouseMoved(abs, rel, clippingSize);
+ for (auto & elem : inputStates_)
+ elem->mouseMoved(abs, rel, clippingSize);
}
// check for mouse scrolled event
if (e.state.Z.rel != 0)
{
- for (unsigned int i = 0; i < inputStates_.size(); ++i)
- inputStates_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
+ for (auto & elem : inputStates_)
+ elem->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
}
return true;
Modified: code/branches/cpp11_v2/src/libraries/core/module/DynLibManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/module/DynLibManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/module/DynLibManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -74,10 +74,10 @@
DynLibManager::~DynLibManager()
{
// Unload & delete resources in turn
- for (DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it)
+ for (auto & elem : mLibList)
{
- it->second->unload();
- delete it->second;
+ elem.second->unload();
+ delete elem.second;
}
// Empty the list
Modified: code/branches/cpp11_v2/src/libraries/core/module/ModuleInstance.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/module/ModuleInstance.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/module/ModuleInstance.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -58,8 +58,8 @@
void ModuleInstance::loadAllStaticallyInitializedInstances(StaticInitialization::Type type)
{
const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type];
- for (std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it)
- (*it)->load();
+ for (const auto & instance : instances)
+ (instance)->load();
}
void ModuleInstance::unloadAllStaticallyInitializedInstances(StaticInitialization::Type type)
@@ -74,8 +74,8 @@
{
std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*>> copy(this->staticallyInitializedInstancesByType_);
this->staticallyInitializedInstancesByType_.clear();
- for (std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*>>::iterator it1 = copy.begin(); it1 != copy.end(); ++it1)
- for (std::set<StaticallyInitializedInstance*>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2)
+ for (auto & elem : copy)
+ for (std::set<StaticallyInitializedInstance*>::iterator it2 = elem.second.begin(); it2 != elem.second.end(); ++it2)
delete (*it2);
}
Modified: code/branches/cpp11_v2/src/libraries/core/module/PluginManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/module/PluginManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/module/PluginManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -58,19 +58,19 @@
ModifyConsoleCommand("PluginManager", __CC_PluginManager_load_name).setObject(nullptr);
ModifyConsoleCommand("PluginManager", __CC_PluginManager_unload_name).setObject(nullptr);
- for (std::map<std::string, PluginReference*>::iterator it = this->references_.begin(); it != this->references_.end(); ++it)
- delete it->second;
- for (std::map<std::string, Plugin*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)
- delete it->second;
+ for (auto & elem : this->references_)
+ delete elem.second;
+ for (auto & elem : this->plugins_)
+ delete elem.second;
}
void PluginManager::findPlugins()
{
const std::vector<std::string>& pluginPaths = ApplicationPaths::getInstance().getPluginPaths();
- for (std::vector<std::string>::const_iterator it = pluginPaths.begin(); it != pluginPaths.end(); ++it)
+ for (auto libraryName : pluginPaths)
{
std::string name;
- std::string libraryName = (*it);
+
std::string filename = libraryName + + specialConfig::pluginExtension;
std::ifstream infile(filename.c_str());
if (infile >> name)
Modified: code/branches/cpp11_v2/src/libraries/core/module/StaticInitializationManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/module/StaticInitializationManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/module/StaticInitializationManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -49,8 +49,8 @@
void StaticInitializationManager::loadModule(ModuleInstance* module)
{
// attention: loading a module may add new handlers to the list
- for (std::list<StaticInitializationHandler*>::iterator it = this->handlers_.begin(); it != this->handlers_.end(); ++it)
- (*it)->loadModule(module);
+ for (auto & elem : this->handlers_)
+ (elem)->loadModule(module);
}
void StaticInitializationManager::unloadModule(ModuleInstance* module)
Modified: code/branches/cpp11_v2/src/libraries/core/object/Context.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/object/Context.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/object/Context.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -69,8 +69,8 @@
{
// unregister context from object lists before object lists are destroyed
this->unregisterObject();
- for (size_t i = 0; i < this->objectLists_.size(); ++i)
- delete this->objectLists_[i];
+ for (auto & elem : this->objectLists_)
+ delete elem;
}
/*static*/ void Context::setRootContext(Context* context)
Modified: code/branches/cpp11_v2/src/libraries/core/object/Listable.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/object/Listable.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/object/Listable.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -75,8 +75,8 @@
*/
void Listable::unregisterObject()
{
- for (size_t i = 0; i < this->elements_.size(); ++i)
- Listable::deleteObjectListElement(this->elements_[i]);
+ for (auto & elem : this->elements_)
+ Listable::deleteObjectListElement(elem);
this->elements_.clear();
}
@@ -90,10 +90,10 @@
std::vector<ObjectListBaseElement*> copy = this->elements_;
this->elements_.clear();
- for (size_t i = 0; i < copy.size(); ++i)
+ for (auto & elem : copy)
{
- copy[i]->changeContext(this->context_, context);
- Listable::deleteObjectListElement(copy[i]);
+ elem->changeContext(this->context_, context);
+ Listable::deleteObjectListElement(elem);
}
this->context_ = context;
Modified: code/branches/cpp11_v2/src/libraries/core/object/ObjectListBase.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/object/ObjectListBase.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/object/ObjectListBase.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -91,8 +91,8 @@
*/
void ObjectListBase::notifyRemovalListeners(ObjectListBaseElement* element) const
{
- for (std::vector<ObjectListElementRemovalListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
- (*it)->removedElement(element);
+ for (const auto & elem : this->listeners_)
+ (elem)->removedElement(element);
}
/**
Modified: code/branches/cpp11_v2/src/libraries/core/singleton/ScopeManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/singleton/ScopeManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/core/singleton/ScopeManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -72,14 +72,14 @@
void ScopeManager::activateListenersForScope(ScopeID::Value scope)
{
- for (std::set<ScopeListener*>::iterator it = this->listeners_[scope].begin(); it != this->listeners_[scope].end(); ++it)
- this->activateListener(*it);
+ for (const auto & elem : this->listeners_[scope])
+ this->activateListener(elem);
}
void ScopeManager::deactivateListenersForScope(ScopeID::Value scope)
{
- for (std::set<ScopeListener*>::iterator it = this->listeners_[scope].begin(); it != this->listeners_[scope].end(); ++it)
- this->deactivateListener(*it);
+ for (const auto & elem : this->listeners_[scope])
+ this->deactivateListener(elem);
}
void ScopeManager::activateListener(ScopeListener* listener)
Modified: code/branches/cpp11_v2/src/libraries/network/FunctionCall.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/network/FunctionCall.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/network/FunctionCall.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -130,9 +130,9 @@
*(uint32_t*)(mem+sizeof(uint32_t)) = this->nrOfArguments_;
*(uint32_t*)(mem+2*sizeof(uint32_t)) = this->objectID_;
mem += 3*sizeof(uint32_t);
- for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it )
+ for(auto & elem : this->arguments_)
{
- it->exportData( mem );
+ elem.exportData( mem );
}
}
Modified: code/branches/cpp11_v2/src/libraries/network/Host.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/network/Host.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/network/Host.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -79,11 +79,11 @@
*/
void Host::addPacket(ENetPacket *packet, int clientID, uint8_t channelID)
{
- for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
+ for(auto & instances_ : instances_s)
{
- if( (*it)->isActive() )
+ if( (instances_)->isActive() )
{
- (*it)->queuePacket(packet, clientID, channelID);
+ (instances_)->queuePacket(packet, clientID, channelID);
}
}
}
@@ -96,9 +96,9 @@
*/
void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
{
- for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
- if( (*it)->isActive() )
- (*it)->doSendChat(message, sourceID, targetID);
+ for(auto & instances_ : instances_s)
+ if( (instances_)->isActive() )
+ (instances_)->doSendChat(message, sourceID, targetID);
}
/**
@@ -113,11 +113,11 @@
bool Host::isServer()
{
- for (std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it )
+ for (auto & instances_ : instances_s)
{
- if( (*it)->isActive() )
+ if( (instances_)->isActive() )
{
- if( (*it)->isServer_() )
+ if( (instances_)->isServer_() )
return true;
}
}
Modified: code/branches/cpp11_v2/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/network/synchronisable/Synchronisable.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/network/synchronisable/Synchronisable.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -87,8 +87,8 @@
deletedObjects_.push(objectID_);
}
// delete all Synchronisable Variables from syncList_ ( which are also in stringList_ )
- for(std::vector<SynchronisableVariableBase*>::iterator it = syncList_.begin(); it!=syncList_.end(); it++)
- delete (*it);
+ for(auto & elem : syncList_)
+ delete (elem);
syncList_.clear();
stringList_.clear();
std::map<uint32_t, Synchronisable*>::iterator it2;
Modified: code/branches/cpp11_v2/src/libraries/tools/DebugDrawer.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/tools/DebugDrawer.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/tools/DebugDrawer.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -391,13 +391,13 @@
{
manualObject->estimateVertexCount(lineVertices.size());
manualObject->estimateIndexCount(lineIndices.size());
- for (std::list<VertexPair>::iterator i = lineVertices.begin(); i != lineVertices.end(); i++)
+ for (auto & elem : lineVertices)
{
- manualObject->position(i->first);
- manualObject->colour(i->second);
+ manualObject->position(elem.first);
+ manualObject->colour(elem.second);
}
- for (std::list<int>::iterator i = lineIndices.begin(); i != lineIndices.end(); i++)
- manualObject->index(*i);
+ for (auto & elem : lineIndices)
+ manualObject->index(elem);
}
else
manualObject->index(0); // this is necessary to avoid crashes with ogre 1.7 if there's a light source in the level
@@ -408,13 +408,13 @@
{
manualObject->estimateVertexCount(triangleVertices.size());
manualObject->estimateIndexCount(triangleIndices.size());
- for (std::list<VertexPair>::iterator i = triangleVertices.begin(); i != triangleVertices.end(); i++)
+ for (auto & elem : triangleVertices)
{
- manualObject->position(i->first);
- manualObject->colour(i->second.r, i->second.g, i->second.b, fillAlpha);
+ manualObject->position(elem.first);
+ manualObject->colour(elem.second.r, elem.second.g, elem.second.b, fillAlpha);
}
- for (std::list<int>::iterator i = triangleIndices.begin(); i != triangleIndices.end(); i++)
- manualObject->index(*i);
+ for (auto & elem : triangleIndices)
+ manualObject->index(elem);
}
else
manualObject->index(0); // this is necessary to avoid crashes with ogre 1.7 if there's a light source in the level
Modified: code/branches/cpp11_v2/src/libraries/tools/IcoSphere.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/tools/IcoSphere.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/tools/IcoSphere.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -115,9 +115,9 @@
{
std::list<TriangleIndices> faces2;
- for (std::list<TriangleIndices>::iterator j = faces.begin(); j != faces.end(); j++)
+ for (auto f : faces)
{
- TriangleIndices f = *j;
+
int a = getMiddlePoint(f.v1, f.v2);
int b = getMiddlePoint(f.v2, f.v3);
int c = getMiddlePoint(f.v3, f.v1);
@@ -193,20 +193,20 @@
void IcoSphere::addToLineIndices(int baseIndex, std::list<int>* target) const
{
- for (std::list<LineIndices>::const_iterator i = lineIndices.begin(); i != lineIndices.end(); i++)
+ for (const auto & elem : lineIndices)
{
- target->push_back(baseIndex + (*i).v1);
- target->push_back(baseIndex + (*i).v2);
+ target->push_back(baseIndex + (elem).v1);
+ target->push_back(baseIndex + (elem).v2);
}
}
void IcoSphere::addToTriangleIndices(int baseIndex, std::list<int>* target) const
{
- for (std::list<TriangleIndices>::const_iterator i = faces.begin(); i != faces.end(); i++)
+ for (const auto & elem : faces)
{
- target->push_back(baseIndex + (*i).v1);
- target->push_back(baseIndex + (*i).v2);
- target->push_back(baseIndex + (*i).v3);
+ target->push_back(baseIndex + (elem).v1);
+ target->push_back(baseIndex + (elem).v2);
+ target->push_back(baseIndex + (elem).v3);
}
}
@@ -216,8 +216,8 @@
transform.setTrans(position);
transform.setScale(Ogre::Vector3(scale, scale, scale));
- for (int i = 0; i < (int) vertices.size(); i++)
- target->push_back(VertexPair(transform * vertices[i], colour));
+ for (auto & elem : vertices)
+ target->push_back(VertexPair(transform * elem, colour));
return vertices.size();
}
Modified: code/branches/cpp11_v2/src/libraries/tools/Shader.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/tools/Shader.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/tools/Shader.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -196,25 +196,25 @@
void Shader::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr)
{
// iterate through the list of parameters
- for (std::list<ParameterContainer>::iterator it = this->parameters_.begin(); it != this->parameters_.end(); ++it)
+ for (auto & elem : this->parameters_)
{
- Ogre::Technique* techniquePtr = materialPtr->getTechnique(it->technique_);
+ Ogre::Technique* techniquePtr = materialPtr->getTechnique(elem.technique_);
if (techniquePtr)
{
- Ogre::Pass* passPtr = techniquePtr->getPass(it->pass_);
+ Ogre::Pass* passPtr = techniquePtr->getPass(elem.pass_);
if (passPtr)
{
// change the value of the parameter depending on its type
- if (it->value_.isType<int>())
- passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->value_.get<int>());
- else if (it->value_.isType<float>())
- passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->value_.get<float>());
+ if (elem.value_.isType<int>())
+ passPtr->getFragmentProgramParameters()->setNamedConstant(elem.parameter_, elem.value_.get<int>());
+ else if (elem.value_.isType<float>())
+ passPtr->getFragmentProgramParameters()->setNamedConstant(elem.parameter_, elem.value_.get<float>());
}
else
- orxout(internal_warning) << "No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << endl;
+ orxout(internal_warning) << "No pass " << elem.pass_ << " in technique " << elem.technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << endl;
}
else
- orxout(internal_warning) << "No technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << endl;
+ orxout(internal_warning) << "No technique " << elem.technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << endl;
}
this->parameters_.clear();
}
@@ -227,8 +227,8 @@
if (Ogre::Root::getSingletonPtr())
{
const Ogre::Root::PluginInstanceList& plugins = Ogre::Root::getSingleton().getInstalledPlugins();
- for (size_t i = 0; i < plugins.size(); ++i)
- if (plugins[i]->getName() == "Cg Program Manager")
+ for (auto & plugin : plugins)
+ if (plugin->getName() == "Cg Program Manager")
return true;
}
return false;
Modified: code/branches/cpp11_v2/src/libraries/util/DisplayStringConversions.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/DisplayStringConversions.h 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/DisplayStringConversions.h 2015-11-21 18:05:53 UTC (rev 10821)
@@ -50,9 +50,9 @@
inline static bool convert(Ogre::DisplayString* output, const std::string& input)
{
Ogre::UTFString::code_point cp;
- for (unsigned int i = 0; i < input.size(); ++i)
+ for (auto & elem : input)
{
- cp = input[i];
+ cp = elem;
cp &= 0xFF;
output->append(1, cp);
}
Modified: code/branches/cpp11_v2/src/libraries/util/Serialise.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/Serialise.h 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/Serialise.h 2015-11-21 18:05:53 UTC (rev 10821)
@@ -671,8 +671,8 @@
template <class T> inline uint32_t returnSize( const std::set<T>& variable )
{
uint32_t tempsize = sizeof(uint32_t); // for the number of entries
- for( typename std::set<T>::iterator it=((std::set<T>*)(&variable))->begin(); it!=((std::set<T>*)(&variable))->end(); ++it)
- tempsize += returnSize( *it );
+ for(const auto & elem : *((std::set<T>*)(&variable)))
+ tempsize += returnSize( elem );
return tempsize;
}
Modified: code/branches/cpp11_v2/src/libraries/util/SignalHandler.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/SignalHandler.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/SignalHandler.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -80,9 +80,9 @@
*/
void SignalHandler::dontCatch()
{
- for ( SignalRecList::iterator it = sigRecList.begin(); it != sigRecList.end(); it++ )
+ for (auto & elem : sigRecList)
{
- signal( it->signal, it->handler );
+ signal( elem.signal, elem.handler );
}
sigRecList.clear();
@@ -132,9 +132,9 @@
exit(EXIT_FAILURE);
}
- for ( SignalCallbackList::iterator it = SignalHandler::getInstance().callbackList.begin(); it != SignalHandler::getInstance().callbackList.end(); it++ )
+ for (auto & elem : SignalHandler::getInstance().callbackList)
{
- (*(it->cb))( it->someData );
+ (*(elem.cb))( elem.someData );
}
Modified: code/branches/cpp11_v2/src/libraries/util/SmallObjectAllocator.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/SmallObjectAllocator.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/SmallObjectAllocator.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -52,8 +52,8 @@
*/
SmallObjectAllocator::~SmallObjectAllocator()
{
- for (std::vector<char*>::iterator it = this->blocks_.begin(); it != this->blocks_.end(); ++it)
- delete[] *it;
+ for (auto & elem : this->blocks_)
+ delete[] elem;
}
/**
Modified: code/branches/cpp11_v2/src/libraries/util/StringUtils.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/StringUtils.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/StringUtils.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -261,9 +261,9 @@
{
std::string output(str.size() * 2, ' ');
size_t i = 0;
- for (size_t pos = 0; pos < str.size(); ++pos)
+ for (auto & elem : str)
{
- switch (str[pos])
+ switch (elem)
{
case '\\': output[i] = '\\'; output[i + 1] = '\\'; break;
case '\n': output[i] = '\\'; output[i + 1] = 'n'; break;
@@ -275,7 +275,7 @@
case '\a': output[i] = '\\'; output[i + 1] = 'a'; break;
case '"': output[i] = '\\'; output[i + 1] = '"'; break;
case '\0': output[i] = '\\'; output[i + 1] = '0'; break;
- default : output[i] = str[pos]; ++i; continue;
+ default : output[i] = elem; ++i; continue;
}
i += 2;
}
@@ -335,9 +335,9 @@
/// Replaces each char between A and Z with its lowercase equivalent.
void lowercase(std::string* str)
{
- for (size_t i = 0; i < str->size(); ++i)
+ for (auto & elem : *str)
{
- (*str)[i] = static_cast<char>(tolower((*str)[i]));
+ elem = static_cast<char>(tolower(elem));
}
}
@@ -352,9 +352,9 @@
/// Replaces each char between a and z with its uppercase equivalent.
void uppercase(std::string* str)
{
- for (size_t i = 0; i < str->size(); ++i)
+ for (auto & elem : *str)
{
- (*str)[i] = static_cast<char>(toupper((*str)[i]));
+ elem = static_cast<char>(toupper(elem));
}
}
@@ -459,11 +459,11 @@
size_t replaceCharacters(std::string& str, char target, char replacement)
{
size_t j = 0;
- for (size_t i = 0; i < str.size(); ++i)
+ for (auto & elem : str)
{
- if (str[i] == target)
+ if (elem == target)
{
- str[i] = replacement;
+ elem = replacement;
++j;
}
}
Modified: code/branches/cpp11_v2/src/libraries/util/output/BaseWriter.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/output/BaseWriter.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/output/BaseWriter.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -115,9 +115,9 @@
std::set<const OutputContextContainer*> sub_contexts;
// iterate over all strings in the config-vector
- for (size_t i = 0; i < this->configurableAdditionalContexts_.size(); ++i)
+ for (auto & full_name : this->configurableAdditionalContexts_)
{
- const std::string& full_name = this->configurableAdditionalContexts_[i];
+
// split the name into main-name and sub-name (if given; otherwise sub-name remains empty). both names are separated by ::
std::string name = full_name;
Modified: code/branches/cpp11_v2/src/libraries/util/output/MemoryWriter.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/output/MemoryWriter.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/output/MemoryWriter.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -64,9 +64,9 @@
*/
void MemoryWriter::resendOutput(OutputListener* listener) const
{
- for (size_t i = 0; i < this->messages_.size(); ++i)
+ for (auto & message : this->messages_)
{
- const Message& message = this->messages_[i];
+
listener->unfilteredOutput(message.level, *message.context, message.lines);
}
}
Modified: code/branches/cpp11_v2/src/libraries/util/output/OutputListener.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/output/OutputListener.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/output/OutputListener.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -110,8 +110,8 @@
{
this->levelMask_ = mask;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- this->listeners_[i]->updatedLevelMask(this);
+ for (auto & elem : this->listeners_)
+ elem->updatedLevelMask(this);
}
/**
@@ -141,8 +141,8 @@
{
this->additionalContextsLevelMask_ = mask;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- this->listeners_[i]->updatedAdditionalContextsLevelMask(this);
+ for (auto & elem : this->listeners_)
+ elem->updatedAdditionalContextsLevelMask(this);
}
/**
@@ -152,8 +152,8 @@
{
this->additionalContextsMask_ = mask;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- this->listeners_[i]->updatedAdditionalContextsMask(this);
+ for (auto & elem : this->listeners_)
+ elem->updatedAdditionalContextsMask(this);
}
/**
Modified: code/branches/cpp11_v2/src/libraries/util/output/OutputManager.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/output/OutputManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/output/OutputManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -131,8 +131,8 @@
std::vector<std::string> lines;
vectorize(message, '\n', &lines);
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- this->listeners_[i]->unfilteredOutput(level, context, lines);
+ for (auto & elem : this->listeners_)
+ elem->unfilteredOutput(level, context, lines);
}
/**
@@ -178,8 +178,8 @@
void OutputManager::updateCombinedLevelMask()
{
int mask = 0;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- mask |= this->listeners_[i]->getLevelMask();
+ for (auto & elem : this->listeners_)
+ mask |= elem->getLevelMask();
this->combinedLevelMask_ = static_cast<OutputLevel>(mask);
}
@@ -189,8 +189,8 @@
void OutputManager::updateCombinedAdditionalContextsLevelMask()
{
int mask = 0;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- mask |= this->listeners_[i]->getAdditionalContextsLevelMask();
+ for (auto & elem : this->listeners_)
+ mask |= elem->getAdditionalContextsLevelMask();
this->combinedAdditionalContextsLevelMask_ = static_cast<OutputLevel>(mask);
}
@@ -200,8 +200,8 @@
void OutputManager::updateCombinedAdditionalContextsMask()
{
this->combinedAdditionalContextsMask_ = 0;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- this->combinedAdditionalContextsMask_ |= this->listeners_[i]->getAdditionalContextsMask();
+ for (auto & elem : this->listeners_)
+ this->combinedAdditionalContextsMask_ |= elem->getAdditionalContextsMask();
}
/**
Modified: code/branches/cpp11_v2/src/libraries/util/output/SubcontextOutputListener.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/output/SubcontextOutputListener.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/libraries/util/output/SubcontextOutputListener.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -78,10 +78,10 @@
this->subcontexts_.clear();
// compose the mask of subcontexts and build the set of sub-context-IDs
- for (std::set<const OutputContextContainer*>::const_iterator it = subcontexts.begin(); it != subcontexts.end(); ++it)
+ for (const auto & subcontext : subcontexts)
{
- this->subcontextsCheckMask_ |= (*it)->mask;
- this->subcontexts_.insert((*it)->sub_id);
+ this->subcontextsCheckMask_ |= (subcontext)->mask;
+ this->subcontexts_.insert((subcontext)->sub_id);
}
OutputListener::setAdditionalContextsMask(this->subcontextsCheckMask_ | this->subcontextsNoCheckMask_);
Modified: code/branches/cpp11_v2/src/modules/docking/Dock.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/docking/Dock.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/docking/Dock.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -326,10 +326,10 @@
const DockingEffect* Dock::getEffect(unsigned int i) const
{
- for (std::list<DockingEffect*>::const_iterator effect = this->effects_.begin(); effect != this->effects_.end(); ++effect)
+ for (const auto & elem : this->effects_)
{
if(i == 0)
- return *effect;
+ return elem;
i--;
}
return nullptr;
@@ -345,10 +345,10 @@
const DockingAnimation* Dock::getAnimation(unsigned int i) const
{
- for (std::list<DockingAnimation*>::const_iterator animation = this->animations_.begin(); animation != this->animations_.end(); ++animation)
+ for (const auto & elem : this->animations_)
{
if(i == 0)
- return *animation;
+ return elem;
i--;
}
return nullptr;
Modified: code/branches/cpp11_v2/src/modules/docking/DockingAnimation.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/docking/DockingAnimation.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/docking/DockingAnimation.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -56,12 +56,12 @@
{
bool check = true;
- for (std::list<DockingAnimation*>::iterator animation = animations.begin(); animation != animations.end(); animation++)
+ for (auto & animations_animation : animations)
{
if(dock)
- check &= (*animation)->docking(player);
+ check &= (animations_animation)->docking(player);
else
- check &= (*animation)->release(player);
+ check &= (animations_animation)->release(player);
}
return check;
Modified: code/branches/cpp11_v2/src/modules/docking/DockingEffect.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/docking/DockingEffect.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/docking/DockingEffect.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -52,12 +52,12 @@
{
bool check = true;
- for (std::list<DockingEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
+ for (auto & effects_effect : effects)
{
if (dock)
- check &= (*effect)->docking(player);
+ check &= (effects_effect)->docking(player);
else
- check &= (*effect)->release(player);
+ check &= (effects_effect)->release(player);
}
return check;
Modified: code/branches/cpp11_v2/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/gametypes/RaceCheckPoint.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/gametypes/RaceCheckPoint.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -145,13 +145,13 @@
Vector3 RaceCheckPoint::getNextCheckpointsAsVector3()
{
Vector3 checkpoints(-1,-1,-1); int count=0;
- for (std::set<int>::iterator it= nextCheckpoints_.begin();it!=nextCheckpoints_.end(); it++ )
+ for (const auto & elem : nextCheckpoints_)
{
switch (count)
{
- case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break;
- case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break;
- case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break;
+ case 0: checkpoints.x = static_cast<Ogre::Real>(elem); break;
+ case 1: checkpoints.y = static_cast<Ogre::Real>(elem); break;
+ case 2: checkpoints.z = static_cast<Ogre::Real>(elem); break;
}
++count;
}
Modified: code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceController.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceController.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceController.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -153,18 +153,18 @@
std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints(RaceCheckPoint* currentCheckpoint, const std::vector<RaceCheckPoint*>& allCheckpoints)
{
std::map<RaceCheckPoint*, int> zaehler; // counts how many times the checkpoint was reached (for simulation)
- for (unsigned int i = 0; i < allCheckpoints.size(); i++)
+ for (auto & allCheckpoint : allCheckpoints)
{
- zaehler.insert(std::pair<RaceCheckPoint*, int>(allCheckpoints[i],0));
+ zaehler.insert(std::pair<RaceCheckPoint*, int>(allCheckpoint,0));
}
int maxWays = rekSimulationCheckpointsReached(currentCheckpoint, zaehler);
std::vector<RaceCheckPoint*> returnVec;
- for (std::map<RaceCheckPoint*, int>::iterator iter = zaehler.begin(); iter != zaehler.end(); iter++)
+ for (auto & elem : zaehler)
{
- if (iter->second == maxWays)
+ if (elem.second == maxWays)
{
- returnVec.push_back(iter->first);
+ returnVec.push_back(elem.first);
}
}
return returnVec;
@@ -225,9 +225,9 @@
RaceCheckPoint* minNextRaceCheckPoint = nullptr;
// find the next checkpoint with the minimal distance
- for (std::set<int>::iterator it = raceCheckpoint->getNextCheckpoints().begin(); it != raceCheckpoint->getNextCheckpoints().end(); ++it)
+ for (auto elem : raceCheckpoint->getNextCheckpoints())
{
- RaceCheckPoint* nextRaceCheckPoint = findCheckpoint(*it);
+ RaceCheckPoint* nextRaceCheckPoint = findCheckpoint(elem);
float distance = recCalculateDistance(nextRaceCheckPoint, this->getControllableEntity()->getPosition());
if (distance < minDistance || minNextRaceCheckPoint == nullptr)
@@ -288,9 +288,9 @@
RaceCheckPoint* SpaceRaceController::findCheckpoint(int index) const
{
- for (size_t i = 0; i < this->checkpoints_.size(); ++i)
- if (this->checkpoints_[i]->getCheckpointIndex() == index)
- return this->checkpoints_[i];
+ for (auto & elem : this->checkpoints_)
+ if (elem->getCheckpointIndex() == index)
+ return elem;
return nullptr;
}
@@ -413,11 +413,11 @@
btVector3 positionObject;
btScalar radiusObject;
- for (std::vector<StaticEntity*>::const_iterator it = allObjects.begin(); it != allObjects.end(); ++it)
+ for (const auto & allObject : allObjects)
{
- for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != nullptr; everyShape++)
+ for (int everyShape=0; (allObject)->getAttachedCollisionShape(everyShape) != nullptr; everyShape++)
{
- btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();
+ btCollisionShape* currentShape = (allObject)->getAttachedCollisionShape(everyShape)->getCollisionShape();
if(currentShape == nullptr)
continue;
Modified: code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -53,8 +53,8 @@
SpaceRaceManager::~SpaceRaceManager()
{
- for (size_t i = 0; i < this->checkpoints_.size(); ++i)
- this->checkpoints_[i]->destroy();
+ for (auto & elem : this->checkpoints_)
+ elem->destroy();
}
void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -76,13 +76,13 @@
this->firstcheckpointvisible_ = true;
}
- for ( std::map< PlayerInfo*, Player>::iterator it = players_.begin(); it != players_.end(); ++it)
+ for (auto & elem : players_)
{
- for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+ for (auto & _i : this->checkpoints_)
{
- if (this->checkpoints_[i]->playerWasHere(it->first)){
- this->checkpointReached(this->checkpoints_[i], it->first /*this->checkpoints_[i]->getPlayer()*/);
+ if (_i->playerWasHere(elem.first)){
+ this->checkpointReached(_i, elem.first /*this->checkpoints_[i]->getPlayer()*/);
}
}
}
@@ -112,9 +112,9 @@
*/
RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const
{
- for (size_t i = 0; i < this->checkpoints_.size(); ++i)
- if (this->checkpoints_[i]->getCheckpointIndex() == index)
- return this->checkpoints_[i];
+ for (auto & elem : this->checkpoints_)
+ if (elem->getCheckpointIndex() == index)
+ return elem;
return nullptr;
}
@@ -124,8 +124,8 @@
{
// the player already visited an old checkpoint; see which checkpoints are possible now
const std::set<int>& possibleCheckpoints = oldCheckpoint->getNextCheckpoints();
- for (std::set<int>::const_iterator it = possibleCheckpoints.begin(); it != possibleCheckpoints.end(); ++it)
- if (this->findCheckpoint(*it) == newCheckpoint)
+ for (const auto & possibleCheckpoint : possibleCheckpoints)
+ if (this->findCheckpoint(possibleCheckpoint) == newCheckpoint)
return true;
return false;
}
@@ -178,8 +178,8 @@
if (oldCheckpoint)
{
const std::set<int>& oldVisible = oldCheckpoint->getNextCheckpoints();
- for (std::set<int>::const_iterator it = oldVisible.begin(); it != oldVisible.end(); ++it)
- this->findCheckpoint(*it)->setRadarVisibility(false);
+ for (const auto & elem : oldVisible)
+ this->findCheckpoint(elem)->setRadarVisibility(false);
}
if (newCheckpoint)
@@ -187,8 +187,8 @@
newCheckpoint->setRadarVisibility(false);
const std::set<int>& newVisible = newCheckpoint->getNextCheckpoints();
- for (std::set<int>::const_iterator it = newVisible.begin(); it != newVisible.end(); ++it)
- this->findCheckpoint(*it)->setRadarVisibility(true);
+ for (const auto & elem : newVisible)
+ this->findCheckpoint(elem)->setRadarVisibility(true);
}
}
}
Modified: code/branches/cpp11_v2/src/modules/jump/Jump.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/jump/Jump.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/jump/Jump.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -632,12 +632,12 @@
} matrix[numI][numJ];
- for (int i = 0; i < numI; ++i)
+ for (auto & elem : matrix)
{
for (int j = 0; j < numJ; ++j)
{
- matrix[i][j].type = PLATFORM_EMPTY;
- matrix[i][j].done = false;
+ elem[j].type = PLATFORM_EMPTY;
+ elem[j].done = false;
}
}
PlatformType platformtype1;
@@ -794,19 +794,19 @@
}
// Fill matrix with selected platform types
- for (int i = 0; i < numI; ++ i)
+ for (auto & elem : matrix)
{
for (int j = 0; j < numJ; ++ j)
{
if (rand()%3 == 0)
{
- matrix[i][j].type = platformtype1;
+ elem[j].type = platformtype1;
}
else
{
- matrix[i][j].type = platformtype2;
+ elem[j].type = platformtype2;
}
- matrix[i][j].done = false;
+ elem[j].done = false;
}
}
Modified: code/branches/cpp11_v2/src/modules/mini4dgame/Mini4Dgame.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/mini4dgame/Mini4Dgame.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/mini4dgame/Mini4Dgame.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -154,13 +154,13 @@
void Mini4Dgame::spawnPlayersIfRequested()
{
// first spawn human players to assign always the left bat to the player in singleplayer
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
- this->spawnPlayer(it->first);
+ for (auto & elem : this->players_)
+ if (elem.first->isHumanPlayer() && (elem.first->isReadyToSpawn() || this->bForceSpawn_))
+ this->spawnPlayer(elem.first);
// now spawn bots
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
- this->spawnPlayer(it->first);
+ for (auto & elem : this->players_)
+ if (!elem.first->isHumanPlayer() && (elem.first->isReadyToSpawn() || this->bForceSpawn_))
+ this->spawnPlayer(elem.first);
}
/**
Modified: code/branches/cpp11_v2/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/notifications/NotificationManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/notifications/NotificationManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -68,8 +68,8 @@
NotificationManager::~NotificationManager()
{
// Destroys all Notifications.
- for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++)
- it->second->destroy();
+ for(auto & elem : this->allNotificationsList_)
+ elem.second->destroy();
this->allNotificationsList_.clear();
orxout(internal_info, context::notifications) << "NotificationManager destroyed." << endl;
@@ -151,12 +151,12 @@
bool all = (sender == NotificationListener::ALL);
bool executed = false;
// Clear all NotificationQueues that have the input sender as target.
- for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
+ for(auto & elem : this->queues_) // Iterate through all NotificationQueues.
{
- const std::set<std::string>& set = it->second->getTargetsSet();
+ const std::set<std::string>& set = elem.second->getTargetsSet();
// If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target.
if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end())
- executed = it->second->tidy() || executed;
+ executed = elem.second->tidy() || executed;
}
return executed;
@@ -186,16 +186,16 @@
bool all = (notification->getSender() == NotificationListener::ALL);
// Insert the Notification in all NotificationQueues that have its sender as target.
- for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
+ for(auto & elem : this->queues_) // Iterate through all NotificationQueues.
{
- const std::set<std::string>& set = it->second->getTargetsSet();
+ const std::set<std::string>& set = elem.second->getTargetsSet();
bool bAll = set.find(NotificationListener::ALL) != set.end();
// If either the Notification has as sender 'all', the NotificationQueue displays all Notifications or the NotificationQueue has the sender of the Notification as target.
if(all || bAll || set.find(notification->getSender()) != set.end())
{
if(!bAll)
- this->notificationLists_[it->second->getName()]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationQueue.
- it->second->update(notification, time); // Update the NotificationQueue.
+ this->notificationLists_[elem.second->getName()]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationQueue.
+ elem.second->update(notification, time); // Update the NotificationQueue.
}
}
@@ -344,10 +344,10 @@
}
// Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue.
- for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
+ for(auto & elem : this->allNotificationsList_)
{
- if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.
- map->insert(std::pair<std::time_t, Notification*>(it->first, it->second));
+ if(!bAll && set.find(elem.second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.
+ map->insert(std::pair<std::time_t, Notification*>(elem.first, elem.second));
}
queue->update(); // Update the queue.
Modified: code/branches/cpp11_v2/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/notifications/NotificationQueue.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/notifications/NotificationQueue.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -205,10 +205,10 @@
if(!notifications->empty())
{
// Add all Notifications that have been created after this NotificationQueue was created.
- for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++)
+ for(auto & notification : *notifications)
{
- if(it->first >= this->creationTime_)
- this->push(it->second, it->first);
+ if(notification.first >= this->creationTime_)
+ this->push(notification.second, notification.first);
}
}
@@ -335,8 +335,8 @@
orxout(verbose, context::notifications) << "Clearing NotificationQueue " << this->getName() << "." << endl;
this->ordering_.clear();
// Delete all NotificationContainers in the list.
- for(std::vector<NotificationContainer*>::iterator it = this->notifications_.begin(); it != this->notifications_.end(); it++)
- delete *it;
+ for(auto & elem : this->notifications_)
+ delete elem;
this->notifications_.clear();
this->size_ = 0;
@@ -425,13 +425,13 @@
std::stringstream stream;
bool first = true;
// Iterate through the set of targets.
- for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
+ for(const auto & elem : this->targets_)
{
if(!first)
stream << ", ";
else
first = false;
- stream << *it;
+ stream << elem;
}
return *(new std::string(stream.str()));
Modified: code/branches/cpp11_v2/src/modules/objects/Attacher.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/Attacher.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/Attacher.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -60,16 +60,16 @@
{
SUPER(Attacher, changedActivity);
- for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
- (*it)->setActive(this->isActive());
+ for (auto & elem : this->objects_)
+ (elem)->setActive(this->isActive());
}
void Attacher::changedVisibility()
{
SUPER(Attacher, changedVisibility);
- for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
- (*it)->setVisible(this->isVisible());
+ for (auto & elem : this->objects_)
+ (elem)->setVisible(this->isVisible());
}
void Attacher::addObject(WorldEntity* object)
@@ -82,10 +82,10 @@
WorldEntity* Attacher::getObject(unsigned int index) const
{
unsigned int i = 0;
- for (std::list<WorldEntity*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+ for (const auto & elem : this->objects_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
Modified: code/branches/cpp11_v2/src/modules/objects/Script.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/Script.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/Script.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -195,9 +195,9 @@
if(this->isForAll())
{
const std::map<unsigned int, PlayerInfo*> clients = PlayerManager::getInstance().getClients();
- for(std::map<unsigned int, PlayerInfo*>::const_iterator it = clients.begin(); it != clients.end(); it++)
+ for(const auto & client : clients)
{
- callStaticNetworkFunction(&Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
+ callStaticNetworkFunction(&Script::executeHelper, client.first, this->getCode(), this->getMode(), this->getNeedsGraphics());
if(this->times_ != Script::INF) // Decrement the number of remaining executions.
{
this->remainingExecutions_--;
Modified: code/branches/cpp11_v2/src/modules/objects/SpaceBoundaries.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/SpaceBoundaries.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/SpaceBoundaries.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -58,11 +58,11 @@
{
this->pawnsIn_.clear();
- for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)
+ for(auto & elem : this->billboards_)
{
- if( current->billy != nullptr)
+ if( elem.billy != nullptr)
{
- delete current->billy;
+ delete elem.billy;
}
}
this->billboards_.clear();
@@ -137,10 +137,10 @@
void SpaceBoundaries::removeAllBillboards()
{
- for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++ )
+ for(auto & elem : this->billboards_)
{
- current->usedYet = false;
- current->billy->setVisible(false);
+ elem.usedYet = false;
+ elem.billy->setVisible(false);
}
}
@@ -207,9 +207,9 @@
float distance;
bool humanItem;
- for( std::list<WeakPtr<Pawn>>::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
+ for(auto currentPawn : pawnsIn_)
{
- Pawn* currentPawn = *current;
+
if( currentPawn && currentPawn->getNode() )
{
distance = this->computeDistance(currentPawn);
Modified: code/branches/cpp11_v2/src/modules/objects/eventsystem/EventDispatcher.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/eventsystem/EventDispatcher.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/eventsystem/EventDispatcher.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -44,8 +44,8 @@
EventDispatcher::~EventDispatcher()
{
if (this->isInitialized())
- for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
- (*it)->destroy();
+ for (auto & elem : this->targets_)
+ (elem)->destroy();
}
void EventDispatcher::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -60,8 +60,8 @@
void EventDispatcher::processEvent(Event& event)
{
- for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
- (*it)->processEvent(event);
+ for (auto & elem : this->targets_)
+ (elem)->processEvent(event);
}
void EventDispatcher::addTarget(BaseObject* target)
@@ -72,10 +72,10 @@
BaseObject* EventDispatcher::getTarget(unsigned int index) const
{
unsigned int i = 0;
- for (std::list<BaseObject*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
+ for (const auto & elem : this->targets_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
return nullptr;
Modified: code/branches/cpp11_v2/src/modules/objects/eventsystem/EventFilter.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/eventsystem/EventFilter.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/eventsystem/EventFilter.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -95,10 +95,10 @@
BaseObject* EventFilter::getFilterSource(unsigned int index) const
{
unsigned int i = 0;
- for (std::list<BaseObject*>::const_iterator it = this->sources_.begin(); it != this->sources_.end(); ++it)
+ for (const auto & elem : this->sources_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
return nullptr;
@@ -112,10 +112,10 @@
EventName* EventFilter::getEventName(unsigned int index) const
{
unsigned int i = 0;
- for (std::list<EventName*>::const_iterator it = this->names_.begin(); it != this->names_.end(); ++it)
+ for (const auto & elem : this->names_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
return nullptr;
Modified: code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -159,9 +159,9 @@
const std::set<WorldEntity*> attached = entity->getAttachedObjects();
bool found = false;
- for(std::set<WorldEntity*>::const_iterator it = attached.begin(); it != attached.end(); it++)
+ for(const auto & elem : attached)
{
- if((*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(*it)->getName() == this->targetName_)
+ if((elem)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(elem)->getName() == this->targetName_)
{
found = true;
break;
Modified: code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -181,9 +181,9 @@
const std::set<WorldEntity*> attached = entity->getAttachedObjects();
bool found = false;
- for(std::set<WorldEntity*>::const_iterator it = attached.begin(); it != attached.end(); it++)
+ for(const auto & elem : attached)
{
- if((*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(*it)->getName() == this->targetName_)
+ if((elem)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(elem)->getName() == this->targetName_)
{
found = true;
break;
Modified: code/branches/cpp11_v2/src/modules/objects/triggers/MultiTrigger.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/MultiTrigger.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/MultiTrigger.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -503,9 +503,9 @@
*/
bool MultiTrigger::checkAnd(BaseObject* triggerer)
{
- for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+ for(auto trigger : this->children_)
{
- TriggerBase* trigger = *it;
+
if(trigger->isMultiTrigger())
{
if(!static_cast<MultiTrigger*>(trigger)->isActive(triggerer))
@@ -530,9 +530,9 @@
*/
bool MultiTrigger::checkOr(BaseObject* triggerer)
{
- for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+ for(auto trigger : this->children_)
{
- TriggerBase* trigger = *it;
+
if(trigger->isMultiTrigger())
{
if(static_cast<MultiTrigger*>(trigger)->isActive(triggerer))
@@ -558,9 +558,9 @@
bool MultiTrigger::checkXor(BaseObject* triggerer)
{
bool triggered = false;
- for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+ for(auto trigger : this->children_)
{
- TriggerBase* trigger = *it;
+
if(triggered)
{
if(trigger->isMultiTrigger())
Modified: code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -233,9 +233,9 @@
bool Trigger::checkAnd()
{
// Iterate over all sub-triggers.
- for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+ for (const auto & elem : this->children_)
{
- if (!(*it)->isActive())
+ if (!(elem)->isActive())
return false;
}
return true;
@@ -251,9 +251,9 @@
bool Trigger::checkOr()
{
// Iterate over all sub-triggers.
- for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+ for (const auto & elem : this->children_)
{
- if ((*it)->isActive())
+ if ((elem)->isActive())
return true;
}
return false;
@@ -269,11 +269,11 @@
bool Trigger::checkXor()
{
bool test = false;
- for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+ for (const auto & elem : this->children_)
{
- if (test && (*it)->isActive())
+ if (test && (elem)->isActive())
return false;
- if ((*it)->isActive())
+ if ((elem)->isActive())
test = true;
}
return test;
Modified: code/branches/cpp11_v2/src/modules/overlays/hud/ChatOverlay.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/overlays/hud/ChatOverlay.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/overlays/hud/ChatOverlay.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -57,8 +57,8 @@
ChatOverlay::~ChatOverlay()
{
- for (std::set<Timer*>::iterator it = this->timers_.begin(); it != this->timers_.end(); ++it)
- delete (*it);
+ for (const auto & elem : this->timers_)
+ delete (elem);
}
void ChatOverlay::setConfigValues()
@@ -91,9 +91,9 @@
{
this->text_->setCaption("");
- for (std::list<Ogre::DisplayString>::iterator it = this->messages_.begin(); it != this->messages_.end(); ++it)
+ for (auto & elem : this->messages_)
{
- this->text_->setCaption(this->text_->getCaption() + "\n" + (*it));
+ this->text_->setCaption(this->text_->getCaption() + "\n" + (elem));
}
}
}
Modified: code/branches/cpp11_v2/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/overlays/hud/HUDNavigation.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/overlays/hud/HUDNavigation.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -130,10 +130,10 @@
return;
}
this->fontName_ = font;
- for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end(); ++it)
+ for (auto & elem : this->activeObjectList_)
{
- if (it->second.text_ != nullptr)
- it->second.text_->setFontName(this->fontName_);
+ if (elem.second.text_ != nullptr)
+ elem.second.text_->setFontName(this->fontName_);
}
}
@@ -150,10 +150,10 @@
return;
}
this->textSize_ = size;
- for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it!=this->activeObjectList_.end(); ++it)
+ for (auto & elem : this->activeObjectList_)
{
- if (it->second.text_)
- it->second.text_->setCharHeight(size);
+ if (elem.second.text_)
+ elem.second.text_->setCharHeight(size);
}
}
@@ -185,8 +185,8 @@
return;
const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
- for (std::list<std::pair<RadarViewable*, unsigned int>>::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++listIt)
- listIt->second = (int)((listIt->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f);
+ for (auto & elem : this->sortedObjectList_)
+ elem.second = (int)((elem.first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f);
this->sortedObjectList_.sort(compareDistance);
@@ -530,18 +530,18 @@
float xScale = this->getActualSize().x;
float yScale = this->getActualSize().y;
- for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end(); ++it)
+ for (auto & elem : this->activeObjectList_)
{
- if (it->second.health_ != nullptr)
- it->second.health_->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale);
- if (it->second.healthLevel_ != nullptr)
- it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * xScale, this->healthLevelMarkerSize_ * yScale);
- if (it->second.panel_ != nullptr)
- it->second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
- if (it->second.text_ != nullptr)
- it->second.text_->setCharHeight(this->textSize_ * yScale);
- if (it->second.target_ != nullptr)
- it->second.target_->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * yScale);
+ if (elem.second.health_ != nullptr)
+ elem.second.health_->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale);
+ if (elem.second.healthLevel_ != nullptr)
+ elem.second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * xScale, this->healthLevelMarkerSize_ * yScale);
+ if (elem.second.panel_ != nullptr)
+ elem.second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
+ if (elem.second.text_ != nullptr)
+ elem.second.text_->setCharHeight(this->textSize_ * yScale);
+ if (elem.second.target_ != nullptr)
+ elem.second.target_->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * yScale);
}
}
@@ -669,10 +669,10 @@
void HUDNavigation::changedOwner()
{
const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects();
- for (std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it)
+ for (const auto & respawnObject : respawnObjects)
{
- if (!(*it)->isHumanShip_)
- this->addObject(*it);
+ if (!(respawnObject)->isHumanShip_)
+ this->addObject(respawnObject);
}
}
Modified: code/branches/cpp11_v2/src/modules/overlays/hud/HUDRadar.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/overlays/hud/HUDRadar.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/overlays/hud/HUDRadar.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -91,10 +91,9 @@
Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->map3DFront_);
Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->map3DBack_);
- for (std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it = this->radarObjects_.begin();
- it != this->radarObjects_.end(); ++it)
+ for (auto & elem : this->radarObjects_)
{
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second);
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(elem.second);
}
}
}
Modified: code/branches/cpp11_v2/src/modules/overlays/stats/Scoreboard.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/overlays/stats/Scoreboard.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/overlays/stats/Scoreboard.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -59,8 +59,8 @@
{
SUPER(Scoreboard, changedVisibility);
- for (unsigned int i = 0; i < this->lines_.size(); ++i)
- this->lines_[i]->changedVisibility();
+ for (auto & elem : this->lines_)
+ elem->changedVisibility();
}
/**
@@ -93,11 +93,11 @@
// update board
unsigned int index = 0;
- for (std::map<PlayerInfo*, Player>::const_iterator it = playerList.begin(); it != playerList.end(); ++it)
+ for (const auto & elem : playerList)
{
- this->lines_[index]->setPlayerName(multi_cast<std::string>(it->first->getName()));
- this->lines_[index]->setScore(multi_cast<std::string>(it->second.frags_));
- this->lines_[index]->setDeaths(multi_cast<std::string>(it->second.killed_));
+ this->lines_[index]->setPlayerName(multi_cast<std::string>(elem.first->getName()));
+ this->lines_[index]->setScore(multi_cast<std::string>(elem.second.frags_));
+ this->lines_[index]->setDeaths(multi_cast<std::string>(elem.second.killed_));
index++;
}
Modified: code/branches/cpp11_v2/src/modules/pickup/PickupCollection.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/PickupCollection.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/pickup/PickupCollection.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -67,10 +67,10 @@
PickupCollection::~PickupCollection()
{
// Destroy all Pickupables constructing this PickupCollection.
- for(std::list<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it)
+ for(auto & elem : this->pickups_)
{
- (*it)->wasRemovedFromCollection();
- (*it)->destroy();
+ (elem)->wasRemovedFromCollection();
+ (elem)->destroy();
}
this->pickups_.clear();
}
@@ -98,8 +98,8 @@
this->processingUsed_ = true;
// Change used for all Pickupables this PickupCollection consists of.
- for(std::list<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it)
- (*it)->setUsed(this->isUsed());
+ for(auto & elem : this->pickups_)
+ (elem)->setUsed(this->isUsed());
this->processingUsed_ = false;
@@ -118,11 +118,11 @@
size_t numPickupsEnabled = 0;
size_t numPickupsInUse = 0;
- for(std::list<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it)
+ for(auto & elem : this->pickups_)
{
- if ((*it)->isEnabled())
+ if ((elem)->isEnabled())
++numPickupsEnabled;
- if ((*it)->isUsed())
+ if ((elem)->isUsed())
++numPickupsInUse;
}
@@ -145,12 +145,12 @@
SUPER(PickupCollection, changedCarrier);
// Change the PickupCarrier for all Pickupables this PickupCollection consists of.
- for(std::list<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it)
+ for(auto & elem : this->pickups_)
{
if(this->getCarrier() == nullptr)
- (*it)->setCarrier(nullptr);
+ (elem)->setCarrier(nullptr);
else
- (*it)->setCarrier(this->getCarrier()->getTarget(*it));
+ (elem)->setCarrier(this->getCarrier()->getTarget(elem));
}
}
@@ -185,9 +185,9 @@
// If at least all the enabled pickups of this PickupCollection are no longer picked up.
bool isOnePickupEnabledAndPickedUp = false;
- for(std::list<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it)
+ for(auto & elem : this->pickups_)
{
- if ((*it)->isEnabled() && (*it)->isPickedUp())
+ if ((elem)->isEnabled() && (elem)->isPickedUp())
{
isOnePickupEnabledAndPickedUp = true;
break;
@@ -207,9 +207,9 @@
*/
bool PickupCollection::isTarget(const PickupCarrier* carrier) const
{
- for(std::list<CollectiblePickup*>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it)
+ for(const auto & elem : this->pickups_)
{
- if(!carrier->isTarget(*it))
+ if(!carrier->isTarget(elem))
return false;
}
Modified: code/branches/cpp11_v2/src/modules/pickup/PickupManager.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/PickupManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/pickup/PickupManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -90,8 +90,8 @@
this->representations_.clear();
// Destroying all the PickupInventoryContainers that are still there.
- for(std::map<uint32_t, PickupInventoryContainer*>::iterator it = this->pickupInventoryContainers_.begin(); it != this->pickupInventoryContainers_.end(); it++)
- delete it->second;
+ for(auto & elem : this->pickupInventoryContainers_)
+ delete elem.second;
this->pickupInventoryContainers_.clear();
// Destroying all the WeakPointers that are still there.
Modified: code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -117,9 +117,9 @@
}
std::set<Pickupable*> pickups = carrier->getPickups();
// Iterate over all Pickupables of the PickupCarrier.
- for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++)
+ for(auto pickup : pickups)
{
- Pickupable* pickup = (*it);
+
if(pickup == nullptr || pickup == this)
continue;
Modified: code/branches/cpp11_v2/src/modules/pong/Pong.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pong/Pong.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/pong/Pong.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -144,12 +144,12 @@
this->ball_->setBatLength(this->center_->getBatLength());
// If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint.
- for (size_t i = 0; i < 2; ++i)
+ for (auto & elem : this->bat_)
{
- if (this->bat_[i] == nullptr)
+ if (elem == nullptr)
{
- this->bat_[i] = new PongBat(this->center_->getContext());
- this->bat_[i]->addTemplate(this->center_->getBattemplate());
+ elem = new PongBat(this->center_->getContext());
+ elem->addTemplate(this->center_->getBattemplate());
}
}
@@ -210,13 +210,13 @@
void Pong::spawnPlayersIfRequested()
{
// first spawn human players to assign always the left bat to the player in singleplayer
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
- this->spawnPlayer(it->first);
+ for (auto & elem : this->players_)
+ if (elem.first->isHumanPlayer() && (elem.first->isReadyToSpawn() || this->bForceSpawn_))
+ this->spawnPlayer(elem.first);
// now spawn bots
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
- this->spawnPlayer(it->first);
+ for (auto & elem : this->players_)
+ if (!elem.first->isHumanPlayer() && (elem.first->isReadyToSpawn() || this->bForceSpawn_))
+ this->spawnPlayer(elem.first);
}
/**
Modified: code/branches/cpp11_v2/src/modules/pong/PongAI.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pong/PongAI.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/pong/PongAI.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -76,8 +76,8 @@
*/
PongAI::~PongAI()
{
- for (std::list<std::pair<Timer*, char>>::iterator it = this->reactionTimers_.begin(); it != this->reactionTimers_.end(); ++it)
- it->first->destroy();
+ for (auto & elem : this->reactionTimers_)
+ elem.first->destroy();
}
/**
Modified: code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -93,8 +93,8 @@
Quest::fail(player);
// Iterate through all players possessing this Quest.
- for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
- QuestEffect::invokeEffects(*it, this->getFailEffectList());
+ for(const auto & elem : players_)
+ QuestEffect::invokeEffects(elem, this->getFailEffectList());
return true;
}
@@ -118,8 +118,8 @@
}
// Iterate through all players possessing the Quest.
- for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
- QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
+ for(const auto & elem : players_)
+ QuestEffect::invokeEffects(elem, this->getCompleteEffectList());
Quest::complete(player);
@@ -241,10 +241,10 @@
const QuestEffect* GlobalQuest::getRewardEffects(unsigned int index) const
{
int i = index;
- for (std::list<QuestEffect*>::const_iterator effect = this->rewards_.begin(); effect != this->rewards_.end(); ++effect)
+ for (const auto & elem : this->rewards_)
{
if(i == 0)
- return *effect;
+ return elem;
i--;
}
Modified: code/branches/cpp11_v2/src/modules/questsystem/Quest.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/Quest.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/questsystem/Quest.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -189,10 +189,10 @@
int i = index;
// Iterate through all subquests.
- for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest)
+ for (const auto & elem : this->subQuests_)
{
if(i == 0) // We're counting down...
- return *subQuest;
+ return elem;
i--;
}
@@ -213,10 +213,10 @@
int i = index;
// Iterate through all QuestHints.
- for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint)
+ for (const auto & elem : this->hints_)
{
if(i == 0) // We're counting down...
- return *hint;
+ return elem;
i--;
}
@@ -236,10 +236,10 @@
int i = index;
// Iterate through all fail QuestEffects.
- for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect)
+ for (const auto & elem : this->failEffects_)
{
if(i == 0) // We're counting down...
- return *effect;
+ return elem;
i--;
}
@@ -259,10 +259,10 @@
int i = index;
// Iterate through all complete QuestEffects.
- for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect)
+ for (const auto & elem : this->completeEffects_)
{
if(i == 0) // We're counting down...
- return *effect;
+ return elem;
i--;
}
Modified: code/branches/cpp11_v2/src/modules/questsystem/QuestEffect.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/QuestEffect.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/questsystem/QuestEffect.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -73,8 +73,8 @@
orxout(verbose, context::quests) << "Invoking QuestEffects on player: " << player << " ." << endl;
- for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
- temp = temp && (*effect)->invoke(player);
+ for (auto & effects_effect : effects)
+ temp = temp && (effects_effect)->invoke(player);
return temp;
}
Modified: code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -235,10 +235,10 @@
const QuestEffect* QuestEffectBeacon::getEffect(unsigned int index) const
{
int i = index;
- for (std::list<QuestEffect*>::const_iterator effect = this->effects_.begin(); effect != this->effects_.end(); ++effect)
+ for (const auto & elem : this->effects_)
{
if(i == 0)
- return *effect;
+ return elem;
i--;
}
Modified: code/branches/cpp11_v2/src/modules/questsystem/QuestListener.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/QuestListener.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/questsystem/QuestListener.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -96,9 +96,9 @@
*/
/* static */ void QuestListener::advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status)
{
- for (std::list<QuestListener*>::iterator it = listeners.begin(); it != listeners.end(); ++it) // Iterate through all QuestListeners
+ for (auto listener : listeners) // Iterate through all QuestListeners
{
- QuestListener* listener = *it;
+
if(listener->getMode() == status || listener->getMode() == QuestListener::ALL) // Check whether the status change affects the give QuestListener.
listener->execute();
}
Modified: code/branches/cpp11_v2/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/QuestManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/questsystem/QuestManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -234,9 +234,9 @@
int QuestManager::getNumRootQuests(PlayerInfo* player)
{
int numQuests = 0;
- for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++)
+ for(auto & elem : this->questMap_)
{
- if(it->second->getParentQuest() == nullptr && !it->second->isInactive(player))
+ if(elem.second->getParentQuest() == nullptr && !elem.second->isInactive(player))
numQuests++;
}
return numQuests;
@@ -254,10 +254,10 @@
*/
Quest* QuestManager::getRootQuest(PlayerInfo* player, int index)
{
- for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++)
+ for(auto & elem : this->questMap_)
{
- if(it->second->getParentQuest() == nullptr && !it->second->isInactive(player) && index-- == 0)
- return it->second;
+ if(elem.second->getParentQuest() == nullptr && !elem.second->isInactive(player) && index-- == 0)
+ return elem.second;
}
return nullptr;
}
@@ -279,9 +279,9 @@
std::list<Quest*> quests = quest->getSubQuestList();
int numQuests = 0;
- for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
+ for(auto & quest : quests)
{
- if(!(*it)->isInactive(player))
+ if(!(quest)->isInactive(player))
numQuests++;
}
return numQuests;
@@ -303,10 +303,10 @@
return this->getRootQuest(player, index);
std::list<Quest*> quests = quest->getSubQuestList();
- for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
+ for(auto & quest : quests)
{
- if(!(*it)->isInactive(player) && index-- == 0)
- return *it;
+ if(!(quest)->isInactive(player) && index-- == 0)
+ return quest;
}
return nullptr;
}
@@ -325,9 +325,9 @@
{
std::list<QuestHint*> hints = quest->getHintsList();
int numHints = 0;
- for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
+ for(auto & hint : hints)
{
- if((*it)->isActive(player))
+ if((hint)->isActive(player))
numHints++;
}
return numHints;
@@ -348,10 +348,10 @@
QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index)
{
std::list<QuestHint*> hints = quest->getHintsList();
- for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
+ for(auto & hint : hints)
{
- if((*it)->isActive(player) && index-- == 0)
- return *it;
+ if((hint)->isActive(player) && index-- == 0)
+ return hint;
}
return nullptr;
}
Modified: code/branches/cpp11_v2/src/modules/questsystem/effects/AddReward.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/effects/AddReward.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/questsystem/effects/AddReward.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -83,10 +83,10 @@
const Rewardable* AddReward::getRewardables(unsigned int index) const
{
int i = index;
- for (std::list<Rewardable*>::const_iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward)
+ for (const auto & elem : this->rewards_)
{
if(i == 0)
- return *reward;
+ return elem;
i--;
}
return nullptr;
@@ -105,8 +105,8 @@
orxout(verbose_more, context::quests) << "AddReward on player: " << player << " ." << endl;
bool temp = true;
- for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
- temp = temp && (*reward)->reward(player);
+ for (auto & elem : this->rewards_)
+ temp = temp && (elem)->reward(player);
orxout(verbose, context::quests) << "Rewardable successfully added to player." << player << " ." << endl;
Modified: code/branches/cpp11_v2/src/modules/tetris/Tetris.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/tetris/Tetris.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/tetris/Tetris.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -103,8 +103,8 @@
this->futureBrick_ = nullptr;
}
- for (std::list<StrongPtr<TetrisStone>>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
- (*it)->destroy();
+ for (auto & elem : this->stones_)
+ (elem)->destroy();
this->stones_.clear();
}
@@ -340,9 +340,9 @@
void Tetris::spawnPlayersIfRequested()
{
// Spawn a human player.
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
- this->spawnPlayer(it->first);
+ for (auto & elem : this->players_)
+ if (elem.first->isHumanPlayer() && (elem.first->isReadyToSpawn() || this->bForceSpawn_))
+ this->spawnPlayer(elem.first);
}
bool Tetris::playerLeft(PlayerInfo* player)
@@ -501,10 +501,10 @@
++it;
}
// adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
- for(std::list<StrongPtr<TetrisStone>>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+ for(auto & elem : this->stones_)
{
- if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
- (*it)->setPosition((*it)->getPosition()-Vector3(0,10,0));
+ if(static_cast<unsigned int>(((elem)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
+ (elem)->setPosition((elem)->getPosition()-Vector3(0,10,0));
}
}
Modified: code/branches/cpp11_v2/src/modules/tetris/TetrisBrick.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/tetris/TetrisBrick.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/tetris/TetrisBrick.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -238,11 +238,11 @@
void TetrisBrick::releaseStones(TetrisCenterpoint* center)
{
assert(this->tetris_);
- for(unsigned int i = 0; i < this->brickStones_.size(); i++)
+ for(auto & elem : this->brickStones_)
{
- this->brickStones_[i]->detachFromParent();
- this->brickStones_[i]->attachToParent(center);
- this->brickStones_[i]->setPosition(this->getPosition()+this->tetris_->rotateVector(this->brickStones_[i]->getPosition(),this->rotationCount_ ));
+ elem->detachFromParent();
+ elem->attachToParent(center);
+ elem->setPosition(this->getPosition()+this->tetris_->rotateVector(elem->getPosition(),this->rotationCount_ ));
}
this->brickStones_.clear();
}
Modified: code/branches/cpp11_v2/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/towerdefense/TowerDefense.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/modules/towerdefense/TowerDefense.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -182,10 +182,10 @@
en1->setDirection(Vector3(0,1,0));
en1->lookAt(waypoints_.at(1)->getPosition() + offset_);
- for (unsigned int i = 0; i < waypoints_.size(); ++ i)
+ for (auto & elem : waypoints_)
{
orxonox::WeakPtr<MovableEntity> waypoint = new MovableEntity(this->center_->getContext());
- waypoint->setPosition(waypoints_.at(i)->getPosition() + offset_);
+ waypoint->setPosition(elem->getPosition() + offset_);
controller->addWaypoint(waypoint);
}
}
Modified: code/branches/cpp11_v2/src/orxonox/Level.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/Level.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/Level.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -105,10 +105,10 @@
void Level::networkCallbackTemplatesChanged()
{
- for( std::set<std::string>::iterator it = this->networkTemplateNames_.begin(); it!=this->networkTemplateNames_.end(); ++it )
+ for(const auto & elem : this->networkTemplateNames_)
{
- assert(Template::getTemplate(*it));
- Template::getTemplate(*it)->applyOn(this);
+ assert(Template::getTemplate(elem));
+ Template::getTemplate(elem)->applyOn(this);
}
}
@@ -134,8 +134,8 @@
// means that e.g. ~Identifiable was not yet called for this object). This means that technically there are still other
// objects alive when ~Level is called. This is the reason why we cannot directly destroy() the Plugins - instead we need
// to call destroyLater() to ensure that no instances from this plugin exist anymore.
- for (std::list<PluginReference*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)
- (*it)->destroyLater();
+ for (auto & elem : this->plugins_)
+ (elem)->destroyLater();
this->plugins_.clear();
}
@@ -172,10 +172,10 @@
BaseObject* Level::getObject(unsigned int index) const
{
unsigned int i = 0;
- for (std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+ for (const auto & elem : this->objects_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
return nullptr;
Modified: code/branches/cpp11_v2/src/orxonox/LevelInfo.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/LevelInfo.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/LevelInfo.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -106,8 +106,8 @@
{
SubString substr = SubString(tags, ",", " "); // Split the string into tags.
const std::vector<std::string>& strings = substr.getAllStrings();
- for (std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
- this->addTag(*it, false);
+ for (const auto & strings_it : strings)
+ this->addTag(strings_it, false);
this->tagsUpdated();
}
@@ -121,8 +121,8 @@
{
SubString substr = SubString(ships, ",", " "); // Split the string into tags.
const std::vector<std::string>& strings = substr.getAllStrings();
- for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
- this->addStartingShip(*it, false);
+ for(const auto & strings_it : strings)
+ this->addStartingShip(strings_it, false);
this->startingshipsUpdated();
}
Modified: code/branches/cpp11_v2/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/LevelManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/LevelManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -174,8 +174,8 @@
// Activate the level that is the first in the list of levels whose activity has been requested.
this->levels_.front()->setActive(true);
// Make every player enter the newly activated level.
- for (std::map<unsigned int, PlayerInfo*>::const_iterator it = PlayerManager::getInstance().getClients().begin(); it != PlayerManager::getInstance().getClients().end(); ++it)
- this->levels_.front()->playerEntered(it->second);
+ for (const auto & elem : PlayerManager::getInstance().getClients())
+ this->levels_.front()->playerEntered(elem.second);
}
}
Modified: code/branches/cpp11_v2/src/orxonox/Scene.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/Scene.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/Scene.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -219,11 +219,10 @@
else if (!wantPhysics && hasPhysics())
{
// Remove all WorldEntities and shove them to the queue since they would still like to be in a physical world.
- for (std::set<WorldEntity*>::const_iterator it = this->physicalObjects_.begin();
- it != this->physicalObjects_.end(); ++it)
+ for (const auto & elem : this->physicalObjects_)
{
- this->physicalWorld_->removeRigidBody((*it)->physicalBody_);
- this->physicalObjectQueue_.insert(*it);
+ this->physicalWorld_->removeRigidBody((elem)->physicalBody_);
+ this->physicalObjectQueue_.insert(elem);
}
this->physicalObjects_.clear();
@@ -255,11 +254,10 @@
if (this->physicalObjectQueue_.size() > 0)
{
// Add all scheduled WorldEntities
- for (std::set<WorldEntity*>::const_iterator it = this->physicalObjectQueue_.begin();
- it != this->physicalObjectQueue_.end(); ++it)
+ for (const auto & elem : this->physicalObjectQueue_)
{
- this->physicalWorld_->addRigidBody((*it)->physicalBody_);
- this->physicalObjects_.insert(*it);
+ this->physicalWorld_->addRigidBody((elem)->physicalBody_);
+ this->physicalObjects_.insert(elem);
}
this->physicalObjectQueue_.clear();
}
@@ -320,10 +318,10 @@
BaseObject* Scene::getObject(unsigned int index) const
{
unsigned int i = 0;
- for (std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+ for (const auto & elem : this->objects_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
return nullptr;
Modified: code/branches/cpp11_v2/src/orxonox/collisionshapes/CompoundCollisionShape.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/collisionshapes/CompoundCollisionShape.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/collisionshapes/CompoundCollisionShape.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -64,13 +64,12 @@
if (this->isInitialized())
{
// Delete all children
- for (std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin();
- it != this->attachedShapes_.end(); ++it)
+ for (auto & elem : this->attachedShapes_)
{
// make sure that the child doesn't want to detach itself --> speedup because of the missing update
- it->first->notifyDetached();
- it->first->destroy();
- if (this->collisionShape_ == it->second)
+ elem.first->notifyDetached();
+ elem.first->destroy();
+ if (this->collisionShape_ == elem.second)
this->collisionShape_ = nullptr; // don't destroy it twice
}
@@ -246,10 +245,10 @@
CollisionShape* CompoundCollisionShape::getAttachedShape(unsigned int index) const
{
unsigned int i = 0;
- for (std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)
+ for (const auto & elem : this->attachedShapes_)
{
if (i == index)
- return it->first;
+ return elem.first;
++i;
}
return nullptr;
@@ -266,17 +265,17 @@
std::vector<CollisionShape*> shapes;
// Iterate through all attached CollisionShapes and add them to the list of shapes.
- for(std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)
- shapes.push_back(it->first);
+ for(auto & elem : this->attachedShapes_)
+ shapes.push_back(elem.first);
// Delete the compound shape and create a new one.
delete this->compoundShape_;
this->compoundShape_ = new btCompoundShape();
// Re-attach all CollisionShapes.
- for(std::vector<CollisionShape*>::iterator it = shapes.begin(); it != shapes.end(); it++)
+ for(auto shape : shapes)
{
- CollisionShape* shape = *it;
+
shape->setScale3D(this->getScale3D());
// Only actually attach if we didn't pick a CompoundCollisionShape with no content.
if (shape->getCollisionShape())
Modified: code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -439,10 +439,10 @@
{
if(newMaster->slaves_.size() > this->maxFormationSize_) continue;
- for(std::vector<FormationController*>::iterator itSlave = this->slaves_.begin(); itSlave != this->slaves_.end(); itSlave++)
+ for(auto & elem : this->slaves_)
{
- (*itSlave)->myMaster_ = newMaster;
- newMaster->slaves_.push_back(*itSlave);
+ (elem)->myMaster_ = newMaster;
+ newMaster->slaves_.push_back(elem);
}
this->slaves_.clear();
this->state_ = SLAVE;
@@ -485,7 +485,7 @@
bool left=true;
int i = 1;
- for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+ for(auto & elem : slaves_)
{
pos = Vector3::ZERO;
if (left)
@@ -496,8 +496,8 @@
i++;
dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK);
}
- (*it)->setTargetOrientation(orient);
- (*it)->setTargetPosition(pos);
+ (elem)->setTargetOrientation(orient);
+ (elem)->setTargetPosition(pos);
left=!left;
}
}
@@ -568,10 +568,10 @@
{
if(this->state_ != MASTER) return;
- for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+ for(auto & elem : slaves_)
{
- (*it)->state_ = FREE;
- (*it)->myMaster_ = nullptr;
+ (elem)->state_ = FREE;
+ (elem)->myMaster_ = nullptr;
}
this->slaves_.clear();
}
@@ -583,12 +583,12 @@
{
if(this->state_ != MASTER) return;
- for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+ for(auto & elem : slaves_)
{
- (*it)->state_ = FREE;
- (*it)->forceFreedom();
- (*it)->targetPosition_ = this->targetPosition_;
- (*it)->bShooting_ = true;
+ (elem)->state_ = FREE;
+ (elem)->forceFreedom();
+ (elem)->targetPosition_ = this->targetPosition_;
+ (elem)->bShooting_ = true;
// (*it)->getControllableEntity()->fire(0);// fire once for fun
}
}
@@ -649,9 +649,9 @@
//add previous master
this->slaves_.push_back(this->myMaster_);
//set this as new master
- for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+ for(auto & elem : slaves_)
{
- (*it)->myMaster_=this;
+ (elem)->myMaster_=this;
}
this->myMaster_=nullptr;
this->state_=MASTER;
@@ -693,11 +693,11 @@
this->formationMode_ = val;
if (this->state_ == MASTER)
{
- for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+ for(auto & elem : slaves_)
{
- (*it)->formationMode_ = val;
+ (elem)->formationMode_ = val;
if (val == ATTACK)
- (*it)->forgetTarget();
+ (elem)->forgetTarget();
}
}
}
Modified: code/branches/cpp11_v2/src/orxonox/controllers/WaypointController.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/controllers/WaypointController.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/controllers/WaypointController.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -43,10 +43,10 @@
WaypointController::~WaypointController()
{
- for (size_t i = 0; i < this->waypoints_.size(); ++i)
+ for (auto & elem : this->waypoints_)
{
- if(this->waypoints_[i])
- this->waypoints_[i]->destroy();
+ if(elem)
+ elem->destroy();
}
}
Modified: code/branches/cpp11_v2/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gamestates/GSLevel.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gamestates/GSLevel.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -250,8 +250,8 @@
it->importMementoState(states);
// delete states
- for (size_t i = 0; i < states.size(); ++i)
- delete states[i];
+ for (auto & state : states)
+ delete state;
}
/**
Modified: code/branches/cpp11_v2/src/orxonox/gametypes/Dynamicmatch.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gametypes/Dynamicmatch.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gametypes/Dynamicmatch.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -404,11 +404,11 @@
*/
void Dynamicmatch::rewardPig()
{
- for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden
+ for (auto & elem : this->playerParty_) //durch alle Spieler iterieren und alle piggys finden
{
- if (it->second==piggy)//Spieler mit der Pig-party frags++
+ if (elem.second==piggy)//Spieler mit der Pig-party frags++
{
- this->playerScored(it->first);
+ this->playerScored(elem.first);
}
}
}
@@ -421,11 +421,11 @@
pawn->setRadarObjectColour(this->partyColours_[it_player->second]);
std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
- for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
+ for (const auto & pawnAttachment : pawnAttachments)
{
- if ((*it)->isA(Class(TeamColourable)))
+ if ((pawnAttachment)->isA(Class(TeamColourable)))
{
- TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
+ TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment);
tc->setTeamColour(this->partyColours_[it_player->second]);
}
}
@@ -440,13 +440,13 @@
notEnoughPigs=true;
if (tutorial) // Announce selectionphase
{
- for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
+ for (auto & elem : this->playerParty_)
{
- if (!it->first)//in order to catch nullpointer
+ if (!elem.first)//in order to catch nullpointer
continue;
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
+ this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
}
}
}
@@ -455,28 +455,28 @@
notEnoughPigs=false;
if(tutorial&&(!notEnoughKillers)&&(!notEnoughChasers)) //Selection phase over
{
- for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
+ for (auto & elem : this->playerParty_)
{
- if (!it->first)//in order to catch nullpointer
+ if (!elem.first)//in order to catch nullpointer
continue;
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- else if (it->second==chaser)
+ else if (elem.second==chaser)
{
if (numberOf[killer]>0)
- this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID(),partyColours_[piggy]);
+ this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]);
else
- this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID(),partyColours_[piggy]);
+ this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]);
//this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
}
- else if (it->second==piggy)
+ else if (elem.second==piggy)
{
- this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID(),partyColours_[chaser]);
+ this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[chaser]);
//this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
}
- else if (it->second==killer)
+ else if (elem.second==killer)
{
- this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID(),partyColours_[chaser]);
+ this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[chaser]);
//this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
}
}
@@ -489,13 +489,13 @@
notEnoughKillers=true;
if (tutorial) // Announce selectionphase
{
- for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
+ for (auto & elem : this->playerParty_)
{
- if (!it->first)//in order to catch nullpointer
+ if (!elem.first)//in order to catch nullpointer
continue;
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
+ this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
}
}
}
@@ -504,28 +504,28 @@
notEnoughKillers=false;
if(tutorial&&(!notEnoughPigs)&&(!notEnoughChasers)) //Selection phase over
{
- for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
+ for (auto & elem : this->playerParty_)
{
- if (!it->first)
+ if (!elem.first)
continue;
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- else if (it->second==chaser)
+ else if (elem.second==chaser)
{
if (numberOf[killer]>0)
- this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID(),partyColours_[piggy]);
+ this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]);
else
- this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID(),partyColours_[piggy]);
+ this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]);
//this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
}
- else if (it->second==piggy)
+ else if (elem.second==piggy)
{
- this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID(),partyColours_[piggy]);
+ this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[piggy]);
//this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
}
- else if (it->second==killer)
+ else if (elem.second==killer)
{
- this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID(),partyColours_[piggy]);
+ this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[piggy]);
//this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
}
}
@@ -539,13 +539,13 @@
notEnoughChasers=true;
if (tutorial) // Announce selectionphase
{
- for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
+ for (auto & elem : this->playerParty_)
{
- if (!it->first)//in order to catch nullpointer
+ if (!elem.first)//in order to catch nullpointer
continue;
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
+ this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
}
}
}
@@ -554,28 +554,28 @@
notEnoughChasers=false;
if(tutorial&&(!notEnoughPigs)&&(!notEnoughKillers)) //Selection phase over
{
- for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
+ for (auto & elem : this->playerParty_)
{
- if (!it->first)
+ if (!elem.first)
continue;
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- else if (it->second==chaser)
+ else if (elem.second==chaser)
{
if (numberOf[killer]>0)
- this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID(),partyColours_[piggy]);
+ this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]);
else
- this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID(),partyColours_[piggy]);
+ this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]);
//this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
}
- else if (it->second==piggy)
+ else if (elem.second==piggy)
{
- this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID(),partyColours_[chaser]);
+ this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[chaser]);
//this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
}
- else if (it->second==killer)
+ else if (elem.second==killer)
{
- this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID(),partyColours_[chaser]);
+ this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[chaser]);
//this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
}
}
@@ -619,11 +619,11 @@
}
else if(tutorial) // Announce selectionphase
{
- for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
+ for (auto & elem : this->playerParty_)
{
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
+ this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
}
}
}
@@ -675,10 +675,10 @@
{
unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
unsigned int index = 0;
- for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
+ for (const auto & teamSpawnPoint : teamSpawnPoints)
{
if (index == randomspawn)
- return (*it);
+ return (teamSpawnPoint);
++index;
}
Modified: code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -138,11 +138,11 @@
if (!this->gtinfo_->hasStarted())
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
// Inform the GametypeInfo that the player is ready to spawn.
- if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
- this->gtinfo_->playerReadyToSpawn(it->first);
+ if(elem.first->isHumanPlayer() && elem.first->isReadyToSpawn())
+ this->gtinfo_->playerReadyToSpawn(elem.first);
}
this->checkStart();
@@ -168,11 +168,11 @@
this->showMenuTimer_.setTimer(3.0f, true, createExecutor(createFunctor(&Gametype::showMenu, this)));
}
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
- if (it->first->getControllableEntity())
+ if (elem.first->getControllableEntity())
{
- ControllableEntity* oldentity = it->first->getControllableEntity();
+ ControllableEntity* oldentity = elem.first->getControllableEntity();
ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getContext());
if (oldentity->getCamera())
@@ -185,10 +185,10 @@
entity->setPosition(oldentity->getWorldPosition());
entity->setOrientation(oldentity->getWorldOrientation());
}
- it->first->startControl(entity);
+ elem.first->startControl(entity);
}
else
- this->spawnPlayerAsDefaultPawn(it->first);
+ this->spawnPlayerAsDefaultPawn(elem.first);
}
}
@@ -340,13 +340,13 @@
unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
unsigned int index = 0;
std::vector<SpawnPoint*> activeSpawnPoints;
- for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)
+ for (const auto & elem : this->spawnpoints_)
{
if (index == randomspawn)
- fallbackSpawnPoint = (*it);
+ fallbackSpawnPoint = (elem);
- if (*it != nullptr && (*it)->isActive())
- activeSpawnPoints.push_back(*it);
+ if (elem != nullptr && (elem)->isActive())
+ activeSpawnPoints.push_back(elem);
++index;
}
@@ -365,16 +365,16 @@
void Gametype::assignDefaultPawnsIfNeeded()
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
- if (!it->first->getControllableEntity())
+ if (!elem.first->getControllableEntity())
{
- it->second.state_ = PlayerState::Dead;
+ elem.second.state_ = PlayerState::Dead;
- if (!it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted())
+ if (!elem.first->isReadyToSpawn() || !this->gtinfo_->hasStarted())
{
- this->spawnPlayerAsDefaultPawn(it->first);
- it->second.state_ = PlayerState::Dead;
+ this->spawnPlayerAsDefaultPawn(elem.first);
+ elem.second.state_ = PlayerState::Dead;
}
}
}
@@ -403,11 +403,11 @@
{
bool allplayersready = true;
bool hashumanplayers = false;
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
- if (!it->first->isReadyToSpawn())
+ if (!elem.first->isReadyToSpawn())
allplayersready = false;
- if (it->first->isHumanPlayer())
+ if (elem.first->isHumanPlayer())
hashumanplayers = true;
}
@@ -429,19 +429,19 @@
void Gametype::spawnPlayersIfRequested()
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
- if (it->first->isReadyToSpawn() || this->bForceSpawn_)
- this->spawnPlayer(it->first);
+ if (elem.first->isReadyToSpawn() || this->bForceSpawn_)
+ this->spawnPlayer(elem.first);
}
}
void Gametype::spawnDeadPlayersIfRequested()
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- if (it->second.state_ == PlayerState::Dead)
- if (it->first->isReadyToSpawn() || this->bForceSpawn_)
- this->spawnPlayer(it->first);
+ for (auto & elem : this->players_)
+ if (elem.second.state_ == PlayerState::Dead)
+ if (elem.first->isReadyToSpawn() || this->bForceSpawn_)
+ this->spawnPlayer(elem.first);
}
void Gametype::spawnPlayer(PlayerInfo* player)
@@ -537,11 +537,11 @@
GSLevelMementoState* Gametype::exportMementoState()
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
- if (it->first->isHumanPlayer() && it->first->getControllableEntity() && it->first->getControllableEntity()->getCamera())
+ if (elem.first->isHumanPlayer() && elem.first->getControllableEntity() && elem.first->getControllableEntity()->getCamera())
{
- Camera* camera = it->first->getControllableEntity()->getCamera();
+ Camera* camera = elem.first->getControllableEntity()->getCamera();
GametypeMementoState* state = new GametypeMementoState();
state->cameraPosition_ = camera->getWorldPosition();
@@ -558,9 +558,9 @@
{
// find correct memento state
GametypeMementoState* state = nullptr;
- for (size_t i = 0; i < states.size(); ++i)
+ for (auto & states_i : states)
{
- state = dynamic_cast<GametypeMementoState*>(states[i]);
+ state = dynamic_cast<GametypeMementoState*>(states_i);
if (state)
break;
}
@@ -586,14 +586,14 @@
}
// find correct player and assign default entity with original position & orientation
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
- if (it->first->isHumanPlayer())
+ if (elem.first->isHumanPlayer())
{
ControllableEntity* entity = this->defaultControllableEntity_.fabricate(scene->getContext());
entity->setPosition(state->cameraPosition_);
entity->setOrientation(state->cameraOrientation_);
- it->first->startControl(entity);
+ elem.first->startControl(entity);
break;
}
}
Modified: code/branches/cpp11_v2/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gametypes/LastManStanding.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gametypes/LastManStanding.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -55,13 +55,13 @@
void LastManStanding::spawnDeadPlayersIfRequested()
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- if (it->second.state_ == PlayerState::Dead)
+ for (auto & elem : this->players_)
+ if (elem.second.state_ == PlayerState::Dead)
{
- bool alive = (0<playerLives_[it->first]&&(inGame_[it->first]));
- if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))
+ bool alive = (0<playerLives_[elem.first]&&(inGame_[elem.first]));
+ if (alive&&(elem.first->isReadyToSpawn() || this->bForceSpawn_))
{
- this->spawnPlayer(it->first);
+ this->spawnPlayer(elem.first);
}
}
}
@@ -113,12 +113,12 @@
int LastManStanding::getMinLives()
{
int min=lives;
- for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
+ for (auto & elem : this->playerLives_)
{
- if (it->second<=0)
+ if (elem.second<=0)
continue;
- if (it->second<lives)
- min=it->second;
+ if (elem.second<lives)
+ min=elem.second;
}
return min;
}
@@ -127,15 +127,15 @@
{
Gametype::end();
- for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
+ for (auto & elem : this->playerLives_)
{
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- if (it->second > 0)
- this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
+ if (elem.second > 0)
+ this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID());
else
- this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
+ this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID());
}
}
@@ -236,41 +236,41 @@
{
this->end();
}
- for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
+ for (auto & elem : this->timeToAct_)
{
- if (playerGetLives(it->first)<=0)//Players without lives shouldn't be affected by time.
+ if (playerGetLives(elem.first)<=0)//Players without lives shouldn't be affected by time.
continue;
- it->second-=dt;//Decreases punishment time.
- if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
+ elem.second-=dt;//Decreases punishment time.
+ if (!inGame_[elem.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
{
- playerDelayTime_[it->first]-=dt;
- if (playerDelayTime_[it->first]<=0)
- this->inGame_[it->first]=true;
+ playerDelayTime_[elem.first]-=dt;
+ if (playerDelayTime_[elem.first]<=0)
+ this->inGame_[elem.first]=true;
- if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
continue;
- int output=1+(int)playerDelayTime_[it->first];
+ int output=1+(int)playerDelayTime_[elem.first];
const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown
- this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
+ this->gtinfo_->sendFadingMessage(message,elem.first->getClientID());
}
- else if (it->second<0.0f)
+ else if (elem.second<0.0f)
{
- it->second=timeRemaining+3.0f;//reset punishment-timer
- if (playerGetLives(it->first)>0)
+ elem.second=timeRemaining+3.0f;//reset punishment-timer
+ if (playerGetLives(elem.first)>0)
{
- this->punishPlayer(it->first);
- if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
+ this->punishPlayer(elem.first);
+ if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
return;
const std::string& message = ""; // resets Camper-Warning-message
- this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
+ this->gtinfo_->sendFadingMessage(message,elem.first->getClientID());
}
}
- else if (it->second<timeRemaining/5)//Warning message
+ else if (elem.second<timeRemaining/5)//Warning message
{
- if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
continue;
const std::string& message = "Camper Warning! Don't forget to shoot.";
- this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
+ this->gtinfo_->sendFadingMessage(message,elem.first->getClientID());
}
}
}
Modified: code/branches/cpp11_v2/src/orxonox/gametypes/LastTeamStanding.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gametypes/LastTeamStanding.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gametypes/LastTeamStanding.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -144,13 +144,13 @@
void LastTeamStanding::spawnDeadPlayersIfRequested()
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- if (it->second.state_ == PlayerState::Dead)
+ for (auto & elem : this->players_)
+ if (elem.second.state_ == PlayerState::Dead)
{
- bool alive = (0 < playerLives_[it->first]&&(inGame_[it->first]));
- if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))
+ bool alive = (0 < playerLives_[elem.first]&&(inGame_[elem.first]));
+ if (alive&&(elem.first->isReadyToSpawn() || this->bForceSpawn_))
{
- this->spawnPlayer(it->first);
+ this->spawnPlayer(elem.first);
}
}
}
@@ -183,41 +183,41 @@
{
this->end();
}
- for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
+ for (auto & elem : this->timeToAct_)
{
- if (playerGetLives(it->first) <= 0)//Players without lives shouldn't be affected by time.
+ if (playerGetLives(elem.first) <= 0)//Players without lives shouldn't be affected by time.
continue;
- it->second -= dt;//Decreases punishment time.
- if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
+ elem.second -= dt;//Decreases punishment time.
+ if (!inGame_[elem.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
{
- playerDelayTime_[it->first] -= dt;
- if (playerDelayTime_[it->first] <= 0)
- this->inGame_[it->first] = true;
+ playerDelayTime_[elem.first] -= dt;
+ if (playerDelayTime_[elem.first] <= 0)
+ this->inGame_[elem.first] = true;
- if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
continue;
- int output = 1 + (int)playerDelayTime_[it->first];
+ int output = 1 + (int)playerDelayTime_[elem.first];
const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown
- this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
+ this->gtinfo_->sendFadingMessage(message,elem.first->getClientID());
}
- else if (it->second < 0.0f)
+ else if (elem.second < 0.0f)
{
- it->second = timeRemaining + 3.0f;//reset punishment-timer
- if (playerGetLives(it->first) > 0)
+ elem.second = timeRemaining + 3.0f;//reset punishment-timer
+ if (playerGetLives(elem.first) > 0)
{
- this->punishPlayer(it->first);
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ this->punishPlayer(elem.first);
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
return;
const std::string& message = ""; // resets Camper-Warning-message
- this->gtinfo_->sendFadingMessage(message, it->first->getClientID());
+ this->gtinfo_->sendFadingMessage(message, elem.first->getClientID());
}
}
- else if (it->second < timeRemaining/5)//Warning message
+ else if (elem.second < timeRemaining/5)//Warning message
{
- if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
continue;
const std::string& message = "Camper Warning! Don't forget to shoot.";
- this->gtinfo_->sendFadingMessage(message, it->first->getClientID());
+ this->gtinfo_->sendFadingMessage(message, elem.first->getClientID());
}
}
}
@@ -228,15 +228,15 @@
Gametype::end();
int party = -1;
//find a player who survived
- for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
+ for (auto & elem : this->playerLives_)
{
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- if (it->second > 0)//a player that is alive
+ if (elem.second > 0)//a player that is alive
{
//which party has survived?
- std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(it->first);
+ std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(elem.first);
if (it2 != this->teamnumbers_.end())
{
party = it2->second;
@@ -254,12 +254,12 @@
int LastTeamStanding::getMinLives()
{
int min = lives;
- for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
+ for (auto & elem : this->playerLives_)
{
- if (it->second <= 0)
+ if (elem.second <= 0)
continue;
- if (it->second < lives)
- min = it->second;
+ if (elem.second < lives)
+ min = elem.second;
}
return min;
}
Modified: code/branches/cpp11_v2/src/orxonox/gametypes/TeamBaseMatch.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gametypes/TeamBaseMatch.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gametypes/TeamBaseMatch.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -151,13 +151,13 @@
int amountControlled = 0;
int amountControlled2 = 0;
- for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
+ for (const auto & elem : this->bases_)
{
- if((*it)->getState() == BaseState::ControlTeam1)
+ if((elem)->getState() == BaseState::ControlTeam1)
{
amountControlled++;
}
- if((*it)->getState() == BaseState::ControlTeam2)
+ if((elem)->getState() == BaseState::ControlTeam2)
{
amountControlled2++;
}
@@ -186,15 +186,15 @@
winningteam = 1;
}
- for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ for (auto & elem : this->teamnumbers_)
{
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- if (it->second == winningteam)
- this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
+ if (elem.second == winningteam)
+ this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID());
else
- this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
+ this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID());
}
this->end();
@@ -237,11 +237,11 @@
{
int count = 0;
- for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
+ for (const auto & elem : this->bases_)
{
- if ((*it)->getState() == BaseState::ControlTeam1 && team == 0)
+ if ((elem)->getState() == BaseState::ControlTeam1 && team == 0)
count++;
- if ((*it)->getState() == BaseState::ControlTeam2 && team == 1)
+ if ((elem)->getState() == BaseState::ControlTeam2 && team == 1)
count++;
}
@@ -257,11 +257,11 @@
TeamBaseMatchBase* TeamBaseMatch::getBase(unsigned int index) const
{
unsigned int i = 0;
- for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
+ for (const auto & elem : this->bases_)
{
i++;
if (i > index)
- return (*it);
+ return (elem);
}
return nullptr;
}
Modified: code/branches/cpp11_v2/src/orxonox/gametypes/TeamDeathmatch.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gametypes/TeamDeathmatch.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gametypes/TeamDeathmatch.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -68,12 +68,12 @@
//find team that won the match
int winnerTeam = 0;
int highestScore = 0;
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
- if ( this->getTeamScore(it->first) > highestScore )
+ if ( this->getTeamScore(elem.first) > highestScore )
{
- winnerTeam = this->getTeam(it->first);
- highestScore = this->getTeamScore(it->first);
+ winnerTeam = this->getTeam(elem.first);
+ highestScore = this->getTeamScore(elem.first);
}
}
Modified: code/branches/cpp11_v2/src/orxonox/gametypes/TeamGametype.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gametypes/TeamGametype.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gametypes/TeamGametype.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -98,9 +98,9 @@
if(player == nullptr) return; // catch null pointers
std::vector<unsigned int> playersperteam(this->teams_, 0);
- for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
- if (it->second < static_cast<int>(this->teams_) && it->second >= 0)
- playersperteam[it->second]++;
+ for (auto & elem : this->teamnumbers_)
+ if (elem.second < static_cast<int>(this->teams_) && elem.second >= 0)
+ playersperteam[elem.second]++;
unsigned int minplayers = static_cast<unsigned int>(-1);
size_t minplayersteam = 0;
@@ -122,10 +122,10 @@
bool valid_player = Gametype::playerLeft(player);
if( (this->players_.size() >= maxPlayers_) && (allowedInGame_[player] == true) ) // if there's a "waiting list"
{
- for (std::map<PlayerInfo*, bool>::iterator it = this->allowedInGame_.begin(); it != this->allowedInGame_.end(); ++it)
+ for (auto & elem : this->allowedInGame_)
{
- if(it->second == false) // waiting player found
- {it->second = true; break;} // allow player to enter
+ if(elem.second == false) // waiting player found
+ {elem.second = true; break;} // allow player to enter
}
}
@@ -140,17 +140,17 @@
void TeamGametype::spawnDeadPlayersIfRequested()
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)\
+ for (auto & elem : this->players_)\
{
- if(allowedInGame_[it->first] == false)//check if dead player is allowed to enter
+ if(allowedInGame_[elem.first] == false)//check if dead player is allowed to enter
{
continue;
}
- if (it->second.state_ == PlayerState::Dead)
+ if (elem.second.state_ == PlayerState::Dead)
{
- if ((it->first->isReadyToSpawn() || this->bForceSpawn_))
+ if ((elem.first->isReadyToSpawn() || this->bForceSpawn_))
{
- this->spawnPlayer(it->first);
+ this->spawnPlayer(elem.first);
}
}
}
@@ -177,11 +177,11 @@
int teamscore = 0;
if(!player || this->getTeam(player) == -1)
return 0;
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ for (auto & elem : this->players_)
{
- if ( this->getTeam(it->first) == this->getTeam(player) )
+ if ( this->getTeam(elem.first) == this->getTeam(player) )
{
- teamscore += it->second.frags_;
+ teamscore += elem.second.frags_;
}
}
return teamscore;
@@ -190,9 +190,9 @@
int TeamGametype::getTeamSize(int team)
{
int teamSize = 0;
- for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ for (auto & elem : this->teamnumbers_)
{
- if (it->second == team)
+ if (elem.second == team)
teamSize++;
}
return teamSize;
@@ -201,9 +201,9 @@
int TeamGametype::getHumansInTeam(int team)
{
int teamSize = 0;
- for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ for (auto & elem : this->teamnumbers_)
{
- if (it->second == team && it->first->isHumanPlayer())
+ if (elem.second == team && elem.first->isHumanPlayer())
teamSize++;
}
return teamSize;
@@ -240,11 +240,11 @@
unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
unsigned int index = 0;
// Get random fallback spawnpoint in case there is no active SpawnPoint.
- for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
+ for (const auto & teamSpawnPoint : teamSpawnPoints)
{
if (index == randomspawn)
{
- fallbackSpawnPoint = (*it);
+ fallbackSpawnPoint = (teamSpawnPoint);
break;
}
@@ -265,10 +265,10 @@
randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
index = 0;
- for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
+ for (const auto & teamSpawnPoint : teamSpawnPoints)
{
if (index == randomspawn)
- return (*it);
+ return (teamSpawnPoint);
++index;
}
@@ -363,11 +363,11 @@
pawn->setRadarObjectColour(this->teamcolours_[teamNr]);
std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
- for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
+ for (const auto & pawnAttachment : pawnAttachments)
{
- if ((*it)->isA(Class(TeamColourable)))
+ if ((pawnAttachment)->isA(Class(TeamColourable)))
{
- TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
+ TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment);
tc->setTeamColour(this->teamcolours_[teamNr]);
}
}
@@ -375,17 +375,17 @@
void TeamGametype::announceTeamWin(int winnerTeam)
{
- for (std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3)
+ for (auto & elem : this->teamnumbers_)
{
- if (it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- if (it3->second == winnerTeam)
+ if (elem.second == winnerTeam)
{
- this->gtinfo_->sendAnnounceMessage("Your team has won the match!", it3->first->getClientID());
+ this->gtinfo_->sendAnnounceMessage("Your team has won the match!", elem.first->getClientID());
}
else
{
- this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", it3->first->getClientID());
+ this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", elem.first->getClientID());
}
}
}
Modified: code/branches/cpp11_v2/src/orxonox/gametypes/UnderAttack.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/gametypes/UnderAttack.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/gametypes/UnderAttack.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -73,15 +73,15 @@
ChatManager::message(message);
this->gameEnded_ = true;
- for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ for (auto & elem : this->teamnumbers_)
{
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- if (it->second == attacker_)
- this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
+ if (elem.second == attacker_)
+ this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID());
else
- this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
+ this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID());
}
}
@@ -154,15 +154,15 @@
std::string message("Time is up! Team 1 has won!");
ChatManager::message(message);
- for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ for (auto & elem : this->teamnumbers_)
{
- if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- if (it->second == 1)
- this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
+ if (elem.second == 1)
+ this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID());
else
- this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
+ this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID());
}
}
Modified: code/branches/cpp11_v2/src/orxonox/interfaces/PickupCarrier.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/interfaces/PickupCarrier.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/interfaces/PickupCarrier.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -134,11 +134,11 @@
PickupCarrier* target = nullptr;
// Go recursively through all children to check whether they are the target.
std::vector<PickupCarrier*>* children = this->getCarrierChildren();
- for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
+ for(auto & elem : *children)
{
- if(pickup->isTarget(*it))
+ if(pickup->isTarget(elem))
{
- target = *it;
+ target = elem;
break;
}
}
Modified: code/branches/cpp11_v2/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/interfaces/Pickupable.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/interfaces/Pickupable.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -159,9 +159,9 @@
bool Pickupable::isTarget(const Identifier* identifier) const
{
// Iterate through all targets of this Pickupable.
- for(std::list<Identifier*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
+ for(const auto & elem : this->targets_)
{
- if(identifier->isA(*it))
+ if(identifier->isA(elem))
return true;
}
Modified: code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -218,10 +218,11 @@
EffectContainer* MultiStateEngine::getEffectContainer(unsigned int index) const
{
unsigned int i = 0;
- for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
+ for (const auto & elem : this->effectContainers_)
{
if (i == index)
- return (*it);
+ return (elem);
+ i++;
}
return nullptr;
}
Modified: code/branches/cpp11_v2/src/orxonox/items/ShipPart.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/items/ShipPart.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/items/ShipPart.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -147,9 +147,9 @@
*/
bool ShipPart::hasEntity(StaticEntity* entity) const
{
- for(unsigned int i = 0; i < this->entityList_.size(); i++)
+ for(auto & elem : this->entityList_)
{
- if(this->entityList_[i] == entity)
+ if(elem == entity)
return true;
}
return false;
Modified: code/branches/cpp11_v2/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/overlays/OverlayGroup.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/overlays/OverlayGroup.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -61,8 +61,8 @@
OverlayGroup::~OverlayGroup()
{
- for (std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
- (*it)->destroy();
+ for (const auto & elem : hudElements_)
+ (elem)->destroy();
this->hudElements_.clear();
}
@@ -85,16 +85,16 @@
//! Scales every element in the set.
void OverlayGroup::setScale(const Vector2& scale)
{
- for (std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
- (*it)->scale(scale / this->scale_);
+ for (const auto & elem : hudElements_)
+ (elem)->scale(scale / this->scale_);
this->scale_ = scale;
}
//! Scrolls every element in the set.
void OverlayGroup::setScroll(const Vector2& scroll)
{
- for (std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
- (*it)->scroll(scroll - this->scroll_);
+ for (const auto & elem : hudElements_)
+ (elem)->scroll(scroll - this->scroll_);
this->scroll_ = scroll;
}
@@ -146,16 +146,16 @@
{
SUPER( OverlayGroup, changedVisibility );
- for (std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
- (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed
+ for (const auto & elem : hudElements_)
+ (elem)->changedVisibility(); //inform all Child Overlays that our visibility has changed
}
void OverlayGroup::setOwner(BaseObject* owner)
{
this->owner_ = owner;
- for (std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
- (*it)->setOwner(owner);
+ for (const auto & elem : hudElements_)
+ (elem)->setOwner(owner);
}
//########### Console commands ############
Modified: code/branches/cpp11_v2/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/sound/SoundManager.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/sound/SoundManager.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -406,12 +406,12 @@
{
if (ambient != nullptr)
{
- for (AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
+ for (auto & elem : this->ambientSounds_)
{
- if (it->first == ambient)
+ if (elem.first == ambient)
{
- it->second = true;
- this->fadeOut(it->first);
+ elem.second = true;
+ this->fadeOut(elem.first);
return;
}
}
Modified: code/branches/cpp11_v2/src/orxonox/sound/SoundStreamer.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/sound/SoundStreamer.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/sound/SoundStreamer.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -67,7 +67,7 @@
alGenBuffers(4, initbuffers);
int current_section;
- for(int i = 0; i < 4; i++)
+ for(auto & initbuffer : initbuffers)
{
long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section);
if (ret == 0)
@@ -81,7 +81,7 @@
return;
}
- alBufferData(initbuffers[i], format, &inbuffer, ret, vorbisInfo->rate);
+ alBufferData(initbuffer, format, &inbuffer, ret, vorbisInfo->rate);
}
alSourceQueueBuffers(audioSource, 4, initbuffers);
Modified: code/branches/cpp11_v2/src/orxonox/weaponsystem/Munition.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/weaponsystem/Munition.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/weaponsystem/Munition.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -54,8 +54,8 @@
Munition::~Munition()
{
- for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
- delete it->second;
+ for (auto & elem : this->currentMagazines_)
+ delete elem.second;
}
Munition::Magazine* Munition::getMagazine(WeaponMode* user) const
@@ -267,8 +267,8 @@
else
{
// Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition)
- for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
- if (it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
+ for (const auto & elem : this->currentMagazines_)
+ if (elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_)
return true;
}
@@ -315,12 +315,12 @@
while (amount > 0)
{
bool change = false;
- for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
+ for (auto & elem : this->currentMagazines_)
{
// Add munition if the magazine isn't full (but only to loaded magazines)
- if (amount > 0 && it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
+ if (amount > 0 && elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_)
{
- it->second->munition_++;
+ elem.second->munition_++;
amount--;
change = true;
}
Modified: code/branches/cpp11_v2/src/orxonox/weaponsystem/Weapon.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/weaponsystem/Weapon.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/weaponsystem/Weapon.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -60,8 +60,8 @@
if (this->weaponPack_)
this->weaponPack_->removeWeapon(this);
- for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
- it->second->destroy();
+ for (auto & elem : this->weaponmodes_)
+ elem.second->destroy();
}
}
@@ -84,10 +84,10 @@
WeaponMode* Weapon::getWeaponmode(unsigned int index) const
{
unsigned int i = 0;
- for (std::multimap<unsigned int, WeaponMode*>::const_iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
+ for (const auto & elem : this->weaponmodes_)
{
if (i == index)
- return it->second;
+ return elem.second;
++i;
}
@@ -135,8 +135,8 @@
void Weapon::reload()
{
- for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
- it->second->reload();
+ for (auto & elem : this->weaponmodes_)
+ elem.second->reload();
}
void Weapon::reloaded()
@@ -147,7 +147,7 @@
void Weapon::notifyWeaponModes()
{
- for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
- it->second->setWeapon(this);
+ for (auto & elem : this->weaponmodes_)
+ elem.second->setWeapon(this);
}
}
Modified: code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -75,8 +75,8 @@
*/
void WeaponPack::fire(unsigned int weaponmode)
{
- for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
- (*it)->fire(weaponmode);
+ for (auto & elem : this->weapons_)
+ (elem)->fire(weaponmode);
}
/**
@@ -85,8 +85,8 @@
*/
void WeaponPack::reload()
{
- for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
- (*it)->reload();
+ for (auto & elem : this->weapons_)
+ (elem)->reload();
}
void WeaponPack::addWeapon(Weapon * weapon)
@@ -113,10 +113,10 @@
{
unsigned int i = 0;
- for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
+ for (const auto & elem : this->weapons_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
@@ -131,10 +131,10 @@
DefaultWeaponmodeLink* WeaponPack::getDefaultWeaponmodeLink(unsigned int index) const
{
unsigned int i = 0;
- for (std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)
+ for (const auto & elem : this->links_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
@@ -143,9 +143,9 @@
unsigned int WeaponPack::getDesiredWeaponmode(unsigned int firemode) const
{
- for (std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)
- if ((*it)->getFiremode() == firemode)
- return (*it)->getWeaponmode();
+ for (const auto & elem : this->links_)
+ if ((elem)->getFiremode() == firemode)
+ return (elem)->getWeaponmode();
return WeaponSystem::WEAPON_MODE_UNASSIGNED;
}
Modified: code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSet.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSet.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSet.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -62,16 +62,16 @@
void WeaponSet::fire()
{
// Fire all WeaponPacks with their defined weaponmode
- for (std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)
- if (it->second != WeaponSystem::WEAPON_MODE_UNASSIGNED)
- it->first->fire(it->second);
+ for (auto & elem : this->weaponpacks_)
+ if (elem.second != WeaponSystem::WEAPON_MODE_UNASSIGNED)
+ elem.first->fire(elem.second);
}
void WeaponSet::reload()
{
// Reload all WeaponPacks with their defined weaponmode
- for (std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)
- it->first->reload();
+ for (auto & elem : this->weaponpacks_)
+ elem.first->reload();
}
void WeaponSet::setWeaponmodeLink(WeaponPack* weaponpack, unsigned int weaponmode)
Modified: code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSystem.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSystem.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSystem.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -105,11 +105,11 @@
WeaponSlot * WeaponSystem::getWeaponSlot(unsigned int index) const
{
unsigned int i = 0;
- for (std::vector<WeaponSlot*>::const_iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
+ for (const auto & elem : this->weaponSlots_)
{
++i;
if (i > index)
- return (*it);
+ return (elem);
}
return nullptr;
}
@@ -152,11 +152,11 @@
WeaponSet * WeaponSystem::getWeaponSet(unsigned int index) const
{
unsigned int i = 0;
- for (std::map<unsigned int, WeaponSet*>::const_iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
+ for (const auto & elem : this->weaponSets_)
{
++i;
if (i > index)
- return it->second;
+ return elem.second;
}
return nullptr;
}
@@ -167,9 +167,9 @@
return false;
unsigned int freeSlots = 0;
- for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
+ for (auto & elem : this->weaponSlots_)
{
- if (!(*it)->isOccupied())
+ if (!(elem)->isOccupied())
++freeSlots;
}
@@ -183,23 +183,23 @@
// Attach all weapons to the first free slots (and to the Pawn)
unsigned int i = 0;
- for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
+ for (auto & elem : this->weaponSlots_)
{
- if (!(*it)->isOccupied() && i < wPack->getNumWeapons())
+ if (!(elem)->isOccupied() && i < wPack->getNumWeapons())
{
Weapon* weapon = wPack->getWeapon(i);
- (*it)->attachWeapon(weapon);
+ (elem)->attachWeapon(weapon);
this->getPawn()->attach(weapon);
++i;
}
}
// Assign the desired weaponmode to the firemodes
- for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
+ for (auto & elem : this->weaponSets_)
{
- unsigned int weaponmode = wPack->getDesiredWeaponmode(it->first);
+ unsigned int weaponmode = wPack->getDesiredWeaponmode(elem.first);
if (weaponmode != WeaponSystem::WEAPON_MODE_UNASSIGNED)
- it->second->setWeaponmodeLink(wPack, weaponmode);
+ elem.second->setWeaponmodeLink(wPack, weaponmode);
}
this->weaponPacks_.push_back(wPack);
@@ -218,8 +218,8 @@
weapon->getWeaponSlot()->removeWeapon();
// Remove all added links from the WeaponSets
- for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
- it->second->removeWeaponmodeLink(wPack);
+ for (auto & elem : this->weaponSets_)
+ elem.second->removeWeaponmodeLink(wPack);
// Remove the WeaponPack from the WeaponSystem
std::vector<WeaponPack*>::iterator it2 = std::find(this->weaponPacks_.begin(),this->weaponPacks_.end(), wPack);
@@ -230,11 +230,11 @@
WeaponPack * WeaponSystem::getWeaponPack(unsigned int index) const
{
unsigned int i = 0;
- for (std::vector<WeaponPack*>::const_iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
+ for (const auto & elem : this->weaponPacks_)
{
++i;
if (i > index)
- return (*it);
+ return (elem);
}
return nullptr;
}
@@ -267,9 +267,9 @@
// Check if the WeaponSet belongs to this WeaponSystem
bool foundWeaponSet = false;
- for (std::map<unsigned int, WeaponSet *>::iterator it2 = this->weaponSets_.begin(); it2 != this->weaponSets_.end(); ++it2)
+ for (auto & elem : this->weaponSets_)
{
- if (it2->second == wSet)
+ if (elem.second == wSet)
{
foundWeaponSet = true;
break;
@@ -295,8 +295,8 @@
void WeaponSystem::reload()
{
- for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
- it->second->reload();
+ for (auto & elem : this->weaponSets_)
+ elem.second->reload();
}
Munition * WeaponSystem::getMunition(SubclassIdentifier<Munition> * identifier)
Modified: code/branches/cpp11_v2/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/worldentities/ControllableEntity.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/worldentities/ControllableEntity.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -164,10 +164,10 @@
CameraPosition* ControllableEntity::getCameraPosition(unsigned int index) const
{
unsigned int i = 0;
- for (std::list<StrongPtr<CameraPosition>>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+ for (const auto & elem : this->cameraPositions_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
return nullptr;
@@ -179,9 +179,9 @@
return 0;
unsigned int counter = 0;
- for (std::list<StrongPtr<CameraPosition>>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+ for (const auto & elem : this->cameraPositions_)
{
- if ((*it) == this->currentCameraPosition_)
+ if ((elem) == this->currentCameraPosition_)
break;
counter++;
}
@@ -476,9 +476,9 @@
WorldEntity* parent = this->getParent();
if (parent)
{
- for (std::list<StrongPtr<CameraPosition>>::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
- if ((*it)->getIsAbsolute())
- parent->attach((*it));
+ for (auto & elem : this->cameraPositions_)
+ if ((elem)->getIsAbsolute())
+ parent->attach((elem));
}
}
Modified: code/branches/cpp11_v2/src/orxonox/worldentities/EffectContainer.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/worldentities/EffectContainer.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/worldentities/EffectContainer.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -88,9 +88,9 @@
WorldEntity* EffectContainer::getEffect(unsigned int index) const
{
unsigned int i = 0;
- for (std::vector<WorldEntity*>::const_iterator it = this->effects_.begin(); it != this->effects_.end(); ++it)
+ for (const auto & elem : this->effects_)
if (i == index)
- return (*it);
+ return (elem);
return nullptr;
}
Modified: code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -232,16 +232,16 @@
this->deactivatePhysics();
// iterate over all children and change their activity as well
- for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+ for (const auto & elem : this->getAttachedObjects())
{
if(!this->isActive())
{
- (*it)->bActiveMem_ = (*it)->isActive();
- (*it)->setActive(this->isActive());
+ (elem)->bActiveMem_ = (elem)->isActive();
+ (elem)->setActive(this->isActive());
}
else
{
- (*it)->setActive((*it)->bActiveMem_);
+ (elem)->setActive((elem)->bActiveMem_);
}
}
}
@@ -258,16 +258,16 @@
if(GameMode::isMaster())
{
// iterate over all children and change their visibility as well
- for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+ for (const auto & elem : this->getAttachedObjects())
{
if(!this->isVisible())
{
- (*it)->bVisibleMem_ = (*it)->isVisible();
- (*it)->setVisible(this->isVisible());
+ (elem)->bVisibleMem_ = (elem)->isVisible();
+ (elem)->setVisible(this->isVisible());
}
else
{
- (*it)->setVisible((*it)->bVisibleMem_);
+ (elem)->setVisible((elem)->bVisibleMem_);
}
}
}
@@ -517,10 +517,10 @@
WorldEntity* WorldEntity::getAttachedObject(unsigned int index)
{
unsigned int i = 0;
- for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+ for (const auto & elem : this->children_)
{
if (i == index)
- return (*it);
+ return (elem);
++i;
}
return nullptr;
@@ -937,8 +937,8 @@
// Note: CollisionShape changes of a child get handled over the internal CompoundCollisionShape already
// Recalculate mass
this->childrenMass_ = 0.0f;
- for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
- this->childrenMass_ += (*it)->getMass();
+ for (const auto & elem : this->children_)
+ this->childrenMass_ += (elem)->getMass();
recalculateMassProps();
// Notify parent WE
if (this->parent_)
Modified: code/branches/cpp11_v2/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/worldentities/pawns/ModularSpaceShip.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/worldentities/pawns/ModularSpaceShip.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -98,15 +98,15 @@
break;
}
// iterate through all attached parts
- for(unsigned int j = 0; j < this->partList_.size(); j++)
+ for(auto & elem : this->partList_)
{
// if the name of the part matches the name of the object, add the object to that parts entitylist (unless it was already done).
- if((this->partList_[j]->getName() == this->getAttachedObject(i)->getName()) && !this->partList_[j]->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))))
+ if((elem->getName() == this->getAttachedObject(i)->getName()) && !elem->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))))
{
// The Entity is added to the part's entityList_
- this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));
+ elem->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));
// An entry in the partMap_ is created, assigning the part to the entity.
- this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]);
+ this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), elem);
}
}
}
@@ -145,10 +145,10 @@
*/
ShipPart* ModularSpaceShip::getPartOfEntity(StaticEntity* entity) const
{
- for (std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it)
+ for (const auto & elem : this->partMap_)
{
- if (it->first == entity)
- return it->second;
+ if (elem.first == entity)
+ return elem.second;
}
return nullptr;
}
@@ -241,11 +241,11 @@
*/
ShipPart* ModularSpaceShip::getShipPartByName(std::string name)
{
- for(std::vector<ShipPart*>::iterator it = this->partList_.begin(); it != this->partList_.end(); ++it)
+ for(auto & elem : this->partList_)
{
- if(orxonox_cast<ShipPart*>(*it)->getName() == name)
+ if(orxonox_cast<ShipPart*>(elem)->getName() == name)
{
- return orxonox_cast<ShipPart*>(*it);
+ return orxonox_cast<ShipPart*>(elem);
}
}
orxout(internal_warning) << "Couldn't find ShipPart with name \"" << name << "\"." << endl;
@@ -260,9 +260,9 @@
*/
bool ModularSpaceShip::hasShipPart(ShipPart* part) const
{
- for(unsigned int i = 0; i < this->partList_.size(); i++)
+ for(auto & elem : this->partList_)
{
- if(this->partList_[i] == part)
+ if(elem == part)
return true;
}
return false;
Modified: code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -157,8 +157,8 @@
SUPER(SpaceShip, tick, dt);
// Run the engines
- for(std::vector<Engine*>::iterator it = this->engineList_.begin(); it != this->engineList_.end(); it++)
- (*it)->run(dt);
+ for(auto & elem : this->engineList_)
+ (elem)->run(dt);
if (this->hasLocalController())
{
@@ -317,9 +317,9 @@
*/
bool SpaceShip::hasEngine(Engine* engine) const
{
- for(unsigned int i = 0; i < this->engineList_.size(); i++)
+ for(auto & elem : this->engineList_)
{
- if(this->engineList_[i] == engine)
+ if(elem == engine)
return true;
}
return false;
@@ -349,9 +349,9 @@
*/
Engine* SpaceShip::getEngineByName(const std::string& name)
{
- for(size_t i = 0; i < this->engineList_.size(); ++i)
- if(this->engineList_[i]->getName() == name)
- return this->engineList_[i];
+ for(auto & elem : this->engineList_)
+ if(elem->getName() == name)
+ return elem;
orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl;
return nullptr;
@@ -395,8 +395,8 @@
*/
void SpaceShip::addSpeedFactor(float factor)
{
- for(unsigned int i=0; i<this->engineList_.size(); i++)
- this->engineList_[i]->addSpeedMultiply(factor);
+ for(auto & elem : this->engineList_)
+ elem->addSpeedMultiply(factor);
}
/**
@@ -407,8 +407,8 @@
*/
void SpaceShip::addSpeed(float speed)
{
- for(unsigned int i=0; i<this->engineList_.size(); i++)
- this->engineList_[i]->addSpeedAdd(speed);
+ for(auto & elem : this->engineList_)
+ elem->addSpeedAdd(speed);
}
/**
@@ -435,10 +435,10 @@
float SpaceShip::getMaxSpeedFront() const
{
float speed=0;
- for(unsigned int i=0; i<this->engineList_.size(); i++)
+ for(auto & elem : this->engineList_)
{
- if(this->engineList_[i]->getMaxSpeedFront() > speed)
- speed = this->engineList_[i]->getMaxSpeedFront();
+ if(elem->getMaxSpeedFront() > speed)
+ speed = elem->getMaxSpeedFront();
}
return speed;
}
Modified: code/branches/cpp11_v2/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc 2015-11-20 17:11:25 UTC (rev 10820)
+++ code/branches/cpp11_v2/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc 2015-11-21 18:05:53 UTC (rev 10821)
@@ -79,11 +79,11 @@
std::set<WorldEntity*> attachments = this->getAttachedObjects();
- for (std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)
+ for (const auto & attachment : attachments)
{
- if ((*it)->isA(Class(TeamColourable)))
+ if ((attachment)->isA(Class(TeamColourable)))
{
- TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
+ TeamColourable* tc = orxonox_cast<TeamColourable*>(attachment);
tc->setTeamColour(colour);
}
}
More information about the Orxonox-commit
mailing list