Index: ps/trunk/source/renderer/ModelRenderer.cpp =================================================================== --- ps/trunk/source/renderer/ModelRenderer.cpp +++ ps/trunk/source/renderer/ModelRenderer.cpp @@ -314,11 +314,14 @@ } }; -struct SMRMaterialBucketKey +class SMRMaterialBucketKey { +public: SMRMaterialBucketKey(CStrIntern effect, const CShaderDefines& defines) : effect(effect), defines(defines) { } + SMRMaterialBucketKey(const SMRMaterialBucketKey& entity) = default; + CStrIntern effect; CShaderDefines defines; Index: ps/trunk/source/renderer/PatchRData.cpp =================================================================== --- ps/trunk/source/renderer/PatchRData.cpp +++ ps/trunk/source/renderer/PatchRData.cpp @@ -1131,7 +1131,7 @@ ENSURE(!(streamflags & ~(STREAM_POS|STREAM_POSTOUV0|STREAM_POSTOUV1))); // Render each batch - for (const std::pair& streamBatch : batches) + for (const std::pair& streamBatch : batches) { GLsizei stride = sizeof(SBaseVertex); SBaseVertex *base = (SBaseVertex *)streamBatch.first->Bind(); @@ -1144,7 +1144,7 @@ shader->AssertPointersBound(); - for (const std::pair& batchIndexBuffer : streamBatch.second) + for (const std::pair& batchIndexBuffer : streamBatch.second) { batchIndexBuffer.first->Bind(); Index: ps/trunk/source/simulation2/components/CCmpCinemaManager.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpCinemaManager.cpp +++ ps/trunk/source/simulation2/components/CCmpCinemaManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -65,7 +65,7 @@ serializer.Bool("MapRevealed", m_MapRevealed); serializer.NumberU32_Unbounded("NumberOfPaths", m_Paths.size()); - for (const std::pair& it : m_Paths) + for (const std::pair& it : m_Paths) SerializePath(it.second, serializer); serializer.NumberU32_Unbounded("NumberOfQueuedPaths", m_PathQueue.size()); Index: ps/trunk/source/simulation2/components/CCmpPathfinder.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpPathfinder.cpp +++ ps/trunk/source/simulation2/components/CCmpPathfinder.cpp @@ -262,7 +262,7 @@ void CCmpPathfinder::GetPassabilityClasses(std::map& nonPathfindingPassClasses, std::map& pathfindingPassClasses) const { - for (const std::pair& pair : m_PassClassMasks) + for (const std::pair& pair : m_PassClassMasks) { if ((GetPassabilityFromMask(pair.second)->m_Obstructions == PathfinderPassability::PATHFINDING)) pathfindingPassClasses[pair.first] = pair.second; Index: ps/trunk/source/simulation2/components/CCmpRangeManager.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpRangeManager.cpp +++ ps/trunk/source/simulation2/components/CCmpRangeManager.cpp @@ -300,13 +300,16 @@ * It must only be passed entities that are in 'entities' * and are currently in the world. */ -struct EntityDistanceOrdering +class EntityDistanceOrdering { +public: EntityDistanceOrdering(const EntityMap& entities, const CFixedVector2D& source) : m_EntityData(entities), m_Source(source) { } + EntityDistanceOrdering(const EntityDistanceOrdering& entity) = default; + bool operator()(entity_id_t a, entity_id_t b) const { const EntityData& da = m_EntityData.find(a)->second; Index: ps/trunk/source/simulation2/components/CCmpTemplateManager.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpTemplateManager.cpp +++ ps/trunk/source/simulation2/components/CCmpTemplateManager.cpp @@ -58,9 +58,9 @@ virtual void Serialize(ISerializer& serialize) { - std::map> templateMap; + std::map> templateMap; - for (const std::pair& templateEnt : m_LatestTemplates) + for (const std::pair& templateEnt : m_LatestTemplates) if (!ENTITY_IS_LOCAL(templateEnt.first)) templateMap[templateEnt.second].push_back(templateEnt.first); @@ -71,9 +71,9 @@ { Init(paramNode); - std::map> templateMap; + std::map> templateMap; Serializer(deserialize, "templates", templateMap); - for (const std::pair>& mapEl : templateMap) + for (const std::pair>& mapEl : templateMap) for (entity_id_t id : mapEl.second) m_LatestTemplates[id] = mapEl.first; } @@ -218,7 +218,7 @@ std::vector CCmpTemplateManager::FindUsedTemplates() const { std::vector usedTemplates; - for (const std::pair& p : m_LatestTemplates) + for (const std::pair& p : m_LatestTemplates) if (std::find(usedTemplates.begin(), usedTemplates.end(), p.second) == usedTemplates.end()) usedTemplates.push_back(p.second); return usedTemplates; @@ -230,7 +230,7 @@ std::vector CCmpTemplateManager::GetEntitiesUsingTemplate(const std::string& templateName) const { std::vector entities; - for (const std::pair& p : m_LatestTemplates) + for (const std::pair& p : m_LatestTemplates) if (p.second == templateName) entities.push_back(p.first); Index: ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp +++ ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp @@ -459,14 +459,14 @@ // store the root influences to mark territory as connected std::vector rootInfluenceEntities; - for (const std::pair >& pair : influenceEntities) + for (const std::pair>& pair : influenceEntities) { // entityGrid stores the weight for a single entity, and is reset per entity Grid entityGrid(tilesW, tilesH); // playerGrid stores the combined weight of all entities for this player Grid playerGrid(tilesW, tilesH); - u8 owner = (u8)pair.first; + u8 owner = static_cast(pair.first); const std::vector& ents = pair.second; // With 2^16 entities, we're safe against overflows as the weight is also limited to 2^16 ENSURE(ents.size() < 1 << 16); Index: ps/trunk/source/simulation2/helpers/HierarchicalPathfinder.cpp =================================================================== --- ps/trunk/source/simulation2/helpers/HierarchicalPathfinder.cpp +++ ps/trunk/source/simulation2/helpers/HierarchicalPathfinder.cpp @@ -467,7 +467,7 @@ if (!dirtinessGrid.any_set_in_square(i0, j0, i1, j1)) continue; - for (const std::pair& passClassMask : m_PassClassMasks) + for (const std::pair& passClassMask : m_PassClassMasks) { pass_class_t passClass = passClassMask.second; Chunk& a = m_Chunks[passClass].at(ci + cj*m_ChunksW); @@ -627,7 +627,8 @@ { // Use FindReachableRegions because we cannot be sure, even if we find a non-dirty chunk nearby, // that we weren't the only bridge connecting that chunk to the rest of the global region. - for (const std::pair >& regionsInNeed : needNewGlobalRegionMap) + for (const std::pair>& regionsInNeed : needNewGlobalRegionMap) + { for (const RegionID& reg : regionsInNeed.second) { std::map& globalRegions = m_GlobalRegions[regionsInNeed.first]; @@ -643,6 +644,7 @@ for (const RegionID& regionId : reachable) globalRegions[regionId] = ID; } + } } HierarchicalPathfinder::RegionID HierarchicalPathfinder::Get(u16 i, u16 j, pass_class_t passClass) const Index: ps/trunk/source/soundmanager/SoundManager.cpp =================================================================== --- ps/trunk/source/soundmanager/SoundManager.cpp +++ ps/trunk/source/soundmanager/SoundManager.cpp @@ -277,7 +277,7 @@ } AL_CHECK; - for (const std::pair& p : m_SoundGroups) + for (const std::pair& p : m_SoundGroups) delete p.second; m_SoundGroups.clear(); Index: ps/trunk/source/third_party/jsonspirit/json_spirit_value.h =================================================================== --- ps/trunk/source/third_party/jsonspirit/json_spirit_value.h +++ ps/trunk/source/third_party/jsonspirit/json_spirit_value.h @@ -17,10 +17,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include // comment out the value types you don't need to reduce build times and intermediate file sizes #define JSON_SPIRIT_VALUE_ENABLED @@ -32,10 +32,10 @@ { enum Value_type{ obj_type, array_type, str_type, bool_type, int_type, real_type, null_type }; - static std::string value_type_to_string( Value_type vtype ); + static inline std::string value_type_to_string(const Value_type vtype ); struct Null{}; - + template< class Config > // Config determines whether the value uses std::string or std::wstring and // whether JSON Objects are represented as vectors or maps class Value_impl @@ -49,7 +49,7 @@ typedef typename String_type::const_pointer Const_str_ptr; // eg const char* Value_impl(); // creates null value - Value_impl( Const_str_ptr value ); + Value_impl( Const_str_ptr value ); Value_impl( const String_type& value ); Value_impl( const Object& value ); Value_impl( const Array& value ); @@ -97,28 +97,28 @@ void check_type( const Value_type vtype ) const; - typedef boost::variant< boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >, + typedef boost::variant< boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >, String_type, bool, boost::int64_t, double, Null, boost::uint64_t > Variant; Variant v_; - class Variant_converter_visitor : public boost::static_visitor< Variant > + class Variant_converter_visitor : public boost::static_visitor< Variant > { public: - + template< typename T, typename A, template< typename, typename > class Cont > - Variant operator()( const Cont< T, A >& cont ) const + Variant operator()( const Cont< T, A >& cont ) const { return Array( cont.begin(), cont.end() ); } - - Variant operator()( int i ) const + + Variant operator()( int i ) const { return static_cast< boost::int64_t >( i ); } - + template - Variant operator()( const T& t ) const + Variant operator()( const T& t ) const { return t; } @@ -161,12 +161,12 @@ return obj.back().value_; } - + static const String_type& get_name( const Pair_type& pair ) { return pair.name_; } - + static const Value_type& get_value( const Pair_type& pair ) { return pair.value_; @@ -212,12 +212,12 @@ { return obj[ name ] = value; } - + static const String_type& get_name( const Pair_type& pair ) { return pair.first; } - + static const Value_type& get_value( const Pair_type& pair ) { return pair.second; @@ -354,7 +354,7 @@ if( type() != lhs.type() ) return false; - return v_ == lhs.v_; + return v_ == lhs.v_; } template< class Config > @@ -383,7 +383,7 @@ template< class Config > void Value_impl< Config >::check_type( const Value_type vtype ) const { - if( type() != vtype ) + if( type() != vtype ) { std::ostringstream os; @@ -408,7 +408,7 @@ return *boost::get< Object >( &v_ ); } - + template< class Config > const typename Value_impl< Config >::Array& Value_impl< Config >::get_array() const { @@ -416,7 +416,7 @@ return *boost::get< Array >( &v_ ); } - + template< class Config > bool Value_impl< Config >::get_bool() const { @@ -424,7 +424,7 @@ return boost::get< bool >( v_ ); } - + template< class Config > int Value_impl< Config >::get_int() const { @@ -432,7 +432,7 @@ return static_cast< int >( get_int64() ); } - + template< class Config > boost::int64_t Value_impl< Config >::get_int64() const { @@ -445,7 +445,7 @@ return boost::get< boost::int64_t >( v_ ); } - + template< class Config > boost::uint64_t Value_impl< Config >::get_uint64() const { @@ -528,49 +528,49 @@ { }; - template< class Value > + template< class Value > int get_value( const Value& value, Type_to_type< int > ) { return value.get_int(); } - - template< class Value > + + template< class Value > boost::int64_t get_value( const Value& value, Type_to_type< boost::int64_t > ) { return value.get_int64(); } - - template< class Value > + + template< class Value > boost::uint64_t get_value( const Value& value, Type_to_type< boost::uint64_t > ) { return value.get_uint64(); } - - template< class Value > + + template< class Value > double get_value( const Value& value, Type_to_type< double > ) { return value.get_real(); } - - template< class Value > + + template< class Value > typename Value::String_type get_value( const Value& value, Type_to_type< typename Value::String_type > ) { return value.get_str(); } - - template< class Value > + + template< class Value > typename Value::Array get_value( const Value& value, Type_to_type< typename Value::Array > ) { return value.get_array(); } - - template< class Value > + + template< class Value > typename Value::Object get_value( const Value& value, Type_to_type< typename Value::Object > ) { return value.get_obj(); } - - template< class Value > + + template< class Value > bool get_value( const Value& value, Type_to_type< bool > ) { return value.get_bool(); @@ -578,13 +578,13 @@ } template< class Config > - template< typename T > + template< typename T > T Value_impl< Config >::get_value() const { return internal_::get_value( *this, internal_::Type_to_type< T >() ); } - static std::string value_type_to_string( const Value_type vtype ) + static inline std::string value_type_to_string( const Value_type vtype ) { switch( vtype ) { Index: ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp +++ ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp @@ -239,7 +239,7 @@ m_MapSettingsVictoryConditions.insert(std::string(victoryCondition)); // Clear Checkboxes before loading data. We don't update victory condition just yet because it might reenable some of the checkboxes. - for (const std::pair& vc : m_VictoryConditions) + for (const std::pair& vc : m_VictoryConditions) { wxCheckBox* checkBox = wxDynamicCast(FindWindow(vc.first), wxCheckBox); if (!checkBox) @@ -249,7 +249,7 @@ checkBox->Enable(true); } - for (const std::pair& vc : m_VictoryConditions) + for (const std::pair& vc : m_VictoryConditions) { std::string escapedTitle = wxString::FromUTF8(vc.second["Data"]["Title"]).Lower().ToStdString(); std::replace(escapedTitle.begin(), escapedTitle.end(), ' ', '_'); @@ -298,20 +298,20 @@ AtObj victoryCondition; wxCheckBox* modifiedCheckbox = wxDynamicCast(FindWindow(controlId), wxCheckBox); - for (const std::pair& vc : m_VictoryConditions) + for (const std::pair& vc : m_VictoryConditions) { - if(vc.first != controlId) + if (vc.first != controlId) continue; - victoryCondition = vc.second; + victoryCondition = vc.second; break; } - if(modifiedCheckbox->GetValue()) + if (modifiedCheckbox->GetValue()) { for (AtIter victoryConditionPair = victoryCondition["Data"]["ChangeOnChecked"]; victoryConditionPair.defined(); ++victoryConditionPair) { - for (const std::pair& vc : m_VictoryConditions) + for (const std::pair& vc : m_VictoryConditions) { std::string escapedTitle = wxString::FromUTF8(vc.second["Data"]["Title"]).Lower().ToStdString(); std::replace(escapedTitle.begin(), escapedTitle.end(), ' ', '_'); @@ -325,7 +325,7 @@ } } - for (const std::pair& vc : m_VictoryConditions) + for (const std::pair& vc : m_VictoryConditions) { if (vc.first == controlId) continue; @@ -333,7 +333,7 @@ wxCheckBox* otherCheckbox = wxDynamicCast(FindWindow(vc.first), wxCheckBox); otherCheckbox->Enable(true); - for (const std::pair& vc2 : m_VictoryConditions) + for (const std::pair& vc2 : m_VictoryConditions) { for (AtIter victoryConditionTitle = vc2.second["Data"]["DisabledWhenChecked"]; victoryConditionTitle.defined(); ++victoryConditionTitle) { @@ -371,7 +371,7 @@ else \ m_MapSettingsVictoryConditions.erase(name); - for (const std::pair& vc : m_VictoryConditions) + for (const std::pair& vc : m_VictoryConditions) { std::string escapedTitle = wxString::FromUTF8(vc.second["Data"]["Title"]).Lower().ToStdString(); std::replace(escapedTitle.begin(), escapedTitle.end(), ' ', '_'); Index: ps/trunk/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp =================================================================== --- ps/trunk/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp +++ ps/trunk/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -491,9 +491,9 @@ CVector2D cursor; msg->pos->GetScreenSpace(cursor.X, cursor.Y); - for (const std::pair& p : cmpCinemaManager->GetPaths()) + for (const std::pair& p : cmpCinemaManager->GetPaths()) { - const CCinemaPath& path = p.second; + const CCinemaPath& path = p.second; if (isPathNodePicked(path, cursor, node, false) || isPathNodePicked(path.GetTargetSpline(), cursor, node, true)) { node.name = path.GetName(); Index: ps/trunk/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp =================================================================== --- ps/trunk/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp +++ ps/trunk/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp @@ -518,10 +518,9 @@ const CFixedVector3D offset = CFixedVector3D(fixed::FromInt(offsetX), fixed::FromInt(0), fixed::FromInt(offsetZ)); const CSimulation2::InterfaceListUnordered& ents = sim.GetEntitiesWithInterfaceUnordered(IID_Selectable); - for (const std::pair& ent : ents) + for (const std::pair& ent : ents) { const entity_id_t entityId = ent.first; - CmpPtr cmpPosition(sim, entityId); if (cmpPosition && cmpPosition->IsInWorld() && Within(cmpPosition->GetPosition(), mapCenterX, mapCenterZ, radiusInTerrainUnits)) Index: ps/trunk/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp =================================================================== --- ps/trunk/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp +++ ps/trunk/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp @@ -767,7 +767,7 @@ void SetPos(const std::map& map) { - for (const std::pair& p : map) + for (const std::pair& p : map) { CmpPtr cmpPosition(*g_Game->GetSimulation2(), p.first); if (!cmpPosition) @@ -859,7 +859,7 @@ void SetPos(const std::map& position, const std::map& angle) { - for (const std::pair& p : position) + for (const std::pair& p : position) { CmpPtr cmpPosition(*g_Game->GetSimulation2(), p.first); if (!cmpPosition) @@ -873,7 +873,7 @@ } - for (const std::pair& p: position) + for (const std::pair& p : position) CheckObstructionAndUpdateVisual(p.first); } @@ -963,7 +963,7 @@ void SetAngle(const std::map& angles) { - for (const std::pair& p : angles) + for (const std::pair& p : angles) { CmpPtr cmpPosition(*g_Game->GetSimulation2(), p.first); if (!cmpPosition) Index: ps/trunk/source/tools/atlas/GameInterface/View.cpp =================================================================== --- ps/trunk/source/tools/atlas/GameInterface/View.cpp +++ ps/trunk/source/tools/atlas/GameInterface/View.cpp @@ -179,7 +179,7 @@ AtlasViewGame::~AtlasViewGame() { - for (const std::pair& p : m_SavedStates) + for (const std::pair& p : m_SavedStates) delete p.second; }