Fix cppcheck warnings

pull/1/head
scrawl 9 years ago committed by Koncord
parent dca0e2f582
commit e362e3e6a5

@ -54,7 +54,7 @@ namespace
*(image->data(x,y)+2) = *it++;
*(image->data(x,y)+1) = *it++;
*image->data(x,y) = *it++;
it++; // skip alpha
++it; // skip alpha
}
}

@ -1,5 +1,6 @@
#include "importer.hpp"
#include <ctime>
#include <iostream>
#include <string>
#include <map>
@ -897,8 +898,13 @@ std::time_t MwIniImporter::lastWriteTime(const boost::filesystem::path& filename
boost::filesystem::path resolved = filename;
#endif
writeTime = boost::filesystem::last_write_time(resolved);
// print timestamp
const int size=1024;
char timeStrBuffer[size];
if (std::strftime(timeStrBuffer, size, "%x %X", localtime(&writeTime)) > 0)
std::cout << "content file: " << resolved << " timestamp = (" << writeTime <<
") " << asctime(localtime(&writeTime)) << std::endl;
") " << timeStrBuffer << std::endl;
}
else
{

@ -45,13 +45,12 @@ void CSMDoc::Loader::load()
bool done = false;
const int batchingSize = 50;
try
{
if (iter->second.mRecordsLeft)
{
Messages messages (Message::Severity_Error);
const int batchingSize = 50;
for (int i=0; i<batchingSize; ++i) // do not flood the system with update signals
if (document->getData().continueLoading (messages))
{

@ -7,7 +7,7 @@
namespace
{
void addMessageIfNotEmpty(CSMDoc::Messages &messages, const CSMWorld::UniversalId &id, const std::string text)
void addMessageIfNotEmpty(CSMDoc::Messages &messages, const CSMWorld::UniversalId &id, const std::string& text)
{
if (!text.empty())
{

@ -120,24 +120,25 @@ QString CSMTools::Search::flatten (const QString& text) const
return flat;
}
CSMTools::Search::Search() : mType (Type_None), mPaddingBefore (10), mPaddingAfter (10) {}
CSMTools::Search::Search() : mType (Type_None), mValue (0), mIdColumn (0), mTypeColumn (0),
mPaddingBefore (10), mPaddingAfter (10) {}
CSMTools::Search::Search (Type type, const std::string& value)
: mType (type), mText (value), mPaddingBefore (10), mPaddingAfter (10)
: mType (type), mText (value), mValue (0), mIdColumn (0), mTypeColumn (0), mPaddingBefore (10), mPaddingAfter (10)
{
if (type!=Type_Text && type!=Type_Id)
throw std::logic_error ("Invalid search parameter (string)");
}
CSMTools::Search::Search (Type type, const QRegExp& value)
: mType (type), mRegExp (value), mPaddingBefore (10), mPaddingAfter (10)
: mType (type), mRegExp (value), mValue (0), mIdColumn (0), mTypeColumn (0), mPaddingBefore (10), mPaddingAfter (10)
{
if (type!=Type_TextRegEx && type!=Type_IdRegEx)
throw std::logic_error ("Invalid search parameter (RegExp)");
}
CSMTools::Search::Search (Type type, int value)
: mType (type), mValue (value), mPaddingBefore (10), mPaddingAfter (10)
: mType (type), mValue (value), mIdColumn (0), mTypeColumn (0), mPaddingBefore (10), mPaddingAfter (10)
{
if (type!=Type_RecordState)
throw std::logic_error ("invalid search parameter (int)");

@ -26,7 +26,7 @@ void CSMTools::SoundGenCheckStage::perform(int stage, CSMDoc::Messages &messages
return;
}
const ESM::SoundGenerator soundGen = record.get();
const ESM::SoundGenerator& soundGen = record.get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_SoundGen, soundGen.mId);
if (!soundGen.mCreature.empty())

@ -277,7 +277,7 @@ namespace CSMWorld
// WARNING: Assumed that the table view has the same order as std::map
std::map<std::string, int>::iterator iter = reactions.begin();
for(int i = 0; i < rowToRemove; ++i)
iter++;
++iter;
reactions.erase(iter);
record.setModified (faction);
@ -314,7 +314,7 @@ namespace CSMWorld
// WARNING: Assumed that the table view has the same order as std::map
std::map<std::string, int>::const_iterator iter = reactions.begin();
for(int i = 0; i < subRowIndex; ++i)
iter++;
++iter;
switch (subColIndex)
{
case 0: return QString((*iter).first.c_str());
@ -337,7 +337,7 @@ namespace CSMWorld
// WARNING: Assumed that the table view has the same order as std::map
std::map<std::string, int>::iterator iter = reactions.begin();
for(int i = 0; i < subRowIndex; ++i)
iter++;
++iter;
std::string factionId = (*iter).first;
int reaction = (*iter).second;

@ -1153,7 +1153,7 @@ QVariant CSMWorld::CreatureAttributesRefIdAdapter::getNestedData (const RefIdCol
const Record<ESM::Creature>& record =
static_cast<const Record<ESM::Creature>&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Creature)));
const ESM::Creature creature = record.get();
const ESM::Creature& creature = record.get();
if (subColIndex == 0)
return subRowIndex;
@ -1259,7 +1259,7 @@ QVariant CSMWorld::CreatureAttackRefIdAdapter::getNestedData (const RefIdColumn
const Record<ESM::Creature>& record =
static_cast<const Record<ESM::Creature>&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Creature)));
const ESM::Creature creature = record.get();
const ESM::Creature& creature = record.get();
if (subRowIndex < 0 || subRowIndex > 2 || subColIndex < 0 || subColIndex > 2)
throw std::runtime_error ("index out of range");
@ -1337,7 +1337,7 @@ QVariant CSMWorld::CreatureMiscRefIdAdapter::getNestedData (const RefIdColumn *c
const Record<ESM::Creature>& record =
static_cast<const Record<ESM::Creature>&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Creature)));
const ESM::Creature creature = record.get();
const ESM::Creature& creature = record.get();
switch (subColIndex)
{

@ -140,7 +140,7 @@ void CSVWorld::DataDisplayDelegate::settingChanged (const CSMPrefs::Setting *set
}
void CSVWorld::DataDisplayDelegateFactory::add (int enumValue, QString enumName, QString iconFilename)
void CSVWorld::DataDisplayDelegateFactory::add (int enumValue, const QString& enumName, const QString& iconFilename)
{
mIcons.push_back (std::make_pair(enumValue, QIcon(iconFilename)));
EnumDelegateFactory::add(enumValue, enumName);

@ -83,7 +83,7 @@ namespace CSVWorld
protected:
void add (int enumValue,const QString enumName, const QString iconFilename);
void add (int enumValue, const QString& enumName, const QString& iconFilename);
};

@ -674,8 +674,6 @@ void CSVWorld::EditWidget::remake(int row)
{
mNestedTableMapper->addMapping (editor, col);
std::string disString = tree->nestedHeaderData (i, col,
Qt::Horizontal, Qt::DisplayRole).toString().toStdString();
// Need to use Qt::DisplayRole in order to get the correct string
// from CSMWorld::Columns
QLabel* label = new QLabel (tree->nestedHeaderData (i, col,

@ -305,7 +305,6 @@ namespace MWMechanics
else
{
distantCombat = (rangeAttack > 500);
weapRange = 150.f;
}

@ -129,12 +129,14 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos;
float dist = distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]);
const float threshold = 10;
if (storage.mMoving) //Stop when you get close
storage.mMoving = (dist > followDistance);
else
{
const float threshold = 10;
storage.mMoving = (dist > followDistance + threshold);
}
if(!storage.mMoving)
{

@ -506,6 +506,9 @@ namespace MWPhysics
private:
btHeightfieldTerrainShape* mShape;
btCollisionObject* mCollisionObject;
void operator=(const HeightField&);
HeightField(const HeightField&);
};
// --------------------------------------------------------------

@ -366,7 +366,7 @@ public:
for (unsigned int i=0; i<colors->size(); ++i)
{
float alpha = 1.f;
if (mMeshType == 0) alpha = i%2 ? 0.f : 1.f; // this is a cylinder, so every second vertex belongs to the bottom-most row
if (mMeshType == 0) alpha = (i%2) ? 0.f : 1.f; // this is a cylinder, so every second vertex belongs to the bottom-most row
else if (mMeshType == 1)
{
if (i>= 49 && i <= 64) alpha = 0.f; // bottom-most row

@ -110,12 +110,11 @@ Qt::ItemFlags ContentSelectorModel::ContentModel::flags(const QModelIndex &index
bool gamefileChecked = (file->gameFiles().count() == 0);
foreach (const QString &fileName, file->gameFiles())
{
bool depFound = false;
foreach (EsmFile *dependency, mFiles)
{
//compare filenames only. Multiple instances
//of the filename (with different paths) is not relevant here.
depFound = (dependency->fileName().compare(fileName, Qt::CaseInsensitive) == 0);
bool depFound = (dependency->fileName().compare(fileName, Qt::CaseInsensitive) == 0);
if (!depFound)
continue;

@ -17,12 +17,9 @@ namespace ContentSelectorModel
ErrorCode_LoadOrder = 3
};
inline LoadOrderError() : mErrorCode(ErrorCode_None) {};
inline LoadOrderError() : mErrorCode(ErrorCode_None) {}
inline LoadOrderError(ErrorCode errorCode, QString fileName)
{
mErrorCode = errorCode;
mFileName = fileName;
}
: mErrorCode(errorCode), mFileName(fileName) {}
inline ErrorCode errorCode() const { return mErrorCode; }
inline QString fileName() const { return mFileName; }
QString toolTip() const;

@ -47,6 +47,9 @@ namespace osgMyGUI
DataManager* mDataManager;
MyGUI::LogManager* mLogManager;
LogFacility* mLogFacility;
void operator=(const Platform&);
Platform(const Platform&);
};
}

@ -258,7 +258,7 @@ void UVController::apply(osg::StateSet* stateset, osg::NodeVisitor* nv)
mat.setTrans(uTrans, vTrans, 0);
// setting once is enough because all other texture units share the same TexMat (see setDefaults).
if (mTextureUnits.size())
if (!mTextureUnits.empty())
{
osg::TexMat* texMat = static_cast<osg::TexMat*>(stateset->getTextureAttribute(*mTextureUnits.begin(), osg::StateAttribute::TEXMAT));
texMat->setMatrix(mat);

@ -177,7 +177,7 @@ bool RigGeometry::initFromParentSkeleton(osg::NodeVisitor* nv)
}
}
for (Vertex2BoneMap::iterator it = vertex2BoneMap.begin(); it != vertex2BoneMap.end(); it++)
for (Vertex2BoneMap::iterator it = vertex2BoneMap.begin(); it != vertex2BoneMap.end(); ++it)
{
mBone2VertexMap[it->second].push_back(it->first);
}

@ -59,7 +59,7 @@ WorkQueue::~WorkQueue()
{
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
while (mQueue.size())
while (!mQueue.empty())
{
WorkItem* item = mQueue.front();
delete item;
@ -88,7 +88,7 @@ osg::ref_ptr<WorkTicket> WorkQueue::addWorkItem(WorkItem *item)
WorkItem *WorkQueue::removeWorkItem()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
while (!mQueue.size() && !mIsReleased)
while (mQueue.empty() && !mIsReleased)
{
mCondition.wait(&mMutex);
}

Loading…
Cancel
Save