mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 15:45:33 +00:00
Fix MSVC's C4267 warnings
This commit is contained in:
parent
a70f93a3cf
commit
f9d42ed396
24 changed files with 50 additions and 51 deletions
|
@ -607,7 +607,6 @@ if (WIN32)
|
|||
4100 # Unreferenced formal parameter (-Wunused-parameter)
|
||||
4127 # Conditional expression is constant
|
||||
4244 # Storing value of one type in variable of another (size_t in int, for example)
|
||||
4267 # Conversion from 'size_t' to 'int', possible loss of data
|
||||
4996 # Function was declared deprecated
|
||||
)
|
||||
|
||||
|
|
|
@ -676,7 +676,7 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const boost::filesystem::p
|
|||
}
|
||||
|
||||
if(line[0] == '[') {
|
||||
int pos = line.find(']');
|
||||
int pos = static_cast<int>(line.find(']'));
|
||||
if(pos < 2) {
|
||||
std::cout << "Warning: ini file wrongly formatted (" << line << "). Line ignored." << std::endl;
|
||||
continue;
|
||||
|
@ -686,12 +686,12 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const boost::filesystem::p
|
|||
continue;
|
||||
}
|
||||
|
||||
int comment_pos = line.find(';');
|
||||
int comment_pos = static_cast<int>(line.find(';'));
|
||||
if(comment_pos > 0) {
|
||||
line = line.substr(0,comment_pos);
|
||||
}
|
||||
|
||||
int pos = line.find('=');
|
||||
int pos = static_cast<int>(line.find('='));
|
||||
if(pos < 1) {
|
||||
continue;
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const boost::filesystem::p
|
|||
while (std::getline(file, line)) {
|
||||
|
||||
// we cant say comment by only looking at first char anymore
|
||||
int comment_pos = line.find('#');
|
||||
int comment_pos = static_cast<int>(line.find('#'));
|
||||
if(comment_pos > 0) {
|
||||
line = line.substr(0,comment_pos);
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const boost::filesystem::p
|
|||
continue;
|
||||
}
|
||||
|
||||
int pos = line.find('=');
|
||||
int pos = static_cast<int>(line.find('='));
|
||||
if(pos < 1) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ void CSMDoc::Blacklist::add (CSMWorld::UniversalId::Type type,
|
|||
{
|
||||
std::vector<std::string>& list = mIds[type];
|
||||
|
||||
int size = list.size();
|
||||
size_t size = list.size();
|
||||
|
||||
list.resize (size+ids.size());
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ CSMFilter::NAryNode::NAryNode (const std::vector<std::shared_ptr<Node> >& nodes,
|
|||
|
||||
int CSMFilter::NAryNode::getSize() const
|
||||
{
|
||||
return mNodes.size();
|
||||
return static_cast<int>(mNodes.size());
|
||||
}
|
||||
|
||||
const CSMFilter::Node& CSMFilter::NAryNode::operator[] (int index) const
|
||||
|
|
|
@ -11,7 +11,7 @@ CSMTools::MandatoryIdStage::MandatoryIdStage (const CSMWorld::CollectionBase& id
|
|||
|
||||
int CSMTools::MandatoryIdStage::setup()
|
||||
{
|
||||
return mIds.size();
|
||||
return static_cast<int>(mIds.size());
|
||||
}
|
||||
|
||||
void CSMTools::MandatoryIdStage::perform (int stage, CSMDoc::Messages& messages)
|
||||
|
|
|
@ -24,7 +24,7 @@ int CSMTools::ReportModel::rowCount (const QModelIndex & parent) const
|
|||
if (parent.isValid())
|
||||
return 0;
|
||||
|
||||
return mRows.size();
|
||||
return static_cast<int>(mRows.size());
|
||||
}
|
||||
|
||||
int CSMTools::ReportModel::columnCount (const QModelIndex & parent) const
|
||||
|
@ -140,7 +140,7 @@ bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& p
|
|||
|
||||
void CSMTools::ReportModel::add (const CSMDoc::Message& message)
|
||||
{
|
||||
beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
|
||||
beginInsertRows (QModelIndex(), static_cast<int>(mRows.size()), static_cast<int>(mRows.size()));
|
||||
|
||||
mRows.push_back (message);
|
||||
|
||||
|
@ -176,7 +176,7 @@ void CSMTools::ReportModel::clear()
|
|||
{
|
||||
if (!mRows.empty())
|
||||
{
|
||||
beginRemoveRows (QModelIndex(), 0, mRows.size()-1);
|
||||
beginRemoveRows (QModelIndex(), 0, static_cast<int>(mRows.size())-1);
|
||||
mRows.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ void CSMWorld::IdTable::reorderRows (int baseIndex, const std::vector<int>& newO
|
|||
if (!newOrder.empty())
|
||||
if (mIdCollection->reorderRows (baseIndex, newOrder))
|
||||
emit dataChanged (index (baseIndex, 0),
|
||||
index (baseIndex+newOrder.size()-1, mIdCollection->getColumns()-1));
|
||||
index (baseIndex+static_cast<int>(newOrder.size())-1, mIdCollection->getColumns()-1));
|
||||
}
|
||||
|
||||
std::pair<CSMWorld::UniversalId, std::string> CSMWorld::IdTable::view (int row) const
|
||||
|
|
|
@ -20,13 +20,13 @@ void CSMWorld::Resources::recreate(const VFS::Manager* vfs, const char * const *
|
|||
mFiles.clear();
|
||||
mIndex.clear();
|
||||
|
||||
int baseSize = mBaseDirectory.size();
|
||||
size_t baseSize = mBaseDirectory.size();
|
||||
|
||||
const std::map<std::string, VFS::File*>& index = vfs->getIndex();
|
||||
for (std::map<std::string, VFS::File*>::const_iterator it = index.begin(); it != index.end(); ++it)
|
||||
{
|
||||
std::string filepath = it->first;
|
||||
if (static_cast<int> (filepath.size())<baseSize+1 ||
|
||||
if (filepath.size()<baseSize+1 ||
|
||||
filepath.substr (0, baseSize)!=mBaseDirectory ||
|
||||
(filepath[baseSize]!='/' && filepath[baseSize]!='\\'))
|
||||
continue;
|
||||
|
@ -60,7 +60,7 @@ void CSMWorld::Resources::recreate(const VFS::Manager* vfs, const char * const *
|
|||
|
||||
int CSMWorld::Resources::getSize() const
|
||||
{
|
||||
return mFiles.size();
|
||||
return static_cast<int>(mFiles.size());
|
||||
}
|
||||
|
||||
std::string CSMWorld::Resources::getId (int index) const
|
||||
|
|
|
@ -30,7 +30,7 @@ void CSVDoc::Operations::setProgress (int current, int max, int type, int thread
|
|||
return;
|
||||
}
|
||||
|
||||
int oldCount = mOperations.size();
|
||||
int oldCount = static_cast<int>(mOperations.size());
|
||||
int newCount = oldCount + 1;
|
||||
|
||||
Operation *operation = new Operation (type, this);
|
||||
|
@ -51,7 +51,7 @@ void CSVDoc::Operations::quitOperation (int type)
|
|||
for (std::vector<Operation *>::iterator iter (mOperations.begin()); iter!=mOperations.end(); ++iter)
|
||||
if ((*iter)->getType()==type)
|
||||
{
|
||||
int oldCount = mOperations.size();
|
||||
int oldCount = static_cast<int>(mOperations.size());
|
||||
int newCount = oldCount - 1;
|
||||
|
||||
mLayout->removeItem ((*iter)->getLayout());
|
||||
|
|
|
@ -30,7 +30,7 @@ void CSVWidget::SceneToolRun::updateIcon()
|
|||
|
||||
void CSVWidget::SceneToolRun::updatePanel()
|
||||
{
|
||||
mTable->setRowCount (mProfiles.size());
|
||||
mTable->setRowCount (static_cast<int>(mProfiles.size()));
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ QRect CSVWidget::SceneToolToggle::getIconBox (int index) const
|
|||
int y = index / xMax;
|
||||
int x = index % xMax;
|
||||
|
||||
int total = mButtons.size();
|
||||
int total = static_cast<int>(mButtons.size());
|
||||
|
||||
int actualYIcons = total/xMax;
|
||||
|
||||
|
@ -154,7 +154,7 @@ void CSVWidget::SceneToolToggle::addButton (const std::string& icon, unsigned in
|
|||
desc.mMask = mask;
|
||||
desc.mSmallIcon = smallIcon;
|
||||
desc.mName = name;
|
||||
desc.mIndex = mButtons.size();
|
||||
desc.mIndex = static_cast<int>(mButtons.size());
|
||||
|
||||
mButtons.insert (std::make_pair (button, desc));
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ void CSVWidget::SceneToolToggle2::addButton (unsigned int id, unsigned int mask,
|
|||
desc.mButtonId = id;
|
||||
desc.mMask = mask;
|
||||
desc.mName = name;
|
||||
desc.mIndex = mButtons.size();
|
||||
desc.mIndex = static_cast<int>(mButtons.size());
|
||||
|
||||
mButtons.insert (std::make_pair (button, desc));
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ QValidator::State CSVWorld::IdValidator::validate (QString& input, int& pos) con
|
|||
|
||||
if (!mNamespace.empty())
|
||||
{
|
||||
std::string namespace_ = input.left (mNamespace.size()).toUtf8().constData();
|
||||
std::string namespace_ = input.left (static_cast<int>(mNamespace.size())).toUtf8().constData();
|
||||
|
||||
if (Misc::StringUtils::lowerCase (namespace_)!=mNamespace)
|
||||
return QValidator::Invalid; // incorrect namespace
|
||||
|
|
|
@ -43,7 +43,7 @@ void BSAFile::fail(const std::string &msg)
|
|||
BSAFile::Hash getHash(const std::string& name)
|
||||
{
|
||||
BSAFile::Hash hash;
|
||||
unsigned l = (name.size() >> 1);
|
||||
unsigned l = (static_cast<unsigned>(name.size()) >> 1);
|
||||
unsigned sum, off, temp, i, n;
|
||||
|
||||
for (sum = off = i = 0; i < l; i++) {
|
||||
|
@ -163,7 +163,7 @@ void BSAFile::readHeader()
|
|||
{
|
||||
FileStruct &fs = mFiles[i];
|
||||
fs.fileSize = offsets[i*2];
|
||||
fs.offset = offsets[i*2+1] + fileDataOffset;
|
||||
fs.offset = static_cast<uint32_t>(offsets[i*2+1] + fileDataOffset);
|
||||
auto namesOffset = offsets[2*filenum+i];
|
||||
fs.setNameInfos(namesOffset, &mStringBuf);
|
||||
fs.hash = hashes[i];
|
||||
|
@ -203,11 +203,11 @@ void Bsa::BSAFile::writeHeader()
|
|||
uint32_t head[3];
|
||||
head[0] = 0x100;
|
||||
auto fileDataOffset = mFiles.empty() ? 12 : mFiles.front().offset;
|
||||
head[1] = fileDataOffset - 12 - 8*mFiles.size();
|
||||
head[1] = static_cast<uint32_t>(fileDataOffset - 12 - 8*mFiles.size());
|
||||
|
||||
output.seekp(0, std::ios_base::end);
|
||||
|
||||
head[2] = mFiles.size();
|
||||
head[2] = static_cast<uint32_t>(mFiles.size());
|
||||
output.seekp(0);
|
||||
output.write(reinterpret_cast<char*>(head), 12);
|
||||
|
||||
|
@ -239,9 +239,9 @@ int BSAFile::getIndex(const char *str) const
|
|||
if(it == mLookup.end())
|
||||
return -1;
|
||||
|
||||
int res = it->second;
|
||||
assert(res >= 0 && (size_t)res < mFiles.size());
|
||||
return res;
|
||||
size_t res = it->second;
|
||||
assert(res >= 0 && res < mFiles.size());
|
||||
return static_cast<int>(res);
|
||||
}
|
||||
|
||||
/// Open an archive file.
|
||||
|
@ -300,7 +300,7 @@ void Bsa::BSAFile::addFile(const std::string& filename, std::istream& file)
|
|||
newFile.hash = getHash(filename);
|
||||
|
||||
if(mFiles.empty())
|
||||
newFile.offset = newStartOfDataBuffer;
|
||||
newFile.offset = static_cast<uint32_t>(newStartOfDataBuffer);
|
||||
else
|
||||
{
|
||||
std::vector<char> buffer;
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
void setNameInfos(size_t index,
|
||||
std::vector<char>* stringBuf
|
||||
) {
|
||||
namesOffset = index;
|
||||
namesOffset = static_cast<uint32_t>(index);
|
||||
namesBuffer = stringBuf;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ protected:
|
|||
the files[] vector above. The iltstr ensures that file name
|
||||
checks are case insensitive.
|
||||
*/
|
||||
typedef std::map<std::string, int, iltstr> Lookup;
|
||||
typedef std::map<std::string, size_t, iltstr> Lookup;
|
||||
Lookup mLookup;
|
||||
|
||||
/// Error handling
|
||||
|
|
|
@ -39,14 +39,14 @@ namespace Compiler
|
|||
Codes block;
|
||||
|
||||
if (iter!=mIfCode.rbegin())
|
||||
Generator::jump (iter->second, codes.size()+1);
|
||||
Generator::jump (iter->second, static_cast<int>(codes.size()+1));
|
||||
|
||||
if (!iter->first.empty())
|
||||
{
|
||||
// if or elseif
|
||||
std::copy (iter->first.begin(), iter->first.end(),
|
||||
std::back_inserter (block));
|
||||
Generator::jumpOnZero (block, iter->second.size()+1);
|
||||
Generator::jumpOnZero (block, static_cast<int>(iter->second.size()+1));
|
||||
}
|
||||
|
||||
std::copy (iter->second.begin(), iter->second.end(),
|
||||
|
@ -113,7 +113,7 @@ namespace Compiler
|
|||
|
||||
Codes skip;
|
||||
|
||||
Generator::jumpOnZero (skip, mCodeBlock.size()+loop.size()+1);
|
||||
Generator::jumpOnZero (skip, static_cast<int> (mCodeBlock.size()+loop.size()+1));
|
||||
|
||||
std::copy (skip.begin(), skip.end(), std::back_inserter (mCode));
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ namespace Compiler
|
|||
{
|
||||
int Literals::getIntegerSize() const
|
||||
{
|
||||
return mIntegers.size() * sizeof (Interpreter::Type_Integer);
|
||||
return static_cast<int>(mIntegers.size() * sizeof (Interpreter::Type_Integer));
|
||||
}
|
||||
|
||||
int Literals::getFloatSize() const
|
||||
{
|
||||
return mFloats.size() * sizeof (Interpreter::Type_Float);
|
||||
return static_cast<int>(mFloats.size() * sizeof (Interpreter::Type_Float));
|
||||
}
|
||||
|
||||
int Literals::getStringSize() const
|
||||
|
@ -41,11 +41,11 @@ namespace Compiler
|
|||
|
||||
code.resize (size+stringBlockSize/4);
|
||||
|
||||
int offset = 0;
|
||||
size_t offset = 0;
|
||||
|
||||
for (const auto & mString : mStrings)
|
||||
{
|
||||
int stringSize = mString.size()+1;
|
||||
size_t stringSize = mString.size()+1;
|
||||
|
||||
std::copy (mString.c_str(), mString.c_str()+stringSize,
|
||||
reinterpret_cast<char *> (&code[size]) + offset);
|
||||
|
|
|
@ -130,12 +130,12 @@ namespace Crash
|
|||
DWORD copied = 0;
|
||||
do {
|
||||
executablePath.resize(executablePath.size() + MAX_PATH);
|
||||
copied = GetModuleFileNameW(nullptr, executablePath.data(), executablePath.size());
|
||||
copied = GetModuleFileNameW(nullptr, executablePath.data(), static_cast<DWORD>(executablePath.size()));
|
||||
} while (copied >= executablePath.size());
|
||||
executablePath.resize(copied);
|
||||
|
||||
memset(mShm->mStartup.mLogFilePath, 0, sizeof(mShm->mStartup.mLogFilePath));
|
||||
int length = crashLogPath.length();
|
||||
size_t length = crashLogPath.length();
|
||||
if (length >= MAX_LONG_PATH) length = MAX_LONG_PATH - 1;
|
||||
strncpy(mShm->mStartup.mLogFilePath, crashLogPath.c_str(), length);
|
||||
mShm->mStartup.mLogFilePath[length] = '\0';
|
||||
|
|
|
@ -203,9 +203,9 @@ void ESMReader::getSubName()
|
|||
}
|
||||
|
||||
// reading the subrecord data anyway.
|
||||
const size_t subNameSize = mCtx.subName.data_size();
|
||||
const int subNameSize = static_cast<int>(mCtx.subName.data_size());
|
||||
getExact(mCtx.subName.rw_data(), subNameSize);
|
||||
mCtx.leftRec -= subNameSize;
|
||||
mCtx.leftRec -= static_cast<uint32_t>(subNameSize);
|
||||
}
|
||||
|
||||
void ESMReader::skipHSub()
|
||||
|
@ -327,7 +327,7 @@ std::string ESMReader::getString(int size)
|
|||
char *ptr = mBuffer.data();
|
||||
getExact(ptr, size);
|
||||
|
||||
size = strnlen(ptr, size);
|
||||
size = static_cast<int>(strnlen(ptr, size));
|
||||
|
||||
// Convert to UTF8 and return
|
||||
if (mEncoder)
|
||||
|
|
|
@ -217,7 +217,7 @@ namespace ESM
|
|||
if (mCounting && !mRecords.empty())
|
||||
{
|
||||
for (std::list<RecordData>::iterator it = mRecords.begin(); it != mRecords.end(); ++it)
|
||||
it->size += size;
|
||||
it->size += static_cast<uint32_t>(size);
|
||||
}
|
||||
|
||||
mStream->write(data, size);
|
||||
|
|
|
@ -326,7 +326,7 @@ void LowLevelFile::seek (size_t position)
|
|||
{
|
||||
assert (mHandle != INVALID_HANDLE_VALUE);
|
||||
|
||||
if (SetFilePointer (mHandle, position, nullptr, SEEK_SET) == INVALID_SET_FILE_POINTER)
|
||||
if (SetFilePointer (mHandle, static_cast<LONG>(position), nullptr, SEEK_SET) == INVALID_SET_FILE_POINTER)
|
||||
if (GetLastError () != NO_ERROR)
|
||||
throw std::runtime_error ("A seek operation on a file failed.");
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ size_t LowLevelFile::read (void * data, size_t size)
|
|||
|
||||
DWORD read;
|
||||
|
||||
if (!ReadFile (mHandle, data, size, &read, nullptr))
|
||||
if (!ReadFile (mHandle, data, static_cast<DWORD>(size), &read, nullptr))
|
||||
throw std::runtime_error ("A read operation on a file failed.");
|
||||
|
||||
return read;
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Interpreter
|
|||
|
||||
for (; index; --index)
|
||||
{
|
||||
offset += std::strlen (literalBlock+offset) + 1;
|
||||
offset += static_cast<int>(std::strlen (literalBlock+offset)) + 1;
|
||||
if (offset / 4 >= static_cast<int> (mCode[3]))
|
||||
throw std::out_of_range("out of range");
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace Gui
|
|||
|
||||
unsigned int MWList::getItemCount()
|
||||
{
|
||||
return mItems.size();
|
||||
return static_cast<unsigned int>(mItems.size());
|
||||
}
|
||||
|
||||
std::string MWList::getItemNameAt(unsigned int at)
|
||||
|
|
|
@ -255,7 +255,7 @@ size_t MovieAudioDecoder::read(char *stream, size_t len)
|
|||
size_t sampleSize = av_get_bytes_per_sample(mOutputSampleFormat);
|
||||
char* data[1];
|
||||
data[0] = stream;
|
||||
av_samples_set_silence((uint8_t**)data, 0, len/sampleSize, 1, mOutputSampleFormat);
|
||||
av_samples_set_silence((uint8_t**)data, 0, static_cast<int>(len/sampleSize), 1, mOutputSampleFormat);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue