Fixed some VS warnings

Thanks to Fraggy again !


Former-commit-id: bd0eea66714701b065892d8b69d576e7b3615dd2
This commit is contained in:
Lynix 2013-09-21 00:10:10 +02:00
parent 6440d38c5c
commit 3167531b39
19 changed files with 95 additions and 73 deletions

View File

@ -54,7 +54,7 @@ class NAZARA_API NzThread::Id
NAZARA_API friend bool operator>(const Id& lhs, const Id& rhs);
NAZARA_API friend bool operator>=(const Id& lhs, const Id& rhs);
NAZARA_API friend bool operator<<(std::ostream& o, const Id& id);
NAZARA_API friend std::ostream& operator<<(std::ostream& o, const Id& id);
private:
Id(NzThreadImpl* thread);

View File

@ -26,7 +26,7 @@ namespace
sf_count_t Read(void* ptr, sf_count_t count, void* user_data)
{
NzInputStream* stream = static_cast<NzInputStream*>(user_data);
return stream->Read(ptr, count);
return static_cast<sf_count_t>(stream->Read(ptr, static_cast<std::size_t>(count)));
}
sf_count_t Seek(sf_count_t offset, int whence, void* user_data)
@ -35,7 +35,7 @@ namespace
switch (whence)
{
case SEEK_CUR:
stream->Read(nullptr, offset);
stream->Read(nullptr, static_cast<std::size_t>(offset));
break;
case SEEK_END:
@ -113,7 +113,7 @@ namespace
if (infos.format & SF_FORMAT_VORBIS)
sf_command(file, SFC_SET_SCALE_FLOAT_INT_READ, nullptr, SF_TRUE);
unsigned int sampleCount = infos.frames*infos.channels;
sf_count_t sampleCount = infos.frames*infos.channels;
std::unique_ptr<nzInt16[]> samples(new nzInt16[sampleCount]);
if (sf_read_short(file, samples.get(), sampleCount) != sampleCount)
@ -124,7 +124,7 @@ namespace
return false;
}
if (!soundBuffer->Create(format, infos.frames*infos.channels, infos.samplerate, samples.get()))
if (!soundBuffer->Create(format, static_cast<unsigned int>(sampleCount), infos.samplerate, samples.get()))
{
sf_close(file);
NazaraError("Failed to create sound buffer");

View File

@ -237,7 +237,7 @@ std::size_t NzFile::Read(void* buffer, std::size_t size)
m_impl->SetCursorPos(NzFile::AtCurrent, size);
return m_impl->GetCursorPos()-currentPos;
return static_cast<std::size_t>(m_impl->GetCursorPos()-currentPos);
}
}

View File

@ -136,7 +136,7 @@ namespace
* On little-endian machines, we can process properly aligned
* data without copying it.
*/
if (!(data - static_cast<const nzUInt8*>(nullptr)) & 3)
if (!((data - static_cast<const nzUInt8*>(nullptr)) & 3))
{
/* data are properly aligned */
X = reinterpret_cast<const nzUInt32*>(data);

View File

@ -135,7 +135,7 @@ bool operator>=(const NzThread::Id& lhs, const NzThread::Id& rhs)
return lhs.m_id >= rhs.m_id;
}
bool operator<<(std::ostream& o, const NzThread::Id& id)
std::ostream& operator<<(std::ostream& o, const NzThread::Id& id)
{
o << id.m_id;
return o;

View File

@ -306,9 +306,9 @@ void NzCamera::UpdateViewport() const
m_projectionMatrixUpdated = false;
}
m_viewport.x = width * m_targetRegion.x;
m_viewport.y = height * m_targetRegion.y;
m_viewport.width = vWidth;
m_viewport.height = vHeight;
m_viewport.x = static_cast<int>(width * m_targetRegion.x);
m_viewport.y = static_cast<int>(height * m_targetRegion.y);
m_viewport.width = static_cast<int>(vWidth);
m_viewport.height = static_cast<int>(vHeight);
m_viewportUpdated = true;
}

View File

