Fix some GCC warnings

Former-commit-id: 31c8460b4656c29ac165d7aa28f335851f2565df
This commit is contained in:
Lynix 2016-05-25 13:52:10 +02:00
parent 840b03691a
commit 8a3339badf
19 changed files with 113 additions and 54 deletions

View File

@ -11,8 +11,8 @@ namespace Ndk
inline CameraComponent::CameraComponent() : inline CameraComponent::CameraComponent() :
m_projectionType(Nz::ProjectionType_Perspective), m_projectionType(Nz::ProjectionType_Perspective),
m_targetRegion(0.f, 0.f, 1.f, 1.f), m_targetRegion(0.f, 0.f, 1.f, 1.f),
m_size(0.f),
m_target(nullptr), m_target(nullptr),
m_size(0.f),
m_frustumUpdated(false), m_frustumUpdated(false),
m_projectionMatrixUpdated(false), m_projectionMatrixUpdated(false),
m_viewMatrixUpdated(false), m_viewMatrixUpdated(false),
@ -30,8 +30,8 @@ namespace Ndk
AbstractViewer(camera), AbstractViewer(camera),
m_projectionType(camera.m_projectionType), m_projectionType(camera.m_projectionType),
m_targetRegion(camera.m_targetRegion), m_targetRegion(camera.m_targetRegion),
m_size(camera.m_size),
m_target(nullptr), m_target(nullptr),
m_size(camera.m_size),
m_frustumUpdated(false), m_frustumUpdated(false),
m_projectionMatrixUpdated(false), m_projectionMatrixUpdated(false),
m_viewMatrixUpdated(false), m_viewMatrixUpdated(false),

View File

@ -8,6 +8,7 @@ namespace Ndk
{ {
inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) : inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) :
Component(graphicsComponent), Component(graphicsComponent),
HandledObject(graphicsComponent),
m_boundingVolume(graphicsComponent.m_boundingVolume), m_boundingVolume(graphicsComponent.m_boundingVolume),
m_transformMatrix(graphicsComponent.m_transformMatrix), m_transformMatrix(graphicsComponent.m_transformMatrix),
m_boundingVolumeUpdated(graphicsComponent.m_boundingVolumeUpdated), m_boundingVolumeUpdated(graphicsComponent.m_boundingVolumeUpdated),
@ -41,7 +42,7 @@ namespace Ndk
r.data.renderOrder = renderOrder; r.data.renderOrder = renderOrder;
r.renderable = std::move(renderable); r.renderable = std::move(renderable);
r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1)); r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1));
InvalidateBoundingVolume(); InvalidateBoundingVolume();
} }

View File

@ -84,8 +84,12 @@ namespace Nz
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag<FontParams>) inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag<FontParams>)
{ {
NazaraUnused(params);
instance.CheckType(index, Nz::LuaType_Table); instance.CheckType(index, Nz::LuaType_Table);
// Structure is empty for now
return 1; return 1;
} }

View File

@ -145,6 +145,7 @@ namespace Ndk
{ {
case Nz::Keyboard::Down: case Nz::Keyboard::Down:
case Nz::Keyboard::Up: case Nz::Keyboard::Up:
{
if (event.key.code == Nz::Keyboard::Up) if (event.key.code == Nz::Keyboard::Up)
m_historyPosition = std::min<std::size_t>(m_commandHistory.size(), m_historyPosition + 1); m_historyPosition = std::min<std::size_t>(m_commandHistory.size(), m_historyPosition + 1);
else else
@ -159,6 +160,10 @@ namespace Ndk
m_inputDrawer.SetText(s_inputPrefix + text); m_inputDrawer.SetText(s_inputPrefix + text);
m_inputTextSprite->Update(m_inputDrawer); m_inputTextSprite->Update(m_inputDrawer);
break; break;
}
default:
break;
} }
break; break;
} }

View File

@ -29,8 +29,8 @@ namespace Ndk
// SDK // SDK
application("Application"), application("Application"),
nodeComponent("NodeComponent"),
entityClass("Entity"), entityClass("Entity"),
nodeComponent("NodeComponent"),
velocityComponent("VelocityComponent"), velocityComponent("VelocityComponent"),
worldClass("World") worldClass("World")
@ -39,9 +39,9 @@ namespace Ndk
// Audio // Audio
musicClass("Music"), musicClass("Music"),
soundClass("Sound"),
soundBuffer("SoundBuffer"), soundBuffer("SoundBuffer"),
soundEmitter("SoundEmitter"), soundEmitter("SoundEmitter"),
soundClass("Sound"),
// Graphics // Graphics
instancedRenderable("InstancedRenderable"), instancedRenderable("InstancedRenderable"),

