1
0
forked from 0ad/0ad

Fix most Clang 10 Warnings

Refs: #5550, #5294

Remove dead code from f71be3c764
Fix buggy code from ff50b0b74c
Comments by: @wraitii, @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D3177
This was SVN commit r24487.
This commit is contained in:
Stan 2020-12-31 14:25:37 +00:00
parent a395a0ab66
commit 4942cabab5
15 changed files with 88 additions and 81 deletions

View File

@ -314,11 +314,14 @@ struct SMRCompareSortByDistItem
}
};
struct SMRMaterialBucketKey
class SMRMaterialBucketKey
{
public:
SMRMaterialBucketKey(CStrIntern effect, const CShaderDefines& defines)
: effect(effect), defines(defines) { }
SMRMaterialBucketKey(const SMRMaterialBucketKey& entity) = default;
CStrIntern effect;
CShaderDefines defines;

View File

@ -1131,7 +1131,7 @@ void CPatchRData::RenderStreams(const std::vector<CPatchRData*>& patches, const
ENSURE(!(streamflags & ~(STREAM_POS|STREAM_POSTOUV0|STREAM_POSTOUV1)));
// Render each batch
for (const std::pair<CVertexBuffer*, StreamIndexBufferBatches>& streamBatch : batches)
for (const std::pair<CVertexBuffer* const, StreamIndexBufferBatches>& streamBatch : batches)
{
GLsizei stride = sizeof(SBaseVertex);
SBaseVertex *base = (SBaseVertex *)streamBatch.first->Bind();
@ -1144,7 +1144,7 @@ void CPatchRData::RenderStreams(const std::vector<CPatchRData*>& patches, const
shader->AssertPointersBound();
for (const std::pair<CVertexBuffer*, StreamBatchElements>& batchIndexBuffer : streamBatch.second)
for (const std::pair<CVertexBuffer* const, StreamBatchElements>& batchIndexBuffer : streamBatch.second)
{
batchIndexBuffer.first->Bind();

View File

@ -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 @@ public:
serializer.Bool("MapRevealed", m_MapRevealed);
serializer.NumberU32_Unbounded("NumberOfPaths", m_Paths.size());
for (const std::pair<CStrW, CCinemaPath>& it : m_Paths)
for (const std::pair<const CStrW, CCinemaPath>& it : m_Paths)
SerializePath(it.second, serializer);
serializer.NumberU32_Unbounded("NumberOfQueuedPaths", m_PathQueue.size());

View File

@ -262,7 +262,7 @@ void CCmpPathfinder::GetPassabilityClasses(std::map<std::string, pass_class_t>&
void CCmpPathfinder::GetPassabilityClasses(std::map<std::string, pass_class_t>& nonPathfindingPassClasses, std::map<std::string, pass_class_t>& pathfindingPassClasses) const
{
for (const std::pair<std::string, pass_class_t>& pair : m_PassClassMasks)
for (const std::pair<const std::string, pass_class_t>& pair : m_PassClassMasks)
{
if ((GetPassabilityFromMask(pair.second)->m_Obstructions == PathfinderPassability::PATHFINDING))
pathfindingPassClasses[pair.first] = pair.second;

View File

@ -300,13 +300,16 @@ struct SerializeHelper<EntityData>
* It must only be passed entities that are in 'entities'
* and are currently in the world.
*/
struct EntityDistanceOrdering
class EntityDistanceOrdering
{
public:
EntityDistanceOrdering(const EntityMap<EntityData>& 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;

View File

@ -58,9 +58,9 @@ public:
virtual void Serialize(ISerializer& serialize)
{
std::map<CStr, std::vector<entity_id_t>> templateMap;
std::map<std::string, std::vector<entity_id_t>> templateMap;
for (const std::pair<entity_id_t, std::string>& templateEnt : m_LatestTemplates)
for (const std::pair<const entity_id_t, std::string>& templateEnt : m_LatestTemplates)
if (!ENTITY_IS_LOCAL(templateEnt.first))
templateMap[templateEnt.second].push_back(templateEnt.first);
@ -71,9 +71,9 @@ public:
{
Init(paramNode);
std::map<CStr, std::vector<entity_id_t>> templateMap;
std::map<std::string, std::vector<entity_id_t>> templateMap;
Serializer(deserialize, "templates", templateMap);
for (const std::pair<CStr, std::vector<entity_id_t>>& mapEl : templateMap)
for (const std::pair<const std::string, std::vector<entity_id_t>>& mapEl : templateMap)
for (entity_id_t id : mapEl.second)
m_LatestTemplates[id] = mapEl.first;
}
@ -218,7 +218,7 @@ std::vector<std::string> CCmpTemplateManager::FindAllTemplates(bool includeActor
std::vector<std::string> CCmpTemplateManager::FindUsedTemplates() const
{
std::vector<std::string> usedTemplates;
for (const std::pair<entity_id_t, std::string>& p : m_LatestTemplates)
for (const std::pair<const entity_id_t, std::string>& 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<std::string> CCmpTemplateManager::FindUsedTemplates() const
std::vector<entity_id_t> CCmpTemplateManager::GetEntitiesUsingTemplate(const std::string& templateName) const
{
std::vector<entity_id_t> entities;
for (const std::pair<entity_id_t, std::string>& p : m_LatestTemplates)
for (const std::pair<const entity_id_t, std::string>& p : m_LatestTemplates)
if (p.second == templateName)
entities.push_back(p.first);

View File

@ -459,14 +459,14 @@ void CCmpTerritoryManager::CalculateTerritories()
// store the root influences to mark territory as connected
std::vector<entity_id_t> rootInfluenceEntities;
for (const std::pair<player_id_t, std::vector<entity_id_t> >& pair : influenceEntities)
for (const std::pair<const player_id_t, std::vector<entity_id_t>>& pair : influenceEntities)
{
// entityGrid stores the weight for a single entity, and is reset per entity
Grid<u32> entityGrid(tilesW, tilesH);
// playerGrid stores the combined weight of all entities for this player
Grid<u32> playerGrid(tilesW, tilesH);
u8 owner = (u8)pair.first;
u8 owner = static_cast<u8>(pair.first);
const std::vector<entity_id_t>& 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);

View File

@ -467,7 +467,7 @@ void HierarchicalPathfinder::Update(Grid<NavcellData>* grid, const Grid<u8>& dir
if (!dirtinessGrid.any_set_in_square(i0, j0, i1, j1))
continue;
for (const std::pair<std::string, pass_class_t>& passClassMask : m_PassClassMasks)
for (const std::pair<const std::string, pass_class_t>& passClassMask : m_PassClassMasks)
{
pass_class_t passClass = passClassMask.second;
Chunk& a = m_Chunks[passClass].at(ci + cj*m_ChunksW);
@ -627,7 +627,8 @@ void HierarchicalPathfinder::UpdateGlobalRegions(const std::map<pass_class_t, st
{
// 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<pass_class_t, std::vector<RegionID> >& regionsInNeed : needNewGlobalRegionMap)
for (const std::pair<const pass_class_t, std::vector<RegionID>>& regionsInNeed : needNewGlobalRegionMap)
{
for (const RegionID& reg : regionsInNeed.second)
{
std::map<RegionID, GlobalRegionID>& globalRegions = m_GlobalRegions[regionsInNeed.first];
@ -643,6 +644,7 @@ void HierarchicalPathfinder::UpdateGlobalRegions(const std::map<pass_class_t, st
for (const RegionID& regionId : reachable)
globalRegions[regionId] = ID;
}
}
}
HierarchicalPathfinder::RegionID HierarchicalPathfinder::Get(u16 i, u16 j, pass_class_t passClass) const

View File

@ -277,7 +277,7 @@ CSoundManager::~CSoundManager()
}
AL_CHECK;
for (const std::pair<std::wstring, CSoundGroup*>& p : m_SoundGroups)
for (const std::pair<const std::wstring, CSoundGroup*>& p : m_SoundGroups)
delete p.second;
m_SoundGroups.clear();

View File

@ -17,10 +17,10 @@
#include <cassert>
#include <sstream>
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/variant.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/variant.hpp>
// 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 @@ namespace json_spirit
{
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 @@ namespace json_spirit
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 @@ namespace json_spirit
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<class T>
Variant operator()( const T& t ) const
Variant operator()( const T& t ) const
{
return t;
}
@ -161,12 +161,12 @@ namespace json_spirit
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 @@ namespace json_spirit
{
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 @@ namespace json_spirit
if( type() != lhs.type() ) return false;
return v_ == lhs.v_;
return v_ == lhs.v_;
}
template< class Config >
@ -383,7 +383,7 @@ namespace json_spirit
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 @@ namespace json_spirit
return *boost::get< Object >( &v_ );
}
template< class Config >
const typename Value_impl< Config >::Array& Value_impl< Config >::get_array() const
{
@ -416,7 +416,7 @@ namespace json_spirit
return *boost::get< Array >( &v_ );
}
template< class Config >
bool Value_impl< Config >::get_bool() const
{
@ -424,7 +424,7 @@ namespace json_spirit
return boost::get< bool >( v_ );
}
template< class Config >
int Value_impl< Config >::get_int() const
{
@ -432,7 +432,7 @@ namespace json_spirit
return static_cast< int >( get_int64() );
}
template< class Config >
boost::int64_t Value_impl< Config >::get_int64() const
{
@ -445,7 +445,7 @@ namespace json_spirit
return boost::get< boost::int64_t >( v_ );
}
template< class Config >
boost::uint64_t Value_impl< Config >::get_uint64() const
{
@ -528,49 +528,49 @@ namespace json_spirit
{
};
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 @@ namespace json_spirit
}
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 )
{

View File

@ -239,7 +239,7 @@ void MapSettingsControl::ReadFromEngine()
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<long, AtObj>& vc : m_VictoryConditions)
for (const std::pair<const long, AtObj>& vc : m_VictoryConditions)
{
wxCheckBox* checkBox = wxDynamicCast(FindWindow(vc.first), wxCheckBox);
if (!checkBox)
@ -249,7 +249,7 @@ void MapSettingsControl::ReadFromEngine()
checkBox->Enable(true);
}
for (const std::pair<long, AtObj>& vc : m_VictoryConditions)
for (const std::pair<const long, AtObj>& vc : m_VictoryConditions)
{
std::string escapedTitle = wxString::FromUTF8(vc.second["Data"]["Title"]).Lower().ToStdString();
std::replace(escapedTitle.begin(), escapedTitle.end(), ' ', '_');
@ -298,20 +298,20 @@ void MapSettingsControl::OnVictoryConditionChanged(long controlId)
AtObj victoryCondition;
wxCheckBox* modifiedCheckbox = wxDynamicCast(FindWindow(controlId), wxCheckBox);
for (const std::pair<long, AtObj>& vc : m_VictoryConditions)
for (const std::pair<const long, AtObj>& 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<long, AtObj>& vc : m_VictoryConditions)
for (const std::pair<const long, AtObj>& vc : m_VictoryConditions)
{
std::string escapedTitle = wxString::FromUTF8(vc.second["Data"]["Title"]).Lower().ToStdString();
std::replace(escapedTitle.begin(), escapedTitle.end(), ' ', '_');
@ -325,7 +325,7 @@ void MapSettingsControl::OnVictoryConditionChanged(long controlId)
}
}
for (const std::pair<long, AtObj>& vc : m_VictoryConditions)
for (const std::pair<const long, AtObj>& vc : m_VictoryConditions)
{
if (vc.first == controlId)
continue;
@ -333,7 +333,7 @@ void MapSettingsControl::OnVictoryConditionChanged(long controlId)
wxCheckBox* otherCheckbox = wxDynamicCast(FindWindow(vc.first), wxCheckBox);
otherCheckbox->Enable(true);
for (const std::pair<long, AtObj>& vc2 : m_VictoryConditions)
for (const std::pair<const long, AtObj>& vc2 : m_VictoryConditions)
{
for (AtIter victoryConditionTitle = vc2.second["Data"]["DisabledWhenChecked"]; victoryConditionTitle.defined(); ++victoryConditionTitle)
{
@ -371,7 +371,7 @@ AtObj MapSettingsControl::UpdateSettingsObject()
else \
m_MapSettingsVictoryConditions.erase(name);
for (const std::pair<long, AtObj>& vc : m_VictoryConditions)
for (const std::pair<const long, AtObj>& vc : m_VictoryConditions)
{
std::string escapedTitle = wxString::FromUTF8(vc.second["Data"]["Title"]).Lower().ToStdString();
std::replace(escapedTitle.begin(), escapedTitle.end(), ' ', '_');

View File

@ -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 @@ QUERYHANDLER(PickPathNode)
CVector2D cursor;
msg->pos->GetScreenSpace(cursor.X, cursor.Y);
for (const std::pair<CStrW, CCinemaPath>& p : cmpCinemaManager->GetPaths())
for (const std::pair<const CStrW, CCinemaPath>& 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();

View File

@ -518,10 +518,9 @@ BEGIN_COMMAND(ResizeMap)
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<entity_id_t, IComponent*>& ent : ents)
for (const std::pair<const entity_id_t, IComponent*>& ent : ents)
{
const entity_id_t entityId = ent.first;
CmpPtr<ICmpPosition> cmpPosition(sim, entityId);
if (cmpPosition && cmpPosition->IsInWorld() && Within(cmpPosition->GetPosition(), mapCenterX, mapCenterZ, radiusInTerrainUnits))

View File

@ -767,7 +767,7 @@ BEGIN_COMMAND(MoveObjects)
void SetPos(const std::map<entity_id_t, CVector3D>& map)
{
for (const std::pair<entity_id_t, CVector3D>& p : map)
for (const std::pair<const entity_id_t, CVector3D>& p : map)
{
CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), p.first);
if (!cmpPosition)
@ -859,7 +859,7 @@ BEGIN_COMMAND(RotateObjectsFromCenterPoint)
void SetPos(const std::map<entity_id_t, CVector3D>& position, const std::map<entity_id_t, float>& angle)
{
for (const std::pair<entity_id_t, CVector3D>& p : position)
for (const std::pair<const entity_id_t, CVector3D>& p : position)
{
CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), p.first);
if (!cmpPosition)
@ -873,7 +873,7 @@ BEGIN_COMMAND(RotateObjectsFromCenterPoint)
}
for (const std::pair<entity_id_t, CVector3D>& p: position)
for (const std::pair<const entity_id_t, CVector3D>& p : position)
CheckObstructionAndUpdateVisual(p.first);
}
@ -963,7 +963,7 @@ BEGIN_COMMAND(RotateObject)
void SetAngle(const std::map<entity_id_t, float>& angles)
{
for (const std::pair<entity_id_t, float>& p : angles)
for (const std::pair<const entity_id_t, float>& p : angles)
{
CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), p.first);
if (!cmpPosition)

View File

@ -179,7 +179,7 @@ AtlasViewGame::AtlasViewGame()
AtlasViewGame::~AtlasViewGame()
{
for (const std::pair<std::wstring, SimState*>& p : m_SavedStates)
for (const std::pair<const std::wstring, SimState*>& p : m_SavedStates)
delete p.second;
}