@ -52,7 +52,7 @@ bool NzMTLParser::Parse()
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->ambient = NzColor(r*255.f, g*255.f, b*255.f);
currentMaterial->ambient = NzColor(static_cast<nzUInt8>(r*255.f), static_cast<nzUInt8>(g*255.f), static_cast<nzUInt8>(b*255.f));
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
@ -67,7 +67,7 @@ bool NzMTLParser::Parse()
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->diffuse = NzColor(r*255.f, g*255.f, b*255.f);
currentMaterial->diffuse = NzColor(static_cast<nzUInt8>(r*255.f), static_cast<nzUInt8>(g*255.f), static_cast<nzUInt8>(b*255.f));
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
@ -82,7 +82,7 @@ bool NzMTLParser::Parse()
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->specular = NzColor(r*255.f, g*255.f, b*255.f);
currentMaterial->specular = NzColor(static_cast<nzUInt8>(r*255.f), static_cast<nzUInt8>(g*255.f), static_cast<nzUInt8>(b*255.f));
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else

View File

@ -277,9 +277,9 @@ void NzView::UpdateViewport() const
unsigned int width = m_target->GetWidth();
unsigned int height = std::max(m_target->GetHeight(), 1U);
m_viewport.x = width * m_targetRegion.x;
m_viewport.y = height * m_targetRegion.y;
m_viewport.width = width * m_targetRegion.width;
m_viewport.height = height * m_targetRegion.height;
m_viewport.x = static_cast<int>(width * m_targetRegion.x);
m_viewport.y = static_cast<int>(height * m_targetRegion.y);
m_viewport.width = static_cast<int>(width * m_targetRegion.width);
m_viewport.height = static_cast<int>(height * m_targetRegion.height);
m_viewportUpdated = true;
}

View File

@ -180,7 +180,7 @@ bool NzLuaInstance::Compare(int index1, int index2, nzLuaComparison comparison)
}
#endif
return lua_compare(m_state, index1, index2, s_comparisons[comparison]);
return (lua_compare(m_state, index1, index2, s_comparisons[comparison]) == 1);
}
void NzLuaInstance::Compute(nzLuaOperation operation)
@ -236,7 +236,7 @@ bool NzLuaInstance::ExecuteFromFile(const NzString& filePath)
return false;
}
unsigned int length = file.GetSize();
unsigned int length = static_cast<unsigned int>(file.GetSize());
NzString source;
source.Resize(length);
@ -331,7 +331,7 @@ void NzLuaInstance::GetMetatable(const NzString& tname) const
bool NzLuaInstance::GetMetatable(int index) const
{
return lua_getmetatable(m_state, index);
return lua_getmetatable(m_state, index) == 1;
}
unsigned int NzLuaInstance::GetStackTop() const
@ -411,34 +411,34 @@ bool NzLuaInstance::IsOfType(int index, nzLuaType type) const
switch (type)
{
case nzLuaType_Boolean:
return lua_isboolean(m_state, index);
return lua_isboolean(m_state, index) == 1;
case nzLuaType_Function:
return lua_isfunction(m_state, index);
return lua_isfunction(m_state, index) == 1;
case nzLuaType_LightUserdata:
return lua_islightuserdata(m_state, index);
return lua_islightuserdata(m_state, index) == 1;
case nzLuaType_Nil:
return lua_isnil(m_state, index);
return lua_isnil(m_state, index) == 1;
case nzLuaType_None:
return lua_isnone(m_state, index);
return lua_isnone(m_state, index) == 1;
case nzLuaType_Number:
return lua_isnumber(m_state, index);
return lua_isnumber(m_state, index) == 1;
case nzLuaType_String:
return lua_isstring(m_state, index);
return lua_isstring(m_state, index) == 1;
case nzLuaType_Table:
return lua_istable(m_state, index);
return lua_istable(m_state, index) == 1;
case nzLuaType_Thread:
return lua_isthread(m_state, index);
return lua_isthread(m_state, index) == 1;
case nzLuaType_Userdata:
return lua_isuserdata(m_state, index);
return lua_isuserdata(m_state, index) == 1;
}
NazaraError("Lua type unhandled (0x" + NzString::Number(type, 16) + ')');
@ -473,7 +473,7 @@ void NzLuaInstance::MoveTo(NzLuaInstance* instance, int n)
bool NzLuaInstance::NewMetatable(const char* str)
{
return luaL_newmetatable(m_state, str);
return luaL_newmetatable(m_state, str) == 1;
}
bool NzLuaInstance::NewMetatable(const NzString& str)
@ -483,12 +483,12 @@ bool NzLuaInstance::NewMetatable(const NzString& str)
bool NzLuaInstance::Next(int index)
{
return lua_next(m_state, index);
return lua_next(m_state, index) == 1;
}
void NzLuaInstance::Pop(unsigned int n)
{
lua_pop(m_state, n);
lua_pop(m_state, static_cast<int>(n));
}
void NzLuaInstance::PushBoolean(bool value)
@ -639,7 +639,7 @@ void NzLuaInstance::SetTimeLimit(nzUInt32 timeLimit)
bool NzLuaInstance::ToBoolean(int index) const
{
return lua_toboolean(m_state, index);
return lua_toboolean(m_state, index) == 1;
}
int NzLuaInstance::ToInteger(int index, bool* succeeded) const
@ -648,9 +648,9 @@ int NzLuaInstance::ToInteger(int index, bool* succeeded) const
int result = lua_tointegerx(m_state, index, &success);
if (succeeded)
*succeeded = success;
*succeeded = (success == 1);
return result;
return result == 1;
}
double NzLuaInstance::ToNumber(int index, bool* succeeded) const
@ -659,9 +659,9 @@ double NzLuaInstance::ToNumber(int index, bool* succeeded) const
double result = lua_tonumberx(m_state, index, &success);
if (succeeded)
*succeeded = success;
*succeeded = (success == 1);
return result;
return result == 1;
}
const char* NzLuaInstance::ToString(int index, std::size_t* length) const
@ -675,9 +675,9 @@ unsigned int NzLuaInstance::ToUnsigned(int index, bool* succeeded) const
unsigned int result = lua_tounsignedx(m_state, index, &success);
if (succeeded)
*succeeded = success;
*succeeded = (success == 1);
return result;
return result == 1;
}
void* NzLuaInstance::ToUserdata(int index) const