View File

@ -76,6 +76,8 @@ namespace Ndk
/*********************************** Nz::SoundBuffer **********************************/ /*********************************** Nz::SoundBuffer **********************************/
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance) soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance)
{ {
NazaraUnused(lua);
Nz::PlacementNew(instance, Nz::SoundBuffer::New()); Nz::PlacementNew(instance, Nz::SoundBuffer::New());
return true; return true;
}); });
@ -115,16 +117,16 @@ namespace Ndk
return 1; return 1;
}); });
soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& soundBuffer) -> int soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance) -> int
{ {
Nz::StringStream stream("SoundBuffer("); Nz::StringStream stream("SoundBuffer(");
if (soundBuffer->IsValid()) if (instance->IsValid())
{ {
Nz::String filePath = soundBuffer->GetFilePath(); Nz::String filePath = instance->GetFilePath();
if (!filePath.IsEmpty()) if (!filePath.IsEmpty())
stream << "File: " << filePath << ", "; stream << "File: " << filePath << ", ";
stream << "Duration: " << soundBuffer->GetDuration() / 1000.f << "s"; stream << "Duration: " << instance->GetDuration() / 1000.f << "s";
} }
stream << ')'; stream << ')';
@ -148,17 +150,17 @@ namespace Ndk
soundEmitter.BindMethod("IsLooping", &Nz::SoundEmitter::IsLooping); soundEmitter.BindMethod("IsLooping", &Nz::SoundEmitter::IsLooping);
soundEmitter.BindMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized); soundEmitter.BindMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized);
soundEmitter.BindMethod("Pause", &Nz::SoundEmitter::Pause); soundEmitter.BindMethod("Pause", &Nz::SoundEmitter::Pause);
soundEmitter.BindMethod("Play", &Nz::SoundEmitter::Play); soundEmitter.BindMethod("Play", &Nz::SoundEmitter::Play);
soundEmitter.BindMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation); soundEmitter.BindMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation);
soundEmitter.BindMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance); soundEmitter.BindMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance);
soundEmitter.BindMethod("SetPitch", &Nz::SoundEmitter::SetPitch); soundEmitter.BindMethod("SetPitch", &Nz::SoundEmitter::SetPitch);
soundEmitter.BindMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition); soundEmitter.BindMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition);
soundEmitter.BindMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity); soundEmitter.BindMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity);
soundEmitter.BindMethod("SetVolume", &Nz::SoundEmitter::SetVolume); soundEmitter.BindMethod("SetVolume", &Nz::SoundEmitter::SetVolume);
soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop); soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop);
} }

View File

@ -238,9 +238,15 @@ namespace Ndk
case 'h': case 'h':
lua.Push(instance.height); lua.Push(instance.height);
return true; return true;
default:
break;
} }
break; break;
} }
default:
break;
} }
return false; return false;
@ -290,6 +296,9 @@ namespace Ndk
} }
break; break;
} }
default:
break;
} }
return false; return false;
@ -313,7 +322,7 @@ namespace Ndk
Nz::PlacementNew(quaternion, *static_cast<Nz::Quaterniond*>(lua.ToUserdata(1))); Nz::PlacementNew(quaternion, *static_cast<Nz::Quaterniond*>(lua.ToUserdata(1)));
else else
break; break;
return true; return true;
} }
@ -389,6 +398,9 @@ namespace Ndk
case 'z': case 'z':
instance.z = value; instance.z = value;
return true; return true;
default:
break;
} }
return false; return false;
@ -455,9 +467,15 @@ namespace Ndk
case 'y': case 'y':
lua.Push(instance.y); lua.Push(instance.y);
return true; return true;
default:
break;
} }
break; break;
} }
default:
break;
} }
return false; return false;
@ -496,9 +514,15 @@ namespace Ndk
case 'y': case 'y':
instance.y = value; instance.y = value;
return true; return true;
default:
break;
} }
break; break;
} }
default:
break;
} }
return false; return false;
@ -582,9 +606,15 @@ namespace Ndk
case 'z': case 'z':
lua.Push(instance.z); lua.Push(instance.z);
return true; return true;
default:
break;
} }
break; break;
} }
default:
break;
} }
return false; return false;
@ -627,9 +657,15 @@ namespace Ndk
case 'z': case 'z':
instance.z = value; instance.z = value;
return true; return true;
default:
break;
} }
break; break;
} }
default:
break;
} }
return false; return false;

