Fix MSVC's C4244 warnings

pull/3075/head
Andrei Kortunov 3 years ago
parent f9d42ed396
commit 963e1b8b3f

@ -603,10 +603,8 @@ if (WIN32)
set(WARNINGS "/W4")
set(WARNINGS_DISABLE
# OpenMW specific warnings
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)
4996 # Function was declared deprecated
)

@ -2,6 +2,12 @@
#define GAME_SOUND_FFMPEG_DECODER_H
#include <stdint.h>
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4244)
#endif
extern "C"
{
#include <libavcodec/avcodec.h>
@ -14,6 +20,10 @@ extern "C"
#include <libswresample/swresample.h>
}
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#include <components/files/constrainedfilestream.hpp>
#include <string>

@ -295,7 +295,7 @@ void Bsa::BSAFile::addFile(const std::string& filename, std::istream& file)
FileStruct newFile;
file.seekg(0, std::ios::end);
newFile.fileSize = file.tellg();
newFile.fileSize = static_cast<uint32_t>(file.tellg());
newFile.setNameInfos(mStringBuf.size(), &mStringBuf);
newFile.hash = getHash(filename);
@ -312,7 +312,7 @@ void Bsa::BSAFile::addFile(const std::string& filename, std::istream& file)
stream.read(buffer.data(), firstFile.fileSize);
stream.seekp(0, std::ios::end);
firstFile.offset = stream.tellp();
firstFile.offset = static_cast<uint32_t>(stream.tellp());
stream.write(buffer.data(), firstFile.fileSize);
@ -320,7 +320,7 @@ void Bsa::BSAFile::addFile(const std::string& filename, std::istream& file)
std::rotate(mFiles.begin(), mFiles.begin() + 1, mFiles.end());
}
stream.seekp(0, std::ios::end);
newFile.offset = stream.tellp();
newFile.offset = static_cast<uint32_t>(stream.tellp());
}
mStringBuf.insert(mStringBuf.end(), filename.begin(), filename.end());

@ -30,7 +30,7 @@ namespace Compiler
if (iter==collection.end())
return -1;
return iter-collection.begin();
return static_cast<int>(iter-collection.begin());
}
bool Locals::search (char type, const std::string& name) const

@ -103,7 +103,7 @@ namespace Compiler
{
blank();
char ch = in.peek();
char ch = static_cast<char>(in.peek());
if (!in.good())
return false;
@ -130,7 +130,7 @@ namespace Compiler
{
std::streampos p_orig = in.tellg();
char ch = in.peek();
char ch = static_cast<char>(in.peek());
if (!in.good())
return false;
@ -156,7 +156,7 @@ namespace Compiler
void blank()
{
std::fill(mData, mData + sizeof(mData), 0);
std::fill(std::begin(mData), std::end(mData), '\0');
mLength = -1;
}

@ -16,17 +16,16 @@ namespace ESM
{
int base = 0;
esm.getHNT(base, "STBA");
mBase = static_cast<float>(base);
mBase = static_cast<T>(base);
int mod = 0;
esm.getHNOT(mod, "STMO");
mMod = static_cast<float>(mod);
mMod = static_cast<T>(mod);
int current = 0;
esm.getHNOT(current, "STCU");
mCurrent = static_cast<float>(current);
mCurrent = static_cast<T>(current);
// mDamage was changed to a float; ensure backwards compatibility
int oldDamage = 0;
esm.getHNOT(oldDamage, "STDA");
mDamage = static_cast<float>(oldDamage);

@ -74,8 +74,8 @@ namespace osgMyGUI
_left -= globalViewSize.width/2;
_top -= globalViewSize.height/2;
_left /= scale;
_top /= scale;
_left = static_cast<int>(_left/scale);
_top = static_cast<int>(_top/scale);
_left += mViewSize.width/2;
_top += mViewSize.height/2;
@ -84,8 +84,8 @@ namespace osgMyGUI
float ScalingLayer::getScaleFactor() const
{
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
float w = viewSize.width;
float h = viewSize.height;
float w = static_cast<float>(viewSize.width);
float h = static_cast<float>(viewSize.height);
float heightScale = (h / mViewSize.height);
float widthScale = (w / mViewSize.width);
@ -103,8 +103,8 @@ namespace osgMyGUI
MyGUI::IntSize globalViewSize = MyGUI::RenderManager::getInstance().getViewSize();
MyGUI::IntSize viewSize = globalViewSize;
float scale = getScaleFactor();
viewSize.width /= scale;
viewSize.height /= scale;
viewSize.width = static_cast<int>(viewSize.width / scale);
viewSize.height = static_cast<int>(viewSize.height / scale);
float hoffset = (globalViewSize.width - mViewSize.width*getScaleFactor())/2.f / static_cast<float>(globalViewSize.width);
float voffset = (globalViewSize.height - mViewSize.height*getScaleFactor())/2.f / static_cast<float>(globalViewSize.height);

@ -4,13 +4,20 @@
#include <stdexcept>
#include <string>
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4244)
#endif
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libswresample/swresample.h>
}
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#include "videostate.hpp"
namespace
@ -276,7 +283,7 @@ size_t MovieAudioDecoder::read(char *stream, size_t len)
mFramePos = std::min<ssize_t>(mFrameSize, sample_skip);
if(sample_skip > 0 || mFrameSize > -sample_skip)
sample_skip -= mFramePos;
sample_skip -= static_cast<int>(mFramePos);
continue;
}

@ -6,6 +6,11 @@
#include <new>
#include <memory>
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4244)
#endif
extern "C"
{
#include <libavutil/avutil.h>
@ -14,6 +19,10 @@ extern "C"
#include <libavutil/channel_layout.h>
}
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#if defined(_WIN32) && !defined(__MINGW32__)
#include <basetsd.h>

@ -9,6 +9,11 @@
#include <osg/Texture2D>
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4244)
#endif
extern "C"
{
#include <libavcodec/avcodec.h>
@ -17,6 +22,10 @@ extern "C"
#include <libavutil/time.h>
}
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
static const char* flushString = "FLUSH";
struct FlushPacket : AVPacket
{

@ -15,6 +15,11 @@ namespace osg
class Texture2D;
}
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4244)
#endif
extern "C"
{
#include <libavcodec/avcodec.h>
@ -28,6 +33,10 @@ extern "C"
#include <libswresample/swresample.h>
}
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#include "videodefs.hpp"
#define VIDEO_PICTURE_QUEUE_SIZE 50

Loading…
Cancel
Save