View File

@ -9,8 +9,17 @@
NzPerlin2D::NzPerlin2D()
{
int grad2Temp[][2] = {{1,1},{-1,1},{1,-1},{-1,-1},
{1,0},{-1,0},{0,1},{0,-1}};
float grad2Temp[][2] = {
{1.f,1.f},
{-1.f,1.f},
{1.f,-1.f},
{-1.f,-1.f},
{1.f,0.f},
{-1.f,0.f},
{0.f,1.f},
{0.f,-1.f}
};
for(int i(0) ; i < 8 ; ++i)
for(int j(0) ; j < 2 ; ++j)

View File

@ -12,9 +12,22 @@ NzSimplex3D::NzSimplex3D()
SkewCoeff3D = 1/3.f;
UnskewCoeff3D = 1/6.f;
int grad3Temp[][3] = {{1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0},
{1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1},
{0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}};
float grad3Temp[][3] = {
{1.f,1.f,0.f},
{-1.f,1.f,0.f},
{1.f,-1.f,0.f},
{-1.f,-1.f,0.f},
{1.f,0.f,1.f},
{-1.f,0.f,1.f},
{1.f,0.f,-1.f},
{-1.f,0.f,-1.f},
{0.f,1.f,1.f},
{0.f,-1.f,1.f},
{0.f,1.f,-1.f},
{0.f,-1.f,-1.f}
};
for(int i(0) ; i < 12 ; ++i)
for(int j(0) ; j < 3 ; ++j)

View File

@ -28,16 +28,16 @@ NzSimplex4D::NzSimplex4D()
for(int j(0) ; j < 4 ; ++j)
lookupTable4D[i][j] = lookupTemp4D[i][j];
int grad4Temp[][4] =
float grad4Temp[][4] =
{
{0,1,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ile(nzShaderType type, const NzString& file
return false;
}
unsigned int length = file.GetSize();
unsigned int length = static_cast<unsigned int>(file.GetSize());
NzString source;
source.Resize(length);

View File

@ -110,7 +110,7 @@ const NzShaderProgram* NzShaderProgramManager::Get(const NzShaderProgramManagerP
{
NazaraDebug("File found");
unsigned int size = shaderFile.GetSize();
unsigned int size = static_cast<unsigned int>(shaderFile.GetSize());
NzByteArray binary;
binary.Resize(size);

View File

@ -19,7 +19,7 @@ NzContextImpl::NzContextImpl()
bool NzContextImpl::Activate()
{
return wglMakeCurrent(m_deviceContext, m_context);
return wglMakeCurrent(m_deviceContext, m_context) == TRUE;
}
bool NzContextImpl::Create(NzContextParameters& parameters)
@ -74,7 +74,7 @@ bool NzContextImpl::Create(NzContextParameters& parameters)
do
{
valid = wglChoosePixelFormat(m_deviceContext, attributes, nullptr, 1, &pixelFormat, &numFormats);
valid = (wglChoosePixelFormat(m_deviceContext, attributes, nullptr, 1, &pixelFormat, &numFormats) == TRUE);
}
while ((!valid || numFormats == 0) && --attributes[19] > 0);
@ -229,6 +229,6 @@ void NzContextImpl::SwapBuffers()
bool NzContextImpl::Desactivate()
{
return wglMakeCurrent(nullptr, nullptr);
return wglMakeCurrent(nullptr, nullptr) == TRUE;
}

View File

@ -1279,9 +1279,9 @@ nzUInt8 NzImage::GetMaxLevel(unsigned int width, unsigned int height, unsigned i
{
static const float invLog2 = 1.f/std::log(2.f);
unsigned int widthLevel = invLog2 * std::log(static_cast<float>(width));
unsigned int heightLevel = invLog2 * std::log(static_cast<float>(height));
unsigned int depthLevel = invLog2 * std::log(static_cast<float>(depth));
unsigned int widthLevel = static_cast<unsigned int>(invLog2 * std::log(static_cast<float>(width)));
unsigned int heightLevel = static_cast<unsigned int>(invLog2 * std::log(static_cast<float>(height)));
unsigned int depthLevel = static_cast<unsigned int>(invLog2 * std::log(static_cast<float>(depth)));
return std::max(std::max(std::max(widthLevel, heightLevel), depthLevel), 1U);
}

View File

@ -217,7 +217,7 @@ namespace
nzUInt8 palette[768];
/* the palette is contained in the last 769 bytes of the file */
unsigned int curPos = stream.GetCursorPos();
nzUInt64 curPos = stream.GetCursorPos();
stream.SetCursorPos(stream.GetSize()-769);
nzUInt8 magic;
if (!stream.Read(&magic, 1))

View File

@ -11,7 +11,7 @@ namespace
{
inline nzUInt8 c4to5(nzUInt8 c)
{
return c * (31.f/15.f);
return static_cast<nzUInt8>(c * (31.f/15.f));
}
inline nzUInt8 c4to8(nzUInt8 c)
@ -21,12 +21,12 @@ namespace
inline nzUInt8 c5to4(nzUInt8 c)
{
return c * (15.f/31.f);
return static_cast<nzUInt8>(c * (15.f/31.f));
}
inline nzUInt8 c5to8(nzUInt8 c)
{
return c * (255.f/31.f);
return static_cast<nzUInt8>(c * (255.f/31.f));
}
inline nzUInt8 c8to4(nzUInt8 c)
@ -36,7 +36,7 @@ namespace
inline nzUInt8 c8to5(nzUInt8 c)
{
return c * (31.f/255.f);
return static_cast<nzUInt8>(c * (31.f/255.f));
}
template<nzPixelFormat from, nzPixelFormat to>

View File

@ -281,12 +281,12 @@ void NzWindowImpl::IgnoreNextMouseEvent(int mouseX, int mouseY)
bool NzWindowImpl::IsMinimized() const
{
return IsIconic(m_handle);
return IsIconic(m_handle) == TRUE;
}
bool NzWindowImpl::IsVisible() const
{
return IsWindowVisible(m_handle);
return IsWindowVisible(m_handle) == TRUE;
}
void NzWindowImpl::ProcessEvents(bool block)
@ -800,7 +800,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA
{
NzEvent event;
event.type = nzEventType_MouseWheelMoved;
event.mouseWheel.delta = m_scrolling/WHEEL_DELTA;
event.mouseWheel.delta = static_cast<float>(m_scrolling/WHEEL_DELTA);
m_parent->PushEvent(event);
m_scrolling %= WHEEL_DELTA;
@ -1001,7 +1001,7 @@ bool NzWindowImpl::Initialize()
windowClass.lpszMenuName = nullptr;
windowClass.style = CS_DBLCLKS; // Gestion du double-clic
return RegisterClassW(&windowClass);
return RegisterClassW(&windowClass) != 0;
}
void NzWindowImpl::Uninitialize()