View File

@ -78,7 +78,7 @@ namespace Nz
* \param v Object to hash * \param v Object to hash
* *
* \remark a HashAppend specialization for type T is required * \remark a HashAppend specialization for type T is required
* *
* \see ComputeHash * \see ComputeHash
*/ */
template<typename T> template<typename T>
@ -178,7 +178,7 @@ namespace Nz
{ {
T reversed = 0; T reversed = 0;
for (std::size_t i = 0; i < sizeof(T); ++i) for (std::size_t i = 0; i < sizeof(T); ++i)
reversed |= T(Detail::BitReverseTable256[(integer >> i * 8) & 0xFF]) << sizeof(T) * 8 - (i + 1) * 8; reversed |= T(Detail::BitReverseTable256[(integer >> i * 8) & 0xFF]) << (sizeof(T) * 8 - (i + 1) * 8);
return reversed; return reversed;
} }

View File

@ -13,6 +13,7 @@ namespace Nz
template<typename T> template<typename T>
HandledObject<T>::HandledObject(const HandledObject& object) HandledObject<T>::HandledObject(const HandledObject& object)
{ {
NazaraUnused(object);
// Don't copy anything, we're a copy of the object, we have no handle right now // Don't copy anything, we're a copy of the object, we have no handle right now
} }
@ -40,7 +41,7 @@ namespace Nz
HandledObject<T>& HandledObject<T>::operator=(const HandledObject& object) HandledObject<T>& HandledObject<T>::operator=(const HandledObject& object)
{ {
// Nothing to do // Nothing to do
return *this; return *this;
} }
template<typename T> template<typename T>

View File

@ -9,9 +9,9 @@ namespace Nz
{ {
inline Light::Light(const Light& light) : inline Light::Light(const Light& light) :
Renderable(light), Renderable(light),
m_color(light.m_color),
m_type(light.m_type), m_type(light.m_type),
m_shadowMapFormat(light.m_shadowMapFormat), m_shadowMapFormat(light.m_shadowMapFormat),
m_color(light.m_color),
m_shadowMapSize(light.m_shadowMapSize), m_shadowMapSize(light.m_shadowMapSize),
m_shadowCastingEnabled(light.m_shadowCastingEnabled), m_shadowCastingEnabled(light.m_shadowCastingEnabled),
m_shadowMapUpdated(false), m_shadowMapUpdated(false),

View File

@ -21,6 +21,8 @@ namespace Nz
{ {
SetConstructor([] (Nz::LuaInstance& lua, T* instance) SetConstructor([] (Nz::LuaInstance& lua, T* instance)
{ {
NazaraUnused(lua);
PlacementNew(instance); PlacementNew(instance);
return true; return true;
}); });
@ -132,9 +134,9 @@ namespace Nz
lua.SetField(pair.first); // Method name lua.SetField(pair.first); // Method name
} }
m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& lua) m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& instance)
{ {
return static_cast<T*>(lua.CheckUserdata(1, info->name)); return static_cast<T*>(instance.CheckUserdata(1, info->name));
}; };
} }
lua.Pop(); // On pop la metatable lua.Pop(); // On pop la metatable
@ -391,11 +393,11 @@ namespace Nz
if (!lua.IsValid(-1)) if (!lua.IsValid(-1))
{ {
for (const ParentFunc& getter : info->parentGetters) for (const ParentFunc& parentGetter : info->parentGetters)
{ {
lua.Pop(); //< Pop the last nil value lua.Pop(); //< Pop the last nil value
getter(lua, instance); parentGetter(lua, instance);
if (lua.IsValid(-1)) if (lua.IsValid(-1))
return; return;
} }

View File

@ -224,7 +224,7 @@ namespace std
// This is SDBM adapted for IP addresses, tested to generate the least collisions possible // This is SDBM adapted for IP addresses, tested to generate the least collisions possible
// (It doesn't mean it cannot be improved though) // (It doesn't mean it cannot be improved though)
std::size_t hash = 0; std::size_t h = 0;
switch (ip.GetProtocol()) switch (ip.GetProtocol())
{ {
case Nz::NetProtocol_Any: case Nz::NetProtocol_Any:
@ -233,20 +233,20 @@ namespace std
case Nz::NetProtocol_IPv4: case Nz::NetProtocol_IPv4:
{ {
hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash; h = ip.ToUInt32() + (h << 6) + (h << 16) - h;
break; break;
} }
case Nz::NetProtocol_IPv6: case Nz::NetProtocol_IPv6:
{ {
Nz::IpAddress::IPv6 v6 = ip.ToIPv6(); Nz::IpAddress::IPv6 v6 = ip.ToIPv6();
for (std::size_t i = 0; i < v6.size(); i++) for (std::size_t i = 0; i < v6.size(); i++)
hash = v6[i] + (hash << 6) + (hash << 16) - hash; h = v6[i] + (h << 6) + (h << 16) - h;
break; break;
} }
} }
return ip.GetPort() + (hash << 6) + (hash << 16) - hash; return ip.GetPort() + (h << 6) + (h << 16) - h;
} }
}; };
} }

View File

@ -79,8 +79,8 @@ namespace Nz
PendingPacket m_pendingPacket; PendingPacket m_pendingPacket;
UInt64 m_keepAliveInterval; UInt64 m_keepAliveInterval;
UInt64 m_keepAliveTime; UInt64 m_keepAliveTime;
bool m_isLowDelayEnabled;
bool m_isKeepAliveEnabled; bool m_isKeepAliveEnabled;
bool m_isLowDelayEnabled;
}; };
} }

View File

@ -12,29 +12,29 @@
namespace Nz namespace Nz
{ {
inline PixelFormatInfo::PixelFormatInfo() : inline PixelFormatInfo::PixelFormatInfo() :
bitsPerPixel(0), content(PixelFormatContent_Undefined),
content(PixelFormatContent_Undefined) bitsPerPixel(0)
{ {
} }
inline PixelFormatInfo::PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : inline PixelFormatInfo::PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
bitsPerPixel(bpp),
content(formatContent),
redType(subType),
greenType(subType),
blueType(subType),
alphaType(subType)
{
}
inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
bitsPerPixel(bpp),
content(formatContent), content(formatContent),
redType(subType), redType(subType),
greenType(subType), greenType(subType),
blueType(subType), blueType(subType),
alphaType(subType), alphaType(subType),
name(formatName) bitsPerPixel(bpp)
{
}
inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
content(formatContent),
redType(subType),
greenType(subType),
blueType(subType),
alphaType(subType),
name(formatName),
bitsPerPixel(bpp)
{ {
} }

View File

@ -385,7 +385,7 @@ namespace Nz
} }
/*! /*!
* \brief Sets the position of the cursor * \brief Sets the position of the cursor
* \return true if cursor is successfully positioned * \return true if cursor is successfully positioned
* *
* \param pos Position of the cursor * \param pos Position of the cursor
@ -404,7 +404,7 @@ namespace Nz
} }
/*! /*!
* \brief Sets the position of the cursor * \brief Sets the position of the cursor
* \return true if cursor is successfully positioned * \return true if cursor is successfully positioned
* *
* \param offset Offset according to the cursor begin position * \param offset Offset according to the cursor begin position
@ -906,5 +906,5 @@ namespace Nz
} }
return true; return true;
}; }
} }

View File

@ -94,6 +94,7 @@ namespace Nz
break; break;
} }
case ParameterType_Color:
case ParameterType_Float: case ParameterType_Float:
case ParameterType_None: case ParameterType_None:
case ParameterType_Pointer: case ParameterType_Pointer:
@ -198,6 +199,7 @@ namespace Nz
} }
case ParameterType_Boolean: case ParameterType_Boolean:
case ParameterType_Color:
case ParameterType_None: case ParameterType_None:
case ParameterType_Pointer: case ParameterType_Pointer:
case ParameterType_Userdata: case ParameterType_Userdata:
@ -207,7 +209,7 @@ namespace Nz
NazaraError("Parameter value is not representable as a float"); NazaraError("Parameter value is not representable as a float");
return false; return false;
} }
/*! /*!
* \brief Gets a parameter as an integer * \brief Gets a parameter as an integer
* \return true if the parameter could be represented as an integer * \return true if the parameter could be represented as an integer
@ -263,6 +265,7 @@ namespace Nz
break; break;
} }
case ParameterType_Color:
case ParameterType_None: case ParameterType_None:
case ParameterType_Pointer: case ParameterType_Pointer:
case ParameterType_Userdata: case ParameterType_Userdata:
@ -331,6 +334,7 @@ namespace Nz
return true; return true;
case ParameterType_Boolean: case ParameterType_Boolean:
case ParameterType_Color:
case ParameterType_Float: case ParameterType_Float:
case ParameterType_Integer: case ParameterType_Integer:
case ParameterType_None: case ParameterType_None:
@ -411,7 +415,7 @@ namespace Nz
NazaraInternalError("Parameter value is not valid"); NazaraInternalError("Parameter value is not valid");
return false; return false;
} }
/*! /*!
* \brief Gets a parameter as an userdata * \brief Gets a parameter as an userdata
* \return true if the parameter could be represented as a userdata * \return true if the parameter could be represented as a userdata
@ -584,7 +588,7 @@ namespace Nz
parameter.type = ParameterType_Integer; parameter.type = ParameterType_Integer;
parameter.value.intVal = value; parameter.value.intVal = value;
} }
/*! /*!
* \brief Sets a pointer parameter named `name` * \brief Sets a pointer parameter named `name`
* *
@ -593,7 +597,7 @@ namespace Nz
* \param name Name of the parameter * \param name Name of the parameter
* \param value The pointer value * \param value The pointer value
* *
* \remark This sets a raw pointer, this class takes no responsibility toward it, * \remark This sets a raw pointer, this class takes no responsibility toward it,
if you wish to destroy the pointed variable along with the parameter list, you should set a userdata if you wish to destroy the pointed variable along with the parameter list, you should set a userdata
*/ */
void ParameterList::SetParameter(const String& name, void* value) void ParameterList::SetParameter(const String& name, void* value)
@ -639,6 +643,7 @@ namespace Nz
switch (it->second.type) switch (it->second.type)
{ {
case ParameterType_Boolean: case ParameterType_Boolean:
case ParameterType_Color:
case ParameterType_Float: case ParameterType_Float:
case ParameterType_Integer: case ParameterType_Integer:
case ParameterType_Pointer: case ParameterType_Pointer:

View File

@ -524,9 +524,9 @@ namespace Nz
Vector3f viewerPos = viewer->GetEyePosition(); Vector3f viewerPos = viewer->GetEyePosition();
Vector3f viewerNormal = viewer->GetForward(); Vector3f viewerNormal = viewer->GetForward();
for (auto& pair : layers) for (auto& layerPair : layers)
{ {
Layer& layer = pair.second; Layer& layer = layerPair.second;
std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (unsigned int index1, unsigned int index2) std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (unsigned int index1, unsigned int index2)
{ {
@ -562,7 +562,7 @@ namespace Nz
auto it = layers.find(i); auto it = layers.find(i);
if (it == layers.end()) if (it == layers.end())
it = layers.insert(std::make_pair(i, Layer())).first; it = layers.insert(std::make_pair(i, Layer())).first;
Layer& layer = it->second; Layer& layer = it->second;
layer.clearCount = 0; layer.clearCount = 0;

View File

@ -57,11 +57,14 @@ namespace Nz
case PixelFormatContent_Stencil: case PixelFormatContent_Stencil:
return AttachmentPoint_Stencil; return AttachmentPoint_Stencil;
case PixelFormatContent_Undefined:
break;
} }
NazaraInternalError("Unexpected pixel format content: 0x" + String::Number(info.content, 16)); NazaraInternalError("Unexpected pixel format content: 0x" + String::Number(info.content, 16));
return AttachmentPoint_Max; return AttachmentPoint_Max;
}; }
GLuint lockedPrevious = 0; GLuint lockedPrevious = 0;
UInt8 lockedLevel = 0; UInt8 lockedLevel = 0;

View File

@ -105,9 +105,9 @@ namespace Nz
for (unsigned int i = 0; i < recursionLevel; ++i) for (unsigned int i = 0; i < recursionLevel; ++i)
{ {
std::size_t triangleCount = triangles.size(); std::size_t triangleCount = triangles.size();
for (std::size_t i = 0; i < triangleCount; ++i) for (std::size_t j = 0; j < triangleCount; ++j)
{ {
Vector3ui& triangle = triangles[i]; Vector3ui& triangle = triangles[j];
unsigned int a = GetMiddleVertex(triangle.x, triangle.y); unsigned int a = GetMiddleVertex(triangle.x, triangle.y);
unsigned int b = GetMiddleVertex(triangle.y, triangle.z); unsigned int b = GetMiddleVertex(triangle.y, triangle.z);