From ff5b72b46911ecbccdb8a7ed2a0012066935d15d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Dec 2016 14:37:12 +0100 Subject: [PATCH 001/243] Graphics/DepthRenderTechnique: No longer require a viewer Fixes crash --- include/Nazara/Graphics/DepthRenderTechnique.hpp | 1 - src/Nazara/Graphics/DepthRenderTechnique.cpp | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/include/Nazara/Graphics/DepthRenderTechnique.hpp b/include/Nazara/Graphics/DepthRenderTechnique.hpp index 9d4ba601f..88d447889 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.hpp +++ b/include/Nazara/Graphics/DepthRenderTechnique.hpp @@ -55,7 +55,6 @@ namespace Nz NazaraSlot(Shader, OnShaderRelease, shaderReleaseSlot); // Autre uniformes - int eyePosition; int sceneAmbient; int textureOverlay; }; diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 542b180a7..7e909064e 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -212,8 +212,6 @@ namespace Nz void DepthRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { - NazaraAssert(sceneData.viewer, "Invalid viewer"); - const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; @@ -240,8 +238,6 @@ namespace Nz // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } @@ -330,8 +326,6 @@ namespace Nz void DepthRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { - NazaraAssert(sceneData.viewer, "Invalid viewer"); - const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; @@ -361,8 +355,6 @@ namespace Nz // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } @@ -423,8 +415,6 @@ namespace Nz // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } @@ -501,8 +491,6 @@ namespace Nz void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { - NazaraAssert(sceneData.viewer, "Invalid viewer"); - const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; @@ -526,8 +514,6 @@ namespace Nz // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } @@ -641,7 +627,6 @@ namespace Nz uniforms.shaderReleaseSlot.Connect(shader->OnShaderRelease, this, &DepthRenderTechnique::OnShaderInvalidated); uniforms.shaderUniformInvalidatedSlot.Connect(shader->OnShaderUniformInvalidated, this, &DepthRenderTechnique::OnShaderInvalidated); - uniforms.eyePosition = shader->GetUniformLocation("EyePosition"); uniforms.textureOverlay = shader->GetUniformLocation("TextureOverlay"); it = m_shaderUniforms.emplace(shader, std::move(uniforms)).first; From 165b73acb3d3aedbfd65fa033b2686369f6916cd Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Dec 2016 14:37:58 +0100 Subject: [PATCH 002/243] Math/Sphere: Fix SquaredDistance weirdness.. Fixes light selection --- include/Nazara/Math/Sphere.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index 0a8d1adae..5252dbdbb 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -485,7 +485,7 @@ namespace Nz template T Sphere::SquaredDistance(const Vector3& point) const { - return Vector3f::SquaredDistance(point, GetPosition() + (point - GetPosition()).Normalize() * radius); + return Vector3f::SquaredDistance(GetPosition(), point) - radius * radius; } /*! From f5f6c859d7f581a0fe0e8bc1bd34793dcd50c5a5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Dec 2016 18:32:58 +0100 Subject: [PATCH 003/243] Math/Sphere: Remove SquaredDistance method --- .../Graphics/ForwardRenderTechnique.inl | 18 +++---- include/Nazara/Math/Algorithm.hpp | 2 +- include/Nazara/Math/Algorithm.inl | 5 +- include/Nazara/Math/Sphere.hpp | 3 -- include/Nazara/Math/Sphere.inl | 51 +++---------------- tests/Engine/Math/Sphere.cpp | 16 +++--- 6 files changed, 27 insertions(+), 68 deletions(-) diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.inl b/include/Nazara/Graphics/ForwardRenderTechnique.inl index 5f7ba181f..208aa9f81 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.inl +++ b/include/Nazara/Graphics/ForwardRenderTechnique.inl @@ -126,7 +126,7 @@ namespace Nz { if (uniforms.locations.type != -1) shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader - + if (uniforms.locations.directionalSpotLightShadowMap != -1) shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); @@ -163,7 +163,7 @@ namespace Nz inline float ForwardRenderTechnique::ComputePointLightScore(const Spheref& object, const AbstractRenderQueue::PointLight& light) { ///TODO: Compute a score depending on the light luminosity - return object.SquaredDistance(light.position); + return object.GetPosition().SquaredDistance(light.position); } /*! @@ -177,7 +177,7 @@ namespace Nz inline float ForwardRenderTechnique::ComputeSpotLightScore(const Spheref& object, const AbstractRenderQueue::SpotLight& light) { ///TODO: Compute a score depending on the light luminosity and spot direction - return object.SquaredDistance(light.position); + return object.GetPosition().SquaredDistance(light.position); } /*! @@ -199,29 +199,29 @@ namespace Nz /*! * \brief Checks whether the point light is suitable for the computations - * \return true if light is enoughly close + * \return true if light is close enough * - * \param object Sphere symbolising the object + * \param object Sphere symbolizing the object * \param light Light to compute */ inline bool ForwardRenderTechnique::IsPointLightSuitable(const Spheref& object, const AbstractRenderQueue::PointLight& light) { // If the object is too far away from this point light, there is not way it could light it - return object.SquaredDistance(light.position) <= light.radius * light.radius; + return object.Contains(light.position); } /*! * \brief Checks whether the spot light is suitable for the computations - * \return true if light is enoughly close + * \return true if light is close enough * - * \param object Sphere symbolising the object + * \param object Sphere symbolizing the object * \param light Light to compute */ inline bool ForwardRenderTechnique::IsSpotLightSuitable(const Spheref& object, const AbstractRenderQueue::SpotLight& light) { ///TODO: Exclude spot lights based on their direction and outer angle? - return object.SquaredDistance(light.position) <= light.radius * light.radius; + return object.Contains(light.position); } } diff --git a/include/Nazara/Math/Algorithm.hpp b/include/Nazara/Math/Algorithm.hpp index f138a8fc9..6decc4b28 100644 --- a/include/Nazara/Math/Algorithm.hpp +++ b/include/Nazara/Math/Algorithm.hpp @@ -53,7 +53,7 @@ namespace Nz unsigned int GetNumberLength(long double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); template /*constexpr*/ unsigned int IntegralLog2(T number); template /*constexpr*/ unsigned int IntegralLog2Pot(T pot); - /*constexpr*/ unsigned int IntegralPow(unsigned int base, unsigned int exponent); + template /*constexpr*/ T IntegralPow(T base, unsigned int exponent); template constexpr T Lerp(const T& from, const T& to, const T2& interpolation); template constexpr T MultiplyAdd(T x, T y, T z); template /*constexpr*/ T NormalizeAngle(T angle); diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index 02ede739a..d7309a148 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -436,9 +436,10 @@ namespace Nz */ //TODO: Mark as constexpr when supported by all major compilers - /*constexpr*/ inline unsigned int IntegralPow(unsigned int base, unsigned int exponent) + template + /*constexpr*/ T IntegralPow(T base, unsigned int exponent) { - unsigned int r = 1; + T r = 1; for (unsigned int i = 0; i < exponent; ++i) r *= base; diff --git a/include/Nazara/Math/Sphere.hpp b/include/Nazara/Math/Sphere.hpp index 8f7ac9e14..feaa8af56 100644 --- a/include/Nazara/Math/Sphere.hpp +++ b/include/Nazara/Math/Sphere.hpp @@ -58,9 +58,6 @@ namespace Nz Sphere& Set(const T sphere[4]); template Sphere& Set(const Sphere& sphere); - T SquaredDistance(T X, T Y, T Z) const; - T SquaredDistance(const Vector3& point) const; - String ToString() const; T& operator[](unsigned int i); diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index 5252dbdbb..02847b243 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -94,7 +94,7 @@ namespace Nz template bool Sphere::Contains(T X, T Y, T Z) const { - return SquaredDistance(X, Y, Z) <= radius * radius; + return Contains(Vector3(X, Y, Z)); } /*! @@ -109,11 +109,8 @@ namespace Nz template bool Sphere::Contains(const Box& box) const { - if (box.GetMinimum().SquaredDistance(GetPosition()) <= radius * radius) - { - if (box.GetMaximum().SquaredDistance(GetPosition()) <= radius * radius) - return true; - } + if (Contains(box.GetMinimum()) && Contains(box.GetMaximum())) + return true; return false; } @@ -128,7 +125,7 @@ namespace Nz template bool Sphere::Contains(const Vector3& point) const { - return Contains(point.x, point.y, point.z); + return GetPosition().SquaredDistance(point) <= radius * radius; } /*! @@ -138,8 +135,6 @@ namespace Nz * \param X X position of the point * \param Y Y position of the point * \param Z Z position of the point - * - * \see SquaredDistance */ template @@ -153,8 +148,6 @@ namespace Nz * \return Distance to the point * * \param point Position of the point - * - * \see SquaredDistance */ template @@ -177,9 +170,7 @@ namespace Nz template Sphere& Sphere::ExtendTo(T X, T Y, T Z) { - T distance = SquaredDistance(X, Y, Z); - if (distance > radius*radius) - radius = std::sqrt(distance); + radius = std::max(radius, Distance(X, Y, Z)); return *this; } @@ -304,7 +295,7 @@ namespace Nz template bool Sphere::Intersect(const Sphere& sphere) const { - return SquaredDistance(sphere.x, sphere.y, sphere.z) <= sphere.radius * sphere.radius; + return GetPosition().SquaredDistance(sphere.x, sphere.y, sphere.z) <= IntegralPow(radius + sphere.radius, 2); } /*! @@ -458,36 +449,6 @@ namespace Nz return *this; } - /*! - * \brief Returns the squared distance from the sphere to the point (can be negative if the point is inside the sphere) - * \return Squared distance to the point - * - * \param X X position of the point - * \param Y Y position of the point - * \param Z Z position of the point - * - * \see Distance - */ - template - T Sphere::SquaredDistance(T X, T Y, T Z) const - { - return SquaredDistance({X, Y, Z}); - } - - /*! - * \brief Returns the squared distance from the sphere to the point (can be negative if the point is inside the sphere) - * \return Squared distance to the point - * - * \param point Position of the point - * - * \see Distance - */ - template - T Sphere::SquaredDistance(const Vector3& point) const - { - return Vector3f::SquaredDistance(GetPosition(), point) - radius * radius; - } - /*! * \brief Gives a string representation * \return A string representation of the object: "Sphere(x, y, z; radius)" diff --git a/tests/Engine/Math/Sphere.cpp b/tests/Engine/Math/Sphere.cpp index ef13ffb38..869987d25 100644 --- a/tests/Engine/Math/Sphere.cpp +++ b/tests/Engine/Math/Sphere.cpp @@ -41,12 +41,10 @@ SCENARIO("Sphere", "[MATH][SPHERE]") { THEN("These results are expected because we don't take into account the border") { - REQUIRE(firstCenterAndUnit.Distance(Nz::Vector3f::UnitX() * 2.f) == Approx(1.f)); - REQUIRE(firstCenterAndUnit.SquaredDistance(Nz::Vector3f::UnitX() * 2.f) == Approx(1.f)); + CHECK(firstCenterAndUnit.Distance(Nz::Vector3f::UnitX() * 2.f) == Approx(1.f)); Nz::Spheref tmp(Nz::Vector3f::UnitX(), 1.f); - REQUIRE(tmp.Distance(Nz::Vector3f::UnitX() * 4.f) == Approx(2.f)); - REQUIRE(tmp.SquaredDistance(Nz::Vector3f::UnitX() * 4.f) == Approx(4.f)); + CHECK(tmp.Distance(Nz::Vector3f::UnitX() * 4.f) == Approx(2.f)); } } @@ -56,7 +54,7 @@ SCENARIO("Sphere", "[MATH][SPHERE]") THEN("This is equal to sphere center and radius 0.75") { - REQUIRE(centerUnitBox.GetSquaredBoundingSphere() == Nz::Spheref(Nz::Vector3f::Zero(), 0.75f)); + CHECK(centerUnitBox.GetSquaredBoundingSphere() == Nz::Spheref(Nz::Vector3f::Zero(), 0.75f)); } } @@ -66,12 +64,12 @@ SCENARIO("Sphere", "[MATH][SPHERE]") THEN("Positive vertex should be the same with centered and unit sphere") { - REQUIRE(positiveVector == firstCenterAndUnit.GetPositiveVertex(positiveVector)); + CHECK(positiveVector == firstCenterAndUnit.GetPositiveVertex(positiveVector)); } AND_THEN("Negative vertex should be the opposite") { - REQUIRE(-positiveVector == firstCenterAndUnit.GetNegativeVertex(positiveVector)); + CHECK(-positiveVector == firstCenterAndUnit.GetNegativeVertex(positiveVector)); } } @@ -81,10 +79,12 @@ SCENARIO("Sphere", "[MATH][SPHERE]") firstCenterAndUnit.ExtendTo(point); + REQUIRE(firstCenterAndUnit.radius == Approx(2.f)); + THEN("Sphere must contain it and distance should be good") { CHECK(firstCenterAndUnit.Contains(point)); - REQUIRE(firstCenterAndUnit.Distance(point) == 1.f); + CHECK(firstCenterAndUnit.Distance(point) == Approx(1.f)); } } From d015d6e85ec92b04728286b7b52efd6feeed0b1f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Dec 2016 19:10:44 +0100 Subject: [PATCH 004/243] Math/Sphere: Fix compilation --- include/Nazara/Math/Sphere.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index 02847b243..ec7e750de 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -295,7 +295,7 @@ namespace Nz template bool Sphere::Intersect(const Sphere& sphere) const { - return GetPosition().SquaredDistance(sphere.x, sphere.y, sphere.z) <= IntegralPow(radius + sphere.radius, 2); + return GetPosition().SquaredDistance(Vector3(sphere.x, sphere.y, sphere.z)) <= IntegralPow(radius + sphere.radius, 2); } /*! From 937fdef953c7f6136c951a5cb010971ff384d6b1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Dec 2016 19:27:05 +0100 Subject: [PATCH 005/243] Math/Sphere: Fix ExtendTo method --- include/Nazara/Math/Sphere.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index ec7e750de..cd748c0ba 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -170,7 +170,7 @@ namespace Nz template Sphere& Sphere::ExtendTo(T X, T Y, T Z) { - radius = std::max(radius, Distance(X, Y, Z)); + radius = std::max(radius, radius + Distance(X, Y, Z)); return *this; } From 2d3c6010be50a70062c4463b05a65ad325e0e969 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Dec 2016 20:14:44 +0100 Subject: [PATCH 006/243] UnitTest/Math: Fix Sphere test --- tests/Engine/Math/Sphere.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Engine/Math/Sphere.cpp b/tests/Engine/Math/Sphere.cpp index 869987d25..a6f23236d 100644 --- a/tests/Engine/Math/Sphere.cpp +++ b/tests/Engine/Math/Sphere.cpp @@ -84,7 +84,7 @@ SCENARIO("Sphere", "[MATH][SPHERE]") THEN("Sphere must contain it and distance should be good") { CHECK(firstCenterAndUnit.Contains(point)); - CHECK(firstCenterAndUnit.Distance(point) == Approx(1.f)); + CHECK(firstCenterAndUnit.Distance(point) == Approx(0.f)); } } From 5aa0c362a6c85bbe017a26fd263a315bbc8ce0c9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Dec 2016 23:08:56 +0100 Subject: [PATCH 007/243] Graphics/DepthRenderTechnique: Fix SceneAmbient uniform not being sent --- src/Nazara/Graphics/DepthRenderTechnique.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 7e909064e..c153fd514 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -627,6 +627,7 @@ namespace Nz uniforms.shaderReleaseSlot.Connect(shader->OnShaderRelease, this, &DepthRenderTechnique::OnShaderInvalidated); uniforms.shaderUniformInvalidatedSlot.Connect(shader->OnShaderUniformInvalidated, this, &DepthRenderTechnique::OnShaderInvalidated); + uniforms.sceneAmbient = shader->GetUniformLocation("SceneAmbient"); uniforms.textureOverlay = shader->GetUniformLocation("TextureOverlay"); it = m_shaderUniforms.emplace(shader, std::move(uniforms)).first; From 997a874c0e7f8d646b6c92a71b596660ae09099e Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Dec 2016 23:55:35 +0100 Subject: [PATCH 008/243] Graphics/ForwardRenderTechnique: Fix light selection --- include/Nazara/Graphics/ForwardRenderTechnique.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.inl b/include/Nazara/Graphics/ForwardRenderTechnique.inl index 208aa9f81..07b735dac 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.inl +++ b/include/Nazara/Graphics/ForwardRenderTechnique.inl @@ -208,7 +208,7 @@ namespace Nz inline bool ForwardRenderTechnique::IsPointLightSuitable(const Spheref& object, const AbstractRenderQueue::PointLight& light) { // If the object is too far away from this point light, there is not way it could light it - return object.Contains(light.position); + return object.Intersect(Spheref(light.position, light.radius)); } /*! @@ -222,6 +222,6 @@ namespace Nz inline bool ForwardRenderTechnique::IsSpotLightSuitable(const Spheref& object, const AbstractRenderQueue::SpotLight& light) { ///TODO: Exclude spot lights based on their direction and outer angle? - return object.Contains(light.position); + return object.Intersect(Spheref(light.position, light.radius)); } } From 7de3c4905f1800966585a205cdd915361bb76734 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 16 Dec 2016 18:37:06 +0100 Subject: [PATCH 009/243] Core/String: Add Format static method --- include/Nazara/Core/String.hpp | 3 +++ include/Nazara/Core/String.inl | 17 +++++++++++++++++ src/Nazara/Core/String.cpp | 19 ++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core/String.hpp b/include/Nazara/Core/String.hpp index ba7f34ff7..c3056e835 100644 --- a/include/Nazara/Core/String.hpp +++ b/include/Nazara/Core/String.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -239,6 +240,8 @@ namespace Nz static String Boolean(bool boolean); static int Compare(const String& first, const String& second); + static inline String Format(const char* format, ...); + static String FormatVA(const char* format, va_list arg); static String Number(float number); static String Number(double number); static String Number(long double number); diff --git a/include/Nazara/Core/String.inl b/include/Nazara/Core/String.inl index a5e099a3c..f4cf48714 100644 --- a/include/Nazara/Core/String.inl +++ b/include/Nazara/Core/String.inl @@ -19,6 +19,23 @@ namespace Nz { } + /*! + * \brief Build a string using a format and returns it + * \return Formatted string + * + * \param format String format + * \param ... Format arguments + */ + String String::Format(const char* format, ...) + { + va_list args; + va_start(args, format); + String result = FormatVA(format, args); + va_end(args); + + return result; + } + /*! * \brief Releases the content to the string */ diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index ac01bf92c..b0ff09ed1 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -5079,7 +5079,7 @@ namespace Nz * \return The expected result * * \param first First string to use for comparison - * \parma second Second string to use for comparison + * \param second Second string to use for comparison */ int String::Compare(const String& first, const String& second) @@ -5093,6 +5093,23 @@ namespace Nz return std::strcmp(first.GetConstBuffer(), second.GetConstBuffer()); } + /*! + * \brief Build a string using a format and returns it + * \return Formatted string + * + * \param format String format + * \param args Format arguments + */ + String String::FormatVA(const char* format, va_list args) + { + std::size_t length = std::vsnprintf(nullptr, 0, format, args); + + auto str = std::make_shared(length); + std::vsnprintf(str->string.get(), length + 1, format, args); + + return String(std::move(str)); + } + /*! * \brief Converts the number to string * \return String representation of the number From b410956d1b117cfc8c8d0658f7584b0ea715f0e3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 18 Dec 2016 00:36:05 +0100 Subject: [PATCH 010/243] Renderer/Renderer: Change texture unit parameter from UInt8 to unsigned int --- include/Nazara/Renderer/Renderer.hpp | 4 ++-- src/Nazara/Renderer/Renderer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index f93fe47e3..db85c4d62 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -102,8 +102,8 @@ namespace Nz static void SetStencilReferenceValue(unsigned int refValue, FaceSide faceSide = FaceSide_FrontAndBack); static void SetStencilZFailOperation(StencilOperation zfailOperation, FaceSide faceSide = FaceSide_FrontAndBack); static bool SetTarget(const RenderTarget* target); - static void SetTexture(UInt8 unit, const Texture* texture); - static void SetTextureSampler(UInt8 textureUnit, const TextureSampler& sampler); + static void SetTexture(unsigned int unit, const Texture* texture); + static void SetTextureSampler(unsigned int textureUnit, const TextureSampler& sampler); static void SetVertexBuffer(const VertexBuffer* vertexBuffer); static void SetViewport(const Recti& viewport); diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index cde92572a..f6257eed4 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -1294,7 +1294,7 @@ namespace Nz return true; } - void Renderer::SetTexture(UInt8 unit, const Texture* texture) + void Renderer::SetTexture(unsigned int unit, const Texture* texture) { #if NAZARA_RENDERER_SAFE if (unit >= s_maxTextureUnit) @@ -1319,7 +1319,7 @@ namespace Nz } } - void Renderer::SetTextureSampler(UInt8 unit, const TextureSampler& sampler) + void Renderer::SetTextureSampler(unsigned int unit, const TextureSampler& sampler) { #if NAZARA_RENDERER_SAFE if (unit >= s_maxTextureUnit) From b468dbe092907112b87a93fdbb4da10e108e19a3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 18 Dec 2016 00:36:41 +0100 Subject: [PATCH 011/243] Renderer: Add uniform dumper when shader fails to validate --- include/Nazara/Renderer/OpenGL.hpp | 2 + src/Nazara/Renderer/OpenGL.cpp | 4 ++ src/Nazara/Renderer/Renderer.cpp | 87 ++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index 535a77388..e7f21d228 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -249,6 +249,8 @@ NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParame NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv; NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv; +NAZARA_RENDERER_API extern PFNGLGETUNIFORMFVPROC glGetUniformfv; +NAZARA_RENDERER_API extern PFNGLGETUNIFORMIVPROC glGetUniformiv; NAZARA_RENDERER_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; NAZARA_RENDERER_API extern PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData; NAZARA_RENDERER_API extern PFNGLISENABLEDPROC glIsEnabled; diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index b06c1c3a7..af4d16d28 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -969,6 +969,8 @@ namespace Nz glGetTexLevelParameteriv = reinterpret_cast(LoadEntry("glGetTexLevelParameteriv")); glGetTexParameterfv = reinterpret_cast(LoadEntry("glGetTexParameterfv")); glGetTexParameteriv = reinterpret_cast(LoadEntry("glGetTexParameteriv")); + glGetUniformfv = reinterpret_cast(LoadEntry("glGetUniformfv")); + glGetUniformiv = reinterpret_cast(LoadEntry("glGetUniformiv")); glGetUniformLocation = reinterpret_cast(LoadEntry("glGetUniformLocation")); glIsEnabled = reinterpret_cast(LoadEntry("glIsEnabled")); glLineWidth = reinterpret_cast(LoadEntry("glLineWidth")); @@ -2203,6 +2205,8 @@ PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv = nullptr; PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv = nullptr; PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv = nullptr; PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv = nullptr; +PFNGLGETUNIFORMFVPROC glGetUniformfv = nullptr; +PFNGLGETUNIFORMIVPROC glGetUniformiv = nullptr; PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = nullptr; PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData = nullptr; PFNGLISENABLEDPROC glIsEnabled = nullptr; diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index f6257eed4..a5140c7ec 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1775,6 +1776,92 @@ namespace Nz if (!s_shader->Validate()) { NazaraError(Error::GetLastError()); + + GLuint program = s_shader->GetOpenGLID(); + + StringStream dump; + + GLint count; + glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &count); + dump << "Active uniforms: " << count << '\n'; + + GLint maxLength; + glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength); + maxLength++; + + StackAllocation stackAlloc = NazaraStackAllocation((maxLength + 1) * sizeof(GLchar)); + GLchar* nameBuffer = static_cast(stackAlloc.GetPtr()); + + for (GLint i = 0; i < count; i++) + { + GLint size; + GLenum type; + + glGetActiveUniform(program, i, maxLength, nullptr, &size, &type, nameBuffer); + + dump << "Uniform #" << i << ": " << nameBuffer << "(Type: 0x" << String::Number(type, 16); + + GLint location = glGetUniformLocation(program, nameBuffer); + switch (type) + { + case GL_FLOAT: + { + GLfloat value; + glGetUniformfv(program, location, &value); + + dump << ", Value = " << value << ')'; + break; + } + case GL_FLOAT_VEC2: + { + GLfloat values[2]; + glGetUniformfv(program, location, &values[0]); + + dump << ", Value = vec2(" << values[0] << ',' << values[1] << ')'; + break; + } + case GL_FLOAT_VEC3: + { + GLfloat values[3]; + glGetUniformfv(program, location, &values[0]); + + dump << ", Value = vec4(" << values[0] << ',' << values[1] << ',' << values[2] << ')'; + break; + } + case GL_FLOAT_VEC4: + { + GLfloat values[4]; + glGetUniformfv(program, location, &values[0]); + + dump << ", Value = vec4(" << values[0] << ',' << values[1] << ',' << values[2] << ',' << values[3] << ')'; + break; + } + case GL_INT: + { + GLint value; + glGetUniformiv(program, location, &value); + + dump << ", Value = " << value; + break; + } + case GL_SAMPLER_2D: + case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_CUBE_SHADOW: + { + GLint value; + glGetUniformiv(program, location, &value); + + dump << ", Unit = " << value; + break; + } + } + + dump << ")\n"; + } + + NazaraNotice("Dumping shader uniforms:\n" + dump.ToString()); + return false; } #endif From 1a8805aad1f3148b0a985aa7da95ed630fe1f452 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 18 Dec 2016 00:37:39 +0100 Subject: [PATCH 012/243] Renderer/UberShaderPreprocessor: Log shader code when failing to compile --- src/Nazara/Renderer/UberShaderPreprocessor.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/UberShaderPreprocessor.cpp b/src/Nazara/Renderer/UberShaderPreprocessor.cpp index 2aeba18b9..ba1ed2ccc 100644 --- a/src/Nazara/Renderer/UberShaderPreprocessor.cpp +++ b/src/Nazara/Renderer/UberShaderPreprocessor.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -85,7 +86,18 @@ namespace Nz code << shaderStage.source; stage.SetSource(code); - stage.Compile(); + + try + { + stage.Compile(); + } + catch (const std::exception&) + { + ErrorFlags errFlags(ErrorFlag_ThrowExceptionDisabled); + + NazaraError("Shader code failed to compile:\n" + code); + throw; + } stageIt = shaderStage.cache.emplace(flags, std::move(stage)).first; } From 682dab32b38c0df66ce2f6e9d3f3682c5e0fbf01 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 18 Dec 2016 01:13:46 +0100 Subject: [PATCH 013/243] Graphics/Shader: Make texture units statics Provides better performances and prevents the sampler type bug to happen --- include/Nazara/Graphics/Enums.hpp | 20 +++ .../Graphics/ForwardRenderTechnique.hpp | 2 +- .../Graphics/ForwardRenderTechnique.inl | 129 ----------------- include/Nazara/Graphics/Light.hpp | 2 - include/Nazara/Graphics/Material.hpp | 4 +- include/Nazara/Graphics/Material.inl | 5 + src/Nazara/Graphics/DepthRenderTechnique.cpp | 14 +- .../Graphics/ForwardRenderTechnique.cpp | 135 +++++++++++++++--- src/Nazara/Graphics/Material.cpp | 47 +++--- src/Nazara/Graphics/MaterialPipeline.cpp | 28 +++- 10 files changed, 203 insertions(+), 183 deletions(-) diff --git a/include/Nazara/Graphics/Enums.hpp b/include/Nazara/Graphics/Enums.hpp index fd87cac6c..fcd241006 100644 --- a/include/Nazara/Graphics/Enums.hpp +++ b/include/Nazara/Graphics/Enums.hpp @@ -148,6 +148,26 @@ namespace Nz ShaderFlags_Max = ShaderFlags_VertexColor * 2 - 1 }; + + enum TextureMap + { + TextureMap_Alpha, + TextureMap_Diffuse, + TextureMap_Emissive, + TextureMap_Height, + TextureMap_ReflectionCube, + TextureMap_Normal, + TextureMap_Overlay, + TextureMap_Shadow2D_1, + TextureMap_Shadow2D_2, + TextureMap_Shadow2D_3, + TextureMap_ShadowCube_1, + TextureMap_ShadowCube_2, + TextureMap_ShadowCube_3, + TextureMap_Specular, + + TextureMap_Max = TextureMap_Specular + }; } #endif // NAZARA_ENUMS_GRAPHICS_HPP diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.hpp b/include/Nazara/Graphics/ForwardRenderTechnique.hpp index 5d82c4bf9..0a35518fc 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.hpp +++ b/include/Nazara/Graphics/ForwardRenderTechnique.hpp @@ -46,7 +46,7 @@ namespace Nz void DrawTransparentModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const; const ShaderUniforms* GetShaderUniforms(const Shader* shader) const; void OnShaderInvalidated(const Shader* shader) const; - void SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int uniformOffset, UInt8 availableTextureUnit) const; + void SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int lightIndex, unsigned int uniformOffset) const; static float ComputeDirectionalLightScore(const Spheref& object, const AbstractRenderQueue::DirectionalLight& light); static float ComputePointLightScore(const Spheref& object, const AbstractRenderQueue::PointLight& light); diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.inl b/include/Nazara/Graphics/ForwardRenderTechnique.inl index 07b735dac..c0d5b5f1b 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.inl +++ b/include/Nazara/Graphics/ForwardRenderTechnique.inl @@ -6,135 +6,6 @@ namespace Nz { - /*! - * \brief Sens the uniforms for light - * - * \param shader Shader to send uniforms to - * \param uniforms Uniforms to send - * \param index Index of the light - * \param uniformOffset Offset for the uniform - * \param availableTextureUnit Unit texture available - */ - - inline void ForwardRenderTechnique::SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int uniformOffset, UInt8 availableTextureUnit) const - { - // If anyone got a better idea.. - int dummyCubemap = Renderer::GetMaxTextureUnits() - 1; - int dummyTexture = Renderer::GetMaxTextureUnits() - 2; - - if (index < m_lights.size()) - { - const LightIndex& lightIndex = m_lights[index]; - - shader->SendInteger(uniforms.locations.type + uniformOffset, lightIndex.type); //< Sends the light type - - switch (lightIndex.type) - { - case LightType_Directional: - { - const auto& light = m_renderQueue.directionalLights[lightIndex.index]; - - shader->SendColor(uniforms.locations.color + uniformOffset, light.color); - shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor)); - shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.direction)); - - if (uniforms.locations.shadowMapping != -1) - shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); - - if (light.shadowMap) - { - Renderer::SetTexture(availableTextureUnit, light.shadowMap); - Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); - - if (uniforms.locations.lightViewProjMatrix != -1) - shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); - - if (uniforms.locations.directionalSpotLightShadowMap != -1) - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit); - } - else if (uniforms.locations.directionalSpotLightShadowMap != -1) - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); - - if (uniforms.locations.directionalSpotLightShadowMap != -1) - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); - break; - } - - case LightType_Point: - { - const auto& light = m_renderQueue.pointLights[lightIndex.index]; - - shader->SendColor(uniforms.locations.color + uniformOffset, light.color); - shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor)); - shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.position, light.attenuation)); - shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(0.f, 0.f, 0.f, light.invRadius)); - - if (uniforms.locations.shadowMapping != -1) - shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); - - if (light.shadowMap) - { - Renderer::SetTexture(availableTextureUnit, light.shadowMap); - Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); - - if (uniforms.locations.pointLightShadowMap != -1) - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, availableTextureUnit); - } - else if (uniforms.locations.pointLightShadowMap != -1) - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); - - if (uniforms.locations.directionalSpotLightShadowMap != -1) - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); - break; - } - - case LightType_Spot: - { - const auto& light = m_renderQueue.spotLights[lightIndex.index]; - - shader->SendColor(uniforms.locations.color + uniformOffset, light.color); - shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor)); - shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.position, light.attenuation)); - shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(light.direction, light.invRadius)); - shader->SendVector(uniforms.locations.parameters3 + uniformOffset, Vector2f(light.innerAngleCosine, light.outerAngleCosine)); - - if (uniforms.locations.shadowMapping != -1) - shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); - - if (light.shadowMap) - { - Renderer::SetTexture(availableTextureUnit, light.shadowMap); - Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); - - if (uniforms.locations.lightViewProjMatrix != -1) - shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); - - if (uniforms.locations.directionalSpotLightShadowMap != -1) - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit); - } - else if (uniforms.locations.directionalSpotLightShadowMap != -1) - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); - - if (uniforms.locations.pointLightShadowMap != -1) - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); - - break; - } - } - } - else - { - if (uniforms.locations.type != -1) - shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader - - if (uniforms.locations.directionalSpotLightShadowMap != -1) - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); - - if (uniforms.locations.pointLightShadowMap != -1) - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); - } - } - /*! * \brief Computes the score for directional light * \return 0.f diff --git a/include/Nazara/Graphics/Light.hpp b/include/Nazara/Graphics/Light.hpp index 071b748c3..3951be6ad 100644 --- a/include/Nazara/Graphics/Light.hpp +++ b/include/Nazara/Graphics/Light.hpp @@ -102,13 +102,11 @@ namespace Nz { int type; int color; - int directionalSpotLightShadowMap; int factors; int lightViewProjMatrix; int parameters1; int parameters2; int parameters3; - int pointLightShadowMap; int shadowMapping; }; diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index f7d15d6fe..be6e2c58b 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -64,7 +64,7 @@ namespace Nz inline Material(const Material& material); inline ~Material(); - void Apply(const MaterialPipeline::Instance& instance, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const; + void Apply(const MaterialPipeline::Instance& instance) const; void BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams = MaterialParams()); @@ -174,6 +174,7 @@ namespace Nz inline Material& operator=(const Material& material); inline static MaterialRef GetDefault(); + inline static int GetTextureUnit(TextureMap textureMap); template static MaterialRef New(Args&&... args); // Signals: @@ -207,6 +208,7 @@ namespace Nz float m_alphaThreshold; float m_shininess; + static std::array s_textureUnits; static MaterialLibrary::LibraryMap s_library; static MaterialLoader::LoaderList s_loaders; static MaterialManager::ManagerMap s_managerMap; diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index cec965e6e..b0ce4ff1c 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -1356,6 +1356,11 @@ namespace Nz return s_defaultMaterial; } + inline int Material::GetTextureUnit(TextureMap textureMap) + { + return s_textureUnits[textureMap]; + } + inline void Material::InvalidatePipeline() { m_pipelineUpdated = false; diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index c153fd514..3f0d76379 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -249,13 +249,12 @@ namespace Nz if (matEntry.enabled) { - UInt8 overlayUnit; - material->Apply(pipelineInstance, 0, &overlayUnit); - overlayUnit++; + unsigned int overlayTextureUnit = Material::GetTextureUnit(TextureMap_Overlay); + material->Apply(pipelineInstance); - shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); + shader->SendInteger(shaderUniforms->textureOverlay, overlayTextureUnit); - Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); + Renderer::SetTextureSampler(overlayTextureUnit, material->GetDiffuseSampler()); auto& overlayMap = matEntry.overlayMap; for (auto& overlayIt : overlayMap) @@ -266,7 +265,7 @@ namespace Nz std::size_t spriteChainCount = spriteChainVector.size(); if (spriteChainCount > 0) { - Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture); + Renderer::SetTexture(overlayTextureUnit, (overlay) ? overlay : &m_whiteTexture); std::size_t spriteChain = 0; // Which chain of sprites are we treating std::size_t spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain @@ -525,8 +524,7 @@ namespace Nz if (matEntry.enabled) { - UInt8 freeTextureUnit; - material->Apply(pipelineInstance, 0, &freeTextureUnit); + material->Apply(pipelineInstance); ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 22961b157..2e8f3e12f 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -318,7 +318,7 @@ namespace Nz // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Ambiant color of the scene + // Ambient color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); @@ -333,13 +333,13 @@ namespace Nz if (matEntry.enabled) { - UInt8 overlayUnit; - material->Apply(pipelineInstance, 0, &overlayUnit); - overlayUnit++; + material->Apply(pipelineInstance); - shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); + unsigned int overlayTextureUnit = Material::GetTextureUnit(TextureMap_Overlay); - Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); + shader->SendInteger(shaderUniforms->textureOverlay, overlayTextureUnit); + + Renderer::SetTextureSampler(overlayTextureUnit, material->GetDiffuseSampler()); auto& overlayMap = matEntry.overlayMap; for (auto& overlayIt : overlayMap) @@ -350,7 +350,7 @@ namespace Nz std::size_t spriteChainCount = spriteChainVector.size(); if (spriteChainCount > 0) { - Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture); + Renderer::SetTexture(overlayTextureUnit, (overlay) ? overlay : &m_whiteTexture); std::size_t spriteChain = 0; // Which chain of sprites are we treating std::size_t spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain @@ -616,8 +616,7 @@ namespace Nz if (matEntry.enabled) { - UInt8 freeTextureUnit; - material->Apply(pipelineInstance, 0, &freeTextureUnit); + material->Apply(pipelineInstance); ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; @@ -688,8 +687,8 @@ namespace Nz } // Sends the uniforms - for (std::size_t i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i); + for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) + SendLightUniforms(shader, shaderUniforms->lightUniforms, i, lightIndex++, shaderUniforms->lightOffset * i); } const Matrix4f* instanceMatrices = &instances[0]; @@ -747,8 +746,8 @@ namespace Nz } // Sends the light uniforms to the shader - for (std::size_t i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); + for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) + SendLightUniforms(shader, shaderUniforms->lightUniforms, i, lightIndex++, shaderUniforms->lightOffset*i); // And we draw drawFunc(meshData.primitiveMode, 0, indexCount); @@ -812,8 +811,7 @@ namespace Nz } // We begin to apply the material - UInt8 freeTextureUnit; - material->Apply(*pipelineInstance, 0, &freeTextureUnit); + material->Apply(*pipelineInstance); // Uniforms are conserved in our program, there's no point to send them back until they change const Shader* shader = pipelineInstance->uberInstance->GetShader(); @@ -833,7 +831,7 @@ namespace Nz lightCount = std::min(m_renderQueue.directionalLights.size(), static_cast(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS)); for (std::size_t i = 0; i < lightCount; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, i, shaderUniforms->lightOffset * i, freeTextureUnit++); + SendLightUniforms(shader, shaderUniforms->lightUniforms, i, i, shaderUniforms->lightOffset * i); } lastShader = shader; @@ -872,7 +870,7 @@ namespace Nz ChooseLights(Spheref(position, radius), false); for (std::size_t i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, i, shaderUniforms->lightOffset*i, freeTextureUnit++); + SendLightUniforms(shader, shaderUniforms->lightUniforms, i, i, shaderUniforms->lightOffset*i); } Renderer::SetMatrix(MatrixType_World, matrix); @@ -915,9 +913,7 @@ namespace Nz uniforms.lightUniforms.locations.parameters1 = shader->GetUniformLocation("Lights[0].parameters1"); uniforms.lightUniforms.locations.parameters2 = shader->GetUniformLocation("Lights[0].parameters2"); uniforms.lightUniforms.locations.parameters3 = shader->GetUniformLocation("Lights[0].parameters3"); - uniforms.lightUniforms.locations.pointLightShadowMap = shader->GetUniformLocation("PointLightShadowMap[0]"); uniforms.lightUniforms.locations.shadowMapping = shader->GetUniformLocation("Lights[0].shadowMapping"); - uniforms.lightUniforms.locations.directionalSpotLightShadowMap = shader->GetUniformLocation("DirectionalSpotLightShadowMap[0]"); } else uniforms.hasLightUniforms = false; @@ -939,6 +935,107 @@ namespace Nz m_shaderUniforms.erase(shader); } + /*! + * \brief Sends the uniforms for light + * + * \param shader Shader to send uniforms to + * \param uniforms Uniforms to send + * \param index Index of the light + * \param uniformOffset Offset for the uniform + * \param availableTextureUnit Unit texture available + */ + void ForwardRenderTechnique::SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int lightIndex, unsigned int uniformOffset) const + { + if (lightIndex < m_lights.size()) + { + const LightIndex& lightInfo = m_lights[lightIndex]; + + shader->SendInteger(uniforms.locations.type + uniformOffset, lightInfo.type); //< Sends the light type + + switch (lightInfo.type) + { + case LightType_Directional: + { + const auto& light = m_renderQueue.directionalLights[lightInfo.index]; + + shader->SendColor(uniforms.locations.color + uniformOffset, light.color); + shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor)); + shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.direction)); + + if (uniforms.locations.shadowMapping != -1) + shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + + if (light.shadowMap) + { + unsigned int textureUnit2D = Material::GetTextureUnit(static_cast(TextureMap_Shadow2D_1 + index)); + + Renderer::SetTexture(textureUnit2D, light.shadowMap); + Renderer::SetTextureSampler(textureUnit2D, s_shadowSampler); + + if (uniforms.locations.lightViewProjMatrix != -1) + shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); + } + break; + } + + case LightType_Point: + { + const auto& light = m_renderQueue.pointLights[lightInfo.index]; + + shader->SendColor(uniforms.locations.color + uniformOffset, light.color); + shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor)); + shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.position, light.attenuation)); + shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(0.f, 0.f, 0.f, light.invRadius)); + + if (uniforms.locations.shadowMapping != -1) + shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + + unsigned int textureUnit = Material::GetTextureUnit(static_cast(TextureMap_ShadowCube_1 + index)); + if (light.shadowMap) + { + unsigned int textureUnitCube = Material::GetTextureUnit(static_cast(TextureMap_ShadowCube_1 + index)); + + Renderer::SetTexture(textureUnitCube, light.shadowMap); + Renderer::SetTextureSampler(textureUnitCube, s_shadowSampler); + } + break; + } + + case LightType_Spot: + { + const auto& light = m_renderQueue.spotLights[lightInfo.index]; + + shader->SendColor(uniforms.locations.color + uniformOffset, light.color); + shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor)); + shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.position, light.attenuation)); + shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(light.direction, light.invRadius)); + shader->SendVector(uniforms.locations.parameters3 + uniformOffset, Vector2f(light.innerAngleCosine, light.outerAngleCosine)); + + if (uniforms.locations.shadowMapping != -1) + shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + + unsigned int textureUnit = Material::GetTextureUnit(static_cast(TextureMap_Shadow2D_1 + index)); + if (light.shadowMap) + { + unsigned int textureUnit2D = Material::GetTextureUnit(static_cast(TextureMap_Shadow2D_1 + index)); + + Renderer::SetTexture(textureUnit2D, light.shadowMap); + Renderer::SetTextureSampler(textureUnit2D, s_shadowSampler); + + if (uniforms.locations.lightViewProjMatrix != -1) + shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); + } + break; + } + } + } + else + { + if (uniforms.locations.type != -1) + shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader + } + } + IndexBuffer ForwardRenderTechnique::s_quadIndexBuffer; TextureSampler ForwardRenderTechnique::s_shadowSampler; VertexBuffer ForwardRenderTechnique::s_quadVertexBuffer; diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index b81bd82b4..d833a601d 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -36,7 +36,7 @@ namespace Nz * \param textureUnit Unit for the texture GL_TEXTURE"i" * \param lastUsedUnit Optional argument to get the last texture unit */ - void Material::Apply(const MaterialPipeline::Instance& instance, UInt8 textureUnit, UInt8* lastUsedUnit) const + void Material::Apply(const MaterialPipeline::Instance& instance) const { const Shader* shader = instance.renderPipeline.GetInfo().shader; @@ -57,54 +57,51 @@ namespace Nz if (m_alphaMap && instance.uniforms[MaterialUniform_AlphaMap] != -1) { + unsigned int textureUnit = s_textureUnits[TextureMap_Alpha]; + Renderer::SetTexture(textureUnit, m_alphaMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - shader->SendInteger(instance.uniforms[MaterialUniform_AlphaMap], textureUnit); - textureUnit++; } if (m_diffuseMap && instance.uniforms[MaterialUniform_DiffuseMap] != -1) { + unsigned int textureUnit = s_textureUnits[TextureMap_Diffuse]; + Renderer::SetTexture(textureUnit, m_diffuseMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - shader->SendInteger(instance.uniforms[MaterialUniform_DiffuseMap], textureUnit); - textureUnit++; } if (m_emissiveMap && instance.uniforms[MaterialUniform_EmissiveMap] != -1) { + unsigned int textureUnit = s_textureUnits[TextureMap_Emissive]; + Renderer::SetTexture(textureUnit, m_emissiveMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - shader->SendInteger(instance.uniforms[MaterialUniform_EmissiveMap], textureUnit); - textureUnit++; } if (m_heightMap && instance.uniforms[MaterialUniform_HeightMap] != -1) { + unsigned int textureUnit = s_textureUnits[TextureMap_Height]; + Renderer::SetTexture(textureUnit, m_heightMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - shader->SendInteger(instance.uniforms[MaterialUniform_HeightMap], textureUnit); - textureUnit++; } if (m_normalMap && instance.uniforms[MaterialUniform_NormalMap] != -1) { + unsigned int textureUnit = s_textureUnits[TextureMap_Normal]; + Renderer::SetTexture(textureUnit, m_normalMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - shader->SendInteger(instance.uniforms[MaterialUniform_NormalMap], textureUnit); - textureUnit++; } if (m_specularMap && instance.uniforms[MaterialUniform_SpecularMap] != -1) { + unsigned int textureUnit = s_textureUnits[TextureMap_Specular]; + Renderer::SetTexture(textureUnit, m_specularMap); Renderer::SetTextureSampler(textureUnit, m_specularSampler); - shader->SendInteger(instance.uniforms[MaterialUniform_SpecularMap], textureUnit); - textureUnit++; } - - if (lastUsedUnit) - *lastUsedUnit = textureUnit; } /*! @@ -459,6 +456,23 @@ namespace Nz s_defaultMaterial->SetFaceFilling(FaceFilling_Line); MaterialLibrary::Register("Default", s_defaultMaterial); + unsigned int textureUnit = 0; + + s_textureUnits[TextureMap_Diffuse] = textureUnit++; + s_textureUnits[TextureMap_Alpha] = textureUnit++; + s_textureUnits[TextureMap_Specular] = textureUnit++; + s_textureUnits[TextureMap_Normal] = textureUnit++; + s_textureUnits[TextureMap_Emissive] = textureUnit++; + s_textureUnits[TextureMap_Overlay] = textureUnit++; + s_textureUnits[TextureMap_ReflectionCube] = textureUnit++; + s_textureUnits[TextureMap_Height] = textureUnit++; + s_textureUnits[TextureMap_Shadow2D_1] = textureUnit++; + s_textureUnits[TextureMap_ShadowCube_1] = textureUnit++; + s_textureUnits[TextureMap_Shadow2D_2] = textureUnit++; + s_textureUnits[TextureMap_ShadowCube_2] = textureUnit++; + s_textureUnits[TextureMap_Shadow2D_3] = textureUnit++; + s_textureUnits[TextureMap_ShadowCube_3] = textureUnit++; + return true; } @@ -473,6 +487,7 @@ namespace Nz MaterialLibrary::Uninitialize(); } + std::array Material::s_textureUnits; MaterialLibrary::LibraryMap Material::s_library; MaterialLoader::LoaderList Material::s_loaders; MaterialManager::ManagerMap Material::s_managerMap; diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 07865c4cd..e8799fdd1 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -3,12 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include - -#ifndef NAZARA_RENDERER_OPENGL -#define NAZARA_RENDERER_OPENGL // Mandatory to include the OpenGL headers -#endif - -#include +#include #include #include @@ -106,6 +101,25 @@ namespace Nz CacheUniform(SpecularMap); #undef CacheUniform + + // Send texture units (those never changes) + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_AlphaMap], Material::GetTextureUnit(TextureMap_Alpha)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_DiffuseMap], Material::GetTextureUnit(TextureMap_Diffuse)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_EmissiveMap], Material::GetTextureUnit(TextureMap_Emissive)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_HeightMap], Material::GetTextureUnit(TextureMap_Height)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_NormalMap], Material::GetTextureUnit(TextureMap_Normal)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_SpecularMap], Material::GetTextureUnit(TextureMap_Specular)); + + renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("ReflectionMap"), Material::GetTextureUnit(TextureMap_ReflectionCube)); + renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("TextureOverlay"), Material::GetTextureUnit(TextureMap_Overlay)); + + renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("DirectionalSpotLightShadowMap[0]"), Material::GetTextureUnit(TextureMap_Shadow2D_1)); + renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("DirectionalSpotLightShadowMap[1]"), Material::GetTextureUnit(TextureMap_Shadow2D_2)); + renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("DirectionalSpotLightShadowMap[2]"), Material::GetTextureUnit(TextureMap_Shadow2D_3)); + + renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("PointLightShadowMap[0]"), Material::GetTextureUnit(TextureMap_ShadowCube_1)); + renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("PointLightShadowMap[1]"), Material::GetTextureUnit(TextureMap_ShadowCube_2)); + renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("PointLightShadowMap[2]"), Material::GetTextureUnit(TextureMap_ShadowCube_3)); } bool MaterialPipeline::Initialize() @@ -178,4 +192,4 @@ namespace Nz MaterialPipelineLibrary::LibraryMap MaterialPipeline::s_library; MaterialPipeline::PipelineCache MaterialPipeline::s_pipelineCache; -} \ No newline at end of file +} From 459c5e7a0903f0aea33945e3f0d55038b5b664e8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 18 Dec 2016 01:16:26 +0100 Subject: [PATCH 014/243] =?UTF-8?q?Graphics/Shaders:=20Add=20possibility?= =?UTF-8?q?=20to=20override=20=C3=9Cber-shaders=20at=20runtime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Nazara/Graphics/MaterialPipeline.cpp | 39 +++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index e8799fdd1..e9f947c90 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -3,6 +3,8 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include #include #include #include @@ -26,6 +28,25 @@ namespace Nz const UInt8 r_phongLightingVertexShader[] = { #include }; + + void OverrideShader(const String& path, String* source) + { + File shaderFile(path, Nz::OpenMode_ReadOnly | Nz::OpenMode_Text); + if (shaderFile.IsOpen()) + { + StringStream shaderSource; + + while (!shaderFile.EndOfFile()) + { + shaderSource << shaderFile.ReadLine(); + shaderSource << '\n'; + } + + *source = shaderSource; + + NazaraNotice(path + " will be used to override built-in shader"); + } + } } /*! @@ -103,11 +124,11 @@ namespace Nz #undef CacheUniform // Send texture units (those never changes) - renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_AlphaMap], Material::GetTextureUnit(TextureMap_Alpha)); - renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_DiffuseMap], Material::GetTextureUnit(TextureMap_Diffuse)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_AlphaMap], Material::GetTextureUnit(TextureMap_Alpha)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_DiffuseMap], Material::GetTextureUnit(TextureMap_Diffuse)); renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_EmissiveMap], Material::GetTextureUnit(TextureMap_Emissive)); - renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_HeightMap], Material::GetTextureUnit(TextureMap_Height)); - renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_NormalMap], Material::GetTextureUnit(TextureMap_Normal)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_HeightMap], Material::GetTextureUnit(TextureMap_Height)); + renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_NormalMap], Material::GetTextureUnit(TextureMap_Normal)); renderPipelineInfo.shader->SendInteger(instance.uniforms[MaterialUniform_SpecularMap], Material::GetTextureUnit(TextureMap_Specular)); renderPipelineInfo.shader->SendInteger(renderPipelineInfo.shader->GetUniformLocation("ReflectionMap"), Material::GetTextureUnit(TextureMap_ReflectionCube)); @@ -131,6 +152,11 @@ namespace Nz String fragmentShader(reinterpret_cast(r_basicFragmentShader), sizeof(r_basicFragmentShader)); String vertexShader(reinterpret_cast(r_basicVertexShader), sizeof(r_basicVertexShader)); + #ifdef NAZARA_DEBUG + OverrideShader("Shaders/Basic/core.frag", &fragmentShader); + OverrideShader("Shaders/Basic/core.vert", &vertexShader); + #endif + uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING"); uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_INSTANCING FLAG_VERTEXCOLOR TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); @@ -144,6 +170,11 @@ namespace Nz String fragmentShader(reinterpret_cast(r_phongLightingFragmentShader), sizeof(r_phongLightingFragmentShader)); String vertexShader(reinterpret_cast(r_phongLightingVertexShader), sizeof(r_phongLightingVertexShader)); + #ifdef NAZARA_DEBUG + OverrideShader("Shaders/PhongLighting/core.frag", &fragmentShader); + OverrideShader("Shaders/PhongLighting/core.vert", &vertexShader); + #endif + uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_DEFERRED FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING EMISSIVE_MAPPING NORMAL_MAPPING PARALLAX_MAPPING SHADOW_MAPPING SPECULAR_MAPPING"); uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_DEFERRED FLAG_INSTANCING FLAG_VERTEXCOLOR COMPUTE_TBNMATRIX PARALLAX_MAPPING SHADOW_MAPPING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); From b64aa726268dc81bb0d76957ba9836697e7f9356 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 18 Dec 2016 01:23:46 +0100 Subject: [PATCH 015/243] Renderer/UberShaderPreprocessor: Fix compile error --- src/Nazara/Renderer/UberShaderPreprocessor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/UberShaderPreprocessor.cpp b/src/Nazara/Renderer/UberShaderPreprocessor.cpp index ba1ed2ccc..b7adc03ee 100644 --- a/src/Nazara/Renderer/UberShaderPreprocessor.cpp +++ b/src/Nazara/Renderer/UberShaderPreprocessor.cpp @@ -95,7 +95,7 @@ namespace Nz { ErrorFlags errFlags(ErrorFlag_ThrowExceptionDisabled); - NazaraError("Shader code failed to compile:\n" + code); + NazaraError("Shader code failed to compile (" + stage.GetLog() + ")\n" + code.ToString()); throw; } From e36374dfc4cb591932dc48935c8691fc21053123 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 19 Dec 2016 18:23:24 +0100 Subject: [PATCH 016/243] SDK/Lua: Fix EulerAngles constructor --- SDK/src/NDK/Lua/LuaBinding_Math.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/Lua/LuaBinding_Math.cpp b/SDK/src/NDK/Lua/LuaBinding_Math.cpp index 6d30bb137..42403a443 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Math.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Math.cpp @@ -20,7 +20,7 @@ namespace Ndk { eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) { - std::size_t argCount = std::min(argumentCount, 1U); + std::size_t argCount = std::min(argumentCount, 3U); switch (argCount) { From a00dd39c51be32bb54234ea7deb8fd8b31aa806b Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 21 Dec 2016 18:25:22 +0100 Subject: [PATCH 017/243] Graphics/MaterialPipeline: Fix error when failing to override a shader --- src/Nazara/Graphics/MaterialPipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index e9f947c90..388de632e 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -31,6 +31,8 @@ namespace Nz void OverrideShader(const String& path, String* source) { + ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled); + File shaderFile(path, Nz::OpenMode_ReadOnly | Nz::OpenMode_Text); if (shaderFile.IsOpen()) { From 645e4aed17871538cf0dd3f63f0f8d05059fd480 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 28 Dec 2016 18:11:19 +0100 Subject: [PATCH 018/243] Examples/Particles: Disable compatibility profile by default --- examples/Particles/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/Particles/main.cpp b/examples/Particles/main.cpp index 67bf99754..bf230bfe7 100644 --- a/examples/Particles/main.cpp +++ b/examples/Particles/main.cpp @@ -17,8 +17,6 @@ int main() { - Nz::ContextParameters::defaultCompatibilityProfile = true; - Ndk::Application app; // Mix all sounds in mono (in order to give them 3D position) From c9b84e3852b0494e1806c785edff3932a3ead8e0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 11 Jan 2017 17:12:35 +0100 Subject: [PATCH 019/243] Core/Signal: Make move constructor/operator noexcept --- include/Nazara/Core/Signal.hpp | 4 ++-- include/Nazara/Core/Signal.inl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index 613502f80..897c32ef9 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -33,7 +33,7 @@ namespace Nz Signal(); Signal(const Signal&) = delete; - Signal(Signal&& signal); + Signal(Signal&& signal) noexcept; ~Signal() = default; void Clear(); @@ -48,7 +48,7 @@ namespace Nz void operator()(Args... args) const; Signal& operator=(const Signal&) = delete; - Signal& operator=(Signal&& signal); + Signal& operator=(Signal&& signal) noexcept; private: struct Slot; diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index 93e0166c0..07a950d89 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -32,7 +32,7 @@ namespace Nz */ template - Signal::Signal(Signal&& signal) + Signal::Signal(Signal&& signal) noexcept { operator=(std::move(signal)); } @@ -182,7 +182,7 @@ namespace Nz */ template - Signal& Signal::operator=(Signal&& signal) + Signal& Signal::operator=(Signal&& signal) noexcept { m_slots = std::move(signal.m_slots); m_slotIterator = signal.m_slotIterator; From 4f1438f0f1acec0c6b4b6095b9df45ee0fa73024 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 11 Jan 2017 18:27:32 +0100 Subject: [PATCH 020/243] SDK/BaseWidget: Add OnParentResized method --- SDK/include/NDK/BaseWidget.hpp | 2 ++ SDK/include/NDK/BaseWidget.inl | 9 ++++++++- SDK/src/NDK/BaseWidget.cpp | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 1e6fe7c64..9ec787890 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -78,11 +78,13 @@ namespace Ndk virtual void OnMouseButtonPress(int x, int y, Nz::Mouse::Button button); virtual void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button); virtual void OnMouseExit(); + virtual void OnParentResized(const Nz::Vector2f& newSize); virtual void OnTextEntered(char32_t character, bool repeated); private: inline BaseWidget(); + inline void NotifyParentResized(const Nz::Vector2f& newSize); inline void UpdateCanvasIndex(std::size_t index); std::size_t m_canvasIndex; diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 0b13ee7c7..4bc1be8b3 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -63,8 +63,9 @@ namespace Ndk inline void BaseWidget::SetContentSize(const Nz::Vector2f& size) { + NotifyParentResized(size); m_contentSize = size; - + Layout(); } @@ -78,6 +79,12 @@ namespace Ndk Layout(); } + inline void BaseWidget::NotifyParentResized(const Nz::Vector2f& newSize) + { + for (const auto& widgetPtr : m_children) + widgetPtr->OnParentResized(newSize); + } + inline void BaseWidget::UpdateCanvasIndex(std::size_t index) { m_canvasIndex = index; diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 43ffbeb52..dcaccd756 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -126,6 +126,10 @@ namespace Ndk { } + void BaseWidget::OnParentResized(const Nz::Vector2f& newSize) + { + } + void BaseWidget::OnTextEntered(char32_t character, bool repeated) { } From d57498be108f32dc59d0463f49bfbf2cf56472cb Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 11 Jan 2017 19:13:40 +0100 Subject: [PATCH 021/243] Sdk/BaseWidget: Widget::Add now returns a pointer (easier to use) --- SDK/include/NDK/BaseWidget.hpp | 2 +- SDK/include/NDK/BaseWidget.inl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 9ec787890..e2fe6d438 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -32,7 +32,7 @@ namespace Ndk BaseWidget(BaseWidget&&) = default; virtual ~BaseWidget(); - template T& Add(Args&&... args); + template T* Add(Args&&... args); inline void AddChild(std::unique_ptr&& widget); inline void Center(); diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 4bc1be8b3..aa2b222b6 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -18,13 +18,13 @@ namespace Ndk } template - inline T& BaseWidget::Add(Args&&... args) + inline T* BaseWidget::Add(Args&&... args) { std::unique_ptr widget = std::make_unique(this, std::forward(args)...); - T& widgetRef = *widget; + T* widgetPtr = widget.get(); AddChild(std::move(widget)); - return widgetRef; + return widgetPtr; } inline void BaseWidget::AddChild(std::unique_ptr&& widget) From 6acf101d77eb6c6b0fcd2e1af99e1fa039e63ebe Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 11 Jan 2017 19:14:21 +0100 Subject: [PATCH 022/243] Sdk/BaseWidget: Fix crash at Canvas destruction --- SDK/include/NDK/BaseWidget.inl | 2 ++ SDK/src/NDK/BaseWidget.cpp | 3 ++- SDK/src/NDK/Canvas.cpp | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index aa2b222b6..1833a2224 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -5,10 +5,12 @@ #include #include #include +#include namespace Ndk { inline BaseWidget::BaseWidget() : + m_canvasIndex(std::numeric_limits::max()), m_backgroundColor(Nz::Color(230, 230, 230, 255)), m_canvas(nullptr), m_contentSize(50.f, 50.f), diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index dcaccd756..b7476dd30 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -25,7 +25,8 @@ namespace Ndk BaseWidget::~BaseWidget() { - m_canvas->UnregisterWidget(m_canvasIndex); + if (m_canvasIndex != std::numeric_limits::max()) + m_canvas->UnregisterWidget(m_canvasIndex); } inline void BaseWidget::EnableBackground(bool enable) diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index c06d320c1..b13b7ef6a 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -49,21 +49,23 @@ namespace Ndk void Canvas::UnregisterWidget(std::size_t index) { + WidgetBox& entry = m_widgetBoxes[index]; + + if (m_hoveredWidget == &entry) + m_hoveredWidget = nullptr; + + if (m_keyboardOwner == entry.widget) + m_keyboardOwner = nullptr; + if (m_widgetBoxes.size() > 1U) { - WidgetBox& entry = m_widgetBoxes[index]; WidgetBox& lastEntry = m_widgetBoxes.back(); - if (m_hoveredWidget == &entry) - m_hoveredWidget = nullptr; - - if (m_keyboardOwner == entry.widget) - m_keyboardOwner = nullptr; - entry = std::move(lastEntry); entry.widget->UpdateCanvasIndex(index); - m_widgetBoxes.pop_back(); } + + m_widgetBoxes.pop_back(); } void Canvas::OnMouseButtonPressed(const Nz::EventHandler* /*eventHandler*/, const Nz::WindowEvent::MouseButtonEvent& event) From fd923ed58b252e9de8ddd55749eec2451c5b1125 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 11 Jan 2017 19:14:32 +0100 Subject: [PATCH 023/243] Sdk/BaseWidget: Add Destroy method --- SDK/include/NDK/BaseWidget.hpp | 3 +++ SDK/src/NDK/BaseWidget.cpp | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index e2fe6d438..76def4b1b 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -37,6 +37,8 @@ namespace Ndk inline void Center(); + inline void Destroy(); + void EnableBackground(bool enable); //virtual BaseWidget* Clone() const = 0; @@ -84,6 +86,7 @@ namespace Ndk private: inline BaseWidget(); + inline void DestroyChild(BaseWidget* widget); inline void NotifyParentResized(const Nz::Vector2f& newSize); inline void UpdateCanvasIndex(std::size_t index); diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index b7476dd30..c627019ea 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace Ndk { @@ -29,7 +30,14 @@ namespace Ndk m_canvas->UnregisterWidget(m_canvasIndex); } - inline void BaseWidget::EnableBackground(bool enable) + void BaseWidget::Destroy() + { + NazaraAssert(this != m_canvas, "Canvas cannot be destroyed by calling Destroy()"); + + m_widgetParent->DestroyChild(this); //< This does delete us + } + + void BaseWidget::EnableBackground(bool enable) { if (m_backgroundEntity.IsValid() == enable) return; @@ -134,4 +142,16 @@ namespace Ndk void BaseWidget::OnTextEntered(char32_t character, bool repeated) { } + + void BaseWidget::DestroyChild(BaseWidget* widget) + { + auto it = std::find_if(m_children.begin(), m_children.end(), [widget] (const std::unique_ptr& widgetPtr) -> bool + { + return widgetPtr.get() == widget; + }); + + NazaraAssert(it != m_children.end(), "Child widget not found in parent"); + + m_children.erase(it); + } } From 14e327c603e35f16a6052b99c58c03ea5ae3031a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Jan 2017 12:11:15 +0100 Subject: [PATCH 024/243] Sdk/TextAreaWidget: Add SetTextColor --- SDK/include/NDK/Widgets/TextAreaWidget.hpp | 4 +++- SDK/include/NDK/Widgets/TextAreaWidget.inl | 19 +++++++++++++++++++ SDK/src/NDK/Widgets/TextAreaWidget.cpp | 7 ------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.hpp b/SDK/include/NDK/Widgets/TextAreaWidget.hpp index 8236b1689..2b0774ec8 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.hpp +++ b/SDK/include/NDK/Widgets/TextAreaWidget.hpp @@ -35,6 +35,7 @@ namespace Ndk inline std::size_t GetCursorPosition() const; inline std::size_t GetLineCount() const; inline const Nz::String& GetText() const; + inline const Nz::Color& GetTextColor() const; std::size_t GetHoveredGlyph(float x, float y) const; @@ -47,7 +48,8 @@ namespace Ndk inline void SetCursorPosition(std::size_t cursorPosition); inline void SetReadOnly(bool readOnly = true); - void SetText(const Nz::String& text); + inline void SetText(const Nz::String& text); + inline void SetTextColor(const Nz::Color& text); void Write(const Nz::String& text); diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.inl b/SDK/include/NDK/Widgets/TextAreaWidget.inl index d923e7223..711f8de8c 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.inl +++ b/SDK/include/NDK/Widgets/TextAreaWidget.inl @@ -35,6 +35,11 @@ namespace Ndk return m_drawer.GetText(); } + inline const Nz::Color& TextAreaWidget::GetTextColor() const + { + return m_drawer.GetColor(); + } + inline bool Ndk::TextAreaWidget::IsMultilineEnabled() const { return m_multiLineEnabled; @@ -72,4 +77,18 @@ namespace Ndk m_cursorEntity->Enable(!m_readOnly); } + + inline void TextAreaWidget::SetText(const Nz::String& text) + { + m_drawer.SetText(text); + + m_textSprite->Update(m_drawer); + } + + inline void TextAreaWidget::SetTextColor(const Nz::Color& text) + { + m_drawer.SetColor(text); + + m_textSprite->Update(m_drawer); + } } diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 0e0f82f57..0c9b7b3d5 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -77,13 +77,6 @@ namespace Ndk SetContentSize(Nz::Vector2f(m_textSprite->GetBoundingVolume().obb.localBox.GetLengths())); } - void TextAreaWidget::SetText(const Nz::String& text) - { - m_drawer.SetText(text); - - m_textSprite->Update(m_drawer); - } - void TextAreaWidget::Write(const Nz::String& text) { if (m_cursorPosition >= m_drawer.GetGlyphCount()) From 58656798914443f8b272e0c64d6e1c37bb7fd278 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Jan 2017 12:11:59 +0100 Subject: [PATCH 025/243] Sdk/BaseWidget: Add a way to change background color --- SDK/include/NDK/BaseWidget.hpp | 2 ++ SDK/include/NDK/BaseWidget.inl | 5 +++++ SDK/src/NDK/BaseWidget.cpp | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 76def4b1b..aa47446f3 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -43,6 +43,7 @@ namespace Ndk //virtual BaseWidget* Clone() const = 0; + inline const Nz::Color& GetBackgroundColor() const; inline Canvas* GetCanvas(); inline const Padding& GetPadding() const; inline const Nz::Vector2f& GetContentSize() const; @@ -52,6 +53,7 @@ namespace Ndk virtual void ResizeToContent() = 0; + void SetBackgroundColor(const Nz::Color& color); inline void SetContentSize(const Nz::Vector2f& size); inline void SetPadding(float left, float top, float right, float bottom); void SetSize(const Nz::Vector2f& size); diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 1833a2224..d5a91a2ed 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -43,6 +43,11 @@ namespace Ndk SetPosition((parentSize.x - mySize.x) / 2.f, (parentSize.y - mySize.y) / 2.f); } + inline const Nz::Color& BaseWidget::GetBackgroundColor() const + { + return m_backgroundColor; + } + inline Canvas* BaseWidget::GetCanvas() { return m_canvas; diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index c627019ea..8bcf972d3 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -61,6 +61,17 @@ namespace Ndk } } + void BaseWidget::SetBackgroundColor(const Nz::Color& color) + { + m_backgroundColor = color; + + if (m_backgroundSprite) + { + m_backgroundSprite->SetColor(color); + m_backgroundSprite->GetMaterial()->Configure((color.IsOpaque()) ? "Basic2D" : "Translucent2D"); //< Our sprite has its own material (see EnableBackground) + } + } + void BaseWidget::SetSize(const Nz::Vector2f& size) { SetContentSize({std::max(size.x - m_padding.left - m_padding.right, 0.f), std::max(size.y - m_padding.top - m_padding.bottom, 0.f)}); From e1e290808a15ce3ba59607b9f1fadebd964809b5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Jan 2017 12:12:58 +0100 Subject: [PATCH 026/243] Sdk/Canvas: Fix crash at Canvas destruction --- SDK/include/NDK/BaseWidget.hpp | 1 + SDK/include/NDK/Canvas.hpp | 2 +- SDK/include/NDK/Canvas.inl | 6 ++++++ SDK/src/NDK/BaseWidget.cpp | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index aa47446f3..22bfa9dcf 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -89,6 +89,7 @@ namespace Ndk inline BaseWidget(); inline void DestroyChild(BaseWidget* widget); + void DestroyChildren(); inline void NotifyParentResized(const Nz::Vector2f& newSize); inline void UpdateCanvasIndex(std::size_t index); diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NDK/Canvas.hpp index a8da5d04e..db271051f 100644 --- a/SDK/include/NDK/Canvas.hpp +++ b/SDK/include/NDK/Canvas.hpp @@ -23,7 +23,7 @@ namespace Ndk inline Canvas(WorldHandle world, Nz::EventHandler& eventHandler); Canvas(const Canvas&) = delete; Canvas(Canvas&&) = delete; - ~Canvas() = default; + inline ~Canvas(); inline const WorldHandle& GetWorld() const; diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index d0d05bf12..173474bdf 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -22,6 +22,12 @@ namespace Ndk m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnTextEntered); } + inline Canvas::~Canvas() + { + // Destroy children explicitly because they signal us when getting destroyed, and that can't happend after our own destruction + DestroyChildren(); + } + inline const WorldHandle& Canvas::GetWorld() const { return m_world; diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 8bcf972d3..a65a8a889 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -165,4 +165,9 @@ namespace Ndk m_children.erase(it); } + + void BaseWidget::DestroyChildren() + { + m_children.clear(); + } } From c9458eeb1714e3f5285c40407f75cdfd086ab826 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Jan 2017 12:13:29 +0100 Subject: [PATCH 027/243] Sdk/BaseWidget: Add visibility control --- SDK/include/NDK/BaseWidget.hpp | 5 +++++ SDK/include/NDK/BaseWidget.inl | 9 ++++++++- SDK/src/NDK/BaseWidget.cpp | 33 +++++++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 22bfa9dcf..2bdf0dd81 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -49,6 +49,8 @@ namespace Ndk inline const Nz::Vector2f& GetContentSize() const; inline Nz::Vector2f GetSize() const; + inline bool IsVisible() const; + void GrabKeyboard(); virtual void ResizeToContent() = 0; @@ -58,6 +60,8 @@ namespace Ndk inline void SetPadding(float left, float top, float right, float bottom); void SetSize(const Nz::Vector2f& size); + void Show(bool show = true); + BaseWidget& operator=(const BaseWidget&) = delete; BaseWidget& operator=(BaseWidget&&) = default; @@ -104,6 +108,7 @@ namespace Ndk Nz::SpriteRef m_backgroundSprite; Nz::Vector2f m_contentSize; BaseWidget* m_widgetParent; + bool m_visible; }; } diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index d5a91a2ed..041abe9bd 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -14,7 +14,8 @@ namespace Ndk m_backgroundColor(Nz::Color(230, 230, 230, 255)), m_canvas(nullptr), m_contentSize(50.f, 50.f), - m_widgetParent(nullptr) + m_widgetParent(nullptr), + m_visible(true) { SetPadding(5.f, 5.f, 5.f, 5.f); } @@ -31,6 +32,7 @@ namespace Ndk inline void BaseWidget::AddChild(std::unique_ptr&& widget) { + widget->Show(m_visible); m_children.emplace_back(std::move(widget)); } @@ -68,6 +70,11 @@ namespace Ndk return Nz::Vector2f(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); } + inline bool BaseWidget::IsVisible() const + { + return m_visible; + } + inline void BaseWidget::SetContentSize(const Nz::Vector2f& size) { NotifyParentResized(size); diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index a65a8a889..69d60965e 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -48,7 +48,7 @@ namespace Ndk m_backgroundSprite->SetColor(m_backgroundColor); m_backgroundSprite->SetMaterial(Nz::Material::New((m_backgroundColor.IsOpaque()) ? "Basic2D" : "Translucent2D")); - m_backgroundEntity = m_world->CreateEntity(); + m_backgroundEntity = CreateEntity(); m_backgroundEntity->AddComponent().Attach(m_backgroundSprite, -1); m_backgroundEntity->AddComponent().SetParent(this); @@ -61,6 +61,11 @@ namespace Ndk } } + void BaseWidget::GrabKeyboard() + { + m_canvas->SetKeyboardOwner(this); + } + void BaseWidget::SetBackgroundColor(const Nz::Color& color) { m_backgroundColor = color; @@ -77,10 +82,27 @@ namespace Ndk SetContentSize({std::max(size.x - m_padding.left - m_padding.right, 0.f), std::max(size.y - m_padding.top - m_padding.bottom, 0.f)}); } + void BaseWidget::Show(bool show) + { + if (m_visible != show) + { + m_visible = show; + + for (const EntityHandle& entity : m_entities) + entity->Enable(show); + + for (const auto& widgetPtr : m_children) + widgetPtr->Show(show); + } + } + EntityHandle BaseWidget::CreateEntity() { - m_entities.emplace_back(m_world->CreateEntity()); - return m_entities.back(); + EntityHandle newEntity = m_world->CreateEntity(); + newEntity->Enable(m_visible); + + m_entities.emplace_back(newEntity); + return newEntity; } void BaseWidget::DestroyEntity(Entity* entity) @@ -91,11 +113,6 @@ namespace Ndk m_entities.erase(it); } - void BaseWidget::GrabKeyboard() - { - m_canvas->SetKeyboardOwner(this); - } - void BaseWidget::Layout() { if (m_canvas) From 954298dc1e02cfed288c4764acf46876301c870a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Jan 2017 22:41:48 +0100 Subject: [PATCH 028/243] Utility/Cursor: Add GetImage() method --- include/Nazara/Utility/Cursor.hpp | 12 ++++++++---- include/Nazara/Utility/Cursor.inl | 31 +++++++++++++++++++++++++++++++ src/Nazara/Utility/Cursor.cpp | 17 ++--------------- 3 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 include/Nazara/Utility/Cursor.inl diff --git a/include/Nazara/Utility/Cursor.hpp b/include/Nazara/Utility/Cursor.hpp index b45fc6a1b..af2a160e1 100644 --- a/include/Nazara/Utility/Cursor.hpp +++ b/include/Nazara/Utility/Cursor.hpp @@ -10,29 +10,33 @@ #include #include #include +#include namespace Nz { class CursorImpl; - class Image; class NAZARA_UTILITY_API Cursor { friend class WindowImpl; public: - Cursor(); - ~Cursor(); + inline Cursor(); + inline ~Cursor(); bool Create(const Image& cursor, int hotSpotX = 0, int hotSpotY = 0); bool Create(const Image& cursor, const Vector2i& hotSpot); void Destroy(); - bool IsValid() const; + inline const Image& GetImage() const; + inline bool IsValid() const; private: + Image m_cursorImage; CursorImpl* m_impl; }; } +#include + #endif // NAZARA_CURSOR_HPP diff --git a/include/Nazara/Utility/Cursor.inl b/include/Nazara/Utility/Cursor.inl new file mode 100644 index 000000000..3073f297e --- /dev/null +++ b/include/Nazara/Utility/Cursor.inl @@ -0,0 +1,31 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline Cursor::Cursor() : + m_impl(nullptr) + { + } + + inline Cursor::~Cursor() + { + Destroy(); + } + + inline const Image& Cursor::GetImage() const + { + return m_cursorImage; + } + + inline bool Cursor::IsValid() const + { + return m_impl != nullptr; + } +} + +#include diff --git a/src/Nazara/Utility/Cursor.cpp b/src/Nazara/Utility/Cursor.cpp index deddbc753..9dafd36bc 100644 --- a/src/Nazara/Utility/Cursor.cpp +++ b/src/Nazara/Utility/Cursor.cpp @@ -16,16 +16,6 @@ namespace Nz { - Cursor::Cursor() : - m_impl(nullptr) - { - } - - Cursor::~Cursor() - { - Destroy(); - } - bool Cursor::Create(const Image& cursor, int hotSpotX, int hotSpotY) { Destroy(); @@ -40,6 +30,8 @@ namespace Nz return false; } + m_cursorImage = cursor; + return true; } @@ -58,9 +50,4 @@ namespace Nz m_impl = nullptr; } } - - bool Cursor::IsValid() const - { - return m_impl != nullptr; - } } From f406068c45ceac40080ee0fa880c143ee7cd87a5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 16 Jan 2017 00:32:59 +0100 Subject: [PATCH 029/243] Utility: Rework cursors -Rename WindowCursor to SystemCursor -Merged Cursor class with SystemCursor enum --- examples/FirstScene/main.cpp | 2 +- examples/Particles/SpacebattleDemo.cpp | 2 +- include/Nazara/Utility/Cursor.hpp | 16 ++++- include/Nazara/Utility/Cursor.inl | 40 +++++++++++- include/Nazara/Utility/Enums.hpp | 50 +++++++-------- include/Nazara/Utility/Window.hpp | 1 - src/Nazara/Utility/Cursor.cpp | 39 +++++++++--- src/Nazara/Utility/Win32/CursorImpl.cpp | 56 +++++++++++++++- src/Nazara/Utility/Win32/CursorImpl.hpp | 14 +++- src/Nazara/Utility/Win32/WindowImpl.cpp | 46 ------------- src/Nazara/Utility/Win32/WindowImpl.hpp | 3 +- src/Nazara/Utility/Window.cpp | 30 +-------- src/Nazara/Utility/X11/CursorImpl.cpp | 82 +++++++++++++++++++++++- src/Nazara/Utility/X11/CursorImpl.hpp | 13 +++- src/Nazara/Utility/X11/WindowImpl.cpp | 85 ++----------------------- src/Nazara/Utility/X11/WindowImpl.hpp | 4 +- 16 files changed, 281 insertions(+), 202 deletions(-) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 863d3edea..b7e7d1198 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -251,7 +251,7 @@ int main() } // On fait disparaître le curseur de la souris - window.SetCursor(Nz::WindowCursor_None); + window.SetCursor(Nz::SystemCursor_None); // On lie la caméra à la fenêtre cameraComp.SetTarget(&window); diff --git a/examples/Particles/SpacebattleDemo.cpp b/examples/Particles/SpacebattleDemo.cpp index 8cc1558c6..7f2cd6b4c 100644 --- a/examples/Particles/SpacebattleDemo.cpp +++ b/examples/Particles/SpacebattleDemo.cpp @@ -644,7 +644,7 @@ void SpacebattleExample::Enter(Ndk::StateMachine& fsm) m_turretReloadSound.LoadFromFile("resources/turretReload.wav"); //m_onMouseMoved.Connect(m_shared.target->GetEventHandler().OnMouseMoved, this, &SpacebattleExample::OnMouseMoved); - //m_shared.target->SetCursor(Nz::WindowCursor_None); + //m_shared.target->SetCursor(Nz::SystemCursor_None); ////////////////////////////////////////////////////////////////////////// diff --git a/include/Nazara/Utility/Cursor.hpp b/include/Nazara/Utility/Cursor.hpp index af2a160e1..ae8dd08b5 100644 --- a/include/Nazara/Utility/Cursor.hpp +++ b/include/Nazara/Utility/Cursor.hpp @@ -22,18 +22,32 @@ namespace Nz public: inline Cursor(); + inline Cursor(SystemCursor systemCursor); //< implicit conversion intended + Cursor(const Cursor&) = delete; + inline Cursor(Cursor&& cursor) noexcept; inline ~Cursor(); - bool Create(const Image& cursor, int hotSpotX = 0, int hotSpotY = 0); bool Create(const Image& cursor, const Vector2i& hotSpot); + bool Create(SystemCursor cursor); + void Destroy(); inline const Image& GetImage() const; + inline SystemCursor GetSystemCursor() const; + inline bool IsValid() const; + Cursor& operator=(const Cursor&) = delete; + inline Cursor& operator=(Cursor&& cursor); + private: + static bool Initialize(); + static void Uninitialize(); + Image m_cursorImage; + SystemCursor m_systemCursor; CursorImpl* m_impl; + bool m_usesSystemCursor; }; } diff --git a/include/Nazara/Utility/Cursor.inl b/include/Nazara/Utility/Cursor.inl index 3073f297e..dc0ce68db 100644 --- a/include/Nazara/Utility/Cursor.inl +++ b/include/Nazara/Utility/Cursor.inl @@ -3,15 +3,30 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz { inline Cursor::Cursor() : - m_impl(nullptr) + m_impl(nullptr), + m_usesSystemCursor(false) { } + inline Cursor::Cursor(SystemCursor systemCursor) : + Cursor() + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + Create(systemCursor); + } + + inline Cursor::Cursor(Cursor&& cursor) noexcept : + Cursor() + { + operator=(std::move(cursor)); + } + inline Cursor::~Cursor() { Destroy(); @@ -19,13 +34,36 @@ namespace Nz inline const Image& Cursor::GetImage() const { + NazaraAssert(IsValid(), "Invalid cursor"); + NazaraAssert(!m_usesSystemCursor, "System cursors have no image"); + return m_cursorImage; } + inline SystemCursor Cursor::GetSystemCursor() const + { + NazaraAssert(IsValid(), "Invalid cursor"); + NazaraAssert(m_usesSystemCursor, "Custom cursor uses an image"); + + return m_systemCursor; + } + inline bool Cursor::IsValid() const { return m_impl != nullptr; } + + inline Cursor& Cursor::operator=(Cursor&& cursor) + { + m_cursorImage = std::move(cursor.m_cursorImage); + m_systemCursor = cursor.m_systemCursor; + m_impl = cursor.m_impl; + m_usesSystemCursor = cursor.m_usesSystemCursor; + + cursor.m_impl = nullptr; + + return *this; + } } #include diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index fd9001d44..23c71d528 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -307,6 +307,31 @@ namespace Nz SamplerWrap_Max = SamplerWrap_Repeat }; + enum SystemCursor + { + SystemCursor_None, + SystemCursor_Default, + + SystemCursor_Crosshair, + SystemCursor_Hand, + SystemCursor_Help, + SystemCursor_Move, + SystemCursor_Pointer, + SystemCursor_Progress, + SystemCursor_ResizeE, + SystemCursor_ResizeN, + SystemCursor_ResizeNE, + SystemCursor_ResizeNW, + SystemCursor_ResizeS, + SystemCursor_ResizeSE, + SystemCursor_ResizeSW, + SystemCursor_ResizeW, + SystemCursor_Text, + SystemCursor_Wait, + + SystemCursor_Max = SystemCursor_Wait + }; + enum StencilOperation { StencilOperation_Decrement, @@ -393,31 +418,6 @@ namespace Nz VertexLayout_Max = VertexLayout_Matrix4 }; - enum WindowCursor - { - WindowCursor_None, - WindowCursor_Default, - - WindowCursor_Crosshair, - WindowCursor_Hand, - WindowCursor_Help, - WindowCursor_Move, - WindowCursor_Pointer, - WindowCursor_Progress, - WindowCursor_ResizeE, - WindowCursor_ResizeN, - WindowCursor_ResizeNE, - WindowCursor_ResizeNW, - WindowCursor_ResizeS, - WindowCursor_ResizeSE, - WindowCursor_ResizeSW, - WindowCursor_ResizeW, - WindowCursor_Text, - WindowCursor_Wait, - - WindowCursor_Max = WindowCursor_Wait - }; - enum WindowEventType { WindowEventType_GainedFocus, diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index 5ecabd8dd..3dbf9897b 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -79,7 +79,6 @@ namespace Nz void ProcessEvents(bool block = false); - void SetCursor(WindowCursor cursor); void SetCursor(const Cursor& cursor); void SetEventListener(bool listener); void SetFocus(); diff --git a/src/Nazara/Utility/Cursor.cpp b/src/Nazara/Utility/Cursor.cpp index 9dafd36bc..9b9af0fb9 100644 --- a/src/Nazara/Utility/Cursor.cpp +++ b/src/Nazara/Utility/Cursor.cpp @@ -16,28 +16,39 @@ namespace Nz { - bool Cursor::Create(const Image& cursor, int hotSpotX, int hotSpotY) + bool Cursor::Create(const Image& cursor, const Vector2i& hotSpot) { Destroy(); - m_impl = new CursorImpl; - if (!m_impl->Create(cursor, hotSpotX, hotSpotY)) + std::unique_ptr impl(new CursorImpl); + if (!impl->Create(cursor, hotSpot.x, hotSpot.y)) { NazaraError("Failed to create cursor implementation"); - delete m_impl; - m_impl = nullptr; - return false; } m_cursorImage = cursor; + m_impl = impl.release(); return true; } - bool Cursor::Create(const Image& cursor, const Vector2i& hotSpot) + inline bool Cursor::Create(SystemCursor cursor) { - return Create(cursor, hotSpot.x, hotSpot.y); + Destroy(); + + std::unique_ptr impl(new CursorImpl); + if (!impl->Create(cursor)) + { + NazaraError("Failed to create cursor implementation"); + return false; + } + + m_impl = impl.release(); + m_systemCursor = cursor; + m_usesSystemCursor = true; + + return true; } void Cursor::Destroy() @@ -49,5 +60,17 @@ namespace Nz delete m_impl; m_impl = nullptr; } + + m_usesSystemCursor = false; + } + + bool Cursor::Initialize() + { + return CursorImpl::Initialize(); + } + + void Cursor::Uninitialize() + { + CursorImpl::Uninitialize(); } } diff --git a/src/Nazara/Utility/Win32/CursorImpl.cpp b/src/Nazara/Utility/Win32/CursorImpl.cpp index eec8785bb..c4c43a6f1 100644 --- a/src/Nazara/Utility/Win32/CursorImpl.cpp +++ b/src/Nazara/Utility/Win32/CursorImpl.cpp @@ -30,27 +30,77 @@ namespace Nz iconInfo.hbmMask = monoBitmap; iconInfo.hbmColor = bitmap; - m_cursor = CreateIconIndirect(&iconInfo); + m_icon = CreateIconIndirect(&iconInfo); DeleteObject(bitmap); DeleteObject(monoBitmap); - if (!m_cursor) + if (!m_icon) { NazaraError("Failed to create cursor: " + Error::GetLastSystemError()); return false; } + m_cursor = m_icon; + + return true; + } + + bool CursorImpl::Create(SystemCursor cursor) + { + if (cursor != SystemCursor_Move) + m_cursor = static_cast(LoadImage(nullptr, s_systemCursorIds[cursor], IMAGE_CURSOR, 0, 0, LR_SHARED)); + else + m_cursor = nullptr; + + // No need to free the cursor if shared + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx + m_icon = nullptr; + return true; } void CursorImpl::Destroy() { - DestroyIcon(m_cursor); + if (m_icon) + DestroyIcon(m_icon); } HCURSOR CursorImpl::GetCursor() { return m_cursor; } + + bool CursorImpl::Initialize() + { + return true; + } + + void CursorImpl::Uninitialize() + { + } + + std::array CursorImpl::s_systemCursorIds = + { + IDC_CROSS, // SystemCursor_Crosshair + IDC_ARROW, // SystemCursor_Default + IDC_HAND, // SystemCursor_Hand + IDC_HELP, // SystemCursor_Help + IDC_SIZEALL, // SystemCursor_Move + nullptr, // SystemCursor_None + IDC_HAND, // SystemCursor_Pointer + IDC_APPSTARTING, // SystemCursor_Progress + IDC_SIZEWE, // SystemCursor_ResizeE + IDC_SIZENS, // SystemCursor_ResizeN + IDC_SIZENESW, // SystemCursor_ResizeNE + IDC_SIZENWSE, // SystemCursor_ResizeNW + IDC_SIZENS, // SystemCursor_ResizeS + IDC_SIZENWSE, // SystemCursor_ResizeSE + IDC_SIZENESW, // SystemCursor_ResizeSW + IDC_SIZEWE, // SystemCursor_ResizeW + IDC_IBEAM, // SystemCursor_Text + IDC_WAIT // SystemCursor_Wait + }; + + static_assert(SystemCursor_Max + 1 == 18, "System cursor array is incomplete"); } diff --git a/src/Nazara/Utility/Win32/CursorImpl.hpp b/src/Nazara/Utility/Win32/CursorImpl.hpp index 78662228e..c6899ed46 100644 --- a/src/Nazara/Utility/Win32/CursorImpl.hpp +++ b/src/Nazara/Utility/Win32/CursorImpl.hpp @@ -8,6 +8,8 @@ #define NAZARA_CURSORIMPL_HPP #include +#include +#include #include namespace Nz @@ -16,14 +18,24 @@ namespace Nz class CursorImpl { + friend class Cursor; + public: bool Create(const Image& image, int hotSpotX, int hotSpotY); + bool Create(SystemCursor cursor); + void Destroy(); HCURSOR GetCursor(); private: - HICON m_cursor = nullptr; + static bool Initialize(); + static void Uninitialize(); + + HCURSOR m_cursor = nullptr; + HICON m_icon = nullptr; + + static std::array s_systemCursorIds; }; } diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index e32caf95f..74f6fb62b 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -4,8 +4,6 @@ // Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation -#define OEMRESOURCE - #include #include #include @@ -38,30 +36,6 @@ namespace Nz { namespace { - LPTSTR windowsCursors[] = - { - IDC_CROSS, // WindowCursor_Crosshair - IDC_ARROW, // WindowCursor_Default - IDC_HAND, // WindowCursor_Hand - IDC_HAND, // WindowCursor_Pointer - IDC_HELP, // WindowCursor_Help - IDC_SIZEALL, // WindowCursor_Move - nullptr, // WindowCursor_None - IDC_APPSTARTING, // WindowCursor_Progress - IDC_SIZENS, // WindowCursor_ResizeN - IDC_SIZENS, // WindowCursor_ResizeS - IDC_SIZENWSE, // WindowCursor_ResizeNW - IDC_SIZENWSE, // WindowCursor_ResizeSE - IDC_SIZENESW, // WindowCursor_ResizeNE - IDC_SIZENESW, // WindowCursor_ResizeSW - IDC_SIZEWE, // WindowCursor_ResizeE - IDC_SIZEWE, // WindowCursor_ResizeW - IDC_IBEAM, // WindowCursor_Text - IDC_WAIT // WindowCursor_Wait - }; - - static_assert(sizeof(windowsCursors)/sizeof(LPTSTR) == WindowCursor_Max+1, "Cursor type array is incomplete"); - const wchar_t* className = L"Nazara Window"; WindowImpl* fullscreenWindow = nullptr; } @@ -321,26 +295,6 @@ namespace Nz } } - void WindowImpl::SetCursor(WindowCursor cursor) - { - #ifdef NAZARA_DEBUG - if (cursor > WindowCursor_Max) - { - NazaraError("Window cursor out of enum"); - return; - } - #endif - - if (cursor != WindowCursor_None) - m_cursor = static_cast(LoadImage(nullptr, windowsCursors[cursor], IMAGE_CURSOR, 0, 0, LR_SHARED)); - else - m_cursor = nullptr; - - // Pas besoin de libérer le curseur par la suite s'il est partagé - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx - ::SetCursor(m_cursor); - } - void WindowImpl::SetCursor(const Cursor& cursor) { m_cursor = cursor.m_impl->GetCursor(); diff --git a/src/Nazara/Utility/Win32/WindowImpl.hpp b/src/Nazara/Utility/Win32/WindowImpl.hpp index ae08e42ad..36ba5d93b 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.hpp +++ b/src/Nazara/Utility/Win32/WindowImpl.hpp @@ -27,7 +27,7 @@ namespace Nz class Mutex; class Window; - #undef IsMinimized // Conflit avec la méthode du même nom + #undef IsMinimized // Conflits with windows.h redefinition class WindowImpl { @@ -62,7 +62,6 @@ namespace Nz void ProcessEvents(bool block); - void SetCursor(WindowCursor cursor); void SetCursor(const Cursor& cursor); void SetEventListener(bool listener); void SetFocus(); diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 73c91168a..61ca49c80 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -90,7 +90,7 @@ namespace Nz // Paramètres par défaut m_impl->EnableKeyRepeat(true); m_impl->EnableSmoothScrolling(false); - m_impl->SetCursor(WindowCursor_Default); + m_impl->SetCursor(SystemCursor_Default); m_impl->SetMaximumSize(-1, -1); m_impl->SetMinimumSize(-1, -1); m_impl->SetVisible(true); @@ -350,34 +350,10 @@ namespace Nz } } - void Window::SetCursor(WindowCursor cursor) - { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Window not created"); - return; - } - #endif - - m_impl->SetCursor(cursor); - } - void Window::SetCursor(const Cursor& cursor) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Window not created"); - return; - } - - if (!cursor.IsValid()) - { - NazaraError("Cursor is not valid"); - return; - } - #endif + NazaraAssert(m_impl, "Window not created"); + NazaraAssert(cursor.IsValid(), "Invalid cursor"); m_impl->SetCursor(cursor); } diff --git a/src/Nazara/Utility/X11/CursorImpl.cpp b/src/Nazara/Utility/X11/CursorImpl.cpp index d09f51a1f..082825c50 100644 --- a/src/Nazara/Utility/X11/CursorImpl.cpp +++ b/src/Nazara/Utility/X11/CursorImpl.cpp @@ -159,16 +159,96 @@ namespace Nz return true; } + bool CursorImpl::Create(SystemCursor cursor) + { + ScopedXCBConnection connection; + + if (xcb_cursor_context_new(connection, m_screen, &m_cursorContext) >= 0) + m_cursor = xcb_cursor_load_cursor(ctx, s_systemCursorIds[cursor]); + + return true; + } + void CursorImpl::Destroy() { ScopedXCBConnection connection; xcb_free_cursor(connection, m_cursor); - m_cursor = 0; + if (m_cursorContext) + xcb_cursor_context_free(m_cursorContext); } xcb_cursor_t CursorImpl::GetCursor() { return m_cursor; } + + bool CursorImpl::Initialize() + { + ScopedXCBConnection connection; + XCBPixmap cursorPixmap(connection); + + xcb_window_t window = X11::XCBDefaultRootWindow(connection); + + if (!cursorPixmap.Create(1, window, 1, 1)) + { + NazaraError("Failed to create pixmap for hidden cursor"); + return false; + } + + hiddenCursor = xcb_generate_id(connection); + + // Create the cursor, using the pixmap as both the shape and the mask of the cursor + if (!X11::CheckCookie( + connection, xcb_create_cursor(connection, + hiddenCursor, + cursorPixmap, + cursorPixmap, + 0, 0, 0, // Foreground RGB color + 0, 0, 0, // Background RGB color + 0, // X + 0 // Y + ))) + { + NazaraError("Failed to create hidden cursor"); + return false; + } + + return true; + } + + void CursorImpl::Uninitialize() + { + if (s_hiddenCursor) + { + ScopedXCBConnection connection; + xcb_free_cursor(connection, s_hiddenCursor); + s_hiddenCursor = 0; + } + } + + std::array CursorImpl::s_systemCursorIds = + { + // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 + "crosshair", // SystemCursor_Crosshair + "left_ptr", // SystemCursor_Default + "hand", // SystemCursor_Hand + "help", // SystemCursor_Help + "fleur", // SystemCursor_Move + nullptr, // SystemCursor_None + "hand", // SystemCursor_Pointer + "watch", // SystemCursor_Progress + "right_side", // SystemCursor_ResizeE + "top_side", // SystemCursor_ResizeN + "top_right_corner", // SystemCursor_ResizeNE + "top_left_corner", // SystemCursor_ResizeNW + "bottom_side", // SystemCursor_ResizeS + "bottom_right_corner", // SystemCursor_ResizeSE + "bottom_left_corner", // SystemCursor_ResizeSW + "left_side", // SystemCursor_ResizeW + "xterm", // SystemCursor_Text + "watch" // SystemCursor_Wait + }; + + static_assert(SystemCursor_Max + 1 == 18, "System cursor array is incomplete"); } diff --git a/src/Nazara/Utility/X11/CursorImpl.hpp b/src/Nazara/Utility/X11/CursorImpl.hpp index 41d91bcb1..b16cd4aa2 100644 --- a/src/Nazara/Utility/X11/CursorImpl.hpp +++ b/src/Nazara/Utility/X11/CursorImpl.hpp @@ -8,6 +8,7 @@ #define NAZARA_CURSORIMPL_HPP #include +#include #include namespace Nz @@ -16,14 +17,24 @@ namespace Nz class CursorImpl { + friend class Cursor; + public: bool Create(const Image& image, int hotSpotX, int hotSpotY); + bool Create(SystemCursor cursor); + void Destroy(); xcb_cursor_t GetCursor(); private: - xcb_cursor_t m_cursor; + static bool Initialize(); + static void Uninitialize(); + + xcb_cursor_t m_cursor = 0; + xcb_cursor_context_t* m_cursorContext = nullptr; + + static std::array s_systemCursorIds; }; } diff --git a/src/Nazara/Utility/X11/WindowImpl.cpp b/src/Nazara/Utility/X11/WindowImpl.cpp index 700b8c6ee..31f546b38 100644 --- a/src/Nazara/Utility/X11/WindowImpl.cpp +++ b/src/Nazara/Utility/X11/WindowImpl.cpp @@ -50,45 +50,7 @@ namespace Nz XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW; - xcb_cursor_t hiddenCursor = 0; - xcb_connection_t* connection = nullptr; - - void CreateHiddenCursor() - { - XCBPixmap cursorPixmap(connection); - - xcb_window_t window = X11::XCBDefaultRootWindow(connection); - - if (!cursorPixmap.Create( - 1, - window, - 1, - 1 - )) - { - NazaraError("Failed to create pixmap for hidden cursor"); - return; - } - - hiddenCursor = xcb_generate_id(connection); - - // Create the cursor, using the pixmap as both the shape and the mask of the cursor - if (!X11::CheckCookie( - connection, - xcb_create_cursor( - connection, - hiddenCursor, - cursorPixmap, - cursorPixmap, - 0, 0, 0, // Foreground RGB color - 0, 0, 0, // Background RGB color - 0, // X - 0 // Y - )) - ) - NazaraError("Failed to create hidden cursor"); - } } WindowImpl::WindowImpl(Window* parent) : @@ -452,34 +414,13 @@ namespace Nz } } - void WindowImpl::SetCursor(Nz::WindowCursor windowCursor) - { - if (windowCursor == Nz::WindowCursor_None) - SetCursor(hiddenCursor); - else - { - const char* name = ConvertWindowCursorToXName(windowCursor); - - xcb_cursor_context_t* ctx; - if (xcb_cursor_context_new(connection, m_screen, &ctx) >= 0) - { - xcb_cursor_t cursor = xcb_cursor_load_cursor(ctx, name); - SetCursor(cursor); - xcb_free_cursor(connection, cursor); - xcb_cursor_context_free(ctx); - } - } - } - void WindowImpl::SetCursor(const Cursor& cursor) { - if (!cursor.IsValid()) - { - NazaraError("Cursor is not valid"); - return; - } + xcb_cursor_t cursorImpl = cursor.m_impl->GetCursor(); + if (!X11::CheckCookie(connection, xcb_change_window_attributes(connection, m_window, XCB_CW_CURSOR, &cursor))) + NazaraError("Failed to change mouse cursor"); - SetCursor(cursor.m_impl->GetCursor()); + xcb_flush(connection); } void WindowImpl::SetEventListener(bool listener) @@ -998,7 +939,7 @@ namespace Nz } } - const char* WindowImpl::ConvertWindowCursorToXName(Nz::WindowCursor cursor) + const char* WindowImpl::ConvertWindowCursorToXName(SystemCursor cursor) { // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 switch (cursor) @@ -1444,22 +1385,6 @@ namespace Nz } } - void WindowImpl::SetCursor(xcb_cursor_t cursor) - { - if (!X11::CheckCookie( - connection, - xcb_change_window_attributes( - connection, - m_window, - XCB_CW_CURSOR, - &cursor - )) - ) - NazaraError("Failed to change mouse cursor"); - - xcb_flush(connection); - } - void WindowImpl::SetMotifHints() { ScopedXCB error(nullptr); diff --git a/src/Nazara/Utility/X11/WindowImpl.hpp b/src/Nazara/Utility/X11/WindowImpl.hpp index 414140179..d56579561 100644 --- a/src/Nazara/Utility/X11/WindowImpl.hpp +++ b/src/Nazara/Utility/X11/WindowImpl.hpp @@ -60,7 +60,6 @@ namespace Nz void ProcessEvents(bool block); - void SetCursor(WindowCursor cursor); void SetCursor(const Cursor& cursor); void SetEventListener(bool listener); void SetFocus(); @@ -84,7 +83,7 @@ namespace Nz void CleanUp(); xcb_keysym_t ConvertKeyCodeToKeySym(xcb_keycode_t keycode, uint16_t state); Keyboard::Key ConvertVirtualKey(xcb_keysym_t symbol); - const char* ConvertWindowCursorToXName(WindowCursor cursor); + const char* ConvertWindowCursorToXName(SystemCursor cursor); void CommonInitialize(); char32_t GetRepresentation(xcb_keysym_t keysym) const; @@ -93,7 +92,6 @@ namespace Nz void ResetVideoMode(); - void SetCursor(xcb_cursor_t cursor); void SetMotifHints(); void SetVideoMode(const VideoMode& mode); void SwitchToFullscreen(); From 5b36ac1953b445745e0f4f730de218b01cea5602 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 16 Jan 2017 00:41:31 +0100 Subject: [PATCH 030/243] Utility: Fix Cursor missing initialization --- include/Nazara/Utility/Cursor.hpp | 1 + src/Nazara/Utility/Utility.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/Nazara/Utility/Cursor.hpp b/include/Nazara/Utility/Cursor.hpp index ae8dd08b5..7fe0b2831 100644 --- a/include/Nazara/Utility/Cursor.hpp +++ b/include/Nazara/Utility/Cursor.hpp @@ -18,6 +18,7 @@ namespace Nz class NAZARA_UTILITY_API Cursor { + friend class Utility; friend class WindowImpl; public: diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 87b154157..3234869ad 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -110,6 +111,13 @@ namespace Nz NazaraError("Failed to initialize window's system"); return false; } + + // Must be initialized after Window + if (!Cursor::Initialize()) + { + NazaraError("Failed to initialize cursors"); + return false; + } } // On enregistre les loaders pour les extensions @@ -180,7 +188,9 @@ namespace Nz Loaders::UnregisterSTBLoader(); Loaders::UnregisterSTBSaver(); + Cursor::Uninitialize(); //< Must be done before Window Window::Uninitialize(); + VertexDeclaration::Uninitialize(); Skeleton::Uninitialize(); PixelFormat::Uninitialize(); From 679f599c791be4d658d0e44174055b0424eb832c Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 16 Jan 2017 21:25:23 +0100 Subject: [PATCH 031/243] Sdk/Console: Fix crash --- SDK/src/NDK/Console.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 82d3d40af..1e49ec25f 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -192,9 +192,12 @@ namespace Ndk m_historyPosition = 1; } - Nz::String text = m_commandHistory[m_commandHistory.size() - m_historyPosition]; - m_inputDrawer.SetText(s_inputPrefix + text); - m_inputTextSprite->Update(m_inputDrawer); + if (!m_commandHistory.empty()) + { + Nz::String text = m_commandHistory[m_commandHistory.size() - m_historyPosition]; + m_inputDrawer.SetText(s_inputPrefix + text); + m_inputTextSprite->Update(m_inputDrawer); + } break; } From 925c4b1ee324fe30cfc14d8556aeab9c215cb137 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 22:40:19 +0100 Subject: [PATCH 032/243] Utility/Enum: Fix SystemCursor order (fixes cursors) --- include/Nazara/Utility/Enums.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 23c71d528..7188b05f4 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -309,13 +309,12 @@ namespace Nz enum SystemCursor { - SystemCursor_None, - SystemCursor_Default, - SystemCursor_Crosshair, + SystemCursor_Default, SystemCursor_Hand, SystemCursor_Help, SystemCursor_Move, + SystemCursor_None, SystemCursor_Pointer, SystemCursor_Progress, SystemCursor_ResizeE, From 5752792565d64b4f67876c42398c5ee9c75ffa41 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 22:41:44 +0100 Subject: [PATCH 033/243] Utility/X11: Fix calling of std::abort() in case of failure --- src/Nazara/Utility/X11/Display.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Nazara/Utility/X11/Display.cpp b/src/Nazara/Utility/X11/Display.cpp index 63fbb65ac..8a9ff719c 100644 --- a/src/Nazara/Utility/X11/Display.cpp +++ b/src/Nazara/Utility/X11/Display.cpp @@ -107,11 +107,10 @@ namespace Nz sharedConnection = xcb_connect(nullptr, &screen_nbr); // Opening display failed: The best we can do at the moment is to output a meaningful error message - // and cause an abnormal program termination if (!sharedConnection || xcb_connection_has_error(sharedConnection)) { NazaraError("Failed to open xcb connection"); - std::abort(); + return false; } OpenConnection(); From c1dfc5c4b898b26bf5d5e8e17c3c68746e710e63 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 23:06:31 +0100 Subject: [PATCH 034/243] Sdk/Widgets: Properly fixes padding --- SDK/include/NDK/BaseWidget.hpp | 1 + SDK/include/NDK/BaseWidget.inl | 5 ++ SDK/include/NDK/Widgets/TextAreaWidget.hpp | 4 +- SDK/src/NDK/BaseWidget.cpp | 5 -- SDK/src/NDK/Canvas.cpp | 3 -- SDK/src/NDK/Widgets/ButtonWidget.cpp | 4 +- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 56 ++++++++++++---------- 7 files changed, 44 insertions(+), 34 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 2bdf0dd81..6cfea3a8c 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -46,6 +46,7 @@ namespace Ndk inline const Nz::Color& GetBackgroundColor() const; inline Canvas* GetCanvas(); inline const Padding& GetPadding() const; + inline Nz::Vector2f GetContentOrigin() const; inline const Nz::Vector2f& GetContentSize() const; inline Nz::Vector2f GetSize() const; diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 041abe9bd..8ad0521a2 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -60,6 +60,11 @@ namespace Ndk return m_padding; } + inline Nz::Vector2f BaseWidget::GetContentOrigin() const + { + return { m_padding.left, m_padding.top }; + } + inline const Nz::Vector2f& BaseWidget::GetContentSize() const { return m_contentSize; diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.hpp b/SDK/include/NDK/Widgets/TextAreaWidget.hpp index 2b0774ec8..311a1a840 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.hpp +++ b/SDK/include/NDK/Widgets/TextAreaWidget.hpp @@ -57,7 +57,7 @@ namespace Ndk TextAreaWidget& operator=(TextAreaWidget&&) = default; private: - void RefreshCursor(); + void Layout() override; void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) override; void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key) override; @@ -67,6 +67,8 @@ namespace Ndk void OnMouseExit() override; void OnTextEntered(char32_t character, bool repeated) override; + void RefreshCursor(); + EntityHandle m_cursorEntity; EntityHandle m_textEntity; Nz::SimpleTextDrawer m_drawer; diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 69d60965e..bdd3b93bb 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -119,12 +119,7 @@ namespace Ndk m_canvas->NotifyWidgetUpdate(m_canvasIndex); if (m_backgroundEntity) - { - NodeComponent& node = m_backgroundEntity->GetComponent(); - node.SetPosition(-m_padding.left, -m_padding.top); - m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); - } } void BaseWidget::InvalidateNode() diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index b13b7ef6a..2aac8846c 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -18,9 +18,6 @@ namespace Ndk { if (m_backgroundEntity) { - NodeComponent& node = m_backgroundEntity->GetComponent(); - node.SetPosition(-m_padding.left, -m_padding.top); - m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); } } diff --git a/SDK/src/NDK/Widgets/ButtonWidget.cpp b/SDK/src/NDK/Widgets/ButtonWidget.cpp index 25ac74c69..88ae0bf35 100644 --- a/SDK/src/NDK/Widgets/ButtonWidget.cpp +++ b/SDK/src/NDK/Widgets/ButtonWidget.cpp @@ -40,12 +40,14 @@ namespace Ndk { BaseWidget::Layout(); + Nz::Vector2f origin = GetContentOrigin(); const Nz::Vector2f& contentSize = GetContentSize(); + m_gradientEntity->GetComponent().SetPosition(origin); m_gradientSprite->SetSize(contentSize); Nz::Boxf textBox = m_textEntity->GetComponent().GetBoundingVolume().aabb; - m_textEntity->GetComponent().SetPosition(contentSize.x / 2 - textBox.width / 2, contentSize.y / 2 - textBox.height / 2); + m_textEntity->GetComponent().SetPosition(origin.x + contentSize.x / 2 - textBox.width / 2, origin.y + contentSize.y / 2 - textBox.height / 2); } void ButtonWidget::OnMouseButtonRelease(int /*x*/, int /*y*/, Nz::Mouse::Button button) diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 0c9b7b3d5..e239efac7 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -94,33 +94,10 @@ namespace Ndk } } - void TextAreaWidget::RefreshCursor() { - std::size_t lineCount = m_drawer.GetLineCount(); - std::size_t line = 0U; - for (std::size_t i = line + 1; i < lineCount; ++i) - { - if (m_drawer.GetLine(i).glyphIndex > m_cursorPosition) - break; + BaseWidget::Layout(); - line = i; - } - const auto& lineInfo = m_drawer.GetLine(line); - - std::size_t glyphCount = m_drawer.GetGlyphCount(); - float position; - if (glyphCount > 0 && lineInfo.glyphIndex < m_cursorPosition) - { - const auto& glyph = m_drawer.GetGlyph(std::min(m_cursorPosition, glyphCount - 1)); - position = glyph.bounds.x; - if (m_cursorPosition >= glyphCount) - position += glyph.bounds.width; - } - else - position = 0.f; - - m_cursorEntity->GetComponent().SetPosition(position, lineInfo.bounds.y); } void TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) @@ -222,4 +199,35 @@ namespace Ndk } } } + + void TextAreaWidget::RefreshCursor() + { + std::size_t lineCount = m_drawer.GetLineCount(); + std::size_t line = 0U; + for (std::size_t i = line + 1; i < lineCount; ++i) + { + if (m_drawer.GetLine(i).glyphIndex > m_cursorPosition) + break; + + line = i; + } + + const auto& lineInfo = m_drawer.GetLine(line); + + std::size_t glyphCount = m_drawer.GetGlyphCount(); + float position; + if (glyphCount > 0 && lineInfo.glyphIndex < m_cursorPosition) + { + const auto& glyph = m_drawer.GetGlyph(std::min(m_cursorPosition, glyphCount - 1)); + position = glyph.bounds.x; + if (m_cursorPosition >= glyphCount) + position += glyph.bounds.width; + } + else + position = 0.f; + + Nz::Vector2f contentOrigin = GetContentOrigin(); + + m_cursorEntity->GetComponent().SetPosition(contentOrigin.x + position, contentOrigin.y + lineInfo.bounds.y); + } } From 36bcdcdb8c77208880a84f5a9127a56754dac083 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 23:35:43 +0100 Subject: [PATCH 035/243] Sdk/Widgets: Make the canvas aware of itself as a widget --- SDK/include/NDK/BaseWidget.hpp | 2 ++ SDK/include/NDK/Canvas.hpp | 2 -- SDK/include/NDK/Canvas.inl | 11 ++++++++++- SDK/src/NDK/BaseWidget.cpp | 26 +++++++++++++++++++++++--- SDK/src/NDK/Canvas.cpp | 8 -------- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 6cfea3a8c..9d13499d9 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -95,8 +95,10 @@ namespace Ndk inline void DestroyChild(BaseWidget* widget); void DestroyChildren(); + void RegisterToCanvas(); inline void NotifyParentResized(const Nz::Vector2f& newSize); inline void UpdateCanvasIndex(std::size_t index); + void UnregisterFromCanvas(); std::size_t m_canvasIndex; std::vector m_entities; diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NDK/Canvas.hpp index db271051f..914287fa2 100644 --- a/SDK/include/NDK/Canvas.hpp +++ b/SDK/include/NDK/Canvas.hpp @@ -33,8 +33,6 @@ namespace Ndk Canvas& operator=(Canvas&&) = delete; protected: - void Layout() override; - void NotifyWidgetUpdate(std::size_t index); std::size_t RegisterWidget(BaseWidget* widget); diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index 173474bdf..83de51b97 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -12,6 +12,10 @@ namespace Ndk m_world(std::move(world)) { m_canvas = this; + m_widgetParent = nullptr; + + // Widgetception + m_canvasIndex = m_canvas->RegisterWidget(this); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, this, &Canvas::OnKeyPressed); m_keyReleasedSlot.Connect(eventHandler.OnKeyReleased, this, &Canvas::OnKeyReleased); @@ -20,12 +24,17 @@ namespace Ndk m_mouseMovedSlot.Connect(eventHandler.OnMouseMoved, this, &Canvas::OnMouseMoved); m_mouseLeftSlot.Connect(eventHandler.OnMouseLeft, this, &Canvas::OnMouseLeft); m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnTextEntered); + + SetPadding(0.f, 0.f, 0.f, 0.f); } inline Canvas::~Canvas() { - // Destroy children explicitly because they signal us when getting destroyed, and that can't happend after our own destruction + // Destroy children explicitly because they signal us when getting destroyed, and that can't happen after our own destruction DestroyChildren(); + + // Prevent our parent from trying to call us + m_canvasIndex = std::numeric_limits::max(); } inline const WorldHandle& Canvas::GetWorld() const diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index bdd3b93bb..a971139eb 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -21,13 +21,12 @@ namespace Ndk m_widgetParent = parent; m_world = m_canvas->GetWorld(); - m_canvasIndex = m_canvas->RegisterWidget(this); + RegisterToCanvas(); } BaseWidget::~BaseWidget() { - if (m_canvasIndex != std::numeric_limits::max()) - m_canvas->UnregisterWidget(m_canvasIndex); + UnregisterFromCanvas(); } void BaseWidget::Destroy() @@ -88,6 +87,11 @@ namespace Ndk { m_visible = show; + if (m_visible) + RegisterToCanvas(); + else + UnregisterFromCanvas(); + for (const EntityHandle& entity : m_entities) entity->Enable(show); @@ -182,4 +186,20 @@ namespace Ndk { m_children.clear(); } + + void BaseWidget::RegisterToCanvas() + { + NazaraAssert(m_canvasIndex == std::numeric_limits::max(), "Widget is already registered to canvas"); + + m_canvasIndex = m_canvas->RegisterWidget(this); + } + + void BaseWidget::UnregisterFromCanvas() + { + if (m_canvasIndex != std::numeric_limits::max()) + { + m_canvas->UnregisterWidget(m_canvasIndex); + m_canvasIndex = std::numeric_limits::max(); + } + } } diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index 2aac8846c..74178d49a 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -14,14 +14,6 @@ namespace Ndk { } - void Canvas::Layout() - { - if (m_backgroundEntity) - { - m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); - } - } - void Canvas::NotifyWidgetUpdate(std::size_t index) { WidgetBox& entry = m_widgetBoxes[index]; From 5d39d60f9410df6a0ff9e9c3f2541d6650c34e3f Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 23:36:19 +0100 Subject: [PATCH 036/243] Sdk/TextAreaWidget: Fix commit fail --- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index e239efac7..089f8a380 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -94,10 +94,13 @@ namespace Ndk } } + void TextAreaWidget::Layout() { BaseWidget::Layout(); + m_textEntity->GetComponent().SetPosition(GetContentOrigin()); + RefreshCursor(); } void TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) From ec795269ad3fb414043126cff6077e2c5e735e61 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 23:38:29 +0100 Subject: [PATCH 037/243] Sdk/TextAreaWidget: Add signals (allowing for controlling the cursor/keys) --- SDK/include/NDK/Widgets/TextAreaWidget.hpp | 8 ++++ SDK/include/NDK/Widgets/TextAreaWidget.inl | 4 ++ SDK/src/NDK/Widgets/TextAreaWidget.cpp | 55 +++++++++++++++++++++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.hpp b/SDK/include/NDK/Widgets/TextAreaWidget.hpp index 311a1a840..6581a9965 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.hpp +++ b/SDK/include/NDK/Widgets/TextAreaWidget.hpp @@ -56,6 +56,14 @@ namespace Ndk TextAreaWidget& operator=(const TextAreaWidget&) = delete; TextAreaWidget& operator=(TextAreaWidget&&) = default; + NazaraSignal(OnTextAreaCursorMove, const TextAreaWidget* /*textArea*/, std::size_t* /*newCursorPosition*/); + NazaraSignal(OnTextAreaKeyBackspace, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/); + NazaraSignal(OnTextAreaKeyDown, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/); + NazaraSignal(OnTextAreaKeyLeft, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/); + NazaraSignal(OnTextAreaKeyReturn, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/); + NazaraSignal(OnTextAreaKeyRight, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/); + NazaraSignal(OnTextAreaKeyUp, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/); + private: void Layout() override; diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.inl b/SDK/include/NDK/Widgets/TextAreaWidget.inl index 711f8de8c..4ddc6d114 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.inl +++ b/SDK/include/NDK/Widgets/TextAreaWidget.inl @@ -66,6 +66,8 @@ namespace Ndk inline void TextAreaWidget::SetCursorPosition(std::size_t cursorPosition) { + OnTextAreaCursorMove(this, &cursorPosition); + m_cursorPosition = std::min(cursorPosition, m_drawer.GetGlyphCount()); RefreshCursor(); @@ -83,6 +85,8 @@ namespace Ndk m_drawer.SetText(text); m_textSprite->Update(m_drawer); + + SetCursorPosition(m_cursorPosition); //< Refresh cursor position (prevent it from being outside of the text) } inline void TextAreaWidget::SetTextColor(const Nz::Color& text) diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 089f8a380..99e450949 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -123,13 +123,53 @@ namespace Ndk break; } + case Nz::Keyboard::Down: + { + bool ignoreDefaultAction = false; + OnTextAreaKeyDown(this, &ignoreDefaultAction); + + if (ignoreDefaultAction) + break; + + //TODO + break; + } + case Nz::Keyboard::Left: + { + bool ignoreDefaultAction = false; + OnTextAreaKeyLeft(this, &ignoreDefaultAction); + + if (ignoreDefaultAction) + break; + MoveCursor(-1); break; + } case Nz::Keyboard::Right: + { + bool ignoreDefaultAction = false; + OnTextAreaKeyRight(this, &ignoreDefaultAction); + + if (ignoreDefaultAction) + break; + MoveCursor(1); break; + } + + case Nz::Keyboard::Up: + { + bool ignoreDefaultAction = false; + OnTextAreaKeyUp(this, &ignoreDefaultAction); + + if (ignoreDefaultAction) + break; + + //TODO + break; + } } } @@ -170,6 +210,12 @@ namespace Ndk { case '\b': { + bool ignoreDefaultAction = false; + OnTextAreaKeyBackspace(this, &ignoreDefaultAction); + + if (ignoreDefaultAction) + break; + const Nz::String& text = m_drawer.GetText(); Nz::String newText; @@ -179,18 +225,23 @@ namespace Ndk if (m_cursorPosition < m_drawer.GetGlyphCount()) newText.Append(text.SubString(text.GetCharacterPosition(m_cursorPosition))); - SetText(newText); MoveCursor(-1); + SetText(newText); break; } case '\r': case '\n': - if (!m_multiLineEnabled) + { + bool ignoreDefaultAction = false; + OnTextAreaKeyReturn(this, &ignoreDefaultAction); + + if (ignoreDefaultAction || !m_multiLineEnabled) break; Write(Nz::String('\n')); break; + } default: { From 27b000470d01af04e2c4d3880f48fdb1418b6977 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 23:39:22 +0100 Subject: [PATCH 038/243] Sdk/Canvas: Fix warning and optimize integer to float conversion --- SDK/src/NDK/Canvas.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index 74178d49a..8e96404f0 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -84,11 +84,12 @@ namespace Ndk const WidgetBox* bestEntry = nullptr; float bestEntryArea = std::numeric_limits::infinity(); + Nz::Vector3f mousePos(float(event.x), float(event.y), 0.f); for (const WidgetBox& entry : m_widgetBoxes) { const Nz::Boxf& box = entry.box; - if (box.Contains(Nz::Vector3f(event.x, event.y, 0.f))) + if (box.Contains(mousePos)) { float area = box.width * box.height; if (area < bestEntryArea) From d1b5357504807d8f4bf5f23a289eeaa71b18307d Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 23:51:59 +0100 Subject: [PATCH 039/243] Utility/X11: Try to fix Linux implementation --- src/Nazara/Utility/X11/CursorImpl.cpp | 13 ++++++++----- src/Nazara/Utility/X11/CursorImpl.hpp | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Nazara/Utility/X11/CursorImpl.cpp b/src/Nazara/Utility/X11/CursorImpl.cpp index 082825c50..2925b2b6d 100644 --- a/src/Nazara/Utility/X11/CursorImpl.cpp +++ b/src/Nazara/Utility/X11/CursorImpl.cpp @@ -162,9 +162,10 @@ namespace Nz bool CursorImpl::Create(SystemCursor cursor) { ScopedXCBConnection connection; + xcb_screen_t* screen = X11::XCBDefaultScreen(connection); - if (xcb_cursor_context_new(connection, m_screen, &m_cursorContext) >= 0) - m_cursor = xcb_cursor_load_cursor(ctx, s_systemCursorIds[cursor]); + if (xcb_cursor_context_new(connection, screen, &m_cursorContext) >= 0) + m_cursor = xcb_cursor_load_cursor(m_cursorContext, s_systemCursorIds[cursor]); return true; } @@ -196,12 +197,12 @@ namespace Nz return false; } - hiddenCursor = xcb_generate_id(connection); + s_hiddenCursor = xcb_generate_id(connection); // Create the cursor, using the pixmap as both the shape and the mask of the cursor if (!X11::CheckCookie( connection, xcb_create_cursor(connection, - hiddenCursor, + s_hiddenCursor, cursorPixmap, cursorPixmap, 0, 0, 0, // Foreground RGB color @@ -226,7 +227,9 @@ namespace Nz s_hiddenCursor = 0; } } - + + xcb_cursor_t CursorImpl::s_hiddenCursor = 0; + std::array CursorImpl::s_systemCursorIds = { // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 diff --git a/src/Nazara/Utility/X11/CursorImpl.hpp b/src/Nazara/Utility/X11/CursorImpl.hpp index b16cd4aa2..4041b81ed 100644 --- a/src/Nazara/Utility/X11/CursorImpl.hpp +++ b/src/Nazara/Utility/X11/CursorImpl.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace Nz { @@ -22,7 +23,7 @@ namespace Nz public: bool Create(const Image& image, int hotSpotX, int hotSpotY); bool Create(SystemCursor cursor); - + void Destroy(); xcb_cursor_t GetCursor(); @@ -33,7 +34,8 @@ namespace Nz xcb_cursor_t m_cursor = 0; xcb_cursor_context_t* m_cursorContext = nullptr; - + + static xcb_cursor_t s_hiddenCursor; static std::array s_systemCursorIds; }; } From eea8b8c7f0f5f994fd03ba33d9a8868cbe4b166e Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Jan 2017 23:57:37 +0100 Subject: [PATCH 040/243] Utility/Window: Fixes compilation for X11 --- src/Nazara/Utility/X11/WindowImpl.cpp | 57 --------------------------- src/Nazara/Utility/X11/WindowImpl.hpp | 1 - 2 files changed, 58 deletions(-) diff --git a/src/Nazara/Utility/X11/WindowImpl.cpp b/src/Nazara/Utility/X11/WindowImpl.cpp index 31f546b38..5e9164b3a 100644 --- a/src/Nazara/Utility/X11/WindowImpl.cpp +++ b/src/Nazara/Utility/X11/WindowImpl.cpp @@ -678,21 +678,11 @@ namespace Nz connection = X11::OpenConnection(); - // Create the hidden cursor - CreateHiddenCursor(); - return true; } void WindowImpl::Uninitialize() { - // Destroy the cursor - if (hiddenCursor) - { - xcb_free_cursor(connection, hiddenCursor); - hiddenCursor = 0; - } - X11::CloseConnection(connection); X11::Uninitialize(); @@ -939,53 +929,6 @@ namespace Nz } } - const char* WindowImpl::ConvertWindowCursorToXName(SystemCursor cursor) - { - // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 - switch (cursor) - { - case Nz::WindowCursor_Crosshair: - return "crosshair"; - case Nz::WindowCursor_Default: - return "left_ptr"; - case Nz::WindowCursor_Hand: - return "hand"; - case Nz::WindowCursor_Help: - return "help"; - case Nz::WindowCursor_Move: - return "fleur"; - case Nz::WindowCursor_None: - return "none"; // Handled in set cursor - case Nz::WindowCursor_Pointer: - return "hand"; - case Nz::WindowCursor_Progress: - return "watch"; - case Nz::WindowCursor_ResizeE: - return "right_side"; - case Nz::WindowCursor_ResizeN: - return "top_side"; - case Nz::WindowCursor_ResizeNE: - return "top_right_corner"; - case Nz::WindowCursor_ResizeNW: - return "top_left_corner"; - case Nz::WindowCursor_ResizeS: - return "bottom_side"; - case Nz::WindowCursor_ResizeSE: - return "bottom_right_corner"; - case Nz::WindowCursor_ResizeSW: - return "bottom_left_corner"; - case Nz::WindowCursor_ResizeW: - return "left_side"; - case Nz::WindowCursor_Text: - return "xterm"; - case Nz::WindowCursor_Wait: - return "watch"; - } - - NazaraError("Cursor is not handled by enumeration"); - return "X_cursor"; - } - void WindowImpl::CommonInitialize() { // Show the window diff --git a/src/Nazara/Utility/X11/WindowImpl.hpp b/src/Nazara/Utility/X11/WindowImpl.hpp index d56579561..8ce44f178 100644 --- a/src/Nazara/Utility/X11/WindowImpl.hpp +++ b/src/Nazara/Utility/X11/WindowImpl.hpp @@ -83,7 +83,6 @@ namespace Nz void CleanUp(); xcb_keysym_t ConvertKeyCodeToKeySym(xcb_keycode_t keycode, uint16_t state); Keyboard::Key ConvertVirtualKey(xcb_keysym_t symbol); - const char* ConvertWindowCursorToXName(SystemCursor cursor); void CommonInitialize(); char32_t GetRepresentation(xcb_keysym_t keysym) const; From 934e646b001997b4518aace37a85298033152efc Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 00:12:50 +0100 Subject: [PATCH 041/243] Utility/Window: Fixes compilation for X11, again --- src/Nazara/Utility/X11/WindowImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/X11/WindowImpl.cpp b/src/Nazara/Utility/X11/WindowImpl.cpp index 5e9164b3a..10cd5fe27 100644 --- a/src/Nazara/Utility/X11/WindowImpl.cpp +++ b/src/Nazara/Utility/X11/WindowImpl.cpp @@ -251,7 +251,7 @@ namespace Nz if (m_window && m_ownsWindow) { // Unhide the mouse cursor (in case it was hidden) - SetCursor(Nz::WindowCursor_Default); + SetCursor(SystemCursor_Default); if (!X11::CheckCookie( connection, @@ -417,7 +417,7 @@ namespace Nz void WindowImpl::SetCursor(const Cursor& cursor) { xcb_cursor_t cursorImpl = cursor.m_impl->GetCursor(); - if (!X11::CheckCookie(connection, xcb_change_window_attributes(connection, m_window, XCB_CW_CURSOR, &cursor))) + if (!X11::CheckCookie(connection, xcb_change_window_attributes(connection, m_window, XCB_CW_CURSOR, &cursorImpl))) NazaraError("Failed to change mouse cursor"); xcb_flush(connection); From b64d384c9925a736b4351f81764a882c274ed728 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 10:27:47 +0100 Subject: [PATCH 042/243] Utility/Cursor: Fix compilation on Linux --- src/Nazara/Utility/Cursor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Utility/Cursor.cpp b/src/Nazara/Utility/Cursor.cpp index 9b9af0fb9..f03a42052 100644 --- a/src/Nazara/Utility/Cursor.cpp +++ b/src/Nazara/Utility/Cursor.cpp @@ -33,7 +33,7 @@ namespace Nz return true; } - inline bool Cursor::Create(SystemCursor cursor) + bool Cursor::Create(SystemCursor cursor) { Destroy(); From 282538876bd6fdc7d632da872e22560df4661bb8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 14:08:33 +0100 Subject: [PATCH 043/243] Utility: Make EventHandler a handled object This is a bit ironic. --- include/Nazara/Utility/EventHandler.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Utility/EventHandler.hpp b/include/Nazara/Utility/EventHandler.hpp index 5bc47bdea..6dba6c751 100644 --- a/include/Nazara/Utility/EventHandler.hpp +++ b/include/Nazara/Utility/EventHandler.hpp @@ -14,7 +14,11 @@ namespace Nz { - class EventHandler + class EventHandler; + + using EventHandlerHandle = Nz::ObjectRef; + + class EventHandler : public HandledObject { public: EventHandler() = default; From b884f5783c87fc438cc83279ef3f7751cd57532b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 14:17:26 +0100 Subject: [PATCH 044/243] Utility: Add CursorController --- include/Nazara/Utility/CursorController.hpp | 42 +++++++++++++++++++++ include/Nazara/Utility/CursorController.inl | 16 ++++++++ include/Nazara/Utility/Window.hpp | 7 +++- include/Nazara/Utility/Window.inl | 13 +++---- src/Nazara/Utility/Window.cpp | 14 +++++++ 5 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 include/Nazara/Utility/CursorController.hpp create mode 100644 include/Nazara/Utility/CursorController.inl diff --git a/include/Nazara/Utility/CursorController.hpp b/include/Nazara/Utility/CursorController.hpp new file mode 100644 index 000000000..0f0e54f23 --- /dev/null +++ b/include/Nazara/Utility/CursorController.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CURSORCONTROLLER_HPP +#define NAZARA_CURSORCONTROLLER_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class CursorController; + + using CursorControllerHandle = Nz::ObjectRef; + + class CursorController : public HandledObject + { + public: + CursorController() = default; + CursorController(const CursorController&) = delete; + CursorController(CursorController&&) = default; + ~CursorController() = default; + + inline void UpdateCursor(const Cursor& cursor); + + CursorController& operator=(const CursorController&) = delete; + CursorController& operator=(CursorController&&) = default; + + NazaraSignal(OnCursorUpdated, const CursorController* /*cursorController*/, const Cursor& /*cursor*/); + }; +} + +#include + +#endif // NAZARA_CURSORCONTROLLER_HPP diff --git a/include/Nazara/Utility/CursorController.inl b/include/Nazara/Utility/CursorController.inl new file mode 100644 index 000000000..0d6f2402d --- /dev/null +++ b/include/Nazara/Utility/CursorController.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline void CursorController::UpdateCursor(const Cursor& cursor) + { + OnCursorUpdated(this, cursor); + } +} + +#include diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index 3dbf9897b..ae7b876f9 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,7 @@ namespace Nz friend class Utility; public: - inline Window(); + Window(); inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default); inline Window(WindowHandle handle); Window(const Window&) = delete; @@ -57,7 +58,8 @@ namespace Nz void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); - EventHandler& GetEventHandler(); + inline CursorController& GetCursorController(); + inline EventHandler& GetEventHandler(); WindowHandle GetHandle() const; unsigned int GetHeight() const; Vector2i GetPosition() const; @@ -119,6 +121,7 @@ namespace Nz std::queue m_events; std::vector m_pendingEvents; ConditionVariable m_eventCondition; + CursorController m_cursorController; EventHandler m_eventHandler; Mutex m_eventMutex; Mutex m_eventConditionMutex; diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index 0fce86ba6..cf820b8fb 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -12,14 +12,6 @@ namespace Nz /*! * \class Nz::Window */ - inline Window::Window() : - m_impl(nullptr), - m_asyncWindow(false), - m_closeOnQuit(true), - m_eventPolling(false), - m_waitForEvent(false) - { - } inline Window::Window(VideoMode mode, const String& title, WindowStyleFlags style) : Window() @@ -75,6 +67,11 @@ namespace Nz } } + inline CursorController& Nz::Window::GetCursorController() + { + return m_cursorController; + } + inline EventHandler& Nz::Window::GetEventHandler() { return m_eventHandler; diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 61ca49c80..043258e26 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -29,6 +29,20 @@ namespace Nz Window* fullscreenWindow = nullptr; } + Window::Window() : + m_impl(nullptr), + m_asyncWindow(false), + m_closeOnQuit(true), + m_eventPolling(false), + m_waitForEvent(false) + { + m_cursorController.OnCursorUpdated.Connect([this](const CursorController*, const Cursor& cursor) + { + if (IsValid()) + SetCursor(cursor); + }); + } + Window::~Window() { Destroy(); From 76d4359c3bef7badfaf0145ae042dedc08b5c6cc Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 14:35:56 +0100 Subject: [PATCH 045/243] Utility/EventHandler: Fix missing includes --- include/Nazara/Utility/EventHandler.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Utility/EventHandler.hpp b/include/Nazara/Utility/EventHandler.hpp index 6dba6c751..64b19d172 100644 --- a/include/Nazara/Utility/EventHandler.hpp +++ b/include/Nazara/Utility/EventHandler.hpp @@ -8,6 +8,8 @@ #define NAZARA_EVENTHANDLER_HPP #include +#include +#include #include #include #include From c4574ed7eca61e11f0f787d9f5c827d9ba501cac Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 15:21:29 +0100 Subject: [PATCH 046/243] Utility: Fix compilation --- include/Nazara/Utility/CursorController.hpp | 4 ++-- include/Nazara/Utility/EventHandler.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Utility/CursorController.hpp b/include/Nazara/Utility/CursorController.hpp index 0f0e54f23..f91f3d9ff 100644 --- a/include/Nazara/Utility/CursorController.hpp +++ b/include/Nazara/Utility/CursorController.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -18,7 +18,7 @@ namespace Nz { class CursorController; - using CursorControllerHandle = Nz::ObjectRef; + using CursorControllerHandle = ObjectHandle; class CursorController : public HandledObject { diff --git a/include/Nazara/Utility/EventHandler.hpp b/include/Nazara/Utility/EventHandler.hpp index 64b19d172..95e9bedc6 100644 --- a/include/Nazara/Utility/EventHandler.hpp +++ b/include/Nazara/Utility/EventHandler.hpp @@ -18,7 +18,7 @@ namespace Nz { class EventHandler; - using EventHandlerHandle = Nz::ObjectRef; + using EventHandlerHandle = ObjectHandle; class EventHandler : public HandledObject { From 670199b55776c874631f9d674e4f0d061277326e Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 21:38:56 +0100 Subject: [PATCH 047/243] Utility/Cursor: Rework Cursor as a handled object --- include/Nazara/Utility/Cursor.hpp | 28 ++++++++++---- include/Nazara/Utility/Cursor.inl | 36 ++++++++--------- include/Nazara/Utility/CursorController.hpp | 4 +- include/Nazara/Utility/CursorController.inl | 2 +- include/Nazara/Utility/Window.hpp | 5 ++- include/Nazara/Utility/Window.inl | 10 +++++ src/Nazara/Utility/Cursor.cpp | 43 +++++++++++++-------- src/Nazara/Utility/Window.cpp | 14 ++++--- 8 files changed, 92 insertions(+), 50 deletions(-) diff --git a/include/Nazara/Utility/Cursor.hpp b/include/Nazara/Utility/Cursor.hpp index 7fe0b2831..77684cfc5 100644 --- a/include/Nazara/Utility/Cursor.hpp +++ b/include/Nazara/Utility/Cursor.hpp @@ -8,28 +8,34 @@ #define NAZARA_CURSOR_HPP #include +#include #include #include #include +#include namespace Nz { class CursorImpl; - class NAZARA_UTILITY_API Cursor + class Cursor; + + using CursorConstRef = ObjectRef; + using CursorRef = ObjectRef; + + class NAZARA_UTILITY_API Cursor : public RefCounted { friend class Utility; friend class WindowImpl; public: inline Cursor(); - inline Cursor(SystemCursor systemCursor); //< implicit conversion intended + inline Cursor(const Image& cursor, const Vector2i& hotSpot, SystemCursor placeholder); Cursor(const Cursor&) = delete; - inline Cursor(Cursor&& cursor) noexcept; + Cursor(Cursor&&) = delete; inline ~Cursor(); - bool Create(const Image& cursor, const Vector2i& hotSpot); - bool Create(SystemCursor cursor); + bool Create(const Image& cursor, const Vector2i& hotSpot, SystemCursor placeholder); void Destroy(); @@ -39,16 +45,24 @@ namespace Nz inline bool IsValid() const; Cursor& operator=(const Cursor&) = delete; - inline Cursor& operator=(Cursor&& cursor); + Cursor& operator=(Cursor&&) = delete; + + static inline Cursor* Get(SystemCursor cursor); + template static CursorRef New(Args&&... args); private: + inline explicit Cursor(SystemCursor systemCursor); + + bool Create(SystemCursor cursor); + static bool Initialize(); static void Uninitialize(); Image m_cursorImage; SystemCursor m_systemCursor; CursorImpl* m_impl; - bool m_usesSystemCursor; + + static std::array s_systemCursors; }; } diff --git a/include/Nazara/Utility/Cursor.inl b/include/Nazara/Utility/Cursor.inl index dc0ce68db..ba817eb9b 100644 --- a/include/Nazara/Utility/Cursor.inl +++ b/include/Nazara/Utility/Cursor.inl @@ -9,11 +9,21 @@ namespace Nz { inline Cursor::Cursor() : - m_impl(nullptr), - m_usesSystemCursor(false) + m_impl(nullptr) { } + inline Cursor::Cursor(const Image& cursor, const Vector2i& hotSpot, SystemCursor placeholder) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + Create(cursor, hotSpot, placeholder); + } + + inline Cursor* Cursor::Get(SystemCursor cursor) + { + return &s_systemCursors[cursor]; + } + inline Cursor::Cursor(SystemCursor systemCursor) : Cursor() { @@ -21,12 +31,6 @@ namespace Nz Create(systemCursor); } - inline Cursor::Cursor(Cursor&& cursor) noexcept : - Cursor() - { - operator=(std::move(cursor)); - } - inline Cursor::~Cursor() { Destroy(); @@ -35,7 +39,7 @@ namespace Nz inline const Image& Cursor::GetImage() const { NazaraAssert(IsValid(), "Invalid cursor"); - NazaraAssert(!m_usesSystemCursor, "System cursors have no image"); + NazaraAssert(m_cursorImage.IsValid(), "System cursors have no image"); return m_cursorImage; } @@ -43,7 +47,6 @@ namespace Nz inline SystemCursor Cursor::GetSystemCursor() const { NazaraAssert(IsValid(), "Invalid cursor"); - NazaraAssert(m_usesSystemCursor, "Custom cursor uses an image"); return m_systemCursor; } @@ -53,16 +56,13 @@ namespace Nz return m_impl != nullptr; } - inline Cursor& Cursor::operator=(Cursor&& cursor) + template + CursorRef Cursor::New(Args&&... args) { - m_cursorImage = std::move(cursor.m_cursorImage); - m_systemCursor = cursor.m_systemCursor; - m_impl = cursor.m_impl; - m_usesSystemCursor = cursor.m_usesSystemCursor; + std::unique_ptr object(new Cursor(std::forward(args)...)); + object->SetPersistent(false); - cursor.m_impl = nullptr; - - return *this; + return object.release(); } } diff --git a/include/Nazara/Utility/CursorController.hpp b/include/Nazara/Utility/CursorController.hpp index f91f3d9ff..5b994e11e 100644 --- a/include/Nazara/Utility/CursorController.hpp +++ b/include/Nazara/Utility/CursorController.hpp @@ -28,12 +28,12 @@ namespace Nz CursorController(CursorController&&) = default; ~CursorController() = default; - inline void UpdateCursor(const Cursor& cursor); + inline void UpdateCursor(const CursorRef& cursor); CursorController& operator=(const CursorController&) = delete; CursorController& operator=(CursorController&&) = default; - NazaraSignal(OnCursorUpdated, const CursorController* /*cursorController*/, const Cursor& /*cursor*/); + NazaraSignal(OnCursorUpdated, const CursorController* /*cursorController*/, const CursorRef& /*cursor*/); }; } diff --git a/include/Nazara/Utility/CursorController.inl b/include/Nazara/Utility/CursorController.inl index 0d6f2402d..1de20a17a 100644 --- a/include/Nazara/Utility/CursorController.inl +++ b/include/Nazara/Utility/CursorController.inl @@ -7,7 +7,7 @@ namespace Nz { - inline void CursorController::UpdateCursor(const Cursor& cursor) + inline void CursorController::UpdateCursor(const CursorRef& cursor) { OnCursorUpdated(this, cursor); } diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index ae7b876f9..7360dd13e 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -58,6 +58,7 @@ namespace Nz void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); + inline const CursorRef& GetCursor() const; inline CursorController& GetCursorController(); inline EventHandler& GetEventHandler(); WindowHandle GetHandle() const; @@ -81,7 +82,8 @@ namespace Nz void ProcessEvents(bool block = false); - void SetCursor(const Cursor& cursor); + void SetCursor(CursorRef cursor); + inline void SetCursor(SystemCursor systemCursor); void SetEventListener(bool listener); void SetFocus(); void SetIcon(const Icon& icon); @@ -122,6 +124,7 @@ namespace Nz std::vector m_pendingEvents; ConditionVariable m_eventCondition; CursorController m_cursorController; + CursorRef m_cursor; EventHandler m_eventHandler; Mutex m_eventMutex; Mutex m_eventConditionMutex; diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index cf820b8fb..0fca50c4d 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -67,6 +67,11 @@ namespace Nz } } + inline const CursorRef& Window::GetCursor() const + { + return m_cursor; + } + inline CursorController& Nz::Window::GetCursorController() { return m_cursorController; @@ -101,6 +106,11 @@ namespace Nz return m_impl != nullptr; } + inline void Window::SetCursor(SystemCursor systemCursor) + { + SetCursor(Cursor::Get(systemCursor)); + } + inline void Window::HandleEvent(const WindowEvent& event) { if (m_eventPolling) diff --git a/src/Nazara/Utility/Cursor.cpp b/src/Nazara/Utility/Cursor.cpp index f03a42052..115eefe0e 100644 --- a/src/Nazara/Utility/Cursor.cpp +++ b/src/Nazara/Utility/Cursor.cpp @@ -16,7 +16,7 @@ namespace Nz { - bool Cursor::Create(const Image& cursor, const Vector2i& hotSpot) + bool Cursor::Create(const Image& cursor, const Vector2i& hotSpot, SystemCursor placeholder) { Destroy(); @@ -29,10 +29,24 @@ namespace Nz m_cursorImage = cursor; m_impl = impl.release(); + m_systemCursor = placeholder; return true; } + void Cursor::Destroy() + { + m_cursorImage.Destroy(); + + if (m_impl) + { + m_impl->Destroy(); + + delete m_impl; + m_impl = nullptr; + } + } + bool Cursor::Create(SystemCursor cursor) { Destroy(); @@ -46,31 +60,28 @@ namespace Nz m_impl = impl.release(); m_systemCursor = cursor; - m_usesSystemCursor = true; return true; } - void Cursor::Destroy() - { - if (m_impl) - { - m_impl->Destroy(); - - delete m_impl; - m_impl = nullptr; - } - - m_usesSystemCursor = false; - } - bool Cursor::Initialize() { - return CursorImpl::Initialize(); + if (!CursorImpl::Initialize()) + return false; + + for (std::size_t i = 0; i <= SystemCursor_Max; ++i) + s_systemCursors[i].Create(static_cast(i)); + + return true; } void Cursor::Uninitialize() { + for (Cursor& cursor : s_systemCursors) + cursor.Destroy(); + CursorImpl::Uninitialize(); } + + std::array Cursor::s_systemCursors; } diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 043258e26..7746a4236 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -36,7 +36,7 @@ namespace Nz m_eventPolling(false), m_waitForEvent(false) { - m_cursorController.OnCursorUpdated.Connect([this](const CursorController*, const Cursor& cursor) + m_cursorController.OnCursorUpdated.Connect([this](const CursorController*, const CursorRef& cursor) { if (IsValid()) SetCursor(cursor); @@ -104,11 +104,12 @@ namespace Nz // Paramètres par défaut m_impl->EnableKeyRepeat(true); m_impl->EnableSmoothScrolling(false); - m_impl->SetCursor(SystemCursor_Default); m_impl->SetMaximumSize(-1, -1); m_impl->SetMinimumSize(-1, -1); m_impl->SetVisible(true); + SetCursor(Cursor::Get(SystemCursor_Default)); + if (opened) m_impl->SetPosition(position.x, position.y); @@ -151,6 +152,8 @@ namespace Nz void Window::Destroy() { + m_cursor.Reset(); + if (m_impl) { OnWindowDestroy(); @@ -364,12 +367,13 @@ namespace Nz } } - void Window::SetCursor(const Cursor& cursor) + void Window::SetCursor(CursorRef cursor) { NazaraAssert(m_impl, "Window not created"); - NazaraAssert(cursor.IsValid(), "Invalid cursor"); + NazaraAssert(cursor && cursor->IsValid(), "Invalid cursor"); - m_impl->SetCursor(cursor); + m_cursor = std::move(cursor); + m_impl->SetCursor(*m_cursor); } void Window::SetEventListener(bool listener) From 439f8d0033fc37c796bed529a5756919f9c1e95a Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 21:44:53 +0100 Subject: [PATCH 048/243] Sdk/Canvas: Little cleanup --- SDK/include/NDK/Canvas.inl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index 83de51b97..9fc19ed56 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -14,9 +14,10 @@ namespace Ndk m_canvas = this; m_widgetParent = nullptr; - // Widgetception - m_canvasIndex = m_canvas->RegisterWidget(this); + // Register ourselves as a widget to handle cursor change + RegisterToCanvas(); + // Connect to every meaningful event m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, this, &Canvas::OnKeyPressed); m_keyReleasedSlot.Connect(eventHandler.OnKeyReleased, this, &Canvas::OnKeyReleased); m_mouseButtonPressedSlot.Connect(eventHandler.OnMouseButtonPressed, this, &Canvas::OnMouseButtonPressed); @@ -25,6 +26,7 @@ namespace Ndk m_mouseLeftSlot.Connect(eventHandler.OnMouseLeft, this, &Canvas::OnMouseLeft); m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnTextEntered); + // Disable padding by default SetPadding(0.f, 0.f, 0.f, 0.f); } From e4b6f8e126aca2cae03ce90529f95aaf659c400d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 21:59:34 +0100 Subject: [PATCH 049/243] Utility/Icon: Make Icon a RefCounted object --- include/Nazara/Utility/Icon.hpp | 16 +++++++++--- include/Nazara/Utility/Icon.inl | 42 +++++++++++++++++++++++++++++++ include/Nazara/Utility/Window.hpp | 7 +++--- src/Nazara/Utility/Icon.cpp | 24 +++--------------- src/Nazara/Utility/Window.cpp | 20 ++++----------- 5 files changed, 67 insertions(+), 42 deletions(-) create mode 100644 include/Nazara/Utility/Icon.inl diff --git a/include/Nazara/Utility/Icon.hpp b/include/Nazara/Utility/Icon.hpp index 4f0397faf..61b68042b 100644 --- a/include/Nazara/Utility/Icon.hpp +++ b/include/Nazara/Utility/Icon.hpp @@ -8,6 +8,7 @@ #define NAZARA_ICON_HPP #include +#include #include #include @@ -16,22 +17,29 @@ namespace Nz class Image; class IconImpl; - class NAZARA_UTILITY_API Icon + class Icon; + + using IconRef = ObjectRef; + + class NAZARA_UTILITY_API Icon : public RefCounted { friend class WindowImpl; public: - Icon(); - ~Icon(); + inline Icon(); + inline explicit Icon(const Image& icon); + inline ~Icon(); bool Create(const Image& icon); void Destroy(); - bool IsValid() const; + inline bool IsValid() const; private: IconImpl* m_impl; }; } +#include + #endif // NAZARA_ICON_HPP diff --git a/include/Nazara/Utility/Icon.inl b/include/Nazara/Utility/Icon.inl new file mode 100644 index 000000000..d7f29eb54 --- /dev/null +++ b/include/Nazara/Utility/Icon.inl @@ -0,0 +1,42 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + Icon::Icon() : + m_impl(nullptr) + { + } + + inline Icon::Icon(const Image& icon) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + Create(icon); + } + + Icon::~Icon() + { + Destroy(); + } + + bool Icon::IsValid() const + { + return m_impl != nullptr; + } + + template + IconRef Icon::New(Args&&... args) + { + std::unique_ptr object(new Icon(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index 7360dd13e..657541c93 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -15,18 +15,18 @@ #include #include #include +#include #include #include #include +#include #include #include #include namespace Nz { - class Cursor; class Image; - class Icon; class WindowImpl; class NAZARA_UTILITY_API Window @@ -86,7 +86,7 @@ namespace Nz inline void SetCursor(SystemCursor systemCursor); void SetEventListener(bool listener); void SetFocus(); - void SetIcon(const Icon& icon); + void SetIcon(IconRef icon); void SetMaximumSize(const Vector2i& maxSize); void SetMaximumSize(int width, int height); void SetMinimumSize(const Vector2i& minSize); @@ -126,6 +126,7 @@ namespace Nz CursorController m_cursorController; CursorRef m_cursor; EventHandler m_eventHandler; + IconRef m_icon; Mutex m_eventMutex; Mutex m_eventConditionMutex; bool m_asyncWindow; diff --git a/src/Nazara/Utility/Icon.cpp b/src/Nazara/Utility/Icon.cpp index 0fa4fba11..21a39142f 100644 --- a/src/Nazara/Utility/Icon.cpp +++ b/src/Nazara/Utility/Icon.cpp @@ -16,30 +16,19 @@ namespace Nz { - Icon::Icon() : - m_impl(nullptr) - { - } - - Icon::~Icon() - { - Destroy(); - } - bool Icon::Create(const Image& icon) { Destroy(); - m_impl = new IconImpl; - if (!m_impl->Create(icon)) + std::unique_ptr impl(new IconImpl); + if (!impl->Create(icon)) { NazaraError("Failed to create icon implementation"); - delete m_impl; - m_impl = nullptr; - return false; } + m_impl = impl.release(); + return true; } @@ -53,9 +42,4 @@ namespace Nz m_impl = nullptr; } } - - bool Icon::IsValid() const - { - return m_impl != nullptr; - } } diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 7746a4236..a6a6d381d 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -408,23 +408,13 @@ namespace Nz m_impl->SetFocus(); } - void Window::SetIcon(const Icon& icon) + void Window::SetIcon(IconRef icon) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Window not created"); - return; - } + NazaraAssert(m_impl, "Window not created"); + NazaraAssert(icon && icon.IsValid(), "Invalid icon"); - if (!icon.IsValid()) - { - NazaraError("Icon is not valid"); - return; - } - #endif - - m_impl->SetIcon(icon); + m_icon = std::move(icon); + m_impl->SetIcon(*m_icon); } void Window::SetMaximumSize(const Vector2i& maxSize) From 6ba35700bfa34f7bc1c0bdbd195d640ad9017fcb Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Jan 2017 23:09:23 +0100 Subject: [PATCH 050/243] Sdk/BaseWidget: Cleanup canvas index --- SDK/include/NDK/BaseWidget.hpp | 6 +++++- SDK/include/NDK/BaseWidget.inl | 8 ++++++-- SDK/include/NDK/Canvas.inl | 2 +- SDK/src/NDK/BaseWidget.cpp | 22 +++++++++++++++------- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 9d13499d9..a3780263f 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace Ndk { @@ -95,11 +96,14 @@ namespace Ndk inline void DestroyChild(BaseWidget* widget); void DestroyChildren(); - void RegisterToCanvas(); + inline bool IsRegisteredToCanvas() const; inline void NotifyParentResized(const Nz::Vector2f& newSize); + void RegisterToCanvas(); inline void UpdateCanvasIndex(std::size_t index); void UnregisterFromCanvas(); + static constexpr std::size_t InvalidCanvasIndex = std::numeric_limits::max(); + std::size_t m_canvasIndex; std::vector m_entities; std::vector> m_children; diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 8ad0521a2..ad6a6ca3b 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -5,12 +5,11 @@ #include #include #include -#include namespace Ndk { inline BaseWidget::BaseWidget() : - m_canvasIndex(std::numeric_limits::max()), + m_canvasIndex(InvalidCanvasIndex), m_backgroundColor(Nz::Color(230, 230, 230, 255)), m_canvas(nullptr), m_contentSize(50.f, 50.f), @@ -98,6 +97,11 @@ namespace Ndk Layout(); } + inline bool BaseWidget::IsRegisteredToCanvas() const + { + return m_canvas && m_canvasIndex != InvalidCanvasIndex; + } + inline void BaseWidget::NotifyParentResized(const Nz::Vector2f& newSize) { for (const auto& widgetPtr : m_children) diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index 9fc19ed56..abe2dee0b 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -36,7 +36,7 @@ namespace Ndk DestroyChildren(); // Prevent our parent from trying to call us - m_canvasIndex = std::numeric_limits::max(); + m_canvasIndex = InvalidCanvasIndex; } inline const WorldHandle& Canvas::GetWorld() const diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index a971139eb..30ceaa86b 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -76,6 +76,14 @@ namespace Ndk } } + void BaseWidget::SetCursor(Nz::SystemCursor systemCursor) + { + m_cursor = systemCursor; + + if (IsRegisteredToCanvas()) + m_canvas->NotifyWidgetCursorUpdate(m_canvasIndex); + } + void BaseWidget::SetSize(const Nz::Vector2f& size) { SetContentSize({std::max(size.x - m_padding.left - m_padding.right, 0.f), std::max(size.y - m_padding.top - m_padding.bottom, 0.f)}); @@ -119,8 +127,8 @@ namespace Ndk void BaseWidget::Layout() { - if (m_canvas) - m_canvas->NotifyWidgetUpdate(m_canvasIndex); + if (IsRegisteredToCanvas()) + m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex); if (m_backgroundEntity) m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); @@ -130,8 +138,8 @@ namespace Ndk { Node::InvalidateNode(); - if (m_canvas) - m_canvas->NotifyWidgetUpdate(m_canvasIndex); + if (IsRegisteredToCanvas()) + m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex); } void BaseWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) @@ -189,17 +197,17 @@ namespace Ndk void BaseWidget::RegisterToCanvas() { - NazaraAssert(m_canvasIndex == std::numeric_limits::max(), "Widget is already registered to canvas"); + NazaraAssert(!IsRegisteredToCanvas(), "Widget is already registered to canvas"); m_canvasIndex = m_canvas->RegisterWidget(this); } void BaseWidget::UnregisterFromCanvas() { - if (m_canvasIndex != std::numeric_limits::max()) + if (IsRegisteredToCanvas()) { m_canvas->UnregisterWidget(m_canvasIndex); - m_canvasIndex = std::numeric_limits::max(); + m_canvasIndex = InvalidCanvasIndex; } } } From 59e0c1af29690e09a7eb6a39e16017ed824af8a7 Mon Sep 17 00:00:00 2001 From: DrLynix Date: Fri, 20 Jan 2017 09:50:26 +0100 Subject: [PATCH 051/243] Utility: Fixes compilation --- include/Nazara/Utility/Icon.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Utility/Icon.hpp b/include/Nazara/Utility/Icon.hpp index 61b68042b..1890d3c00 100644 --- a/include/Nazara/Utility/Icon.hpp +++ b/include/Nazara/Utility/Icon.hpp @@ -35,6 +35,8 @@ namespace Nz inline bool IsValid() const; + template static IconRef New(Args&&... args); + private: IconImpl* m_impl; }; From 15de1214cb1b53c09bd6dbe814c9ae9707e3b87a Mon Sep 17 00:00:00 2001 From: DrLynix Date: Fri, 20 Jan 2017 10:04:43 +0100 Subject: [PATCH 052/243] Utility: Fixes compilation --- src/Nazara/Utility/X11/WindowImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Utility/X11/WindowImpl.cpp b/src/Nazara/Utility/X11/WindowImpl.cpp index 10cd5fe27..d0cf3da59 100644 --- a/src/Nazara/Utility/X11/WindowImpl.cpp +++ b/src/Nazara/Utility/X11/WindowImpl.cpp @@ -251,7 +251,7 @@ namespace Nz if (m_window && m_ownsWindow) { // Unhide the mouse cursor (in case it was hidden) - SetCursor(SystemCursor_Default); + SetCursor(*Cursor::Get(SystemCursor_Default)); if (!X11::CheckCookie( connection, From e00d00931c0e4bca55d4a4894e98e77df2eba2fd Mon Sep 17 00:00:00 2001 From: DrLynix Date: Fri, 20 Jan 2017 10:07:20 +0100 Subject: [PATCH 053/243] Spoilers.. --- SDK/src/NDK/BaseWidget.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 30ceaa86b..2c04987bd 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -76,14 +76,6 @@ namespace Ndk } } - void BaseWidget::SetCursor(Nz::SystemCursor systemCursor) - { - m_cursor = systemCursor; - - if (IsRegisteredToCanvas()) - m_canvas->NotifyWidgetCursorUpdate(m_canvasIndex); - } - void BaseWidget::SetSize(const Nz::Vector2f& size) { SetContentSize({std::max(size.x - m_padding.left - m_padding.right, 0.f), std::max(size.y - m_padding.top - m_padding.bottom, 0.f)}); @@ -128,7 +120,7 @@ namespace Ndk void BaseWidget::Layout() { if (IsRegisteredToCanvas()) - m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex); + m_canvas->NotifyWidgetUpdate(m_canvasIndex); if (m_backgroundEntity) m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); @@ -139,7 +131,7 @@ namespace Ndk Node::InvalidateNode(); if (IsRegisteredToCanvas()) - m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex); + m_canvas->NotifyWidgetUpdate(m_canvasIndex); } void BaseWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) From f383eca19a4a1b30d04944ecb8d91f2ecb9a1024 Mon Sep 17 00:00:00 2001 From: DrLynix Date: Fri, 20 Jan 2017 12:58:35 +0100 Subject: [PATCH 054/243] Update copyright year --- SDK/include/NDK/Algorithm.hpp | 2 +- SDK/include/NDK/Algorithm.inl | 2 +- SDK/include/NDK/Application.hpp | 2 +- SDK/include/NDK/Application.inl | 2 +- SDK/include/NDK/BaseComponent.hpp | 2 +- SDK/include/NDK/BaseComponent.inl | 2 +- SDK/include/NDK/BaseSystem.hpp | 2 +- SDK/include/NDK/BaseSystem.inl | 2 +- SDK/include/NDK/BaseWidget.hpp | 2 +- SDK/include/NDK/BaseWidget.inl | 2 +- SDK/include/NDK/Canvas.hpp | 2 +- SDK/include/NDK/Canvas.inl | 2 +- SDK/include/NDK/Component.hpp | 2 +- SDK/include/NDK/Component.inl | 2 +- SDK/include/NDK/Components/CameraComponent.hpp | 2 +- SDK/include/NDK/Components/CameraComponent.inl | 2 +- SDK/include/NDK/Components/CollisionComponent2D.hpp | 2 +- SDK/include/NDK/Components/CollisionComponent2D.inl | 2 +- SDK/include/NDK/Components/CollisionComponent3D.hpp | 2 +- SDK/include/NDK/Components/CollisionComponent3D.inl | 2 +- SDK/include/NDK/Components/GraphicsComponent.hpp | 2 +- SDK/include/NDK/Components/GraphicsComponent.inl | 2 +- SDK/include/NDK/Components/LightComponent.hpp | 2 +- SDK/include/NDK/Components/LightComponent.inl | 2 +- SDK/include/NDK/Components/ListenerComponent.hpp | 2 +- SDK/include/NDK/Components/ListenerComponent.inl | 2 +- SDK/include/NDK/Components/NodeComponent.hpp | 2 +- SDK/include/NDK/Components/NodeComponent.inl | 2 +- SDK/include/NDK/Components/ParticleEmitterComponent.hpp | 2 +- SDK/include/NDK/Components/ParticleEmitterComponent.inl | 2 +- SDK/include/NDK/Components/ParticleGroupComponent.hpp | 2 +- SDK/include/NDK/Components/ParticleGroupComponent.inl | 2 +- SDK/include/NDK/Components/PhysicsComponent2D.hpp | 2 +- SDK/include/NDK/Components/PhysicsComponent2D.inl | 2 +- SDK/include/NDK/Components/PhysicsComponent3D.hpp | 2 +- SDK/include/NDK/Components/PhysicsComponent3D.inl | 2 +- SDK/include/NDK/Components/VelocityComponent.hpp | 2 +- SDK/include/NDK/Components/VelocityComponent.inl | 2 +- SDK/include/NDK/Console.hpp | 2 +- SDK/include/NDK/Console.inl | 2 +- SDK/include/NDK/Entity.hpp | 2 +- SDK/include/NDK/Entity.inl | 2 +- SDK/include/NDK/EntityList.hpp | 2 +- SDK/include/NDK/EntityList.inl | 2 +- SDK/include/NDK/EntityOwner.hpp | 2 +- SDK/include/NDK/EntityOwner.inl | 2 +- SDK/include/NDK/Lua/LuaBinding.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding.inl | 2 +- SDK/include/NDK/Lua/LuaBinding_Audio.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Base.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Core.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Graphics.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Math.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Network.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Renderer.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_SDK.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Utility.hpp | 2 +- SDK/include/NDK/LuaAPI.hpp | 2 +- SDK/include/NDK/LuaAPI.inl | 2 +- SDK/include/NDK/Sdk.hpp | 2 +- SDK/include/NDK/Sdk.inl | 2 +- SDK/include/NDK/State.hpp | 2 +- SDK/include/NDK/StateMachine.hpp | 2 +- SDK/include/NDK/StateMachine.inl | 2 +- SDK/include/NDK/System.hpp | 2 +- SDK/include/NDK/System.inl | 2 +- SDK/include/NDK/Systems/ListenerSystem.hpp | 2 +- SDK/include/NDK/Systems/ListenerSystem.inl | 2 +- SDK/include/NDK/Systems/ParticleSystem.hpp | 2 +- SDK/include/NDK/Systems/ParticleSystem.inl | 2 +- SDK/include/NDK/Systems/PhysicsSystem2D.hpp | 2 +- SDK/include/NDK/Systems/PhysicsSystem2D.inl | 2 +- SDK/include/NDK/Systems/PhysicsSystem3D.hpp | 2 +- SDK/include/NDK/Systems/PhysicsSystem3D.inl | 2 +- SDK/include/NDK/Systems/RenderSystem.hpp | 2 +- SDK/include/NDK/Systems/RenderSystem.inl | 2 +- SDK/include/NDK/Systems/VelocitySystem.hpp | 2 +- SDK/include/NDK/Systems/VelocitySystem.inl | 2 +- SDK/include/NDK/Widgets/ButtonWidget.hpp | 2 +- SDK/include/NDK/Widgets/ButtonWidget.inl | 2 +- SDK/include/NDK/Widgets/LabelWidget.hpp | 2 +- SDK/include/NDK/Widgets/LabelWidget.inl | 2 +- SDK/include/NDK/Widgets/TextAreaWidget.hpp | 2 +- SDK/include/NDK/Widgets/TextAreaWidget.inl | 2 +- SDK/include/NDK/World.hpp | 2 +- SDK/include/NDK/World.inl | 2 +- SDK/src/NDK/Application.cpp | 2 +- SDK/src/NDK/BaseComponent.cpp | 2 +- SDK/src/NDK/BaseSystem.cpp | 2 +- SDK/src/NDK/BaseWidget.cpp | 2 +- SDK/src/NDK/Canvas.cpp | 2 +- SDK/src/NDK/Components/CameraComponent.cpp | 2 +- SDK/src/NDK/Components/CollisionComponent2D.cpp | 2 +- SDK/src/NDK/Components/CollisionComponent3D.cpp | 2 +- SDK/src/NDK/Components/GraphicsComponent.cpp | 2 +- SDK/src/NDK/Components/LightComponent.cpp | 2 +- SDK/src/NDK/Components/ListenerComponent.cpp | 2 +- SDK/src/NDK/Components/NodeComponent.cpp | 2 +- SDK/src/NDK/Components/ParticleEmitterComponent.cpp | 2 +- SDK/src/NDK/Components/ParticleGroupComponent.cpp | 2 +- SDK/src/NDK/Components/PhysicsComponent2D.cpp | 2 +- SDK/src/NDK/Components/PhysicsComponent3D.cpp | 2 +- SDK/src/NDK/Components/VelocityComponent.cpp | 2 +- SDK/src/NDK/Console.cpp | 2 +- SDK/src/NDK/Entity.cpp | 2 +- SDK/src/NDK/Lua/LuaBinding_Renderer.cpp | 2 +- SDK/src/NDK/Lua/LuaBinding_SDK.cpp | 2 +- SDK/src/NDK/Sdk.cpp | 2 +- SDK/src/NDK/State.cpp | 2 +- SDK/src/NDK/Systems/ListenerSystem.cpp | 2 +- SDK/src/NDK/Systems/ParticleSystem.cpp | 2 +- SDK/src/NDK/Systems/PhysicsSystem2D.cpp | 2 +- SDK/src/NDK/Systems/PhysicsSystem3D.cpp | 2 +- SDK/src/NDK/Systems/RenderSystem.cpp | 2 +- SDK/src/NDK/Systems/VelocitySystem.cpp | 2 +- SDK/src/NDK/Widgets/ButtonWidget.cpp | 2 +- SDK/src/NDK/Widgets/LabelWidget.cpp | 2 +- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 2 +- SDK/src/NDK/World.cpp | 2 +- include/Nazara/Audio/Algorithm.hpp | 2 +- include/Nazara/Audio/Algorithm.inl | 2 +- include/Nazara/Audio/Audio.hpp | 2 +- include/Nazara/Audio/ConfigCheck.hpp | 2 +- include/Nazara/Audio/Debug.hpp | 2 +- include/Nazara/Audio/DebugOff.hpp | 2 +- include/Nazara/Audio/Enums.hpp | 2 +- include/Nazara/Audio/Music.hpp | 2 +- include/Nazara/Audio/OpenAL.hpp | 2 +- include/Nazara/Audio/Sound.hpp | 2 +- include/Nazara/Audio/SoundBuffer.hpp | 2 +- include/Nazara/Audio/SoundBuffer.inl | 2 +- include/Nazara/Audio/SoundEmitter.hpp | 2 +- include/Nazara/Audio/SoundStream.hpp | 2 +- include/Nazara/Core/AbstractHash.hpp | 2 +- include/Nazara/Core/AbstractLogger.hpp | 2 +- include/Nazara/Core/Algorithm.hpp | 2 +- include/Nazara/Core/Algorithm.inl | 2 +- include/Nazara/Core/Bitset.hpp | 2 +- include/Nazara/Core/Bitset.inl | 2 +- include/Nazara/Core/ByteArray.hpp | 2 +- include/Nazara/Core/ByteArray.inl | 2 +- include/Nazara/Core/ByteStream.hpp | 2 +- include/Nazara/Core/ByteStream.inl | 2 +- include/Nazara/Core/CallOnExit.hpp | 2 +- include/Nazara/Core/CallOnExit.inl | 2 +- include/Nazara/Core/Clock.hpp | 2 +- include/Nazara/Core/Color.hpp | 2 +- include/Nazara/Core/Color.inl | 2 +- include/Nazara/Core/ConditionVariable.hpp | 2 +- include/Nazara/Core/ConditionVariable.inl | 2 +- include/Nazara/Core/ConfigCheck.hpp | 2 +- include/Nazara/Core/Core.hpp | 2 +- include/Nazara/Core/Debug.hpp | 2 +- include/Nazara/Core/Debug/NewRedefinition.hpp | 2 +- include/Nazara/Core/DebugOff.hpp | 2 +- include/Nazara/Core/Directory.hpp | 2 +- include/Nazara/Core/DynLib.hpp | 2 +- include/Nazara/Core/Endianness.hpp | 2 +- include/Nazara/Core/Endianness.inl | 2 +- include/Nazara/Core/Enums.hpp | 2 +- include/Nazara/Core/Error.hpp | 2 +- include/Nazara/Core/ErrorFlags.hpp | 2 +- include/Nazara/Core/File.hpp | 2 +- include/Nazara/Core/File.inl | 2 +- include/Nazara/Core/FileLogger.hpp | 2 +- include/Nazara/Core/Flags.hpp | 2 +- include/Nazara/Core/Flags.inl | 2 +- include/Nazara/Core/Functor.hpp | 2 +- include/Nazara/Core/Functor.inl | 2 +- include/Nazara/Core/GuillotineBinPack.hpp | 2 +- include/Nazara/Core/HandledObject.hpp | 2 +- include/Nazara/Core/HandledObject.inl | 2 +- include/Nazara/Core/HardwareInfo.hpp | 2 +- include/Nazara/Core/Hash/CRC32.hpp | 2 +- include/Nazara/Core/Hash/Fletcher16.hpp | 2 +- include/Nazara/Core/Hash/MD5.hpp | 2 +- include/Nazara/Core/Hash/SHA1.hpp | 2 +- include/Nazara/Core/Hash/SHA224.hpp | 2 +- include/Nazara/Core/Hash/SHA256.hpp | 2 +- include/Nazara/Core/Hash/SHA384.hpp | 2 +- include/Nazara/Core/Hash/SHA512.hpp | 2 +- include/Nazara/Core/Hash/Whirlpool.hpp | 2 +- include/Nazara/Core/Initializer.hpp | 2 +- include/Nazara/Core/Initializer.inl | 2 +- include/Nazara/Core/LockGuard.hpp | 2 +- include/Nazara/Core/LockGuard.inl | 2 +- include/Nazara/Core/Log.hpp | 2 +- include/Nazara/Core/MemoryHelper.hpp | 2 +- include/Nazara/Core/MemoryHelper.inl | 2 +- include/Nazara/Core/MemoryManager.hpp | 2 +- include/Nazara/Core/MemoryPool.hpp | 2 +- include/Nazara/Core/MemoryPool.inl | 2 +- include/Nazara/Core/MemoryStream.hpp | 2 +- include/Nazara/Core/MemoryStream.inl | 2 +- include/Nazara/Core/MemoryView.hpp | 2 +- include/Nazara/Core/Mutex.hpp | 2 +- include/Nazara/Core/Mutex.inl | 2 +- include/Nazara/Core/ObjectHandle.hpp | 2 +- include/Nazara/Core/ObjectHandle.inl | 2 +- include/Nazara/Core/ObjectLibrary.hpp | 2 +- include/Nazara/Core/ObjectLibrary.inl | 2 +- include/Nazara/Core/ObjectRef.hpp | 2 +- include/Nazara/Core/ObjectRef.inl | 2 +- include/Nazara/Core/OffsetOf.hpp | 2 +- include/Nazara/Core/ParameterList.hpp | 2 +- include/Nazara/Core/PluginManager.hpp | 2 +- include/Nazara/Core/Primitive.hpp | 2 +- include/Nazara/Core/Primitive.inl | 2 +- include/Nazara/Core/PrimitiveList.hpp | 2 +- include/Nazara/Core/RefCounted.hpp | 2 +- include/Nazara/Core/Resource.hpp | 2 +- include/Nazara/Core/ResourceLoader.hpp | 2 +- include/Nazara/Core/ResourceLoader.inl | 2 +- include/Nazara/Core/ResourceManager.hpp | 2 +- include/Nazara/Core/ResourceManager.inl | 2 +- include/Nazara/Core/ResourceParameters.hpp | 2 +- include/Nazara/Core/ResourceSaver.hpp | 2 +- include/Nazara/Core/ResourceSaver.inl | 2 +- include/Nazara/Core/Semaphore.hpp | 2 +- include/Nazara/Core/SerializationContext.hpp | 2 +- include/Nazara/Core/SerializationContext.inl | 2 +- include/Nazara/Core/Signal.hpp | 2 +- include/Nazara/Core/Signal.inl | 2 +- include/Nazara/Core/SparsePtr.hpp | 2 +- include/Nazara/Core/SparsePtr.inl | 2 +- include/Nazara/Core/StdLogger.hpp | 2 +- include/Nazara/Core/Stream.hpp | 2 +- include/Nazara/Core/Stream.inl | 2 +- include/Nazara/Core/String.hpp | 2 +- include/Nazara/Core/String.inl | 2 +- include/Nazara/Core/StringStream.hpp | 2 +- include/Nazara/Core/TaskScheduler.hpp | 2 +- include/Nazara/Core/TaskScheduler.inl | 2 +- include/Nazara/Core/Thread.hpp | 2 +- include/Nazara/Core/Thread.inl | 2 +- include/Nazara/Core/ThreadSafety.hpp | 2 +- include/Nazara/Core/ThreadSafetyOff.hpp | 2 +- include/Nazara/Core/Unicode.hpp | 2 +- include/Nazara/Core/Updatable.hpp | 2 +- include/Nazara/Graphics/AbstractBackground.hpp | 2 +- include/Nazara/Graphics/AbstractRenderQueue.hpp | 2 +- include/Nazara/Graphics/AbstractRenderTechnique.hpp | 2 +- include/Nazara/Graphics/AbstractViewer.hpp | 2 +- include/Nazara/Graphics/Billboard.hpp | 2 +- include/Nazara/Graphics/Billboard.inl | 2 +- include/Nazara/Graphics/ColorBackground.hpp | 2 +- include/Nazara/Graphics/ColorBackground.inl | 2 +- include/Nazara/Graphics/ConfigCheck.hpp | 2 +- include/Nazara/Graphics/CullingList.hpp | 2 +- include/Nazara/Graphics/CullingList.inl | 2 +- include/Nazara/Graphics/Debug.hpp | 2 +- include/Nazara/Graphics/DebugOff.hpp | 2 +- include/Nazara/Graphics/DeferredBloomPass.hpp | 2 +- include/Nazara/Graphics/DeferredDOFPass.hpp | 2 +- include/Nazara/Graphics/DeferredFXAAPass.hpp | 2 +- include/Nazara/Graphics/DeferredFinalPass.hpp | 2 +- include/Nazara/Graphics/DeferredFogPass.hpp | 2 +- include/Nazara/Graphics/DeferredForwardPass.hpp | 2 +- include/Nazara/Graphics/DeferredGeometryPass.hpp | 2 +- include/Nazara/Graphics/DeferredPhongLightingPass.hpp | 2 +- include/Nazara/Graphics/DeferredRenderPass.hpp | 2 +- include/Nazara/Graphics/DeferredRenderQueue.hpp | 2 +- include/Nazara/Graphics/DeferredRenderTechnique.hpp | 2 +- include/Nazara/Graphics/DepthRenderQueue.hpp | 2 +- include/Nazara/Graphics/DepthRenderQueue.inl | 2 +- include/Nazara/Graphics/DepthRenderTechnique.hpp | 2 +- include/Nazara/Graphics/DepthRenderTechnique.inl | 2 +- include/Nazara/Graphics/Drawable.hpp | 2 +- include/Nazara/Graphics/Enums.hpp | 2 +- include/Nazara/Graphics/ForwardRenderQueue.hpp | 2 +- include/Nazara/Graphics/ForwardRenderTechnique.hpp | 2 +- include/Nazara/Graphics/ForwardRenderTechnique.inl | 2 +- include/Nazara/Graphics/Graphics.hpp | 2 +- include/Nazara/Graphics/GuillotineTextureAtlas.hpp | 2 +- include/Nazara/Graphics/InstancedRenderable.hpp | 2 +- include/Nazara/Graphics/InstancedRenderable.inl | 2 +- include/Nazara/Graphics/Light.hpp | 2 +- include/Nazara/Graphics/Light.inl | 2 +- include/Nazara/Graphics/Material.hpp | 2 +- include/Nazara/Graphics/Material.inl | 2 +- include/Nazara/Graphics/MaterialPipeline.hpp | 2 +- include/Nazara/Graphics/MaterialPipeline.inl | 2 +- include/Nazara/Graphics/Model.hpp | 2 +- include/Nazara/Graphics/Model.inl | 2 +- include/Nazara/Graphics/ParticleController.hpp | 2 +- include/Nazara/Graphics/ParticleDeclaration.hpp | 2 +- include/Nazara/Graphics/ParticleDeclaration.inl | 2 +- include/Nazara/Graphics/ParticleEmitter.hpp | 2 +- include/Nazara/Graphics/ParticleFunctionController.hpp | 2 +- include/Nazara/Graphics/ParticleFunctionController.inl | 2 +- include/Nazara/Graphics/ParticleFunctionGenerator.hpp | 2 +- include/Nazara/Graphics/ParticleFunctionGenerator.inl | 2 +- include/Nazara/Graphics/ParticleFunctionRenderer.hpp | 2 +- include/Nazara/Graphics/ParticleFunctionRenderer.inl | 2 +- include/Nazara/Graphics/ParticleGenerator.hpp | 2 +- include/Nazara/Graphics/ParticleGroup.hpp | 2 +- include/Nazara/Graphics/ParticleGroup.inl | 2 +- include/Nazara/Graphics/ParticleMapper.hpp | 2 +- include/Nazara/Graphics/ParticleMapper.inl | 2 +- include/Nazara/Graphics/ParticleRenderer.hpp | 2 +- include/Nazara/Graphics/ParticleStruct.hpp | 2 +- include/Nazara/Graphics/RenderTechniques.hpp | 2 +- include/Nazara/Graphics/Renderable.hpp | 2 +- include/Nazara/Graphics/Renderable.inl | 2 +- include/Nazara/Graphics/SceneData.hpp | 2 +- include/Nazara/Graphics/SkeletalModel.hpp | 2 +- include/Nazara/Graphics/SkinningManager.hpp | 2 +- include/Nazara/Graphics/SkyboxBackground.hpp | 2 +- include/Nazara/Graphics/SkyboxBackground.inl | 2 +- include/Nazara/Graphics/Sprite.hpp | 2 +- include/Nazara/Graphics/Sprite.inl | 2 +- include/Nazara/Graphics/TextSprite.hpp | 2 +- include/Nazara/Graphics/TextSprite.inl | 2 +- include/Nazara/Graphics/TextureBackground.hpp | 2 +- include/Nazara/Graphics/TextureBackground.inl | 2 +- include/Nazara/Graphics/TileMap.hpp | 2 +- include/Nazara/Graphics/TileMap.inl | 2 +- include/Nazara/Lua/ConfigCheck.hpp | 2 +- include/Nazara/Lua/Debug.hpp | 2 +- include/Nazara/Lua/DebugOff.hpp | 2 +- include/Nazara/Lua/Enums.hpp | 2 +- include/Nazara/Lua/Lua.hpp | 2 +- include/Nazara/Lua/LuaClass.hpp | 2 +- include/Nazara/Lua/LuaClass.inl | 2 +- include/Nazara/Lua/LuaInstance.hpp | 2 +- include/Nazara/Lua/LuaInstance.inl | 2 +- include/Nazara/Math/Algorithm.hpp | 2 +- include/Nazara/Math/Algorithm.inl | 2 +- include/Nazara/Math/BoundingVolume.hpp | 2 +- include/Nazara/Math/BoundingVolume.inl | 2 +- include/Nazara/Math/Box.hpp | 2 +- include/Nazara/Math/Box.inl | 2 +- include/Nazara/Math/Enums.hpp | 2 +- include/Nazara/Math/EulerAngles.hpp | 2 +- include/Nazara/Math/EulerAngles.inl | 2 +- include/Nazara/Math/Frustum.hpp | 2 +- include/Nazara/Math/Frustum.inl | 2 +- include/Nazara/Math/Matrix4.hpp | 2 +- include/Nazara/Math/Matrix4.inl | 2 +- include/Nazara/Math/OrientedBox.hpp | 2 +- include/Nazara/Math/OrientedBox.inl | 2 +- include/Nazara/Math/Plane.hpp | 2 +- include/Nazara/Math/Plane.inl | 2 +- include/Nazara/Math/Quaternion.hpp | 2 +- include/Nazara/Math/Quaternion.inl | 2 +- include/Nazara/Math/Ray.hpp | 2 +- include/Nazara/Math/Ray.inl | 2 +- include/Nazara/Math/Rect.hpp | 2 +- include/Nazara/Math/Rect.inl | 2 +- include/Nazara/Math/Sphere.hpp | 2 +- include/Nazara/Math/Sphere.inl | 2 +- include/Nazara/Math/Vector2.hpp | 2 +- include/Nazara/Math/Vector2.inl | 2 +- include/Nazara/Math/Vector3.hpp | 2 +- include/Nazara/Math/Vector3.inl | 2 +- include/Nazara/Math/Vector4.hpp | 2 +- include/Nazara/Math/Vector4.inl | 2 +- include/Nazara/Network/AbstractSocket.hpp | 2 +- include/Nazara/Network/AbstractSocket.inl | 2 +- include/Nazara/Network/Algorithm.hpp | 2 +- include/Nazara/Network/Algorithm.inl | 2 +- include/Nazara/Network/ConfigCheck.hpp | 2 +- include/Nazara/Network/Debug.hpp | 2 +- include/Nazara/Network/DebugOff.hpp | 2 +- include/Nazara/Network/Enums.hpp | 2 +- include/Nazara/Network/IpAddress.hpp | 2 +- include/Nazara/Network/IpAddress.inl | 2 +- include/Nazara/Network/NetPacket.hpp | 2 +- include/Nazara/Network/NetPacket.inl | 2 +- include/Nazara/Network/Network.hpp | 2 +- include/Nazara/Network/RUdpConnection.inl | 2 +- include/Nazara/Network/RUdpMessage.hpp | 2 +- include/Nazara/Network/SocketHandle.hpp | 2 +- include/Nazara/Network/SocketPoller.hpp | 2 +- include/Nazara/Network/SocketPoller.inl | 2 +- include/Nazara/Network/TcpClient.hpp | 2 +- include/Nazara/Network/TcpClient.inl | 2 +- include/Nazara/Network/TcpServer.hpp | 2 +- include/Nazara/Network/TcpServer.inl | 2 +- include/Nazara/Network/UdpSocket.hpp | 2 +- include/Nazara/Network/UdpSocket.inl | 2 +- include/Nazara/Noise/ConfigCheck.hpp | 2 +- include/Nazara/Noise/Debug.hpp | 2 +- include/Nazara/Noise/DebugOff.hpp | 2 +- include/Nazara/Noise/Enums.hpp | 2 +- include/Nazara/Noise/FBM.hpp | 2 +- include/Nazara/Noise/HybridMultiFractal.hpp | 2 +- include/Nazara/Noise/MixerBase.hpp | 2 +- include/Nazara/Noise/Noise.hpp | 2 +- include/Nazara/Noise/NoiseBase.hpp | 2 +- include/Nazara/Noise/NoiseTools.hpp | 2 +- include/Nazara/Noise/Perlin.hpp | 2 +- include/Nazara/Noise/Simplex.hpp | 2 +- include/Nazara/Noise/Worley.hpp | 2 +- include/Nazara/Physics2D/Collider2D.hpp | 2 +- include/Nazara/Physics2D/Collider2D.inl | 2 +- include/Nazara/Physics2D/ConfigCheck.hpp | 2 +- include/Nazara/Physics2D/Debug.hpp | 2 +- include/Nazara/Physics2D/DebugOff.hpp | 2 +- include/Nazara/Physics2D/Enums.hpp | 2 +- include/Nazara/Physics2D/PhysWorld2D.hpp | 2 +- include/Nazara/Physics2D/Physics2D.hpp | 2 +- include/Nazara/Physics2D/RigidBody2D.hpp | 2 +- include/Nazara/Physics3D/Collider3D.hpp | 2 +- include/Nazara/Physics3D/Collider3D.inl | 2 +- include/Nazara/Physics3D/ConfigCheck.hpp | 2 +- include/Nazara/Physics3D/Debug.hpp | 2 +- include/Nazara/Physics3D/DebugOff.hpp | 2 +- include/Nazara/Physics3D/Enums.hpp | 2 +- include/Nazara/Physics3D/PhysWorld3D.hpp | 2 +- include/Nazara/Physics3D/Physics3D.hpp | 2 +- include/Nazara/Physics3D/RigidBody3D.hpp | 2 +- include/Nazara/Renderer/ConfigCheck.hpp | 2 +- include/Nazara/Renderer/Context.hpp | 2 +- include/Nazara/Renderer/ContextParameters.hpp | 2 +- include/Nazara/Renderer/Debug.hpp | 2 +- include/Nazara/Renderer/DebugDrawer.hpp | 2 +- include/Nazara/Renderer/DebugOff.hpp | 2 +- include/Nazara/Renderer/Enums.hpp | 2 +- include/Nazara/Renderer/GpuQuery.hpp | 2 +- include/Nazara/Renderer/OpenGL.hpp | 2 +- include/Nazara/Renderer/RenderBuffer.hpp | 2 +- include/Nazara/Renderer/RenderBuffer.inl | 2 +- include/Nazara/Renderer/RenderPipeline.hpp | 2 +- include/Nazara/Renderer/RenderPipeline.inl | 2 +- include/Nazara/Renderer/RenderStates.hpp | 2 +- include/Nazara/Renderer/RenderStates.inl | 2 +- include/Nazara/Renderer/RenderTarget.hpp | 2 +- include/Nazara/Renderer/RenderTargetParameters.hpp | 2 +- include/Nazara/Renderer/RenderTexture.hpp | 2 +- include/Nazara/Renderer/RenderTexture.inl | 2 +- include/Nazara/Renderer/RenderWindow.hpp | 2 +- include/Nazara/Renderer/Renderer.hpp | 2 +- include/Nazara/Renderer/Shader.hpp | 2 +- include/Nazara/Renderer/Shader.inl | 2 +- include/Nazara/Renderer/ShaderStage.hpp | 2 +- include/Nazara/Renderer/Texture.hpp | 2 +- include/Nazara/Renderer/Texture.inl | 2 +- include/Nazara/Renderer/TextureSampler.hpp | 2 +- include/Nazara/Renderer/UberShader.hpp | 2 +- include/Nazara/Renderer/UberShaderInstance.hpp | 2 +- include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp | 2 +- include/Nazara/Renderer/UberShaderPreprocessor.hpp | 2 +- include/Nazara/Renderer/UberShaderPreprocessor.inl | 2 +- include/Nazara/Utility/AbstractAtlas.hpp | 2 +- include/Nazara/Utility/AbstractBuffer.hpp | 2 +- include/Nazara/Utility/AbstractImage.hpp | 2 +- include/Nazara/Utility/AbstractImage.inl | 2 +- include/Nazara/Utility/AbstractTextDrawer.hpp | 2 +- include/Nazara/Utility/Algorithm.hpp | 2 +- include/Nazara/Utility/Animation.hpp | 2 +- include/Nazara/Utility/Animation.inl | 2 +- include/Nazara/Utility/Buffer.hpp | 2 +- include/Nazara/Utility/Buffer.inl | 2 +- include/Nazara/Utility/BufferMapper.hpp | 2 +- include/Nazara/Utility/BufferMapper.inl | 2 +- include/Nazara/Utility/ConfigCheck.hpp | 2 +- include/Nazara/Utility/CubemapParams.hpp | 2 +- include/Nazara/Utility/Cursor.hpp | 2 +- include/Nazara/Utility/Cursor.inl | 2 +- include/Nazara/Utility/CursorController.hpp | 2 +- include/Nazara/Utility/CursorController.inl | 2 +- include/Nazara/Utility/Debug.hpp | 2 +- include/Nazara/Utility/DebugOff.hpp | 2 +- include/Nazara/Utility/Enums.hpp | 2 +- include/Nazara/Utility/Event.hpp | 2 +- include/Nazara/Utility/EventHandler.hpp | 2 +- include/Nazara/Utility/EventHandler.inl | 2 +- include/Nazara/Utility/Font.hpp | 2 +- include/Nazara/Utility/Font.inl | 2 +- include/Nazara/Utility/FontData.hpp | 2 +- include/Nazara/Utility/FontGlyph.hpp | 2 +- include/Nazara/Utility/Formats/MD5AnimParser.hpp | 2 +- include/Nazara/Utility/Formats/MD5MeshParser.hpp | 2 +- include/Nazara/Utility/Formats/MTLParser.hpp | 2 +- include/Nazara/Utility/Formats/MTLParser.inl | 2 +- include/Nazara/Utility/Formats/OBJParser.hpp | 2 +- include/Nazara/Utility/Formats/OBJParser.inl | 2 +- include/Nazara/Utility/GuillotineImageAtlas.hpp | 2 +- include/Nazara/Utility/Icon.hpp | 2 +- include/Nazara/Utility/Icon.inl | 2 +- include/Nazara/Utility/Image.hpp | 2 +- include/Nazara/Utility/Image.inl | 2 +- include/Nazara/Utility/IndexBuffer.hpp | 2 +- include/Nazara/Utility/IndexBuffer.inl | 2 +- include/Nazara/Utility/IndexIterator.hpp | 2 +- include/Nazara/Utility/IndexIterator.inl | 2 +- include/Nazara/Utility/IndexMapper.hpp | 2 +- include/Nazara/Utility/Joint.hpp | 2 +- include/Nazara/Utility/Joystick.hpp | 2 +- include/Nazara/Utility/Keyboard.hpp | 2 +- include/Nazara/Utility/MaterialData.hpp | 2 +- include/Nazara/Utility/Mesh.hpp | 2 +- include/Nazara/Utility/Mesh.inl | 2 +- include/Nazara/Utility/MeshData.hpp | 2 +- include/Nazara/Utility/Mouse.hpp | 2 +- include/Nazara/Utility/Node.hpp | 2 +- include/Nazara/Utility/PixelFormat.hpp | 2 +- include/Nazara/Utility/PixelFormat.inl | 2 +- include/Nazara/Utility/Sequence.hpp | 2 +- include/Nazara/Utility/SimpleTextDrawer.hpp | 2 +- include/Nazara/Utility/SkeletalMesh.hpp | 2 +- include/Nazara/Utility/SkeletalMesh.inl | 2 +- include/Nazara/Utility/Skeleton.hpp | 2 +- include/Nazara/Utility/Skeleton.inl | 2 +- include/Nazara/Utility/SoftwareBuffer.hpp | 2 +- include/Nazara/Utility/StaticMesh.hpp | 2 +- include/Nazara/Utility/StaticMesh.inl | 2 +- include/Nazara/Utility/SubMesh.hpp | 2 +- include/Nazara/Utility/TriangleIterator.hpp | 2 +- include/Nazara/Utility/Utility.hpp | 2 +- include/Nazara/Utility/VertexBuffer.hpp | 2 +- include/Nazara/Utility/VertexBuffer.inl | 2 +- include/Nazara/Utility/VertexDeclaration.hpp | 2 +- include/Nazara/Utility/VertexDeclaration.inl | 2 +- include/Nazara/Utility/VertexMapper.hpp | 2 +- include/Nazara/Utility/VertexMapper.inl | 2 +- include/Nazara/Utility/VertexStruct.hpp | 2 +- include/Nazara/Utility/VideoMode.hpp | 2 +- include/Nazara/Utility/Window.hpp | 2 +- include/Nazara/Utility/Window.inl | 2 +- include/Nazara/Utility/WindowHandle.hpp | 2 +- plugins/Assimp/CustomStream.cpp | 2 +- plugins/Assimp/CustomStream.hpp | 2 +- src/Nazara/Audio/Audio.cpp | 2 +- src/Nazara/Audio/Debug/NewOverload.cpp | 2 +- src/Nazara/Audio/Formats/sndfileLoader.cpp | 2 +- src/Nazara/Audio/Formats/sndfileLoader.hpp | 2 +- src/Nazara/Audio/Music.cpp | 2 +- src/Nazara/Audio/OpenAL.cpp | 2 +- src/Nazara/Audio/Sound.cpp | 2 +- src/Nazara/Audio/SoundBuffer.cpp | 2 +- src/Nazara/Audio/SoundEmitter.cpp | 2 +- src/Nazara/Audio/SoundStream.cpp | 2 +- src/Nazara/Core/AbstractHash.cpp | 2 +- src/Nazara/Core/AbstractLogger.cpp | 2 +- src/Nazara/Core/AlgorithmCore.cpp | 2 +- src/Nazara/Core/ByteArray.cpp | 2 +- src/Nazara/Core/ByteStream.cpp | 2 +- src/Nazara/Core/Clock.cpp | 2 +- src/Nazara/Core/Color.cpp | 2 +- src/Nazara/Core/ConditionVariable.cpp | 2 +- src/Nazara/Core/Core.cpp | 2 +- src/Nazara/Core/Debug/NewOverload.cpp | 2 +- src/Nazara/Core/Debug/NewRedefinition.cpp | 2 +- src/Nazara/Core/Directory.cpp | 2 +- src/Nazara/Core/DynLib.cpp | 2 +- src/Nazara/Core/Error.cpp | 2 +- src/Nazara/Core/ErrorFlags.cpp | 2 +- src/Nazara/Core/File.cpp | 2 +- src/Nazara/Core/FileLogger.cpp | 2 +- src/Nazara/Core/GuillotineBinPack.cpp | 2 +- src/Nazara/Core/HardwareInfo.cpp | 2 +- src/Nazara/Core/Hash/CRC32.cpp | 2 +- src/Nazara/Core/Hash/Fletcher16.cpp | 2 +- src/Nazara/Core/Hash/MD5.cpp | 2 +- src/Nazara/Core/Hash/SHA/Internal.cpp | 2 +- src/Nazara/Core/Hash/SHA/Internal.hpp | 2 +- src/Nazara/Core/Hash/SHA1.cpp | 2 +- src/Nazara/Core/Hash/SHA224.cpp | 2 +- src/Nazara/Core/Hash/SHA256.cpp | 2 +- src/Nazara/Core/Hash/SHA384.cpp | 2 +- src/Nazara/Core/Hash/SHA512.cpp | 2 +- src/Nazara/Core/Hash/Whirlpool.cpp | 2 +- src/Nazara/Core/Log.cpp | 2 +- src/Nazara/Core/MemoryManager.cpp | 2 +- src/Nazara/Core/MemoryStream.cpp | 2 +- src/Nazara/Core/MemoryView.cpp | 2 +- src/Nazara/Core/Mutex.cpp | 2 +- src/Nazara/Core/ParameterList.cpp | 2 +- src/Nazara/Core/PluginManager.cpp | 2 +- src/Nazara/Core/PrimitiveList.cpp | 2 +- src/Nazara/Core/RefCounted.cpp | 2 +- src/Nazara/Core/Resource.cpp | 2 +- src/Nazara/Core/Semaphore.cpp | 2 +- src/Nazara/Core/SerializationContext.cpp | 2 +- src/Nazara/Core/StdLogger.cpp | 2 +- src/Nazara/Core/Stream.cpp | 2 +- src/Nazara/Core/String.cpp | 2 +- src/Nazara/Core/StringStream.cpp | 2 +- src/Nazara/Core/TaskScheduler.cpp | 2 +- src/Nazara/Core/Thread.cpp | 2 +- src/Nazara/Core/Unicode.cpp | 2 +- src/Nazara/Core/Updatable.cpp | 2 +- src/Nazara/Core/Win32/ClockImpl.cpp | 2 +- src/Nazara/Core/Win32/ClockImpl.hpp | 2 +- src/Nazara/Core/Win32/ConditionVariableImpl.cpp | 2 +- src/Nazara/Core/Win32/ConditionVariableImpl.hpp | 2 +- src/Nazara/Core/Win32/DirectoryImpl.cpp | 2 +- src/Nazara/Core/Win32/DirectoryImpl.hpp | 2 +- src/Nazara/Core/Win32/DynLibImpl.cpp | 2 +- src/Nazara/Core/Win32/DynLibImpl.hpp | 2 +- src/Nazara/Core/Win32/FileImpl.cpp | 2 +- src/Nazara/Core/Win32/FileImpl.hpp | 2 +- src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 2 +- src/Nazara/Core/Win32/HardwareInfoImpl.hpp | 2 +- src/Nazara/Core/Win32/MutexImpl.cpp | 2 +- src/Nazara/Core/Win32/MutexImpl.hpp | 2 +- src/Nazara/Core/Win32/SemaphoreImpl.cpp | 2 +- src/Nazara/Core/Win32/SemaphoreImpl.hpp | 2 +- src/Nazara/Core/Win32/TaskSchedulerImpl.cpp | 2 +- src/Nazara/Core/Win32/TaskSchedulerImpl.hpp | 2 +- src/Nazara/Core/Win32/ThreadImpl.cpp | 2 +- src/Nazara/Core/Win32/ThreadImpl.hpp | 2 +- src/Nazara/Core/Win32/Time.cpp | 2 +- src/Nazara/Core/Win32/Time.hpp | 2 +- src/Nazara/Graphics/AbstractBackground.cpp | 2 +- src/Nazara/Graphics/AbstractRenderQueue.cpp | 2 +- src/Nazara/Graphics/AbstractRenderTechnique.cpp | 2 +- src/Nazara/Graphics/AbstractViewer.cpp | 2 +- src/Nazara/Graphics/Billboard.cpp | 2 +- src/Nazara/Graphics/ColorBackground.cpp | 2 +- src/Nazara/Graphics/Debug/NewOverload.cpp | 2 +- src/Nazara/Graphics/DeferredBloomPass.cpp | 2 +- src/Nazara/Graphics/DeferredDOFPass.cpp | 2 +- src/Nazara/Graphics/DeferredFXAAPass.cpp | 2 +- src/Nazara/Graphics/DeferredFinalPass.cpp | 2 +- src/Nazara/Graphics/DeferredFogPass.cpp | 2 +- src/Nazara/Graphics/DeferredForwardPass.cpp | 2 +- src/Nazara/Graphics/DeferredGeometryPass.cpp | 2 +- src/Nazara/Graphics/DeferredPhongLightingPass.cpp | 2 +- src/Nazara/Graphics/DeferredRenderPass.cpp | 2 +- src/Nazara/Graphics/DeferredRenderQueue.cpp | 2 +- src/Nazara/Graphics/DeferredRenderTechnique.cpp | 2 +- src/Nazara/Graphics/DepthRenderQueue.cpp | 2 +- src/Nazara/Graphics/DepthRenderTechnique.cpp | 2 +- src/Nazara/Graphics/Drawable.cpp | 2 +- src/Nazara/Graphics/Formats/MeshLoader.cpp | 2 +- src/Nazara/Graphics/Formats/MeshLoader.hpp | 2 +- src/Nazara/Graphics/Formats/TextureLoader.cpp | 2 +- src/Nazara/Graphics/Formats/TextureLoader.hpp | 2 +- src/Nazara/Graphics/ForwardRenderQueue.cpp | 2 +- src/Nazara/Graphics/ForwardRenderTechnique.cpp | 2 +- src/Nazara/Graphics/Graphics.cpp | 2 +- src/Nazara/Graphics/GuillotineTextureAtlas.cpp | 2 +- src/Nazara/Graphics/InstancedRenderable.cpp | 2 +- src/Nazara/Graphics/Light.cpp | 2 +- src/Nazara/Graphics/Material.cpp | 2 +- src/Nazara/Graphics/MaterialPipeline.cpp | 2 +- src/Nazara/Graphics/Model.cpp | 2 +- src/Nazara/Graphics/ParticleController.cpp | 2 +- src/Nazara/Graphics/ParticleDeclaration.cpp | 2 +- src/Nazara/Graphics/ParticleEmitter.cpp | 2 +- src/Nazara/Graphics/ParticleFunctionController.cpp | 2 +- src/Nazara/Graphics/ParticleFunctionGenerator.cpp | 2 +- src/Nazara/Graphics/ParticleFunctionRenderer.cpp | 2 +- src/Nazara/Graphics/ParticleGenerator.cpp | 2 +- src/Nazara/Graphics/ParticleGroup.cpp | 2 +- src/Nazara/Graphics/ParticleMapper.cpp | 2 +- src/Nazara/Graphics/ParticleRenderer.cpp | 2 +- src/Nazara/Graphics/RenderTechniques.cpp | 2 +- src/Nazara/Graphics/Renderable.cpp | 2 +- src/Nazara/Graphics/SkeletalModel.cpp | 2 +- src/Nazara/Graphics/SkinningManager.cpp | 2 +- src/Nazara/Graphics/SkyboxBackground.cpp | 2 +- src/Nazara/Graphics/Sprite.cpp | 2 +- src/Nazara/Graphics/TextSprite.cpp | 2 +- src/Nazara/Graphics/TextureBackground.cpp | 2 +- src/Nazara/Graphics/TileMap.cpp | 2 +- src/Nazara/Lua/Debug/NewOverload.cpp | 2 +- src/Nazara/Lua/Lua.cpp | 2 +- src/Nazara/Lua/LuaInstance.cpp | 2 +- src/Nazara/Network/AbstractSocket.cpp | 2 +- src/Nazara/Network/AlgorithmNetwork.cpp | 2 +- src/Nazara/Network/Debug/NewOverload.cpp | 2 +- src/Nazara/Network/IpAddress.cpp | 2 +- src/Nazara/Network/NetPacket.cpp | 2 +- src/Nazara/Network/Network.cpp | 2 +- src/Nazara/Network/RUdpConnection.cpp | 2 +- src/Nazara/Network/SocketPoller.cpp | 2 +- src/Nazara/Network/SystemSocket.hpp | 2 +- src/Nazara/Network/TcpClient.cpp | 2 +- src/Nazara/Network/TcpServer.cpp | 2 +- src/Nazara/Network/UdpSocket.cpp | 2 +- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 +- src/Nazara/Network/Win32/IpAddressImpl.hpp | 2 +- src/Nazara/Network/Win32/SocketImpl.cpp | 2 +- src/Nazara/Network/Win32/SocketImpl.hpp | 2 +- src/Nazara/Network/Win32/SocketPollerImpl.cpp | 2 +- src/Nazara/Network/Win32/SocketPollerImpl.hpp | 2 +- src/Nazara/Noise/Debug/NewOverload.cpp | 2 +- src/Nazara/Noise/FBM.cpp | 2 +- src/Nazara/Noise/HybridMultiFractal.cpp | 2 +- src/Nazara/Noise/MixerBase.cpp | 2 +- src/Nazara/Noise/Noise.cpp | 2 +- src/Nazara/Noise/NoiseBase.cpp | 2 +- src/Nazara/Noise/NoiseTools.cpp | 2 +- src/Nazara/Noise/Perlin.cpp | 2 +- src/Nazara/Noise/Simplex.cpp | 2 +- src/Nazara/Noise/Worley.cpp | 2 +- src/Nazara/Physics2D/Collider2D.cpp | 2 +- src/Nazara/Physics2D/Debug/NewOverload.cpp | 2 +- src/Nazara/Physics2D/PhysWorld2D.cpp | 2 +- src/Nazara/Physics2D/Physics2D.cpp | 2 +- src/Nazara/Physics2D/RigidBody2D.cpp | 2 +- src/Nazara/Physics3D/Collider3D.cpp | 2 +- src/Nazara/Physics3D/Debug/NewOverload.cpp | 2 +- src/Nazara/Physics3D/PhysWorld3D.cpp | 2 +- src/Nazara/Physics3D/Physics3D.cpp | 2 +- src/Nazara/Physics3D/RigidBody3D.cpp | 2 +- src/Nazara/Renderer/Context.cpp | 2 +- src/Nazara/Renderer/ContextParameters.cpp | 2 +- src/Nazara/Renderer/Debug/NewOverload.cpp | 2 +- src/Nazara/Renderer/DebugDrawer.cpp | 2 +- src/Nazara/Renderer/GpuQuery.cpp | 2 +- src/Nazara/Renderer/HardwareBuffer.cpp | 2 +- src/Nazara/Renderer/HardwareBuffer.hpp | 2 +- src/Nazara/Renderer/OpenGL.cpp | 2 +- src/Nazara/Renderer/RenderBuffer.cpp | 2 +- src/Nazara/Renderer/RenderTarget.cpp | 2 +- src/Nazara/Renderer/RenderTexture.cpp | 2 +- src/Nazara/Renderer/RenderWindow.cpp | 2 +- src/Nazara/Renderer/Renderer.cpp | 2 +- src/Nazara/Renderer/Shader.cpp | 2 +- src/Nazara/Renderer/ShaderStage.cpp | 2 +- src/Nazara/Renderer/Texture.cpp | 2 +- src/Nazara/Renderer/TextureSampler.cpp | 2 +- src/Nazara/Renderer/UberShader.cpp | 2 +- src/Nazara/Renderer/UberShaderInstance.cpp | 2 +- src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp | 2 +- src/Nazara/Renderer/UberShaderPreprocessor.cpp | 2 +- src/Nazara/Renderer/Win32/ContextImpl.cpp | 2 +- src/Nazara/Renderer/Win32/ContextImpl.hpp | 2 +- src/Nazara/Utility/AbstractAtlas.cpp | 2 +- src/Nazara/Utility/AbstractBuffer.cpp | 2 +- src/Nazara/Utility/AbstractImage.cpp | 2 +- src/Nazara/Utility/AbstractTextDrawer.cpp | 2 +- src/Nazara/Utility/AlgorithmUtility.cpp | 2 +- src/Nazara/Utility/Animation.cpp | 2 +- src/Nazara/Utility/Buffer.cpp | 2 +- src/Nazara/Utility/Cursor.cpp | 2 +- src/Nazara/Utility/Debug/NewOverload.cpp | 2 +- src/Nazara/Utility/Font.cpp | 2 +- src/Nazara/Utility/FontData.cpp | 2 +- src/Nazara/Utility/Formats/DDSConstants.cpp | 2 +- src/Nazara/Utility/Formats/DDSLoader.cpp | 2 +- src/Nazara/Utility/Formats/DDSLoader.hpp | 2 +- src/Nazara/Utility/Formats/FreeTypeLoader.cpp | 2 +- src/Nazara/Utility/Formats/FreeTypeLoader.hpp | 2 +- src/Nazara/Utility/Formats/MD2Constants.cpp | 2 +- src/Nazara/Utility/Formats/MD2Constants.hpp | 2 +- src/Nazara/Utility/Formats/MD2Loader.cpp | 2 +- src/Nazara/Utility/Formats/MD2Loader.hpp | 2 +- src/Nazara/Utility/Formats/MD5AnimLoader.cpp | 2 +- src/Nazara/Utility/Formats/MD5AnimLoader.hpp | 2 +- src/Nazara/Utility/Formats/MD5AnimParser.cpp | 2 +- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 2 +- src/Nazara/Utility/Formats/MD5MeshLoader.hpp | 2 +- src/Nazara/Utility/Formats/MD5MeshParser.cpp | 2 +- src/Nazara/Utility/Formats/MTLParser.cpp | 2 +- src/Nazara/Utility/Formats/OBJLoader.cpp | 2 +- src/Nazara/Utility/Formats/OBJLoader.hpp | 2 +- src/Nazara/Utility/Formats/OBJParser.cpp | 2 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 2 +- src/Nazara/Utility/Formats/OBJSaver.hpp | 2 +- src/Nazara/Utility/Formats/PCXLoader.cpp | 2 +- src/Nazara/Utility/Formats/PCXLoader.hpp | 2 +- src/Nazara/Utility/Formats/STBLoader.cpp | 2 +- src/Nazara/Utility/Formats/STBLoader.hpp | 2 +- src/Nazara/Utility/Formats/STBSaver.cpp | 2 +- src/Nazara/Utility/Formats/STBSaver.hpp | 2 +- src/Nazara/Utility/GuillotineImageAtlas.cpp | 2 +- src/Nazara/Utility/Icon.cpp | 2 +- src/Nazara/Utility/Image.cpp | 2 +- src/Nazara/Utility/IndexBuffer.cpp | 2 +- src/Nazara/Utility/IndexMapper.cpp | 2 +- src/Nazara/Utility/Joint.cpp | 2 +- src/Nazara/Utility/Keyboard.cpp | 2 +- src/Nazara/Utility/Mesh.cpp | 2 +- src/Nazara/Utility/Mouse.cpp | 2 +- src/Nazara/Utility/Node.cpp | 2 +- src/Nazara/Utility/PixelFormat.cpp | 2 +- src/Nazara/Utility/SimpleTextDrawer.cpp | 2 +- src/Nazara/Utility/SkeletalMesh.cpp | 2 +- src/Nazara/Utility/Skeleton.cpp | 2 +- src/Nazara/Utility/SoftwareBuffer.cpp | 2 +- src/Nazara/Utility/StaticMesh.cpp | 2 +- src/Nazara/Utility/SubMesh.cpp | 2 +- src/Nazara/Utility/TriangleIterator.cpp | 2 +- src/Nazara/Utility/Utility.cpp | 2 +- src/Nazara/Utility/VertexBuffer.cpp | 2 +- src/Nazara/Utility/VertexDeclaration.cpp | 2 +- src/Nazara/Utility/VertexMapper.cpp | 2 +- src/Nazara/Utility/VideoMode.cpp | 2 +- src/Nazara/Utility/VideoModeImpl.hpp | 2 +- src/Nazara/Utility/Win32/CursorImpl.cpp | 2 +- src/Nazara/Utility/Win32/CursorImpl.hpp | 2 +- src/Nazara/Utility/Win32/IconImpl.cpp | 2 +- src/Nazara/Utility/Win32/IconImpl.hpp | 2 +- src/Nazara/Utility/Win32/InputImpl.cpp | 2 +- src/Nazara/Utility/Win32/InputImpl.hpp | 2 +- src/Nazara/Utility/Win32/VideoModeImpl.cpp | 2 +- src/Nazara/Utility/Win32/VideoModeImpl.hpp | 2 +- src/Nazara/Utility/Win32/WindowImpl.cpp | 2 +- src/Nazara/Utility/Win32/WindowImpl.hpp | 2 +- src/Nazara/Utility/Window.cpp | 2 +- src/Nazara/Utility/X11/ScopedXCB.inl | 2 +- 797 files changed, 797 insertions(+), 797 deletions(-) diff --git a/SDK/include/NDK/Algorithm.hpp b/SDK/include/NDK/Algorithm.hpp index da75f4ff7..9e29f53cf 100644 --- a/SDK/include/NDK/Algorithm.hpp +++ b/SDK/include/NDK/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Algorithm.inl b/SDK/include/NDK/Algorithm.inl index fbdad365b..54339ce38 100644 --- a/SDK/include/NDK/Algorithm.inl +++ b/SDK/include/NDK/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index b3f803fe1..2ada48555 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 0b4f2ce10..e7f074c3e 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NDK/BaseComponent.hpp index 0a48c394d..8a4d51bfe 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NDK/BaseComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/BaseComponent.inl b/SDK/include/NDK/BaseComponent.inl index 0e8af931f..7abade990 100644 --- a/SDK/include/NDK/BaseComponent.inl +++ b/SDK/include/NDK/BaseComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/BaseSystem.hpp b/SDK/include/NDK/BaseSystem.hpp index 7433f7d04..a323f2952 100644 --- a/SDK/include/NDK/BaseSystem.hpp +++ b/SDK/include/NDK/BaseSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/BaseSystem.inl b/SDK/include/NDK/BaseSystem.inl index 79971e3d6..e949d254b 100644 --- a/SDK/include/NDK/BaseSystem.inl +++ b/SDK/include/NDK/BaseSystem.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index a3780263f..5022ade61 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index ad6a6ca3b..9134b3c32 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NDK/Canvas.hpp index 914287fa2..f3ba31705 100644 --- a/SDK/include/NDK/Canvas.hpp +++ b/SDK/include/NDK/Canvas.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index abe2dee0b..9ad38b852 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Component.hpp b/SDK/include/NDK/Component.hpp index b0f61fd92..14afd253b 100644 --- a/SDK/include/NDK/Component.hpp +++ b/SDK/include/NDK/Component.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Component.inl b/SDK/include/NDK/Component.inl index 6ca3f1944..a629dc8b4 100644 --- a/SDK/include/NDK/Component.inl +++ b/SDK/include/NDK/Component.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/CameraComponent.hpp b/SDK/include/NDK/Components/CameraComponent.hpp index 5a9efe742..04859b1de 100644 --- a/SDK/include/NDK/Components/CameraComponent.hpp +++ b/SDK/include/NDK/Components/CameraComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index 9aadfd509..0b445f1f3 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/CollisionComponent2D.hpp b/SDK/include/NDK/Components/CollisionComponent2D.hpp index b282a850e..28c3637a2 100644 --- a/SDK/include/NDK/Components/CollisionComponent2D.hpp +++ b/SDK/include/NDK/Components/CollisionComponent2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/CollisionComponent2D.inl b/SDK/include/NDK/Components/CollisionComponent2D.inl index 62bf422cb..147e8ec32 100644 --- a/SDK/include/NDK/Components/CollisionComponent2D.inl +++ b/SDK/include/NDK/Components/CollisionComponent2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/CollisionComponent3D.hpp b/SDK/include/NDK/Components/CollisionComponent3D.hpp index 9a9671660..992e73053 100644 --- a/SDK/include/NDK/Components/CollisionComponent3D.hpp +++ b/SDK/include/NDK/Components/CollisionComponent3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/CollisionComponent3D.inl b/SDK/include/NDK/Components/CollisionComponent3D.inl index d5dfeaacc..7d82252af 100644 --- a/SDK/include/NDK/Components/CollisionComponent3D.inl +++ b/SDK/include/NDK/Components/CollisionComponent3D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 418500a96..cd62f9b2f 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 6ca950e24..e67b6f323 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/LightComponent.hpp b/SDK/include/NDK/Components/LightComponent.hpp index 80f84a759..ba1c5f5c7 100644 --- a/SDK/include/NDK/Components/LightComponent.hpp +++ b/SDK/include/NDK/Components/LightComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/LightComponent.inl b/SDK/include/NDK/Components/LightComponent.inl index ba11703c5..10237b8ac 100644 --- a/SDK/include/NDK/Components/LightComponent.inl +++ b/SDK/include/NDK/Components/LightComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/ListenerComponent.hpp b/SDK/include/NDK/Components/ListenerComponent.hpp index a2b9d59d2..6e4b8284f 100644 --- a/SDK/include/NDK/Components/ListenerComponent.hpp +++ b/SDK/include/NDK/Components/ListenerComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/ListenerComponent.inl b/SDK/include/NDK/Components/ListenerComponent.inl index f2276e439..8728ce9bc 100644 --- a/SDK/include/NDK/Components/ListenerComponent.inl +++ b/SDK/include/NDK/Components/ListenerComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/NodeComponent.hpp b/SDK/include/NDK/Components/NodeComponent.hpp index c2a4eeb83..a04f9b333 100644 --- a/SDK/include/NDK/Components/NodeComponent.hpp +++ b/SDK/include/NDK/Components/NodeComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/NodeComponent.inl b/SDK/include/NDK/Components/NodeComponent.inl index 0150cbbfa..0e953c86e 100644 --- a/SDK/include/NDK/Components/NodeComponent.inl +++ b/SDK/include/NDK/Components/NodeComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp index 6ad3e3981..dd40f7aaa 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.inl b/SDK/include/NDK/Components/ParticleEmitterComponent.inl index 7f8e62cd8..292a2ed8f 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.inl +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.hpp b/SDK/include/NDK/Components/ParticleGroupComponent.hpp index 549a6df5c..533eb907e 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.hpp +++ b/SDK/include/NDK/Components/ParticleGroupComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.inl b/SDK/include/NDK/Components/ParticleGroupComponent.inl index 591e78605..dc3072faa 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.inl +++ b/SDK/include/NDK/Components/ParticleGroupComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.hpp b/SDK/include/NDK/Components/PhysicsComponent2D.hpp index 90dd7a5e6..1f4cc63c9 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.inl b/SDK/include/NDK/Components/PhysicsComponent2D.inl index 312e23e3a..7aea6dca6 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.inl +++ b/SDK/include/NDK/Components/PhysicsComponent2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/PhysicsComponent3D.hpp b/SDK/include/NDK/Components/PhysicsComponent3D.hpp index 9fb1bb45e..f6f13ec09 100644 --- a/SDK/include/NDK/Components/PhysicsComponent3D.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/PhysicsComponent3D.inl b/SDK/include/NDK/Components/PhysicsComponent3D.inl index cad098af8..72646e16a 100644 --- a/SDK/include/NDK/Components/PhysicsComponent3D.inl +++ b/SDK/include/NDK/Components/PhysicsComponent3D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/VelocityComponent.hpp b/SDK/include/NDK/Components/VelocityComponent.hpp index 909adf4d4..39cdd9f1a 100644 --- a/SDK/include/NDK/Components/VelocityComponent.hpp +++ b/SDK/include/NDK/Components/VelocityComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Components/VelocityComponent.inl b/SDK/include/NDK/Components/VelocityComponent.inl index e72eca8b7..2cf4f1ec3 100644 --- a/SDK/include/NDK/Components/VelocityComponent.inl +++ b/SDK/include/NDK/Components/VelocityComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Console.hpp b/SDK/include/NDK/Console.hpp index 59a98df0d..5c7935a7c 100644 --- a/SDK/include/NDK/Console.hpp +++ b/SDK/include/NDK/Console.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Console.inl b/SDK/include/NDK/Console.inl index 94a6daf91..c97adda20 100644 --- a/SDK/include/NDK/Console.inl +++ b/SDK/include/NDK/Console.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index dbe77815c..ecf9fcc62 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index 535f2c1f4..e6f997226 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/EntityList.hpp b/SDK/include/NDK/EntityList.hpp index 006967413..4047388cc 100644 --- a/SDK/include/NDK/EntityList.hpp +++ b/SDK/include/NDK/EntityList.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index 224fdd1dc..126af0a7e 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/EntityOwner.hpp b/SDK/include/NDK/EntityOwner.hpp index d0a4a4f59..9216b3d3c 100644 --- a/SDK/include/NDK/EntityOwner.hpp +++ b/SDK/include/NDK/EntityOwner.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/EntityOwner.inl b/SDK/include/NDK/EntityOwner.inl index 2cb64f1e8..7a7c94815 100644 --- a/SDK/include/NDK/EntityOwner.inl +++ b/SDK/include/NDK/EntityOwner.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding.hpp b/SDK/include/NDK/Lua/LuaBinding.hpp index 307345589..88b6a88ef 100644 --- a/SDK/include/NDK/Lua/LuaBinding.hpp +++ b/SDK/include/NDK/Lua/LuaBinding.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding.inl b/SDK/include/NDK/Lua/LuaBinding.inl index ca77dfcf6..c9f3f86bb 100644 --- a/SDK/include/NDK/Lua/LuaBinding.inl +++ b/SDK/include/NDK/Lua/LuaBinding.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_Audio.hpp b/SDK/include/NDK/Lua/LuaBinding_Audio.hpp index 510654342..1764fb729 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Audio.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Audio.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_Base.hpp b/SDK/include/NDK/Lua/LuaBinding_Base.hpp index 29c486835..36c41af8c 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Base.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Base.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_Core.hpp b/SDK/include/NDK/Lua/LuaBinding_Core.hpp index 54400958f..97d31cde4 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Core.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Core.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp b/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp index 75a6eff8f..0bfece994 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_Math.hpp b/SDK/include/NDK/Lua/LuaBinding_Math.hpp index 195d34ec2..d94f357c3 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Math.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Math.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_Network.hpp b/SDK/include/NDK/Lua/LuaBinding_Network.hpp index f69e038a7..a9a5b31e0 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Network.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Network.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp b/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp index 7655c9ac3..a2db03f8d 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_SDK.hpp b/SDK/include/NDK/Lua/LuaBinding_SDK.hpp index facfd5620..b6b7079eb 100644 --- a/SDK/include/NDK/Lua/LuaBinding_SDK.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_SDK.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Lua/LuaBinding_Utility.hpp b/SDK/include/NDK/Lua/LuaBinding_Utility.hpp index 80afde5bf..b10492efc 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Utility.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Utility.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/LuaAPI.hpp b/SDK/include/NDK/LuaAPI.hpp index bc4631e47..3ed73d9d2 100644 --- a/SDK/include/NDK/LuaAPI.hpp +++ b/SDK/include/NDK/LuaAPI.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index 6b7573597..4cc0e4342 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Sdk.hpp b/SDK/include/NDK/Sdk.hpp index 7883162ea..5b976d1eb 100644 --- a/SDK/include/NDK/Sdk.hpp +++ b/SDK/include/NDK/Sdk.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Sdk.inl b/SDK/include/NDK/Sdk.inl index 3cbafab66..de2bb8043 100644 --- a/SDK/include/NDK/Sdk.inl +++ b/SDK/include/NDK/Sdk.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/State.hpp b/SDK/include/NDK/State.hpp index 621227fbe..cc8155ccf 100644 --- a/SDK/include/NDK/State.hpp +++ b/SDK/include/NDK/State.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/StateMachine.hpp b/SDK/include/NDK/StateMachine.hpp index c36464fea..dae81ecd0 100644 --- a/SDK/include/NDK/StateMachine.hpp +++ b/SDK/include/NDK/StateMachine.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/StateMachine.inl b/SDK/include/NDK/StateMachine.inl index c522f5431..d30146a97 100644 --- a/SDK/include/NDK/StateMachine.inl +++ b/SDK/include/NDK/StateMachine.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/System.hpp b/SDK/include/NDK/System.hpp index b5a50f76f..935362763 100644 --- a/SDK/include/NDK/System.hpp +++ b/SDK/include/NDK/System.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/System.inl b/SDK/include/NDK/System.inl index d0359cc63..b3927d145 100644 --- a/SDK/include/NDK/System.inl +++ b/SDK/include/NDK/System.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/ListenerSystem.hpp b/SDK/include/NDK/Systems/ListenerSystem.hpp index bb166a4c1..290700284 100644 --- a/SDK/include/NDK/Systems/ListenerSystem.hpp +++ b/SDK/include/NDK/Systems/ListenerSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/ListenerSystem.inl b/SDK/include/NDK/Systems/ListenerSystem.inl index e5f296d27..e555b080e 100644 --- a/SDK/include/NDK/Systems/ListenerSystem.inl +++ b/SDK/include/NDK/Systems/ListenerSystem.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/ParticleSystem.hpp b/SDK/include/NDK/Systems/ParticleSystem.hpp index 61149b206..950ec80c9 100644 --- a/SDK/include/NDK/Systems/ParticleSystem.hpp +++ b/SDK/include/NDK/Systems/ParticleSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/ParticleSystem.inl b/SDK/include/NDK/Systems/ParticleSystem.inl index e5f296d27..e555b080e 100644 --- a/SDK/include/NDK/Systems/ParticleSystem.inl +++ b/SDK/include/NDK/Systems/ParticleSystem.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/PhysicsSystem2D.hpp b/SDK/include/NDK/Systems/PhysicsSystem2D.hpp index 31426450a..a117abaee 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem2D.hpp +++ b/SDK/include/NDK/Systems/PhysicsSystem2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/PhysicsSystem2D.inl b/SDK/include/NDK/Systems/PhysicsSystem2D.inl index 21a34a6d4..1199d8830 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem2D.inl +++ b/SDK/include/NDK/Systems/PhysicsSystem2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/PhysicsSystem3D.hpp b/SDK/include/NDK/Systems/PhysicsSystem3D.hpp index 35194b7c8..9d653695a 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem3D.hpp +++ b/SDK/include/NDK/Systems/PhysicsSystem3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/PhysicsSystem3D.inl b/SDK/include/NDK/Systems/PhysicsSystem3D.inl index b6b1cbb03..3ea4b6be2 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem3D.inl +++ b/SDK/include/NDK/Systems/PhysicsSystem3D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index 61ccefe75..61f7bd0a0 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/RenderSystem.inl b/SDK/include/NDK/Systems/RenderSystem.inl index 4b758aa92..8a443f993 100644 --- a/SDK/include/NDK/Systems/RenderSystem.inl +++ b/SDK/include/NDK/Systems/RenderSystem.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/VelocitySystem.hpp b/SDK/include/NDK/Systems/VelocitySystem.hpp index 71edcbe7e..d46eb7678 100644 --- a/SDK/include/NDK/Systems/VelocitySystem.hpp +++ b/SDK/include/NDK/Systems/VelocitySystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/VelocitySystem.inl b/SDK/include/NDK/Systems/VelocitySystem.inl index e5f296d27..e555b080e 100644 --- a/SDK/include/NDK/Systems/VelocitySystem.inl +++ b/SDK/include/NDK/Systems/VelocitySystem.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Widgets/ButtonWidget.hpp b/SDK/include/NDK/Widgets/ButtonWidget.hpp index e2173d17e..d1f940e3f 100644 --- a/SDK/include/NDK/Widgets/ButtonWidget.hpp +++ b/SDK/include/NDK/Widgets/ButtonWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Widgets/ButtonWidget.inl b/SDK/include/NDK/Widgets/ButtonWidget.inl index 92d40719a..fedc7614a 100644 --- a/SDK/include/NDK/Widgets/ButtonWidget.inl +++ b/SDK/include/NDK/Widgets/ButtonWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Widgets/LabelWidget.hpp b/SDK/include/NDK/Widgets/LabelWidget.hpp index 736cfd650..06f53273c 100644 --- a/SDK/include/NDK/Widgets/LabelWidget.hpp +++ b/SDK/include/NDK/Widgets/LabelWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Widgets/LabelWidget.inl b/SDK/include/NDK/Widgets/LabelWidget.inl index 4d4e100ce..a2d5d891f 100644 --- a/SDK/include/NDK/Widgets/LabelWidget.inl +++ b/SDK/include/NDK/Widgets/LabelWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.hpp b/SDK/include/NDK/Widgets/TextAreaWidget.hpp index 6581a9965..0bf5a3a59 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.hpp +++ b/SDK/include/NDK/Widgets/TextAreaWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.inl b/SDK/include/NDK/Widgets/TextAreaWidget.inl index 4ddc6d114..077f538ec 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.inl +++ b/SDK/include/NDK/Widgets/TextAreaWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index 5e819e517..9b2546eda 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index 212038625..dcdb0c057 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 4098b8a2b..e159c0101 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/BaseComponent.cpp b/SDK/src/NDK/BaseComponent.cpp index 39d67d211..4af8caed2 100644 --- a/SDK/src/NDK/BaseComponent.cpp +++ b/SDK/src/NDK/BaseComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/BaseSystem.cpp b/SDK/src/NDK/BaseSystem.cpp index b6ebe9892..c7e6c8741 100644 --- a/SDK/src/NDK/BaseSystem.cpp +++ b/SDK/src/NDK/BaseSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 2c04987bd..4d7f12fa8 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index 8e96404f0..4f72e73b1 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/CameraComponent.cpp b/SDK/src/NDK/Components/CameraComponent.cpp index ae1c129c3..13b6bdd2b 100644 --- a/SDK/src/NDK/Components/CameraComponent.cpp +++ b/SDK/src/NDK/Components/CameraComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/CollisionComponent2D.cpp b/SDK/src/NDK/Components/CollisionComponent2D.cpp index 912742b0e..ff10019f6 100644 --- a/SDK/src/NDK/Components/CollisionComponent2D.cpp +++ b/SDK/src/NDK/Components/CollisionComponent2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/CollisionComponent3D.cpp b/SDK/src/NDK/Components/CollisionComponent3D.cpp index d54c460be..4ec2bff81 100644 --- a/SDK/src/NDK/Components/CollisionComponent3D.cpp +++ b/SDK/src/NDK/Components/CollisionComponent3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NDK/Components/GraphicsComponent.cpp index 8a8516e16..8ec5319cd 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NDK/Components/GraphicsComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/LightComponent.cpp b/SDK/src/NDK/Components/LightComponent.cpp index d49d5f8f9..f463eb52d 100644 --- a/SDK/src/NDK/Components/LightComponent.cpp +++ b/SDK/src/NDK/Components/LightComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/ListenerComponent.cpp b/SDK/src/NDK/Components/ListenerComponent.cpp index 7d88c5be5..3d261fcb3 100644 --- a/SDK/src/NDK/Components/ListenerComponent.cpp +++ b/SDK/src/NDK/Components/ListenerComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/NodeComponent.cpp b/SDK/src/NDK/Components/NodeComponent.cpp index 40584236a..d54da5ecb 100644 --- a/SDK/src/NDK/Components/NodeComponent.cpp +++ b/SDK/src/NDK/Components/NodeComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp index e700b6497..89cbaf983 100644 --- a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp +++ b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/ParticleGroupComponent.cpp b/SDK/src/NDK/Components/ParticleGroupComponent.cpp index 4e0845871..c9c64f1e4 100644 --- a/SDK/src/NDK/Components/ParticleGroupComponent.cpp +++ b/SDK/src/NDK/Components/ParticleGroupComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/PhysicsComponent2D.cpp b/SDK/src/NDK/Components/PhysicsComponent2D.cpp index db66178b9..b64ee37b5 100644 --- a/SDK/src/NDK/Components/PhysicsComponent2D.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/PhysicsComponent3D.cpp b/SDK/src/NDK/Components/PhysicsComponent3D.cpp index 7dfffab85..2581723a7 100644 --- a/SDK/src/NDK/Components/PhysicsComponent3D.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Components/VelocityComponent.cpp b/SDK/src/NDK/Components/VelocityComponent.cpp index 15c5ca31f..be1fcec02 100644 --- a/SDK/src/NDK/Components/VelocityComponent.cpp +++ b/SDK/src/NDK/Components/VelocityComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 1e49ec25f..9719e4b62 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 4f60bb427..ce72aca62 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp b/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp index 7f881e20d..00088ecb9 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot +// Copyright (C) 2017 Jérôme Leclercq, Arnaud Cadot // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp index ad9bb49e9..415188014 100644 --- a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot +// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 81080af06..312e9a777 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/State.cpp b/SDK/src/NDK/State.cpp index 701b98565..afe0fd708 100644 --- a/SDK/src/NDK/State.cpp +++ b/SDK/src/NDK/State.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Systems/ListenerSystem.cpp b/SDK/src/NDK/Systems/ListenerSystem.cpp index 3de647a08..6c41de58f 100644 --- a/SDK/src/NDK/Systems/ListenerSystem.cpp +++ b/SDK/src/NDK/Systems/ListenerSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Systems/ParticleSystem.cpp b/SDK/src/NDK/Systems/ParticleSystem.cpp index 9321c0ec2..9a60e0595 100644 --- a/SDK/src/NDK/Systems/ParticleSystem.cpp +++ b/SDK/src/NDK/Systems/ParticleSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Systems/PhysicsSystem2D.cpp b/SDK/src/NDK/Systems/PhysicsSystem2D.cpp index adedfc170..2616b185f 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem2D.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Systems/PhysicsSystem3D.cpp b/SDK/src/NDK/Systems/PhysicsSystem3D.cpp index c26c932e0..3b4706cc2 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem3D.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index bdbb6cb5b..f586056a2 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Systems/VelocitySystem.cpp b/SDK/src/NDK/Systems/VelocitySystem.cpp index bc8042cd7..844374c8a 100644 --- a/SDK/src/NDK/Systems/VelocitySystem.cpp +++ b/SDK/src/NDK/Systems/VelocitySystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Widgets/ButtonWidget.cpp b/SDK/src/NDK/Widgets/ButtonWidget.cpp index 88ae0bf35..8d3a69e33 100644 --- a/SDK/src/NDK/Widgets/ButtonWidget.cpp +++ b/SDK/src/NDK/Widgets/ButtonWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Widgets/LabelWidget.cpp b/SDK/src/NDK/Widgets/LabelWidget.cpp index df9c0e1c7..7e4cdf840 100644 --- a/SDK/src/NDK/Widgets/LabelWidget.cpp +++ b/SDK/src/NDK/Widgets/LabelWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 99e450949..a5a557f9f 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 78b250aaf..545fab499 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/include/Nazara/Audio/Algorithm.hpp b/include/Nazara/Audio/Algorithm.hpp index ea5bd09b6..5173cbdb2 100644 --- a/include/Nazara/Audio/Algorithm.hpp +++ b/include/Nazara/Audio/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Algorithm.inl b/include/Nazara/Audio/Algorithm.inl index ce3c87369..64f0b9f46 100644 --- a/include/Nazara/Audio/Algorithm.inl +++ b/include/Nazara/Audio/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Audio.hpp b/include/Nazara/Audio/Audio.hpp index c80d478d0..1a7c7a1a4 100644 --- a/include/Nazara/Audio/Audio.hpp +++ b/include/Nazara/Audio/Audio.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/ConfigCheck.hpp b/include/Nazara/Audio/ConfigCheck.hpp index 70d0c6fe5..e69257bd5 100644 --- a/include/Nazara/Audio/ConfigCheck.hpp +++ b/include/Nazara/Audio/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Debug.hpp b/include/Nazara/Audio/Debug.hpp index 4e6124741..4ff3e269a 100644 --- a/include/Nazara/Audio/Debug.hpp +++ b/include/Nazara/Audio/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/DebugOff.hpp b/include/Nazara/Audio/DebugOff.hpp index e5149d5b5..557486b46 100644 --- a/include/Nazara/Audio/DebugOff.hpp +++ b/include/Nazara/Audio/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Enums.hpp b/include/Nazara/Audio/Enums.hpp index 20866e5e9..80c4dd91f 100644 --- a/include/Nazara/Audio/Enums.hpp +++ b/include/Nazara/Audio/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Music.hpp b/include/Nazara/Audio/Music.hpp index 29e71fab7..74d315d19 100644 --- a/include/Nazara/Audio/Music.hpp +++ b/include/Nazara/Audio/Music.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/OpenAL.hpp b/include/Nazara/Audio/OpenAL.hpp index aa80f406e..79345c907 100644 --- a/include/Nazara/Audio/OpenAL.hpp +++ b/include/Nazara/Audio/OpenAL.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Sound.hpp b/include/Nazara/Audio/Sound.hpp index 23d6f11bd..c5083387f 100644 --- a/include/Nazara/Audio/Sound.hpp +++ b/include/Nazara/Audio/Sound.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/SoundBuffer.hpp b/include/Nazara/Audio/SoundBuffer.hpp index 6b8e5c385..db38f780f 100644 --- a/include/Nazara/Audio/SoundBuffer.hpp +++ b/include/Nazara/Audio/SoundBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/SoundBuffer.inl b/include/Nazara/Audio/SoundBuffer.inl index a4c42be69..bb4168d2c 100644 --- a/include/Nazara/Audio/SoundBuffer.inl +++ b/include/Nazara/Audio/SoundBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/SoundEmitter.hpp b/include/Nazara/Audio/SoundEmitter.hpp index 9a68d88cc..4bcdca176 100644 --- a/include/Nazara/Audio/SoundEmitter.hpp +++ b/include/Nazara/Audio/SoundEmitter.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/SoundStream.hpp b/include/Nazara/Audio/SoundStream.hpp index 8fd93f412..1d821272b 100644 --- a/include/Nazara/Audio/SoundStream.hpp +++ b/include/Nazara/Audio/SoundStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/AbstractHash.hpp b/include/Nazara/Core/AbstractHash.hpp index f3c848ed3..92da667bd 100644 --- a/include/Nazara/Core/AbstractHash.hpp +++ b/include/Nazara/Core/AbstractHash.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/AbstractLogger.hpp b/include/Nazara/Core/AbstractLogger.hpp index fbe61c080..fb2ba6c0f 100644 --- a/include/Nazara/Core/AbstractLogger.hpp +++ b/include/Nazara/Core/AbstractLogger.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Algorithm.hpp b/include/Nazara/Core/Algorithm.hpp index a6d5e77a7..ceba7f14e 100644 --- a/include/Nazara/Core/Algorithm.hpp +++ b/include/Nazara/Core/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index fea1fd964..a1d846085 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index 622238854..2ea0502a4 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index afec6983a..44a5e2c16 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteArray.hpp b/include/Nazara/Core/ByteArray.hpp index 4bdc34150..d6a4a6f27 100644 --- a/include/Nazara/Core/ByteArray.hpp +++ b/include/Nazara/Core/ByteArray.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteArray.inl b/include/Nazara/Core/ByteArray.inl index b5d8b1510..81406d84f 100644 --- a/include/Nazara/Core/ByteArray.inl +++ b/include/Nazara/Core/ByteArray.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteStream.hpp b/include/Nazara/Core/ByteStream.hpp index fab7c8f4a..a49b08eff 100644 --- a/include/Nazara/Core/ByteStream.hpp +++ b/include/Nazara/Core/ByteStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteStream.inl b/include/Nazara/Core/ByteStream.inl index dadc056ca..1dbf9535e 100644 --- a/include/Nazara/Core/ByteStream.inl +++ b/include/Nazara/Core/ByteStream.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/CallOnExit.hpp b/include/Nazara/Core/CallOnExit.hpp index 3c11ea205..dd0d60728 100644 --- a/include/Nazara/Core/CallOnExit.hpp +++ b/include/Nazara/Core/CallOnExit.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/CallOnExit.inl b/include/Nazara/Core/CallOnExit.inl index 0318752cc..d4c5e393c 100644 --- a/include/Nazara/Core/CallOnExit.inl +++ b/include/Nazara/Core/CallOnExit.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Clock.hpp b/include/Nazara/Core/Clock.hpp index e624c59d8..870d88c9f 100644 --- a/include/Nazara/Core/Clock.hpp +++ b/include/Nazara/Core/Clock.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Color.hpp b/include/Nazara/Core/Color.hpp index 5fef4f854..4ed06796f 100644 --- a/include/Nazara/Core/Color.hpp +++ b/include/Nazara/Core/Color.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Color.inl b/include/Nazara/Core/Color.inl index 5d71393df..6d9fe4d35 100644 --- a/include/Nazara/Core/Color.inl +++ b/include/Nazara/Core/Color.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ConditionVariable.hpp b/include/Nazara/Core/ConditionVariable.hpp index 19ab9e863..d73cb0f8f 100644 --- a/include/Nazara/Core/ConditionVariable.hpp +++ b/include/Nazara/Core/ConditionVariable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ConditionVariable.inl b/include/Nazara/Core/ConditionVariable.inl index 636c98493..f9603e1c1 100644 --- a/include/Nazara/Core/ConditionVariable.inl +++ b/include/Nazara/Core/ConditionVariable.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ConfigCheck.hpp b/include/Nazara/Core/ConfigCheck.hpp index aa1ac5cfa..0e3b1e66e 100644 --- a/include/Nazara/Core/ConfigCheck.hpp +++ b/include/Nazara/Core/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Core.hpp b/include/Nazara/Core/Core.hpp index 00840dc1a..672e4ecc9 100644 --- a/include/Nazara/Core/Core.hpp +++ b/include/Nazara/Core/Core.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Debug.hpp b/include/Nazara/Core/Debug.hpp index 6301f574a..3a3d0444c 100644 --- a/include/Nazara/Core/Debug.hpp +++ b/include/Nazara/Core/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Debug/NewRedefinition.hpp b/include/Nazara/Core/Debug/NewRedefinition.hpp index 5b9b2088f..b50d4feb3 100644 --- a/include/Nazara/Core/Debug/NewRedefinition.hpp +++ b/include/Nazara/Core/Debug/NewRedefinition.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/DebugOff.hpp b/include/Nazara/Core/DebugOff.hpp index 62788ee15..931fa629d 100644 --- a/include/Nazara/Core/DebugOff.hpp +++ b/include/Nazara/Core/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Directory.hpp b/include/Nazara/Core/Directory.hpp index 9dd24ee7d..21a1da8da 100644 --- a/include/Nazara/Core/Directory.hpp +++ b/include/Nazara/Core/Directory.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/DynLib.hpp b/include/Nazara/Core/DynLib.hpp index 4f2759e22..2f4ccb530 100644 --- a/include/Nazara/Core/DynLib.hpp +++ b/include/Nazara/Core/DynLib.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Endianness.hpp b/include/Nazara/Core/Endianness.hpp index 8bd1d61b4..5ebd558e2 100644 --- a/include/Nazara/Core/Endianness.hpp +++ b/include/Nazara/Core/Endianness.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Endianness.inl b/include/Nazara/Core/Endianness.inl index 67df87c45..3ef527105 100644 --- a/include/Nazara/Core/Endianness.inl +++ b/include/Nazara/Core/Endianness.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Enums.hpp b/include/Nazara/Core/Enums.hpp index 1020cd2b6..5a6e67565 100644 --- a/include/Nazara/Core/Enums.hpp +++ b/include/Nazara/Core/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Error.hpp b/include/Nazara/Core/Error.hpp index fbc4de38b..cd9e49fe6 100644 --- a/include/Nazara/Core/Error.hpp +++ b/include/Nazara/Core/Error.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ErrorFlags.hpp b/include/Nazara/Core/ErrorFlags.hpp index 43f2ae589..76d89a858 100644 --- a/include/Nazara/Core/ErrorFlags.hpp +++ b/include/Nazara/Core/ErrorFlags.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/File.hpp b/include/Nazara/Core/File.hpp index d4d1e6522..86a224314 100644 --- a/include/Nazara/Core/File.hpp +++ b/include/Nazara/Core/File.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/File.inl b/include/Nazara/Core/File.inl index ff0d148fd..15ac3fabd 100644 --- a/include/Nazara/Core/File.inl +++ b/include/Nazara/Core/File.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/FileLogger.hpp b/include/Nazara/Core/FileLogger.hpp index d7b1d8f14..7ca79f66c 100644 --- a/include/Nazara/Core/FileLogger.hpp +++ b/include/Nazara/Core/FileLogger.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index d4f536356..1dbd102a0 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 26e82c56c..67fee6a26 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Functor.hpp b/include/Nazara/Core/Functor.hpp index 7ce9995a7..b392cc591 100644 --- a/include/Nazara/Core/Functor.hpp +++ b/include/Nazara/Core/Functor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Functor.inl b/include/Nazara/Core/Functor.inl index d5cefe434..ea7bdbad2 100644 --- a/include/Nazara/Core/Functor.inl +++ b/include/Nazara/Core/Functor.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/GuillotineBinPack.hpp b/include/Nazara/Core/GuillotineBinPack.hpp index 878df27ea..61671ff50 100644 --- a/include/Nazara/Core/GuillotineBinPack.hpp +++ b/include/Nazara/Core/GuillotineBinPack.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/HandledObject.hpp b/include/Nazara/Core/HandledObject.hpp index eeb9c4bfa..a103f6750 100644 --- a/include/Nazara/Core/HandledObject.hpp +++ b/include/Nazara/Core/HandledObject.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/include/Nazara/Core/HandledObject.inl b/include/Nazara/Core/HandledObject.inl index 43feebcd3..53f77bbed 100644 --- a/include/Nazara/Core/HandledObject.inl +++ b/include/Nazara/Core/HandledObject.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/include/Nazara/Core/HardwareInfo.hpp b/include/Nazara/Core/HardwareInfo.hpp index 2a79165cf..73b49e894 100644 --- a/include/Nazara/Core/HardwareInfo.hpp +++ b/include/Nazara/Core/HardwareInfo.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/CRC32.hpp b/include/Nazara/Core/Hash/CRC32.hpp index 79da031b3..444b81ae5 100644 --- a/include/Nazara/Core/Hash/CRC32.hpp +++ b/include/Nazara/Core/Hash/CRC32.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/Fletcher16.hpp b/include/Nazara/Core/Hash/Fletcher16.hpp index 6bc95db68..a360c3adf 100644 --- a/include/Nazara/Core/Hash/Fletcher16.hpp +++ b/include/Nazara/Core/Hash/Fletcher16.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/MD5.hpp b/include/Nazara/Core/Hash/MD5.hpp index 1c8bd0d25..28026816b 100644 --- a/include/Nazara/Core/Hash/MD5.hpp +++ b/include/Nazara/Core/Hash/MD5.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA1.hpp b/include/Nazara/Core/Hash/SHA1.hpp index 8e410adb7..55291e1f7 100644 --- a/include/Nazara/Core/Hash/SHA1.hpp +++ b/include/Nazara/Core/Hash/SHA1.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA224.hpp b/include/Nazara/Core/Hash/SHA224.hpp index 48893c8d0..3013a8170 100644 --- a/include/Nazara/Core/Hash/SHA224.hpp +++ b/include/Nazara/Core/Hash/SHA224.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA256.hpp b/include/Nazara/Core/Hash/SHA256.hpp index 1adf5ad52..e20e1d994 100644 --- a/include/Nazara/Core/Hash/SHA256.hpp +++ b/include/Nazara/Core/Hash/SHA256.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA384.hpp b/include/Nazara/Core/Hash/SHA384.hpp index 54643cbbd..814d80f57 100644 --- a/include/Nazara/Core/Hash/SHA384.hpp +++ b/include/Nazara/Core/Hash/SHA384.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA512.hpp b/include/Nazara/Core/Hash/SHA512.hpp index a17726b74..df09cd163 100644 --- a/include/Nazara/Core/Hash/SHA512.hpp +++ b/include/Nazara/Core/Hash/SHA512.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/Whirlpool.hpp b/include/Nazara/Core/Hash/Whirlpool.hpp index f7922254d..caff8f349 100644 --- a/include/Nazara/Core/Hash/Whirlpool.hpp +++ b/include/Nazara/Core/Hash/Whirlpool.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Initializer.hpp b/include/Nazara/Core/Initializer.hpp index d884dfcc8..7fb19e69e 100644 --- a/include/Nazara/Core/Initializer.hpp +++ b/include/Nazara/Core/Initializer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Initializer.inl b/include/Nazara/Core/Initializer.inl index 23cc7b2de..0d886d0a0 100644 --- a/include/Nazara/Core/Initializer.inl +++ b/include/Nazara/Core/Initializer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/LockGuard.hpp b/include/Nazara/Core/LockGuard.hpp index d9ef5aa85..d8d03725c 100644 --- a/include/Nazara/Core/LockGuard.hpp +++ b/include/Nazara/Core/LockGuard.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/LockGuard.inl b/include/Nazara/Core/LockGuard.inl index 73beab112..4fa95884f 100644 --- a/include/Nazara/Core/LockGuard.inl +++ b/include/Nazara/Core/LockGuard.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Log.hpp b/include/Nazara/Core/Log.hpp index fc64c8a49..f3826f568 100644 --- a/include/Nazara/Core/Log.hpp +++ b/include/Nazara/Core/Log.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryHelper.hpp b/include/Nazara/Core/MemoryHelper.hpp index e2ed7fc3e..6f53a012f 100644 --- a/include/Nazara/Core/MemoryHelper.hpp +++ b/include/Nazara/Core/MemoryHelper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryHelper.inl b/include/Nazara/Core/MemoryHelper.inl index d3fe43155..f7380e1b8 100644 --- a/include/Nazara/Core/MemoryHelper.inl +++ b/include/Nazara/Core/MemoryHelper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryManager.hpp b/include/Nazara/Core/MemoryManager.hpp index 39d5be712..caed09b61 100644 --- a/include/Nazara/Core/MemoryManager.hpp +++ b/include/Nazara/Core/MemoryManager.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryPool.hpp b/include/Nazara/Core/MemoryPool.hpp index 7aaa462bb..bda0915fa 100644 --- a/include/Nazara/Core/MemoryPool.hpp +++ b/include/Nazara/Core/MemoryPool.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryPool.inl b/include/Nazara/Core/MemoryPool.inl index 732c50fa9..db0cbc648 100644 --- a/include/Nazara/Core/MemoryPool.inl +++ b/include/Nazara/Core/MemoryPool.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryStream.hpp b/include/Nazara/Core/MemoryStream.hpp index 929e8e5bd..4c34eabc6 100644 --- a/include/Nazara/Core/MemoryStream.hpp +++ b/include/Nazara/Core/MemoryStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryStream.inl b/include/Nazara/Core/MemoryStream.inl index 6cdf06b26..e1369d819 100644 --- a/include/Nazara/Core/MemoryStream.inl +++ b/include/Nazara/Core/MemoryStream.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryView.hpp b/include/Nazara/Core/MemoryView.hpp index 41f4b1ee2..5b3cf63b7 100644 --- a/include/Nazara/Core/MemoryView.hpp +++ b/include/Nazara/Core/MemoryView.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Mutex.hpp b/include/Nazara/Core/Mutex.hpp index 14de9d282..303b163f1 100644 --- a/include/Nazara/Core/Mutex.hpp +++ b/include/Nazara/Core/Mutex.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Mutex.inl b/include/Nazara/Core/Mutex.inl index fe4a77577..9e79fff02 100644 --- a/include/Nazara/Core/Mutex.inl +++ b/include/Nazara/Core/Mutex.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectHandle.hpp b/include/Nazara/Core/ObjectHandle.hpp index b3cc080dd..66c6161e4 100644 --- a/include/Nazara/Core/ObjectHandle.hpp +++ b/include/Nazara/Core/ObjectHandle.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index d5badc964..920d407a6 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectLibrary.hpp b/include/Nazara/Core/ObjectLibrary.hpp index ee0a40e29..a13fbc3e6 100644 --- a/include/Nazara/Core/ObjectLibrary.hpp +++ b/include/Nazara/Core/ObjectLibrary.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectLibrary.inl b/include/Nazara/Core/ObjectLibrary.inl index e656a820e..b5384a2a7 100644 --- a/include/Nazara/Core/ObjectLibrary.inl +++ b/include/Nazara/Core/ObjectLibrary.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectRef.hpp b/include/Nazara/Core/ObjectRef.hpp index 6a69a22ee..1414e5d78 100644 --- a/include/Nazara/Core/ObjectRef.hpp +++ b/include/Nazara/Core/ObjectRef.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectRef.inl b/include/Nazara/Core/ObjectRef.inl index 85baff8bf..c3e783186 100644 --- a/include/Nazara/Core/ObjectRef.inl +++ b/include/Nazara/Core/ObjectRef.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/OffsetOf.hpp b/include/Nazara/Core/OffsetOf.hpp index d6596dcf2..5c26aa870 100644 --- a/include/Nazara/Core/OffsetOf.hpp +++ b/include/Nazara/Core/OffsetOf.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ParameterList.hpp b/include/Nazara/Core/ParameterList.hpp index b34f0eca0..75972b49c 100644 --- a/include/Nazara/Core/ParameterList.hpp +++ b/include/Nazara/Core/ParameterList.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/PluginManager.hpp b/include/Nazara/Core/PluginManager.hpp index 833f0c5d2..5857a2255 100644 --- a/include/Nazara/Core/PluginManager.hpp +++ b/include/Nazara/Core/PluginManager.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Primitive.hpp b/include/Nazara/Core/Primitive.hpp index 16c27100d..7afcace47 100644 --- a/include/Nazara/Core/Primitive.hpp +++ b/include/Nazara/Core/Primitive.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Primitive.inl b/include/Nazara/Core/Primitive.inl index 8124a7ed9..fff7f82bb 100644 --- a/include/Nazara/Core/Primitive.inl +++ b/include/Nazara/Core/Primitive.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/PrimitiveList.hpp b/include/Nazara/Core/PrimitiveList.hpp index 79d2363c2..a8cbed1d0 100644 --- a/include/Nazara/Core/PrimitiveList.hpp +++ b/include/Nazara/Core/PrimitiveList.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/RefCounted.hpp b/include/Nazara/Core/RefCounted.hpp index 542784787..7a2f8c7fc 100644 --- a/include/Nazara/Core/RefCounted.hpp +++ b/include/Nazara/Core/RefCounted.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Resource.hpp b/include/Nazara/Core/Resource.hpp index 7d1a12530..2322b25c1 100644 --- a/include/Nazara/Core/Resource.hpp +++ b/include/Nazara/Core/Resource.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceLoader.hpp b/include/Nazara/Core/ResourceLoader.hpp index 8af3e3cd3..3fce094e0 100644 --- a/include/Nazara/Core/ResourceLoader.hpp +++ b/include/Nazara/Core/ResourceLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceLoader.inl b/include/Nazara/Core/ResourceLoader.inl index 2ac72c6df..c60be5674 100644 --- a/include/Nazara/Core/ResourceLoader.inl +++ b/include/Nazara/Core/ResourceLoader.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceManager.hpp b/include/Nazara/Core/ResourceManager.hpp index ca5735811..c99e84f78 100644 --- a/include/Nazara/Core/ResourceManager.hpp +++ b/include/Nazara/Core/ResourceManager.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceManager.inl b/include/Nazara/Core/ResourceManager.inl index 6fec2aae0..d590cc680 100644 --- a/include/Nazara/Core/ResourceManager.inl +++ b/include/Nazara/Core/ResourceManager.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceParameters.hpp b/include/Nazara/Core/ResourceParameters.hpp index e4f32e06a..8ddbecec1 100644 --- a/include/Nazara/Core/ResourceParameters.hpp +++ b/include/Nazara/Core/ResourceParameters.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceSaver.hpp b/include/Nazara/Core/ResourceSaver.hpp index 05b6d7175..08e7ae745 100644 --- a/include/Nazara/Core/ResourceSaver.hpp +++ b/include/Nazara/Core/ResourceSaver.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceSaver.inl b/include/Nazara/Core/ResourceSaver.inl index a22c29d60..007f4cc75 100644 --- a/include/Nazara/Core/ResourceSaver.inl +++ b/include/Nazara/Core/ResourceSaver.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Semaphore.hpp b/include/Nazara/Core/Semaphore.hpp index c64ebc4e0..8c18cf6f4 100644 --- a/include/Nazara/Core/Semaphore.hpp +++ b/include/Nazara/Core/Semaphore.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/SerializationContext.hpp b/include/Nazara/Core/SerializationContext.hpp index 64c558a7b..cf5d83223 100644 --- a/include/Nazara/Core/SerializationContext.hpp +++ b/include/Nazara/Core/SerializationContext.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/SerializationContext.inl b/include/Nazara/Core/SerializationContext.inl index 47f56e5c2..5edd4e618 100644 --- a/include/Nazara/Core/SerializationContext.inl +++ b/include/Nazara/Core/SerializationContext.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index 897c32ef9..c325b40ce 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index 07a950d89..9e711a65f 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/SparsePtr.hpp b/include/Nazara/Core/SparsePtr.hpp index 6e36fcc57..f4d777fa8 100644 --- a/include/Nazara/Core/SparsePtr.hpp +++ b/include/Nazara/Core/SparsePtr.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/SparsePtr.inl b/include/Nazara/Core/SparsePtr.inl index 0da69b0ad..db8fb6b33 100644 --- a/include/Nazara/Core/SparsePtr.inl +++ b/include/Nazara/Core/SparsePtr.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StdLogger.hpp b/include/Nazara/Core/StdLogger.hpp index 16fd0bb47..ecc6e1ac7 100644 --- a/include/Nazara/Core/StdLogger.hpp +++ b/include/Nazara/Core/StdLogger.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Stream.hpp b/include/Nazara/Core/Stream.hpp index e4949d441..f00c373e8 100644 --- a/include/Nazara/Core/Stream.hpp +++ b/include/Nazara/Core/Stream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Stream.inl b/include/Nazara/Core/Stream.inl index f4f1557d7..abd97c051 100644 --- a/include/Nazara/Core/Stream.inl +++ b/include/Nazara/Core/Stream.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/String.hpp b/include/Nazara/Core/String.hpp index c3056e835..30f88de00 100644 --- a/include/Nazara/Core/String.hpp +++ b/include/Nazara/Core/String.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/String.inl b/include/Nazara/Core/String.inl index f4cf48714..027ab4349 100644 --- a/include/Nazara/Core/String.inl +++ b/include/Nazara/Core/String.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StringStream.hpp b/include/Nazara/Core/StringStream.hpp index f727ed35c..6898e5b6a 100644 --- a/include/Nazara/Core/StringStream.hpp +++ b/include/Nazara/Core/StringStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/TaskScheduler.hpp b/include/Nazara/Core/TaskScheduler.hpp index 3a061168d..405e88ed3 100644 --- a/include/Nazara/Core/TaskScheduler.hpp +++ b/include/Nazara/Core/TaskScheduler.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/TaskScheduler.inl b/include/Nazara/Core/TaskScheduler.inl index 96e240081..62b77447b 100644 --- a/include/Nazara/Core/TaskScheduler.inl +++ b/include/Nazara/Core/TaskScheduler.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Thread.hpp b/include/Nazara/Core/Thread.hpp index 4e4dd4efb..a4b4d92f6 100644 --- a/include/Nazara/Core/Thread.hpp +++ b/include/Nazara/Core/Thread.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Thread.inl b/include/Nazara/Core/Thread.inl index f372c803f..f2065adfa 100644 --- a/include/Nazara/Core/Thread.inl +++ b/include/Nazara/Core/Thread.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ThreadSafety.hpp b/include/Nazara/Core/ThreadSafety.hpp index 5b1629b5b..271d6c474 100644 --- a/include/Nazara/Core/ThreadSafety.hpp +++ b/include/Nazara/Core/ThreadSafety.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ThreadSafetyOff.hpp b/include/Nazara/Core/ThreadSafetyOff.hpp index 29c327e0d..196ef7d07 100644 --- a/include/Nazara/Core/ThreadSafetyOff.hpp +++ b/include/Nazara/Core/ThreadSafetyOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Unicode.hpp b/include/Nazara/Core/Unicode.hpp index a42e88e90..4dfb670a3 100644 --- a/include/Nazara/Core/Unicode.hpp +++ b/include/Nazara/Core/Unicode.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Updatable.hpp b/include/Nazara/Core/Updatable.hpp index fd93dafe8..e1a7cf5a9 100644 --- a/include/Nazara/Core/Updatable.hpp +++ b/include/Nazara/Core/Updatable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core Module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/AbstractBackground.hpp b/include/Nazara/Graphics/AbstractBackground.hpp index 8e21326e5..7c6ce8348 100644 --- a/include/Nazara/Graphics/AbstractBackground.hpp +++ b/include/Nazara/Graphics/AbstractBackground.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/AbstractRenderQueue.hpp b/include/Nazara/Graphics/AbstractRenderQueue.hpp index a245787ab..f0074cd50 100644 --- a/include/Nazara/Graphics/AbstractRenderQueue.hpp +++ b/include/Nazara/Graphics/AbstractRenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/AbstractRenderTechnique.hpp b/include/Nazara/Graphics/AbstractRenderTechnique.hpp index d13ac88ee..4279a5f39 100644 --- a/include/Nazara/Graphics/AbstractRenderTechnique.hpp +++ b/include/Nazara/Graphics/AbstractRenderTechnique.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/AbstractViewer.hpp b/include/Nazara/Graphics/AbstractViewer.hpp index a38bb6bd7..9bef56373 100644 --- a/include/Nazara/Graphics/AbstractViewer.hpp +++ b/include/Nazara/Graphics/AbstractViewer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Billboard.hpp b/include/Nazara/Graphics/Billboard.hpp index 68a64a4b5..c82a5d2bf 100644 --- a/include/Nazara/Graphics/Billboard.hpp +++ b/include/Nazara/Graphics/Billboard.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index 45c2ef918..137524e95 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ColorBackground.hpp b/include/Nazara/Graphics/ColorBackground.hpp index 95113f71b..57de236f9 100644 --- a/include/Nazara/Graphics/ColorBackground.hpp +++ b/include/Nazara/Graphics/ColorBackground.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ColorBackground.inl b/include/Nazara/Graphics/ColorBackground.inl index 67b1f2558..30d870365 100644 --- a/include/Nazara/Graphics/ColorBackground.inl +++ b/include/Nazara/Graphics/ColorBackground.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ConfigCheck.hpp b/include/Nazara/Graphics/ConfigCheck.hpp index c2bbda886..3ec60640d 100644 --- a/include/Nazara/Graphics/ConfigCheck.hpp +++ b/include/Nazara/Graphics/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/CullingList.hpp b/include/Nazara/Graphics/CullingList.hpp index f8c50d83d..e484be81a 100644 --- a/include/Nazara/Graphics/CullingList.hpp +++ b/include/Nazara/Graphics/CullingList.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/CullingList.inl b/include/Nazara/Graphics/CullingList.inl index d4f80b3d7..270caefb3 100644 --- a/include/Nazara/Graphics/CullingList.inl +++ b/include/Nazara/Graphics/CullingList.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Debug.hpp b/include/Nazara/Graphics/Debug.hpp index 1d048c131..f20764d29 100644 --- a/include/Nazara/Graphics/Debug.hpp +++ b/include/Nazara/Graphics/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DebugOff.hpp b/include/Nazara/Graphics/DebugOff.hpp index c90640fc0..325dc62f9 100644 --- a/include/Nazara/Graphics/DebugOff.hpp +++ b/include/Nazara/Graphics/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredBloomPass.hpp b/include/Nazara/Graphics/DeferredBloomPass.hpp index 5c45a2277..5246f45c2 100644 --- a/include/Nazara/Graphics/DeferredBloomPass.hpp +++ b/include/Nazara/Graphics/DeferredBloomPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredDOFPass.hpp b/include/Nazara/Graphics/DeferredDOFPass.hpp index c3d6e4c0f..6a0b213da 100644 --- a/include/Nazara/Graphics/DeferredDOFPass.hpp +++ b/include/Nazara/Graphics/DeferredDOFPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredFXAAPass.hpp b/include/Nazara/Graphics/DeferredFXAAPass.hpp index 1c74ffb1c..696450796 100644 --- a/include/Nazara/Graphics/DeferredFXAAPass.hpp +++ b/include/Nazara/Graphics/DeferredFXAAPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredFinalPass.hpp b/include/Nazara/Graphics/DeferredFinalPass.hpp index f6b633925..52c7e8233 100644 --- a/include/Nazara/Graphics/DeferredFinalPass.hpp +++ b/include/Nazara/Graphics/DeferredFinalPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredFogPass.hpp b/include/Nazara/Graphics/DeferredFogPass.hpp index babccb0bf..807f0752d 100644 --- a/include/Nazara/Graphics/DeferredFogPass.hpp +++ b/include/Nazara/Graphics/DeferredFogPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredForwardPass.hpp b/include/Nazara/Graphics/DeferredForwardPass.hpp index cd5341d85..5bf53f107 100644 --- a/include/Nazara/Graphics/DeferredForwardPass.hpp +++ b/include/Nazara/Graphics/DeferredForwardPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredGeometryPass.hpp b/include/Nazara/Graphics/DeferredGeometryPass.hpp index 15437f0d8..dcfa47f90 100644 --- a/include/Nazara/Graphics/DeferredGeometryPass.hpp +++ b/include/Nazara/Graphics/DeferredGeometryPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp index 68eb96264..4b14900d7 100644 --- a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp +++ b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredRenderPass.hpp b/include/Nazara/Graphics/DeferredRenderPass.hpp index 7053bbaa5..784ad3c29 100644 --- a/include/Nazara/Graphics/DeferredRenderPass.hpp +++ b/include/Nazara/Graphics/DeferredRenderPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredRenderQueue.hpp b/include/Nazara/Graphics/DeferredRenderQueue.hpp index 922174df6..982469873 100644 --- a/include/Nazara/Graphics/DeferredRenderQueue.hpp +++ b/include/Nazara/Graphics/DeferredRenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredRenderTechnique.hpp b/include/Nazara/Graphics/DeferredRenderTechnique.hpp index 36ac47c8b..bdac459e9 100644 --- a/include/Nazara/Graphics/DeferredRenderTechnique.hpp +++ b/include/Nazara/Graphics/DeferredRenderTechnique.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DepthRenderQueue.hpp b/include/Nazara/Graphics/DepthRenderQueue.hpp index 81ec921c0..ed7c9f3c3 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.hpp +++ b/include/Nazara/Graphics/DepthRenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DepthRenderQueue.inl b/include/Nazara/Graphics/DepthRenderQueue.inl index 8fbce164b..7646c76a7 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.inl +++ b/include/Nazara/Graphics/DepthRenderQueue.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DepthRenderTechnique.hpp b/include/Nazara/Graphics/DepthRenderTechnique.hpp index 88d447889..d28b8a5c4 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.hpp +++ b/include/Nazara/Graphics/DepthRenderTechnique.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DepthRenderTechnique.inl b/include/Nazara/Graphics/DepthRenderTechnique.inl index ac6b052d0..9b32e7d42 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.inl +++ b/include/Nazara/Graphics/DepthRenderTechnique.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Drawable.hpp b/include/Nazara/Graphics/Drawable.hpp index 5d5eca95b..13a2141b5 100644 --- a/include/Nazara/Graphics/Drawable.hpp +++ b/include/Nazara/Graphics/Drawable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Enums.hpp b/include/Nazara/Graphics/Enums.hpp index fcd241006..68a8ed95e 100644 --- a/include/Nazara/Graphics/Enums.hpp +++ b/include/Nazara/Graphics/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index 56474a642..f0ac6edda 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.hpp b/include/Nazara/Graphics/ForwardRenderTechnique.hpp index 0a35518fc..9b5c152df 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.hpp +++ b/include/Nazara/Graphics/ForwardRenderTechnique.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.inl b/include/Nazara/Graphics/ForwardRenderTechnique.inl index c0d5b5f1b..ae22668ec 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.inl +++ b/include/Nazara/Graphics/ForwardRenderTechnique.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Graphics.hpp b/include/Nazara/Graphics/Graphics.hpp index e2aef76ba..499837466 100644 --- a/include/Nazara/Graphics/Graphics.hpp +++ b/include/Nazara/Graphics/Graphics.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/GuillotineTextureAtlas.hpp b/include/Nazara/Graphics/GuillotineTextureAtlas.hpp index 42449712c..3c5aa2d4b 100644 --- a/include/Nazara/Graphics/GuillotineTextureAtlas.hpp +++ b/include/Nazara/Graphics/GuillotineTextureAtlas.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index 3f117c84b..1f7ec8314 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/InstancedRenderable.inl b/include/Nazara/Graphics/InstancedRenderable.inl index 5ee49dc6a..47e47eac1 100644 --- a/include/Nazara/Graphics/InstancedRenderable.inl +++ b/include/Nazara/Graphics/InstancedRenderable.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Light.hpp b/include/Nazara/Graphics/Light.hpp index 3951be6ad..8574bb783 100644 --- a/include/Nazara/Graphics/Light.hpp +++ b/include/Nazara/Graphics/Light.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index 2852834b7..b30daaf60 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index be6e2c58b..bf14b1792 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index b0ce4ff1c..61f2220d4 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/MaterialPipeline.hpp b/include/Nazara/Graphics/MaterialPipeline.hpp index cf64d5e40..79028ac45 100644 --- a/include/Nazara/Graphics/MaterialPipeline.hpp +++ b/include/Nazara/Graphics/MaterialPipeline.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl index 0cbea4e61..263dbcad3 100644 --- a/include/Nazara/Graphics/MaterialPipeline.inl +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Model.hpp b/include/Nazara/Graphics/Model.hpp index b1755c7d8..e512e5201 100644 --- a/include/Nazara/Graphics/Model.hpp +++ b/include/Nazara/Graphics/Model.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index 8e659e869..7925e9e70 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleController.hpp b/include/Nazara/Graphics/ParticleController.hpp index 05537ba55..5012c82d2 100644 --- a/include/Nazara/Graphics/ParticleController.hpp +++ b/include/Nazara/Graphics/ParticleController.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleDeclaration.hpp b/include/Nazara/Graphics/ParticleDeclaration.hpp index 770cbe31d..db5519d24 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.hpp +++ b/include/Nazara/Graphics/ParticleDeclaration.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleDeclaration.inl b/include/Nazara/Graphics/ParticleDeclaration.inl index dafa2653a..efbb4fd39 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.inl +++ b/include/Nazara/Graphics/ParticleDeclaration.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index cfbb9e98a..c085c9062 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionController.hpp b/include/Nazara/Graphics/ParticleFunctionController.hpp index 6b3c4a974..c61197fc2 100644 --- a/include/Nazara/Graphics/ParticleFunctionController.hpp +++ b/include/Nazara/Graphics/ParticleFunctionController.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionController.inl b/include/Nazara/Graphics/ParticleFunctionController.inl index eb4365fda..92e78e4af 100644 --- a/include/Nazara/Graphics/ParticleFunctionController.inl +++ b/include/Nazara/Graphics/ParticleFunctionController.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionGenerator.hpp b/include/Nazara/Graphics/ParticleFunctionGenerator.hpp index 7aa5bb9f3..63d7fd755 100644 --- a/include/Nazara/Graphics/ParticleFunctionGenerator.hpp +++ b/include/Nazara/Graphics/ParticleFunctionGenerator.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionGenerator.inl b/include/Nazara/Graphics/ParticleFunctionGenerator.inl index 9cb11683c..787e1cdce 100644 --- a/include/Nazara/Graphics/ParticleFunctionGenerator.inl +++ b/include/Nazara/Graphics/ParticleFunctionGenerator.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionRenderer.hpp b/include/Nazara/Graphics/ParticleFunctionRenderer.hpp index 810027ae9..b4d8772df 100644 --- a/include/Nazara/Graphics/ParticleFunctionRenderer.hpp +++ b/include/Nazara/Graphics/ParticleFunctionRenderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionRenderer.inl b/include/Nazara/Graphics/ParticleFunctionRenderer.inl index cf859fbfe..12b53bf88 100644 --- a/include/Nazara/Graphics/ParticleFunctionRenderer.inl +++ b/include/Nazara/Graphics/ParticleFunctionRenderer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleGenerator.hpp b/include/Nazara/Graphics/ParticleGenerator.hpp index d072ae346..d4fcb71fa 100644 --- a/include/Nazara/Graphics/ParticleGenerator.hpp +++ b/include/Nazara/Graphics/ParticleGenerator.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index 460694160..93d3f63d4 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleGroup.inl b/include/Nazara/Graphics/ParticleGroup.inl index f0e205346..330d6546f 100644 --- a/include/Nazara/Graphics/ParticleGroup.inl +++ b/include/Nazara/Graphics/ParticleGroup.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleMapper.hpp b/include/Nazara/Graphics/ParticleMapper.hpp index ffbe2a5ad..ba5a8e0f1 100644 --- a/include/Nazara/Graphics/ParticleMapper.hpp +++ b/include/Nazara/Graphics/ParticleMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleMapper.inl b/include/Nazara/Graphics/ParticleMapper.inl index 1a4566c33..289fdf045 100644 --- a/include/Nazara/Graphics/ParticleMapper.inl +++ b/include/Nazara/Graphics/ParticleMapper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleRenderer.hpp b/include/Nazara/Graphics/ParticleRenderer.hpp index 2ddca18b3..4549d0701 100644 --- a/include/Nazara/Graphics/ParticleRenderer.hpp +++ b/include/Nazara/Graphics/ParticleRenderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleStruct.hpp b/include/Nazara/Graphics/ParticleStruct.hpp index b4f55a3a1..4e14ab9ca 100644 --- a/include/Nazara/Graphics/ParticleStruct.hpp +++ b/include/Nazara/Graphics/ParticleStruct.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/RenderTechniques.hpp b/include/Nazara/Graphics/RenderTechniques.hpp index a4642ffc8..79fb0c629 100644 --- a/include/Nazara/Graphics/RenderTechniques.hpp +++ b/include/Nazara/Graphics/RenderTechniques.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Renderable.hpp b/include/Nazara/Graphics/Renderable.hpp index 412caa301..62cf861c6 100644 --- a/include/Nazara/Graphics/Renderable.hpp +++ b/include/Nazara/Graphics/Renderable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Renderable.inl b/include/Nazara/Graphics/Renderable.inl index 804567814..4c572a1cb 100644 --- a/include/Nazara/Graphics/Renderable.inl +++ b/include/Nazara/Graphics/Renderable.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SceneData.hpp b/include/Nazara/Graphics/SceneData.hpp index 94aafbda4..d6e54cc1b 100644 --- a/include/Nazara/Graphics/SceneData.hpp +++ b/include/Nazara/Graphics/SceneData.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkeletalModel.hpp b/include/Nazara/Graphics/SkeletalModel.hpp index 99791168a..bb427a3e2 100644 --- a/include/Nazara/Graphics/SkeletalModel.hpp +++ b/include/Nazara/Graphics/SkeletalModel.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkinningManager.hpp b/include/Nazara/Graphics/SkinningManager.hpp index a8f76768e..040964428 100644 --- a/include/Nazara/Graphics/SkinningManager.hpp +++ b/include/Nazara/Graphics/SkinningManager.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkyboxBackground.hpp b/include/Nazara/Graphics/SkyboxBackground.hpp index 95ce2872a..4f433ed3e 100644 --- a/include/Nazara/Graphics/SkyboxBackground.hpp +++ b/include/Nazara/Graphics/SkyboxBackground.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkyboxBackground.inl b/include/Nazara/Graphics/SkyboxBackground.inl index 6171f1e28..3379ca9d1 100644 --- a/include/Nazara/Graphics/SkyboxBackground.inl +++ b/include/Nazara/Graphics/SkyboxBackground.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Sprite.hpp b/include/Nazara/Graphics/Sprite.hpp index 2c42f4ce1..3625708da 100644 --- a/include/Nazara/Graphics/Sprite.hpp +++ b/include/Nazara/Graphics/Sprite.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index deec75959..c9f698371 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TextSprite.hpp b/include/Nazara/Graphics/TextSprite.hpp index 3e05c2795..19a3ec1a7 100644 --- a/include/Nazara/Graphics/TextSprite.hpp +++ b/include/Nazara/Graphics/TextSprite.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index d5db90805..c7ba17585 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TextureBackground.hpp b/include/Nazara/Graphics/TextureBackground.hpp index 741c974b7..272bcc63f 100644 --- a/include/Nazara/Graphics/TextureBackground.hpp +++ b/include/Nazara/Graphics/TextureBackground.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TextureBackground.inl b/include/Nazara/Graphics/TextureBackground.inl index 31067f36c..7686fa466 100644 --- a/include/Nazara/Graphics/TextureBackground.inl +++ b/include/Nazara/Graphics/TextureBackground.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TileMap.hpp b/include/Nazara/Graphics/TileMap.hpp index 02371c33c..dbc36aff5 100644 --- a/include/Nazara/Graphics/TileMap.hpp +++ b/include/Nazara/Graphics/TileMap.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index f8faa7b54..0ed57a1be 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/ConfigCheck.hpp b/include/Nazara/Lua/ConfigCheck.hpp index 1701205c8..ee3010113 100644 --- a/include/Nazara/Lua/ConfigCheck.hpp +++ b/include/Nazara/Lua/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/Debug.hpp b/include/Nazara/Lua/Debug.hpp index 8cfefe4fc..991f620a2 100644 --- a/include/Nazara/Lua/Debug.hpp +++ b/include/Nazara/Lua/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/DebugOff.hpp b/include/Nazara/Lua/DebugOff.hpp index 3609f245d..59c38fd94 100644 --- a/include/Nazara/Lua/DebugOff.hpp +++ b/include/Nazara/Lua/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/Enums.hpp b/include/Nazara/Lua/Enums.hpp index 93068314f..f62357e6f 100644 --- a/include/Nazara/Lua/Enums.hpp +++ b/include/Nazara/Lua/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/Lua.hpp b/include/Nazara/Lua/Lua.hpp index e41de7e1e..e1c084f8f 100644 --- a/include/Nazara/Lua/Lua.hpp +++ b/include/Nazara/Lua/Lua.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/LuaClass.hpp b/include/Nazara/Lua/LuaClass.hpp index 3085aed0f..13dcbb828 100644 --- a/include/Nazara/Lua/LuaClass.hpp +++ b/include/Nazara/Lua/LuaClass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl index 3168ba43d..94c1f8125 100644 --- a/include/Nazara/Lua/LuaClass.inl +++ b/include/Nazara/Lua/LuaClass.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index 34a09d11a..5f27c76e6 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index 6c3a4ff7e..9c54982e4 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Algorithm.hpp b/include/Nazara/Math/Algorithm.hpp index 6decc4b28..5ffbe8106 100644 --- a/include/Nazara/Math/Algorithm.hpp +++ b/include/Nazara/Math/Algorithm.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index d7309a148..9a0eaabfb 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/BoundingVolume.hpp b/include/Nazara/Math/BoundingVolume.hpp index 6c863b729..b5c4e8b9e 100644 --- a/include/Nazara/Math/BoundingVolume.hpp +++ b/include/Nazara/Math/BoundingVolume.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/BoundingVolume.inl b/include/Nazara/Math/BoundingVolume.inl index a1efd8364..d2dee79f8 100644 --- a/include/Nazara/Math/BoundingVolume.inl +++ b/include/Nazara/Math/BoundingVolume.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index 25e9a8069..b3f0aed2b 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 71c98a70b..fb22039ba 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Enums.hpp b/include/Nazara/Math/Enums.hpp index 76649906f..0430df83a 100644 --- a/include/Nazara/Math/Enums.hpp +++ b/include/Nazara/Math/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/EulerAngles.hpp b/include/Nazara/Math/EulerAngles.hpp index ab267e81f..b55adc4dd 100644 --- a/include/Nazara/Math/EulerAngles.hpp +++ b/include/Nazara/Math/EulerAngles.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/EulerAngles.inl b/include/Nazara/Math/EulerAngles.inl index 3b12e7abe..d903de52a 100644 --- a/include/Nazara/Math/EulerAngles.inl +++ b/include/Nazara/Math/EulerAngles.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Frustum.hpp b/include/Nazara/Math/Frustum.hpp index 96c78004c..26242caef 100644 --- a/include/Nazara/Math/Frustum.hpp +++ b/include/Nazara/Math/Frustum.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index 71f385cac..f459a0526 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index 91927d68a..c90439de4 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index f045ac28a..f3effcc5e 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/OrientedBox.hpp b/include/Nazara/Math/OrientedBox.hpp index 2b806e56b..dfd8f6b28 100644 --- a/include/Nazara/Math/OrientedBox.hpp +++ b/include/Nazara/Math/OrientedBox.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/OrientedBox.inl b/include/Nazara/Math/OrientedBox.inl index 3320dce1a..674e8bdb0 100644 --- a/include/Nazara/Math/OrientedBox.inl +++ b/include/Nazara/Math/OrientedBox.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Plane.hpp b/include/Nazara/Math/Plane.hpp index 0eb201123..0970b5a6d 100644 --- a/include/Nazara/Math/Plane.hpp +++ b/include/Nazara/Math/Plane.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Plane.inl b/include/Nazara/Math/Plane.inl index 625abe3e4..15bf8cae7 100644 --- a/include/Nazara/Math/Plane.inl +++ b/include/Nazara/Math/Plane.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Quaternion.hpp b/include/Nazara/Math/Quaternion.hpp index bbb313bd5..27adb8b36 100644 --- a/include/Nazara/Math/Quaternion.hpp +++ b/include/Nazara/Math/Quaternion.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges - Jérôme Leclercq +// Copyright (C) 2017 Rémi Bèges - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index f7f7c693c..def663ee4 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges - Jérôme Leclercq +// Copyright (C) 2017 Rémi Bèges - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Ray.hpp b/include/Nazara/Math/Ray.hpp index 7e8c0790a..01e86afaf 100644 --- a/include/Nazara/Math/Ray.hpp +++ b/include/Nazara/Math/Ray.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Gawaboumga (https://github.com/Gawaboumga) - Jérôme Leclercq +// Copyright (C) 2017 Gawaboumga (https://github.com/Gawaboumga) - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Ray.inl b/include/Nazara/Math/Ray.inl index 6045615ed..2149af8b7 100644 --- a/include/Nazara/Math/Ray.inl +++ b/include/Nazara/Math/Ray.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Gawaboumga (https://github.com/Gawaboumga) - Jérôme Leclercq +// Copyright (C) 2017 Gawaboumga (https://github.com/Gawaboumga) - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index 843ff6126..f297cddd3 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 21d0e7e93..0365ebf54 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Sphere.hpp b/include/Nazara/Math/Sphere.hpp index feaa8af56..57d2d6765 100644 --- a/include/Nazara/Math/Sphere.hpp +++ b/include/Nazara/Math/Sphere.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index cd748c0ba..8d803c2e0 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index 49890b06f..ecbd5e4fe 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index 8ca023843..1883ecfdc 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 27681683f..8cfe59397 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges - Jérôme Leclercq +// Copyright (C) 2017 Rémi Bèges - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 604cbfb86..37be47fba 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges - Jérôme Leclercq +// Copyright (C) 2017 Rémi Bèges - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index d878c2ea5..c39c0b250 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges - Jérôme Leclercq +// Copyright (C) 2017 Rémi Bèges - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index f3cad0a31..b79e6a644 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges - Jérôme Leclercq +// Copyright (C) 2017 Rémi Bèges - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/AbstractSocket.hpp b/include/Nazara/Network/AbstractSocket.hpp index f3789ebf0..d137c9050 100644 --- a/include/Nazara/Network/AbstractSocket.hpp +++ b/include/Nazara/Network/AbstractSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/AbstractSocket.inl b/include/Nazara/Network/AbstractSocket.inl index 5b5174b98..fe8aed5af 100644 --- a/include/Nazara/Network/AbstractSocket.inl +++ b/include/Nazara/Network/AbstractSocket.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Algorithm.hpp b/include/Nazara/Network/Algorithm.hpp index ec8164ef4..001d98059 100644 --- a/include/Nazara/Network/Algorithm.hpp +++ b/include/Nazara/Network/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Algorithm.inl b/include/Nazara/Network/Algorithm.inl index ecf609987..5364298d4 100644 --- a/include/Nazara/Network/Algorithm.inl +++ b/include/Nazara/Network/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ConfigCheck.hpp b/include/Nazara/Network/ConfigCheck.hpp index 2f1ba1dc8..c17f870dc 100644 --- a/include/Nazara/Network/ConfigCheck.hpp +++ b/include/Nazara/Network/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Debug.hpp b/include/Nazara/Network/Debug.hpp index 0826a3ecc..40f5296fa 100644 --- a/include/Nazara/Network/Debug.hpp +++ b/include/Nazara/Network/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/DebugOff.hpp b/include/Nazara/Network/DebugOff.hpp index e9df99f1f..d6bf6d17f 100644 --- a/include/Nazara/Network/DebugOff.hpp +++ b/include/Nazara/Network/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Enums.hpp b/include/Nazara/Network/Enums.hpp index 32d9484ae..7dccd7dd1 100644 --- a/include/Nazara/Network/Enums.hpp +++ b/include/Nazara/Network/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/IpAddress.hpp b/include/Nazara/Network/IpAddress.hpp index 32def1031..c3775effd 100644 --- a/include/Nazara/Network/IpAddress.hpp +++ b/include/Nazara/Network/IpAddress.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index ed06b1af7..7e59099d2 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/NetPacket.hpp b/include/Nazara/Network/NetPacket.hpp index 7eef2979a..9d5bb99a4 100644 --- a/include/Nazara/Network/NetPacket.hpp +++ b/include/Nazara/Network/NetPacket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/NetPacket.inl b/include/Nazara/Network/NetPacket.inl index e9765c9dc..6d55831d4 100644 --- a/include/Nazara/Network/NetPacket.inl +++ b/include/Nazara/Network/NetPacket.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Network.hpp b/include/Nazara/Network/Network.hpp index 16cf940d2..ca6ca9ee6 100644 --- a/include/Nazara/Network/Network.hpp +++ b/include/Nazara/Network/Network.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/RUdpConnection.inl b/include/Nazara/Network/RUdpConnection.inl index 2960cbced..eaf4a0e7a 100644 --- a/include/Nazara/Network/RUdpConnection.inl +++ b/include/Nazara/Network/RUdpConnection.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/RUdpMessage.hpp b/include/Nazara/Network/RUdpMessage.hpp index 5d4fdb4a5..d0c10197c 100644 --- a/include/Nazara/Network/RUdpMessage.hpp +++ b/include/Nazara/Network/RUdpMessage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/SocketHandle.hpp b/include/Nazara/Network/SocketHandle.hpp index 2a09b80c3..be87e1da7 100644 --- a/include/Nazara/Network/SocketHandle.hpp +++ b/include/Nazara/Network/SocketHandle.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/SocketPoller.hpp b/include/Nazara/Network/SocketPoller.hpp index 0684ef41f..74f90c17f 100644 --- a/include/Nazara/Network/SocketPoller.hpp +++ b/include/Nazara/Network/SocketPoller.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/SocketPoller.inl b/include/Nazara/Network/SocketPoller.inl index c3e415508..66331b9cb 100644 --- a/include/Nazara/Network/SocketPoller.inl +++ b/include/Nazara/Network/SocketPoller.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpClient.hpp b/include/Nazara/Network/TcpClient.hpp index 0fcedcf39..dc41d8eb5 100644 --- a/include/Nazara/Network/TcpClient.hpp +++ b/include/Nazara/Network/TcpClient.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpClient.inl b/include/Nazara/Network/TcpClient.inl index 23f5412da..0ab267436 100644 --- a/include/Nazara/Network/TcpClient.inl +++ b/include/Nazara/Network/TcpClient.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpServer.hpp b/include/Nazara/Network/TcpServer.hpp index da1b48e73..9eab2f0a3 100644 --- a/include/Nazara/Network/TcpServer.hpp +++ b/include/Nazara/Network/TcpServer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpServer.inl b/include/Nazara/Network/TcpServer.inl index 1fcb4eb32..c3aedbd0e 100644 --- a/include/Nazara/Network/TcpServer.inl +++ b/include/Nazara/Network/TcpServer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/UdpSocket.hpp b/include/Nazara/Network/UdpSocket.hpp index 2aac124af..e6470e365 100644 --- a/include/Nazara/Network/UdpSocket.hpp +++ b/include/Nazara/Network/UdpSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/UdpSocket.inl b/include/Nazara/Network/UdpSocket.inl index 4096d8c04..3e4dee4df 100644 --- a/include/Nazara/Network/UdpSocket.inl +++ b/include/Nazara/Network/UdpSocket.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/ConfigCheck.hpp b/include/Nazara/Noise/ConfigCheck.hpp index 9c6df7851..93a90e13f 100644 --- a/include/Nazara/Noise/ConfigCheck.hpp +++ b/include/Nazara/Noise/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Debug.hpp b/include/Nazara/Noise/Debug.hpp index 4696c79b9..4068c5a95 100644 --- a/include/Nazara/Noise/Debug.hpp +++ b/include/Nazara/Noise/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/DebugOff.hpp b/include/Nazara/Noise/DebugOff.hpp index 4b368b6ea..a0ca07927 100644 --- a/include/Nazara/Noise/DebugOff.hpp +++ b/include/Nazara/Noise/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Enums.hpp b/include/Nazara/Noise/Enums.hpp index 7962d8415..fdc2b7ec3 100644 --- a/include/Nazara/Noise/Enums.hpp +++ b/include/Nazara/Noise/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/FBM.hpp b/include/Nazara/Noise/FBM.hpp index 584fb3a10..41cbc5758 100644 --- a/include/Nazara/Noise/FBM.hpp +++ b/include/Nazara/Noise/FBM.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/HybridMultiFractal.hpp b/include/Nazara/Noise/HybridMultiFractal.hpp index cbb80ef65..78d94f4de 100644 --- a/include/Nazara/Noise/HybridMultiFractal.hpp +++ b/include/Nazara/Noise/HybridMultiFractal.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/MixerBase.hpp b/include/Nazara/Noise/MixerBase.hpp index 8b7a99d56..61df26543 100644 --- a/include/Nazara/Noise/MixerBase.hpp +++ b/include/Nazara/Noise/MixerBase.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Noise.hpp b/include/Nazara/Noise/Noise.hpp index c1ec5b1da..8138ee41b 100644 --- a/include/Nazara/Noise/Noise.hpp +++ b/include/Nazara/Noise/Noise.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/NoiseBase.hpp b/include/Nazara/Noise/NoiseBase.hpp index f7f9eba09..744070e26 100644 --- a/include/Nazara/Noise/NoiseBase.hpp +++ b/include/Nazara/Noise/NoiseBase.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/NoiseTools.hpp b/include/Nazara/Noise/NoiseTools.hpp index 6238caec3..b3fd1bada 100644 --- a/include/Nazara/Noise/NoiseTools.hpp +++ b/include/Nazara/Noise/NoiseTools.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Perlin.hpp b/include/Nazara/Noise/Perlin.hpp index 781d03148..64211c4e4 100644 --- a/include/Nazara/Noise/Perlin.hpp +++ b/include/Nazara/Noise/Perlin.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Simplex.hpp b/include/Nazara/Noise/Simplex.hpp index 4f33c24ff..2b6309671 100644 --- a/include/Nazara/Noise/Simplex.hpp +++ b/include/Nazara/Noise/Simplex.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Worley.hpp b/include/Nazara/Noise/Worley.hpp index 6b9f21f73..1b820e513 100644 --- a/include/Nazara/Noise/Worley.hpp +++ b/include/Nazara/Noise/Worley.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Collider2D.hpp b/include/Nazara/Physics2D/Collider2D.hpp index 7bc1c7618..610d1a00f 100644 --- a/include/Nazara/Physics2D/Collider2D.hpp +++ b/include/Nazara/Physics2D/Collider2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Collider2D.inl b/include/Nazara/Physics2D/Collider2D.inl index 5c3909cde..f5b222875 100644 --- a/include/Nazara/Physics2D/Collider2D.inl +++ b/include/Nazara/Physics2D/Collider2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/ConfigCheck.hpp b/include/Nazara/Physics2D/ConfigCheck.hpp index 3b3b90afc..288cfd59a 100644 --- a/include/Nazara/Physics2D/ConfigCheck.hpp +++ b/include/Nazara/Physics2D/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Debug.hpp b/include/Nazara/Physics2D/Debug.hpp index 729491e7c..d98efc02d 100644 --- a/include/Nazara/Physics2D/Debug.hpp +++ b/include/Nazara/Physics2D/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/DebugOff.hpp b/include/Nazara/Physics2D/DebugOff.hpp index ffbd0a25a..5cedb88f3 100644 --- a/include/Nazara/Physics2D/DebugOff.hpp +++ b/include/Nazara/Physics2D/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Enums.hpp b/include/Nazara/Physics2D/Enums.hpp index 529af6f6c..86c1411f4 100644 --- a/include/Nazara/Physics2D/Enums.hpp +++ b/include/Nazara/Physics2D/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index e194f89d2..c2ffb437c 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Physics2D.hpp b/include/Nazara/Physics2D/Physics2D.hpp index 27fdf3128..3a9f2b731 100644 --- a/include/Nazara/Physics2D/Physics2D.hpp +++ b/include/Nazara/Physics2D/Physics2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/RigidBody2D.hpp b/include/Nazara/Physics2D/RigidBody2D.hpp index 79b7d64bc..5f14d8ff9 100644 --- a/include/Nazara/Physics2D/RigidBody2D.hpp +++ b/include/Nazara/Physics2D/RigidBody2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Collider3D.hpp b/include/Nazara/Physics3D/Collider3D.hpp index 89e0a4879..13bf32c2f 100644 --- a/include/Nazara/Physics3D/Collider3D.hpp +++ b/include/Nazara/Physics3D/Collider3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Collider3D.inl b/include/Nazara/Physics3D/Collider3D.inl index aeb7073d8..3ded7d289 100644 --- a/include/Nazara/Physics3D/Collider3D.inl +++ b/include/Nazara/Physics3D/Collider3D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/ConfigCheck.hpp b/include/Nazara/Physics3D/ConfigCheck.hpp index 012cc426c..7b882ef42 100644 --- a/include/Nazara/Physics3D/ConfigCheck.hpp +++ b/include/Nazara/Physics3D/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Debug.hpp b/include/Nazara/Physics3D/Debug.hpp index ef111fb96..506b3a773 100644 --- a/include/Nazara/Physics3D/Debug.hpp +++ b/include/Nazara/Physics3D/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/DebugOff.hpp b/include/Nazara/Physics3D/DebugOff.hpp index b8b84c240..9804c567d 100644 --- a/include/Nazara/Physics3D/DebugOff.hpp +++ b/include/Nazara/Physics3D/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Enums.hpp b/include/Nazara/Physics3D/Enums.hpp index b01c9bb83..12c754899 100644 --- a/include/Nazara/Physics3D/Enums.hpp +++ b/include/Nazara/Physics3D/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/PhysWorld3D.hpp b/include/Nazara/Physics3D/PhysWorld3D.hpp index ea84aa931..633be2b61 100644 --- a/include/Nazara/Physics3D/PhysWorld3D.hpp +++ b/include/Nazara/Physics3D/PhysWorld3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Physics3D.hpp b/include/Nazara/Physics3D/Physics3D.hpp index 949301002..b0d6f69f5 100644 --- a/include/Nazara/Physics3D/Physics3D.hpp +++ b/include/Nazara/Physics3D/Physics3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/RigidBody3D.hpp b/include/Nazara/Physics3D/RigidBody3D.hpp index d895e9040..502fd21a7 100644 --- a/include/Nazara/Physics3D/RigidBody3D.hpp +++ b/include/Nazara/Physics3D/RigidBody3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/ConfigCheck.hpp b/include/Nazara/Renderer/ConfigCheck.hpp index 71cc3d5eb..d8e677789 100644 --- a/include/Nazara/Renderer/ConfigCheck.hpp +++ b/include/Nazara/Renderer/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Context.hpp b/include/Nazara/Renderer/Context.hpp index 4bfb7b1b0..d9836cbe8 100644 --- a/include/Nazara/Renderer/Context.hpp +++ b/include/Nazara/Renderer/Context.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/ContextParameters.hpp b/include/Nazara/Renderer/ContextParameters.hpp index ddfc76ea3..99940a24f 100644 --- a/include/Nazara/Renderer/ContextParameters.hpp +++ b/include/Nazara/Renderer/ContextParameters.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Debug.hpp b/include/Nazara/Renderer/Debug.hpp index ef0e73147..22444ba98 100644 --- a/include/Nazara/Renderer/Debug.hpp +++ b/include/Nazara/Renderer/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/DebugDrawer.hpp b/include/Nazara/Renderer/DebugDrawer.hpp index 7880a1ae4..491183605 100644 --- a/include/Nazara/Renderer/DebugDrawer.hpp +++ b/include/Nazara/Renderer/DebugDrawer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/DebugOff.hpp b/include/Nazara/Renderer/DebugOff.hpp index b20650b99..ecc9a1b92 100644 --- a/include/Nazara/Renderer/DebugOff.hpp +++ b/include/Nazara/Renderer/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 2d0e6d3a7..9c898fcf8 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/GpuQuery.hpp b/include/Nazara/Renderer/GpuQuery.hpp index 87b758966..8ed4006f8 100644 --- a/include/Nazara/Renderer/GpuQuery.hpp +++ b/include/Nazara/Renderer/GpuQuery.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index e7f21d228..08b741b97 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderBuffer.hpp b/include/Nazara/Renderer/RenderBuffer.hpp index cfe66651e..3b02cf4fd 100644 --- a/include/Nazara/Renderer/RenderBuffer.hpp +++ b/include/Nazara/Renderer/RenderBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl index bd81e7a17..84d5b86bd 100644 --- a/include/Nazara/Renderer/RenderBuffer.inl +++ b/include/Nazara/Renderer/RenderBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderPipeline.hpp b/include/Nazara/Renderer/RenderPipeline.hpp index aee5584b7..846cfb4af 100644 --- a/include/Nazara/Renderer/RenderPipeline.hpp +++ b/include/Nazara/Renderer/RenderPipeline.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderPipeline.inl b/include/Nazara/Renderer/RenderPipeline.inl index 5982b0562..2a1aef815 100644 --- a/include/Nazara/Renderer/RenderPipeline.inl +++ b/include/Nazara/Renderer/RenderPipeline.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index fc4d10eeb..dee9db808 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 525491162..7f976ff13 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderTarget.hpp b/include/Nazara/Renderer/RenderTarget.hpp index d018cb952..b30f77ebf 100644 --- a/include/Nazara/Renderer/RenderTarget.hpp +++ b/include/Nazara/Renderer/RenderTarget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderTargetParameters.hpp b/include/Nazara/Renderer/RenderTargetParameters.hpp index 990848c53..b978a310b 100644 --- a/include/Nazara/Renderer/RenderTargetParameters.hpp +++ b/include/Nazara/Renderer/RenderTargetParameters.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderTexture.hpp b/include/Nazara/Renderer/RenderTexture.hpp index 798e441ee..ad340009e 100644 --- a/include/Nazara/Renderer/RenderTexture.hpp +++ b/include/Nazara/Renderer/RenderTexture.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderTexture.inl b/include/Nazara/Renderer/RenderTexture.inl index 7b8c32c68..2ad902355 100644 --- a/include/Nazara/Renderer/RenderTexture.inl +++ b/include/Nazara/Renderer/RenderTexture.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index 3560dfcc9..c71ad2b34 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index db85c4d62..d549a48bb 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Shader.hpp b/include/Nazara/Renderer/Shader.hpp index aa9dabba8..27c68a9d6 100644 --- a/include/Nazara/Renderer/Shader.hpp +++ b/include/Nazara/Renderer/Shader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Shader.inl b/include/Nazara/Renderer/Shader.inl index b868c540e..079ef6ff3 100644 --- a/include/Nazara/Renderer/Shader.inl +++ b/include/Nazara/Renderer/Shader.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/ShaderStage.hpp b/include/Nazara/Renderer/ShaderStage.hpp index 1dfce1f51..7471312f7 100644 --- a/include/Nazara/Renderer/ShaderStage.hpp +++ b/include/Nazara/Renderer/ShaderStage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index 6d52beb6f..7c5f9ab6e 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Texture.inl b/include/Nazara/Renderer/Texture.inl index 4dc53464b..f59898f28 100644 --- a/include/Nazara/Renderer/Texture.inl +++ b/include/Nazara/Renderer/Texture.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/TextureSampler.hpp b/include/Nazara/Renderer/TextureSampler.hpp index 21675e6c9..12ad54655 100644 --- a/include/Nazara/Renderer/TextureSampler.hpp +++ b/include/Nazara/Renderer/TextureSampler.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/UberShader.hpp b/include/Nazara/Renderer/UberShader.hpp index 541715895..af822db89 100644 --- a/include/Nazara/Renderer/UberShader.hpp +++ b/include/Nazara/Renderer/UberShader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/UberShaderInstance.hpp b/include/Nazara/Renderer/UberShaderInstance.hpp index 080cb8294..b0f0f78d5 100644 --- a/include/Nazara/Renderer/UberShaderInstance.hpp +++ b/include/Nazara/Renderer/UberShaderInstance.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp b/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp index 9a0c8a6f9..5f0a16900 100644 --- a/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp +++ b/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.hpp b/include/Nazara/Renderer/UberShaderPreprocessor.hpp index 1411b731c..6732fab23 100644 --- a/include/Nazara/Renderer/UberShaderPreprocessor.hpp +++ b/include/Nazara/Renderer/UberShaderPreprocessor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.inl b/include/Nazara/Renderer/UberShaderPreprocessor.inl index 1e6528775..463935b3d 100644 --- a/include/Nazara/Renderer/UberShaderPreprocessor.inl +++ b/include/Nazara/Renderer/UberShaderPreprocessor.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractAtlas.hpp b/include/Nazara/Utility/AbstractAtlas.hpp index 16d09235f..49565cdf2 100644 --- a/include/Nazara/Utility/AbstractAtlas.hpp +++ b/include/Nazara/Utility/AbstractAtlas.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractBuffer.hpp b/include/Nazara/Utility/AbstractBuffer.hpp index ff264d6b9..a0f183218 100644 --- a/include/Nazara/Utility/AbstractBuffer.hpp +++ b/include/Nazara/Utility/AbstractBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractImage.hpp b/include/Nazara/Utility/AbstractImage.hpp index ffeacbca4..7bba13de1 100644 --- a/include/Nazara/Utility/AbstractImage.hpp +++ b/include/Nazara/Utility/AbstractImage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractImage.inl b/include/Nazara/Utility/AbstractImage.inl index b3e5fc417..fe456669f 100644 --- a/include/Nazara/Utility/AbstractImage.inl +++ b/include/Nazara/Utility/AbstractImage.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractTextDrawer.hpp b/include/Nazara/Utility/AbstractTextDrawer.hpp index dd05e5af6..becb9dac6 100644 --- a/include/Nazara/Utility/AbstractTextDrawer.hpp +++ b/include/Nazara/Utility/AbstractTextDrawer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Algorithm.hpp b/include/Nazara/Utility/Algorithm.hpp index 70c4cdc60..1652976c3 100644 --- a/include/Nazara/Utility/Algorithm.hpp +++ b/include/Nazara/Utility/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Animation.hpp b/include/Nazara/Utility/Animation.hpp index 2ab1f2baa..7f7595bbd 100644 --- a/include/Nazara/Utility/Animation.hpp +++ b/include/Nazara/Utility/Animation.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Animation.inl b/include/Nazara/Utility/Animation.inl index 0ae58c0f4..d56733c57 100644 --- a/include/Nazara/Utility/Animation.inl +++ b/include/Nazara/Utility/Animation.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Buffer.hpp b/include/Nazara/Utility/Buffer.hpp index 3655de53c..526a153e4 100644 --- a/include/Nazara/Utility/Buffer.hpp +++ b/include/Nazara/Utility/Buffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Buffer.inl b/include/Nazara/Utility/Buffer.inl index df54a3987..afeef1624 100644 --- a/include/Nazara/Utility/Buffer.inl +++ b/include/Nazara/Utility/Buffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/BufferMapper.hpp b/include/Nazara/Utility/BufferMapper.hpp index b34c41c73..4f80528fd 100644 --- a/include/Nazara/Utility/BufferMapper.hpp +++ b/include/Nazara/Utility/BufferMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/BufferMapper.inl b/include/Nazara/Utility/BufferMapper.inl index 1284ba26d..4b7b8be35 100644 --- a/include/Nazara/Utility/BufferMapper.inl +++ b/include/Nazara/Utility/BufferMapper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/ConfigCheck.hpp b/include/Nazara/Utility/ConfigCheck.hpp index 01d224a7a..bbfd6ea66 100644 --- a/include/Nazara/Utility/ConfigCheck.hpp +++ b/include/Nazara/Utility/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/CubemapParams.hpp b/include/Nazara/Utility/CubemapParams.hpp index 0f9e6eba4..6153eb06d 100644 --- a/include/Nazara/Utility/CubemapParams.hpp +++ b/include/Nazara/Utility/CubemapParams.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Cursor.hpp b/include/Nazara/Utility/Cursor.hpp index 77684cfc5..870b17b55 100644 --- a/include/Nazara/Utility/Cursor.hpp +++ b/include/Nazara/Utility/Cursor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Cursor.inl b/include/Nazara/Utility/Cursor.inl index ba817eb9b..58d15bdec 100644 --- a/include/Nazara/Utility/Cursor.inl +++ b/include/Nazara/Utility/Cursor.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/CursorController.hpp b/include/Nazara/Utility/CursorController.hpp index 5b994e11e..0c2943356 100644 --- a/include/Nazara/Utility/CursorController.hpp +++ b/include/Nazara/Utility/CursorController.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/CursorController.inl b/include/Nazara/Utility/CursorController.inl index 1de20a17a..b1f54d05a 100644 --- a/include/Nazara/Utility/CursorController.inl +++ b/include/Nazara/Utility/CursorController.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Debug.hpp b/include/Nazara/Utility/Debug.hpp index 85319685a..2041a7363 100644 --- a/include/Nazara/Utility/Debug.hpp +++ b/include/Nazara/Utility/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/DebugOff.hpp b/include/Nazara/Utility/DebugOff.hpp index 5cb9a0750..621ac2c38 100644 --- a/include/Nazara/Utility/DebugOff.hpp +++ b/include/Nazara/Utility/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 7188b05f4..d72b90d6c 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Event.hpp b/include/Nazara/Utility/Event.hpp index c5535abff..b67eedc0c 100644 --- a/include/Nazara/Utility/Event.hpp +++ b/include/Nazara/Utility/Event.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/EventHandler.hpp b/include/Nazara/Utility/EventHandler.hpp index 95e9bedc6..78cba94bc 100644 --- a/include/Nazara/Utility/EventHandler.hpp +++ b/include/Nazara/Utility/EventHandler.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl index 719ffddcb..4ba3f49bd 100644 --- a/include/Nazara/Utility/EventHandler.inl +++ b/include/Nazara/Utility/EventHandler.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Font.hpp b/include/Nazara/Utility/Font.hpp index 9a226d91e..643120aab 100644 --- a/include/Nazara/Utility/Font.hpp +++ b/include/Nazara/Utility/Font.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Font.inl b/include/Nazara/Utility/Font.inl index 241915a3e..efe2a4adc 100644 --- a/include/Nazara/Utility/Font.inl +++ b/include/Nazara/Utility/Font.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/FontData.hpp b/include/Nazara/Utility/FontData.hpp index 78da99792..5b0868e3c 100644 --- a/include/Nazara/Utility/FontData.hpp +++ b/include/Nazara/Utility/FontData.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/FontGlyph.hpp b/include/Nazara/Utility/FontGlyph.hpp index 2ea194116..ea673e178 100644 --- a/include/Nazara/Utility/FontGlyph.hpp +++ b/include/Nazara/Utility/FontGlyph.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/MD5AnimParser.hpp b/include/Nazara/Utility/Formats/MD5AnimParser.hpp index 3a9e2163d..d62cdaae8 100644 --- a/include/Nazara/Utility/Formats/MD5AnimParser.hpp +++ b/include/Nazara/Utility/Formats/MD5AnimParser.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/MD5MeshParser.hpp b/include/Nazara/Utility/Formats/MD5MeshParser.hpp index b515c1226..dce6bcc72 100644 --- a/include/Nazara/Utility/Formats/MD5MeshParser.hpp +++ b/include/Nazara/Utility/Formats/MD5MeshParser.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/MTLParser.hpp b/include/Nazara/Utility/Formats/MTLParser.hpp index 708e30685..ec50f2137 100644 --- a/include/Nazara/Utility/Formats/MTLParser.hpp +++ b/include/Nazara/Utility/Formats/MTLParser.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/MTLParser.inl b/include/Nazara/Utility/Formats/MTLParser.inl index 0f8cd4f66..00e9e8b89 100644 --- a/include/Nazara/Utility/Formats/MTLParser.inl +++ b/include/Nazara/Utility/Formats/MTLParser.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 82c1220bf..c01f7724a 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index 41e794f82..4b780672b 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/GuillotineImageAtlas.hpp b/include/Nazara/Utility/GuillotineImageAtlas.hpp index 318b92d6b..739328dc6 100644 --- a/include/Nazara/Utility/GuillotineImageAtlas.hpp +++ b/include/Nazara/Utility/GuillotineImageAtlas.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Icon.hpp b/include/Nazara/Utility/Icon.hpp index 1890d3c00..db93e9495 100644 --- a/include/Nazara/Utility/Icon.hpp +++ b/include/Nazara/Utility/Icon.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Icon.inl b/include/Nazara/Utility/Icon.inl index d7f29eb54..5c6b60068 100644 --- a/include/Nazara/Utility/Icon.inl +++ b/include/Nazara/Utility/Icon.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index e1712aed1..4e5b094cc 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Image.inl b/include/Nazara/Utility/Image.inl index 5cb8ef42f..b59a2629b 100644 --- a/include/Nazara/Utility/Image.inl +++ b/include/Nazara/Utility/Image.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexBuffer.hpp b/include/Nazara/Utility/IndexBuffer.hpp index 75010bdc0..2c66bc6ed 100644 --- a/include/Nazara/Utility/IndexBuffer.hpp +++ b/include/Nazara/Utility/IndexBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index f598c5291..b439623eb 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexIterator.hpp b/include/Nazara/Utility/IndexIterator.hpp index 7620d3b28..5c15bbdc2 100644 --- a/include/Nazara/Utility/IndexIterator.hpp +++ b/include/Nazara/Utility/IndexIterator.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexIterator.inl b/include/Nazara/Utility/IndexIterator.inl index f0d3d5a95..df1613d67 100644 --- a/include/Nazara/Utility/IndexIterator.inl +++ b/include/Nazara/Utility/IndexIterator.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexMapper.hpp b/include/Nazara/Utility/IndexMapper.hpp index 7f632f196..84c73bc53 100644 --- a/include/Nazara/Utility/IndexMapper.hpp +++ b/include/Nazara/Utility/IndexMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Joint.hpp b/include/Nazara/Utility/Joint.hpp index 77227a605..f82668986 100644 --- a/include/Nazara/Utility/Joint.hpp +++ b/include/Nazara/Utility/Joint.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Joystick.hpp b/include/Nazara/Utility/Joystick.hpp index ce84c9473..f80b4b590 100644 --- a/include/Nazara/Utility/Joystick.hpp +++ b/include/Nazara/Utility/Joystick.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Keyboard.hpp b/include/Nazara/Utility/Keyboard.hpp index 8eea51ff5..bfd050d73 100644 --- a/include/Nazara/Utility/Keyboard.hpp +++ b/include/Nazara/Utility/Keyboard.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index 0c1e28cdd..c2634d92c 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 8cbbaf70b..a05f7c9f4 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Mesh.inl b/include/Nazara/Utility/Mesh.inl index 4877e03fe..e63cb389f 100644 --- a/include/Nazara/Utility/Mesh.inl +++ b/include/Nazara/Utility/Mesh.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/MeshData.hpp b/include/Nazara/Utility/MeshData.hpp index e9a3021f6..54b5ca0e7 100644 --- a/include/Nazara/Utility/MeshData.hpp +++ b/include/Nazara/Utility/MeshData.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Mouse.hpp b/include/Nazara/Utility/Mouse.hpp index 47fd7a1e0..552011904 100644 --- a/include/Nazara/Utility/Mouse.hpp +++ b/include/Nazara/Utility/Mouse.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Node.hpp b/include/Nazara/Utility/Node.hpp index 71ba4d73d..e70732837 100644 --- a/include/Nazara/Utility/Node.hpp +++ b/include/Nazara/Utility/Node.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/PixelFormat.hpp b/include/Nazara/Utility/PixelFormat.hpp index 92eecb7f4..8731ad29f 100644 --- a/include/Nazara/Utility/PixelFormat.hpp +++ b/include/Nazara/Utility/PixelFormat.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index 59ad2ab04..b4dfd95ee 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Sequence.hpp b/include/Nazara/Utility/Sequence.hpp index b8549a4bf..1f729e5e4 100644 --- a/include/Nazara/Utility/Sequence.hpp +++ b/include/Nazara/Utility/Sequence.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index 7c2db6c20..90b501690 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SkeletalMesh.hpp b/include/Nazara/Utility/SkeletalMesh.hpp index 616fb3dec..3efe704da 100644 --- a/include/Nazara/Utility/SkeletalMesh.hpp +++ b/include/Nazara/Utility/SkeletalMesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SkeletalMesh.inl b/include/Nazara/Utility/SkeletalMesh.inl index 69119dc87..561e906e9 100644 --- a/include/Nazara/Utility/SkeletalMesh.inl +++ b/include/Nazara/Utility/SkeletalMesh.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Skeleton.hpp b/include/Nazara/Utility/Skeleton.hpp index 8312f967f..0ed6c6691 100644 --- a/include/Nazara/Utility/Skeleton.hpp +++ b/include/Nazara/Utility/Skeleton.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Skeleton.inl b/include/Nazara/Utility/Skeleton.inl index 4c0ef4546..ece3fbf98 100644 --- a/include/Nazara/Utility/Skeleton.inl +++ b/include/Nazara/Utility/Skeleton.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SoftwareBuffer.hpp b/include/Nazara/Utility/SoftwareBuffer.hpp index 1bd4eb3db..f199a9a8e 100644 --- a/include/Nazara/Utility/SoftwareBuffer.hpp +++ b/include/Nazara/Utility/SoftwareBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/StaticMesh.hpp b/include/Nazara/Utility/StaticMesh.hpp index d5fe8907d..066bcee45 100644 --- a/include/Nazara/Utility/StaticMesh.hpp +++ b/include/Nazara/Utility/StaticMesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/StaticMesh.inl b/include/Nazara/Utility/StaticMesh.inl index 06afcec95..efe6ffd12 100644 --- a/include/Nazara/Utility/StaticMesh.inl +++ b/include/Nazara/Utility/StaticMesh.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SubMesh.hpp b/include/Nazara/Utility/SubMesh.hpp index 525930e0b..d9d5cd2bf 100644 --- a/include/Nazara/Utility/SubMesh.hpp +++ b/include/Nazara/Utility/SubMesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/TriangleIterator.hpp b/include/Nazara/Utility/TriangleIterator.hpp index 32c9ceb07..bfc5a01fc 100644 --- a/include/Nazara/Utility/TriangleIterator.hpp +++ b/include/Nazara/Utility/TriangleIterator.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Utility.hpp b/include/Nazara/Utility/Utility.hpp index 31ec543ee..d78121f2c 100644 --- a/include/Nazara/Utility/Utility.hpp +++ b/include/Nazara/Utility/Utility.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexBuffer.hpp b/include/Nazara/Utility/VertexBuffer.hpp index 12614355e..8f5b608e2 100644 --- a/include/Nazara/Utility/VertexBuffer.hpp +++ b/include/Nazara/Utility/VertexBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index 45dc75ea7..588289f92 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexDeclaration.hpp b/include/Nazara/Utility/VertexDeclaration.hpp index 8c1e4b55a..594f1b5f0 100644 --- a/include/Nazara/Utility/VertexDeclaration.hpp +++ b/include/Nazara/Utility/VertexDeclaration.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index beed900d5..26cd39736 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index e18250d7c..486d000fd 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index 4a155bfbd..6892f9091 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexStruct.hpp b/include/Nazara/Utility/VertexStruct.hpp index d9fa1d050..2a811722e 100644 --- a/include/Nazara/Utility/VertexStruct.hpp +++ b/include/Nazara/Utility/VertexStruct.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VideoMode.hpp b/include/Nazara/Utility/VideoMode.hpp index 3c2243817..4d6a77768 100644 --- a/include/Nazara/Utility/VideoMode.hpp +++ b/include/Nazara/Utility/VideoMode.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index 657541c93..32487370a 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index 0fca50c4d..c81c89b80 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/WindowHandle.hpp b/include/Nazara/Utility/WindowHandle.hpp index 9b5e34c83..f49a400e0 100644 --- a/include/Nazara/Utility/WindowHandle.hpp +++ b/include/Nazara/Utility/WindowHandle.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/plugins/Assimp/CustomStream.cpp b/plugins/Assimp/CustomStream.cpp index 6dbdd90b6..04e8cddce 100644 --- a/plugins/Assimp/CustomStream.cpp +++ b/plugins/Assimp/CustomStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Assimp Plugin" // For conditions of distribution and use, see copyright notice in Plugin.cpp diff --git a/plugins/Assimp/CustomStream.hpp b/plugins/Assimp/CustomStream.hpp index 9cb155e7c..55197d05c 100644 --- a/plugins/Assimp/CustomStream.hpp +++ b/plugins/Assimp/CustomStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Assimp Plugin" // For conditions of distribution and use, see copyright notice in Plugin.cpp diff --git a/src/Nazara/Audio/Audio.cpp b/src/Nazara/Audio/Audio.cpp index 6eaa86c39..08ff28198 100644 --- a/src/Nazara/Audio/Audio.cpp +++ b/src/Nazara/Audio/Audio.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Debug/NewOverload.cpp b/src/Nazara/Audio/Debug/NewOverload.cpp index 359db9756..85431a7a0 100644 --- a/src/Nazara/Audio/Debug/NewOverload.cpp +++ b/src/Nazara/Audio/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Formats/sndfileLoader.cpp b/src/Nazara/Audio/Formats/sndfileLoader.cpp index 055e3b6a6..25c30e4ad 100644 --- a/src/Nazara/Audio/Formats/sndfileLoader.cpp +++ b/src/Nazara/Audio/Formats/sndfileLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Formats/sndfileLoader.hpp b/src/Nazara/Audio/Formats/sndfileLoader.hpp index 01576d5a3..724b5a5fe 100644 --- a/src/Nazara/Audio/Formats/sndfileLoader.hpp +++ b/src/Nazara/Audio/Formats/sndfileLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index b2b0e7e3b..cdfe4caac 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/OpenAL.cpp b/src/Nazara/Audio/OpenAL.cpp index 489855022..755a68a0b 100644 --- a/src/Nazara/Audio/OpenAL.cpp +++ b/src/Nazara/Audio/OpenAL.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Sound.cpp b/src/Nazara/Audio/Sound.cpp index 3e2e27faa..87e15ee2c 100644 --- a/src/Nazara/Audio/Sound.cpp +++ b/src/Nazara/Audio/Sound.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/SoundBuffer.cpp b/src/Nazara/Audio/SoundBuffer.cpp index 4b2b0410e..2888710f1 100644 --- a/src/Nazara/Audio/SoundBuffer.cpp +++ b/src/Nazara/Audio/SoundBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/SoundEmitter.cpp b/src/Nazara/Audio/SoundEmitter.cpp index 840c4f47d..4492771f4 100644 --- a/src/Nazara/Audio/SoundEmitter.cpp +++ b/src/Nazara/Audio/SoundEmitter.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/SoundStream.cpp b/src/Nazara/Audio/SoundStream.cpp index 88bc0069b..eec87ccc1 100644 --- a/src/Nazara/Audio/SoundStream.cpp +++ b/src/Nazara/Audio/SoundStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/AbstractHash.cpp b/src/Nazara/Core/AbstractHash.cpp index 419ba74e9..ae2cb63b5 100644 --- a/src/Nazara/Core/AbstractHash.cpp +++ b/src/Nazara/Core/AbstractHash.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/AbstractLogger.cpp b/src/Nazara/Core/AbstractLogger.cpp index a1bf859a7..4ae945c0a 100644 --- a/src/Nazara/Core/AbstractLogger.cpp +++ b/src/Nazara/Core/AbstractLogger.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/AlgorithmCore.cpp b/src/Nazara/Core/AlgorithmCore.cpp index 1a9d8a171..6d6b09b80 100644 --- a/src/Nazara/Core/AlgorithmCore.cpp +++ b/src/Nazara/Core/AlgorithmCore.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ByteArray.cpp b/src/Nazara/Core/ByteArray.cpp index 592170e40..4402af91d 100644 --- a/src/Nazara/Core/ByteArray.cpp +++ b/src/Nazara/Core/ByteArray.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ByteStream.cpp b/src/Nazara/Core/ByteStream.cpp index bc52f1782..489f90338 100644 --- a/src/Nazara/Core/ByteStream.cpp +++ b/src/Nazara/Core/ByteStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Clock.cpp b/src/Nazara/Core/Clock.cpp index 60482b18e..881d7c40e 100644 --- a/src/Nazara/Core/Clock.cpp +++ b/src/Nazara/Core/Clock.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Color.cpp b/src/Nazara/Core/Color.cpp index 35128a38d..d87ab5cc6 100644 --- a/src/Nazara/Core/Color.cpp +++ b/src/Nazara/Core/Color.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ConditionVariable.cpp b/src/Nazara/Core/ConditionVariable.cpp index 0730ea829..86ecb11ed 100644 --- a/src/Nazara/Core/ConditionVariable.cpp +++ b/src/Nazara/Core/ConditionVariable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Core.cpp b/src/Nazara/Core/Core.cpp index 026e4a247..4a27bd482 100644 --- a/src/Nazara/Core/Core.cpp +++ b/src/Nazara/Core/Core.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Debug/NewOverload.cpp b/src/Nazara/Core/Debug/NewOverload.cpp index 1638b4918..95b2fc888 100644 --- a/src/Nazara/Core/Debug/NewOverload.cpp +++ b/src/Nazara/Core/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Debug/NewRedefinition.cpp b/src/Nazara/Core/Debug/NewRedefinition.cpp index 73a467e5c..77aa93b00 100644 --- a/src/Nazara/Core/Debug/NewRedefinition.cpp +++ b/src/Nazara/Core/Debug/NewRedefinition.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Directory.cpp b/src/Nazara/Core/Directory.cpp index b48930419..1470a0f3d 100644 --- a/src/Nazara/Core/Directory.cpp +++ b/src/Nazara/Core/Directory.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/DynLib.cpp b/src/Nazara/Core/DynLib.cpp index 515f437b4..10e5d4247 100644 --- a/src/Nazara/Core/DynLib.cpp +++ b/src/Nazara/Core/DynLib.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Error.cpp b/src/Nazara/Core/Error.cpp index 8de5e5747..1e50d87fb 100644 --- a/src/Nazara/Core/Error.cpp +++ b/src/Nazara/Core/Error.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ErrorFlags.cpp b/src/Nazara/Core/ErrorFlags.cpp index 003e37a23..01cc6fbcf 100644 --- a/src/Nazara/Core/ErrorFlags.cpp +++ b/src/Nazara/Core/ErrorFlags.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 35706fb70..9aa9374e0 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/FileLogger.cpp b/src/Nazara/Core/FileLogger.cpp index f08bd1b31..6dadfdcf1 100644 --- a/src/Nazara/Core/FileLogger.cpp +++ b/src/Nazara/Core/FileLogger.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/GuillotineBinPack.cpp b/src/Nazara/Core/GuillotineBinPack.cpp index e43e07572..0f74bab5b 100644 --- a/src/Nazara/Core/GuillotineBinPack.cpp +++ b/src/Nazara/Core/GuillotineBinPack.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/HardwareInfo.cpp b/src/Nazara/Core/HardwareInfo.cpp index baef7c2f3..a4bec3194 100644 --- a/src/Nazara/Core/HardwareInfo.cpp +++ b/src/Nazara/Core/HardwareInfo.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/CRC32.cpp b/src/Nazara/Core/Hash/CRC32.cpp index a7d0a87dc..db4a52634 100644 --- a/src/Nazara/Core/Hash/CRC32.cpp +++ b/src/Nazara/Core/Hash/CRC32.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/Fletcher16.cpp b/src/Nazara/Core/Hash/Fletcher16.cpp index 447a7ed3b..d1d563aca 100644 --- a/src/Nazara/Core/Hash/Fletcher16.cpp +++ b/src/Nazara/Core/Hash/Fletcher16.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/MD5.cpp b/src/Nazara/Core/Hash/MD5.cpp index 53082d4cc..769ccb1a8 100644 --- a/src/Nazara/Core/Hash/MD5.cpp +++ b/src/Nazara/Core/Hash/MD5.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA/Internal.cpp b/src/Nazara/Core/Hash/SHA/Internal.cpp index ad5b1d30c..91d6d5e9c 100644 --- a/src/Nazara/Core/Hash/SHA/Internal.cpp +++ b/src/Nazara/Core/Hash/SHA/Internal.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA/Internal.hpp b/src/Nazara/Core/Hash/SHA/Internal.hpp index 711cec4bb..35171eeb9 100644 --- a/src/Nazara/Core/Hash/SHA/Internal.hpp +++ b/src/Nazara/Core/Hash/SHA/Internal.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA1.cpp b/src/Nazara/Core/Hash/SHA1.cpp index 6550d343d..6ba573a10 100644 --- a/src/Nazara/Core/Hash/SHA1.cpp +++ b/src/Nazara/Core/Hash/SHA1.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA224.cpp b/src/Nazara/Core/Hash/SHA224.cpp index d071e9345..0cf5e8777 100644 --- a/src/Nazara/Core/Hash/SHA224.cpp +++ b/src/Nazara/Core/Hash/SHA224.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA256.cpp b/src/Nazara/Core/Hash/SHA256.cpp index 9b5f56983..fec15b074 100644 --- a/src/Nazara/Core/Hash/SHA256.cpp +++ b/src/Nazara/Core/Hash/SHA256.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA384.cpp b/src/Nazara/Core/Hash/SHA384.cpp index 3f647260e..7fdb85ea9 100644 --- a/src/Nazara/Core/Hash/SHA384.cpp +++ b/src/Nazara/Core/Hash/SHA384.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA512.cpp b/src/Nazara/Core/Hash/SHA512.cpp index af56d937a..27812fdb7 100644 --- a/src/Nazara/Core/Hash/SHA512.cpp +++ b/src/Nazara/Core/Hash/SHA512.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/Whirlpool.cpp b/src/Nazara/Core/Hash/Whirlpool.cpp index c3e7380ae..12b3e2a1b 100644 --- a/src/Nazara/Core/Hash/Whirlpool.cpp +++ b/src/Nazara/Core/Hash/Whirlpool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Log.cpp b/src/Nazara/Core/Log.cpp index 1ff1ea373..b3dfed34a 100644 --- a/src/Nazara/Core/Log.cpp +++ b/src/Nazara/Core/Log.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/MemoryManager.cpp b/src/Nazara/Core/MemoryManager.cpp index 3a4883bec..2c4034623 100644 --- a/src/Nazara/Core/MemoryManager.cpp +++ b/src/Nazara/Core/MemoryManager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/MemoryStream.cpp b/src/Nazara/Core/MemoryStream.cpp index a2fb7ff2b..fb5d8ca93 100644 --- a/src/Nazara/Core/MemoryStream.cpp +++ b/src/Nazara/Core/MemoryStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/MemoryView.cpp b/src/Nazara/Core/MemoryView.cpp index e501a031f..0d69b7a53 100644 --- a/src/Nazara/Core/MemoryView.cpp +++ b/src/Nazara/Core/MemoryView.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Mutex.cpp b/src/Nazara/Core/Mutex.cpp index 68c94a8cf..953568ecc 100644 --- a/src/Nazara/Core/Mutex.cpp +++ b/src/Nazara/Core/Mutex.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index bda37b4d4..5206dd333 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/PluginManager.cpp b/src/Nazara/Core/PluginManager.cpp index b71af6677..2a7fa8eee 100644 --- a/src/Nazara/Core/PluginManager.cpp +++ b/src/Nazara/Core/PluginManager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/PrimitiveList.cpp b/src/Nazara/Core/PrimitiveList.cpp index a8d406b94..038ebe98e 100644 --- a/src/Nazara/Core/PrimitiveList.cpp +++ b/src/Nazara/Core/PrimitiveList.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/RefCounted.cpp b/src/Nazara/Core/RefCounted.cpp index 31e749515..9532e5d86 100644 --- a/src/Nazara/Core/RefCounted.cpp +++ b/src/Nazara/Core/RefCounted.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Resource.cpp b/src/Nazara/Core/Resource.cpp index 82ef768d1..efd8a4eb6 100644 --- a/src/Nazara/Core/Resource.cpp +++ b/src/Nazara/Core/Resource.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Semaphore.cpp b/src/Nazara/Core/Semaphore.cpp index 1b2194095..e4a52b43f 100644 --- a/src/Nazara/Core/Semaphore.cpp +++ b/src/Nazara/Core/Semaphore.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/SerializationContext.cpp b/src/Nazara/Core/SerializationContext.cpp index 734b3b23d..e1665a416 100644 --- a/src/Nazara/Core/SerializationContext.cpp +++ b/src/Nazara/Core/SerializationContext.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/StdLogger.cpp b/src/Nazara/Core/StdLogger.cpp index c8dfc60bb..9fb14c140 100644 --- a/src/Nazara/Core/StdLogger.cpp +++ b/src/Nazara/Core/StdLogger.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Stream.cpp b/src/Nazara/Core/Stream.cpp index f82591fed..afc213814 100644 --- a/src/Nazara/Core/Stream.cpp +++ b/src/Nazara/Core/Stream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index b0ff09ed1..a0bca5d64 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/StringStream.cpp b/src/Nazara/Core/StringStream.cpp index 0b27077e5..d39b3afb8 100644 --- a/src/Nazara/Core/StringStream.cpp +++ b/src/Nazara/Core/StringStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/TaskScheduler.cpp b/src/Nazara/Core/TaskScheduler.cpp index a29436407..fc14c5ea6 100644 --- a/src/Nazara/Core/TaskScheduler.cpp +++ b/src/Nazara/Core/TaskScheduler.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Thread.cpp b/src/Nazara/Core/Thread.cpp index 0c4cd8008..c9532ec19 100644 --- a/src/Nazara/Core/Thread.cpp +++ b/src/Nazara/Core/Thread.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Unicode.cpp b/src/Nazara/Core/Unicode.cpp index 0f6dd8452..cec6dbba8 100644 --- a/src/Nazara/Core/Unicode.cpp +++ b/src/Nazara/Core/Unicode.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Updatable.cpp b/src/Nazara/Core/Updatable.cpp index 3699b10a6..1ce56e3fd 100644 --- a/src/Nazara/Core/Updatable.cpp +++ b/src/Nazara/Core/Updatable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/ClockImpl.cpp b/src/Nazara/Core/Win32/ClockImpl.cpp index 311688d29..d78e7328c 100644 --- a/src/Nazara/Core/Win32/ClockImpl.cpp +++ b/src/Nazara/Core/Win32/ClockImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/ClockImpl.hpp b/src/Nazara/Core/Win32/ClockImpl.hpp index f1bcf8aaa..46411b68b 100644 --- a/src/Nazara/Core/Win32/ClockImpl.hpp +++ b/src/Nazara/Core/Win32/ClockImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/ConditionVariableImpl.cpp b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp index a387a7638..7cd5416a8 100644 --- a/src/Nazara/Core/Win32/ConditionVariableImpl.cpp +++ b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/ConditionVariableImpl.hpp b/src/Nazara/Core/Win32/ConditionVariableImpl.hpp index 469cf6099..36b559ff3 100644 --- a/src/Nazara/Core/Win32/ConditionVariableImpl.hpp +++ b/src/Nazara/Core/Win32/ConditionVariableImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/DirectoryImpl.cpp b/src/Nazara/Core/Win32/DirectoryImpl.cpp index 9901b9c10..824d81746 100644 --- a/src/Nazara/Core/Win32/DirectoryImpl.cpp +++ b/src/Nazara/Core/Win32/DirectoryImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/DirectoryImpl.hpp b/src/Nazara/Core/Win32/DirectoryImpl.hpp index 843587d52..141d4070c 100644 --- a/src/Nazara/Core/Win32/DirectoryImpl.hpp +++ b/src/Nazara/Core/Win32/DirectoryImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/DynLibImpl.cpp b/src/Nazara/Core/Win32/DynLibImpl.cpp index 0256e40fb..aa42fda18 100644 --- a/src/Nazara/Core/Win32/DynLibImpl.cpp +++ b/src/Nazara/Core/Win32/DynLibImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/DynLibImpl.hpp b/src/Nazara/Core/Win32/DynLibImpl.hpp index aa2a3a9c1..e61969e84 100644 --- a/src/Nazara/Core/Win32/DynLibImpl.hpp +++ b/src/Nazara/Core/Win32/DynLibImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/FileImpl.cpp b/src/Nazara/Core/Win32/FileImpl.cpp index 1fb5a19eb..b7c5d0f2d 100644 --- a/src/Nazara/Core/Win32/FileImpl.cpp +++ b/src/Nazara/Core/Win32/FileImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/FileImpl.hpp b/src/Nazara/Core/Win32/FileImpl.hpp index dabfc266c..000835f6f 100644 --- a/src/Nazara/Core/Win32/FileImpl.hpp +++ b/src/Nazara/Core/Win32/FileImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index 542c58d79..e1cdfaf50 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.hpp b/src/Nazara/Core/Win32/HardwareInfoImpl.hpp index 3f923cfdd..f876cefb9 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.hpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/MutexImpl.cpp b/src/Nazara/Core/Win32/MutexImpl.cpp index 0dcce2aa3..7c4e18f34 100644 --- a/src/Nazara/Core/Win32/MutexImpl.cpp +++ b/src/Nazara/Core/Win32/MutexImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/MutexImpl.hpp b/src/Nazara/Core/Win32/MutexImpl.hpp index 8f5ad9010..ac9717846 100644 --- a/src/Nazara/Core/Win32/MutexImpl.hpp +++ b/src/Nazara/Core/Win32/MutexImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/SemaphoreImpl.cpp b/src/Nazara/Core/Win32/SemaphoreImpl.cpp index 31c329f2e..19bc17c74 100644 --- a/src/Nazara/Core/Win32/SemaphoreImpl.cpp +++ b/src/Nazara/Core/Win32/SemaphoreImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/SemaphoreImpl.hpp b/src/Nazara/Core/Win32/SemaphoreImpl.hpp index ac60cab1b..a78b2328f 100644 --- a/src/Nazara/Core/Win32/SemaphoreImpl.hpp +++ b/src/Nazara/Core/Win32/SemaphoreImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp index ef83e4b28..3aba937e4 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp index aabd58b86..59dc79c73 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/ThreadImpl.cpp b/src/Nazara/Core/Win32/ThreadImpl.cpp index 2d62b860d..5b44b94b6 100644 --- a/src/Nazara/Core/Win32/ThreadImpl.cpp +++ b/src/Nazara/Core/Win32/ThreadImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/ThreadImpl.hpp b/src/Nazara/Core/Win32/ThreadImpl.hpp index d036c124c..12e7f5c14 100644 --- a/src/Nazara/Core/Win32/ThreadImpl.hpp +++ b/src/Nazara/Core/Win32/ThreadImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/Time.cpp b/src/Nazara/Core/Win32/Time.cpp index 9ed58bc46..2fab92eb3 100644 --- a/src/Nazara/Core/Win32/Time.cpp +++ b/src/Nazara/Core/Win32/Time.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/Time.hpp b/src/Nazara/Core/Win32/Time.hpp index a0ba7da36..9ad8a7aa6 100644 --- a/src/Nazara/Core/Win32/Time.hpp +++ b/src/Nazara/Core/Win32/Time.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/AbstractBackground.cpp b/src/Nazara/Graphics/AbstractBackground.cpp index 28d0f0d4f..5d1f23a6d 100644 --- a/src/Nazara/Graphics/AbstractBackground.cpp +++ b/src/Nazara/Graphics/AbstractBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/AbstractRenderQueue.cpp b/src/Nazara/Graphics/AbstractRenderQueue.cpp index 1346e37ff..c623b218f 100644 --- a/src/Nazara/Graphics/AbstractRenderQueue.cpp +++ b/src/Nazara/Graphics/AbstractRenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/AbstractRenderTechnique.cpp b/src/Nazara/Graphics/AbstractRenderTechnique.cpp index 9872178cf..8a33b7b46 100644 --- a/src/Nazara/Graphics/AbstractRenderTechnique.cpp +++ b/src/Nazara/Graphics/AbstractRenderTechnique.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/AbstractViewer.cpp b/src/Nazara/Graphics/AbstractViewer.cpp index bd8752bc7..e83737baa 100644 --- a/src/Nazara/Graphics/AbstractViewer.cpp +++ b/src/Nazara/Graphics/AbstractViewer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index 4aed923ae..c4382eefb 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ColorBackground.cpp b/src/Nazara/Graphics/ColorBackground.cpp index dcacb1a46..52653a8e7 100644 --- a/src/Nazara/Graphics/ColorBackground.cpp +++ b/src/Nazara/Graphics/ColorBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Debug/NewOverload.cpp b/src/Nazara/Graphics/Debug/NewOverload.cpp index 6c5b5c8f0..b79e8408e 100644 --- a/src/Nazara/Graphics/Debug/NewOverload.cpp +++ b/src/Nazara/Graphics/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index 643024ead..e51543641 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredDOFPass.cpp b/src/Nazara/Graphics/DeferredDOFPass.cpp index b39085400..9760ff300 100644 --- a/src/Nazara/Graphics/DeferredDOFPass.cpp +++ b/src/Nazara/Graphics/DeferredDOFPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredFXAAPass.cpp b/src/Nazara/Graphics/DeferredFXAAPass.cpp index d4ba72ddf..fa2d80d46 100644 --- a/src/Nazara/Graphics/DeferredFXAAPass.cpp +++ b/src/Nazara/Graphics/DeferredFXAAPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredFinalPass.cpp b/src/Nazara/Graphics/DeferredFinalPass.cpp index c4ab348eb..228e9d035 100644 --- a/src/Nazara/Graphics/DeferredFinalPass.cpp +++ b/src/Nazara/Graphics/DeferredFinalPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredFogPass.cpp b/src/Nazara/Graphics/DeferredFogPass.cpp index f47a4ea56..c6fbfddf9 100644 --- a/src/Nazara/Graphics/DeferredFogPass.cpp +++ b/src/Nazara/Graphics/DeferredFogPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredForwardPass.cpp b/src/Nazara/Graphics/DeferredForwardPass.cpp index ed7ad45d1..55780708f 100644 --- a/src/Nazara/Graphics/DeferredForwardPass.cpp +++ b/src/Nazara/Graphics/DeferredForwardPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index c6c6c59ed..6d5883c48 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index 8f83f9a6b..2eff9abc9 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredRenderPass.cpp b/src/Nazara/Graphics/DeferredRenderPass.cpp index 280f6658c..c4c265b58 100644 --- a/src/Nazara/Graphics/DeferredRenderPass.cpp +++ b/src/Nazara/Graphics/DeferredRenderPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 6aecb8a5a..22ead6ec0 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredRenderTechnique.cpp b/src/Nazara/Graphics/DeferredRenderTechnique.cpp index 45c8bf7c3..01a0d1fa8 100644 --- a/src/Nazara/Graphics/DeferredRenderTechnique.cpp +++ b/src/Nazara/Graphics/DeferredRenderTechnique.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index fbc24bb19..46096e33f 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 3f0d76379..d58975d7f 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Drawable.cpp b/src/Nazara/Graphics/Drawable.cpp index 7db121225..79df17ef1 100644 --- a/src/Nazara/Graphics/Drawable.cpp +++ b/src/Nazara/Graphics/Drawable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Formats/MeshLoader.cpp b/src/Nazara/Graphics/Formats/MeshLoader.cpp index 38f836e90..ad5d58736 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.cpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Formats/MeshLoader.hpp b/src/Nazara/Graphics/Formats/MeshLoader.hpp index db2a08bac..215e19c44 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.hpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Formats/TextureLoader.cpp b/src/Nazara/Graphics/Formats/TextureLoader.cpp index 7530726fb..d3667a945 100644 --- a/src/Nazara/Graphics/Formats/TextureLoader.cpp +++ b/src/Nazara/Graphics/Formats/TextureLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Formats/TextureLoader.hpp b/src/Nazara/Graphics/Formats/TextureLoader.hpp index 7d071c050..f068aeb5d 100644 --- a/src/Nazara/Graphics/Formats/TextureLoader.hpp +++ b/src/Nazara/Graphics/Formats/TextureLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 6c6915214..8eb70fe7e 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 2e8f3e12f..c0493e74b 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index 8f5427718..e1b202716 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp index 7c2122281..0699b7fcf 100644 --- a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp +++ b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index e927e2d22..5eb0f17fa 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Light.cpp b/src/Nazara/Graphics/Light.cpp index 275d78a79..a2b188006 100644 --- a/src/Nazara/Graphics/Light.cpp +++ b/src/Nazara/Graphics/Light.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index d833a601d..df871f9f2 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 388de632e..761bc500f 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index d382c77d9..a8e277d68 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleController.cpp b/src/Nazara/Graphics/ParticleController.cpp index d46bb1621..ab94bae69 100644 --- a/src/Nazara/Graphics/ParticleController.cpp +++ b/src/Nazara/Graphics/ParticleController.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index 60786c1f1..63b329aa4 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index 038e69ce9..89811dd53 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleFunctionController.cpp b/src/Nazara/Graphics/ParticleFunctionController.cpp index 9b300f450..0519d08cc 100644 --- a/src/Nazara/Graphics/ParticleFunctionController.cpp +++ b/src/Nazara/Graphics/ParticleFunctionController.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleFunctionGenerator.cpp b/src/Nazara/Graphics/ParticleFunctionGenerator.cpp index 67d43770d..649fc1c12 100644 --- a/src/Nazara/Graphics/ParticleFunctionGenerator.cpp +++ b/src/Nazara/Graphics/ParticleFunctionGenerator.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleFunctionRenderer.cpp b/src/Nazara/Graphics/ParticleFunctionRenderer.cpp index 36dfea3df..779dc4e6d 100644 --- a/src/Nazara/Graphics/ParticleFunctionRenderer.cpp +++ b/src/Nazara/Graphics/ParticleFunctionRenderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleGenerator.cpp b/src/Nazara/Graphics/ParticleGenerator.cpp index 304a99e8c..edb745e99 100644 --- a/src/Nazara/Graphics/ParticleGenerator.cpp +++ b/src/Nazara/Graphics/ParticleGenerator.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index f2c46d91c..08743a58e 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleMapper.cpp b/src/Nazara/Graphics/ParticleMapper.cpp index 27a4b4075..05932abaa 100644 --- a/src/Nazara/Graphics/ParticleMapper.cpp +++ b/src/Nazara/Graphics/ParticleMapper.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleRenderer.cpp b/src/Nazara/Graphics/ParticleRenderer.cpp index e5fa56c74..9195d05ae 100644 --- a/src/Nazara/Graphics/ParticleRenderer.cpp +++ b/src/Nazara/Graphics/ParticleRenderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/RenderTechniques.cpp b/src/Nazara/Graphics/RenderTechniques.cpp index 8298245b7..5dc3c66cd 100644 --- a/src/Nazara/Graphics/RenderTechniques.cpp +++ b/src/Nazara/Graphics/RenderTechniques.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Renderable.cpp b/src/Nazara/Graphics/Renderable.cpp index 5b02cd5cb..28a487209 100644 --- a/src/Nazara/Graphics/Renderable.cpp +++ b/src/Nazara/Graphics/Renderable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/SkeletalModel.cpp b/src/Nazara/Graphics/SkeletalModel.cpp index b91ac0076..b571cb9dc 100644 --- a/src/Nazara/Graphics/SkeletalModel.cpp +++ b/src/Nazara/Graphics/SkeletalModel.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/SkinningManager.cpp b/src/Nazara/Graphics/SkinningManager.cpp index 7391eeea6..3472238b9 100644 --- a/src/Nazara/Graphics/SkinningManager.cpp +++ b/src/Nazara/Graphics/SkinningManager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/SkyboxBackground.cpp b/src/Nazara/Graphics/SkyboxBackground.cpp index 4a646bdbe..0a2459b7f 100644 --- a/src/Nazara/Graphics/SkyboxBackground.cpp +++ b/src/Nazara/Graphics/SkyboxBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index d23fe4122..04e648991 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 5b3eb2cf6..70975929f 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/TextureBackground.cpp b/src/Nazara/Graphics/TextureBackground.cpp index a990f4af6..cd6c68c05 100644 --- a/src/Nazara/Graphics/TextureBackground.cpp +++ b/src/Nazara/Graphics/TextureBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp index ab035a7e4..7fe358fb8 100644 --- a/src/Nazara/Graphics/TileMap.cpp +++ b/src/Nazara/Graphics/TileMap.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Lua/Debug/NewOverload.cpp b/src/Nazara/Lua/Debug/NewOverload.cpp index e7cf94bd6..8c83e037e 100644 --- a/src/Nazara/Lua/Debug/NewOverload.cpp +++ b/src/Nazara/Lua/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Lua/Lua.cpp b/src/Nazara/Lua/Lua.cpp index 9b53443e7..83ec20a86 100644 --- a/src/Nazara/Lua/Lua.cpp +++ b/src/Nazara/Lua/Lua.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 5162645b2..5e23d0a86 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/AbstractSocket.cpp b/src/Nazara/Network/AbstractSocket.cpp index 516364373..03b27c57f 100644 --- a/src/Nazara/Network/AbstractSocket.cpp +++ b/src/Nazara/Network/AbstractSocket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/AlgorithmNetwork.cpp b/src/Nazara/Network/AlgorithmNetwork.cpp index 307ac679a..4538230f3 100644 --- a/src/Nazara/Network/AlgorithmNetwork.cpp +++ b/src/Nazara/Network/AlgorithmNetwork.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Debug/NewOverload.cpp b/src/Nazara/Network/Debug/NewOverload.cpp index 80be1880c..b6d707ee5 100644 --- a/src/Nazara/Network/Debug/NewOverload.cpp +++ b/src/Nazara/Network/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/IpAddress.cpp b/src/Nazara/Network/IpAddress.cpp index 29be756ea..fc63be189 100644 --- a/src/Nazara/Network/IpAddress.cpp +++ b/src/Nazara/Network/IpAddress.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/NetPacket.cpp b/src/Nazara/Network/NetPacket.cpp index 900170b89..0dda7c864 100644 --- a/src/Nazara/Network/NetPacket.cpp +++ b/src/Nazara/Network/NetPacket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Network.cpp b/src/Nazara/Network/Network.cpp index 3e798e681..57ddfd83b 100644 --- a/src/Nazara/Network/Network.cpp +++ b/src/Nazara/Network/Network.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/RUdpConnection.cpp b/src/Nazara/Network/RUdpConnection.cpp index 1b374d604..f704b9568 100644 --- a/src/Nazara/Network/RUdpConnection.cpp +++ b/src/Nazara/Network/RUdpConnection.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/SocketPoller.cpp b/src/Nazara/Network/SocketPoller.cpp index 049970433..fa5aa837e 100644 --- a/src/Nazara/Network/SocketPoller.cpp +++ b/src/Nazara/Network/SocketPoller.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/SystemSocket.hpp b/src/Nazara/Network/SystemSocket.hpp index 95b7dff37..df71c43c7 100644 --- a/src/Nazara/Network/SystemSocket.hpp +++ b/src/Nazara/Network/SystemSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index 2be3d44cf..b5fd845ee 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/TcpServer.cpp b/src/Nazara/Network/TcpServer.cpp index 7a33c066b..95aaaf098 100644 --- a/src/Nazara/Network/TcpServer.cpp +++ b/src/Nazara/Network/TcpServer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/UdpSocket.cpp b/src/Nazara/Network/UdpSocket.cpp index b49aedcf3..679922513 100644 --- a/src/Nazara/Network/UdpSocket.cpp +++ b/src/Nazara/Network/UdpSocket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 2dac156ce..992b075a9 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/IpAddressImpl.hpp b/src/Nazara/Network/Win32/IpAddressImpl.hpp index e85dc7411..3415906d9 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.hpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 5a02b4bae..9606da500 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/SocketImpl.hpp b/src/Nazara/Network/Win32/SocketImpl.hpp index 94e2e9a8c..f7c278a41 100644 --- a/src/Nazara/Network/Win32/SocketImpl.hpp +++ b/src/Nazara/Network/Win32/SocketImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp index dd80c233d..292e8dfa5 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.hpp b/src/Nazara/Network/Win32/SocketPollerImpl.hpp index a8a45a7de..0a745878d 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.hpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/Debug/NewOverload.cpp b/src/Nazara/Noise/Debug/NewOverload.cpp index 1e2da7321..d761e94b8 100644 --- a/src/Nazara/Noise/Debug/NewOverload.cpp +++ b/src/Nazara/Noise/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/FBM.cpp b/src/Nazara/Noise/FBM.cpp index 96126ec60..95d79c2cd 100644 --- a/src/Nazara/Noise/FBM.cpp +++ b/src/Nazara/Noise/FBM.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/HybridMultiFractal.cpp b/src/Nazara/Noise/HybridMultiFractal.cpp index 4278d23b2..86ae2e9cd 100644 --- a/src/Nazara/Noise/HybridMultiFractal.cpp +++ b/src/Nazara/Noise/HybridMultiFractal.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/MixerBase.cpp b/src/Nazara/Noise/MixerBase.cpp index d3dd82acc..f3fbc0f8a 100644 --- a/src/Nazara/Noise/MixerBase.cpp +++ b/src/Nazara/Noise/MixerBase.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/Noise.cpp b/src/Nazara/Noise/Noise.cpp index 6cfad09c1..880527834 100644 --- a/src/Nazara/Noise/Noise.cpp +++ b/src/Nazara/Noise/Noise.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/NoiseBase.cpp b/src/Nazara/Noise/NoiseBase.cpp index 1dc74595a..0a4f09505 100644 --- a/src/Nazara/Noise/NoiseBase.cpp +++ b/src/Nazara/Noise/NoiseBase.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/NoiseTools.cpp b/src/Nazara/Noise/NoiseTools.cpp index 9cf6efd39..5f6274357 100644 --- a/src/Nazara/Noise/NoiseTools.cpp +++ b/src/Nazara/Noise/NoiseTools.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/Perlin.cpp b/src/Nazara/Noise/Perlin.cpp index a400972ff..9d0249759 100644 --- a/src/Nazara/Noise/Perlin.cpp +++ b/src/Nazara/Noise/Perlin.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/Simplex.cpp b/src/Nazara/Noise/Simplex.cpp index b1a2bd0b6..d73465c70 100644 --- a/src/Nazara/Noise/Simplex.cpp +++ b/src/Nazara/Noise/Simplex.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Noise/Worley.cpp b/src/Nazara/Noise/Worley.cpp index 4f2aa90f7..81fd8aad0 100644 --- a/src/Nazara/Noise/Worley.cpp +++ b/src/Nazara/Noise/Worley.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Rémi Bèges +// Copyright (C) 2017 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/Collider2D.cpp b/src/Nazara/Physics2D/Collider2D.cpp index 986a03ccf..928ea3974 100644 --- a/src/Nazara/Physics2D/Collider2D.cpp +++ b/src/Nazara/Physics2D/Collider2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/Debug/NewOverload.cpp b/src/Nazara/Physics2D/Debug/NewOverload.cpp index 0c82acc94..0bbef36d9 100644 --- a/src/Nazara/Physics2D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics2D/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 878a84400..62d194e9b 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/Physics2D.cpp b/src/Nazara/Physics2D/Physics2D.cpp index 840b14755..f6acdb152 100644 --- a/src/Nazara/Physics2D/Physics2D.cpp +++ b/src/Nazara/Physics2D/Physics2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 9fdb34d50..9078749b3 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index 7cddffdbe..d71f4caa8 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/Debug/NewOverload.cpp b/src/Nazara/Physics3D/Debug/NewOverload.cpp index b87984066..da675a56f 100644 --- a/src/Nazara/Physics3D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics3D/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/PhysWorld3D.cpp b/src/Nazara/Physics3D/PhysWorld3D.cpp index c6990f635..be2677ef6 100644 --- a/src/Nazara/Physics3D/PhysWorld3D.cpp +++ b/src/Nazara/Physics3D/PhysWorld3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/Physics3D.cpp b/src/Nazara/Physics3D/Physics3D.cpp index 8fb470f2a..033d13374 100644 --- a/src/Nazara/Physics3D/Physics3D.cpp +++ b/src/Nazara/Physics3D/Physics3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/RigidBody3D.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp index 5051fa143..9a909f98f 100644 --- a/src/Nazara/Physics3D/RigidBody3D.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp index 69919d094..acc57006e 100644 --- a/src/Nazara/Renderer/Context.cpp +++ b/src/Nazara/Renderer/Context.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/ContextParameters.cpp b/src/Nazara/Renderer/ContextParameters.cpp index 9f85bc662..cdb087561 100644 --- a/src/Nazara/Renderer/ContextParameters.cpp +++ b/src/Nazara/Renderer/ContextParameters.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Debug/NewOverload.cpp b/src/Nazara/Renderer/Debug/NewOverload.cpp index 6ef952271..1a198d979 100644 --- a/src/Nazara/Renderer/Debug/NewOverload.cpp +++ b/src/Nazara/Renderer/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp index 9f06c880f..9357d17f9 100644 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ b/src/Nazara/Renderer/DebugDrawer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/GpuQuery.cpp b/src/Nazara/Renderer/GpuQuery.cpp index 4e7ff228f..ce3235e63 100644 --- a/src/Nazara/Renderer/GpuQuery.cpp +++ b/src/Nazara/Renderer/GpuQuery.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/HardwareBuffer.cpp b/src/Nazara/Renderer/HardwareBuffer.cpp index d7b5219b4..52bc339c2 100644 --- a/src/Nazara/Renderer/HardwareBuffer.cpp +++ b/src/Nazara/Renderer/HardwareBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/HardwareBuffer.hpp b/src/Nazara/Renderer/HardwareBuffer.hpp index 15a629c8b..d9cb26368 100644 --- a/src/Nazara/Renderer/HardwareBuffer.hpp +++ b/src/Nazara/Renderer/HardwareBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index af4d16d28..455247952 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp index b6b182ab8..56e20da55 100644 --- a/src/Nazara/Renderer/RenderBuffer.cpp +++ b/src/Nazara/Renderer/RenderBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderTarget.cpp b/src/Nazara/Renderer/RenderTarget.cpp index 717c7497a..c028fc028 100644 --- a/src/Nazara/Renderer/RenderTarget.cpp +++ b/src/Nazara/Renderer/RenderTarget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index d90ba5f1a..aa32dd447 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index 61131d9f1..61c299bf7 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index a5140c7ec..39405c38b 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Shader.cpp b/src/Nazara/Renderer/Shader.cpp index 65deb8b3b..5b9c95cab 100644 --- a/src/Nazara/Renderer/Shader.cpp +++ b/src/Nazara/Renderer/Shader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/ShaderStage.cpp b/src/Nazara/Renderer/ShaderStage.cpp index 771a2ced1..98f863d59 100644 --- a/src/Nazara/Renderer/ShaderStage.cpp +++ b/src/Nazara/Renderer/ShaderStage.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index 458fb9992..9feb83de1 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/TextureSampler.cpp b/src/Nazara/Renderer/TextureSampler.cpp index bd09a943f..ec3b25dd7 100644 --- a/src/Nazara/Renderer/TextureSampler.cpp +++ b/src/Nazara/Renderer/TextureSampler.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/UberShader.cpp b/src/Nazara/Renderer/UberShader.cpp index 18a3c11fe..81afe85d9 100644 --- a/src/Nazara/Renderer/UberShader.cpp +++ b/src/Nazara/Renderer/UberShader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/UberShaderInstance.cpp b/src/Nazara/Renderer/UberShaderInstance.cpp index ec7043542..cef1c517e 100644 --- a/src/Nazara/Renderer/UberShaderInstance.cpp +++ b/src/Nazara/Renderer/UberShaderInstance.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp b/src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp index 166645528..5a6413212 100644 --- a/src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp +++ b/src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/UberShaderPreprocessor.cpp b/src/Nazara/Renderer/UberShaderPreprocessor.cpp index b7adc03ee..6f838d6cf 100644 --- a/src/Nazara/Renderer/UberShaderPreprocessor.cpp +++ b/src/Nazara/Renderer/UberShaderPreprocessor.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Win32/ContextImpl.cpp b/src/Nazara/Renderer/Win32/ContextImpl.cpp index 2f7094f70..e99e672dc 100644 --- a/src/Nazara/Renderer/Win32/ContextImpl.cpp +++ b/src/Nazara/Renderer/Win32/ContextImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Win32/ContextImpl.hpp b/src/Nazara/Renderer/Win32/ContextImpl.hpp index 0e5c7cbc9..b9ac2c460 100644 --- a/src/Nazara/Renderer/Win32/ContextImpl.hpp +++ b/src/Nazara/Renderer/Win32/ContextImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AbstractAtlas.cpp b/src/Nazara/Utility/AbstractAtlas.cpp index 555b0beae..10e4d286f 100644 --- a/src/Nazara/Utility/AbstractAtlas.cpp +++ b/src/Nazara/Utility/AbstractAtlas.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AbstractBuffer.cpp b/src/Nazara/Utility/AbstractBuffer.cpp index e7bd5ce19..aa550c5a5 100644 --- a/src/Nazara/Utility/AbstractBuffer.cpp +++ b/src/Nazara/Utility/AbstractBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AbstractImage.cpp b/src/Nazara/Utility/AbstractImage.cpp index adf50d5ae..f539605f1 100644 --- a/src/Nazara/Utility/AbstractImage.cpp +++ b/src/Nazara/Utility/AbstractImage.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AbstractTextDrawer.cpp b/src/Nazara/Utility/AbstractTextDrawer.cpp index c6eb131ae..563c8bf57 100644 --- a/src/Nazara/Utility/AbstractTextDrawer.cpp +++ b/src/Nazara/Utility/AbstractTextDrawer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index 90a3d53e3..d37d02f96 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index a996f85a5..eb53424fe 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Buffer.cpp b/src/Nazara/Utility/Buffer.cpp index 4e589b938..e65488d28 100644 --- a/src/Nazara/Utility/Buffer.cpp +++ b/src/Nazara/Utility/Buffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Cursor.cpp b/src/Nazara/Utility/Cursor.cpp index 115eefe0e..e8b3e0b21 100644 --- a/src/Nazara/Utility/Cursor.cpp +++ b/src/Nazara/Utility/Cursor.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Debug/NewOverload.cpp b/src/Nazara/Utility/Debug/NewOverload.cpp index 00dc7f90c..18bca9315 100644 --- a/src/Nazara/Utility/Debug/NewOverload.cpp +++ b/src/Nazara/Utility/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Font.cpp b/src/Nazara/Utility/Font.cpp index b5914aa58..63cc28495 100644 --- a/src/Nazara/Utility/Font.cpp +++ b/src/Nazara/Utility/Font.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/FontData.cpp b/src/Nazara/Utility/FontData.cpp index b9be6b8e7..00480ec9f 100644 --- a/src/Nazara/Utility/FontData.cpp +++ b/src/Nazara/Utility/FontData.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/DDSConstants.cpp b/src/Nazara/Utility/Formats/DDSConstants.cpp index 3c078475f..0fda7ac16 100644 --- a/src/Nazara/Utility/Formats/DDSConstants.cpp +++ b/src/Nazara/Utility/Formats/DDSConstants.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/DDSLoader.cpp b/src/Nazara/Utility/Formats/DDSLoader.cpp index 1e707e610..ad2ff9969 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.cpp +++ b/src/Nazara/Utility/Formats/DDSLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq - 2009 Cruden BV +// Copyright (C) 2017 Jérôme Leclercq - 2009 Cruden BV // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/DDSLoader.hpp b/src/Nazara/Utility/Formats/DDSLoader.hpp index 8027d1356..dd524fd04 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.hpp +++ b/src/Nazara/Utility/Formats/DDSLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp index aed76d608..f6ab78b1d 100644 --- a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp +++ b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq - 2009 Cruden BV +// Copyright (C) 2017 Jérôme Leclercq - 2009 Cruden BV // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/FreeTypeLoader.hpp b/src/Nazara/Utility/Formats/FreeTypeLoader.hpp index a88e2adae..f7775fca5 100644 --- a/src/Nazara/Utility/Formats/FreeTypeLoader.hpp +++ b/src/Nazara/Utility/Formats/FreeTypeLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD2Constants.cpp b/src/Nazara/Utility/Formats/MD2Constants.cpp index f80cb0b2c..f381689ec 100644 --- a/src/Nazara/Utility/Formats/MD2Constants.cpp +++ b/src/Nazara/Utility/Formats/MD2Constants.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD2Constants.hpp b/src/Nazara/Utility/Formats/MD2Constants.hpp index 694f15dae..deb16757d 100644 --- a/src/Nazara/Utility/Formats/MD2Constants.hpp +++ b/src/Nazara/Utility/Formats/MD2Constants.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index c28a12de0..76ee1c1ea 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD2Loader.hpp b/src/Nazara/Utility/Formats/MD2Loader.hpp index 3fdafd4d0..98a405600 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.hpp +++ b/src/Nazara/Utility/Formats/MD2Loader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp index e263ceef3..026c9e5d7 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.hpp b/src/Nazara/Utility/Formats/MD5AnimLoader.hpp index b1691ee6b..610d0d53f 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.hpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5AnimParser.cpp b/src/Nazara/Utility/Formats/MD5AnimParser.cpp index a1b02153b..5930fe5a3 100644 --- a/src/Nazara/Utility/Formats/MD5AnimParser.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimParser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index 26aef0a1f..0168e4ffe 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.hpp b/src/Nazara/Utility/Formats/MD5MeshLoader.hpp index 02b63d0ff..b59d57998 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.hpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5MeshParser.cpp b/src/Nazara/Utility/Formats/MD5MeshParser.cpp index ce5264d01..470e9a41a 100644 --- a/src/Nazara/Utility/Formats/MD5MeshParser.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshParser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index c3b60a6e5..894f20f02 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 2371e18fd..951892085 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJLoader.hpp b/src/Nazara/Utility/Formats/OBJLoader.hpp index 46dd8d976..dbbeaa6bc 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.hpp +++ b/src/Nazara/Utility/Formats/OBJLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index eed0ee2b1..ab1cbdbfb 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 761432473..513f28ff7 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJSaver.hpp b/src/Nazara/Utility/Formats/OBJSaver.hpp index ed909f165..3647a317c 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.hpp +++ b/src/Nazara/Utility/Formats/OBJSaver.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/PCXLoader.cpp b/src/Nazara/Utility/Formats/PCXLoader.cpp index 1dc7622bd..bb0e1b43b 100644 --- a/src/Nazara/Utility/Formats/PCXLoader.cpp +++ b/src/Nazara/Utility/Formats/PCXLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/PCXLoader.hpp b/src/Nazara/Utility/Formats/PCXLoader.hpp index 6ef8d86c1..be3574026 100644 --- a/src/Nazara/Utility/Formats/PCXLoader.hpp +++ b/src/Nazara/Utility/Formats/PCXLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/STBLoader.cpp b/src/Nazara/Utility/Formats/STBLoader.cpp index 3ca5b3708..83b9880dd 100644 --- a/src/Nazara/Utility/Formats/STBLoader.cpp +++ b/src/Nazara/Utility/Formats/STBLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/STBLoader.hpp b/src/Nazara/Utility/Formats/STBLoader.hpp index 03e08c72f..4b94f84e9 100644 --- a/src/Nazara/Utility/Formats/STBLoader.hpp +++ b/src/Nazara/Utility/Formats/STBLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/STBSaver.cpp b/src/Nazara/Utility/Formats/STBSaver.cpp index 26c6067fe..0e2f31e3f 100644 --- a/src/Nazara/Utility/Formats/STBSaver.cpp +++ b/src/Nazara/Utility/Formats/STBSaver.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/STBSaver.hpp b/src/Nazara/Utility/Formats/STBSaver.hpp index 9a511c07e..e1bbbe3e1 100644 --- a/src/Nazara/Utility/Formats/STBSaver.hpp +++ b/src/Nazara/Utility/Formats/STBSaver.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/GuillotineImageAtlas.cpp b/src/Nazara/Utility/GuillotineImageAtlas.cpp index b3e630921..74cff70db 100644 --- a/src/Nazara/Utility/GuillotineImageAtlas.cpp +++ b/src/Nazara/Utility/GuillotineImageAtlas.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Icon.cpp b/src/Nazara/Utility/Icon.cpp index 21a39142f..843e64456 100644 --- a/src/Nazara/Utility/Icon.cpp +++ b/src/Nazara/Utility/Icon.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index 39d99cdd1..bdfe57007 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/IndexBuffer.cpp b/src/Nazara/Utility/IndexBuffer.cpp index 90090aabe..ed49535cd 100644 --- a/src/Nazara/Utility/IndexBuffer.cpp +++ b/src/Nazara/Utility/IndexBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/IndexMapper.cpp b/src/Nazara/Utility/IndexMapper.cpp index 5a664128c..7ddcd9a08 100644 --- a/src/Nazara/Utility/IndexMapper.cpp +++ b/src/Nazara/Utility/IndexMapper.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Joint.cpp b/src/Nazara/Utility/Joint.cpp index 4bd040faa..5d3a3796c 100644 --- a/src/Nazara/Utility/Joint.cpp +++ b/src/Nazara/Utility/Joint.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Keyboard.cpp b/src/Nazara/Utility/Keyboard.cpp index fb0bb05a5..08f4b05a7 100644 --- a/src/Nazara/Utility/Keyboard.cpp +++ b/src/Nazara/Utility/Keyboard.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 32db98e24..27c1bd186 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Mouse.cpp b/src/Nazara/Utility/Mouse.cpp index 24cec91f7..b25ce2506 100644 --- a/src/Nazara/Utility/Mouse.cpp +++ b/src/Nazara/Utility/Mouse.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Node.cpp b/src/Nazara/Utility/Node.cpp index 8754ab320..2832df42d 100644 --- a/src/Nazara/Utility/Node.cpp +++ b/src/Nazara/Utility/Node.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index 77f6bdbb2..8bfe461e3 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index cdf6f8ceb..1b8c41653 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/SkeletalMesh.cpp b/src/Nazara/Utility/SkeletalMesh.cpp index 0f81ac189..e866c0d33 100644 --- a/src/Nazara/Utility/SkeletalMesh.cpp +++ b/src/Nazara/Utility/SkeletalMesh.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Skeleton.cpp b/src/Nazara/Utility/Skeleton.cpp index 70f7adb07..7d33ad9bd 100644 --- a/src/Nazara/Utility/Skeleton.cpp +++ b/src/Nazara/Utility/Skeleton.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/SoftwareBuffer.cpp b/src/Nazara/Utility/SoftwareBuffer.cpp index 2f69e02ac..6dce1fc6a 100644 --- a/src/Nazara/Utility/SoftwareBuffer.cpp +++ b/src/Nazara/Utility/SoftwareBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/StaticMesh.cpp b/src/Nazara/Utility/StaticMesh.cpp index 6c6056864..a1a25f3d7 100644 --- a/src/Nazara/Utility/StaticMesh.cpp +++ b/src/Nazara/Utility/StaticMesh.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index c8da223f0..9607052fb 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/TriangleIterator.cpp b/src/Nazara/Utility/TriangleIterator.cpp index 53086ddb8..68f65c0db 100644 --- a/src/Nazara/Utility/TriangleIterator.cpp +++ b/src/Nazara/Utility/TriangleIterator.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 3234869ad..c6e87e0bb 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/VertexBuffer.cpp b/src/Nazara/Utility/VertexBuffer.cpp index bd3073427..371ba2efa 100644 --- a/src/Nazara/Utility/VertexBuffer.cpp +++ b/src/Nazara/Utility/VertexBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 945888406..51160ab3f 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/VertexMapper.cpp b/src/Nazara/Utility/VertexMapper.cpp index 158dae801..43a96a89a 100644 --- a/src/Nazara/Utility/VertexMapper.cpp +++ b/src/Nazara/Utility/VertexMapper.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/VideoMode.cpp b/src/Nazara/Utility/VideoMode.cpp index 2c6a2f321..7d1f3beec 100644 --- a/src/Nazara/Utility/VideoMode.cpp +++ b/src/Nazara/Utility/VideoMode.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/VideoModeImpl.hpp b/src/Nazara/Utility/VideoModeImpl.hpp index 7baeb6478..e5c5c0118 100644 --- a/src/Nazara/Utility/VideoModeImpl.hpp +++ b/src/Nazara/Utility/VideoModeImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/CursorImpl.cpp b/src/Nazara/Utility/Win32/CursorImpl.cpp index c4c43a6f1..c2fff0a40 100644 --- a/src/Nazara/Utility/Win32/CursorImpl.cpp +++ b/src/Nazara/Utility/Win32/CursorImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/CursorImpl.hpp b/src/Nazara/Utility/Win32/CursorImpl.hpp index c6899ed46..a8f82377c 100644 --- a/src/Nazara/Utility/Win32/CursorImpl.hpp +++ b/src/Nazara/Utility/Win32/CursorImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/IconImpl.cpp b/src/Nazara/Utility/Win32/IconImpl.cpp index 0fdbe087b..19e7fffb0 100644 --- a/src/Nazara/Utility/Win32/IconImpl.cpp +++ b/src/Nazara/Utility/Win32/IconImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/IconImpl.hpp b/src/Nazara/Utility/Win32/IconImpl.hpp index d3539d9f3..7ba9acc7a 100644 --- a/src/Nazara/Utility/Win32/IconImpl.hpp +++ b/src/Nazara/Utility/Win32/IconImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/InputImpl.cpp b/src/Nazara/Utility/Win32/InputImpl.cpp index ba604deb8..e250ae8be 100644 --- a/src/Nazara/Utility/Win32/InputImpl.cpp +++ b/src/Nazara/Utility/Win32/InputImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/InputImpl.hpp b/src/Nazara/Utility/Win32/InputImpl.hpp index b2a0a9302..e91bfd889 100644 --- a/src/Nazara/Utility/Win32/InputImpl.hpp +++ b/src/Nazara/Utility/Win32/InputImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/VideoModeImpl.cpp b/src/Nazara/Utility/Win32/VideoModeImpl.cpp index ab9fe3430..95a964790 100644 --- a/src/Nazara/Utility/Win32/VideoModeImpl.cpp +++ b/src/Nazara/Utility/Win32/VideoModeImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/VideoModeImpl.hpp b/src/Nazara/Utility/Win32/VideoModeImpl.hpp index 722553305..460cec364 100644 --- a/src/Nazara/Utility/Win32/VideoModeImpl.hpp +++ b/src/Nazara/Utility/Win32/VideoModeImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index 74f6fb62b..c9e94876e 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Win32/WindowImpl.hpp b/src/Nazara/Utility/Win32/WindowImpl.hpp index 36ba5d93b..83056f825 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.hpp +++ b/src/Nazara/Utility/Win32/WindowImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index a6a6d381d..3130c6641 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/X11/ScopedXCB.inl b/src/Nazara/Utility/X11/ScopedXCB.inl index 8b2710a10..d9881b9af 100644 --- a/src/Nazara/Utility/X11/ScopedXCB.inl +++ b/src/Nazara/Utility/X11/ScopedXCB.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp From 18862fd1ba3812057c1b0a1ac9e36d127de6e419 Mon Sep 17 00:00:00 2001 From: DrLynix Date: Fri, 20 Jan 2017 13:02:19 +0100 Subject: [PATCH 055/243] Forgot to save those two files --- SDK/src/NDK/Lua/LuaBinding_SDK.cpp | 2 +- include/Nazara/Network/RUdpConnection.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp index 415188014..0de791f85 100644 --- a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot +// Copyright (C) 2017 Jérôme Leclercq, Arnaud Cadot // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/include/Nazara/Network/RUdpConnection.hpp b/include/Nazara/Network/RUdpConnection.hpp index 6166d787a..3cdb6c3be 100644 --- a/include/Nazara/Network/RUdpConnection.hpp +++ b/include/Nazara/Network/RUdpConnection.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp From 85f02086901bbe0ef6ad6f7a1b5f243d3dd8362c Mon Sep 17 00:00:00 2001 From: DrLynix Date: Fri, 20 Jan 2017 14:33:05 +0100 Subject: [PATCH 056/243] Newtork/AbstractSocket: Allow to specify receive and send buffer size per socket --- include/Nazara/Network/AbstractSocket.hpp | 7 +- src/Nazara/Network/AbstractSocket.cpp | 48 ++++++++++++- src/Nazara/Network/Posix/SocketImpl.cpp | 86 +++++++++++++++++++++-- src/Nazara/Network/Posix/SocketImpl.hpp | 4 ++ src/Nazara/Network/Win32/SocketImpl.cpp | 82 ++++++++++++++++++++- src/Nazara/Network/Win32/SocketImpl.hpp | 6 +- 6 files changed, 222 insertions(+), 11 deletions(-) diff --git a/include/Nazara/Network/AbstractSocket.hpp b/include/Nazara/Network/AbstractSocket.hpp index d137c9050..8a2e55e25 100644 --- a/include/Nazara/Network/AbstractSocket.hpp +++ b/include/Nazara/Network/AbstractSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -34,6 +34,11 @@ namespace Nz inline bool IsBlockingEnabled() const; std::size_t QueryAvailableBytes() const; + std::size_t QueryReceiveBufferSize() const; + std::size_t QuerySendBufferSize() const; + + void SetReceiveBufferSize(std::size_t size); + void SetSendBufferSize(std::size_t size); AbstractSocket& operator=(const AbstractSocket&) = delete; AbstractSocket& operator=(AbstractSocket&& abstractSocket); diff --git a/src/Nazara/Network/AbstractSocket.cpp b/src/Nazara/Network/AbstractSocket.cpp index 03b27c57f..f562900d2 100644 --- a/src/Nazara/Network/AbstractSocket.cpp +++ b/src/Nazara/Network/AbstractSocket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -111,6 +111,52 @@ namespace Nz return SocketImpl::QueryAvailableBytes(m_handle); } + /*! + * \brief Queries the maximum socket receive buffer size + * \return The size of the receive buffer in bytes. + */ + std::size_t AbstractSocket::QueryReceiveBufferSize() const + { + if (m_handle == SocketImpl::InvalidHandle) + return 0; + + return SocketImpl::QueryReceiveBufferSize(m_handle); + } + + /*! + * \brief Queries the maximum socket send buffer size + * \return The size of the send buffer in bytes. + */ + std::size_t AbstractSocket::QuerySendBufferSize() const + { + if (m_handle == SocketImpl::InvalidHandle) + return 0; + + return SocketImpl::QuerySendBufferSize(m_handle); + } + + /*! + * \brief Sets the maximum receive buffer size + * + * \param size The new maximum receive buffer size in bytes + */ + void AbstractSocket::SetReceiveBufferSize(std::size_t size) + { + if (m_handle != SocketImpl::InvalidHandle) + SocketImpl::SetReceiveBufferSize(m_handle, size); + } + + /*! + * \brief Sets the maximum send buffer size + * + * \param size The new maximum send buffer size in bytes + */ + void AbstractSocket::SetSendBufferSize(std::size_t size) + { + if (m_handle != SocketImpl::InvalidHandle) + SocketImpl::SetSendBufferSize(m_handle, size); + } + /*! * \brief Operation to do when closing socket */ diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 954ac4f43..69f0d0bf3 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -277,7 +277,7 @@ namespace Nz bool SocketImpl::QueryBroadcasting(SocketHandle handle, SocketError* error) { bool code; - unsigned int codeLength = sizeof(code); + socklen_t codeLength = sizeof(code); if (getsockopt(handle, SOL_SOCKET, SO_BROADCAST, &code, &codeLength) == SOCKET_ERROR) { @@ -296,7 +296,7 @@ namespace Nz bool SocketImpl::QueryKeepAlive(SocketHandle handle, SocketError* error) { bool code; - unsigned int codeLength = sizeof(code); + socklen_t codeLength = sizeof(code); if (getsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &code, &codeLength) == SOCKET_ERROR) { @@ -315,14 +315,14 @@ namespace Nz std::size_t SocketImpl::QueryMaxDatagramSize(SocketHandle handle, SocketError* error) { unsigned int code; - unsigned int codeLength = sizeof(code); + socklen_t codeLength = sizeof(code); if (getsockopt(handle, IPPROTO_IP, IP_MTU, &code, &codeLength) == SOCKET_ERROR) { if (error) *error = TranslateErrnoToResolveError(GetLastErrorCode()); - return -1; + return 0; } if (error) @@ -334,7 +334,7 @@ namespace Nz bool SocketImpl::QueryNoDelay(SocketHandle handle, SocketError* error) { bool code; - unsigned int codeLength = sizeof(code); + socklen_t codeLength = sizeof(code); if (getsockopt(handle, IPPROTO_TCP, TCP_NODELAY, &code, &codeLength) == SOCKET_ERROR) { @@ -350,6 +350,25 @@ namespace Nz return code; } + std::size_t SocketImpl::QueryReceiveBufferSize(SocketHandle handle, SocketError* error) + { + unsigned int code; + socklen_t codeLength = sizeof(code); + + if (getsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&code), &codeLength) == SOCKET_ERROR) + { + if (error) + *error = TranslateErrnoToResolveError(GetLastErrorCode()); + + return 0; + } + + if (error) + *error = SocketError_NoError; + + return code; + } + IpAddress SocketImpl::QueryPeerAddress(SocketHandle handle, SocketError* error) { NazaraAssert(handle != InvalidHandle, "Invalid handle"); @@ -371,6 +390,25 @@ namespace Nz return IpAddressImpl::FromSockAddr(reinterpret_cast(nameBuffer.data())); } + std::size_t SocketImpl::QuerySendBufferSize(SocketHandle handle, SocketError* error) + { + unsigned int code; + socklen_t codeLength = sizeof(code); + + if (getsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&code), &codeLength) == SOCKET_ERROR) + { + if (error) + *error = TranslateErrnoToResolveError(GetLastErrorCode()); + + return 0; + } + + if (error) + *error = SocketError_NoError; + + return code; + } + IpAddress SocketImpl::QuerySocketAddress(SocketHandle handle, SocketError* error) { NazaraAssert(handle != InvalidHandle, "Invalid handle"); @@ -659,6 +697,44 @@ namespace Nz return true; } + bool SocketImpl::SetReceiveBufferSize(SocketHandle handle, std::size_t size, SocketError* error) + { + NazaraAssert(handle != InvalidHandle, "Invalid handle"); + + int option = static_cast(size); + if (setsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&option), sizeof(option)) == SOCKET_ERROR) + { + if (error) + *error = TranslateErrnoToResolveError(GetLastErrorCode()); + + return false; //< Error + } + + if (error) + *error = SocketError_NoError; + + return true; + } + + bool SocketImpl::SetSendBufferSize(SocketHandle handle, std::size_t size, SocketError* error) + { + NazaraAssert(handle != InvalidHandle, "Invalid handle"); + + int option = static_cast(size); + if (setsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&option), sizeof(option)) == SOCKET_ERROR) + { + if (error) + *error = TranslateErrnoToResolveError(GetLastErrorCode()); + + return false; //< Error + } + + if (error) + *error = SocketError_NoError; + + return true; + } + SocketError SocketImpl::TranslateErrnoToResolveError(int error) { switch (error) diff --git a/src/Nazara/Network/Posix/SocketImpl.hpp b/src/Nazara/Network/Posix/SocketImpl.hpp index c120bd19a..a543d8880 100644 --- a/src/Nazara/Network/Posix/SocketImpl.hpp +++ b/src/Nazara/Network/Posix/SocketImpl.hpp @@ -55,6 +55,8 @@ namespace Nz static bool QueryNoDelay(SocketHandle handle, SocketError* error = nullptr); static IpAddress QueryPeerAddress(SocketHandle handle, SocketError* error = nullptr); static IpAddress QuerySocketAddress(SocketHandle handle, SocketError* error = nullptr); + static std::size_t QueryReceiveBufferSize(SocketHandle handle, SocketError* error = nullptr); + static std::size_t QuerySendBufferSize(SocketHandle handle, SocketError* error = nullptr); static int Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error); @@ -68,6 +70,8 @@ namespace Nz static bool SetBroadcasting(SocketHandle handle, bool broadcasting, SocketError* error = nullptr); static bool SetKeepAlive(SocketHandle handle, bool enabled, UInt64 msTime, UInt64 msInterval, SocketError* error = nullptr); static bool SetNoDelay(SocketHandle handle, bool nodelay, SocketError* error = nullptr); + static bool SetReceiveBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr); + static bool SetSendBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr); static SocketError TranslateErrnoToResolveError(int error); static int TranslateNetProtocolToAF(NetProtocol protocol); diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 9606da500..74550fe37 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -331,7 +331,7 @@ namespace Nz std::size_t SocketImpl::QueryMaxDatagramSize(SocketHandle handle, SocketError* error) { - unsigned int code; + DWORD code; int codeLength = sizeof(code); if (getsockopt(handle, SOL_SOCKET, SO_MAX_MSG_SIZE, reinterpret_cast(&code), &codeLength) == SOCKET_ERROR) @@ -339,7 +339,7 @@ namespace Nz if (error) *error = TranslateWSAErrorToSocketError(WSAGetLastError()); - return -1; + return 0; } if (error) @@ -367,6 +367,25 @@ namespace Nz return code == TRUE; } + std::size_t SocketImpl::QueryReceiveBufferSize(SocketHandle handle, SocketError* error) + { + DWORD code; + int codeLength = sizeof(code); + + if (getsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&code), &codeLength) == SOCKET_ERROR) + { + if (error) + *error = TranslateWSAErrorToSocketError(WSAGetLastError()); + + return 0; + } + + if (error) + *error = SocketError_NoError; + + return code; + } + IpAddress SocketImpl::QueryPeerAddress(SocketHandle handle, SocketError* error) { NazaraAssert(handle != InvalidHandle, "Invalid handle"); @@ -415,6 +434,25 @@ namespace Nz return IpAddressImpl::FromSockAddr(reinterpret_cast(nameBuffer.data())); } + std::size_t SocketImpl::QuerySendBufferSize(SocketHandle handle, SocketError* error) + { + DWORD code; + int codeLength = sizeof(code); + + if (getsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&code), &codeLength) == SOCKET_ERROR) + { + if (error) + *error = TranslateWSAErrorToSocketError(WSAGetLastError()); + + return 0; + } + + if (error) + *error = SocketError_NoError; + + return code; + } + int SocketImpl::Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error) { NazaraAssert(fdarray && nfds > 0, "Invalid fdarray"); @@ -677,6 +715,44 @@ namespace Nz return true; } + bool SocketImpl::SetReceiveBufferSize(SocketHandle handle, std::size_t size, SocketError* error) + { + NazaraAssert(handle != InvalidHandle, "Invalid handle"); + + DWORD option = size; + if (setsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&option), sizeof(option)) == SOCKET_ERROR) + { + if (error) + *error = TranslateWSAErrorToSocketError(WSAGetLastError()); + + return false; //< Error + } + + if (error) + *error = SocketError_NoError; + + return true; + } + + bool SocketImpl::SetSendBufferSize(SocketHandle handle, std::size_t size, SocketError* error) + { + NazaraAssert(handle != InvalidHandle, "Invalid handle"); + + DWORD option = size; + if (setsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&option), sizeof(option)) == SOCKET_ERROR) + { + if (error) + *error = TranslateWSAErrorToSocketError(WSAGetLastError()); + + return false; //< Error + } + + if (error) + *error = SocketError_NoError; + + return true; + } + SocketError SocketImpl::TranslateWSAErrorToSocketError(int error) { switch (error) diff --git a/src/Nazara/Network/Win32/SocketImpl.hpp b/src/Nazara/Network/Win32/SocketImpl.hpp index f7c278a41..5af2b2534 100644 --- a/src/Nazara/Network/Win32/SocketImpl.hpp +++ b/src/Nazara/Network/Win32/SocketImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -54,8 +54,10 @@ namespace Nz static bool QueryKeepAlive(SocketHandle handle, SocketError* error = nullptr); static std::size_t QueryMaxDatagramSize(SocketHandle handle, SocketError* error = nullptr); static bool QueryNoDelay(SocketHandle handle, SocketError* error = nullptr); + static std::size_t QueryReceiveBufferSize(SocketHandle handle, SocketError* error = nullptr); static IpAddress QueryPeerAddress(SocketHandle handle, SocketError* error = nullptr); static IpAddress QuerySocketAddress(SocketHandle handle, SocketError* error = nullptr); + static std::size_t QuerySendBufferSize(SocketHandle handle, SocketError* error = nullptr); static int Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error); @@ -69,6 +71,8 @@ namespace Nz static bool SetBroadcasting(SocketHandle handle, bool broadcasting, SocketError* error = nullptr); static bool SetKeepAlive(SocketHandle handle, bool enabled, UInt64 msTime, UInt64 msInterval, SocketError* error = nullptr); static bool SetNoDelay(SocketHandle handle, bool nodelay, SocketError* error = nullptr); + static bool SetReceiveBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr); + static bool SetSendBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr); static SocketError TranslateWSAErrorToSocketError(int error); static int TranslateNetProtocolToAF(NetProtocol protocol); From f8357526b902467dff41c791fc3e9287b777938c Mon Sep 17 00:00:00 2001 From: DrLynix Date: Fri, 20 Jan 2017 17:55:08 +0100 Subject: [PATCH 057/243] Update .gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d455ab7a9..c3b787c86 100644 --- a/.gitignore +++ b/.gitignore @@ -15,12 +15,14 @@ examples/bin/*.exe examples/bin/*.pdb examples/bin/*.dll examples/bin/*.so +examples/bin/Demo* # Unit tests tests/*.exe tests/*.pdb tests/*.dll tests/*.so +tests/NazaraUnitTests* # Example generated files examples/bin/HardwareInfo.txt @@ -49,6 +51,7 @@ build/**/*.project # GMake build/**/*.make +build/**/*.d # Visual Studio build/**/*.pdb @@ -60,7 +63,7 @@ build/**/*.vcxprojResolveAssemblyReference.cache build/**/*.nativecodeanalysis.all.xml build/**/*.nativecodeanalysis.xml build/**/*.VC.opendb -build/**/*.VC.db +build/**/*.VC.db* # Compiled Object files build/**/*.slo From bb3f39531915a8362456fae3f602b7b34aeef218 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 20 Jan 2017 19:40:54 +0100 Subject: [PATCH 058/243] Revert "Spoilers.." This reverts commit e00d00931c0e4bca55d4a4894e98e77df2eba2fd. --- SDK/src/NDK/BaseWidget.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 4d7f12fa8..c4ef2d1f8 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -76,6 +76,14 @@ namespace Ndk } } + void BaseWidget::SetCursor(Nz::SystemCursor systemCursor) + { + m_cursor = systemCursor; + + if (IsRegisteredToCanvas()) + m_canvas->NotifyWidgetCursorUpdate(m_canvasIndex); + } + void BaseWidget::SetSize(const Nz::Vector2f& size) { SetContentSize({std::max(size.x - m_padding.left - m_padding.right, 0.f), std::max(size.y - m_padding.top - m_padding.bottom, 0.f)}); @@ -120,7 +128,7 @@ namespace Ndk void BaseWidget::Layout() { if (IsRegisteredToCanvas()) - m_canvas->NotifyWidgetUpdate(m_canvasIndex); + m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex); if (m_backgroundEntity) m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); @@ -131,7 +139,7 @@ namespace Ndk Node::InvalidateNode(); if (IsRegisteredToCanvas()) - m_canvas->NotifyWidgetUpdate(m_canvasIndex); + m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex); } void BaseWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) From cf286e0413decd613ffed8a45be3dd9fca2256d9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 20 Jan 2017 20:03:00 +0100 Subject: [PATCH 059/243] Sdk/Widgets: Add possibility to set cursor when mouse hover a widget --- SDK/include/NDK/BaseWidget.hpp | 4 ++++ SDK/include/NDK/BaseWidget.inl | 6 ++++++ SDK/include/NDK/Canvas.hpp | 8 ++++++-- SDK/include/NDK/Canvas.inl | 23 ++++++++++++++++++++++- SDK/src/NDK/Canvas.cpp | 19 ++++++++----------- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 2 ++ 6 files changed, 48 insertions(+), 14 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 5022ade61..723e93e80 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ namespace Ndk inline const Nz::Color& GetBackgroundColor() const; inline Canvas* GetCanvas(); + inline Nz::SystemCursor GetCursor() const; inline const Padding& GetPadding() const; inline Nz::Vector2f GetContentOrigin() const; inline const Nz::Vector2f& GetContentSize() const; @@ -58,6 +60,7 @@ namespace Ndk virtual void ResizeToContent() = 0; void SetBackgroundColor(const Nz::Color& color); + void SetCursor(Nz::SystemCursor systemCursor); inline void SetContentSize(const Nz::Vector2f& size); inline void SetPadding(float left, float top, float right, float bottom); void SetSize(const Nz::Vector2f& size); @@ -113,6 +116,7 @@ namespace Ndk WorldHandle m_world; Nz::Color m_backgroundColor; Nz::SpriteRef m_backgroundSprite; + Nz::SystemCursor m_cursor; Nz::Vector2f m_contentSize; BaseWidget* m_widgetParent; bool m_visible; diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 9134b3c32..63b71a942 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -12,6 +12,7 @@ namespace Ndk m_canvasIndex(InvalidCanvasIndex), m_backgroundColor(Nz::Color(230, 230, 230, 255)), m_canvas(nullptr), + m_cursor(Nz::SystemCursor_Default), m_contentSize(50.f, 50.f), m_widgetParent(nullptr), m_visible(true) @@ -54,6 +55,11 @@ namespace Ndk return m_canvas; } + inline Nz::SystemCursor BaseWidget::GetCursor() const + { + return m_cursor; + } + inline const BaseWidget::Padding& BaseWidget::GetPadding() const { return m_padding; diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NDK/Canvas.hpp index f3ba31705..0cc314b73 100644 --- a/SDK/include/NDK/Canvas.hpp +++ b/SDK/include/NDK/Canvas.hpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace Ndk @@ -20,7 +21,7 @@ namespace Ndk public: struct Padding; - inline Canvas(WorldHandle world, Nz::EventHandler& eventHandler); + inline Canvas(WorldHandle world, Nz::EventHandler& eventHandler, Nz::CursorControllerHandle cursorController); Canvas(const Canvas&) = delete; Canvas(Canvas&&) = delete; inline ~Canvas(); @@ -33,7 +34,8 @@ namespace Ndk Canvas& operator=(Canvas&&) = delete; protected: - void NotifyWidgetUpdate(std::size_t index); + inline void NotifyWidgetBoxUpdate(std::size_t index); + inline void NotifyWidgetCursorUpdate(std::size_t index); std::size_t RegisterWidget(BaseWidget* widget); @@ -54,6 +56,7 @@ namespace Ndk { BaseWidget* widget; Nz::Boxf box; + Nz::SystemCursor cursor; }; NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot); @@ -65,6 +68,7 @@ namespace Ndk NazaraSlot(Nz::EventHandler, OnTextEntered, m_textEnteredSlot); std::vector m_widgetBoxes; + Nz::CursorControllerHandle m_cursorController; const WidgetBox* m_hoveredWidget; BaseWidget* m_keyboardOwner; WorldHandle m_world; diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index 9ad38b852..3dd5de87f 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -3,10 +3,12 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include namespace Ndk { - inline Canvas::Canvas(WorldHandle world, Nz::EventHandler& eventHandler) : + inline Canvas::Canvas(WorldHandle world, Nz::EventHandler& eventHandler, Nz::CursorControllerHandle cursorController) : + m_cursorController(cursorController), m_hoveredWidget(nullptr), m_keyboardOwner(nullptr), m_world(std::move(world)) @@ -44,6 +46,25 @@ namespace Ndk return m_world; } + inline void Canvas::NotifyWidgetBoxUpdate(std::size_t index) + { + WidgetBox& entry = m_widgetBoxes[index]; + + Nz::Vector3f pos = entry.widget->GetPosition(); + Nz::Vector2f size = entry.widget->GetContentSize(); + + entry.box.Set(pos.x, pos.y, pos.z, size.x, size.y, 1.f); + } + + inline void Canvas::NotifyWidgetCursorUpdate(std::size_t index) + { + WidgetBox& entry = m_widgetBoxes[index]; + + entry.cursor = entry.widget->GetCursor(); + if (m_cursorController && m_hoveredWidget == &entry) + m_cursorController->UpdateCursor(Nz::Cursor::Get(entry.cursor)); + } + inline void Ndk::Canvas::SetKeyboardOwner(BaseWidget* widget) { m_keyboardOwner = widget; diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index 4f72e73b1..84e4b5bd8 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -14,25 +14,16 @@ namespace Ndk { } - void Canvas::NotifyWidgetUpdate(std::size_t index) - { - WidgetBox& entry = m_widgetBoxes[index]; - - Nz::Vector3f pos = entry.widget->GetPosition(); - Nz::Vector2f size = entry.widget->GetContentSize(); - - entry.box.Set(pos.x, pos.y, pos.z, size.x, size.y, 1.f); - } - std::size_t Canvas::RegisterWidget(BaseWidget* widget) { WidgetBox box; + box.cursor = widget->GetCursor(); box.widget = widget; std::size_t index = m_widgetBoxes.size(); m_widgetBoxes.emplace_back(box); - NotifyWidgetUpdate(index); + NotifyWidgetBoxUpdate(index); return index; } @@ -109,6 +100,9 @@ namespace Ndk m_hoveredWidget = bestEntry; m_hoveredWidget->widget->OnMouseEnter(); + + if (m_cursorController) + m_cursorController->UpdateCursor(Nz::Cursor::Get(m_hoveredWidget->cursor)); } int x = static_cast(std::round(event.x - m_hoveredWidget->box.x)); @@ -120,6 +114,9 @@ namespace Ndk { m_hoveredWidget->widget->OnMouseExit(); m_hoveredWidget = nullptr; + + if (m_cursorController) + m_cursorController->UpdateCursor(Nz::Cursor::Get(Nz::SystemCursor_Default)); } } diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index a5a557f9f..53a9ffdb4 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -32,6 +32,8 @@ namespace Ndk m_textEntity->AddComponent().Attach(m_textSprite); m_textEntity->AddComponent().SetParent(this); + SetCursor(Nz::SystemCursor_Text); + Layout(); } From 174feda1e9cbbbace8a5f68cb4c8f03fcc872065 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 20 Jan 2017 20:03:17 +0100 Subject: [PATCH 060/243] Sdk/TextAreaWidget: Make cursor sprite black --- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 53a9ffdb4..932757621 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -18,7 +18,7 @@ namespace Ndk m_readOnly(false) { m_cursorSprite = Nz::Sprite::New(); - m_cursorSprite->SetColor(Nz::Color(192, 192, 192)); + m_cursorSprite->SetColor(Nz::Color::Black); m_cursorSprite->SetSize(1.f, float(m_drawer.GetFont()->GetSizeInfo(m_drawer.GetCharacterSize()).lineHeight)); m_cursorEntity = CreateEntity(); From a84110a5755b3e74062135b2b8d3ab9311a8dad1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 21 Jan 2017 20:31:53 +0100 Subject: [PATCH 061/243] Core/ObjectHandle: Fix operator<= --- include/Nazara/Core/ObjectHandle.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Core/ObjectHandle.hpp b/include/Nazara/Core/ObjectHandle.hpp index 66c6161e4..bf22734d3 100644 --- a/include/Nazara/Core/ObjectHandle.hpp +++ b/include/Nazara/Core/ObjectHandle.hpp @@ -69,7 +69,7 @@ namespace Nz template bool operator<(const T& lhs, const ObjectHandle& rhs); template bool operator<(const ObjectHandle& lhs, const T& rhs); - template bool operator<=(const ObjectHandle, const ObjectHandle& rhs); + template bool operator<=(const ObjectHandle&, const ObjectHandle& rhs); template bool operator<=(const T& lhs, const ObjectHandle& rhs); template bool operator<=(const ObjectHandle& lhs, const T& rhs); From 071147bf51ac19eda4b5909f3f7c178e6cf7f124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 23 Jan 2017 11:58:05 +0100 Subject: [PATCH 062/243] Network/AbstractSocket: Prevent querying/setting receive/send buffer size without opening the socket first --- include/Nazara/Network/UdpSocket.hpp | 2 +- src/Nazara/Network/AbstractSocket.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Network/UdpSocket.hpp b/include/Nazara/Network/UdpSocket.hpp index e6470e365..3c4abdfe7 100644 --- a/include/Nazara/Network/UdpSocket.hpp +++ b/include/Nazara/Network/UdpSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/AbstractSocket.cpp b/src/Nazara/Network/AbstractSocket.cpp index f562900d2..3b3d9cb56 100644 --- a/src/Nazara/Network/AbstractSocket.cpp +++ b/src/Nazara/Network/AbstractSocket.cpp @@ -117,8 +117,7 @@ namespace Nz */ std::size_t AbstractSocket::QueryReceiveBufferSize() const { - if (m_handle == SocketImpl::InvalidHandle) - return 0; + NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket must be created first"); return SocketImpl::QueryReceiveBufferSize(m_handle); } @@ -129,8 +128,7 @@ namespace Nz */ std::size_t AbstractSocket::QuerySendBufferSize() const { - if (m_handle == SocketImpl::InvalidHandle) - return 0; + NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket must be created first"); return SocketImpl::QuerySendBufferSize(m_handle); } @@ -142,8 +140,9 @@ namespace Nz */ void AbstractSocket::SetReceiveBufferSize(std::size_t size) { - if (m_handle != SocketImpl::InvalidHandle) - SocketImpl::SetReceiveBufferSize(m_handle, size); + NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket must be created first"); + + SocketImpl::SetReceiveBufferSize(m_handle, size); } /*! @@ -153,8 +152,9 @@ namespace Nz */ void AbstractSocket::SetSendBufferSize(std::size_t size) { - if (m_handle != SocketImpl::InvalidHandle) - SocketImpl::SetSendBufferSize(m_handle, size); + NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket must be created first"); + + SocketImpl::SetSendBufferSize(m_handle, size); } /*! From 28965b799e7ff35a60f18691e73f0bad9b8947ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 25 Jan 2017 15:53:25 +0100 Subject: [PATCH 063/243] Core/MemoryPool: Fix incorrect inlines --- include/Nazara/Core/MemoryPool.hpp | 8 +++++--- include/Nazara/Core/MemoryPool.inl | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Core/MemoryPool.hpp b/include/Nazara/Core/MemoryPool.hpp index bda0915fa..10f147f5c 100644 --- a/include/Nazara/Core/MemoryPool.hpp +++ b/include/Nazara/Core/MemoryPool.hpp @@ -22,12 +22,14 @@ namespace Nz ~MemoryPool() = default; void* Allocate(unsigned int size); + template void Delete(T* ptr); + void Free(void* ptr); - unsigned int GetBlockSize() const; - unsigned int GetFreeBlocks() const; - unsigned int GetSize() const; + inline unsigned int GetBlockSize() const; + inline unsigned int GetFreeBlocks() const; + inline unsigned int GetSize() const; template T* New(Args&&... args); diff --git a/include/Nazara/Core/MemoryPool.inl b/include/Nazara/Core/MemoryPool.inl index db0cbc648..41443e38b 100644 --- a/include/Nazara/Core/MemoryPool.inl +++ b/include/Nazara/Core/MemoryPool.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include #include @@ -95,9 +96,8 @@ namespace Nz * * \remark If ptr is null, nothing is done */ - template - inline void MemoryPool::Delete(T* ptr) + void MemoryPool::Delete(T* ptr) { if (ptr) { From 311e2a545dc00d6bef7deab9f30e53d132d3b86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 25 Jan 2017 15:54:13 +0100 Subject: [PATCH 064/243] Network/SocketPoller: Fix cases where EAGAIN is not the same as EWOULDBLOCK (Posix) --- src/Nazara/Network/Posix/SocketImpl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 69f0d0bf3..7d28e6785 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -465,6 +465,7 @@ namespace Nz int errorCode = GetLastErrorCode(); switch (errorCode) { + case EAGAIN: case EWOULDBLOCK: { // If we have no data and are not blocking, return true with 0 byte read From 9e3341a32ae61994aa5ce4646199dbddfc22ad16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 25 Jan 2017 15:55:07 +0100 Subject: [PATCH 065/243] Commit current work This is a temporary branch because I'm missing a USB drive, huehue --- include/Nazara/Network/ENetHost.hpp | 121 ++++ include/Nazara/Network/ENetHost.inl | 65 ++ include/Nazara/Network/ENetPacket.hpp | 78 +++ include/Nazara/Network/ENetPeer.hpp | 205 ++++++ include/Nazara/Network/ENetPeer.inl | 29 + include/Nazara/Network/ENetProtocol.hpp | 272 ++++++++ src/Nazara/Network/ENetHost.cpp | 743 ++++++++++++++++++++ src/Nazara/Network/ENetPacket.cpp | 23 + src/Nazara/Network/ENetPeer.cpp | 885 ++++++++++++++++++++++++ src/Nazara/Network/ENetSocket.cpp | 642 +++++++++++++++++ 10 files changed, 3063 insertions(+) create mode 100644 include/Nazara/Network/ENetHost.hpp create mode 100644 include/Nazara/Network/ENetHost.inl create mode 100644 include/Nazara/Network/ENetPacket.hpp create mode 100644 include/Nazara/Network/ENetPeer.hpp create mode 100644 include/Nazara/Network/ENetPeer.inl create mode 100644 include/Nazara/Network/ENetProtocol.hpp create mode 100644 src/Nazara/Network/ENetHost.cpp create mode 100644 src/Nazara/Network/ENetPacket.cpp create mode 100644 src/Nazara/Network/ENetPeer.cpp create mode 100644 src/Nazara/Network/ENetSocket.cpp diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp new file mode 100644 index 000000000..87d4dd37b --- /dev/null +++ b/include/Nazara/Network/ENetHost.hpp @@ -0,0 +1,121 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_ENETHOST_HPP +#define NAZARA_ENETHOST_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class ENetPeer; + + class NAZARA_NETWORK_API ENetHost + { + friend ENetPeer; + friend class Network; + + public: + inline ENetHost(); + ENetHost(const ENetHost&) = delete; + ENetHost(ENetHost&&) = default; + inline ~ENetHost(); + + void Broadcast(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet); + + bool Connect(const IpAddress& remoteAddress, std::size_t channelCount = 0, UInt32 data = 0); + bool Connect(const String& hostName, NetProtocol protocol = NetProtocol_Any, const String& service = "http", ResolveError* error = nullptr, std::size_t channelCount = 0, UInt32 data = 0); + + inline bool Create(NetProtocol protocol, UInt16 port, std::size_t peerCount, std::size_t channelCount = 0); + bool Create(const IpAddress& address, std::size_t peerCount, std::size_t channelCount = 0); + bool Create(const IpAddress& address, std::size_t peerCount, std::size_t channelCount, UInt32 incomingBandwidth, UInt32 outgoingBandwidth); + void Destroy(); + + void Flush(); + + int Service(ENetEvent* event, UInt32 timeout); + + ENetHost& operator=(const ENetHost&) = delete; + ENetHost& operator=(ENetHost&&) = default; + + private: + bool InitSocket(const IpAddress& address); + + inline void AddToDispatchQueue(ENetPeer* peer); + inline void RemoveFromDispatchQueue(ENetPeer* peer); + + bool DispatchIncomingCommands(ENetEvent* event); + + ENetPeer* HandleConnect(ENetProtocolHeader* header, ENetProtocol* command); + bool HandleIncomingCommands(ENetEvent* event); + bool HandleSendReliable(ENetPeer& peer, const ENetProtocol& command, UInt8** currentData); + + int ReceiveIncomingCommands(ENetEvent* event); + + void NotifyConnect(ENetPeer* peer, ENetEvent* event); + void NotifyDisconnect(ENetPeer*, ENetEvent* event); + + void ThrottleBandwidth(); + + static bool Initialize(); + static void Uninitialize(); + + std::array m_commands; + std::array m_packetData[2]; + std::bernoulli_distribution m_packetLossProbability; + std::size_t m_bandwidthLimitedPeers; + std::size_t m_bufferCount; + std::size_t m_channelLimit; + std::size_t m_commandCount; + std::size_t m_duplicatePeers; + std::size_t m_maximumPacketSize; + std::size_t m_maximumWaitingData; + std::size_t m_receivedDataLength; + std::vector m_peers; + Bitset m_dispatchQueue; + MemoryPool m_packetPool; + IpAddress m_address; + IpAddress m_receivedAddress; + SocketPoller m_poller; + UdpSocket m_socket; + UInt32 m_bandwidthThrottleEpoch; + UInt32 m_connectedPeers; + UInt32 m_mtu; + UInt32 m_randomSeed; + UInt32 m_incomingBandwidth; + UInt32 m_outgoingBandwidth; + UInt32 m_serviceTime; + UInt32 m_totalSentData; + UInt32 m_totalSentPackets; + UInt32 m_totalReceivedData; + UInt32 m_totalReceivedPackets; + UInt8* m_receivedData; + bool m_isSimulationEnabled; + bool m_shouldAcceptConnections; + bool m_recalculateBandwidthLimits; + + static std::mt19937 s_randomGenerator; + static std::mt19937_64 s_randomGenerator64; + }; +} + +#include + +#endif // NAZARA_RUDPSERVER_HPP diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl new file mode 100644 index 000000000..c4a077e8b --- /dev/null +++ b/include/Nazara/Network/ENetHost.inl @@ -0,0 +1,65 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline ENetHost::ENetHost() : + m_packetPool(sizeof(ENetPacket)) + { + } + + inline ENetHost::~ENetHost() + { + Destroy(); + } + + inline bool ENetHost::Create(NetProtocol protocol, UInt16 port, std::size_t peerCount, std::size_t channelCount) + { + NazaraAssert(protocol != NetProtocol_Any, "Any protocol not supported for Listen"); //< TODO + NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol"); + + IpAddress any; + switch (protocol) + { + case NetProtocol_Any: + case NetProtocol_Unknown: + NazaraInternalError("Invalid protocol Any at this point"); + return false; + + case NetProtocol_IPv4: + any = IpAddress::AnyIpV4; + break; + + case NetProtocol_IPv6: + any = IpAddress::AnyIpV6; + break; + } + + any.SetPort(port); + return Create(any, peerCount, channelCount); + } + + inline void ENetHost::Destroy() + { + m_poller.Clear(); + m_peers.clear(); + m_socket.Close(); + } + + inline void ENetHost::AddToDispatchQueue(ENetPeer* peer) + { + m_dispatchQueue.UnboundedSet(peer->m_incomingPeerID); + } + + inline void ENetHost::RemoveFromDispatchQueue(ENetPeer* peer) + { + m_dispatchQueue.UnboundedReset(peer->m_incomingPeerID); + } +} + +#include diff --git a/include/Nazara/Network/ENetPacket.hpp b/include/Nazara/Network/ENetPacket.hpp new file mode 100644 index 000000000..ad1610eb4 --- /dev/null +++ b/include/Nazara/Network/ENetPacket.hpp @@ -0,0 +1,78 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_ENETPACKET_HPP +#define NAZARA_ENETPACKET_HPP + +#include +#include + +namespace Nz +{ + enum ENetPacketFlag + { + ENetPacketFlag_NoAllocate, + ENetPacketFlag_Reliable, + ENetPacketFlag_Unsequenced, + ENetPacketFlag_UnreliableFragment, + ENetPacketFlag_Sent + }; + + template<> + struct EnumAsFlags + { + static constexpr bool value = true; + static constexpr int max = ENetPacketFlag_Sent; + }; + + using ENetPacketFlags = Flags; + + class MemoryPool; + + struct ENetPacket + { + MemoryPool* owner; + ENetPacketFlags flags; + NetPacket data; + std::size_t referenceCount = 0; + }; + + struct ENetPacketRef + { + ENetPacketRef() = default; + + ENetPacketRef(ENetPacket* packet) + { + Reset(packet); + } + + ~ENetPacketRef() + { + Reset(); + } + + void Reset(ENetPacket* packet = nullptr); + + operator ENetPacket*() const + { + return m_packet; + } + + ENetPacket* operator->() const + { + return m_packet; + } + + ENetPacketRef& operator=(ENetPacket* packet) + { + Reset(packet); + } + + ENetPacket* m_packet = nullptr; + }; +} + +#endif // NAZARA_ENETPACKET_HPP diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp new file mode 100644 index 000000000..4ae8ca16b --- /dev/null +++ b/include/Nazara/Network/ENetPeer.hpp @@ -0,0 +1,205 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_ENETPEER_HPP +#define NAZARA_ENETPEER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class ENetHost; + + class NAZARA_NETWORK_API ENetPeer + { + friend ENetHost; + friend struct PacketRef; + + public: + ENetPeer(const ENetPeer&) = delete; + ENetPeer(ENetPeer&&) = default; + ~ENetPeer() = default; + + void Disconnect(UInt32 data); + void DisconnectLater(UInt32 data); + void DisconnectNow(UInt32 data); + + void Ping(); + + bool Receive(ENetPacketRef* packet, UInt8* channelId); + void Reset(); + + bool Send(UInt8 channelId, ENetPacketRef packetRef); + bool Send(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet); + + void ThrottleConfigure(UInt32 interval, UInt32 acceleration, UInt32 deceleration); + + ENetPeer& operator=(const ENetPeer&) = delete; + ENetPeer& operator=(ENetPeer&&) = default; + + private: + ENetPeer(ENetHost* host, UInt16 peerId); + + void InitIncoming(std::size_t channelCount, const IpAddress& address, ENetProtocolConnect& incomingCommand); + void InitOutgoing(std::size_t channelCount, const IpAddress& address, UInt32 connectId, UInt32 windowSize); + + struct Acknowledgement; + struct Channel; + struct IncomingCommmand; + struct OutgoingCommand; + + // Protocol functions + inline void ChangeState(ENetPeerState state); + inline void DispatchState(ENetPeerState state); + + void DispatchIncomingReliableCommands(Channel& channel); + void DispatchIncomingUnreliableCommands(Channel& channel); + + void OnConnect(); + void OnDisconnect(); + + ENetProtocolCommand RemoveSentReliableCommands(UInt16 reliableSequenceNumber, UInt8 channelId); + void RemoveSentUnreliableCommands(); + + void ResetQueues(); + + bool QueueAcknowledgement(ENetProtocol& command, UInt16 sentTime); + IncomingCommmand* QueueIncomingCommand(ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount); + void QueueOutgoingCommand(ENetProtocol& command, ENetPacketRef packet, UInt32 offset, UInt16 length); + + void SetupOutgoingCommand(OutgoingCommand& outgoingCommand); + + int Throttle(UInt32 rtt); + + struct Acknowledgement + { + ENetProtocol command; + UInt32 sentTime; + }; + + struct Channel + { + Channel() + { + incomingReliableSequenceNumber = 0; + incomingUnreliableSequenceNumber = 0; + outgoingReliableSequenceNumber = 0; + outgoingUnreliableSequenceNumber = 0; + usedReliableWindows = 0; + reliableWindows.fill(0); + } + + std::array reliableWindows; + std::list incomingReliableCommands; + std::list incomingUnreliableCommands; + UInt16 incomingReliableSequenceNumber; + UInt16 incomingUnreliableSequenceNumber; + UInt16 outgoingReliableSequenceNumber; + UInt16 outgoingUnreliableSequenceNumber; + UInt16 usedReliableWindows; + }; + + struct IncomingCommmand + { + ENetProtocol command; + UInt16 reliableSequenceNumber; + UInt16 unreliableSequenceNumber; + UInt32 fragmentsRemaining; + std::vector fragments; + ENetPacketRef packet; + }; + + struct OutgoingCommand + { + ENetProtocol command; + ENetPacketRef packet; + UInt16 fragmentLength; + UInt16 reliableSequenceNumber; + UInt16 sendAttempts; + UInt16 unreliableSequenceNumber; + UInt32 fragmentOffset; + UInt32 roundTripTimeout; + UInt32 roundTripTimeoutLimit; + UInt32 sentTime; + }; + + ENetHost* m_host; + IpAddress m_address; /**< Internet address of the peer */ + std::vector m_channels; + std::list m_acknowledgements; + std::list m_dispatchedCommands; + std::list m_outgoingReliableCommands; + std::list m_outgoingUnreliableCommands; + std::list m_sentReliableCommands; + std::list m_sentUnreliableCommands; + MemoryPool m_packetPool; + //ENetListNode m_dispatchList; + ENetPeerState m_state; + UInt8 m_incomingSessionID; + UInt8 m_outgoingSessionID; + UInt16 m_incomingPeerID; + UInt16 m_incomingUnsequencedGroup; + UInt16 m_outgoingPeerID; + UInt16 m_outgoingReliableSequenceNumber; + UInt16 m_outgoingUnsequencedGroup; + UInt32 m_connectID; + UInt32 m_earliestTimeout; + UInt32 m_eventData; + UInt32 m_highestRoundTripTimeVariance; + UInt32 m_incomingBandwidth; /**< Downstream bandwidth of the client in bytes/second */ + UInt32 m_incomingBandwidthThrottleEpoch; + UInt32 m_incomingDataTotal; + UInt32 m_lastReceiveTime; + UInt32 m_lastRoundTripTime; + UInt32 m_lastRoundTripTimeVariance; + UInt32 m_lastSendTime; + UInt32 m_lowestRoundTripTime; + UInt32 m_mtu; + UInt32 m_nextTimeout; + UInt32 m_outgoingBandwidth; /**< Upstream bandwidth of the client in bytes/second */ + UInt32 m_outgoingBandwidthThrottleEpoch; + UInt32 m_outgoingDataTotal; + UInt32 m_packetLoss; /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */ + UInt32 m_packetLossEpoch; + UInt32 m_packetLossVariance; + UInt32 m_packetThrottle; + UInt32 m_packetThrottleAcceleration; + UInt32 m_packetThrottleCounter; + UInt32 m_packetThrottleDeceleration; + UInt32 m_packetThrottleEpoch; + UInt32 m_packetThrottleInterval; + UInt32 m_packetThrottleLimit; + UInt32 m_packetsLost; + UInt32 m_packetsSent; + UInt32 m_pingInterval; + UInt32 m_reliableDataInTransit; + UInt32 m_roundTripTime; /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgment */ + UInt32 m_roundTripTimeVariance; + UInt32 m_timeoutLimit; + UInt32 m_timeoutMaximum; + UInt32 m_timeoutMinimum; + UInt32 m_unsequencedWindow[ENetPeer_ReliableWindowSize / 32]; + UInt32 m_windowSize; + std::size_t m_totalWaitingData; + }; +} + +#include + +#endif // NAZARA_ENETPEER_HPP diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl new file mode 100644 index 000000000..a0cebbc4e --- /dev/null +++ b/include/Nazara/Network/ENetPeer.inl @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline void ENetPeer::ChangeState(ENetPeerState state) + { + if (state == ENetPeerState::Connected || state == ENetPeerState::DisconnectLater) + OnConnect(); + else + OnDisconnect(); + + m_state = state; + } + + inline void ENetPeer::DispatchState(ENetPeerState state) + { + ChangeState(state); + + m_host->AddToDispatchQueue(this); + } +} + +#include diff --git a/include/Nazara/Network/ENetProtocol.hpp b/include/Nazara/Network/ENetProtocol.hpp new file mode 100644 index 000000000..d4d74fd01 --- /dev/null +++ b/include/Nazara/Network/ENetProtocol.hpp @@ -0,0 +1,272 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_ENETPROTOCOL_HPP +#define NAZARA_ENETPROTOCOL_HPP + +#include +#include +#include + +namespace Nz +{ + // Constants for the ENet implementation and protocol + enum ENetConstants + { + ENetHost_BandwidthThrottleInterval = 1000, + ENetHost_DefaultMaximumPacketSize = 32 * 1024 * 1024, + ENetHost_DefaultMaximumWaitingData = 32 * 1024 * 1024, + ENetHost_DefaultMTU = 1400, + ENetHost_ReceiveBufferSize = 256 * 1024, + ENetHost_SendBufferSize = 256 * 1024, + + ENetPeer_DefaultPacketThrottle = 32, + ENetPeer_DefaultRoundTripTime = 500, + ENetPeer_FreeReliableWindows = 8, + ENetPeer_FreeUnsequencedWindows = 32, + ENetPeer_PacketLossInterval = 10000, + ENetPeer_PacketLossScale = (1 << 16), + ENetPeer_PacketThrottleAcceleration = 2, + ENetPeer_PacketThrottleCounter = 7, + ENetPeer_PacketThrottleDeceleration = 2, + ENetPeer_PacketThrottleInterval = 5000, + ENetPeer_PacketThrottleScale = 32, + ENetPeer_PingInterval = 500, + ENetPeer_ReliableWindows = 16, + ENetPeer_ReliableWindowSize = 0x1000, + ENetPeer_TimeoutLimit = 32, + ENetPeer_TimeoutMaximum = 30000, + ENetPeer_TimeoutMinimum = 5000, + ENetPeer_UnsequencedWindows = 64, + ENetPeer_UnsequencedWindowSize = 1024, + ENetPeer_WindowSizeScale = 64 * 1024, + + ENetProtocol_MaximumChannelCount = 255, + ENetProtocol_MaximumFragmentCount = 1024 * 1024, + ENetProtocol_MaximumMTU = 4096, + ENetProtocol_MaximumPacketCommands = 32, + ENetProtocol_MaximumPeerId = 0xFFF, + ENetProtocol_MaximumWindowSize = 65536, + ENetProtocol_MinimumChannelCount = 1, + ENetProtocol_MinimumMTU = 576, + ENetProtocol_MinimumWindowSize = 4096 + }; + + enum class ENetPeerState + { + AcknowledgingConnect = 2, + AcknowledgingDisconnect = 8, + Connecting = 1, + ConnectionPending = 3, + ConnectionSucceeded = 4, + Connected = 5, + Disconnected = 0, + Disconnecting = 7, + DisconnectLater = 6, + Zombie = 9 + }; + + enum ENetProtocolCommand + { + // Keeping the values is important for compatibility with the native ENet protocol + ENetProtocolCommand_Acknowledge = 1, + ENetProtocolCommand_BandwidthLimit = 10, + ENetProtocolCommand_Connect = 2, + ENetProtocolCommand_Disconnect = 4, + ENetProtocolCommand_None = 0, + ENetProtocolCommand_Ping = 5, + ENetProtocolCommand_SendFragment = 8, + ENetProtocolCommand_SendReliable = 6, + ENetProtocolCommand_SendUnreliable = 7, + ENetProtocolCommand_SendUnreliableFragment = 12, + ENetProtocolCommand_SendUnsequenced = 9, + ENetProtocolCommand_ThrottleConfigure = 11, + ENetProtocolCommand_VerifyConnect = 3, + ENetProtocolCommand_Count = 13, + + ENetProtocolCommand_Mask = 0x0F + }; + + enum ENetProtocolFlag + { + ENetProtocolFlag_Acknowledge = (1 << 7), + ENetProtocolFlag_Unsequenced = (1 << 6), + + ENetProtocolHeaderFlag_Compressed = (1 << 14), + ENetProtocolHeaderFlag_SentTime = (1 << 15), + ENetProtocolHeaderFlag_Mask = ENetProtocolHeaderFlag_Compressed | ENetProtocolHeaderFlag_SentTime, + + ENetProtocolHeaderSessionMask = (3 << 12), + ENetProtocolHeaderSessionShift = 12 + }; + + enum class ENetEventType + { + /** no event occurred within the specified time limit */ + None, + + /** a connection request initiated by enet_host_connect has completed. + * The peer field contains the peer which successfully connected. + */ + Connect, + + /** a peer has disconnected. This event is generated on a successful + * completion of a disconnect initiated by enet_peer_disconnect, if + * a peer has timed out, or if a connection request initialized by + * enet_host_connect has timed out. The peer field contains the peer + * which disconnected. The data field contains user supplied data + * describing the disconnection, or 0, if none is available. + */ + Disconnect, + + /** a packet has been received from a peer. The peer field specifies the + * peer which sent the packet. The channelID field specifies the channel + * number upon which the packet was received. The packet field contains + * the packet that was received; this packet must be destroyed with + * enet_packet_destroy after use. + */ + Receive + }; + + struct ENetEvent + { + ENetEventType type; + ENetPeer* peer; + UInt8 channelId; + UInt32 data; + ENetPacketRef packet; + }; + + struct ENetProtocolHeader + { + UInt16 peerID; + UInt16 sentTime; + }; + + struct ENetProtocolCommandHeader + { + UInt8 command; + UInt8 channelID; + UInt16 reliableSequenceNumber; + }; + + struct ENetProtocolAcknowledge + { + ENetProtocolCommandHeader header; + UInt16 receivedReliableSequenceNumber; + UInt16 receivedSentTime; + }; + + struct ENetProtocolConnect + { + ENetProtocolCommandHeader header; + UInt16 outgoingPeerID; + UInt8 incomingSessionID; + UInt8 outgoingSessionID; + UInt32 mtu; + UInt32 windowSize; + UInt32 channelCount; + UInt32 incomingBandwidth; + UInt32 outgoingBandwidth; + UInt32 packetThrottleInterval; + UInt32 packetThrottleAcceleration; + UInt32 packetThrottleDeceleration; + UInt32 connectID; + UInt32 data; + }; + + struct ENetProtocolBandwidthLimit + { + ENetProtocolCommandHeader header; + UInt32 incomingBandwidth; + UInt32 outgoingBandwidth; + }; + + struct ENetProtocolDisconnect + { + ENetProtocolCommandHeader header; + UInt32 data; + }; + + struct ENetProtocolPing + { + ENetProtocolCommandHeader header; + }; + + struct ENetProtocolSendFragment + { + ENetProtocolCommandHeader header; + UInt16 startSequenceNumber; + UInt16 dataLength; + UInt32 fragmentCount; + UInt32 fragmentNumber; + UInt32 totalLength; + UInt32 fragmentOffset; + }; + + struct ENetProtocolSendReliable + { + ENetProtocolCommandHeader header; + UInt16 dataLength; + }; + + struct ENetProtocolSendUnreliable + { + ENetProtocolCommandHeader header; + UInt16 unreliableSequenceNumber; + UInt16 dataLength; + }; + + struct ENetProtocolSendUnsequenced + { + ENetProtocolCommandHeader header; + UInt16 unsequencedGroup; + UInt16 dataLength; + }; + + struct ENetProtocolThrottleConfigure + { + ENetProtocolCommandHeader header; + UInt32 packetThrottleInterval; + UInt32 packetThrottleAcceleration; + UInt32 packetThrottleDeceleration; + }; + + struct ENetProtocolVerifyConnect + { + ENetProtocolCommandHeader header; + UInt16 outgoingPeerID; + UInt8 incomingSessionID; + UInt8 outgoingSessionID; + UInt32 mtu; + UInt32 windowSize; + UInt32 channelCount; + UInt32 incomingBandwidth; + UInt32 outgoingBandwidth; + UInt32 packetThrottleInterval; + UInt32 packetThrottleAcceleration; + UInt32 packetThrottleDeceleration; + UInt32 connectID; + }; + + union ENetProtocol + { + ENetProtocolCommandHeader header; + ENetProtocolAcknowledge acknowledge; + ENetProtocolBandwidthLimit bandwidthLimit; + ENetProtocolConnect connect; + ENetProtocolDisconnect disconnect; + ENetProtocolPing ping; + ENetProtocolSendReliable sendReliable; + ENetProtocolSendUnreliable sendUnreliable; + ENetProtocolSendUnsequenced sendUnsequenced; + ENetProtocolSendFragment sendFragment; + ENetProtocolThrottleConfigure throttleConfigure; + ENetProtocolVerifyConnect verifyConnect; + }; +} + +#endif // NAZARA_ENETPROTOCOL_HPP diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp new file mode 100644 index 000000000..05179e615 --- /dev/null +++ b/src/Nazara/Network/ENetHost.cpp @@ -0,0 +1,743 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ENET_TIME_OVERFLOW 86400000 + +#define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) +#define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) +#define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) +#define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) + +#define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) + +namespace Nz +{ + /// Temporary + template + T HostToNet(T value) + { + #ifdef NAZARA_LITTLE_ENDIAN + return SwapBytes(value); + #else + return value; + #endif + } + + /// Temporary + template + T NetToHost(T value) + { + #ifdef NAZARA_LITTLE_ENDIAN + return SwapBytes(value); + #else + return value; + #endif + } + + + void ENetHost::Broadcast(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet) + { + ENetPacket* enetPacket = m_packetPool.New(); + enetPacket->flags = flags; + enetPacket->data = std::move(packet); + enetPacket->owner = &m_packetPool; + + for (ENetPeer& peer : m_peers) + { + if (peer.m_state != ENetPeerState::Connected) + continue; + + peer.Send(channelId, enetPacket); + } + } + + bool ENetHost::Connect(const IpAddress& remoteAddress, std::size_t channelCount, UInt32 data) + { + NazaraAssert(remoteAddress.IsValid(), "Invalid remote address"); + NazaraAssert(remoteAddress.GetPort() != 0, "Remote address has no port"); + + std::size_t peerId; + for (peerId = 0; peerId < m_peers.size(); ++peerId) + { + if (m_peers[peerId].m_state == ENetPeerState::Disconnected) + break; + } + + if (peerId >= m_peers.size()) + { + NazaraError("Insufficient peers"); + return false; + } + + m_channelLimit = Clamp(channelCount, ENetConstants::ENetProtocol_MinimumChannelCount, ENetConstants::ENetProtocol_MaximumChannelCount); + + UInt32 windowSize; + if (m_outgoingBandwidth == 0) + windowSize = ENetProtocol_MaximumWindowSize; + else + windowSize = (m_outgoingBandwidth / ENetConstants::ENetPeer_WindowSizeScale) * ENetProtocol_MinimumWindowSize; + + ENetPeer& peer = m_peers[peerId]; + peer.InitOutgoing(channelCount, remoteAddress, ++m_randomSeed, windowSize); + + ENetProtocol command; + command.header.command = ENetProtocolCommand_Connect | ENetProtocolFlag_Acknowledge; + command.header.channelID = 0xFF; + + command.connect.channelCount = HostToNet(static_cast(channelCount)); + command.connect.connectID = peer.m_connectID; + command.connect.data = HostToNet(data); + command.connect.incomingBandwidth = HostToNet(m_incomingBandwidth); + command.connect.incomingSessionID = peer.m_incomingSessionID; + command.connect.mtu = HostToNet(peer.m_mtu); + command.connect.outgoingBandwidth = HostToNet(m_outgoingBandwidth); + command.connect.outgoingPeerID = HostToNet(peer.m_incomingPeerID); + command.connect.outgoingSessionID = peer.m_outgoingSessionID; + command.connect.packetThrottleAcceleration = HostToNet(peer.m_packetThrottleAcceleration); + command.connect.packetThrottleDeceleration = HostToNet(peer.m_packetThrottleDeceleration); + command.connect.packetThrottleInterval = HostToNet(peer.m_packetThrottleInterval); + command.connect.windowSize = HostToNet(peer.m_windowSize); + + peer.QueueOutgoingCommand(command, nullptr, 0, 0); + + return true; + } + + bool ENetHost::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error, std::size_t channelCount, UInt32 data) + { + std::vector results = IpAddress::ResolveHostname(protocol, hostName, service, error); + if (results.empty()) + return false; + + IpAddress hostnameAddress; + for (const HostnameInfo& result : results) + { + if (!result.address) + continue; + + if (result.socketType != SocketType_UDP) + continue; + + hostnameAddress = result.address; + break; //< Take first valid address + } + + return Connect(hostnameAddress, channelCount, data); + } + + bool ENetHost::Create(const IpAddress& address, std::size_t peerCount, std::size_t channelCount) + { + return Create(address, peerCount, channelCount, 0, 0); + } + + bool ENetHost::Create(const IpAddress& address, std::size_t peerCount, std::size_t channelCount, UInt32 incomingBandwidth, UInt32 outgoingBandwidth) + { + NazaraAssert(address.IsValid(), "Invalid listening address"); + + if (peerCount > ENetConstants::ENetProtocol_MaximumPeerId) + { + NazaraError("Peer count exceeds maximum peer count supported by protocol (" + String::Number(ENetConstants::ENetProtocol_MaximumPeerId) + ")"); + return false; + } + + if (!InitSocket(address)) + return false; + + m_peers.resize(peerCount); + + m_address = address; + m_randomSeed = *reinterpret_cast(this); + m_randomSeed += s_randomGenerator(); + m_randomSeed = (m_randomSeed << 16) | (m_randomSeed >> 16); + m_channelLimit = Clamp(channelCount, ENetConstants::ENetProtocol_MinimumChannelCount, ENetConstants::ENetProtocol_MaximumChannelCount); + m_incomingBandwidth = incomingBandwidth; + m_outgoingBandwidth = outgoingBandwidth; + m_bandwidthThrottleEpoch = 0; + m_recalculateBandwidthLimits = false; + m_mtu = ENetConstants::ENetHost_DefaultMTU; + m_commandCount = 0; + m_bufferCount = 0; + m_receivedAddress = IpAddress::AnyIpV4; + m_receivedData = nullptr; + m_receivedDataLength = 0; + + m_totalSentData = 0; + m_totalSentPackets = 0; + m_totalReceivedData = 0; + m_totalReceivedPackets = 0; + + m_bandwidthLimitedPeers = 0; + m_connectedPeers = 0; + m_duplicatePeers = ENetConstants::ENetProtocol_MaximumPeerId; + m_maximumPacketSize = ENetConstants::ENetHost_DefaultMaximumPacketSize; + m_maximumWaitingData = ENetConstants::ENetHost_DefaultMaximumWaitingData; + + return true; + } + + void ENetHost::Flush() + { + m_serviceTime = GetElapsedMilliseconds(); + + SendOutgoingCommands(nullptr, 0); + } + + int ENetHost::Service(ENetEvent* event, UInt32 timeout) + { + UInt32 waitCondition; + + if (event) + { + event->type = ENetEventType::None; + event->peer = nullptr; + event->packet = nullptr; + + if (DispatchIncomingCommands(event)) + return 1; + } + + m_serviceTime = GetElapsedMilliseconds(); + timeout += m_serviceTime; + + do + { + if (ENET_TIME_DIFFERENCE(m_serviceTime, m_bandwidthThrottleEpoch) >= ENetConstants::ENetHost_BandwidthThrottleInterval) + ThrottleBandwidth(); + + switch (SendOutgoingCommands(event, true)) + { + case 1: + return 1; + + case -1: + #ifdef ENET_DEBUG + perror("Error sending outgoing packets"); + #endif + return -1; + + default: + break; + } + + switch (ReceiveIncomingCommands(event)) + { + case 1: + return 1; + + case -1: +#ifdef ENET_DEBUG + perror("Error receiving incoming packets"); +#endif + + return -1; + + default: + break; + } + + switch (SendOutgoingCommands(event, 1)) + { + case 1: + return 1; + + case -1: +#ifdef ENET_DEBUG + perror("Error sending outgoing packets"); +#endif + + return -1; + + default: + break; + } + + if (event) + { + switch (DispatchIncomingCommands(event)) + { + case 1: + return 1; + + case -1: + #ifdef ENET_DEBUG + perror("Error dispatching incoming packets"); + #endif + + return -1; + + default: + break; + } + } + + if (ENET_TIME_GREATER_EQUAL(m_serviceTime, timeout)) + return 0; + + for (;;) + { + m_serviceTime = GetElapsedMilliseconds(); + + if (ENET_TIME_GREATER_EQUAL(m_serviceTime, timeout)) + return 0; + + SocketError error; + if (m_poller.Wait(ENET_TIME_DIFFERENCE(timeout, m_serviceTime), &error)) + break; + + if (error != SocketError_NoError) + return -1; + } + + m_serviceTime = GetElapsedMilliseconds(); + } + while (m_poller.IsReady(m_socket)); + + return 0; + } + + bool ENetHost::InitSocket(const IpAddress& address) + { + if (!m_socket.Create(address.GetProtocol())) + return false; + + m_socket.EnableBlocking(false); + m_socket.EnableBroadcasting(true); + m_socket.SetReceiveBufferSize(ENetConstants::ENetHost_ReceiveBufferSize); + m_socket.SetSendBufferSize(ENetConstants::ENetHost_SendBufferSize); + + if (!address.IsLoopback()) + { + if (m_socket.Bind(address) != SocketState_Bound) + { + NazaraError("Failed to bind address " + address.ToString()); + return false; + } + } + + m_poller.RegisterSocket(m_socket); + + return true; + } + + bool ENetHost::DispatchIncomingCommands(ENetEvent* event) + { + for (std::size_t bit = m_dispatchQueue.FindFirst(); bit != m_dispatchQueue.npos; bit = m_dispatchQueue.FindNext(bit)) + { + m_dispatchQueue.Reset(bit); + + ENetPeer& peer = m_peers[bit]; + switch (peer.m_state) + { + case ENetPeerState::ConnectionPending: + case ENetPeerState::ConnectionSucceeded: + peer.ChangeState(ENetPeerState::Connected); + + event->type = ENetEventType::Connect; + event->peer = &peer; + event->data = peer.m_eventData; + return true; + + case ENetPeerState::Zombie: + m_recalculateBandwidthLimits = true; + + event->type = ENetEventType::Disconnect; + event->peer = &peer; + event->data = peer.m_eventData; + + peer.Reset(); + return true; + + case ENetPeerState::Connected: + if (peer.m_dispatchedCommands.empty()) + continue; + + if (!peer.Receive(&event->packet, &event->channelId)) + continue; + + event->type = ENetEventType::Receive; + event->peer = &peer; + + if (!peer.m_dispatchedCommands.empty()) + AddToDispatchQueue(&peer); + + return true; + } + } + + return false; + } + + ENetPeer* ENetHost::HandleConnect(ENetProtocolHeader* header, ENetProtocol* command) + { + UInt32 channelCount = NetToHost(command->connect.channelCount); + + if (channelCount < ENetProtocol_MinimumChannelCount || channelCount > ENetProtocol_MaximumChannelCount) + return nullptr; + + std::size_t duplicatePeers = 0; + ENetPeer* peer = nullptr; + for (ENetPeer& currentPeer : m_peers) + { + if (currentPeer.m_state == ENetPeerState::Disconnected) + { + if (!peer) + peer = ¤tPeer; + } + else if (currentPeer.m_state != ENetPeerState::Connecting) + { + // Compare users without comparing their port + IpAddress first(currentPeer.m_address); + first.SetPort(0); + + IpAddress second(m_receivedAddress); + second.SetPort(0); + + if (first == second) + { + if (currentPeer.m_address.GetPort() == m_receivedAddress.GetPort() && currentPeer.m_connectID == command->connect.connectID) + return nullptr; + + ++duplicatePeers; + } + } + } + + if (!peer || duplicatePeers >= m_duplicatePeers) + return nullptr; + + channelCount = std::min(channelCount, m_channelLimit); + + peer->InitIncoming(channelCount, m_receivedAddress, command->connect); + + UInt32 windowSize; + if (m_incomingBandwidth == 0) + windowSize = ENetConstants::ENetProtocol_MaximumWindowSize; + else + windowSize = (m_incomingBandwidth / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + + windowSize = std::max(windowSize, NetToHost(command->connect.windowSize)); + windowSize = Clamp(windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + + ENetProtocol verifyCommand; + verifyCommand.header.command = ENetProtocolCommand_VerifyConnect | ENetProtocolFlag_Acknowledge; + verifyCommand.header.channelID = 0xFF; + verifyCommand.verifyConnect.outgoingPeerID = HostToNet(peer->m_incomingPeerID); + verifyCommand.verifyConnect.incomingSessionID = peer->m_outgoingSessionID; + verifyCommand.verifyConnect.outgoingSessionID = peer->m_incomingSessionID; + verifyCommand.verifyConnect.mtu = HostToNet(peer->m_mtu); + verifyCommand.verifyConnect.windowSize = HostToNet(windowSize); + verifyCommand.verifyConnect.channelCount = HostToNet(channelCount); + verifyCommand.verifyConnect.incomingBandwidth = HostToNet(m_incomingBandwidth); + verifyCommand.verifyConnect.outgoingBandwidth = HostToNet(m_outgoingBandwidth); + verifyCommand.verifyConnect.packetThrottleInterval = HostToNet(peer->m_packetThrottleInterval); + verifyCommand.verifyConnect.packetThrottleAcceleration = HostToNet(peer->m_packetThrottleAcceleration); + verifyCommand.verifyConnect.packetThrottleDeceleration = HostToNet(peer->m_packetThrottleDeceleration); + verifyCommand.verifyConnect.connectID = peer->m_connectID; + + peer->QueueOutgoingCommand(verifyCommand, nullptr, 0, 0); + + return peer; + } + + bool ENetHost::HandleIncomingCommands(ENetEvent* event) + { + if (m_receivedDataLength < NazaraOffsetOf(ENetProtocolHeader, sentTime)) + return false; + + ENetProtocolHeader* header = reinterpret_cast(m_receivedData); + + peerID = NetToHost(header->peerID); + sessionID = (peerID & ENET_PROTOCOL_HEADER_SESSION_MASK) >> ENET_PROTOCOL_HEADER_SESSION_SHIFT; + flags = peerID & ENET_PROTOCOL_HEADER_FLAG_MASK; + peerID &= ~(ENET_PROTOCOL_HEADER_FLAG_MASK | ENET_PROTOCOL_HEADER_SESSION_MASK); + + headerSize = (flags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME ? sizeof(ENetProtocolHeader) : (size_t) & ((ENetProtocolHeader *)0)->sentTime); + if (host->checksum != NULL) + headerSize += sizeof(enet_uint32); + + if (peerID == ENET_PROTOCOL_MAXIMUM_PEER_ID) + peer = NULL; + else + if (peerID >= host->peerCount) + return 0; + else + { + peer = &host->peers[peerID]; + + if (peer->state == ENET_PEER_STATE_DISCONNECTED || + peer->state == ENET_PEER_STATE_ZOMBIE || + ((host->receivedAddress.host != peer->address.host || + host->receivedAddress.port != peer->address.port) && + peer->address.host != ENET_HOST_BROADCAST) || + (peer->outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID && + sessionID != peer->incomingSessionID)) + return 0; + } + + return false; + } + + bool ENetHost::HandleSendReliable(ENetPeer& peer, const ENetProtocol& command, UInt8** currentData) + { + if (command.header.channelID >= peer.m_channels.size() || (peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater)) + return false; + + UInt16 dataLength = NetToHost(command.sendReliable.dataLength); + *currentData += dataLength; + if (dataLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) + return false; + + if (!peer.QueueIncomingCommand(command, co)) + + return true; + } + + int ENetHost::ReceiveIncomingCommands(ENetEvent* event) + { + for (unsigned int i = 0; i < 256; ++i) + { + NetPacket packet; + + std::size_t receivedLength; + if (!m_socket.Receive(m_packetData[0].data(), m_packetData[0].size(), &m_receivedAddress, &receivedLength)) + return -1; //< Error + + if (receivedLength == 0) + return 0; + + m_receivedData = m_packetData[0].data(); + m_receivedDataLength = receivedLength; + + m_totalReceivedData += receivedLength; + m_totalReceivedPackets++; + + // Intercept + + switch (HandleIncomingCommands(event)) + { + case 1: + return 1; + + case -1: + return -1; + + default: + break; + } + } + + return -1; + } + + void ENetHost::NotifyConnect(ENetPeer* peer, ENetEvent* event) + { + m_recalculateBandwidthLimits = true; + + if (event) + { + peer->ChangeState(ENetPeerState::Connected); + + event->type = ENetEventType::Connect; + event->peer = peer; + event->data = peer->m_eventData; + } + else + peer->DispatchState(peer->m_state == ENetPeerState::Connecting ? ENetPeerState::ConnectionSucceeded : ENetPeerState::ConnectionPending); + } + + void ENetHost::NotifyDisconnect(ENetPeer* peer, ENetEvent* event) + { + if (peer->m_state >= ENetPeerState::ConnectionPending) + m_recalculateBandwidthLimits = true; + + if (peer->m_state != ENetPeerState::Connecting && (peer->m_state < ENetPeerState::ConnectionSucceeded)) + peer->Reset(); + else if (event) + { + event->type = ENetEventType::Disconnect; + event->peer = peer; + event->data = peer->m_eventData; + + peer->Reset(); + } + else + { + peer->m_eventData = 0; + + peer->DispatchState(ENetPeerState::Zombie); + } + } + + void ENetHost::ThrottleBandwidth() + { + UInt32 currentTime = GetElapsedMilliseconds(); + UInt32 elapsedTime = currentTime - m_bandwidthThrottleEpoch; + + if (elapsedTime < ENetConstants::ENetHost_BandwidthThrottleInterval) + return; + + m_bandwidthThrottleEpoch = currentTime; + + if (m_connectedPeers == 0) + return; + + UInt32 dataTotal = ~0; + UInt32 bandwidth = ~0; + + if (m_outgoingBandwidth != 0) + { + bandwidth = (m_outgoingBandwidth * elapsedTime) / 1000; + + dataTotal = 0; + for (ENetPeer& peer : m_peers) + { + if (peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) + continue; + + dataTotal += peer.m_outgoingDataTotal; + } + } + + UInt32 peersRemaining = m_connectedPeers; + UInt32 bandwidthLimit = ~0; + UInt32 throttle = ~0; + bool needsAdjustment = m_bandwidthLimitedPeers > 0; + + while (peersRemaining > 0 && needsAdjustment) + { + needsAdjustment = false; + + if (dataTotal <= bandwidth) + throttle = ENetConstants::ENetPeer_PacketThrottleScale; + else + throttle = (bandwidth * ENetConstants::ENetPeer_PacketThrottleScale) / dataTotal; + + for (ENetPeer& peer : m_peers) + { + if ((peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) || + peer.m_incomingBandwidth == 0 || peer.m_outgoingBandwidthThrottleEpoch == currentTime) + continue; + + UInt32 peerBandwidth = (peer.m_incomingBandwidth * elapsedTime) / 1000; + if ((throttle * peer.m_outgoingDataTotal) / ENetConstants::ENetPeer_PacketThrottleScale <= peerBandwidth) + continue; + + peer.m_packetThrottleLimit = (peerBandwidth * ENetConstants::ENetPeer_PacketThrottleScale) / peer.m_outgoingDataTotal; + + if (peer.m_packetThrottleLimit == 0) + peer.m_packetThrottleLimit = 1; + + if (peer.m_packetThrottle > peer.m_packetThrottleLimit) + peer.m_packetThrottle = peer.m_packetThrottleLimit; + + peer.m_outgoingBandwidthThrottleEpoch = currentTime; + + peer.m_incomingDataTotal = 0; + peer.m_outgoingDataTotal = 0; + + needsAdjustment = true; + --peersRemaining; + bandwidth -= peerBandwidth; + dataTotal -= peerBandwidth; + } + } + + if (peersRemaining > 0) + { + if (dataTotal <= bandwidth) + throttle = ENetConstants::ENetPeer_PacketThrottleScale; + else + throttle = (bandwidth * ENetConstants::ENetPeer_PacketThrottleScale) / dataTotal; + + for (ENetPeer& peer : m_peers) + { + if ((peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) || + peer.m_outgoingBandwidthThrottleEpoch == currentTime) + continue; + + peer.m_packetThrottleLimit = throttle; + + if (peer.m_packetThrottle > peer.m_packetThrottleLimit) + peer.m_packetThrottle = peer.m_packetThrottleLimit; + + peer.m_incomingDataTotal = 0; + peer.m_outgoingDataTotal = 0; + } + } + + if (m_recalculateBandwidthLimits) + { + m_recalculateBandwidthLimits = false; + + peersRemaining = m_connectedPeers; + bandwidth = m_incomingBandwidth; + needsAdjustment = true; + + if (bandwidth == 0) + bandwidthLimit = 0; + else + { + while (peersRemaining > 0 && needsAdjustment) + { + needsAdjustment = false; + bandwidthLimit = bandwidth / peersRemaining; + + for (ENetPeer& peer : m_peers) + { + if ((peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) || + peer.m_incomingBandwidthThrottleEpoch == currentTime) + continue; + + if (peer.m_outgoingBandwidth > 0 && peer.m_outgoingBandwidth >= bandwidthLimit) + continue; + + peer.m_incomingBandwidthThrottleEpoch = currentTime; + + needsAdjustment = true; + --peersRemaining; + bandwidth -= peer.m_outgoingBandwidth; + } + } + } + + for (ENetPeer& peer : m_peers) + { + if (peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) + continue; + + ENetProtocol command; + command.header.command = ENetProtocolCommand_BandwidthLimit | ENetProtocolFlag_Acknowledge; + command.header.channelID = 0xFF; + command.bandwidthLimit.outgoingBandwidth = HostToNet(m_outgoingBandwidth); + + if (peer.m_incomingBandwidthThrottleEpoch == currentTime) + command.bandwidthLimit.incomingBandwidth = HostToNet(peer.m_outgoingBandwidth); + else + command.bandwidthLimit.incomingBandwidth = HostToNet(bandwidthLimit); + + peer.QueueOutgoingCommand(command, nullptr, 0, 0); + } + } + } + + bool ENetHost::Initialize() + { + std::random_device device; + s_randomGenerator.seed(device()); + s_randomGenerator64.seed(device()); + + return true; + } + + void ENetHost::Uninitialize() + { + } + + std::mt19937 ENetHost::s_randomGenerator; + std::mt19937_64 ENetHost::s_randomGenerator64; +} \ No newline at end of file diff --git a/src/Nazara/Network/ENetPacket.cpp b/src/Nazara/Network/ENetPacket.cpp new file mode 100644 index 000000000..ec2bc4ab7 --- /dev/null +++ b/src/Nazara/Network/ENetPacket.cpp @@ -0,0 +1,23 @@ +#include +#include +#include + +namespace Nz +{ + /// Temporary + void ENetPacketRef::Reset(ENetPacket* packet = nullptr) + { + if (m_packet) + { + if (--m_packet->referenceCount == 0) + { + m_packet->owner->Delete(m_packet); + return; + } + } + + m_packet = packet; + if (m_packet) + m_packet->referenceCount++; + } +} \ No newline at end of file diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp new file mode 100644 index 000000000..9e5471c21 --- /dev/null +++ b/src/Nazara/Network/ENetPeer.cpp @@ -0,0 +1,885 @@ +#include +#include +#include +#include +#include + +namespace Nz +{ + /// Temporary + template + T HostToNet(T value) + { + #ifdef NAZARA_LITTLE_ENDIAN + return SwapBytes(value); + #else + return value; + #endif + } + + /// Temporary + template + T NetToHost(T value) + { + #ifdef NAZARA_LITTLE_ENDIAN + return SwapBytes(value); + #else + return value; + #endif + } + + namespace + { + static std::size_t commandSizes[ENetProtocolCommand_Count] = + { + 0, + sizeof(ENetProtocolAcknowledge), + sizeof(ENetProtocolConnect), + sizeof(ENetProtocolVerifyConnect), + sizeof(ENetProtocolDisconnect), + sizeof(ENetProtocolPing), + sizeof(ENetProtocolSendReliable), + sizeof(ENetProtocolSendUnreliable), + sizeof(ENetProtocolSendFragment), + sizeof(ENetProtocolSendUnsequenced), + sizeof(ENetProtocolBandwidthLimit), + sizeof(ENetProtocolThrottleConfigure), + sizeof(ENetProtocolSendFragment) + }; + + std::size_t enet_protocol_command_size(UInt8 commandNumber) + { + return commandSizes[commandNumber & ENetProtocolCommand_Mask]; + } + } + + ENetPeer::ENetPeer(ENetHost* host, UInt16 peerId) : + m_packetPool(sizeof(ENetPacket)), + m_host(host), + m_incomingPeerID(peerId), + m_incomingSessionID(0xFF), + m_outgoingSessionID(0xFF) + { + Reset(); + } + + void ENetPeer::Disconnect(UInt32 data) + { + if (m_state == ENetPeerState::Disconnecting || + m_state == ENetPeerState::Disconnected || + m_state == ENetPeerState::AcknowledgingDisconnect || + m_state == ENetPeerState::Zombie) + return; + + ResetQueues(); + + ENetProtocol command; + command.header.command = ENetProtocolCommand_Disconnect; + command.header.channelID = 0xFF; + command.disconnect.data = HostToNet(data); + + if (m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater) + command.header.command |= ENetProtocolFlag_Acknowledge; + else + command.header.command |= ENetProtocolFlag_Unsequenced; + + QueueOutgoingCommand(command, nullptr, 0, 0); + + if (m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater) + { + OnDisconnect(); + + m_state = ENetPeerState::Disconnecting; + } + else + { + m_host->Flush(); + + Reset(); + } + } + + void ENetPeer::DisconnectLater(UInt32 data) + { + if ((m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater) && + !m_outgoingReliableCommands.empty() && + !m_outgoingUnreliableCommands.empty() && + !m_sentReliableCommands.empty()) + { + m_state = ENetPeerState::DisconnectLater; + m_eventData = data; + } + else + Disconnect(data); + } + + void ENetPeer::DisconnectNow(UInt32 data) + { + if (m_state == ENetPeerState::Disconnected) + return; + + if (m_state != ENetPeerState::Zombie && m_state != ENetPeerState::Disconnecting) + { + ResetQueues(); + + ENetProtocol command; + command.header.command = ENetProtocolCommand_Disconnect | ENetProtocolFlag_Unsequenced; + command.header.channelID = 0xFF; + command.disconnect.data = HostToNet(data); + + QueueOutgoingCommand(command, nullptr, 0, 0); + + m_host->Flush(); + } + + Reset(); + } + + void ENetPeer::Ping() + { + if (m_state != ENetPeerState::Connected) + return; + + ENetProtocol command; + command.header.command = ENetProtocolCommand_Ping | ENetProtocolFlag_Acknowledge; + command.header.channelID = 0xFF; + + QueueOutgoingCommand(command, nullptr, 0, 0); + } + + bool ENetPeer::Receive(ENetPacketRef* packet, UInt8* channelId) + { + if (m_dispatchedCommands.empty()) + return false; + + IncomingCommmand& incomingCommand = m_dispatchedCommands.front(); + + m_totalWaitingData -= incomingCommand.packet->data.GetSize(); + + if (packet) + *packet = std::move(incomingCommand.packet); + + if (channelId) + *channelId = incomingCommand.command.header.channelID; + + m_dispatchedCommands.pop_front(); + + return true; + } + + void ENetPeer::Reset() + { + OnDisconnect(); + + m_outgoingPeerID = ENetConstants::ENetProtocol_MaximumPeerId; + m_connectID = 0; + + m_state = ENetPeerState::Disconnected; + + m_incomingBandwidth = 0; + m_outgoingBandwidth = 0; + m_incomingBandwidthThrottleEpoch = 0; + m_outgoingBandwidthThrottleEpoch = 0; + m_incomingDataTotal = 0; + m_outgoingDataTotal = 0; + m_lastSendTime = 0; + m_lastReceiveTime = 0; + m_nextTimeout = 0; + m_earliestTimeout = 0; + m_packetLossEpoch = 0; + m_packetsSent = 0; + m_packetsLost = 0; + m_packetLoss = 0; + m_packetLossVariance = 0; + m_packetThrottle = ENetConstants::ENetProtocol_MaximumWindowSize; + m_packetThrottleLimit = ENetConstants::ENetPeer_PacketThrottleScale; + m_packetThrottleCounter = 0; + m_packetThrottleEpoch = 0; + m_packetThrottleAcceleration = ENetConstants::ENetPeer_PacketThrottleAcceleration; + m_packetThrottleDeceleration = ENetConstants::ENetPeer_PacketThrottleDeceleration; + m_packetThrottleInterval = ENetConstants::ENetPeer_PacketThrottleInterval; + m_pingInterval = ENetConstants::ENetPeer_PingInterval; + m_timeoutLimit = ENetConstants::ENetPeer_TimeoutLimit; + m_timeoutMinimum = ENetConstants::ENetPeer_TimeoutMinimum; + m_timeoutMaximum = ENetConstants::ENetPeer_TimeoutMaximum; + m_lastRoundTripTime = ENetConstants::ENetPeer_DefaultRoundTripTime; + m_lowestRoundTripTime = ENetConstants::ENetPeer_DefaultRoundTripTime; + m_lastRoundTripTimeVariance = 0; + m_highestRoundTripTimeVariance = 0; + m_roundTripTime = ENetConstants::ENetPeer_DefaultRoundTripTime; + m_roundTripTimeVariance = 0; + m_mtu = m_host->m_mtu; + m_reliableDataInTransit = 0; + m_outgoingReliableSequenceNumber = 0; + m_windowSize = ENetConstants::ENetProtocol_MaximumWindowSize; + m_incomingUnsequencedGroup = 0; + m_outgoingUnsequencedGroup = 0; + m_eventData = 0; + m_totalWaitingData = 0; + + std::memset(m_unsequencedWindow, 0, sizeof(m_unsequencedWindow)); + + ResetQueues(); + } + + bool ENetPeer::Send(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet) + { + ENetPacket* enetPacket = m_packetPool.New(); + enetPacket->flags = flags; + enetPacket->data = std::move(packet); + enetPacket->owner = &m_packetPool; + + return Send(channelId, enetPacket); + } + + bool ENetPeer::Send(UInt8 channelId, ENetPacketRef packetRef) + { + if (m_state != ENetPeerState::Connected || channelId >= m_channels.size() || packetRef->data.GetSize() > m_host->m_maximumPacketSize) + return false; + + Channel& channel = m_channels[channelId]; + + std::size_t fragmentLength = m_mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment); + //if (m_host->m_checksum != nullptr) + // fragmentLength -= sizeof(UInt32); + + UInt32 packetSize = static_cast(packetRef->data.GetSize()); + if (packetSize > fragmentLength) + { + UInt32 fragmentCount = (packetSize + fragmentLength - 1) / fragmentLength; + UInt32 fragmentNumber; + UInt32 fragmentOffset; + + UInt8 commandNumber; + UInt16 startSequenceNumber; + + if (fragmentCount > ENetConstants::ENetProtocol_MaximumFragmentCount) + return false; + + if ((packetRef->flags & (ENetPacketFlag_Reliable | ENetPacketFlag_UnreliableFragment)) == ENetPacketFlag_UnreliableFragment && + channel.outgoingUnreliableSequenceNumber < 0xFFFF) + { + commandNumber = ENetProtocolCommand_SendUnreliable; + startSequenceNumber = HostToNet(channel.outgoingUnreliableSequenceNumber + 1); + } + else + { + commandNumber = ENetProtocolCommand_SendFragment | ENetProtocolFlag_Acknowledge; + startSequenceNumber = HostToNet(channel.outgoingReliableSequenceNumber + 1); + } + + for (fragmentNumber = 0, + fragmentOffset = 0; + fragmentOffset < packetSize; + ++fragmentNumber, + fragmentOffset += fragmentLength) + { + if (packetSize - fragmentOffset < fragmentLength) + fragmentLength = packetSize - fragmentOffset; + + OutgoingCommand outgoingCommand; + outgoingCommand.fragmentOffset = fragmentOffset; + outgoingCommand.fragmentLength = fragmentLength; + outgoingCommand.packet = packetRef; + outgoingCommand.command.header.command = commandNumber; + outgoingCommand.command.header.channelID = channelId; + outgoingCommand.command.sendFragment.startSequenceNumber = startSequenceNumber; + outgoingCommand.command.sendFragment.dataLength = HostToNet(fragmentLength); + outgoingCommand.command.sendFragment.fragmentCount = HostToNet(fragmentCount); + outgoingCommand.command.sendFragment.fragmentNumber = HostToNet(fragmentNumber); + outgoingCommand.command.sendFragment.totalLength = HostToNet(packetSize); + outgoingCommand.command.sendFragment.fragmentOffset = HostToNet(fragmentOffset); + + SetupOutgoingCommand(outgoingCommand); + } + + return true; + } + + ENetProtocol command; + command.header.channelID = channelId; + + if ((packetRef->flags & (ENetPacketFlag_Reliable | ENetPacketFlag_Unsequenced)) == ENetPacketFlag_Unsequenced) + command.header.command = ENetProtocolCommand_SendUnsequenced | ENetProtocolFlag_Unsequenced; + else if (packetRef->flags & ENetPacketFlag_Reliable || channel.outgoingUnreliableSequenceNumber >= 0xFFFF) + command.header.command = ENetProtocolCommand_SendReliable | ENetProtocolFlag_Acknowledge; + else + command.header.command = ENetProtocolCommand_SendUnreliable; + + QueueOutgoingCommand(command, packetRef, 0, packetSize); + + return true; + } + + void ENetPeer::ThrottleConfigure(UInt32 interval, UInt32 acceleration, UInt32 deceleration) + { + m_packetThrottleInterval = interval; + m_packetThrottleAcceleration = acceleration; + m_packetThrottleDeceleration = deceleration; + + ENetProtocol command; + command.header.command = ENetProtocolCommand_ThrottleConfigure | ENetProtocolFlag_Acknowledge; + command.header.channelID = 0xFF; + + command.throttleConfigure.packetThrottleInterval = HostToNet(interval); + command.throttleConfigure.packetThrottleAcceleration = HostToNet(acceleration); + command.throttleConfigure.packetThrottleDeceleration = HostToNet(deceleration); + + QueueOutgoingCommand(command, nullptr, 0, 0); + } + + void ENetPeer::InitIncoming(std::size_t channelCount, const IpAddress& address, ENetProtocolConnect& incomingCommand) + { + m_channels.resize(channelCount); + m_address = address; + + m_connectID = incomingCommand.connectID; + m_eventData = NetToHost(incomingCommand.data); + m_incomingBandwidth = NetToHost(incomingCommand.incomingBandwidth); + m_outgoingBandwidth = NetToHost(incomingCommand.outgoingBandwidth); + m_packetThrottleInterval = NetToHost(incomingCommand.packetThrottleInterval); + m_packetThrottleAcceleration = NetToHost(incomingCommand.packetThrottleAcceleration); + m_packetThrottleDeceleration = NetToHost(incomingCommand.packetThrottleDeceleration); + m_outgoingPeerID = NetToHost(incomingCommand.outgoingPeerID); + m_state = ENetPeerState::AcknowledgingConnect; + + UInt8 incomingSessionId, outgoingSessionId; + + incomingSessionId = incomingCommand.incomingSessionID == 0xFF ? m_outgoingSessionID : incomingCommand.incomingSessionID; + incomingSessionId = (incomingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); + if (incomingSessionId == m_outgoingSessionID) + incomingSessionId = (incomingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); + m_outgoingSessionID = incomingSessionId; + + outgoingSessionId = incomingCommand.outgoingSessionID == 0xFF ? m_incomingSessionID : incomingCommand.outgoingSessionID; + outgoingSessionId = (outgoingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); + if (outgoingSessionId == m_incomingSessionID) + outgoingSessionId = (outgoingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); + m_incomingSessionID = outgoingSessionId; + + m_mtu = Clamp(NetToHost(incomingCommand.mtu), ENetConstants::ENetProtocol_MinimumMTU, ENetConstants::ENetProtocol_MaximumMTU); + + if (m_host->m_outgoingBandwidth == 0 && m_incomingBandwidth == 0) + m_windowSize = ENetConstants::ENetProtocol_MaximumWindowSize; + else if (m_host->m_outgoingBandwidth == 0 || m_incomingBandwidth == 0) + m_windowSize = (std::max(m_host->m_outgoingBandwidth, m_incomingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + else + m_windowSize = (std::min(m_host->m_outgoingBandwidth, m_incomingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + + m_windowSize = Clamp(m_windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + } + + void ENetPeer::InitOutgoing(std::size_t channelCount, const IpAddress& address, UInt32 connectId, UInt32 windowSize) + { + m_channels.resize(channelCount); + + m_address = address; + m_connectID = connectId; + m_state = ENetPeerState::Connecting; + m_windowSize = Clamp(windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + } + + void ENetPeer::DispatchIncomingReliableCommands(Channel& channel) + { + auto currentCommand = channel.incomingReliableCommands.begin(); + for (; currentCommand != channel.incomingReliableCommands.end(); ++currentCommand) + { + IncomingCommmand& incomingCommand = *currentCommand; + + if (incomingCommand.fragmentsRemaining > 0 || incomingCommand.reliableSequenceNumber != (channel.incomingReliableSequenceNumber + 1)) + break; + + channel.incomingReliableSequenceNumber = incomingCommand.reliableSequenceNumber; + + if (!incomingCommand.fragments.empty()) + channel.incomingReliableSequenceNumber += incomingCommand.fragments.size() - 1; + } + + if (currentCommand == channel.incomingReliableCommands.begin()) + return; + + channel.incomingUnreliableSequenceNumber = 0; + + m_dispatchedCommands.splice(m_dispatchedCommands.end(), m_dispatchedCommands, channel.incomingReliableCommands.begin(), currentCommand); + + m_host->AddToDispatchQueue(this); + + if (!channel.incomingUnreliableCommands.empty()) + DispatchIncomingUnreliableCommands(channel); + } + + void ENetPeer::DispatchIncomingUnreliableCommands(Channel& channel) + { + std::list::iterator currentCommand; + std::list::iterator droppedCommand; + std::list::iterator startCommand; + + for (droppedCommand = startCommand = currentCommand = channel.incomingUnreliableCommands.begin(); + currentCommand != channel.incomingUnreliableCommands.end(); + ++currentCommand) + { + IncomingCommmand& incomingCommand = *currentCommand; + + if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) == ENetProtocolCommand_SendUnsequenced) + continue; + + if (incomingCommand.reliableSequenceNumber == channel.incomingReliableSequenceNumber) + { + if (incomingCommand.fragmentsRemaining <= 0) + { + channel.incomingUnreliableSequenceNumber = incomingCommand.unreliableSequenceNumber; + continue; + } + + if (startCommand != currentCommand) + { + m_dispatchedCommands.splice(m_dispatchedCommands.end(), m_dispatchedCommands, startCommand, currentCommand); + + m_host->AddToDispatchQueue(this); + + droppedCommand = currentCommand; + } + else if (droppedCommand != currentCommand) + { + droppedCommand = currentCommand; + --droppedCommand; + } + } + else + { + UInt16 reliableWindow = incomingCommand.reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + + if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + reliableWindow += ENetConstants::ENetPeer_ReliableWindows; + + if (reliableWindow >= currentWindow && reliableWindow < currentWindow + ENetConstants::ENetPeer_ReliableWindowSize - 1) + break; + + droppedCommand = currentCommand; + ++droppedCommand; + + if (startCommand != currentCommand) + { + m_dispatchedCommands.splice(m_dispatchedCommands.end(), m_dispatchedCommands, startCommand, currentCommand); + + m_host->AddToDispatchQueue(this); + } + } + + startCommand = currentCommand; + ++startCommand; + } + + if (startCommand != currentCommand) + { + m_dispatchedCommands.splice(m_dispatchedCommands.end(), m_dispatchedCommands, startCommand, currentCommand); + + m_host->AddToDispatchQueue(this); + + droppedCommand = currentCommand; + } + + channel.incomingUnreliableCommands.erase(channel.incomingUnreliableCommands.begin(), droppedCommand); + } + + void ENetPeer::OnConnect() + { + if (m_state != ENetPeerState::Connected && m_state != ENetPeerState::DisconnectLater) + { + if (m_incomingBandwidth != 0) + ++m_host->m_bandwidthLimitedPeers; + + ++m_host->m_connectedPeers; + } + } + + void ENetPeer::OnDisconnect() + { + if (m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater) + { + if (m_incomingBandwidth != 0) + --m_host->m_bandwidthLimitedPeers; + + --m_host->m_connectedPeers; + } + } + + ENetProtocolCommand ENetPeer::RemoveSentReliableCommands(UInt16 reliableSequenceNumber, UInt8 channelId) + { + std::list* commandList = nullptr; + + bool found = true; + auto currentCommand = m_sentReliableCommands.begin(); + commandList = &m_sentReliableCommands; + for (; currentCommand != m_sentReliableCommands.end(); ++currentCommand) + { + found = true; + + if (currentCommand->reliableSequenceNumber == reliableSequenceNumber && + currentCommand->command.header.channelID == channelId) + break; + } + + bool wasSent = true; + if (currentCommand == m_sentReliableCommands.end()) + { + currentCommand = m_outgoingReliableCommands.begin(); + commandList = &m_sentReliableCommands; + for (; currentCommand != m_outgoingReliableCommands.end(); ++currentCommand) + { + found = true; + + if (currentCommand->sendAttempts < 1) + return ENetProtocolCommand_None; + + if (currentCommand->reliableSequenceNumber == reliableSequenceNumber && + currentCommand->command.header.channelID == channelId) + break; + } + + if (currentCommand == m_outgoingReliableCommands.end()) + return ENetProtocolCommand_None; + + wasSent = false; + } + + if (!found) //< Really useful? + return ENetProtocolCommand_None; + + if (channelId < m_channels.size()) + { + Channel& channel = m_channels[channelId]; + + UInt16 reliableWindow = reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + if (channel.reliableWindows[reliableWindow] > 0) + { + --channel.reliableWindows[reliableWindow]; + if (!channel.reliableWindows[reliableWindow]) + channel.usedReliableWindows &= ~(1 << reliableWindow); + } + } + + ENetProtocolCommand commandNumber = static_cast(currentCommand->command.header.command & ENetProtocolCommand_Mask); + + if (currentCommand->packet && wasSent) + m_reliableDataInTransit -= currentCommand->fragmentLength; + + commandList->erase(currentCommand); + + if (m_sentReliableCommands.empty()) + return commandNumber; + + currentCommand = m_sentReliableCommands.begin(); + m_nextTimeout = currentCommand->sentTime + currentCommand->roundTripTimeout; + + return commandNumber; + } + + void ENetPeer::RemoveSentUnreliableCommands() + { + m_sentUnreliableCommands.clear(); + } + + void ENetPeer::ResetQueues() + { + m_host->RemoveFromDispatchQueue(this); + + m_acknowledgements.clear(); + m_dispatchedCommands.clear(); + m_outgoingReliableCommands.clear(); + m_outgoingUnreliableCommands.clear(); + m_sentReliableCommands.clear(); + m_sentUnreliableCommands.clear(); + + m_channels.clear(); + } + + bool ENetPeer::QueueAcknowledgement(ENetProtocol& command, UInt16 sentTime) + { + if (command.header.channelID < m_channels.size()) + { + Channel& channel = m_channels[command.header.channelID]; + + UInt16 reliableWindow = command.header.reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + + if (command.header.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + reliableWindow += ENetConstants::ENetPeer_ReliableWindows; + + if (reliableWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1 && reliableWindow <= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows) + return false; + } + + Acknowledgement acknowledgment; + acknowledgment.command = command; + acknowledgment.sentTime = sentTime; + + m_outgoingDataTotal += sizeof(Acknowledgement); + + m_acknowledgements.emplace_back(acknowledgment); + + return true; + } + + ENetPeer::IncomingCommmand* ENetPeer::QueueIncomingCommand(ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount) + { + static IncomingCommmand dummyCommand; + + UInt32 reliableSequenceNumber = 0; + UInt32 unreliableSequenceNumber = 0; + UInt16 reliableWindow; + UInt16 currentWindow; + + auto discardCommand = [&]() -> IncomingCommmand* + { + if (fragmentCount > 0) + return nullptr; //< Error + + return &dummyCommand; + }; + + if (m_state == ENetPeerState::DisconnectLater) + return discardCommand(); + + Channel& channel = m_channels[command.header.channelID]; + + if ((command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendUnsequenced) + { + reliableSequenceNumber = command.header.reliableSequenceNumber; + reliableWindow = reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + + if (reliableSequenceNumber < channel.incomingReliableSequenceNumber) + reliableWindow += ENetConstants::ENetPeer_ReliableWindows; + + if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1) + return discardCommand(); + } + + std::list* commandList = nullptr; + std::list::reverse_iterator currentCommand; + + switch (command.header.command & ENetProtocolCommand_Mask) + { + case ENetProtocolCommand_SendFragment: + case ENetProtocolCommand_SendReliable: + { + if (reliableSequenceNumber == channel.incomingReliableSequenceNumber) + return discardCommand(); + + commandList = &channel.incomingReliableCommands; + + for (currentCommand = channel.incomingReliableCommands.rbegin(); currentCommand != channel.incomingReliableCommands.rend(); ++currentCommand) + { + IncomingCommmand& incomingCommand = *currentCommand; + + if (reliableSequenceNumber >= channel.incomingReliableSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + continue; + } + else + if (incomingCommand.reliableSequenceNumber >= channel.incomingReliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber <= reliableSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < reliableSequenceNumber) + break; + + return discardCommand(); + } + } + break; + } + + case ENetProtocolCommand_SendUnreliable: + case ENetProtocolCommand_SendUnreliableFragment: + { + unreliableSequenceNumber = NetToHost(command.sendUnreliable.unreliableSequenceNumber); + + if (reliableSequenceNumber == channel.incomingReliableSequenceNumber && unreliableSequenceNumber <= channel.incomingUnreliableSequenceNumber) + return discardCommand(); + + commandList = &channel.incomingUnreliableCommands; + + for (currentCommand = channel.incomingUnreliableCommands.rbegin(); currentCommand != channel.incomingUnreliableCommands.rend(); ++currentCommand) + { + IncomingCommmand& incomingCommand = *currentCommand; + + if ((command.header.command & ENetProtocolCommand_Mask) == ENetProtocolCommand_SendUnsequenced) //< wtf + continue; + + if (reliableSequenceNumber >= channel.incomingReliableSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + continue; + } + else + if (incomingCommand.reliableSequenceNumber >= channel.incomingReliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber < reliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber > reliableSequenceNumber) + continue; + + if (incomingCommand.unreliableSequenceNumber <= unreliableSequenceNumber) + { + if (incomingCommand.unreliableSequenceNumber < unreliableSequenceNumber) + break; + + return discardCommand(); + } + } + break; + } + + case ENetProtocolCommand_SendUnsequenced: + { + commandList = &channel.incomingUnreliableCommands; + + currentCommand = channel.incomingUnreliableCommands.rend(); + break; + } + + default: + return discardCommand(); + } + + if (m_totalWaitingData >= m_host->m_maximumWaitingData) + return nullptr; + + ENetPacket* packet = m_packetPool.New(); + packet->flags = flags; + packet->data.Reset(0, data, dataLength); + packet->owner = &m_packetPool; + + IncomingCommmand incomingCommand; + incomingCommand.reliableSequenceNumber = command.header.reliableSequenceNumber; + incomingCommand.unreliableSequenceNumber = unreliableSequenceNumber & 0xFFFF; + incomingCommand.command = command; + incomingCommand.packet = packet; + incomingCommand.fragments.resize(fragmentCount, 0); + incomingCommand.fragmentsRemaining = fragmentCount; + + auto it = commandList->insert(currentCommand.base(), incomingCommand); + + switch (command.header.command & ENetProtocolCommand_Mask) + { + case ENetProtocolCommand_SendFragment: + case ENetProtocolCommand_SendReliable: + DispatchIncomingReliableCommands(channel); + break; + + default: + DispatchIncomingUnreliableCommands(channel); + break; + } + + return &(*it); + } + + void ENetPeer::QueueOutgoingCommand(ENetProtocol& command, ENetPacketRef packet, UInt32 offset, UInt16 length) + { + OutgoingCommand outgoingCommand; + outgoingCommand.command = command; + outgoingCommand.fragmentLength = length; + outgoingCommand.fragmentOffset = length; + outgoingCommand.packet = packet; + + SetupOutgoingCommand(outgoingCommand); + } + + void ENetPeer::SetupOutgoingCommand(OutgoingCommand& outgoingCommand) + { + m_outgoingDataTotal += enet_protocol_command_size(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength; + + if (outgoingCommand.command.header.channelID == 0xFF) + { + ++m_outgoingReliableSequenceNumber; + + outgoingCommand.reliableSequenceNumber = m_outgoingReliableSequenceNumber; + outgoingCommand.unreliableSequenceNumber = 0; + } + else + { + Channel* channel = &m_channels[outgoingCommand.command.header.channelID]; + if (outgoingCommand.command.header.command & ENetProtocolFlag_Acknowledge) + { + ++channel->outgoingReliableSequenceNumber; + channel->outgoingUnreliableSequenceNumber = 0; + + outgoingCommand.reliableSequenceNumber = channel->outgoingReliableSequenceNumber; + outgoingCommand.unreliableSequenceNumber = 0; + } + else if (outgoingCommand.command.header.command & ENetProtocolFlag_Unsequenced) + { + ++m_outgoingUnsequencedGroup; + + outgoingCommand.reliableSequenceNumber = 0; + outgoingCommand.unreliableSequenceNumber = 0; + } + else + { + if (outgoingCommand.fragmentOffset == 0) + ++channel->outgoingUnreliableSequenceNumber; + + outgoingCommand.reliableSequenceNumber = channel->outgoingReliableSequenceNumber; + outgoingCommand.unreliableSequenceNumber = channel->outgoingUnreliableSequenceNumber; + } + } + + outgoingCommand.sendAttempts = 0; + outgoingCommand.sentTime = 0; + outgoingCommand.roundTripTimeout = 0; + outgoingCommand.roundTripTimeoutLimit = 0; + outgoingCommand.command.header.reliableSequenceNumber = HostToNet(outgoingCommand.reliableSequenceNumber); + + switch (outgoingCommand.command.header.command & ENetProtocolCommand_Mask) + { + case ENetProtocolCommand_SendUnreliable: + outgoingCommand.command.sendUnreliable.unreliableSequenceNumber = HostToNet(outgoingCommand.unreliableSequenceNumber); + break; + + case ENetProtocolCommand_SendUnsequenced: + outgoingCommand.command.sendUnsequenced.unsequencedGroup = HostToNet(m_outgoingUnsequencedGroup); + break; + + default: + break; + } + + if (outgoingCommand.command.header.command & ENetProtocolCommand_Acknowledge) + m_outgoingReliableCommands.emplace_back(outgoingCommand); + else + m_outgoingUnreliableCommands.emplace_back(outgoingCommand); + } + + int ENetPeer::Throttle(UInt32 rtt) + { + if (m_lastRoundTripTime <= m_lastRoundTripTimeVariance) + m_packetThrottle = m_packetThrottleLimit; + else + { + if (rtt < m_lastRoundTripTime) + { + m_packetThrottle = std::max(m_packetThrottle + m_packetThrottleAcceleration, m_packetThrottleLimit); + return 1; + } + else if (rtt > m_lastRoundTripTime + 2 * m_lastRoundTripTimeVariance) + { + if (m_packetThrottle > m_packetThrottleDeceleration) + m_packetThrottle -= m_packetThrottleDeceleration; + else + m_packetThrottle = 0; + + return -1; + } + } + + return 0; + } +} \ No newline at end of file diff --git a/src/Nazara/Network/ENetSocket.cpp b/src/Nazara/Network/ENetSocket.cpp new file mode 100644 index 000000000..e86313fb4 --- /dev/null +++ b/src/Nazara/Network/ENetSocket.cpp @@ -0,0 +1,642 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + /*! + * \ingroup network + * \class Nz::ENetConnection + * \brief Network class that represents a reliable UDP connection, based on ENet library + */ + + /*! + * \brief Constructs a RUdpConnection object by default + */ + + ENetSocket::ENetSocket() : + m_bandwidthThrottleEpoch(0), + m_mtu(ENetConstants::DefaultMTU), + m_isSimulationEnabled(false), + m_shouldAcceptConnections(true) + { + m_randomSeed = *reinterpret_cast(this); + m_randomSeed += s_randomGenerator(); + m_randomSeed = (m_randomSeed << 16) | (m_randomSeed >> 16); + + } + + /*! + * \brief Connects to the IpAddress + * \return true + * + * \param remoteAddress Address to connect to + * + * \remark Produces a NazaraAssert if socket is not bound + * \remark Produces a NazaraAssert if remote is invalid + * \remark Produces a NazaraAssert if port is not specified + */ + + bool RUdpConnection::Connect(const IpAddress& remoteAddress) + { + NazaraAssert(m_socket.GetState() == SocketState_Bound, "Socket must be bound first"); + NazaraAssert(remoteAddress.IsValid(), "Invalid remote address"); + NazaraAssert(remoteAddress.GetPort() != 0, "Remote address has no port"); + + PeerData& client = RegisterPeer(remoteAddress, PeerState_Connecting); + client.stateData1 = s_randomGenerator(); + + NetPacket connectionRequestPacket(NetCode_RequestConnection); + connectionRequestPacket << client.stateData1; + + EnqueuePacket(client, PacketPriority_Immediate, PacketReliability_Reliable, connectionRequestPacket); + return true; + } + + /*! + * \brief Connects to the hostname + * \return true If successful + * + * \param hostName Hostname of the remote + * \param protocol Net protocol to use + * \param service Specify the protocol used + * \param error Optional argument to get the error + */ + + bool RUdpConnection::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error) + { + std::vector results = IpAddress::ResolveHostname(protocol, hostName, service, error); + if (results.empty()) + { + m_lastError = SocketError_ResolveError; + return false; + } + + IpAddress hostnameAddress; + for (const HostnameInfo& result : results) + { + if (!result.address) + continue; + + if (result.socketType != SocketType_UDP) + continue; + + hostnameAddress = result.address; + break; //< Take first valid address + } + + return Connect(hostnameAddress); + } + + /*! + * \brief Listens to a socket + * \return true If successfully bound + * + * \param remoteAddress Address to listen to + */ + + bool RUdpConnection::Listen(const IpAddress& address) + { + if (!InitSocket(address.GetProtocol())) + return false; + + return m_socket.Bind(address) == SocketState_Bound; + } + + /*! + * \brief Polls the message + * \return true If there is a message + * + * \param message Message to poll + * + * \remark Produces a NazaraAssert if message is invalid + */ + + bool RUdpConnection::PollMessage(RUdpMessage* message) + { + NazaraAssert(message, "Invalid message"); + + if (m_receivedMessages.empty()) + return false; + + *message = std::move(m_receivedMessages.front()); + m_receivedMessages.pop(); + return true; + } + + /*! + * \brief Sends the packet to a peer + * \return true If peer exists (false may result from disconnected client) + * + * \param peerIp IpAddress of the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + + bool RUdpConnection::Send(const IpAddress& peerIp, PacketPriority priority, PacketReliability reliability, const NetPacket& packet) + { + auto it = m_peerByIP.find(peerIp); + if (it == m_peerByIP.end()) + return false; /// Silently fail (probably a disconnected client) + + EnqueuePacket(m_peers[it->second], priority, reliability, packet); + return true; + } + + /*! + * \brief Updates the reliable connection + */ + + void RUdpConnection::Update() + { + m_currentTime = m_clock.GetMicroseconds(); + + NetPacket receivedPacket; + IpAddress senderIp; + while (m_socket.ReceivePacket(&receivedPacket, &senderIp)) + OnPacketReceived(senderIp, std::move(receivedPacket)); + + //for (unsigned int i = m_activeClients.FindFirst(); i != m_activeClients.npos; i = m_activeClients.FindNext(i)) + //{ + // PeerData& clientData = m_peers[i]; + + CallOnExit resetIterator([this] () { m_peerIterator = m_peers.size(); }); + + for (m_peerIterator = 0; m_peerIterator < m_peers.size(); ++m_peerIterator) + { + PeerData& peer = m_peers[m_peerIterator]; + + UInt32 timeSinceLastPacket = static_cast(m_currentTime - peer.lastPacketTime); + if (timeSinceLastPacket > m_timeBeforeTimeOut) + { + DisconnectPeer(peer.index); + continue; + } + else if (timeSinceLastPacket > m_timeBeforePing) + { + if (m_currentTime - peer.lastPingTime > m_pingInterval) + { + NetPacket pingPacket(NetCode_Ping); + EnqueuePacket(peer, PacketPriority_Low, PacketReliability_Unreliable, pingPacket); + } + } + + if (peer.state == PeerState_WillAck && m_currentTime - peer.stateData1 > m_forceAckSendTime) + { + NetPacket acknowledgePacket(NetCode_Acknowledge); + EnqueuePacket(peer, PacketPriority_Low, PacketReliability_Reliable, acknowledgePacket); + } + + for (unsigned int priority = PacketPriority_Highest; priority <= PacketPriority_Lowest; ++priority) + { + std::vector& pendingPackets = peer.pendingPackets[priority]; + for (PendingPacket& packetData : pendingPackets) + SendPacket(peer, std::move(packetData)); + + pendingPackets.clear(); + } + + auto it = peer.pendingAckQueue.begin(); + while (it != peer.pendingAckQueue.end()) + { + if (m_currentTime - it->timeSent > 2 * peer.roundTripTime) + { + OnPacketLost(peer, std::move(*it)); + it = peer.pendingAckQueue.erase(it); + } + else + ++it; + } + } + //m_activeClients.Reset(); + } + + /*! + * \brief Disconnects a peer + * + * \param peerIndex Index of the peer + * + * \remark Produces a NazaraNotice + */ + + void RUdpConnection::DisconnectPeer(std::size_t peerIndex) + { + PeerData& peer = m_peers[peerIndex]; + NazaraNotice(m_socket.GetBoundAddress().ToString() + ": " + peer.address.ToString() + " has been disconnected due to time-out"); + + OnPeerDisconnected(this, peer.address); + + // Remove from IP lookup table + m_peerByIP.erase(peer.address); + + // Can we safely "remove" this slot? + if (m_peerIterator >= m_peers.size() - 1 || peerIndex > m_peerIterator) + { + // Yes we can + PeerData& newSlot = m_peers[peerIndex]; + newSlot = std::move(m_peers.back()); + newSlot.index = peerIndex; //< Update the moved slot index before resizing (in case it's the last one) + } + else + { + // Nope, let's be tricky + PeerData& current = m_peers[m_peerIterator]; + PeerData& newSlot = m_peers[peerIndex]; + + newSlot = std::move(current); + newSlot.index = peerIndex; //< Update the moved slot index + + current = std::move(m_peers.back()); + current.index = m_peerIterator; //< Update the moved slot index + + --m_peerIterator; + } + + // Pop the last entry (from where we moved our slot) + m_peers.pop_back(); + } + + /*! + * \brief Enqueues a packet in the sending list + * + * \param peer Data relative to the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + + void RUdpConnection::EnqueuePacket(PeerData& peer, PacketPriority priority, PacketReliability reliability, const NetPacket& packet) + { + UInt16 protocolBegin = static_cast(m_protocol & 0xFFFF); + UInt16 protocolEnd = static_cast((m_protocol & 0xFFFF0000) >> 16); + + NetPacket data(packet.GetNetCode(), MessageHeader + packet.GetDataSize() + MessageFooter); + data << protocolBegin; + + data.GetStream()->SetCursorPos(NetPacket::HeaderSize + MessageHeader); + data.Write(packet.GetConstData() + NetPacket::HeaderSize, packet.GetDataSize()); + + data << protocolEnd; + EnqueuePacketInternal(peer, priority, reliability, std::move(data)); + } + + /*! + * \brief Enqueues internally a packet in the sending list + * + * \param peer Data relative to the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + + void RUdpConnection::EnqueuePacketInternal(PeerData& peer, PacketPriority priority, PacketReliability reliability, NetPacket&& data) + { + PendingPacket pendingPacket; + pendingPacket.data = std::move(data); + pendingPacket.priority = priority; + pendingPacket.reliability = reliability; + + peer.pendingPackets[priority].emplace_back(std::move(pendingPacket)); + m_activeClients.UnboundedSet(peer.index); + } + + /*! + * \brief Inits the internal socket + * \return true If successful + * + * \param protocol Net protocol to use + */ + + bool ENetSocket::InitSocket(NetProtocol protocol) + { + CallOnExit updateLastError([this] + { + m_lastError = m_socket.GetLastError(); + }); + + if (!m_socket.Create(protocol)) + return false; + + m_socket.EnableBlocking(false); + m_socket.SetReceiveBufferSize(ENetConstants::ReceiveBufferSize); + m_socket.SetSendBufferSize(ENetConstants::SendBufferSize); + + return true; + } + + /*! + * \brief Processes the acks + * + * \param peer Data relative to the peer + * \param lastAck Last index of the ack + * \param ackBits Bits for acking + */ + + void RUdpConnection::ProcessAcks(PeerData& peer, SequenceIndex lastAck, UInt32 ackBits) + { + auto it = peer.pendingAckQueue.begin(); + while (it != peer.pendingAckQueue.end()) + { + bool acked = false; + if (lastAck == it->sequenceId) + acked = true; + else if (!IsAckMoreRecent(it->sequenceId, lastAck)) + { + unsigned int difference = ComputeSequenceDifference(lastAck, it->sequenceId); + if (difference <= 32) + acked = (ackBits >> (difference - 1)) & 1; + } + + if (acked) + { + it = peer.pendingAckQueue.erase(it); + } + else + ++it; + } + } + + /*! + * \brief Registers a peer + * \return Data relative to the peer + * + * \param address Address of the peer + * \param state Status of the peer + */ + + RUdpConnection::PeerData& RUdpConnection::RegisterPeer(const IpAddress& address, PeerState state) + { + PeerData data; + data.address = address; + data.localSequence = 0; + data.remoteSequence = 0; + data.index = m_peers.size(); + data.lastPacketTime = m_currentTime; + data.lastPingTime = m_currentTime; + data.roundTripTime = 1'000'000; ///< Okay that's quite a lot + data.state = state; + + m_activeClients.UnboundedSet(data.index); + m_peerByIP[address] = data.index; + + m_peers.emplace_back(std::move(data)); + return m_peers.back(); + } + + /*! + * \brief Operation to do when client requests a connection + * + * \param address Address of the peer + * \param sequenceId Sequence index for the ack + * \param token Token for connection + */ + + void RUdpConnection::OnClientRequestingConnection(const IpAddress& address, SequenceIndex sequenceId, UInt64 token) + { + // Call hook to check if client should be accepted or not + OnPeerConnection(this, address); + + PeerData& client = RegisterPeer(address, PeerState_Aknowledged); + client.remoteSequence = sequenceId; + + /// Acknowledge connection + NetPacket connectionAcceptedPacket(NetCode_AcknowledgeConnection); + //connectionAcceptedPacket << address; + connectionAcceptedPacket << ~token; + + EnqueuePacket(client, PacketPriority_Immediate, PacketReliability_Reliable, connectionAcceptedPacket); + } + + /*! + * \brief Operation to do when a packet is lost + * + * \param peer Data relative to the peer + * \param packet Pending packet + */ + + void RUdpConnection::OnPacketLost(PeerData& peer, PendingAckPacket&& packet) + { + //NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Lost packet " + String::Number(packet.sequenceId)); + + if (IsReliable(packet.reliability)) + EnqueuePacketInternal(peer, packet.priority, packet.reliability, std::move(packet.data)); + } + + /*! + * \brief Operation to do when receiving a packet + * + * \param peerIndex Index of the peer + * + * \remark Produces a NazaraNotice + */ + + void RUdpConnection::OnPacketReceived(const IpAddress& peerIp, NetPacket&& packet) + { + UInt16 protocolBegin; + UInt16 protocolEnd; + SequenceIndex sequenceId; + SequenceIndex lastAck; + UInt32 ackBits; + + packet.GetStream()->SetCursorPos(packet.GetSize() - MessageFooter); + packet >> protocolEnd; + + packet.GetStream()->SetCursorPos(NetPacket::HeaderSize); + packet >> protocolBegin; + + UInt32 protocolId = static_cast(protocolEnd) << 16 | protocolBegin; + if (protocolId != m_protocol) + return; ///< Ignore + + packet >> sequenceId >> lastAck >> ackBits; + + auto it = m_peerByIP.find(peerIp); + if (it == m_peerByIP.end()) + { + switch (packet.GetNetCode()) + { + case NetCode_RequestConnection: + { + UInt64 token; + packet >> token; + + NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_RequestConnection from " + peerIp.ToString() + ": " + String::Number(token)); + if (!m_shouldAcceptConnections) + return; //< Ignore + + OnClientRequestingConnection(peerIp, sequenceId, token); + break; + } + + default: + return; //< Ignore + } + } + else + { + PeerData& peer = m_peers[it->second]; + peer.lastPacketTime = m_currentTime; + + if (peer.receivedQueue.find(sequenceId) != peer.receivedQueue.end()) + return; //< Ignore + + if (m_isSimulationEnabled && m_packetLossProbability(s_randomGenerator)) + { + NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Lost packet " + String::Number(sequenceId) + " from " + peerIp.ToString() + " for simulation purpose"); + return; + } + + ///< Receiving a packet from an acknowledged client means the connection works in both ways + if (peer.state == PeerState_Aknowledged && packet.GetNetCode() != NetCode_RequestConnection) + { + peer.state = PeerState_Connected; + OnPeerAcknowledged(this, peerIp); + } + + if (IsAckMoreRecent(sequenceId, peer.remoteSequence)) + peer.remoteSequence = sequenceId; + + ProcessAcks(peer, lastAck, ackBits); + + peer.receivedQueue.insert(sequenceId); + + switch (packet.GetNetCode()) + { + case NetCode_Acknowledge: + return; //< Do not switch to will ack mode (to prevent infinite replies, just let's ping/pong do that) + + case NetCode_AcknowledgeConnection: + { + if (peer.state == PeerState_Connected) + break; + + IpAddress externalAddress; + UInt64 token; + packet /*>> externalAddress*/ >> token; + + NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_AcknowledgeConnection from " + peerIp.ToString() + ": " + String::Number(token)); + if (token == ~peer.stateData1) + { + peer.state = PeerState_Connected; + OnConnectedToPeer(this); + } + else + { + NazaraNotice("Received wrong token (" + String::Number(token) + " instead of " + String::Number(~peer.stateData1) + ") from client " + peer.address); + return; //< Ignore + } + + break; + } + + case NetCode_RequestConnection: + NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_RequestConnection from " + peerIp.ToString()); + return; //< Ignore + + case NetCode_Ping: + { + NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_Ping from " + peerIp.ToString()); + + NetPacket pongPacket(NetCode_Pong); + EnqueuePacket(peer, PacketPriority_Low, PacketReliability_Unreliable, pongPacket); + break; + } + + case NetCode_Pong: + NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_Pong from " + peerIp.ToString()); + break; + + default: + { + NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received 0x" + String::Number(packet.GetNetCode(), 16) + " from " + peerIp.ToString()); + RUdpMessage receivedMessage; + receivedMessage.from = peerIp; + receivedMessage.data = std::move(packet); + + m_receivedMessages.emplace(std::move(receivedMessage)); + break; + } + } + + if (!HasPendingPackets(peer)) + { + peer.state = PeerState_WillAck; + peer.stateData1 = m_currentTime; + } + } + } + + /*! + * \brief Sends a packet to a peer + * + * \param peer Data relative to the peer + * \param packet Pending packet + */ + + void RUdpConnection::SendPacket(PeerData& peer, PendingPacket&& packet) + { + if (peer.state == PeerState_WillAck) + peer.state = PeerState_Connected; + + SequenceIndex remoteSequence = peer.remoteSequence; + + UInt32 previousAcks = 0; + for (SequenceIndex ack : peer.receivedQueue) + { + if (ack == remoteSequence) + continue; + + unsigned int difference = ComputeSequenceDifference(remoteSequence, ack); + if (difference <= 32U) + previousAcks |= (1U << (difference - 1)); + } + + SequenceIndex sequenceId = ++peer.localSequence; + + packet.data.GetStream()->SetCursorPos(NetPacket::HeaderSize + sizeof(UInt16)); ///< Protocol begin has already been filled + packet.data << sequenceId; + packet.data << remoteSequence; + packet.data << previousAcks; + + m_socket.SendPacket(peer.address, packet.data); + + PendingAckPacket pendingAckPacket; + pendingAckPacket.data = std::move(packet.data); + pendingAckPacket.priority = packet.priority; + pendingAckPacket.reliability = packet.reliability; + pendingAckPacket.sequenceId = sequenceId; + pendingAckPacket.timeSent = m_currentTime; + + peer.pendingAckQueue.emplace_back(std::move(pendingAckPacket)); + } + + /*! + * \brief Initializes the RUdpConnection class + * \return true + */ + + bool RUdpConnection::Initialize() + { + std::random_device device; + s_randomGenerator.seed(device()); + + return true; + } + + /*! + * \brief Uninitializes the RUdpConnection class + */ + + void RUdpConnection::Uninitialize() + { + } + + std::mt19937_64 RUdpConnection::s_randomGenerator; +} From 12b4073033d3ef2a360a7cf61484ec7242ea7572 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Jan 2017 09:28:41 +0100 Subject: [PATCH 066/243] Progress --- include/Nazara/Network/ENetHost.hpp | 8 +- include/Nazara/Network/ENetPeer.hpp | 8 +- src/Nazara/Network/ENetHost.cpp | 443 ++++++++++++++++++++++++++-- src/Nazara/Network/ENetPeer.cpp | 43 +-- 4 files changed, 433 insertions(+), 69 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 87d4dd37b..03d10d541 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -63,9 +63,15 @@ namespace Nz bool DispatchIncomingCommands(ENetEvent* event); + bool HandleAcknowledge(ENetEvent* event, ENetPeer* peer, const ENetProtocol* command); + bool HandleBandwidthLimit(ENetPeer* peer, const ENetProtocol* command); ENetPeer* HandleConnect(ENetProtocolHeader* header, ENetProtocol* command); + bool HandleDisconnect(ENetPeer* peer, const ENetProtocol* command); bool HandleIncomingCommands(ENetEvent* event); - bool HandleSendReliable(ENetPeer& peer, const ENetProtocol& command, UInt8** currentData); + bool HandlePing(ENetPeer* peer, const ENetProtocol* command); + bool HandleSendReliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); + bool HandleThrottleConfigure(ENetPeer* peer, const ENetProtocol* command); + bool HandleVerifyConnect(ENetEvent* event, ENetPeer* peer, ENetProtocol* command); int ReceiveIncomingCommands(ENetEvent* event); diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 4ae8ca16b..7d522f203 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -74,15 +74,15 @@ namespace Nz void OnConnect(); void OnDisconnect(); - ENetProtocolCommand RemoveSentReliableCommands(UInt16 reliableSequenceNumber, UInt8 channelId); + ENetProtocolCommand RemoveSentReliableCommand(UInt16 reliableSequenceNumber, UInt8 channelId); void RemoveSentUnreliableCommands(); void ResetQueues(); - - bool QueueAcknowledgement(ENetProtocol& command, UInt16 sentTime); + + bool QueueAcknowledgement(ENetProtocol* command, UInt16 sentTime); IncomingCommmand* QueueIncomingCommand(ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount); void QueueOutgoingCommand(ENetProtocol& command, ENetPacketRef packet, UInt32 offset, UInt16 length); - + void SetupOutgoingCommand(OutgoingCommand& outgoingCommand); int Throttle(UInt32 rtt); diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 05179e615..5bb9b7bdf 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -27,7 +27,7 @@ namespace Nz return value; #endif } - + /// Temporary template T NetToHost(T value) @@ -39,6 +39,31 @@ namespace Nz #endif } + namespace + { + static std::size_t s_commandSizes[ENetProtocolCommand_Count] = + { + 0, + sizeof(ENetProtocolAcknowledge), + sizeof(ENetProtocolConnect), + sizeof(ENetProtocolVerifyConnect), + sizeof(ENetProtocolDisconnect), + sizeof(ENetProtocolPing), + sizeof(ENetProtocolSendReliable), + sizeof(ENetProtocolSendUnreliable), + sizeof(ENetProtocolSendFragment), + sizeof(ENetProtocolSendUnsequenced), + sizeof(ENetProtocolBandwidthLimit), + sizeof(ENetProtocolThrottleConfigure), + sizeof(ENetProtocolSendFragment) + }; + + std::size_t enet_protocol_command_size(UInt8 commandNumber) + { + return s_commandSizes[commandNumber & ENetProtocolCommand_Mask]; + } + } + void ENetHost::Broadcast(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet) { @@ -372,6 +397,116 @@ namespace Nz return false; } + bool ENetHost::HandleAcknowledge(ENetEvent* event, ENetPeer* peer, const ENetProtocol* command) + { + if (peer->m_state == ENetPeerState::Disconnected || peer->m_state == ENetPeerState::Zombie) + return true; + + UInt32 receivedSentTime = NetToHost(command->acknowledge.receivedSentTime); + receivedSentTime |= m_serviceTime & 0xFFFF0000; + if ((receivedSentTime & 0x8000) > (m_serviceTime & 0x8000)) + receivedSentTime -= 0x10000; + + if (ENET_TIME_LESS(m_serviceTime, receivedSentTime)) + return true; + + peer->m_lastReceiveTime = m_serviceTime; + peer->m_earliestTimeout = 0; + + UInt32 roundTripTime = ENET_TIME_DIFFERENCE(m_serviceTime, receivedSentTime); + + peer->Throttle(roundTripTime); + + peer->m_roundTripTimeVariance -= peer->m_roundTripTimeVariance / 4; + + if (roundTripTime >= peer->m_roundTripTime) + { + peer->m_roundTripTime += (roundTripTime - peer->m_roundTripTime) / 8; + peer->m_roundTripTimeVariance += (roundTripTime - peer->m_roundTripTime) / 4; + } + else + { + peer->m_roundTripTime -= (peer->m_roundTripTime - roundTripTime) / 8; + peer->m_roundTripTimeVariance += (peer->m_roundTripTime - roundTripTime) / 4; + } + + if (peer->m_roundTripTime < peer->m_lowestRoundTripTime) + peer->m_lowestRoundTripTime = peer->m_roundTripTime; + + if (peer->m_roundTripTimeVariance > peer->m_highestRoundTripTimeVariance) + peer->m_highestRoundTripTimeVariance = peer->m_roundTripTimeVariance; + + if (peer->m_packetThrottleEpoch == 0 || ENET_TIME_DIFFERENCE(m_serviceTime, peer->m_packetThrottleEpoch) >= peer->packetThrottleInterval) + { + peer->m_lastRoundTripTime = peer->m_lowestRoundTripTime; + peer->m_lastRoundTripTimeVariance = peer->m_highestRoundTripTimeVariance; + peer->m_lowestRoundTripTime = peer->m_roundTripTime; + peer->m_highestRoundTripTimeVariance = peer->m_roundTripTimeVariance; + peer->m_packetThrottleEpoch = m_serviceTime; + } + + UInt16 receivedReliableSequenceNumber = NetToHost(command->acknowledge.receivedReliableSequenceNumber); + + ENetProtocolCommand commandNumber = peer->RemoveSentReliableCommand(receivedReliableSequenceNumber, command->header.channelID); + + switch (peer->m_state) + { + case ENetPeerState::AcknowledgingConnect: + if (commandNumber != ENetProtocolCommand_VerifyConnect) + return false; + + NotifyConnect(peer, event); + break; + + case ENetPeerState::Disconnecting: + if (commandNumber != ENetProtocolCommand_Disconnect) + return false; + + NotifyDisconnect(peer, event); + break; + + case ENetPeerState::DisconnectLater: + if (peer->m_outgoingReliableCommands.empty() && peer->m_outgoingUnreliableCommands.empty() && peer->m_sentReliableCommands.empty()) + peer->Disconnect(peer->m_eventData); + + break; + + default: + break; + } + + return true; + } + + bool ENetHost::HandleBandwidthLimit(ENetPeer* peer, const ENetProtocol* command) + { + if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + return false; + + if (peer->m_incomingBandwidth != 0) + --m_bandwidthLimitedPeers; + + peer->m_incomingBandwidth = NetToHost(command->bandwidthLimit.incomingBandwidth); + peer->m_outgoingBandwidth = NetToHost(command->bandwidthLimit.outgoingBandwidth); + + if (peer->m_incomingBandwidth != 0) + ++m_bandwidthLimitedPeers; + + if (peer->m_incomingBandwidth == 0 && m_outgoingBandwidth == 0) + peer->m_windowSize = ENetConstants::ENetProtocol_MaximumWindowSize; + else + { + if (peer->m_incomingBandwidth == 0 || m_outgoingBandwidth == 0) + peer->m_windowSize = (std::max(peer->m_incomingBandwidth, m_outgoingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + else + peer->m_windowSize = (std::min(peer->m_incomingBandwidth, m_outgoingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + + peer->m_windowSize = Clamp(peer->m_windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + } + + return true; + } + ENetPeer* ENetHost::HandleConnect(ENetProtocolHeader* header, ENetProtocol* command) { UInt32 channelCount = NetToHost(command->connect.channelCount); @@ -410,7 +545,7 @@ namespace Nz if (!peer || duplicatePeers >= m_duplicatePeers) return nullptr; - channelCount = std::min(channelCount, m_channelLimit); + channelCount = std::min(channelCount, m_channelLimit); peer->InitIncoming(channelCount, m_receivedAddress, command->connect); @@ -444,6 +579,37 @@ namespace Nz return peer; } + bool ENetHost::HandleDisconnect(ENetPeer* peer, const ENetProtocol * command) + { + if (peer->m_state == ENetPeerState::Disconnected || peer->m_state == ENetPeerState::Zombie || peer->m_state == ENetPeerState::AcknowledgingDisconnect) + return true; + + peer->ResetQueues(); + + if (peer->m_state == ENetPeerState::ConnectionSucceeded || peer->m_state == ENetPeerState::Disconnecting || peer->m_state == ENetPeerState::Connecting) + peer->DispatchState(ENetPeerState::Zombie); + else + { + if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + { + if (peer->m_state == ENetPeerState::ConnectionPending) + m_recalculateBandwidthLimits = true; + + peer->Reset(); + } + else + if (command->header.command & ENetProtocolFlag_Acknowledge) + peer->ChangeState(ENetPeerState::AcknowledgingDisconnect); + else + peer->DispatchState(ENetPeerState::Zombie); + } + + if (peer->m_state != ENetPeerState::Disconnected) + peer->m_eventData = NetToHost(command->disconnect.data); + + return true; + } + bool ENetHost::HandleIncomingCommands(ENetEvent* event) { if (m_receivedDataLength < NazaraOffsetOf(ENetProtocolHeader, sentTime)) @@ -451,58 +617,275 @@ namespace Nz ENetProtocolHeader* header = reinterpret_cast(m_receivedData); - peerID = NetToHost(header->peerID); - sessionID = (peerID & ENET_PROTOCOL_HEADER_SESSION_MASK) >> ENET_PROTOCOL_HEADER_SESSION_SHIFT; - flags = peerID & ENET_PROTOCOL_HEADER_FLAG_MASK; - peerID &= ~(ENET_PROTOCOL_HEADER_FLAG_MASK | ENET_PROTOCOL_HEADER_SESSION_MASK); + UInt16 peerID = NetToHost(header->peerID); + UInt8 sessionID = (peerID & ENetProtocolHeaderSessionMask) >> ENetProtocolHeaderSessionShift; + UInt16 flags = peerID & ENetProtocolHeaderFlag_Mask; + peerID &= ~(ENetProtocolHeaderFlag_Mask | ENetProtocolHeaderSessionMask); - headerSize = (flags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME ? sizeof(ENetProtocolHeader) : (size_t) & ((ENetProtocolHeader *)0)->sentTime); - if (host->checksum != NULL) - headerSize += sizeof(enet_uint32); + std::size_t headerSize = (flags & ENetProtocolHeaderFlag_SentTime ? sizeof(ENetProtocolHeader) : (size_t) & ((ENetProtocolHeader *)0)->sentTime); - if (peerID == ENET_PROTOCOL_MAXIMUM_PEER_ID) - peer = NULL; + ENetPeer* peer; + if (peerID == ENetConstants::ENetProtocol_MaximumPeerId) + peer = nullptr; else - if (peerID >= host->peerCount) - return 0; + { + if (peerID >= m_peers.size()) + return false; else { - peer = &host->peers[peerID]; + peer = &m_peers[peerID]; - if (peer->state == ENET_PEER_STATE_DISCONNECTED || - peer->state == ENET_PEER_STATE_ZOMBIE || - ((host->receivedAddress.host != peer->address.host || - host->receivedAddress.port != peer->address.port) && - peer->address.host != ENET_HOST_BROADCAST) || - (peer->outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID && - sessionID != peer->incomingSessionID)) - return 0; + if (peer->m_state == ENetPeerState::Disconnected || peer->m_state == ENetPeerState::Zombie) + return false; + + if (m_receivedAddress != peer->m_address && peer->m_address != IpAddress::BroadcastIpV4) + return false; + + if (peer->m_outgoingPeerID < ENetConstants::ENetProtocol_MaximumPeerId && sessionID != peer->m_incomingSessionID) + return false; + } + } + + // Compression handling + + // Checksum + + if (peer) + { + peer->m_address = m_receivedAddress; + peer->m_incomingDataTotal += m_receivedDataLength; + } + + auto commandError = [&]() -> bool + { + if (event && event->type != ENetEventType::None) + return true; + + return false; + }; + + UInt8* currentData = m_receivedData + headerSize; + + while (currentData < &m_receivedData[m_receivedDataLength]) + { + ENetProtocol* command = reinterpret_cast(currentData); + + if (currentData + sizeof(ENetProtocolCommandHeader) > &m_receivedData[m_receivedDataLength]) + break; + + UInt8 commandNumber = command->header.command & ENetProtocolCommand_Mask; + if (commandNumber >= ENetProtocolCommand_Count) + break; + + std::size_t commandSize = s_commandSizes[commandNumber]; + if (commandSize == 0 || currentData + commandSize > &m_receivedData[m_receivedDataLength]) + break; + + currentData += commandSize; + + if (!peer && commandNumber != ENetProtocolCommand_Connect) + break; + + command->header.reliableSequenceNumber = NetToHost(command->header.reliableSequenceNumber); + + switch (commandNumber) + { + case ENetProtocolCommand_Acknowledge: + if (!HandleAcknowledge(event, peer, command)) + return commandError(); + + break; + + case ENetProtocolCommand_Connect: + if (peer) + return commandError(); + + peer = HandleConnect(header, command); + if (!peer) + return commandError(); + + break; + + case ENetProtocolCommand_VerifyConnect: + if (!HandleVerifyConnect(event, peer, command)) + return commandError(); + + break; + + case ENetProtocolCommand_Disconnect: + if (!HandleDisconnect(peer, command)) + return commandError(); + + break; + + case ENetProtocolCommand_Ping: + if (!HandlePing(peer, command)) + return commandError(); + + break; + + case ENetProtocolCommand_SendReliable: + if (!HandleSendReliable(peer, command, ¤tData)) + return commandError(); + + break; + + case ENetProtocolCommand_SendUnreliable: + if (!HandleSendUnreliable(peer, command, ¤tData)) + return commandError(); + + break; + + case ENetProtocolCommand_SendUnsequenced: + if (!HandleSendUnsequenced(peer, command, ¤tData)) + return commandError(); + + break; + + case ENetProtocolCommand_SendFragment: + if (!HandleSendFragment(peer, command, ¤tData)) + return commandError(); + + break; + + case ENetProtocolCommand_BandwidthLimit: + if (!HandleBandwidthLimit(peer, command)) + return commandError(); + + break; + + case ENetProtocolCommand_ThrottleConfigure: + if (!HandleThrottleConfigure(peer, command)) + return commandError(); + + break; + + case ENetProtocolCommand_SendUnreliableFragment: + if (!HandleSendUnreliableFragment(peer, command, ¤tData)) + return commandError(); + + break; + + default: + return commandError(); } - return false; + if (peer && (command->header.command & ENetProtocolCommand_Acknowledge) != 0) + { + UInt16 sentTime; + + if (!(flags & ENetProtocolHeaderFlag_SentTime)) + break; + + sentTime = NetToHost(header->sentTime); + + switch (peer->m_state) + { + case ENetPeerState::Disconnecting: + case ENetPeerState::AcknowledgingConnect: + case ENetPeerState::Disconnected: + case ENetPeerState::Zombie: + break; + + case ENetPeerState::AcknowledgingDisconnect: + if ((command->header.command & ENetProtocolCommand_Mask) == ENetProtocolCommand_Disconnect) + peer->QueueAcknowledgement(command, sentTime); + break; + + default: + peer->QueueAcknowledgement(command, sentTime); + break; + } + } + } + + return commandError(); } - bool ENetHost::HandleSendReliable(ENetPeer& peer, const ENetProtocol& command, UInt8** currentData) + bool ENetHost::HandlePing(ENetPeer* peer, const ENetProtocol* command) { - if (command.header.channelID >= peer.m_channels.size() || (peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater)) + if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) return false; - UInt16 dataLength = NetToHost(command.sendReliable.dataLength); + return true; + } + + bool ENetHost::HandleSendReliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) + { + if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + return false; + + UInt16 dataLength = NetToHost(command->sendReliable.dataLength); *currentData += dataLength; if (dataLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) return false; - if (!peer.QueueIncomingCommand(command, co)) + if (!peer->QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendReliable), dataLength, ENetPacketFlag_Reliable, 0)) + return false; return true; } + bool ENetHost::HandleThrottleConfigure(ENetPeer* peer, const ENetProtocol* command) + { + if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + return false; + + peer->m_packetThrottleInterval = NetToHost(command->throttleConfigure.packetThrottleInterval); + peer->m_packetThrottleAcceleration = NetToHost(command->throttleConfigure.packetThrottleAcceleration); + peer->m_packetThrottleDeceleration = NetToHost(command->throttleConfigure.packetThrottleDeceleration); + + return true; + } + + bool ENetHost::HandleVerifyConnect(ENetEvent* event, ENetPeer* peer, ENetProtocol* command) + { + if (peer->m_state != ENetPeerState::Connecting) + return false; + + UInt32 channelCount = NetToHost(command->verifyConnect.channelCount); + + if (channelCount < ENetConstants::ENetProtocol_MinimumChannelCount || channelCount > ENetConstants::ENetProtocol_MaximumChannelCount || + NetToHost(command->verifyConnect.packetThrottleInterval) != peer->m_packetThrottleInterval || + NetToHost(command->verifyConnect.packetThrottleAcceleration) != peer->m_packetThrottleAcceleration || + NetToHost(command->verifyConnect.packetThrottleDeceleration) != peer->m_packetThrottleDeceleration || + command->verifyConnect.connectID != peer->m_connectID) + { + peer->m_eventData = 0; + + peer->DispatchState(ENetPeerState::Zombie); + + return false; + } + + peer->RemoveSentReliableCommand(1, 0xFF); + + if (channelCount < peer->m_channels.size()) + peer->m_channels.resize(channelCount); + + peer->m_outgoingPeerID = NetToHost(command->verifyConnect.outgoingPeerID); + peer->m_incomingSessionID = command->verifyConnect.incomingSessionID; + peer->m_outgoingSessionID = command->verifyConnect.outgoingSessionID; + + UInt32 mtu = Clamp(NetToHost(command->verifyConnect.mtu), ENetConstants::ENetProtocol_MinimumMTU, ENetConstants::ENetProtocol_MaximumMTU); + peer->m_mtu = std::min(peer->m_mtu, mtu); + + UInt32 windowSize = Clamp(NetToHost(command->verifyConnect.windowSize), ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + peer->m_windowSize = std::min(peer->m_windowSize, windowSize); + + peer->m_incomingBandwidth = NetToHost(command->verifyConnect.incomingBandwidth); + peer->m_outgoingBandwidth = NetToHost(command->verifyConnect.outgoingBandwidth); + + NotifyConnect(peer, event); + return true; + } + int ENetHost::ReceiveIncomingCommands(ENetEvent* event) { for (unsigned int i = 0; i < 256; ++i) { NetPacket packet; - + std::size_t receivedLength; if (!m_socket.Receive(m_packetData[0].data(), m_packetData[0].size(), &m_receivedAddress, &receivedLength)) return -1; //< Error @@ -525,7 +908,7 @@ namespace Nz case -1: return -1; - + default: break; } @@ -740,4 +1123,4 @@ namespace Nz std::mt19937 ENetHost::s_randomGenerator; std::mt19937_64 ENetHost::s_randomGenerator64; -} \ No newline at end of file +} diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 9e5471c21..6f7f33312 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -16,7 +16,7 @@ namespace Nz return value; #endif } - + /// Temporary template T NetToHost(T value) @@ -28,31 +28,6 @@ namespace Nz #endif } - namespace - { - static std::size_t commandSizes[ENetProtocolCommand_Count] = - { - 0, - sizeof(ENetProtocolAcknowledge), - sizeof(ENetProtocolConnect), - sizeof(ENetProtocolVerifyConnect), - sizeof(ENetProtocolDisconnect), - sizeof(ENetProtocolPing), - sizeof(ENetProtocolSendReliable), - sizeof(ENetProtocolSendUnreliable), - sizeof(ENetProtocolSendFragment), - sizeof(ENetProtocolSendUnsequenced), - sizeof(ENetProtocolBandwidthLimit), - sizeof(ENetProtocolThrottleConfigure), - sizeof(ENetProtocolSendFragment) - }; - - std::size_t enet_protocol_command_size(UInt8 commandNumber) - { - return commandSizes[commandNumber & ENetProtocolCommand_Mask]; - } - } - ENetPeer::ENetPeer(ENetHost* host, UInt16 peerId) : m_packetPool(sizeof(ENetPacket)), m_host(host), @@ -505,8 +480,8 @@ namespace Nz } } - ENetProtocolCommand ENetPeer::RemoveSentReliableCommands(UInt16 reliableSequenceNumber, UInt8 channelId) - { + ENetProtocolCommand ENetPeer::RemoveSentReliableCommand(UInt16 reliableSequenceNumber, UInt8 channelId) + { std::list* commandList = nullptr; bool found = true; @@ -595,16 +570,16 @@ namespace Nz m_channels.clear(); } - bool ENetPeer::QueueAcknowledgement(ENetProtocol& command, UInt16 sentTime) + bool ENetPeer::QueueAcknowledgement(ENetProtocol*command, UInt16 sentTime) { - if (command.header.channelID < m_channels.size()) + if (command->header.channelID < m_channels.size()) { - Channel& channel = m_channels[command.header.channelID]; + Channel& channel = m_channels[command->header.channelID]; - UInt16 reliableWindow = command.header.reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + UInt16 reliableWindow = command->header.reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; - if (command.header.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + if (command->header.reliableSequenceNumber < channel.incomingReliableSequenceNumber) reliableWindow += ENetConstants::ENetPeer_ReliableWindows; if (reliableWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1 && reliableWindow <= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows) @@ -882,4 +857,4 @@ namespace Nz return 0; } -} \ No newline at end of file +} From 8a59dc88b844992f75fadb72492ea4ffe0515948 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 14:48:31 +0100 Subject: [PATCH 067/243] Commit progression --- include/Nazara/Network/ENetHost.hpp | 30 +- include/Nazara/Network/ENetHost.inl | 12 +- include/Nazara/Network/ENetPacket.hpp | 33 +- include/Nazara/Network/ENetPeer.hpp | 129 ++--- include/Nazara/Network/ENetPeer.inl | 14 +- include/Nazara/Network/ENetProtocol.hpp | 47 +- include/Nazara/Network/Enums.hpp | 2 + src/Nazara/Network/ENetHost.cpp | 711 ++++++++++++++++++++++-- src/Nazara/Network/ENetPacket.cpp | 6 +- src/Nazara/Network/ENetPeer.cpp | 50 +- src/Nazara/Network/ENetSocket.cpp | 642 --------------------- 11 files changed, 865 insertions(+), 811 deletions(-) delete mode 100644 src/Nazara/Network/ENetSocket.cpp diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 03d10d541..3b86a1f25 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -40,8 +41,10 @@ namespace Nz void Broadcast(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet); - bool Connect(const IpAddress& remoteAddress, std::size_t channelCount = 0, UInt32 data = 0); - bool Connect(const String& hostName, NetProtocol protocol = NetProtocol_Any, const String& service = "http", ResolveError* error = nullptr, std::size_t channelCount = 0, UInt32 data = 0); + bool CheckEvents(ENetEvent* event); + + ENetPeer* Connect(const IpAddress& remoteAddress, std::size_t channelCount = 0, UInt32 data = 0); + ENetPeer* Connect(const String& hostName, NetProtocol protocol = NetProtocol_Any, const String& service = "http", ResolveError* error = nullptr, std::size_t channelCount = 0, UInt32 data = 0); inline bool Create(NetProtocol protocol, UInt16 port, std::size_t peerCount, std::size_t channelCount = 0); bool Create(const IpAddress& address, std::size_t peerCount, std::size_t channelCount = 0); @@ -58,8 +61,10 @@ namespace Nz private: bool InitSocket(const IpAddress& address); - inline void AddToDispatchQueue(ENetPeer* peer); - inline void RemoveFromDispatchQueue(ENetPeer* peer); + void AddToDispatchQueue(ENetPeer* peer); + void RemoveFromDispatchQueue(ENetPeer* peer); + + bool CheckTimeouts(ENetPeer* peer, ENetEvent* event); bool DispatchIncomingCommands(ENetEvent* event); @@ -69,7 +74,11 @@ namespace Nz bool HandleDisconnect(ENetPeer* peer, const ENetProtocol* command); bool HandleIncomingCommands(ENetEvent* event); bool HandlePing(ENetPeer* peer, const ENetProtocol* command); + bool HandleSendFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); bool HandleSendReliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); + bool HandleSendUnreliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); + bool HandleSendUnreliableFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); + bool HandleSendUnsequenced(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); bool HandleThrottleConfigure(ENetPeer* peer, const ENetProtocol* command); bool HandleVerifyConnect(ENetEvent* event, ENetPeer* peer, ENetProtocol* command); @@ -78,12 +87,19 @@ namespace Nz void NotifyConnect(ENetPeer* peer, ENetEvent* event); void NotifyDisconnect(ENetPeer*, ENetEvent* event); + void SendAcknowledgements(ENetPeer* peer); + bool SendReliableOutgoingCommands(ENetPeer* peer); + int SendOutgoingCommands(ENetEvent* event, bool checkForTimeouts); + void SendUnreliableOutgoingCommands(ENetPeer* peer); + void ThrottleBandwidth(); + static std::size_t GetCommandSize(UInt8 commandNumber); static bool Initialize(); static void Uninitialize(); std::array m_commands; + std::array m_buffers; std::array m_packetData[2]; std::bernoulli_distribution m_packetLossProbability; std::size_t m_bandwidthLimitedPeers; @@ -93,6 +109,8 @@ namespace Nz std::size_t m_duplicatePeers; std::size_t m_maximumPacketSize; std::size_t m_maximumWaitingData; + std::size_t m_packetSize; + std::size_t m_peerCount; std::size_t m_receivedDataLength; std::vector m_peers; Bitset m_dispatchQueue; @@ -101,6 +119,7 @@ namespace Nz IpAddress m_receivedAddress; SocketPoller m_poller; UdpSocket m_socket; + UInt16 m_headerFlags; UInt32 m_bandwidthThrottleEpoch; UInt32 m_connectedPeers; UInt32 m_mtu; @@ -113,6 +132,7 @@ namespace Nz UInt32 m_totalReceivedData; UInt32 m_totalReceivedPackets; UInt8* m_receivedData; + bool m_continueSending; bool m_isSimulationEnabled; bool m_shouldAcceptConnections; bool m_recalculateBandwidthLimits; diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl index c4a077e8b..e547d4e5d 100644 --- a/include/Nazara/Network/ENetHost.inl +++ b/include/Nazara/Network/ENetHost.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -50,16 +50,6 @@ namespace Nz m_peers.clear(); m_socket.Close(); } - - inline void ENetHost::AddToDispatchQueue(ENetPeer* peer) - { - m_dispatchQueue.UnboundedSet(peer->m_incomingPeerID); - } - - inline void ENetHost::RemoveFromDispatchQueue(ENetPeer* peer) - { - m_dispatchQueue.UnboundedReset(peer->m_incomingPeerID); - } } #include diff --git a/include/Nazara/Network/ENetPacket.hpp b/include/Nazara/Network/ENetPacket.hpp index ad1610eb4..54a5d4676 100644 --- a/include/Nazara/Network/ENetPacket.hpp +++ b/include/Nazara/Network/ENetPacket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -40,7 +40,7 @@ namespace Nz std::size_t referenceCount = 0; }; - struct ENetPacketRef + struct NAZARA_NETWORK_API ENetPacketRef { ENetPacketRef() = default; @@ -49,6 +49,18 @@ namespace Nz Reset(packet); } + ENetPacketRef(const ENetPacketRef& packet) : + ENetPacketRef() + { + Reset(packet); + } + + ENetPacketRef(ENetPacketRef&& packet) : + m_packet(packet.m_packet) + { + packet.m_packet = nullptr; + } + ~ENetPacketRef() { Reset(); @@ -69,6 +81,23 @@ namespace Nz ENetPacketRef& operator=(ENetPacket* packet) { Reset(packet); + + return *this; + } + + ENetPacketRef& operator=(const ENetPacketRef& packet) + { + Reset(packet); + + return *this; + } + + ENetPacketRef& operator=(ENetPacketRef&& packet) + { + m_packet = packet.m_packet; + packet.m_packet = nullptr; + + return *this; } ENetPacket* m_packet = nullptr; diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 7d522f203..e68b85de9 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -32,6 +32,7 @@ namespace Nz friend struct PacketRef; public: + ENetPeer(ENetHost* host, UInt16 peerId); ENetPeer(const ENetPeer&) = delete; ENetPeer(ENetPeer&&) = default; ~ENetPeer() = default; @@ -40,6 +41,8 @@ namespace Nz void DisconnectLater(UInt32 data); void DisconnectNow(UInt32 data); + inline const IpAddress& GetAddress() const; + void Ping(); bool Receive(ENetPacketRef* packet, UInt8* channelId); @@ -54,8 +57,6 @@ namespace Nz ENetPeer& operator=(ENetPeer&&) = default; private: - ENetPeer(ENetHost* host, UInt16 peerId); - void InitIncoming(std::size_t channelCount, const IpAddress& address, ENetProtocolConnect& incomingCommand); void InitOutgoing(std::size_t channelCount, const IpAddress& address, UInt32 connectId, UInt32 windowSize); @@ -66,7 +67,7 @@ namespace Nz // Protocol functions inline void ChangeState(ENetPeerState state); - inline void DispatchState(ENetPeerState state); + void DispatchState(ENetPeerState state); void DispatchIncomingReliableCommands(Channel& channel); void DispatchIncomingUnreliableCommands(Channel& channel); @@ -80,7 +81,7 @@ namespace Nz void ResetQueues(); bool QueueAcknowledgement(ENetProtocol* command, UInt16 sentTime); - IncomingCommmand* QueueIncomingCommand(ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount); + IncomingCommmand* QueueIncomingCommand(const ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount); void QueueOutgoingCommand(ENetProtocol& command, ENetPacketRef packet, UInt32 offset, UInt16 length); void SetupOutgoingCommand(OutgoingCommand& outgoingCommand); @@ -139,64 +140,66 @@ namespace Nz UInt32 sentTime; }; - ENetHost* m_host; - IpAddress m_address; /**< Internet address of the peer */ - std::vector m_channels; - std::list m_acknowledgements; - std::list m_dispatchedCommands; - std::list m_outgoingReliableCommands; - std::list m_outgoingUnreliableCommands; - std::list m_sentReliableCommands; - std::list m_sentUnreliableCommands; - MemoryPool m_packetPool; - //ENetListNode m_dispatchList; - ENetPeerState m_state; - UInt8 m_incomingSessionID; - UInt8 m_outgoingSessionID; - UInt16 m_incomingPeerID; - UInt16 m_incomingUnsequencedGroup; - UInt16 m_outgoingPeerID; - UInt16 m_outgoingReliableSequenceNumber; - UInt16 m_outgoingUnsequencedGroup; - UInt32 m_connectID; - UInt32 m_earliestTimeout; - UInt32 m_eventData; - UInt32 m_highestRoundTripTimeVariance; - UInt32 m_incomingBandwidth; /**< Downstream bandwidth of the client in bytes/second */ - UInt32 m_incomingBandwidthThrottleEpoch; - UInt32 m_incomingDataTotal; - UInt32 m_lastReceiveTime; - UInt32 m_lastRoundTripTime; - UInt32 m_lastRoundTripTimeVariance; - UInt32 m_lastSendTime; - UInt32 m_lowestRoundTripTime; - UInt32 m_mtu; - UInt32 m_nextTimeout; - UInt32 m_outgoingBandwidth; /**< Upstream bandwidth of the client in bytes/second */ - UInt32 m_outgoingBandwidthThrottleEpoch; - UInt32 m_outgoingDataTotal; - UInt32 m_packetLoss; /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */ - UInt32 m_packetLossEpoch; - UInt32 m_packetLossVariance; - UInt32 m_packetThrottle; - UInt32 m_packetThrottleAcceleration; - UInt32 m_packetThrottleCounter; - UInt32 m_packetThrottleDeceleration; - UInt32 m_packetThrottleEpoch; - UInt32 m_packetThrottleInterval; - UInt32 m_packetThrottleLimit; - UInt32 m_packetsLost; - UInt32 m_packetsSent; - UInt32 m_pingInterval; - UInt32 m_reliableDataInTransit; - UInt32 m_roundTripTime; /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgment */ - UInt32 m_roundTripTimeVariance; - UInt32 m_timeoutLimit; - UInt32 m_timeoutMaximum; - UInt32 m_timeoutMinimum; - UInt32 m_unsequencedWindow[ENetPeer_ReliableWindowSize / 32]; - UInt32 m_windowSize; - std::size_t m_totalWaitingData; + static constexpr std::size_t unsequencedWindow = ENetPeer_ReliableWindowSize / 32; + + ENetHost* m_host; + IpAddress m_address; /**< Internet address of the peer */ + std::array m_unsequencedWindow; + std::list m_acknowledgements; + std::list m_dispatchedCommands; + std::list m_outgoingReliableCommands; + std::list m_outgoingUnreliableCommands; + std::list m_sentReliableCommands; + std::list m_sentUnreliableCommands; + std::size_t m_totalWaitingData; + std::vector m_channels; + MemoryPool m_packetPool; + //ENetListNode m_dispatchList; + ENetPeerState m_state; + UInt8 m_incomingSessionID; + UInt8 m_outgoingSessionID; + UInt16 m_incomingPeerID; + UInt16 m_incomingUnsequencedGroup; + UInt16 m_outgoingPeerID; + UInt16 m_outgoingReliableSequenceNumber; + UInt16 m_outgoingUnsequencedGroup; + UInt32 m_connectID; + UInt32 m_earliestTimeout; + UInt32 m_eventData; + UInt32 m_highestRoundTripTimeVariance; + UInt32 m_incomingBandwidth; /**< Downstream bandwidth of the client in bytes/second */ + UInt32 m_incomingBandwidthThrottleEpoch; + UInt32 m_incomingDataTotal; + UInt32 m_lastReceiveTime; + UInt32 m_lastRoundTripTime; + UInt32 m_lastRoundTripTimeVariance; + UInt32 m_lastSendTime; + UInt32 m_lowestRoundTripTime; + UInt32 m_mtu; + UInt32 m_nextTimeout; + UInt32 m_outgoingBandwidth; /**< Upstream bandwidth of the client in bytes/second */ + UInt32 m_outgoingBandwidthThrottleEpoch; + UInt32 m_outgoingDataTotal; + UInt32 m_packetLoss; /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */ + UInt32 m_packetLossEpoch; + UInt32 m_packetLossVariance; + UInt32 m_packetThrottle; + UInt32 m_packetThrottleAcceleration; + UInt32 m_packetThrottleCounter; + UInt32 m_packetThrottleDeceleration; + UInt32 m_packetThrottleEpoch; + UInt32 m_packetThrottleInterval; + UInt32 m_packetThrottleLimit; + UInt32 m_packetsLost; + UInt32 m_packetsSent; + UInt32 m_pingInterval; + UInt32 m_reliableDataInTransit; + UInt32 m_roundTripTime; /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgment */ + UInt32 m_roundTripTimeVariance; + UInt32 m_timeoutLimit; + UInt32 m_timeoutMaximum; + UInt32 m_timeoutMinimum; + UInt32 m_windowSize; }; } diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index a0cebbc4e..2c7044b6e 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -8,6 +8,11 @@ namespace Nz { + inline const IpAddress& ENetPeer::GetAddress() const + { + return m_address; + } + inline void ENetPeer::ChangeState(ENetPeerState state) { if (state == ENetPeerState::Connected || state == ENetPeerState::DisconnectLater) @@ -17,13 +22,6 @@ namespace Nz m_state = state; } - - inline void ENetPeer::DispatchState(ENetPeerState state) - { - ChangeState(state); - - m_host->AddToDispatchQueue(this); - } } #include diff --git a/include/Nazara/Network/ENetProtocol.hpp b/include/Nazara/Network/ENetProtocol.hpp index d4d74fd01..8b62f7dc7 100644 --- a/include/Nazara/Network/ENetProtocol.hpp +++ b/include/Nazara/Network/ENetProtocol.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -13,6 +13,8 @@ namespace Nz { + class ENetPeer; + // Constants for the ENet implementation and protocol enum ENetConstants { @@ -140,27 +142,38 @@ namespace Nz ENetPacketRef packet; }; - struct ENetProtocolHeader + + #ifdef _MSC_VER + #pragma pack(push, 1) + #define NAZARA_PACKED + #elif defined(__GNUC__) || defined(__clang__) + #define NAZARA_PACKED __attribute__ ((packed)) + #else + #define NAZARA_PACKED + #endif + + + struct NAZARA_PACKED ENetProtocolHeader { UInt16 peerID; UInt16 sentTime; }; - struct ENetProtocolCommandHeader + struct NAZARA_PACKED ENetProtocolCommandHeader { UInt8 command; UInt8 channelID; UInt16 reliableSequenceNumber; }; - struct ENetProtocolAcknowledge + struct NAZARA_PACKED ENetProtocolAcknowledge { ENetProtocolCommandHeader header; UInt16 receivedReliableSequenceNumber; UInt16 receivedSentTime; }; - struct ENetProtocolConnect + struct NAZARA_PACKED ENetProtocolConnect { ENetProtocolCommandHeader header; UInt16 outgoingPeerID; @@ -178,25 +191,25 @@ namespace Nz UInt32 data; }; - struct ENetProtocolBandwidthLimit + struct NAZARA_PACKED ENetProtocolBandwidthLimit { ENetProtocolCommandHeader header; UInt32 incomingBandwidth; UInt32 outgoingBandwidth; }; - struct ENetProtocolDisconnect + struct NAZARA_PACKED ENetProtocolDisconnect { ENetProtocolCommandHeader header; UInt32 data; }; - struct ENetProtocolPing + struct NAZARA_PACKED ENetProtocolPing { ENetProtocolCommandHeader header; }; - struct ENetProtocolSendFragment + struct NAZARA_PACKED ENetProtocolSendFragment { ENetProtocolCommandHeader header; UInt16 startSequenceNumber; @@ -207,27 +220,27 @@ namespace Nz UInt32 fragmentOffset; }; - struct ENetProtocolSendReliable + struct NAZARA_PACKED ENetProtocolSendReliable { ENetProtocolCommandHeader header; UInt16 dataLength; }; - struct ENetProtocolSendUnreliable + struct NAZARA_PACKED ENetProtocolSendUnreliable { ENetProtocolCommandHeader header; UInt16 unreliableSequenceNumber; UInt16 dataLength; }; - struct ENetProtocolSendUnsequenced + struct NAZARA_PACKED ENetProtocolSendUnsequenced { ENetProtocolCommandHeader header; UInt16 unsequencedGroup; UInt16 dataLength; }; - struct ENetProtocolThrottleConfigure + struct NAZARA_PACKED ENetProtocolThrottleConfigure { ENetProtocolCommandHeader header; UInt32 packetThrottleInterval; @@ -235,7 +248,7 @@ namespace Nz UInt32 packetThrottleDeceleration; }; - struct ENetProtocolVerifyConnect + struct NAZARA_PACKED ENetProtocolVerifyConnect { ENetProtocolCommandHeader header; UInt16 outgoingPeerID; @@ -252,7 +265,7 @@ namespace Nz UInt32 connectID; }; - union ENetProtocol + union NAZARA_PACKED ENetProtocol { ENetProtocolCommandHeader header; ENetProtocolAcknowledge acknowledge; @@ -267,6 +280,10 @@ namespace Nz ENetProtocolThrottleConfigure throttleConfigure; ENetProtocolVerifyConnect verifyConnect; }; + + #ifdef _MSC_VER + #pragma pack(pop) + #endif } #endif // NAZARA_ENETPROTOCOL_HPP diff --git a/include/Nazara/Network/Enums.hpp b/include/Nazara/Network/Enums.hpp index 7dccd7dd1..f80ba6cd9 100644 --- a/include/Nazara/Network/Enums.hpp +++ b/include/Nazara/Network/Enums.hpp @@ -7,6 +7,8 @@ #ifndef NAZARA_ENUMS_NETWORK_HPP #define NAZARA_ENUMS_NETWORK_HPP +#include + namespace Nz { enum NetCode : UInt16 diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 5bb9b7bdf..ffe15635a 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -1,9 +1,10 @@ -#include +#include #include #include #include #include #include +#include #include #define ENET_TIME_OVERFLOW 86400000 @@ -57,11 +58,6 @@ namespace Nz sizeof(ENetProtocolThrottleConfigure), sizeof(ENetProtocolSendFragment) }; - - std::size_t enet_protocol_command_size(UInt8 commandNumber) - { - return s_commandSizes[commandNumber & ENetProtocolCommand_Mask]; - } } @@ -81,7 +77,19 @@ namespace Nz } } - bool ENetHost::Connect(const IpAddress& remoteAddress, std::size_t channelCount, UInt32 data) + bool ENetHost::CheckEvents(ENetEvent* event) + { + if (!event) + return false; + + event->type = ENetEventType::None; + event->peer = nullptr; + event->packet.Reset(); + + return DispatchIncomingCommands(event); + } + + ENetPeer* ENetHost::Connect(const IpAddress& remoteAddress, std::size_t channelCount, UInt32 data) { NazaraAssert(remoteAddress.IsValid(), "Invalid remote address"); NazaraAssert(remoteAddress.GetPort() != 0, "Remote address has no port"); @@ -96,7 +104,7 @@ namespace Nz if (peerId >= m_peers.size()) { NazaraError("Insufficient peers"); - return false; + return nullptr; } m_channelLimit = Clamp(channelCount, ENetConstants::ENetProtocol_MinimumChannelCount, ENetConstants::ENetProtocol_MaximumChannelCount); @@ -130,10 +138,10 @@ namespace Nz peer.QueueOutgoingCommand(command, nullptr, 0, 0); - return true; + return &peer; } - bool ENetHost::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error, std::size_t channelCount, UInt32 data) + ENetPeer* ENetHost::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error, std::size_t channelCount, UInt32 data) { std::vector results = IpAddress::ResolveHostname(protocol, hostName, service, error); if (results.empty()) @@ -173,7 +181,9 @@ namespace Nz if (!InitSocket(address)) return false; - m_peers.resize(peerCount); + m_peers.reserve(peerCount); + for (std::size_t i = 0; i < peerCount; ++i) + m_peers.emplace_back(this, UInt16(i)); m_address = address; m_randomSeed = *reinterpret_cast(this); @@ -187,6 +197,7 @@ namespace Nz m_mtu = ENetConstants::ENetHost_DefaultMTU; m_commandCount = 0; m_bufferCount = 0; + m_peerCount = peerCount; m_receivedAddress = IpAddress::AnyIpV4; m_receivedData = nullptr; m_receivedDataLength = 0; @@ -214,8 +225,6 @@ namespace Nz int ENetHost::Service(ENetEvent* event, UInt32 timeout) { - UInt32 waitCondition; - if (event) { event->type = ENetEventType::None; @@ -265,7 +274,7 @@ namespace Nz break; } - switch (SendOutgoingCommands(event, 1)) + switch (SendOutgoingCommands(event, true)) { case 1: return 1; @@ -283,21 +292,8 @@ namespace Nz if (event) { - switch (DispatchIncomingCommands(event)) - { - case 1: - return 1; - - case -1: - #ifdef ENET_DEBUG - perror("Error dispatching incoming packets"); - #endif - - return -1; - - default: - break; - } + if (DispatchIncomingCommands(event)) + return 1; } if (ENET_TIME_GREATER_EQUAL(m_serviceTime, timeout)) @@ -310,12 +306,8 @@ namespace Nz if (ENET_TIME_GREATER_EQUAL(m_serviceTime, timeout)) return 0; - SocketError error; - if (m_poller.Wait(ENET_TIME_DIFFERENCE(timeout, m_serviceTime), &error)) + if (m_poller.Wait(ENET_TIME_DIFFERENCE(timeout, m_serviceTime))) break; - - if (error != SocketError_NoError) - return -1; } m_serviceTime = GetElapsedMilliseconds(); @@ -349,6 +341,62 @@ namespace Nz return true; } + void ENetHost::AddToDispatchQueue(ENetPeer* peer) + { + m_dispatchQueue.UnboundedSet(peer->m_incomingPeerID); + } + + void ENetHost::RemoveFromDispatchQueue(ENetPeer* peer) + { + m_dispatchQueue.UnboundedReset(peer->m_incomingPeerID); + } + + bool ENetHost::CheckTimeouts(ENetPeer* peer, ENetEvent* event) + { + auto currentCommand = peer->m_sentReliableCommands.begin(); + + while (currentCommand != peer->m_sentReliableCommands.end()) + { + auto outgoingCommand = currentCommand; + + ++currentCommand; + + if (ENET_TIME_DIFFERENCE(m_serviceTime, outgoingCommand->sentTime) < outgoingCommand->roundTripTimeout) + continue; + + if (peer->m_earliestTimeout == 0 || ENET_TIME_LESS(outgoingCommand->sentTime, peer->m_earliestTimeout)) + peer->m_earliestTimeout = outgoingCommand->sentTime; + + if (peer->m_earliestTimeout != 0 && (ENET_TIME_DIFFERENCE(m_serviceTime, peer->m_earliestTimeout) >= peer->m_timeoutMaximum || + (outgoingCommand->roundTripTimeout >= outgoingCommand->roundTripTimeoutLimit && ENET_TIME_DIFFERENCE(m_serviceTime, peer->m_earliestTimeout) >= peer->m_timeoutMinimum))) + { + NotifyDisconnect(peer, event); + return true; + } + + if (outgoingCommand->packet) + peer->m_reliableDataInTransit -= outgoingCommand->fragmentLength; + + ++peer->m_packetsLost; + + outgoingCommand->roundTripTimeout *= 2; + + peer->m_outgoingReliableCommands.emplace_front(std::move(*outgoingCommand)); + peer->m_sentReliableCommands.erase(outgoingCommand); + + // Okay this should just never procs, I don't see how it would be possible + /*if (currentCommand == enet_list_begin(&peer->sentReliableCommands) && + !enet_list_empty(&peer->sentReliableCommands)) + { + outgoingCommand = (ENetOutgoingCommand *) currentCommand; + + peer->nextTimeout = outgoingCommand->sentTime + outgoingCommand->roundTripTimeout; + }*/ + } + + return false; + } + bool ENetHost::DispatchIncomingCommands(ENetEvent* event) { for (std::size_t bit = m_dispatchQueue.FindFirst(); bit != m_dispatchQueue.npos; bit = m_dispatchQueue.FindNext(bit)) @@ -391,6 +439,9 @@ namespace Nz AddToDispatchQueue(&peer); return true; + + default: + break; } } @@ -436,7 +487,7 @@ namespace Nz if (peer->m_roundTripTimeVariance > peer->m_highestRoundTripTimeVariance) peer->m_highestRoundTripTimeVariance = peer->m_roundTripTimeVariance; - if (peer->m_packetThrottleEpoch == 0 || ENET_TIME_DIFFERENCE(m_serviceTime, peer->m_packetThrottleEpoch) >= peer->packetThrottleInterval) + if (peer->m_packetThrottleEpoch == 0 || ENET_TIME_DIFFERENCE(m_serviceTime, peer->m_packetThrottleEpoch) >= peer->m_packetThrottleInterval) { peer->m_lastRoundTripTime = peer->m_lowestRoundTripTime; peer->m_lastRoundTripTimeVariance = peer->m_highestRoundTripTimeVariance; @@ -770,7 +821,7 @@ namespace Nz return commandError(); } - if (peer && (command->header.command & ENetProtocolCommand_Acknowledge) != 0) + if (peer && (command->header.command & ENetProtocolFlag_Acknowledge) != 0) { UInt16 sentTime; @@ -810,6 +861,90 @@ namespace Nz return true; } + bool ENetHost::HandleSendFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) + { + if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + return false; + + UInt16 fragmentLength = NetToHost(command->sendFragment.dataLength); + *currentData += fragmentLength; + if (fragmentLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) + return false; + + ENetPeer::Channel& channel = peer->m_channels[command->header.channelID]; + UInt32 startSequenceNumber = NetToHost(command->sendFragment.startSequenceNumber); + UInt16 startWindow = startSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + + if (startSequenceNumber < channel.incomingReliableSequenceNumber) + startWindow += ENetConstants::ENetPeer_ReliableWindows; + + if (startWindow < currentWindow || startWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1) + return true; + + UInt32 fragmentNumber = NetToHost(command->sendFragment.fragmentNumber); + UInt32 fragmentCount = NetToHost(command->sendFragment.fragmentCount); + UInt32 fragmentOffset = NetToHost(command->sendFragment.fragmentOffset); + UInt32 totalLength = NetToHost(command->sendFragment.totalLength); + + if (fragmentCount > ENetConstants::ENetProtocol_MaximumFragmentCount || fragmentNumber >= fragmentCount || totalLength > m_maximumPacketSize || + fragmentOffset >= totalLength || fragmentLength > totalLength - fragmentOffset) + return false; + + ENetPeer::IncomingCommmand* startCommand = nullptr; + for (auto currentCommand = channel.incomingReliableCommands.rbegin(); currentCommand != channel.incomingReliableCommands.rend(); ++currentCommand) + { + ENetPeer::IncomingCommmand& incomingCommand = *currentCommand; + + if (startSequenceNumber >= channel.incomingReliableSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + continue; + } + else if (incomingCommand.reliableSequenceNumber >= channel.incomingReliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber <= startSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < startSequenceNumber) + break; + + if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendFragment || + totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.size()) + return false; + + startCommand = &incomingCommand; + break; + } + } + + if (startCommand) + { + ENetProtocol hostCommand = *command; + hostCommand.header.reliableSequenceNumber = startSequenceNumber; + + if (!peer->QueueIncomingCommand(hostCommand, nullptr, totalLength, ENetPacketFlag_Reliable, fragmentCount)) + return false; + } + + if ((startCommand->fragments[fragmentNumber / 32] & (1 << (fragmentNumber % 32))) == 0) + { + --startCommand->fragmentsRemaining; + + startCommand->fragments[fragmentNumber / 32] |= (1 << (fragmentNumber % 32)); + + if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) + fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; + + std::memcpy(startCommand->packet->data.GetData() + Nz::NetPacket::HeaderSize + fragmentOffset, reinterpret_cast(command) + sizeof(ENetProtocolSendFragment), fragmentLength); + + if (startCommand->fragmentsRemaining <= 0) + peer->DispatchIncomingReliableCommands(channel); + } + + return false; + } + bool ENetHost::HandleSendReliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) { if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) @@ -826,6 +961,152 @@ namespace Nz return true; } + bool ENetHost::HandleSendUnreliable(ENetPeer * peer, const ENetProtocol * command, UInt8 ** currentData) + { + if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + return false; + + UInt16 dataLength = NetToHost(command->sendUnreliable.dataLength); + *currentData += dataLength; + if (dataLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) + return false; + + if (!peer->QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendUnreliable), dataLength, 0, 0)) + return false; + + return true; + } + + bool ENetHost::HandleSendUnreliableFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) + { + if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + return false; + + UInt16 fragmentLength = NetToHost(command->sendFragment.dataLength); + *currentData += fragmentLength; + if (fragmentLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) + return false; + + ENetPeer::Channel& channel = peer->m_channels[command->header.channelID]; + UInt32 reliableSequenceNumber = command->header.reliableSequenceNumber; + UInt32 startSequenceNumber = NetToHost(command->sendFragment.startSequenceNumber); + + UInt16 reliableWindow = reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + + if (startSequenceNumber < channel.incomingReliableSequenceNumber) + reliableWindow += ENetConstants::ENetPeer_ReliableWindows; + + if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1) + return true; + + if (reliableSequenceNumber == channel.incomingReliableSequenceNumber && startSequenceNumber <= channel.incomingUnreliableSequenceNumber) + return true; + + UInt32 fragmentNumber = NetToHost(command->sendFragment.fragmentNumber); + UInt32 fragmentCount = NetToHost(command->sendFragment.fragmentCount); + UInt32 fragmentOffset = NetToHost(command->sendFragment.fragmentOffset); + UInt32 totalLength = NetToHost(command->sendFragment.totalLength); + + if (fragmentCount > ENetConstants::ENetProtocol_MaximumFragmentCount || fragmentNumber >= fragmentCount || totalLength > m_maximumPacketSize || + fragmentOffset >= totalLength || fragmentLength > totalLength - fragmentOffset) + return false; + + ENetPeer::IncomingCommmand* startCommand = nullptr; + for (auto currentCommand = channel.incomingUnreliableCommands.rbegin(); currentCommand != channel.incomingUnreliableCommands.rend(); ++currentCommand) + { + ENetPeer::IncomingCommmand& incomingCommand = *currentCommand; + + if (startSequenceNumber >= channel.incomingReliableSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + continue; + } + else if (incomingCommand.reliableSequenceNumber >= channel.incomingReliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber < reliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber > reliableSequenceNumber) + continue; + + if (incomingCommand.unreliableSequenceNumber <= startSequenceNumber) + { + if (incomingCommand.unreliableSequenceNumber < startSequenceNumber) + break; + + if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendUnreliableFragment || + totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.size()) + return false; + + startCommand = &incomingCommand; + break; + } + } + + if (startCommand) + { + if (!peer->QueueIncomingCommand(*command, nullptr, totalLength, ENetPacketFlag_UnreliableFragment, fragmentCount)) + return false; + } + + if ((startCommand->fragments[fragmentNumber / 32] & (1 << (fragmentNumber % 32))) == 0) + { + --startCommand->fragmentsRemaining; + + startCommand->fragments[fragmentNumber / 32] |= (1 << (fragmentNumber % 32)); + + if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) + fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; + + std::memcpy(startCommand->packet->data.GetData() + Nz::NetPacket::HeaderSize + fragmentOffset, reinterpret_cast(command) + sizeof(ENetProtocolSendFragment), fragmentLength); + + if (startCommand->fragmentsRemaining <= 0) + peer->DispatchIncomingUnreliableCommands(channel); + } + + return true; + } + + bool ENetHost::HandleSendUnsequenced(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) + { + if (command->header.channelID >= peer->m_channels.size() || peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + return false; + + std::size_t dataLength = NetToHost(command->sendUnsequenced.dataLength); + *currentData += dataLength; + if (dataLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) + return false; + + UInt32 unsequencedGroup = NetToHost(command->sendUnsequenced.unsequencedGroup); + UInt32 index = unsequencedGroup % ENetConstants::ENetPeer_UnsequencedWindowSize; + + if (unsequencedGroup < peer->m_incomingUnsequencedGroup) + unsequencedGroup += 0x10000; + + if (unsequencedGroup >= static_cast(peer->m_incomingUnsequencedGroup) + ENetConstants::ENetPeer_UnsequencedWindows * ENetConstants::ENetPeer_UnsequencedWindowSize) + return true; + + unsequencedGroup &= 0xFFFF; + + if (unsequencedGroup - index != peer->m_incomingUnsequencedGroup) + { + peer->m_incomingUnsequencedGroup = unsequencedGroup - index; + + peer->m_unsequencedWindow.fill(0); + } + else if (peer->m_unsequencedWindow[index / 32] & (1 << (index % 32))) + return true; + + if (!peer->QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendUnsequenced), dataLength, ENetPacketFlag_Unsequenced, 0)) + return false; + + peer->m_unsequencedWindow[index / 32] |= 1 << (index % 32); + + return true; + } + bool ENetHost::HandleThrottleConfigure(ENetPeer* peer, const ENetProtocol* command) { if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) @@ -901,17 +1182,8 @@ namespace Nz // Intercept - switch (HandleIncomingCommands(event)) - { - case 1: - return 1; - - case -1: - return -1; - - default: - break; - } + if (HandleIncomingCommands(event)) + return 1; } return -1; @@ -956,6 +1228,346 @@ namespace Nz } } + void ENetHost::SendAcknowledgements(ENetPeer* peer) + { + std::cout << "SendAcknowledgements " << peer->m_acknowledgements.size() << std::endl; + + auto currentAcknowledgement = peer->m_acknowledgements.begin(); + while (currentAcknowledgement != peer->m_acknowledgements.end()) + { + if (m_commandCount >= m_commands.size() || m_bufferCount >= m_buffers.size() || peer->m_mtu - m_packetSize < sizeof(ENetProtocolAcknowledge)) + { + m_continueSending = true; + break; + } + + ENetPeer::Acknowledgement& acknowledgement = *currentAcknowledgement; + + ENetProtocol& command = m_commands[m_commandCount]; + NetBuffer& buffer = m_buffers[m_bufferCount]; + + buffer.data = &command; + buffer.dataLength = sizeof(ENetProtocolAcknowledge); + + m_packetSize += buffer.dataLength; + + UInt16 reliableSequenceNumber = HostToNet(acknowledgement.command.header.reliableSequenceNumber); + + command.header.command = ENetProtocolCommand_Acknowledge; + command.header.channelID = acknowledgement.command.header.channelID; + command.header.reliableSequenceNumber = reliableSequenceNumber; + command.acknowledge.receivedReliableSequenceNumber = reliableSequenceNumber; + command.acknowledge.receivedSentTime = HostToNet(acknowledgement.sentTime); + + if ((acknowledgement.command.header.command & ENetProtocolCommand_Mask) == ENetProtocolCommand_Disconnect) + peer->DispatchState(ENetPeerState::Zombie); + + currentAcknowledgement = peer->m_acknowledgements.erase(currentAcknowledgement); + + ++m_bufferCount; + ++m_commandCount; + } + } + + bool ENetHost::SendReliableOutgoingCommands(ENetPeer* peer) + { + bool canPing = true; + bool windowExceeded = false; + bool windowWrap = false; + + auto currentCommand = peer->m_outgoingReliableCommands.begin(); + while (currentCommand != peer->m_outgoingReliableCommands.end()) + { + auto outgoingCommand = currentCommand; + + UInt16 reliableWindow = outgoingCommand->reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + ENetPeer::Channel* channel = (outgoingCommand->command.header.channelID < peer->m_channels.size()) ? &peer->m_channels[outgoingCommand->command.header.channelID] : nullptr; + if (channel) + { + if (!windowWrap && outgoingCommand->sendAttempts < 1 && !(outgoingCommand->reliableSequenceNumber % ENetPeer_ReliableWindowSize) && + ((channel->reliableWindows[(reliableWindow + ENetPeer_ReliableWindows - 1) % ENetPeer_ReliableWindows] >= ENetPeer_ReliableWindowSize) || + channel->usedReliableWindows & ((((1 << ENetPeer_ReliableWindows) - 1) << reliableWindow) | + (((1 << ENetPeer_FreeReliableWindows) - 1) >> (ENetPeer_ReliableWindows - reliableWindow))))) + windowWrap = true; + + if (windowWrap) + { + ++currentCommand; + continue; + } + } + + if (outgoingCommand->packet) + { + if (!windowExceeded) + { + UInt32 windowSize = (peer->m_packetThrottle * peer->m_windowSize) / ENetPeer_PacketThrottleScale; + + if (peer->m_reliableDataInTransit + outgoingCommand->fragmentLength > std::max(windowSize, peer->m_mtu)) + windowExceeded = true; + } + + if (windowExceeded) + { + ++currentCommand; + continue; + } + } + + canPing = false; + + std::size_t commandSize = s_commandSizes[outgoingCommand->command.header.command & ENetProtocolCommand_Mask]; + if (m_commandCount >= m_commands.size() || m_bufferCount + 1 >= m_buffers.size() || peer->m_mtu - m_packetSize < commandSize || + (outgoingCommand->packet && UInt16(peer->m_mtu - m_packetSize) < UInt16(commandSize + outgoingCommand->fragmentLength))) + { + m_continueSending = true; + break; + } + + ++currentCommand; + + if (channel && outgoingCommand->sendAttempts < 1) + { + channel->usedReliableWindows |= 1 << reliableWindow; + ++channel->reliableWindows[reliableWindow]; + } + + ++outgoingCommand->sendAttempts; + + if (outgoingCommand->roundTripTimeout == 0) + { + outgoingCommand->roundTripTimeout = peer->m_roundTripTime + 4 * peer->m_roundTripTimeVariance; + outgoingCommand->roundTripTimeoutLimit = peer->m_timeoutLimit * outgoingCommand->roundTripTimeout; + } + + if (peer->m_sentReliableCommands.empty()) + peer->m_nextTimeout = m_serviceTime + outgoingCommand->roundTripTimeout; + + peer->m_sentReliableCommands.emplace_back(std::move(*outgoingCommand)); + peer->m_outgoingReliableCommands.erase(outgoingCommand); + + outgoingCommand = peer->m_sentReliableCommands.end(); + --outgoingCommand; + + outgoingCommand->sentTime = m_serviceTime; + + ENetProtocol& command = m_commands[m_commandCount]; + NetBuffer& buffer = m_buffers[m_bufferCount]; + + buffer.data = &command; + buffer.dataLength = commandSize; + + m_packetSize += buffer.dataLength; + m_headerFlags |= ENetProtocolHeaderFlag_SentTime; + + command = outgoingCommand->command; + + if (outgoingCommand->packet) + { + ++m_bufferCount; + + NetBuffer& packetBuffer = m_buffers[m_bufferCount]; + packetBuffer.data = outgoingCommand->packet->data.GetData() + Nz::NetPacket::HeaderSize + outgoingCommand->fragmentOffset; + packetBuffer.dataLength = outgoingCommand->fragmentLength; + + m_packetSize += packetBuffer.dataLength; + + peer->m_reliableDataInTransit += outgoingCommand->fragmentLength; + } + + ++peer->m_packetsSent; + ++m_bufferCount; + ++m_commandCount; + } + + return canPing; + } + + int ENetHost::SendOutgoingCommands(ENetEvent* event, bool checkForTimeouts) + { + std::array headerData; + ENetProtocolHeader* header = reinterpret_cast(headerData.data()); + + m_continueSending = true; + + while (m_continueSending) + { + m_continueSending = false; + + for (std::size_t peer = 0; peer < m_peerCount; ++peer) + { + ENetPeer* currentPeer = &m_peers[peer]; + if (currentPeer->m_state == ENetPeerState::Disconnected || currentPeer->m_state == ENetPeerState::Zombie) + continue; + + m_headerFlags = 0; + m_commandCount = 0; + m_bufferCount = 1; + m_packetSize = sizeof(ENetProtocolHeader); + + if (!currentPeer->m_acknowledgements.empty()) + SendAcknowledgements(currentPeer); + + if (checkForTimeouts && !currentPeer->m_sentReliableCommands.empty() && ENET_TIME_GREATER_EQUAL(m_serviceTime, currentPeer->m_nextTimeout) && + CheckTimeouts(currentPeer, event)) + { + if (event && event->type != ENetEventType::None) + return 1; + else + continue; + } + + if ((currentPeer->m_outgoingReliableCommands.empty() || SendReliableOutgoingCommands(currentPeer)) && currentPeer->m_sentReliableCommands.empty() && + ENET_TIME_DIFFERENCE(m_serviceTime, currentPeer->m_lastReceiveTime) >= currentPeer->m_pingInterval && currentPeer->m_mtu - m_packetSize >= sizeof(ENetProtocolPing)) + { + currentPeer->Ping(); + SendReliableOutgoingCommands(currentPeer); + } + + if (!currentPeer->m_outgoingUnreliableCommands.empty()) + SendUnreliableOutgoingCommands(currentPeer); + + if (m_commandCount == 0) + continue; + + if (currentPeer->m_packetLossEpoch == 0) + currentPeer->m_packetLossEpoch = m_serviceTime; + else if (ENET_TIME_DIFFERENCE(m_serviceTime, currentPeer->m_packetLossEpoch) >= ENetPeer_PacketLossInterval && currentPeer->m_packetsSent > 0) + { + UInt32 packetLoss = currentPeer->m_packetsLost * ENetPeer_PacketLossScale / currentPeer->m_packetsSent; + + #ifdef ENET_DEBUG + printf("peer %u: %f%%+-%f%% packet loss, %u+-%u ms round trip time, %f%% throttle, %u/%u outgoing, %u/%u incoming\n", currentPeer->incomingPeerID, currentPeer->packetLoss / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer->packetLossVariance / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer->roundTripTime, currentPeer->roundTripTimeVariance, currentPeer->packetThrottle / (float) ENET_PEER_PACKET_THROTTLE_SCALE, enet_list_size(¤tPeer->outgoingReliableCommands), enet_list_size(¤tPeer->outgoingUnreliableCommands), currentPeer->channels != NULL ? enet_list_size(¤tPeer->channels->incomingReliableCommands) : 0, currentPeer->channels != NULL ? enet_list_size(¤tPeer->channels->incomingUnreliableCommands) : 0); + #endif + + currentPeer->m_packetLossVariance -= currentPeer->m_packetLossVariance / 4; + + if (packetLoss >= currentPeer->m_packetLoss) + { + currentPeer->m_packetLoss += (packetLoss - currentPeer->m_packetLoss) / 8; + currentPeer->m_packetLossVariance += (packetLoss - currentPeer->m_packetLoss) / 4; + } + else + { + currentPeer->m_packetLoss -= (currentPeer->m_packetLoss - packetLoss) / 8; + currentPeer->m_packetLossVariance += (currentPeer->m_packetLoss - packetLoss) / 4; + } + + currentPeer->m_packetLossEpoch = m_serviceTime; + currentPeer->m_packetsSent = 0; + currentPeer->m_packetsLost = 0; + } + + + m_buffers[0].data = headerData.data(); + if (m_headerFlags & ENetProtocolHeaderFlag_SentTime) + { + header->sentTime = HostToNet(static_cast(m_serviceTime)); + + m_buffers[0].dataLength = sizeof(ENetProtocolHeader); + } + else + m_buffers[0].dataLength = NazaraOffsetOf(ENetProtocolHeader, sentTime); + + if (currentPeer->m_outgoingPeerID < ENetConstants::ENetProtocol_MaximumPeerId) + m_headerFlags |= currentPeer->m_outgoingSessionID << ENetProtocolHeaderSessionShift; + + header->peerID = HostToNet(static_cast(currentPeer->m_outgoingPeerID | m_headerFlags)); + + currentPeer->m_lastSendTime = m_serviceTime; + + std::size_t sentLength; + if (!m_socket.SendMultiple(currentPeer->m_address, m_buffers.data(), m_bufferCount, &sentLength)) + return -1; + + currentPeer->RemoveSentUnreliableCommands(); + + m_totalSentData += sentLength; + m_totalSentPackets++; + } + } + + return 0; + } + + void ENetHost::SendUnreliableOutgoingCommands(ENetPeer* peer) + { + auto currentCommand = peer->m_outgoingUnreliableCommands.begin(); + while (currentCommand != peer->m_outgoingUnreliableCommands.end()) + { + auto outgoingCommand = currentCommand; + + std::size_t commandSize = s_commandSizes[outgoingCommand->command.header.command & ENetProtocolCommand_Mask]; + + if (m_commandCount >= m_commands.size() || m_bufferCount + 1 >= m_buffers.size() || peer->m_mtu - m_packetSize < commandSize || + (outgoingCommand->packet && peer->m_mtu - m_packetSize < commandSize + outgoingCommand->fragmentLength)) + { + m_continueSending = true; + break; + } + + ++currentCommand; + + if (outgoingCommand->packet && outgoingCommand->fragmentOffset == 0) + { + peer->m_packetThrottleCounter += ENetConstants::ENetPeer_PacketThrottleCounter; + peer->m_packetThrottleCounter %= ENetConstants::ENetPeer_PacketThrottleScale; + + if (peer->m_packetThrottleCounter > peer->m_packetThrottle) + { + UInt16 reliableSequenceNumber = outgoingCommand->reliableSequenceNumber; + UInt16 unreliableSequenceNumber = outgoingCommand->unreliableSequenceNumber; + + for (;;) + { + peer->m_outgoingUnreliableCommands.erase(outgoingCommand); + + if (currentCommand == peer->m_outgoingUnreliableCommands.end()) + break; + + outgoingCommand = currentCommand; + if (outgoingCommand->reliableSequenceNumber != reliableSequenceNumber || outgoingCommand->unreliableSequenceNumber != unreliableSequenceNumber) + break; + + ++currentCommand; + } + + continue; + } + } + + ENetProtocol& command = m_commands[m_commandCount]; + NetBuffer& buffer = m_buffers[m_bufferCount]; + + buffer.data = &command; + buffer.dataLength = commandSize; + + command = outgoingCommand->command; + + if (outgoingCommand->packet) + { + ++m_bufferCount; + + NetBuffer& packetBuffer = m_buffers[m_bufferCount]; + packetBuffer.data = outgoingCommand->packet->data.GetData() + Nz::NetPacket::HeaderSize + outgoingCommand->fragmentOffset; + packetBuffer.dataLength = outgoingCommand->fragmentLength; + + m_packetSize += packetBuffer.dataLength; + + peer->m_sentUnreliableCommands.emplace_back(std::move(*outgoingCommand)); + } + + peer->m_outgoingUnreliableCommands.erase(outgoingCommand); + + ++m_bufferCount; + ++m_commandCount; + } + + if (peer->m_state == ENetPeerState::DisconnectLater && peer->m_outgoingReliableCommands.empty() && + peer->m_outgoingUnreliableCommands.empty() && peer->m_sentReliableCommands.empty()) + peer->Disconnect(peer->m_eventData); + } + void ENetHost::ThrottleBandwidth() { UInt32 currentTime = GetElapsedMilliseconds(); @@ -1108,6 +1720,11 @@ namespace Nz } } + std::size_t ENetHost::GetCommandSize(UInt8 commandNumber) + { + return s_commandSizes[commandNumber & ENetProtocolCommand_Mask]; + } + bool ENetHost::Initialize() { std::random_device device; diff --git a/src/Nazara/Network/ENetPacket.cpp b/src/Nazara/Network/ENetPacket.cpp index ec2bc4ab7..a22cc7fb8 100644 --- a/src/Nazara/Network/ENetPacket.cpp +++ b/src/Nazara/Network/ENetPacket.cpp @@ -1,11 +1,11 @@ -#include +#include #include #include namespace Nz { /// Temporary - void ENetPacketRef::Reset(ENetPacket* packet = nullptr) + void ENetPacketRef::Reset(ENetPacket* packet) { if (m_packet) { @@ -20,4 +20,4 @@ namespace Nz if (m_packet) m_packet->referenceCount++; } -} \ No newline at end of file +} diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 6f7f33312..2031755c4 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -1,7 +1,8 @@ -#include +#include #include #include #include +#include #include namespace Nz @@ -129,7 +130,7 @@ namespace Nz IncomingCommmand& incomingCommand = m_dispatchedCommands.front(); - m_totalWaitingData -= incomingCommand.packet->data.GetSize(); + m_totalWaitingData -= incomingCommand.packet->data.GetDataSize(); if (packet) *packet = std::move(incomingCommand.packet); @@ -192,7 +193,7 @@ namespace Nz m_eventData = 0; m_totalWaitingData = 0; - std::memset(m_unsequencedWindow, 0, sizeof(m_unsequencedWindow)); + m_unsequencedWindow.fill(0); ResetQueues(); } @@ -209,7 +210,7 @@ namespace Nz bool ENetPeer::Send(UInt8 channelId, ENetPacketRef packetRef) { - if (m_state != ENetPeerState::Connected || channelId >= m_channels.size() || packetRef->data.GetSize() > m_host->m_maximumPacketSize) + if (m_state != ENetPeerState::Connected || channelId >= m_channels.size() || packetRef->data.GetDataSize() > m_host->m_maximumPacketSize) return false; Channel& channel = m_channels[channelId]; @@ -218,7 +219,7 @@ namespace Nz //if (m_host->m_checksum != nullptr) // fragmentLength -= sizeof(UInt32); - UInt32 packetSize = static_cast(packetRef->data.GetSize()); + UInt32 packetSize = static_cast(packetRef->data.GetDataSize()); if (packetSize > fragmentLength) { UInt32 fragmentCount = (packetSize + fragmentLength - 1) / fragmentLength; @@ -254,7 +255,7 @@ namespace Nz OutgoingCommand outgoingCommand; outgoingCommand.fragmentOffset = fragmentOffset; - outgoingCommand.fragmentLength = fragmentLength; + outgoingCommand.fragmentLength = static_cast(fragmentLength); outgoingCommand.packet = packetRef; outgoingCommand.command.header.command = commandNumber; outgoingCommand.command.header.channelID = channelId; @@ -275,11 +276,20 @@ namespace Nz command.header.channelID = channelId; if ((packetRef->flags & (ENetPacketFlag_Reliable | ENetPacketFlag_Unsequenced)) == ENetPacketFlag_Unsequenced) + { command.header.command = ENetProtocolCommand_SendUnsequenced | ENetProtocolFlag_Unsequenced; + command.sendUnsequenced.dataLength = HostToNet(UInt16(packetRef->data.GetDataSize())); + } else if (packetRef->flags & ENetPacketFlag_Reliable || channel.outgoingUnreliableSequenceNumber >= 0xFFFF) + { command.header.command = ENetProtocolCommand_SendReliable | ENetProtocolFlag_Acknowledge; + command.sendReliable.dataLength = HostToNet(UInt16(packetRef->data.GetDataSize())); + } else + { command.header.command = ENetProtocolCommand_SendUnreliable; + command.sendUnreliable.dataLength = HostToNet(UInt16(packetRef->data.GetDataSize())); + } QueueOutgoingCommand(command, packetRef, 0, packetSize); @@ -354,6 +364,13 @@ namespace Nz m_windowSize = Clamp(windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); } + void ENetPeer::DispatchState(ENetPeerState state) + { + ChangeState(state); + + m_host->AddToDispatchQueue(this); + } + void ENetPeer::DispatchIncomingReliableCommands(Channel& channel) { auto currentCommand = channel.incomingReliableCommands.begin(); @@ -375,7 +392,7 @@ namespace Nz channel.incomingUnreliableSequenceNumber = 0; - m_dispatchedCommands.splice(m_dispatchedCommands.end(), m_dispatchedCommands, channel.incomingReliableCommands.begin(), currentCommand); + m_dispatchedCommands.splice(m_dispatchedCommands.end(), channel.incomingReliableCommands, channel.incomingReliableCommands.begin(), currentCommand); m_host->AddToDispatchQueue(this); @@ -408,7 +425,7 @@ namespace Nz if (startCommand != currentCommand) { - m_dispatchedCommands.splice(m_dispatchedCommands.end(), m_dispatchedCommands, startCommand, currentCommand); + m_dispatchedCommands.splice(m_dispatchedCommands.end(), channel.incomingUnreliableCommands, startCommand, currentCommand); m_host->AddToDispatchQueue(this); @@ -436,7 +453,7 @@ namespace Nz if (startCommand != currentCommand) { - m_dispatchedCommands.splice(m_dispatchedCommands.end(), m_dispatchedCommands, startCommand, currentCommand); + m_dispatchedCommands.splice(m_dispatchedCommands.end(), channel.incomingUnreliableCommands, startCommand, currentCommand); m_host->AddToDispatchQueue(this); } @@ -448,7 +465,7 @@ namespace Nz if (startCommand != currentCommand) { - m_dispatchedCommands.splice(m_dispatchedCommands.end(), m_dispatchedCommands, startCommand, currentCommand); + m_dispatchedCommands.splice(m_dispatchedCommands.end(), channel.incomingUnreliableCommands, startCommand, currentCommand); m_host->AddToDispatchQueue(this); @@ -587,7 +604,7 @@ namespace Nz } Acknowledgement acknowledgment; - acknowledgment.command = command; + acknowledgment.command = *command; acknowledgment.sentTime = sentTime; m_outgoingDataTotal += sizeof(Acknowledgement); @@ -597,7 +614,7 @@ namespace Nz return true; } - ENetPeer::IncomingCommmand* ENetPeer::QueueIncomingCommand(ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount) + ENetPeer::IncomingCommmand* ENetPeer::QueueIncomingCommand(const ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount) { static IncomingCommmand dummyCommand; @@ -740,6 +757,9 @@ namespace Nz incomingCommand.fragments.resize(fragmentCount, 0); incomingCommand.fragmentsRemaining = fragmentCount; + if (packet) + m_totalWaitingData += packet->data.GetDataSize(); + auto it = commandList->insert(currentCommand.base(), incomingCommand); switch (command.header.command & ENetProtocolCommand_Mask) @@ -762,7 +782,7 @@ namespace Nz OutgoingCommand outgoingCommand; outgoingCommand.command = command; outgoingCommand.fragmentLength = length; - outgoingCommand.fragmentOffset = length; + outgoingCommand.fragmentOffset = offset; outgoingCommand.packet = packet; SetupOutgoingCommand(outgoingCommand); @@ -770,7 +790,7 @@ namespace Nz void ENetPeer::SetupOutgoingCommand(OutgoingCommand& outgoingCommand) { - m_outgoingDataTotal += enet_protocol_command_size(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength; + m_outgoingDataTotal += ENetHost::GetCommandSize(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength; if (outgoingCommand.command.header.channelID == 0xFF) { @@ -827,7 +847,7 @@ namespace Nz break; } - if (outgoingCommand.command.header.command & ENetProtocolCommand_Acknowledge) + if (outgoingCommand.command.header.command & ENetProtocolFlag_Acknowledge) m_outgoingReliableCommands.emplace_back(outgoingCommand); else m_outgoingUnreliableCommands.emplace_back(outgoingCommand); diff --git a/src/Nazara/Network/ENetSocket.cpp b/src/Nazara/Network/ENetSocket.cpp deleted file mode 100644 index e86313fb4..000000000 --- a/src/Nazara/Network/ENetSocket.cpp +++ /dev/null @@ -1,642 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Utility module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - /*! - * \ingroup network - * \class Nz::ENetConnection - * \brief Network class that represents a reliable UDP connection, based on ENet library - */ - - /*! - * \brief Constructs a RUdpConnection object by default - */ - - ENetSocket::ENetSocket() : - m_bandwidthThrottleEpoch(0), - m_mtu(ENetConstants::DefaultMTU), - m_isSimulationEnabled(false), - m_shouldAcceptConnections(true) - { - m_randomSeed = *reinterpret_cast(this); - m_randomSeed += s_randomGenerator(); - m_randomSeed = (m_randomSeed << 16) | (m_randomSeed >> 16); - - } - - /*! - * \brief Connects to the IpAddress - * \return true - * - * \param remoteAddress Address to connect to - * - * \remark Produces a NazaraAssert if socket is not bound - * \remark Produces a NazaraAssert if remote is invalid - * \remark Produces a NazaraAssert if port is not specified - */ - - bool RUdpConnection::Connect(const IpAddress& remoteAddress) - { - NazaraAssert(m_socket.GetState() == SocketState_Bound, "Socket must be bound first"); - NazaraAssert(remoteAddress.IsValid(), "Invalid remote address"); - NazaraAssert(remoteAddress.GetPort() != 0, "Remote address has no port"); - - PeerData& client = RegisterPeer(remoteAddress, PeerState_Connecting); - client.stateData1 = s_randomGenerator(); - - NetPacket connectionRequestPacket(NetCode_RequestConnection); - connectionRequestPacket << client.stateData1; - - EnqueuePacket(client, PacketPriority_Immediate, PacketReliability_Reliable, connectionRequestPacket); - return true; - } - - /*! - * \brief Connects to the hostname - * \return true If successful - * - * \param hostName Hostname of the remote - * \param protocol Net protocol to use - * \param service Specify the protocol used - * \param error Optional argument to get the error - */ - - bool RUdpConnection::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error) - { - std::vector results = IpAddress::ResolveHostname(protocol, hostName, service, error); - if (results.empty()) - { - m_lastError = SocketError_ResolveError; - return false; - } - - IpAddress hostnameAddress; - for (const HostnameInfo& result : results) - { - if (!result.address) - continue; - - if (result.socketType != SocketType_UDP) - continue; - - hostnameAddress = result.address; - break; //< Take first valid address - } - - return Connect(hostnameAddress); - } - - /*! - * \brief Listens to a socket - * \return true If successfully bound - * - * \param remoteAddress Address to listen to - */ - - bool RUdpConnection::Listen(const IpAddress& address) - { - if (!InitSocket(address.GetProtocol())) - return false; - - return m_socket.Bind(address) == SocketState_Bound; - } - - /*! - * \brief Polls the message - * \return true If there is a message - * - * \param message Message to poll - * - * \remark Produces a NazaraAssert if message is invalid - */ - - bool RUdpConnection::PollMessage(RUdpMessage* message) - { - NazaraAssert(message, "Invalid message"); - - if (m_receivedMessages.empty()) - return false; - - *message = std::move(m_receivedMessages.front()); - m_receivedMessages.pop(); - return true; - } - - /*! - * \brief Sends the packet to a peer - * \return true If peer exists (false may result from disconnected client) - * - * \param peerIp IpAddress of the peer - * \param priority Priority of the packet - * \param reliability Policy of reliability of the packet - * \param packet Packet to send - */ - - bool RUdpConnection::Send(const IpAddress& peerIp, PacketPriority priority, PacketReliability reliability, const NetPacket& packet) - { - auto it = m_peerByIP.find(peerIp); - if (it == m_peerByIP.end()) - return false; /// Silently fail (probably a disconnected client) - - EnqueuePacket(m_peers[it->second], priority, reliability, packet); - return true; - } - - /*! - * \brief Updates the reliable connection - */ - - void RUdpConnection::Update() - { - m_currentTime = m_clock.GetMicroseconds(); - - NetPacket receivedPacket; - IpAddress senderIp; - while (m_socket.ReceivePacket(&receivedPacket, &senderIp)) - OnPacketReceived(senderIp, std::move(receivedPacket)); - - //for (unsigned int i = m_activeClients.FindFirst(); i != m_activeClients.npos; i = m_activeClients.FindNext(i)) - //{ - // PeerData& clientData = m_peers[i]; - - CallOnExit resetIterator([this] () { m_peerIterator = m_peers.size(); }); - - for (m_peerIterator = 0; m_peerIterator < m_peers.size(); ++m_peerIterator) - { - PeerData& peer = m_peers[m_peerIterator]; - - UInt32 timeSinceLastPacket = static_cast(m_currentTime - peer.lastPacketTime); - if (timeSinceLastPacket > m_timeBeforeTimeOut) - { - DisconnectPeer(peer.index); - continue; - } - else if (timeSinceLastPacket > m_timeBeforePing) - { - if (m_currentTime - peer.lastPingTime > m_pingInterval) - { - NetPacket pingPacket(NetCode_Ping); - EnqueuePacket(peer, PacketPriority_Low, PacketReliability_Unreliable, pingPacket); - } - } - - if (peer.state == PeerState_WillAck && m_currentTime - peer.stateData1 > m_forceAckSendTime) - { - NetPacket acknowledgePacket(NetCode_Acknowledge); - EnqueuePacket(peer, PacketPriority_Low, PacketReliability_Reliable, acknowledgePacket); - } - - for (unsigned int priority = PacketPriority_Highest; priority <= PacketPriority_Lowest; ++priority) - { - std::vector& pendingPackets = peer.pendingPackets[priority]; - for (PendingPacket& packetData : pendingPackets) - SendPacket(peer, std::move(packetData)); - - pendingPackets.clear(); - } - - auto it = peer.pendingAckQueue.begin(); - while (it != peer.pendingAckQueue.end()) - { - if (m_currentTime - it->timeSent > 2 * peer.roundTripTime) - { - OnPacketLost(peer, std::move(*it)); - it = peer.pendingAckQueue.erase(it); - } - else - ++it; - } - } - //m_activeClients.Reset(); - } - - /*! - * \brief Disconnects a peer - * - * \param peerIndex Index of the peer - * - * \remark Produces a NazaraNotice - */ - - void RUdpConnection::DisconnectPeer(std::size_t peerIndex) - { - PeerData& peer = m_peers[peerIndex]; - NazaraNotice(m_socket.GetBoundAddress().ToString() + ": " + peer.address.ToString() + " has been disconnected due to time-out"); - - OnPeerDisconnected(this, peer.address); - - // Remove from IP lookup table - m_peerByIP.erase(peer.address); - - // Can we safely "remove" this slot? - if (m_peerIterator >= m_peers.size() - 1 || peerIndex > m_peerIterator) - { - // Yes we can - PeerData& newSlot = m_peers[peerIndex]; - newSlot = std::move(m_peers.back()); - newSlot.index = peerIndex; //< Update the moved slot index before resizing (in case it's the last one) - } - else - { - // Nope, let's be tricky - PeerData& current = m_peers[m_peerIterator]; - PeerData& newSlot = m_peers[peerIndex]; - - newSlot = std::move(current); - newSlot.index = peerIndex; //< Update the moved slot index - - current = std::move(m_peers.back()); - current.index = m_peerIterator; //< Update the moved slot index - - --m_peerIterator; - } - - // Pop the last entry (from where we moved our slot) - m_peers.pop_back(); - } - - /*! - * \brief Enqueues a packet in the sending list - * - * \param peer Data relative to the peer - * \param priority Priority of the packet - * \param reliability Policy of reliability of the packet - * \param packet Packet to send - */ - - void RUdpConnection::EnqueuePacket(PeerData& peer, PacketPriority priority, PacketReliability reliability, const NetPacket& packet) - { - UInt16 protocolBegin = static_cast(m_protocol & 0xFFFF); - UInt16 protocolEnd = static_cast((m_protocol & 0xFFFF0000) >> 16); - - NetPacket data(packet.GetNetCode(), MessageHeader + packet.GetDataSize() + MessageFooter); - data << protocolBegin; - - data.GetStream()->SetCursorPos(NetPacket::HeaderSize + MessageHeader); - data.Write(packet.GetConstData() + NetPacket::HeaderSize, packet.GetDataSize()); - - data << protocolEnd; - EnqueuePacketInternal(peer, priority, reliability, std::move(data)); - } - - /*! - * \brief Enqueues internally a packet in the sending list - * - * \param peer Data relative to the peer - * \param priority Priority of the packet - * \param reliability Policy of reliability of the packet - * \param packet Packet to send - */ - - void RUdpConnection::EnqueuePacketInternal(PeerData& peer, PacketPriority priority, PacketReliability reliability, NetPacket&& data) - { - PendingPacket pendingPacket; - pendingPacket.data = std::move(data); - pendingPacket.priority = priority; - pendingPacket.reliability = reliability; - - peer.pendingPackets[priority].emplace_back(std::move(pendingPacket)); - m_activeClients.UnboundedSet(peer.index); - } - - /*! - * \brief Inits the internal socket - * \return true If successful - * - * \param protocol Net protocol to use - */ - - bool ENetSocket::InitSocket(NetProtocol protocol) - { - CallOnExit updateLastError([this] - { - m_lastError = m_socket.GetLastError(); - }); - - if (!m_socket.Create(protocol)) - return false; - - m_socket.EnableBlocking(false); - m_socket.SetReceiveBufferSize(ENetConstants::ReceiveBufferSize); - m_socket.SetSendBufferSize(ENetConstants::SendBufferSize); - - return true; - } - - /*! - * \brief Processes the acks - * - * \param peer Data relative to the peer - * \param lastAck Last index of the ack - * \param ackBits Bits for acking - */ - - void RUdpConnection::ProcessAcks(PeerData& peer, SequenceIndex lastAck, UInt32 ackBits) - { - auto it = peer.pendingAckQueue.begin(); - while (it != peer.pendingAckQueue.end()) - { - bool acked = false; - if (lastAck == it->sequenceId) - acked = true; - else if (!IsAckMoreRecent(it->sequenceId, lastAck)) - { - unsigned int difference = ComputeSequenceDifference(lastAck, it->sequenceId); - if (difference <= 32) - acked = (ackBits >> (difference - 1)) & 1; - } - - if (acked) - { - it = peer.pendingAckQueue.erase(it); - } - else - ++it; - } - } - - /*! - * \brief Registers a peer - * \return Data relative to the peer - * - * \param address Address of the peer - * \param state Status of the peer - */ - - RUdpConnection::PeerData& RUdpConnection::RegisterPeer(const IpAddress& address, PeerState state) - { - PeerData data; - data.address = address; - data.localSequence = 0; - data.remoteSequence = 0; - data.index = m_peers.size(); - data.lastPacketTime = m_currentTime; - data.lastPingTime = m_currentTime; - data.roundTripTime = 1'000'000; ///< Okay that's quite a lot - data.state = state; - - m_activeClients.UnboundedSet(data.index); - m_peerByIP[address] = data.index; - - m_peers.emplace_back(std::move(data)); - return m_peers.back(); - } - - /*! - * \brief Operation to do when client requests a connection - * - * \param address Address of the peer - * \param sequenceId Sequence index for the ack - * \param token Token for connection - */ - - void RUdpConnection::OnClientRequestingConnection(const IpAddress& address, SequenceIndex sequenceId, UInt64 token) - { - // Call hook to check if client should be accepted or not - OnPeerConnection(this, address); - - PeerData& client = RegisterPeer(address, PeerState_Aknowledged); - client.remoteSequence = sequenceId; - - /// Acknowledge connection - NetPacket connectionAcceptedPacket(NetCode_AcknowledgeConnection); - //connectionAcceptedPacket << address; - connectionAcceptedPacket << ~token; - - EnqueuePacket(client, PacketPriority_Immediate, PacketReliability_Reliable, connectionAcceptedPacket); - } - - /*! - * \brief Operation to do when a packet is lost - * - * \param peer Data relative to the peer - * \param packet Pending packet - */ - - void RUdpConnection::OnPacketLost(PeerData& peer, PendingAckPacket&& packet) - { - //NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Lost packet " + String::Number(packet.sequenceId)); - - if (IsReliable(packet.reliability)) - EnqueuePacketInternal(peer, packet.priority, packet.reliability, std::move(packet.data)); - } - - /*! - * \brief Operation to do when receiving a packet - * - * \param peerIndex Index of the peer - * - * \remark Produces a NazaraNotice - */ - - void RUdpConnection::OnPacketReceived(const IpAddress& peerIp, NetPacket&& packet) - { - UInt16 protocolBegin; - UInt16 protocolEnd; - SequenceIndex sequenceId; - SequenceIndex lastAck; - UInt32 ackBits; - - packet.GetStream()->SetCursorPos(packet.GetSize() - MessageFooter); - packet >> protocolEnd; - - packet.GetStream()->SetCursorPos(NetPacket::HeaderSize); - packet >> protocolBegin; - - UInt32 protocolId = static_cast(protocolEnd) << 16 | protocolBegin; - if (protocolId != m_protocol) - return; ///< Ignore - - packet >> sequenceId >> lastAck >> ackBits; - - auto it = m_peerByIP.find(peerIp); - if (it == m_peerByIP.end()) - { - switch (packet.GetNetCode()) - { - case NetCode_RequestConnection: - { - UInt64 token; - packet >> token; - - NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_RequestConnection from " + peerIp.ToString() + ": " + String::Number(token)); - if (!m_shouldAcceptConnections) - return; //< Ignore - - OnClientRequestingConnection(peerIp, sequenceId, token); - break; - } - - default: - return; //< Ignore - } - } - else - { - PeerData& peer = m_peers[it->second]; - peer.lastPacketTime = m_currentTime; - - if (peer.receivedQueue.find(sequenceId) != peer.receivedQueue.end()) - return; //< Ignore - - if (m_isSimulationEnabled && m_packetLossProbability(s_randomGenerator)) - { - NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Lost packet " + String::Number(sequenceId) + " from " + peerIp.ToString() + " for simulation purpose"); - return; - } - - ///< Receiving a packet from an acknowledged client means the connection works in both ways - if (peer.state == PeerState_Aknowledged && packet.GetNetCode() != NetCode_RequestConnection) - { - peer.state = PeerState_Connected; - OnPeerAcknowledged(this, peerIp); - } - - if (IsAckMoreRecent(sequenceId, peer.remoteSequence)) - peer.remoteSequence = sequenceId; - - ProcessAcks(peer, lastAck, ackBits); - - peer.receivedQueue.insert(sequenceId); - - switch (packet.GetNetCode()) - { - case NetCode_Acknowledge: - return; //< Do not switch to will ack mode (to prevent infinite replies, just let's ping/pong do that) - - case NetCode_AcknowledgeConnection: - { - if (peer.state == PeerState_Connected) - break; - - IpAddress externalAddress; - UInt64 token; - packet /*>> externalAddress*/ >> token; - - NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_AcknowledgeConnection from " + peerIp.ToString() + ": " + String::Number(token)); - if (token == ~peer.stateData1) - { - peer.state = PeerState_Connected; - OnConnectedToPeer(this); - } - else - { - NazaraNotice("Received wrong token (" + String::Number(token) + " instead of " + String::Number(~peer.stateData1) + ") from client " + peer.address); - return; //< Ignore - } - - break; - } - - case NetCode_RequestConnection: - NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_RequestConnection from " + peerIp.ToString()); - return; //< Ignore - - case NetCode_Ping: - { - NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_Ping from " + peerIp.ToString()); - - NetPacket pongPacket(NetCode_Pong); - EnqueuePacket(peer, PacketPriority_Low, PacketReliability_Unreliable, pongPacket); - break; - } - - case NetCode_Pong: - NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received NetCode_Pong from " + peerIp.ToString()); - break; - - default: - { - NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Received 0x" + String::Number(packet.GetNetCode(), 16) + " from " + peerIp.ToString()); - RUdpMessage receivedMessage; - receivedMessage.from = peerIp; - receivedMessage.data = std::move(packet); - - m_receivedMessages.emplace(std::move(receivedMessage)); - break; - } - } - - if (!HasPendingPackets(peer)) - { - peer.state = PeerState_WillAck; - peer.stateData1 = m_currentTime; - } - } - } - - /*! - * \brief Sends a packet to a peer - * - * \param peer Data relative to the peer - * \param packet Pending packet - */ - - void RUdpConnection::SendPacket(PeerData& peer, PendingPacket&& packet) - { - if (peer.state == PeerState_WillAck) - peer.state = PeerState_Connected; - - SequenceIndex remoteSequence = peer.remoteSequence; - - UInt32 previousAcks = 0; - for (SequenceIndex ack : peer.receivedQueue) - { - if (ack == remoteSequence) - continue; - - unsigned int difference = ComputeSequenceDifference(remoteSequence, ack); - if (difference <= 32U) - previousAcks |= (1U << (difference - 1)); - } - - SequenceIndex sequenceId = ++peer.localSequence; - - packet.data.GetStream()->SetCursorPos(NetPacket::HeaderSize + sizeof(UInt16)); ///< Protocol begin has already been filled - packet.data << sequenceId; - packet.data << remoteSequence; - packet.data << previousAcks; - - m_socket.SendPacket(peer.address, packet.data); - - PendingAckPacket pendingAckPacket; - pendingAckPacket.data = std::move(packet.data); - pendingAckPacket.priority = packet.priority; - pendingAckPacket.reliability = packet.reliability; - pendingAckPacket.sequenceId = sequenceId; - pendingAckPacket.timeSent = m_currentTime; - - peer.pendingAckQueue.emplace_back(std::move(pendingAckPacket)); - } - - /*! - * \brief Initializes the RUdpConnection class - * \return true - */ - - bool RUdpConnection::Initialize() - { - std::random_device device; - s_randomGenerator.seed(device()); - - return true; - } - - /*! - * \brief Uninitializes the RUdpConnection class - */ - - void RUdpConnection::Uninitialize() - { - } - - std::mt19937_64 RUdpConnection::s_randomGenerator; -} From 1d6f22cd8ac1e924a5c3cd042f7c0c1e19685df5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 14:49:07 +0100 Subject: [PATCH 068/243] Core/Flags: Make Flags default-constructible --- include/Nazara/Core/Flags.hpp | 2 +- include/Nazara/Core/Flags.inl | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index 1dbd102a0..f356a04a5 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -29,7 +29,7 @@ namespace Nz public: using BitField = typename std::conditional<(EnumAsFlags::max > 32), UInt64, UInt32>::type; - constexpr Flags(BitField value); + constexpr Flags(BitField value = 0); constexpr Flags(E enumVal); explicit constexpr operator bool() const; diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 67fee6a26..57ffd9e7e 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -13,13 +13,13 @@ namespace Nz * \brief Core class used to combine enumeration values into flags bitfield */ - /*! - * \brief Constructs a Flags object using a bitfield - * - * \param value Bitfield to be used + /*! + * \brief Constructs a Flags object using a bitfield + * + * \param value Bitfield to be used * * Uses a bitfield to builds the flag value. (e.g. if bit 0 is active, then Enum value 0 will be set as active). - */ + */ template constexpr Flags::Flags(BitField value) : m_value(value) From ab3b730d217c5d26216962e32b5083d9a44ea777 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 14:51:01 +0100 Subject: [PATCH 069/243] Network/TcpClient|UdpSocket: Add SendMultiple method To efficiently merge multiples buffers into a reduced number of network packets --- include/Nazara/Network/AbstractSocket.hpp | 4 +- include/Nazara/Network/NetBuffer.hpp | 21 ++++++++++ include/Nazara/Network/TcpClient.hpp | 2 + include/Nazara/Network/UdpSocket.hpp | 8 ++-- src/Nazara/Network/Posix/SocketImpl.cpp | 51 +++++++++++++++++++++++ src/Nazara/Network/Posix/SocketImpl.hpp | 1 + src/Nazara/Network/TcpClient.cpp | 39 +++++++++++++++++ src/Nazara/Network/UdpSocket.cpp | 25 +++++++++++ src/Nazara/Network/Win32/SocketImpl.cpp | 51 ++++++++++++++++++++++- src/Nazara/Network/Win32/SocketImpl.hpp | 10 +++-- 10 files changed, 201 insertions(+), 11 deletions(-) create mode 100644 include/Nazara/Network/NetBuffer.hpp diff --git a/include/Nazara/Network/AbstractSocket.hpp b/include/Nazara/Network/AbstractSocket.hpp index 8a2e55e25..0b33c6a8f 100644 --- a/include/Nazara/Network/AbstractSocket.hpp +++ b/include/Nazara/Network/AbstractSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -68,4 +68,4 @@ namespace Nz #include -#endif // NAZARA_ABSTRACTSOCKET_HPP \ No newline at end of file +#endif // NAZARA_ABSTRACTSOCKET_HPP diff --git a/include/Nazara/Network/NetBuffer.hpp b/include/Nazara/Network/NetBuffer.hpp new file mode 100644 index 000000000..0c05c53b2 --- /dev/null +++ b/include/Nazara/Network/NetBuffer.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_NETBUFFER_HPP +#define NAZARA_NETBUFFER_HPP + +#include + +namespace Nz +{ + struct NetBuffer + { + void* data; + std::size_t dataLength; + }; +} + +#endif // NAZARA_NETBUFFER_HPP diff --git a/include/Nazara/Network/TcpClient.hpp b/include/Nazara/Network/TcpClient.hpp index dc41d8eb5..a3b229bda 100644 --- a/include/Nazara/Network/TcpClient.hpp +++ b/include/Nazara/Network/TcpClient.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace Nz { @@ -49,6 +50,7 @@ namespace Nz bool ReceivePacket(NetPacket* packet); bool Send(const void* buffer, std::size_t size, std::size_t* sent); + bool SendMultiple(const NetBuffer* buffers, std::size_t bufferCount, std::size_t* sent); bool SendPacket(const NetPacket& packet); bool SetCursorPos(UInt64 offset) override; diff --git a/include/Nazara/Network/UdpSocket.hpp b/include/Nazara/Network/UdpSocket.hpp index 3c4abdfe7..04ca41db0 100644 --- a/include/Nazara/Network/UdpSocket.hpp +++ b/include/Nazara/Network/UdpSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace Nz { @@ -29,7 +30,7 @@ namespace Nz inline bool Create(NetProtocol protocol); void EnableBroadcasting(bool broadcasting); - + inline IpAddress GetBoundAddress() const; inline UInt16 GetBoundPort() const; inline SocketState GetState() const; @@ -42,6 +43,7 @@ namespace Nz bool ReceivePacket(NetPacket* packet, IpAddress* from); bool Send(const IpAddress& to, const void* buffer, std::size_t size, std::size_t* sent); + bool SendMultiple(const IpAddress& to, const NetBuffer* buffers, std::size_t bufferCount, std::size_t* sent); bool SendPacket(const IpAddress& to, const NetPacket& packet); private: @@ -55,4 +57,4 @@ namespace Nz #include -#endif // NAZARA_UDPSOCKET_HPP \ No newline at end of file +#endif // NAZARA_UDPSOCKET_HPP diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 7d28e6785..93fe74d4d 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -577,6 +577,57 @@ namespace Nz return true; } + bool SocketImpl::SendMultiple(SocketHandle handle, const NetBuffer* buffers, std::size_t bufferCount, const IpAddress& to, int* sent, SocketError* error) + { + NazaraAssert(handle != InvalidHandle, "Invalid handle"); + NazaraAssert(buffers && bufferCount > 0, "Invalid buffers"); + + StackAllocation memory = NazaraStackAllocation(bufferCount * sizeof(iovec)); + iovec* sysBuffers = static_cast(memory.GetPtr()); + for (std::size_t i = 0; i < bufferCount; ++i) + { + sysBuffers[i].iov_base = buffers[i].data; + sysBuffers[i].iov_len = buffers[i].dataLength; + } + + struct msghdr header; + std::memset(&header, 0, sizeof(header); + + IpAddressImpl::SockAddrBuffer nameBuffer; + header.msg_namelen = IpAddressImpl::ToSockAddr(to, nameBuffer.data()); + header.msg_name = nameBuffer.data(); + msgHdr.msg_iov = sysBuffers; + msgHdr.msg_iovlen = static_cast(bufferCount); + + int sentLength = sendmsg (socket, &msgHdr, MSG_NOSIGNAL); + if (byteSent == SOCKET_ERROR) + { + int errorCode = GetLastErrorCode(); + switch (errorCode) + { + case EWOULDBLOCK: + byteSent = 0; + break; + + default: + { + if (error) + *error = TranslateErrnoToResolveError(errorCode); + + return false; //< Error + } + } + } + + if (sent) + *sent = static_cast(byteSent); + + if (error) + *error = SocketError_NoError; + + return true; + } + bool SocketImpl::SendTo(SocketHandle handle, const void* buffer, int length, const IpAddress& to, int* sent, SocketError* error) { NazaraAssert(handle != InvalidHandle, "Invalid handle"); diff --git a/src/Nazara/Network/Posix/SocketImpl.hpp b/src/Nazara/Network/Posix/SocketImpl.hpp index a543d8880..e90d4cc74 100644 --- a/src/Nazara/Network/Posix/SocketImpl.hpp +++ b/src/Nazara/Network/Posix/SocketImpl.hpp @@ -64,6 +64,7 @@ namespace Nz static bool ReceiveFrom(SocketHandle handle, void* buffer, int length, IpAddress* from, int* read, SocketError* error); static bool Send(SocketHandle handle, const void* buffer, int length, int* sent, SocketError* error); + static bool SendMultiple(SocketHandle handle, const NetBuffer* buffers, std::size_t bufferCount, const IpAddress& to, int* sent, SocketError* error); static bool SendTo(SocketHandle handle, const void* buffer, int length, const IpAddress& to, int* sent, SocketError* error); static bool SetBlocking(SocketHandle handle, bool blocking, SocketError* error = nullptr); diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index b5fd845ee..54144e8fd 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -353,6 +353,45 @@ namespace Nz return true; } + /*! + * \brief Sends multiple buffers at once + * \return true If data were sent + * + * \param buffers A pointer to an array of NetBuffer containing buffers and size data + * \param size Number of NetBuffer to send + * \param sent Optional argument to get the number of bytes sent + */ + bool TcpClient::SendMultiple(const NetBuffer* buffers, std::size_t bufferCount, std::size_t* sent) + { + NazaraAssert(buffers && bufferCount > 0, "Invalid buffer"); + + int byteSent; + if (!SocketImpl::SendMultiple(m_handle, buffers, bufferCount, m_peerAddress, &byteSent, &m_lastError)) + { + switch (m_lastError) + { + case SocketError_ConnectionClosed: + case SocketError_ConnectionRefused: + UpdateState(SocketState_NotConnected); + break; + + default: + break; + } + + if (sent) + *sent = byteSent; + + return false; + } + + if (sent) + *sent = byteSent; + + UpdateState(SocketState_Connected); + return true; + } + /*! * \brief Sends the packet available * \return true If packet sent diff --git a/src/Nazara/Network/UdpSocket.cpp b/src/Nazara/Network/UdpSocket.cpp index 679922513..c13dee343 100644 --- a/src/Nazara/Network/UdpSocket.cpp +++ b/src/Nazara/Network/UdpSocket.cpp @@ -179,6 +179,31 @@ namespace Nz return true; } + /*! + * \brief Sends multiple buffers as one datagram + * \return true If data were sent + * + * \param to Destination IpAddress (must match socket protocol) + * \param buffers A pointer to an array of NetBuffer containing buffers and size data + * \param size Number of NetBuffer to send + * \param sent Optional argument to get the number of bytes sent + */ + bool UdpSocket::SendMultiple(const IpAddress& to, const NetBuffer* buffers, std::size_t bufferCount, std::size_t* sent) + { + NazaraAssert(to.IsValid(), "Invalid ip address"); + NazaraAssert(to.GetProtocol() == m_protocol, "IP Address has a different protocol than the socket"); + NazaraAssert(buffers && bufferCount > 0, "Invalid buffer"); + + int byteSent; + if (!SocketImpl::SendMultiple(m_handle, buffers, bufferCount, to, &byteSent, &m_lastError)) + return false; + + if (sent) + *sent = byteSent; + + return true; + } + /*! * \brief Sends the packet available * \return true If packet sent diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 74550fe37..3a5c285e9 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -608,6 +608,53 @@ namespace Nz return true; } + bool SocketImpl::SendMultiple(SocketHandle handle, const NetBuffer* buffers, std::size_t bufferCount, const IpAddress& to, int* sent, SocketError* error) + { + NazaraAssert(handle != InvalidHandle, "Invalid handle"); + NazaraAssert(buffers && bufferCount > 0, "Invalid buffers"); + + IpAddressImpl::SockAddrBuffer nameBuffer; + int bufferLength = IpAddressImpl::ToSockAddr(to, nameBuffer.data()); + + StackAllocation memory = NazaraStackAllocation(bufferCount * sizeof(WSABUF)); + WSABUF* winBuffers = static_cast(memory.GetPtr()); + for (std::size_t i = 0; i < bufferCount; ++i) + { + winBuffers[i].buf = static_cast(buffers[i].data); + winBuffers[i].len = static_cast(buffers[i].dataLength); + } + + DWORD byteSent; + if (WSASendTo(handle, winBuffers, static_cast(bufferCount), &byteSent, 0, reinterpret_cast(nameBuffer.data()), bufferLength, nullptr, nullptr) == SOCKET_ERROR) + { + int errorCode = WSAGetLastError(); + switch (errorCode) + { + case WSAEWOULDBLOCK: + { + byteSent = 0; + break; + } + + default: + { + if (error) + *error = TranslateWSAErrorToSocketError(errorCode); + + return false; //< Error + } + } + } + + if (sent) + *sent = static_cast(byteSent); + + if (error) + *error = SocketError_NoError; + + return true; + } + bool SocketImpl::SendTo(SocketHandle handle, const void* buffer, int length, const IpAddress& to, int* sent, SocketError* error) { NazaraAssert(handle != InvalidHandle, "Invalid handle"); @@ -719,7 +766,7 @@ namespace Nz { NazaraAssert(handle != InvalidHandle, "Invalid handle"); - DWORD option = size; + DWORD option = static_cast(size); if (setsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&option), sizeof(option)) == SOCKET_ERROR) { if (error) @@ -738,7 +785,7 @@ namespace Nz { NazaraAssert(handle != InvalidHandle, "Invalid handle"); - DWORD option = size; + DWORD option = static_cast(size); if (setsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&option), sizeof(option)) == SOCKET_ERROR) { if (error) diff --git a/src/Nazara/Network/Win32/SocketImpl.hpp b/src/Nazara/Network/Win32/SocketImpl.hpp index 5af2b2534..edcc7ce09 100644 --- a/src/Nazara/Network/Win32/SocketImpl.hpp +++ b/src/Nazara/Network/Win32/SocketImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -7,9 +7,10 @@ #ifndef NAZARA_SOCKETIMPL_HPP #define NAZARA_SOCKETIMPL_HPP -#include #include #include +#include +#include #include #define NAZARA_NETWORK_POLL_SUPPORT NAZARA_CORE_WINDOWS_NT6 @@ -34,7 +35,7 @@ namespace Nz static SocketState Bind(SocketHandle handle, const IpAddress& address, SocketError* error); static SocketHandle Create(NetProtocol protocol, SocketType type, SocketError* error); - + static void ClearErrorCode(SocketHandle handle); static void Close(SocketHandle handle); @@ -65,6 +66,7 @@ namespace Nz static bool ReceiveFrom(SocketHandle handle, void* buffer, int length, IpAddress* from, int* read, SocketError* error); static bool Send(SocketHandle handle, const void* buffer, int length, int* sent, SocketError* error); + static bool SendMultiple(SocketHandle handle, const NetBuffer* buffers, std::size_t bufferCount, const IpAddress& to, int* sent, SocketError* error); static bool SendTo(SocketHandle handle, const void* buffer, int length, const IpAddress& to, int* sent, SocketError* error); static bool SetBlocking(SocketHandle handle, bool blocking, SocketError* error = nullptr); @@ -87,4 +89,4 @@ namespace Nz }; } -#endif // NAZARA_SOCKETIMPL_HPP \ No newline at end of file +#endif // NAZARA_SOCKETIMPL_HPP From 002d33f590458681c6c6fbd3ec27e491d0c57e9e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 14:55:37 +0100 Subject: [PATCH 070/243] Network/SocketImpl: Fix compilation --- src/Nazara/Network/Posix/SocketImpl.cpp | 2 +- src/Nazara/Network/Win32/SocketImpl.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 93fe74d4d..b41895a42 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -465,7 +466,6 @@ namespace Nz int errorCode = GetLastErrorCode(); switch (errorCode) { - case EAGAIN: case EWOULDBLOCK: { // If we have no data and are not blocking, return true with 0 byte read diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 3a5c285e9..5c4bdaa0c 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -1,10 +1,11 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include #include +#include #include #if defined(NAZARA_COMPILER_MINGW) && __GNUC__ < 5 From 453ca77c1b6dba611771577da31472293c8f4e93 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 15:05:04 +0100 Subject: [PATCH 071/243] Network/SocketImpl: Fix Send causing a SocketError_Internal status on non-blocking sockets --- src/Nazara/Network/Posix/SocketImpl.cpp | 36 +++++++++++++++++++---- src/Nazara/Network/Win32/SocketImpl.cpp | 38 +++++++++++++++++++++---- 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index b41895a42..257a1c3bc 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -562,10 +562,22 @@ namespace Nz int byteSent = send(handle, reinterpret_cast(buffer), length, 0); if (byteSent == SOCKET_ERROR) { - if (error) - *error = TranslateErrnoToResolveError(GetLastErrorCode()); + int errorCode = GetLastErrorCode(); - return false; //< Error + switch (errorCode) + { + case EWOULDBLOCK: + byteSent = 0; + break; + + default: + { + if (error) + *error = TranslateErrnoToResolveError(errorCode); + + return false; //< Error + } + } } if (sent) @@ -639,10 +651,22 @@ namespace Nz int byteSent = sendto(handle, reinterpret_cast(buffer), length, 0, reinterpret_cast(nameBuffer.data()), bufferLength); if (byteSent == SOCKET_ERROR) { - if (error) - *error = TranslateErrnoToResolveError(GetLastErrorCode()); + int errorCode = GetLastErrorCode(); - return false; //< Error + switch (errorCode) + { + case EWOULDBLOCK: + byteSent = 0; + break; + + default: + { + if (error) + *error = TranslateErrnoToResolveError(errorCode); + + return false; //< Error + } + } } if (sent) diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 5c4bdaa0c..32404f53a 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -594,10 +594,23 @@ namespace Nz int byteSent = send(handle, reinterpret_cast(buffer), length, 0); if (byteSent == SOCKET_ERROR) { - if (error) - *error = TranslateWSAErrorToSocketError(WSAGetLastError()); + int errorCode = WSAGetLastError(); + switch (errorCode) + { + case WSAEWOULDBLOCK: + { + byteSent = 0; + break; + } - return false; //< Error + default: + { + if (error) + *error = TranslateWSAErrorToSocketError(errorCode); + + return false; //< Error + } + } } if (sent) @@ -667,10 +680,23 @@ namespace Nz int byteSent = sendto(handle, reinterpret_cast(buffer), length, 0, reinterpret_cast(nameBuffer.data()), bufferLength); if (byteSent == SOCKET_ERROR) { - if (error) - *error = TranslateWSAErrorToSocketError(WSAGetLastError()); + int errorCode = WSAGetLastError(); + switch (errorCode) + { + case WSAEWOULDBLOCK: + { + byteSent = 0; + break; + } - return false; //< Error + default: + { + if (error) + *error = TranslateWSAErrorToSocketError(errorCode); + + return false; //< Error + } + } } if (sent) From d8b7ff9fa635c7b4d538e1e1411682c6b4f3de4d Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 15:05:26 +0100 Subject: [PATCH 072/243] Network/SocketImpl: Fix possible code errors (Posix) --- src/Nazara/Network/Posix/SocketImpl.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 257a1c3bc..2897a99fc 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -464,6 +464,9 @@ namespace Nz if (byteRead == SOCKET_ERROR) { int errorCode = GetLastErrorCode(); + if (errorCode == EAGAIN) + errorCode = EWOULDBLOCK; + switch (errorCode) { case EWOULDBLOCK: @@ -513,6 +516,9 @@ namespace Nz if (byteRead == SOCKET_ERROR) { int errorCode = GetLastErrorCode(); + if (errorCode == EAGAIN) + errorCode = EWOULDBLOCK; + switch (errorCode) { case EWOULDBLOCK: @@ -563,6 +569,8 @@ namespace Nz if (byteSent == SOCKET_ERROR) { int errorCode = GetLastErrorCode(); + if (errorCode == EAGAIN) + errorCode = EWOULDBLOCK; switch (errorCode) { @@ -595,7 +603,7 @@ namespace Nz NazaraAssert(buffers && bufferCount > 0, "Invalid buffers"); StackAllocation memory = NazaraStackAllocation(bufferCount * sizeof(iovec)); - iovec* sysBuffers = static_cast(memory.GetPtr()); + struct iovec* sysBuffers = static_cast(memory.GetPtr()); for (std::size_t i = 0; i < bufferCount; ++i) { sysBuffers[i].iov_base = buffers[i].data; @@ -611,16 +619,19 @@ namespace Nz msgHdr.msg_iov = sysBuffers; msgHdr.msg_iovlen = static_cast(bufferCount); - int sentLength = sendmsg (socket, &msgHdr, MSG_NOSIGNAL); + int sentLength = sendmsg(socket, &msgHdr, MSG_NOSIGNAL); if (byteSent == SOCKET_ERROR) { int errorCode = GetLastErrorCode(); + if (errorCode == EAGAIN) + errorCode = EWOULDBLOCK; + switch (errorCode) { case EWOULDBLOCK: byteSent = 0; break; - + default: { if (error) @@ -652,6 +663,8 @@ namespace Nz if (byteSent == SOCKET_ERROR) { int errorCode = GetLastErrorCode(); + if (errorCode == EAGAIN) + errorCode = EWOULDBLOCK; switch (errorCode) { From 348942106450571c3e243bbb91c402b786551d18 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 15:08:26 +0100 Subject: [PATCH 073/243] Network/UdpSocket: Fix UdpSocket::Receive failing when peers suddenly closes its socket --- src/Nazara/Network/UdpSocket.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Network/UdpSocket.cpp b/src/Nazara/Network/UdpSocket.cpp index c13dee343..145257afc 100644 --- a/src/Nazara/Network/UdpSocket.cpp +++ b/src/Nazara/Network/UdpSocket.cpp @@ -93,7 +93,18 @@ namespace Nz int read; if (!SocketImpl::ReceiveFrom(m_handle, buffer, static_cast(size), from, &read, &m_lastError)) - return false; + { + switch (m_lastError) + { + case SocketError_ConnectionClosed: + m_lastError = SocketError_NoError; + read = 0; + break; + + default: + return false; + } + } if (received) *received = read; From 86ae60b6c2d1be933d42909272396fdf7a0f148c Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 16:07:41 +0100 Subject: [PATCH 074/243] Network: Fix compilation --- include/Nazara/Network/Enums.hpp | 2 ++ src/Nazara/Network/Posix/SocketImpl.hpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Network/Enums.hpp b/include/Nazara/Network/Enums.hpp index 7dccd7dd1..f80ba6cd9 100644 --- a/include/Nazara/Network/Enums.hpp +++ b/include/Nazara/Network/Enums.hpp @@ -7,6 +7,8 @@ #ifndef NAZARA_ENUMS_NETWORK_HPP #define NAZARA_ENUMS_NETWORK_HPP +#include + namespace Nz { enum NetCode : UInt16 diff --git a/src/Nazara/Network/Posix/SocketImpl.hpp b/src/Nazara/Network/Posix/SocketImpl.hpp index e90d4cc74..7ee2e24f6 100644 --- a/src/Nazara/Network/Posix/SocketImpl.hpp +++ b/src/Nazara/Network/Posix/SocketImpl.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #define NAZARA_NETWORK_POLL_SUPPORT 1 @@ -88,4 +89,4 @@ namespace Nz }; } -#endif // NAZARA_SOCKETIMPL_HPP \ No newline at end of file +#endif // NAZARA_SOCKETIMPL_HPP From 90237186b5a78ff4755600fd264f4b439f9c3916 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 16:25:48 +0100 Subject: [PATCH 075/243] Network/SocketImpl: Fix missing include --- src/Nazara/Network/Posix/SocketImpl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 2897a99fc..baaa8a0d0 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include From 31ebe5983e84bba1f9c894111e7169bf8cddd865 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 16:31:41 +0100 Subject: [PATCH 076/243] Network: Fix typo.. --- src/Nazara/Network/Posix/SocketImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index baaa8a0d0..19da49c89 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include From 7602b4a041ac3ab01557c2ef337fb730293ba399 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 16:37:16 +0100 Subject: [PATCH 077/243] Network/SocketImpl: Fix typo --- src/Nazara/Network/Posix/SocketImpl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 19da49c89..3b7f9bccb 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -611,12 +611,12 @@ namespace Nz sysBuffers[i].iov_len = buffers[i].dataLength; } - struct msghdr header; - std::memset(&header, 0, sizeof(header); + struct msghdr msgHdr; + std::memset(&msgHdr, 0, sizeof(header)); IpAddressImpl::SockAddrBuffer nameBuffer; - header.msg_namelen = IpAddressImpl::ToSockAddr(to, nameBuffer.data()); - header.msg_name = nameBuffer.data(); + msgHdr.msg_namelen = IpAddressImpl::ToSockAddr(to, nameBuffer.data()); + msgHdr.msg_name = nameBuffer.data(); msgHdr.msg_iov = sysBuffers; msgHdr.msg_iovlen = static_cast(bufferCount); From 80442924c1c38b3eb14777ae5d44d2442c6debfb Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 16:43:54 +0100 Subject: [PATCH 078/243] Network/SocketImpl: Fix code, once more --- src/Nazara/Network/Posix/SocketImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 3b7f9bccb..a75a0df35 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -612,7 +612,7 @@ namespace Nz } struct msghdr msgHdr; - std::memset(&msgHdr, 0, sizeof(header)); + std::memset(&msgHdr, 0, sizeof(msgHdr)); IpAddressImpl::SockAddrBuffer nameBuffer; msgHdr.msg_namelen = IpAddressImpl::ToSockAddr(to, nameBuffer.data()); @@ -620,7 +620,7 @@ namespace Nz msgHdr.msg_iov = sysBuffers; msgHdr.msg_iovlen = static_cast(bufferCount); - int sentLength = sendmsg(socket, &msgHdr, MSG_NOSIGNAL); + int byteSent = sendmsg(socket, &msgHdr, MSG_NOSIGNAL); if (byteSent == SOCKET_ERROR) { int errorCode = GetLastErrorCode(); From 42d5f849f7331ce4b3f8034098d74de41c3a9932 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 16:49:09 +0100 Subject: [PATCH 079/243] Network/SocketImpl: Okay, I promise to try to compile myself next time --- src/Nazara/Network/Posix/SocketImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index a75a0df35..be6f84581 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -620,7 +620,7 @@ namespace Nz msgHdr.msg_iov = sysBuffers; msgHdr.msg_iovlen = static_cast(bufferCount); - int byteSent = sendmsg(socket, &msgHdr, MSG_NOSIGNAL); + int byteSent = sendmsg(handle, &msgHdr, MSG_NOSIGNAL); if (byteSent == SOCKET_ERROR) { int errorCode = GetLastErrorCode(); From 0e03aae6dcbae465ce69d65c5da1594eb0698565 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 17:12:23 +0100 Subject: [PATCH 080/243] Network/ENetPeer: Fix compilation --- include/Nazara/Network/ENetPeer.hpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index e68b85de9..1099e4472 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -16,11 +16,9 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include namespace Nz { From 664e3a33ecab433978ca51bfe2013e377f51bf2f Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 27 Jan 2017 17:19:49 +0100 Subject: [PATCH 081/243] Network/ENet: Fix compilation and warnings --- src/Nazara/Network/ENetHost.cpp | 11 ++++------- src/Nazara/Network/ENetPeer.cpp | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index ffe15635a..df77e25c9 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #define ENET_TIME_OVERFLOW 86400000 @@ -145,7 +144,7 @@ namespace Nz { std::vector results = IpAddress::ResolveHostname(protocol, hostName, service, error); if (results.empty()) - return false; + return nullptr; IpAddress hostnameAddress; for (const HostnameInfo& result : results) @@ -558,7 +557,7 @@ namespace Nz return true; } - ENetPeer* ENetHost::HandleConnect(ENetProtocolHeader* header, ENetProtocol* command) + ENetPeer* ENetHost::HandleConnect(ENetProtocolHeader* /*header*/, ENetProtocol* command) { UInt32 channelCount = NetToHost(command->connect.channelCount); @@ -853,7 +852,7 @@ namespace Nz return commandError(); } - bool ENetHost::HandlePing(ENetPeer* peer, const ENetProtocol* command) + bool ENetHost::HandlePing(ENetPeer* peer, const ENetProtocol* /*command*/) { if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) return false; @@ -1071,7 +1070,7 @@ namespace Nz bool ENetHost::HandleSendUnsequenced(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) { - if (command->header.channelID >= peer->m_channels.size() || peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) return false; std::size_t dataLength = NetToHost(command->sendUnsequenced.dataLength); @@ -1230,8 +1229,6 @@ namespace Nz void ENetHost::SendAcknowledgements(ENetPeer* peer) { - std::cout << "SendAcknowledgements " << peer->m_acknowledgements.size() << std::endl; - auto currentAcknowledgement = peer->m_acknowledgements.begin(); while (currentAcknowledgement != peer->m_acknowledgements.end()) { diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 2031755c4..37afe8958 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -30,11 +30,11 @@ namespace Nz } ENetPeer::ENetPeer(ENetHost* host, UInt16 peerId) : - m_packetPool(sizeof(ENetPacket)), m_host(host), - m_incomingPeerID(peerId), + m_packetPool(sizeof(ENetPacket)), m_incomingSessionID(0xFF), - m_outgoingSessionID(0xFF) + m_outgoingSessionID(0xFF), + m_incomingPeerID(peerId) { Reset(); } From 8fc734674dff80c25f36edd3565b7a273a04a669 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Jan 2017 11:06:09 +0100 Subject: [PATCH 082/243] Network/ENet: Fix fragments and cleanup --- include/Nazara/Network/ENetPeer.hpp | 18 ++++--- include/Nazara/Network/ENetPeer.inl | 15 ++++++ src/Nazara/Network/ENetHost.cpp | 82 ++++++++++++++--------------- src/Nazara/Network/ENetPeer.cpp | 19 +++---- 4 files changed, 73 insertions(+), 61 deletions(-) diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 1099e4472..377d8f734 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -40,6 +40,11 @@ namespace Nz void DisconnectNow(UInt32 data); inline const IpAddress& GetAddress() const; + inline ENetPeerState GetState() const; + + inline bool HasPendingCommands(); + + inline bool IsConnected() const; void Ping(); @@ -116,12 +121,12 @@ namespace Nz struct IncomingCommmand { - ENetProtocol command; - UInt16 reliableSequenceNumber; - UInt16 unreliableSequenceNumber; - UInt32 fragmentsRemaining; - std::vector fragments; - ENetPacketRef packet; + ENetProtocol command; + Bitset<> fragments; + ENetPacketRef packet; + UInt16 reliableSequenceNumber; + UInt16 unreliableSequenceNumber; + UInt32 fragmentsRemaining; }; struct OutgoingCommand @@ -152,7 +157,6 @@ namespace Nz std::size_t m_totalWaitingData; std::vector m_channels; MemoryPool m_packetPool; - //ENetListNode m_dispatchList; ENetPeerState m_state; UInt8 m_incomingSessionID; UInt8 m_outgoingSessionID; diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index 2c7044b6e..5c0f76731 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -13,6 +13,21 @@ namespace Nz return m_address; } + inline ENetPeerState ENetPeer::GetState() const + { + return m_state; + } + + inline bool ENetPeer::HasPendingCommands() + { + return m_outgoingReliableCommands.empty() && m_outgoingUnreliableCommands.empty() && m_sentReliableCommands.empty(); + } + + inline bool ENetPeer::IsConnected() const + { + return m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater; + } + inline void ENetPeer::ChangeState(ENetPeerState state) { if (state == ENetPeerState::Connected || state == ENetPeerState::DisconnectLater) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index df77e25c9..a6e98a0c4 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -69,7 +69,7 @@ namespace Nz for (ENetPeer& peer : m_peers) { - if (peer.m_state != ENetPeerState::Connected) + if (peer.GetState() != ENetPeerState::Connected) continue; peer.Send(channelId, enetPacket); @@ -96,7 +96,7 @@ namespace Nz std::size_t peerId; for (peerId = 0; peerId < m_peers.size(); ++peerId) { - if (m_peers[peerId].m_state == ENetPeerState::Disconnected) + if (m_peers[peerId].GetState() == ENetPeerState::Disconnected) break; } @@ -403,7 +403,7 @@ namespace Nz m_dispatchQueue.Reset(bit); ENetPeer& peer = m_peers[bit]; - switch (peer.m_state) + switch (peer.GetState()) { case ENetPeerState::ConnectionPending: case ENetPeerState::ConnectionSucceeded: @@ -449,7 +449,7 @@ namespace Nz bool ENetHost::HandleAcknowledge(ENetEvent* event, ENetPeer* peer, const ENetProtocol* command) { - if (peer->m_state == ENetPeerState::Disconnected || peer->m_state == ENetPeerState::Zombie) + if (peer->GetState() == ENetPeerState::Disconnected || peer->GetState() == ENetPeerState::Zombie) return true; UInt32 receivedSentTime = NetToHost(command->acknowledge.receivedSentTime); @@ -499,7 +499,7 @@ namespace Nz ENetProtocolCommand commandNumber = peer->RemoveSentReliableCommand(receivedReliableSequenceNumber, command->header.channelID); - switch (peer->m_state) + switch (peer->GetState()) { case ENetPeerState::AcknowledgingConnect: if (commandNumber != ENetProtocolCommand_VerifyConnect) @@ -516,7 +516,7 @@ namespace Nz break; case ENetPeerState::DisconnectLater: - if (peer->m_outgoingReliableCommands.empty() && peer->m_outgoingUnreliableCommands.empty() && peer->m_sentReliableCommands.empty()) + if (!peer->HasPendingCommands()) peer->Disconnect(peer->m_eventData); break; @@ -530,7 +530,7 @@ namespace Nz bool ENetHost::HandleBandwidthLimit(ENetPeer* peer, const ENetProtocol* command) { - if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + if (!peer->IsConnected()) return false; if (peer->m_incomingBandwidth != 0) @@ -568,12 +568,12 @@ namespace Nz ENetPeer* peer = nullptr; for (ENetPeer& currentPeer : m_peers) { - if (currentPeer.m_state == ENetPeerState::Disconnected) + if (currentPeer.GetState() == ENetPeerState::Disconnected) { if (!peer) peer = ¤tPeer; } - else if (currentPeer.m_state != ENetPeerState::Connecting) + else if (currentPeer.GetState() != ENetPeerState::Connecting) { // Compare users without comparing their port IpAddress first(currentPeer.m_address); @@ -631,18 +631,18 @@ namespace Nz bool ENetHost::HandleDisconnect(ENetPeer* peer, const ENetProtocol * command) { - if (peer->m_state == ENetPeerState::Disconnected || peer->m_state == ENetPeerState::Zombie || peer->m_state == ENetPeerState::AcknowledgingDisconnect) + if (peer->GetState() == ENetPeerState::Disconnected || peer->GetState() == ENetPeerState::Zombie || peer->GetState() == ENetPeerState::AcknowledgingDisconnect) return true; peer->ResetQueues(); - if (peer->m_state == ENetPeerState::ConnectionSucceeded || peer->m_state == ENetPeerState::Disconnecting || peer->m_state == ENetPeerState::Connecting) + if (peer->GetState() == ENetPeerState::ConnectionSucceeded || peer->GetState() == ENetPeerState::Disconnecting || peer->GetState() == ENetPeerState::Connecting) peer->DispatchState(ENetPeerState::Zombie); else { - if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + if (!peer->IsConnected()) { - if (peer->m_state == ENetPeerState::ConnectionPending) + if (peer->GetState() == ENetPeerState::ConnectionPending) m_recalculateBandwidthLimits = true; peer->Reset(); @@ -654,7 +654,7 @@ namespace Nz peer->DispatchState(ENetPeerState::Zombie); } - if (peer->m_state != ENetPeerState::Disconnected) + if (peer->GetState() != ENetPeerState::Disconnected) peer->m_eventData = NetToHost(command->disconnect.data); return true; @@ -685,7 +685,7 @@ namespace Nz { peer = &m_peers[peerID]; - if (peer->m_state == ENetPeerState::Disconnected || peer->m_state == ENetPeerState::Zombie) + if (peer->GetState() == ENetPeerState::Disconnected || peer->GetState() == ENetPeerState::Zombie) return false; if (m_receivedAddress != peer->m_address && peer->m_address != IpAddress::BroadcastIpV4) @@ -829,7 +829,7 @@ namespace Nz sentTime = NetToHost(header->sentTime); - switch (peer->m_state) + switch (peer->GetState()) { case ENetPeerState::Disconnecting: case ENetPeerState::AcknowledgingConnect: @@ -854,7 +854,7 @@ namespace Nz bool ENetHost::HandlePing(ENetPeer* peer, const ENetProtocol* /*command*/) { - if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + if (!peer->IsConnected()) return false; return true; @@ -862,7 +862,7 @@ namespace Nz bool ENetHost::HandleSendFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) { - if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) return false; UInt16 fragmentLength = NetToHost(command->sendFragment.dataLength); @@ -909,7 +909,7 @@ namespace Nz break; if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendFragment || - totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.size()) + totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.GetSize()) return false; startCommand = &incomingCommand; @@ -926,11 +926,11 @@ namespace Nz return false; } - if ((startCommand->fragments[fragmentNumber / 32] & (1 << (fragmentNumber % 32))) == 0) + if (!startCommand->fragments.Test(fragmentNumber)) { --startCommand->fragmentsRemaining; - startCommand->fragments[fragmentNumber / 32] |= (1 << (fragmentNumber % 32)); + startCommand->fragments.Set(fragmentNumber); if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; @@ -946,7 +946,7 @@ namespace Nz bool ENetHost::HandleSendReliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) { - if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) return false; UInt16 dataLength = NetToHost(command->sendReliable.dataLength); @@ -962,7 +962,7 @@ namespace Nz bool ENetHost::HandleSendUnreliable(ENetPeer * peer, const ENetProtocol * command, UInt8 ** currentData) { - if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) return false; UInt16 dataLength = NetToHost(command->sendUnreliable.dataLength); @@ -978,7 +978,7 @@ namespace Nz bool ENetHost::HandleSendUnreliableFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) { - if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) return false; UInt16 fragmentLength = NetToHost(command->sendFragment.dataLength); @@ -1050,11 +1050,11 @@ namespace Nz return false; } - if ((startCommand->fragments[fragmentNumber / 32] & (1 << (fragmentNumber % 32))) == 0) + if (!startCommand->fragments.Test(fragmentNumber)) { --startCommand->fragmentsRemaining; - startCommand->fragments[fragmentNumber / 32] |= (1 << (fragmentNumber % 32)); + startCommand->fragments.Set(fragmentNumber); if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; @@ -1070,7 +1070,7 @@ namespace Nz bool ENetHost::HandleSendUnsequenced(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) { - if (command->header.channelID >= peer->m_channels.size() || (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater)) + if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) return false; std::size_t dataLength = NetToHost(command->sendUnsequenced.dataLength); @@ -1108,7 +1108,7 @@ namespace Nz bool ENetHost::HandleThrottleConfigure(ENetPeer* peer, const ENetProtocol* command) { - if (peer->m_state != ENetPeerState::Connected && peer->m_state != ENetPeerState::DisconnectLater) + if (!peer->IsConnected()) return false; peer->m_packetThrottleInterval = NetToHost(command->throttleConfigure.packetThrottleInterval); @@ -1120,7 +1120,7 @@ namespace Nz bool ENetHost::HandleVerifyConnect(ENetEvent* event, ENetPeer* peer, ENetProtocol* command) { - if (peer->m_state != ENetPeerState::Connecting) + if (peer->GetState() != ENetPeerState::Connecting) return false; UInt32 channelCount = NetToHost(command->verifyConnect.channelCount); @@ -1201,15 +1201,15 @@ namespace Nz event->data = peer->m_eventData; } else - peer->DispatchState(peer->m_state == ENetPeerState::Connecting ? ENetPeerState::ConnectionSucceeded : ENetPeerState::ConnectionPending); + peer->DispatchState(peer->GetState() == ENetPeerState::Connecting ? ENetPeerState::ConnectionSucceeded : ENetPeerState::ConnectionPending); } void ENetHost::NotifyDisconnect(ENetPeer* peer, ENetEvent* event) { - if (peer->m_state >= ENetPeerState::ConnectionPending) + if (peer->GetState() >= ENetPeerState::ConnectionPending) m_recalculateBandwidthLimits = true; - if (peer->m_state != ENetPeerState::Connecting && (peer->m_state < ENetPeerState::ConnectionSucceeded)) + if (peer->GetState() != ENetPeerState::Connecting && (peer->GetState() < ENetPeerState::ConnectionSucceeded)) peer->Reset(); else if (event) { @@ -1394,7 +1394,7 @@ namespace Nz for (std::size_t peer = 0; peer < m_peerCount; ++peer) { ENetPeer* currentPeer = &m_peers[peer]; - if (currentPeer->m_state == ENetPeerState::Disconnected || currentPeer->m_state == ENetPeerState::Zombie) + if (currentPeer->GetState() == ENetPeerState::Disconnected || currentPeer->GetState() == ENetPeerState::Zombie) continue; m_headerFlags = 0; @@ -1560,8 +1560,7 @@ namespace Nz ++m_commandCount; } - if (peer->m_state == ENetPeerState::DisconnectLater && peer->m_outgoingReliableCommands.empty() && - peer->m_outgoingUnreliableCommands.empty() && peer->m_sentReliableCommands.empty()) + if (peer->GetState() == ENetPeerState::DisconnectLater && !peer->HasPendingCommands()) peer->Disconnect(peer->m_eventData); } @@ -1588,7 +1587,7 @@ namespace Nz dataTotal = 0; for (ENetPeer& peer : m_peers) { - if (peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) + if (peer.IsConnected()) continue; dataTotal += peer.m_outgoingDataTotal; @@ -1611,8 +1610,7 @@ namespace Nz for (ENetPeer& peer : m_peers) { - if ((peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) || - peer.m_incomingBandwidth == 0 || peer.m_outgoingBandwidthThrottleEpoch == currentTime) + if (!peer.IsConnected() || peer.m_incomingBandwidth == 0 || peer.m_outgoingBandwidthThrottleEpoch == currentTime) continue; UInt32 peerBandwidth = (peer.m_incomingBandwidth * elapsedTime) / 1000; @@ -1648,8 +1646,7 @@ namespace Nz for (ENetPeer& peer : m_peers) { - if ((peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) || - peer.m_outgoingBandwidthThrottleEpoch == currentTime) + if (!peer.IsConnected() || peer.m_outgoingBandwidthThrottleEpoch == currentTime) continue; peer.m_packetThrottleLimit = throttle; @@ -1681,8 +1678,7 @@ namespace Nz for (ENetPeer& peer : m_peers) { - if ((peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) || - peer.m_incomingBandwidthThrottleEpoch == currentTime) + if (!peer.IsConnected() || peer.m_incomingBandwidthThrottleEpoch == currentTime) continue; if (peer.m_outgoingBandwidth > 0 && peer.m_outgoingBandwidth >= bandwidthLimit) @@ -1699,7 +1695,7 @@ namespace Nz for (ENetPeer& peer : m_peers) { - if (peer.m_state != ENetPeerState::Connected && peer.m_state != ENetPeerState::DisconnectLater) + if (!peer.IsConnected()) continue; ENetProtocol command; diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 37afe8958..38025108f 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -54,14 +54,14 @@ namespace Nz command.header.channelID = 0xFF; command.disconnect.data = HostToNet(data); - if (m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater) + if (IsConnected()) command.header.command |= ENetProtocolFlag_Acknowledge; else command.header.command |= ENetProtocolFlag_Unsequenced; QueueOutgoingCommand(command, nullptr, 0, 0); - if (m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater) + if (IsConnected()) { OnDisconnect(); @@ -77,10 +77,7 @@ namespace Nz void ENetPeer::DisconnectLater(UInt32 data) { - if ((m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater) && - !m_outgoingReliableCommands.empty() && - !m_outgoingUnreliableCommands.empty() && - !m_sentReliableCommands.empty()) + if (IsConnected() && !m_outgoingReliableCommands.empty() && !m_outgoingUnreliableCommands.empty() && !m_sentReliableCommands.empty()) { m_state = ENetPeerState::DisconnectLater; m_eventData = data; @@ -383,8 +380,8 @@ namespace Nz channel.incomingReliableSequenceNumber = incomingCommand.reliableSequenceNumber; - if (!incomingCommand.fragments.empty()) - channel.incomingReliableSequenceNumber += incomingCommand.fragments.size() - 1; + if (incomingCommand.fragments.GetSize() == 0) + channel.incomingReliableSequenceNumber += incomingCommand.fragments.GetSize() - 1; } if (currentCommand == channel.incomingReliableCommands.begin()) @@ -477,7 +474,7 @@ namespace Nz void ENetPeer::OnConnect() { - if (m_state != ENetPeerState::Connected && m_state != ENetPeerState::DisconnectLater) + if (!IsConnected()) { if (m_incomingBandwidth != 0) ++m_host->m_bandwidthLimitedPeers; @@ -488,7 +485,7 @@ namespace Nz void ENetPeer::OnDisconnect() { - if (m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater) + if (IsConnected()) { if (m_incomingBandwidth != 0) --m_host->m_bandwidthLimitedPeers; @@ -754,7 +751,7 @@ namespace Nz incomingCommand.unreliableSequenceNumber = unreliableSequenceNumber & 0xFFFF; incomingCommand.command = command; incomingCommand.packet = packet; - incomingCommand.fragments.resize(fragmentCount, 0); + incomingCommand.fragments.Resize(fragmentCount); incomingCommand.fragmentsRemaining = fragmentCount; if (packet) From c9d5f2f1ac449f4026b16f02bbf87e253f975eaf Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Jan 2017 12:08:35 +0100 Subject: [PATCH 083/243] Network/ENet: More cleanup --- include/Nazara/Network/ENetHost.hpp | 2 - include/Nazara/Network/ENetPeer.hpp | 5 +- include/Nazara/Network/ENetPeer.inl | 5 + include/Nazara/Network/ENetProtocol.hpp | 8 ++ src/Nazara/Network/ENetHost.cpp | 89 ++----------- src/Nazara/Network/ENetPeer.cpp | 158 +++++++++++++++--------- 6 files changed, 130 insertions(+), 137 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 3b86a1f25..344ffce82 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -64,8 +64,6 @@ namespace Nz void AddToDispatchQueue(ENetPeer* peer); void RemoveFromDispatchQueue(ENetPeer* peer); - bool CheckTimeouts(ENetPeer* peer, ENetEvent* event); - bool DispatchIncomingCommands(ENetEvent* event); bool HandleAcknowledge(ENetEvent* event, ENetPeer* peer, const ENetProtocol* command); diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 377d8f734..7ccaf3d8d 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -68,8 +68,10 @@ namespace Nz struct IncomingCommmand; struct OutgoingCommand; - // Protocol functions inline void ChangeState(ENetPeerState state); + + bool CheckTimeouts(ENetEvent* event); + void DispatchState(ENetPeerState state); void DispatchIncomingReliableCommands(Channel& channel); @@ -85,6 +87,7 @@ namespace Nz bool QueueAcknowledgement(ENetProtocol* command, UInt16 sentTime); IncomingCommmand* QueueIncomingCommand(const ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount); + inline void QueueOutgoingCommand(ENetProtocol& command); void QueueOutgoingCommand(ENetProtocol& command, ENetPacketRef packet, UInt32 offset, UInt16 length); void SetupOutgoingCommand(OutgoingCommand& outgoingCommand); diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index 5c0f76731..1e74e0cae 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -37,6 +37,11 @@ namespace Nz m_state = state; } + + inline void ENetPeer::QueueOutgoingCommand(ENetProtocol& command) + { + QueueOutgoingCommand(command, ENetPacketRef(), 0, 0); + } } #include diff --git a/include/Nazara/Network/ENetProtocol.hpp b/include/Nazara/Network/ENetProtocol.hpp index 8b62f7dc7..0434cafc2 100644 --- a/include/Nazara/Network/ENetProtocol.hpp +++ b/include/Nazara/Network/ENetProtocol.hpp @@ -267,6 +267,14 @@ namespace Nz union NAZARA_PACKED ENetProtocol { + ENetProtocol() = default; + + ENetProtocol(UInt8 command, UInt8 channel) + { + header.command = command; + header.channelID = channel; + } + ENetProtocolCommandHeader header; ENetProtocolAcknowledge acknowledge; ENetProtocolBandwidthLimit bandwidthLimit; diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index a6e98a0c4..afa870b12 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -117,10 +117,7 @@ namespace Nz ENetPeer& peer = m_peers[peerId]; peer.InitOutgoing(channelCount, remoteAddress, ++m_randomSeed, windowSize); - ENetProtocol command; - command.header.command = ENetProtocolCommand_Connect | ENetProtocolFlag_Acknowledge; - command.header.channelID = 0xFF; - + ENetProtocol command(ENetProtocolCommand_Connect | ENetProtocolFlag_Acknowledge, 0xFF); command.connect.channelCount = HostToNet(static_cast(channelCount)); command.connect.connectID = peer.m_connectID; command.connect.data = HostToNet(data); @@ -134,8 +131,7 @@ namespace Nz command.connect.packetThrottleDeceleration = HostToNet(peer.m_packetThrottleDeceleration); command.connect.packetThrottleInterval = HostToNet(peer.m_packetThrottleInterval); command.connect.windowSize = HostToNet(peer.m_windowSize); - - peer.QueueOutgoingCommand(command, nullptr, 0, 0); + peer.QueueOutgoingCommand(command); return &peer; } @@ -350,52 +346,6 @@ namespace Nz m_dispatchQueue.UnboundedReset(peer->m_incomingPeerID); } - bool ENetHost::CheckTimeouts(ENetPeer* peer, ENetEvent* event) - { - auto currentCommand = peer->m_sentReliableCommands.begin(); - - while (currentCommand != peer->m_sentReliableCommands.end()) - { - auto outgoingCommand = currentCommand; - - ++currentCommand; - - if (ENET_TIME_DIFFERENCE(m_serviceTime, outgoingCommand->sentTime) < outgoingCommand->roundTripTimeout) - continue; - - if (peer->m_earliestTimeout == 0 || ENET_TIME_LESS(outgoingCommand->sentTime, peer->m_earliestTimeout)) - peer->m_earliestTimeout = outgoingCommand->sentTime; - - if (peer->m_earliestTimeout != 0 && (ENET_TIME_DIFFERENCE(m_serviceTime, peer->m_earliestTimeout) >= peer->m_timeoutMaximum || - (outgoingCommand->roundTripTimeout >= outgoingCommand->roundTripTimeoutLimit && ENET_TIME_DIFFERENCE(m_serviceTime, peer->m_earliestTimeout) >= peer->m_timeoutMinimum))) - { - NotifyDisconnect(peer, event); - return true; - } - - if (outgoingCommand->packet) - peer->m_reliableDataInTransit -= outgoingCommand->fragmentLength; - - ++peer->m_packetsLost; - - outgoingCommand->roundTripTimeout *= 2; - - peer->m_outgoingReliableCommands.emplace_front(std::move(*outgoingCommand)); - peer->m_sentReliableCommands.erase(outgoingCommand); - - // Okay this should just never procs, I don't see how it would be possible - /*if (currentCommand == enet_list_begin(&peer->sentReliableCommands) && - !enet_list_empty(&peer->sentReliableCommands)) - { - outgoingCommand = (ENetOutgoingCommand *) currentCommand; - - peer->nextTimeout = outgoingCommand->sentTime + outgoingCommand->roundTripTimeout; - }*/ - } - - return false; - } - bool ENetHost::DispatchIncomingCommands(ENetEvent* event) { for (std::size_t bit = m_dispatchQueue.FindFirst(); bit != m_dispatchQueue.npos; bit = m_dispatchQueue.FindNext(bit)) @@ -608,9 +558,7 @@ namespace Nz windowSize = std::max(windowSize, NetToHost(command->connect.windowSize)); windowSize = Clamp(windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); - ENetProtocol verifyCommand; - verifyCommand.header.command = ENetProtocolCommand_VerifyConnect | ENetProtocolFlag_Acknowledge; - verifyCommand.header.channelID = 0xFF; + ENetProtocol verifyCommand(ENetProtocolCommand_VerifyConnect | ENetProtocolFlag_Acknowledge, 0xFF); verifyCommand.verifyConnect.outgoingPeerID = HostToNet(peer->m_incomingPeerID); verifyCommand.verifyConnect.incomingSessionID = peer->m_outgoingSessionID; verifyCommand.verifyConnect.outgoingSessionID = peer->m_incomingSessionID; @@ -623,8 +571,7 @@ namespace Nz verifyCommand.verifyConnect.packetThrottleAcceleration = HostToNet(peer->m_packetThrottleAcceleration); verifyCommand.verifyConnect.packetThrottleDeceleration = HostToNet(peer->m_packetThrottleDeceleration); verifyCommand.verifyConnect.connectID = peer->m_connectID; - - peer->QueueOutgoingCommand(verifyCommand, nullptr, 0, 0); + peer->QueueOutgoingCommand(verifyCommand); return peer; } @@ -930,7 +877,7 @@ namespace Nz { --startCommand->fragmentsRemaining; - startCommand->fragments.Set(fragmentNumber); + startCommand->fragments.Set(fragmentNumber, true); if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; @@ -1036,7 +983,7 @@ namespace Nz break; if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendUnreliableFragment || - totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.size()) + totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.GetSize()) return false; startCommand = &incomingCommand; @@ -1054,7 +1001,7 @@ namespace Nz { --startCommand->fragmentsRemaining; - startCommand->fragments.Set(fragmentNumber); + startCommand->fragments.Set(fragmentNumber, true); if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; @@ -1405,8 +1352,7 @@ namespace Nz if (!currentPeer->m_acknowledgements.empty()) SendAcknowledgements(currentPeer); - if (checkForTimeouts && !currentPeer->m_sentReliableCommands.empty() && ENET_TIME_GREATER_EQUAL(m_serviceTime, currentPeer->m_nextTimeout) && - CheckTimeouts(currentPeer, event)) + if (checkForTimeouts && !currentPeer->m_sentReliableCommands.empty() && ENET_TIME_GREATER_EQUAL(m_serviceTime, currentPeer->m_nextTimeout) && currentPeer->CheckTimeouts(event)) { if (event && event->type != ENetEventType::None) return 1; @@ -1617,14 +1563,7 @@ namespace Nz if ((throttle * peer.m_outgoingDataTotal) / ENetConstants::ENetPeer_PacketThrottleScale <= peerBandwidth) continue; - peer.m_packetThrottleLimit = (peerBandwidth * ENetConstants::ENetPeer_PacketThrottleScale) / peer.m_outgoingDataTotal; - - if (peer.m_packetThrottleLimit == 0) - peer.m_packetThrottleLimit = 1; - - if (peer.m_packetThrottle > peer.m_packetThrottleLimit) - peer.m_packetThrottle = peer.m_packetThrottleLimit; - + peer.m_packetThrottleLimit = Clamp((peerBandwidth * ENetConstants::ENetPeer_PacketThrottleScale) / peer.m_outgoingDataTotal, 0, peer.m_packetThrottleLimit); peer.m_outgoingBandwidthThrottleEpoch = currentTime; peer.m_incomingDataTotal = 0; @@ -1650,9 +1589,7 @@ namespace Nz continue; peer.m_packetThrottleLimit = throttle; - - if (peer.m_packetThrottle > peer.m_packetThrottleLimit) - peer.m_packetThrottle = peer.m_packetThrottleLimit; + peer.m_packetThrottle = std::min(peer.m_packetThrottle, peer.m_packetThrottleLimit); peer.m_incomingDataTotal = 0; peer.m_outgoingDataTotal = 0; @@ -1698,9 +1635,7 @@ namespace Nz if (!peer.IsConnected()) continue; - ENetProtocol command; - command.header.command = ENetProtocolCommand_BandwidthLimit | ENetProtocolFlag_Acknowledge; - command.header.channelID = 0xFF; + ENetProtocol command(ENetProtocolCommand_BandwidthLimit | ENetProtocolFlag_Acknowledge, 0xFF); command.bandwidthLimit.outgoingBandwidth = HostToNet(m_outgoingBandwidth); if (peer.m_incomingBandwidthThrottleEpoch == currentTime) @@ -1708,7 +1643,7 @@ namespace Nz else command.bandwidthLimit.incomingBandwidth = HostToNet(bandwidthLimit); - peer.QueueOutgoingCommand(command, nullptr, 0, 0); + peer.QueueOutgoingCommand(command); } } } diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 38025108f..e444a4d02 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -5,6 +5,15 @@ #include #include +#define ENET_TIME_OVERFLOW 86400000 + +#define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) +#define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) +#define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) +#define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) + +#define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) + namespace Nz { /// Temporary @@ -49,9 +58,7 @@ namespace Nz ResetQueues(); - ENetProtocol command; - command.header.command = ENetProtocolCommand_Disconnect; - command.header.channelID = 0xFF; + ENetProtocol command(ENetProtocolCommand_Disconnect, 0xFF); command.disconnect.data = HostToNet(data); if (IsConnected()) @@ -59,7 +66,7 @@ namespace Nz else command.header.command |= ENetProtocolFlag_Unsequenced; - QueueOutgoingCommand(command, nullptr, 0, 0); + QueueOutgoingCommand(command); if (IsConnected()) { @@ -95,12 +102,9 @@ namespace Nz { ResetQueues(); - ENetProtocol command; - command.header.command = ENetProtocolCommand_Disconnect | ENetProtocolFlag_Unsequenced; - command.header.channelID = 0xFF; + ENetProtocol command(ENetProtocolCommand_Disconnect | ENetProtocolFlag_Unsequenced, 0xFF); command.disconnect.data = HostToNet(data); - - QueueOutgoingCommand(command, nullptr, 0, 0); + QueueOutgoingCommand(command); m_host->Flush(); } @@ -116,8 +120,7 @@ namespace Nz ENetProtocol command; command.header.command = ENetProtocolCommand_Ping | ENetProtocolFlag_Acknowledge; command.header.channelID = 0xFF; - - QueueOutgoingCommand(command, nullptr, 0, 0); + QueueOutgoingCommand(command); } bool ENetPeer::Receive(ENetPacketRef* packet, UInt8* channelId) @@ -299,66 +302,56 @@ namespace Nz m_packetThrottleAcceleration = acceleration; m_packetThrottleDeceleration = deceleration; - ENetProtocol command; - command.header.command = ENetProtocolCommand_ThrottleConfigure | ENetProtocolFlag_Acknowledge; - command.header.channelID = 0xFF; - + ENetProtocol command(ENetProtocolCommand_ThrottleConfigure | ENetProtocolFlag_Acknowledge, 0xFF); command.throttleConfigure.packetThrottleInterval = HostToNet(interval); command.throttleConfigure.packetThrottleAcceleration = HostToNet(acceleration); command.throttleConfigure.packetThrottleDeceleration = HostToNet(deceleration); - - QueueOutgoingCommand(command, nullptr, 0, 0); + QueueOutgoingCommand(command); } - void ENetPeer::InitIncoming(std::size_t channelCount, const IpAddress& address, ENetProtocolConnect& incomingCommand) + bool ENetPeer::CheckTimeouts(ENetEvent* event) { - m_channels.resize(channelCount); - m_address = address; + auto currentCommand = m_sentReliableCommands.begin(); + while (currentCommand != m_sentReliableCommands.end()) + { + auto outgoingCommand = currentCommand; - m_connectID = incomingCommand.connectID; - m_eventData = NetToHost(incomingCommand.data); - m_incomingBandwidth = NetToHost(incomingCommand.incomingBandwidth); - m_outgoingBandwidth = NetToHost(incomingCommand.outgoingBandwidth); - m_packetThrottleInterval = NetToHost(incomingCommand.packetThrottleInterval); - m_packetThrottleAcceleration = NetToHost(incomingCommand.packetThrottleAcceleration); - m_packetThrottleDeceleration = NetToHost(incomingCommand.packetThrottleDeceleration); - m_outgoingPeerID = NetToHost(incomingCommand.outgoingPeerID); - m_state = ENetPeerState::AcknowledgingConnect; + ++currentCommand; - UInt8 incomingSessionId, outgoingSessionId; + if (ENET_TIME_DIFFERENCE(m_host->m_serviceTime, outgoingCommand->sentTime) < outgoingCommand->roundTripTimeout) + continue; - incomingSessionId = incomingCommand.incomingSessionID == 0xFF ? m_outgoingSessionID : incomingCommand.incomingSessionID; - incomingSessionId = (incomingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); - if (incomingSessionId == m_outgoingSessionID) - incomingSessionId = (incomingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); - m_outgoingSessionID = incomingSessionId; + if (m_earliestTimeout == 0 || ENET_TIME_LESS(outgoingCommand->sentTime, m_earliestTimeout)) + m_earliestTimeout = outgoingCommand->sentTime; - outgoingSessionId = incomingCommand.outgoingSessionID == 0xFF ? m_incomingSessionID : incomingCommand.outgoingSessionID; - outgoingSessionId = (outgoingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); - if (outgoingSessionId == m_incomingSessionID) - outgoingSessionId = (outgoingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); - m_incomingSessionID = outgoingSessionId; + if (m_earliestTimeout != 0 && (ENET_TIME_DIFFERENCE(m_host->m_serviceTime, m_earliestTimeout) >= m_timeoutMaximum || + (outgoingCommand->roundTripTimeout >= outgoingCommand->roundTripTimeoutLimit && ENET_TIME_DIFFERENCE(m_host->m_serviceTime, m_earliestTimeout) >= m_timeoutMinimum))) + { + m_host->NotifyDisconnect(this, event); + return true; + } - m_mtu = Clamp(NetToHost(incomingCommand.mtu), ENetConstants::ENetProtocol_MinimumMTU, ENetConstants::ENetProtocol_MaximumMTU); + if (outgoingCommand->packet) + m_reliableDataInTransit -= outgoingCommand->fragmentLength; - if (m_host->m_outgoingBandwidth == 0 && m_incomingBandwidth == 0) - m_windowSize = ENetConstants::ENetProtocol_MaximumWindowSize; - else if (m_host->m_outgoingBandwidth == 0 || m_incomingBandwidth == 0) - m_windowSize = (std::max(m_host->m_outgoingBandwidth, m_incomingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; - else - m_windowSize = (std::min(m_host->m_outgoingBandwidth, m_incomingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + ++m_packetsLost; - m_windowSize = Clamp(m_windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); - } + outgoingCommand->roundTripTimeout *= 2; - void ENetPeer::InitOutgoing(std::size_t channelCount, const IpAddress& address, UInt32 connectId, UInt32 windowSize) - { - m_channels.resize(channelCount); + m_outgoingReliableCommands.emplace_front(std::move(*outgoingCommand)); + m_sentReliableCommands.erase(outgoingCommand); - m_address = address; - m_connectID = connectId; - m_state = ENetPeerState::Connecting; - m_windowSize = Clamp(windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + // Okay this should just never procs, I don't see how it would be possible + /*if (currentCommand == enet_list_begin(&peer->sentReliableCommands) && + !enet_list_empty(&peer->sentReliableCommands)) + { + outgoingCommand = (ENetOutgoingCommand *) currentCommand; + + peer->nextTimeout = outgoingCommand->sentTime + outgoingCommand->roundTripTimeout; + }*/ + } + + return false; } void ENetPeer::DispatchState(ENetPeerState state) @@ -472,6 +465,57 @@ namespace Nz channel.incomingUnreliableCommands.erase(channel.incomingUnreliableCommands.begin(), droppedCommand); } + void ENetPeer::InitIncoming(std::size_t channelCount, const IpAddress& address, ENetProtocolConnect& incomingCommand) + { + m_channels.resize(channelCount); + m_address = address; + + m_connectID = incomingCommand.connectID; + m_eventData = NetToHost(incomingCommand.data); + m_incomingBandwidth = NetToHost(incomingCommand.incomingBandwidth); + m_outgoingBandwidth = NetToHost(incomingCommand.outgoingBandwidth); + m_packetThrottleInterval = NetToHost(incomingCommand.packetThrottleInterval); + m_packetThrottleAcceleration = NetToHost(incomingCommand.packetThrottleAcceleration); + m_packetThrottleDeceleration = NetToHost(incomingCommand.packetThrottleDeceleration); + m_outgoingPeerID = NetToHost(incomingCommand.outgoingPeerID); + m_state = ENetPeerState::AcknowledgingConnect; + + UInt8 incomingSessionId, outgoingSessionId; + + incomingSessionId = incomingCommand.incomingSessionID == 0xFF ? m_outgoingSessionID : incomingCommand.incomingSessionID; + incomingSessionId = (incomingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); + if (incomingSessionId == m_outgoingSessionID) + incomingSessionId = (incomingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); + m_outgoingSessionID = incomingSessionId; + + outgoingSessionId = incomingCommand.outgoingSessionID == 0xFF ? m_incomingSessionID : incomingCommand.outgoingSessionID; + outgoingSessionId = (outgoingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); + if (outgoingSessionId == m_incomingSessionID) + outgoingSessionId = (outgoingSessionId + 1) & (ENetProtocolHeaderSessionMask >> ENetProtocolHeaderSessionShift); + m_incomingSessionID = outgoingSessionId; + + m_mtu = Clamp(NetToHost(incomingCommand.mtu), ENetConstants::ENetProtocol_MinimumMTU, ENetConstants::ENetProtocol_MaximumMTU); + + if (m_host->m_outgoingBandwidth == 0 && m_incomingBandwidth == 0) + m_windowSize = ENetConstants::ENetProtocol_MaximumWindowSize; + else if (m_host->m_outgoingBandwidth == 0 || m_incomingBandwidth == 0) + m_windowSize = (std::max(m_host->m_outgoingBandwidth, m_incomingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + else + m_windowSize = (std::min(m_host->m_outgoingBandwidth, m_incomingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + + m_windowSize = Clamp(m_windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + } + + void ENetPeer::InitOutgoing(std::size_t channelCount, const IpAddress& address, UInt32 connectId, UInt32 windowSize) + { + m_channels.resize(channelCount); + + m_address = address; + m_connectID = connectId; + m_state = ENetPeerState::Connecting; + m_windowSize = Clamp(windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + } + void ENetPeer::OnConnect() { if (!IsConnected()) @@ -498,7 +542,7 @@ namespace Nz { std::list* commandList = nullptr; - bool found = true; + bool found = false; auto currentCommand = m_sentReliableCommands.begin(); commandList = &m_sentReliableCommands; for (; currentCommand != m_sentReliableCommands.end(); ++currentCommand) From 6ab6ec4f14f097849d2aef2a1d90dee7ad9dde59 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Jan 2017 12:14:41 +0100 Subject: [PATCH 084/243] Network/ENetPeer: Improved stability of connections http://lists.cubik.org/pipermail/enet-discuss/2014-May/002308.html --- src/Nazara/Network/ENetPeer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index e444a4d02..d29860e4d 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -336,7 +336,9 @@ namespace Nz ++m_packetsLost; - outgoingCommand->roundTripTimeout *= 2; + // http://lists.cubik.org/pipermail/enet-discuss/2014-May/002308.html + outgoingCommand->roundTripTimeout = m_roundTripTime + 4 * m_roundTripTimeVariance; + outgoingCommand->roundTripTimeoutLimit = m_timeoutLimit * outgoingCommand->roundTripTimeout; m_outgoingReliableCommands.emplace_front(std::move(*outgoingCommand)); m_sentReliableCommands.erase(outgoingCommand); From 9d9d7472ca3de240fffb6027c5b336468f062dbd Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Jan 2017 14:09:43 +0100 Subject: [PATCH 085/243] Network/ENetPacket: Fix a huge bug with packets --- src/Nazara/Network/ENetPacket.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Nazara/Network/ENetPacket.cpp b/src/Nazara/Network/ENetPacket.cpp index a22cc7fb8..494ae1a54 100644 --- a/src/Nazara/Network/ENetPacket.cpp +++ b/src/Nazara/Network/ENetPacket.cpp @@ -10,10 +10,7 @@ namespace Nz if (m_packet) { if (--m_packet->referenceCount == 0) - { m_packet->owner->Delete(m_packet); - return; - } } m_packet = packet; From 5207f2c821e79a5d82169a7bc889ea4eaa9269b6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Jan 2017 17:15:33 +0100 Subject: [PATCH 086/243] Network/ENet: Fix some remaining bugs.... --- src/Nazara/Network/ENetHost.cpp | 4 ++-- src/Nazara/Network/ENetPeer.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index afa870b12..28f586307 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -1082,7 +1082,7 @@ namespace Nz peer->DispatchState(ENetPeerState::Zombie); - return false; + return true; } peer->RemoveSentReliableCommand(1, 0xFF); @@ -1201,7 +1201,7 @@ namespace Nz command.header.channelID = acknowledgement.command.header.channelID; command.header.reliableSequenceNumber = reliableSequenceNumber; command.acknowledge.receivedReliableSequenceNumber = reliableSequenceNumber; - command.acknowledge.receivedSentTime = HostToNet(acknowledgement.sentTime); + command.acknowledge.receivedSentTime = HostToNet(acknowledgement.sentTime); if ((acknowledgement.command.header.command & ENetProtocolCommand_Mask) == ENetProtocolCommand_Disconnect) peer->DispatchState(ENetPeerState::Zombie); diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index d29860e4d..340c3152a 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -375,7 +375,7 @@ namespace Nz channel.incomingReliableSequenceNumber = incomingCommand.reliableSequenceNumber; - if (incomingCommand.fragments.GetSize() == 0) + if (incomingCommand.fragments.GetSize() > 0) channel.incomingReliableSequenceNumber += incomingCommand.fragments.GetSize() - 1; } From 34828929b2b545d6d9ce90251a97866a47563ba1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Jan 2017 17:16:14 +0100 Subject: [PATCH 087/243] Network/ENetHost: Fix a bug --- src/Nazara/Network/ENetHost.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 28f586307..814f843ff 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -983,7 +983,7 @@ namespace Nz break; if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendUnreliableFragment || - totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.GetSize()) + totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.GetSize()) return false; startCommand = &incomingCommand; @@ -1068,7 +1068,7 @@ namespace Nz bool ENetHost::HandleVerifyConnect(ENetEvent* event, ENetPeer* peer, ENetProtocol* command) { if (peer->GetState() != ENetPeerState::Connecting) - return false; + return true; UInt32 channelCount = NetToHost(command->verifyConnect.channelCount); @@ -1082,7 +1082,7 @@ namespace Nz peer->DispatchState(ENetPeerState::Zombie); - return true; + return false; } peer->RemoveSentReliableCommand(1, 0xFF); From 4e2a037d6b06cab659a3e9a1430b65c9d0feaca8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Jan 2017 17:17:42 +0100 Subject: [PATCH 088/243] Network/ENetPeer: Add total packet lost/sent counter --- include/Nazara/Network/ENetPeer.hpp | 2 ++ src/Nazara/Network/ENetHost.cpp | 1 + src/Nazara/Network/ENetPeer.cpp | 3 +++ 3 files changed, 6 insertions(+) diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 7ccaf3d8d..aa3c9f2da 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -205,6 +205,8 @@ namespace Nz UInt32 m_timeoutMaximum; UInt32 m_timeoutMinimum; UInt32 m_windowSize; + UInt64 m_totalPacketLost; + UInt64 m_totalPacketSent; }; } diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 814f843ff..d9a09d2c8 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -1320,6 +1320,7 @@ namespace Nz } ++peer->m_packetsSent; + ++peer->m_totalPacketSent; ++m_bufferCount; ++m_commandCount; } diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 340c3152a..c969dde4b 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -191,6 +191,8 @@ namespace Nz m_incomingUnsequencedGroup = 0; m_outgoingUnsequencedGroup = 0; m_eventData = 0; + m_totalPacketLost = 0; + m_totalPacketSent = 0; m_totalWaitingData = 0; m_unsequencedWindow.fill(0); @@ -335,6 +337,7 @@ namespace Nz m_reliableDataInTransit -= outgoingCommand->fragmentLength; ++m_packetsLost; + ++m_totalPacketLost; // http://lists.cubik.org/pipermail/enet-discuss/2014-May/002308.html outgoingCommand->roundTripTimeout = m_roundTripTime + 4 * m_roundTripTimeVariance; From 4e517bc1e3666be901fdb1cf3be08bfd037fdec7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Jan 2017 17:18:06 +0100 Subject: [PATCH 089/243] Network/ENetHost: Add network simulator --- include/Nazara/Network/ENetHost.hpp | 14 +++++- include/Nazara/Network/ENetHost.inl | 3 +- src/Nazara/Network/ENetHost.cpp | 70 ++++++++++++++++++++++++++--- src/Nazara/Network/ENetPeer.cpp | 1 - 4 files changed, 78 insertions(+), 10 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 344ffce82..0dcf58a86 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -55,6 +55,8 @@ namespace Nz int Service(ENetEvent* event, UInt32 timeout); + void SimulateNetwork(double packetLossProbability, UInt16 minDelay, UInt16 maxDelay); + ENetHost& operator=(const ENetHost&) = delete; ENetHost& operator=(ENetHost&&) = default; @@ -96,6 +98,13 @@ namespace Nz static bool Initialize(); static void Uninitialize(); + struct PendingPacket + { + IpAddress from; + NetPacket data; + UInt32 deliveryTime; + }; + std::array m_commands; std::array m_buffers; std::array m_packetData[2]; @@ -110,7 +119,10 @@ namespace Nz std::size_t m_packetSize; std::size_t m_peerCount; std::size_t m_receivedDataLength; + std::uniform_int_distribution m_packetDelayDistribution; std::vector m_peers; + std::vector m_pendingPackets; + UInt8* m_receivedData; Bitset m_dispatchQueue; MemoryPool m_packetPool; IpAddress m_address; @@ -129,10 +141,8 @@ namespace Nz UInt32 m_totalSentPackets; UInt32 m_totalReceivedData; UInt32 m_totalReceivedPackets; - UInt8* m_receivedData; bool m_continueSending; bool m_isSimulationEnabled; - bool m_shouldAcceptConnections; bool m_recalculateBandwidthLimits; static std::mt19937 s_randomGenerator; diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl index e547d4e5d..c7e65ab95 100644 --- a/include/Nazara/Network/ENetHost.inl +++ b/include/Nazara/Network/ENetHost.inl @@ -9,7 +9,8 @@ namespace Nz { inline ENetHost::ENetHost() : - m_packetPool(sizeof(ENetPacket)) + m_packetPool(sizeof(ENetPacket)), + m_isSimulationEnabled(false) { } diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index d9a09d2c8..3587e19d1 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -312,6 +312,20 @@ namespace Nz return 0; } + void ENetHost::SimulateNetwork(double packetLossProbability, UInt16 minDelay, UInt16 maxDelay) + { + NazaraAssert(maxDelay >= minDelay, "Maximum delay cannot be greater than minimum delay"); + + if (packetLossProbability <= 0.0 && minDelay == 0 && maxDelay == 0) + m_isSimulationEnabled = false; + else + { + m_isSimulationEnabled = true; + m_packetDelayDistribution = std::uniform_int_distribution(minDelay, maxDelay); + m_packetLossProbability = std::bernoulli_distribution(packetLossProbability); + } + } + bool ENetHost::InitSocket(const IpAddress& address) { if (!m_socket.Create(address.GetProtocol())) @@ -1111,14 +1125,58 @@ namespace Nz { for (unsigned int i = 0; i < 256; ++i) { - NetPacket packet; - + bool shouldReceive = true; std::size_t receivedLength; - if (!m_socket.Receive(m_packetData[0].data(), m_packetData[0].size(), &m_receivedAddress, &receivedLength)) - return -1; //< Error - if (receivedLength == 0) - return 0; + if (m_isSimulationEnabled) + { + for (auto it = m_pendingPackets.begin(); it != m_pendingPackets.end(); ++it) + { + if (m_serviceTime >= it->deliveryTime) + { + shouldReceive = false; + + m_receivedAddress = it->from; + receivedLength = it->data.GetDataSize(); + std::memcpy(m_packetData[0].data(), it->data.GetConstData() + NetPacket::HeaderSize, receivedLength); + + m_pendingPackets.erase(it); + break; + } + } + } + + if (shouldReceive) + { + if (!m_socket.Receive(m_packetData[0].data(), m_packetData[0].size(), &m_receivedAddress, &receivedLength)) + return -1; //< Error + + if (receivedLength == 0) + return 0; + + if (m_isSimulationEnabled) + { + if (m_packetLossProbability(s_randomGenerator)) + continue; + + UInt16 delay = m_packetDelayDistribution(s_randomGenerator); + if (delay > 0) + { + PendingPacket pendingPacket; + pendingPacket.deliveryTime = m_serviceTime + delay; + pendingPacket.from = m_receivedAddress; + pendingPacket.data.Reset(0, m_packetData[0].data(), receivedLength); + + auto it = std::upper_bound(m_pendingPackets.begin(), m_pendingPackets.end(), pendingPacket, [] (const PendingPacket& first, const PendingPacket& second) + { + return first.deliveryTime < second.deliveryTime; + }); + + m_pendingPackets.emplace(it, std::move(pendingPacket)); + continue; + } + } + } m_receivedData = m_packetData[0].data(); m_receivedDataLength = receivedLength; diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index c969dde4b..d0181a01d 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #define ENET_TIME_OVERFLOW 86400000 From b5797dfa12b11a307c55525c64b8abbb5b9c16af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 30 Jan 2017 18:08:21 +0100 Subject: [PATCH 090/243] Network/ENetHost: Move handling to ENetPeer --- include/Nazara/Network/ENetHost.hpp | 13 +- include/Nazara/Network/ENetPeer.hpp | 15 +- src/Nazara/Network/ENetHost.cpp | 473 +--------------------------- src/Nazara/Network/ENetPeer.cpp | 449 +++++++++++++++++++++++++- 4 files changed, 475 insertions(+), 475 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 0dcf58a86..fe9956538 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -68,19 +68,8 @@ namespace Nz bool DispatchIncomingCommands(ENetEvent* event); - bool HandleAcknowledge(ENetEvent* event, ENetPeer* peer, const ENetProtocol* command); - bool HandleBandwidthLimit(ENetPeer* peer, const ENetProtocol* command); ENetPeer* HandleConnect(ENetProtocolHeader* header, ENetProtocol* command); - bool HandleDisconnect(ENetPeer* peer, const ENetProtocol* command); bool HandleIncomingCommands(ENetEvent* event); - bool HandlePing(ENetPeer* peer, const ENetProtocol* command); - bool HandleSendFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); - bool HandleSendReliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); - bool HandleSendUnreliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); - bool HandleSendUnreliableFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); - bool HandleSendUnsequenced(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData); - bool HandleThrottleConfigure(ENetPeer* peer, const ENetProtocol* command); - bool HandleVerifyConnect(ENetEvent* event, ENetPeer* peer, ENetProtocol* command); int ReceiveIncomingCommands(ENetEvent* event); diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index aa3c9f2da..c0d24f6f6 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -77,6 +78,18 @@ namespace Nz void DispatchIncomingReliableCommands(Channel& channel); void DispatchIncomingUnreliableCommands(Channel& channel); + bool HandleAcknowledge(const ENetProtocol* command, ENetEvent* event); + bool HandleBandwidthLimit(const ENetProtocol* command); + bool HandleDisconnect(const ENetProtocol* command); + bool HandlePing(const ENetProtocol* command); + bool HandleSendFragment(const ENetProtocol* command, UInt8** data); + bool HandleSendReliable(const ENetProtocol* command, UInt8** data); + bool HandleSendUnreliable(const ENetProtocol* command, UInt8** data); + bool HandleSendUnreliableFragment(const ENetProtocol* command, UInt8** data); + bool HandleSendUnsequenced(const ENetProtocol* command, UInt8** data); + bool HandleThrottleConfigure(const ENetProtocol* command); + bool HandleVerifyConnect(const ENetProtocol* command, ENetEvent* event); + void OnConnect(); void OnDisconnect(); diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 3587e19d1..4da174baf 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -411,116 +411,6 @@ namespace Nz return false; } - bool ENetHost::HandleAcknowledge(ENetEvent* event, ENetPeer* peer, const ENetProtocol* command) - { - if (peer->GetState() == ENetPeerState::Disconnected || peer->GetState() == ENetPeerState::Zombie) - return true; - - UInt32 receivedSentTime = NetToHost(command->acknowledge.receivedSentTime); - receivedSentTime |= m_serviceTime & 0xFFFF0000; - if ((receivedSentTime & 0x8000) > (m_serviceTime & 0x8000)) - receivedSentTime -= 0x10000; - - if (ENET_TIME_LESS(m_serviceTime, receivedSentTime)) - return true; - - peer->m_lastReceiveTime = m_serviceTime; - peer->m_earliestTimeout = 0; - - UInt32 roundTripTime = ENET_TIME_DIFFERENCE(m_serviceTime, receivedSentTime); - - peer->Throttle(roundTripTime); - - peer->m_roundTripTimeVariance -= peer->m_roundTripTimeVariance / 4; - - if (roundTripTime >= peer->m_roundTripTime) - { - peer->m_roundTripTime += (roundTripTime - peer->m_roundTripTime) / 8; - peer->m_roundTripTimeVariance += (roundTripTime - peer->m_roundTripTime) / 4; - } - else - { - peer->m_roundTripTime -= (peer->m_roundTripTime - roundTripTime) / 8; - peer->m_roundTripTimeVariance += (peer->m_roundTripTime - roundTripTime) / 4; - } - - if (peer->m_roundTripTime < peer->m_lowestRoundTripTime) - peer->m_lowestRoundTripTime = peer->m_roundTripTime; - - if (peer->m_roundTripTimeVariance > peer->m_highestRoundTripTimeVariance) - peer->m_highestRoundTripTimeVariance = peer->m_roundTripTimeVariance; - - if (peer->m_packetThrottleEpoch == 0 || ENET_TIME_DIFFERENCE(m_serviceTime, peer->m_packetThrottleEpoch) >= peer->m_packetThrottleInterval) - { - peer->m_lastRoundTripTime = peer->m_lowestRoundTripTime; - peer->m_lastRoundTripTimeVariance = peer->m_highestRoundTripTimeVariance; - peer->m_lowestRoundTripTime = peer->m_roundTripTime; - peer->m_highestRoundTripTimeVariance = peer->m_roundTripTimeVariance; - peer->m_packetThrottleEpoch = m_serviceTime; - } - - UInt16 receivedReliableSequenceNumber = NetToHost(command->acknowledge.receivedReliableSequenceNumber); - - ENetProtocolCommand commandNumber = peer->RemoveSentReliableCommand(receivedReliableSequenceNumber, command->header.channelID); - - switch (peer->GetState()) - { - case ENetPeerState::AcknowledgingConnect: - if (commandNumber != ENetProtocolCommand_VerifyConnect) - return false; - - NotifyConnect(peer, event); - break; - - case ENetPeerState::Disconnecting: - if (commandNumber != ENetProtocolCommand_Disconnect) - return false; - - NotifyDisconnect(peer, event); - break; - - case ENetPeerState::DisconnectLater: - if (!peer->HasPendingCommands()) - peer->Disconnect(peer->m_eventData); - - break; - - default: - break; - } - - return true; - } - - bool ENetHost::HandleBandwidthLimit(ENetPeer* peer, const ENetProtocol* command) - { - if (!peer->IsConnected()) - return false; - - if (peer->m_incomingBandwidth != 0) - --m_bandwidthLimitedPeers; - - peer->m_incomingBandwidth = NetToHost(command->bandwidthLimit.incomingBandwidth); - peer->m_outgoingBandwidth = NetToHost(command->bandwidthLimit.outgoingBandwidth); - - if (peer->m_incomingBandwidth != 0) - ++m_bandwidthLimitedPeers; - - if (peer->m_incomingBandwidth == 0 && m_outgoingBandwidth == 0) - peer->m_windowSize = ENetConstants::ENetProtocol_MaximumWindowSize; - else - { - if (peer->m_incomingBandwidth == 0 || m_outgoingBandwidth == 0) - peer->m_windowSize = (std::max(peer->m_incomingBandwidth, m_outgoingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; - else - peer->m_windowSize = (std::min(peer->m_incomingBandwidth, m_outgoingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; - - peer->m_windowSize = Clamp(peer->m_windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); - } - - return true; - } - ENetPeer* ENetHost::HandleConnect(ENetProtocolHeader* /*header*/, ENetProtocol* command) { UInt32 channelCount = NetToHost(command->connect.channelCount); @@ -590,37 +480,6 @@ namespace Nz return peer; } - bool ENetHost::HandleDisconnect(ENetPeer* peer, const ENetProtocol * command) - { - if (peer->GetState() == ENetPeerState::Disconnected || peer->GetState() == ENetPeerState::Zombie || peer->GetState() == ENetPeerState::AcknowledgingDisconnect) - return true; - - peer->ResetQueues(); - - if (peer->GetState() == ENetPeerState::ConnectionSucceeded || peer->GetState() == ENetPeerState::Disconnecting || peer->GetState() == ENetPeerState::Connecting) - peer->DispatchState(ENetPeerState::Zombie); - else - { - if (!peer->IsConnected()) - { - if (peer->GetState() == ENetPeerState::ConnectionPending) - m_recalculateBandwidthLimits = true; - - peer->Reset(); - } - else - if (command->header.command & ENetProtocolFlag_Acknowledge) - peer->ChangeState(ENetPeerState::AcknowledgingDisconnect); - else - peer->DispatchState(ENetPeerState::Zombie); - } - - if (peer->GetState() != ENetPeerState::Disconnected) - peer->m_eventData = NetToHost(command->disconnect.data); - - return true; - } - bool ENetHost::HandleIncomingCommands(ENetEvent* event) { if (m_receivedDataLength < NazaraOffsetOf(ENetProtocolHeader, sentTime)) @@ -702,7 +561,7 @@ namespace Nz switch (commandNumber) { case ENetProtocolCommand_Acknowledge: - if (!HandleAcknowledge(event, peer, command)) + if (!peer->HandleAcknowledge(command, event)) return commandError(); break; @@ -718,61 +577,61 @@ namespace Nz break; case ENetProtocolCommand_VerifyConnect: - if (!HandleVerifyConnect(event, peer, command)) + if (!peer->HandleVerifyConnect(command, event)) return commandError(); break; case ENetProtocolCommand_Disconnect: - if (!HandleDisconnect(peer, command)) + if (!peer->HandleDisconnect(command)) return commandError(); break; case ENetProtocolCommand_Ping: - if (!HandlePing(peer, command)) + if (!peer->HandlePing(command)) return commandError(); break; case ENetProtocolCommand_SendReliable: - if (!HandleSendReliable(peer, command, ¤tData)) + if (!peer->HandleSendReliable(command, ¤tData)) return commandError(); break; case ENetProtocolCommand_SendUnreliable: - if (!HandleSendUnreliable(peer, command, ¤tData)) + if (!peer->HandleSendUnreliable(command, ¤tData)) return commandError(); break; case ENetProtocolCommand_SendUnsequenced: - if (!HandleSendUnsequenced(peer, command, ¤tData)) + if (!peer->HandleSendUnsequenced(command, ¤tData)) return commandError(); break; case ENetProtocolCommand_SendFragment: - if (!HandleSendFragment(peer, command, ¤tData)) + if (!peer->HandleSendFragment(command, ¤tData)) return commandError(); break; case ENetProtocolCommand_BandwidthLimit: - if (!HandleBandwidthLimit(peer, command)) + if (!peer->HandleBandwidthLimit(command)) return commandError(); break; case ENetProtocolCommand_ThrottleConfigure: - if (!HandleThrottleConfigure(peer, command)) + if (!peer->HandleThrottleConfigure(command)) return commandError(); break; case ENetProtocolCommand_SendUnreliableFragment: - if (!HandleSendUnreliableFragment(peer, command, ¤tData)) + if (!peer->HandleSendUnreliableFragment(command, ¤tData)) return commandError(); break; @@ -813,314 +672,6 @@ namespace Nz return commandError(); } - bool ENetHost::HandlePing(ENetPeer* peer, const ENetProtocol* /*command*/) - { - if (!peer->IsConnected()) - return false; - - return true; - } - - bool ENetHost::HandleSendFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) - { - if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) - return false; - - UInt16 fragmentLength = NetToHost(command->sendFragment.dataLength); - *currentData += fragmentLength; - if (fragmentLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) - return false; - - ENetPeer::Channel& channel = peer->m_channels[command->header.channelID]; - UInt32 startSequenceNumber = NetToHost(command->sendFragment.startSequenceNumber); - UInt16 startWindow = startSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; - UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; - - if (startSequenceNumber < channel.incomingReliableSequenceNumber) - startWindow += ENetConstants::ENetPeer_ReliableWindows; - - if (startWindow < currentWindow || startWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1) - return true; - - UInt32 fragmentNumber = NetToHost(command->sendFragment.fragmentNumber); - UInt32 fragmentCount = NetToHost(command->sendFragment.fragmentCount); - UInt32 fragmentOffset = NetToHost(command->sendFragment.fragmentOffset); - UInt32 totalLength = NetToHost(command->sendFragment.totalLength); - - if (fragmentCount > ENetConstants::ENetProtocol_MaximumFragmentCount || fragmentNumber >= fragmentCount || totalLength > m_maximumPacketSize || - fragmentOffset >= totalLength || fragmentLength > totalLength - fragmentOffset) - return false; - - ENetPeer::IncomingCommmand* startCommand = nullptr; - for (auto currentCommand = channel.incomingReliableCommands.rbegin(); currentCommand != channel.incomingReliableCommands.rend(); ++currentCommand) - { - ENetPeer::IncomingCommmand& incomingCommand = *currentCommand; - - if (startSequenceNumber >= channel.incomingReliableSequenceNumber) - { - if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) - continue; - } - else if (incomingCommand.reliableSequenceNumber >= channel.incomingReliableSequenceNumber) - break; - - if (incomingCommand.reliableSequenceNumber <= startSequenceNumber) - { - if (incomingCommand.reliableSequenceNumber < startSequenceNumber) - break; - - if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendFragment || - totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.GetSize()) - return false; - - startCommand = &incomingCommand; - break; - } - } - - if (startCommand) - { - ENetProtocol hostCommand = *command; - hostCommand.header.reliableSequenceNumber = startSequenceNumber; - - if (!peer->QueueIncomingCommand(hostCommand, nullptr, totalLength, ENetPacketFlag_Reliable, fragmentCount)) - return false; - } - - if (!startCommand->fragments.Test(fragmentNumber)) - { - --startCommand->fragmentsRemaining; - - startCommand->fragments.Set(fragmentNumber, true); - - if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) - fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; - - std::memcpy(startCommand->packet->data.GetData() + Nz::NetPacket::HeaderSize + fragmentOffset, reinterpret_cast(command) + sizeof(ENetProtocolSendFragment), fragmentLength); - - if (startCommand->fragmentsRemaining <= 0) - peer->DispatchIncomingReliableCommands(channel); - } - - return false; - } - - bool ENetHost::HandleSendReliable(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) - { - if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) - return false; - - UInt16 dataLength = NetToHost(command->sendReliable.dataLength); - *currentData += dataLength; - if (dataLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) - return false; - - if (!peer->QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendReliable), dataLength, ENetPacketFlag_Reliable, 0)) - return false; - - return true; - } - - bool ENetHost::HandleSendUnreliable(ENetPeer * peer, const ENetProtocol * command, UInt8 ** currentData) - { - if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) - return false; - - UInt16 dataLength = NetToHost(command->sendUnreliable.dataLength); - *currentData += dataLength; - if (dataLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) - return false; - - if (!peer->QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendUnreliable), dataLength, 0, 0)) - return false; - - return true; - } - - bool ENetHost::HandleSendUnreliableFragment(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) - { - if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) - return false; - - UInt16 fragmentLength = NetToHost(command->sendFragment.dataLength); - *currentData += fragmentLength; - if (fragmentLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) - return false; - - ENetPeer::Channel& channel = peer->m_channels[command->header.channelID]; - UInt32 reliableSequenceNumber = command->header.reliableSequenceNumber; - UInt32 startSequenceNumber = NetToHost(command->sendFragment.startSequenceNumber); - - UInt16 reliableWindow = reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; - UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; - - if (startSequenceNumber < channel.incomingReliableSequenceNumber) - reliableWindow += ENetConstants::ENetPeer_ReliableWindows; - - if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1) - return true; - - if (reliableSequenceNumber == channel.incomingReliableSequenceNumber && startSequenceNumber <= channel.incomingUnreliableSequenceNumber) - return true; - - UInt32 fragmentNumber = NetToHost(command->sendFragment.fragmentNumber); - UInt32 fragmentCount = NetToHost(command->sendFragment.fragmentCount); - UInt32 fragmentOffset = NetToHost(command->sendFragment.fragmentOffset); - UInt32 totalLength = NetToHost(command->sendFragment.totalLength); - - if (fragmentCount > ENetConstants::ENetProtocol_MaximumFragmentCount || fragmentNumber >= fragmentCount || totalLength > m_maximumPacketSize || - fragmentOffset >= totalLength || fragmentLength > totalLength - fragmentOffset) - return false; - - ENetPeer::IncomingCommmand* startCommand = nullptr; - for (auto currentCommand = channel.incomingUnreliableCommands.rbegin(); currentCommand != channel.incomingUnreliableCommands.rend(); ++currentCommand) - { - ENetPeer::IncomingCommmand& incomingCommand = *currentCommand; - - if (startSequenceNumber >= channel.incomingReliableSequenceNumber) - { - if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) - continue; - } - else if (incomingCommand.reliableSequenceNumber >= channel.incomingReliableSequenceNumber) - break; - - if (incomingCommand.reliableSequenceNumber < reliableSequenceNumber) - break; - - if (incomingCommand.reliableSequenceNumber > reliableSequenceNumber) - continue; - - if (incomingCommand.unreliableSequenceNumber <= startSequenceNumber) - { - if (incomingCommand.unreliableSequenceNumber < startSequenceNumber) - break; - - if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendUnreliableFragment || - totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.GetSize()) - return false; - - startCommand = &incomingCommand; - break; - } - } - - if (startCommand) - { - if (!peer->QueueIncomingCommand(*command, nullptr, totalLength, ENetPacketFlag_UnreliableFragment, fragmentCount)) - return false; - } - - if (!startCommand->fragments.Test(fragmentNumber)) - { - --startCommand->fragmentsRemaining; - - startCommand->fragments.Set(fragmentNumber, true); - - if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) - fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; - - std::memcpy(startCommand->packet->data.GetData() + Nz::NetPacket::HeaderSize + fragmentOffset, reinterpret_cast(command) + sizeof(ENetProtocolSendFragment), fragmentLength); - - if (startCommand->fragmentsRemaining <= 0) - peer->DispatchIncomingUnreliableCommands(channel); - } - - return true; - } - - bool ENetHost::HandleSendUnsequenced(ENetPeer* peer, const ENetProtocol* command, UInt8** currentData) - { - if (command->header.channelID >= peer->m_channels.size() || !peer->IsConnected()) - return false; - - std::size_t dataLength = NetToHost(command->sendUnsequenced.dataLength); - *currentData += dataLength; - if (dataLength >= m_maximumPacketSize || *currentData < m_receivedData || *currentData > &m_receivedData[m_receivedDataLength]) - return false; - - UInt32 unsequencedGroup = NetToHost(command->sendUnsequenced.unsequencedGroup); - UInt32 index = unsequencedGroup % ENetConstants::ENetPeer_UnsequencedWindowSize; - - if (unsequencedGroup < peer->m_incomingUnsequencedGroup) - unsequencedGroup += 0x10000; - - if (unsequencedGroup >= static_cast(peer->m_incomingUnsequencedGroup) + ENetConstants::ENetPeer_UnsequencedWindows * ENetConstants::ENetPeer_UnsequencedWindowSize) - return true; - - unsequencedGroup &= 0xFFFF; - - if (unsequencedGroup - index != peer->m_incomingUnsequencedGroup) - { - peer->m_incomingUnsequencedGroup = unsequencedGroup - index; - - peer->m_unsequencedWindow.fill(0); - } - else if (peer->m_unsequencedWindow[index / 32] & (1 << (index % 32))) - return true; - - if (!peer->QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendUnsequenced), dataLength, ENetPacketFlag_Unsequenced, 0)) - return false; - - peer->m_unsequencedWindow[index / 32] |= 1 << (index % 32); - - return true; - } - - bool ENetHost::HandleThrottleConfigure(ENetPeer* peer, const ENetProtocol* command) - { - if (!peer->IsConnected()) - return false; - - peer->m_packetThrottleInterval = NetToHost(command->throttleConfigure.packetThrottleInterval); - peer->m_packetThrottleAcceleration = NetToHost(command->throttleConfigure.packetThrottleAcceleration); - peer->m_packetThrottleDeceleration = NetToHost(command->throttleConfigure.packetThrottleDeceleration); - - return true; - } - - bool ENetHost::HandleVerifyConnect(ENetEvent* event, ENetPeer* peer, ENetProtocol* command) - { - if (peer->GetState() != ENetPeerState::Connecting) - return true; - - UInt32 channelCount = NetToHost(command->verifyConnect.channelCount); - - if (channelCount < ENetConstants::ENetProtocol_MinimumChannelCount || channelCount > ENetConstants::ENetProtocol_MaximumChannelCount || - NetToHost(command->verifyConnect.packetThrottleInterval) != peer->m_packetThrottleInterval || - NetToHost(command->verifyConnect.packetThrottleAcceleration) != peer->m_packetThrottleAcceleration || - NetToHost(command->verifyConnect.packetThrottleDeceleration) != peer->m_packetThrottleDeceleration || - command->verifyConnect.connectID != peer->m_connectID) - { - peer->m_eventData = 0; - - peer->DispatchState(ENetPeerState::Zombie); - - return false; - } - - peer->RemoveSentReliableCommand(1, 0xFF); - - if (channelCount < peer->m_channels.size()) - peer->m_channels.resize(channelCount); - - peer->m_outgoingPeerID = NetToHost(command->verifyConnect.outgoingPeerID); - peer->m_incomingSessionID = command->verifyConnect.incomingSessionID; - peer->m_outgoingSessionID = command->verifyConnect.outgoingSessionID; - - UInt32 mtu = Clamp(NetToHost(command->verifyConnect.mtu), ENetConstants::ENetProtocol_MinimumMTU, ENetConstants::ENetProtocol_MaximumMTU); - peer->m_mtu = std::min(peer->m_mtu, mtu); - - UInt32 windowSize = Clamp(NetToHost(command->verifyConnect.windowSize), ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); - peer->m_windowSize = std::min(peer->m_windowSize, windowSize); - - peer->m_incomingBandwidth = NetToHost(command->verifyConnect.incomingBandwidth); - peer->m_outgoingBandwidth = NetToHost(command->verifyConnect.outgoingBandwidth); - - NotifyConnect(peer, event); - return true; - } - int ENetHost::ReceiveIncomingCommands(ENetEvent* event) { for (unsigned int i = 0; i < 256; ++i) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index d0181a01d..e90d77954 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -469,6 +469,453 @@ namespace Nz channel.incomingUnreliableCommands.erase(channel.incomingUnreliableCommands.begin(), droppedCommand); } + bool ENetPeer::HandleAcknowledge(const ENetProtocol* command, ENetEvent* event) + { + if (m_state == ENetPeerState::Disconnected || m_state == ENetPeerState::Zombie) + return true; + + UInt32 serviceTime = m_host->m_serviceTime; + UInt32 receivedSentTime = NetToHost(command->acknowledge.receivedSentTime); + receivedSentTime |= serviceTime & 0xFFFF0000; + if ((receivedSentTime & 0x8000) > (serviceTime & 0x8000)) + receivedSentTime -= 0x10000; + + if (ENET_TIME_LESS(serviceTime, receivedSentTime)) + return true; + + m_lastReceiveTime = serviceTime; + m_earliestTimeout = 0; + + UInt32 roundTripTime = ENET_TIME_DIFFERENCE(serviceTime, receivedSentTime); + + Throttle(roundTripTime); + + m_roundTripTimeVariance -= m_roundTripTimeVariance / 4; + + if (roundTripTime >= m_roundTripTime) + { + m_roundTripTime += (roundTripTime - m_roundTripTime) / 8; + m_roundTripTimeVariance += (roundTripTime - m_roundTripTime) / 4; + } + else + { + m_roundTripTime -= (m_roundTripTime - roundTripTime) / 8; + m_roundTripTimeVariance += (m_roundTripTime - roundTripTime) / 4; + } + + m_lowestRoundTripTime = std::min(m_lowestRoundTripTime, m_roundTripTime); + m_highestRoundTripTimeVariance = std::max(m_highestRoundTripTimeVariance, m_roundTripTimeVariance); + + if (m_packetThrottleEpoch == 0 || ENET_TIME_DIFFERENCE(serviceTime, m_packetThrottleEpoch) >= m_packetThrottleInterval) + { + m_lastRoundTripTime = m_lowestRoundTripTime; + m_lastRoundTripTimeVariance = m_highestRoundTripTimeVariance; + m_lowestRoundTripTime = m_roundTripTime; + m_highestRoundTripTimeVariance = m_roundTripTimeVariance; + m_packetThrottleEpoch = serviceTime; + } + + UInt16 receivedReliableSequenceNumber = NetToHost(command->acknowledge.receivedReliableSequenceNumber); + + ENetProtocolCommand commandNumber = RemoveSentReliableCommand(receivedReliableSequenceNumber, command->header.channelID); + + switch (m_state) + { + case ENetPeerState::AcknowledgingConnect: + if (commandNumber != ENetProtocolCommand_VerifyConnect) + return false; + + m_host->NotifyConnect(this, event); + break; + + case ENetPeerState::Disconnecting: + if (commandNumber != ENetProtocolCommand_Disconnect) + return false; + + m_host->NotifyDisconnect(this, event); + break; + + case ENetPeerState::DisconnectLater: + if (!HasPendingCommands()) + Disconnect(m_eventData); + + break; + + default: + break; + } + + return true; + } + + bool ENetPeer::HandleBandwidthLimit(const ENetProtocol* command) + { + if (!IsConnected()) + return false; + + if (m_incomingBandwidth != 0) + --m_host->m_bandwidthLimitedPeers; + + m_incomingBandwidth = NetToHost(command->bandwidthLimit.incomingBandwidth); + m_outgoingBandwidth = NetToHost(command->bandwidthLimit.outgoingBandwidth); + + if (m_incomingBandwidth != 0) + ++m_host->m_bandwidthLimitedPeers; + + if (m_incomingBandwidth == 0 && m_host->m_outgoingBandwidth == 0) + m_windowSize = ENetConstants::ENetProtocol_MaximumWindowSize; + else + { + if (m_incomingBandwidth == 0 || m_host->m_outgoingBandwidth == 0) + m_windowSize = (std::max(m_incomingBandwidth, m_host->m_outgoingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + else + m_windowSize = (std::min(m_incomingBandwidth, m_host->m_outgoingBandwidth) / ENetConstants::ENetPeer_WindowSizeScale) * ENetConstants::ENetProtocol_MinimumWindowSize; + + m_windowSize = Clamp(m_windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + } + + return true; + } + + bool ENetPeer::HandleDisconnect(const ENetProtocol* command) + { + if (m_state == ENetPeerState::Disconnected || m_state == ENetPeerState::Zombie || m_state == ENetPeerState::AcknowledgingDisconnect) + return true; + + ResetQueues(); + + if (m_state == ENetPeerState::ConnectionSucceeded || m_state == ENetPeerState::Disconnecting || m_state == ENetPeerState::Connecting) + DispatchState(ENetPeerState::Zombie); + else + { + if (!IsConnected()) + { + if (m_state == ENetPeerState::ConnectionPending) + m_host->m_recalculateBandwidthLimits = true; + + Reset(); + } + else + if (command->header.command & ENetProtocolFlag_Acknowledge) + ChangeState(ENetPeerState::AcknowledgingDisconnect); + else + DispatchState(ENetPeerState::Zombie); + } + + if (m_state != ENetPeerState::Disconnected) + m_eventData = NetToHost(command->disconnect.data); + + return true; + } + + bool ENetPeer::HandlePing(const ENetProtocol* /*command*/) + { + if (!IsConnected()) + return false; + + return true; + } + + bool ENetPeer::HandleSendFragment(const ENetProtocol* command, UInt8** data) + { + if (command->header.channelID >= m_channels.size() || !IsConnected()) + return false; + + UInt16 fragmentLength = NetToHost(command->sendFragment.dataLength); + *data += fragmentLength; + if (fragmentLength >= m_host->m_maximumPacketSize || *data < m_host->m_receivedData || *data > &m_host->m_receivedData[m_host->m_receivedDataLength]) + return false; + + ENetPeer::Channel& channel = m_channels[command->header.channelID]; + UInt32 startSequenceNumber = NetToHost(command->sendFragment.startSequenceNumber); + UInt16 startWindow = startSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + + if (startSequenceNumber < channel.incomingReliableSequenceNumber) + startWindow += ENetConstants::ENetPeer_ReliableWindows; + + if (startWindow < currentWindow || startWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1) + return true; + + UInt32 fragmentNumber = NetToHost(command->sendFragment.fragmentNumber); + UInt32 fragmentCount = NetToHost(command->sendFragment.fragmentCount); + UInt32 fragmentOffset = NetToHost(command->sendFragment.fragmentOffset); + UInt32 totalLength = NetToHost(command->sendFragment.totalLength); + + if (fragmentCount > ENetConstants::ENetProtocol_MaximumFragmentCount || fragmentNumber >= fragmentCount || totalLength > m_host->m_maximumPacketSize || + fragmentOffset >= totalLength || fragmentLength > totalLength - fragmentOffset) + return false; + + ENetPeer::IncomingCommmand* startCommand = nullptr; + for (auto currentCommand = channel.incomingReliableCommands.rbegin(); currentCommand != channel.incomingReliableCommands.rend(); ++currentCommand) + { + ENetPeer::IncomingCommmand& incomingCommand = *currentCommand; + + if (startSequenceNumber >= channel.incomingReliableSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + continue; + } + else if (incomingCommand.reliableSequenceNumber >= channel.incomingReliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber <= startSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < startSequenceNumber) + break; + + if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendFragment || + totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.GetSize()) + return false; + + startCommand = &incomingCommand; + break; + } + } + + if (startCommand) + { + ENetProtocol hostCommand = *command; + hostCommand.header.reliableSequenceNumber = startSequenceNumber; + + if (!QueueIncomingCommand(hostCommand, nullptr, totalLength, ENetPacketFlag_Reliable, fragmentCount)) + return false; + } + + if (!startCommand->fragments.Test(fragmentNumber)) + { + --startCommand->fragmentsRemaining; + + startCommand->fragments.Set(fragmentNumber, true); + + if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) + fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; + + std::memcpy(startCommand->packet->data.GetData() + NetPacket::HeaderSize + fragmentOffset, reinterpret_cast(command) + sizeof(ENetProtocolSendFragment), fragmentLength); + + if (startCommand->fragmentsRemaining <= 0) + DispatchIncomingReliableCommands(channel); + } + + return false; + } + + bool ENetPeer::HandleSendReliable(const ENetProtocol* command, UInt8** data) + { + if (command->header.channelID >= m_channels.size() || !IsConnected()) + return false; + + UInt16 dataLength = NetToHost(command->sendReliable.dataLength); + *data += dataLength; + if (dataLength >= m_host->m_maximumPacketSize || *data < m_host->m_receivedData || *data > &m_host->m_receivedData[m_host->m_receivedDataLength]) + return false; + + if (!QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendReliable), dataLength, ENetPacketFlag_Reliable, 0)) + return false; + + return true; + } + + bool ENetPeer::HandleSendUnreliable(const ENetProtocol* command, UInt8** data) + { + if (command->header.channelID >= m_channels.size() || !IsConnected()) + return false; + + UInt16 dataLength = NetToHost(command->sendUnreliable.dataLength); + *data += dataLength; + if (dataLength >= m_host->m_maximumPacketSize || *data < m_host->m_receivedData || *data > &m_host->m_receivedData[m_host->m_receivedDataLength]) + return false; + + if (!QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendUnreliable), dataLength, 0, 0)) + return false; + + return true; + } + + bool ENetPeer::HandleSendUnreliableFragment(const ENetProtocol* command, UInt8** data) + { + if (command->header.channelID >= m_channels.size() || !IsConnected()) + return false; + + UInt16 fragmentLength = NetToHost(command->sendFragment.dataLength); + *data += fragmentLength; + if (fragmentLength >= m_host->m_maximumPacketSize || *data < m_host->m_receivedData || *data > &m_host->m_receivedData[m_host->m_receivedDataLength]) + return false; + + ENetPeer::Channel& channel = m_channels[command->header.channelID]; + UInt32 reliableSequenceNumber = command->header.reliableSequenceNumber; + UInt32 startSequenceNumber = NetToHost(command->sendFragment.startSequenceNumber); + + UInt16 reliableWindow = reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize; + + if (startSequenceNumber < channel.incomingReliableSequenceNumber) + reliableWindow += ENetConstants::ENetPeer_ReliableWindows; + + if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENetConstants::ENetPeer_FreeReliableWindows - 1) + return true; + + if (reliableSequenceNumber == channel.incomingReliableSequenceNumber && startSequenceNumber <= channel.incomingUnreliableSequenceNumber) + return true; + + UInt32 fragmentNumber = NetToHost(command->sendFragment.fragmentNumber); + UInt32 fragmentCount = NetToHost(command->sendFragment.fragmentCount); + UInt32 fragmentOffset = NetToHost(command->sendFragment.fragmentOffset); + UInt32 totalLength = NetToHost(command->sendFragment.totalLength); + + if (fragmentCount > ENetConstants::ENetProtocol_MaximumFragmentCount || fragmentNumber >= fragmentCount || totalLength > m_host->m_maximumPacketSize || + fragmentOffset >= totalLength || fragmentLength > totalLength - fragmentOffset) + return false; + + ENetPeer::IncomingCommmand* startCommand = nullptr; + for (auto currentCommand = channel.incomingUnreliableCommands.rbegin(); currentCommand != channel.incomingUnreliableCommands.rend(); ++currentCommand) + { + ENetPeer::IncomingCommmand& incomingCommand = *currentCommand; + + if (startSequenceNumber >= channel.incomingReliableSequenceNumber) + { + if (incomingCommand.reliableSequenceNumber < channel.incomingReliableSequenceNumber) + continue; + } + else if (incomingCommand.reliableSequenceNumber >= channel.incomingReliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber < reliableSequenceNumber) + break; + + if (incomingCommand.reliableSequenceNumber > reliableSequenceNumber) + continue; + + if (incomingCommand.unreliableSequenceNumber <= startSequenceNumber) + { + if (incomingCommand.unreliableSequenceNumber < startSequenceNumber) + break; + + if ((incomingCommand.command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendUnreliableFragment || + totalLength != incomingCommand.packet->data.GetDataSize() || fragmentCount != incomingCommand.fragments.GetSize()) + return false; + + startCommand = &incomingCommand; + break; + } + } + + if (startCommand) + { + if (!QueueIncomingCommand(*command, nullptr, totalLength, ENetPacketFlag_UnreliableFragment, fragmentCount)) + return false; + } + + if (!startCommand->fragments.Test(fragmentNumber)) + { + --startCommand->fragmentsRemaining; + + startCommand->fragments.Set(fragmentNumber, true); + + if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) + fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; + + std::memcpy(startCommand->packet->data.GetData() + NetPacket::HeaderSize + fragmentOffset, reinterpret_cast(command) + sizeof(ENetProtocolSendFragment), fragmentLength); + + if (startCommand->fragmentsRemaining <= 0) + DispatchIncomingUnreliableCommands(channel); + } + + return true; + } + + bool ENetPeer::HandleSendUnsequenced(const ENetProtocol* command, UInt8** data) + { + if (command->header.channelID >= m_channels.size() || !IsConnected()) + return false; + + std::size_t dataLength = NetToHost(command->sendUnsequenced.dataLength); + *data += dataLength; + if (dataLength >= m_host->m_maximumPacketSize || *data < m_host->m_receivedData || *data > &m_host->m_receivedData[m_host->m_receivedDataLength]) + return false; + + UInt32 unsequencedGroup = NetToHost(command->sendUnsequenced.unsequencedGroup); + UInt32 index = unsequencedGroup % ENetConstants::ENetPeer_UnsequencedWindowSize; + + if (unsequencedGroup < m_incomingUnsequencedGroup) + unsequencedGroup += 0x10000; + + if (unsequencedGroup >= static_cast(m_incomingUnsequencedGroup) + ENetConstants::ENetPeer_UnsequencedWindows * ENetConstants::ENetPeer_UnsequencedWindowSize) + return true; + + unsequencedGroup &= 0xFFFF; + + if (unsequencedGroup - index != m_incomingUnsequencedGroup) + { + m_incomingUnsequencedGroup = unsequencedGroup - index; + + m_unsequencedWindow.fill(0); + } + else if (m_unsequencedWindow[index / 32] & (1 << (index % 32))) + return true; + + if (!QueueIncomingCommand(*command, reinterpret_cast(command) + sizeof(ENetProtocolSendUnsequenced), dataLength, ENetPacketFlag_Unsequenced, 0)) + return false; + + m_unsequencedWindow[index / 32] |= 1 << (index % 32); + + return true; + } + + bool ENetPeer::HandleThrottleConfigure(const ENetProtocol* command) + { + if (!IsConnected()) + return false; + + m_packetThrottleInterval = NetToHost(command->throttleConfigure.packetThrottleInterval); + m_packetThrottleAcceleration = NetToHost(command->throttleConfigure.packetThrottleAcceleration); + m_packetThrottleDeceleration = NetToHost(command->throttleConfigure.packetThrottleDeceleration); + + return true; + } + + bool ENetPeer::HandleVerifyConnect(const ENetProtocol* command, ENetEvent* event) + { + if (m_state != ENetPeerState::Connecting) + return true; + + UInt32 channelCount = NetToHost(command->verifyConnect.channelCount); + + if (channelCount < ENetConstants::ENetProtocol_MinimumChannelCount || channelCount > ENetConstants::ENetProtocol_MaximumChannelCount || + NetToHost(command->verifyConnect.packetThrottleInterval) != m_packetThrottleInterval || + NetToHost(command->verifyConnect.packetThrottleAcceleration) != m_packetThrottleAcceleration || + NetToHost(command->verifyConnect.packetThrottleDeceleration) != m_packetThrottleDeceleration || + command->verifyConnect.connectID != m_connectID) + { + m_eventData = 0; + + DispatchState(ENetPeerState::Zombie); + + return false; + } + + RemoveSentReliableCommand(1, 0xFF); + + if (channelCount < m_channels.size()) + m_channels.resize(channelCount); + + m_outgoingPeerID = NetToHost(command->verifyConnect.outgoingPeerID); + m_incomingSessionID = command->verifyConnect.incomingSessionID; + m_outgoingSessionID = command->verifyConnect.outgoingSessionID; + + UInt32 mtu = Clamp(NetToHost(command->verifyConnect.mtu), ENetConstants::ENetProtocol_MinimumMTU, ENetConstants::ENetProtocol_MaximumMTU); + m_mtu = std::min(m_mtu, mtu); + + UInt32 windowSize = Clamp(NetToHost(command->verifyConnect.windowSize), ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); + m_windowSize = std::min(m_windowSize, windowSize); + + m_incomingBandwidth = NetToHost(command->verifyConnect.incomingBandwidth); + m_outgoingBandwidth = NetToHost(command->verifyConnect.outgoingBandwidth); + + m_host->NotifyConnect(this, event); + return true; + } + void ENetPeer::InitIncoming(std::size_t channelCount, const IpAddress& address, ENetProtocolConnect& incomingCommand) { m_channels.resize(channelCount); From 3ff483d2f6e896e58d877e68b04aab74609b1881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 30 Jan 2017 18:08:38 +0100 Subject: [PATCH 091/243] Network/ENetPeer: Add GetPeerId() --- include/Nazara/Network/ENetPeer.hpp | 1 + include/Nazara/Network/ENetPeer.inl | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index c0d24f6f6..a6a00ba23 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -41,6 +41,7 @@ namespace Nz void DisconnectNow(UInt32 data); inline const IpAddress& GetAddress() const; + inline UInt16 GetPeerId() const; inline ENetPeerState GetState() const; inline bool HasPendingCommands(); diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index 1e74e0cae..324a1fb80 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -13,6 +13,11 @@ namespace Nz return m_address; } + inline UInt16 ENetPeer::GetPeerId() const + { + return m_incomingPeerID; + } + inline ENetPeerState ENetPeer::GetState() const { return m_state; From 4f1df53f075831fcd6154a54964d98559ef38964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 31 Jan 2017 15:31:11 +0100 Subject: [PATCH 092/243] Network/ENetPeer: Fix DisconnectLater not waiting for pending commands --- src/Nazara/Network/ENetPeer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index e90d77954..ae0952be5 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -83,7 +83,7 @@ namespace Nz void ENetPeer::DisconnectLater(UInt32 data) { - if (IsConnected() && !m_outgoingReliableCommands.empty() && !m_outgoingUnreliableCommands.empty() && !m_sentReliableCommands.empty()) + if (IsConnected() && HasPendingCommands()) { m_state = ENetPeerState::DisconnectLater; m_eventData = data; @@ -596,10 +596,12 @@ namespace Nz Reset(); } else + { if (command->header.command & ENetProtocolFlag_Acknowledge) ChangeState(ENetPeerState::AcknowledgingDisconnect); else DispatchState(ENetPeerState::Zombie); + } } if (m_state != ENetPeerState::Disconnected) From 2f057191aadf79265a27917be17dfd1e61127c33 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 31 Jan 2017 22:19:17 +0100 Subject: [PATCH 093/243] Network/ENetHost: Add GetServiceTime() --- include/Nazara/Network/ENetHost.hpp | 2 ++ include/Nazara/Network/ENetHost.inl | 5 +++++ src/Nazara/Network/ENetPeer.cpp | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index fe9956538..97b12f2c0 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -53,6 +53,8 @@ namespace Nz void Flush(); + inline UInt32 GetServiceTime() const; + int Service(ENetEvent* event, UInt32 timeout); void SimulateNetwork(double packetLossProbability, UInt16 minDelay, UInt16 maxDelay); diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl index c7e65ab95..8aa722771 100644 --- a/include/Nazara/Network/ENetHost.inl +++ b/include/Nazara/Network/ENetHost.inl @@ -51,6 +51,11 @@ namespace Nz m_peers.clear(); m_socket.Close(); } + + inline UInt32 Nz::ENetHost::GetServiceTime() const + { + return m_serviceTime; + } } #include diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index ae0952be5..6c5940629 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -474,7 +474,8 @@ namespace Nz if (m_state == ENetPeerState::Disconnected || m_state == ENetPeerState::Zombie) return true; - UInt32 serviceTime = m_host->m_serviceTime; + UInt32 serviceTime = m_host->GetServiceTime(); + UInt32 receivedSentTime = NetToHost(command->acknowledge.receivedSentTime); receivedSentTime |= serviceTime & 0xFFFF0000; if ((receivedSentTime & 0x8000) > (serviceTime & 0x8000)) From 6b8d9deb43907d4c5fcb4b3f69b24afac10500fa Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 31 Jan 2017 23:04:53 +0100 Subject: [PATCH 094/243] Network/ENet: Clean up time functions --- include/Nazara/Network/ENetProtocol.hpp | 10 ++++++++ include/Nazara/Network/ENetProtocol.inl | 34 +++++++++++++++++++++++++ src/Nazara/Network/ENetHost.cpp | 23 +++++------------ src/Nazara/Network/ENetPeer.cpp | 14 +++++----- 4 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 include/Nazara/Network/ENetProtocol.inl diff --git a/include/Nazara/Network/ENetProtocol.hpp b/include/Nazara/Network/ENetProtocol.hpp index 0434cafc2..e3df5e092 100644 --- a/include/Nazara/Network/ENetProtocol.hpp +++ b/include/Nazara/Network/ENetProtocol.hpp @@ -13,6 +13,14 @@ namespace Nz { + constexpr UInt32 ENetTimeOverflow = 24 * 60 * 60 * 1000; + + inline UInt32 ENetTimeDifference(UInt32 a, UInt32 b); + inline bool ENetTimeLess(UInt32 a, UInt32 b); + inline bool ENetTimeLessEqual(UInt32 a, UInt32 b); + inline bool ENetTimeGreater(UInt32 a, UInt32 b); + inline bool ENetTimeGreaterEqual(UInt32 a, UInt32 b); + class ENetPeer; // Constants for the ENet implementation and protocol @@ -294,4 +302,6 @@ namespace Nz #endif } +#include + #endif // NAZARA_ENETPROTOCOL_HPP diff --git a/include/Nazara/Network/ENetProtocol.inl b/include/Nazara/Network/ENetProtocol.inl new file mode 100644 index 000000000..b854f26c8 --- /dev/null +++ b/include/Nazara/Network/ENetProtocol.inl @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + UInt32 ENetTimeDifference(UInt32 a, UInt32 b) + { + return (ENetTimeLess(a, b)) ? b - a : a - b; + } + + bool ENetTimeLess(UInt32 a, UInt32 b) + { + return (a - b >= ENetTimeOverflow); + } + + bool ENetTimeLessEqual(UInt32 a, UInt32 b) + { + return !ENetTimeGreater(a, b); + } + + bool ENetTimeGreater(UInt32 a, UInt32 b) + { + return ENetTimeLess(b, a); + } + + bool ENetTimeGreaterEqual(UInt32 a, UInt32 b) + { + return !ENetTimeLess(a, b); + } +} diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 4da174baf..360142c37 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -6,15 +6,6 @@ #include #include -#define ENET_TIME_OVERFLOW 86400000 - -#define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) -#define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) -#define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) -#define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) - -#define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) - namespace Nz { /// Temporary @@ -235,7 +226,7 @@ namespace Nz do { - if (ENET_TIME_DIFFERENCE(m_serviceTime, m_bandwidthThrottleEpoch) >= ENetConstants::ENetHost_BandwidthThrottleInterval) + if (ENetTimeDifference(m_serviceTime, m_bandwidthThrottleEpoch) >= ENetConstants::ENetHost_BandwidthThrottleInterval) ThrottleBandwidth(); switch (SendOutgoingCommands(event, true)) @@ -291,17 +282,17 @@ namespace Nz return 1; } - if (ENET_TIME_GREATER_EQUAL(m_serviceTime, timeout)) + if (ENetTimeGreaterEqual(m_serviceTime, timeout)) return 0; for (;;) { m_serviceTime = GetElapsedMilliseconds(); - if (ENET_TIME_GREATER_EQUAL(m_serviceTime, timeout)) + if (ENetTimeGreaterEqual(m_serviceTime, timeout)) return 0; - if (m_poller.Wait(ENET_TIME_DIFFERENCE(timeout, m_serviceTime))) + if (m_poller.Wait(ENetTimeDifference(timeout, m_serviceTime))) break; } @@ -962,7 +953,7 @@ namespace Nz if (!currentPeer->m_acknowledgements.empty()) SendAcknowledgements(currentPeer); - if (checkForTimeouts && !currentPeer->m_sentReliableCommands.empty() && ENET_TIME_GREATER_EQUAL(m_serviceTime, currentPeer->m_nextTimeout) && currentPeer->CheckTimeouts(event)) + if (checkForTimeouts && !currentPeer->m_sentReliableCommands.empty() && ENetTimeGreaterEqual(m_serviceTime, currentPeer->m_nextTimeout) && currentPeer->CheckTimeouts(event)) { if (event && event->type != ENetEventType::None) return 1; @@ -971,7 +962,7 @@ namespace Nz } if ((currentPeer->m_outgoingReliableCommands.empty() || SendReliableOutgoingCommands(currentPeer)) && currentPeer->m_sentReliableCommands.empty() && - ENET_TIME_DIFFERENCE(m_serviceTime, currentPeer->m_lastReceiveTime) >= currentPeer->m_pingInterval && currentPeer->m_mtu - m_packetSize >= sizeof(ENetProtocolPing)) + ENetTimeDifference(m_serviceTime, currentPeer->m_lastReceiveTime) >= currentPeer->m_pingInterval && currentPeer->m_mtu - m_packetSize >= sizeof(ENetProtocolPing)) { currentPeer->Ping(); SendReliableOutgoingCommands(currentPeer); @@ -985,7 +976,7 @@ namespace Nz if (currentPeer->m_packetLossEpoch == 0) currentPeer->m_packetLossEpoch = m_serviceTime; - else if (ENET_TIME_DIFFERENCE(m_serviceTime, currentPeer->m_packetLossEpoch) >= ENetPeer_PacketLossInterval && currentPeer->m_packetsSent > 0) + else if (ENetTimeDifference(m_serviceTime, currentPeer->m_packetLossEpoch) >= ENetPeer_PacketLossInterval && currentPeer->m_packetsSent > 0) { UInt32 packetLoss = currentPeer->m_packetsLost * ENetPeer_PacketLossScale / currentPeer->m_packetsSent; diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 6c5940629..33c7fc465 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -319,14 +319,14 @@ namespace Nz ++currentCommand; - if (ENET_TIME_DIFFERENCE(m_host->m_serviceTime, outgoingCommand->sentTime) < outgoingCommand->roundTripTimeout) + if (ENetTimeDifference(serviceTime, outgoingCommand->sentTime) < outgoingCommand->roundTripTimeout) continue; - if (m_earliestTimeout == 0 || ENET_TIME_LESS(outgoingCommand->sentTime, m_earliestTimeout)) + if (m_earliestTimeout == 0 || ENetTimeLess(outgoingCommand->sentTime, m_earliestTimeout)) m_earliestTimeout = outgoingCommand->sentTime; - if (m_earliestTimeout != 0 && (ENET_TIME_DIFFERENCE(m_host->m_serviceTime, m_earliestTimeout) >= m_timeoutMaximum || - (outgoingCommand->roundTripTimeout >= outgoingCommand->roundTripTimeoutLimit && ENET_TIME_DIFFERENCE(m_host->m_serviceTime, m_earliestTimeout) >= m_timeoutMinimum))) + if (m_earliestTimeout != 0 && (ENetTimeDifference(serviceTime, m_earliestTimeout) >= m_timeoutMaximum || + (outgoingCommand->roundTripTimeout >= outgoingCommand->roundTripTimeoutLimit && ENetTimeDifference(serviceTime, m_earliestTimeout) >= m_timeoutMinimum))) { m_host->NotifyDisconnect(this, event); return true; @@ -481,13 +481,13 @@ namespace Nz if ((receivedSentTime & 0x8000) > (serviceTime & 0x8000)) receivedSentTime -= 0x10000; - if (ENET_TIME_LESS(serviceTime, receivedSentTime)) + if (ENetTimeLess(serviceTime, receivedSentTime)) return true; m_lastReceiveTime = serviceTime; m_earliestTimeout = 0; - UInt32 roundTripTime = ENET_TIME_DIFFERENCE(serviceTime, receivedSentTime); + UInt32 roundTripTime = ENetTimeDifference(serviceTime, receivedSentTime); Throttle(roundTripTime); @@ -507,7 +507,7 @@ namespace Nz m_lowestRoundTripTime = std::min(m_lowestRoundTripTime, m_roundTripTime); m_highestRoundTripTimeVariance = std::max(m_highestRoundTripTimeVariance, m_roundTripTimeVariance); - if (m_packetThrottleEpoch == 0 || ENET_TIME_DIFFERENCE(serviceTime, m_packetThrottleEpoch) >= m_packetThrottleInterval) + if (m_packetThrottleEpoch == 0 || ENetTimeDifference(serviceTime, m_packetThrottleEpoch) >= m_packetThrottleInterval) { m_lastRoundTripTime = m_lowestRoundTripTime; m_lastRoundTripTimeVariance = m_highestRoundTripTimeVariance; From 85257da07e80da568c89b65af4bc09a0d90005f3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 31 Jan 2017 23:05:18 +0100 Subject: [PATCH 095/243] Network/ENet: Fix some warnings --- include/Nazara/Network/ENetHost.hpp | 4 ++-- src/Nazara/Network/ENetHost.cpp | 4 ++-- src/Nazara/Network/ENetPeer.cpp | 23 +++++++---------------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 97b12f2c0..376e03002 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -128,10 +128,10 @@ namespace Nz UInt32 m_incomingBandwidth; UInt32 m_outgoingBandwidth; UInt32 m_serviceTime; - UInt32 m_totalSentData; UInt32 m_totalSentPackets; - UInt32 m_totalReceivedData; UInt32 m_totalReceivedPackets; + UInt64 m_totalSentData; + UInt64 m_totalReceivedData; bool m_continueSending; bool m_isSimulationEnabled; bool m_recalculateBandwidthLimits; diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 360142c37..0b73a1491 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -440,7 +440,7 @@ namespace Nz if (!peer || duplicatePeers >= m_duplicatePeers) return nullptr; - channelCount = std::min(channelCount, m_channelLimit); + channelCount = std::min(channelCount, UInt32(m_channelLimit)); peer->InitIncoming(channelCount, m_receivedAddress, command->connect); @@ -514,7 +514,7 @@ namespace Nz if (peer) { peer->m_address = m_receivedAddress; - peer->m_incomingDataTotal += m_receivedDataLength; + peer->m_incomingDataTotal += UInt32(m_receivedDataLength); } auto commandError = [&]() -> bool diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 33c7fc465..a3946e56e 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -4,15 +4,6 @@ #include #include -#define ENET_TIME_OVERFLOW 86400000 - -#define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) -#define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) -#define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) -#define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) - -#define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) - namespace Nz { /// Temporary @@ -216,9 +207,7 @@ namespace Nz Channel& channel = m_channels[channelId]; - std::size_t fragmentLength = m_mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment); - //if (m_host->m_checksum != nullptr) - // fragmentLength -= sizeof(UInt32); + UInt16 fragmentLength = static_cast(m_mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment)); UInt32 packetSize = static_cast(packetRef->data.GetDataSize()); if (packetSize > fragmentLength) @@ -252,11 +241,11 @@ namespace Nz fragmentOffset += fragmentLength) { if (packetSize - fragmentOffset < fragmentLength) - fragmentLength = packetSize - fragmentOffset; + fragmentLength = UInt16(packetSize - fragmentOffset); OutgoingCommand outgoingCommand; outgoingCommand.fragmentOffset = fragmentOffset; - outgoingCommand.fragmentLength = static_cast(fragmentLength); + outgoingCommand.fragmentLength = fragmentLength; outgoingCommand.packet = packetRef; outgoingCommand.command.header.command = commandNumber; outgoingCommand.command.header.channelID = channelId; @@ -312,6 +301,8 @@ namespace Nz bool ENetPeer::CheckTimeouts(ENetEvent* event) { + UInt32 serviceTime = m_host->GetServiceTime(); + auto currentCommand = m_sentReliableCommands.begin(); while (currentCommand != m_sentReliableCommands.end()) { @@ -816,7 +807,7 @@ namespace Nz startCommand->fragments.Set(fragmentNumber, true); if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) - fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; + fragmentLength = static_cast(startCommand->packet->data.GetDataSize() - fragmentOffset); std::memcpy(startCommand->packet->data.GetData() + NetPacket::HeaderSize + fragmentOffset, reinterpret_cast(command) + sizeof(ENetProtocolSendFragment), fragmentLength); @@ -1285,7 +1276,7 @@ namespace Nz void ENetPeer::SetupOutgoingCommand(OutgoingCommand& outgoingCommand) { - m_outgoingDataTotal += ENetHost::GetCommandSize(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength; + m_outgoingDataTotal += static_cast(ENetHost::GetCommandSize(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength); if (outgoingCommand.command.header.channelID == 0xFF) { From a087174bf8d6e79b21b4eee36eaa2d015ede121a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Feb 2017 00:13:08 +0100 Subject: [PATCH 096/243] Network/Algorithm: Add HostToNet and NetToHost --- include/Nazara/Network/Algorithm.hpp | 7 +++++++ include/Nazara/Network/Algorithm.inl | 25 +++++++++++++++++++++++++ src/Nazara/Network/ENetHost.cpp | 24 +----------------------- src/Nazara/Network/ENetPeer.cpp | 26 ++------------------------ 4 files changed, 35 insertions(+), 47 deletions(-) diff --git a/include/Nazara/Network/Algorithm.hpp b/include/Nazara/Network/Algorithm.hpp index 001d98059..f2d99b605 100644 --- a/include/Nazara/Network/Algorithm.hpp +++ b/include/Nazara/Network/Algorithm.hpp @@ -11,10 +11,17 @@ #include #include #include +#include namespace Nz { NAZARA_NETWORK_API bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port = nullptr, bool* isIPv6 = nullptr, const char** endOfRead = nullptr); + + template + std::enable_if_t::value, T> HostToNet(T value); + + template + std::enable_if_t::value, T> NetToHost(T value); } #include diff --git a/include/Nazara/Network/Algorithm.inl b/include/Nazara/Network/Algorithm.inl index 5364298d4..4cba24136 100644 --- a/include/Nazara/Network/Algorithm.inl +++ b/include/Nazara/Network/Algorithm.inl @@ -2,6 +2,31 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include +#include #include +namespace Nz +{ + template + std::enable_if_t::value, T> HostToNet(T value) + { +#ifdef NAZARA_LITTLE_ENDIAN + return SwapBytes(value); +#else + return value; +#endif + } + + template + std::enable_if_t::value, T> NetToHost(T value) + { +#ifdef NAZARA_LITTLE_ENDIAN + return SwapBytes(value); +#else + return value; +#endif + } +} + #include diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 0b73a1491..0461b1053 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -1,35 +1,13 @@ #include #include -#include #include +#include #include #include #include namespace Nz { - /// Temporary - template - T HostToNet(T value) - { - #ifdef NAZARA_LITTLE_ENDIAN - return SwapBytes(value); - #else - return value; - #endif - } - - /// Temporary - template - T NetToHost(T value) - { - #ifdef NAZARA_LITTLE_ENDIAN - return SwapBytes(value); - #else - return value; - #endif - } - namespace { static std::size_t s_commandSizes[ENetProtocolCommand_Count] = diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index a3946e56e..152f1b4ef 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -1,33 +1,11 @@ #include -#include +#include #include #include #include namespace Nz { - /// Temporary - template - T HostToNet(T value) - { - #ifdef NAZARA_LITTLE_ENDIAN - return SwapBytes(value); - #else - return value; - #endif - } - - /// Temporary - template - T NetToHost(T value) - { - #ifdef NAZARA_LITTLE_ENDIAN - return SwapBytes(value); - #else - return value; - #endif - } - ENetPeer::ENetPeer(ENetHost* host, UInt16 peerId) : m_host(host), m_packetPool(sizeof(ENetPacket)), @@ -683,7 +661,7 @@ namespace Nz startCommand->fragments.Set(fragmentNumber, true); if (fragmentOffset + fragmentLength > startCommand->packet->data.GetDataSize()) - fragmentLength = startCommand->packet->data.GetDataSize() - fragmentOffset; + fragmentLength = static_cast(startCommand->packet->data.GetDataSize() - fragmentOffset); std::memcpy(startCommand->packet->data.GetData() + NetPacket::HeaderSize + fragmentOffset, reinterpret_cast(command) + sizeof(ENetProtocolSendFragment), fragmentLength); From 7b8100dafe2577a878357ad00ed72271976bb66e Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Feb 2017 00:20:22 +0100 Subject: [PATCH 097/243] Network/ENet: Add ENet licence --- include/Nazara/Network/ENetHost.hpp | 12 +++++++++++- include/Nazara/Network/ENetPeer.hpp | 12 +++++++++++- src/Nazara/Network/ENetHost.cpp | 16 +++++++++++++++- src/Nazara/Network/ENetPacket.cpp | 4 ++++ src/Nazara/Network/ENetPeer.cpp | 16 +++++++++++++++- 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 376e03002..06d8259c5 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -1,4 +1,14 @@ -// Copyright (C) 2017 Jérôme Leclercq +/* + Copyright(c) 2002 - 2016 Lee Salzman + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index a6a00ba23..4c4248ad8 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -1,4 +1,14 @@ -// Copyright (C) 2017 Jérôme Leclercq +/* + Copyright(c) 2002 - 2016 Lee Salzman + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 0461b1053..3659139ac 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -1,4 +1,18 @@ -#include +/* + Copyright(c) 2002 - 2016 Lee Salzman + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include #include #include #include diff --git a/src/Nazara/Network/ENetPacket.cpp b/src/Nazara/Network/ENetPacket.cpp index 494ae1a54..4b4157ac4 100644 --- a/src/Nazara/Network/ENetPacket.cpp +++ b/src/Nazara/Network/ENetPacket.cpp @@ -1,3 +1,7 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + #include #include #include diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 152f1b4ef..88b5568ff 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -1,4 +1,18 @@ -#include +/* + Copyright(c) 2002 - 2016 Lee Salzman + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include #include #include #include From 0f2d315c1d127be6f2f1e698ef77006e61d5dedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 1 Feb 2017 17:51:41 +0100 Subject: [PATCH 098/243] Network/ENet: Fix header dependency --- include/Nazara/Network/ENetHost.hpp | 6 ++---- include/Nazara/Network/ENetPeer.hpp | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 06d8259c5..83e8fd147 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -36,8 +36,6 @@ namespace Nz { - class ENetPeer; - class NAZARA_NETWORK_API ENetHost { friend ENetPeer; @@ -153,4 +151,4 @@ namespace Nz #include -#endif // NAZARA_RUDPSERVER_HPP +#endif // NAZARA_ENETHOST_HPP diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 4c4248ad8..e2b76c54a 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include From 41d06fed38bccae3183dd720ba4d343dec6ca3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 1 Feb 2017 17:52:01 +0100 Subject: [PATCH 099/243] Network/ENetHost: Fix packet leak when broadcasting with no peer connected --- src/Nazara/Network/ENetHost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 3659139ac..aff71c9c3 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -45,7 +45,7 @@ namespace Nz void ENetHost::Broadcast(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet) { - ENetPacket* enetPacket = m_packetPool.New(); + ENetPacketRef enetPacket = m_packetPool.New(); enetPacket->flags = flags; enetPacket->data = std::move(packet); enetPacket->owner = &m_packetPool; From ed8deed23c9d41b65d1ddc96a3b0a295ab5d9cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 1 Feb 2017 17:52:32 +0100 Subject: [PATCH 100/243] Core/MemoryHelper: Add PlacementDestroy --- include/Nazara/Core/MemoryHelper.hpp | 5 ++++- include/Nazara/Core/MemoryHelper.inl | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/MemoryHelper.hpp b/include/Nazara/Core/MemoryHelper.hpp index 6f53a012f..dc1bcc475 100644 --- a/include/Nazara/Core/MemoryHelper.hpp +++ b/include/Nazara/Core/MemoryHelper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -38,6 +38,9 @@ namespace Nz template T* PlacementNew(T* ptr, Args&&... args); + template + void PlacementDestroy(T* ptr); + class StackAllocation { public: diff --git a/include/Nazara/Core/MemoryHelper.inl b/include/Nazara/Core/MemoryHelper.inl index f7380e1b8..dcee8ca4e 100644 --- a/include/Nazara/Core/MemoryHelper.inl +++ b/include/Nazara/Core/MemoryHelper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -64,6 +64,17 @@ namespace Nz return new (ptr) T(std::forward(args)...); } + /*! + * \brief Calls the object destructor explicitly + * + * \param ptr Pointer to a previously constructed pointer on raw memory + */ + template + void PlacementDestroy(T* ptr) + { + ptr->~T(); + } + /*! * \ingroup core * \class Nz::StackAllocation From 9c66711a5362aa2c55a4012e761f890120ad5482 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Feb 2017 20:02:12 +0100 Subject: [PATCH 101/243] Update version --- include/Nazara/Prerequesites.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Prerequesites.hpp b/include/Nazara/Prerequesites.hpp index 13a044f68..0ac6b0fae 100644 --- a/include/Nazara/Prerequesites.hpp +++ b/include/Nazara/Prerequesites.hpp @@ -77,8 +77,8 @@ // Nazara version macro #define NAZARA_VERSION_MAJOR 0 -#define NAZARA_VERSION_MINOR 2 -#define NAZARA_VERSION_PATCH 1 +#define NAZARA_VERSION_MINOR 3 +#define NAZARA_VERSION_PATCH 0 #include From 2518a3939ff54d84538ce93c0c8ee8ac0c1fa388 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Feb 2017 20:54:25 +0100 Subject: [PATCH 102/243] Update documentation version --- Doxyfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doxyfile b/Doxyfile index 04a327a38..116ba2c2a 100644 --- a/Doxyfile +++ b/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "Nazara Engine" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 0.2 +PROJECT_NUMBER = 0.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 1a677387d1facf09a4df0578ed1b25eafa7dec4f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 7 Feb 2017 20:12:31 +0100 Subject: [PATCH 103/243] Noise/NoiseBase: Replace default_random_engine by mt19937 --- include/Nazara/Noise/NoiseBase.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Noise/NoiseBase.hpp b/include/Nazara/Noise/NoiseBase.hpp index 744070e26..cdf068083 100644 --- a/include/Nazara/Noise/NoiseBase.hpp +++ b/include/Nazara/Noise/NoiseBase.hpp @@ -40,7 +40,7 @@ namespace Nz static std::array s_gradients4; private: - std::default_random_engine m_randomEngine; + std::mt19937 m_randomEngine; }; } From 4df5ec776cc40a4872c5a353402aa0fe0b24a7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 8 Feb 2017 16:27:55 +0100 Subject: [PATCH 104/243] Sdk/Entity: Fix entity destruction not calling Component::OnDetached --- SDK/src/NDK/Entity.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index ce72aca62..d88556a31 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -158,11 +158,16 @@ namespace Ndk } m_systemBits.Clear(); - UnregisterAllHandles(); + // We properly destroy each component + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + m_components[i]->SetEntity(nullptr); m_components.clear(); m_componentBits.Reset(); + // And then free every handle + UnregisterAllHandles(); + m_valid = false; } From ab6e9d3b86eb5c3793541f12705622c6c61ad4fb Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Feb 2017 15:20:43 +0100 Subject: [PATCH 105/243] Core/String: Fix FormatVA bug --- src/Nazara/Core/String.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index a0bca5d64..7ea8c7df2 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -5102,10 +5102,14 @@ namespace Nz */ String String::FormatVA(const char* format, va_list args) { + // Copy va_list to use it twice + va_list args2; + va_copy(args2, args); + std::size_t length = std::vsnprintf(nullptr, 0, format, args); auto str = std::make_shared(length); - std::vsnprintf(str->string.get(), length + 1, format, args); + std::vsnprintf(str->string.get(), length + 1, format, args2); return String(std::move(str)); } From 212f3eddf00bef96944060520f803692767d0c29 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Feb 2017 02:10:37 +0100 Subject: [PATCH 106/243] Network/UdpSocket: Fix documentation [skip ci] --- src/Nazara/Network/UdpSocket.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Nazara/Network/UdpSocket.cpp b/src/Nazara/Network/UdpSocket.cpp index 145257afc..bc86f8401 100644 --- a/src/Nazara/Network/UdpSocket.cpp +++ b/src/Nazara/Network/UdpSocket.cpp @@ -17,6 +17,12 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::UdpSocket + * \brief Network class that represents a UDP socket, allowing for sending/receiving datagrams. + */ + /*! * \brief Binds a specific IpAddress * \return State of the socket From 414779b53c2f582b6307b3f9f8ac43917fdd4494 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Feb 2017 02:18:38 +0100 Subject: [PATCH 107/243] Network/ENetPacket: Remove unused flags --- include/Nazara/Network/ENetPacket.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Network/ENetPacket.hpp b/include/Nazara/Network/ENetPacket.hpp index 54a5d4676..5aecb0edd 100644 --- a/include/Nazara/Network/ENetPacket.hpp +++ b/include/Nazara/Network/ENetPacket.hpp @@ -14,18 +14,16 @@ namespace Nz { enum ENetPacketFlag { - ENetPacketFlag_NoAllocate, ENetPacketFlag_Reliable, ENetPacketFlag_Unsequenced, - ENetPacketFlag_UnreliableFragment, - ENetPacketFlag_Sent + ENetPacketFlag_UnreliableFragment }; template<> struct EnumAsFlags { static constexpr bool value = true; - static constexpr int max = ENetPacketFlag_Sent; + static constexpr int max = ENetPacketFlag_UnreliableFragment; }; using ENetPacketFlags = Flags; From 5655ff3fcf51de82a2cb8c9d984aed4d2956cd7a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Feb 2017 02:19:27 +0100 Subject: [PATCH 108/243] Network/ENetPacketFlags: Add Unreliable flag typedef for zero --- include/Nazara/Network/ENetPacket.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Network/ENetPacket.hpp b/include/Nazara/Network/ENetPacket.hpp index 5aecb0edd..54b0c42c6 100644 --- a/include/Nazara/Network/ENetPacket.hpp +++ b/include/Nazara/Network/ENetPacket.hpp @@ -28,6 +28,8 @@ namespace Nz using ENetPacketFlags = Flags; + constexpr ENetPacketFlags ENetPacketFlag_Unreliable = 0; + class MemoryPool; struct ENetPacket From 1904ce1576d914e1f265eb575c8a8d7b5ad9fb16 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Feb 2017 02:21:00 +0100 Subject: [PATCH 109/243] Network/ENetPeer: Fix fragmented packet handling --- src/Nazara/Network/ENetPeer.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 88b5568ff..6f0824af6 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -205,32 +205,24 @@ namespace Nz if (packetSize > fragmentLength) { UInt32 fragmentCount = (packetSize + fragmentLength - 1) / fragmentLength; - UInt32 fragmentNumber; - UInt32 fragmentOffset; - - UInt8 commandNumber; - UInt16 startSequenceNumber; - if (fragmentCount > ENetConstants::ENetProtocol_MaximumFragmentCount) return false; + UInt8 commandNumber; + UInt16 startSequenceNumber; if ((packetRef->flags & (ENetPacketFlag_Reliable | ENetPacketFlag_UnreliableFragment)) == ENetPacketFlag_UnreliableFragment && channel.outgoingUnreliableSequenceNumber < 0xFFFF) { commandNumber = ENetProtocolCommand_SendUnreliable; - startSequenceNumber = HostToNet(channel.outgoingUnreliableSequenceNumber + 1); + startSequenceNumber = HostToNet(channel.outgoingUnreliableSequenceNumber + 1); } else { commandNumber = ENetProtocolCommand_SendFragment | ENetProtocolFlag_Acknowledge; - startSequenceNumber = HostToNet(channel.outgoingReliableSequenceNumber + 1); + startSequenceNumber = HostToNet(channel.outgoingReliableSequenceNumber + 1); } - for (fragmentNumber = 0, - fragmentOffset = 0; - fragmentOffset < packetSize; - ++fragmentNumber, - fragmentOffset += fragmentLength) + for (UInt32 fragmentNumber = 0, fragmentOffset = 0; fragmentOffset < packetSize; ++fragmentNumber, fragmentOffset += fragmentLength) { if (packetSize - fragmentOffset < fragmentLength) fragmentLength = UInt16(packetSize - fragmentOffset); From 7cc11245f9e5916bc3e1ec42e6ced8c3cb31c1c9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 15 Feb 2017 07:13:00 +0100 Subject: [PATCH 110/243] Core/Flags: Move external operators to the global scope Fixes usage of those operators outside of the Nz namespace, global scoping is not an issue thanks to the enable_if --- include/Nazara/Core/Flags.hpp | 10 +-- include/Nazara/Core/Flags.inl | 115 +++++++++++++++++----------------- 2 files changed, 62 insertions(+), 63 deletions(-) diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index f356a04a5..cb336def6 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -54,13 +54,13 @@ namespace Nz private: BitField m_value; }; - - template constexpr std::enable_if_t::value, Flags> operator~(E lhs); - template constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs); - template constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs); - template constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs); } +template constexpr std::enable_if_t::value, Nz::Flags> operator~(E lhs); +template constexpr std::enable_if_t::value, Nz::Flags> operator|(E lhs, E rhs); +template constexpr std::enable_if_t::value, Nz::Flags> operator&(E lhs, E rhs); +template constexpr std::enable_if_t::value, Nz::Flags> operator^(E lhs, E rhs); + #include #endif // NAZARA_FLAGS_HPP diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 57ffd9e7e..973da958d 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -209,68 +209,67 @@ namespace Nz { return 1U << static_cast(enumValue); } +} +/*! +* \brief Override binary NOT operator on enum to turns into a Flags object. +* \return A Flags object with reversed bits. +* +* \param lhs Enumeration value to reverse. +* +* Returns a Flags object with all state enabled except for the enum one. +*/ +template +constexpr std::enable_if_t::value, Nz::Flags> operator~(E lhs) +{ + return ~Nz::Flags(lhs); +} - /*! - * \brief Override binary NOT operator on enum to turns into a Flags object. - * \return A Flags object with reversed bits. - * - * \param lhs Enumeration value to reverse. - * - * Returns a Flags object with all state enabled except for the enum one. - */ - template - constexpr std::enable_if_t::value, Flags> operator~(E lhs) - { - return ~Flags(lhs); - } +/*! +* \brief Override binary OR operator on enum to turns into a Flags object. +* \return A Flags object with combined enum states. +* +* \param lhs First enumeration value to combine. +* \param rhs Second enumeration value to combine. +* +* Returns a Flags object with combined states from the two enumeration values. +*/ +template +constexpr std::enable_if_t::value, Nz::Flags> operator|(E lhs, E rhs) +{ + return Nz::Flags(lhs) | rhs; +} - /*! - * \brief Override binary OR operator on enum to turns into a Flags object. - * \return A Flags object with combined enum states. - * - * \param lhs First enumeration value to combine. - * \param rhs Second enumeration value to combine. - * - * Returns a Flags object with combined states from the two enumeration values. - */ - template - constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs) - { - return Flags(lhs) | rhs; - } +/*! +* \brief Override binary AND operator on enum to turns into a Flags object. +* \return A Flags object with compare enum states. +* +* \param lhs First enumeration value to compare. +* \param rhs Second enumeration value to compare. +* +* Returns a Flags object with compared states from the two enumeration values. +* In this case, only one flag will be enabled if both enumeration values are the same. +*/ +template +constexpr std::enable_if_t::value, Nz::Flags> operator&(E lhs, E rhs) +{ + return Nz::Flags(lhs) & rhs; +} - /*! - * \brief Override binary AND operator on enum to turns into a Flags object. - * \return A Flags object with compare enum states. - * - * \param lhs First enumeration value to compare. - * \param rhs Second enumeration value to compare. - * - * Returns a Flags object with compared states from the two enumeration values. - * In this case, only one flag will be enabled if both enumeration values are the same. - */ - template - constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs) - { - return Flags(lhs) & rhs; - } - - /*! - * \brief Override binary XOR operator on enum to turns into a Flags object. - * \return A Flags object with XORed enum states. - * - * \param lhs First enumeration value to compare. - * \param rhs Second enumeration value to compare. - * - * Returns a Flags object with XORed states from the two enumeration values. - * In this case, two flags will be enabled if both the enumeration values are different. - */ - template - constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs) - { - return Flags(lhs) ^ rhs; - } +/*! +* \brief Override binary XOR operator on enum to turns into a Flags object. +* \return A Flags object with XORed enum states. +* +* \param lhs First enumeration value to compare. +* \param rhs Second enumeration value to compare. +* +* Returns a Flags object with XORed states from the two enumeration values. +* In this case, two flags will be enabled if both the enumeration values are different. +*/ +template +constexpr std::enable_if_t::value, Nz::Flags> operator^(E lhs, E rhs) +{ + return Nz::Flags(lhs) ^ rhs; } #include From 890b06bfcb796feb8bd8935a7f07fda205731c7a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 15 Feb 2017 08:26:56 +0100 Subject: [PATCH 111/243] Network/ENet: Refactor --- include/Nazara/Network/ENetPeer.hpp | 4 ++++ include/Nazara/Network/ENetPeer.inl | 20 ++++++++++++++++++++ src/Nazara/Network/ENetHost.cpp | 28 +++++++++++++++------------- src/Nazara/Network/ENetPeer.cpp | 2 +- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index e2b76c54a..2d11f17a0 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -50,6 +50,10 @@ namespace Nz void DisconnectNow(UInt32 data); inline const IpAddress& GetAddress() const; + inline UInt32 GetMtu() const; + inline UInt32 GetPacketThrottleAcceleration() const; + inline UInt32 GetPacketThrottleDeceleration() const; + inline UInt32 GetPacketThrottleInterval() const; inline UInt16 GetPeerId() const; inline ENetPeerState GetState() const; diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index 324a1fb80..fdac3ab4d 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -13,6 +13,26 @@ namespace Nz return m_address; } + inline UInt32 ENetPeer::GetMtu() const + { + return m_mtu; + } + + inline UInt32 ENetPeer::GetPacketThrottleAcceleration() const + { + return m_packetThrottleAcceleration; + } + + inline UInt32 ENetPeer::GetPacketThrottleDeceleration() const + { + return m_packetThrottleDeceleration; + } + + inline UInt32 ENetPeer::GetPacketThrottleInterval() const + { + return m_packetThrottleInterval; + } + inline UInt16 ENetPeer::GetPeerId() const { return m_incomingPeerID; diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index aff71c9c3..c4223653c 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -335,12 +335,12 @@ namespace Nz void ENetHost::AddToDispatchQueue(ENetPeer* peer) { - m_dispatchQueue.UnboundedSet(peer->m_incomingPeerID); + m_dispatchQueue.UnboundedSet(peer->GetPeerId()); } void ENetHost::RemoveFromDispatchQueue(ENetPeer* peer) { - m_dispatchQueue.UnboundedReset(peer->m_incomingPeerID); + m_dispatchQueue.UnboundedReset(peer->GetPeerId()); } bool ENetHost::DispatchIncomingCommands(ENetEvent* event) @@ -446,18 +446,20 @@ namespace Nz windowSize = Clamp(windowSize, ENetConstants::ENetProtocol_MinimumWindowSize, ENetConstants::ENetProtocol_MaximumWindowSize); ENetProtocol verifyCommand(ENetProtocolCommand_VerifyConnect | ENetProtocolFlag_Acknowledge, 0xFF); - verifyCommand.verifyConnect.outgoingPeerID = HostToNet(peer->m_incomingPeerID); + verifyCommand.verifyConnect.connectID = peer->m_connectID; verifyCommand.verifyConnect.incomingSessionID = peer->m_outgoingSessionID; verifyCommand.verifyConnect.outgoingSessionID = peer->m_incomingSessionID; - verifyCommand.verifyConnect.mtu = HostToNet(peer->m_mtu); - verifyCommand.verifyConnect.windowSize = HostToNet(windowSize); + verifyCommand.verifyConnect.channelCount = HostToNet(channelCount); verifyCommand.verifyConnect.incomingBandwidth = HostToNet(m_incomingBandwidth); + verifyCommand.verifyConnect.mtu = HostToNet(peer->GetMtu()); verifyCommand.verifyConnect.outgoingBandwidth = HostToNet(m_outgoingBandwidth); - verifyCommand.verifyConnect.packetThrottleInterval = HostToNet(peer->m_packetThrottleInterval); - verifyCommand.verifyConnect.packetThrottleAcceleration = HostToNet(peer->m_packetThrottleAcceleration); - verifyCommand.verifyConnect.packetThrottleDeceleration = HostToNet(peer->m_packetThrottleDeceleration); - verifyCommand.verifyConnect.connectID = peer->m_connectID; + verifyCommand.verifyConnect.outgoingPeerID = HostToNet(peer->GetPeerId()); + verifyCommand.verifyConnect.packetThrottleAcceleration = HostToNet(peer->GetPacketThrottleAcceleration()); + verifyCommand.verifyConnect.packetThrottleDeceleration = HostToNet(peer->GetPacketThrottleDeceleration()); + verifyCommand.verifyConnect.packetThrottleInterval = HostToNet(peer->GetPacketThrottleInterval()); + verifyCommand.verifyConnect.windowSize = HostToNet(windowSize); + peer->QueueOutgoingCommand(verifyCommand); return peer; @@ -475,7 +477,7 @@ namespace Nz UInt16 flags = peerID & ENetProtocolHeaderFlag_Mask; peerID &= ~(ENetProtocolHeaderFlag_Mask | ENetProtocolHeaderSessionMask); - std::size_t headerSize = (flags & ENetProtocolHeaderFlag_SentTime ? sizeof(ENetProtocolHeader) : (size_t) & ((ENetProtocolHeader *)0)->sentTime); + std::size_t headerSize = (flags & ENetProtocolHeaderFlag_SentTime) ? sizeof(ENetProtocolHeader) : NazaraOffsetOf(ENetProtocolHeader, sentTime); ENetPeer* peer; if (peerID == ENetConstants::ENetProtocol_MaximumPeerId) @@ -491,7 +493,7 @@ namespace Nz if (peer->GetState() == ENetPeerState::Disconnected || peer->GetState() == ENetPeerState::Zombie) return false; - if (m_receivedAddress != peer->m_address && peer->m_address != IpAddress::BroadcastIpV4) + if (m_receivedAddress != peer->GetAddress() && peer->GetAddress() != IpAddress::BroadcastIpV4) return false; if (peer->m_outgoingPeerID < ENetConstants::ENetProtocol_MaximumPeerId && sessionID != peer->m_incomingSessionID) @@ -771,7 +773,7 @@ namespace Nz auto currentAcknowledgement = peer->m_acknowledgements.begin(); while (currentAcknowledgement != peer->m_acknowledgements.end()) { - if (m_commandCount >= m_commands.size() || m_bufferCount >= m_buffers.size() || peer->m_mtu - m_packetSize < sizeof(ENetProtocolAcknowledge)) + if (m_commandCount >= m_commands.size() || m_bufferCount >= m_buffers.size() || peer->GetMtu() - m_packetSize < sizeof(ENetProtocolAcknowledge)) { m_continueSending = true; break; @@ -1013,7 +1015,7 @@ namespace Nz currentPeer->m_lastSendTime = m_serviceTime; std::size_t sentLength; - if (!m_socket.SendMultiple(currentPeer->m_address, m_buffers.data(), m_bufferCount, &sentLength)) + if (!m_socket.SendMultiple(currentPeer->GetAddress(), m_buffers.data(), m_bufferCount, &sentLength)) return -1; currentPeer->RemoveSentUnreliableCommands(); diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 6f0824af6..0408e6c50 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -845,7 +845,7 @@ namespace Nz if (!IsConnected()) return false; - m_packetThrottleInterval = NetToHost(command->throttleConfigure.packetThrottleInterval); + m_packetThrottleInterval = NetToHost(command->throttleConfigure.packetThrottleInterval); m_packetThrottleAcceleration = NetToHost(command->throttleConfigure.packetThrottleAcceleration); m_packetThrottleDeceleration = NetToHost(command->throttleConfigure.packetThrottleDeceleration); From 8225ad3b41708724bbfbce62a62943698e6e8c75 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 15 Feb 2017 08:27:15 +0100 Subject: [PATCH 112/243] Network/ENetHost: Optimize acknowledgements handling --- include/Nazara/Network/ENetPeer.hpp | 2 +- src/Nazara/Network/ENetHost.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 2d11f17a0..a9f2a0219 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -178,13 +178,13 @@ namespace Nz ENetHost* m_host; IpAddress m_address; /**< Internet address of the peer */ std::array m_unsequencedWindow; - std::list m_acknowledgements; std::list m_dispatchedCommands; std::list m_outgoingReliableCommands; std::list m_outgoingUnreliableCommands; std::list m_sentReliableCommands; std::list m_sentUnreliableCommands; std::size_t m_totalWaitingData; + std::vector m_acknowledgements; std::vector m_channels; MemoryPool m_packetPool; ENetPeerState m_state; diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index c4223653c..6f6c740ad 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -770,8 +770,8 @@ namespace Nz void ENetHost::SendAcknowledgements(ENetPeer* peer) { - auto currentAcknowledgement = peer->m_acknowledgements.begin(); - while (currentAcknowledgement != peer->m_acknowledgements.end()) + auto it = peer->m_acknowledgements.begin(); + for (; it != peer->m_acknowledgements.end(); ++it) { if (m_commandCount >= m_commands.size() || m_bufferCount >= m_buffers.size() || peer->GetMtu() - m_packetSize < sizeof(ENetProtocolAcknowledge)) { @@ -779,7 +779,7 @@ namespace Nz break; } - ENetPeer::Acknowledgement& acknowledgement = *currentAcknowledgement; + ENetPeer::Acknowledgement& acknowledgement = *it; ENetProtocol& command = m_commands[m_commandCount]; NetBuffer& buffer = m_buffers[m_bufferCount]; @@ -800,11 +800,11 @@ namespace Nz if ((acknowledgement.command.header.command & ENetProtocolCommand_Mask) == ENetProtocolCommand_Disconnect) peer->DispatchState(ENetPeerState::Zombie); - currentAcknowledgement = peer->m_acknowledgements.erase(currentAcknowledgement); - ++m_bufferCount; ++m_commandCount; } + + peer->m_acknowledgements.erase(peer->m_acknowledgements.begin(), it); } bool ENetHost::SendReliableOutgoingCommands(ENetPeer* peer) From dee5986de5af8d1d31e3db897ed7dcd0e5e3d103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 16 Feb 2017 16:14:24 +0100 Subject: [PATCH 113/243] Network/NetPacket: Allow empty pointer for NetPacket creating (won't initialize memory) --- include/Nazara/Network/NetPacket.inl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Network/NetPacket.inl b/include/Nazara/Network/NetPacket.inl index 6d55831d4..eb68d1e53 100644 --- a/include/Nazara/Network/NetPacket.inl +++ b/include/Nazara/Network/NetPacket.inl @@ -155,7 +155,9 @@ namespace Nz { InitStream(HeaderSize + size, HeaderSize, OpenMode_ReadOnly); m_buffer->Resize(HeaderSize + size); - std::memcpy(m_buffer->GetBuffer() + HeaderSize, ptr, size); + + if (ptr) + std::memcpy(m_buffer->GetBuffer() + HeaderSize, ptr, size); m_netCode = netCode; } From 7b49b3dd0e342db9ac6e6b092779d70bbe09d57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 16 Feb 2017 16:14:40 +0100 Subject: [PATCH 114/243] Network/ENetPeer: Fix crash when handling fragment packets --- src/Nazara/Network/ENetPeer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 6f0824af6..c343e7913 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -651,12 +651,13 @@ namespace Nz } } - if (startCommand) + if (!startCommand) { ENetProtocol hostCommand = *command; hostCommand.header.reliableSequenceNumber = startSequenceNumber; - if (!QueueIncomingCommand(hostCommand, nullptr, totalLength, ENetPacketFlag_Reliable, fragmentCount)) + startCommand = QueueIncomingCommand(hostCommand, nullptr, totalLength, ENetPacketFlag_Reliable, fragmentCount); + if (!startCommand) return false; } From b7ee6d7b29e7466ce012523d70bf63164c8de55c Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 16 Feb 2017 23:26:00 +0100 Subject: [PATCH 115/243] Network/ENet: Move all packet allocation to host --- include/Nazara/Network/ENetHost.hpp | 3 +++ include/Nazara/Network/ENetHost.inl | 8 ++++++++ include/Nazara/Network/ENetPeer.hpp | 4 +--- include/Nazara/Network/ENetPeer.inl | 9 +++++++++ src/Nazara/Network/ENetHost.cpp | 21 ++++++++++++++------- src/Nazara/Network/ENetPeer.cpp | 21 ++------------------- 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 83e8fd147..b1304ab81 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -71,6 +71,9 @@ namespace Nz ENetHost& operator=(ENetHost&&) = default; private: + ENetPacketRef AllocatePacket(ENetPacketFlags flags); + inline ENetPacketRef AllocatePacket(ENetPacketFlags flags, NetPacket&& data); + bool InitSocket(const IpAddress& address); void AddToDispatchQueue(ENetPeer* peer); diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl index 8aa722771..9a70d9b78 100644 --- a/include/Nazara/Network/ENetHost.inl +++ b/include/Nazara/Network/ENetHost.inl @@ -56,6 +56,14 @@ namespace Nz { return m_serviceTime; } + + inline ENetPacketRef ENetHost::AllocatePacket(ENetPacketFlags flags, NetPacket&& data) + { + ENetPacketRef ref = AllocatePacket(flags); + ref->data = std::move(data); + + return ref; + } } #include diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index a9f2a0219..19144c2f2 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,7 @@ namespace Nz friend struct PacketRef; public: - ENetPeer(ENetHost* host, UInt16 peerId); + inline ENetPeer(ENetHost* host, UInt16 peerId); ENetPeer(const ENetPeer&) = delete; ENetPeer(ENetPeer&&) = default; ~ENetPeer() = default; @@ -186,7 +185,6 @@ namespace Nz std::size_t m_totalWaitingData; std::vector m_acknowledgements; std::vector m_channels; - MemoryPool m_packetPool; ENetPeerState m_state; UInt8 m_incomingSessionID; UInt8 m_outgoingSessionID; diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index fdac3ab4d..e9c15fe35 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -8,6 +8,15 @@ namespace Nz { + inline ENetPeer::ENetPeer(ENetHost* host, UInt16 peerId) : + m_host(host), + m_incomingSessionID(0xFF), + m_outgoingSessionID(0xFF), + m_incomingPeerID(peerId) + { + Reset(); + } + inline const IpAddress& ENetPeer::GetAddress() const { return m_address; diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 6f6c740ad..76c81eb38 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -45,10 +45,7 @@ namespace Nz void ENetHost::Broadcast(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet) { - ENetPacketRef enetPacket = m_packetPool.New(); - enetPacket->flags = flags; - enetPacket->data = std::move(packet); - enetPacket->owner = &m_packetPool; + ENetPacketRef enetPacket = AllocatePacket(flags, std::move(packet)); for (ENetPeer& peer : m_peers) { @@ -309,6 +306,15 @@ namespace Nz } } + ENetPacketRef ENetHost::AllocatePacket(ENetPacketFlags flags) + { + ENetPacketRef enetPacket = m_packetPool.New(); + enetPacket->flags = flags; + enetPacket->owner = &m_packetPool; + + return enetPacket; + } + bool ENetHost::InitSocket(const IpAddress& address) { if (!m_socket.Create(address.GetProtocol())) @@ -841,7 +847,7 @@ namespace Nz { UInt32 windowSize = (peer->m_packetThrottle * peer->m_windowSize) / ENetPeer_PacketThrottleScale; - if (peer->m_reliableDataInTransit + outgoingCommand->fragmentLength > std::max(windowSize, peer->m_mtu)) + if (peer->m_reliableDataInTransit + outgoingCommand->fragmentLength > std::max(windowSize, peer->GetMtu())) windowExceeded = true; } @@ -855,8 +861,8 @@ namespace Nz canPing = false; std::size_t commandSize = s_commandSizes[outgoingCommand->command.header.command & ENetProtocolCommand_Mask]; - if (m_commandCount >= m_commands.size() || m_bufferCount + 1 >= m_buffers.size() || peer->m_mtu - m_packetSize < commandSize || - (outgoingCommand->packet && UInt16(peer->m_mtu - m_packetSize) < UInt16(commandSize + outgoingCommand->fragmentLength))) + if (m_commandCount >= m_commands.size() || m_bufferCount + 1 >= m_buffers.size() || peer->GetMtu() - m_packetSize < commandSize || + (outgoingCommand->packet && UInt16(peer->GetMtu() - m_packetSize) < UInt16(commandSize + outgoingCommand->fragmentLength))) { m_continueSending = true; break; @@ -1092,6 +1098,7 @@ namespace Nz m_packetSize += packetBuffer.dataLength; + // In order to keep the packet buffer alive until we send it, place it into a temporary queue peer->m_sentUnreliableCommands.emplace_back(std::move(*outgoingCommand)); } diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 0408e6c50..3bdfb7537 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -20,16 +20,6 @@ namespace Nz { - ENetPeer::ENetPeer(ENetHost* host, UInt16 peerId) : - m_host(host), - m_packetPool(sizeof(ENetPacket)), - m_incomingSessionID(0xFF), - m_outgoingSessionID(0xFF), - m_incomingPeerID(peerId) - { - Reset(); - } - void ENetPeer::Disconnect(UInt32 data) { if (m_state == ENetPeerState::Disconnecting || @@ -184,12 +174,7 @@ namespace Nz bool ENetPeer::Send(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet) { - ENetPacket* enetPacket = m_packetPool.New(); - enetPacket->flags = flags; - enetPacket->data = std::move(packet); - enetPacket->owner = &m_packetPool; - - return Send(channelId, enetPacket); + return Send(channelId, m_host->AllocatePacket(flags, std::move(packet)); } bool ENetPeer::Send(UInt8 channelId, ENetPacketRef packetRef) @@ -1214,10 +1199,8 @@ namespace Nz if (m_totalWaitingData >= m_host->m_maximumWaitingData) return nullptr; - ENetPacket* packet = m_packetPool.New(); - packet->flags = flags; + ENetPacketRef packet = m_host->AllocatePacket(flags); packet->data.Reset(0, data, dataLength); - packet->owner = &m_packetPool; IncomingCommmand incomingCommand; incomingCommand.reliableSequenceNumber = command.header.reliableSequenceNumber; From e0dca1b043a8af9d08248456877205936a2178e7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 16 Feb 2017 23:26:28 +0100 Subject: [PATCH 116/243] Network/ENetPeer: Optimize CheckTimeouts function --- src/Nazara/Network/ENetPeer.cpp | 35 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 3bdfb7537..d9ca262cb 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -271,39 +271,38 @@ namespace Nz bool ENetPeer::CheckTimeouts(ENetEvent* event) { UInt32 serviceTime = m_host->GetServiceTime(); + bool timedOut = false; - auto currentCommand = m_sentReliableCommands.begin(); - while (currentCommand != m_sentReliableCommands.end()) + auto it = m_sentReliableCommands.begin(); + for (; it != m_sentReliableCommands.end(); ++it) { - auto outgoingCommand = currentCommand; + OutgoingCommand& command = *it; - ++currentCommand; - - if (ENetTimeDifference(serviceTime, outgoingCommand->sentTime) < outgoingCommand->roundTripTimeout) + if (ENetTimeDifference(serviceTime, command.sentTime) < command.roundTripTimeout) continue; - if (m_earliestTimeout == 0 || ENetTimeLess(outgoingCommand->sentTime, m_earliestTimeout)) - m_earliestTimeout = outgoingCommand->sentTime; + if (m_earliestTimeout == 0 || ENetTimeLess(command.sentTime, m_earliestTimeout)) + m_earliestTimeout = command.sentTime; if (m_earliestTimeout != 0 && (ENetTimeDifference(serviceTime, m_earliestTimeout) >= m_timeoutMaximum || - (outgoingCommand->roundTripTimeout >= outgoingCommand->roundTripTimeoutLimit && ENetTimeDifference(serviceTime, m_earliestTimeout) >= m_timeoutMinimum))) + (command.roundTripTimeout >= command.roundTripTimeoutLimit && ENetTimeDifference(serviceTime, m_earliestTimeout) >= m_timeoutMinimum))) { m_host->NotifyDisconnect(this, event); - return true; + timedOut = true; + break; } - if (outgoingCommand->packet) - m_reliableDataInTransit -= outgoingCommand->fragmentLength; + if (command.packet) + m_reliableDataInTransit -= command.fragmentLength; ++m_packetsLost; ++m_totalPacketLost; // http://lists.cubik.org/pipermail/enet-discuss/2014-May/002308.html - outgoingCommand->roundTripTimeout = m_roundTripTime + 4 * m_roundTripTimeVariance; - outgoingCommand->roundTripTimeoutLimit = m_timeoutLimit * outgoingCommand->roundTripTimeout; + command.roundTripTimeout = m_roundTripTime + 4 * m_roundTripTimeVariance; + command.roundTripTimeoutLimit = m_timeoutLimit * command.roundTripTimeout; - m_outgoingReliableCommands.emplace_front(std::move(*outgoingCommand)); - m_sentReliableCommands.erase(outgoingCommand); + m_outgoingReliableCommands.emplace_front(std::move(command)); // Okay this should just never procs, I don't see how it would be possible /*if (currentCommand == enet_list_begin(&peer->sentReliableCommands) && @@ -315,7 +314,9 @@ namespace Nz }*/ } - return false; + m_sentReliableCommands.erase(m_sentReliableCommands.begin(), it); + + return timedOut; } void ENetPeer::DispatchState(ENetPeerState state) From 490f6becb21446bcfc9732c5727409d30a7f6511 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 16 Feb 2017 23:37:28 +0100 Subject: [PATCH 117/243] Fix compilation... That parenthesis probably didn't make it to GitHub, damn you packet losses! --- src/Nazara/Network/ENetPeer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 94e223ae9..9e7b3802d 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -174,7 +174,7 @@ namespace Nz bool ENetPeer::Send(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet) { - return Send(channelId, m_host->AllocatePacket(flags, std::move(packet)); + return Send(channelId, m_host->AllocatePacket(flags, std::move(packet))); } bool ENetPeer::Send(UInt8 channelId, ENetPacketRef packetRef) From dc158d06a8c8bcc591e19f174b011bf4a0ed1ef4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 17 Feb 2017 00:21:28 +0100 Subject: [PATCH 118/243] Fix warnings reported by Clang --- src/Nazara/Graphics/DepthRenderTechnique.cpp | 2 +- .../Graphics/ForwardRenderTechnique.cpp | 2 - src/Nazara/Graphics/ParticleGroup.cpp | 8 ++-- src/Nazara/Utility/Image.cpp | 1 - src/Nazara/Utility/IndexBuffer.cpp | 4 +- src/Nazara/Utility/SimpleTextDrawer.cpp | 4 +- src/Nazara/Utility/VertexBuffer.cpp | 4 +- src/Nazara/Utility/X11/CursorImpl.cpp | 40 ++++++++++--------- src/Nazara/Utility/X11/Display.cpp | 6 +-- src/Nazara/Utility/X11/WindowImpl.cpp | 6 +-- src/Nazara/Utility/X11/WindowImpl.hpp | 1 - 11 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index d58975d7f..13f8b30af 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -68,7 +68,7 @@ namespace Nz * \param sceneData Data of the scene */ - void DepthRenderTechnique::Clear(const SceneData& sceneData) const + void DepthRenderTechnique::Clear(const SceneData& /*sceneData*/) const { Renderer::Enable(RendererParameter_DepthBuffer, true); Renderer::Enable(RendererParameter_DepthWrite, true); diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index c0493e74b..543587b3d 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -990,7 +990,6 @@ namespace Nz if (uniforms.locations.shadowMapping != -1) shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); - unsigned int textureUnit = Material::GetTextureUnit(static_cast(TextureMap_ShadowCube_1 + index)); if (light.shadowMap) { unsigned int textureUnitCube = Material::GetTextureUnit(static_cast(TextureMap_ShadowCube_1 + index)); @@ -1014,7 +1013,6 @@ namespace Nz if (uniforms.locations.shadowMapping != -1) shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); - unsigned int textureUnit = Material::GetTextureUnit(static_cast(TextureMap_Shadow2D_1 + index)); if (light.shadowMap) { unsigned int textureUnit2D = Material::GetTextureUnit(static_cast(TextureMap_Shadow2D_1 + index)); diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index 08743a58e..ab9f6568c 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -40,9 +40,9 @@ namespace Nz ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : m_declaration(std::move(declaration)), - m_processing(false), m_maxParticleCount(maxParticleCount), - m_particleCount(0) + m_particleCount(0), + m_processing(false) { // In case of error, the constructor can only throw an exception ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -64,10 +64,10 @@ namespace Nz m_generators(system.m_generators), m_declaration(system.m_declaration), m_renderer(system.m_renderer), - m_processing(false), m_maxParticleCount(system.m_maxParticleCount), m_particleCount(system.m_particleCount), - m_particleSize(system.m_particleSize) + m_particleSize(system.m_particleSize), + m_processing(false) { ErrorFlags flags(ErrorFlag_ThrowException, true); diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index bdfe57007..15d9133fe 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -835,7 +835,6 @@ namespace Nz if (!PixelFormat::IsCompressed(m_sharedImage->format)) { const PixelFormatInfo& info = PixelFormat::GetInfo(m_sharedImage->format); - const UInt8* pixel = GetConstPixels(); Bitset<> workingBitset; std::size_t pixelCount = m_sharedImage->width * m_sharedImage->height * ((m_sharedImage->type == ImageType_Cubemap) ? 6 : m_sharedImage->depth); diff --git a/src/Nazara/Utility/IndexBuffer.cpp b/src/Nazara/Utility/IndexBuffer.cpp index ed49535cd..306fffb7f 100644 --- a/src/Nazara/Utility/IndexBuffer.cpp +++ b/src/Nazara/Utility/IndexBuffer.cpp @@ -35,10 +35,10 @@ namespace Nz IndexBuffer::IndexBuffer(const IndexBuffer& indexBuffer) : RefCounted(), m_buffer(indexBuffer.m_buffer), - m_largeIndices(indexBuffer.m_largeIndices), m_endOffset(indexBuffer.m_endOffset), m_indexCount(indexBuffer.m_indexCount), - m_startOffset(indexBuffer.m_startOffset) + m_startOffset(indexBuffer.m_startOffset), + m_largeIndices(indexBuffer.m_largeIndices) { } diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 1b8c41653..fb153185c 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -365,12 +365,14 @@ namespace Nz { case '\n': { + // Extend the line bounding rect to the last glyph it contains, thus extending upon all glyphs of the line if (!m_glyphs.empty()) { - Glyph& glyph = m_glyphs.back(); + Glyph& lastGlyph = m_glyphs.back(); m_lines.back().bounds.ExtendTo(glyph.bounds); } + // Reset cursor advance = 0; m_drawPos.x = 0; m_drawPos.y += sizeInfo.lineHeight; diff --git a/src/Nazara/Utility/VertexBuffer.cpp b/src/Nazara/Utility/VertexBuffer.cpp index 371ba2efa..f06d46ed0 100644 --- a/src/Nazara/Utility/VertexBuffer.cpp +++ b/src/Nazara/Utility/VertexBuffer.cpp @@ -31,10 +31,10 @@ namespace Nz VertexBuffer::VertexBuffer(const VertexBuffer& vertexBuffer) : RefCounted(), m_buffer(vertexBuffer.m_buffer), - m_vertexDeclaration(vertexBuffer.m_vertexDeclaration), m_endOffset(vertexBuffer.m_endOffset), m_startOffset(vertexBuffer.m_startOffset), - m_vertexCount(vertexBuffer.m_vertexCount) + m_vertexCount(vertexBuffer.m_vertexCount), + m_vertexDeclaration(vertexBuffer.m_vertexDeclaration) { } diff --git a/src/Nazara/Utility/X11/CursorImpl.cpp b/src/Nazara/Utility/X11/CursorImpl.cpp index 2925b2b6d..94f10629e 100644 --- a/src/Nazara/Utility/X11/CursorImpl.cpp +++ b/src/Nazara/Utility/X11/CursorImpl.cpp @@ -232,25 +232,27 @@ namespace Nz std::array CursorImpl::s_systemCursorIds = { - // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 - "crosshair", // SystemCursor_Crosshair - "left_ptr", // SystemCursor_Default - "hand", // SystemCursor_Hand - "help", // SystemCursor_Help - "fleur", // SystemCursor_Move - nullptr, // SystemCursor_None - "hand", // SystemCursor_Pointer - "watch", // SystemCursor_Progress - "right_side", // SystemCursor_ResizeE - "top_side", // SystemCursor_ResizeN - "top_right_corner", // SystemCursor_ResizeNE - "top_left_corner", // SystemCursor_ResizeNW - "bottom_side", // SystemCursor_ResizeS - "bottom_right_corner", // SystemCursor_ResizeSE - "bottom_left_corner", // SystemCursor_ResizeSW - "left_side", // SystemCursor_ResizeW - "xterm", // SystemCursor_Text - "watch" // SystemCursor_Wait + { + // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 + "crosshair", // SystemCursor_Crosshair + "left_ptr", // SystemCursor_Default + "hand", // SystemCursor_Hand + "help", // SystemCursor_Help + "fleur", // SystemCursor_Move + nullptr, // SystemCursor_None + "hand", // SystemCursor_Pointer + "watch", // SystemCursor_Progress + "right_side", // SystemCursor_ResizeE + "top_side", // SystemCursor_ResizeN + "top_right_corner", // SystemCursor_ResizeNE + "top_left_corner", // SystemCursor_ResizeNW + "bottom_side", // SystemCursor_ResizeS + "bottom_right_corner", // SystemCursor_ResizeSE + "bottom_left_corner", // SystemCursor_ResizeSW + "left_side", // SystemCursor_ResizeW + "xterm", // SystemCursor_Text + "watch" // SystemCursor_Wait + } }; static_assert(SystemCursor_Max + 1 == 18, "System cursor array is incomplete"); diff --git a/src/Nazara/Utility/X11/Display.cpp b/src/Nazara/Utility/X11/Display.cpp index 8a9ff719c..1232cea64 100644 --- a/src/Nazara/Utility/X11/Display.cpp +++ b/src/Nazara/Utility/X11/Display.cpp @@ -229,14 +229,14 @@ namespace Nz return screen_nbr; } - xcb_screen_t* X11::XCBScreenOfDisplay(xcb_connection_t* connection, int screen_nbr) + xcb_screen_t* X11::XCBScreenOfDisplay(xcb_connection_t* connection, int screenIndex) { NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(connection)); - for (; iter.rem; --screen_nbr, xcb_screen_next (&iter)) + for (; iter.rem; --screenIndex, xcb_screen_next (&iter)) { - if (screen_nbr == 0) + if (screenIndex == 0) return iter.data; } diff --git a/src/Nazara/Utility/X11/WindowImpl.cpp b/src/Nazara/Utility/X11/WindowImpl.cpp index d0cf3da59..884244287 100644 --- a/src/Nazara/Utility/X11/WindowImpl.cpp +++ b/src/Nazara/Utility/X11/WindowImpl.cpp @@ -58,7 +58,6 @@ namespace Nz m_style(0), m_parent(parent), m_smoothScrolling(false), - m_scrolling(0), m_mousePos(0, 0), m_keyRepeat(true) { @@ -1134,7 +1133,6 @@ namespace Nz // if (std::isprint(codePoint)) Is not working ? + handle combining ? { - WindowEvent event; event.type = Nz::WindowEventType_TextEntered; event.text.character = codePoint; event.text.repeated = false; @@ -1396,7 +1394,7 @@ namespace Nz hints.functions |= MWM_FUNC_CLOSE; } - ScopedXCB error(xcb_request_check( + ScopedXCB propertyError(xcb_request_check( connection, xcb_change_property_checked( connection, @@ -1410,7 +1408,7 @@ namespace Nz ) )); - if (error) + if (propertyError) NazaraError("xcb_change_property failed, could not set window hints"); } else diff --git a/src/Nazara/Utility/X11/WindowImpl.hpp b/src/Nazara/Utility/X11/WindowImpl.hpp index 8ce44f178..d82ff06cc 100644 --- a/src/Nazara/Utility/X11/WindowImpl.hpp +++ b/src/Nazara/Utility/X11/WindowImpl.hpp @@ -111,7 +111,6 @@ namespace Nz bool m_ownsWindow; bool m_smoothScrolling; bool m_threadActive; - short m_scrolling; Vector2i m_mousePos; bool m_keyRepeat; From a4100d5b4e210f70a105d5cd728584e9f6014f9f Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 17 Feb 2017 00:21:40 +0100 Subject: [PATCH 119/243] Utility/X11: Fix crash at startup --- src/Nazara/Utility/X11/CursorImpl.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/X11/CursorImpl.cpp b/src/Nazara/Utility/X11/CursorImpl.cpp index 94f10629e..aa59290b3 100644 --- a/src/Nazara/Utility/X11/CursorImpl.cpp +++ b/src/Nazara/Utility/X11/CursorImpl.cpp @@ -164,8 +164,19 @@ namespace Nz ScopedXCBConnection connection; xcb_screen_t* screen = X11::XCBDefaultScreen(connection); - if (xcb_cursor_context_new(connection, screen, &m_cursorContext) >= 0) - m_cursor = xcb_cursor_load_cursor(m_cursorContext, s_systemCursorIds[cursor]); + const char* cursorName = s_systemCursorIds[cursor]; + if (cursorName) + { + if (xcb_cursor_context_new(connection, screen, &m_cursorContext) >= 0) + m_cursor = xcb_cursor_load_cursor(m_cursorContext, cursorName); + else + { + NazaraError("Failed to create cursor context"); + return false; + } + } + else + m_cursor = s_hiddenCursor; return true; } From ee9712fdcdf41fa9a10868bf4f151497ceb16a3d Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 17 Feb 2017 00:38:44 +0100 Subject: [PATCH 120/243] Some more warning fixes --- src/Nazara/Renderer/RenderTexture.cpp | 20 +++++++++---------- .../Renderer/UberShaderPreprocessor.cpp | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index aa32dd447..8ae1a4bb1 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -36,7 +36,7 @@ namespace Nz unsigned int width; }; - unsigned int attachmentIndex[AttachmentPoint_Max+1] = + unsigned int s_attachmentIndex[AttachmentPoint_Max+1] = { 3, // AttachmentPoint_Color 0, // AttachmentPoint_Depth @@ -117,7 +117,7 @@ namespace Nz return false; } - unsigned int depthStencilIndex = attachmentIndex[AttachmentPoint_DepthStencil]; + unsigned int depthStencilIndex = s_attachmentIndex[AttachmentPoint_DepthStencil]; if (m_impl->attachments.size() > depthStencilIndex && m_impl->attachments[depthStencilIndex].isUsed) { if (attachmentPoint == AttachmentPoint_Depth) @@ -154,7 +154,7 @@ namespace Nz Unlock(); - unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; + unsigned int attachIndex = s_attachmentIndex[attachmentPoint] + index; if (attachIndex >= m_impl->attachments.size()) m_impl->attachments.resize(attachIndex+1); @@ -223,7 +223,7 @@ namespace Nz return false; } - unsigned int depthStencilIndex = attachmentIndex[AttachmentPoint_DepthStencil]; + unsigned int depthStencilIndex = s_attachmentIndex[AttachmentPoint_DepthStencil]; if (attachmentPoint == AttachmentPoint_Depth && m_impl->attachments.size() > depthStencilIndex && m_impl->attachments[depthStencilIndex].isUsed) { @@ -288,7 +288,7 @@ namespace Nz Unlock(); - unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; + unsigned int attachIndex = s_attachmentIndex[attachmentPoint] + index; if (attachIndex >= m_impl->attachments.size()) m_impl->attachments.resize(attachIndex+1); @@ -394,7 +394,7 @@ namespace Nz } #endif - unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; + unsigned int attachIndex = s_attachmentIndex[attachmentPoint] + index; if (attachIndex >= m_impl->attachments.size()) return; @@ -575,7 +575,7 @@ namespace Nz #if NAZARA_RENDERER_SAFE for (unsigned int i = 0; i < targetCount; ++i) { - unsigned int index = attachmentIndex[AttachmentPoint_Color] + targets[i]; + unsigned int index = s_attachmentIndex[AttachmentPoint_Color] + targets[i]; if (index >= m_impl->attachments.size() || !m_impl->attachments[index].isUsed) { NazaraError("Target " + String::Number(targets[i]) + " not attached"); @@ -598,7 +598,7 @@ namespace Nz #if NAZARA_RENDERER_SAFE for (UInt8 target : targets) { - unsigned int index = attachmentIndex[AttachmentPoint_Color] + target; + unsigned int index = s_attachmentIndex[AttachmentPoint_Color] + target; if (index >= m_impl->attachments.size() || !m_impl->attachments[index].isUsed) { NazaraError("Target " + String::Number(target) + " not attached"); @@ -752,7 +752,7 @@ namespace Nz for (UInt8 index : m_impl->colorTargets) { - Attachment& attachment = m_impl->attachments[attachmentIndex[AttachmentPoint_Color] + index]; + Attachment& attachment = m_impl->attachments[s_attachmentIndex[AttachmentPoint_Color] + index]; if (!attachment.isBuffer) attachment.texture->InvalidateMipmaps(); } @@ -833,7 +833,7 @@ namespace Nz m_impl->colorTargets.clear(); unsigned int colorIndex = 0; - for (unsigned int index = attachmentIndex[AttachmentPoint_Color]; index < m_impl->attachments.size(); ++index) + for (unsigned int index = s_attachmentIndex[AttachmentPoint_Color]; index < m_impl->attachments.size(); ++index) m_impl->colorTargets.push_back(colorIndex++); } diff --git a/src/Nazara/Renderer/UberShaderPreprocessor.cpp b/src/Nazara/Renderer/UberShaderPreprocessor.cpp index 6f838d6cf..b6d524645 100644 --- a/src/Nazara/Renderer/UberShaderPreprocessor.cpp +++ b/src/Nazara/Renderer/UberShaderPreprocessor.cpp @@ -93,7 +93,7 @@ namespace Nz } catch (const std::exception&) { - ErrorFlags errFlags(ErrorFlag_ThrowExceptionDisabled); + ErrorFlags errFlags2(ErrorFlag_ThrowExceptionDisabled); NazaraError("Shader code failed to compile (" + stage.GetLog() + ")\n" + code.ToString()); throw; From cc57fed42e0d4605c50f46a96de778d60db9a64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 17 Feb 2017 17:30:27 +0100 Subject: [PATCH 121/243] Network/ENetPeer: Fix crash --- src/Nazara/Network/ENetPeer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 9e7b3802d..e7a39e3e5 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -271,7 +271,6 @@ namespace Nz bool ENetPeer::CheckTimeouts(ENetEvent* event) { UInt32 serviceTime = m_host->GetServiceTime(); - bool timedOut = false; auto it = m_sentReliableCommands.begin(); for (; it != m_sentReliableCommands.end(); ++it) @@ -288,8 +287,7 @@ namespace Nz (command.roundTripTimeout >= command.roundTripTimeoutLimit && ENetTimeDifference(serviceTime, m_earliestTimeout) >= m_timeoutMinimum))) { m_host->NotifyDisconnect(this, event); - timedOut = true; - break; + return true; } if (command.packet) @@ -316,7 +314,7 @@ namespace Nz m_sentReliableCommands.erase(m_sentReliableCommands.begin(), it); - return timedOut; + return false; } void ENetPeer::DispatchState(ENetPeerState state) From c2e4ccaf72a96b0b5e0e2a76e72fddfa0af35634 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 19 Feb 2017 23:15:13 +0100 Subject: [PATCH 122/243] Various little fixes (#118) * Add missing override qualifier * Mostly shadowing, virtual destructor and other little things --- SDK/include/NDK/BaseWidget.inl | 2 +- .../NDK/Components/CameraComponent.inl | 1 + SDK/include/NDK/Widgets/ButtonWidget.hpp | 2 +- SDK/src/NDK/Lua/LuaBinding_SDK.cpp | 12 ++++----- include/Nazara/Audio/Music.hpp | 16 ++++++------ include/Nazara/Audio/Sound.hpp | 16 ++++++------ include/Nazara/Core/ByteStream.hpp | 2 +- include/Nazara/Core/Functor.hpp | 6 ++--- include/Nazara/Graphics/ColorBackground.hpp | 4 +-- include/Nazara/Graphics/DeferredBloomPass.hpp | 4 +-- include/Nazara/Graphics/DeferredDOFPass.hpp | 4 +-- include/Nazara/Graphics/DeferredFXAAPass.hpp | 2 +- include/Nazara/Graphics/DeferredFinalPass.hpp | 2 +- include/Nazara/Graphics/DeferredFogPass.hpp | 2 +- .../Nazara/Graphics/DeferredForwardPass.hpp | 4 +-- .../Nazara/Graphics/DeferredGeometryPass.hpp | 4 +-- .../Graphics/DeferredPhongLightingPass.hpp | 2 +- include/Nazara/Graphics/TextureBackground.hpp | 4 +-- include/Nazara/Noise/MixerBase.hpp | 2 +- include/Nazara/Noise/NoiseBase.hpp | 2 +- .../UberShaderInstancePreprocessor.hpp | 2 +- .../Renderer/UberShaderPreprocessor.hpp | 2 +- include/Nazara/Utility/EventHandler.inl | 3 ++- include/Nazara/Utility/Image.hpp | 26 +++++++++---------- include/Nazara/Utility/Joint.hpp | 2 +- include/Nazara/Utility/SkeletalMesh.hpp | 4 +-- include/Nazara/Utility/StaticMesh.hpp | 4 +-- plugins/Assimp/Plugin.cpp | 8 +++--- src/Nazara/Core/GuillotineBinPack.cpp | 6 ++--- src/Nazara/Core/MemoryManager.cpp | 4 +-- src/Nazara/Graphics/ParticleGroup.cpp | 8 +++--- src/Nazara/Renderer/TextureSampler.cpp | 8 +++--- src/Nazara/Utility/SimpleTextDrawer.cpp | 2 +- .../Utility/EventHandler/EventState.cpp | 4 +-- .../Engine/Utility/EventHandler/KeyState.cpp | 2 +- .../Utility/EventHandler/MouseClickState.cpp | 2 +- tests/Engine/Utility/EventHandler/Text.cpp | 2 +- tests/SDK/NDK/EntityList.cpp | 4 +-- 38 files changed, 94 insertions(+), 92 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 63b71a942..17592241f 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -10,8 +10,8 @@ namespace Ndk { inline BaseWidget::BaseWidget() : m_canvasIndex(InvalidCanvasIndex), - m_backgroundColor(Nz::Color(230, 230, 230, 255)), m_canvas(nullptr), + m_backgroundColor(Nz::Color(230, 230, 230, 255)), m_cursor(Nz::SystemCursor_Default), m_contentSize(50.f, 50.f), m_widgetParent(nullptr), diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index 0b445f1f3..33c63bfe3 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -39,6 +39,7 @@ namespace Ndk inline CameraComponent::CameraComponent(const CameraComponent& camera) : Component(camera), AbstractViewer(camera), + HandledObject(camera), m_visibilityHash(camera.m_visibilityHash), m_projectionType(camera.m_projectionType), m_targetRegion(camera.m_targetRegion), diff --git a/SDK/include/NDK/Widgets/ButtonWidget.hpp b/SDK/include/NDK/Widgets/ButtonWidget.hpp index d1f940e3f..78f978719 100644 --- a/SDK/include/NDK/Widgets/ButtonWidget.hpp +++ b/SDK/include/NDK/Widgets/ButtonWidget.hpp @@ -27,7 +27,7 @@ namespace Ndk //virtual ButtonWidget* Clone() const = 0; - void ResizeToContent(); + void ResizeToContent() override; inline void UpdateText(const Nz::AbstractTextDrawer& drawer); diff --git a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp index 0de791f85..4d8408282 100644 --- a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp @@ -96,23 +96,23 @@ namespace Ndk entity.BindMethod("AddComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int { - LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance); + LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(instance); - return binding->adder(instance, handle); + return bindingComponent->adder(instance, handle); }); entity.BindMethod("GetComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int { - LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance); + LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(instance); - return binding->getter(instance, handle->GetComponent(binding->index)); + return bindingComponent->getter(instance, handle->GetComponent(bindingComponent->index)); }); entity.BindMethod("RemoveComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int { - LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance); + LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(instance); - handle->RemoveComponent(binding->index); + handle->RemoveComponent(bindingComponent->index); return 0; }); } diff --git a/include/Nazara/Audio/Music.hpp b/include/Nazara/Audio/Music.hpp index 74d315d19..86ccc6906 100644 --- a/include/Nazara/Audio/Music.hpp +++ b/include/Nazara/Audio/Music.hpp @@ -43,27 +43,27 @@ namespace Nz bool Create(SoundStream* soundStream); void Destroy(); - void EnableLooping(bool loop); + void EnableLooping(bool loop) override; - UInt32 GetDuration() const; + UInt32 GetDuration() const override; AudioFormat GetFormat() const; - UInt32 GetPlayingOffset() const; + UInt32 GetPlayingOffset() const override; UInt64 GetSampleCount() const; UInt32 GetSampleRate() const; - SoundStatus GetStatus() const; + SoundStatus GetStatus() const override; - bool IsLooping() const; + bool IsLooping() const override; bool OpenFromFile(const String& filePath, const MusicParams& params = MusicParams()); bool OpenFromMemory(const void* data, std::size_t size, const MusicParams& params = MusicParams()); bool OpenFromStream(Stream& stream, const MusicParams& params = MusicParams()); - void Pause(); - void Play(); + void Pause() override; + void Play() override; void SetPlayingOffset(UInt32 offset); - void Stop(); + void Stop() override; Music& operator=(const Music&) = delete; Music& operator=(Music&&) = delete; ///TODO diff --git a/include/Nazara/Audio/Sound.hpp b/include/Nazara/Audio/Sound.hpp index c5083387f..114b177ab 100644 --- a/include/Nazara/Audio/Sound.hpp +++ b/include/Nazara/Audio/Sound.hpp @@ -23,14 +23,14 @@ namespace Nz Sound(Sound&&) = default; ~Sound(); - void EnableLooping(bool loop); + void EnableLooping(bool loop) override; const SoundBuffer* GetBuffer() const; - UInt32 GetDuration() const; - UInt32 GetPlayingOffset() const; - SoundStatus GetStatus() const; + UInt32 GetDuration() const override; + UInt32 GetPlayingOffset() const override; + SoundStatus GetStatus() const override; - bool IsLooping() const; + bool IsLooping() const override; bool IsPlayable() const; bool IsPlaying() const; @@ -38,13 +38,13 @@ namespace Nz bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams()); bool LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams()); - void Pause(); - void Play(); + void Pause() override; + void Play() override; void SetBuffer(const SoundBuffer* buffer); void SetPlayingOffset(UInt32 offset); - void Stop(); + void Stop() override; Sound& operator=(const Sound&) = delete; ///TODO? Sound& operator=(Sound&&) = default; diff --git a/include/Nazara/Core/ByteStream.hpp b/include/Nazara/Core/ByteStream.hpp index a49b08eff..eed461205 100644 --- a/include/Nazara/Core/ByteStream.hpp +++ b/include/Nazara/Core/ByteStream.hpp @@ -24,7 +24,7 @@ namespace Nz ByteStream(const void* ptr, Nz::UInt64 size); ByteStream(const ByteStream&) = delete; inline ByteStream(ByteStream&& stream); - ~ByteStream(); + virtual ~ByteStream(); inline Endianness GetDataEndianness() const; inline Nz::UInt64 GetSize() const; diff --git a/include/Nazara/Core/Functor.hpp b/include/Nazara/Core/Functor.hpp index b392cc591..17578474c 100644 --- a/include/Nazara/Core/Functor.hpp +++ b/include/Nazara/Core/Functor.hpp @@ -25,7 +25,7 @@ namespace Nz { FunctorWithoutArgs(F func); - void Run(); + void Run() override; private: F m_func; @@ -36,7 +36,7 @@ namespace Nz { FunctorWithArgs(F func, Args&&... args); - void Run(); + void Run() override; private: F m_func; @@ -48,7 +48,7 @@ namespace Nz { MemberWithoutArgs(void (C::*func)(), C* object); - void Run(); + void Run() override; private: void (C::*m_func)(); diff --git a/include/Nazara/Graphics/ColorBackground.hpp b/include/Nazara/Graphics/ColorBackground.hpp index 57de236f9..d76a92977 100644 --- a/include/Nazara/Graphics/ColorBackground.hpp +++ b/include/Nazara/Graphics/ColorBackground.hpp @@ -26,9 +26,9 @@ namespace Nz ColorBackground(const ColorBackground&) = default; ColorBackground(ColorBackground&&) = delete; - void Draw(const AbstractViewer* viewer) const; + void Draw(const AbstractViewer* viewer) const override; - BackgroundType GetBackgroundType() const; + BackgroundType GetBackgroundType() const override; Color GetColor() const; void SetColor(const Color& color); diff --git a/include/Nazara/Graphics/DeferredBloomPass.hpp b/include/Nazara/Graphics/DeferredBloomPass.hpp index 5246f45c2..c00cc3c4c 100644 --- a/include/Nazara/Graphics/DeferredBloomPass.hpp +++ b/include/Nazara/Graphics/DeferredBloomPass.hpp @@ -29,8 +29,8 @@ namespace Nz float GetBrightThreshold() const; Texture* GetTexture(unsigned int i) const; - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; - bool Resize(const Vector2ui& dimensions); + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const override; + bool Resize(const Vector2ui& dimensions) override; void SetBlurPassCount(unsigned int passCount); void SetBrightLuminance(float luminance); diff --git a/include/Nazara/Graphics/DeferredDOFPass.hpp b/include/Nazara/Graphics/DeferredDOFPass.hpp index 6a0b213da..b4025be7d 100644 --- a/include/Nazara/Graphics/DeferredDOFPass.hpp +++ b/include/Nazara/Graphics/DeferredDOFPass.hpp @@ -23,8 +23,8 @@ namespace Nz DeferredDOFPass(); virtual ~DeferredDOFPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; - bool Resize(const Vector2ui& dimensions); + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const override; + bool Resize(const Vector2ui& dimensions) override; protected: RenderTexture m_dofRTT; diff --git a/include/Nazara/Graphics/DeferredFXAAPass.hpp b/include/Nazara/Graphics/DeferredFXAAPass.hpp index 696450796..e8179f46d 100644 --- a/include/Nazara/Graphics/DeferredFXAAPass.hpp +++ b/include/Nazara/Graphics/DeferredFXAAPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFXAAPass(); virtual ~DeferredFXAAPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const override; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredFinalPass.hpp b/include/Nazara/Graphics/DeferredFinalPass.hpp index 52c7e8233..d99c8ed30 100644 --- a/include/Nazara/Graphics/DeferredFinalPass.hpp +++ b/include/Nazara/Graphics/DeferredFinalPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFinalPass(); virtual ~DeferredFinalPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const override; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredFogPass.hpp b/include/Nazara/Graphics/DeferredFogPass.hpp index 807f0752d..c1ccbdc88 100644 --- a/include/Nazara/Graphics/DeferredFogPass.hpp +++ b/include/Nazara/Graphics/DeferredFogPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFogPass(); virtual ~DeferredFogPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const override; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredForwardPass.hpp b/include/Nazara/Graphics/DeferredForwardPass.hpp index 5bf53f107..7fc619da2 100644 --- a/include/Nazara/Graphics/DeferredForwardPass.hpp +++ b/include/Nazara/Graphics/DeferredForwardPass.hpp @@ -20,8 +20,8 @@ namespace Nz DeferredForwardPass(); virtual ~DeferredForwardPass(); - void Initialize(DeferredRenderTechnique* technique); - bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const; + void Initialize(DeferredRenderTechnique* technique) override; + bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const override; protected: const ForwardRenderTechnique* m_forwardTechnique; diff --git a/include/Nazara/Graphics/DeferredGeometryPass.hpp b/include/Nazara/Graphics/DeferredGeometryPass.hpp index dcfa47f90..b390263b6 100644 --- a/include/Nazara/Graphics/DeferredGeometryPass.hpp +++ b/include/Nazara/Graphics/DeferredGeometryPass.hpp @@ -21,8 +21,8 @@ namespace Nz DeferredGeometryPass(); virtual ~DeferredGeometryPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; - bool Resize(const Vector2ui& dimensions); + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const override; + bool Resize(const Vector2ui& dimensions) override; protected: struct ShaderUniforms; diff --git a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp index 4b14900d7..cbff41041 100644 --- a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp +++ b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp @@ -28,7 +28,7 @@ namespace Nz bool IsLightMeshesDrawingEnabled() const; - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const override; protected: LightUniforms m_directionalLightUniforms; diff --git a/include/Nazara/Graphics/TextureBackground.hpp b/include/Nazara/Graphics/TextureBackground.hpp index 272bcc63f..bdb088812 100644 --- a/include/Nazara/Graphics/TextureBackground.hpp +++ b/include/Nazara/Graphics/TextureBackground.hpp @@ -24,9 +24,9 @@ namespace Nz public: TextureBackground(TextureRef texture = TextureRef()); - void Draw(const AbstractViewer* viewer) const; + void Draw(const AbstractViewer* viewer) const override; - BackgroundType GetBackgroundType() const; + BackgroundType GetBackgroundType() const override; inline const TextureRef& GetTexture() const; inline void SetTexture(TextureRef texture); diff --git a/include/Nazara/Noise/MixerBase.hpp b/include/Nazara/Noise/MixerBase.hpp index 61df26543..954932114 100644 --- a/include/Nazara/Noise/MixerBase.hpp +++ b/include/Nazara/Noise/MixerBase.hpp @@ -15,7 +15,7 @@ namespace Nz { public: MixerBase(); - ~MixerBase() = default; + virtual ~MixerBase() = default; virtual float Get(float x, float y, float scale) const = 0; virtual float Get(float x, float y, float z, float scale) const = 0; diff --git a/include/Nazara/Noise/NoiseBase.hpp b/include/Nazara/Noise/NoiseBase.hpp index cdf068083..dc57a6e40 100644 --- a/include/Nazara/Noise/NoiseBase.hpp +++ b/include/Nazara/Noise/NoiseBase.hpp @@ -19,7 +19,7 @@ namespace Nz { public: NoiseBase(unsigned int seed = 0); - ~NoiseBase() = default; + virtual ~NoiseBase() = default; virtual float Get(float x, float y, float scale) const = 0; virtual float Get(float x, float y, float z, float scale) const = 0; diff --git a/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp b/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp index 5f0a16900..ee44950a0 100644 --- a/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp +++ b/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp @@ -18,7 +18,7 @@ namespace Nz UberShaderInstancePreprocessor(const Shader* shader); virtual ~UberShaderInstancePreprocessor(); - bool Activate() const; + bool Activate() const override; }; } diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.hpp b/include/Nazara/Renderer/UberShaderPreprocessor.hpp index 6732fab23..710835ec2 100644 --- a/include/Nazara/Renderer/UberShaderPreprocessor.hpp +++ b/include/Nazara/Renderer/UberShaderPreprocessor.hpp @@ -29,7 +29,7 @@ namespace Nz UberShaderPreprocessor() = default; ~UberShaderPreprocessor(); - UberShaderInstance* Get(const ParameterList& parameters) const; + UberShaderInstance* Get(const ParameterList& parameters) const override; void SetShader(ShaderStageType stage, const String& source, const String& shaderFlags, const String& requiredFlags = String()); bool SetShaderFromFile(ShaderStageType stage, const String& filePath, const String& shaderFlags, const String& requiredFlags = String()); diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl index 4ba3f49bd..39191300d 100644 --- a/include/Nazara/Utility/EventHandler.inl +++ b/include/Nazara/Utility/EventHandler.inl @@ -8,7 +8,8 @@ namespace Nz { - inline EventHandler::EventHandler(const EventHandler&) + inline EventHandler::EventHandler(const EventHandler& other) : + HandledObject(other) { } diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index 4e5b094cc..cbae97f9a 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -78,18 +78,18 @@ namespace Nz bool FlipVertically(); const UInt8* GetConstPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, UInt8 level = 0) const; - unsigned int GetDepth(UInt8 level = 0) const; - PixelFormatType GetFormat() const; - unsigned int GetHeight(UInt8 level = 0) const; - UInt8 GetLevelCount() const; - UInt8 GetMaxLevel() const; - std::size_t GetMemoryUsage() const; - std::size_t GetMemoryUsage(UInt8 level) const; + unsigned int GetDepth(UInt8 level = 0) const override; + PixelFormatType GetFormat() const override; + unsigned int GetHeight(UInt8 level = 0) const override; + UInt8 GetLevelCount() const override; + UInt8 GetMaxLevel() const override; + std::size_t GetMemoryUsage() const override; + std::size_t GetMemoryUsage(UInt8 level) const override; Color GetPixelColor(unsigned int x, unsigned int y = 0, unsigned int z = 0) const; UInt8* GetPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, UInt8 level = 0); - Vector3ui GetSize(UInt8 level = 0) const; - ImageType GetType() const; - unsigned int GetWidth(UInt8 level = 0) const; + Vector3ui GetSize(UInt8 level = 0) const override; + ImageType GetType() const override; + unsigned int GetWidth(UInt8 level = 0) const override; bool HasAlpha() const; @@ -126,9 +126,9 @@ namespace Nz void SetLevelCount(UInt8 levelCount); bool SetPixelColor(const Color& color, unsigned int x, unsigned int y = 0, unsigned int z = 0); - bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0); - bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0); - bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0); + bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override; + bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override; + bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override; Image& operator=(const Image& image); diff --git a/include/Nazara/Utility/Joint.hpp b/include/Nazara/Utility/Joint.hpp index f82668986..fad4b3d22 100644 --- a/include/Nazara/Utility/Joint.hpp +++ b/include/Nazara/Utility/Joint.hpp @@ -35,7 +35,7 @@ namespace Nz void SetName(const String& name); private: - void InvalidateNode(); + void InvalidateNode() override; void UpdateSkinningMatrix() const; Matrix4f m_inverseBindMatrix; diff --git a/include/Nazara/Utility/SkeletalMesh.hpp b/include/Nazara/Utility/SkeletalMesh.hpp index 3efe704da..d67210c74 100644 --- a/include/Nazara/Utility/SkeletalMesh.hpp +++ b/include/Nazara/Utility/SkeletalMesh.hpp @@ -29,13 +29,13 @@ namespace Nz void Destroy(); const Boxf& GetAABB() const override; - AnimationType GetAnimationType() const final; + AnimationType GetAnimationType() const final override; const IndexBuffer* GetIndexBuffer() const override; VertexBuffer* GetVertexBuffer(); const VertexBuffer* GetVertexBuffer() const; unsigned int GetVertexCount() const override; - bool IsAnimated() const final; + bool IsAnimated() const final override; bool IsValid() const; void SetAABB(const Boxf& aabb); diff --git a/include/Nazara/Utility/StaticMesh.hpp b/include/Nazara/Utility/StaticMesh.hpp index 066bcee45..125af6301 100644 --- a/include/Nazara/Utility/StaticMesh.hpp +++ b/include/Nazara/Utility/StaticMesh.hpp @@ -32,13 +32,13 @@ namespace Nz bool GenerateAABB(); const Boxf& GetAABB() const override; - AnimationType GetAnimationType() const final; + AnimationType GetAnimationType() const final override; const IndexBuffer* GetIndexBuffer() const override; VertexBuffer* GetVertexBuffer(); const VertexBuffer* GetVertexBuffer() const; unsigned int GetVertexCount() const override; - bool IsAnimated() const final; + bool IsAnimated() const final override; bool IsValid() const; void SetAABB(const Boxf& aabb); diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index e65d460db..a5cdf3cbf 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -141,12 +141,12 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) { for (unsigned int i = 0; i < scene->mNumMeshes; ++i) { - aiMesh* mesh = scene->mMeshes[i]; - if (mesh->HasBones()) // Inline functions can be safely called + aiMesh* currentMesh = scene->mMeshes[i]; + if (currentMesh->HasBones()) // Inline functions can be safely called { animatedMesh = true; - for (unsigned int j = 0; j < mesh->mNumBones; ++j) - joints.insert(mesh->mBones[j]->mName.C_Str()); + for (unsigned int j = 0; j < currentMesh->mNumBones; ++j) + joints.insert(currentMesh->mBones[j]->mName.C_Str()); } } } diff --git a/src/Nazara/Core/GuillotineBinPack.cpp b/src/Nazara/Core/GuillotineBinPack.cpp index 0f74bab5b..85270a562 100644 --- a/src/Nazara/Core/GuillotineBinPack.cpp +++ b/src/Nazara/Core/GuillotineBinPack.cpp @@ -312,9 +312,9 @@ namespace Nz while (!remainingRects.empty()) { // Stores the penalty score of the best rectangle placement - bigger=worse, smaller=better. - bool bestFlipped; - std::size_t bestFreeRect; - std::size_t bestRect; + bool bestFlipped = false; + std::size_t bestFreeRect = m_freeRectangles.size(); + std::size_t bestRect = std::numeric_limits::min(); int bestScore = std::numeric_limits::max(); for (std::size_t i = 0; i < m_freeRectangles.size(); ++i) diff --git a/src/Nazara/Core/MemoryManager.cpp b/src/Nazara/Core/MemoryManager.cpp index 2c4034623..aaf6bc520 100644 --- a/src/Nazara/Core/MemoryManager.cpp +++ b/src/Nazara/Core/MemoryManager.cpp @@ -413,9 +413,9 @@ namespace Nz while (ptr != &s_list) { if (ptr->file) - std::fprintf(log, "-0x%p -> %zu bytes allocated at %s:%u\n", reinterpret_cast(ptr) + sizeof(Block), ptr->size, ptr->file, ptr->line); + std::fprintf(log, "-0x%s -> %zu bytes allocated at %s:%u\n", reinterpret_cast(ptr) + sizeof(Block), ptr->size, ptr->file, ptr->line); else - std::fprintf(log, "-0x%p -> %zu bytes allocated at unknown position\n", reinterpret_cast(ptr) + sizeof(Block), ptr->size); + std::fprintf(log, "-0x%s -> %zu bytes allocated at unknown position\n", reinterpret_cast(ptr) + sizeof(Block), ptr->size); void* pointer = ptr; ptr = ptr->next; diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index ab9f6568c..34a46089b 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -39,9 +39,9 @@ namespace Nz */ ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : - m_declaration(std::move(declaration)), m_maxParticleCount(maxParticleCount), m_particleCount(0), + m_declaration(std::move(declaration)), m_processing(false) { // In case of error, the constructor can only throw an exception @@ -60,13 +60,13 @@ namespace Nz ParticleGroup::ParticleGroup(const ParticleGroup& system) : Renderable(system), + m_maxParticleCount(system.m_maxParticleCount), + m_particleCount(system.m_particleCount), + m_particleSize(system.m_particleSize), m_controllers(system.m_controllers), m_generators(system.m_generators), m_declaration(system.m_declaration), m_renderer(system.m_renderer), - m_maxParticleCount(system.m_maxParticleCount), - m_particleCount(system.m_particleCount), - m_particleSize(system.m_particleSize), m_processing(false) { ErrorFlags flags(ErrorFlag_ThrowException, true); diff --git a/src/Nazara/Renderer/TextureSampler.cpp b/src/Nazara/Renderer/TextureSampler.cpp index ec3b25dd7..4f1f9233f 100644 --- a/src/Nazara/Renderer/TextureSampler.cpp +++ b/src/Nazara/Renderer/TextureSampler.cpp @@ -129,7 +129,7 @@ namespace Nz if (s_useAnisotropicFilter) { - for (const std::pair& pair : s_samplers) + for (const std::pair& pair : s_samplers) { if (((pair.first >> 5) & 0xFF) == 0) glSamplerParameterf(pair.second, GL_TEXTURE_MAX_ANISOTROPY_EXT, static_cast(anisotropyLevel)); @@ -149,7 +149,7 @@ namespace Nz s_defaultFilterMode = filterMode; - for (const std::pair& pair : s_samplers) + for (const std::pair& pair : s_samplers) { if (((pair.first >> 1) & 0x3) == SamplerFilter_Default) { @@ -204,7 +204,7 @@ namespace Nz s_defaultWrapMode = wrapMode; GLenum wrapEnum = OpenGL::SamplerWrapMode[wrapMode]; - for (const std::pair& pair : s_samplers) + for (const std::pair& pair : s_samplers) { if (((pair.first >> 3) & 0x3) == SamplerWrap_Default) { @@ -380,7 +380,7 @@ namespace Nz if (!s_samplers.empty()) { Context::EnsureContext(); - for (const std::pair& pair : s_samplers) + for (const std::pair& pair : s_samplers) OpenGL::DeleteSampler(pair.second); s_samplers.clear(); diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index fb153185c..d7a1bc713 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -369,7 +369,7 @@ namespace Nz if (!m_glyphs.empty()) { Glyph& lastGlyph = m_glyphs.back(); - m_lines.back().bounds.ExtendTo(glyph.bounds); + m_lines.back().bounds.ExtendTo(lastGlyph.bounds); } // Reset cursor diff --git a/tests/Engine/Utility/EventHandler/EventState.cpp b/tests/Engine/Utility/EventHandler/EventState.cpp index 4f74e3000..9fa5ea244 100644 --- a/tests/Engine/Utility/EventHandler/EventState.cpp +++ b/tests/Engine/Utility/EventHandler/EventState.cpp @@ -53,9 +53,9 @@ void EventState::AddEvent(const Nz::WindowEvent& event) m_events.push_back(Nz::String::Number(m_count) + " - " + ToString(event)); Nz::String content; - for (auto&& event : m_events) + for (auto&& currentEvent : m_events) { - content += event + "\n"; + content += currentEvent + "\n"; } content += "\nM for Menu"; m_text.SetContent(content, 36); diff --git a/tests/Engine/Utility/EventHandler/KeyState.cpp b/tests/Engine/Utility/EventHandler/KeyState.cpp index 043dc5837..6244e8ed6 100644 --- a/tests/Engine/Utility/EventHandler/KeyState.cpp +++ b/tests/Engine/Utility/EventHandler/KeyState.cpp @@ -46,7 +46,7 @@ void KeyState::DrawMenu() m_text.SetContent("Clic on a key, this text should change !\nN for alternating event\nM for Menu"); } -void KeyState::ManageInput(KeyStatus isKeyPressed, const Nz::WindowEvent::KeyEvent& key, Ndk::StateMachine& fsm) +void KeyState::ManageInput(KeyStatus /*isKeyPressed*/, const Nz::WindowEvent::KeyEvent& key, Ndk::StateMachine& fsm) { if (key.code == Nz::Keyboard::Key::M && key.shift) fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); diff --git a/tests/Engine/Utility/EventHandler/MouseClickState.cpp b/tests/Engine/Utility/EventHandler/MouseClickState.cpp index 1de923bd4..bc2627195 100644 --- a/tests/Engine/Utility/EventHandler/MouseClickState.cpp +++ b/tests/Engine/Utility/EventHandler/MouseClickState.cpp @@ -58,7 +58,7 @@ void MouseClickState::DrawMenu() m_text.SetContent("Click in the windows, this text should change !\nM for Menu"); } -void MouseClickState::ManageInput(MouseStatus mouseStatus, const Nz::WindowEvent::MouseButtonEvent& mouse, Ndk::StateMachine& fsm) +void MouseClickState::ManageInput(MouseStatus mouseStatus, const Nz::WindowEvent::MouseButtonEvent& mouse, Ndk::StateMachine& /*fsm*/) { Nz::String content; if (mouseStatus == MouseStatus::Pressed) diff --git a/tests/Engine/Utility/EventHandler/Text.cpp b/tests/Engine/Utility/EventHandler/Text.cpp index 75cece5b9..98637b276 100644 --- a/tests/Engine/Utility/EventHandler/Text.cpp +++ b/tests/Engine/Utility/EventHandler/Text.cpp @@ -11,7 +11,7 @@ Text::Text(StateContext& stateContext) : m_context(stateContext) { m_text = m_context.world.CreateEntity(); - Ndk::NodeComponent& nodeComponent = m_text->AddComponent(); + m_text->AddComponent(); Ndk::GraphicsComponent& graphicsComponent = m_text->AddComponent(); m_textSprite = Nz::TextSprite::New(); diff --git a/tests/SDK/NDK/EntityList.cpp b/tests/SDK/NDK/EntityList.cpp index 4b76766d5..30a57573d 100644 --- a/tests/SDK/NDK/EntityList.cpp +++ b/tests/SDK/NDK/EntityList.cpp @@ -16,8 +16,8 @@ SCENARIO("EntityList", "[NDK][ENTITYLIST]") THEN("These results are expected") { REQUIRE(entityList.Has(entity->GetId())); - const Ndk::EntityHandle& entity = world.CreateEntity(); - REQUIRE(!entityList.Has(entity->GetId())); + const Ndk::EntityHandle& newEntity = world.CreateEntity(); + REQUIRE(!entityList.Has(newEntity->GetId())); } } From b0d0a63fcac4b3d67bd2f16a7dc25dc3754899da Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Feb 2017 23:37:31 +0100 Subject: [PATCH 123/243] Network/ENet: Add peer-side lag simulation --- include/Nazara/Network/ENetHost.hpp | 12 +++- include/Nazara/Network/ENetPeer.hpp | 7 +++ include/Nazara/Network/ENetPeer.inl | 8 ++- include/Nazara/Network/ENetProtocol.hpp | 2 +- src/Nazara/Network/ENetHost.cpp | 75 +++++++++++++++++++++---- src/Nazara/Network/ENetPeer.cpp | 14 +++++ 6 files changed, 104 insertions(+), 14 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index b1304ab81..edb9155ab 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -100,13 +100,20 @@ namespace Nz static bool Initialize(); static void Uninitialize(); - struct PendingPacket + struct PendingIncomingPacket { IpAddress from; NetPacket data; UInt32 deliveryTime; }; + struct PendingOutgoingPacket + { + IpAddress to; + NetPacket data; + UInt32 deliveryTime; + }; + std::array m_commands; std::array m_buffers; std::array m_packetData[2]; @@ -123,7 +130,8 @@ namespace Nz std::size_t m_receivedDataLength; std::uniform_int_distribution m_packetDelayDistribution; std::vector m_peers; - std::vector m_pendingPackets; + std::vector m_pendingIncomingPackets; + std::vector m_pendingOutgoingPackets; UInt8* m_receivedData; Bitset m_dispatchQueue; MemoryPool m_packetPool; diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 19144c2f2..e3538e6fb 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include namespace Nz @@ -59,6 +60,7 @@ namespace Nz inline bool HasPendingCommands(); inline bool IsConnected() const; + inline bool IsSimulationEnabled() const; void Ping(); @@ -68,6 +70,8 @@ namespace Nz bool Send(UInt8 channelId, ENetPacketRef packetRef); bool Send(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet); + void SimulateNetwork(double packetLossProbability, UInt16 minDelay, UInt16 maxDelay); + void ThrottleConfigure(UInt32 interval, UInt32 acceleration, UInt32 deceleration); ENetPeer& operator=(const ENetPeer&) = delete; @@ -177,12 +181,14 @@ namespace Nz ENetHost* m_host; IpAddress m_address; /**< Internet address of the peer */ std::array m_unsequencedWindow; + std::bernoulli_distribution m_packetLossProbability; std::list m_dispatchedCommands; std::list m_outgoingReliableCommands; std::list m_outgoingUnreliableCommands; std::list m_sentReliableCommands; std::list m_sentUnreliableCommands; std::size_t m_totalWaitingData; + std::uniform_int_distribution m_packetDelayDistribution; std::vector m_acknowledgements; std::vector m_channels; ENetPeerState m_state; @@ -232,6 +238,7 @@ namespace Nz UInt32 m_windowSize; UInt64 m_totalPacketLost; UInt64 m_totalPacketSent; + bool m_isSimulationEnabled; }; } diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index e9c15fe35..bcec4a8c1 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -12,7 +12,8 @@ namespace Nz m_host(host), m_incomingSessionID(0xFF), m_outgoingSessionID(0xFF), - m_incomingPeerID(peerId) + m_incomingPeerID(peerId), + m_isSimulationEnabled(false) { Reset(); } @@ -62,6 +63,11 @@ namespace Nz return m_state == ENetPeerState::Connected || m_state == ENetPeerState::DisconnectLater; } + inline bool ENetPeer::IsSimulationEnabled() const + { + return m_isSimulationEnabled; + } + inline void ENetPeer::ChangeState(ENetPeerState state) { if (state == ENetPeerState::Connected || state == ENetPeerState::DisconnectLater) diff --git a/include/Nazara/Network/ENetProtocol.hpp b/include/Nazara/Network/ENetProtocol.hpp index e3df5e092..7cd613ab0 100644 --- a/include/Nazara/Network/ENetProtocol.hpp +++ b/include/Nazara/Network/ENetProtocol.hpp @@ -28,7 +28,7 @@ namespace Nz { ENetHost_BandwidthThrottleInterval = 1000, ENetHost_DefaultMaximumPacketSize = 32 * 1024 * 1024, - ENetHost_DefaultMaximumWaitingData = 32 * 1024 * 1024, + ENetHost_DefaultMaximumWaitingData = 32 * 1024 * 1024, ENetHost_DefaultMTU = 1400, ENetHost_ReceiveBufferSize = 256 * 1024, ENetHost_SendBufferSize = 256 * 1024, diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 76c81eb38..84083b24d 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -672,7 +672,7 @@ namespace Nz if (m_isSimulationEnabled) { - for (auto it = m_pendingPackets.begin(); it != m_pendingPackets.end(); ++it) + for (auto it = m_pendingIncomingPackets.begin(); it != m_pendingIncomingPackets.end(); ++it) { if (m_serviceTime >= it->deliveryTime) { @@ -682,7 +682,7 @@ namespace Nz receivedLength = it->data.GetDataSize(); std::memcpy(m_packetData[0].data(), it->data.GetConstData() + NetPacket::HeaderSize, receivedLength); - m_pendingPackets.erase(it); + m_pendingIncomingPackets.erase(it); break; } } @@ -704,17 +704,17 @@ namespace Nz UInt16 delay = m_packetDelayDistribution(s_randomGenerator); if (delay > 0) { - PendingPacket pendingPacket; + PendingIncomingPacket pendingPacket; pendingPacket.deliveryTime = m_serviceTime + delay; pendingPacket.from = m_receivedAddress; pendingPacket.data.Reset(0, m_packetData[0].data(), receivedLength); - auto it = std::upper_bound(m_pendingPackets.begin(), m_pendingPackets.end(), pendingPacket, [] (const PendingPacket& first, const PendingPacket& second) + auto it = std::upper_bound(m_pendingIncomingPackets.begin(), m_pendingIncomingPackets.end(), pendingPacket, [] (const PendingIncomingPacket& first, const PendingIncomingPacket& second) { return first.deliveryTime < second.deliveryTime; }); - m_pendingPackets.emplace(it, std::move(pendingPacket)); + m_pendingIncomingPackets.emplace(it, std::move(pendingPacket)); continue; } } @@ -1020,17 +1020,72 @@ namespace Nz currentPeer->m_lastSendTime = m_serviceTime; - std::size_t sentLength; - if (!m_socket.SendMultiple(currentPeer->GetAddress(), m_buffers.data(), m_bufferCount, &sentLength)) - return -1; + // Simulate network by adding delay to packet sending and losing some packets + bool sendNow = true; + if (!currentPeer->IsSimulationEnabled()) + { + sendNow = false; + if (!currentPeer->m_packetLossProbability(s_randomGenerator)) + { + Nz::UInt16 delay = currentPeer->m_packetDelayDistribution(s_randomGenerator); + if (delay == 0) + sendNow = true; + else + { + PendingOutgoingPacket outgoingPacket; + outgoingPacket.deliveryTime = m_serviceTime + delay; + outgoingPacket.to = currentPeer->GetAddress(); + + // Accumulate every temporary buffer into a datagram + for (std::size_t i = 0; i < m_bufferCount; ++i) + { + NetBuffer& buffer = m_buffers[i]; + outgoingPacket.data.Write(buffer.data, buffer.dataLength); + } + + m_totalSentData += outgoingPacket.data.GetDataSize(); + + // Add it to the right place + auto it = std::upper_bound(m_pendingOutgoingPackets.begin(), m_pendingOutgoingPackets.end(), outgoingPacket, [](const PendingOutgoingPacket& first, const PendingOutgoingPacket& second) + { + return first.deliveryTime < second.deliveryTime; + }); + + m_pendingOutgoingPackets.emplace(it, std::move(outgoingPacket)); + } + } + } + + if (sendNow) + { + std::size_t sentLength = 0; + + if (!m_socket.SendMultiple(currentPeer->GetAddress(), m_buffers.data(), m_bufferCount, &sentLength)) + return -1; + + m_totalSentData += sentLength; + } currentPeer->RemoveSentUnreliableCommands(); - - m_totalSentData += sentLength; m_totalSentPackets++; } } + if (!m_pendingOutgoingPackets.empty()) + { + auto it = m_pendingOutgoingPackets.begin(); + for (; it != m_pendingOutgoingPackets.end(); ++it) + { + if (m_serviceTime < it->deliveryTime) + break; + + if (!m_socket.Send(it->to, it->data.GetConstData() + NetPacket::HeaderSize, it->data.GetDataSize(), nullptr)) + return -1; + } + + m_pendingOutgoingPackets.erase(m_pendingOutgoingPackets.begin(), it); + } + return 0; } diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index e7a39e3e5..1d28cae42 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -177,6 +177,20 @@ namespace Nz return Send(channelId, m_host->AllocatePacket(flags, std::move(packet))); } + void ENetPeer::SimulateNetwork(double packetLossProbability, UInt16 minDelay, UInt16 maxDelay) + { + NazaraAssert(maxDelay >= minDelay, "Maximum delay cannot be greater than minimum delay"); + + if (packetLossProbability <= 0.0 && minDelay == 0 && maxDelay == 0) + m_isSimulationEnabled = false; + else + { + m_isSimulationEnabled = true; + m_packetDelayDistribution = std::uniform_int_distribution(minDelay, maxDelay); + m_packetLossProbability = std::bernoulli_distribution(packetLossProbability); + } + } + bool ENetPeer::Send(UInt8 channelId, ENetPacketRef packetRef) { if (m_state != ENetPeerState::Connected || channelId >= m_channels.size() || packetRef->data.GetDataSize() > m_host->m_maximumPacketSize) From 218d9f3974f627355dbf04c7a81994871f467e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 21 Feb 2017 15:58:02 +0100 Subject: [PATCH 124/243] Network/ENetHost: Add GetBoundAddress() --- include/Nazara/Network/ENetHost.hpp | 1 + include/Nazara/Network/ENetHost.inl | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index edb9155ab..4941df353 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -61,6 +61,7 @@ namespace Nz void Flush(); + inline Nz::IpAddress GetBoundAddress() const; inline UInt32 GetServiceTime() const; int Service(ENetEvent* event, UInt32 timeout); diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl index 9a70d9b78..3f35a8f39 100644 --- a/include/Nazara/Network/ENetHost.inl +++ b/include/Nazara/Network/ENetHost.inl @@ -52,6 +52,11 @@ namespace Nz m_socket.Close(); } + inline Nz::IpAddress ENetHost::GetBoundAddress() const + { + return m_address; + } + inline UInt32 Nz::ENetHost::GetServiceTime() const { return m_serviceTime; From 7b47a6ad2e08be302e78b1d607c34e5e43953623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 21 Feb 2017 15:58:31 +0100 Subject: [PATCH 125/243] Physics2D: Add support for trigger and callbacks --- include/Nazara/Physics2D/Collider2D.hpp | 13 +++ include/Nazara/Physics2D/Collider2D.inl | 21 +++++ include/Nazara/Physics2D/PhysWorld2D.hpp | 28 +++++- src/Nazara/Physics2D/Collider2D.cpp | 12 +++ src/Nazara/Physics2D/PhysWorld2D.cpp | 105 +++++++++++++++++++++++ src/Nazara/Physics2D/RigidBody2D.cpp | 2 +- 6 files changed, 179 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Physics2D/Collider2D.hpp b/include/Nazara/Physics2D/Collider2D.hpp index 610d1a00f..7238237af 100644 --- a/include/Nazara/Physics2D/Collider2D.hpp +++ b/include/Nazara/Physics2D/Collider2D.hpp @@ -42,8 +42,15 @@ namespace Nz virtual float ComputeInertialMatrix(float mass) const = 0; + inline unsigned int GetCollisionId() const; + virtual ColliderType2D GetType() const = 0; + inline bool IsTrigger() const; + + inline void SetCollisionId(unsigned long typeId); + inline void SetTrigger(bool trigger); + Collider2D& operator=(const Collider2D&) = delete; Collider2D& operator=(Collider2D&&) = delete; @@ -53,6 +60,12 @@ namespace Nz protected: virtual std::vector CreateShapes(RigidBody2D* body) const = 0; + bool m_trigger; + unsigned int m_collisionId; + + private: + virtual std::vector GenerateShapes(RigidBody2D* body) const; + static Collider2DLibrary::LibraryMap s_library; }; diff --git a/include/Nazara/Physics2D/Collider2D.inl b/include/Nazara/Physics2D/Collider2D.inl index f5b222875..bf4902a81 100644 --- a/include/Nazara/Physics2D/Collider2D.inl +++ b/include/Nazara/Physics2D/Collider2D.inl @@ -7,6 +7,26 @@ namespace Nz { + inline unsigned int Collider2D::GetCollisionId() const + { + return m_collisionId; + } + + inline bool Collider2D::IsTrigger() const + { + return m_trigger; + } + + inline void Collider2D::SetCollisionId(unsigned long typeId) + { + m_collisionId = typeId; + } + + inline void Collider2D::SetTrigger(bool trigger) + { + m_trigger = trigger; + } + inline const Rectf& BoxCollider2D::GetRect() const { return m_rect; @@ -82,3 +102,4 @@ namespace Nz } #include +#include "Collider2D.hpp" diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index c2ffb437c..760773c7d 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -10,14 +10,26 @@ #include #include #include +#include +#include +struct cpCollisionHandler; struct cpSpace; namespace Nz { + class RigidBody2D; + class NAZARA_PHYSICS2D_API PhysWorld2D { + using ContactEndCallback = void(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata); + using ContactPreSolveCallback = bool(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata); + using ContactPostSolveCallback = void(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata); + using ContactStartCallback = bool(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata); + public: + struct Callback; + PhysWorld2D(); PhysWorld2D(const PhysWorld2D&) = delete; PhysWorld2D(PhysWorld2D&&) = delete; ///TODO @@ -27,8 +39,10 @@ namespace Nz cpSpace* GetHandle() const; float GetStepSize() const; + void RegisterCallbacks(unsigned int collisionId, const Callback& callbacks); + void RegisterCallbacks(unsigned int collisionIdA, unsigned int collisionIdB, const Callback& callbacks); + void SetGravity(const Vector2f& gravity); - void SetSolverModel(unsigned int model); void SetStepSize(float stepSize); void Step(float timestep); @@ -36,7 +50,19 @@ namespace Nz PhysWorld2D& operator=(const PhysWorld2D&) = delete; PhysWorld2D& operator=(PhysWorld2D&&) = delete; ///TODO + struct Callback + { + ContactEndCallback endCallback; + ContactPreSolveCallback preSolveCallback; + ContactPostSolveCallback postSolveCallback; + ContactStartCallback startCallback; + void* userdata; + }; + private: + void InitCallbacks(cpCollisionHandler* handler, const Callback& callbacks); + + std::unordered_map> m_callbacks; cpSpace* m_handle; float m_stepSize; float m_timestepAccumulator; diff --git a/src/Nazara/Physics2D/Collider2D.cpp b/src/Nazara/Physics2D/Collider2D.cpp index 928ea3974..cce3301aa 100644 --- a/src/Nazara/Physics2D/Collider2D.cpp +++ b/src/Nazara/Physics2D/Collider2D.cpp @@ -11,6 +11,18 @@ namespace Nz { Collider2D::~Collider2D() = default; + std::vector Collider2D::GenerateShapes(RigidBody2D* body) const + { + std::vector shapes = CreateShapes(body); + for (cpShape* shape : shapes) + { + cpShapeSetCollisionType(shape, m_collisionId); + cpShapeSetSensor(shape, (m_trigger) ? cpTrue : cpFalse); + } + + return shapes; + } + /******************************** BoxCollider2D *********************************/ BoxCollider2D::BoxCollider2D(const Vector2f& size, float radius) : diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 62d194e9b..16ead3332 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -37,6 +37,16 @@ namespace Nz return m_stepSize; } + void PhysWorld2D::RegisterCallbacks(unsigned int collisionId, const Callback& callbacks) + { + InitCallbacks(cpSpaceAddWildcardHandler(m_handle, collisionId), callbacks); + } + + void PhysWorld2D::RegisterCallbacks(unsigned int collisionIdA, unsigned int collisionIdB, const Callback& callbacks) + { + InitCallbacks(cpSpaceAddCollisionHandler(m_handle, collisionIdA, collisionIdB), callbacks); + } + void PhysWorld2D::SetGravity(const Vector2f& gravity) { cpSpaceSetGravity(m_handle, cpv(gravity.x, gravity.y)); @@ -57,4 +67,99 @@ namespace Nz m_timestepAccumulator -= m_stepSize; } } + + void PhysWorld2D::InitCallbacks(cpCollisionHandler* handler, const Callback& callbacks) + { + auto it = m_callbacks.emplace(handler, std::make_unique(callbacks)).first; + + handler->userData = &it->second; + + if (callbacks.startCallback) + { + handler->beginFunc = [](cpArbiter* arb, cpSpace* space, void *data) -> cpBool + { + cpBody* firstBody; + cpBody* secondBody; + cpArbiterGetBodies(arb, &firstBody, &secondBody); + + PhysWorld2D* world = static_cast(cpSpaceGetUserData(space)); + RigidBody2D* firstRigidBody = static_cast(cpBodyGetUserData(firstBody)); + RigidBody2D* secondRigidBody = static_cast(cpBodyGetUserData(secondBody)); + + const Callback* customCallbacks = static_cast(data); + if (customCallbacks->startCallback(*world, *firstRigidBody, *secondRigidBody, customCallbacks->userdata)) + { + cpBool retA = cpArbiterCallWildcardBeginA(arb, space); + cpBool retB = cpArbiterCallWildcardBeginB(arb, space); + return retA && retB; + } + else + return cpFalse; + }; + } + + if (callbacks.endCallback) + { + handler->separateFunc = [](cpArbiter* arb, cpSpace* space, void *data) + { + cpBody* firstBody; + cpBody* secondBody; + cpArbiterGetBodies(arb, &firstBody, &secondBody); + + PhysWorld2D* world = static_cast(cpSpaceGetUserData(space)); + RigidBody2D* firstRigidBody = static_cast(cpBodyGetUserData(firstBody)); + RigidBody2D* secondRigidBody = static_cast(cpBodyGetUserData(secondBody)); + + const Callback* customCallbacks = static_cast(data); + customCallbacks->endCallback(*world, *firstRigidBody, *secondRigidBody, customCallbacks->userdata); + + cpArbiterCallWildcardSeparateA(arb, space); + cpArbiterCallWildcardSeparateB(arb, space); + }; + } + + if (callbacks.preSolveCallback) + { + handler->preSolveFunc = [](cpArbiter* arb, cpSpace* space, void *data) -> cpBool + { + cpBody* firstBody; + cpBody* secondBody; + cpArbiterGetBodies(arb, &firstBody, &secondBody); + + PhysWorld2D* world = static_cast(cpSpaceGetUserData(space)); + RigidBody2D* firstRigidBody = static_cast(cpBodyGetUserData(firstBody)); + RigidBody2D* secondRigidBody = static_cast(cpBodyGetUserData(secondBody)); + + const Callback* customCallbacks = static_cast(data); + if (customCallbacks->preSolveCallback(*world, *firstRigidBody, *secondRigidBody, customCallbacks->userdata)) + { + cpBool retA = cpArbiterCallWildcardPreSolveA(arb, space); + cpBool retB = cpArbiterCallWildcardPreSolveB(arb, space); + return retA && retB; + } + else + return cpFalse; + }; + } + + if (callbacks.postSolveCallback) + { + handler->postSolveFunc = [](cpArbiter* arb, cpSpace* space, void *data) + { + cpBody* firstBody; + cpBody* secondBody; + cpArbiterGetBodies(arb, &firstBody, &secondBody); + + PhysWorld2D* world = static_cast(cpSpaceGetUserData(space)); + RigidBody2D* firstRigidBody = static_cast(cpBodyGetUserData(firstBody)); + RigidBody2D* secondRigidBody = static_cast(cpBodyGetUserData(secondBody)); + + const Callback* customCallbacks = static_cast(data); + customCallbacks->postSolveCallback(*world, *firstRigidBody, *secondRigidBody, customCallbacks->userdata); + + cpArbiterCallWildcardPostSolveA(arb, space); + cpArbiterCallWildcardPostSolveB(arb, space); + }; + } + } } diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 9078749b3..82c3a34ce 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -190,7 +190,7 @@ namespace Nz else m_geom = NullCollider2D::New(); - m_shapes = m_geom->CreateShapes(this); + m_shapes = m_geom->GenerateShapes(this); cpSpace* space = m_world->GetHandle(); for (cpShape* shape : m_shapes) From a53a916399058c326e58fcf846ac89481197a169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 21 Feb 2017 16:55:05 +0100 Subject: [PATCH 126/243] Network/ENetHost: Fix simulation being always active --- src/Nazara/Network/ENetHost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 84083b24d..d32b6d5f9 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -1022,7 +1022,7 @@ namespace Nz // Simulate network by adding delay to packet sending and losing some packets bool sendNow = true; - if (!currentPeer->IsSimulationEnabled()) + if (currentPeer->IsSimulationEnabled()) { sendNow = false; if (!currentPeer->m_packetLossProbability(s_randomGenerator)) From d68cb35056f08655b18894c887f9285d797d4053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 21 Feb 2017 17:02:52 +0100 Subject: [PATCH 127/243] Physics2D/Collider2D: Fix collision id and trigger default values --- include/Nazara/Physics2D/Collider2D.hpp | 2 +- include/Nazara/Physics2D/Collider2D.inl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Physics2D/Collider2D.hpp b/include/Nazara/Physics2D/Collider2D.hpp index 7238237af..e5b988756 100644 --- a/include/Nazara/Physics2D/Collider2D.hpp +++ b/include/Nazara/Physics2D/Collider2D.hpp @@ -35,7 +35,7 @@ namespace Nz friend RigidBody2D; public: - Collider2D() = default; + inline Collider2D(); Collider2D(const Collider2D&) = delete; Collider2D(Collider2D&&) = delete; virtual ~Collider2D(); diff --git a/include/Nazara/Physics2D/Collider2D.inl b/include/Nazara/Physics2D/Collider2D.inl index bf4902a81..71b909a2c 100644 --- a/include/Nazara/Physics2D/Collider2D.inl +++ b/include/Nazara/Physics2D/Collider2D.inl @@ -7,6 +7,12 @@ namespace Nz { + inline Collider2D::Collider2D() : + m_collisionId(0), + m_trigger(false) + { + } + inline unsigned int Collider2D::GetCollisionId() const { return m_collisionId; From 096ea72fb60aae0fb1f5b207d2072a4b77baaba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Feb 2017 13:00:05 +0100 Subject: [PATCH 128/243] Physics2D/PhysWorld2D: Fix crash with physics callbacks --- src/Nazara/Physics2D/PhysWorld2D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 16ead3332..7c15beee3 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -72,7 +72,7 @@ namespace Nz { auto it = m_callbacks.emplace(handler, std::make_unique(callbacks)).first; - handler->userData = &it->second; + handler->userData = it->second.get(); if (callbacks.startCallback) { From 45262145aad7678051d59470f35e5dfcc7df0aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Feb 2017 15:31:51 +0100 Subject: [PATCH 129/243] Physics2D/RigidBody2D: Add Userdata field --- include/Nazara/Physics2D/RigidBody2D.hpp | 3 +++ src/Nazara/Physics2D/RigidBody2D.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/Nazara/Physics2D/RigidBody2D.hpp b/include/Nazara/Physics2D/RigidBody2D.hpp index 5f14d8ff9..726c7c1e1 100644 --- a/include/Nazara/Physics2D/RigidBody2D.hpp +++ b/include/Nazara/Physics2D/RigidBody2D.hpp @@ -43,6 +43,7 @@ namespace Nz float GetMass() const; Vector2f GetPosition() const; float GetRotation() const; + void* GetUserdata() const; Vector2f GetVelocity() const; bool IsMoveable() const; @@ -54,6 +55,7 @@ namespace Nz void SetMassCenter(const Vector2f& center); void SetPosition(const Vector2f& position); void SetRotation(float rotation); + void SetUserdata(void* ud); void SetVelocity(const Vector2f& velocity); RigidBody2D& operator=(const RigidBody2D& object); @@ -66,6 +68,7 @@ namespace Nz std::vector m_shapes; Collider2DRef m_geom; cpBody* m_handle; + void* m_userData; PhysWorld2D* m_world; float m_gravityFactor; float m_mass; diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 82c3a34ce..1bdc17968 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -20,6 +20,7 @@ namespace Nz RigidBody2D::RigidBody2D(PhysWorld2D* world, float mass, Collider2DRef geom) : m_geom(), + m_userData(nullptr), m_world(world), m_gravityFactor(1.f), m_mass(1.f) @@ -34,6 +35,7 @@ namespace Nz RigidBody2D::RigidBody2D(const RigidBody2D& object) : m_geom(object.m_geom), + m_userData(object.m_userData), m_world(object.m_world), m_gravityFactor(object.m_gravityFactor), m_mass(0.f) @@ -50,11 +52,14 @@ namespace Nz RigidBody2D::RigidBody2D(RigidBody2D&& object) : m_shapes(std::move(object.m_shapes)), m_geom(std::move(object.m_geom)), + m_userData(object.m_userData), m_handle(object.m_handle), m_world(object.m_world), m_gravityFactor(object.m_gravityFactor), m_mass(object.m_mass) { + cpBodySetUserData(m_handle, this); + object.m_handle = nullptr; } @@ -144,6 +149,11 @@ namespace Nz return static_cast(cpBodyGetAngle(m_handle)); } + void* RigidBody2D::GetUserdata() const + { + return m_userData; + } + Vector2f RigidBody2D::GetVelocity() const { cpVect vel = cpBodyGetVelocity(m_handle); @@ -242,6 +252,11 @@ namespace Nz cpBodySetAngle(m_handle, rotation); } + void RigidBody2D::SetUserdata(void* ud) + { + m_userData = ud; + } + void RigidBody2D::SetVelocity(const Vector2f& velocity) { cpBodySetVelocity(m_handle, cpv(velocity.x, velocity.y)); @@ -262,8 +277,11 @@ namespace Nz m_gravityFactor = object.m_gravityFactor; m_mass = object.m_mass; m_shapes = std::move(object.m_shapes); + m_userData = object.m_userData; m_world = object.m_world; + cpBodySetUserData(m_handle, this); + object.m_handle = nullptr; return *this; From b1e4aea496811ede06f43809e0c22a895221d53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Feb 2017 16:52:34 +0100 Subject: [PATCH 130/243] Physics2D/RigidBody2D: Add signal for movement/release --- include/Nazara/Physics2D/RigidBody2D.hpp | 4 ++++ src/Nazara/Physics2D/RigidBody2D.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/Nazara/Physics2D/RigidBody2D.hpp b/include/Nazara/Physics2D/RigidBody2D.hpp index 726c7c1e1..f57ce6a48 100644 --- a/include/Nazara/Physics2D/RigidBody2D.hpp +++ b/include/Nazara/Physics2D/RigidBody2D.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,9 @@ namespace Nz RigidBody2D& operator=(const RigidBody2D& object); RigidBody2D& operator=(RigidBody2D&& object); + NazaraSignal(OnRigidBody2DMove, RigidBody2D* /*oldPointer*/, RigidBody2D* /*newPointer*/); + NazaraSignal(OnRigidBody2DRelease, RigidBody2D* /*rigidBody*/); + private: void Create(float mass = 1.f, float moment = 1.f); void Destroy(); diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 1bdc17968..8993fe398 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -50,6 +50,8 @@ namespace Nz } RigidBody2D::RigidBody2D(RigidBody2D&& object) : + OnRigidBody2DMove(std::move(object.OnRigidBody2DMove)), + OnRigidBody2DRelease(std::move(object.OnRigidBody2DRelease)), m_shapes(std::move(object.m_shapes)), m_geom(std::move(object.m_geom)), m_userData(object.m_userData), @@ -61,10 +63,14 @@ namespace Nz cpBodySetUserData(m_handle, this); object.m_handle = nullptr; + + OnRigidBody2DMove(&object, this); } RigidBody2D::~RigidBody2D() { + OnRigidBody2DRelease(this); + Destroy(); } @@ -272,6 +278,9 @@ namespace Nz { Destroy(); + OnRigidBody2DMove = std::move(object.OnRigidBody2DMove); + OnRigidBody2DRelease = std::move(object.OnRigidBody2DRelease); + m_handle = object.m_handle; m_geom = std::move(object.m_geom); m_gravityFactor = object.m_gravityFactor; @@ -284,6 +293,8 @@ namespace Nz object.m_handle = nullptr; + OnRigidBody2DMove(&object, this); + return *this; } From ce6eb1d6d91588b0ecb88dbc1919f66078635818 Mon Sep 17 00:00:00 2001 From: EloD10 Date: Wed, 22 Feb 2017 17:54:00 +0100 Subject: [PATCH 131/243] Update Console.cpp (#117) * Update Console.cpp Deleting a semicolon * Update ButtonWidget.cpp Removing empty fuction * Update ButtonWidget.hpp Removing unnecessary variable --- SDK/include/NDK/Widgets/ButtonWidget.hpp | 1 - SDK/src/NDK/Console.cpp | 2 +- SDK/src/NDK/Widgets/ButtonWidget.cpp | 5 +---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/SDK/include/NDK/Widgets/ButtonWidget.hpp b/SDK/include/NDK/Widgets/ButtonWidget.hpp index 78f978719..8f2231501 100644 --- a/SDK/include/NDK/Widgets/ButtonWidget.hpp +++ b/SDK/include/NDK/Widgets/ButtonWidget.hpp @@ -40,7 +40,6 @@ namespace Ndk void Layout() override; void OnMouseEnter() override; - void OnMouseMoved(int x, int y, int deltaX, int deltaY) override; void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button) override; void OnMouseExit() override; diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 9719e4b62..3843978ad 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -300,7 +300,7 @@ namespace Ndk void Console::ExecuteInput() { Nz::String input = m_inputDrawer.GetText(); - Nz::String inputCmd = input.SubString(s_inputPrefixSize);; + Nz::String inputCmd = input.SubString(s_inputPrefixSize); m_inputDrawer.SetText(s_inputPrefix); if (m_commandHistory.empty() || m_commandHistory.back() != inputCmd) diff --git a/SDK/src/NDK/Widgets/ButtonWidget.cpp b/SDK/src/NDK/Widgets/ButtonWidget.cpp index 8d3a69e33..29c04c98f 100644 --- a/SDK/src/NDK/Widgets/ButtonWidget.cpp +++ b/SDK/src/NDK/Widgets/ButtonWidget.cpp @@ -61,10 +61,7 @@ namespace Ndk m_gradientSprite->SetColor(Nz::Color(128, 128, 128)); } - void ButtonWidget::OnMouseMoved(int x, int y, int deltaX, int deltaY) - { - } - + void ButtonWidget::OnMouseExit() { m_gradientSprite->SetColor(Nz::Color(74, 74, 74)); From 8d402f0491990d33812893e26ad659e7559f5abb Mon Sep 17 00:00:00 2001 From: EloD10 Date: Thu, 23 Feb 2017 00:07:51 +0100 Subject: [PATCH 132/243] Update ContextParameters.cpp (#119) * Update ContextParameters.cpp Changing an incorrect comment * Update ContextParameters.cpp --- src/Nazara/Renderer/ContextParameters.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Nazara/Renderer/ContextParameters.cpp b/src/Nazara/Renderer/ContextParameters.cpp index cdb087561..1af405b2e 100644 --- a/src/Nazara/Renderer/ContextParameters.cpp +++ b/src/Nazara/Renderer/ContextParameters.cpp @@ -8,28 +8,28 @@ namespace Nz { - // Version majeure d'OpenGL, initialisé par OpenGL::Initialize() + // Major version of OpenGL, initialised by OpenGL::Initialize() UInt8 ContextParameters::defaultMajorVersion; - // Version majeure d'OpenGL, initialisé par OpenGL::Initialize() + // Minor version of OpenGL, initialised by OpenGL::Initialize() UInt8 ContextParameters::defaultMinorVersion; - // Contexte de partage par défaut, initialisé par OpenGL::Initialize() + // Context of default sharing, initialised by OpenGL::Initialize() const Context* ContextParameters::defaultShareContext = nullptr; - // Si possible, garder la compatibilité avec les fonctionnalités dépréciées + // If it's possible, keep the compatibility with deprecated functionalities bool ContextParameters::defaultCompatibilityProfile = false; - // Mode debug d'OpenGL par défaut + // Default debug mode of OpenGL #if NAZARA_RENDERER_OPENGL_DEBUG || defined(NAZARA_DEBUG) bool ContextParameters::defaultDebugMode = true; #else bool ContextParameters::defaultDebugMode = false; #endif - // Active le double-buffering sur les contextes + // Enables double-buffering on contexts Active le double-buffering sur les contextes bool ContextParameters::defaultDoubleBuffered = false; - // Active le partage des ressources entre contextes (Via le defaultShareContext) + // Enables ressource sharing on contexts (via defaultShareContext) bool ContextParameters::defaultShared = true; } From 55d9a226656736f55887519f0ea473952a3fd76b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 23 Feb 2017 00:09:39 +0100 Subject: [PATCH 133/243] NDK/BaseWidget: Children widgets are now automatically parented to their parent --- SDK/include/NDK/BaseWidget.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 17592241f..e84a67a49 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -33,6 +33,7 @@ namespace Ndk inline void BaseWidget::AddChild(std::unique_ptr&& widget) { widget->Show(m_visible); + widget->SetParent(this); m_children.emplace_back(std::move(widget)); } From 14022ccee25e702fd4685eccaa644eb1ec651190 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 24 Feb 2017 10:15:13 +0100 Subject: [PATCH 134/243] Network/ENetPeer: Fix crash --- src/Nazara/Network/ENetPeer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 1d28cae42..5407fec35 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -986,7 +986,7 @@ namespace Nz if (currentCommand == m_sentReliableCommands.end()) { currentCommand = m_outgoingReliableCommands.begin(); - commandList = &m_sentReliableCommands; + commandList = &m_outgoingReliableCommands; for (; currentCommand != m_outgoingReliableCommands.end(); ++currentCommand) { found = true; From b4ecf563c1fa444c7b903c2479a1ac9526284bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 27 Feb 2017 16:29:24 +0100 Subject: [PATCH 135/243] Add pdb to package --- build/scripts/actions/package.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index 62d4792b3..cbdae329c 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -86,7 +86,7 @@ ACTION.Function = function () local exeFilterFunc if (os.is("windows")) then binFileMasks = {"**.dll"} - libFileMasks = {"**.lib", "**.a"} + libFileMasks = {"**.lib", "**.a", "**.pdb"} exeFileExt = ".exe" exeFilterFunc = function (filePath) return true end else From f22dd81d35e455672784123036984f1097367f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 27 Feb 2017 16:30:18 +0100 Subject: [PATCH 136/243] Physics2D/RigidBody2D: Add AddImpulse method --- include/Nazara/Physics2D/RigidBody2D.hpp | 2 ++ src/Nazara/Physics2D/RigidBody2D.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/Nazara/Physics2D/RigidBody2D.hpp b/include/Nazara/Physics2D/RigidBody2D.hpp index f57ce6a48..9763aba47 100644 --- a/include/Nazara/Physics2D/RigidBody2D.hpp +++ b/include/Nazara/Physics2D/RigidBody2D.hpp @@ -34,6 +34,8 @@ namespace Nz void AddForce(const Vector2f& force, CoordSys coordSys = CoordSys_Global); void AddForce(const Vector2f& force, const Vector2f& point, CoordSys coordSys = CoordSys_Global); + void AddImpulse(const Vector2f& impulse, CoordSys coordSys = CoordSys_Global); + void AddImpulse(const Vector2f& impulse, const Vector2f& point, CoordSys coordSys = CoordSys_Global); void AddTorque(float torque); Rectf GetAABB() const; diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 8993fe398..d01a426a2 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -93,6 +93,25 @@ namespace Nz } } + void RigidBody2D::AddImpulse(const Vector2f& impulse, CoordSys coordSys) + { + return AddImpulse(impulse, GetCenterOfGravity(coordSys), coordSys); + } + + void RigidBody2D::AddImpulse(const Vector2f& impulse, const Vector2f& point, CoordSys coordSys) + { + switch (coordSys) + { + case CoordSys_Global: + cpBodyApplyImpulseAtWorldPoint(m_handle, cpv(impulse.x, impulse.y), cpv(point.x, point.y)); + break; + + case CoordSys_Local: + cpBodyApplyImpulseAtLocalPoint(m_handle, cpv(impulse.x, impulse.y), cpv(point.x, point.y)); + break; + } + } + void RigidBody2D::AddTorque(float torque) { cpBodySetTorque(m_handle, cpBodyGetTorque(m_handle) + torque); From 5ebf1254740e793668efb81a9a4f5b7c1c3fca51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 1 Mar 2017 17:40:12 +0100 Subject: [PATCH 137/243] Physics2D: Add NearestBodyQuery --- include/Nazara/Physics2D/Collider2D.hpp | 11 ++++++- include/Nazara/Physics2D/Collider2D.inl | 39 ++++++++++++++++++++++-- include/Nazara/Physics2D/PhysWorld2D.hpp | 15 +++++++++ src/Nazara/Physics2D/Collider2D.cpp | 3 ++ src/Nazara/Physics2D/PhysWorld2D.cpp | 34 +++++++++++++++++++++ src/Nazara/Physics2D/RigidBody2D.cpp | 3 ++ 6 files changed, 101 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Physics2D/Collider2D.hpp b/include/Nazara/Physics2D/Collider2D.hpp index e5b988756..b09e8781f 100644 --- a/include/Nazara/Physics2D/Collider2D.hpp +++ b/include/Nazara/Physics2D/Collider2D.hpp @@ -42,13 +42,19 @@ namespace Nz virtual float ComputeInertialMatrix(float mass) const = 0; + inline Nz::UInt32 GetCategoryMask() const; + inline Nz::UInt32 GetCollisionGroup() const; inline unsigned int GetCollisionId() const; + inline Nz::UInt32 GetCollisionMask() const; virtual ColliderType2D GetType() const = 0; inline bool IsTrigger() const; - inline void SetCollisionId(unsigned long typeId); + inline void SetCategoryMask(Nz::UInt32 categoryMask); + inline void SetCollisionGroup(Nz::UInt32 groupId); + inline void SetCollisionId(unsigned int typeId); + inline void SetCollisionMask(Nz::UInt32 mask); inline void SetTrigger(bool trigger); Collider2D& operator=(const Collider2D&) = delete; @@ -61,7 +67,10 @@ namespace Nz virtual std::vector CreateShapes(RigidBody2D* body) const = 0; bool m_trigger; + Nz::UInt32 m_categoryMask; + Nz::UInt32 m_collisionGroup; unsigned int m_collisionId; + Nz::UInt32 m_collisionMask; private: virtual std::vector GenerateShapes(RigidBody2D* body) const; diff --git a/include/Nazara/Physics2D/Collider2D.inl b/include/Nazara/Physics2D/Collider2D.inl index 71b909a2c..60cf8559f 100644 --- a/include/Nazara/Physics2D/Collider2D.inl +++ b/include/Nazara/Physics2D/Collider2D.inl @@ -2,32 +2,66 @@ // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include namespace Nz { inline Collider2D::Collider2D() : + m_trigger(false), + m_categoryMask(0xFFFFFFFF), + m_collisionGroup(0), m_collisionId(0), - m_trigger(false) + m_collisionMask(0xFFFFFFFF) { } + inline Nz::UInt32 Collider2D::GetCategoryMask() const + { + return m_categoryMask; + } + + inline Nz::UInt32 Collider2D::GetCollisionGroup() const + { + return m_collisionGroup; + } + inline unsigned int Collider2D::GetCollisionId() const { return m_collisionId; } + inline Nz::UInt32 Collider2D::GetCollisionMask() const + { + return m_collisionMask; + } + inline bool Collider2D::IsTrigger() const { return m_trigger; } - inline void Collider2D::SetCollisionId(unsigned long typeId) + inline void Collider2D::SetCategoryMask(Nz::UInt32 categoryMask) + { + m_categoryMask = categoryMask; + } + + inline void Collider2D::SetCollisionGroup(Nz::UInt32 groupId) + { + m_collisionGroup = groupId; + } + + inline void Collider2D::SetCollisionId(unsigned int typeId) { m_collisionId = typeId; } + inline void Collider2D::SetCollisionMask(Nz::UInt32 mask) + { + m_collisionMask = mask; + } + inline void Collider2D::SetTrigger(bool trigger) { m_trigger = trigger; @@ -108,4 +142,3 @@ namespace Nz } #include -#include "Collider2D.hpp" diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index 760773c7d..09e39959b 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -8,6 +8,7 @@ #define NAZARA_PHYSWORLD2D_HPP #include +#include #include #include #include @@ -29,6 +30,7 @@ namespace Nz public: struct Callback; + struct NearestQueryResult; PhysWorld2D(); PhysWorld2D(const PhysWorld2D&) = delete; @@ -39,6 +41,8 @@ namespace Nz cpSpace* GetHandle() const; float GetStepSize() const; + bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result); + void RegisterCallbacks(unsigned int collisionId, const Callback& callbacks); void RegisterCallbacks(unsigned int collisionIdA, unsigned int collisionIdB, const Callback& callbacks); @@ -59,6 +63,17 @@ namespace Nz void* userdata; }; + struct NearestQueryResult + { + Nz::RigidBody2D* nearestBody; + Nz::Vector2f closestPoint; + Nz::Vector2f fraction; + float distance; + }; + + NazaraSignal(OnPhysWorld2DPreStep, const PhysWorld2D* /*physWorld*/); + NazaraSignal(OnPhysWorld2DPostStep, const PhysWorld2D* /*physWorld*/); + private: void InitCallbacks(cpCollisionHandler* handler, const Callback& callbacks); diff --git a/src/Nazara/Physics2D/Collider2D.cpp b/src/Nazara/Physics2D/Collider2D.cpp index cce3301aa..3a679fad9 100644 --- a/src/Nazara/Physics2D/Collider2D.cpp +++ b/src/Nazara/Physics2D/Collider2D.cpp @@ -13,9 +13,12 @@ namespace Nz std::vector Collider2D::GenerateShapes(RigidBody2D* body) const { + cpShapeFilter filter = cpShapeFilterNew(m_collisionGroup, m_categoryMask, m_collisionMask); + std::vector shapes = CreateShapes(body); for (cpShape* shape : shapes) { + cpShapeSetFilter(shape, filter); cpShapeSetCollisionType(shape, m_collisionId); cpShapeSetSensor(shape, (m_trigger) ? cpTrue : cpFalse); } diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 7c15beee3..52881b827 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -37,6 +37,35 @@ namespace Nz return m_stepSize; } + bool PhysWorld2D::NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result) + { + cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask); + + if (result) + { + cpPointQueryInfo queryInfo; + + if (cpShape* shape = cpSpacePointQueryNearest(m_handle, { from.x, from.y }, maxDistance, filter, &queryInfo)) + { + result->closestPoint.Set(queryInfo.point.x, queryInfo.point.y); + result->distance = queryInfo.distance; + result->fraction.Set(queryInfo.gradient.x, queryInfo.gradient.y); + result->nearestBody = static_cast(cpShapeGetUserData(shape)); + + return true; + } + else + return false; + } + else + { + if (cpShape* shape = cpSpacePointQueryNearest(m_handle, { from.x, from.y }, maxDistance, filter, nullptr)) + return true; + else + return false; + } + } + void PhysWorld2D::RegisterCallbacks(unsigned int collisionId, const Callback& callbacks) { InitCallbacks(cpSpaceAddWildcardHandler(m_handle, collisionId), callbacks); @@ -63,7 +92,12 @@ namespace Nz while (m_timestepAccumulator >= m_stepSize) { + OnPhysWorld2DPreStep(this); + cpSpaceStep(m_handle, m_stepSize); + + OnPhysWorld2DPostStep(this); + m_timestepAccumulator -= m_stepSize; } } diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index d01a426a2..d4d5aafd0 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -229,7 +229,10 @@ namespace Nz cpSpace* space = m_world->GetHandle(); for (cpShape* shape : m_shapes) + { + cpShapeSetUserData(shape, this); cpSpaceAddShape(space, shape); + } cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); } From 834f65c0ae2b75e674fa61202dd7ca71fd46035f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Mar 2017 10:34:02 +0100 Subject: [PATCH 138/243] Physics2D/PhysWorld2D: Add optimized NearestBodyQuery --- include/Nazara/Physics2D/PhysWorld2D.hpp | 1 + src/Nazara/Physics2D/PhysWorld2D.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index 09e39959b..3360b6584 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -41,6 +41,7 @@ namespace Nz cpSpace* GetHandle() const; float GetStepSize() const; + bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D* nearestBody); bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result); void RegisterCallbacks(unsigned int collisionId, const Callback& callbacks); diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 52881b827..81d1824f1 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -37,6 +37,21 @@ namespace Nz return m_stepSize; } + bool PhysWorld2D::NearestBodyQuery(const Vector2f & from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D* nearestBody) + { + cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask); + + if (cpShape* shape = cpSpacePointQueryNearest(m_handle, {from.x, from.y}, maxDistance, filter, nullptr)) + { + if (nearestBody) + nearestBody = static_cast(cpShapeGetUserData(shape)); + + return true; + } + else + return false; + } + bool PhysWorld2D::NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result) { cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask); From a50a822fade1482af1af45ed3e8354f328e07b72 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Mar 2017 11:22:59 +0100 Subject: [PATCH 139/243] Physics2D/PhysWorld2D: Fix NearestBodyQuery --- include/Nazara/Physics2D/PhysWorld2D.hpp | 2 +- src/Nazara/Physics2D/PhysWorld2D.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index 3360b6584..efd49c008 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -41,7 +41,7 @@ namespace Nz cpSpace* GetHandle() const; float GetStepSize() const; - bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D* nearestBody); + bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D** nearestBody); bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result); void RegisterCallbacks(unsigned int collisionId, const Callback& callbacks); diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 81d1824f1..1383f931b 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -37,14 +37,14 @@ namespace Nz return m_stepSize; } - bool PhysWorld2D::NearestBodyQuery(const Vector2f & from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D* nearestBody) + bool PhysWorld2D::NearestBodyQuery(const Vector2f & from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D** nearestBody) { cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask); if (cpShape* shape = cpSpacePointQueryNearest(m_handle, {from.x, from.y}, maxDistance, filter, nullptr)) { if (nearestBody) - nearestBody = static_cast(cpShapeGetUserData(shape)); + *nearestBody = static_cast(cpShapeGetUserData(shape)); return true; } From 04f7b401500def9530bb76a8f467ecea55466e3b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Mar 2017 13:07:02 +0100 Subject: [PATCH 140/243] Physics2D/RigidBody2D: Fix querying --- include/Nazara/Physics2D/PhysWorld2D.hpp | 2 +- src/Nazara/Physics2D/RigidBody2D.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index efd49c008..f116b7729 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -41,7 +41,7 @@ namespace Nz cpSpace* GetHandle() const; float GetStepSize() const; - bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D** nearestBody); + bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D** nearestBody = nullptr); bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result); void RegisterCallbacks(unsigned int collisionId, const Callback& callbacks); diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index d4d5aafd0..d96ba3eb1 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -61,6 +61,8 @@ namespace Nz m_mass(object.m_mass) { cpBodySetUserData(m_handle, this); + for (cpShape* shape : m_shapes) + cpShapeSetUserData(shape, this); object.m_handle = nullptr; @@ -312,6 +314,8 @@ namespace Nz m_world = object.m_world; cpBodySetUserData(m_handle, this); + for (cpShape* shape : m_shapes) + cpShapeSetUserData(shape, this); object.m_handle = nullptr; @@ -324,6 +328,7 @@ namespace Nz { m_handle = cpBodyNew(mass, moment); cpBodySetUserData(m_handle, this); + cpSpaceAddBody(m_world->GetHandle(), m_handle); } From f2fb0f62c2dbb66270d0cbde3cc14dc37d60cf0f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Mar 2017 16:18:34 +0100 Subject: [PATCH 141/243] Switch ENet errors to Nazara --- src/Nazara/Network/ENetHost.cpp | 37 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index d32b6d5f9..6f726b644 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -224,9 +224,7 @@ namespace Nz return 1; case -1: - #ifdef ENET_DEBUG - perror("Error sending outgoing packets"); - #endif + NazaraError("Error sending outgoing packets"); return -1; default: @@ -235,34 +233,29 @@ namespace Nz switch (ReceiveIncomingCommands(event)) { - case 1: - return 1; + case 1: + return 1; - case -1: -#ifdef ENET_DEBUG - perror("Error receiving incoming packets"); -#endif + case -1: + NazaraError("Error receiving incoming packets"); + return -1; - return -1; - - default: - break; + default: + break; } switch (SendOutgoingCommands(event, true)) { - case 1: - return 1; + case 1: + return 1; - case -1: -#ifdef ENET_DEBUG - perror("Error sending outgoing packets"); -#endif + case -1: + NazaraError("Error sending outgoing packets"); - return -1; + return -1; - default: - break; + default: + break; } if (event) From 605e5c2fd0ee3563517e7aee6f5933d1ffb4e306 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 3 Mar 2017 17:52:07 +0100 Subject: [PATCH 142/243] Sdk/BaseComponent: Add OnEntityDestruction callback Also fixes physics component callbacks (OnContactEnd by example) being fired while entity is destroyed --- SDK/include/NDK/BaseComponent.hpp | 1 + SDK/include/NDK/Components/PhysicsComponent2D.hpp | 1 + SDK/include/NDK/Components/PhysicsComponent3D.hpp | 1 + SDK/src/NDK/BaseComponent.cpp | 9 +++++++++ SDK/src/NDK/Components/PhysicsComponent2D.cpp | 6 ++++++ SDK/src/NDK/Components/PhysicsComponent3D.cpp | 7 +++++++ SDK/src/NDK/Entity.cpp | 4 ++++ 7 files changed, 29 insertions(+) diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NDK/BaseComponent.hpp index 8a4d51bfe..e21a1e38f 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NDK/BaseComponent.hpp @@ -47,6 +47,7 @@ namespace Ndk virtual void OnComponentAttached(BaseComponent& component); virtual void OnComponentDetached(BaseComponent& component); virtual void OnDetached(); + virtual void OnEntityDestruction(); void SetEntity(Entity* entity); diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.hpp b/SDK/include/NDK/Components/PhysicsComponent2D.hpp index 1f4cc63c9..2bbe693a1 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent2D.hpp @@ -55,6 +55,7 @@ namespace Ndk void OnComponentAttached(BaseComponent& component) override; void OnComponentDetached(BaseComponent& component) override; void OnDetached() override; + void OnEntityDestruction() override; std::unique_ptr m_object; }; diff --git a/SDK/include/NDK/Components/PhysicsComponent3D.hpp b/SDK/include/NDK/Components/PhysicsComponent3D.hpp index f6f13ec09..8be86537e 100644 --- a/SDK/include/NDK/Components/PhysicsComponent3D.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent3D.hpp @@ -62,6 +62,7 @@ namespace Ndk void OnComponentAttached(BaseComponent& component) override; void OnComponentDetached(BaseComponent& component) override; void OnDetached() override; + void OnEntityDestruction() override; std::unique_ptr m_object; }; diff --git a/SDK/src/NDK/BaseComponent.cpp b/SDK/src/NDK/BaseComponent.cpp index 4af8caed2..204076e54 100644 --- a/SDK/src/NDK/BaseComponent.cpp +++ b/SDK/src/NDK/BaseComponent.cpp @@ -54,6 +54,15 @@ namespace Ndk { } + /*! + * \brief Operation to perform when the entity is destroyed and we're still attached to it + * + * \remark This is always called before the entity proper destruction, and thus its components. + */ + void BaseComponent::OnEntityDestruction() + { + } + std::vector BaseComponent::s_entries; std::unordered_map BaseComponent::s_idToIndex; } diff --git a/SDK/src/NDK/Components/PhysicsComponent2D.cpp b/SDK/src/NDK/Components/PhysicsComponent2D.cpp index b64ee37b5..58cab2982 100644 --- a/SDK/src/NDK/Components/PhysicsComponent2D.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent2D.cpp @@ -88,5 +88,11 @@ namespace Ndk m_object.reset(); } + void PhysicsComponent2D::OnEntityDestruction() + { + // Kill rigidbody before entity destruction to force contact callbacks to be called while the entity is still valid + m_object.reset(); + } + ComponentIndex PhysicsComponent2D::componentIndex; } diff --git a/SDK/src/NDK/Components/PhysicsComponent3D.cpp b/SDK/src/NDK/Components/PhysicsComponent3D.cpp index 2581723a7..e0a22d08f 100644 --- a/SDK/src/NDK/Components/PhysicsComponent3D.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent3D.cpp @@ -88,5 +88,12 @@ namespace Ndk m_object.reset(); } + void PhysicsComponent3D::OnEntityDestruction() + { + // Kill rigid body before entity destruction to force contact callbacks to be called while the entity is still valid + m_object.reset(); + + } + ComponentIndex PhysicsComponent3D::componentIndex; } diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index d88556a31..b8c37c761 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -145,6 +145,10 @@ namespace Ndk void Entity::Destroy() { + // We prepare components for entity destruction (some components needs this to handle some final callbacks while the entity is still valid) + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + m_components[i]->OnEntityDestruction(); + // We alert each system for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) { From 3fe54ff777531f1a69a958fc39cd2fc58f2f56fd Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 3 Mar 2017 17:52:19 +0100 Subject: [PATCH 143/243] Sdk/Entity: Add OnEntityDestruction callback --- SDK/include/NDK/Entity.hpp | 3 +++ SDK/src/NDK/Entity.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index ecf9fcc62..e386100f8 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -65,6 +66,8 @@ namespace Ndk Entity& operator=(const Entity&) = delete; Entity& operator=(Entity&&) = delete; + NazaraSignal(OnEntityDestruction, Entity* /*entity*/); + private: Entity(World* world, EntityId id); diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index b8c37c761..ae5743163 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -145,6 +145,9 @@ namespace Ndk void Entity::Destroy() { + OnEntityDestruction(this); + OnEntityDestruction.Clear(); + // We prepare components for entity destruction (some components needs this to handle some final callbacks while the entity is still valid) for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) m_components[i]->OnEntityDestruction(); From d14574151a8fe6b838e8ce390be481ba18a90384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 6 Mar 2017 13:11:17 +0100 Subject: [PATCH 144/243] Build: Add AdditionalCompilationFlags build option --- build/config.lua | 3 +++ build/scripts/common.lua | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/build/config.lua b/build/config.lua index 8ecc7c24e..7c3e5a910 100644 --- a/build/config.lua +++ b/build/config.lua @@ -1,6 +1,9 @@ -- This file contains special configurations values, such as directories to extern libraries (Qt) -- Editing this file is not required to use/compile the engine, as default values should be enough +-- Additionnal compilation flags +--AdditionalCompilationFlags = -fsanitize=address -- Enable ASan + -- Builds Nazara extern libraries (such as lua/STB) BuildDependencies = true diff --git a/build/scripts/common.lua b/build/scripts/common.lua index e3ea13d62..55654c641 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -505,10 +505,24 @@ function NazaraBuild:LoadConfig() end end + local AddStringOption = function (option, name, description) + newoption({ + trigger = name, + description = description + }) + + local str = _OPTIONS[name] + if (str) then + configTable[option] = str + end + end + + AddBoolOption("BuildDependencies", "with-extlibs", "Builds the extern libraries") AddBoolOption("BuildExamples", "with-examples", "Builds the examples") AddBoolOption("ServerMode", "server", "Excludes client-only modules/tools/examples") AddBoolOption("UniteModules", "united", "Builds all the modules as one united library") + AddStringOption("AdditionalCompilationFlags", "compile-flags", "Specify additionnal compilation flags to be added to every generated project") -- Configurations do From 8147b0807e1e27d5d0d02cc516600349c7808bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 6 Mar 2017 13:16:55 +0100 Subject: [PATCH 145/243] Woops --- build/config.lua | 4 ++-- build/scripts/common.lua | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/build/config.lua b/build/config.lua index 7c3e5a910..12a9f8e77 100644 --- a/build/config.lua +++ b/build/config.lua @@ -1,8 +1,8 @@ -- This file contains special configurations values, such as directories to extern libraries (Qt) -- Editing this file is not required to use/compile the engine, as default values should be enough --- Additionnal compilation flags ---AdditionalCompilationFlags = -fsanitize=address -- Enable ASan +-- Additionnal compilation options +--AdditionalCompilationOptions = "-fsanitize=address" -- Enable ASan -- Builds Nazara extern libraries (such as lua/STB) BuildDependencies = true diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 55654c641..790ef2469 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -522,7 +522,29 @@ function NazaraBuild:LoadConfig() AddBoolOption("BuildExamples", "with-examples", "Builds the examples") AddBoolOption("ServerMode", "server", "Excludes client-only modules/tools/examples") AddBoolOption("UniteModules", "united", "Builds all the modules as one united library") - AddStringOption("AdditionalCompilationFlags", "compile-flags", "Specify additionnal compilation flags to be added to every generated project") + + -- AdditionalCompilationOptions + do + newoption({ + trigger = "compile-options", + description = "Specify additionnal compilation options to be added to every generated project." + }) + + configTable["AdditionalCompilationOptions"] = configTable["AdditionalCompilationOptions"] or "" + if (_OPTIONS["compile-options"] ~= nil) then + configTable["AdditionalCompilationOptions"] = configTable["AdditionalCompilationOptions"] .. ";" .. _OPTIONS["compile-options"] + end + + local configs = {} + local paths = string.explode(configTable["AdditionalCompilationOptions"], ";") + for k,v in pairs(paths) do + if (#v > 0) then + table.insert(configs, v) + end + end + + configTable["Configurations"] = configs + end -- Configurations do @@ -806,6 +828,8 @@ function NazaraBuild:PrepareGeneric() buildoptions("-ftree-vectorize") filter({}) + + buildoptions(self.Config["AdditionalCompilationOptions"]) end function NazaraBuild:PrepareMainWorkspace() From f88174c8cafcbebf245ae3f7f1fbe39f7e61e4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 6 Mar 2017 13:20:02 +0100 Subject: [PATCH 146/243] Woops again (works this time) --- build/scripts/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 790ef2469..ea7097e97 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -543,7 +543,7 @@ function NazaraBuild:LoadConfig() end end - configTable["Configurations"] = configs + configTable["AdditionalCompilationOptions"] = configs end -- Configurations From ede6dd90b80c0618d2db17cd62a0a9b3034c3240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 6 Mar 2017 14:02:35 +0100 Subject: [PATCH 147/243] Physics2D/PhysWorld: Add Raycast queries --- include/Nazara/Physics2D/PhysWorld2D.hpp | 12 ++++++ src/Nazara/Physics2D/PhysWorld2D.cpp | 52 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index f116b7729..3f4c3e696 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -31,6 +31,7 @@ namespace Nz public: struct Callback; struct NearestQueryResult; + struct RaycastHit; PhysWorld2D(); PhysWorld2D(const PhysWorld2D&) = delete; @@ -44,6 +45,9 @@ namespace Nz bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D** nearestBody = nullptr); bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result); + bool RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector* hitInfos); + bool RaycastQueryFirst(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RaycastHit* hitInfo = nullptr); + void RegisterCallbacks(unsigned int collisionId, const Callback& callbacks); void RegisterCallbacks(unsigned int collisionIdA, unsigned int collisionIdB, const Callback& callbacks); @@ -72,6 +76,14 @@ namespace Nz float distance; }; + struct RaycastHit + { + Nz::RigidBody2D* nearestBody; + Nz::Vector2f hitPos; + Nz::Vector2f hitNormal; + float fraction; + }; + NazaraSignal(OnPhysWorld2DPreStep, const PhysWorld2D* /*physWorld*/); NazaraSignal(OnPhysWorld2DPostStep, const PhysWorld2D* /*physWorld*/); diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 1383f931b..6b18dbdd8 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -81,6 +81,58 @@ namespace Nz } } + bool PhysWorld2D::RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector* hitInfos) + { + auto callback = [](cpShape* shape, cpVect point, cpVect normal, cpFloat alpha, void* data) + { + std::vector* results = reinterpret_cast*>(data); + + RaycastHit hitInfo; + hitInfo.fraction = alpha; + hitInfo.hitNormal.Set(normal.x, normal.y); + hitInfo.hitPos.Set(point.x, point.y); + hitInfo.nearestBody = static_cast(cpShapeGetUserData(shape)); + + results->emplace_back(std::move(hitInfo)); + }; + + cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask); + + std::size_t previousSize = hitInfos->size(); + cpSpaceSegmentQuery(m_handle, { from.x, from.y }, { to.x, to.y }, radius, filter, callback, hitInfos); + + return hitInfos->size() != previousSize; + } + + bool PhysWorld2D::RaycastQueryFirst(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RaycastHit* hitInfo) + { + cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask); + + if (hitInfo) + { + cpSegmentQueryInfo queryInfo; + + if (cpShape* shape = cpSpaceSegmentQueryFirst(m_handle, { from.x, from.y }, { to.x, to.y }, radius, filter, &queryInfo)) + { + hitInfo->fraction = queryInfo.alpha; + hitInfo->hitNormal.Set(queryInfo.normal.x, queryInfo.normal.y); + hitInfo->hitPos.Set(queryInfo.point.x, queryInfo.point.y); + hitInfo->nearestBody = static_cast(cpShapeGetUserData(queryInfo.shape)); + + return true; + } + else + return false; + } + else + { + if (cpShape* shape = cpSpaceSegmentQueryFirst(m_handle, { from.x, from.y }, { to.x, to.y }, radius, filter, nullptr)) + return true; + else + return false; + } + } + void PhysWorld2D::RegisterCallbacks(unsigned int collisionId, const Callback& callbacks) { InitCallbacks(cpSpaceAddWildcardHandler(m_handle, collisionId), callbacks); From 78d6a69bcbbc84f36e091edbda641f6c9248c1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 7 Mar 2017 09:36:29 +0100 Subject: [PATCH 148/243] Physics2D/PhysWorld2D: Fix SetMass calls during callbacks --- include/Nazara/Physics2D/PhysWorld2D.hpp | 21 ++++++++++- src/Nazara/Physics2D/PhysWorld2D.cpp | 47 ++++++++++++++++++++++++ src/Nazara/Physics2D/RigidBody2D.cpp | 11 ++++-- 3 files changed, 73 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index 3f4c3e696..c3858dc1a 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -19,10 +20,10 @@ struct cpSpace; namespace Nz { - class RigidBody2D; - class NAZARA_PHYSICS2D_API PhysWorld2D { + friend RigidBody2D; + using ContactEndCallback = void(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata); using ContactPreSolveCallback = bool(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata); using ContactPostSolveCallback = void(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata); @@ -90,7 +91,23 @@ namespace Nz private: void InitCallbacks(cpCollisionHandler* handler, const Callback& callbacks); + using PostStep = std::function; + + void OnRigidBodyMoved(RigidBody2D* oldPointer, RigidBody2D* newPointer); + void OnRigidBodyRelease(RigidBody2D* rigidBody); + + void RegisterPostStep(RigidBody2D* rigidBody, PostStep&& func); + + struct PostStepContainer + { + NazaraSlot(RigidBody2D, OnRigidBody2DMove, onMovedSlot); + NazaraSlot(RigidBody2D, OnRigidBody2DRelease, onReleaseSlot); + + std::vector funcs; + }; + std::unordered_map> m_callbacks; + std::unordered_map m_rigidPostSteps; cpSpace* m_handle; float m_stepSize; float m_timestepAccumulator; diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 6b18dbdd8..f3dcba77d 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -164,6 +164,16 @@ namespace Nz cpSpaceStep(m_handle, m_stepSize); OnPhysWorld2DPostStep(this); + if (!m_rigidPostSteps.empty()) + { + for (const auto& pair : m_rigidPostSteps) + { + for (const auto& step : pair.second.funcs) + step(); + } + + m_rigidPostSteps.clear(); + } m_timestepAccumulator -= m_stepSize; } @@ -263,4 +273,41 @@ namespace Nz }; } } + + void PhysWorld2D::OnRigidBodyMoved(RigidBody2D* oldPointer, RigidBody2D* newPointer) + { + auto it = m_rigidPostSteps.find(oldPointer); + if (it == m_rigidPostSteps.end()) + return; //< Shouldn't happen + + m_rigidPostSteps.emplace(std::make_pair(newPointer, std::move(it->second))); + m_rigidPostSteps.erase(oldPointer); + } + + void PhysWorld2D::OnRigidBodyRelease(RigidBody2D* rigidBody) + { + m_rigidPostSteps.erase(rigidBody); + } + + void PhysWorld2D::RegisterPostStep(RigidBody2D* rigidBody, PostStep&& func) + { + // If space isn't locked, no need to wait + if (!cpSpaceIsLocked(m_handle)) + { + func(); + return; + } + + auto it = m_rigidPostSteps.find(rigidBody); + if (it == m_rigidPostSteps.end()) + { + PostStepContainer postStep; + postStep.onMovedSlot.Connect(rigidBody->OnRigidBody2DMove, this, &PhysWorld2D::OnRigidBodyMoved); + postStep.onReleaseSlot.Connect(rigidBody->OnRigidBody2DRelease, this, &PhysWorld2D::OnRigidBodyRelease); + + it = m_rigidPostSteps.insert(std::make_pair(rigidBody, std::move(postStep))).first; + } + + it->second.funcs.emplace_back(std::move(func)); + } } diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index d96ba3eb1..aef36d0ad 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -249,15 +249,18 @@ namespace Nz cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); } else - cpBodySetType(m_handle, CP_BODY_TYPE_STATIC); + m_world->RegisterPostStep(this, [this]() { cpBodySetType(m_handle, CP_BODY_TYPE_STATIC); } ); } else if (mass > 0.f) { if (cpBodyGetType(m_handle) == CP_BODY_TYPE_STATIC) { - cpBodySetType(m_handle, CP_BODY_TYPE_DYNAMIC); - cpBodySetMass(m_handle, mass); - cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); + m_world->RegisterPostStep(this, [this, mass]() + { + cpBodySetType(m_handle, CP_BODY_TYPE_DYNAMIC); + cpBodySetMass(m_handle, mass); + cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); + }); } } From 43f8f21df6a9d3cfb37ff214193d31a03d98a362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 8 Mar 2017 13:16:53 +0100 Subject: [PATCH 149/243] Physics2D/RigidBody2D: Fix SetMass occasionnal crash --- src/Nazara/Physics2D/RigidBody2D.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index aef36d0ad..8bf713402 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -245,23 +245,26 @@ namespace Nz { if (mass > 0.f) { - cpBodySetMass(m_handle, mass); - cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); + m_world->RegisterPostStep(this, [this, mass]() + { + cpBodySetMass(m_handle, mass); + cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); + }); } else m_world->RegisterPostStep(this, [this]() { cpBodySetType(m_handle, CP_BODY_TYPE_STATIC); } ); } else if (mass > 0.f) { - if (cpBodyGetType(m_handle) == CP_BODY_TYPE_STATIC) + m_world->RegisterPostStep(this, [this, mass]() { - m_world->RegisterPostStep(this, [this, mass]() + if (cpBodyGetType(m_handle) == CP_BODY_TYPE_STATIC) { cpBodySetType(m_handle, CP_BODY_TYPE_DYNAMIC); cpBodySetMass(m_handle, mass); cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); - }); - } + } + }); } m_mass = mass; From b0d61802b626858e530db0097ea57b1fd85942a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 8 Mar 2017 13:17:04 +0100 Subject: [PATCH 150/243] Network/SocketPoller: Fix documentation --- src/Nazara/Network/SocketPoller.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Network/SocketPoller.cpp b/src/Nazara/Network/SocketPoller.cpp index fa5aa837e..43250a84f 100644 --- a/src/Nazara/Network/SocketPoller.cpp +++ b/src/Nazara/Network/SocketPoller.cpp @@ -142,13 +142,15 @@ namespace Nz } /*! - * \brief Wait until any registered socket switches to a ready state + * \brief Wait until any registered socket switches to a ready state. * * Waits a specific/undetermined amount of time until at least one socket part of the SocketPoller becomes ready. * To query the ready state of the registered socket, use the IsReady function. * * \param msTimeout Maximum time to wait in milliseconds, 0 for infinity * + * \return True if at least one socket registered to the poller is ready. + * * \remark It is an error to try to unregister a non-registered socket from a SocketPoller. * * \see IsReady From 9c7b2ed4b841b22ba83a7d57af44bc87b4dfbcf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 8 Mar 2017 15:52:59 +0100 Subject: [PATCH 151/243] Sdk/World: Fix entity ids being reused before destruction --- SDK/src/NDK/World.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 545fab499..cad4660d4 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -185,12 +185,12 @@ namespace Ndk NazaraAssert(entity.IsValid(), "Entity must be valid"); - // Send back the identifier of the entity to the free queue - m_freeIdList.push_back(entity.GetId()); - // Destruction of the entity (invalidation of handle by the same way) entity.Destroy(); + // Send back the identifier of the entity to the free queue + m_freeIdList.push_back(entity.GetId()); + // We take out the handle from the list of alive entities // With the idiom swap and pop From 0818a2187bb9cdd9445ad4a2124d09f48e3f2b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 8 Mar 2017 16:32:08 +0100 Subject: [PATCH 152/243] Sdk/Entity: Fix OnDetached being called after OnEntityRemove when destructing --- SDK/src/NDK/Entity.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index ae5743163..29b8f75df 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -152,6 +152,10 @@ namespace Ndk for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) m_components[i]->OnEntityDestruction(); + // Detach components while they're still attached to systems + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + m_components[i]->SetEntity(nullptr); + // We alert each system for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) { @@ -165,10 +169,7 @@ namespace Ndk } m_systemBits.Clear(); - // We properly destroy each component - for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) - m_components[i]->SetEntity(nullptr); - + // Destroy components m_components.clear(); m_componentBits.Reset(); From 4ea43e0b0b35d78c9205380c20570b858415ddee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 8 Mar 2017 17:36:13 +0100 Subject: [PATCH 153/243] Sdk/Entity: Fix problem when moving entities --- SDK/src/NDK/Entity.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 29b8f75df..7cdc87d07 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -30,6 +30,7 @@ namespace Ndk m_enabled(entity.m_enabled), m_valid(entity.m_valid) { + entity.m_world = nullptr; } /*! @@ -53,7 +54,8 @@ namespace Ndk Entity::~Entity() { - Destroy(); + if (m_world) + Destroy(); } /*! From b2e4296cc78f640c853b004b607654187ab35b2f Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Mar 2017 21:05:56 +0100 Subject: [PATCH 154/243] Network/ENetHost: Fix peers default values not being initialized --- src/Nazara/Network/ENetHost.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 6f726b644..d4d1be9f9 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -156,10 +156,6 @@ namespace Nz if (!InitSocket(address)) return false; - m_peers.reserve(peerCount); - for (std::size_t i = 0; i < peerCount; ++i) - m_peers.emplace_back(this, UInt16(i)); - m_address = address; m_randomSeed = *reinterpret_cast(this); m_randomSeed += s_randomGenerator(); @@ -188,6 +184,10 @@ namespace Nz m_maximumPacketSize = ENetConstants::ENetHost_DefaultMaximumPacketSize; m_maximumWaitingData = ENetConstants::ENetHost_DefaultMaximumWaitingData; + m_peers.reserve(peerCount); + for (std::size_t i = 0; i < peerCount; ++i) + m_peers.emplace_back(this, UInt16(i)); + return true; } From 1917a0e8dd9a578bdc32bb8141029aab0e77fac0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Mar 2017 21:06:09 +0100 Subject: [PATCH 155/243] Network/ENetPeer: Fix fragments handling --- src/Nazara/Network/ENetPeer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 5407fec35..2a9adfcbf 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -674,7 +674,7 @@ namespace Nz DispatchIncomingReliableCommands(channel); } - return false; + return true; } bool ENetPeer::HandleSendReliable(const ENetProtocol* command, UInt8** data) From a4fe005e3b0a203610df2f4c780d561740a23009 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Mar 2017 22:40:15 +0100 Subject: [PATCH 156/243] Network/ENetPeer: Fix packets not being resend after timeout sometimes --- src/Nazara/Network/ENetPeer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 2a9adfcbf..5ce92a1e4 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -287,12 +287,15 @@ namespace Nz UInt32 serviceTime = m_host->GetServiceTime(); auto it = m_sentReliableCommands.begin(); - for (; it != m_sentReliableCommands.end(); ++it) + for (; it != m_sentReliableCommands.end();) { OutgoingCommand& command = *it; if (ENetTimeDifference(serviceTime, command.sentTime) < command.roundTripTimeout) + { + ++it; continue; + } if (m_earliestTimeout == 0 || ENetTimeLess(command.sentTime, m_earliestTimeout)) m_earliestTimeout = command.sentTime; @@ -315,6 +318,7 @@ namespace Nz command.roundTripTimeoutLimit = m_timeoutLimit * command.roundTripTimeout; m_outgoingReliableCommands.emplace_front(std::move(command)); + it = m_sentReliableCommands.erase(it); // Okay this should just never procs, I don't see how it would be possible /*if (currentCommand == enet_list_begin(&peer->sentReliableCommands) && @@ -326,8 +330,6 @@ namespace Nz }*/ } - m_sentReliableCommands.erase(m_sentReliableCommands.begin(), it); - return false; } From cdf7c11ef854d5c004e8830db04836f2d6c28c22 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Mar 2017 18:20:18 +0100 Subject: [PATCH 157/243] Fix crash when RigidBody2D is moved while having poststeps --- SDK/src/NDK/Components/PhysicsComponent3D.cpp | 1 - include/Nazara/Physics2D/PhysWorld2D.hpp | 2 +- src/Nazara/Physics2D/PhysWorld2D.cpp | 2 +- src/Nazara/Physics2D/RigidBody2D.cpp | 18 +++++++++--------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/SDK/src/NDK/Components/PhysicsComponent3D.cpp b/SDK/src/NDK/Components/PhysicsComponent3D.cpp index e0a22d08f..31b3fb6ac 100644 --- a/SDK/src/NDK/Components/PhysicsComponent3D.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent3D.cpp @@ -92,7 +92,6 @@ namespace Ndk { // Kill rigid body before entity destruction to force contact callbacks to be called while the entity is still valid m_object.reset(); - } ComponentIndex PhysicsComponent3D::componentIndex; diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index c3858dc1a..7b31d9743 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -91,7 +91,7 @@ namespace Nz private: void InitCallbacks(cpCollisionHandler* handler, const Callback& callbacks); - using PostStep = std::function; + using PostStep = std::function; void OnRigidBodyMoved(RigidBody2D* oldPointer, RigidBody2D* newPointer); void OnRigidBodyRelease(RigidBody2D* rigidBody); diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index f3dcba77d..f77c509ed 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -169,7 +169,7 @@ namespace Nz for (const auto& pair : m_rigidPostSteps) { for (const auto& step : pair.second.funcs) - step(); + step(pair.first); } m_rigidPostSteps.clear(); diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 8bf713402..f31e9ef54 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -245,24 +245,24 @@ namespace Nz { if (mass > 0.f) { - m_world->RegisterPostStep(this, [this, mass]() + m_world->RegisterPostStep(this, [mass](Nz::RigidBody2D* body) { - cpBodySetMass(m_handle, mass); - cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); + cpBodySetMass(body->GetHandle(), mass); + cpBodySetMoment(body->GetHandle(), body->GetGeom()->ComputeInertialMatrix(mass)); }); } else - m_world->RegisterPostStep(this, [this]() { cpBodySetType(m_handle, CP_BODY_TYPE_STATIC); } ); + m_world->RegisterPostStep(this, [](Nz::RigidBody2D* body) { cpBodySetType(body->GetHandle(), CP_BODY_TYPE_STATIC); } ); } else if (mass > 0.f) { - m_world->RegisterPostStep(this, [this, mass]() + m_world->RegisterPostStep(this, [mass](Nz::RigidBody2D* body) { - if (cpBodyGetType(m_handle) == CP_BODY_TYPE_STATIC) + if (cpBodyGetType(body->GetHandle()) == CP_BODY_TYPE_STATIC) { - cpBodySetType(m_handle, CP_BODY_TYPE_DYNAMIC); - cpBodySetMass(m_handle, mass); - cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass)); + cpBodySetType(body->GetHandle(), CP_BODY_TYPE_DYNAMIC); + cpBodySetMass(body->GetHandle(), mass); + cpBodySetMoment(body->GetHandle(), body->GetGeom()->ComputeInertialMatrix(mass)); } }); } From ef474fc3a40d200cad317d81eb48af2e1cc650af Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Mar 2017 18:21:07 +0100 Subject: [PATCH 158/243] Physics2D/PhysWorld2D: Fix compilation --- src/Nazara/Physics2D/PhysWorld2D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index f77c509ed..e56749d66 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -294,7 +294,7 @@ namespace Nz // If space isn't locked, no need to wait if (!cpSpaceIsLocked(m_handle)) { - func(); + func(rigidBody); return; } From 353ade3efd2be0195e26b7ecf6f9b3f3d98cb8f8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Mar 2017 11:36:48 +0100 Subject: [PATCH 159/243] Core/Signal: Make movement noexcept --- include/Nazara/Core/Signal.hpp | 14 +++++++------- include/Nazara/Core/Signal.inl | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index c325b40ce..0dfff4a1e 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -69,7 +69,7 @@ namespace Nz SlotListIndex index; }; - void Disconnect(const SlotPtr& slot); + void Disconnect(const SlotPtr& slot) noexcept; SlotList m_slots; mutable SlotListIndex m_slotIterator; @@ -84,17 +84,17 @@ namespace Nz public: Connection() = default; Connection(const Connection& connection) = default; - Connection(Connection&& connection) = default; + Connection(Connection&& connection) noexcept = default; ~Connection() = default; template void Connect(BaseClass& signal, ConnectArgs&&... args); - void Disconnect(); + void Disconnect() noexcept; bool IsConnected() const; Connection& operator=(const Connection& connection) = default; - Connection& operator=(Connection&& connection) = default; + Connection& operator=(Connection&& connection) noexcept = default; private: Connection(const SlotPtr& slot); @@ -113,12 +113,12 @@ namespace Nz ConnectionGuard(const Connection& connection); ConnectionGuard(const ConnectionGuard& connection) = delete; ConnectionGuard(Connection&& connection); - ConnectionGuard(ConnectionGuard&& connection) = default; + ConnectionGuard(ConnectionGuard&& connection) noexcept = default; ~ConnectionGuard(); template void Connect(BaseClass& signal, ConnectArgs&&... args); - void Disconnect(); + void Disconnect() noexcept; Connection& GetConnection(); @@ -127,7 +127,7 @@ namespace Nz ConnectionGuard& operator=(const Connection& connection); ConnectionGuard& operator=(const ConnectionGuard& connection) = delete; ConnectionGuard& operator=(Connection&& connection); - ConnectionGuard& operator=(ConnectionGuard&& connection); + ConnectionGuard& operator=(ConnectionGuard&& connection) noexcept; private: Connection m_connection; diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index 9e711a65f..65df55712 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -205,7 +205,7 @@ namespace Nz */ template - void Signal::Disconnect(const SlotPtr& slot) + void Signal::Disconnect(const SlotPtr& slot) noexcept { NazaraAssert(slot, "Invalid slot pointer"); NazaraAssert(slot->index < m_slots.size(), "Invalid slot index"); @@ -277,7 +277,7 @@ namespace Nz */ template - void Signal::Connection::Disconnect() + void Signal::Connection::Disconnect() noexcept { if (SlotPtr ptr = m_ptr.lock()) ptr->signal->Disconnect(ptr); @@ -353,7 +353,7 @@ namespace Nz */ template - void Signal::ConnectionGuard::Disconnect() + void Signal::ConnectionGuard::Disconnect() noexcept { m_connection.Disconnect(); } @@ -420,7 +420,7 @@ namespace Nz */ template - typename Signal::ConnectionGuard& Signal::ConnectionGuard::operator=(ConnectionGuard&& connection) + typename Signal::ConnectionGuard& Signal::ConnectionGuard::operator=(ConnectionGuard&& connection) noexcept { m_connection.Disconnect(); m_connection = std::move(connection.m_connection); From 4d932e93170852598dbf13d8e14928326fa6c9d9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Mar 2017 11:36:58 +0100 Subject: [PATCH 160/243] PhysWorld2D: Ensure PostStepContainer is move-constructible noexcept --- include/Nazara/Physics2D/PhysWorld2D.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index 7b31d9743..52db98189 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -106,6 +106,8 @@ namespace Nz std::vector funcs; }; + static_assert(std::is_nothrow_move_constructible::value, "PostStepContainer should be noexcept MoveConstructible"); + std::unordered_map> m_callbacks; std::unordered_map m_rigidPostSteps; cpSpace* m_handle; From 9531edfffc01363ee67dc0025919382498da3ddd Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Mar 2017 17:07:40 +0100 Subject: [PATCH 161/243] Core/Signal: Fix move behaviour with GCC 4.9 .... --- include/Nazara/Core/Signal.inl | 38 ++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index 65df55712..d71388c94 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -246,6 +246,18 @@ namespace Nz * \brief Core class that represents a connection attached to a signal */ + /*! + * \brief Constructs a Signal::Connection object with by move semantic + * + * \param connection Connection object to move + */ + template + Signal::Connection::Connection(Connection&& connection) noexcept : + m_ptr(std::move(connection.m_ptr)) + { + connection.m_ptr.reset(); //< Fuck you GCC 4.9 + } + /*! * \brief Constructs a Signal::Connection object with a slot * @@ -294,6 +306,18 @@ namespace Nz return !m_ptr.expired(); } + /*! + * \brief Constructs a Signal::ConnectionGuard object by move semantic + * + * \param connection Connection to move + */ + template + typename Signal::Connection& Signal::Connection::operator=(Connection&& connection) noexcept + { + m_ptr = std::move(connection.m_ptr); + connection.m_ptr.reset(); //< Fuck you GCC 4.9 + } + /*! * \class Nz::Signal::ConnectionGuard * \brief Core class that represents a RAII for a connection attached to a signal @@ -406,8 +430,11 @@ namespace Nz template typename Signal::ConnectionGuard& Signal::ConnectionGuard::operator=(Connection&& connection) { - m_connection.Disconnect(); - m_connection = std::move(connection); + if (&connection != this) + { + m_connection.Disconnect(); + m_connection = std::move(connection); + } return *this; } @@ -422,8 +449,11 @@ namespace Nz template typename Signal::ConnectionGuard& Signal::ConnectionGuard::operator=(ConnectionGuard&& connection) noexcept { - m_connection.Disconnect(); - m_connection = std::move(connection.m_connection); + if (&connection != this) + { + m_connection.Disconnect(); + m_connection = std::move(connection.m_connection); + } return *this; } From 82edb5c7cb55b4c520be1815ebd9992b4d819c35 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Mar 2017 17:10:11 +0100 Subject: [PATCH 162/243] Core/Signal: Fix compilation --- include/Nazara/Core/Signal.hpp | 4 ++-- include/Nazara/Core/Signal.inl | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index 0dfff4a1e..1569c5d0e 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -84,7 +84,7 @@ namespace Nz public: Connection() = default; Connection(const Connection& connection) = default; - Connection(Connection&& connection) noexcept = default; + Connection(Connection&& connection) noexcept; ~Connection() = default; template @@ -94,7 +94,7 @@ namespace Nz bool IsConnected() const; Connection& operator=(const Connection& connection) = default; - Connection& operator=(Connection&& connection) noexcept = default; + Connection& operator=(Connection&& connection) noexcept; private: Connection(const SlotPtr& slot); diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index d71388c94..c4e89bd40 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -316,6 +316,8 @@ namespace Nz { m_ptr = std::move(connection.m_ptr); connection.m_ptr.reset(); //< Fuck you GCC 4.9 + + return *this; } /*! From 9341f7e62af8269890e89eb3b6683a2d010c882f Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Mar 2017 07:55:54 +0100 Subject: [PATCH 163/243] Add Tutorial 02 source code --- examples/Tut01/main.cpp | 2 +- examples/Tut02/build.lua | 11 +++++++++ examples/Tut02/main.cpp | 50 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 examples/Tut02/build.lua create mode 100644 examples/Tut02/main.cpp diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index b5e07074d..b1d962e1e 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -1,4 +1,4 @@ -// Sources pour https://github.com/DigitalPulseSoftware/NazaraEngine/wiki/(FR)-Tutoriel-01---Hello-World +// Sources pour https://github.com/DigitalPulseSoftware/NazaraEngine/wiki/(FR)-Tutoriel:-%5B01%5D-Hello-World #include #include diff --git a/examples/Tut02/build.lua b/examples/Tut02/build.lua new file mode 100644 index 000000000..dbb8a8c9f --- /dev/null +++ b/examples/Tut02/build.lua @@ -0,0 +1,11 @@ +EXAMPLE.Name = "Tut02_Events" + +EXAMPLE.EnableConsole = true + +EXAMPLE.Files = { + "main.cpp" +} + +EXAMPLE.Libraries = { + "NazaraSDK" +} diff --git a/examples/Tut02/main.cpp b/examples/Tut02/main.cpp new file mode 100644 index 000000000..83de624c6 --- /dev/null +++ b/examples/Tut02/main.cpp @@ -0,0 +1,50 @@ +// Sources pour https://github.com/DigitalPulseSoftware/NazaraEngine/wiki/(FR)-Tutoriel:-%5B02%5D-Gestion-des-événements + +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + Ndk::Application application(argc, argv); + + Nz::RenderWindow& mainWindow = application.AddWindow(); + mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test"); + + mainWindow.EnableCloseOnQuit(false); + + Ndk::World& world = application.AddWorld(); + world.GetSystem().SetGlobalUp(Nz::Vector3f::Down()); + world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(117, 122, 214))); + + Ndk::EntityHandle viewEntity = world.CreateEntity(); + viewEntity->AddComponent(); + + Ndk::CameraComponent& viewer = viewEntity->AddComponent(); + viewer.SetTarget(&mainWindow); + viewer.SetProjectionType(Nz::ProjectionType_Orthogonal); + + + Nz::EventHandler& eventHandler = mainWindow.GetEventHandler(); + eventHandler.OnKeyPressed.Connect([](const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& e) + { + std::cout << Nz::Keyboard::GetKeyName(e.code) << std::endl; + + // Profitons-en aussi pour nous donner un moyen de quitter le programme + if (e.code == Nz::Keyboard::Escape) + Ndk::Application::Instance()->Quit(); // Cette ligne casse la boucle Run() de l'application + }); + + + while (application.Run()) + { + mainWindow.Display(); + } + + return EXIT_SUCCESS; +} From 02508fb99d71c6fb808e3fa51772bd9ff058e974 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Mar 2017 07:49:01 +0100 Subject: [PATCH 164/243] Sdk/BaseComponent: Add GetEntity method --- SDK/include/NDK/BaseComponent.hpp | 1 + SDK/include/NDK/BaseComponent.inl | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NDK/BaseComponent.hpp index e21a1e38f..d9fdcba45 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NDK/BaseComponent.hpp @@ -29,6 +29,7 @@ namespace Ndk virtual std::unique_ptr Clone() const = 0; + inline const EntityHandle& GetEntity() const; ComponentIndex GetIndex() const; inline static ComponentIndex GetMaxComponentIndex(); diff --git a/SDK/include/NDK/BaseComponent.inl b/SDK/include/NDK/BaseComponent.inl index 7abade990..0596eb589 100644 --- a/SDK/include/NDK/BaseComponent.inl +++ b/SDK/include/NDK/BaseComponent.inl @@ -19,11 +19,19 @@ namespace Ndk { } + /*! + * \brief Gets the entity owning this component + * \return A handle to the entity owning this component, may be invalid if no entity owns it. + */ + inline const EntityHandle& BaseComponent::GetEntity() const + { + return m_entity; + } + /*! * \brief Gets the index of the component * \return Index of the component */ - inline ComponentIndex BaseComponent::GetIndex() const { return m_componentIndex; From 6d0314741a94deb33949901e7f1ad043ddbedf86 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 25 Mar 2017 10:12:01 +0100 Subject: [PATCH 165/243] Core/ObjectHandle: Fix self-movement case --- include/Nazara/Core/ObjectHandle.inl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index 920d407a6..f4c70ae85 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -128,6 +128,9 @@ namespace Nz template void ObjectHandle::Reset(ObjectHandle&& handle) noexcept { + if (this == &handle) + return; + if (m_object) m_object->UnregisterHandle(this); From 5ec913311fd6a68f1d65b6ad665b10fd17d0dabc Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 30 Mar 2017 16:32:29 +0200 Subject: [PATCH 166/243] Physics2D/PhysWorld2D: Add RegionQuery method --- include/Nazara/Physics2D/PhysWorld2D.hpp | 2 ++ src/Nazara/Physics2D/PhysWorld2D.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index 52db98189..4873e5642 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -49,6 +49,8 @@ namespace Nz bool RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector* hitInfos); bool RaycastQueryFirst(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RaycastHit* hitInfo = nullptr); + void RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector* bodies); + void RegisterCallbacks(unsigned int collisionId, const Callback& callbacks); void RegisterCallbacks(unsigned int collisionIdA, unsigned int collisionIdB, const Callback& callbacks); diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index e56749d66..0e22ae0af 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -83,9 +83,11 @@ namespace Nz bool PhysWorld2D::RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector* hitInfos) { + using ResultType = decltype(hitInfos); + auto callback = [](cpShape* shape, cpVect point, cpVect normal, cpFloat alpha, void* data) { - std::vector* results = reinterpret_cast*>(data); + ResultType results = static_cast(data); RaycastHit hitInfo; hitInfo.fraction = alpha; @@ -133,6 +135,20 @@ namespace Nz } } + void PhysWorld2D::RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector* bodies) + { + using ResultType = decltype(bodies); + + auto callback = [] (cpShape* shape, void* data) + { + ResultType results = static_cast(data); + results->push_back(static_cast(cpShapeGetUserData(shape))); + }; + + cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask); + cpSpaceBBQuery(m_handle, cpBBNew(boundingBox.x, boundingBox.y + boundingBox.height, boundingBox.x + boundingBox.width, boundingBox.y), filter, callback, bodies); + } + void PhysWorld2D::RegisterCallbacks(unsigned int collisionId, const Callback& callbacks) { InitCallbacks(cpSpaceAddWildcardHandler(m_handle, collisionId), callbacks); From bb272c57f5c0a55cddd90d864745b0ede0068aa8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 30 Mar 2017 18:43:05 +0200 Subject: [PATCH 167/243] Lua/LuaInstance: Fix movement --- include/Nazara/Lua/LuaInstance.hpp | 4 ++-- include/Nazara/Lua/LuaInstance.inl | 27 ------------------------- src/Nazara/Lua/LuaInstance.cpp | 32 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index 5f27c76e6..39b0879a8 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -31,7 +31,7 @@ namespace Nz public: LuaInstance(); LuaInstance(const LuaInstance&) = delete; - inline LuaInstance(LuaInstance&& instance) noexcept; + LuaInstance(LuaInstance&& instance) noexcept; ~LuaInstance(); void ArgCheck(bool condition, unsigned int argNum, const char* error) const; @@ -173,7 +173,7 @@ namespace Nz void* ToUserdata(int index, const String& tname) const; LuaInstance& operator=(const LuaInstance&) = delete; - inline LuaInstance& operator=(LuaInstance&& instance) noexcept; + LuaInstance& operator=(LuaInstance&& instance) noexcept; static int GetIndexOfUpValue(int upValue); static LuaInstance* GetInstance(lua_State* state); diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index 9c54982e4..c2e299ed4 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -14,18 +14,6 @@ namespace Nz { - inline LuaInstance::LuaInstance(LuaInstance&& instance) noexcept : - m_memoryLimit(instance.m_memoryLimit), - m_memoryUsage(instance.m_memoryUsage), - m_timeLimit(instance.m_timeLimit), - m_clock(std::move(instance.m_clock)), - m_lastError(std::move(instance.m_lastError)), - m_state(instance.m_state), - m_level(instance.m_level) - { - instance.m_state = nullptr; - } - inline lua_State* LuaInstance::GetInternalState() const { return m_state; @@ -51,21 +39,6 @@ namespace Nz return m_timeLimit; } - inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept - { - m_clock = std::move(instance.m_clock); - m_lastError = std::move(instance.m_lastError); - m_level = instance.m_level; - m_memoryLimit = instance.m_memoryLimit; - m_memoryUsage = instance.m_memoryUsage; - m_state = instance.m_state; - m_timeLimit = instance.m_timeLimit; - - instance.m_state = nullptr; - - return *this; - } - // Functions args inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag) { diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 5e23d0a86..380e7c48f 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -143,6 +143,20 @@ namespace Nz luaL_openlibs(m_state); } + LuaInstance::LuaInstance(LuaInstance&& instance) noexcept : + m_memoryLimit(instance.m_memoryLimit), + m_memoryUsage(instance.m_memoryUsage), + m_timeLimit(instance.m_timeLimit), + m_clock(std::move(instance.m_clock)), + m_lastError(std::move(instance.m_lastError)), + m_state(instance.m_state), + m_level(instance.m_level) + { + instance.m_state = nullptr; + + lua_setallocf(m_state, MemoryAllocator, this); + } + LuaInstance::~LuaInstance() { if (m_state) @@ -801,6 +815,24 @@ namespace Nz return luaL_testudata(m_state, index, tname.GetConstBuffer()); } + LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept + { + m_clock = std::move(instance.m_clock); + m_lastError = std::move(instance.m_lastError); + m_level = instance.m_level; + m_memoryLimit = instance.m_memoryLimit; + m_memoryUsage = instance.m_memoryUsage; + m_state = instance.m_state; + m_timeLimit = instance.m_timeLimit; + + instance.m_state = nullptr; + + // Update allocator pointer + lua_setallocf(m_state, MemoryAllocator, this); + + return *this; + } + int LuaInstance::GetIndexOfUpValue(int upValue) { return lua_upvalueindex(upValue); From eac291955136bd4745e5ca3ceda6517075d7ab90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 5 Apr 2017 10:10:42 +0200 Subject: [PATCH 168/243] Build/Package: Copy .pdb in the bin directory --- build/scripts/actions/package.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index cbdae329c..bc86c4ba4 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -85,8 +85,8 @@ ACTION.Function = function () local exeFileExt local exeFilterFunc if (os.is("windows")) then - binFileMasks = {"**.dll"} - libFileMasks = {"**.lib", "**.a", "**.pdb"} + binFileMasks = {"**.dll", "**.pdb"} + libFileMasks = {"**.lib", "**.a"} exeFileExt = ".exe" exeFilterFunc = function (filePath) return true end else From ca4a93c4af42c84f36ec99c9943151786be3db58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 5 Apr 2017 15:57:54 +0200 Subject: [PATCH 169/243] Fix compilation error on Linux --- include/Nazara/Lua/LuaInstance.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index c2e299ed4..b30c7eca4 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include From 7b4f4380653de678e59626fa7dc4d92904ff2b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 14 Apr 2017 16:53:03 +0200 Subject: [PATCH 170/243] Math/Algorithm: Fix NumberEquals for signed integers --- include/Nazara/Math/Algorithm.inl | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index 9a0eaabfb..612cdf952 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -97,6 +97,29 @@ namespace Nz return 0; } + + template /*constexpr*/ std::enable_if_t::value || !std::is_integral::value, bool> NumberEquals(T a, T b, T maxDifference) + { + if (b > a) + std::swap(a, b); + + T diff = a - b; + return diff <= maxDifference; + } + + template /*constexpr*/ std::enable_if_t::value && std::is_integral::value, bool> NumberEquals(T a, T b, T maxDifference) + { + if (b > a) + std::swap(a, b); + + if ((b < 0) && (a > std::numeric_limits::max() + b)) + return false; + + if ((b > 0) && (a < std::numeric_limits::min() + b)) + return false; + + return std::abs(a - b) <= maxDifference; + } } /*! @@ -565,11 +588,7 @@ namespace Nz //TODO: Mark as constexpr when supported by all major compilers /*constexpr*/ inline bool NumberEquals(T a, T b, T maxDifference) { - if (b > a) - std::swap(a, b); - - T diff = a - b; - return diff <= maxDifference; + return Detail::NumberEquals(a, b, maxDifference); } /*! From 0a75bce99d9cae5a04ca5a53ef769106f2648ff5 Mon Sep 17 00:00:00 2001 From: Santiago Castro Date: Tue, 18 Apr 2017 00:36:28 -0300 Subject: [PATCH 171/243] Fix broken Markdown headings (#124) --- readme_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme_fr.md b/readme_fr.md index 808788b0d..22215c42c 100644 --- a/readme_fr.md +++ b/readme_fr.md @@ -43,7 +43,7 @@ Vous pouvez lire des tutoriaux sur l'installation, la compilation et l'utilisati [Wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) [Forum](https://forum.digitalpulsesoftware.net) -###Remerciements: +### Remerciements: - **RafBill** et **Raakz:** Recherche de bugs et/ou tests - **Fissal "DrFisher" Hannoun**: Aide et conseils lors de la conception de l'architecture du moteur From eb70453574e87eeae2e57b648830711e3ea1e647 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Thu, 20 Apr 2017 12:30:43 +0200 Subject: [PATCH 172/243] State machine as a stack (#123) * State machine as a stack * Fix comments linked to code review * I will think to compile, next time --- SDK/include/NDK/StateMachine.hpp | 14 +++- SDK/include/NDK/StateMachine.inl | 137 +++++++++++++++++++++++++------ tests/SDK/NDK/StateMachine.cpp | 64 ++++++++++++++- 3 files changed, 186 insertions(+), 29 deletions(-) diff --git a/SDK/include/NDK/StateMachine.hpp b/SDK/include/NDK/StateMachine.hpp index dae81ecd0..e9e665c44 100644 --- a/SDK/include/NDK/StateMachine.hpp +++ b/SDK/include/NDK/StateMachine.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace Ndk { @@ -25,14 +26,21 @@ namespace Ndk inline const std::shared_ptr& GetCurrentState() const; + inline bool IsTopState(const State* state) const; + + inline std::shared_ptr PopState(); + inline bool PopStatesUntil(std::shared_ptr state); + inline void PushState(std::shared_ptr state); + + inline void SetState(std::shared_ptr state); + inline bool Update(float elapsedTime); inline StateMachine& operator=(StateMachine&& fsm) = default; StateMachine& operator=(const StateMachine&) = delete; private: - std::shared_ptr m_currentState; - std::shared_ptr m_nextState; + std::vector> m_states; }; } diff --git a/SDK/include/NDK/StateMachine.inl b/SDK/include/NDK/StateMachine.inl index d30146a97..1086df54d 100644 --- a/SDK/include/NDK/StateMachine.inl +++ b/SDK/include/NDK/StateMachine.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include -#include #include namespace Ndk @@ -11,7 +10,7 @@ namespace Ndk /*! * \ingroup NDK * \class Ndk::StateMachine - * \brief NDK class that represents a state machine, to represent the multiple states of your program + * \brief NDK class that represents a state machine, to represent the multiple states of your program as a stack */ /*! @@ -23,61 +22,153 @@ namespace Ndk * \remark Produces a NazaraAssert if nullptr is given */ - inline StateMachine::StateMachine(std::shared_ptr originalState) : - m_currentState(std::move(originalState)) + inline StateMachine::StateMachine(std::shared_ptr originalState) { - NazaraAssert(m_currentState, "StateMachine must have a state to begin with"); - m_currentState->Enter(*this); + NazaraAssert(originalState, "StateMachine must have a state to begin with"); + PushState(std::move(originalState)); } /*! * \brief Destructs the object * - * \remark Calls "Leave" on the state + * \remark Calls "Leave" on all the states */ inline StateMachine::~StateMachine() { - m_currentState->Leave(*this); + for (std::shared_ptr& state : m_states) + state->Leave(*this); } /*! - * \brief Changes the current state of the machine + * \brief Replaces the current state on the top of the machine * - * \param state Next state to represent + * \param state State to replace the top one if it is nullptr, no action is performed */ inline void StateMachine::ChangeState(std::shared_ptr state) { - m_nextState = std::move(state); + if (state) + { + PopState(); + PushState(std::move(state)); + } } /*! - * \brief Gets the current state of the machine + * \brief Gets the current state on the top of the machine * \return A constant reference to the state + * + * \remark The stack is supposed to be non empty, otherwise it is undefined behaviour + * + * \see PopStatesUntil */ inline const std::shared_ptr& StateMachine::GetCurrentState() const { - return m_currentState; + return m_states.back(); } /*! - * \brief Updates the state - * \return True if update is successful + * \brief Checks whether the state is on the top of the machine + * \return true If it is the case + * + * \param state State to compare the top with + */ + + inline bool StateMachine::IsTopState(const State* state) const + { + if (m_states.empty()) + return false; + + return m_states.back().get() == state; + } + + /*! + * \brief Pops the state on the top of the machine + * \return Old state on the top, nullptr if stack was empty + * + * \remark This method can completely empty the stack + */ + + inline std::shared_ptr StateMachine::PopState() + { + if (m_states.empty()) + return nullptr; + + m_states.back()->Leave(*this); + std::shared_ptr oldTopState = std::move(m_states.back()); + m_states.pop_back(); + return oldTopState; + } + + /*! + * \brief Pops all the states of the machine until a specific one is reached + * \return true If that specific state is on top, false if stack is empty + * + * \param state State to find on the stack if it is nullptr, no action is performed + * + * \remark This method can completely empty the stack + */ + + inline bool StateMachine::PopStatesUntil(std::shared_ptr state) + { + if (!state) + return false; + + while (!m_states.empty() && !IsTopState(state.get())) + PopState(); + + return !m_states.empty(); + } + + /*! + * \brief Pushes a new state on the top of the machine + * + * \param state Next state to represent if it is nullptr, it performs no action + * + * \remark Produces a NazaraAssert if the same state is pushed two times on the stack + */ + + inline void StateMachine::PushState(std::shared_ptr state) + { + if (state) + { + NazaraAssert(std::find(m_states.begin(), m_states.end(), state) == m_states.end(), "The same state was pushed two times"); + + m_states.push_back(std::move(state)); + m_states.back()->Enter(*this); + } + } + + /*! + * \brief Pops every states of the machine to put a new one + * + * \param state State to reset the stack with if it is nullptr, no action is performed + */ + + inline void StateMachine::SetState(std::shared_ptr state) + { + if (state) + { + while (!m_states.empty()) + PopState(); + + PushState(std::move(state)); + } + } + + /*! + * \brief Updates all the states + * \return true If update is successful for everyone of them * * \param elapsedTime Delta time used for the update */ inline bool StateMachine::Update(float elapsedTime) { - if (m_nextState) - { - m_currentState->Leave(*this); - m_currentState = std::move(m_nextState); - m_currentState->Enter(*this); - } - - return m_currentState->Update(*this, elapsedTime); + return std::all_of(m_states.begin(), m_states.end(), [=](std::shared_ptr& state) { + return state->Update(*this, elapsedTime); + }); } } diff --git a/tests/SDK/NDK/StateMachine.cpp b/tests/SDK/NDK/StateMachine.cpp index 1c14b1e76..066a150d7 100644 --- a/tests/SDK/NDK/StateMachine.cpp +++ b/tests/SDK/NDK/StateMachine.cpp @@ -28,21 +28,79 @@ class TestState : public Ndk::State bool m_isUpdated; }; +class SecondTestState : public Ndk::State +{ + public: + void Enter(Ndk::StateMachine& /*fsm*/) override + { + m_isUpdated = false; + } + + bool IsUpdated() const + { + return m_isUpdated; + } + + void Leave(Ndk::StateMachine& /*fsm*/) override + { + } + + bool Update(Ndk::StateMachine& fsm, float /*elapsedTime*/) override + { + if (fsm.IsTopState(this)) + m_isUpdated = true; + return true; + } + + private: + bool m_isUpdated; +}; + SCENARIO("State & StateMachine", "[NDK][STATE]") { - GIVEN("A statemachine with our TestState") + GIVEN("A statemachine with our test states") { std::shared_ptr testState = std::make_shared(); - Ndk::StateMachine stateMachine(testState); + std::shared_ptr secondTestState = std::make_shared(); + Ndk::StateMachine stateMachine(secondTestState); + stateMachine.PushState(testState); REQUIRE(!testState->IsUpdated()); + REQUIRE(!secondTestState->IsUpdated()); WHEN("We update our machine") { stateMachine.Update(1.f); - THEN("Our state has been updated") + THEN("Our state on the top has been updated but not the bottom one") { + REQUIRE(stateMachine.IsTopState(testState.get())); + REQUIRE(!stateMachine.IsTopState(secondTestState.get())); + REQUIRE(testState->IsUpdated()); + REQUIRE(!secondTestState->IsUpdated()); + } + } + + WHEN("We exchange the states' positions while emptying the stack") + { + REQUIRE(stateMachine.PopStatesUntil(secondTestState)); + REQUIRE(stateMachine.IsTopState(secondTestState.get())); + + std::shared_ptr oldState = stateMachine.PopState(); + REQUIRE(stateMachine.PopState() == nullptr); + + stateMachine.SetState(testState); + stateMachine.PushState(oldState); + + stateMachine.Update(1.f); + + THEN("Both states should be updated") + { + REQUIRE(!stateMachine.IsTopState(testState.get())); + REQUIRE(stateMachine.IsTopState(secondTestState.get())); + + REQUIRE(testState->IsUpdated()); + REQUIRE(secondTestState->IsUpdated()); } } } From 48b348135ee7a93ebcaebf15aee47e69b76de183 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 20 Apr 2017 23:42:45 +0200 Subject: [PATCH 173/243] Refactor EntityList and prevent World to invalidate its own handles between updates --- SDK/include/NDK/EntityList.cpp | 0 SDK/include/NDK/EntityList.hpp | 62 +++++---- SDK/include/NDK/EntityList.inl | 163 +++++++++++++---------- SDK/include/NDK/Systems/RenderSystem.hpp | 2 +- SDK/include/NDK/World.hpp | 16 ++- SDK/include/NDK/World.inl | 11 +- SDK/src/NDK/EntityList.cpp | 14 ++ SDK/src/NDK/Systems/RenderSystem.cpp | 25 +++- SDK/src/NDK/World.cpp | 82 +++++++----- 9 files changed, 231 insertions(+), 144 deletions(-) create mode 100644 SDK/include/NDK/EntityList.cpp create mode 100644 SDK/src/NDK/EntityList.cpp diff --git a/SDK/include/NDK/EntityList.cpp b/SDK/include/NDK/EntityList.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/SDK/include/NDK/EntityList.hpp b/SDK/include/NDK/EntityList.hpp index 4047388cc..22a632e65 100644 --- a/SDK/include/NDK/EntityList.hpp +++ b/SDK/include/NDK/EntityList.hpp @@ -16,45 +16,59 @@ namespace Ndk class NDK_API EntityList { public: - using Container = std::vector; + class iterator; + friend iterator; + using size_type = std::size_t; - EntityList() = default; + inline EntityList(); ~EntityList() = default; inline void Clear(); - inline bool Has(const Entity* entity); - inline bool Has(EntityId entity); + inline bool Has(const Entity* entity) const; + inline bool Has(EntityId entity) const; inline void Insert(Entity* entity); inline void Remove(Entity* entity); // STL API - inline Container::iterator begin(); - inline Container::const_iterator begin() const; - - inline Container::const_iterator cbegin() const; - inline Container::const_iterator cend() const; - inline Container::const_reverse_iterator crbegin() const; - inline Container::const_reverse_iterator crend() const; - + inline iterator begin(); inline bool empty() const; - - inline Container::iterator end(); - inline Container::const_iterator end() const; - - inline Container::reverse_iterator rbegin(); - inline Container::const_reverse_iterator rbegin() const; - - inline Container::reverse_iterator rend(); - inline Container::const_reverse_iterator rend() const; - - inline Container::size_type size() const; + inline iterator end(); + inline size_type size() const; private: - std::vector m_entities; + inline std::size_t FindNext(std::size_t currentId) const; + inline World* GetWorld() const; + Nz::Bitset m_entityBits; + World* m_world; + }; + + class EntityList::iterator : public std::iterator + { + friend EntityList; + + public: + inline iterator(const iterator& iterator); + + const EntityHandle& operator*() const; + + inline iterator& operator=(const iterator& iterator); + inline iterator& operator++(); + inline iterator operator++(int); + + friend inline bool operator==(const iterator& lhs, const iterator& rhs); + friend inline bool operator!=(const iterator& lhs, const iterator& rhs); + + friend inline void swap(iterator& lhs, iterator& rhs); + + private: + inline iterator(const EntityList* world, std::size_t nextId); + + std::size_t m_nextEntityId; + const EntityList* m_list; }; } diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index 126af0a7e..6d9447a7f 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -2,8 +2,10 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include +#include "EntityList.hpp" namespace Ndk { @@ -16,22 +18,34 @@ namespace Ndk /*! * \brief Clears the set from every entities */ - - inline void EntityList::Clear() + inline EntityList::EntityList() : + m_world(nullptr) { - m_entities.clear(); - m_entityBits.Clear(); } /*! - * \brief Checks whether or not the set contains the entity + * \brief Clears the set from every entities + * + * \remark This resets the implicit world member, allowing you to insert entities from a different world than previously + */ + inline void EntityList::Clear() + { + m_entityBits.Clear(); + m_world = nullptr; + } + + /*! + * \brief Checks whether or not the EntityList contains the entity * \return true If it is the case * * \param entity Pointer to the entity + * + * \remark If the Insert function was called since the EntityList construction (or last call to Clear), the entity passed by parameter must belong to the same world as the previously inserted entities. */ - - inline bool EntityList::Has(const Entity* entity) + inline bool EntityList::Has(const Entity* entity) const { + NazaraAssert(!m_world || !entity || entity->GetWorld() == m_world, "Incompatible world"); + return entity && entity->IsValid() && Has(entity->GetId()); } @@ -41,8 +55,7 @@ namespace Ndk * * \param id Identifier of the entity */ - - inline bool EntityList::Has(EntityId entity) + inline bool EntityList::Has(EntityId entity) const { return m_entityBits.UnboundedTest(entity); } @@ -50,18 +63,18 @@ namespace Ndk /*! * \brief Inserts the entity into the set * - * \param entity Pointer to the entity + * \param entity Valid pointer to an entity * * \remark If entity is already contained, no action is performed + * \remark If any entity has been inserted since construction (or last Clear call), the entity must belong to the same world as the previously inserted entities */ - inline void EntityList::Insert(Entity* entity) { - if (!Has(entity)) - { - m_entities.emplace_back(entity); - m_entityBits.UnboundedSet(entity->GetId(), true); - } + NazaraAssert(entity, "Invalid entity"); + NazaraAssert(!m_world || entity->GetWorld() == m_world, "Incompatible world"); + + m_entityBits.UnboundedSet(entity->GetId(), true); + m_world = entity->GetWorld(); } /*! @@ -70,89 +83,101 @@ namespace Ndk * \param entity Pointer to the entity * * \remark If entity is not contained, no action is performed + * \remark This function never resets the implicit world member, even if it empties the list. Use the Clear method if you want to reset it. + * + * \see Clear */ - inline void EntityList::Remove(Entity* entity) { - if (Has(entity)) - { - auto it = std::find(m_entities.begin(), m_entities.end(), *entity); - NazaraAssert(it != m_entities.end(), "Entity should be part of the vector"); - - std::swap(*it, m_entities.back()); - m_entities.pop_back(); // We get it out of the vector - m_entityBits.UnboundedSet(entity->GetId(), false); - } + m_entityBits.UnboundedSet(entity->GetId(), false); } - // Nz::Interface STD - inline EntityList::Container::iterator EntityList::begin() + // STL Interface + inline EntityList::iterator EntityList::begin() { - return m_entities.begin(); - } - - inline EntityList::Container::const_iterator EntityList::begin() const - { - return m_entities.begin(); - } - - inline EntityList::Container::const_iterator EntityList::cbegin() const - { - return m_entities.cbegin(); - } - - inline EntityList::Container::const_iterator EntityList::cend() const - { - return m_entities.cend(); - } - - inline EntityList::Container::const_reverse_iterator EntityList::crbegin() const - { - return m_entities.crbegin(); - } - - inline EntityList::Container::const_reverse_iterator EntityList::crend() const - { - return m_entities.crend(); + return EntityList::iterator(this, m_entityBits.FindFirst()); } inline bool EntityList::empty() const { - return m_entities.empty(); + return m_entityBits.TestAny(); } - inline EntityList::Container::iterator EntityList::end() + inline EntityList::iterator EntityList::end() { - return m_entities.end(); + return EntityList::iterator(this, m_entityBits.npos); } - inline EntityList::Container::const_iterator EntityList::end() const + inline EntityList::size_type EntityList::size() const { - return m_entities.end(); + return m_entityBits.Count(); } - inline EntityList::Container::reverse_iterator EntityList::rbegin() + inline std::size_t EntityList::FindNext(std::size_t currentId) const { - return m_entities.rbegin(); + return m_entityBits.FindNext(currentId); } - inline EntityList::Container::const_reverse_iterator EntityList::rbegin() const + inline World* EntityList::GetWorld() const { - return m_entities.rbegin(); + return m_world; } - inline EntityList::Container::reverse_iterator EntityList::rend() + + inline EntityList::iterator::iterator(const EntityList* list, std::size_t nextId) : + m_nextEntityId(nextId), + m_list(list) { - return m_entities.rend(); } - inline EntityList::Container::const_reverse_iterator EntityList::rend() const + inline EntityList::iterator::iterator(const iterator& iterator) : + m_nextEntityId(iterator.m_nextEntityId), + m_list(iterator.m_list) { - return m_entities.rend(); } - inline EntityList::Container::size_type EntityList::size() const + inline EntityList::iterator& EntityList::iterator::operator=(const iterator& iterator) { - return m_entities.size(); + m_nextEntityId = iterator.m_nextEntityId; + m_list = iterator.m_list; + + return *this; + } + + inline EntityList::iterator& EntityList::iterator::operator++() + { + m_nextEntityId = m_list->FindNext(m_nextEntityId); + + return *this; + } + + inline EntityList::iterator EntityList::iterator::operator++(int) + { + std::size_t previousId = m_nextEntityId; + + m_nextEntityId = m_list->FindNext(m_nextEntityId); + + return iterator(m_list, previousId); + } + + inline bool operator==(const EntityList::iterator& lhs, const EntityList::iterator& rhs) + { + NazaraAssert(lhs.m_list == rhs.m_list, "Cannot compare iterator coming from different lists"); + + return lhs.m_nextEntityId == rhs.m_nextEntityId; + } + + inline bool operator!=(const EntityList::iterator& lhs, const EntityList::iterator& rhs) + { + return !operator==(lhs, rhs); + } + + inline void swap(EntityList::iterator& lhs, EntityList::iterator& rhs) + { + NazaraAssert(lhs.m_list == rhs.m_list, "Cannot compare iterator coming from different lists"); + + using std::swap; + + std::swap(lhs.m_nextEntityId, rhs.m_nextEntityId); } } diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index 61f7bd0a0..a74cb9d0e 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -57,7 +57,7 @@ namespace Ndk std::unique_ptr m_renderTechnique; std::vector m_volumeEntries; - EntityList m_cameras; + std::vector m_cameras; EntityList m_drawables; EntityList m_directionalLights; EntityList m_lights; diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index 9b2546eda..b1f1abde1 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,7 @@ namespace Ndk friend Entity; public: - using EntityList = std::vector; + using EntityVector = std::vector; inline World(bool addDefaultSystems = true); World(const World&) = delete; @@ -41,13 +42,13 @@ namespace Ndk template SystemType& AddSystem(Args&&... args); const EntityHandle& CreateEntity(); - inline EntityList CreateEntities(unsigned int count); + inline EntityVector CreateEntities(unsigned int count); void Clear() noexcept; const EntityHandle& CloneEntity(EntityId id); const EntityHandle& GetEntity(EntityId id); - inline const EntityList& GetEntities(); + inline const EntityList& GetEntities() const; inline BaseSystem& GetSystem(SystemIndex index); template SystemType& GetSystem(); @@ -55,7 +56,7 @@ namespace Ndk template bool HasSystem() const; void KillEntity(Entity* entity); - inline void KillEntities(const EntityList& list); + inline void KillEntities(const EntityVector& list); inline bool IsEntityValid(const Entity* entity) const; inline bool IsEntityIdValid(EntityId id) const; @@ -79,19 +80,22 @@ namespace Ndk struct EntityBlock { EntityBlock(Entity&& e) : - entity(std::move(e)) + entity(std::move(e)), + handle(&entity) { } EntityBlock(EntityBlock&& block) = default; Entity entity; - std::size_t aliveIndex; + EntityHandle handle; }; std::vector> m_systems; std::vector m_orderedSystems; std::vector m_entities; + std::vector m_entityBlocks; + std::vector> m_waitingEntities; std::vector m_freeIdList; EntityList m_aliveEntities; Nz::Bitset m_dirtyEntities; diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index dcdb0c057..45d358ad4 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -82,9 +82,9 @@ namespace Ndk * \param count Number of entities to create */ - inline World::EntityList World::CreateEntities(unsigned int count) + inline World::EntityVector World::CreateEntities(unsigned int count) { - EntityList list; + EntityVector list; list.reserve(count); for (unsigned int i = 0; i < count; ++i) @@ -98,7 +98,7 @@ namespace Ndk * \return A constant reference to the entities */ - inline const World::EntityList& World::GetEntities() + inline const EntityList& World::GetEntities() const { return m_aliveEntities; } @@ -170,7 +170,7 @@ namespace Ndk * \param list Set of entities to kill */ - inline void World::KillEntities(const EntityList& list) + inline void World::KillEntities(const EntityVector& list) { for (const EntityHandle& entity : list) KillEntity(entity); @@ -197,7 +197,7 @@ namespace Ndk inline bool World::IsEntityIdValid(EntityId id) const { - return id < m_entities.size() && m_entities[id].entity.IsValid(); + return id < m_entityBlocks.size() && m_entityBlocks[id]->entity.IsValid(); } /*! @@ -270,6 +270,7 @@ namespace Ndk m_killedEntities = std::move(world.m_killedEntities); m_orderedSystems = std::move(world.m_orderedSystems); m_orderedSystemsUpdated = world.m_orderedSystemsUpdated; + m_waitingEntities = std::move(world.m_waitingEntities); m_entities = std::move(world.m_entities); for (EntityBlock& block : m_entities) diff --git a/SDK/src/NDK/EntityList.cpp b/SDK/src/NDK/EntityList.cpp new file mode 100644 index 000000000..03fd3afc3 --- /dev/null +++ b/SDK/src/NDK/EntityList.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#include +#include + +namespace Ndk +{ + const EntityHandle& EntityList::iterator::operator*() const + { + return m_list->GetWorld()->GetEntity(static_cast(m_nextEntityId)); + } +} diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index f586056a2..44b0d1bba 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -48,7 +48,15 @@ namespace Ndk { m_forceRenderQueueInvalidation = true; //< Hackfix until lights and particles are handled by culling list - m_cameras.Remove(entity); + for (auto it = m_cameras.begin(); it != m_cameras.end(); ++it) + { + if (it->GetObject() == entity) + { + m_cameras.erase(it); + break; + } + } + m_directionalLights.Remove(entity); m_drawables.Remove(entity); m_lights.Remove(entity); @@ -74,14 +82,23 @@ namespace Ndk if (entity->HasComponent() && entity->HasComponent()) { - m_cameras.Insert(entity); + m_cameras.emplace_back(entity); std::sort(m_cameras.begin(), m_cameras.end(), [](const EntityHandle& handle1, const EntityHandle& handle2) { return handle1->GetComponent().GetLayer() < handle2->GetComponent().GetLayer(); }); } else - m_cameras.Remove(entity); + { + for (auto it = m_cameras.begin(); it != m_cameras.end(); ++it) + { + if (it->GetObject() == entity) + { + m_cameras.erase(it); + break; + } + } + } if (entity->HasComponent() && entity->HasComponent()) { @@ -181,7 +198,7 @@ namespace Ndk GraphicsComponent& graphicsComponent = drawable->GetComponent(); graphicsComponent.EnsureBoundingVolumeUpdate(); } - + bool forceInvalidation = false; std::size_t visibilityHash = m_drawableCulling.Cull(camComponent.GetFrustum(), &forceInvalidation); diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index cad4660d4..db3cef529 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -60,29 +60,47 @@ namespace Ndk const EntityHandle& World::CreateEntity() { EntityId id; + EntityBlock* entBlock; if (!m_freeIdList.empty()) { // We get an identifier id = m_freeIdList.back(); m_freeIdList.pop_back(); + + entBlock = &m_entities[id]; + m_entityBlocks[id] = entBlock; } else { // We allocate a new entity id = static_cast(m_entities.size()); - // We can't use emplace_back due to the scope - m_entities.push_back(Entity(this, id)); + if (m_entities.capacity() > m_entities.size()) + { + m_entities.push_back(Entity(this, id)); //< We can't use emplace_back due to the scope + entBlock = &m_entities.back(); + } + else + { + // Pushing to entities would reallocate vector and thus, invalidate EntityHandles (which we don't want until world update) + // To prevent this, allocate them into a separate vector and move them at update + // For now, we are counting on m_entities grow strategy to prevent + m_waitingEntities.emplace_back(std::make_unique(Entity(this, id))); + entBlock = m_waitingEntities.back().get(); + } + + if (id >= m_entityBlocks.size()) + m_entityBlocks.resize(id + 1); + + m_entityBlocks[id] = entBlock; } - // We initialise the entity and we add it to the list of alive entities - Entity& entity = m_entities[id].entity; - entity.Create(); + // We initialize the entity and we add it to the list of alive entities + entBlock->entity.Create(); - m_aliveEntities.emplace_back(&entity); - m_entities[id].aliveIndex = m_aliveEntities.size() - 1; + m_aliveEntities.Insert(&entBlock->entity); - return m_aliveEntities.back(); + return entBlock->handle; } /*! @@ -97,7 +115,7 @@ namespace Ndk // This is made to avoid that handle warn uselessly entities before their destruction m_entities.clear(); - m_aliveEntities.clear(); + m_aliveEntities.Clear(); m_dirtyEntities.Clear(); m_killedEntities.Clear(); } @@ -158,7 +176,7 @@ namespace Ndk const EntityHandle& World::GetEntity(EntityId id) { if (IsEntityIdValid(id)) - return m_aliveEntities[m_entities[id].aliveIndex]; + return m_entities[id].handle; else { NazaraError("Invalid ID"); @@ -177,45 +195,39 @@ namespace Ndk if (!m_orderedSystemsUpdated) ReorderSystems(); + // Move waiting entities to entity list + if (!m_waitingEntities.empty()) + { + constexpr std::size_t MinEntityCapacity = 10; //< We want to be able to grow entity count by at least ten entities per update without going to the waiting list + + m_entities.reserve(m_entities.size() + m_waitingEntities.size() + MinEntityCapacity); + for (auto& blockPtr : m_waitingEntities) + m_entities.push_back(std::move(*blockPtr)); + + m_waitingEntities.clear(); + } + // Handle killed entities before last call for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i)) { - EntityBlock& block = m_entities[i]; - Entity& entity = block.entity; + NazaraAssert(i < m_entityBlocks.size(), "Entity index out of range"); - NazaraAssert(entity.IsValid(), "Entity must be valid"); + Entity* entity = &m_entityBlocks[i]->entity; // Destruction of the entity (invalidation of handle by the same way) - entity.Destroy(); + entity->Destroy(); // Send back the identifier of the entity to the free queue - m_freeIdList.push_back(entity.GetId()); - - // We take out the handle from the list of alive entities - // With the idiom swap and pop - - NazaraAssert(block.aliveIndex < m_aliveEntities.size(), "Alive index out of range"); - - if (block.aliveIndex < m_aliveEntities.size() - 1) // If it's not the last handle - { - EntityHandle& lastHandle = m_aliveEntities.back(); - EntityHandle& myHandle = m_aliveEntities[block.aliveIndex]; - - myHandle = std::move(lastHandle); - - // We don't forget to update the index associated to the entity - m_entities[myHandle->GetId()].aliveIndex = block.aliveIndex; - } - m_aliveEntities.pop_back(); + m_freeIdList.push_back(entity->GetId()); } m_killedEntities.Reset(); // Handle of entities which need an update from the systems for (std::size_t i = m_dirtyEntities.FindFirst(); i != m_dirtyEntities.npos; i = m_dirtyEntities.FindNext(i)) { - NazaraAssert(i < m_entities.size(), "Entity index out of range"); + NazaraAssert(i < m_entityBlocks.size(), "Entity index out of range"); - Entity* entity = &m_entities[i].entity; + Entity* entity = &m_entityBlocks[i]->entity; // Check entity validity (as it could have been reported as dirty and killed during the same iteration) if (!entity->IsValid()) @@ -242,7 +254,7 @@ namespace Ndk } else { - // No, it shouldn't, remove it if it's part of the system + // No it shouldn't, remove it if it's part of the system if (partOfSystem) system->RemoveEntity(entity); } From 53b92106ff29b9257725a39bad41e1846923ae22 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 21 Apr 2017 01:02:23 +0200 Subject: [PATCH 174/243] Sdk/World: Fix block pointers --- SDK/src/NDK/World.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index db3cef529..3daf21e06 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -73,7 +73,7 @@ namespace Ndk else { // We allocate a new entity - id = static_cast(m_entities.size()); + id = static_cast(m_entityBlocks.size()); if (m_entities.capacity() > m_entities.size()) { @@ -205,6 +205,10 @@ namespace Ndk m_entities.push_back(std::move(*blockPtr)); m_waitingEntities.clear(); + + // Update entity blocks pointers + for (std::size_t i = 0; i < m_entities.size(); ++i) + m_entityBlocks[i] = &m_entities[i]; } // Handle killed entities before last call From 203509f14163e34930d4021847307cbecb53281e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 21 Apr 2017 01:02:46 +0200 Subject: [PATCH 175/243] Sdk/BaseSystem: Reuse EntityList --- SDK/include/NDK/BaseSystem.hpp | 6 ++--- SDK/include/NDK/BaseSystem.inl | 22 +++++------------- SDK/include/NDK/EntityList.hpp | 11 ++++++--- SDK/include/NDK/EntityList.inl | 41 +++++++++++++++++++++++++++++++--- 4 files changed, 54 insertions(+), 26 deletions(-) diff --git a/SDK/include/NDK/BaseSystem.hpp b/SDK/include/NDK/BaseSystem.hpp index a323f2952..99dcbf768 100644 --- a/SDK/include/NDK/BaseSystem.hpp +++ b/SDK/include/NDK/BaseSystem.hpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace Ndk @@ -33,7 +34,7 @@ namespace Ndk bool Filters(const Entity* entity) const; - inline const std::vector& GetEntities() const; + inline const EntityList& GetEntities() const; inline SystemIndex GetIndex() const; inline int GetUpdateOrder() const; inline float GetUpdateRate() const; @@ -84,12 +85,11 @@ namespace Ndk static inline bool Initialize(); static inline void Uninitialize(); - std::vector m_entities; - Nz::Bitset m_entityBits; Nz::Bitset<> m_excludedComponents; mutable Nz::Bitset<> m_filterResult; Nz::Bitset<> m_requiredAnyComponents; Nz::Bitset<> m_requiredComponents; + EntityList m_entities; SystemIndex m_systemIndex; World* m_world; bool m_updateEnabled; diff --git a/SDK/include/NDK/BaseSystem.inl b/SDK/include/NDK/BaseSystem.inl index e949d254b..5969dd8e3 100644 --- a/SDK/include/NDK/BaseSystem.inl +++ b/SDK/include/NDK/BaseSystem.inl @@ -56,7 +56,7 @@ namespace Ndk * \return A constant reference to the list of entities */ - inline const std::vector& BaseSystem::GetEntities() const + inline const EntityList& BaseSystem::GetEntities() const { return m_entities; } @@ -121,10 +121,7 @@ namespace Ndk inline bool BaseSystem::HasEntity(const Entity* entity) const { - if (!entity) - return false; - - return m_entityBits.UnboundedTest(entity->GetId()); + return m_entities.Has(entity); } /*! @@ -288,9 +285,7 @@ namespace Ndk { NazaraAssert(entity, "Invalid entity"); - m_entities.emplace_back(entity); - m_entityBits.UnboundedSet(entity->GetId(), true); - + m_entities.Insert(entity); entity->RegisterSystem(m_systemIndex); OnEntityAdded(entity); @@ -308,14 +303,7 @@ namespace Ndk { NazaraAssert(entity, "Invalid entity"); - auto it = std::find(m_entities.begin(), m_entities.end(), *entity); - NazaraAssert(it != m_entities.end(), "Entity is not part of this system"); - - // To avoid moving a lot of handles, we swap and pop - std::swap(*it, m_entities.back()); - m_entities.pop_back(); // We get it out of the vector - - m_entityBits.Reset(entity->GetId()); + m_entities.Remove(entity); entity->UnregisterSystem(m_systemIndex); OnEntityRemoved(entity); // And we alert our callback @@ -360,7 +348,7 @@ namespace Ndk } /*! - * \brief Uninitializes the BaseSystem + * \brief Uninitialize the BaseSystem */ inline void BaseSystem::Uninitialize() diff --git a/SDK/include/NDK/EntityList.hpp b/SDK/include/NDK/EntityList.hpp index 22a632e65..76097f87b 100644 --- a/SDK/include/NDK/EntityList.hpp +++ b/SDK/include/NDK/EntityList.hpp @@ -21,6 +21,8 @@ namespace Ndk using size_type = std::size_t; inline EntityList(); + inline EntityList(const EntityList& entityList); + inline EntityList(EntityList&& entityList) noexcept; ~EntityList() = default; inline void Clear(); @@ -33,11 +35,14 @@ namespace Ndk inline void Remove(Entity* entity); // STL API - inline iterator begin(); + inline iterator begin() const; inline bool empty() const; - inline iterator end(); + inline iterator end() const; inline size_type size() const; + inline EntityList& operator=(const EntityList& entityList); + inline EntityList& operator=(EntityList&& entityList) noexcept; + private: inline std::size_t FindNext(std::size_t currentId) const; inline World* GetWorld() const; @@ -46,7 +51,7 @@ namespace Ndk World* m_world; }; - class EntityList::iterator : public std::iterator + class NDK_API EntityList::iterator : public std::iterator { friend EntityList; diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index 6d9447a7f..8d639b762 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -16,13 +16,32 @@ namespace Ndk */ /*! - * \brief Clears the set from every entities + * \brief Construct a new entity list */ inline EntityList::EntityList() : m_world(nullptr) { } + /*! + * \brief Construct a new entity list by copying another one + */ + inline EntityList::EntityList(const EntityList& entityList) : + m_entityBits(entityList.m_entityBits), + m_world(entityList.m_world) + { + } + + /*! + * \brief Construct a new entity list by moving a list into this one + */ + inline EntityList::EntityList(EntityList&& entityList) noexcept : + m_entityBits(std::move(entityList.m_entityBits)), + m_world(entityList.m_world) + { + } + + /*! * \brief Clears the set from every entities * @@ -93,7 +112,7 @@ namespace Ndk } // STL Interface - inline EntityList::iterator EntityList::begin() + inline EntityList::iterator EntityList::begin() const { return EntityList::iterator(this, m_entityBits.FindFirst()); } @@ -103,7 +122,7 @@ namespace Ndk return m_entityBits.TestAny(); } - inline EntityList::iterator EntityList::end() + inline EntityList::iterator EntityList::end() const { return EntityList::iterator(this, m_entityBits.npos); } @@ -113,6 +132,22 @@ namespace Ndk return m_entityBits.Count(); } + inline EntityList& EntityList::operator=(const EntityList& entityList) + { + m_entityBits = entityList.m_entityBits; + m_world = entityList.m_world; + + return *this; + } + + inline EntityList& EntityList::operator=(EntityList && entityList) noexcept + { + m_entityBits = std::move(entityList.m_entityBits); + m_world = entityList.m_world; + + return *this; + } + inline std::size_t EntityList::FindNext(std::size_t currentId) const { return m_entityBits.FindNext(currentId); From 3c99782643007fbb501c25e517d0b6e839b3e6cc Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 21 Apr 2017 21:27:07 +0200 Subject: [PATCH 176/243] Sdk/EntityList: Fix empty() behavior --- SDK/include/NDK/EntityList.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index 8d639b762..ad87540cd 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -119,7 +119,7 @@ namespace Ndk inline bool EntityList::empty() const { - return m_entityBits.TestAny(); + return !m_entityBits.TestAny(); } inline EntityList::iterator EntityList::end() const From 4f6706284e99eb0f85fa200bcd064ba8c1cd8dce Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 21 Apr 2017 21:27:27 +0200 Subject: [PATCH 177/243] Sdk/World: Fix entity block handling --- SDK/include/NDK/World.inl | 3 ++- SDK/src/NDK/World.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index 45d358ad4..4720ab3db 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -266,6 +266,7 @@ namespace Ndk { m_aliveEntities = std::move(world.m_aliveEntities); m_dirtyEntities = std::move(world.m_dirtyEntities); + m_entityBlocks = std::move(world.m_entityBlocks); m_freeIdList = std::move(world.m_freeIdList); m_killedEntities = std::move(world.m_killedEntities); m_orderedSystems = std::move(world.m_orderedSystems); @@ -285,7 +286,7 @@ namespace Ndk inline void World::Invalidate() { - m_dirtyEntities.Resize(m_entities.size(), false); + m_dirtyEntities.Resize(m_entityBlocks.size(), false); m_dirtyEntities.Set(true); // Activation of all bits } diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 3daf21e06..a40d5f175 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -68,6 +68,8 @@ namespace Ndk m_freeIdList.pop_back(); entBlock = &m_entities[id]; + entBlock->handle.Reset(&entBlock->entity); //< Reset handle (as it was reset when entity got destroyed) + m_entityBlocks[id] = entBlock; } else @@ -114,6 +116,7 @@ namespace Ndk // First, destruction of entities, then handles // This is made to avoid that handle warn uselessly entities before their destruction m_entities.clear(); + m_entityBlocks.clear(); m_aliveEntities.Clear(); m_dirtyEntities.Clear(); From 33b10989e2da7f7c39ac68d618d513a6f9dc28ec Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 21 Apr 2017 21:39:37 +0200 Subject: [PATCH 178/243] Physics2D/PhysWorld2D: Initialize callbacks to nullptr to prevent misuse --- include/Nazara/Physics2D/PhysWorld2D.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index 4873e5642..30a3b1141 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -64,10 +64,10 @@ namespace Nz struct Callback { - ContactEndCallback endCallback; - ContactPreSolveCallback preSolveCallback; - ContactPostSolveCallback postSolveCallback; - ContactStartCallback startCallback; + ContactEndCallback endCallback = nullptr; + ContactPreSolveCallback preSolveCallback = nullptr; + ContactPostSolveCallback postSolveCallback = nullptr; + ContactStartCallback startCallback = nullptr; void* userdata; }; From 140e52203d25c0a5df6c6bf3efdd39dcd428a271 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 21 Apr 2017 21:48:05 +0200 Subject: [PATCH 179/243] Graphics/ForwardRenderQueue: Cleanup a bit --- include/Nazara/Graphics/ForwardRenderQueue.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index f0ac6edda..218fd312d 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -73,7 +73,7 @@ namespace Nz std::vector billboards; }; - typedef std::map BatchedBillboardContainer; + using BatchedBillboardContainer = std::map; struct BatchedBillboardPipelineEntry { @@ -81,7 +81,7 @@ namespace Nz bool enabled = false; }; - typedef std::map BillboardPipelineBatches; + using BillboardPipelineBatches = std::map; /// Sprites struct SpriteChain_XYZ_Color_UV @@ -97,7 +97,7 @@ namespace Nz std::vector spriteChains; }; - typedef std::map SpriteOverlayBatches; + using SpriteOverlayBatches = std::map; struct BatchedBasicSpriteEntry { @@ -107,7 +107,7 @@ namespace Nz bool enabled = false; }; - typedef std::map SpriteMaterialBatches; + using SpriteMaterialBatches = std::map; struct BatchedSpritePipelineEntry { @@ -115,7 +115,7 @@ namespace Nz bool enabled = false; }; - typedef std::map SpritePipelineBatches; + using SpritePipelineBatches = std::map; /// Meshes struct MeshDataComparator @@ -132,7 +132,7 @@ namespace Nz Spheref squaredBoundingSphere; }; - typedef std::map MeshInstanceContainer; + using MeshInstanceContainer = std::map; struct BatchedModelEntry { @@ -142,7 +142,7 @@ namespace Nz bool enabled = false; }; - typedef std::map MeshMaterialBatches; + using MeshMaterialBatches = std::map; struct BatchedMaterialEntry { @@ -150,7 +150,7 @@ namespace Nz MeshMaterialBatches materialMap; }; - typedef std::map MeshPipelineBatches; + using MeshPipelineBatches = std::map; struct TransparentModelData { @@ -160,7 +160,7 @@ namespace Nz const Material* material; }; - typedef std::vector TransparentModelContainer; + using TransparentModelContainer = std::vector; struct Layer { From c06db7d9c5a796a54f7f073ae97b1a796a77676c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 12:58:14 +0200 Subject: [PATCH 180/243] SDK: Fix unit tests --- tests/SDK/NDK/BaseSystem.cpp | 4 ++-- tests/SDK/NDK/Entity.cpp | 12 ++++++------ tests/SDK/NDK/EntityOwner.cpp | 6 +++--- tests/SDK/NDK/World.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/SDK/NDK/BaseSystem.cpp b/tests/SDK/NDK/BaseSystem.cpp index a202c1f70..3bb0fa9e4 100644 --- a/tests/SDK/NDK/BaseSystem.cpp +++ b/tests/SDK/NDK/BaseSystem.cpp @@ -38,7 +38,7 @@ SCENARIO("BaseSystem", "[NDK][BASESYSTEM]") WHEN("We add an entity") { - const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::EntityHandle entity = world.CreateEntity(); entity->AddComponent(); THEN("System should have it") @@ -50,7 +50,7 @@ SCENARIO("BaseSystem", "[NDK][BASESYSTEM]") WHEN("We add an entity with excluded component") { - const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::EntityHandle entity = world.CreateEntity(); entity->AddComponent(); entity->AddComponent(); diff --git a/tests/SDK/NDK/Entity.cpp b/tests/SDK/NDK/Entity.cpp index cf02370ec..dd3216fb0 100644 --- a/tests/SDK/NDK/Entity.cpp +++ b/tests/SDK/NDK/Entity.cpp @@ -57,18 +57,18 @@ SCENARIO("Entity", "[NDK][ENTITY]") { Ndk::World world; Ndk::BaseSystem& system = world.AddSystem(); - const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::EntityHandle entity = world.CreateEntity(); WHEN("We add our UpdateComponent") { UpdatableComponent& updatableComponent = entity->AddComponent(); - REQUIRE(!updatableComponent.IsUpdated()); + CHECK(!updatableComponent.IsUpdated()); THEN("Update the world should update the entity's component") { world.Update(1.f); UpdatableComponent& updatableComponentGet = entity->GetComponent(); - REQUIRE(updatableComponentGet.IsUpdated()); + CHECK(updatableComponentGet.IsUpdated()); } THEN("Update the world should not update the entity's component if it's disabled") @@ -76,14 +76,14 @@ SCENARIO("Entity", "[NDK][ENTITY]") entity->Enable(false); world.Update(1.f); UpdatableComponent& updatableComponentGet = entity->GetComponent(); - REQUIRE(!updatableComponentGet.IsUpdated()); + CHECK(!updatableComponentGet.IsUpdated()); } THEN("We can remove its component") { entity->RemoveComponent(Ndk::GetComponentIndex()); world.Update(1.f); - REQUIRE(!entity->HasComponent()); + CHECK(!entity->HasComponent()); } } @@ -94,7 +94,7 @@ SCENARIO("Entity", "[NDK][ENTITY]") THEN("It's no more valid") { - REQUIRE(!world.IsEntityValid(entity)); + CHECK(!world.IsEntityValid(entity)); } } } diff --git a/tests/SDK/NDK/EntityOwner.cpp b/tests/SDK/NDK/EntityOwner.cpp index eb9a29edf..df5130c2a 100644 --- a/tests/SDK/NDK/EntityOwner.cpp +++ b/tests/SDK/NDK/EntityOwner.cpp @@ -7,7 +7,7 @@ SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]") GIVEN("A world & an entity") { Ndk::World world; - const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::EntityHandle entity = world.CreateEntity(); WHEN("We set the ownership of the entity to our owner") { @@ -15,14 +15,14 @@ SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]") THEN("Entity is still valid") { - REQUIRE(entity.IsValid()); + CHECK(entity.IsValid()); } THEN("Resetting or getting out of scope is no more valid") { entityOwner.Reset(); world.Update(1.f); - REQUIRE(!entity.IsValid()); + CHECK(!entity.IsValid()); } } } diff --git a/tests/SDK/NDK/World.cpp b/tests/SDK/NDK/World.cpp index 85ee241b4..d46b6621b 100644 --- a/tests/SDK/NDK/World.cpp +++ b/tests/SDK/NDK/World.cpp @@ -79,7 +79,7 @@ SCENARIO("World", "[NDK][WORLD]") AND_WHEN("We update our world with our entity") { REQUIRE(&world.GetSystem(UpdateSystem::systemIndex) == &world.GetSystem()); - const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::EntityHandle entity = world.CreateEntity(); UpdatableComponent& component = entity->AddComponent(); THEN("Our entity component must be updated") From 0708531f6c78325fdb42ab1deb711a360f760399 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 12:58:39 +0200 Subject: [PATCH 181/243] Sdk/World: Inline GetEntity and KillEntity --- SDK/include/NDK/World.hpp | 4 ++-- SDK/include/NDK/World.inl | 37 ++++++++++++++++++++++++++++++++++++- SDK/src/NDK/World.cpp | 36 +----------------------------------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index b1f1abde1..29b9a4a9e 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -47,7 +47,7 @@ namespace Ndk void Clear() noexcept; const EntityHandle& CloneEntity(EntityId id); - const EntityHandle& GetEntity(EntityId id); + inline const EntityHandle& GetEntity(EntityId id); inline const EntityList& GetEntities() const; inline BaseSystem& GetSystem(SystemIndex index); template SystemType& GetSystem(); @@ -55,7 +55,7 @@ namespace Ndk inline bool HasSystem(SystemIndex index) const; template bool HasSystem() const; - void KillEntity(Entity* entity); + inline void KillEntity(Entity* entity); inline void KillEntities(const EntityVector& list); inline bool IsEntityValid(const Entity* entity) const; diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index 4720ab3db..d45f0ff1d 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -164,18 +164,53 @@ namespace Ndk return HasSystem(index); } + /*! + * \brief Marks an entity for deletion + * + * \param Pointer to the entity + * + * \remark If the entity pointer is invalid, nothing is done + * \remark For safety, entities are not killed until the next world update + */ + inline void World::KillEntity(Entity* entity) + { + if (IsEntityValid(entity)) + m_killedEntities.UnboundedSet(entity->GetId(), true); + } + /*! * \brief Kills a set of entities * + * This function has the same effect as calling KillEntity for every entity contained in the vector + * * \param list Set of entities to kill */ - inline void World::KillEntities(const EntityVector& list) { for (const EntityHandle& entity : list) KillEntity(entity); } + /*! + * \brief Gets an entity + * \return A constant reference to a handle of the entity + * + * \param id Identifier of the entity + * + * \remark Handle referenced by this function can move in memory when updating the world, do not keep a reference to a handle from a world update to another + * \remark If an invalid identifier is provided, an error got triggered and an invalid handle is returned + */ + inline const EntityHandle& World::GetEntity(EntityId id) + { + if (IsEntityIdValid(id)) + return m_entityBlocks[id]->handle; + else + { + NazaraError("Invalid ID"); + return EntityHandle::InvalidHandle; + } + } + /*! * \brief Checks whether or not an entity is valid * \return true If it is the case diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index a40d5f175..88a23060d 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -141,7 +141,7 @@ namespace Ndk return EntityHandle::InvalidHandle; } - EntityHandle clone = CreateEntity(); + const EntityHandle& clone = CreateEntity(); const Nz::Bitset<>& componentBits = original->GetComponentBits(); for (std::size_t i = componentBits.FindFirst(); i != componentBits.npos; i = componentBits.FindNext(i)) @@ -153,40 +153,6 @@ namespace Ndk return GetEntity(clone->GetId()); } - /*! - * \brief Kills an entity - * - * \param Pointer to the entity - * - * \remark No change is done if entity is invalid - */ - - void World::KillEntity(Entity* entity) - { - if (IsEntityValid(entity)) - m_killedEntities.UnboundedSet(entity->GetId(), true); - } - - /*! - * \brief Gets an entity - * \return A constant reference to the modified entity - * - * \param id Identifier of the entity - * - * \remark Produces a NazaraError if entity identifier is not valid - */ - - const EntityHandle& World::GetEntity(EntityId id) - { - if (IsEntityIdValid(id)) - return m_entities[id].handle; - else - { - NazaraError("Invalid ID"); - return EntityHandle::InvalidHandle; - } - } - /*! * \brief Updates the world * From ec310b957749d36ced26a6c99c2b9a8beabed965 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 12:59:06 +0200 Subject: [PATCH 182/243] Sdk/Entity: Fix removed components sometimes not being removed --- SDK/src/NDK/Entity.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 7cdc87d07..7419ac627 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -24,6 +24,7 @@ namespace Ndk HandledObject(std::move(entity)), m_components(std::move(entity.m_components)), m_componentBits(std::move(entity.m_componentBits)), + m_removedComponentBits(std::move(entity.m_removedComponentBits)), m_systemBits(std::move(entity.m_systemBits)), m_id(entity.m_id), m_world(entity.m_world), From 06038a4d81feda62e87e1a5ac975b4d723936555 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 15:08:05 +0200 Subject: [PATCH 183/243] Cleanup pass --- include/Nazara/Math/Box.hpp | 4 +-- include/Nazara/Math/Box.inl | 34 +++++------------- include/Nazara/Math/Rect.hpp | 4 +-- include/Nazara/Math/Rect.inl | 32 ++++------------- include/Nazara/Math/Sphere.hpp | 4 +-- include/Nazara/Math/Sphere.inl | 34 +++++------------- include/Nazara/Utility/IndexIterator.hpp | 18 +++++----- include/Nazara/Utility/IndexIterator.inl | 16 ++++----- include/Nazara/Utility/IndexMapper.hpp | 18 +++++----- include/Nazara/Utility/TriangleIterator.hpp | 6 ++-- plugins/Assimp/Plugin.cpp | 8 ++--- src/Nazara/Core/Hash/MD5.cpp | 8 ++--- src/Nazara/Core/Hash/Whirlpool.cpp | 12 +++---- src/Nazara/Core/String.cpp | 2 +- .../Graphics/ForwardRenderTechnique.cpp | 4 +-- src/Nazara/Physics2D/PhysWorld2D.cpp | 18 +++++----- src/Nazara/Physics2D/RigidBody2D.cpp | 2 +- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 8 ++--- src/Nazara/Utility/Formats/OBJLoader.cpp | 4 +-- src/Nazara/Utility/Formats/OBJParser.cpp | 6 ++-- src/Nazara/Utility/IndexMapper.cpp | 36 +++++++------------ src/Nazara/Utility/Mesh.cpp | 16 ++++----- src/Nazara/Utility/SimpleTextDrawer.cpp | 6 ++-- src/Nazara/Utility/Skeleton.cpp | 17 +++------ src/Nazara/Utility/TriangleIterator.cpp | 13 ++----- 25 files changed, 124 insertions(+), 206 deletions(-) diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index b3f0aed2b..9434cda27 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -74,8 +74,8 @@ namespace Nz Box& Transform(const Matrix4& matrix, bool applyTranslation = true); Box& Translate(const Vector3& translation); - T& operator[](unsigned int i); - T operator[](unsigned int i) const; + T& operator[](std::size_t i); + T operator[](std::size_t i) const; Box operator*(T scalar) const; Box operator*(const Vector3& vec) const; diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index fb22039ba..1b5276ee6 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -735,24 +735,15 @@ namespace Nz * \brief Returns the ith element of the box * \return A reference to the ith element of the box * - * \remark Access to index greather than 6 is undefined behavior - * \remark Produce a NazaraError if you try to acces to index greather than 6 with NAZARA_MATH_SAFE defined + * \remark Access to index greater than 6 is undefined behavior + * \remark Produce a NazaraError if you try to access to index greater than 6 with NAZARA_MATH_SAFE defined * \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 6 */ template - T& Box::operator[](unsigned int i) + T& Box::operator[](std::size_t i) { - #if NAZARA_MATH_SAFE - if (i >= 6) - { - StringStream ss; - ss << "Index out of range: (" << i << " >= 6)"; - - NazaraError(ss); - throw std::domain_error(ss.ToString()); - } - #endif + NazaraAssert(i < 6, "Index out of range"); return *(&x+i); } @@ -761,24 +752,15 @@ namespace Nz * \brief Returns the ith element of the box * \return A value to the ith element of the box * - * \remark Access to index greather than 6 is undefined behavior - * \remark Produce a NazaraError if you try to acces to index greather than 6 with NAZARA_MATH_SAFE defined + * \remark Access to index greater than 6 is undefined behavior + * \remark Produce a NazaraError if you try to access to index greater than 6 with NAZARA_MATH_SAFE defined * \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 6 */ template - T Box::operator[](unsigned int i) const + T Box::operator[](std::size_t i) const { - #if NAZARA_MATH_SAFE - if (i >= 6) - { - StringStream ss; - ss << "Index out of range: (" << i << " >= 6)"; - - NazaraError(ss); - throw std::domain_error(ss.ToString()); - } - #endif + NazaraAssert(i < 6, "Index out of range"); return *(&x+i); } diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index f297cddd3..9ca7f2ef5 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -64,8 +64,8 @@ namespace Nz Rect& Translate(const Vector2& translation); - T& operator[](unsigned int i); - T operator[](unsigned int i) const; + T& operator[](std::size_t i); + T operator[](std::size_t i) const; Rect operator*(T scalar) const; Rect operator*(const Vector2& vec) const; diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 0365ebf54..47a837cbd 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -578,23 +578,14 @@ namespace Nz * \return A reference to the ith element of the rectangle * * \remark Access to index greather than 4 is undefined behavior - * \remark Produce a NazaraError if you try to acces to index greather than 4 with NAZARA_MATH_SAFE defined + * \remark Produce a NazaraError if you try to access to index greater than 4 with NAZARA_MATH_SAFE defined * \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4 */ template - T& Rect::operator[](unsigned int i) + T& Rect::operator[](std::size_t i) { - #if NAZARA_MATH_SAFE - if (i >= 4) - { - StringStream ss; - ss << "Index out of range: (" << i << " >= 4)"; - - NazaraError(ss); - throw std::domain_error(ss.ToString()); - } - #endif + NazaraAssert(i < 4, "Index out of range"); return *(&x+i); } @@ -603,24 +594,15 @@ namespace Nz * \brief Returns the ith element of the rectangle * \return A value to the ith element of the rectangle * - * \remark Access to index greather than 4 is undefined behavior - * \remark Produce a NazaraError if you try to acces to index greather than 4 with NAZARA_MATH_SAFE defined + * \remark Access to index greater than 4 is undefined behavior + * \remark Produce a NazaraError if you try to access to index greater than 4 with NAZARA_MATH_SAFE defined * \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4 */ template - T Rect::operator[](unsigned int i) const + T Rect::operator[](std::size_t i) const { - #if NAZARA_MATH_SAFE - if (i >= 4) - { - StringStream ss; - ss << "Index out of range: (" << i << " >= 4)"; - - NazaraError(ss); - throw std::domain_error(ss.ToString()); - } - #endif + NazaraAssert(i < 4, "Index out of range"); return *(&x+i); } diff --git a/include/Nazara/Math/Sphere.hpp b/include/Nazara/Math/Sphere.hpp index 57d2d6765..cfa693507 100644 --- a/include/Nazara/Math/Sphere.hpp +++ b/include/Nazara/Math/Sphere.hpp @@ -60,8 +60,8 @@ namespace Nz String ToString() const; - T& operator[](unsigned int i); - T operator[](unsigned int i) const; + T& operator[](std::size_t i); + T operator[](std::size_t i) const; Sphere operator*(T scalar) const; Sphere& operator=(const Sphere& other) = default; diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index 8d803c2e0..5aede77c2 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -466,24 +466,15 @@ namespace Nz * \brief Returns the ith element of the sphere * \return A reference to the ith element of the sphere * - * \remark Access to index greather than 4 is undefined behavior - * \remark Produce a NazaraError if you try to acces to index greather than 4 with NAZARA_MATH_SAFE defined + * \remark Access to index greater than 4 is undefined behavior + * \remark Produce a NazaraError if you try to access to index greater than 4 with NAZARA_MATH_SAFE defined * \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4 */ template - T& Sphere::operator[](unsigned int i) + T& Sphere::operator[](std::size_t i) { - #if NAZARA_MATH_SAFE - if (i >= 4) - { - StringStream ss; - ss << "Index out of range: (" << i << " >= 4)"; - - NazaraError(ss); - throw std::domain_error(ss.ToString()); - } - #endif + NazaraAssert(i < 4, "Index out of range"); return *(&x+i); } @@ -492,24 +483,15 @@ namespace Nz * \brief Returns the ith element of the sphere * \return A value to the ith element of the sphere * - * \remark Access to index greather than 4 is undefined behavior - * \remark Produce a NazaraError if you try to acces to index greather than 4 with NAZARA_MATH_SAFE defined + * \remark Access to index greater than 4 is undefined behavior + * \remark Produce a NazaraError if you try to access to index greater than 4 with NAZARA_MATH_SAFE defined * \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4 */ template - T Sphere::operator[](unsigned int i) const + T Sphere::operator[](std::size_t i) const { - #if NAZARA_MATH_SAFE - if (i >= 4) - { - StringStream ss; - ss << "Index out of range: (" << i << " >= 4)"; - - NazaraError(ss); - throw std::domain_error(ss.ToString()); - } - #endif + NazaraAssert(i < 4, "Index out of range"); return *(&x+i); } diff --git a/include/Nazara/Utility/IndexIterator.hpp b/include/Nazara/Utility/IndexIterator.hpp index 5c15bbdc2..63f9d96b9 100644 --- a/include/Nazara/Utility/IndexIterator.hpp +++ b/include/Nazara/Utility/IndexIterator.hpp @@ -26,15 +26,15 @@ namespace Nz Reference operator*() const; - Reference operator[](unsigned int index) const; + Reference operator[](std::size_t index) const; IndexIterator& operator=(const IndexIterator& iterator); - IndexIterator operator+(unsigned int indexCount) const; - IndexIterator operator-(unsigned int indexCount) const; + IndexIterator operator+(std::size_t indexCount) const; + IndexIterator operator-(std::size_t indexCount) const; - IndexIterator& operator+=(unsigned int indexCount); - IndexIterator& operator-=(unsigned int indexCount); + IndexIterator& operator+=(std::size_t indexCount); + IndexIterator& operator-=(std::size_t indexCount); IndexIterator& operator++(); IndexIterator operator++(int); @@ -50,10 +50,10 @@ namespace Nz friend bool operator>=(const IndexIterator& lhs, const IndexIterator& rhs); private: - IndexIterator(IndexMapper* mapper, unsigned int index); + IndexIterator(IndexMapper* mapper, std::size_t index); IndexMapper* m_mapper; - unsigned int m_index; + std::size_t m_index; }; class IndexIterator::Reference @@ -70,10 +70,10 @@ namespace Nz operator UInt32() const; private: - Reference(IndexMapper* mapper, unsigned int index); + Reference(IndexMapper* mapper, std::size_t index); IndexMapper* m_mapper; - unsigned int m_index; + std::size_t m_index; }; } diff --git a/include/Nazara/Utility/IndexIterator.inl b/include/Nazara/Utility/IndexIterator.inl index df1613d67..0398059f6 100644 --- a/include/Nazara/Utility/IndexIterator.inl +++ b/include/Nazara/Utility/IndexIterator.inl @@ -20,7 +20,7 @@ namespace Nz { } - inline IndexIterator::IndexIterator(IndexMapper* mapper, unsigned int index) : + inline IndexIterator::IndexIterator(IndexMapper* mapper, std::size_t index) : m_mapper(mapper), m_index(index) { @@ -31,7 +31,7 @@ namespace Nz return Reference(m_mapper, m_index); } - inline IndexIterator::Reference IndexIterator::operator[](unsigned int index) const + inline IndexIterator::Reference IndexIterator::operator[](std::size_t index) const { return Reference(m_mapper, m_index+index); } @@ -44,24 +44,24 @@ namespace Nz return *this; } - inline IndexIterator IndexIterator::operator+(unsigned int indexCount) const + inline IndexIterator IndexIterator::operator+(std::size_t indexCount) const { return IndexIterator(m_mapper, m_index + indexCount); } - inline IndexIterator IndexIterator::operator-(unsigned int indexCount) const + inline IndexIterator IndexIterator::operator-(std::size_t indexCount) const { return IndexIterator(m_mapper, m_index - indexCount); } - inline IndexIterator& IndexIterator::operator+=(unsigned int indexCount) + inline IndexIterator& IndexIterator::operator+=(std::size_t indexCount) { m_index += indexCount; return *this; } - inline IndexIterator& IndexIterator::operator-=(unsigned int indexCount) + inline IndexIterator& IndexIterator::operator-=(std::size_t indexCount) { m_index += indexCount; @@ -133,7 +133,7 @@ namespace Nz /**************************IndexIterator::Reference*************************/ - inline IndexIterator::Reference::Reference(IndexMapper* mapper, unsigned int index) : + inline IndexIterator::Reference::Reference(IndexMapper* mapper, std::size_t index) : m_mapper(mapper), m_index(index) { @@ -148,7 +148,7 @@ namespace Nz inline IndexIterator::Reference& IndexIterator::Reference::operator=(const IndexIterator::Reference& reference) { - m_mapper->Set(m_index, reference); // Conversion implicite en UInt32 + m_mapper->Set(m_index, reference); // Implicit conversion to UInt32 return *this; } diff --git a/include/Nazara/Utility/IndexMapper.hpp b/include/Nazara/Utility/IndexMapper.hpp index 84c73bc53..b18e8989f 100644 --- a/include/Nazara/Utility/IndexMapper.hpp +++ b/include/Nazara/Utility/IndexMapper.hpp @@ -17,9 +17,6 @@ namespace Nz class IndexIterator; class SubMesh; - using IndexMapperGetter = UInt32 (*)(const void* buffer, unsigned int i); - using IndexMapperSetter = void (*)(void* buffer, unsigned int i, UInt32 value); - class NAZARA_UTILITY_API IndexMapper { public: @@ -29,11 +26,11 @@ namespace Nz IndexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly); ~IndexMapper() = default; - UInt32 Get(unsigned int i) const; + UInt32 Get(std::size_t i) const; const IndexBuffer* GetBuffer() const; - unsigned int GetIndexCount() const; + std::size_t GetIndexCount() const; - void Set(unsigned int i, UInt32 value); + void Set(std::size_t i, UInt32 value); void Unmap(); @@ -45,10 +42,13 @@ namespace Nz // Méthodes STD private: + using Getter = UInt32(*)(const void* buffer, std::size_t i); + using Setter = void(*)(void* buffer, std::size_t i, UInt32 value); + BufferMapper m_mapper; - IndexMapperGetter m_getter; - IndexMapperSetter m_setter; - unsigned int m_indexCount; + Getter m_getter; + Setter m_setter; + std::size_t m_indexCount; }; } diff --git a/include/Nazara/Utility/TriangleIterator.hpp b/include/Nazara/Utility/TriangleIterator.hpp index bfc5a01fc..8bf17a2eb 100644 --- a/include/Nazara/Utility/TriangleIterator.hpp +++ b/include/Nazara/Utility/TriangleIterator.hpp @@ -24,7 +24,7 @@ namespace Nz bool Advance(); - UInt32 operator[](unsigned int i) const; + UInt32 operator[](std::size_t i) const; void Unmap(); @@ -32,8 +32,8 @@ namespace Nz PrimitiveMode m_primitiveMode; UInt32 m_triangleIndices[3]; IndexMapper m_indexMapper; - unsigned int m_currentIndex; - unsigned int m_indexCount; + std::size_t m_currentIndex; + std::size_t m_indexCount; }; } diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index a5cdf3cbf..8a4ec0e09 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -153,7 +153,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) if (animatedMesh) { - mesh->CreateSkeletal(joints.size()); + mesh->CreateSkeletal(UInt32(joints.size())); Skeleton* skeleton = mesh->GetSkeleton(); @@ -171,7 +171,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) mesh->CreateStatic(); // aiMaterial index in scene => Material index and data in Mesh - std::unordered_map> materials; + std::unordered_map> materials; for (unsigned int i = 0; i < scene->mNumMeshes; ++i) { @@ -300,7 +300,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue) == aiReturn_SUCCESS) matData.SetParameter(MaterialData::FaceCulling, !iValue); - matIt = materials.insert(std::make_pair(iMesh->mMaterialIndex, std::make_pair(materials.size(), std::move(matData)))).first; + matIt = materials.insert(std::make_pair(iMesh->mMaterialIndex, std::make_pair(UInt32(materials.size()), std::move(matData)))).first; } subMesh->SetMaterialIndex(matIt->first); @@ -308,7 +308,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) mesh->AddSubMesh(subMesh); } - mesh->SetMaterialCount(std::max(materials.size(), 1)); + mesh->SetMaterialCount(std::max(UInt32(materials.size()), 1)); for (const auto& pair : materials) mesh->SetMaterialData(pair.second.first, pair.second.second); } diff --git a/src/Nazara/Core/Hash/MD5.cpp b/src/Nazara/Core/Hash/MD5.cpp index 769ccb1a8..b0f25d684 100644 --- a/src/Nazara/Core/Hash/MD5.cpp +++ b/src/Nazara/Core/Hash/MD5.cpp @@ -101,7 +101,7 @@ namespace Nz { struct HashMD5_state { - UInt32 count[2]; /* message length in bits, lsw first */ + std::size_t count[2]; /* message length in bits, lsw first */ UInt32 abcd[4]; /* digest buffer */ UInt8 buf[64]; /* accumulate block */ }; @@ -280,9 +280,9 @@ namespace Nz void HashMD5::Append(const UInt8* data, std::size_t len) { const UInt8 *p = data; - int left = len; + std::size_t left = len; int offset = (m_state->count[0] >> 3) & 63; - UInt32 nbits = len << 3; + std::size_t nbits = len << 3; if (len <= 0) return; @@ -296,7 +296,7 @@ namespace Nz /* Process an initial partial block. */ if (offset) { - int copy = (offset + len > 64 ? 64 - offset : len); + std::size_t copy = (offset + len > 64 ? 64 - offset : len); std::memcpy(m_state->buf + offset, p, copy); if (offset + copy < 64) diff --git a/src/Nazara/Core/Hash/Whirlpool.cpp b/src/Nazara/Core/Hash/Whirlpool.cpp index 12b3e2a1b..e01fb4f4f 100644 --- a/src/Nazara/Core/Hash/Whirlpool.cpp +++ b/src/Nazara/Core/Hash/Whirlpool.cpp @@ -75,8 +75,8 @@ namespace Nz { struct HashWhirlpool_state { - int bufferBits; // current number of bits on the buffer */ - int bufferPos; // current (possibly incomplete) byte slot on the buffer */ + std::size_t bufferBits; // current number of bits on the buffer */ + std::size_t bufferPos; // current (possibly incomplete) byte slot on the buffer */ UInt8 bitLength[32]; // global number of hashed bits (256-bit counter) */ UInt8 buffer[64]; // buffer of data to hash */ UInt64 hash[8]; // the hashing state */ @@ -877,8 +877,8 @@ namespace Nz UInt32 b; UInt8* buffer = m_state->buffer; UInt8* bitLength = m_state->bitLength; - int bufferBits = m_state->bufferBits; - int bufferPos = m_state->bufferPos; + std::size_t bufferBits = m_state->bufferBits; + std::size_t bufferPos = m_state->bufferPos; // tally the length of the added data UInt64 value = len; @@ -968,8 +968,8 @@ namespace Nz UInt8 *buffer = m_state->buffer; UInt8 *bitLength = m_state->bitLength; - int bufferBits = m_state->bufferBits; - int bufferPos = m_state->bufferPos; + std::size_t bufferBits = m_state->bufferBits; + std::size_t bufferPos = m_state->bufferPos; UInt8 *digest = result; // append a '1'-bit diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 7ea8c7df2..98a8b882c 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -2115,7 +2115,7 @@ namespace Nz return ptr - m_sharedString->string.get(); } - catch (utf8::not_enough_room& e) + catch (utf8::not_enough_room& /*e*/) { // Returns npos } diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 543587b3d..2f9319ca0 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -33,8 +33,8 @@ namespace Nz Vector2f uv; }; - std::size_t s_maxQuads = std::numeric_limits::max() / 6; - std::size_t s_vertexBufferSize = 4 * 1024 * 1024; // 4 MiB + UInt32 s_maxQuads = std::numeric_limits::max() / 6; + UInt32 s_vertexBufferSize = 4 * 1024 * 1024; // 4 MiB } /*! diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 0e22ae0af..cbf098786 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -62,9 +62,9 @@ namespace Nz if (cpShape* shape = cpSpacePointQueryNearest(m_handle, { from.x, from.y }, maxDistance, filter, &queryInfo)) { - result->closestPoint.Set(queryInfo.point.x, queryInfo.point.y); - result->distance = queryInfo.distance; - result->fraction.Set(queryInfo.gradient.x, queryInfo.gradient.y); + result->closestPoint.Set(Nz::Vector2(queryInfo.point.x, queryInfo.point.y)); + result->distance = float(queryInfo.distance); + result->fraction.Set(Nz::Vector2(queryInfo.gradient.x, queryInfo.gradient.y)); result->nearestBody = static_cast(cpShapeGetUserData(shape)); return true; @@ -90,9 +90,9 @@ namespace Nz ResultType results = static_cast(data); RaycastHit hitInfo; - hitInfo.fraction = alpha; - hitInfo.hitNormal.Set(normal.x, normal.y); - hitInfo.hitPos.Set(point.x, point.y); + hitInfo.fraction = float(alpha); + hitInfo.hitNormal.Set(Nz::Vector2(normal.x, normal.y)); + hitInfo.hitPos.Set(Nz::Vector2(point.x, point.y)); hitInfo.nearestBody = static_cast(cpShapeGetUserData(shape)); results->emplace_back(std::move(hitInfo)); @@ -116,9 +116,9 @@ namespace Nz if (cpShape* shape = cpSpaceSegmentQueryFirst(m_handle, { from.x, from.y }, { to.x, to.y }, radius, filter, &queryInfo)) { - hitInfo->fraction = queryInfo.alpha; - hitInfo->hitNormal.Set(queryInfo.normal.x, queryInfo.normal.y); - hitInfo->hitPos.Set(queryInfo.point.x, queryInfo.point.y); + hitInfo->fraction = float(queryInfo.alpha); + hitInfo->hitNormal.Set(Nz::Vector2(queryInfo.normal.x, queryInfo.normal.y)); + hitInfo->hitPos.Set(Nz::Vector2(queryInfo.point.x, queryInfo.point.y)); hitInfo->nearestBody = static_cast(cpShapeGetUserData(queryInfo.shape)); return true; diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index f31e9ef54..3b2f927f9 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -215,7 +215,7 @@ namespace Nz cpVect vel = cpBodyGetVelocity(m_handle); Destroy(); - Create(mass, moment); + Create(float(mass), float(moment)); cpBodySetAngle(m_handle, rot); cpBodySetPosition(m_handle, pos); diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index 0168e4ffe..5284d1d2c 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -91,8 +91,8 @@ namespace Nz bool largeIndices = (vertexCount > std::numeric_limits::max()); - IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, indexCount, parameters.storage, 0); - VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent_Skinning), vertexCount, parameters.storage, 0); + IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, UInt32(indexCount), parameters.storage, 0); + VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent_Skinning), UInt32(vertexCount), parameters.storage, 0); // Index buffer IndexMapper indexMapper(indexBuffer, BufferAccess_DiscardAndWrite); @@ -236,7 +236,7 @@ namespace Nz // Index buffer bool largeIndices = (vertexCount > std::numeric_limits::max()); - IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, indexCount, parameters.storage, 0); + IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, UInt32(indexCount), parameters.storage, 0); IndexMapper indexMapper(indexBuffer, BufferAccess_DiscardAndWrite); IndexIterator index = indexMapper.begin(); @@ -251,7 +251,7 @@ namespace Nz indexMapper.Unmap(); // Vertex buffer - VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage, 0); + VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), UInt32(vertexCount), parameters.storage, 0); BufferMapper vertexMapper(vertexBuffer, BufferAccess_WriteOnly); MeshVertex* vertices = static_cast(vertexMapper.GetPointer()); diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 951892085..563300aaf 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -233,8 +233,8 @@ namespace Nz } // Création des buffers - IndexBufferRef indexBuffer = IndexBuffer::New(vertexCount > std::numeric_limits::max(), indices.size(), parameters.storage, 0); - VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage, 0); + IndexBufferRef indexBuffer = IndexBuffer::New(vertexCount > std::numeric_limits::max(), UInt32(indices.size()), parameters.storage, 0); + VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), UInt32(vertexCount), parameters.storage, 0); // Remplissage des indices IndexMapper indexMapper(indexBuffer, BufferAccess_WriteOnly); diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index ab1cbdbfb..f85251f57 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -228,7 +228,7 @@ namespace Nz if (p < 0) { - p += m_positions.size() - 1; + p += static_cast(m_positions.size() - 1); if (p < 0) { Error("Vertex index out of range (" + String::Number(p) + " < 0"); @@ -239,7 +239,7 @@ namespace Nz if (n < 0) { - n += m_normals.size() - 1; + n += static_cast(m_normals.size() - 1); if (n < 0) { Error("Normal index out of range (" + String::Number(n) + " < 0"); @@ -250,7 +250,7 @@ namespace Nz if (t < 0) { - t += m_texCoords.size() - 1; + t += static_cast(m_texCoords.size() - 1); if (t < 0) { Error("Texture coordinates index out of range (" + String::Number(t) + " < 0"); diff --git a/src/Nazara/Utility/IndexMapper.cpp b/src/Nazara/Utility/IndexMapper.cpp index 7ddcd9a08..78fdd36a0 100644 --- a/src/Nazara/Utility/IndexMapper.cpp +++ b/src/Nazara/Utility/IndexMapper.cpp @@ -12,38 +12,38 @@ namespace Nz { namespace { - UInt32 GetterSequential(const void* buffer, unsigned int i) + UInt32 GetterSequential(const void* buffer, std::size_t i) { NazaraUnused(buffer); - return i; + return static_cast(i); } - UInt32 Getter16(const void* buffer, unsigned int i) + UInt32 Getter16(const void* buffer, std::size_t i) { const UInt16* ptr = static_cast(buffer); return ptr[i]; } - UInt32 Getter32(const void* buffer, unsigned int i) + UInt32 Getter32(const void* buffer, std::size_t i) { const UInt32* ptr = static_cast(buffer); return ptr[i]; } - void Setter16(void* buffer, unsigned int i, UInt32 value) + void Setter16(void* buffer, std::size_t i, UInt32 value) { UInt16* ptr = static_cast(buffer); ptr[i] = static_cast(value); } - void Setter32(void* buffer, unsigned int i, UInt32 value) + void Setter32(void* buffer, std::size_t i, UInt32 value) { UInt32* ptr = static_cast(buffer); ptr[i] = value; } - void SetterError(void*, unsigned int, UInt32) + void SetterError(void*, std::size_t, UInt32) { NazaraError("Index buffer opened with read-only access"); } @@ -113,15 +113,9 @@ namespace Nz { } - UInt32 IndexMapper::Get(unsigned int i) const + UInt32 IndexMapper::Get(std::size_t i) const { - #if NAZARA_UTILITY_SAFE - if (i >= m_indexCount) - { - NazaraError("Index out of range (" + String::Number(i) + " >= " + String::Number(m_indexCount) + ')'); - return 0; - } - #endif + NazaraAssert(i < m_indexCount, "Index out of range"); return m_getter(m_mapper.GetPointer(), i); } @@ -131,20 +125,14 @@ namespace Nz return m_mapper.GetBuffer(); } - unsigned int IndexMapper::GetIndexCount() const + std::size_t IndexMapper::GetIndexCount() const { return m_indexCount; } - void IndexMapper::Set(unsigned int i, UInt32 value) + void IndexMapper::Set(std::size_t i, UInt32 value) { - #if NAZARA_UTILITY_SAFE - if (i >= m_indexCount) - { - NazaraError("Index out of range (" + String::Number(i) + " >= " + String::Number(m_indexCount) + ')'); - return; - } - #endif + NazaraAssert(i < m_indexCount, "Index out of range"); m_setter(m_mapper.GetPointer(), i, value); } diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 27c1bd186..b6985714e 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -79,7 +79,7 @@ namespace Nz NazaraAssert(subMesh, "Invalid submesh"); NazaraAssert(subMesh->GetAnimationType() == m_impl->animationType, "Submesh animation type doesn't match mesh animation type"); - m_impl->subMeshes.push_back(subMesh); + m_impl->subMeshes.emplace_back(subMesh); InvalidateAABB(); } @@ -92,10 +92,10 @@ namespace Nz NazaraAssert(subMesh, "Invalid submesh"); NazaraAssert(subMesh->GetAnimationType() == m_impl->animationType, "Submesh animation type doesn't match mesh animation type"); - UInt32 index = m_impl->subMeshes.size(); + std::size_t index = m_impl->subMeshes.size(); - m_impl->subMeshes.push_back(subMesh); - m_impl->subMeshMap[identifier] = index; + m_impl->subMeshes.emplace_back(subMesh); + m_impl->subMeshMap[identifier] = static_cast(index); InvalidateAABB(); } @@ -349,11 +349,11 @@ namespace Nz if (!m_impl->aabbUpdated) { - UInt32 subMeshCount = m_impl->subMeshes.size(); + std::size_t subMeshCount = m_impl->subMeshes.size(); if (subMeshCount > 0) { m_impl->aabb.Set(m_impl->subMeshes[0]->GetAABB()); - for (UInt32 i = 1; i < subMeshCount; ++i) + for (std::size_t i = 1; i < subMeshCount; ++i) m_impl->aabb.ExtendTo(m_impl->subMeshes[i]->GetAABB()); } else @@ -407,7 +407,7 @@ namespace Nz { NazaraAssert(m_impl, "Mesh should be created first"); - return m_impl->materialData.size(); + return static_cast(m_impl->materialData.size()); } Skeleton* Mesh::GetSkeleton() @@ -466,7 +466,7 @@ namespace Nz { NazaraAssert(m_impl, "Mesh should be created first"); - return m_impl->subMeshes.size(); + return static_cast(m_impl->subMeshes.size()); } UInt32 Mesh::GetSubMeshIndex(const String& identifier) const diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index d7a1bc713..1901a6ca2 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -243,7 +243,7 @@ namespace Nz m_workingBounds.MakeZero(); //< Compute bounds as float to speedup bounds computation (as casting between floats and integers is costly) if (m_font) - m_lines.emplace_back(Line{Rectf(0.f, 0.f, 0.f, m_font->GetSizeInfo(m_characterSize).lineHeight), 0}); + m_lines.emplace_back(Line{Rectf(0.f, 0.f, 0.f, float(m_font->GetSizeInfo(m_characterSize).lineHeight)), 0}); else m_lines.emplace_back(Line{Rectf::Zero(), 0}); } @@ -354,7 +354,7 @@ namespace Nz { glyph.atlas = nullptr; - glyph.bounds.Set(m_drawPos.x, m_drawPos.y, float(advance), sizeInfo.lineHeight); + glyph.bounds.Set(m_drawPos.x, m_drawPos.y, float(advance), float(sizeInfo.lineHeight)); glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner_LeftTop)); glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner_RightTop)); @@ -377,7 +377,7 @@ namespace Nz m_drawPos.x = 0; m_drawPos.y += sizeInfo.lineHeight; - m_lines.emplace_back(Line{Rectf(0.f, sizeInfo.lineHeight * m_lines.size(), 0.f, sizeInfo.lineHeight), m_glyphs.size() + 1}); + m_lines.emplace_back(Line{Rectf(0.f, float(sizeInfo.lineHeight * m_lines.size()), 0.f, float(sizeInfo.lineHeight)), m_glyphs.size() + 1}); break; } } diff --git a/src/Nazara/Utility/Skeleton.cpp b/src/Nazara/Utility/Skeleton.cpp index 7d33ad9bd..480522b4e 100644 --- a/src/Nazara/Utility/Skeleton.cpp +++ b/src/Nazara/Utility/Skeleton.cpp @@ -72,12 +72,12 @@ namespace Nz if (!m_impl->aabbUpdated) { - UInt32 jointCount = m_impl->joints.size(); + std::size_t jointCount = m_impl->joints.size(); if (jointCount > 0) { Vector3f pos = m_impl->joints[0].GetPosition(); m_impl->aabb.Set(pos.x, pos.y, pos.z, 0.f, 0.f, 0.f); - for (UInt32 i = 1; i < jointCount; ++i) + for (std::size_t i = 1; i < jointCount; ++i) m_impl->aabb.ExtendTo(m_impl->joints[i].GetPosition()); } else @@ -219,7 +219,7 @@ namespace Nz } #endif - return m_impl->joints.size(); + return static_cast(m_impl->joints.size()); } int Skeleton::GetJointIndex(const String& jointName) const @@ -411,16 +411,9 @@ namespace Nz String name = m_impl->joints[i].GetName(); if (!name.IsEmpty()) { - #if NAZARA_UTILITY_SAFE - auto it = m_impl->jointMap.find(name); - if (it != m_impl->jointMap.end()) - { - NazaraWarning("Joint name \"" + name + "\" is already present in joint map for joint #" + String::Number(it->second)); - continue; - } - #endif + NazaraAssert(m_impl->jointMap.find(name) == m_impl->jointMap.end(), "Joint name \"" + name + "\" is already present in joint map"); - m_impl->jointMap[name] = i; + m_impl->jointMap[name] = static_cast(i); } } diff --git a/src/Nazara/Utility/TriangleIterator.cpp b/src/Nazara/Utility/TriangleIterator.cpp index 68f65c0db..ad6dfb2c6 100644 --- a/src/Nazara/Utility/TriangleIterator.cpp +++ b/src/Nazara/Utility/TriangleIterator.cpp @@ -66,18 +66,9 @@ namespace Nz return true; } - UInt32 TriangleIterator::operator[](unsigned int i) const + UInt32 TriangleIterator::operator[](std::size_t i) const { - #if NAZARA_UTILITY_SAFE - if (i >= 3) - { - StringStream ss; - ss << "Index out of range: (" << i << " >= 3)"; - - NazaraError(ss); - throw std::domain_error(ss.ToString()); - } - #endif + NazaraAssert(i < 3, "Index out of range"); return m_triangleIndices[i]; } From d8a2d08e277bab851b872e419a755613a7dfae13 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 15:08:21 +0200 Subject: [PATCH 184/243] UnitTest: Add some checks --- tests/Engine/Math/AlgorithmMath.cpp | 20 ++++++++++++++++++-- tests/SDK/NDK/EntityOwner.cpp | 8 ++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/Engine/Math/AlgorithmMath.cpp b/tests/Engine/Math/AlgorithmMath.cpp index 01413d902..e6dc2218b 100644 --- a/tests/Engine/Math/AlgorithmMath.cpp +++ b/tests/Engine/Math/AlgorithmMath.cpp @@ -1,5 +1,6 @@ #include #include +#include TEST_CASE("Approach", "[MATH][ALGORITHM]") { @@ -48,6 +49,11 @@ TEST_CASE("CountBits", "[MATH][ALGORITHM]") { REQUIRE(Nz::CountBits(0) == 0); } + + SECTION("Number 0xFFFFFFFF has 32 bit set to 1") + { + REQUIRE(Nz::CountBits(0xFFFFFFFF) == 32); + } } TEST_CASE("DegreeToRadian", "[MATH][ALGORITHM]") @@ -205,9 +211,19 @@ TEST_CASE("NumberEquals", "[MATH][ALGORITHM]") CHECK(Nz::NumberEquals(2.35, 2.35, 0.01)); } - SECTION("3 and 4 unsigned should be the same at 1") + SECTION("0 and 4 unsigned should be the same at 1") { - CHECK(Nz::NumberEquals(3U, 4U, 1U)); + CHECK(Nz::NumberEquals(0U, 4U, 4U)); + } + + SECTION("Maximum integer and -1 should not be equal") + { + CHECK_FALSE(Nz::NumberEquals(std::numeric_limits::max(), -1)); + } + + SECTION("Maximum integer and minimum integer should not be equal") + { + CHECK_FALSE(Nz::NumberEquals(std::numeric_limits::max(), std::numeric_limits::min())); } } diff --git a/tests/SDK/NDK/EntityOwner.cpp b/tests/SDK/NDK/EntityOwner.cpp index eb9a29edf..464dce4d6 100644 --- a/tests/SDK/NDK/EntityOwner.cpp +++ b/tests/SDK/NDK/EntityOwner.cpp @@ -24,6 +24,14 @@ SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]") world.Update(1.f); REQUIRE(!entity.IsValid()); } + + THEN("Moving an entity owner works") + { + Ndk::EntityOwner entityOwner2(std::move(entityOwner)); + entityOwner2.Reset(); + world.Update(1.f); + REQUIRE(!entity.IsValid()); + } } } } \ No newline at end of file From 883d7b02a7c1630b3bfe7ac8629184801064de59 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 15:08:43 +0200 Subject: [PATCH 185/243] Math/Algorithm: Optimize NumberEquals unsigned and float cases --- include/Nazara/Math/Algorithm.inl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index 612cdf952..e50385c78 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -98,7 +98,13 @@ namespace Nz return 0; } - template /*constexpr*/ std::enable_if_t::value || !std::is_integral::value, bool> NumberEquals(T a, T b, T maxDifference) + template /*constexpr*/ std::enable_if_t::value, bool> NumberEquals(T a, T b, T maxDifference) + { + T diff = std::abs(a - b); + return diff <= maxDifference; + } + + template /*constexpr*/ std::enable_if_t::value || (!std::is_integral::value && !std::is_floating_point::value), bool> NumberEquals(T a, T b, T maxDifference) { if (b > a) std::swap(a, b); @@ -112,13 +118,8 @@ namespace Nz if (b > a) std::swap(a, b); - if ((b < 0) && (a > std::numeric_limits::max() + b)) - return false; - - if ((b > 0) && (a < std::numeric_limits::min() + b)) - return false; - - return std::abs(a - b) <= maxDifference; + using UnsignedT = std::make_unsigned_t; + return static_cast(a) - static_cast(b) <= static_cast(maxDifference); } } @@ -487,7 +488,7 @@ namespace Nz template constexpr T Lerp(const T& from, const T& to, const T2& interpolation) { - return from + interpolation * (to - from); + return static_cast(from + interpolation * (to - from)); } /*! From f6fe589b03a5a98668f5a5f704bcc0cc7b5a8b25 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 15:33:59 +0200 Subject: [PATCH 186/243] Fix #120 --- src/Nazara/Renderer/Context.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp index acc57006e..7fbad6002 100644 --- a/src/Nazara/Renderer/Context.cpp +++ b/src/Nazara/Renderer/Context.cpp @@ -121,9 +121,7 @@ namespace Nz break; default: - // Peut être rajouté par une extension - ss << "Unknown"; - break; + return; //< Block NVidia buffer usage hint for now } ss << '\n'; From e3514db87fe1bd2dd64c60178aff7055cb8c0019 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 17:11:42 +0200 Subject: [PATCH 187/243] Sdk/GraphicsComponent: Add methods to update local matrix and render order --- .../NDK/Components/GraphicsComponent.hpp | 3 +++ .../NDK/Components/GraphicsComponent.inl | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index cd62f9b2f..68961b99a 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -51,6 +51,9 @@ namespace Ndk inline void RemoveFromCullingList(GraphicsComponentCullingList* cullingList) const; + inline void UpdateLocalMatrix(const Nz::InstancedRenderable* instancedRenderable, const Nz::Matrix4f& localMatrix); + inline void UpdateRenderOrder(const Nz::InstancedRenderable* instancedRenderable, int renderOrder); + static ComponentIndex componentIndex; private: diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index e67b6f323..34bd57dd9 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -142,6 +142,32 @@ namespace Ndk } } + inline void GraphicsComponent::UpdateLocalMatrix(const Nz::InstancedRenderable* instancedRenderable, const Nz::Matrix4f& localMatrix) + { + for (auto& renderable : m_renderables) + { + if (renderable.renderable == instancedRenderable) + { + renderable.data.localMatrix = localMatrix; + + InvalidateBoundingVolume(); + break; + } + } + } + + inline void GraphicsComponent::UpdateRenderOrder(const Nz::InstancedRenderable* instancedRenderable, int renderOrder) + { + for (auto& renderable : m_renderables) + { + if (renderable.renderable == instancedRenderable) + { + renderable.data.renderOrder = renderOrder; + break; + } + } + } + /*! * \brief Invalidates the bounding volume */ From 52a4a590e1288226dea6f9ed5d8c36c8462f8c52 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 17:13:51 +0200 Subject: [PATCH 188/243] Graphics/Material: Fix depth sorting flag handling for meshes --- .../NDK/Components/CameraComponent.hpp | 2 +- .../NDK/Components/CameraComponent.inl | 10 -- SDK/src/NDK/Components/CameraComponent.cpp | 11 ++ .../Nazara/Graphics/AbstractRenderQueue.hpp | 2 +- include/Nazara/Graphics/AbstractViewer.hpp | 1 + .../Nazara/Graphics/DeferredRenderQueue.hpp | 2 +- include/Nazara/Graphics/DepthRenderQueue.hpp | 2 +- .../Nazara/Graphics/ForwardRenderQueue.hpp | 16 +- src/Nazara/Graphics/DeferredRenderQueue.cpp | 6 +- src/Nazara/Graphics/DepthRenderQueue.cpp | 2 +- src/Nazara/Graphics/ForwardRenderQueue.cpp | 139 +++++++++++------- .../Graphics/ForwardRenderTechnique.cpp | 10 +- src/Nazara/Graphics/MaterialPipeline.cpp | 2 + 13 files changed, 122 insertions(+), 83 deletions(-) diff --git a/SDK/include/NDK/Components/CameraComponent.hpp b/SDK/include/NDK/Components/CameraComponent.hpp index 04859b1de..f4a29f2e4 100644 --- a/SDK/include/NDK/Components/CameraComponent.hpp +++ b/SDK/include/NDK/Components/CameraComponent.hpp @@ -44,7 +44,7 @@ namespace Ndk const Nz::Frustumf& GetFrustum() const override; inline unsigned int GetLayer() const; const Nz::Matrix4f& GetProjectionMatrix() const override; - inline Nz::ProjectionType GetProjectionType() const; + Nz::ProjectionType GetProjectionType() const override; inline const Nz::Vector2f& GetSize() const; const Nz::RenderTarget* GetTarget() const override; inline const Nz::Rectf& GetTargetRegion() const; diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index 33c63bfe3..1018f9f3d 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -117,16 +117,6 @@ namespace Ndk return m_layer; } - /*! - * \brief Gets the projection type of the camera - * \return Projection type of the camera - */ - - inline Nz::ProjectionType CameraComponent::GetProjectionType() const - { - return m_projectionType; - } - /*! * \brief Gets the size of the camera * \return Size of the camera diff --git a/SDK/src/NDK/Components/CameraComponent.cpp b/SDK/src/NDK/Components/CameraComponent.cpp index 13b6bdd2b..2441dd7a8 100644 --- a/SDK/src/NDK/Components/CameraComponent.cpp +++ b/SDK/src/NDK/Components/CameraComponent.cpp @@ -93,6 +93,17 @@ namespace Ndk return m_projectionMatrix; } + + /*! + * \brief Gets the projection type of the camera + * \return Projection type of the camera + */ + Nz::ProjectionType CameraComponent::GetProjectionType() const + { + return m_projectionType; + } + + /*! * \brief Gets the target of the camera * \return A constant reference to the render target of the camera diff --git a/include/Nazara/Graphics/AbstractRenderQueue.hpp b/include/Nazara/Graphics/AbstractRenderQueue.hpp index f0074cd50..0e3b94f2f 100644 --- a/include/Nazara/Graphics/AbstractRenderQueue.hpp +++ b/include/Nazara/Graphics/AbstractRenderQueue.hpp @@ -51,7 +51,7 @@ namespace Nz virtual void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) = 0; virtual void AddPointLight(const PointLight& light); virtual void AddSpotLight(const SpotLight& light); - virtual void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) = 0; + virtual void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) = 0; virtual void Clear(bool fully = false); diff --git a/include/Nazara/Graphics/AbstractViewer.hpp b/include/Nazara/Graphics/AbstractViewer.hpp index 9bef56373..21a62a890 100644 --- a/include/Nazara/Graphics/AbstractViewer.hpp +++ b/include/Nazara/Graphics/AbstractViewer.hpp @@ -33,6 +33,7 @@ namespace Nz virtual Vector3f GetForward() const = 0; virtual const Frustumf& GetFrustum() const = 0; virtual const Matrix4f& GetProjectionMatrix() const = 0; + virtual Nz::ProjectionType GetProjectionType() const = 0; virtual const RenderTarget* GetTarget() const = 0; virtual const Matrix4f& GetViewMatrix() const = 0; virtual const Recti& GetViewport() const = 0; diff --git a/include/Nazara/Graphics/DeferredRenderQueue.hpp b/include/Nazara/Graphics/DeferredRenderQueue.hpp index 982469873..5f9f7538e 100644 --- a/include/Nazara/Graphics/DeferredRenderQueue.hpp +++ b/include/Nazara/Graphics/DeferredRenderQueue.hpp @@ -37,7 +37,7 @@ namespace Nz void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) override; void AddDrawable(int renderOrder, const Drawable* drawable) override; void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) override; - void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) override; + void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) override; void Clear(bool fully = false) override; diff --git a/include/Nazara/Graphics/DepthRenderQueue.hpp b/include/Nazara/Graphics/DepthRenderQueue.hpp index ed7c9f3c3..871cefa66 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.hpp +++ b/include/Nazara/Graphics/DepthRenderQueue.hpp @@ -38,7 +38,7 @@ namespace Nz void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) override; void AddPointLight(const PointLight& light) override; void AddSpotLight(const SpotLight& light) override; - void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) override; + void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) override; private: inline bool IsMaterialSuitable(const Material* material) const; diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index 218fd312d..b081641c1 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,7 @@ namespace Nz void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) override; void AddDrawable(int renderOrder, const Drawable* drawable) override; void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) override; - void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) override; + void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) override; void Clear(bool fully = false) override; @@ -156,7 +157,7 @@ namespace Nz { Matrix4f transformMatrix; MeshData meshData; - Spheref squaredBoundingSphere; + Spheref obbSphere; const Material* material; }; @@ -165,10 +166,11 @@ namespace Nz struct Layer { BillboardPipelineBatches billboards; - SpritePipelineBatches basicSprites; + SpritePipelineBatches opaqueSprites; + SpritePipelineBatches depthSortedSprites; MeshPipelineBatches opaqueModels; - TransparentModelContainer transparentModels; - std::vector transparentModelData; + TransparentModelContainer depthSortedMeshes; + std::vector depthSortedMeshData; std::vector otherDrawables; unsigned int clearCount = 0; }; @@ -179,6 +181,10 @@ namespace Nz BillboardData* GetBillboardData(int renderOrder, const Material* material, unsigned int count); Layer& GetLayer(int i); ///TODO: Inline + void SortBillboards(Layer& layer, const Planef& nearPlane); + void SortForOrthographic(const AbstractViewer* viewer); + void SortForPerspective(const AbstractViewer* viewer); + void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer); void OnMaterialInvalidation(const Material* material); void OnTextureInvalidation(const Texture* texture); diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 22ead6ec0..a0455fe11 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -191,8 +191,8 @@ namespace Nz void DeferredRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { - if (material->IsBlendingEnabled()) - // One transparent material ? I don't like it, go see if I'm in the forward queue + if (material->IsBlendingEnabled() || material->IsDepthSortingEnabled()) //< Fixme: Deferred Shading should be able to handle depth sorting + // Deferred Shading cannot handle blended objects, put them in the forward list m_forwardQueue->AddMesh(renderOrder, material, meshData, meshAABB, transformMatrix); else { @@ -254,7 +254,7 @@ namespace Nz * \param overlay Texture of the sprites */ - void DeferredRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) + void DeferredRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay) { m_forwardQueue->AddSprites(renderOrder, material, vertices, spriteCount, overlay); } diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index 46096e33f..a2acdf4bb 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -351,7 +351,7 @@ namespace Nz * \remark Produces a NazaraAssert if material is invalid */ - void DepthRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) + void DepthRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay) { NazaraAssert(material, "Invalid material"); NazaraUnused(renderOrder); diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 8eb70fe7e..c594157b9 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -376,23 +376,23 @@ namespace Nz { NazaraAssert(material, "Invalid material"); - if (material->IsBlendingEnabled()) + if (material->IsDepthSortingEnabled()) { Layer& currentLayer = GetLayer(renderOrder); - auto& transparentModels = currentLayer.transparentModels; - auto& transparentModelData = currentLayer.transparentModelData; + auto& transparentMeshes = currentLayer.depthSortedMeshes; + auto& transparentData = currentLayer.depthSortedMeshData; - // The material is transparent, we must draw this mesh using another way (after the rendering of opages objects while sorting them) - std::size_t index = transparentModelData.size(); - transparentModelData.resize(index+1); + // The material is marked for depth sorting, we must draw this mesh using another way (after the rendering of opaques objects while sorting them) + std::size_t index = transparentData.size(); + transparentData.resize(index+1); - TransparentModelData& data = transparentModelData.back(); + TransparentModelData& data = transparentData.back(); data.material = material; data.meshData = meshData; - data.squaredBoundingSphere = Spheref(transformMatrix.GetTranslation() + meshAABB.GetCenter(), meshAABB.GetSquaredRadius()); + data.obbSphere = Spheref(transformMatrix.GetTranslation() + meshAABB.GetCenter(), meshAABB.GetSquaredRadius()); data.transformMatrix = transformMatrix; - transparentModels.push_back(index); + transparentMeshes.push_back(index); } else { @@ -457,12 +457,12 @@ namespace Nz * * \remark Produces a NazaraAssert if material is invalid */ - void ForwardRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) + void ForwardRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay) { NazaraAssert(material, "Invalid material"); Layer& currentLayer = GetLayer(renderOrder); - SpritePipelineBatches& basicSprites = currentLayer.basicSprites; + SpritePipelineBatches& basicSprites = currentLayer.opaqueSprites; const MaterialPipeline* materialPipeline = material->GetPipeline(); @@ -545,7 +545,7 @@ namespace Nz pipelineEntry.enabled = false; } - for (auto& pipelinePair : layer.basicSprites) + for (auto& pipelinePair : layer.opaqueSprites) { auto& pipelineEntry = pipelinePair.second; @@ -597,8 +597,8 @@ namespace Nz } layer.otherDrawables.clear(); - layer.transparentModels.clear(); - layer.transparentModelData.clear(); + layer.depthSortedMeshes.clear(); + layer.depthSortedMeshData.clear(); ++it; } } @@ -613,44 +613,10 @@ namespace Nz void ForwardRenderQueue::Sort(const AbstractViewer* viewer) { - Planef nearPlane = viewer->GetFrustum().GetPlane(FrustumPlane_Near); - Vector3f viewerPos = viewer->GetEyePosition(); - Vector3f viewerNormal = viewer->GetForward(); - - for (auto& pair : layers) - { - Layer& layer = pair.second; - - std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (std::size_t index1, std::size_t index2) - { - const Spheref& sphere1 = layer.transparentModelData[index1].squaredBoundingSphere; - const Spheref& sphere2 = layer.transparentModelData[index2].squaredBoundingSphere; - - Vector3f position1 = sphere1.GetNegativeVertex(viewerNormal); - Vector3f position2 = sphere2.GetNegativeVertex(viewerNormal); - - return nearPlane.Distance(position1) > nearPlane.Distance(position2); - }); - - for (auto& pipelinePair : layer.billboards) - { - for (auto& matPair : pipelinePair.second.materialMap) - { - const Material* mat = matPair.first; - - if (mat->IsDepthSortingEnabled()) - { - BatchedBillboardEntry& entry = matPair.second; - auto& billboardVector = entry.billboards; - - std::sort(billboardVector.begin(), billboardVector.end(), [&viewerPos] (const BillboardData& data1, const BillboardData& data2) - { - return viewerPos.SquaredDistance(data1.center) > viewerPos.SquaredDistance(data2.center); - }); - } - } - } - } + if (viewer->GetProjectionType() == ProjectionType_Orthogonal) + SortForOrthographic(viewer); + else + SortForPerspective(viewer); } /*! @@ -715,12 +681,75 @@ namespace Nz return layer; } + void ForwardRenderQueue::SortBillboards(Layer& layer, const Planef& nearPlane) + { + for (auto& pipelinePair : layer.billboards) + { + for (auto& matPair : pipelinePair.second.materialMap) + { + const Material* mat = matPair.first; + + if (mat->IsDepthSortingEnabled()) + { + BatchedBillboardEntry& entry = matPair.second; + auto& billboardVector = entry.billboards; + + std::sort(billboardVector.begin(), billboardVector.end(), [&nearPlane] (const BillboardData& data1, const BillboardData& data2) + { + return nearPlane.Distance(data1.center) > nearPlane.Distance(data2.center); + }); + } + } + } + } + + void ForwardRenderQueue::SortForOrthographic(const AbstractViewer * viewer) + { + Planef nearPlane = viewer->GetFrustum().GetPlane(FrustumPlane_Near); + Vector3f viewerPos = viewer->GetEyePosition(); + + for (auto& pair : layers) + { + Layer& layer = pair.second; + + std::sort(layer.depthSortedMeshes.begin(), layer.depthSortedMeshes.end(), [&layer, &nearPlane] (std::size_t index1, std::size_t index2) + { + const Spheref& sphere1 = layer.depthSortedMeshData[index1].obbSphere; + const Spheref& sphere2 = layer.depthSortedMeshData[index2].obbSphere; + + return nearPlane.Distance(sphere1.GetPosition()) > nearPlane.Distance(sphere2.GetPosition()); + }); + + SortBillboards(layer, nearPlane); + } + } + + void ForwardRenderQueue::SortForPerspective(const AbstractViewer* viewer) + { + Planef nearPlane = viewer->GetFrustum().GetPlane(FrustumPlane_Near); + Vector3f viewerPos = viewer->GetEyePosition(); + + for (auto& pair : layers) + { + Layer& layer = pair.second; + + std::sort(layer.depthSortedMeshes.begin(), layer.depthSortedMeshes.end(), [&layer, &viewerPos] (std::size_t index1, std::size_t index2) + { + const Spheref& sphere1 = layer.depthSortedMeshData[index1].obbSphere; + const Spheref& sphere2 = layer.depthSortedMeshData[index2].obbSphere; + + return viewerPos.SquaredDistance(sphere1.GetPosition()) > viewerPos.SquaredDistance(sphere2.GetPosition()); + }); + + SortBillboards(layer, nearPlane); + } + } + /*! * \brief Handle the invalidation of an index buffer * * \param indexBuffer Index buffer being invalidated */ - void ForwardRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer) { for (auto& pair : layers) @@ -757,7 +786,7 @@ namespace Nz { Layer& layer = pair.second; - for (auto& pipelineEntry : layer.basicSprites) + for (auto& pipelineEntry : layer.opaqueSprites) pipelineEntry.second.materialMap.erase(material); for (auto& pipelineEntry : layer.billboards) @@ -779,7 +808,7 @@ namespace Nz for (auto& pair : layers) { Layer& layer = pair.second; - for (auto& pipelineEntry : layer.basicSprites) + for (auto& pipelineEntry : layer.opaqueSprites) { for (auto& materialEntry : pipelineEntry.second.materialMap) materialEntry.second.overlayMap.erase(texture); diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 2f9319ca0..910e2bd1f 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -101,7 +101,7 @@ namespace Nz if (!layer.opaqueModels.empty()) DrawOpaqueModels(sceneData, layer); - if (!layer.transparentModels.empty()) + if (!layer.depthSortedMeshes.empty()) DrawTransparentModels(sceneData, layer); if (!layer.basicSprites.empty()) @@ -796,9 +796,9 @@ namespace Nz const ShaderUniforms* shaderUniforms = nullptr; unsigned int lightCount = 0; - for (unsigned int index : layer.transparentModels) + for (unsigned int index : layer.depthSortedMeshes) { - const ForwardRenderQueue::TransparentModelData& modelData = layer.transparentModelData[index]; + const ForwardRenderQueue::TransparentModelData& modelData = layer.depthSortedMeshData[index]; // Material const Material* material = modelData.material; @@ -865,8 +865,8 @@ namespace Nz if (shaderUniforms->hasLightUniforms && lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS) { // Compute the closest lights - Vector3f position = matrix.GetTranslation() + modelData.squaredBoundingSphere.GetPosition(); - float radius = modelData.squaredBoundingSphere.radius; + Vector3f position = matrix.GetTranslation() + modelData.obbSphere.GetPosition(); + float radius = modelData.obbSphere.radius; ChooseLights(Spheref(position, radius), false); for (std::size_t i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 761bc500f..e9a100ad2 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -197,6 +197,7 @@ namespace Nz pipelineInfo.blending = true; pipelineInfo.depthWrite = false; pipelineInfo.faceCulling = false; + pipelineInfo.depthSorting = true; pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha; pipelineInfo.srcBlend = BlendFunc_SrcAlpha; @@ -207,6 +208,7 @@ namespace Nz pipelineInfo.depthBuffer = true; pipelineInfo.depthWrite = false; pipelineInfo.faceCulling = false; + pipelineInfo.depthSorting = true; pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha; pipelineInfo.srcBlend = BlendFunc_SrcAlpha; From b5191d142a922d4982b087f0092e9dc21078902f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 17:13:56 +0200 Subject: [PATCH 189/243] Fix warning --- src/Nazara/Utility/SimpleTextDrawer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 1901a6ca2..1b53f808f 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -354,7 +354,7 @@ namespace Nz { glyph.atlas = nullptr; - glyph.bounds.Set(m_drawPos.x, m_drawPos.y, float(advance), float(sizeInfo.lineHeight)); + glyph.bounds.Set(float(m_drawPos.x), float(m_drawPos.y), float(advance), float(sizeInfo.lineHeight)); glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner_LeftTop)); glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner_RightTop)); From 3e9ae9856a920f64185e88cd26750963f35c5b92 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 17:14:56 +0200 Subject: [PATCH 190/243] Forgot to save files.. --- src/Nazara/Graphics/DepthRenderTechnique.cpp | 4 ++-- src/Nazara/Graphics/ForwardRenderTechnique.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 13f8b30af..4acbbc56d 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -95,7 +95,7 @@ namespace Nz if (!layer.opaqueModels.empty()) DrawOpaqueModels(sceneData, layer); - if (!layer.basicSprites.empty()) + if (!layer.opaqueSprites.empty()) DrawBasicSprites(sceneData, layer); if (!layer.billboards.empty()) @@ -219,7 +219,7 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity()); Renderer::SetVertexBuffer(&m_spriteBuffer); - for (auto& pipelinePair : layer.basicSprites) + for (auto& pipelinePair : layer.opaqueSprites) { const MaterialPipeline* pipeline = pipelinePair.first; auto& pipelineEntry = pipelinePair.second; diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 910e2bd1f..e450c06a4 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -104,7 +104,7 @@ namespace Nz if (!layer.depthSortedMeshes.empty()) DrawTransparentModels(sceneData, layer); - if (!layer.basicSprites.empty()) + if (!layer.opaqueSprites.empty()) DrawBasicSprites(sceneData, layer); if (!layer.billboards.empty()) @@ -301,7 +301,7 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity()); Renderer::SetVertexBuffer(&m_spriteBuffer); - for (auto& pipelinePair : layer.basicSprites) + for (auto& pipelinePair : layer.opaqueSprites) { const MaterialPipeline* pipeline = pipelinePair.first; auto& pipelineEntry = pipelinePair.second; From af41b240adc1238b43fa25691726c915a313627e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Apr 2017 13:40:13 +0200 Subject: [PATCH 191/243] Graphics: Add support for depth-sorted sprites --- .../Nazara/Graphics/ForwardRenderQueue.hpp | 17 +- .../Graphics/ForwardRenderTechnique.hpp | 1 + src/Nazara/Graphics/ForwardRenderQueue.cpp | 117 ++++++++----- .../Graphics/ForwardRenderTechnique.cpp | 154 +++++++++++++++++- 4 files changed, 238 insertions(+), 51 deletions(-) diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index b081641c1..bc5c2456e 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -153,7 +153,7 @@ namespace Nz using MeshPipelineBatches = std::map; - struct TransparentModelData + struct UnbatchedModelData { Matrix4f transformMatrix; MeshData meshData; @@ -161,16 +161,23 @@ namespace Nz const Material* material; }; - using TransparentModelContainer = std::vector; + struct UnbatchedSpriteData + { + std::size_t spriteCount; + const Material* material; + const Texture* overlay; + const VertexStruct_XYZ_Color_UV* vertices; + }; struct Layer { BillboardPipelineBatches billboards; SpritePipelineBatches opaqueSprites; - SpritePipelineBatches depthSortedSprites; MeshPipelineBatches opaqueModels; - TransparentModelContainer depthSortedMeshes; - std::vector depthSortedMeshData; + std::vector depthSortedMeshes; + std::vector depthSortedSprites; + std::vector depthSortedMeshData; + std::vector depthSortedSpriteData; std::vector otherDrawables; unsigned int clearCount = 0; }; diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.hpp b/include/Nazara/Graphics/ForwardRenderTechnique.hpp index 9b5c152df..cadb60473 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.hpp +++ b/include/Nazara/Graphics/ForwardRenderTechnique.hpp @@ -43,6 +43,7 @@ namespace Nz void DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const; void DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const; void DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const; + void DrawOrderedSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const; void DrawTransparentModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const; const ShaderUniforms* GetShaderUniforms(const Shader* shader) const; void OnShaderInvalidated(const Shader* shader) const; diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index c594157b9..ba8c68358 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -386,7 +386,7 @@ namespace Nz std::size_t index = transparentData.size(); transparentData.resize(index+1); - TransparentModelData& data = transparentData.back(); + UnbatchedModelData& data = transparentData.back(); data.material = material; data.meshData = meshData; data.obbSphere = Spheref(transformMatrix.GetTranslation() + meshAABB.GetCenter(), meshAABB.GetSquaredRadius()); @@ -462,48 +462,69 @@ namespace Nz NazaraAssert(material, "Invalid material"); Layer& currentLayer = GetLayer(renderOrder); - SpritePipelineBatches& basicSprites = currentLayer.opaqueSprites; - const MaterialPipeline* materialPipeline = material->GetPipeline(); - - auto pipelineIt = basicSprites.find(materialPipeline); - if (pipelineIt == basicSprites.end()) + if (material->IsDepthSortingEnabled()) { - BatchedSpritePipelineEntry materialEntry; - pipelineIt = basicSprites.insert(SpritePipelineBatches::value_type(materialPipeline, std::move(materialEntry))).first; + auto& transparentSprites = currentLayer.depthSortedSprites; + auto& transparentData = currentLayer.depthSortedSpriteData; + + // The material is marked for depth sorting, we must draw this mesh using another way (after the rendering of opaques objects while sorting them) + std::size_t index = transparentData.size(); + transparentData.resize(index + 1); + + UnbatchedSpriteData& data = transparentData.back(); + data.material = material; + data.overlay = overlay; + data.spriteCount = spriteCount; + data.vertices = vertices; + + transparentSprites.push_back(index); } - - BatchedSpritePipelineEntry& pipelineEntry = pipelineIt->second; - pipelineEntry.enabled = true; - - SpriteMaterialBatches& materialMap = pipelineEntry.materialMap; - - auto matIt = materialMap.find(material); - if (matIt == materialMap.end()) + else { - BatchedBasicSpriteEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); + SpritePipelineBatches& sprites = currentLayer.opaqueSprites; - matIt = materialMap.insert(SpriteMaterialBatches::value_type(material, std::move(entry))).first; + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = sprites.find(materialPipeline); + if (pipelineIt == sprites.end()) + { + BatchedSpritePipelineEntry materialEntry; + pipelineIt = sprites.insert(SpritePipelineBatches::value_type(materialPipeline, std::move(materialEntry))).first; + } + + BatchedSpritePipelineEntry& pipelineEntry = pipelineIt->second; + pipelineEntry.enabled = true; + + SpriteMaterialBatches& materialMap = pipelineEntry.materialMap; + + auto matIt = materialMap.find(material); + if (matIt == materialMap.end()) + { + BatchedBasicSpriteEntry entry; + entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); + + matIt = materialMap.insert(SpriteMaterialBatches::value_type(material, std::move(entry))).first; + } + + BatchedBasicSpriteEntry& entry = matIt->second; + entry.enabled = true; + + auto& overlayMap = entry.overlayMap; + + auto overlayIt = overlayMap.find(overlay); + if (overlayIt == overlayMap.end()) + { + BatchedSpriteEntry overlayEntry; + if (overlay) + overlayEntry.textureReleaseSlot.Connect(overlay->OnTextureRelease, this, &ForwardRenderQueue::OnTextureInvalidation); + + overlayIt = overlayMap.insert(std::make_pair(overlay, std::move(overlayEntry))).first; + } + + auto& spriteVector = overlayIt->second.spriteChains; + spriteVector.push_back(SpriteChain_XYZ_Color_UV({vertices, spriteCount})); } - - BatchedBasicSpriteEntry& entry = matIt->second; - entry.enabled = true; - - auto& overlayMap = entry.overlayMap; - - auto overlayIt = overlayMap.find(overlay); - if (overlayIt == overlayMap.end()) - { - BatchedSpriteEntry overlayEntry; - if (overlay) - overlayEntry.textureReleaseSlot.Connect(overlay->OnTextureRelease, this, &ForwardRenderQueue::OnTextureInvalidation); - - overlayIt = overlayMap.insert(std::make_pair(overlay, std::move(overlayEntry))).first; - } - - auto& spriteVector = overlayIt->second.spriteChains; - spriteVector.push_back(SpriteChain_XYZ_Color_UV({vertices, spriteCount})); } /*! @@ -596,9 +617,11 @@ namespace Nz } } - layer.otherDrawables.clear(); layer.depthSortedMeshes.clear(); layer.depthSortedMeshData.clear(); + layer.depthSortedSpriteData.clear(); + layer.depthSortedSprites.clear(); + layer.otherDrawables.clear(); ++it; } } @@ -717,7 +740,15 @@ namespace Nz const Spheref& sphere1 = layer.depthSortedMeshData[index1].obbSphere; const Spheref& sphere2 = layer.depthSortedMeshData[index2].obbSphere; - return nearPlane.Distance(sphere1.GetPosition()) > nearPlane.Distance(sphere2.GetPosition()); + return nearPlane.Distance(sphere1.GetPosition()) < nearPlane.Distance(sphere2.GetPosition()); + }); + + std::sort(layer.depthSortedSprites.begin(), layer.depthSortedSprites.end(), [&layer, &nearPlane] (std::size_t index1, std::size_t index2) + { + const Vector3f& pos1 = layer.depthSortedSpriteData[index1].vertices[0].position; + const Vector3f& pos2 = layer.depthSortedSpriteData[index2].vertices[0].position; + + return nearPlane.Distance(pos1) < nearPlane.Distance(pos2); }); SortBillboards(layer, nearPlane); @@ -741,6 +772,14 @@ namespace Nz return viewerPos.SquaredDistance(sphere1.GetPosition()) > viewerPos.SquaredDistance(sphere2.GetPosition()); }); + std::sort(layer.depthSortedSprites.begin(), layer.depthSortedSprites.end(), [&layer, &viewerPos] (std::size_t index1, std::size_t index2) + { + const Vector3f& pos1 = layer.depthSortedSpriteData[index1].vertices[0].position; + const Vector3f& pos2 = layer.depthSortedSpriteData[index2].vertices[0].position; + + return viewerPos.SquaredDistance(pos1) > viewerPos.SquaredDistance(pos2); + }); + SortBillboards(layer, nearPlane); } } diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index e450c06a4..1d202c837 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -107,6 +107,9 @@ namespace Nz if (!layer.opaqueSprites.empty()) DrawBasicSprites(sceneData, layer); + if (!layer.depthSortedSprites.empty()) + DrawOrderedSprites(sceneData, layer); + if (!layer.billboards.empty()) DrawBillboards(sceneData, layer); @@ -301,6 +304,9 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity()); Renderer::SetVertexBuffer(&m_spriteBuffer); + const unsigned int overlayTextureUnit = Material::GetTextureUnit(TextureMap_Overlay); + const std::size_t maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); + for (auto& pipelinePair : layer.opaqueSprites) { const MaterialPipeline* pipeline = pipelinePair.first; @@ -323,6 +329,9 @@ namespace Nz // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); + // Overlay texture unit + shader->SendInteger(shaderUniforms->textureOverlay, overlayTextureUnit); + lastShader = shader; } @@ -335,10 +344,6 @@ namespace Nz { material->Apply(pipelineInstance); - unsigned int overlayTextureUnit = Material::GetTextureUnit(TextureMap_Overlay); - - shader->SendInteger(shaderUniforms->textureOverlay, overlayTextureUnit); - Renderer::SetTextureSampler(overlayTextureUnit, material->GetDiffuseSampler()); auto& overlayMap = matEntry.overlayMap; @@ -362,7 +367,6 @@ namespace Nz VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); std::size_t spriteCount = 0; - std::size_t maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); do { @@ -777,6 +781,142 @@ namespace Nz } } + void ForwardRenderTechnique::DrawOrderedSprites(const SceneData & sceneData, ForwardRenderQueue::Layer & layer) const + { + NazaraAssert(sceneData.viewer, "Invalid viewer"); + + Renderer::SetIndexBuffer(&s_quadIndexBuffer); + Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity()); + Renderer::SetVertexBuffer(&m_spriteBuffer); + + const Material* lastMaterial = nullptr; + const MaterialPipeline* lastPipeline = nullptr; + const Shader* lastShader = nullptr; + const Texture* lastOverlay = nullptr; + const MaterialPipeline::Instance* pipelineInstance = nullptr; + + const unsigned int overlayTextureUnit = Material::GetTextureUnit(TextureMap_Overlay); + + bool updateVertexBuffer = true; + const std::size_t maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); + + std::size_t alreadyDrawnCount = 0; + std::size_t spriteIndex = 0; + std::size_t spriteChainOffset = 0; + auto splitChainIt = layer.depthSortedSprites.end(); + + for (auto it = layer.depthSortedSprites.begin(); it != layer.depthSortedSprites.end();) + { + if (updateVertexBuffer) + { + // We open the buffer in writing mode + BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); + VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); + + std::size_t availableSpriteSpace = maxSpriteCount; + bool split = false; + for (auto it2 = it; it2 != layer.depthSortedSprites.end(); ++it2) + { + const ForwardRenderQueue::UnbatchedSpriteData& spriteData = layer.depthSortedSpriteData[*it2]; + + std::size_t count = std::min(availableSpriteSpace, spriteData.spriteCount - spriteChainOffset); + + std::memcpy(vertices, spriteData.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); + vertices += count * 4; + + availableSpriteSpace -= count; + + // Have we treated the entire chain ? + if (count != spriteData.spriteCount) + { + // Oops, not enough space to store current chain + spriteChainOffset += count; + splitChainIt = it2; + split = true; + break; + } + + // Switch to next sprite chain, if any + spriteChainOffset = 0; + } + + spriteIndex = 0; + updateVertexBuffer = false; + + if (!split) + splitChainIt = layer.depthSortedSprites.end(); + } + + std::size_t index = *it; + + const ForwardRenderQueue::UnbatchedSpriteData& spriteData = layer.depthSortedSpriteData[index]; + + const Material* material = spriteData.material; + if (material != lastMaterial) + { + const MaterialPipeline* pipeline = material->GetPipeline(); + if (pipeline != lastPipeline) + { + pipelineInstance = &pipeline->Apply(ShaderFlags_TextureOverlay | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance->uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) + { + // Index of uniforms in the shader + const ShaderUniforms* shaderUniforms = GetShaderUniforms(shader); + + // Ambient color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); + // Overlay texture unit + shader->SendInteger(shaderUniforms->textureOverlay, overlayTextureUnit); + + lastShader = shader; + } + + lastPipeline = pipeline; + } + + material->Apply(*pipelineInstance); + + Renderer::SetTextureSampler(overlayTextureUnit, material->GetDiffuseSampler()); + + lastMaterial = material; + } + + const Texture* overlay = (spriteData.overlay) ? spriteData.overlay : &m_whiteTexture; + if (overlay != lastOverlay) + { + Renderer::SetTexture(overlayTextureUnit, overlay); + lastOverlay = overlay; + } + + std::size_t spriteCount; + if (it != splitChainIt) + { + spriteCount = spriteData.spriteCount - alreadyDrawnCount; + alreadyDrawnCount = 0; + + ++it; + } + else + { + spriteCount = spriteChainOffset; + + alreadyDrawnCount = spriteCount; + updateVertexBuffer = true; + + // Restart at current iterator next time + } + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, spriteIndex * 6, spriteCount * 6); + spriteIndex += spriteCount; + } + } + /*! * \brief Draws transparent models * @@ -796,9 +936,9 @@ namespace Nz const ShaderUniforms* shaderUniforms = nullptr; unsigned int lightCount = 0; - for (unsigned int index : layer.depthSortedMeshes) + for (std::size_t index : layer.depthSortedMeshes) { - const ForwardRenderQueue::TransparentModelData& modelData = layer.depthSortedMeshData[index]; + const ForwardRenderQueue::UnbatchedModelData& modelData = layer.depthSortedMeshData[index]; // Material const Material* material = modelData.material; From 064ffd294505a5dff38b8849df71d36a5e14c4e6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 May 2017 19:46:57 +0200 Subject: [PATCH 192/243] SDK/EntityList: Improve documentation --- SDK/include/NDK/EntityList.cpp | 0 SDK/include/NDK/EntityList.inl | 3 +++ 2 files changed, 3 insertions(+) delete mode 100644 SDK/include/NDK/EntityList.cpp diff --git a/SDK/include/NDK/EntityList.cpp b/SDK/include/NDK/EntityList.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index 6d9447a7f..21bf51bdb 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -63,10 +63,13 @@ namespace Ndk /*! * \brief Inserts the entity into the set * + * Marks an entity as present in this entity list, it must belongs to the same world as others entities contained in this list. + * * \param entity Valid pointer to an entity * * \remark If entity is already contained, no action is performed * \remark If any entity has been inserted since construction (or last Clear call), the entity must belong to the same world as the previously inserted entities + * \remark It's up to the programmer to remove an entity from this list before its deletion */ inline void EntityList::Insert(Entity* entity) { From 19f9191815cefe04dcc5e94a535dbf8908f86257 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 May 2017 20:14:58 +0200 Subject: [PATCH 193/243] SDK/World: Improve doc --- SDK/src/NDK/World.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 88a23060d..81b862df9 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -79,6 +79,8 @@ namespace Ndk if (m_entities.capacity() > m_entities.size()) { + NazaraAssert(m_waitingEntities.empty(), "There should be no waiting entities if space is available in main container"); + m_entities.push_back(Entity(this, id)); //< We can't use emplace_back due to the scope entBlock = &m_entities.back(); } @@ -86,7 +88,7 @@ namespace Ndk { // Pushing to entities would reallocate vector and thus, invalidate EntityHandles (which we don't want until world update) // To prevent this, allocate them into a separate vector and move them at update - // For now, we are counting on m_entities grow strategy to prevent + // For now, we are counting on m_entities grow strategy to keep allocation frequency low m_waitingEntities.emplace_back(std::make_unique(Entity(this, id))); entBlock = m_waitingEntities.back().get(); } @@ -167,7 +169,7 @@ namespace Ndk // Move waiting entities to entity list if (!m_waitingEntities.empty()) { - constexpr std::size_t MinEntityCapacity = 10; //< We want to be able to grow entity count by at least ten entities per update without going to the waiting list + constexpr std::size_t MinEntityCapacity = 10; //< We want to be able to grow maximum entity count by at least ten without going to the waiting list m_entities.reserve(m_entities.size() + m_waitingEntities.size() + MinEntityCapacity); for (auto& blockPtr : m_waitingEntities) From c9969d1b579934d2fe742fc4d053be76186a1ff7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 May 2017 21:21:25 +0200 Subject: [PATCH 194/243] Sdk/BaseComponent: Disable implicit copying --- SDK/include/NDK/BaseComponent.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NDK/BaseComponent.hpp index d9fdcba45..e6dfb5ed9 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NDK/BaseComponent.hpp @@ -23,7 +23,6 @@ namespace Ndk using Factory = std::function; BaseComponent(ComponentIndex componentIndex); - BaseComponent(const BaseComponent&) = default; BaseComponent(BaseComponent&&) = default; virtual ~BaseComponent(); @@ -34,7 +33,7 @@ namespace Ndk inline static ComponentIndex GetMaxComponentIndex(); - BaseComponent& operator=(const BaseComponent&) = default; + BaseComponent& operator=(const BaseComponent&) = delete; BaseComponent& operator=(BaseComponent&&) = default; protected: @@ -44,6 +43,8 @@ namespace Ndk static ComponentIndex RegisterComponent(ComponentId id, Factory factoryFunc); private: + BaseComponent(const BaseComponent&) = default; + virtual void OnAttached(); virtual void OnComponentAttached(BaseComponent& component); virtual void OnComponentDetached(BaseComponent& component); From 4a0cb4e1f13c7e6082ebda206a9e07b7629915ed Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 May 2017 21:26:01 +0200 Subject: [PATCH 195/243] Sdk/World: Get rid of now useless trick in Clone method EntityHandle can no longer move in memory until a world update --- SDK/src/NDK/World.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 81b862df9..8b7b51186 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -152,7 +152,7 @@ namespace Ndk clone->AddComponent(std::move(component)); } - return GetEntity(clone->GetId()); + return clone; } /*! From 3d25501f9fb8e568fba36a6b3f4cfe79917a0216 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 13 May 2017 20:00:15 +0200 Subject: [PATCH 196/243] Sdk: Fix compilation --- SDK/include/NDK/BaseComponent.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NDK/BaseComponent.hpp index e6dfb5ed9..427fb017e 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NDK/BaseComponent.hpp @@ -37,14 +37,14 @@ namespace Ndk BaseComponent& operator=(BaseComponent&&) = default; protected: + BaseComponent(const BaseComponent&) = default; + ComponentIndex m_componentIndex; EntityHandle m_entity; static ComponentIndex RegisterComponent(ComponentId id, Factory factoryFunc); private: - BaseComponent(const BaseComponent&) = default; - virtual void OnAttached(); virtual void OnComponentAttached(BaseComponent& component); virtual void OnComponentDetached(BaseComponent& component); From bb3eebb9ccf21adc9e29ce4f9eb0f99952791888 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 May 2017 22:13:31 +0200 Subject: [PATCH 197/243] Sdk/EntityList: Automatically remove entities from lists on destruction --- SDK/include/NDK/Entity.hpp | 8 +++- SDK/include/NDK/Entity.inl | 20 +++++++--- SDK/include/NDK/EntityList.hpp | 5 ++- SDK/include/NDK/EntityList.inl | 55 ++++++++++++++++++++++++---- SDK/src/NDK/Entity.cpp | 9 ++++- SDK/src/NDK/Systems/RenderSystem.cpp | 6 --- 6 files changed, 81 insertions(+), 22 deletions(-) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index e386100f8..5419da0d2 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -17,14 +17,17 @@ namespace Ndk { class BaseComponent; + class BaseSystem; class Entity; + class EntityList; class World; using EntityHandle = Nz::ObjectHandle; class NDK_API Entity : public Nz::HandledObject { - friend class BaseSystem; + friend BaseSystem; + friend EntityList; friend World; public: @@ -78,13 +81,16 @@ namespace Ndk inline Nz::Bitset<>& GetRemovedComponentBits(); + inline void RegisterEntityList(EntityList* list); inline void RegisterSystem(SystemIndex index); inline void SetWorld(World* world) noexcept; + inline void UnregisterEntityList(EntityList* list); inline void UnregisterSystem(SystemIndex index); std::vector> m_components; + std::vector m_containedInLists; Nz::Bitset<> m_componentBits; Nz::Bitset<> m_removedComponentBits; Nz::Bitset<> m_systemBits; diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index e6f997226..adb2153d8 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -257,11 +258,10 @@ namespace Ndk return m_removedComponentBits; } - /*! - * \brief Registers a system for the entity - * - * \param index Index of the system - */ + inline void Entity::RegisterEntityList(EntityList* list) + { + m_containedInLists.push_back(list); + } inline void Entity::RegisterSystem(SystemIndex index) { @@ -289,6 +289,16 @@ namespace Ndk * \param index Index of the system */ + inline void Entity::UnregisterEntityList(EntityList* list) + { + auto it = std::find(m_containedInLists.begin(), m_containedInLists.end(), list); + assert(it != m_containedInLists.end()); + + // Swap and pop idiom + *it = m_containedInLists.back(); + m_containedInLists.pop_back(); + } + inline void Entity::UnregisterSystem(SystemIndex index) { m_systemBits.UnboundedReset(index); diff --git a/SDK/include/NDK/EntityList.hpp b/SDK/include/NDK/EntityList.hpp index 76097f87b..b659b15fb 100644 --- a/SDK/include/NDK/EntityList.hpp +++ b/SDK/include/NDK/EntityList.hpp @@ -15,6 +15,8 @@ namespace Ndk { class NDK_API EntityList { + friend Entity; + public: class iterator; friend iterator; @@ -23,7 +25,7 @@ namespace Ndk inline EntityList(); inline EntityList(const EntityList& entityList); inline EntityList(EntityList&& entityList) noexcept; - ~EntityList() = default; + inline ~EntityList(); inline void Clear(); @@ -46,6 +48,7 @@ namespace Ndk private: inline std::size_t FindNext(std::size_t currentId) const; inline World* GetWorld() const; + inline void NotifyEntityDestruction(const Entity* entity); Nz::Bitset m_entityBits; World* m_world; diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index f5a751323..d178d2b09 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -5,7 +5,6 @@ #include #include #include -#include "EntityList.hpp" namespace Ndk { @@ -30,6 +29,8 @@ namespace Ndk m_entityBits(entityList.m_entityBits), m_world(entityList.m_world) { + for (const Ndk::EntityHandle& entity : *this) + entity->RegisterEntityList(this); } /*! @@ -39,6 +40,17 @@ namespace Ndk m_entityBits(std::move(entityList.m_entityBits)), m_world(entityList.m_world) { + for (const Ndk::EntityHandle& entity : *this) + { + entity->UnregisterEntityList(&entityList); + entity->RegisterEntityList(this); + } + } + + inline EntityList::~EntityList() + { + for (const Ndk::EntityHandle& entity : *this) + entity->UnregisterEntityList(this); } @@ -49,6 +61,9 @@ namespace Ndk */ inline void EntityList::Clear() { + for (const Ndk::EntityHandle& entity : *this) + entity->UnregisterEntityList(this); + m_entityBits.Clear(); m_world = nullptr; } @@ -88,15 +103,18 @@ namespace Ndk * * \remark If entity is already contained, no action is performed * \remark If any entity has been inserted since construction (or last Clear call), the entity must belong to the same world as the previously inserted entities - * \remark It's up to the programmer to remove an entity from this list before its deletion */ inline void EntityList::Insert(Entity* entity) { NazaraAssert(entity, "Invalid entity"); - NazaraAssert(!m_world || entity->GetWorld() == m_world, "Incompatible world"); - m_entityBits.UnboundedSet(entity->GetId(), true); - m_world = entity->GetWorld(); + if (!Has(entity)) + { + entity->RegisterEntityList(this); + + m_entityBits.UnboundedSet(entity->GetId(), true); + m_world = entity->GetWorld(); + } } /*! @@ -111,7 +129,12 @@ namespace Ndk */ inline void EntityList::Remove(Entity* entity) { - m_entityBits.UnboundedSet(entity->GetId(), false); + if (Has(entity)) + { + m_entityBits.Reset(entity->GetId()); + + entity->UnregisterEntityList(this); + } } // STL Interface @@ -140,14 +163,23 @@ namespace Ndk m_entityBits = entityList.m_entityBits; m_world = entityList.m_world; + for (const Ndk::EntityHandle& entity : *this) + entity->RegisterEntityList(this); + return *this; } - inline EntityList& EntityList::operator=(EntityList && entityList) noexcept + inline EntityList& EntityList::operator=(EntityList&& entityList) noexcept { m_entityBits = std::move(entityList.m_entityBits); m_world = entityList.m_world; + for (const Ndk::EntityHandle& entity : *this) + { + entity->UnregisterEntityList(&entityList); + entity->RegisterEntityList(this); + } + return *this; } @@ -161,6 +193,13 @@ namespace Ndk return m_world; } + inline void EntityList::NotifyEntityDestruction(const Entity* entity) + { + assert(Has(entity)); + + m_entityBits.Reset(entity->GetId()); + } + inline EntityList::iterator::iterator(const EntityList* list, std::size_t nextId) : m_nextEntityId(nextId), @@ -216,6 +255,6 @@ namespace Ndk using std::swap; - std::swap(lhs.m_nextEntityId, rhs.m_nextEntityId); + swap(lhs.m_nextEntityId, rhs.m_nextEntityId); } } diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 7419ac627..fab08b237 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -23,6 +23,7 @@ namespace Ndk Entity::Entity(Entity&& entity) : HandledObject(std::move(entity)), m_components(std::move(entity.m_components)), + m_containedInLists(std::move(entity.m_containedInLists)), m_componentBits(std::move(entity.m_componentBits)), m_removedComponentBits(std::move(entity.m_removedComponentBits)), m_systemBits(std::move(entity.m_systemBits)), @@ -176,9 +177,15 @@ namespace Ndk m_components.clear(); m_componentBits.Reset(); - // And then free every handle + // Free every handle UnregisterAllHandles(); + // Remove from every list + for (EntityList* list : m_containedInLists) + list->NotifyEntityDestruction(this); + + m_containedInLists.clear(); + m_valid = false; } diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index 44b0d1bba..022621596 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -57,12 +57,6 @@ namespace Ndk } } - m_directionalLights.Remove(entity); - m_drawables.Remove(entity); - m_lights.Remove(entity); - m_particleGroups.Remove(entity); - m_pointSpotLights.Remove(entity); - if (entity->HasComponent()) { GraphicsComponent& gfxComponent = entity->GetComponent(); From 7425993d2deb725312543deaa205a761f9c99ed4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 15 May 2017 10:11:42 +0200 Subject: [PATCH 198/243] SDK/World: Fix waiting entities not being cleared on time --- SDK/src/NDK/World.cpp | 1 + tests/SDK/NDK/Systems/ListenerSystem.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 8b7b51186..3ed1a25d0 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -119,6 +119,7 @@ namespace Ndk // This is made to avoid that handle warn uselessly entities before their destruction m_entities.clear(); m_entityBlocks.clear(); + m_waitingEntities.clear(); m_aliveEntities.Clear(); m_dirtyEntities.Clear(); diff --git a/tests/SDK/NDK/Systems/ListenerSystem.cpp b/tests/SDK/NDK/Systems/ListenerSystem.cpp index 2792dbc25..b83b24cd1 100644 --- a/tests/SDK/NDK/Systems/ListenerSystem.cpp +++ b/tests/SDK/NDK/Systems/ListenerSystem.cpp @@ -11,7 +11,7 @@ SCENARIO("ListenerSystem", "[NDK][LISTENERSYSTEM]") GIVEN("A world and an entity with listener & node components") { Ndk::World world; - const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::EntityHandle entity = world.CreateEntity(); Ndk::ListenerComponent& listenerComponent = entity->AddComponent(); Ndk::NodeComponent& nodeComponent = entity->AddComponent(); From 65d3b59e03613233bddbf8cf3ec1c716a5e5e124 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 16 May 2017 09:07:28 +0200 Subject: [PATCH 199/243] Network/SocketPoller: Makes it possible to watch read and write states --- include/Nazara/Network/Enums.hpp | 19 +++- include/Nazara/Network/SocketPoller.hpp | 7 +- src/Nazara/Network/Linux/SocketPollerImpl.cpp | 45 ++++++--- src/Nazara/Network/Linux/SocketPollerImpl.hpp | 8 +- src/Nazara/Network/Posix/SocketPollerImpl.cpp | 46 ++++++--- src/Nazara/Network/Posix/SocketPollerImpl.hpp | 5 +- src/Nazara/Network/SocketPoller.cpp | 43 +++++++-- src/Nazara/Network/Win32/SocketPollerImpl.cpp | 96 +++++++++++-------- src/Nazara/Network/Win32/SocketPollerImpl.hpp | 16 ++-- 9 files changed, 192 insertions(+), 93 deletions(-) diff --git a/include/Nazara/Network/Enums.hpp b/include/Nazara/Network/Enums.hpp index f80ba6cd9..39bce0dd0 100644 --- a/include/Nazara/Network/Enums.hpp +++ b/include/Nazara/Network/Enums.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_ENUMS_NETWORK_HPP #define NAZARA_ENUMS_NETWORK_HPP -#include +#include namespace Nz { @@ -91,6 +91,23 @@ namespace Nz SocketError_Max = SocketError_UnreachableHost }; + enum SocketPollEvent + { + SocketPollEvent_Read, //< One or more sockets is ready for a read operation + SocketPollEvent_Write, //< One or more sockets is ready for a write operation + + SocketPollEvent_Max = SocketPollEvent_Write + }; + + template<> + struct EnumAsFlags + { + static constexpr bool value = true; + static constexpr int max = SocketPollEvent_Max; + }; + + using SocketPollEventFlags = Flags; + enum SocketState { SocketState_Bound, //< The socket is currently bound diff --git a/include/Nazara/Network/SocketPoller.hpp b/include/Nazara/Network/SocketPoller.hpp index 74f90c17f..c801ca5e2 100644 --- a/include/Nazara/Network/SocketPoller.hpp +++ b/include/Nazara/Network/SocketPoller.hpp @@ -24,10 +24,11 @@ namespace Nz void Clear(); - bool IsReady(const AbstractSocket& socket) const; + bool IsReadyToRead(const AbstractSocket& socket) const; + bool IsReadyToWrite(const AbstractSocket& socket) const; bool IsRegistered(const AbstractSocket& socket) const; - bool RegisterSocket(AbstractSocket& socket); + bool RegisterSocket(AbstractSocket& socket, SocketPollEventFlags eventFlags); void UnregisterSocket(AbstractSocket& socket); bool Wait(UInt64 msTimeout); @@ -41,4 +42,4 @@ namespace Nz #include -#endif // NAZARA_SOCKETPOLLER_HPP \ No newline at end of file +#endif // NAZARA_SOCKETPOLLER_HPP diff --git a/src/Nazara/Network/Linux/SocketPollerImpl.cpp b/src/Nazara/Network/Linux/SocketPollerImpl.cpp index c839d7352..6617efd37 100644 --- a/src/Nazara/Network/Linux/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Linux/SocketPollerImpl.cpp @@ -23,13 +23,19 @@ namespace Nz void SocketPollerImpl::Clear() { - m_activeSockets.clear(); + m_readyToReadSockets.clear(); + m_readyToWriteSockets.clear(); m_sockets.clear(); } - bool SocketPollerImpl::IsReady(SocketHandle socket) const + bool SocketPollerImpl::IsReadyToRead(SocketHandle socket) const { - return m_activeSockets.count(socket) != 0; + return m_readyToReadSockets.count(socket) != 0; + } + + bool SocketPollerImpl::IsReadyToWrite(SocketHandle socket) const + { + return m_readyToWriteSockets.count(socket) != 0; } bool SocketPollerImpl::IsRegistered(SocketHandle socket) const @@ -37,15 +43,21 @@ namespace Nz return m_sockets.count(socket) != 0; } - bool SocketPollerImpl::RegisterSocket(SocketHandle socket) + bool SocketPollerImpl::RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags) { NazaraAssert(!IsRegistered(socket), "Socket is already registered"); - epoll_event event; - event.events = EPOLLIN; - event.data.fd = socket; + epoll_event entry; + entry.events = 0; + entry.data.fd = socket; - if (epoll_ctl(m_handle, EPOLL_CTL_ADD, socket, &event) != 0) + if (eventFlags & SocketPollEvent_Read) + entry.events |= EPOLLIN; + + if (eventFlags & SocketPollEvent_Write) + entry.events |= EPOLLOUT; + + if (epoll_ctl(m_handle, EPOLL_CTL_ADD, socket, &entry) != 0) { NazaraError("Failed to add socket to epoll structure (errno " + String::Number(errno) + ": " + Error::GetLastSystemError() + ')'); return false; @@ -60,7 +72,8 @@ namespace Nz { NazaraAssert(IsRegistered(socket), "Socket is not registered"); - m_activeSockets.erase(socket); + m_readyToReadSockets.erase(socket); + m_readyToWriteSockets.erase(socket); m_sockets.erase(socket); if (epoll_ctl(m_handle, EPOLL_CTL_DEL, socket, nullptr) != 0) @@ -84,21 +97,27 @@ namespace Nz return 0; } - m_activeSockets.clear(); + m_readyToReadSockets.clear(); + m_readyToWriteSockets.clear(); if (activeSockets > 0) { int socketCount = activeSockets; for (int i = 0; i < socketCount; ++i) { - if (m_events[i].events & (EPOLLIN | EPOLLHUP | EPOLLERR)) + if (m_events[i].events & (EPOLLIN | EPOLLOUT | EPOLLHUP | EPOLLERR)) { - m_activeSockets.insert(m_events[i].data.fd); + if (m_events[i].events & (EPOLLIN | EPOLLHUP | EPOLLERR)) + m_readyToReadSockets.insert(m_events[i].data.fd); + + if (m_events[i].events & (EPOLLOUT | EPOLLERR)) + m_readyToWriteSockets.insert(m_events[i].data.fd); + if (m_events[i].events & EPOLLERR) NazaraWarning("Descriptor " + String::Number(m_events[i].data.fd) + " was returned by epoll with EPOLLERR status"); } else { - NazaraWarning("Descriptor " + String::Number(m_events[i].data.fd) + " was returned by epoll without EPOLLIN (events: 0x" + String::Number(m_events[i].events, 16) + ')'); + NazaraWarning("Descriptor " + String::Number(m_events[i].data.fd) + " was returned by epoll without EPOLLIN nor EPOLLOUT flags (events: 0x" + String::Number(m_events[i].events, 16) + ')'); activeSockets--; } } diff --git a/src/Nazara/Network/Linux/SocketPollerImpl.hpp b/src/Nazara/Network/Linux/SocketPollerImpl.hpp index 1c54471fc..a804102fa 100644 --- a/src/Nazara/Network/Linux/SocketPollerImpl.hpp +++ b/src/Nazara/Network/Linux/SocketPollerImpl.hpp @@ -23,16 +23,18 @@ namespace Nz void Clear(); - bool IsReady(SocketHandle socket) const; + bool IsReadyToRead(SocketHandle socket) const; + bool IsReadyToWrite(SocketHandle socket) const; bool IsRegistered(SocketHandle socket) const; - bool RegisterSocket(SocketHandle socket); + bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags); void UnregisterSocket(SocketHandle socket); int Wait(UInt64 msTimeout, SocketError* error); private: - std::unordered_set m_activeSockets; + std::unordered_set m_readyToReadSockets; + std::unordered_set m_readyToWriteSockets; std::unordered_set m_sockets; std::vector m_events; int m_handle; diff --git a/src/Nazara/Network/Posix/SocketPollerImpl.cpp b/src/Nazara/Network/Posix/SocketPollerImpl.cpp index 5d2a6c317..59b8a8ca7 100644 --- a/src/Nazara/Network/Posix/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Posix/SocketPollerImpl.cpp @@ -10,14 +10,20 @@ namespace Nz { void SocketPollerImpl::Clear() { - m_activeSockets.clear(); + m_readyToReadSockets.clear(); + m_readyToWriteSockets.clear(); m_allSockets.clear(); m_sockets.clear(); } - bool SocketPollerImpl::IsReady(SocketHandle socket) const + bool SocketPollerImpl::IsReadyToRead(SocketHandle socket) const { - return m_activeSockets.count(socket) != 0; + return m_readyToReadSockets.count(socket) != 0; + } + + bool SocketPollerImpl::IsReadyToWrite(SocketHandle socket) const + { + return m_readyToWriteSockets.count(socket) != 0; } bool SocketPollerImpl::IsRegistered(SocketHandle socket) const @@ -25,16 +31,22 @@ namespace Nz return m_allSockets.count(socket) != 0; } - bool SocketPollerImpl::RegisterSocket(SocketHandle socket) + bool SocketPollerImpl::RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags) { NazaraAssert(!IsRegistered(socket), "Socket is already registered"); PollSocket entry = { socket, - POLLRDNORM, + 0, 0 }; + if (eventFlags & SocketPollEvent_Read) + entry.events |= POLLRDNORM; + + if (eventFlags & SocketPollEvent_Write) + entry.events |= POLLWRNORM; + m_allSockets[socket] = m_sockets.size(); m_sockets.emplace_back(entry); @@ -57,10 +69,11 @@ namespace Nz // Now move it properly (lastElement is invalid after the following line) and pop it m_sockets[entry] = std::move(m_sockets.back()); } - m_sockets.pop_back(); - m_activeSockets.erase(socket); + m_allSockets.erase(socket); + m_readyToReadSockets.erase(socket); + m_readyToWriteSockets.erase(socket); } int SocketPollerImpl::Wait(UInt64 msTimeout, SocketError* error) @@ -68,20 +81,25 @@ namespace Nz int activeSockets; // Reset status of sockets - for (PollSocket& entry : m_sockets) - entry.revents = 0; - activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast(msTimeout), error); - m_activeSockets.clear(); - if (activeSockets > 0) + m_readyToReadSockets.clear(); + m_readyToWriteSockets.clear(); + if (activeSockets > 0U) { int socketRemaining = activeSockets; for (PollSocket& entry : m_sockets) { - if (entry.revents & POLLRDNORM) + if (entry.revents != 0) { - m_activeSockets.insert(entry.fd); + if (entry.revents & POLLRDNORM) + m_readyToReadSockets.insert(entry.fd); + + if (entry.revents & POLLWRNORM) + m_readyToWriteSockets.insert(entry.fd); + + entry.revents = 0; + if (--socketRemaining == 0) break; } diff --git a/src/Nazara/Network/Posix/SocketPollerImpl.hpp b/src/Nazara/Network/Posix/SocketPollerImpl.hpp index 3472c3265..3582121d4 100644 --- a/src/Nazara/Network/Posix/SocketPollerImpl.hpp +++ b/src/Nazara/Network/Posix/SocketPollerImpl.hpp @@ -27,13 +27,14 @@ namespace Nz bool IsReady(SocketHandle socket) const; bool IsRegistered(SocketHandle socket) const; - bool RegisterSocket(SocketHandle socket); + bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags); void UnregisterSocket(SocketHandle socket); int Wait(UInt64 msTimeout, SocketError* error); private: - std::unordered_set m_activeSockets; + std::unordered_set m_readyToReadSockets; + std::unordered_set m_readyToWriteSockets; std::unordered_map m_allSockets; std::vector m_sockets; }; diff --git a/src/Nazara/Network/SocketPoller.cpp b/src/Nazara/Network/SocketPoller.cpp index 43250a84f..7ef261ef9 100644 --- a/src/Nazara/Network/SocketPoller.cpp +++ b/src/Nazara/Network/SocketPoller.cpp @@ -57,12 +57,13 @@ namespace Nz /*! * \brief Checks if a specific socket is ready to read data * - * This function allows you to read the results of the last Wait operation and if a specific socket is ready. + * This function allows you to read the results of the last Wait operation and if a specific socket is ready to read (has incoming data). * - * A socket in the ready state (with the exception of TcpServer) has incoming data and can be read without blocking. + * A socket in the ready to read state (with the exception of TcpServer) has incoming data and can be read without blocking. * - * \remark When used on a TcpServer socket, this function returns true if the server is ready to accept a new client. - * \remark You must call Wait before using this function in order to refresh the state. + * \remark You must call Wait before using this function in order to refresh the read state. + * \remark A socket must be registered with SocketPollerEvent_Read event flag for its read state to be watched + * \remark A TcpServer socket becomes ready to read when it is ready to accept a new client. * * \param socket Reference to the socket to check * @@ -70,11 +71,32 @@ namespace Nz * * \see Wait */ - bool SocketPoller::IsReady(const AbstractSocket& socket) const + bool SocketPoller::IsReadyToRead(const AbstractSocket& socket) const { NazaraAssert(IsRegistered(socket), "Socket is not registered in the poller"); - return m_impl->IsReady(socket.GetNativeHandle()); + return m_impl->IsReadyToRead(socket.GetNativeHandle()); + } + + /*! + * \brief Checks if a specific socket is ready to write data + * + * This function allows you to read the results of the last Wait operation and if a specific socket is ready to write (can be written to without blocking). + * + * \remark You must call Wait before using this function in order to refresh the read state. + * \remark A socket must be registered with SocketPollerEvent_Write event flag for its read state to be watched + * + * \param socket Reference to the socket to check + * + * \return True if the socket is available for writing without blocking, false otherwise + * + * \see Wait + */ + bool SocketPoller::IsReadyToWrite(const AbstractSocket& socket) const + { + NazaraAssert(IsRegistered(socket), "Socket is not registered in the poller"); + + return m_impl->IsReadyToWrite(socket.GetNativeHandle()); } /*! @@ -97,7 +119,7 @@ namespace Nz /*! * \brief Register a socket in the SocketPoller * - * A registered socket is part of the SocketPoller and will be checked by the next Wait operations. + * A registered socket is part of the SocketPoller and will be checked by the next Wait operations according to the event flags passed when registered. * * The SocketPoller keeps a reference to the internal handle of registered socket, which should not be freed while it is registered in the SocketPooler. * @@ -107,17 +129,18 @@ namespace Nz * \remark The socket should not be freed while it is registered in the SocketPooler. * * \param socket Reference to the socket to register + * \param eventFlags Socket events to watch * * \return True if the socket is registered, false otherwise * * \see IsRegistered * \see UnregisterSocket */ - bool SocketPoller::RegisterSocket(AbstractSocket& socket) + bool SocketPoller::RegisterSocket(AbstractSocket& socket, SocketPollEventFlags eventFlags) { NazaraAssert(!IsRegistered(socket), "This socket is already registered in this SocketPoller"); - return m_impl->RegisterSocket(socket.GetNativeHandle()); + return m_impl->RegisterSocket(socket.GetNativeHandle(), eventFlags); } /*! @@ -145,7 +168,7 @@ namespace Nz * \brief Wait until any registered socket switches to a ready state. * * Waits a specific/undetermined amount of time until at least one socket part of the SocketPoller becomes ready. - * To query the ready state of the registered socket, use the IsReady function. + * To query the ready state of the registered socket, use the IsReadyToRead or IsReadyToWrite functions. * * \param msTimeout Maximum time to wait in milliseconds, 0 for infinity * diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp index 292e8dfa5..405f80c8f 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -10,29 +10,43 @@ namespace Nz SocketPollerImpl::SocketPollerImpl() { #if !NAZARA_NETWORK_POLL_SUPPORT - FD_ZERO(&m_activeSockets); - FD_ZERO(&m_sockets); + FD_ZERO(&m_readSockets); + FD_ZERO(&m_readyToReadSockets); + FD_ZERO(&m_readyToWriteSockets); + FD_ZERO(&m_writeSockets); #endif } void SocketPollerImpl::Clear() { #if NAZARA_NETWORK_POLL_SUPPORT - m_activeSockets.clear(); m_allSockets.clear(); + m_readyToReadSockets.clear(); + m_readyToWriteSockets.clear(); m_sockets.clear(); #else - FD_ZERO(&m_activeSockets); - FD_ZERO(&m_sockets); + FD_ZERO(&m_readSockets); + FD_ZERO(&m_readyToReadSockets); + FD_ZERO(&m_readyToWriteSockets); + FD_ZERO(&m_writeSockets); #endif } - bool SocketPollerImpl::IsReady(SocketHandle socket) const + bool SocketPollerImpl::IsReadyToRead(SocketHandle socket) const { #if NAZARA_NETWORK_POLL_SUPPORT - return m_activeSockets.count(socket) != 0; + return m_readyToReadSockets.count(socket) != 0; #else - return FD_ISSET(socket, &m_activeSockets) != 0; + return FD_ISSET(socket, &m_readyToReadSockets) != 0; + #endif + } + + bool SocketPollerImpl::IsReadyToWrite(SocketHandle socket) const + { + #if NAZARA_NETWORK_POLL_SUPPORT + return m_readyToWriteSockets.count(socket) != 0; + #else + return FD_ISSET(socket, &m_readyToWriteSockets) != 0; #endif } @@ -41,31 +55,45 @@ namespace Nz #if NAZARA_NETWORK_POLL_SUPPORT return m_allSockets.count(socket) != 0; #else - return FD_ISSET(socket, &m_sockets) != 0; + return FD_ISSET(socket, &m_readSockets) != 0 || + FD_ISSET(socket, &m_writeSockets) != 0; #endif } - bool SocketPollerImpl::RegisterSocket(SocketHandle socket) + bool SocketPollerImpl::RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags) { NazaraAssert(!IsRegistered(socket), "Socket is already registered"); #if NAZARA_NETWORK_POLL_SUPPORT PollSocket entry = { socket, - POLLRDNORM, + 0, 0 }; + if (eventFlags & SocketPollEvent_Read) + entry.events |= POLLRDNORM; + + if (eventFlags & SocketPollEvent_Write) + entry.events |= POLLWRNORM; + m_allSockets[socket] = m_sockets.size(); m_sockets.emplace_back(entry); #else - if (m_sockets.fd_count > FD_SETSIZE) + for (std::size_t i = 0; i < 2; ++i) { - NazaraError("Socket count exceeding FD_SETSIZE (" + String::Number(FD_SETSIZE) + ")"); - return false; - } + if (eventFlags & ((i == 0) ? SocketPollEvent_Read : SocketPollEvent_Write) == 0) + continue; - FD_SET(socket, &m_sockets); + fd_set& targetSet = (i == 0) ? m_readSockets : m_writeSockets; + if (targetSet.fd_count > FD_SETSIZE) + { + NazaraError("Socket count exceeding hard-coded FD_SETSIZE (" + String::Number(FD_SETSIZE) + ")"); + return false; + } + + FD_SET(socket, &targetSet); + } #endif return true; @@ -88,13 +116,16 @@ namespace Nz // Now move it properly (lastElement is invalid after the following line) and pop it m_sockets[entry] = std::move(m_sockets.back()); } - m_sockets.pop_back(); - m_activeSockets.erase(socket); + m_allSockets.erase(socket); + m_readyToReadSockets.erase(socket); + m_readyToWriteSockets.erase(socket); #else - FD_CLR(socket, &m_activeSockets); - FD_CLR(socket, &m_sockets); + FD_CLR(socket, &m_readSockets); + FD_CLR(socket, &m_readyToReadSockets); + FD_CLR(socket, &m_readyToWriteSockets); + FD_CLR(socket, &m_writeSockets); #endif } @@ -103,35 +134,18 @@ namespace Nz int activeSockets; #if NAZARA_NETWORK_POLL_SUPPORT - // Reset status of sockets - for (PollSocket& entry : m_sockets) - entry.revents = 0; - activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast(msTimeout), error); + x - m_activeSockets.clear(); - if (activeSockets > 0U) - { - int socketRemaining = activeSockets; - for (PollSocket& entry : m_sockets) - { - if (entry.revents & POLLRDNORM) - { - m_activeSockets.insert(entry.fd); - if (--socketRemaining == 0) - break; - } - } - } #else - - m_activeSockets = m_sockets; + m_readyToReadSockets = m_readSockets; + m_readyToWriteSockets = m_writeSockets; timeval tv; tv.tv_sec = static_cast(msTimeout / 1000ULL); tv.tv_usec = static_cast((msTimeout % 1000ULL) * 1000ULL); - activeSockets = ::select(0xDEADBEEF, &m_activeSockets, nullptr, nullptr, (msTimeout > 0) ? &tv : nullptr); //< The first argument is ignored on Windows + activeSockets = ::select(0xDEADBEEF, &m_readyToReadSockets, &m_readyToWriteSockets, nullptr, (msTimeout > 0) ? &tv : nullptr); //< The first argument is ignored on Windows if (activeSockets == SOCKET_ERROR) { if (error) diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.hpp b/src/Nazara/Network/Win32/SocketPollerImpl.hpp index 0a745878d..a94af1372 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.hpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.hpp @@ -25,24 +25,28 @@ namespace Nz void Clear(); - bool IsReady(SocketHandle socket) const; + bool IsReadyToRead(SocketHandle socket) const; + bool IsReadyToWrite(SocketHandle socket) const; bool IsRegistered(SocketHandle socket) const; - bool RegisterSocket(SocketHandle socket); + bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags); void UnregisterSocket(SocketHandle socket); int Wait(UInt64 msTimeout, SocketError* error); private: #if NAZARA_NETWORK_POLL_SUPPORT - std::unordered_set m_activeSockets; + std::unordered_set m_readyToReadSockets; + std::unordered_set m_readyToWriteSockets; std::unordered_map m_allSockets; std::vector m_sockets; #else - fd_set m_sockets; - fd_set m_activeSockets; + fd_set m_readSockets; + fd_set m_readyToReadSockets; + fd_set m_readyToWriteSockets; + fd_set m_writeSockets; #endif }; } -#endif // NAZARA_SOCKETPOLLERIMPL_HPP \ No newline at end of file +#endif // NAZARA_SOCKETPOLLERIMPL_HPP From d516b0907b8247c61255b8c6041ad9bb67bb5742 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 16 May 2017 09:11:02 +0200 Subject: [PATCH 200/243] Network/ENetHost: Fix usage of SocketPoller --- src/Nazara/Network/ENetHost.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index d4d1be9f9..e12f80454 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -280,7 +280,7 @@ namespace Nz m_serviceTime = GetElapsedMilliseconds(); } - while (m_poller.IsReady(m_socket)); + while (m_poller.IsReadyToRead(m_socket)); return 0; } @@ -327,7 +327,7 @@ namespace Nz } } - m_poller.RegisterSocket(m_socket); + m_poller.RegisterSocket(m_socket, SocketPollEvent_Read); return true; } From 999cb13f000918cbefd598dc3b265d28179aa539 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 16 May 2017 09:19:37 +0200 Subject: [PATCH 201/243] Fix test compilation --- tests/Engine/Network/SocketPoller.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Engine/Network/SocketPoller.cpp b/tests/Engine/Network/SocketPoller.cpp index 7081c1b30..2e880cf5c 100644 --- a/tests/Engine/Network/SocketPoller.cpp +++ b/tests/Engine/Network/SocketPoller.cpp @@ -27,7 +27,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]") WHEN("We register the server socket to the poller") { - REQUIRE(serverPoller.RegisterSocket(server)); + REQUIRE(serverPoller.RegisterSocket(server, Nz::SocketPollEvent_Read)); THEN("The poller should have registered our socket") { @@ -48,7 +48,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]") WHEN("We register the client socket to the poller") { - REQUIRE(serverPoller.RegisterSocket(serverToClient)); + REQUIRE(serverPoller.RegisterSocket(serverToClient, Nz::SocketPollEvent_Read)); THEN("The poller should have registered our socket") { @@ -65,7 +65,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]") REQUIRE(serverPoller.Wait(1000)); - CHECK(serverPoller.IsReady(serverToClient)); + CHECK(serverPoller.IsReadyToRead(serverToClient)); CHECK(serverToClient.Read(buffer.data(), buffer.size()) == sent); @@ -73,7 +73,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]") { REQUIRE_FALSE(serverPoller.Wait(100)); - REQUIRE_FALSE(serverPoller.IsReady(serverToClient)); + REQUIRE_FALSE(serverPoller.IsReadyToRead(serverToClient)); } } } From 1cdac50af215da6d033099ded414716fd08f3c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 16 May 2017 10:09:09 +0200 Subject: [PATCH 202/243] Network/SocketPoller: Fix RegisterSocket on Windows --- src/Nazara/Network/Win32/SocketPollerImpl.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp index 405f80c8f..e228da789 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -82,7 +82,7 @@ namespace Nz #else for (std::size_t i = 0; i < 2; ++i) { - if (eventFlags & ((i == 0) ? SocketPollEvent_Read : SocketPollEvent_Write) == 0) + if ((eventFlags & ((i == 0) ? SocketPollEvent_Read : SocketPollEvent_Write)) == 0) continue; fd_set& targetSet = (i == 0) ? m_readSockets : m_writeSockets; @@ -135,8 +135,6 @@ namespace Nz #if NAZARA_NETWORK_POLL_SUPPORT activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast(msTimeout), error); - x - #else m_readyToReadSockets = m_readSockets; m_readyToWriteSockets = m_writeSockets; From ba24181fd69d900881e71277bbecaee2bb7dbf67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 17 May 2017 11:29:55 +0200 Subject: [PATCH 203/243] Network/SocketPollerImpl: Fix possible weird behavior with SocketPoller --- src/Nazara/Network/Win32/SocketPollerImpl.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp index e228da789..3513ce722 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -136,14 +136,26 @@ namespace Nz #if NAZARA_NETWORK_POLL_SUPPORT activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast(msTimeout), error); #else - m_readyToReadSockets = m_readSockets; - m_readyToWriteSockets = m_writeSockets; + fd_set* readSet = nullptr; + fd_set* writeSet = nullptr; + + if (m_readSockets.fd_count > 0) + { + m_readyToReadSockets = m_readSockets; + readSet = &m_readyToReadSockets; + } + + if (m_writeSockets.fd_count > 0) + { + m_readyToWriteSockets = m_writeSockets; + readSet = &m_readyToWriteSockets; + } timeval tv; tv.tv_sec = static_cast(msTimeout / 1000ULL); tv.tv_usec = static_cast((msTimeout % 1000ULL) * 1000ULL); - activeSockets = ::select(0xDEADBEEF, &m_readyToReadSockets, &m_readyToWriteSockets, nullptr, (msTimeout > 0) ? &tv : nullptr); //< The first argument is ignored on Windows + activeSockets = ::select(0xDEADBEEF, readSet, writeSet, nullptr, (msTimeout > 0) ? &tv : nullptr); //< The first argument is ignored on Windows if (activeSockets == SOCKET_ERROR) { if (error) From 3b7881ebfecb888dae28607a9cb582e2ae14a403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 17 May 2017 11:29:55 +0200 Subject: [PATCH 204/243] Network/SocketPollerImpl: Fix possible weird behavior with SocketPoller --- src/Nazara/Network/Win32/SocketPollerImpl.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp index e228da789..3513ce722 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -136,14 +136,26 @@ namespace Nz #if NAZARA_NETWORK_POLL_SUPPORT activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast(msTimeout), error); #else - m_readyToReadSockets = m_readSockets; - m_readyToWriteSockets = m_writeSockets; + fd_set* readSet = nullptr; + fd_set* writeSet = nullptr; + + if (m_readSockets.fd_count > 0) + { + m_readyToReadSockets = m_readSockets; + readSet = &m_readyToReadSockets; + } + + if (m_writeSockets.fd_count > 0) + { + m_readyToWriteSockets = m_writeSockets; + readSet = &m_readyToWriteSockets; + } timeval tv; tv.tv_sec = static_cast(msTimeout / 1000ULL); tv.tv_usec = static_cast((msTimeout % 1000ULL) * 1000ULL); - activeSockets = ::select(0xDEADBEEF, &m_readyToReadSockets, &m_readyToWriteSockets, nullptr, (msTimeout > 0) ? &tv : nullptr); //< The first argument is ignored on Windows + activeSockets = ::select(0xDEADBEEF, readSet, writeSet, nullptr, (msTimeout > 0) ? &tv : nullptr); //< The first argument is ignored on Windows if (activeSockets == SOCKET_ERROR) { if (error) From 09bace0f28baf5761889c82318593aa6e8ff1b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 18 May 2017 11:44:28 +0200 Subject: [PATCH 205/243] Sdk/LuaBinding: Bind UdpSocket --- SDK/include/NDK/Lua/LuaBinding_Network.hpp | 2 + SDK/src/NDK/Lua/LuaBinding_Network.cpp | 60 +++++++++++++++++++++- examples/FirstScene/main.cpp | 2 + include/Nazara/Network/UdpSocket.hpp | 1 - include/Nazara/Network/UdpSocket.inl | 10 ---- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/SDK/include/NDK/Lua/LuaBinding_Network.hpp b/SDK/include/NDK/Lua/LuaBinding_Network.hpp index a9a5b31e0..3774cb5e8 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Network.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Network.hpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace Ndk @@ -23,6 +24,7 @@ namespace Ndk Nz::LuaClass abstractSocket; Nz::LuaClass ipAddress; + Nz::LuaClass udpSocket; }; } diff --git a/SDK/src/NDK/Lua/LuaBinding_Network.cpp b/SDK/src/NDK/Lua/LuaBinding_Network.cpp index d6f92cb40..a47cdbfb6 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Network.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Network.cpp @@ -32,7 +32,7 @@ namespace Ndk { std::size_t argCount = std::min(argumentCount, 9U); - int argIndex = 2; + int argIndex = 1; switch (argCount) { case 0: @@ -142,6 +142,63 @@ namespace Ndk } }); } + + udpSocket.Reset("UdpSocket"); + { + udpSocket.Inherit(abstractSocket); + + udpSocket.BindDefaultConstructor(); + + udpSocket.BindMethod("Create", &Nz::UdpSocket::Create); + udpSocket.BindMethod("EnableBroadcasting", &Nz::UdpSocket::EnableBroadcasting); + udpSocket.BindMethod("GetBoundAddress", &Nz::UdpSocket::GetBoundAddress); + udpSocket.BindMethod("GetBoundPort", &Nz::UdpSocket::GetBoundPort); + udpSocket.BindMethod("IsBroadcastingEnabled", &Nz::UdpSocket::IsBroadcastingEnabled); + udpSocket.BindMethod("QueryMaxDatagramSize", &Nz::UdpSocket::QueryMaxDatagramSize); + + udpSocket.BindMethod("Bind", [](Nz::LuaInstance& lua, Nz::UdpSocket& instance, std::size_t /*argumentCount*/) -> int + { + int argIndex = 2; + if (lua.IsOfType(argIndex, "IpAddress")) + return lua.Push(instance.Bind(*static_cast(lua.ToUserdata(argIndex)))); + else + return lua.Push(instance.Bind(lua.Check(&argIndex))); + }); + + udpSocket.BindMethod("Receive", [](Nz::LuaInstance& lua, Nz::UdpSocket& instance, std::size_t /*argumentCount*/) -> int + { + Nz::IpAddress from; + + std::array buffer; + std::size_t received; + if (instance.Receive(buffer.data(), buffer.size(), &from, &received)) + { + lua.PushBoolean(true); + lua.PushString(from.ToString()); + lua.PushString(buffer.data(), received); + return 3; + } + + lua.PushBoolean(false); + return 1; + }); + + udpSocket.BindMethod("Send", [](Nz::LuaInstance& lua, Nz::UdpSocket& instance, std::size_t /*argumentCount*/) -> int + { + int argIndex = 2; + Nz::String to = lua.Check(&argIndex); + + std::size_t bufferLength; + const char* buffer = lua.CheckString(argIndex, &bufferLength); + + std::size_t sent; + bool ret; + if ((ret = instance.Send(Nz::IpAddress(to), buffer, bufferLength, &sent)) != true) + sent = 0; + + return lua.Push(std::make_pair(ret, sent)); + }); + } } /*! @@ -154,6 +211,7 @@ namespace Ndk // Classes abstractSocket.Register(instance); ipAddress.Register(instance); + udpSocket.Register(instance); // Enums diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index b7e7d1198..4acbdf5a1 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -16,6 +16,7 @@ #include // Module de scripting #include // Module graphique #include // Module de rendu +#include // Module utilitaire #include // Module utilitaire #include #include @@ -33,6 +34,7 @@ int main() { // Ndk::Application est une classe s'occupant de l'initialisation du moteur ainsi que de la gestion de beaucoup de choses Ndk::Application application; + Nz::Initializer network; // Nazara étant initialisé, nous pouvons créer le monde pour contenir notre scène. // Dans un ECS, le monde représente bien ce que son nom indique, c'est l'ensemble de ce qui existe au niveau de l'application. diff --git a/include/Nazara/Network/UdpSocket.hpp b/include/Nazara/Network/UdpSocket.hpp index 04ca41db0..0086249e9 100644 --- a/include/Nazara/Network/UdpSocket.hpp +++ b/include/Nazara/Network/UdpSocket.hpp @@ -33,7 +33,6 @@ namespace Nz inline IpAddress GetBoundAddress() const; inline UInt16 GetBoundPort() const; - inline SocketState GetState() const; inline bool IsBroadcastingEnabled() const; diff --git a/include/Nazara/Network/UdpSocket.inl b/include/Nazara/Network/UdpSocket.inl index 3e4dee4df..2925c1935 100644 --- a/include/Nazara/Network/UdpSocket.inl +++ b/include/Nazara/Network/UdpSocket.inl @@ -103,16 +103,6 @@ namespace Nz return m_boundAddress.GetPort(); } - /*! - * \brief Gets the state of the socket - * \return State of the socket - */ - - inline SocketState UdpSocket::GetState() const - { - return m_state; - } - /*! * \brief Checks whether the broadcasting is enabled * \return true If it is the case From 3ca179b954e22b640ef753bd8064727a328d6250 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 19 May 2017 16:31:29 +0200 Subject: [PATCH 206/243] Network/ENet: Separate Connect event into OutgoingConnect and IncomingConnect --- include/Nazara/Network/ENetHost.hpp | 2 +- include/Nazara/Network/ENetProtocol.hpp | 18 +++++++++++------- src/Nazara/Network/ENetHost.cpp | 15 +++++++++++---- src/Nazara/Network/ENetPeer.cpp | 6 +++--- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 4941df353..eb5c7d6de 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -87,7 +87,7 @@ namespace Nz int ReceiveIncomingCommands(ENetEvent* event); - void NotifyConnect(ENetPeer* peer, ENetEvent* event); + void NotifyConnect(ENetPeer* peer, ENetEvent* event, bool incoming); void NotifyDisconnect(ENetPeer*, ENetEvent* event); void SendAcknowledgements(ENetPeer* peer); diff --git a/include/Nazara/Network/ENetProtocol.hpp b/include/Nazara/Network/ENetProtocol.hpp index 7cd613ab0..dab014aa2 100644 --- a/include/Nazara/Network/ENetProtocol.hpp +++ b/include/Nazara/Network/ENetProtocol.hpp @@ -118,11 +118,6 @@ namespace Nz /** no event occurred within the specified time limit */ None, - /** a connection request initiated by enet_host_connect has completed. - * The peer field contains the peer which successfully connected. - */ - Connect, - /** a peer has disconnected. This event is generated on a successful * completion of a disconnect initiated by enet_peer_disconnect, if * a peer has timed out, or if a connection request initialized by @@ -132,11 +127,20 @@ namespace Nz */ Disconnect, + /** a connection request initiated by enet_host_connect from this host has completed. + * The peer field contains the peer which successfully connected. + */ + OutgoingConnect, + + /** a connection request initiated by enet_host_connect from another host has completed. + * The peer field contains the peer which successfully connected. + */ + IncomingConnect, + /** a packet has been received from a peer. The peer field specifies the * peer which sent the packet. The channelID field specifies the channel * number upon which the packet was received. The packet field contains - * the packet that was received; this packet must be destroyed with - * enet_packet_destroy after use. + * the packet that was received; */ Receive }; diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index d4d1be9f9..ade03bb10 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -352,10 +352,17 @@ namespace Nz switch (peer.GetState()) { case ENetPeerState::ConnectionPending: + peer.ChangeState(ENetPeerState::Connected); + + event->type = ENetEventType::IncomingConnect; + event->peer = &peer; + event->data = peer.m_eventData; + return true; + case ENetPeerState::ConnectionSucceeded: peer.ChangeState(ENetPeerState::Connected); - event->type = ENetEventType::Connect; + event->type = ENetEventType::OutgoingConnect; event->peer = &peer; event->data = peer.m_eventData; return true; @@ -728,7 +735,7 @@ namespace Nz return -1; } - void ENetHost::NotifyConnect(ENetPeer* peer, ENetEvent* event) + void ENetHost::NotifyConnect(ENetPeer* peer, ENetEvent* event, bool incoming) { m_recalculateBandwidthLimits = true; @@ -736,12 +743,12 @@ namespace Nz { peer->ChangeState(ENetPeerState::Connected); - event->type = ENetEventType::Connect; + event->type = (incoming) ? ENetEventType::IncomingConnect : ENetEventType::OutgoingConnect; event->peer = peer; event->data = peer->m_eventData; } else - peer->DispatchState(peer->GetState() == ENetPeerState::Connecting ? ENetPeerState::ConnectionSucceeded : ENetPeerState::ConnectionPending); + peer->DispatchState((peer->GetState() == ENetPeerState::Connecting) ? ENetPeerState::ConnectionSucceeded : ENetPeerState::ConnectionPending); } void ENetHost::NotifyDisconnect(ENetPeer* peer, ENetEvent* event) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 5ce92a1e4..cbae37148 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -501,7 +501,7 @@ namespace Nz if (commandNumber != ENetProtocolCommand_VerifyConnect) return false; - m_host->NotifyConnect(this, event); + m_host->NotifyConnect(this, event, true); break; case ENetPeerState::Disconnecting: @@ -864,7 +864,7 @@ namespace Nz NetToHost(command->verifyConnect.packetThrottleInterval) != m_packetThrottleInterval || NetToHost(command->verifyConnect.packetThrottleAcceleration) != m_packetThrottleAcceleration || NetToHost(command->verifyConnect.packetThrottleDeceleration) != m_packetThrottleDeceleration || - command->verifyConnect.connectID != m_connectID) + command->verifyConnect.connectID != m_connectID) { m_eventData = 0; @@ -891,7 +891,7 @@ namespace Nz m_incomingBandwidth = NetToHost(command->verifyConnect.incomingBandwidth); m_outgoingBandwidth = NetToHost(command->verifyConnect.outgoingBandwidth); - m_host->NotifyConnect(this, event); + m_host->NotifyConnect(this, event, false); return true; } From 3e972401488da555e742fc33fa266fb13cd80af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 29 May 2017 18:01:19 +0200 Subject: [PATCH 207/243] Core/ParameterList: Add ForEach methods --- include/Nazara/Core/ParameterList.hpp | 5 ++++ include/Nazara/Core/ParameterList.inl | 42 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 include/Nazara/Core/ParameterList.inl diff --git a/include/Nazara/Core/ParameterList.hpp b/include/Nazara/Core/ParameterList.hpp index 75972b49c..3e9d3a825 100644 --- a/include/Nazara/Core/ParameterList.hpp +++ b/include/Nazara/Core/ParameterList.hpp @@ -27,6 +27,9 @@ namespace Nz void Clear(); + inline void ForEach(const std::function& callback); + inline void ForEach(const std::function& callback) const; + bool GetBooleanParameter(const String& name, bool* value) const; bool GetColorParameter(const String& name, Color* value) const; bool GetFloatParameter(const String& name, float* value) const; @@ -102,4 +105,6 @@ namespace Nz std::ostream& operator<<(std::ostream& out, const Nz::ParameterList& parameterList); +#include + #endif // NAZARA_PARAMETERLIST_HPP diff --git a/include/Nazara/Core/ParameterList.inl b/include/Nazara/Core/ParameterList.inl new file mode 100644 index 000000000..b1983b49b --- /dev/null +++ b/include/Nazara/Core/ParameterList.inl @@ -0,0 +1,42 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \brief Iterates over every value of the parameter list + * + * \param callback Callback function called with every parameter contained in the list, which can return true to remove the key (or false to keep it) + * + * \remark Changing the ParameterList while iterating on it may cause bugs, but querying data is safe. + */ + inline void ParameterList::ForEach(const std::function& callback) + { + for (auto it = m_parameters.begin(); it != m_parameters.end();) + { + if (callback(*this, it->first)) + it = m_parameters.erase(it); + else + ++it; + } + } + + /*! + * \brief Iterates over every value of the parameter list + * + * \param callback Callback function called with every parameter contained in the list + * + * \remark Changing the ParameterList while iterating on it may cause bugs, but querying data is safe. + */ + inline void ParameterList::ForEach(const std::function& callback) const + { + for (auto& pair : m_parameters) + callback(*this, pair.first); + } +} + +#include From 30a4e20ee535c386f01ba9775e46c78b4e1a5002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 29 May 2017 18:01:31 +0200 Subject: [PATCH 208/243] Lua/LuaInstance: Expose some raw functions --- include/Nazara/Lua/LuaInstance.hpp | 3 +++ src/Nazara/Lua/LuaInstance.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index 39b0879a8..2ac752c9e 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -101,6 +101,7 @@ namespace Nz bool GetMetatable(int index) const; unsigned int GetStackTop() const; LuaType GetTable(int index = -2) const; + LuaType GetTableRaw(int index = -2) const; inline UInt32 GetTimeLimit() const; LuaType GetType(int index) const; const char* GetTypeName(LuaType type) const; @@ -113,6 +114,7 @@ namespace Nz bool IsValid(int index) const; long long Length(int index) const; + std::size_t LengthRaw(int index) const; void MoveTo(LuaInstance* instance, int n) const; @@ -161,6 +163,7 @@ namespace Nz void SetMetatable(int index) const; void SetMemoryLimit(std::size_t memoryLimit); void SetTable(int index = -3) const; + void SetTableRaw(int index = -3) const; void SetTimeLimit(UInt32 timeLimit); bool ToBoolean(int index) const; diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 380e7c48f..1c8f25567 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -503,6 +503,11 @@ namespace Nz return FromLuaType(lua_gettable(m_state, index)); } + LuaType LuaInstance::GetTableRaw(int index) const + { + return FromLuaType(lua_rawget(m_state, index)); + } + LuaType LuaInstance::GetType(int index) const { return FromLuaType(lua_type(m_state, index)); @@ -586,6 +591,11 @@ namespace Nz return luaL_len(m_state, index); } + std::size_t LuaInstance::LengthRaw(int index) const + { + return lua_rawlen(m_state, index); + } + void LuaInstance::MoveTo(LuaInstance* instance, int n) const { lua_xmove(m_state, instance->m_state, n); @@ -750,6 +760,11 @@ namespace Nz lua_settable(m_state, index); } + void LuaInstance::SetTableRaw(int index) const + { + lua_rawset(m_state, index); + } + void LuaInstance::SetTimeLimit(UInt32 timeLimit) { if (m_timeLimit != timeLimit) From bc4a533b96f9716c89de07230c2fbbc0b46b321d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 29 May 2017 19:55:02 +0200 Subject: [PATCH 209/243] Core/ParameterList: Use double and long long instead of float and int --- include/Nazara/Core/Enums.hpp | 2 +- include/Nazara/Core/ParameterList.hpp | 12 ++-- src/Nazara/Core/ParameterList.cpp | 73 ++++++++++++------------ src/Nazara/Utility/Formats/OBJLoader.cpp | 6 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 8 +-- tests/Engine/Core/ParameterList.cpp | 8 +-- 6 files changed, 53 insertions(+), 56 deletions(-) diff --git a/include/Nazara/Core/Enums.hpp b/include/Nazara/Core/Enums.hpp index 5a6e67565..2bacb1f2d 100644 --- a/include/Nazara/Core/Enums.hpp +++ b/include/Nazara/Core/Enums.hpp @@ -105,7 +105,7 @@ namespace Nz { ParameterType_Boolean, ParameterType_Color, - ParameterType_Float, + ParameterType_Double, ParameterType_Integer, ParameterType_None, ParameterType_Pointer, diff --git a/include/Nazara/Core/ParameterList.hpp b/include/Nazara/Core/ParameterList.hpp index 3e9d3a825..d6b3985b4 100644 --- a/include/Nazara/Core/ParameterList.hpp +++ b/include/Nazara/Core/ParameterList.hpp @@ -32,8 +32,8 @@ namespace Nz bool GetBooleanParameter(const String& name, bool* value) const; bool GetColorParameter(const String& name, Color* value) const; - bool GetFloatParameter(const String& name, float* value) const; - bool GetIntegerParameter(const String& name, int* value) const; + bool GetDoubleParameter(const String& name, double* value) const; + bool GetIntegerParameter(const String& name, long long* value) const; bool GetParameterType(const String& name, ParameterType* type) const; bool GetPointerParameter(const String& name, void** value) const; bool GetStringParameter(const String& name, String* value) const; @@ -48,8 +48,8 @@ namespace Nz void SetParameter(const String& name, const String& value); void SetParameter(const String& name, const char* value); void SetParameter(const String& name, bool value); - void SetParameter(const String& name, float value); - void SetParameter(const String& name, int value); + void SetParameter(const String& name, double value); + void SetParameter(const String& name, long long value); void SetParameter(const String& name, void* value); void SetParameter(const String& name, void* value, Destructor destructor); @@ -84,8 +84,8 @@ namespace Nz ~Value() {} bool boolVal; - float floatVal; - int intVal; + double doubleVal; + long long intVal; void* ptrVal; Color colorVal; String stringVal; diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 5206dd333..89fdb4591 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -95,7 +95,7 @@ namespace Nz } case ParameterType_Color: - case ParameterType_Float: + case ParameterType_Double: case ParameterType_None: case ParameterType_Pointer: case ParameterType_Userdata: @@ -137,9 +137,9 @@ namespace Nz return true; case ParameterType_Boolean: + case ParameterType_Double: case ParameterType_Integer: case ParameterType_String: - case ParameterType_Float: case ParameterType_None: case ParameterType_Pointer: case ParameterType_Userdata: @@ -151,19 +151,19 @@ namespace Nz } /*! - * \brief Gets a parameter as a float - * \return true if the parameter could be represented as a float + * \brief Gets a parameter as a double + * \return true if the parameter could be represented as a double * * \param name Name of the parameter - * \param value Pointer to a float to hold the retrieved value + * \param value Pointer to a double to hold the retrieved value * * \remark value must be a valid pointer * \remark In case of failure, the variable pointed by value keep its value - * \remark If the parameter is not a float, a conversion will be performed, compatibles types are: - Integer: The integer value is converted to its float representation + * \remark If the parameter is not a double, a conversion will be performed, compatibles types are: + Integer: The integer value is converted to its double representation String: Conversion obeys the rule as described by String::ToDouble */ - bool ParameterList::GetFloatParameter(const String& name, float* value) const + bool ParameterList::GetDoubleParameter(const String& name, double* value) const { NazaraAssert(value, "Invalid pointer"); @@ -178,12 +178,12 @@ namespace Nz switch (it->second.type) { - case ParameterType_Float: - *value = it->second.value.floatVal; + case ParameterType_Double: + *value = it->second.value.doubleVal; return true; case ParameterType_Integer: - *value = static_cast(it->second.value.intVal); + *value = static_cast(it->second.value.intVal); return true; case ParameterType_String: @@ -191,7 +191,7 @@ namespace Nz double converted; if (it->second.value.stringVal.ToDouble(&converted)) { - *value = static_cast(converted); + *value = converted; return true; } @@ -206,7 +206,7 @@ namespace Nz break; } - NazaraError("Parameter value is not representable as a float"); + NazaraError("Parameter value is not representable as a double"); return false; } @@ -219,12 +219,12 @@ namespace Nz * * \remark value must be a valid pointer * \remark In case of failure, the variable pointed by value keep its value - * \remark If the parameter is not a float, a conversion will be performed, compatibles types are: + * \remark If the parameter is not an integer, a conversion will be performed, compatibles types are: Boolean: The boolean is represented as 1 if true and 0 if false - Float: The floating-point value is truncated and converted to a integer - String: Conversion obeys the rule as described by String::ToInteger but fails if the value could not be represented as a int + Double: The floating-point value is truncated and converted to a integer + String: Conversion obeys the rule as described by String::ToInteger */ - bool ParameterList::GetIntegerParameter(const String& name, int* value) const + bool ParameterList::GetIntegerParameter(const String& name, long long* value) const { NazaraAssert(value, "Invalid pointer"); @@ -243,8 +243,8 @@ namespace Nz *value = (it->second.value.boolVal) ? 1 : 0; return true; - case ParameterType_Float: - *value = static_cast(it->second.value.floatVal); + case ParameterType_Double: + *value = static_cast(it->second.value.doubleVal); return true; case ParameterType_Integer: @@ -256,11 +256,8 @@ namespace Nz long long converted; if (it->second.value.stringVal.ToInteger(&converted)) { - if (converted <= std::numeric_limits::max() && converted >= std::numeric_limits::min()) - { - *value = static_cast(converted); - return true; - } + *value = converted; + return true; } break; } @@ -335,7 +332,7 @@ namespace Nz case ParameterType_Boolean: case ParameterType_Color: - case ParameterType_Float: + case ParameterType_Double: case ParameterType_Integer: case ParameterType_None: case ParameterType_String: @@ -358,7 +355,7 @@ namespace Nz * \remark If the parameter is not a string, a conversion will be performed, all types are compatibles: Boolean: Conversion obeys the rules of String::Boolean Color: Conversion obeys the rules of Color::ToString - Float: Conversion obeys the rules of String::Number + Double: Conversion obeys the rules of String::Number Integer: Conversion obeys the rules of String::Number None: An empty string is returned Pointer: Conversion obeys the rules of String::Pointer @@ -387,8 +384,8 @@ namespace Nz *value = it->second.value.colorVal.ToString(); return true; - case ParameterType_Float: - *value = String::Number(it->second.value.floatVal); + case ParameterType_Double: + *value = String::Number(it->second.value.doubleVal); return true; case ParameterType_Integer: @@ -560,18 +557,18 @@ namespace Nz } /*! - * \brief Sets a float parameter named `name` + * \brief Sets a double parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter - * \param value The float value + * \param value The double value */ - void ParameterList::SetParameter(const String& name, float value) + void ParameterList::SetParameter(const String& name, double value) { Parameter& parameter = CreateValue(name); - parameter.type = ParameterType_Float; - parameter.value.floatVal = value; + parameter.type = ParameterType_Double; + parameter.value.doubleVal = value; } /*! @@ -582,7 +579,7 @@ namespace Nz * \param name Name of the parameter * \param value The integer value */ - void ParameterList::SetParameter(const String& name, int value) + void ParameterList::SetParameter(const String& name, long long value) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_Integer; @@ -627,8 +624,8 @@ namespace Nz case ParameterType_Color: ss << "Color(" << it->second.value.colorVal.ToString() << ")"; break; - case ParameterType_Float: - ss << "Float(" << it->second.value.floatVal << ")"; + case ParameterType_Double: + ss << "Double(" << it->second.value.doubleVal << ")"; break; case ParameterType_Integer: ss << "Integer(" << it->second.value.intVal << ")"; @@ -692,7 +689,7 @@ namespace Nz { case ParameterType_Boolean: case ParameterType_Color: - case ParameterType_Float: + case ParameterType_Double: case ParameterType_Integer: case ParameterType_Pointer: std::memcpy(¶meter, &it->second, sizeof(Parameter)); @@ -764,7 +761,7 @@ namespace Nz case ParameterType_Boolean: case ParameterType_Color: - case ParameterType_Float: + case ParameterType_Double: case ParameterType_Integer: case ParameterType_None: case ParameterType_Pointer: diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 563300aaf..d7dd15d14 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -124,8 +124,8 @@ namespace Nz // Some default settings data.SetParameter(MaterialData::Blending, true); data.SetParameter(MaterialData::DepthWrite, true); - data.SetParameter(MaterialData::DstBlend, static_cast(BlendFunc_InvSrcAlpha)); - data.SetParameter(MaterialData::SrcBlend, static_cast(BlendFunc_SrcAlpha)); + data.SetParameter(MaterialData::DstBlend, static_cast(BlendFunc_InvSrcAlpha)); + data.SetParameter(MaterialData::SrcBlend, static_cast(BlendFunc_SrcAlpha)); } it = materialCache.emplace(matName, std::move(data)).first; @@ -139,7 +139,7 @@ namespace Nz bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) { - int reservedVertexCount; + long long reservedVertexCount; if (!parameters.custom.GetIntegerParameter("NativeOBJLoader_VertexCount", &reservedVertexCount)) reservedVertexCount = 100; diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 513f28ff7..7b3507730 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -128,7 +128,7 @@ namespace Nz else { Color colorVal; - float fValue; + double dValue; if (matData.GetColorParameter(MaterialData::AmbientColor, &colorVal)) material->ambient = colorVal; @@ -139,8 +139,8 @@ namespace Nz if (matData.GetColorParameter(MaterialData::SpecularColor, &colorVal)) material->specular = colorVal; - if (matData.GetFloatParameter(MaterialData::Shininess, &fValue)) - material->shininess = fValue; + if (matData.GetDoubleParameter(MaterialData::Shininess, &dValue)) + material->shininess = float(dValue); if (matData.GetStringParameter(MaterialData::AlphaTexturePath, &strVal)) material->alphaMap = strVal; @@ -176,7 +176,7 @@ namespace Nz UInt32 faceIndex = 0; TriangleIterator triangle(staticMesh); - do + do { OBJParser::Face& face = meshes[i].faces[faceIndex]; face.firstVertex = faceIndex * 3; diff --git a/tests/Engine/Core/ParameterList.cpp b/tests/Engine/Core/ParameterList.cpp index ef2729833..5d998f5b8 100644 --- a/tests/Engine/Core/ParameterList.cpp +++ b/tests/Engine/Core/ParameterList.cpp @@ -24,13 +24,13 @@ SCENARIO("ParameterList", "[CORE][PARAMETERLIST]") WHEN("We add Float '3.f'") { - float fl = 3.f; - parameterList.SetParameter("float", fl); + double fl = 3.f; + parameterList.SetParameter("double", fl); THEN("We can get it back") { - float newFl; - REQUIRE(parameterList.GetFloatParameter("float", &newFl)); + double newFl; + REQUIRE(parameterList.GetDoubleParameter("double", &newFl)); REQUIRE(newFl == fl); } } From 308f6d744897ef70274a73855198d17fdf5dde28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 29 May 2017 20:00:39 +0200 Subject: [PATCH 210/243] #Oops --- plugins/Assimp/Plugin.cpp | 16 ++++---- src/Nazara/Graphics/Material.cpp | 66 ++++++++++++++++---------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 8a4ec0e09..744434137 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -108,21 +108,21 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) if (parameters.optimizeIndexBuffers) postProcess |= aiProcess_ImproveCacheLocality; - float smoothingAngle = 80.f; - parameters.custom.GetFloatParameter("AssimpLoader_SmoothingAngle", &smoothingAngle); + double smoothingAngle = 80.f; + parameters.custom.GetDoubleParameter("AssimpLoader_SmoothingAngle", &smoothingAngle); - int triangleLimit = 1'000'000; + long long triangleLimit = 1'000'000; parameters.custom.GetIntegerParameter("AssimpLoader_TriangleLimit", &triangleLimit); - int vertexLimit = 1'000'000; + long long vertexLimit = 1'000'000; parameters.custom.GetIntegerParameter("AssimpLoader_VertexLimit", &vertexLimit); aiPropertyStore* properties = aiCreatePropertyStore(); - aiSetImportPropertyFloat(properties, AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, smoothingAngle); + aiSetImportPropertyFloat(properties, AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, float(smoothingAngle)); aiSetImportPropertyInteger(properties, AI_CONFIG_PP_LBW_MAX_WEIGHTS, 4); aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SBP_REMOVE, ~aiPrimitiveType_TRIANGLE); //< We only want triangles - aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, triangleLimit); - aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SLM_VERTEX_LIMIT, vertexLimit); + aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, int(triangleLimit)); + aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SLM_VERTEX_LIMIT, int(vertexLimit)); aiSetImportPropertyInteger(properties, AI_CONFIG_PP_RVC_FLAGS, aiComponent_COLORS); const aiScene* scene = aiImportFileExWithProperties(userdata.originalFilePath, postProcess, &fileIO, properties); @@ -276,7 +276,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) break; } - matData.SetParameter(wrapKey, static_cast(wrap)); + matData.SetParameter(wrapKey, static_cast(wrap)); } } }; diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index df871f9f2..0e865038a 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -114,14 +114,14 @@ namespace Nz { Color color; bool isEnabled; - float fValue; - int iValue; + double dValue; + long long iValue; String path; ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled, true); - if (matData.GetFloatParameter(MaterialData::AlphaThreshold, &fValue)) - SetAlphaThreshold(fValue); + if (matData.GetDoubleParameter(MaterialData::AlphaThreshold, &dValue)) + SetAlphaThreshold(float(dValue)); if (matData.GetBooleanParameter(MaterialData::AlphaTest, &isEnabled)) EnableAlphaTest(isEnabled); @@ -147,17 +147,17 @@ namespace Nz if (matData.GetIntegerParameter(MaterialData::FaceFilling, &iValue)) SetFaceFilling(static_cast(iValue)); - if (matData.GetFloatParameter(MaterialData::LineWidth, &fValue)) - SetLineWidth(fValue); + if (matData.GetDoubleParameter(MaterialData::LineWidth, &dValue)) + SetLineWidth(float(dValue)); - if (matData.GetFloatParameter(MaterialData::PointSize, &fValue)) - SetPointSize(fValue); + if (matData.GetDoubleParameter(MaterialData::PointSize, &dValue)) + SetPointSize(float(dValue)); if (matData.GetColorParameter(MaterialData::SpecularColor, &color)) SetSpecularColor(color); - if (matData.GetFloatParameter(MaterialData::Shininess, &fValue)) - SetShininess(fValue); + if (matData.GetDoubleParameter(MaterialData::Shininess, &dValue)) + SetShininess(float(dValue)); if (matData.GetIntegerParameter(MaterialData::SrcBlend, &iValue)) SetSrcBlend(static_cast(iValue)); @@ -277,17 +277,17 @@ namespace Nz matData->SetParameter(MaterialData::AlphaTest, IsAlphaTestEnabled()); matData->SetParameter(MaterialData::AlphaThreshold, GetAlphaThreshold()); matData->SetParameter(MaterialData::AmbientColor, GetAmbientColor()); - matData->SetParameter(MaterialData::CullingSide, int(GetFaceCulling())); - matData->SetParameter(MaterialData::DepthFunc, int(GetDepthFunc())); + matData->SetParameter(MaterialData::CullingSide, static_cast(GetFaceCulling())); + matData->SetParameter(MaterialData::DepthFunc, static_cast(GetDepthFunc())); matData->SetParameter(MaterialData::DepthSorting, IsDepthSortingEnabled()); matData->SetParameter(MaterialData::DiffuseColor, GetDiffuseColor()); - matData->SetParameter(MaterialData::DstBlend, int(GetDstBlend())); - matData->SetParameter(MaterialData::FaceFilling, int(GetFaceFilling())); + matData->SetParameter(MaterialData::DstBlend, static_cast(GetDstBlend())); + matData->SetParameter(MaterialData::FaceFilling, static_cast(GetFaceFilling())); matData->SetParameter(MaterialData::LineWidth, GetLineWidth()); matData->SetParameter(MaterialData::PointSize, GetPointSize()); matData->SetParameter(MaterialData::Shininess, GetShininess()); matData->SetParameter(MaterialData::SpecularColor, GetSpecularColor()); - matData->SetParameter(MaterialData::SrcBlend, int(GetSrcBlend())); + matData->SetParameter(MaterialData::SrcBlend, static_cast(GetSrcBlend())); // RendererParameter matData->SetParameter(MaterialData::Blending, IsBlendingEnabled()); @@ -299,29 +299,29 @@ namespace Nz matData->SetParameter(MaterialData::StencilTest, IsStencilTestEnabled()); // Samplers - matData->SetParameter(MaterialData::DiffuseAnisotropyLevel, int(GetDiffuseSampler().GetAnisotropicLevel())); - matData->SetParameter(MaterialData::DiffuseFilter, int(GetDiffuseSampler().GetFilterMode())); - matData->SetParameter(MaterialData::DiffuseWrap, int(GetDiffuseSampler().GetWrapMode())); + matData->SetParameter(MaterialData::DiffuseAnisotropyLevel, static_cast(GetDiffuseSampler().GetAnisotropicLevel())); + matData->SetParameter(MaterialData::DiffuseFilter, static_cast(GetDiffuseSampler().GetFilterMode())); + matData->SetParameter(MaterialData::DiffuseWrap, static_cast(GetDiffuseSampler().GetWrapMode())); - matData->SetParameter(MaterialData::SpecularAnisotropyLevel, int(GetSpecularSampler().GetAnisotropicLevel())); - matData->SetParameter(MaterialData::SpecularFilter, int(GetSpecularSampler().GetFilterMode())); - matData->SetParameter(MaterialData::SpecularWrap, int(GetSpecularSampler().GetWrapMode())); + matData->SetParameter(MaterialData::SpecularAnisotropyLevel, static_cast(GetSpecularSampler().GetAnisotropicLevel())); + matData->SetParameter(MaterialData::SpecularFilter, static_cast(GetSpecularSampler().GetFilterMode())); + matData->SetParameter(MaterialData::SpecularWrap, static_cast(GetSpecularSampler().GetWrapMode())); // Stencil - matData->SetParameter(MaterialData::StencilCompare, int(GetPipelineInfo().stencilCompare.front)); - matData->SetParameter(MaterialData::StencilFail, int(GetPipelineInfo().stencilFail.front)); - matData->SetParameter(MaterialData::StencilPass, int(GetPipelineInfo().stencilPass.front)); - matData->SetParameter(MaterialData::StencilZFail, int(GetPipelineInfo().stencilDepthFail.front)); - matData->SetParameter(MaterialData::StencilMask, int(GetPipelineInfo().stencilWriteMask.front)); - matData->SetParameter(MaterialData::StencilReference, int(GetPipelineInfo().stencilReference.front)); + matData->SetParameter(MaterialData::StencilCompare, static_cast(GetPipelineInfo().stencilCompare.front)); + matData->SetParameter(MaterialData::StencilFail, static_cast(GetPipelineInfo().stencilFail.front)); + matData->SetParameter(MaterialData::StencilPass, static_cast(GetPipelineInfo().stencilPass.front)); + matData->SetParameter(MaterialData::StencilZFail, static_cast(GetPipelineInfo().stencilDepthFail.front)); + matData->SetParameter(MaterialData::StencilMask, static_cast(GetPipelineInfo().stencilWriteMask.front)); + matData->SetParameter(MaterialData::StencilReference, static_cast(GetPipelineInfo().stencilReference.front)); // Stencil (back) - matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetPipelineInfo().stencilCompare.back)); - matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetPipelineInfo().stencilFail.back)); - matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetPipelineInfo().stencilPass.back)); - matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetPipelineInfo().stencilDepthFail.back)); - matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetPipelineInfo().stencilWriteMask.back)); - matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetPipelineInfo().stencilReference.back)); + matData->SetParameter(MaterialData::BackFaceStencilCompare, static_cast(GetPipelineInfo().stencilCompare.back)); + matData->SetParameter(MaterialData::BackFaceStencilFail, static_cast(GetPipelineInfo().stencilFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilPass, static_cast(GetPipelineInfo().stencilPass.back)); + matData->SetParameter(MaterialData::BackFaceStencilZFail, static_cast(GetPipelineInfo().stencilDepthFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilMask, static_cast(GetPipelineInfo().stencilWriteMask.back)); + matData->SetParameter(MaterialData::BackFaceStencilReference, static_cast(GetPipelineInfo().stencilReference.back)); // Textures if (HasAlphaMap()) From 3b914422c825aed2b71d01f201866b8bd2f25ddf Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 30 May 2017 00:50:28 +0200 Subject: [PATCH 211/243] SDK/EntityList: Fix warning on GCC --- SDK/include/NDK/EntityList.hpp | 4 ++-- SDK/include/NDK/EntityList.inl | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SDK/include/NDK/EntityList.hpp b/SDK/include/NDK/EntityList.hpp index b659b15fb..8303f7fa4 100644 --- a/SDK/include/NDK/EntityList.hpp +++ b/SDK/include/NDK/EntityList.hpp @@ -59,11 +59,11 @@ namespace Ndk friend EntityList; public: - inline iterator(const iterator& iterator); + inline iterator(const iterator& it); const EntityHandle& operator*() const; - inline iterator& operator=(const iterator& iterator); + inline iterator& operator=(const iterator& it); inline iterator& operator++(); inline iterator operator++(int); diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index d178d2b09..8d871e2c6 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -207,16 +207,16 @@ namespace Ndk { } - inline EntityList::iterator::iterator(const iterator& iterator) : - m_nextEntityId(iterator.m_nextEntityId), - m_list(iterator.m_list) + inline EntityList::iterator::iterator(const iterator& it) : + m_nextEntityId(it.m_nextEntityId), + m_list(it.m_list) { } - inline EntityList::iterator& EntityList::iterator::operator=(const iterator& iterator) + inline EntityList::iterator& EntityList::iterator::operator=(const iterator& it) { - m_nextEntityId = iterator.m_nextEntityId; - m_list = iterator.m_list; + m_nextEntityId = it.m_nextEntityId; + m_list = it.m_list; return *this; } From 4f1d52b395566cbbe718274ce1342b4097b1af17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 1 Jun 2017 17:24:28 +0200 Subject: [PATCH 212/243] Fix [Box|Rect]::Contains including outer border points --- include/Nazara/Math/Box.inl | 6 +++--- include/Nazara/Math/Rect.inl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 1b5276ee6..60275b206 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -133,9 +133,9 @@ namespace Nz template bool Box::Contains(T X, T Y, T Z) const { - return X >= x && X <= x + width && - Y >= y && Y <= y + height && - Z >= z && Z <= z + depth; + return X >= x && X < x + width && + Y >= y && Y < y + height && + Z >= z && Z < z + depth; } /*! diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 47a837cbd..f5d96c249 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -117,8 +117,8 @@ namespace Nz template bool Rect::Contains(T X, T Y) const { - return X >= x && X <= (x + width) && - Y >= y && Y <= (y + height); + return X >= x && X < (x + width) && + Y >= y && Y < (y + height); } /*! From 8752d1e0f40e8710b0f406dc5ae4159cc52db6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 1 Jun 2017 17:25:21 +0200 Subject: [PATCH 213/243] Network: Add ErrorToString for ResolveError/SocketError --- include/Nazara/Network/Algorithm.hpp | 4 + src/Nazara/Network/AlgorithmNetwork.cpp | 110 +++++++++++++++++++++++- 2 files changed, 110 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Network/Algorithm.hpp b/include/Nazara/Network/Algorithm.hpp index 001d98059..1befe974e 100644 --- a/include/Nazara/Network/Algorithm.hpp +++ b/include/Nazara/Network/Algorithm.hpp @@ -9,11 +9,15 @@ #include #include +#include #include #include namespace Nz { + NAZARA_NETWORK_API const char* ErrorToString(Nz::ResolveError resolveError); + NAZARA_NETWORK_API const char* ErrorToString(Nz::SocketError socketError); + NAZARA_NETWORK_API bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port = nullptr, bool* isIPv6 = nullptr, const char** endOfRead = nullptr); } diff --git a/src/Nazara/Network/AlgorithmNetwork.cpp b/src/Nazara/Network/AlgorithmNetwork.cpp index 4538230f3..9a593db39 100644 --- a/src/Nazara/Network/AlgorithmNetwork.cpp +++ b/src/Nazara/Network/AlgorithmNetwork.cpp @@ -19,7 +19,6 @@ namespace Nz * \param number Optional argument to return the number parsed * \param endOfRead Optional argument to determine where parsing stopped */ - bool ParseDecimal(const char* str, unsigned int* number, const char** endOfRead) { const char* ptr = str; @@ -52,7 +51,6 @@ namespace Nz * \param number Optional argument to return the number parsed * \param endOfRead Optional argument to determine where parsing stopped */ - bool ParseHexadecimal(const char* str, unsigned int* number, const char** endOfRead) { const char* ptr = str; @@ -78,8 +76,113 @@ namespace Nz } } + /*! - * \ingroup network + * \ingroup network + * \brief Returns the text representation of an error + * \return Text representation of an error + * + * \param resolveError Error enumeration + */ + const char* ErrorToString(Nz::ResolveError resolveError) + { + switch (resolveError) + { + case Nz::ResolveError_NoError: + return "No error"; + + case Nz::ResolveError_Internal: + return "An internal error occurred"; + + case Nz::ResolveError_ResourceError: + return "The operating system lacks the resources to proceed"; + + case Nz::ResolveError_NonRecoverable: + return "A nonrecoverable error occurred"; + + case Nz::ResolveError_NotFound: + return "No such host is known"; + + case Nz::ResolveError_NotInitialized: + return "Nazara Network has not been initialized"; + + case Nz::ResolveError_ProtocolNotSupported: + return "A specified protocol is not supported by the server"; + + case Nz::ResolveError_TemporaryFailure: + return "A temporary failure occurred, try again"; + + case Nz::ResolveError_Unknown: + return "An unknown error occurred"; + + default: + return "Invalid error value"; + } + } + + /*! + * \ingroup network + * \brief Returns the text representation of an error + * \return Text representation of an error + * + * \param socketError Error enumeration + */ + const char* ErrorToString(Nz::SocketError socketError) + { + switch (socketError) + { + case Nz::SocketError_NoError: + return "No error"; + + case Nz::SocketError_AddressNotAvailable: + return "The address is already in use"; + + case Nz::SocketError_ConnectionClosed: + return "The connection has been closed"; + + case Nz::SocketError_ConnectionRefused: + return "The connection attempt was refused"; + + case Nz::SocketError_DatagramSize: + return "The datagram size is over the system limit"; + + case Nz::SocketError_Internal: + return "An internal error occurred"; + + case Nz::SocketError_Packet: + return "Packet encoding or decoding failed"; + + case Nz::SocketError_NetworkError: + return "Networking subsystem failed"; + + case Nz::SocketError_NotInitialized: + return "Network module has not been initialized"; + + case Nz::SocketError_NotSupported: + return "This operation is not supported"; + + case Nz::SocketError_ResolveError: + return "The hostname couldn't be resolved"; + + case Nz::SocketError_ResourceError: + return "The operating system lacks the resources to proceed"; + + case Nz::SocketError_TimedOut: + return "The operation timed out"; + + case Nz::SocketError_Unknown: + return "An unknown error occurred"; + + case Nz::SocketError_UnreachableHost: + return "The host is not reachable"; + + default: + return "Invalid error value"; + } + } + + /*! + * \ingroup network * \brief Parse a textual IPv4 or IPv6 address * \return true If successful * @@ -97,7 +200,6 @@ namespace Nz * \remark Produces a NazaraAssert if addressPtr is invalid * \remark Produces a NazaraAssert if result is invalid */ - bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port, bool* isIPv6, const char** endOfRead) { NazaraAssert(addressPtr, "Invalid address string"); From e32c1a8b8b34408328a210263ada489f6b8dbbc1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Jun 2017 17:28:58 +0200 Subject: [PATCH 214/243] Utility/PixelFormat: Move Flip to .cpp Because of std::swap_range usage (Thanks Microsoft) --- include/Nazara/Utility/PixelFormat.hpp | 2 +- include/Nazara/Utility/PixelFormat.inl | 96 -------------------------- src/Nazara/Utility/PixelFormat.cpp | 96 ++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 97 deletions(-) diff --git a/include/Nazara/Utility/PixelFormat.hpp b/include/Nazara/Utility/PixelFormat.hpp index 8731ad29f..f6c3a36a4 100644 --- a/include/Nazara/Utility/PixelFormat.hpp +++ b/include/Nazara/Utility/PixelFormat.hpp @@ -65,7 +65,7 @@ namespace Nz static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst); static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst); - static inline bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst); + static bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst); static inline UInt8 GetBitsPerPixel(PixelFormatType format); static inline PixelFormatContent GetContent(PixelFormatType format); diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index b4dfd95ee..4fe75c8b5 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -227,102 +227,6 @@ namespace Nz return true; } - inline bool PixelFormat::Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst) - { - #if NAZARA_UTILITY_SAFE - if (!IsValid(format)) - { - NazaraError("Invalid pixel format"); - return false; - } - #endif - - auto it = s_flipFunctions[flipping].find(format); - if (it != s_flipFunctions[flipping].end()) - it->second(width, height, depth, reinterpret_cast(src), reinterpret_cast(dst)); - else - { - // Flipping générique - - #if NAZARA_UTILITY_SAFE - if (IsCompressed(format)) - { - NazaraError("No function to flip compressed format"); - return false; - } - #endif - - UInt8 bpp = GetBytesPerPixel(format); - unsigned int lineStride = width*bpp; - switch (flipping) - { - case PixelFlipping_Horizontally: - { - if (src == dst) - { - for (unsigned int z = 0; z < depth; ++z) - { - UInt8* ptr = reinterpret_cast(dst) + width*height*z; - for (unsigned int y = 0; y < height/2; ++y) - std::swap_ranges(&ptr[y*lineStride], &ptr[(y+1)*lineStride-1], &ptr[(height-y-1)*lineStride]); - } - } - else - { - for (unsigned int z = 0; z < depth; ++z) - { - const UInt8* srcPtr = reinterpret_cast(src); - UInt8* dstPtr = reinterpret_cast(dst) + (width-1)*height*depth*bpp; - for (unsigned int y = 0; y < height; ++y) - { - std::memcpy(dstPtr, srcPtr, lineStride); - - srcPtr += lineStride; - dstPtr -= lineStride; - } - } - } - break; - } - - case PixelFlipping_Vertically: - { - if (src == dst) - { - for (unsigned int z = 0; z < depth; ++z) - { - UInt8* ptr = reinterpret_cast(dst) + width*height*z; - for (unsigned int y = 0; y < height; ++y) - { - for (unsigned int x = 0; x < width/2; ++x) - std::swap_ranges(&ptr[x*bpp], &ptr[(x+1)*bpp], &ptr[(width-x)*bpp]); - - ptr += lineStride; - } - } - } - else - { - for (unsigned int z = 0; z < depth; ++z) - { - UInt8* ptr = reinterpret_cast(dst) + width*height*z; - for (unsigned int y = 0; y < height; ++y) - { - for (unsigned int x = 0; x < width; ++x) - std::memcpy(&ptr[x*bpp], &ptr[(width-x)*bpp], bpp); - - ptr += lineStride; - } - } - } - break; - } - } - } - - return true; - } - inline UInt8 PixelFormat::GetBitsPerPixel(PixelFormatType format) { return s_pixelFormatInfos[format].bitsPerPixel; diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index 8bfe461e3..f27f6bd00 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -1268,6 +1268,102 @@ namespace Nz } } + bool PixelFormat::Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst) + { + #if NAZARA_UTILITY_SAFE + if (!IsValid(format)) + { + NazaraError("Invalid pixel format"); + return false; + } + #endif + + auto it = s_flipFunctions[flipping].find(format); + if (it != s_flipFunctions[flipping].end()) + it->second(width, height, depth, reinterpret_cast(src), reinterpret_cast(dst)); + else + { + // Flipping générique + + #if NAZARA_UTILITY_SAFE + if (IsCompressed(format)) + { + NazaraError("No function to flip compressed format"); + return false; + } + #endif + + UInt8 bpp = GetBytesPerPixel(format); + unsigned int lineStride = width*bpp; + switch (flipping) + { + case PixelFlipping_Horizontally: + { + if (src == dst) + { + for (unsigned int z = 0; z < depth; ++z) + { + UInt8* ptr = reinterpret_cast(dst) + width*height*z; + for (unsigned int y = 0; y < height / 2; ++y) + std::swap_ranges(&ptr[y*lineStride], &ptr[(y + 1)*lineStride - 1], &ptr[(height - y - 1)*lineStride]); + } + } + else + { + for (unsigned int z = 0; z < depth; ++z) + { + const UInt8* srcPtr = reinterpret_cast(src); + UInt8* dstPtr = reinterpret_cast(dst) + (width - 1)*height*depth*bpp; + for (unsigned int y = 0; y < height; ++y) + { + std::memcpy(dstPtr, srcPtr, lineStride); + + srcPtr += lineStride; + dstPtr -= lineStride; + } + } + } + break; + } + + case PixelFlipping_Vertically: + { + if (src == dst) + { + for (unsigned int z = 0; z < depth; ++z) + { + UInt8* ptr = reinterpret_cast(dst) + width*height*z; + for (unsigned int y = 0; y < height; ++y) + { + for (unsigned int x = 0; x < width / 2; ++x) + std::swap_ranges(&ptr[x*bpp], &ptr[(x + 1)*bpp], &ptr[(width - x)*bpp]); + + ptr += lineStride; + } + } + } + else + { + for (unsigned int z = 0; z < depth; ++z) + { + UInt8* ptr = reinterpret_cast(dst) + width*height*z; + for (unsigned int y = 0; y < height; ++y) + { + for (unsigned int x = 0; x < width; ++x) + std::memcpy(&ptr[x*bpp], &ptr[(width - x)*bpp], bpp); + + ptr += lineStride; + } + } + } + break; + } + } + } + + return true; + } + PixelFormatType PixelFormat::IdentifyFormat(const PixelFormatInfo& info) { for (unsigned int i = 0; i <= PixelFormatType_Max; ++i) From c98fb482e7bb54054b6cf40eddd1dffb745824ec Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 5 Jun 2017 15:06:19 +0200 Subject: [PATCH 215/243] Network/ENetPeer: Add GetRoundTripTime method --- include/Nazara/Network/ENetPeer.hpp | 1 + include/Nazara/Network/ENetPeer.inl | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index e3538e6fb..4e36378a5 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -55,6 +55,7 @@ namespace Nz inline UInt32 GetPacketThrottleDeceleration() const; inline UInt32 GetPacketThrottleInterval() const; inline UInt16 GetPeerId() const; + inline UInt32 GetRoundTripTime() const; inline ENetPeerState GetState() const; inline bool HasPendingCommands(); diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index bcec4a8c1..d831b4d0d 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -48,6 +48,11 @@ namespace Nz return m_incomingPeerID; } + inline UInt32 ENetPeer::GetRoundTripTime() const + { + return m_roundTripTime; + } + inline ENetPeerState ENetPeer::GetState() const { return m_state; From 184a970b722e16477a327a3810ea9ce01ca3891d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 6 Jun 2017 16:50:09 +0200 Subject: [PATCH 216/243] Fix all flags.. --- include/Nazara/Core/Flags.hpp | 5 +++ include/Nazara/Core/Flags.inl | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index cb336def6..5285ef601 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -54,6 +54,11 @@ namespace Nz private: BitField m_value; }; + + template constexpr std::enable_if_t::value, Flags> operator~(E lhs); + template constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs); + template constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs); + template constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs); } template constexpr std::enable_if_t::value, Nz::Flags> operator~(E lhs); diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 973da958d..3832d3b50 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -209,6 +209,68 @@ namespace Nz { return 1U << static_cast(enumValue); } + + + /*! + * \brief Override binary NOT operator on enum to turns into a Flags object. + * \return A Flags object with reversed bits. + * + * \param lhs Enumeration value to reverse. + * + * Returns a Flags object with all state enabled except for the enum one. + */ + template + constexpr std::enable_if_t::value, Flags> operator~(E lhs) + { + return ~Flags(lhs); + } + + /*! + * \brief Override binary OR operator on enum to turns into a Flags object. + * \return A Flags object with combined enum states. + * + * \param lhs First enumeration value to combine. + * \param rhs Second enumeration value to combine. + * + * Returns a Flags object with combined states from the two enumeration values. + */ + template + constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs) + { + return Flags(lhs) | rhs; + } + + /*! + * \brief Override binary AND operator on enum to turns into a Flags object. + * \return A Flags object with compare enum states. + * + * \param lhs First enumeration value to compare. + * \param rhs Second enumeration value to compare. + * + * Returns a Flags object with compared states from the two enumeration values. + * In this case, only one flag will be enabled if both enumeration values are the same. + */ + template + constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs) + { + return Flags(lhs) & rhs; + } + + /*! + * \brief Override binary XOR operator on enum to turns into a Flags object. + * \return A Flags object with XORed enum states. + * + * \param lhs First enumeration value to compare. + * \param rhs Second enumeration value to compare. + * + * Returns a Flags object with XORed states from the two enumeration values. + * In this case, two flags will be enabled if both the enumeration values are different. + */ + template + constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs) + { + return Flags(lhs) ^ rhs; + } } /*! From b7df3bd1c4acd7fc0de159159bff992c2a801092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 6 Jun 2017 18:08:36 +0200 Subject: [PATCH 217/243] Core/Flags: Try some hack to fix compilation --- include/Nazara/Core/Flags.hpp | 19 ++-- include/Nazara/Core/Flags.inl | 180 ++++++++++++---------------------- 2 files changed, 72 insertions(+), 127 deletions(-) diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index 5285ef601..293a8dfa8 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -55,16 +55,19 @@ namespace Nz BitField m_value; }; - template constexpr std::enable_if_t::value, Flags> operator~(E lhs); - template constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs); - template constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs); - template constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs); + // Little hack to have them in both Nz and global scope + namespace DetailFlagOperators + { + template constexpr std::enable_if_t::value, Flags> operator~(E lhs); + template constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs); + template constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs); + template constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs); + } + + using namespace DetailFlagOperators; } -template constexpr std::enable_if_t::value, Nz::Flags> operator~(E lhs); -template constexpr std::enable_if_t::value, Nz::Flags> operator|(E lhs, E rhs); -template constexpr std::enable_if_t::value, Nz::Flags> operator&(E lhs, E rhs); -template constexpr std::enable_if_t::value, Nz::Flags> operator^(E lhs, E rhs); +using namespace Nz::DetailFlagOperators; #include diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 3832d3b50..11cd22109 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -211,127 +211,69 @@ namespace Nz } - /*! - * \brief Override binary NOT operator on enum to turns into a Flags object. - * \return A Flags object with reversed bits. - * - * \param lhs Enumeration value to reverse. - * - * Returns a Flags object with all state enabled except for the enum one. - */ - template - constexpr std::enable_if_t::value, Flags> operator~(E lhs) + namespace DetailFlagOperators { - return ~Flags(lhs); + /*! + * \brief Override binary NOT operator on enum to turns into a Flags object. + * \return A Flags object with reversed bits. + * + * \param lhs Enumeration value to reverse. + * + * Returns a Flags object with all state enabled except for the enum one. + */ + template + constexpr std::enable_if_t::value, Flags> operator~(E lhs) + { + return ~Flags(lhs); + } + + /*! + * \brief Override binary OR operator on enum to turns into a Flags object. + * \return A Flags object with combined enum states. + * + * \param lhs First enumeration value to combine. + * \param rhs Second enumeration value to combine. + * + * Returns a Flags object with combined states from the two enumeration values. + */ + template + constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs) + { + return Flags(lhs) | rhs; + } + + /*! + * \brief Override binary AND operator on enum to turns into a Flags object. + * \return A Flags object with compare enum states. + * + * \param lhs First enumeration value to compare. + * \param rhs Second enumeration value to compare. + * + * Returns a Flags object with compared states from the two enumeration values. + * In this case, only one flag will be enabled if both enumeration values are the same. + */ + template + constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs) + { + return Flags(lhs) & rhs; + } + + /*! + * \brief Override binary XOR operator on enum to turns into a Flags object. + * \return A Flags object with XORed enum states. + * + * \param lhs First enumeration value to compare. + * \param rhs Second enumeration value to compare. + * + * Returns a Flags object with XORed states from the two enumeration values. + * In this case, two flags will be enabled if both the enumeration values are different. + */ + template + constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs) + { + return Flags(lhs) ^ rhs; + } } - - /*! - * \brief Override binary OR operator on enum to turns into a Flags object. - * \return A Flags object with combined enum states. - * - * \param lhs First enumeration value to combine. - * \param rhs Second enumeration value to combine. - * - * Returns a Flags object with combined states from the two enumeration values. - */ - template - constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs) - { - return Flags(lhs) | rhs; - } - - /*! - * \brief Override binary AND operator on enum to turns into a Flags object. - * \return A Flags object with compare enum states. - * - * \param lhs First enumeration value to compare. - * \param rhs Second enumeration value to compare. - * - * Returns a Flags object with compared states from the two enumeration values. - * In this case, only one flag will be enabled if both enumeration values are the same. - */ - template - constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs) - { - return Flags(lhs) & rhs; - } - - /*! - * \brief Override binary XOR operator on enum to turns into a Flags object. - * \return A Flags object with XORed enum states. - * - * \param lhs First enumeration value to compare. - * \param rhs Second enumeration value to compare. - * - * Returns a Flags object with XORed states from the two enumeration values. - * In this case, two flags will be enabled if both the enumeration values are different. - */ - template - constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs) - { - return Flags(lhs) ^ rhs; - } -} - -/*! -* \brief Override binary NOT operator on enum to turns into a Flags object. -* \return A Flags object with reversed bits. -* -* \param lhs Enumeration value to reverse. -* -* Returns a Flags object with all state enabled except for the enum one. -*/ -template -constexpr std::enable_if_t::value, Nz::Flags> operator~(E lhs) -{ - return ~Nz::Flags(lhs); -} - -/*! -* \brief Override binary OR operator on enum to turns into a Flags object. -* \return A Flags object with combined enum states. -* -* \param lhs First enumeration value to combine. -* \param rhs Second enumeration value to combine. -* -* Returns a Flags object with combined states from the two enumeration values. -*/ -template -constexpr std::enable_if_t::value, Nz::Flags> operator|(E lhs, E rhs) -{ - return Nz::Flags(lhs) | rhs; -} - -/*! -* \brief Override binary AND operator on enum to turns into a Flags object. -* \return A Flags object with compare enum states. -* -* \param lhs First enumeration value to compare. -* \param rhs Second enumeration value to compare. -* -* Returns a Flags object with compared states from the two enumeration values. -* In this case, only one flag will be enabled if both enumeration values are the same. -*/ -template -constexpr std::enable_if_t::value, Nz::Flags> operator&(E lhs, E rhs) -{ - return Nz::Flags(lhs) & rhs; -} - -/*! -* \brief Override binary XOR operator on enum to turns into a Flags object. -* \return A Flags object with XORed enum states. -* -* \param lhs First enumeration value to compare. -* \param rhs Second enumeration value to compare. -* -* Returns a Flags object with XORed states from the two enumeration values. -* In this case, two flags will be enabled if both the enumeration values are different. -*/ -template -constexpr std::enable_if_t::value, Nz::Flags> operator^(E lhs, E rhs) -{ - return Nz::Flags(lhs) ^ rhs; } #include From a8129b218b63474fa6b06a0f42338b32eeaee172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 7 Jun 2017 21:18:07 +0200 Subject: [PATCH 218/243] Refactor LuaInstance to prepare coroutine handling --- SDK/include/NDK/Console.hpp | 6 +- SDK/include/NDK/Lua/LuaBinding.hpp | 12 +- SDK/include/NDK/Lua/LuaBinding.inl | 4 +- SDK/include/NDK/Lua/LuaBinding_Audio.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Base.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Core.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Graphics.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Math.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Network.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Renderer.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_SDK.hpp | 2 +- SDK/include/NDK/Lua/LuaBinding_Utility.hpp | 2 +- SDK/include/NDK/LuaAPI.hpp | 4 +- SDK/include/NDK/LuaAPI.inl | 402 ++++----- SDK/src/NDK/Application.cpp | 16 +- SDK/src/NDK/Console.cpp | 8 +- SDK/src/NDK/Lua/LuaBinding.cpp | 26 +- SDK/src/NDK/Lua/LuaBinding_Audio.cpp | 22 +- SDK/src/NDK/Lua/LuaBinding_Core.cpp | 108 +-- SDK/src/NDK/Lua/LuaBinding_Graphics.cpp | 40 +- SDK/src/NDK/Lua/LuaBinding_Math.cpp | 84 +- SDK/src/NDK/Lua/LuaBinding_Network.cpp | 184 ++--- SDK/src/NDK/Lua/LuaBinding_Renderer.cpp | 10 +- SDK/src/NDK/Lua/LuaBinding_SDK.cpp | 58 +- SDK/src/NDK/Lua/LuaBinding_Utility.cpp | 202 +++-- SDK/src/NDK/LuaAPI.cpp | 4 +- include/Nazara/Lua/LuaClass.hpp | 60 +- include/Nazara/Lua/LuaClass.inl | 330 ++++---- include/Nazara/Lua/LuaInstance.hpp | 180 +---- include/Nazara/Lua/LuaInstance.inl | 779 ------------------ include/Nazara/Lua/LuaState.hpp | 197 +++++ include/Nazara/Lua/LuaState.inl | 788 ++++++++++++++++++ src/Nazara/Lua/LuaInstance.cpp | 853 +------------------- src/Nazara/Lua/LuaState.cpp | 834 +++++++++++++++++++ 34 files changed, 2635 insertions(+), 2594 deletions(-) create mode 100644 include/Nazara/Lua/LuaState.hpp create mode 100644 include/Nazara/Lua/LuaState.inl create mode 100644 src/Nazara/Lua/LuaState.cpp diff --git a/SDK/include/NDK/Console.hpp b/SDK/include/NDK/Console.hpp index 5c7935a7c..9635373e0 100644 --- a/SDK/include/NDK/Console.hpp +++ b/SDK/include/NDK/Console.hpp @@ -19,7 +19,7 @@ namespace Nz { - class LuaInstance; + class LuaState; } namespace Ndk @@ -32,7 +32,7 @@ namespace Ndk class NDK_API Console : public Nz::Node, public Nz::HandledObject { public: - Console(World& world, const Nz::Vector2f& size, Nz::LuaInstance& instance); + Console(World& world, const Nz::Vector2f& size, Nz::LuaState& state); Console(const Console& console) = delete; Console(Console&& console) = default; ~Console() = default; @@ -83,7 +83,7 @@ namespace Ndk EntityOwner m_input; EntityOwner m_inputBackground; Nz::FontRef m_defaultFont; - Nz::LuaInstance& m_instance; + Nz::LuaState& m_state; Nz::SpriteRef m_historyBackgroundSprite; Nz::SpriteRef m_inputBackgroundSprite; Nz::SimpleTextDrawer m_historyDrawer; diff --git a/SDK/include/NDK/Lua/LuaBinding.hpp b/SDK/include/NDK/Lua/LuaBinding.hpp index 88b6a88ef..c1ea9206d 100644 --- a/SDK/include/NDK/Lua/LuaBinding.hpp +++ b/SDK/include/NDK/Lua/LuaBinding.hpp @@ -24,7 +24,7 @@ namespace Ndk template void BindComponent(const Nz::String& name); - void RegisterClasses(Nz::LuaInstance& instance); + void RegisterClasses(Nz::LuaState& state); std::unique_ptr core; std::unique_ptr math; @@ -40,13 +40,13 @@ namespace Ndk private: template - static int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle); + static int AddComponentOfType(Nz::LuaState& lua, EntityHandle& handle); template - static int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component); + static int PushComponentOfType(Nz::LuaState& lua, BaseComponent& component); - using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&); - using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&); + using AddComponentFunc = int(*)(Nz::LuaState&, EntityHandle&); + using GetComponentFunc = int(*)(Nz::LuaState&, BaseComponent&); struct ComponentBinding { @@ -56,7 +56,7 @@ namespace Ndk Nz::String name; }; - ComponentBinding* QueryComponentIndex(Nz::LuaInstance& lua, int argIndex = 2); + ComponentBinding* QueryComponentIndex(Nz::LuaState& lua, int argIndex = 2); std::vector m_componentBinding; std::unordered_map m_componentBindingByName; diff --git a/SDK/include/NDK/Lua/LuaBinding.inl b/SDK/include/NDK/Lua/LuaBinding.inl index c9f3f86bb..502f179ae 100644 --- a/SDK/include/NDK/Lua/LuaBinding.inl +++ b/SDK/include/NDK/Lua/LuaBinding.inl @@ -33,7 +33,7 @@ namespace Ndk } template - int LuaBinding::AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle) + int LuaBinding::AddComponentOfType(Nz::LuaState& lua, EntityHandle& handle) { static_assert(std::is_base_of::value, "ComponentType must inherit BaseComponent"); @@ -43,7 +43,7 @@ namespace Ndk } template - int LuaBinding::PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component) + int LuaBinding::PushComponentOfType(Nz::LuaState& lua, BaseComponent& component) { static_assert(std::is_base_of::value, "ComponentType must inherit BaseComponent"); diff --git a/SDK/include/NDK/Lua/LuaBinding_Audio.hpp b/SDK/include/NDK/Lua/LuaBinding_Audio.hpp index 1764fb729..d842ecc9b 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Audio.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Audio.hpp @@ -21,7 +21,7 @@ namespace Ndk LuaBinding_Audio(LuaBinding& binding); ~LuaBinding_Audio() = default; - void Register(Nz::LuaInstance& instance) override; + void Register(Nz::LuaState& state) override; Nz::LuaClass music; Nz::LuaClass sound; diff --git a/SDK/include/NDK/Lua/LuaBinding_Base.hpp b/SDK/include/NDK/Lua/LuaBinding_Base.hpp index 36c41af8c..8e596e999 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Base.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Base.hpp @@ -30,7 +30,7 @@ namespace Ndk LuaBinding_Base(LuaBinding& binding); virtual ~LuaBinding_Base(); - virtual void Register(Nz::LuaInstance& instance) = 0; + virtual void Register(Nz::LuaState& state) = 0; // Implementation lies in the respective .cpp files (still searching for a cleaner way..) static std::unique_ptr BindCore(LuaBinding& binding); diff --git a/SDK/include/NDK/Lua/LuaBinding_Core.hpp b/SDK/include/NDK/Lua/LuaBinding_Core.hpp index 97d31cde4..decca39fc 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Core.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Core.hpp @@ -21,7 +21,7 @@ namespace Ndk LuaBinding_Core(LuaBinding& binding); ~LuaBinding_Core() = default; - void Register(Nz::LuaInstance& instance) override; + void Register(Nz::LuaState& state) override; Nz::LuaClass clock; Nz::LuaClass directory; diff --git a/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp b/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp index 0bfece994..cd71f0fc5 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp @@ -22,7 +22,7 @@ namespace Ndk LuaBinding_Graphics(LuaBinding& binding); ~LuaBinding_Graphics() = default; - void Register(Nz::LuaInstance& instance) override; + void Register(Nz::LuaState& state) override; Nz::LuaClass abstractViewer; Nz::LuaClass instancedRenderable; diff --git a/SDK/include/NDK/Lua/LuaBinding_Math.hpp b/SDK/include/NDK/Lua/LuaBinding_Math.hpp index d94f357c3..386912bab 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Math.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Math.hpp @@ -23,7 +23,7 @@ namespace Ndk LuaBinding_Math(LuaBinding& binding); ~LuaBinding_Math() = default; - void Register(Nz::LuaInstance& instance) override; + void Register(Nz::LuaState& state) override; Nz::LuaClass eulerAngles; Nz::LuaClass matrix4d; diff --git a/SDK/include/NDK/Lua/LuaBinding_Network.hpp b/SDK/include/NDK/Lua/LuaBinding_Network.hpp index 3774cb5e8..daee2b224 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Network.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Network.hpp @@ -20,7 +20,7 @@ namespace Ndk LuaBinding_Network(LuaBinding& binding); ~LuaBinding_Network() = default; - void Register(Nz::LuaInstance& instance) override; + void Register(Nz::LuaState& state) override; Nz::LuaClass abstractSocket; Nz::LuaClass ipAddress; diff --git a/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp b/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp index a2db03f8d..af1ffeaa5 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp @@ -18,7 +18,7 @@ namespace Ndk LuaBinding_Renderer(LuaBinding& binding); ~LuaBinding_Renderer() = default; - void Register(Nz::LuaInstance& instance) override; + void Register(Nz::LuaState& state) override; Nz::LuaClass texture; Nz::LuaClass textureLibrary; diff --git a/SDK/include/NDK/Lua/LuaBinding_SDK.hpp b/SDK/include/NDK/Lua/LuaBinding_SDK.hpp index b6b7079eb..8a6a0915e 100644 --- a/SDK/include/NDK/Lua/LuaBinding_SDK.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_SDK.hpp @@ -22,7 +22,7 @@ namespace Ndk LuaBinding_SDK(LuaBinding& binding); ~LuaBinding_SDK() = default; - void Register(Nz::LuaInstance& instance) override; + void Register(Nz::LuaState& state) override; Nz::LuaClass application; Nz::LuaClass entity; diff --git a/SDK/include/NDK/Lua/LuaBinding_Utility.hpp b/SDK/include/NDK/Lua/LuaBinding_Utility.hpp index b10492efc..8aefd20c6 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Utility.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Utility.hpp @@ -21,7 +21,7 @@ namespace Ndk LuaBinding_Utility(LuaBinding& binding); ~LuaBinding_Utility() = default; - void Register(Nz::LuaInstance& instance) override; + void Register(Nz::LuaState& state) override; // Utility Nz::LuaClass abstractImage; diff --git a/SDK/include/NDK/LuaAPI.hpp b/SDK/include/NDK/LuaAPI.hpp index 3ed73d9d2..d3e755fc6 100644 --- a/SDK/include/NDK/LuaAPI.hpp +++ b/SDK/include/NDK/LuaAPI.hpp @@ -11,7 +11,7 @@ namespace Nz { - class LuaInstance; + class LuaState; } namespace Ndk @@ -28,7 +28,7 @@ namespace Ndk static bool Initialize(); - static void RegisterClasses(Nz::LuaInstance& instance); + static void RegisterClasses(Nz::LuaState& state); static void Uninitialize(); diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index 4cc0e4342..84e3fb34e 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include @@ -28,103 +28,103 @@ namespace Nz { - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Color* color, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Color* color, TypeTag) { - instance.CheckType(index, Nz::LuaType_Table); + state.CheckType(index, Nz::LuaType_Table); - color->r = instance.CheckField("r", index); - color->g = instance.CheckField("g", index); - color->b = instance.CheckField("b", index); - color->a = instance.CheckField("a", 255, index); + color->r = state.CheckField("r", index); + color->g = state.CheckField("g", index); + color->b = state.CheckField("b", index); + color->a = state.CheckField("a", 255, index); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesd* angles, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, EulerAnglesd* angles, TypeTag) { - switch (instance.GetType(index)) + switch (state.GetType(index)) { case Nz::LuaType_Table: - angles->Set(instance.CheckField("pitch", index), instance.CheckField("yaw", index), instance.CheckField("roll", index)); + angles->Set(state.CheckField("pitch", index), state.CheckField("yaw", index), state.CheckField("roll", index)); return 1; default: { - if (instance.IsOfType(index, "EulerAngles")) - angles->Set(*static_cast(instance.ToUserdata(index))); + if (state.IsOfType(index, "EulerAngles")) + angles->Set(*static_cast(state.ToUserdata(index))); else - angles->Set(*static_cast(instance.CheckUserdata(index, "Quaternion"))); + angles->Set(*static_cast(state.CheckUserdata(index, "Quaternion"))); return 1; } } } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesf* angles, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, EulerAnglesf* angles, TypeTag) { EulerAnglesd anglesDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &anglesDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &anglesDouble, TypeTag()); angles->Set(anglesDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontRef* fontRef, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, FontRef* fontRef, TypeTag) { - *fontRef = *static_cast(instance.CheckUserdata(index, "Font")); + *fontRef = *static_cast(state.CheckUserdata(index, "Font")); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, FontParams* params, TypeTag) { NazaraUnused(params); - instance.CheckType(index, Nz::LuaType_Table); + state.CheckType(index, Nz::LuaType_Table); // Structure is empty for now return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ImageParams* params, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, ImageParams* params, TypeTag) { - instance.CheckType(index, Nz::LuaType_Table); + state.CheckType(index, Nz::LuaType_Table); - params->levelCount = instance.CheckField("LevelCount"); - params->loadFormat = instance.CheckField("LoadFormat"); + params->levelCount = state.CheckField("LevelCount"); + params->loadFormat = state.CheckField("LoadFormat"); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, IpAddress* address, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, IpAddress* address, TypeTag) { - switch (instance.GetType(index)) + switch (state.GetType(index)) { case Nz::LuaType_String: - address->BuildFromAddress(instance.CheckString(index)); + address->BuildFromAddress(state.CheckString(index)); return 1; default: - *address = *static_cast(instance.CheckUserdata(index, "IpAddress")); + *address = *static_cast(state.CheckUserdata(index, "IpAddress")); return 1; } } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Matrix4d* mat, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Matrix4d* mat, TypeTag) { - switch (instance.GetType(index)) + switch (state.GetType(index)) { case Nz::LuaType_Table: { double values[16]; for (std::size_t i = 0; i < 16; ++i) { - instance.PushInteger(i + 1); - instance.GetTable(); + state.PushInteger(i + 1); + state.GetTable(); - values[i] = instance.CheckNumber(-1); - instance.Pop(); + values[i] = state.CheckNumber(-1); + state.Pop(); } mat->Set(values); @@ -133,500 +133,500 @@ namespace Nz default: { - if (instance.IsOfType(index, "Matrix4")) - mat->Set(*static_cast(instance.ToUserdata(index))); + if (state.IsOfType(index, "Matrix4")) + mat->Set(*static_cast(state.ToUserdata(index))); return 1; } } } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Matrix4f* mat, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Matrix4f* mat, TypeTag) { Matrix4d matDouble = Matrix4d::Identity(); - unsigned int ret = LuaImplQueryArg(instance, index, &matDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &matDouble, TypeTag()); mat->Set(matDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MeshParams* params, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MeshParams* params, TypeTag) { - instance.CheckType(index, Nz::LuaType_Table); + state.CheckType(index, Nz::LuaType_Table); - params->animated = instance.CheckField("Animated", params->animated); - params->center = instance.CheckField("Center", params->center); - params->matrix = instance.CheckField("Matrix", params->matrix); - params->optimizeIndexBuffers = instance.CheckField("OptimizeIndexBuffers", params->optimizeIndexBuffers); - params->texCoordOffset = instance.CheckField("TexCoordOffset", params->texCoordOffset); - params->texCoordScale = instance.CheckField("TexCoordScale", params->texCoordScale); + params->animated = state.CheckField("Animated", params->animated); + params->center = state.CheckField("Center", params->center); + params->matrix = state.CheckField("Matrix", params->matrix); + params->optimizeIndexBuffers = state.CheckField("OptimizeIndexBuffers", params->optimizeIndexBuffers); + params->texCoordOffset = state.CheckField("TexCoordOffset", params->texCoordOffset); + params->texCoordScale = state.CheckField("TexCoordScale", params->texCoordScale); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaterniond* quat, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Quaterniond* quat, TypeTag) { - switch (instance.GetType(index)) + switch (state.GetType(index)) { case Nz::LuaType_Table: - quat->Set(instance.CheckField("w", index), instance.CheckField("x", index), instance.CheckField("y", index), instance.CheckField("z", index)); + quat->Set(state.CheckField("w", index), state.CheckField("x", index), state.CheckField("y", index), state.CheckField("z", index)); return 1; default: { - if (instance.IsOfType(index, "EulerAngles")) - quat->Set(*static_cast(instance.ToUserdata(index))); + if (state.IsOfType(index, "EulerAngles")) + quat->Set(*static_cast(state.ToUserdata(index))); else - quat->Set(*static_cast(instance.CheckUserdata(index, "Quaternion"))); + quat->Set(*static_cast(state.CheckUserdata(index, "Quaternion"))); return 1; } } } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaternionf* quat, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Quaternionf* quat, TypeTag) { Quaterniond quatDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &quatDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &quatDouble, TypeTag()); quat->Set(quatDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectd* rect, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectd* rect, TypeTag) { - instance.CheckType(index, LuaType_Table); + state.CheckType(index, LuaType_Table); - rect->x = instance.CheckField("x", index); - rect->y = instance.CheckField("y", index); - rect->width = instance.CheckField("width", index); - rect->height = instance.CheckField("height", index); + rect->x = state.CheckField("x", index); + rect->y = state.CheckField("y", index); + rect->width = state.CheckField("width", index); + rect->height = state.CheckField("height", index); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectf* rect, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectf* rect, TypeTag) { Rectd rectDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &rectDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag()); rect->Set(rectDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Recti* rect, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Recti* rect, TypeTag) { Rectd rectDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &rectDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag()); rect->Set(rectDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectui* rect, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectui* rect, TypeTag) { Rectd rectDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &rectDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag()); rect->Set(rectDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2d* vec, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2d* vec, TypeTag) { - switch (instance.GetType(index)) + switch (state.GetType(index)) { case Nz::LuaType_Number: if (index < 0 && index > -2) - instance.Error("Vector2 expected, two numbers are required to convert it"); + state.Error("Vector2 expected, two numbers are required to convert it"); - vec->Set(instance.CheckNumber(index), instance.CheckNumber(index + 1)); + vec->Set(state.CheckNumber(index), state.CheckNumber(index + 1)); return 2; case Nz::LuaType_Table: - vec->Set(instance.CheckField("x", index), instance.CheckField("y", index)); + vec->Set(state.CheckField("x", index), state.CheckField("y", index)); return 1; default: - vec->Set(*static_cast(instance.CheckUserdata(index, "Vector2"))); + vec->Set(*static_cast(state.CheckUserdata(index, "Vector2"))); return 1; } } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2f* vec, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2f* vec, TypeTag) { Vector2d vecDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &vecDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); vec->Set(vecDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2ui* vec, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2ui* vec, TypeTag) { Vector2d vecDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &vecDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); vec->Set(vecDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3d* vec, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3d* vec, TypeTag) { - switch (instance.GetType(index)) + switch (state.GetType(index)) { case Nz::LuaType_Number: if (index < 0 && index > -3) - instance.Error("Vector3 expected, three numbers are required to convert it"); + state.Error("Vector3 expected, three numbers are required to convert it"); - vec->Set(instance.CheckNumber(index), instance.CheckNumber(index + 1), instance.CheckNumber(index + 2, 0.0)); + vec->Set(state.CheckNumber(index), state.CheckNumber(index + 1), state.CheckNumber(index + 2, 0.0)); return 3; case Nz::LuaType_Table: - vec->Set(instance.CheckField("x", index), instance.CheckField("y", index), instance.CheckField("z", 0.0, index)); + vec->Set(state.CheckField("x", index), state.CheckField("y", index), state.CheckField("z", 0.0, index)); return 1; default: - vec->Set(*static_cast(instance.CheckUserdata(index, "Vector3"))); + vec->Set(*static_cast(state.CheckUserdata(index, "Vector3"))); return 1; } } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3f* vec, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3f* vec, TypeTag) { Vector3d vecDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &vecDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); vec->Set(vecDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3ui* vec, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3ui* vec, TypeTag) { Vector3d vecDouble; - unsigned int ret = LuaImplQueryArg(instance, index, &vecDouble, TypeTag()); + unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); vec->Set(vecDouble); return ret; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::EntityHandle* handle, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::EntityHandle* handle, TypeTag) { - *handle = *static_cast(instance.CheckUserdata(index, "Entity")); + *handle = *static_cast(state.CheckUserdata(index, "Entity")); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::WorldHandle* handle, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::WorldHandle* handle, TypeTag) { - *handle = *static_cast(instance.CheckUserdata(index, "World")); + *handle = *static_cast(state.CheckUserdata(index, "World")); return 1; } #ifndef NDK_SERVER - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, InstancedRenderableRef* renderable, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, InstancedRenderableRef* renderable, TypeTag) { - if (instance.IsOfType(index, "InstancedRenderable") || - instance.IsOfType(index, "Model") || - instance.IsOfType(index, "Sprite")) + if (state.IsOfType(index, "InstancedRenderable") || + state.IsOfType(index, "Model") || + state.IsOfType(index, "Sprite")) { - *renderable = *static_cast(instance.ToUserdata(index)); + *renderable = *static_cast(state.ToUserdata(index)); } else - instance.ArgError(index, "is not a InstancedRenderable instance"); + state.ArgError(index, "is not a InstancedRenderable instance"); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MaterialRef* materialRef, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MaterialRef* materialRef, TypeTag) { - *materialRef = *static_cast(instance.CheckUserdata(index, "Material")); + *materialRef = *static_cast(state.CheckUserdata(index, "Material")); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MaterialParams* params, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MaterialParams* params, TypeTag) { - instance.CheckType(index, Nz::LuaType_Table); + state.CheckType(index, Nz::LuaType_Table); - params->loadAlphaMap = instance.CheckField("LoadAlphaMap", params->loadAlphaMap); - params->loadDiffuseMap = instance.CheckField("LoadDiffuseMap", params->loadDiffuseMap); - params->loadEmissiveMap = instance.CheckField("LoadEmissiveMap", params->loadEmissiveMap); - params->loadHeightMap = instance.CheckField("LoadHeightMap", params->loadHeightMap); - params->loadNormalMap = instance.CheckField("LoadNormalMap", params->loadNormalMap); - params->loadSpecularMap = instance.CheckField("LoadSpecularMap", params->loadSpecularMap); - params->shaderName = instance.CheckField("ShaderName", params->shaderName); + params->loadAlphaMap = state.CheckField("LoadAlphaMap", params->loadAlphaMap); + params->loadDiffuseMap = state.CheckField("LoadDiffuseMap", params->loadDiffuseMap); + params->loadEmissiveMap = state.CheckField("LoadEmissiveMap", params->loadEmissiveMap); + params->loadHeightMap = state.CheckField("LoadHeightMap", params->loadHeightMap); + params->loadNormalMap = state.CheckField("LoadNormalMap", params->loadNormalMap); + params->loadSpecularMap = state.CheckField("LoadSpecularMap", params->loadSpecularMap); + params->shaderName = state.CheckField("ShaderName", params->shaderName); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ModelParameters* params, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, ModelParameters* params, TypeTag) { - instance.CheckType(index, Nz::LuaType_Table); + state.CheckType(index, Nz::LuaType_Table); - params->loadMaterials = instance.CheckField("LoadMaterials", params->loadMaterials); + params->loadMaterials = state.CheckField("LoadMaterials", params->loadMaterials); - LuaImplQueryArg(instance, -1, ¶ms->material, TypeTag()); - LuaImplQueryArg(instance, -1, ¶ms->mesh, TypeTag()); + LuaImplQueryArg(state, -1, ¶ms->material, TypeTag()); + LuaImplQueryArg(state, -1, ¶ms->mesh, TypeTag()); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MusicParams* params, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MusicParams* params, TypeTag) { - instance.CheckType(index, Nz::LuaType_Table); + state.CheckType(index, Nz::LuaType_Table); - params->forceMono = instance.CheckField("ForceMono", params->forceMono); + params->forceMono = state.CheckField("ForceMono", params->forceMono); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SoundBufferParams* params, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, SoundBufferParams* params, TypeTag) { - instance.CheckType(index, Nz::LuaType_Table); + state.CheckType(index, Nz::LuaType_Table); - params->forceMono = instance.CheckField("ForceMono", params->forceMono); + params->forceMono = state.CheckField("ForceMono", params->forceMono); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SpriteRef* spriteRef, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, SpriteRef* spriteRef, TypeTag) { - *spriteRef = *static_cast(instance.CheckUserdata(index, "Sprite")); + *spriteRef = *static_cast(state.CheckUserdata(index, "Sprite")); return 1; } - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, TextureRef* textureRef, TypeTag) + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, TextureRef* textureRef, TypeTag) { - *textureRef = *static_cast(instance.CheckUserdata(index, "Texture")); + *textureRef = *static_cast(state.CheckUserdata(index, "Texture")); return 1; } #endif - inline int LuaImplReplyVal(const LuaInstance& instance, Color&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Color&& val, TypeTag) { - instance.PushTable(); - instance.PushField("r", val.r); - instance.PushField("g", val.g); - instance.PushField("b", val.b); - instance.PushField("a", val.a); + state.PushTable(); + state.PushField("r", val.r); + state.PushField("g", val.g); + state.PushField("b", val.b); + state.PushField("a", val.a); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesd&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, EulerAnglesd&& val, TypeTag) { - instance.PushInstance("EulerAngles", val); + state.PushInstance("EulerAngles", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesf&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, EulerAnglesf&& val, TypeTag) { - instance.PushInstance("EulerAngles", val); + state.PushInstance("EulerAngles", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, FontRef&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, FontRef&& val, TypeTag) { - instance.PushInstance("Font", val); + state.PushInstance("Font", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Font::SizeInfo&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Font::SizeInfo&& val, TypeTag) { - instance.PushTable(); - instance.PushField("LineHeight", val.lineHeight); - instance.PushField("SpaceAdvance", val.spaceAdvance); - instance.PushField("UnderlinePosition", val.underlinePosition); - instance.PushField("UnderlineThickness", val.underlineThickness); + state.PushTable(); + state.PushField("LineHeight", val.lineHeight); + state.PushField("SpaceAdvance", val.spaceAdvance); + state.PushField("UnderlinePosition", val.underlinePosition); + state.PushField("UnderlineThickness", val.underlineThickness); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, ImageParams&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, ImageParams&& val, TypeTag) { - instance.PushTable(0, 2); - instance.PushField("LevelCount", val.levelCount); - instance.PushField("LoadFormat", val.loadFormat); + state.PushTable(0, 2); + state.PushField("LevelCount", val.levelCount); + state.PushField("LoadFormat", val.loadFormat); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, IpAddress&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, IpAddress&& val, TypeTag) { - instance.PushInstance("IpAddress", val); + state.PushInstance("IpAddress", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Matrix4d&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Matrix4d&& val, TypeTag) { - instance.PushInstance("Matrix4", val); + state.PushInstance("Matrix4", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Matrix4f&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Matrix4f&& val, TypeTag) { - instance.PushInstance("Matrix4", val); + state.PushInstance("Matrix4", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Quaterniond&& val, TypeTag) { - instance.PushInstance("Quaternion", val); + state.PushInstance("Quaternion", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Quaternionf&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Quaternionf&& val, TypeTag) { - instance.PushInstance("Quaternion", val); + state.PushInstance("Quaternion", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Rectd&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Rectd&& val, TypeTag) { - instance.PushInstance("Rect", val); + state.PushInstance("Rect", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Rectf&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Rectf&& val, TypeTag) { - instance.PushInstance("Rect", val); + state.PushInstance("Rect", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Recti&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Recti&& val, TypeTag) { - instance.PushInstance("Rect", val); + state.PushInstance("Rect", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Rectui&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Rectui&& val, TypeTag) { - instance.PushInstance("Rect", val); + state.PushInstance("Rect", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Vector2d&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Vector2d&& val, TypeTag) { - instance.PushInstance("Vector2", val); + state.PushInstance("Vector2", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Vector2f&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Vector2f&& val, TypeTag) { - instance.PushInstance("Vector2", val); + state.PushInstance("Vector2", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Vector2ui&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Vector2ui&& val, TypeTag) { - instance.PushInstance("Vector2", val); + state.PushInstance("Vector2", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Vector3d&& val, TypeTag) { - instance.PushInstance("Vector3", val); + state.PushInstance("Vector3", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Vector3f&& val, TypeTag) { - instance.PushInstance("Vector3", val); + state.PushInstance("Vector3", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Vector3ui&& val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Vector3ui&& val, TypeTag) { - instance.PushInstance("Vector3", val); + state.PushInstance("Vector3", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Entity* ptr, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::Entity* ptr, TypeTag) { - instance.PushInstance("Entity", ptr); + state.PushInstance("Entity", ptr); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Application* ptr, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::Application* ptr, TypeTag) { - instance.PushInstance("Application", ptr); + state.PushInstance("Application", ptr); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::EntityHandle&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::EntityHandle&& handle, TypeTag) { - instance.PushInstance("Entity", handle); + state.PushInstance("Entity", handle); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::NodeComponentHandle&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::NodeComponentHandle&& handle, TypeTag) { - instance.PushInstance("NodeComponent", handle); + state.PushInstance("NodeComponent", handle); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::VelocityComponentHandle&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::VelocityComponentHandle&& handle, TypeTag) { - instance.PushInstance("VelocityComponent", handle); + state.PushInstance("VelocityComponent", handle); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::World* ptr, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::World* ptr, TypeTag) { - instance.PushInstance("World", ptr); + state.PushInstance("World", ptr); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::WorldHandle&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::WorldHandle&& handle, TypeTag) { - instance.PushInstance("World", handle); + state.PushInstance("World", handle); return 1; } #ifndef NDK_SERVER - inline int LuaImplReplyVal(const LuaInstance& instance, MaterialRef&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, MaterialRef&& handle, TypeTag) { - instance.PushInstance("Material", handle); + state.PushInstance("Material", handle); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, const SoundBuffer* val, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, const SoundBuffer* val, TypeTag) { - instance.PushInstance("SoundBuffer", val); + state.PushInstance("SoundBuffer", val); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, SpriteRef&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, SpriteRef&& handle, TypeTag) { - instance.PushInstance("Sprite", handle); + state.PushInstance("Sprite", handle); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, TextureRef&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, TextureRef&& handle, TypeTag) { - instance.PushInstance("Texture", handle); + state.PushInstance("Texture", handle); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::CameraComponentHandle&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::CameraComponentHandle&& handle, TypeTag) { - instance.PushInstance("CameraComponent", handle); + state.PushInstance("CameraComponent", handle); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::ConsoleHandle&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::ConsoleHandle&& handle, TypeTag) { - instance.PushInstance("Console", handle); + state.PushInstance("Console", handle); return 1; } - inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::GraphicsComponentHandle&& handle, TypeTag) + inline int LuaImplReplyVal(const LuaState& state, Ndk::GraphicsComponentHandle&& handle, TypeTag) { - instance.PushInstance("GraphicsComponent", handle); + state.PushInstance("GraphicsComponent", handle); return 1; } #endif diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index e159c0101..c70ec181b 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -164,25 +164,25 @@ namespace Ndk LuaAPI::RegisterClasses(overlay->lua); // Override "print" function to add a line in the console - overlay->lua.PushFunction([&consoleRef] (Nz::LuaInstance& instance) + overlay->lua.PushFunction([&consoleRef] (Nz::LuaState& state) { Nz::StringStream stream; - unsigned int argCount = instance.GetStackTop(); - instance.GetGlobal("tostring"); + unsigned int argCount = state.GetStackTop(); + state.GetGlobal("tostring"); for (unsigned int i = 1; i <= argCount; ++i) { - instance.PushValue(-1); // tostring function - instance.PushValue(i); // argument - instance.Call(1, 1); + state.PushValue(-1); // tostring function + state.PushValue(i); // argument + state.Call(1, 1); std::size_t length; - const char* str = instance.CheckString(-1, &length); + const char* str = state.CheckString(-1, &length); if (i > 1) stream << '\t'; stream << Nz::String(str, length); - instance.Pop(1); + state.Pop(1); } consoleRef.AddLine(stream); diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 3843978ad..a59bfdf81 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -33,10 +33,10 @@ namespace Ndk * \param instance Lua instance that will interact with the world */ - Console::Console(World& world, const Nz::Vector2f& size, Nz::LuaInstance& instance) : + Console::Console(World& world, const Nz::Vector2f& size, Nz::LuaState& state) : m_historyPosition(0), m_defaultFont(Nz::Font::GetDefault()), - m_instance(instance), + m_state(state), m_size(size), m_opened(false), m_characterSize(24) @@ -310,8 +310,8 @@ namespace Ndk AddLineInternal(input); //< With the input prefix - if (!m_instance.Execute(inputCmd)) - AddLineInternal(m_instance.GetLastError(), Nz::Color::Red); + if (!m_state.Execute(inputCmd)) + AddLineInternal(m_state.GetLastError(), Nz::Color::Red); RefreshHistory(); } diff --git a/SDK/src/NDK/Lua/LuaBinding.cpp b/SDK/src/NDK/Lua/LuaBinding.cpp index cb763b3b4..715351e52 100644 --- a/SDK/src/NDK/Lua/LuaBinding.cpp +++ b/SDK/src/NDK/Lua/LuaBinding.cpp @@ -22,7 +22,7 @@ namespace Ndk utility = LuaBinding_Base::BindUtility(*this); #ifndef NDK_SERVER - audio = LuaBinding_Base::BindAudio(*this); + audio = LuaBinding_Base::BindAudio(*this); renderer = LuaBinding_Base::BindRenderer(*this); graphics = LuaBinding_Base::BindGraphics(*this); #endif @@ -36,31 +36,31 @@ namespace Ndk * \param instance Lua instance that will interact with the engine & SDK */ - void LuaBinding::RegisterClasses(Nz::LuaInstance& instance) + void LuaBinding::RegisterClasses(Nz::LuaState& state) { - core->Register(instance); - math->Register(instance); - network->Register(instance); - sdk->Register(instance); - utility->Register(instance); + core->Register(state); + math->Register(state); + network->Register(state); + sdk->Register(state); + utility->Register(state); #ifndef NDK_SERVER - audio->Register(instance); - graphics->Register(instance); - renderer->Register(instance); + audio->Register(state); + graphics->Register(state); + renderer->Register(state); #endif // ComponentType (fake enumeration to expose component indexes) - instance.PushTable(0, m_componentBinding.size()); + state.PushTable(0, m_componentBinding.size()); { for (const ComponentBinding& entry : m_componentBinding) { if (entry.name.IsEmpty()) continue; - instance.PushField(entry.name, entry.index); + state.PushField(entry.name, entry.index); } } - instance.SetGlobal("ComponentType"); + state.SetGlobal("ComponentType"); } } diff --git a/SDK/src/NDK/Lua/LuaBinding_Audio.cpp b/SDK/src/NDK/Lua/LuaBinding_Audio.cpp index 619fe2850..1611c1b8c 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Audio.cpp @@ -77,7 +77,7 @@ namespace Ndk music.BindMethod("Stop", &Nz::Music::Stop); // Manual - music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int + music.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int { Nz::StringStream ss("Music("); ss << instance.GetFilePath() << ')'; @@ -104,7 +104,7 @@ namespace Ndk sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset); // Manual - sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& instance, std::size_t /*argumentCount*/) -> int + sound.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Sound& instance, std::size_t /*argumentCount*/) -> int { Nz::StringStream ss("Sound("); if (const Nz::SoundBuffer* buffer = instance.GetBuffer()) @@ -120,7 +120,7 @@ namespace Ndk /*********************************** Nz::SoundBuffer **********************************/ soundBuffer.Reset("SoundBuffer"); { - soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount) + soundBuffer.SetConstructor([] (Nz::LuaState& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount) { NazaraUnused(lua); NazaraUnused(argumentCount); @@ -143,7 +143,7 @@ namespace Ndk soundBuffer.BindStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported); // Manual - soundBuffer.BindMethod("Create", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int + soundBuffer.BindMethod("Create", [] (Nz::LuaState& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int { int index = 2; Nz::AudioFormat format = lua.Check(&index); @@ -158,13 +158,13 @@ namespace Ndk return 1; }); - soundBuffer.BindMethod("GetSamples", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int + soundBuffer.BindMethod("GetSamples", [] (Nz::LuaState& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int { lua.PushString(reinterpret_cast(instance->GetSamples()), instance->GetSampleCount() * sizeof(Nz::Int16)); return 1; }); - soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int + soundBuffer.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int { Nz::StringStream ss("SoundBuffer("); if (instance->IsValid()) @@ -188,11 +188,11 @@ namespace Ndk * * \param instance Lua instance that will interact with the Audio classes */ - void LuaBinding_Audio::Register(Nz::LuaInstance& instance) + void LuaBinding_Audio::Register(Nz::LuaState& state) { - music.Register(instance); - sound.Register(instance); - soundBuffer.Register(instance); - soundEmitter.Register(instance); + music.Register(state); + sound.Register(state); + soundBuffer.Register(state); + soundEmitter.Register(state); } } diff --git a/SDK/src/NDK/Lua/LuaBinding_Core.cpp b/SDK/src/NDK/Lua/LuaBinding_Core.cpp index fc53f72c3..f86aafa98 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Core.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Core.cpp @@ -32,28 +32,28 @@ namespace Ndk stream.BindMethod("IsWritable", &Nz::Stream::IsWritable); stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos); - stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int { + stream.BindMethod("Read", [] (Nz::LuaState& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int { int argIndex = 2; std::size_t length = lua.Check(&argIndex); std::unique_ptr buffer(new char[length]); - std::size_t readLength = instance.Read(buffer.get(), length); + std::size_t readLength = stream.Read(buffer.get(), length); lua.PushString(Nz::String(buffer.get(), readLength)); return 1; }); - stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int { + stream.BindMethod("Write", [] (Nz::LuaState& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int { int argIndex = 2; std::size_t bufferSize = 0; const char* buffer = lua.CheckString(argIndex, &bufferSize); - if (instance.IsTextModeEnabled()) - lua.Push(instance.Write(Nz::String(buffer, bufferSize))); + if (stream.IsTextModeEnabled()) + lua.Push(stream.Write(Nz::String(buffer, bufferSize))); else - lua.Push(instance.Write(buffer, bufferSize)); + lua.Push(stream.Write(buffer, bufferSize)); return 1; }); } @@ -61,7 +61,7 @@ namespace Ndk /*********************************** Nz::Clock **********************************/ clock.Reset("Clock"); { - clock.SetConstructor([] (Nz::LuaInstance& lua, Nz::Clock* instance, std::size_t argumentCount) + clock.SetConstructor([] (Nz::LuaState& lua, Nz::Clock* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 2U); @@ -103,11 +103,11 @@ namespace Ndk clock.BindMethod("Unpause", &Nz::Clock::Unpause); // Manual - clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& instance, std::size_t /*argumentCount*/) -> int { + clock.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Clock& clock, std::size_t /*argumentCount*/) -> int { Nz::StringStream ss("Clock(Elapsed: "); - ss << instance.GetSeconds(); + ss << clock.GetSeconds(); ss << "s, Paused: "; - ss << instance.IsPaused(); + ss << clock.IsPaused(); ss << ')'; lua.PushString(ss); @@ -118,7 +118,7 @@ namespace Ndk /********************************* Nz::Directory ********************************/ directory.Reset("Directory"); { - directory.SetConstructor([] (Nz::LuaInstance& lua, Nz::Directory* instance, std::size_t argumentCount) + directory.SetConstructor([] (Nz::LuaState& lua, Nz::Directory* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 1U); @@ -159,9 +159,9 @@ namespace Ndk directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent); // Manual - directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int { + directory.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Directory& dir, std::size_t /*argumentCount*/) -> int { Nz::StringStream ss("Directory("); - ss << instance.GetPath(); + ss << dir.GetPath(); ss << ')'; lua.PushString(ss); @@ -174,7 +174,7 @@ namespace Ndk { file.Inherit(stream); - file.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* instance, std::size_t argumentCount) + file.SetConstructor([] (Nz::LuaState& lua, Nz::File* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 1U); @@ -237,7 +237,7 @@ namespace Ndk file.BindStaticMethod("Rename", &Nz::File::Rename); // Manual - file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int + file.BindMethod("Open", [] (Nz::LuaState& lua, Nz::File& file, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 2U); @@ -246,13 +246,13 @@ namespace Ndk { case 0: case 1: - return lua.Push(instance.Open(lua.Check(&argIndex, Nz::OpenMode_NotOpen))); + return lua.Push(file.Open(lua.Check(&argIndex, Nz::OpenMode_NotOpen))); case 2: { Nz::String filePath = lua.Check(&argIndex); Nz::UInt32 openMode = lua.Check(&argIndex, Nz::OpenMode_NotOpen); - return lua.Push(instance.Open(filePath, openMode)); + return lua.Push(file.Open(filePath, openMode)); } } @@ -260,7 +260,7 @@ namespace Ndk return 0; }); - file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int + file.BindMethod("SetCursorPos", [] (Nz::LuaState& lua, Nz::File& file, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 2U); @@ -268,13 +268,13 @@ namespace Ndk switch (argCount) { case 1: - return lua.Push(instance.SetCursorPos(lua.Check(&argIndex))); + return lua.Push(file.SetCursorPos(lua.Check(&argIndex))); case 2: { Nz::CursorPosition curPos = lua.Check(&argIndex); Nz::Int64 offset = lua.Check(&argIndex); - return lua.Push(instance.SetCursorPos(curPos, offset)); + return lua.Push(file.SetCursorPos(curPos, offset)); } } @@ -282,10 +282,10 @@ namespace Ndk return 0; }); - file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int { + file.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::File& file, std::size_t /*argumentCount*/) -> int { Nz::StringStream ss("File("); - if (instance.IsOpen()) - ss << "Path: " << instance.GetPath(); + if (file.IsOpen()) + ss << "Path: " << file.GetPath(); ss << ')'; @@ -300,55 +300,55 @@ namespace Ndk * * \param instance Lua instance that will interact with the Core classes */ - void LuaBinding_Core::Register(Nz::LuaInstance& instance) + void LuaBinding_Core::Register(Nz::LuaState& state) { // Classes - clock.Register(instance); - directory.Register(instance); - file.Register(instance); - stream.Register(instance); + clock.Register(state); + directory.Register(state); + file.Register(state); + stream.Register(state); // Enums // Nz::CursorPosition static_assert(Nz::CursorPosition_Max + 1 == 3, "Nz::CursorPosition has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 3); + state.PushTable(0, 3); { - instance.PushField("AtBegin", Nz::CursorPosition_AtBegin); - instance.PushField("AtCurrent", Nz::CursorPosition_AtCurrent); - instance.PushField("AtEnd", Nz::CursorPosition_AtEnd); + state.PushField("AtBegin", Nz::CursorPosition_AtBegin); + state.PushField("AtCurrent", Nz::CursorPosition_AtCurrent); + state.PushField("AtEnd", Nz::CursorPosition_AtEnd); } - instance.SetGlobal("CursorPosition"); + state.SetGlobal("CursorPosition"); // Nz::HashType static_assert(Nz::HashType_Max + 1 == 9, "Nz::HashType has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 9); + state.PushTable(0, 9); { - instance.PushField("CRC32", Nz::HashType_CRC32); - instance.PushField("Fletcher16", Nz::HashType_Fletcher16); - instance.PushField("MD5", Nz::HashType_MD5); - instance.PushField("SHA1", Nz::HashType_SHA1); - instance.PushField("SHA224", Nz::HashType_SHA224); - instance.PushField("SHA256", Nz::HashType_SHA256); - instance.PushField("SHA384", Nz::HashType_SHA384); - instance.PushField("SHA512", Nz::HashType_SHA512); - instance.PushField("Whirlpool", Nz::HashType_Whirlpool); + state.PushField("CRC32", Nz::HashType_CRC32); + state.PushField("Fletcher16", Nz::HashType_Fletcher16); + state.PushField("MD5", Nz::HashType_MD5); + state.PushField("SHA1", Nz::HashType_SHA1); + state.PushField("SHA224", Nz::HashType_SHA224); + state.PushField("SHA256", Nz::HashType_SHA256); + state.PushField("SHA384", Nz::HashType_SHA384); + state.PushField("SHA512", Nz::HashType_SHA512); + state.PushField("Whirlpool", Nz::HashType_Whirlpool); } - instance.SetGlobal("HashType"); + state.SetGlobal("HashType"); // Nz::OpenMode static_assert(Nz::OpenMode_Max + 1 == 8, "Nz::OpenModeFlags has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, Nz::OpenMode_Max + 1); + state.PushTable(0, Nz::OpenMode_Max + 1); { - instance.PushField("Append", Nz::OpenMode_Append); - instance.PushField("NotOpen", Nz::OpenMode_NotOpen); - instance.PushField("Lock", Nz::OpenMode_Lock); - instance.PushField("ReadOnly", Nz::OpenMode_ReadOnly); - instance.PushField("ReadWrite", Nz::OpenMode_ReadWrite); - instance.PushField("Text", Nz::OpenMode_Text); - instance.PushField("Truncate", Nz::OpenMode_Truncate); - instance.PushField("WriteOnly", Nz::OpenMode_WriteOnly); + state.PushField("Append", Nz::OpenMode_Append); + state.PushField("NotOpen", Nz::OpenMode_NotOpen); + state.PushField("Lock", Nz::OpenMode_Lock); + state.PushField("ReadOnly", Nz::OpenMode_ReadOnly); + state.PushField("ReadWrite", Nz::OpenMode_ReadWrite); + state.PushField("Text", Nz::OpenMode_Text); + state.PushField("Truncate", Nz::OpenMode_Truncate); + state.PushField("WriteOnly", Nz::OpenMode_WriteOnly); } - instance.SetGlobal("OpenMode"); + state.SetGlobal("OpenMode"); } } diff --git a/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp b/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp index f87ac6556..d33811f49 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp @@ -37,7 +37,7 @@ namespace Ndk /*********************************** Nz::Material ***********************************/ material.Reset("Material"); { - material.SetConstructor([] (Nz::LuaInstance& lua, Nz::MaterialRef* instance, std::size_t argumentCount) + material.SetConstructor([] (Nz::LuaState& lua, Nz::MaterialRef* instance, std::size_t argumentCount) { switch (argumentCount) { @@ -70,7 +70,7 @@ namespace Ndk return false; }); - material.BindMethod("Configure", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int + material.BindMethod("Configure", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "MaterialPipeline")) @@ -168,7 +168,7 @@ namespace Ndk material.BindStaticMethod("GetDefault", &Nz::Material::GetDefault); - material.BindMethod("SetAlphaMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int + material.BindMethod("SetAlphaMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "Texture")) @@ -180,7 +180,7 @@ namespace Ndk return lua.Push(instance->SetAlphaMap(lua.Check(&argIndex))); }); - material.BindMethod("SetDiffuseMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int + material.BindMethod("SetDiffuseMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "Texture")) @@ -192,7 +192,7 @@ namespace Ndk return lua.Push(instance->SetDiffuseMap(lua.Check(&argIndex))); }); - material.BindMethod("SetEmissiveMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int + material.BindMethod("SetEmissiveMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "Texture")) @@ -204,7 +204,7 @@ namespace Ndk return lua.Push(instance->SetEmissiveMap(lua.Check(&argIndex))); }); - material.BindMethod("SetHeightMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int + material.BindMethod("SetHeightMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "Texture")) @@ -216,7 +216,7 @@ namespace Ndk return lua.Push(instance->SetHeightMap(lua.Check(&argIndex))); }); - material.BindMethod("SetNormalMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int + material.BindMethod("SetNormalMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "Texture")) @@ -228,7 +228,7 @@ namespace Ndk return lua.Push(instance->SetNormalMap(lua.Check(&argIndex))); }); - material.BindMethod("SetShader", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int + material.BindMethod("SetShader", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "UberShader")) @@ -240,7 +240,7 @@ namespace Ndk return lua.Push(instance->SetShader(lua.Check(&argIndex))); }); - material.BindMethod("SetSpecularMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int + material.BindMethod("SetSpecularMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "Texture")) @@ -261,7 +261,7 @@ namespace Ndk return reinterpret_cast(modelRef); //TODO: Make a ObjectRefCast }); - model.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::ModelRef* instance, std::size_t /*argumentCount*/) + model.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::ModelRef* instance, std::size_t /*argumentCount*/) { Nz::PlacementNew(instance, Nz::Model::New()); return true; @@ -293,7 +293,7 @@ namespace Ndk return reinterpret_cast(spriteRef); //TODO: Make a ObjectRefCast }); - sprite.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::SpriteRef* instance, std::size_t /*argumentCount*/) + sprite.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::SpriteRef* instance, std::size_t /*argumentCount*/) { Nz::PlacementNew(instance, Nz::Sprite::New()); return true; @@ -314,7 +314,7 @@ namespace Ndk sprite.BindMethod("SetTextureCoords", &Nz::Sprite::SetTextureCoords); sprite.BindMethod("SetTextureRect", &Nz::Sprite::SetTextureRect); - sprite.BindMethod("SetMaterial", [] (Nz::LuaInstance& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int + sprite.BindMethod("SetMaterial", [] (Nz::LuaState& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; bool resizeSprite = lua.CheckBoolean(argIndex + 1, true); @@ -327,7 +327,7 @@ namespace Ndk return 0; }); - sprite.BindMethod("SetTexture", [] (Nz::LuaInstance& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int + sprite.BindMethod("SetTexture", [] (Nz::LuaState& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; bool resizeSprite = lua.CheckBoolean(argIndex + 1, true); @@ -358,13 +358,13 @@ namespace Ndk * \param instance Lua instance that will interact with the Graphics classes */ - void LuaBinding_Graphics::Register(Nz::LuaInstance& instance) + void LuaBinding_Graphics::Register(Nz::LuaState& state) { - abstractViewer.Register(instance); - instancedRenderable.Register(instance); - material.Register(instance); - model.Register(instance); - sprite.Register(instance); - spriteLibrary.Register(instance); + abstractViewer.Register(state); + instancedRenderable.Register(state); + material.Register(state); + model.Register(state); + sprite.Register(state); + spriteLibrary.Register(state); } } diff --git a/SDK/src/NDK/Lua/LuaBinding_Math.cpp b/SDK/src/NDK/Lua/LuaBinding_Math.cpp index 42403a443..c218c2a66 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Math.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Math.cpp @@ -18,7 +18,7 @@ namespace Ndk /*********************************** Nz::EulerAngles **********************************/ eulerAngles.Reset("EulerAngles"); { - eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) + eulerAngles.SetConstructor([] (Nz::LuaState& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 3U); @@ -46,7 +46,7 @@ namespace Ndk eulerAngles.BindMethod("__tostring", &Nz::EulerAnglesd::ToString); - eulerAngles.SetGetter([] (Nz::LuaInstance& lua, Nz::EulerAnglesd& instance) + eulerAngles.SetGetter([] (Nz::LuaState& lua, Nz::EulerAnglesd& instance) { std::size_t length; const char* ypr = lua.CheckString(2, &length); @@ -103,7 +103,7 @@ namespace Ndk return false; }); - eulerAngles.SetSetter([] (Nz::LuaInstance& lua, Nz::EulerAnglesd& instance) + eulerAngles.SetSetter([] (Nz::LuaState& lua, Nz::EulerAnglesd& instance) { std::size_t length; const char* ypr = lua.CheckString(2, &length); @@ -165,7 +165,7 @@ namespace Ndk /*********************************** Nz::Matrix4 **********************************/ matrix4d.Reset("Matrix4"); { - matrix4d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Matrix4d* matrix, std::size_t argumentCount) + matrix4d.SetConstructor([] (Nz::LuaState& lua, Nz::Matrix4d* matrix, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 3U); @@ -207,7 +207,7 @@ namespace Ndk matrix4d.BindMethod("GetDeterminant", &Nz::Matrix4d::GetDeterminant); matrix4d.BindMethod("GetDeterminantAffine", &Nz::Matrix4d::GetDeterminantAffine); - matrix4d.BindMethod("GetInverse", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + matrix4d.BindMethod("GetInverse", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int { Nz::Matrix4d result; if (instance.GetInverse(&result)) @@ -216,7 +216,7 @@ namespace Ndk return lua.Push(false); }); - matrix4d.BindMethod("GetInverseAffine", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + matrix4d.BindMethod("GetInverseAffine", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int { Nz::Matrix4d result; if (instance.GetInverseAffine(&result)) @@ -232,7 +232,7 @@ namespace Ndk matrix4d.BindMethod("GetSquaredScale", &Nz::Matrix4d::GetSquaredScale); matrix4d.BindMethod("GetTranslation", &Nz::Matrix4d::GetTranslation); - matrix4d.BindMethod("GetTransposed", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + matrix4d.BindMethod("GetTransposed", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int { Nz::Matrix4d result; instance.GetTransposed(&result); @@ -243,7 +243,7 @@ namespace Ndk matrix4d.BindMethod("HasNegativeScale", &Nz::Matrix4d::HasNegativeScale); matrix4d.BindMethod("HasScale", &Nz::Matrix4d::HasScale); - matrix4d.BindMethod("Inverse", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + matrix4d.BindMethod("Inverse", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int { bool succeeded; instance.Inverse(&succeeded); @@ -251,7 +251,7 @@ namespace Ndk return lua.Push(succeeded); }); - matrix4d.BindMethod("InverseAffine", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + matrix4d.BindMethod("InverseAffine", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int { bool succeeded; instance.InverseAffine(&succeeded); @@ -273,7 +273,7 @@ namespace Ndk matrix4d.BindMethod("MakeViewMatrix", &Nz::Matrix4d::MakeViewMatrix); matrix4d.BindMethod("MakeZero", &Nz::Matrix4d::MakeZero); - matrix4d.BindMethod("Set", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t argumentCount) -> int + matrix4d.BindMethod("Set", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 3U); @@ -305,7 +305,7 @@ namespace Ndk matrix4d.BindMethod("SetScale", &Nz::Matrix4d::SetScale); matrix4d.BindMethod("SetTranslation", &Nz::Matrix4d::SetTranslation); - matrix4d.BindMethod("Transform", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + matrix4d.BindMethod("Transform", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "Vector2")) @@ -345,7 +345,7 @@ namespace Ndk matrix4d.BindStaticMethod("ViewMatrix", &Nz::Matrix4d::ViewMatrix); matrix4d.BindStaticMethod("Zero", &Nz::Matrix4d::Zero); - matrix4d.SetGetter([] (Nz::LuaInstance& lua, Nz::Matrix4d& instance) + matrix4d.SetGetter([] (Nz::LuaState& lua, Nz::Matrix4d& instance) { bool succeeded = false; std::size_t index = static_cast(lua.ToInteger(2, &succeeded)); @@ -356,7 +356,7 @@ namespace Ndk return true; }); - matrix4d.SetSetter([] (Nz::LuaInstance& lua, Nz::Matrix4d& instance) + matrix4d.SetSetter([] (Nz::LuaState& lua, Nz::Matrix4d& instance) { bool succeeded = false; std::size_t index = static_cast(lua.ToInteger(2, &succeeded)); @@ -372,7 +372,7 @@ namespace Ndk /*********************************** Nz::Rect **********************************/ rect.Reset("Rect"); { - rect.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* instance, std::size_t argumentCount) + rect.SetConstructor([] (Nz::LuaState& lua, Nz::Rectd* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 4U); @@ -422,7 +422,7 @@ namespace Ndk rect.BindMethod("__tostring", &Nz::Rectd::ToString); - rect.SetGetter([] (Nz::LuaInstance& lua, Nz::Rectd& instance) + rect.SetGetter([] (Nz::LuaState& lua, Nz::Rectd& instance) { switch (lua.GetType(2)) { @@ -475,7 +475,7 @@ namespace Ndk return false; }); - rect.SetSetter([] (Nz::LuaInstance& lua, Nz::Rectd& instance) + rect.SetSetter([] (Nz::LuaState& lua, Nz::Rectd& instance) { switch (lua.GetType(2)) { @@ -531,7 +531,7 @@ namespace Ndk /*********************************** Nz::Quaternion **********************************/ quaternion.Reset("Quaternion"); { - quaternion.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* instance, std::size_t argumentCount) + quaternion.SetConstructor([] (Nz::LuaState& lua, Nz::Quaterniond* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 4U); @@ -587,7 +587,7 @@ namespace Ndk quaternion.BindStaticMethod("RotationBetween", &Nz::Quaterniond::RotationBetween); quaternion.BindStaticMethod("Slerp", &Nz::Quaterniond::Slerp); - quaternion.BindMethod("GetNormal", [] (Nz::LuaInstance& lua, Nz::Quaterniond& instance, std::size_t /*argumentCount*/) -> int + quaternion.BindMethod("GetNormal", [] (Nz::LuaState& lua, Nz::Quaterniond& instance, std::size_t /*argumentCount*/) -> int { double length; @@ -597,7 +597,7 @@ namespace Ndk return 2; }); - quaternion.BindMethod("Normalize", [] (Nz::LuaInstance& lua, Nz::Quaterniond& instance, std::size_t /*argumentCount*/) -> int + quaternion.BindMethod("Normalize", [] (Nz::LuaState& lua, Nz::Quaterniond& instance, std::size_t /*argumentCount*/) -> int { double length; @@ -608,20 +608,20 @@ namespace Ndk return 2; }); - quaternion.BindStaticMethod("Normalize", [] (Nz::LuaInstance& instance) -> int + quaternion.BindStaticMethod("Normalize", [] (Nz::LuaState& state) -> int { int argIndex = 1; - Nz::Quaterniond quat = instance.Check(&argIndex); + Nz::Quaterniond quat = state.Check(&argIndex); double length; - instance.Push(Nz::Quaterniond::Normalize(quat, &length)); - instance.Push(length); + state.Push(Nz::Quaterniond::Normalize(quat, &length)); + state.Push(length); return 2; }); - quaternion.SetGetter([] (Nz::LuaInstance& lua, Nz::Quaterniond& instance) + quaternion.SetGetter([] (Nz::LuaState& lua, Nz::Quaterniond& instance) { std::size_t length; const char* wxyz = lua.CheckString(2, &length); @@ -651,7 +651,7 @@ namespace Ndk return false; }); - quaternion.SetSetter([] (Nz::LuaInstance& lua, Nz::Quaterniond& instance) + quaternion.SetSetter([] (Nz::LuaState& lua, Nz::Quaterniond& instance) { std::size_t length; const char* wxyz = lua.CheckString(2, &length); @@ -690,7 +690,7 @@ namespace Ndk /*********************************** Nz::Vector2 **********************************/ vector2d.Reset("Vector2"); { - vector2d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector2d* vector, std::size_t argumentCount) + vector2d.SetConstructor([] (Nz::LuaState& lua, Nz::Vector2d* vector, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 2U); @@ -720,7 +720,7 @@ namespace Ndk vector2d.BindMethod("__tostring", &Nz::Vector2d::ToString); - vector2d.SetGetter([] (Nz::LuaInstance& lua, Nz::Vector2d& instance) + vector2d.SetGetter([] (Nz::LuaState& lua, Nz::Vector2d& instance) { switch (lua.GetType(2)) { @@ -765,7 +765,7 @@ namespace Ndk return false; }); - vector2d.SetSetter([] (Nz::LuaInstance& lua, Nz::Vector2d& instance) + vector2d.SetSetter([] (Nz::LuaState& lua, Nz::Vector2d& instance) { switch (lua.GetType(2)) { @@ -816,7 +816,7 @@ namespace Ndk /*********************************** Nz::Vector3 **********************************/ vector3d.Reset("Vector3"); { - vector3d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector3d* vector, std::size_t argumentCount) + vector3d.SetConstructor([] (Nz::LuaState& lua, Nz::Vector3d* vector, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 3U); @@ -860,7 +860,7 @@ namespace Ndk vector3d.BindMethod("__tostring", &Nz::Vector3d::ToString); - vector3d.SetGetter([] (Nz::LuaInstance& lua, Nz::Vector3d& instance) + vector3d.SetGetter([] (Nz::LuaState& lua, Nz::Vector3d& instance) { switch (lua.GetType(2)) { @@ -909,7 +909,7 @@ namespace Ndk return false; }); - vector3d.SetSetter([] (Nz::LuaInstance& lua, Nz::Vector3d& instance) + vector3d.SetSetter([] (Nz::LuaState& lua, Nz::Vector3d& instance) { switch (lua.GetType(2)) { @@ -967,20 +967,20 @@ namespace Ndk * * \param instance Lua instance that will interact with the Math classes */ - void LuaBinding_Math::Register(Nz::LuaInstance& instance) + void LuaBinding_Math::Register(Nz::LuaState& state) { - eulerAngles.Register(instance); - matrix4d.Register(instance); - quaternion.Register(instance); - rect.Register(instance); - vector2d.Register(instance); - vector3d.Register(instance); + eulerAngles.Register(state); + matrix4d.Register(state); + quaternion.Register(state); + rect.Register(state); + vector2d.Register(state); + vector3d.Register(state); - quaternion.PushGlobalTable(instance); + quaternion.PushGlobalTable(state); { - instance.PushField("Identity", Nz::Quaterniond::Identity()); - instance.PushField("Zero", Nz::Quaterniond::Zero()); + state.PushField("Identity", Nz::Quaterniond::Identity()); + state.PushField("Zero", Nz::Quaterniond::Zero()); } - instance.Pop(); + state.Pop(); } } diff --git a/SDK/src/NDK/Lua/LuaBinding_Network.cpp b/SDK/src/NDK/Lua/LuaBinding_Network.cpp index a47cdbfb6..c54ef89a0 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Network.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Network.cpp @@ -28,7 +28,7 @@ namespace Ndk /*********************************** Nz::IpAddress **********************************/ ipAddress.Reset("IpAddress"); { - ipAddress.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* instance, std::size_t argumentCount) + ipAddress.SetConstructor([] (Nz::LuaState& lua, Nz::IpAddress* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 9U); @@ -85,59 +85,59 @@ namespace Ndk ipAddress.BindMethod("ToUInt32", &Nz::IpAddress::ToUInt32); ipAddress.BindMethod("__tostring", &Nz::IpAddress::ToString); - ipAddress.BindStaticMethod("ResolveAddress", [] (Nz::LuaInstance& instance) -> int + ipAddress.BindStaticMethod("ResolveAddress", [] (Nz::LuaState& state) -> int { Nz::String service; Nz::ResolveError error = Nz::ResolveError_Unknown; int argIndex = 2; - Nz::String hostName = Nz::IpAddress::ResolveAddress(instance.Check(&argIndex), &service, &error); + Nz::String hostName = Nz::IpAddress::ResolveAddress(state.Check(&argIndex), &service, &error); if (error == Nz::ResolveError_NoError) { - instance.Push(hostName); - instance.Push(service); + state.Push(hostName); + state.Push(service); return 2; } else { - instance.PushBoolean(false); - instance.Push(error); + state.PushBoolean(false); + state.Push(error); return 2; } }); - ipAddress.BindStaticMethod("ResolveHostname", [] (Nz::LuaInstance& instance) -> int + ipAddress.BindStaticMethod("ResolveHostname", [] (Nz::LuaState& state) -> int { Nz::ResolveError error = Nz::ResolveError_Unknown; int argIndex = 2; - Nz::NetProtocol protocol = instance.Check(&argIndex); - Nz::String hostname = instance.Check(&argIndex); - Nz::String service = instance.Check(&argIndex, "http"); + Nz::NetProtocol protocol = state.Check(&argIndex); + Nz::String hostname = state.Check(&argIndex); + Nz::String service = state.Check(&argIndex, "http"); std::vector addresses = Nz::IpAddress::ResolveHostname(protocol, hostname, service, &error); if (error == Nz::ResolveError_NoError) { int index = 1; - instance.PushTable(addresses.size()); + state.PushTable(addresses.size()); for (Nz::HostnameInfo& info : addresses) { - instance.PushInteger(index++); - instance.PushTable(0, 4); - instance.PushField("Address", std::move(info.address)); - instance.PushField("CanonicalName", std::move(info.canonicalName)); - instance.PushField("Protocol", std::move(info.protocol)); - instance.PushField("SocketType", std::move(info.socketType)); - instance.SetTable(); + state.PushInteger(index++); + state.PushTable(0, 4); + state.PushField("Address", std::move(info.address)); + state.PushField("CanonicalName", std::move(info.canonicalName)); + state.PushField("Protocol", std::move(info.protocol)); + state.PushField("SocketType", std::move(info.socketType)); + state.SetTable(); } return 1; } else { - instance.PushBoolean(false); - instance.Push(error); + state.PushBoolean(false); + state.Push(error); return 2; } }); @@ -156,22 +156,22 @@ namespace Ndk udpSocket.BindMethod("IsBroadcastingEnabled", &Nz::UdpSocket::IsBroadcastingEnabled); udpSocket.BindMethod("QueryMaxDatagramSize", &Nz::UdpSocket::QueryMaxDatagramSize); - udpSocket.BindMethod("Bind", [](Nz::LuaInstance& lua, Nz::UdpSocket& instance, std::size_t /*argumentCount*/) -> int + udpSocket.BindMethod("Bind", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int { int argIndex = 2; if (lua.IsOfType(argIndex, "IpAddress")) - return lua.Push(instance.Bind(*static_cast(lua.ToUserdata(argIndex)))); + return lua.Push(socket.Bind(*static_cast(lua.ToUserdata(argIndex)))); else - return lua.Push(instance.Bind(lua.Check(&argIndex))); + return lua.Push(socket.Bind(lua.Check(&argIndex))); }); - udpSocket.BindMethod("Receive", [](Nz::LuaInstance& lua, Nz::UdpSocket& instance, std::size_t /*argumentCount*/) -> int + udpSocket.BindMethod("Receive", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int { Nz::IpAddress from; std::array buffer; std::size_t received; - if (instance.Receive(buffer.data(), buffer.size(), &from, &received)) + if (socket.Receive(buffer.data(), buffer.size(), &from, &received)) { lua.PushBoolean(true); lua.PushString(from.ToString()); @@ -183,7 +183,7 @@ namespace Ndk return 1; }); - udpSocket.BindMethod("Send", [](Nz::LuaInstance& lua, Nz::UdpSocket& instance, std::size_t /*argumentCount*/) -> int + udpSocket.BindMethod("Send", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int { int argIndex = 2; Nz::String to = lua.Check(&argIndex); @@ -193,7 +193,7 @@ namespace Ndk std::size_t sent; bool ret; - if ((ret = instance.Send(Nz::IpAddress(to), buffer, bufferLength, &sent)) != true) + if ((ret = socket.Send(Nz::IpAddress(to), buffer, bufferLength, &sent)) != true) sent = 0; return lua.Push(std::make_pair(ret, sent)); @@ -206,108 +206,108 @@ namespace Ndk * * \param instance Lua instance that will interact with the Network classes */ - void LuaBinding_Network::Register(Nz::LuaInstance& instance) + void LuaBinding_Network::Register(Nz::LuaState& state) { // Classes - abstractSocket.Register(instance); - ipAddress.Register(instance); - udpSocket.Register(instance); + abstractSocket.Register(state); + ipAddress.Register(state); + udpSocket.Register(state); // Enums // Nz::NetProtocol static_assert(Nz::NetProtocol_Max + 1 == 4, "Nz::NetProtocol has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 4); + state.PushTable(0, 4); { - instance.PushField("Any", Nz::NetProtocol_Any); - instance.PushField("IPv4", Nz::NetProtocol_IPv4); - instance.PushField("IPv6", Nz::NetProtocol_IPv6); - instance.PushField("Unknown", Nz::NetProtocol_Unknown); + state.PushField("Any", Nz::NetProtocol_Any); + state.PushField("IPv4", Nz::NetProtocol_IPv4); + state.PushField("IPv6", Nz::NetProtocol_IPv6); + state.PushField("Unknown", Nz::NetProtocol_Unknown); } - instance.SetGlobal("NetProtocol"); + state.SetGlobal("NetProtocol"); // Nz::PacketPriority static_assert(Nz::PacketPriority_Max + 1 == 4, "Nz::PacketPriority has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 6); + state.PushTable(0, 6); { - instance.PushField("High", Nz::PacketPriority_High); - instance.PushField("Highest", Nz::PacketPriority_Highest); - instance.PushField("Immediate", Nz::PacketPriority_Immediate); - instance.PushField("Medium", Nz::PacketPriority_Medium); - instance.PushField("Low", Nz::PacketPriority_Low); - instance.PushField("Lowest", Nz::PacketPriority_Lowest); + state.PushField("High", Nz::PacketPriority_High); + state.PushField("Highest", Nz::PacketPriority_Highest); + state.PushField("Immediate", Nz::PacketPriority_Immediate); + state.PushField("Medium", Nz::PacketPriority_Medium); + state.PushField("Low", Nz::PacketPriority_Low); + state.PushField("Lowest", Nz::PacketPriority_Lowest); } - instance.SetGlobal("PacketPriority"); + state.SetGlobal("PacketPriority"); // Nz::PacketReliability static_assert(Nz::PacketReliability_Max + 1 == 3, "Nz::PacketReliability has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 3); + state.PushTable(0, 3); { - instance.PushField("Reliable", Nz::PacketReliability_Reliable); - instance.PushField("ReliableOrdered", Nz::PacketReliability_ReliableOrdered); - instance.PushField("Unreliable", Nz::PacketReliability_Unreliable); + state.PushField("Reliable", Nz::PacketReliability_Reliable); + state.PushField("ReliableOrdered", Nz::PacketReliability_ReliableOrdered); + state.PushField("Unreliable", Nz::PacketReliability_Unreliable); } - instance.SetGlobal("PacketReliability"); + state.SetGlobal("PacketReliability"); // Nz::ResolveError static_assert(Nz::ResolveError_Max + 1 == 9, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 9); + state.PushTable(0, 9); { - instance.PushField("Internal", Nz::ResolveError_Internal); - instance.PushField("ResourceError", Nz::ResolveError_ResourceError); - instance.PushField("NoError", Nz::ResolveError_NoError); - instance.PushField("NonRecoverable", Nz::ResolveError_NonRecoverable); - instance.PushField("NotFound", Nz::ResolveError_NotFound); - instance.PushField("NotInitialized", Nz::ResolveError_NotInitialized); - instance.PushField("ProtocolNotSupported", Nz::ResolveError_ProtocolNotSupported); - instance.PushField("TemporaryFailure", Nz::ResolveError_TemporaryFailure); - instance.PushField("Unknown", Nz::ResolveError_Unknown); + state.PushField("Internal", Nz::ResolveError_Internal); + state.PushField("ResourceError", Nz::ResolveError_ResourceError); + state.PushField("NoError", Nz::ResolveError_NoError); + state.PushField("NonRecoverable", Nz::ResolveError_NonRecoverable); + state.PushField("NotFound", Nz::ResolveError_NotFound); + state.PushField("NotInitialized", Nz::ResolveError_NotInitialized); + state.PushField("ProtocolNotSupported", Nz::ResolveError_ProtocolNotSupported); + state.PushField("TemporaryFailure", Nz::ResolveError_TemporaryFailure); + state.PushField("Unknown", Nz::ResolveError_Unknown); } - instance.SetGlobal("ResolveError"); + state.SetGlobal("ResolveError"); // Nz::SocketError static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 15); + state.PushTable(0, 15); { - instance.PushField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable); - instance.PushField("ConnectionClosed", Nz::SocketError_ConnectionClosed); - instance.PushField("ConnectionRefused", Nz::SocketError_ConnectionRefused); - instance.PushField("DatagramSize", Nz::SocketError_DatagramSize); - instance.PushField("Internal", Nz::SocketError_Internal); - instance.PushField("Packet", Nz::SocketError_Packet); - instance.PushField("NetworkError", Nz::SocketError_NetworkError); - instance.PushField("NoError", Nz::SocketError_NoError); - instance.PushField("NotInitialized", Nz::SocketError_NotInitialized); - instance.PushField("NotSupported", Nz::SocketError_NotSupported); - instance.PushField("ResolveError", Nz::SocketError_ResolveError); - instance.PushField("ResourceError", Nz::SocketError_ResourceError); - instance.PushField("TimedOut", Nz::SocketError_TimedOut); - instance.PushField("Unknown", Nz::SocketError_Unknown); - instance.PushField("UnreachableHost", Nz::SocketError_UnreachableHost); + state.PushField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable); + state.PushField("ConnectionClosed", Nz::SocketError_ConnectionClosed); + state.PushField("ConnectionRefused", Nz::SocketError_ConnectionRefused); + state.PushField("DatagramSize", Nz::SocketError_DatagramSize); + state.PushField("Internal", Nz::SocketError_Internal); + state.PushField("Packet", Nz::SocketError_Packet); + state.PushField("NetworkError", Nz::SocketError_NetworkError); + state.PushField("NoError", Nz::SocketError_NoError); + state.PushField("NotInitialized", Nz::SocketError_NotInitialized); + state.PushField("NotSupported", Nz::SocketError_NotSupported); + state.PushField("ResolveError", Nz::SocketError_ResolveError); + state.PushField("ResourceError", Nz::SocketError_ResourceError); + state.PushField("TimedOut", Nz::SocketError_TimedOut); + state.PushField("Unknown", Nz::SocketError_Unknown); + state.PushField("UnreachableHost", Nz::SocketError_UnreachableHost); } - instance.SetGlobal("SocketError"); + state.SetGlobal("SocketError"); // Nz::SocketState static_assert(Nz::SocketState_Max + 1 == 5, "Nz::SocketState has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 5); + state.PushTable(0, 5); { - instance.PushField("Bound", Nz::SocketState_Bound); - instance.PushField("Connecting", Nz::SocketState_Connecting); - instance.PushField("Connected", Nz::SocketState_Connected); - instance.PushField("NotConnected", Nz::SocketState_NotConnected); - instance.PushField("Resolving", Nz::SocketState_Resolving); + state.PushField("Bound", Nz::SocketState_Bound); + state.PushField("Connecting", Nz::SocketState_Connecting); + state.PushField("Connected", Nz::SocketState_Connected); + state.PushField("NotConnected", Nz::SocketState_NotConnected); + state.PushField("Resolving", Nz::SocketState_Resolving); } - instance.SetGlobal("SocketState"); + state.SetGlobal("SocketState"); // Nz::SocketType static_assert(Nz::SocketType_Max + 1 == 4, "Nz::SocketState has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, 4); + state.PushTable(0, 4); { - instance.PushField("Raw", Nz::SocketType_Raw); - instance.PushField("TCP", Nz::SocketType_TCP); - instance.PushField("UDP", Nz::SocketType_UDP); - instance.PushField("Unknown", Nz::SocketType_Unknown); + state.PushField("Raw", Nz::SocketType_Raw); + state.PushField("TCP", Nz::SocketType_TCP); + state.PushField("UDP", Nz::SocketType_UDP); + state.PushField("Unknown", Nz::SocketType_Unknown); } - instance.SetGlobal("SocketType"); + state.SetGlobal("SocketType"); } } diff --git a/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp b/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp index 00088ecb9..064d21cfe 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp @@ -27,7 +27,7 @@ namespace Ndk return reinterpret_cast(textureRef); //TODO: Make a ObjectRefCast }); - texture.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::TextureRef* instance, std::size_t /*argumentCount*/) + texture.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::TextureRef* instance, std::size_t /*argumentCount*/) { Nz::PlacementNew(instance, Nz::Texture::New()); return true; @@ -101,10 +101,10 @@ namespace Ndk * * \param instance Lua instance that will interact with the Renderer classes */ - void LuaBinding_Renderer::Register(Nz::LuaInstance& instance) + void LuaBinding_Renderer::Register(Nz::LuaState& state) { - texture.Register(instance); - textureLibrary.Register(instance); - textureManager.Register(instance); + texture.Register(state); + textureLibrary.Register(state); + textureManager.Register(state); } } diff --git a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp index 4d8408282..a4ae0b792 100644 --- a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp @@ -40,7 +40,7 @@ namespace Ndk application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled); #endif - application.BindMethod("AddWorld", [] (Nz::LuaInstance& lua, Application* instance, std::size_t /*argumentCount*/) -> int + application.BindMethod("AddWorld", [] (Nz::LuaState& lua, Application* instance, std::size_t /*argumentCount*/) -> int { lua.Push(instance->AddWorld().CreateHandle()); return 1; @@ -94,23 +94,23 @@ namespace Ndk entity.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents); entity.BindMethod("__tostring", &EntityHandle::ToString); - entity.BindMethod("AddComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int + entity.BindMethod("AddComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int { - LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(instance); + LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); - return bindingComponent->adder(instance, handle); + return bindingComponent->adder(state, handle); }); - entity.BindMethod("GetComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int + entity.BindMethod("GetComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int { - LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(instance); + LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); - return bindingComponent->getter(instance, handle->GetComponent(bindingComponent->index)); + return bindingComponent->getter(state, handle->GetComponent(bindingComponent->index)); }); - entity.BindMethod("RemoveComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int + entity.BindMethod("RemoveComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int { - LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(instance); + LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); handle->RemoveComponent(bindingComponent->index); return 0; @@ -129,7 +129,7 @@ namespace Ndk /*********************************** Ndk::VelocityComponent **********************************/ velocityComponent.Reset("VelocityComponent"); { - velocityComponent.SetGetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance) + velocityComponent.SetGetter([] (Nz::LuaState& lua, VelocityComponentHandle& instance) { std::size_t length; const char* member = lua.CheckString(2, &length); @@ -143,7 +143,7 @@ namespace Ndk return false; }); - velocityComponent.SetSetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance) + velocityComponent.SetSetter([] (Nz::LuaState& lua, VelocityComponentHandle& instance) { std::size_t length; const char* member = lua.CheckString(2, &length); @@ -193,7 +193,7 @@ namespace Ndk /*********************************** Ndk::GraphicsComponent **********************************/ graphicsComponent.Reset("GraphicsComponent"); { - graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent* instance, std::size_t argumentCount) -> int + graphicsComponent.BindMethod("Attach", [] (Nz::LuaState& lua, Ndk::GraphicsComponent* instance, std::size_t argumentCount) -> int { /* void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); @@ -267,19 +267,19 @@ namespace Ndk * * \param instance Lua instance that will interact with the SDK classes */ - void LuaBinding_SDK::Register(Nz::LuaInstance& instance) + void LuaBinding_SDK::Register(Nz::LuaState& state) { // Classes - application.Register(instance); - entity.Register(instance); - nodeComponent.Register(instance); - velocityComponent.Register(instance); - world.Register(instance); + application.Register(state); + entity.Register(state); + nodeComponent.Register(state); + velocityComponent.Register(state); + world.Register(state); #ifndef NDK_SERVER - cameraComponent.Register(instance); - console.Register(instance); - graphicsComponent.Register(instance); + cameraComponent.Register(state); + console.Register(state); + graphicsComponent.Register(state); #endif // Enums @@ -292,23 +292,23 @@ namespace Ndk * \param instance Lua instance that will interact with the component * \param argIndex Index of the component */ - LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaInstance& instance, int argIndex) + LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaState& state, int argIndex) { - switch (instance.GetType(argIndex)) + switch (state.GetType(argIndex)) { case Nz::LuaType_Number: { - ComponentIndex componentIndex = instance.Check(&argIndex); + ComponentIndex componentIndex = state.Check(&argIndex); if (componentIndex > m_componentBinding.size()) { - instance.Error("Invalid component index"); + state.Error("Invalid component index"); return nullptr; } ComponentBinding& binding = m_componentBinding[componentIndex]; if (binding.name.IsEmpty()) { - instance.Error("Invalid component index"); + state.Error("Invalid component index"); return nullptr; } @@ -317,11 +317,11 @@ namespace Ndk case Nz::LuaType_String: { - const char* key = instance.CheckString(argIndex); + const char* key = state.CheckString(argIndex); auto it = m_componentBindingByName.find(key); if (it == m_componentBindingByName.end()) { - instance.Error("Invalid component name"); + state.Error("Invalid component name"); return nullptr; } @@ -332,7 +332,7 @@ namespace Ndk break; } - instance.Error("Invalid component index at #" + Nz::String::Number(argIndex)); + state.Error("Invalid component index at #" + Nz::String::Number(argIndex)); return nullptr; } } diff --git a/SDK/src/NDK/Lua/LuaBinding_Utility.cpp b/SDK/src/NDK/Lua/LuaBinding_Utility.cpp index 173d6c3c5..6d7baf588 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Utility.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Utility.cpp @@ -29,7 +29,7 @@ namespace Ndk abstractImage.BindMethod("IsCompressed", &Nz::AbstractImage::IsCompressed); abstractImage.BindMethod("IsCubemap", &Nz::AbstractImage::IsCubemap); - abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaInstance& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int + abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaState& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 1U); switch (argCount) @@ -50,7 +50,7 @@ namespace Ndk return 0; }); - abstractImage.BindMethod("Update", [] (Nz::LuaInstance& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int + abstractImage.BindMethod("Update", [] (Nz::LuaState& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 6U); int argIndex = 2; @@ -100,7 +100,7 @@ namespace Ndk /*********************************** Nz::Font **********************************/ font.Reset("Font"); { - font.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::FontRef* instance, std::size_t /*argumentCount*/) + font.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::FontRef* instance, std::size_t /*argumentCount*/) { Nz::PlacementNew(instance, Nz::Font::New()); return true; @@ -112,7 +112,7 @@ namespace Ndk font.BindMethod("Destroy", &Nz::Font::Destroy); - font.BindMethod("GetCachedGlyphCount", [] (Nz::LuaInstance& lua, Nz::FontRef& instance, std::size_t argumentCount) -> int + font.BindMethod("GetCachedGlyphCount", [] (Nz::LuaState& lua, Nz::FontRef& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 2U); @@ -216,29 +216,29 @@ namespace Ndk node.BindMethod("SetPosition", (void(Nz::Node::*)(const Nz::Vector3f&, Nz::CoordSys)) &Nz::Node::SetPosition, Nz::CoordSys_Local); node.BindMethod("SetRotation", (void(Nz::Node::*)(const Nz::Quaternionf&, Nz::CoordSys)) &Nz::Node::SetRotation, Nz::CoordSys_Local); - node.BindMethod("Move", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int + node.BindMethod("Move", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int { int argIndex = 2; Nz::Vector3f offset = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - instance.Move(offset, coordSys); + node.Move(offset, coordSys); return 0; }); - node.BindMethod("Rotate", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int + node.BindMethod("Rotate", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int { int argIndex = 2; Nz::Quaternionf rotation = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - instance.Rotate(rotation, coordSys); + node.Rotate(rotation, coordSys); return 0; }); - node.BindMethod("Scale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int + node.BindMethod("Scale", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -248,15 +248,15 @@ namespace Ndk case 1: { if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - instance.Scale(lua.Check(&argIndex)); + node.Scale(lua.Check(&argIndex)); else - instance.Scale(lua.Check(&argIndex)); + node.Scale(lua.Check(&argIndex)); return 0; } case 3: - instance.Scale(lua.Check(&argIndex)); + node.Scale(lua.Check(&argIndex)); return 0; } @@ -264,7 +264,7 @@ namespace Ndk return 0; }); - node.BindMethod("SetScale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int + node.BindMethod("SetScale", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -278,10 +278,10 @@ namespace Ndk { float scale = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - instance.SetScale(scale, coordSys); + node.SetScale(scale, coordSys); } else - instance.SetScale(lua.Check(&argIndex)); + node.SetScale(lua.Check(&argIndex)); return 0; } @@ -292,7 +292,7 @@ namespace Ndk Nz::Vector3f scale = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - instance.SetScale(scale, coordSys); + node.SetScale(scale, coordSys); return 0; } } @@ -301,7 +301,7 @@ namespace Ndk return 0; }); - node.BindMethod("SetInitialScale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int + node.BindMethod("SetInitialScale", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -311,16 +311,16 @@ namespace Ndk case 1: { if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - instance.SetInitialScale(lua.Check(&argIndex)); + node.SetInitialScale(lua.Check(&argIndex)); else - instance.SetInitialScale(lua.Check(&argIndex)); + node.SetInitialScale(lua.Check(&argIndex)); return 0; } case 2: case 3: - instance.SetInitialScale(lua.Check(&argIndex)); + node.SetInitialScale(lua.Check(&argIndex)); return 0; } @@ -335,112 +335,110 @@ namespace Ndk * * \param instance Lua instance that will interact with the Utility classes */ - void LuaBinding_Utility::Register(Nz::LuaInstance& instance) + void LuaBinding_Utility::Register(Nz::LuaState& state) { - abstractImage.Register(instance); - font.Register(instance); - keyboard.Register(instance); - node.Register(instance); + abstractImage.Register(state); + font.Register(state); + keyboard.Register(state); + node.Register(state); - keyboard.PushGlobalTable(instance); + keyboard.PushGlobalTable(state); { static_assert(Nz::Keyboard::Count == 121, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding"); - instance.PushField("Undefined", Nz::Keyboard::Undefined); + state.PushField("Undefined", Nz::Keyboard::Undefined); // A-Z for (std::size_t i = 0; i < 26; ++i) - instance.PushField(Nz::String('A' + char(i)), Nz::Keyboard::A + i); + state.PushField(Nz::String('A' + char(i)), Nz::Keyboard::A + i); // Numerical for (std::size_t i = 0; i < 10; ++i) { - instance.PushField("Num" + Nz::String::Number(i), Nz::Keyboard::Num0 + i); - instance.PushField("Numpad" + Nz::String::Number(i), Nz::Keyboard::Numpad0 + i); + state.PushField("Num" + Nz::String::Number(i), Nz::Keyboard::Num0 + i); + state.PushField("Numpad" + Nz::String::Number(i), Nz::Keyboard::Numpad0 + i); } // F1-F15 for (std::size_t i = 0; i < 15; ++i) - instance.PushField('F' + Nz::String::Number(i+1), Nz::Keyboard::F1 + i); + state.PushField('F' + Nz::String::Number(i+1), Nz::Keyboard::F1 + i); // And all the others... - instance.PushField("Down", Nz::Keyboard::Down); - instance.PushField("Left", Nz::Keyboard::Left); - instance.PushField("Right", Nz::Keyboard::Right); - instance.PushField("Up", Nz::Keyboard::Up); + state.PushField("Down", Nz::Keyboard::Down); + state.PushField("Left", Nz::Keyboard::Left); + state.PushField("Right", Nz::Keyboard::Right); + state.PushField("Up", Nz::Keyboard::Up); - instance.PushField("Add", Nz::Keyboard::Add); - instance.PushField("Decimal", Nz::Keyboard::Decimal); - instance.PushField("Divide", Nz::Keyboard::Divide); - instance.PushField("Multiply", Nz::Keyboard::Multiply); - instance.PushField("Subtract", Nz::Keyboard::Subtract); + state.PushField("Add", Nz::Keyboard::Add); + state.PushField("Decimal", Nz::Keyboard::Decimal); + state.PushField("Divide", Nz::Keyboard::Divide); + state.PushField("Multiply", Nz::Keyboard::Multiply); + state.PushField("Subtract", Nz::Keyboard::Subtract); - instance.PushField("Backslash", Nz::Keyboard::Backslash); - instance.PushField("Backspace", Nz::Keyboard::Backspace); - instance.PushField("Clear", Nz::Keyboard::Clear); - instance.PushField("Comma", Nz::Keyboard::Comma); - instance.PushField("Dash", Nz::Keyboard::Dash); - instance.PushField("Delete", Nz::Keyboard::Delete); - instance.PushField("End", Nz::Keyboard::End); - instance.PushField("Equal", Nz::Keyboard::Equal); - instance.PushField("Escape", Nz::Keyboard::Escape); - instance.PushField("Home", Nz::Keyboard::Home); - instance.PushField("Insert", Nz::Keyboard::Insert); - instance.PushField("LAlt", Nz::Keyboard::LAlt); - instance.PushField("LBracket", Nz::Keyboard::LBracket); - instance.PushField("LControl", Nz::Keyboard::LControl); - instance.PushField("LShift", Nz::Keyboard::LShift); - instance.PushField("LSystem", Nz::Keyboard::LSystem); - instance.PushField("PageDown", Nz::Keyboard::PageDown); - instance.PushField("PageUp", Nz::Keyboard::PageUp); - instance.PushField("Pause", Nz::Keyboard::Pause); - instance.PushField("Period", Nz::Keyboard::Period); - instance.PushField("Print", Nz::Keyboard::Print); - instance.PushField("PrintScreen", Nz::Keyboard::PrintScreen); - instance.PushField("Quote", Nz::Keyboard::Quote); - instance.PushField("RAlt", Nz::Keyboard::RAlt); - instance.PushField("RBracket", Nz::Keyboard::RBracket); - instance.PushField("RControl", Nz::Keyboard::RControl); - instance.PushField("Return", Nz::Keyboard::Return); - instance.PushField("RShift", Nz::Keyboard::RShift); - instance.PushField("RSystem", Nz::Keyboard::RSystem); - instance.PushField("Semicolon", Nz::Keyboard::Semicolon); - instance.PushField("Slash", Nz::Keyboard::Slash); - instance.PushField("Space", Nz::Keyboard::Space); - instance.PushField("Tab", Nz::Keyboard::Tab); - instance.PushField("Tilde", Nz::Keyboard::Tilde); - instance.PushField("Browser_Back", Nz::Keyboard::Browser_Back); - instance.PushField("Browser_Favorites", Nz::Keyboard::Browser_Favorites); - instance.PushField("Browser_Forward", Nz::Keyboard::Browser_Forward); - instance.PushField("Browser_Home", Nz::Keyboard::Browser_Home); - instance.PushField("Browser_Refresh", Nz::Keyboard::Browser_Refresh); - instance.PushField("Browser_Search", Nz::Keyboard::Browser_Search); - instance.PushField("Browser_Stop", Nz::Keyboard::Browser_Stop); - instance.PushField("Media_Next", Nz::Keyboard::Media_Next); - instance.PushField("Media_Play", Nz::Keyboard::Media_Play); - instance.PushField("Media_Previous", Nz::Keyboard::Media_Previous); - instance.PushField("Media_Stop", Nz::Keyboard::Media_Stop); - instance.PushField("Volume_Down", Nz::Keyboard::Volume_Down); - instance.PushField("Volume_Mute", Nz::Keyboard::Volume_Mute); - instance.PushField("Volume_Up", Nz::Keyboard::Volume_Up); - instance.PushField("CapsLock", Nz::Keyboard::CapsLock); - instance.PushField("NumLock", Nz::Keyboard::NumLock); - instance.PushField("ScrollLock", Nz::Keyboard::ScrollLock); + state.PushField("Backslash", Nz::Keyboard::Backslash); + state.PushField("Backspace", Nz::Keyboard::Backspace); + state.PushField("Clear", Nz::Keyboard::Clear); + state.PushField("Comma", Nz::Keyboard::Comma); + state.PushField("Dash", Nz::Keyboard::Dash); + state.PushField("Delete", Nz::Keyboard::Delete); + state.PushField("End", Nz::Keyboard::End); + state.PushField("Equal", Nz::Keyboard::Equal); + state.PushField("Escape", Nz::Keyboard::Escape); + state.PushField("Home", Nz::Keyboard::Home); + state.PushField("Insert", Nz::Keyboard::Insert); + state.PushField("LAlt", Nz::Keyboard::LAlt); + state.PushField("LBracket", Nz::Keyboard::LBracket); + state.PushField("LControl", Nz::Keyboard::LControl); + state.PushField("LShift", Nz::Keyboard::LShift); + state.PushField("LSystem", Nz::Keyboard::LSystem); + state.PushField("PageDown", Nz::Keyboard::PageDown); + state.PushField("PageUp", Nz::Keyboard::PageUp); + state.PushField("Pause", Nz::Keyboard::Pause); + state.PushField("Period", Nz::Keyboard::Period); + state.PushField("Print", Nz::Keyboard::Print); + state.PushField("PrintScreen", Nz::Keyboard::PrintScreen); + state.PushField("Quote", Nz::Keyboard::Quote); + state.PushField("RAlt", Nz::Keyboard::RAlt); + state.PushField("RBracket", Nz::Keyboard::RBracket); + state.PushField("RControl", Nz::Keyboard::RControl); + state.PushField("Return", Nz::Keyboard::Return); + state.PushField("RShift", Nz::Keyboard::RShift); + state.PushField("RSystem", Nz::Keyboard::RSystem); + state.PushField("Semicolon", Nz::Keyboard::Semicolon); + state.PushField("Slash", Nz::Keyboard::Slash); + state.PushField("Space", Nz::Keyboard::Space); + state.PushField("Tab", Nz::Keyboard::Tab); + state.PushField("Tilde", Nz::Keyboard::Tilde); + state.PushField("Browser_Back", Nz::Keyboard::Browser_Back); + state.PushField("Browser_Favorites", Nz::Keyboard::Browser_Favorites); + state.PushField("Browser_Forward", Nz::Keyboard::Browser_Forward); + state.PushField("Browser_Home", Nz::Keyboard::Browser_Home); + state.PushField("Browser_Refresh", Nz::Keyboard::Browser_Refresh); + state.PushField("Browser_Search", Nz::Keyboard::Browser_Search); + state.PushField("Browser_Stop", Nz::Keyboard::Browser_Stop); + state.PushField("Media_Next", Nz::Keyboard::Media_Next); + state.PushField("Media_Play", Nz::Keyboard::Media_Play); + state.PushField("Media_Previous", Nz::Keyboard::Media_Previous); + state.PushField("Media_Stop", Nz::Keyboard::Media_Stop); + state.PushField("Volume_Down", Nz::Keyboard::Volume_Down); + state.PushField("Volume_Mute", Nz::Keyboard::Volume_Mute); + state.PushField("Volume_Up", Nz::Keyboard::Volume_Up); + state.PushField("CapsLock", Nz::Keyboard::CapsLock); + state.PushField("NumLock", Nz::Keyboard::NumLock); + state.PushField("ScrollLock", Nz::Keyboard::ScrollLock); } - instance.Pop(); + state.Pop(); static_assert(Nz::WindowStyle_Max + 1 == 6, "Nz::WindowStyle has been updated but change was not reflected to Lua binding"); - instance.PushTable(0, Nz::WindowStyle_Max + 1); + state.PushTable(0, Nz::WindowStyle_Max + 1); { - instance.PushField("None", Nz::WindowStyle_None); - instance.PushField("Fullscreen", Nz::WindowStyle_Fullscreen); - instance.PushField("Closable", Nz::WindowStyle_Closable); - instance.PushField("Resizable", Nz::WindowStyle_Resizable); - instance.PushField("Titlebar", Nz::WindowStyle_Titlebar); - instance.PushField("Threaded", Nz::WindowStyle_Threaded); + state.PushField("None", Nz::WindowStyle_None); + state.PushField("Fullscreen", Nz::WindowStyle_Fullscreen); + state.PushField("Closable", Nz::WindowStyle_Closable); + state.PushField("Resizable", Nz::WindowStyle_Resizable); + state.PushField("Titlebar", Nz::WindowStyle_Titlebar); + state.PushField("Threaded", Nz::WindowStyle_Threaded); } - instance.SetGlobal("WindowStyle"); - - + state.SetGlobal("WindowStyle"); } } diff --git a/SDK/src/NDK/LuaAPI.cpp b/SDK/src/NDK/LuaAPI.cpp index a28fbb05f..3a82d2130 100644 --- a/SDK/src/NDK/LuaAPI.cpp +++ b/SDK/src/NDK/LuaAPI.cpp @@ -44,10 +44,10 @@ namespace Ndk * \param instance Lua instance that will interact with the engine & SDK */ - void LuaAPI::RegisterClasses(Nz::LuaInstance& instance) + void LuaAPI::RegisterClasses(Nz::LuaState& state) { Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true); - GetBinding()->RegisterClasses(instance); + GetBinding()->RegisterClasses(state); } /*! diff --git a/include/Nazara/Lua/LuaClass.hpp b/include/Nazara/Lua/LuaClass.hpp index 13dcbb828..451f91c08 100644 --- a/include/Nazara/Lua/LuaClass.hpp +++ b/include/Nazara/Lua/LuaClass.hpp @@ -26,13 +26,13 @@ namespace Nz friend class LuaClass; public: - using ClassFunc = std::function; - using ClassIndexFunc = std::function; - using ConstructorFunc = std::function; + using ClassFunc = std::function; + using ClassIndexFunc = std::function; + using ConstructorFunc = std::function; template using ConvertToParent = std::function; - using FinalizerFunc = std::function; - using StaticIndexFunc = std::function; - using StaticFunc = std::function; + using FinalizerFunc = std::function; + using StaticIndexFunc = std::function; + using StaticFunc = std::function; LuaClass() = default; LuaClass(const String& name); @@ -54,9 +54,9 @@ namespace Nz void Reset(); void Reset(const String& name); - void Register(LuaInstance& lua); + void Register(LuaState& state); - void PushGlobalTable(LuaInstance& lua); + void PushGlobalTable(LuaState& state); void SetConstructor(ConstructorFunc constructor); void SetFinalizer(FinalizerFunc finalizer); @@ -69,18 +69,18 @@ namespace Nz template friend struct LuaClassImplFinalizerSetupProxy; - void PushClassInfo(LuaInstance& lua); - void SetupConstructor(LuaInstance& lua); - void SetupDefaultToString(LuaInstance& lua); - void SetupFinalizer(LuaInstance& lua); - void SetupGetter(LuaInstance& lua, LuaCFunction proxy); - void SetupGlobalTable(LuaInstance& lua); - void SetupMetatable(LuaInstance& lua); - void SetupMethod(LuaInstance& lua, LuaCFunction proxy, const String& name, std::size_t methodIndex); - void SetupSetter(LuaInstance& lua, LuaCFunction proxy); + void PushClassInfo(LuaState& state); + void SetupConstructor(LuaState& state); + void SetupDefaultToString(LuaState& state); + void SetupFinalizer(LuaState& state); + void SetupGetter(LuaState& state, LuaCFunction proxy); + void SetupGlobalTable(LuaState& state); + void SetupMetatable(LuaState& state); + void SetupMethod(LuaState& state, LuaCFunction proxy, const String& name, std::size_t methodIndex); + void SetupSetter(LuaState& state, LuaCFunction proxy); - using ParentFunc = std::function; - using InstanceGetter = std::function; + using ParentFunc = std::function; + using InstanceGetter = std::function; struct ClassInfo { @@ -98,17 +98,17 @@ namespace Nz int globalTableRef = -1; }; - static int ConstructorProxy(lua_State* state); - static int FinalizerProxy(lua_State* state); - static int InfoDestructor(lua_State* state); - static void Get(const std::shared_ptr& info, LuaInstance& lua, T* instance); - static int GetterProxy(lua_State* state); - static int MethodProxy(lua_State* state); - static int SetterProxy(lua_State* state); - static int StaticGetterProxy(lua_State* state); - static int StaticMethodProxy(lua_State* state); - static int StaticSetterProxy(lua_State* state); - static int ToStringProxy(lua_State* state); + static int ConstructorProxy(lua_State* internalState); + static int FinalizerProxy(lua_State* internalState); + static int InfoDestructor(lua_State* internalState); + static void Get(const std::shared_ptr& info, LuaState& state, T* instance); + static int GetterProxy(lua_State* internalState); + static int MethodProxy(lua_State* internalState); + static int SetterProxy(lua_State* internalState); + static int StaticGetterProxy(lua_State* internalState); + static int StaticMethodProxy(lua_State* internalState); + static int StaticSetterProxy(lua_State* internalState); + static int ToStringProxy(lua_State* internalState); std::map m_methods; std::map m_staticMethods; diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl index 94c1f8125..40b7374bc 100644 --- a/include/Nazara/Lua/LuaClass.inl +++ b/include/Nazara/Lua/LuaClass.inl @@ -19,9 +19,9 @@ namespace Nz template inline void LuaClass::BindDefaultConstructor() { - SetConstructor([] (Nz::LuaInstance& lua, T* instance, std::size_t argumentCount) + SetConstructor([] (Nz::LuaState& state, T* instance, std::size_t argumentCount) { - NazaraUnused(lua); + NazaraUnused(state); NazaraUnused(argumentCount); PlacementNew(instance); @@ -47,14 +47,14 @@ namespace Nz std::shared_ptr::ClassInfo>& parentInfo = parent.m_info; - parentInfo->instanceGetters[m_info->name] = [info = m_info, convertFunc] (LuaInstance& lua) -> P* + parentInfo->instanceGetters[m_info->name] = [info = m_info, convertFunc] (LuaState& state) -> P* { - return convertFunc(static_cast(lua.CheckUserdata(1, info->name))); + return convertFunc(static_cast(state.CheckUserdata(1, info->name))); }; - m_info->parentGetters.emplace_back([parentInfo, convertFunc] (LuaInstance& lua, T* instance) + m_info->parentGetters.emplace_back([parentInfo, convertFunc] (LuaState& state, T* instance) { - LuaClass

::Get(parentInfo, lua, convertFunc(instance)); + LuaClass

::Get(parentInfo, state, convertFunc(instance)); }); } @@ -71,30 +71,30 @@ namespace Nz m_info = std::make_shared(); m_info->name = name; - m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& instance) + m_info->instanceGetters[m_info->name] = [info = m_info] (LuaState& state) { - return static_cast(instance.CheckUserdata(1, info->name)); + return static_cast(state.CheckUserdata(1, info->name)); }; } template - void LuaClass::Register(LuaInstance& lua) + void LuaClass::Register(LuaState& state) { - PushClassInfo(lua); + PushClassInfo(state); - // Let's create the metatable which will be associated with every instance. - SetupMetatable(lua); + // Let's create the metatable which will be associated with every state. + SetupMetatable(state); if (m_info->constructor || m_info->staticGetter || m_info->staticSetter || !m_staticMethods.empty()) - SetupGlobalTable(lua); + SetupGlobalTable(state); - lua.Pop(); // Pop our ClassInfo, which is now referenced by all our functions + state.Pop(); // Pop our ClassInfo, which is now referenced by all our functions } template - void LuaClass::PushGlobalTable(LuaInstance& lua) + void LuaClass::PushGlobalTable(LuaState& state) { - lua.PushReference(m_info->globalTableRef); + state.PushReference(m_info->globalTableRef); } template @@ -127,11 +127,11 @@ namespace Nz { typename LuaImplMethodProxy::template Impl handler(std::forward(defArgs)...); - BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int + BindMethod(name, [func, handler] (LuaState& state, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArguments(lua); + handler.ProcessArguments(state); - return handler.Invoke(lua, object, func); + return handler.Invoke(state, object, func); }); } @@ -141,11 +141,11 @@ namespace Nz { typename LuaImplMethodProxy::template Impl handler(std::forward(defArgs)...); - BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int + BindMethod(name, [func, handler] (LuaState& state, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArguments(lua); + handler.ProcessArguments(state); - return handler.Invoke(lua, object, func); + return handler.Invoke(state, object, func); }); } @@ -155,11 +155,11 @@ namespace Nz { typename LuaImplMethodProxy::template Impl handler(std::forward(defArgs)...); - BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int + BindMethod(name, [func, handler] (LuaState& state, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArguments(lua); + handler.ProcessArguments(state); - return handler.Invoke(lua, object, func); + return handler.Invoke(state, object, func); }); } @@ -169,11 +169,11 @@ namespace Nz { typename LuaImplMethodProxy::template Impl handler(std::forward(defArgs)...); - BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int + BindMethod(name, [func, handler] (LuaState& state, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArguments(lua); + handler.ProcessArguments(state); - return handler.Invoke(lua, object, func); + return handler.Invoke(state, object, func); }); } @@ -201,11 +201,11 @@ namespace Nz { typename LuaImplFunctionProxy::template Impl handler(std::forward(defArgs)...); - BindStaticMethod(name, [func, handler] (LuaInstance& lua) -> int + BindStaticMethod(name, [func, handler] (LuaState& state) -> int { - handler.ProcessArguments(lua); + handler.ProcessArguments(state); - return handler.Invoke(lua, func); + return handler.Invoke(state, func); }); } @@ -216,37 +216,37 @@ namespace Nz } template - void LuaClass::PushClassInfo(LuaInstance& lua) + void LuaClass::PushClassInfo(LuaState& state) { // Our ClassInfo has to outlive the LuaClass, because we don't want to force the user to keep the LuaClass alive // To do that, each Registration creates a tiny shared_ptr wrapper whose life is directly managed by Lua. // This shared_ptr object gets pushed as a up-value for every proxy function set in the metatable. // This way, there is no way our ClassInfo gets freed before any instance and the global class gets destroyed. - std::shared_ptr* info = static_cast*>(lua.PushUserdata(sizeof(std::shared_ptr))); + std::shared_ptr* info = static_cast*>(state.PushUserdata(sizeof(std::shared_ptr))); PlacementNew(info, m_info); // Setup a tiny metatable to let Lua know how to destroy our ClassInfo - lua.PushTable(0, 1); - lua.PushLightUserdata(info); - lua.PushCFunction(InfoDestructor, 1); - lua.SetField("__gc"); - lua.SetMetatable(-2); + state.PushTable(0, 1); + state.PushLightUserdata(info); + state.PushCFunction(InfoDestructor, 1); + state.SetField("__gc"); + state.SetMetatable(-2); } template - void LuaClass::SetupConstructor(LuaInstance& lua) + void LuaClass::SetupConstructor(LuaState& state) { - lua.PushValue(1); // ClassInfo - lua.PushCFunction(ConstructorProxy, 1); - lua.SetField("__call"); // ClassMeta.__call = ConstructorProxy + state.PushValue(1); // ClassInfo + state.PushCFunction(ConstructorProxy, 1); + state.SetField("__call"); // ClassMeta.__call = ConstructorProxy } template - void LuaClass::SetupDefaultToString(LuaInstance& lua) + void LuaClass::SetupDefaultToString(LuaState& state) { - lua.PushValue(1); // shared_ptr on UserData - lua.PushCFunction(ToStringProxy, 1); - lua.SetField("__tostring"); + state.PushValue(1); // shared_ptr on UserData + state.PushCFunction(ToStringProxy, 1); + state.SetField("__tostring"); } template @@ -255,61 +255,61 @@ namespace Nz template struct LuaClassImplFinalizerSetupProxy { - static void Setup(LuaInstance& lua) + static void Setup(LuaState& state) { - lua.PushValue(1); // ClassInfo - lua.PushCFunction(LuaClass::FinalizerProxy, 1); - lua.SetField("__gc"); + state.PushValue(1); // ClassInfo + state.PushCFunction(LuaClass::FinalizerProxy, 1); + state.SetField("__gc"); } }; template struct LuaClassImplFinalizerSetupProxy { - static void Setup(LuaInstance&) + static void Setup(LuaState&) { } }; template - void LuaClass::SetupFinalizer(LuaInstance& lua) + void LuaClass::SetupFinalizer(LuaState& state) { - LuaClassImplFinalizerSetupProxy::value>::Setup(lua); + LuaClassImplFinalizerSetupProxy::value>::Setup(state); } template - void LuaClass::SetupGetter(LuaInstance& lua, LuaCFunction proxy) + void LuaClass::SetupGetter(LuaState& state, LuaCFunction proxy) { - lua.PushValue(1); // ClassInfo - lua.PushValue(-2); // Metatable - lua.PushCFunction(proxy, 2); + state.PushValue(1); // ClassInfo + state.PushValue(-2); // Metatable + state.PushCFunction(proxy, 2); - lua.SetField("__index"); // Getter + state.SetField("__index"); // Getter } template - void LuaClass::SetupGlobalTable(LuaInstance& lua) + void LuaClass::SetupGlobalTable(LuaState& state) { // Create the global table - lua.PushTable(); // Class = {} + state.PushTable(); // Class = {} // Create a metatable which will be used for our global table - lua.PushTable(); // ClassMeta = {} + state.PushTable(); // ClassMeta = {} if (m_info->constructor) - SetupConstructor(lua); + SetupConstructor(state); if (m_info->staticGetter) - SetupGetter(lua, StaticGetterProxy); + SetupGetter(state, StaticGetterProxy); else { // Optimize by assigning the metatable instead of a search function - lua.PushValue(-1); // Metatable - lua.SetField("__index"); + state.PushValue(-1); // Metatable + state.SetField("__index"); } if (m_info->staticSetter) - SetupSetter(lua, StaticSetterProxy); + SetupSetter(state, StaticSetterProxy); m_info->staticMethods.reserve(m_staticMethods.size()); for (auto& pair : m_staticMethods) @@ -317,41 +317,41 @@ namespace Nz std::size_t methodIndex = m_info->staticMethods.size(); m_info->staticMethods.push_back(pair.second); - SetupMethod(lua, StaticMethodProxy, pair.first, methodIndex); + SetupMethod(state, StaticMethodProxy, pair.first, methodIndex); } - lua.SetMetatable(-2); // setmetatable(Class, ClassMeta), pops ClassMeta + state.SetMetatable(-2); // setmetatable(Class, ClassMeta), pops ClassMeta - lua.PushValue(-1); // As CreateReference() pops the table, push a copy - m_info->globalTableRef = lua.CreateReference(); + state.PushValue(-1); // As CreateReference() pops the table, push a copy + m_info->globalTableRef = state.CreateReference(); - lua.SetGlobal(m_info->name); // _G["Class"] = Class + state.SetGlobal(m_info->name); // _G["Class"] = Class } template - void LuaClass::SetupMetatable(LuaInstance& lua) + void LuaClass::SetupMetatable(LuaState& state) { - if (!lua.NewMetatable(m_info->name)) + if (!state.NewMetatable(m_info->name)) NazaraWarning("Class \"" + m_info->name + "\" already registred in this instance"); { - SetupFinalizer(lua); + SetupFinalizer(state); if (m_info->getter || !m_info->parentGetters.empty()) - SetupGetter(lua, GetterProxy); + SetupGetter(state, GetterProxy); else { // Optimize by assigning the metatable instead of a search function // This is only possible if we have no custom getter nor parent - lua.PushValue(-1); // Metatable - lua.SetField("__index"); + state.PushValue(-1); // Metatable + state.SetField("__index"); } if (m_info->setter) - SetupSetter(lua, SetterProxy); + SetupSetter(state, SetterProxy); // In case a __tostring method is missing, add a default implementation returning the class name if (m_methods.find("__tostring") == m_methods.end()) - SetupDefaultToString(lua); + SetupDefaultToString(state); m_info->methods.reserve(m_methods.size()); for (auto& pair : m_methods) @@ -359,80 +359,80 @@ namespace Nz std::size_t methodIndex = m_info->methods.size(); m_info->methods.push_back(pair.second); - SetupMethod(lua, MethodProxy, pair.first, methodIndex); + SetupMethod(state, MethodProxy, pair.first, methodIndex); } } - lua.Pop(); //< Pops the metatable, it won't be collected before it's referenced by the Lua registry. + state.Pop(); //< Pops the metatable, it won't be collected before it's referenced by the Lua registry. } template - void LuaClass::SetupMethod(LuaInstance& lua, LuaCFunction proxy, const String& name, std::size_t methodIndex) + void LuaClass::SetupMethod(LuaState& state, LuaCFunction proxy, const String& name, std::size_t methodIndex) { - lua.PushValue(1); // ClassInfo - lua.PushInteger(methodIndex); - lua.PushCFunction(proxy, 2); + state.PushValue(1); // ClassInfo + state.PushInteger(methodIndex); + state.PushCFunction(proxy, 2); - lua.SetField(name); // Method name + state.SetField(name); // Method name } template - void LuaClass::SetupSetter(LuaInstance& lua, LuaCFunction proxy) + void LuaClass::SetupSetter(LuaState& state, LuaCFunction proxy) { - lua.PushValue(1); // ClassInfo - lua.PushCFunction(proxy, 1); + state.PushValue(1); // ClassInfo + state.PushCFunction(proxy, 1); - lua.SetField("__newindex"); // Setter + state.SetField("__newindex"); // Setter } template - int LuaClass::ConstructorProxy(lua_State* state) + int LuaClass::ConstructorProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); const ConstructorFunc& constructor = info->constructor; - lua.Remove(1); // On enlève l'argument "table" du stack + state.Remove(1); // On enlève l'argument "table" du stack - std::size_t argCount = lua.GetStackTop(); + std::size_t argCount = state.GetStackTop(); - T* instance = static_cast(lua.PushUserdata(sizeof(T))); + T* instance = static_cast(state.PushUserdata(sizeof(T))); - if (!constructor(lua, instance, argCount)) + if (!constructor(state, instance, argCount)) { - lua.Error("Constructor failed"); + state.Error("Constructor failed"); return 0; // Normalement jamais exécuté (l'erreur provoquant une exception) } - lua.SetMetatable(info->name); + state.SetMetatable(info->name); return 1; } template - int LuaClass::FinalizerProxy(lua_State* state) + int LuaClass::FinalizerProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); const FinalizerFunc& finalizer = info->finalizer; - T* instance = static_cast(lua.CheckUserdata(1, info->name)); - lua.Remove(1); //< Remove the instance from the Lua stack + T* instance = static_cast(state.CheckUserdata(1, info->name)); + state.Remove(1); //< Remove the instance from the Lua stack - if (!finalizer || finalizer(lua, *instance)) + if (!finalizer || finalizer(state, *instance)) instance->~T(); return 0; } template - int LuaClass::InfoDestructor(lua_State* state) + int LuaClass::InfoDestructor(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); - lua.DestroyReference(info->globalTableRef); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); + state.DestroyReference(info->globalTableRef); using namespace std; // Obligatoire pour le destructeur info.~shared_ptr(); // Si vous voyez une autre façon de faire, je suis preneur @@ -441,27 +441,27 @@ namespace Nz } template - void LuaClass::Get(const std::shared_ptr& info, LuaInstance& lua, T* instance) + void LuaClass::Get(const std::shared_ptr& info, LuaState& state, T* instance) { const ClassIndexFunc& getter = info->getter; - if (!getter || !getter(lua, *instance)) + if (!getter || !getter(state, *instance)) { // Query from the metatable - lua.GetMetatable(info->name); //< Metatable - lua.PushValue(2); //< Field - lua.GetTable(); // Metatable[Field] + state.GetMetatable(info->name); //< Metatable + state.PushValue(2); //< Field + state.GetTable(); // Metatable[Field] - lua.Remove(-2); // Remove Metatable + state.Remove(-2); // Remove Metatable - if (!lua.IsValid(-1)) + if (!state.IsValid(-1)) { for (const ParentFunc& parentGetter : info->parentGetters) { - lua.Pop(); //< Pop the last nil value + state.Pop(); //< Pop the last nil value - parentGetter(lua, instance); - if (lua.IsValid(-1)) + parentGetter(state, instance); + if (state.IsValid(-1)) return; } } @@ -469,131 +469,131 @@ namespace Nz } template - int LuaClass::GetterProxy(lua_State* state) + int LuaClass::GetterProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - T* instance = static_cast(lua.CheckUserdata(1, info->name)); + T* instance = static_cast(state.CheckUserdata(1, info->name)); - Get(info, lua, instance); + Get(info, state, instance); return 1; } template - int LuaClass::MethodProxy(lua_State* state) + int LuaClass::MethodProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); T* instance = nullptr; - if (lua.GetMetatable(1)) + if (state.GetMetatable(1)) { - LuaType type = lua.GetField("__name"); + LuaType type = state.GetField("__name"); if (type == LuaType_String) { - String name = lua.ToString(-1); + String name = state.ToString(-1); auto it = info->instanceGetters.find(name); if (it != info->instanceGetters.end()) - instance = it->second(lua); + instance = it->second(state); } - lua.Pop(2); + state.Pop(2); } if (!instance) { - lua.Error("Method cannot be called without an object"); + state.Error("Method cannot be called without an object"); return 0; } - std::size_t argCount = lua.GetStackTop() - 1U; + std::size_t argCount = state.GetStackTop() - 1U; - unsigned int index = static_cast(lua.ToInteger(lua.GetIndexOfUpValue(2))); + unsigned int index = static_cast(state.ToInteger(state.GetIndexOfUpValue(2))); const ClassFunc& method = info->methods[index]; - return method(lua, *instance, argCount); + return method(state, *instance, argCount); } template - int LuaClass::SetterProxy(lua_State* state) + int LuaClass::SetterProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); const ClassIndexFunc& setter = info->setter; - T& instance = *static_cast(lua.CheckUserdata(1, info->name)); + T& instance = *static_cast(state.CheckUserdata(1, info->name)); - if (!setter(lua, instance)) + if (!setter(state, instance)) { std::size_t length; - const char* str = lua.ToString(2, &length); + const char* str = state.ToString(2, &length); - lua.Error("Class \"" + info->name + "\" has no field \"" + String(str, length) + "\")"); + state.Error("Class \"" + info->name + "\" has no field \"" + String(str, length) + "\")"); } return 1; } template - int LuaClass::StaticGetterProxy(lua_State* state) + int LuaClass::StaticGetterProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); const StaticIndexFunc& getter = info->staticGetter; - if (!getter(lua)) + if (!getter(state)) { // On accède alors à la table - lua.PushValue(lua.GetIndexOfUpValue(2)); - lua.PushValue(-2); - lua.GetTable(); + state.PushValue(state.GetIndexOfUpValue(2)); + state.PushValue(-2); + state.GetTable(); } return 1; } template - int LuaClass::StaticMethodProxy(lua_State* state) + int LuaClass::StaticMethodProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); - unsigned int index = static_cast(lua.ToInteger(lua.GetIndexOfUpValue(2))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); + unsigned int index = static_cast(state.ToInteger(state.GetIndexOfUpValue(2))); const StaticFunc& method = info->staticMethods[index]; - return method(lua); + return method(state); } template - int LuaClass::StaticSetterProxy(lua_State* state) + int LuaClass::StaticSetterProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); const StaticIndexFunc& setter = info->staticSetter; - if (!setter(lua)) + if (!setter(state)) { std::size_t length; - const char* str = lua.ToString(2, &length); + const char* str = state.ToString(2, &length); - lua.Error("Class \"" + info->name + "\" has no static field \"" + String(str, length) + ')'); + state.Error("Class \"" + info->name + "\" has no static field \"" + String(str, length) + ')'); } return 1; } template - int LuaClass::ToStringProxy(lua_State* state) + int LuaClass::ToStringProxy(lua_State* internalState) { - LuaInstance& lua = *LuaInstance::GetInstance(state); + LuaState state = LuaInstance::GetState(internalState); - std::shared_ptr& info = *static_cast*>(lua.ToUserdata(lua.GetIndexOfUpValue(1))); + std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - lua.PushString(info->name); + state.PushString(info->name); return 1; } } diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index 2ac752c9e..45d19ddba 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -4,201 +4,41 @@ #pragma once -#ifndef NAZARA_LUASTATE_HPP -#define NAZARA_LUASTATE_HPP +#ifndef NAZARA_LUAINSTANCE_HPP +#define NAZARA_LUAINSTANCE_HPP #include -#include -#include -#include -#include -#include +#include #include #include -struct lua_Debug; -struct lua_State; - namespace Nz { - class LuaInstance; - - using LuaCFunction = int (*)(lua_State* state); - using LuaFunction = std::function; - - class NAZARA_LUA_API LuaInstance + class NAZARA_LUA_API LuaInstance : public LuaState { + friend class LuaState; + public: LuaInstance(); LuaInstance(const LuaInstance&) = delete; - LuaInstance(LuaInstance&& instance) noexcept; + LuaInstance(LuaInstance&& instance) = default; ~LuaInstance(); - void ArgCheck(bool condition, unsigned int argNum, const char* error) const; - void ArgCheck(bool condition, unsigned int argNum, const String& error) const; - int ArgError(unsigned int argNum, const char* error) const; - int ArgError(unsigned int argNum, const String& error) const; - - bool Call(unsigned int argCount); - bool Call(unsigned int argCount, unsigned int resultCount); - - template T Check(int* index) const; - template T Check(int* index, T defValue) const; - void CheckAny(int index) const; - bool CheckBoolean(int index) const; - bool CheckBoolean(int index, bool defValue) const; - template T CheckBoundInteger(int index) const; - template T CheckBoundInteger(int index, T defValue) const; - template T CheckField(const char* fieldName, int tableIndex = -1) const; - template T CheckField(const String& fieldName, int tableIndex = -1) const; - template T CheckField(const char* fieldName, T defValue, int tableIndex = -1) const; - template T CheckField(const String& fieldName, T defValue, int tableIndex = -1) const; - long long CheckInteger(int index) const; - long long CheckInteger(int index, long long defValue) const; - template T CheckGlobal(const char* fieldName) const; - template T CheckGlobal(const String& fieldName) const; - template T CheckGlobal(const char* fieldName, T defValue) const; - template T CheckGlobal(const String& fieldName, T defValue) const; - double CheckNumber(int index) const; - double CheckNumber(int index, double defValue) const; - void CheckStack(int space, const char* error = nullptr) const; - void CheckStack(int space, const String& error) const; - const char* CheckString(int index, std::size_t* length = nullptr) const; - const char* CheckString(int index, const char* defValue, std::size_t* length = nullptr) const; - void CheckType(int index, LuaType type) const; - void* CheckUserdata(int index, const char* tname) const; - void* CheckUserdata(int index, const String& tname) const; - - bool Compare(int index1, int index2, LuaComparison comparison) const; - void Compute(LuaOperation operation) const; - - void Concatenate(int count) const; - - int CreateReference(); - void DestroyReference(int ref); - - String DumpStack() const; - - void Error(const char* message) const; - void Error(const String& message) const; - - bool Execute(const String& code); - bool ExecuteFromFile(const String& filePath); - bool ExecuteFromMemory(const void* data, std::size_t size); - bool ExecuteFromStream(Stream& stream); - - int GetAbsIndex(int index) const; - LuaType GetField(const char* fieldName, int tableIndex = -1) const; - LuaType GetField(const String& fieldName, int tableIndex = -1) const; - LuaType GetGlobal(const char* name) const; - LuaType GetGlobal(const String& name) const; - inline lua_State* GetInternalState() const; - inline String GetLastError() const; - inline std::size_t GetMemoryLimit() const; - inline std::size_t GetMemoryUsage() const; - LuaType GetMetatable(const char* tname) const; - LuaType GetMetatable(const String& tname) const; - bool GetMetatable(int index) const; - unsigned int GetStackTop() const; - LuaType GetTable(int index = -2) const; - LuaType GetTableRaw(int index = -2) const; - inline UInt32 GetTimeLimit() const; - LuaType GetType(int index) const; - const char* GetTypeName(LuaType type) const; - - void Insert(int index) const; - - bool IsOfType(int index, LuaType type) const; - bool IsOfType(int index, const char* tname) const; - bool IsOfType(int index, const String& tname) const; - bool IsValid(int index) const; - - long long Length(int index) const; - std::size_t LengthRaw(int index) const; - - void MoveTo(LuaInstance* instance, int n) const; - - bool NewMetatable(const char* str); - bool NewMetatable(const String& str); - bool Next(int index = -2) const; - - void Pop(unsigned int n = 1U) const; - - template int Push(T arg) const; - template int Push(T firstArg, T2 secondArg, Args... args) const; - void PushBoolean(bool value) const; - void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0) const; - template void PushField(const char* name, T&& arg, int tableIndex = -2) const; - template void PushField(const String& name, T&& arg, int tableIndex = -2) const; - void PushFunction(LuaFunction func) const; - template void PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const; - template void PushGlobal(const char* name, T&& arg); - template void PushGlobal(const String& name, T&& arg); - template void PushInstance(const char* tname, const T& instance) const; - template void PushInstance(const char* tname, T&& instance) const; - template void PushInstance(const char* tname, Args&&... args) const; - void PushInteger(long long value) const; - void PushLightUserdata(void* value) const; - void PushMetatable(const char* str) const; - void PushMetatable(const String& str) const; - void PushNil() const; - void PushNumber(double value) const; - void PushReference(int ref) const; - void PushString(const char* str) const; - void PushString(const char* str, std::size_t size) const; - void PushString(const String& str) const; - void PushTable(std::size_t sequenceElementCount = 0, std::size_t arrayElementCount = 0) const; - void* PushUserdata(std::size_t size) const; - void PushValue(int index) const; - - void Remove(int index) const; - void Replace(int index) const; - - void SetField(const char* name, int tableIndex = -2) const; - void SetField(const String& name, int tableIndex = -2) const; - void SetGlobal(const char* name); - void SetGlobal(const String& name); - void SetMetatable(const char* tname) const; - void SetMetatable(const String& tname) const; - void SetMetatable(int index) const; - void SetMemoryLimit(std::size_t memoryLimit); - void SetTable(int index = -3) const; - void SetTableRaw(int index = -3) const; - void SetTimeLimit(UInt32 timeLimit); - - bool ToBoolean(int index) const; - long long ToInteger(int index, bool* succeeded = nullptr) const; - double ToNumber(int index, bool* succeeded = nullptr) const; - const void* ToPointer(int index) const; - const char* ToString(int index, std::size_t* length = nullptr) const; - void* ToUserdata(int index) const; - void* ToUserdata(int index, const char* tname) const; - void* ToUserdata(int index, const String& tname) const; - LuaInstance& operator=(const LuaInstance&) = delete; - LuaInstance& operator=(LuaInstance&& instance) noexcept; - - static int GetIndexOfUpValue(int upValue); - static LuaInstance* GetInstance(lua_State* state); + LuaInstance& operator=(LuaInstance&& instance) = default; private: - template T CheckBounds(int index, long long value) const; - bool Run(int argCount, int resultCount); - static void* MemoryAllocator(void *ud, void *ptr, std::size_t osize, std::size_t nsize); - static int ProxyFunc(lua_State* state); - static void TimeLimiter(lua_State* state, lua_Debug* debug); + static void TimeLimiter(lua_State* internalState, lua_Debug* debug); std::size_t m_memoryLimit; std::size_t m_memoryUsage; UInt32 m_timeLimit; Clock m_clock; - String m_lastError; - lua_State* m_state; unsigned int m_level; }; } #include -#endif // NAZARA_LUASTATE_HPP +#endif // NAZARA_LUAINSTANCE_HPP diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index b30c7eca4..f4394eb6b 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -15,783 +15,4 @@ namespace Nz { - inline lua_State* LuaInstance::GetInternalState() const - { - return m_state; - } - - inline String LuaInstance::GetLastError() const - { - return m_lastError; - } - - inline std::size_t LuaInstance::GetMemoryLimit() const - { - return m_memoryLimit; - } - - inline std::size_t LuaInstance::GetMemoryUsage() const - { - return m_memoryUsage; - } - - inline UInt32 LuaInstance::GetTimeLimit() const - { - return m_timeLimit; - } - - // Functions args - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag) - { - *arg = instance.CheckBoolean(index); - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, bool defValue, TypeTag) - { - *arg = instance.CheckBoolean(index, defValue); - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, std::string* arg, TypeTag) - { - std::size_t strLength = 0; - const char* str = instance.CheckString(index, &strLength); - - arg->assign(str, strLength); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, String* arg, TypeTag) - { - std::size_t strLength = 0; - const char* str = instance.CheckString(index, &strLength); - - arg->Set(str, strLength); - - return 1; - } - - template - std::enable_if_t::value && !EnumAsFlags::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag) - { - using UnderlyingT = std::underlying_type_t; - return LuaImplQueryArg(instance, index, reinterpret_cast(arg), TypeTag()); - } - - template - std::enable_if_t::value && !EnumAsFlags::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag) - { - using UnderlyingT = std::underlying_type_t; - return LuaImplQueryArg(instance, index, reinterpret_cast(arg), static_cast(defValue), TypeTag()); - } - - template - std::enable_if_t::value && EnumAsFlags::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag) - { - using UnderlyingT = std::underlying_type_t; - - UnderlyingT pot2Val; - unsigned int ret = LuaImplQueryArg(instance, index, &pot2Val, TypeTag()); - - *arg = static_cast(IntegralLog2Pot(pot2Val)); - return ret; - } - - template - std::enable_if_t::value && EnumAsFlags::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag) - { - using UnderlyingT = std::underlying_type_t; - - UnderlyingT pot2Val; - unsigned int ret = LuaImplQueryArg(instance, index, &pot2Val, 1U << static_cast(defValue), TypeTag()); - - *arg = static_cast(IntegralLog2Pot(pot2Val)); - return ret; - } - - template - unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Flags* arg, TypeTag>) - { - *arg = Flags(instance.CheckBoundInteger(index)); - return 1; - } - - template - std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag) - { - *arg = static_cast(instance.CheckNumber(index)); - return 1; - } - - template - std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag) - { - *arg = static_cast(instance.CheckNumber(index, static_cast(defValue))); - return 1; - } - - template - std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag) - { - *arg = instance.CheckBoundInteger(index); - return 1; - } - - template - std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag) - { - *arg = instance.CheckBoundInteger(index, defValue); - return 1; - } - - template - std::enable_if_t::value && !std::is_enum::value && !std::is_floating_point::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, const T& defValue, TypeTag tag) - { - if (instance.IsValid(index)) - return LuaImplQueryArg(instance, index, arg, tag); - else - { - *arg = defValue; - return 1; - } - } - - template - unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag) - { - return LuaImplQueryArg(instance, index, arg, TypeTag()); - } - - template - unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, const T& defValue, TypeTag) - { - return LuaImplQueryArg(instance, index, arg, defValue, TypeTag()); - } - - // Function returns - inline int LuaImplReplyVal(const LuaInstance& instance, bool val, TypeTag) - { - instance.PushBoolean(val); - return 1; - } - - inline int LuaImplReplyVal(const LuaInstance& instance, double val, TypeTag) - { - instance.PushNumber(val); - return 1; - } - - inline int LuaImplReplyVal(const LuaInstance& instance, float val, TypeTag) - { - instance.PushNumber(val); - return 1; - } - - template - std::enable_if_t::value && !EnumAsFlags::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag) - { - using EnumT = typename std::underlying_type::type; - return LuaImplReplyVal(instance, static_cast(val), TypeTag()); - } - - template - std::enable_if_t::value && EnumAsFlags::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag) - { - Flags flags(val); - return LuaImplReplyVal(instance, flags, TypeTag()); - } - - template - int LuaImplReplyVal(const LuaInstance& instance, Flags val, TypeTag>) - { - instance.PushInteger(UInt32(val)); - return 1; - } - - template - std::enable_if_t::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag) - { - instance.PushInteger(val); - return 1; - } - - template - std::enable_if_t::value || std::is_enum::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag) - { - return LuaImplReplyVal(instance, val, TypeTag()); - } - - template - std::enable_if_t::value || std::is_enum::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag) - { - return LuaImplReplyVal(instance, val, TypeTag()); - } - - template - std::enable_if_t::value && !std::is_enum::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag) - { - return LuaImplReplyVal(instance, std::move(val), TypeTag()); - } - - template - std::enable_if_t::value && !std::is_enum::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag) - { - return LuaImplReplyVal(instance, std::move(val), TypeTag()); - } - - template - int LuaImplReplyVal(const LuaInstance& instance, T&& val, TypeTag) - { - return LuaImplReplyVal(instance, std::forward(val), TypeTag()); - } - - inline int LuaImplReplyVal(const LuaInstance& instance, std::string&& val, TypeTag) - { - instance.PushString(val.c_str(), val.size()); - return 1; - } - - template - inline int LuaImplReplyVal(const LuaInstance& instance, std::vector&& valContainer, TypeTag>) - { - std::size_t index = 1; - instance.PushTable(valContainer.size()); - for (T& val : valContainer) - { - instance.PushInteger(index++); - if (LuaImplReplyVal(instance, std::move(val), TypeTag()) != 1) - { - instance.Error("Couldn't create table: type need more than one place to store"); - return 0; - } - instance.SetTable(); - } - - return 1; - } - - inline int LuaImplReplyVal(const LuaInstance& instance, ByteArray&& val, TypeTag) - { - instance.PushString(reinterpret_cast(val.GetConstBuffer()), val.GetSize()); - return 1; - } - - inline int LuaImplReplyVal(const LuaInstance& instance, String&& val, TypeTag) - { - instance.PushString(std::move(val)); - return 1; - } - - template - int LuaImplReplyVal(const LuaInstance& instance, std::pair&& val, TypeTag>) - { - int retVal = 0; - - retVal += LuaImplReplyVal(instance, std::move(val.first), TypeTag()); - retVal += LuaImplReplyVal(instance, std::move(val.second), TypeTag()); - - return retVal; - } - - template - struct LuaImplArgProcesser; - - template<> - struct LuaImplArgProcesser - { - template - static unsigned int Process(const LuaInstance& instance, unsigned int argIndex, ArgContainer& args, DefArgContainer& defArgs) - { - return LuaImplQueryArg(instance, argIndex, &std::get(args), std::get() - N - 1>(defArgs), TypeTag()); - } - }; - - template<> - struct LuaImplArgProcesser - { - template - static unsigned int Process(const LuaInstance& instance, unsigned int argIndex, ArgContainer& args, DefArgContainer& defArgs) - { - NazaraUnused(defArgs); - - return LuaImplQueryArg(instance, argIndex, &std::get(args), TypeTag()); - } - }; - - template - class LuaImplFunctionProxy - { - public: - template - class Impl - { - static constexpr std::size_t ArgCount = sizeof...(Args); - static constexpr std::size_t DefArgCount = sizeof...(DefArgs); - - static_assert(ArgCount >= DefArgCount, "There cannot be more default arguments than argument"); - - static constexpr std::size_t FirstDefArg = ArgCount - DefArgCount; - - public: - Impl(DefArgs... defArgs) : - m_defaultArgs(std::forward(defArgs)...) - { - } - - void ProcessArguments(const LuaInstance& instance) const - { - m_index = 1; - ProcessArgs<0, Args...>(instance); - } - - int Invoke(const LuaInstance& instance, void(*func)(Args...)) const - { - NazaraUnused(instance); - - Apply(func, m_args); - return 0; - } - - template - int Invoke(const LuaInstance& instance, Ret(*func)(Args...)) const - { - return LuaImplReplyVal(instance, std::move(Apply(func, m_args)), TypeTag()); - } - - private: - using ArgContainer = std::tuple>...>; - using DefArgContainer = std::tuple>...>; - - template - void ProcessArgs(const LuaInstance& instance) const - { - NazaraUnused(instance); - - // No argument to process - } - - template - void ProcessArgs(const LuaInstance& instance) const - { - LuaImplArgProcesser<(N >= FirstDefArg)>::template Process(instance, m_index, m_args, m_defaultArgs); - } - - template - void ProcessArgs(const LuaInstance& instance) const - { - ProcessArgs(instance); - ProcessArgs(instance); - } - - mutable ArgContainer m_args; - DefArgContainer m_defaultArgs; - mutable unsigned int m_index; - }; - }; - - template - class LuaImplMethodProxy - { - public: - template - class Impl - { - static constexpr std::size_t ArgCount = sizeof...(Args); - static constexpr std::size_t DefArgCount = sizeof...(DefArgs); - - static_assert(ArgCount >= DefArgCount, "There cannot be more default arguments than argument"); - - static constexpr std::size_t FirstDefArg = ArgCount - DefArgCount; - - public: - Impl(DefArgs... defArgs) : - m_defaultArgs(std::forward(defArgs)...) - { - } - - void ProcessArguments(const LuaInstance& instance) const - { - m_index = 2; //< 1 being the instance - ProcessArgs<0, Args...>(instance); - } - - template - std::enable_if_t::value, int> Invoke(const LuaInstance& instance, T& object, void(P::*func)(Args...)) const - { - NazaraUnused(instance); - - Apply(object, func, m_args); - return 0; - } - - template - std::enable_if_t::value, int> Invoke(const LuaInstance& instance, T& object, Ret(P::*func)(Args...)) const - { - return LuaImplReplyVal(instance, std::move(Apply(object, func, m_args)), TypeTag()); - } - - template - std::enable_if_t::value, int> Invoke(const LuaInstance& instance, T& object, T&(P::*func)(Args...)) const - { - T& r = Apply(object, func, m_args); - if (&r == &object) - { - instance.PushValue(1); //< Userdata - return 1; - } - else - return LuaImplReplyVal(instance, r, TypeTag()); - } - - template - std::enable_if_t::value, int> Invoke(const LuaInstance& instance, const T& object, void(P::*func)(Args...) const) const - { - NazaraUnused(instance); - - Apply(object, func, m_args); - return 0; - } - - template - std::enable_if_t::value, int> Invoke(const LuaInstance& instance, const T& object, Ret(P::*func)(Args...) const) const - { - return LuaImplReplyVal(instance, std::move(Apply(object, func, m_args)), TypeTag()); - } - - template - std::enable_if_t::value, int> Invoke(const LuaInstance& instance, const T& object, const T&(P::*func)(Args...) const) const - { - const T& r = Apply(object, func, m_args); - if (&r == &object) - { - instance.PushValue(1); //< Userdata - return 1; - } - else - return LuaImplReplyVal(instance, r, TypeTag()); - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaInstance& instance, T& object, void(P::*func)(Args...)) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - Apply(*object, func, m_args); - return 0; - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaInstance& instance, T& object, Ret(P::*func)(Args...)) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - return LuaImplReplyVal(instance, std::move(Apply(*object, func, m_args)), TypeTag()); - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaInstance& instance, T& object, typename PointedType::type&(P::*func)(Args...) const) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - const typename PointedType::type& r = Apply(*object, func, m_args); - if (&r == &*object) - { - instance.PushValue(1); //< Userdata - return 1; - } - else - return LuaImplReplyVal(instance, r, TypeTag()); - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaInstance& instance, const T& object, void(P::*func)(Args...) const) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - Apply(*object, func, m_args); - return 0; - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaInstance& instance, const T& object, Ret(P::*func)(Args...) const) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - return LuaImplReplyVal(instance, std::move(Apply(*object, func, m_args)), TypeTag()); - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaInstance& instance, const T& object, const typename PointedType::type&(P::*func)(Args...) const) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - const typename PointedType::type& r = Apply(*object, func, m_args); - if (&r == &*object) - { - instance.PushValue(1); //< Userdata - return 1; - } - else - return LuaImplReplyVal(instance, r, TypeTag()); - } - - private: - using ArgContainer = std::tuple>...>; - using DefArgContainer = std::tuple>...>; - - template - void ProcessArgs(const LuaInstance& instance) const - { - NazaraUnused(instance); - - // No argument to process - } - - template - void ProcessArgs(const LuaInstance& instance) const - { - m_index += LuaImplArgProcesser<(N >= FirstDefArg)>::template Process(instance, m_index, m_args, m_defaultArgs); - } - - template - void ProcessArgs(const LuaInstance& instance) const - { - ProcessArgs(instance); - ProcessArgs(instance); - } - - mutable ArgContainer m_args; - DefArgContainer m_defaultArgs; - mutable unsigned int m_index; - }; - }; - - template - T LuaInstance::Check(int* index) const - { - NazaraAssert(index, "Invalid index pointer"); - - T object; - *index += LuaImplQueryArg(*this, *index, &object, TypeTag()); - - return object; - } - - template - T LuaInstance::Check(int* index, T defValue) const - { - NazaraAssert(index, "Invalid index pointer"); - - T object; - *index += LuaImplQueryArg(*this, *index, &object, defValue, TypeTag()); - - return object; - } - - template - inline T LuaInstance::CheckBoundInteger(int index) const - { - return CheckBounds(index, CheckInteger(index)); - } - - template - inline T LuaInstance::CheckBoundInteger(int index, T defValue) const - { - return CheckBounds(index, CheckInteger(index, defValue)); - } - - template - T LuaInstance::CheckField(const char* fieldName, int tableIndex) const - { - T object; - - GetField(fieldName, tableIndex); - tableIndex += LuaImplQueryArg(*this, -1, &object, TypeTag()); - Pop(); - - return object; - } - - template - T LuaInstance::CheckField(const String& fieldName, int tableIndex) const - { - return CheckField(fieldName.GetConstBuffer(), tableIndex); - } - - template - T LuaInstance::CheckField(const char* fieldName, T defValue, int tableIndex) const - { - T object; - - GetField(fieldName, tableIndex); - tableIndex += LuaImplQueryArg(*this, -1, &object, defValue, TypeTag()); - Pop(); - - return object; - } - - template - T LuaInstance::CheckField(const String& fieldName, T defValue, int tableIndex) const - { - return CheckField(fieldName.GetConstBuffer(), defValue, tableIndex); - } - - template - T LuaInstance::CheckGlobal(const char* fieldName) const - { - T object; - - GetGlobal(fieldName); - LuaImplQueryArg(*this, -1, &object, TypeTag()); - Pop(); - - return object; - } - - template - T LuaInstance::CheckGlobal(const String& fieldName) const - { - return CheckGlobal(fieldName.GetConstBuffer()); - } - - template - T LuaInstance::CheckGlobal(const char* fieldName, T defValue) const - { - T object; - - GetGlobal(fieldName); - LuaImplQueryArg(*this, -1, &object, defValue, TypeTag()); - Pop(); - - return object; - } - - template - T LuaInstance::CheckGlobal(const String& fieldName, T defValue) const - { - return CheckGlobal(fieldName.GetConstBuffer(), defValue); - } - - template - int LuaInstance::Push(T arg) const - { - return LuaImplReplyVal(*this, std::move(arg), TypeTag()); - } - - template - int LuaInstance::Push(T firstArg, T2 secondArg, Args... args) const - { - int valCount = 0; - valCount += Push(std::move(firstArg)); - valCount += Push(secondArg, std::forward(args)...); - - return valCount; - } - - template - void LuaInstance::PushField(const char* name, T&& arg, int tableIndex) const - { - Push(std::forward(arg)); - SetField(name, tableIndex); - } - - template - void LuaInstance::PushField(const String& name, T&& arg, int tableIndex) const - { - PushField(name.GetConstBuffer(), std::forward(arg), tableIndex); - } - - template - void LuaInstance::PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const - { - typename LuaImplFunctionProxy::template Impl handler(std::forward(defArgs)...); - - PushFunction([func, handler] (LuaInstance& lua) -> int - { - handler.ProcessArguments(lua); - - return handler.Invoke(lua, func); - }); - } - - template - void LuaInstance::PushGlobal(const char* name, T&& arg) - { - Push(std::forward(arg)); - SetGlobal(name); - } - - template - void LuaInstance::PushGlobal(const String& name, T&& arg) - { - PushGlobal(name.GetConstBuffer(), std::forward(arg)); - } - - template - void LuaInstance::PushInstance(const char* tname, const T& instance) const - { - T* userdata = static_cast(PushUserdata(sizeof(T))); - PlacementNew(userdata, instance); - - SetMetatable(tname); - } - - template - void LuaInstance::PushInstance(const char* tname, T&& instance) const - { - T* userdata = static_cast(PushUserdata(sizeof(T))); - PlacementNew(userdata, std::move(instance)); - - SetMetatable(tname); - } - - template - void LuaInstance::PushInstance(const char* tname, Args&&... args) const - { - T* userdata = static_cast(PushUserdata(sizeof(T))); - PlacementNew(userdata, std::forward(args)...); - - SetMetatable(tname); - } - - template - T LuaInstance::CheckBounds(int index, long long value) const - { - constexpr long long minBounds = std::numeric_limits::min(); - constexpr long long maxBounds = std::numeric_limits::max(); - if (value < minBounds || value > maxBounds) - { - Nz::StringStream stream; - stream << "Argument #" << index << " is outside value range [" << minBounds << ", " << maxBounds << "] (" << value << ')'; - Error(stream); - } - - return static_cast(value); - } } diff --git a/include/Nazara/Lua/LuaState.hpp b/include/Nazara/Lua/LuaState.hpp new file mode 100644 index 000000000..a34ec27fd --- /dev/null +++ b/include/Nazara/Lua/LuaState.hpp @@ -0,0 +1,197 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Lua scripting module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_LUASTATE_HPP +#define NAZARA_LUASTATE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +struct lua_Debug; +struct lua_State; + +namespace Nz +{ + class LuaInstance; + class LuaState; + + using LuaCFunction = int (*)(lua_State* internalState); + using LuaFunction = std::function; + + class NAZARA_LUA_API LuaState + { + public: + LuaState(const LuaState&) = default; + LuaState(LuaState&& instance) noexcept; + ~LuaState() = default; + + void ArgCheck(bool condition, unsigned int argNum, const char* error) const; + void ArgCheck(bool condition, unsigned int argNum, const String& error) const; + int ArgError(unsigned int argNum, const char* error) const; + int ArgError(unsigned int argNum, const String& error) const; + + bool Call(unsigned int argCount); + bool Call(unsigned int argCount, unsigned int resultCount); + + template T Check(int* index) const; + template T Check(int* index, T defValue) const; + void CheckAny(int index) const; + bool CheckBoolean(int index) const; + bool CheckBoolean(int index, bool defValue) const; + template T CheckBoundInteger(int index) const; + template T CheckBoundInteger(int index, T defValue) const; + template T CheckField(const char* fieldName, int tableIndex = -1) const; + template T CheckField(const String& fieldName, int tableIndex = -1) const; + template T CheckField(const char* fieldName, T defValue, int tableIndex = -1) const; + template T CheckField(const String& fieldName, T defValue, int tableIndex = -1) const; + long long CheckInteger(int index) const; + long long CheckInteger(int index, long long defValue) const; + template T CheckGlobal(const char* fieldName) const; + template T CheckGlobal(const String& fieldName) const; + template T CheckGlobal(const char* fieldName, T defValue) const; + template T CheckGlobal(const String& fieldName, T defValue) const; + double CheckNumber(int index) const; + double CheckNumber(int index, double defValue) const; + void CheckStack(int space, const char* error = nullptr) const; + void CheckStack(int space, const String& error) const; + const char* CheckString(int index, std::size_t* length = nullptr) const; + const char* CheckString(int index, const char* defValue, std::size_t* length = nullptr) const; + void CheckType(int index, LuaType type) const; + void* CheckUserdata(int index, const char* tname) const; + void* CheckUserdata(int index, const String& tname) const; + + bool Compare(int index1, int index2, LuaComparison comparison) const; + void Compute(LuaOperation operation) const; + + void Concatenate(int count) const; + + int CreateReference(); + void DestroyReference(int ref); + + String DumpStack() const; + + void Error(const char* message) const; + void Error(const String& message) const; + + bool Execute(const String& code); + bool ExecuteFromFile(const String& filePath); + bool ExecuteFromMemory(const void* data, std::size_t size); + bool ExecuteFromStream(Stream& stream); + + int GetAbsIndex(int index) const; + LuaType GetField(const char* fieldName, int tableIndex = -1) const; + LuaType GetField(const String& fieldName, int tableIndex = -1) const; + LuaType GetGlobal(const char* name) const; + LuaType GetGlobal(const String& name) const; + inline lua_State* GetInternalState() const; + inline String GetLastError() const; + LuaType GetMetatable(const char* tname) const; + LuaType GetMetatable(const String& tname) const; + bool GetMetatable(int index) const; + unsigned int GetStackTop() const; + LuaType GetTable(int index = -2) const; + LuaType GetTableRaw(int index = -2) const; + LuaType GetType(int index) const; + const char* GetTypeName(LuaType type) const; + + void Insert(int index) const; + + bool IsOfType(int index, LuaType type) const; + bool IsOfType(int index, const char* tname) const; + bool IsOfType(int index, const String& tname) const; + bool IsValid(int index) const; + + long long Length(int index) const; + std::size_t LengthRaw(int index) const; + + void MoveTo(LuaState* instance, int n) const; + + bool NewMetatable(const char* str); + bool NewMetatable(const String& str); + bool Next(int index = -2) const; + + void Pop(unsigned int n = 1U) const; + + template int Push(T arg) const; + template int Push(T firstArg, T2 secondArg, Args... args) const; + void PushBoolean(bool value) const; + void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0) const; + template void PushField(const char* name, T&& arg, int tableIndex = -2) const; + template void PushField(const String& name, T&& arg, int tableIndex = -2) const; + void PushFunction(LuaFunction func) const; + template void PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const; + template void PushGlobal(const char* name, T&& arg); + template void PushGlobal(const String& name, T&& arg); + template void PushInstance(const char* tname, const T& instance) const; + template void PushInstance(const char* tname, T&& instance) const; + template void PushInstance(const char* tname, Args&&... args) const; + void PushInteger(long long value) const; + void PushLightUserdata(void* value) const; + void PushMetatable(const char* str) const; + void PushMetatable(const String& str) const; + void PushNil() const; + void PushNumber(double value) const; + void PushReference(int ref) const; + void PushString(const char* str) const; + void PushString(const char* str, std::size_t size) const; + void PushString(const String& str) const; + void PushTable(std::size_t sequenceElementCount = 0, std::size_t arrayElementCount = 0) const; + void* PushUserdata(std::size_t size) const; + void PushValue(int index) const; + + void Remove(int index) const; + void Replace(int index) const; + + void SetField(const char* name, int tableIndex = -2) const; + void SetField(const String& name, int tableIndex = -2) const; + void SetGlobal(const char* name); + void SetGlobal(const String& name); + void SetMetatable(const char* tname) const; + void SetMetatable(const String& tname) const; + void SetMetatable(int index) const; + void SetMemoryLimit(std::size_t memoryLimit); + void SetTable(int index = -3) const; + void SetTableRaw(int index = -3) const; + void SetTimeLimit(UInt32 timeLimit); + + bool ToBoolean(int index) const; + long long ToInteger(int index, bool* succeeded = nullptr) const; + double ToNumber(int index, bool* succeeded = nullptr) const; + const void* ToPointer(int index) const; + const char* ToString(int index, std::size_t* length = nullptr) const; + void* ToUserdata(int index) const; + void* ToUserdata(int index, const char* tname) const; + void* ToUserdata(int index, const String& tname) const; + + LuaState& operator=(const LuaState&) = default; + LuaState& operator=(LuaState&& instance) noexcept; + + static int GetIndexOfUpValue(int upValue); + static LuaState GetState(lua_State* internalState); + + protected: + LuaState(LuaInstance* instance, lua_State* internalState); + + template T CheckBounds(int index, long long value) const; + bool Run(int argCount, int resultCount); + + static int ProxyFunc(lua_State* internalState); + + String m_lastError; + LuaInstance* m_instance; + lua_State* m_state; + }; +} + +#include + +#endif // NAZARA_LUASTATE_HPP diff --git a/include/Nazara/Lua/LuaState.inl b/include/Nazara/Lua/LuaState.inl new file mode 100644 index 000000000..dbc9016cf --- /dev/null +++ b/include/Nazara/Lua/LuaState.inl @@ -0,0 +1,788 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Lua scripting module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + inline LuaState::LuaState(LuaInstance* instance, lua_State* internalState) : + m_instance(instance), + m_state(internalState) + { + } + + inline lua_State* LuaState::GetInternalState() const + { + return m_state; + } + + inline String LuaState::GetLastError() const + { + return m_lastError; + } + + // Functions args + inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, bool* arg, TypeTag) + { + *arg = instance.CheckBoolean(index); + return 1; + } + + inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, bool* arg, bool defValue, TypeTag) + { + *arg = instance.CheckBoolean(index, defValue); + return 1; + } + + inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, std::string* arg, TypeTag) + { + std::size_t strLength = 0; + const char* str = instance.CheckString(index, &strLength); + + arg->assign(str, strLength); + + return 1; + } + + inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, String* arg, TypeTag) + { + std::size_t strLength = 0; + const char* str = instance.CheckString(index, &strLength); + + arg->Set(str, strLength); + + return 1; + } + + template + std::enable_if_t::value && !EnumAsFlags::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) + { + using UnderlyingT = std::underlying_type_t; + return LuaImplQueryArg(instance, index, reinterpret_cast(arg), TypeTag()); + } + + template + std::enable_if_t::value && !EnumAsFlags::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag) + { + using UnderlyingT = std::underlying_type_t; + return LuaImplQueryArg(instance, index, reinterpret_cast(arg), static_cast(defValue), TypeTag()); + } + + template + std::enable_if_t::value && EnumAsFlags::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) + { + using UnderlyingT = std::underlying_type_t; + + UnderlyingT pot2Val; + unsigned int ret = LuaImplQueryArg(instance, index, &pot2Val, TypeTag()); + + *arg = static_cast(IntegralLog2Pot(pot2Val)); + return ret; + } + + template + std::enable_if_t::value && EnumAsFlags::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag) + { + using UnderlyingT = std::underlying_type_t; + + UnderlyingT pot2Val; + unsigned int ret = LuaImplQueryArg(instance, index, &pot2Val, 1U << static_cast(defValue), TypeTag()); + + *arg = static_cast(IntegralLog2Pot(pot2Val)); + return ret; + } + + template + unsigned int LuaImplQueryArg(const LuaState& instance, int index, Flags* arg, TypeTag>) + { + *arg = Flags(instance.CheckBoundInteger(index)); + return 1; + } + + template + std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) + { + *arg = static_cast(instance.CheckNumber(index)); + return 1; + } + + template + std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag) + { + *arg = static_cast(instance.CheckNumber(index, static_cast(defValue))); + return 1; + } + + template + std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) + { + *arg = instance.CheckBoundInteger(index); + return 1; + } + + template + std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag) + { + *arg = instance.CheckBoundInteger(index, defValue); + return 1; + } + + template + std::enable_if_t::value && !std::is_enum::value && !std::is_floating_point::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, const T& defValue, TypeTag tag) + { + if (instance.IsValid(index)) + return LuaImplQueryArg(instance, index, arg, tag); + else + { + *arg = defValue; + return 1; + } + } + + template + unsigned int LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) + { + return LuaImplQueryArg(instance, index, arg, TypeTag()); + } + + template + unsigned int LuaImplQueryArg(const LuaState& instance, int index, T* arg, const T& defValue, TypeTag) + { + return LuaImplQueryArg(instance, index, arg, defValue, TypeTag()); + } + + // Function returns + inline int LuaImplReplyVal(const LuaState& instance, bool val, TypeTag) + { + instance.PushBoolean(val); + return 1; + } + + inline int LuaImplReplyVal(const LuaState& instance, double val, TypeTag) + { + instance.PushNumber(val); + return 1; + } + + inline int LuaImplReplyVal(const LuaState& instance, float val, TypeTag) + { + instance.PushNumber(val); + return 1; + } + + template + std::enable_if_t::value && !EnumAsFlags::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) + { + using EnumT = typename std::underlying_type::type; + return LuaImplReplyVal(instance, static_cast(val), TypeTag()); + } + + template + std::enable_if_t::value && EnumAsFlags::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) + { + Flags flags(val); + return LuaImplReplyVal(instance, flags, TypeTag()); + } + + template + int LuaImplReplyVal(const LuaState& instance, Flags val, TypeTag>) + { + instance.PushInteger(UInt32(val)); + return 1; + } + + template + std::enable_if_t::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) + { + instance.PushInteger(val); + return 1; + } + + template + std::enable_if_t::value || std::is_enum::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) + { + return LuaImplReplyVal(instance, val, TypeTag()); + } + + template + std::enable_if_t::value || std::is_enum::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) + { + return LuaImplReplyVal(instance, val, TypeTag()); + } + + template + std::enable_if_t::value && !std::is_enum::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) + { + return LuaImplReplyVal(instance, std::move(val), TypeTag()); + } + + template + std::enable_if_t::value && !std::is_enum::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) + { + return LuaImplReplyVal(instance, std::move(val), TypeTag()); + } + + template + int LuaImplReplyVal(const LuaState& instance, T&& val, TypeTag) + { + return LuaImplReplyVal(instance, std::forward(val), TypeTag()); + } + + inline int LuaImplReplyVal(const LuaState& instance, std::string&& val, TypeTag) + { + instance.PushString(val.c_str(), val.size()); + return 1; + } + + template + inline int LuaImplReplyVal(const LuaState& instance, std::vector&& valContainer, TypeTag>) + { + std::size_t index = 1; + instance.PushTable(valContainer.size()); + for (T& val : valContainer) + { + instance.PushInteger(index++); + if (LuaImplReplyVal(instance, std::move(val), TypeTag()) != 1) + { + instance.Error("Couldn't create table: type need more than one place to store"); + return 0; + } + instance.SetTable(); + } + + return 1; + } + + inline int LuaImplReplyVal(const LuaState& instance, ByteArray&& val, TypeTag) + { + instance.PushString(reinterpret_cast(val.GetConstBuffer()), val.GetSize()); + return 1; + } + + inline int LuaImplReplyVal(const LuaState& instance, String&& val, TypeTag) + { + instance.PushString(std::move(val)); + return 1; + } + + template + int LuaImplReplyVal(const LuaState& instance, std::pair&& val, TypeTag>) + { + int retVal = 0; + + retVal += LuaImplReplyVal(instance, std::move(val.first), TypeTag()); + retVal += LuaImplReplyVal(instance, std::move(val.second), TypeTag()); + + return retVal; + } + + template + struct LuaImplArgProcesser; + + template<> + struct LuaImplArgProcesser + { + template + static unsigned int Process(const LuaState& instance, unsigned int argIndex, ArgContainer& args, DefArgContainer& defArgs) + { + return LuaImplQueryArg(instance, argIndex, &std::get(args), std::get() - N - 1>(defArgs), TypeTag()); + } + }; + + template<> + struct LuaImplArgProcesser + { + template + static unsigned int Process(const LuaState& instance, unsigned int argIndex, ArgContainer& args, DefArgContainer& defArgs) + { + NazaraUnused(defArgs); + + return LuaImplQueryArg(instance, argIndex, &std::get(args), TypeTag()); + } + }; + + template + class LuaImplFunctionProxy + { + public: + template + class Impl + { + static constexpr std::size_t ArgCount = sizeof...(Args); + static constexpr std::size_t DefArgCount = sizeof...(DefArgs); + + static_assert(ArgCount >= DefArgCount, "There cannot be more default arguments than argument"); + + static constexpr std::size_t FirstDefArg = ArgCount - DefArgCount; + + public: + Impl(DefArgs... defArgs) : + m_defaultArgs(std::forward(defArgs)...) + { + } + + void ProcessArguments(const LuaState& instance) const + { + m_index = 1; + ProcessArgs<0, Args...>(instance); + } + + int Invoke(const LuaState& instance, void(*func)(Args...)) const + { + NazaraUnused(instance); + + Apply(func, m_args); + return 0; + } + + template + int Invoke(const LuaState& instance, Ret(*func)(Args...)) const + { + return LuaImplReplyVal(instance, std::move(Apply(func, m_args)), TypeTag()); + } + + private: + using ArgContainer = std::tuple>...>; + using DefArgContainer = std::tuple>...>; + + template + void ProcessArgs(const LuaState& instance) const + { + NazaraUnused(instance); + + // No argument to process + } + + template + void ProcessArgs(const LuaState& instance) const + { + LuaImplArgProcesser<(N >= FirstDefArg)>::template Process(instance, m_index, m_args, m_defaultArgs); + } + + template + void ProcessArgs(const LuaState& instance) const + { + ProcessArgs(instance); + ProcessArgs(instance); + } + + mutable ArgContainer m_args; + DefArgContainer m_defaultArgs; + mutable unsigned int m_index; + }; + }; + + template + class LuaImplMethodProxy + { + public: + template + class Impl + { + static constexpr std::size_t ArgCount = sizeof...(Args); + static constexpr std::size_t DefArgCount = sizeof...(DefArgs); + + static_assert(ArgCount >= DefArgCount, "There cannot be more default arguments than argument"); + + static constexpr std::size_t FirstDefArg = ArgCount - DefArgCount; + + public: + Impl(DefArgs... defArgs) : + m_defaultArgs(std::forward(defArgs)...) + { + } + + void ProcessArguments(const LuaState& instance) const + { + m_index = 2; //< 1 being the instance + ProcessArgs<0, Args...>(instance); + } + + template + std::enable_if_t::value, int> Invoke(const LuaState& instance, T& object, void(P::*func)(Args...)) const + { + NazaraUnused(instance); + + Apply(object, func, m_args); + return 0; + } + + template + std::enable_if_t::value, int> Invoke(const LuaState& instance, T& object, Ret(P::*func)(Args...)) const + { + return LuaImplReplyVal(instance, std::move(Apply(object, func, m_args)), TypeTag()); + } + + template + std::enable_if_t::value, int> Invoke(const LuaState& instance, T& object, T&(P::*func)(Args...)) const + { + T& r = Apply(object, func, m_args); + if (&r == &object) + { + instance.PushValue(1); //< Userdata + return 1; + } + else + return LuaImplReplyVal(instance, r, TypeTag()); + } + + template + std::enable_if_t::value, int> Invoke(const LuaState& instance, const T& object, void(P::*func)(Args...) const) const + { + NazaraUnused(instance); + + Apply(object, func, m_args); + return 0; + } + + template + std::enable_if_t::value, int> Invoke(const LuaState& instance, const T& object, Ret(P::*func)(Args...) const) const + { + return LuaImplReplyVal(instance, std::move(Apply(object, func, m_args)), TypeTag()); + } + + template + std::enable_if_t::value, int> Invoke(const LuaState& instance, const T& object, const T&(P::*func)(Args...) const) const + { + const T& r = Apply(object, func, m_args); + if (&r == &object) + { + instance.PushValue(1); //< Userdata + return 1; + } + else + return LuaImplReplyVal(instance, r, TypeTag()); + } + + template + std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, T& object, void(P::*func)(Args...)) const + { + if (!object) + { + instance.Error("Invalid object"); + return 0; + } + + Apply(*object, func, m_args); + return 0; + } + + template + std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, T& object, Ret(P::*func)(Args...)) const + { + if (!object) + { + instance.Error("Invalid object"); + return 0; + } + + return LuaImplReplyVal(instance, std::move(Apply(*object, func, m_args)), TypeTag()); + } + + template + std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, T& object, typename PointedType::type&(P::*func)(Args...) const) const + { + if (!object) + { + instance.Error("Invalid object"); + return 0; + } + + const typename PointedType::type& r = Apply(*object, func, m_args); + if (&r == &*object) + { + instance.PushValue(1); //< Userdata + return 1; + } + else + return LuaImplReplyVal(instance, r, TypeTag()); + } + + template + std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, const T& object, void(P::*func)(Args...) const) const + { + if (!object) + { + instance.Error("Invalid object"); + return 0; + } + + Apply(*object, func, m_args); + return 0; + } + + template + std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, const T& object, Ret(P::*func)(Args...) const) const + { + if (!object) + { + instance.Error("Invalid object"); + return 0; + } + + return LuaImplReplyVal(instance, std::move(Apply(*object, func, m_args)), TypeTag()); + } + + template + std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, const T& object, const typename PointedType::type&(P::*func)(Args...) const) const + { + if (!object) + { + instance.Error("Invalid object"); + return 0; + } + + const typename PointedType::type& r = Apply(*object, func, m_args); + if (&r == &*object) + { + instance.PushValue(1); //< Userdata + return 1; + } + else + return LuaImplReplyVal(instance, r, TypeTag()); + } + + private: + using ArgContainer = std::tuple>...>; + using DefArgContainer = std::tuple>...>; + + template + void ProcessArgs(const LuaState& instance) const + { + NazaraUnused(instance); + + // No argument to process + } + + template + void ProcessArgs(const LuaState& instance) const + { + m_index += LuaImplArgProcesser<(N >= FirstDefArg)>::template Process(instance, m_index, m_args, m_defaultArgs); + } + + template + void ProcessArgs(const LuaState& instance) const + { + ProcessArgs(instance); + ProcessArgs(instance); + } + + mutable ArgContainer m_args; + DefArgContainer m_defaultArgs; + mutable unsigned int m_index; + }; + }; + + template + T LuaState::Check(int* index) const + { + NazaraAssert(index, "Invalid index pointer"); + + T object; + *index += LuaImplQueryArg(*this, *index, &object, TypeTag()); + + return object; + } + + template + T LuaState::Check(int* index, T defValue) const + { + NazaraAssert(index, "Invalid index pointer"); + + T object; + *index += LuaImplQueryArg(*this, *index, &object, defValue, TypeTag()); + + return object; + } + + template + inline T LuaState::CheckBoundInteger(int index) const + { + return CheckBounds(index, CheckInteger(index)); + } + + template + inline T LuaState::CheckBoundInteger(int index, T defValue) const + { + return CheckBounds(index, CheckInteger(index, defValue)); + } + + template + T LuaState::CheckField(const char* fieldName, int tableIndex) const + { + T object; + + GetField(fieldName, tableIndex); + tableIndex += LuaImplQueryArg(*this, -1, &object, TypeTag()); + Pop(); + + return object; + } + + template + T LuaState::CheckField(const String& fieldName, int tableIndex) const + { + return CheckField(fieldName.GetConstBuffer(), tableIndex); + } + + template + T LuaState::CheckField(const char* fieldName, T defValue, int tableIndex) const + { + T object; + + GetField(fieldName, tableIndex); + tableIndex += LuaImplQueryArg(*this, -1, &object, defValue, TypeTag()); + Pop(); + + return object; + } + + template + T LuaState::CheckField(const String& fieldName, T defValue, int tableIndex) const + { + return CheckField(fieldName.GetConstBuffer(), defValue, tableIndex); + } + + template + T LuaState::CheckGlobal(const char* fieldName) const + { + T object; + + GetGlobal(fieldName); + LuaImplQueryArg(*this, -1, &object, TypeTag()); + Pop(); + + return object; + } + + template + T LuaState::CheckGlobal(const String& fieldName) const + { + return CheckGlobal(fieldName.GetConstBuffer()); + } + + template + T LuaState::CheckGlobal(const char* fieldName, T defValue) const + { + T object; + + GetGlobal(fieldName); + LuaImplQueryArg(*this, -1, &object, defValue, TypeTag()); + Pop(); + + return object; + } + + template + T LuaState::CheckGlobal(const String& fieldName, T defValue) const + { + return CheckGlobal(fieldName.GetConstBuffer(), defValue); + } + + template + int LuaState::Push(T arg) const + { + return LuaImplReplyVal(*this, std::move(arg), TypeTag()); + } + + template + int LuaState::Push(T firstArg, T2 secondArg, Args... args) const + { + int valCount = 0; + valCount += Push(std::move(firstArg)); + valCount += Push(secondArg, std::forward(args)...); + + return valCount; + } + + template + void LuaState::PushField(const char* name, T&& arg, int tableIndex) const + { + Push(std::forward(arg)); + SetField(name, tableIndex); + } + + template + void LuaState::PushField(const String& name, T&& arg, int tableIndex) const + { + PushField(name.GetConstBuffer(), std::forward(arg), tableIndex); + } + + template + void LuaState::PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const + { + typename LuaImplFunctionProxy::template Impl handler(std::forward(defArgs)...); + + PushFunction([func, handler] (LuaState& lua) -> int + { + handler.ProcessArguments(lua); + + return handler.Invoke(lua, func); + }); + } + + template + void LuaState::PushGlobal(const char* name, T&& arg) + { + Push(std::forward(arg)); + SetGlobal(name); + } + + template + void LuaState::PushGlobal(const String& name, T&& arg) + { + PushGlobal(name.GetConstBuffer(), std::forward(arg)); + } + + template + void LuaState::PushInstance(const char* tname, const T& instance) const + { + T* userdata = static_cast(PushUserdata(sizeof(T))); + PlacementNew(userdata, instance); + + SetMetatable(tname); + } + + template + void LuaState::PushInstance(const char* tname, T&& instance) const + { + T* userdata = static_cast(PushUserdata(sizeof(T))); + PlacementNew(userdata, std::move(instance)); + + SetMetatable(tname); + } + + template + void LuaState::PushInstance(const char* tname, Args&&... args) const + { + T* userdata = static_cast(PushUserdata(sizeof(T))); + PlacementNew(userdata, std::forward(args)...); + + SetMetatable(tname); + } + + template + T LuaState::CheckBounds(int index, long long value) const + { + constexpr long long minBounds = std::numeric_limits::min(); + constexpr long long maxBounds = std::numeric_limits::max(); + if (value < minBounds || value > maxBounds) + { + Nz::StringStream stream; + stream << "Argument #" << index << " is outside value range [" << minBounds << ", " << maxBounds << "] (" << value << ')'; + Error(stream); + } + + return static_cast(value); + } +} diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 1c8f25567..607edc126 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -21,117 +21,16 @@ namespace Nz { namespace { - LuaType FromLuaType(int type) + int AtPanic(lua_State* internalState) { - switch (type) - { - case LUA_TBOOLEAN: - return LuaType_Boolean; - - case LUA_TFUNCTION: - return LuaType_Function; - - case LUA_TLIGHTUSERDATA: - return LuaType_LightUserdata; - - case LUA_TNIL: - return LuaType_Nil; - - case LUA_TNONE: - return LuaType_None; - - case LUA_TNUMBER: - return LuaType_Number; - - case LUA_TSTRING: - return LuaType_String; - - case LUA_TTABLE: - return LuaType_Table; - - case LUA_TTHREAD: - return LuaType_Thread; - - case LUA_TUSERDATA: - return LuaType_Userdata; - - default: - return LuaType_None; - } - } - - struct StreamData - { - Stream* stream; - char buffer[NAZARA_CORE_FILE_BUFFERSIZE]; - }; - - int AtPanic(lua_State* state) - { - String lastError(lua_tostring(state, -1)); + String lastError(lua_tostring(internalState, -1)); throw std::runtime_error("Lua panic: " + lastError); } - - const char* StreamReader(lua_State* state, void* data, std::size_t* size) - { - NazaraUnused(state); - - StreamData* streamData = static_cast(data); - - if (streamData->stream->EndOfStream()) - return nullptr; - else - { - *size = streamData->stream->Read(streamData->buffer, NAZARA_CORE_FILE_BUFFERSIZE); - return streamData->buffer; - } - } - - int s_comparisons[] = { - LUA_OPEQ, // LuaComparison_Equality - LUA_OPLT, // LuaComparison_Less - LUA_OPLE // LuaComparison_LessOrEqual - }; - - static_assert(sizeof(s_comparisons)/sizeof(int) == LuaComparison_Max+1, "Lua comparison array is incomplete"); - - int s_operations[] = { - LUA_OPADD, // LuaOperation_Addition - LUA_OPBAND, // LuaOperation_BitwiseAnd - LUA_OPSHL, // LuaOperation_BitwiseLeftShift - LUA_OPBNOT, // LuaOperation_BitwiseNot - LUA_OPBOR, // LuaOperation_BitwiseOr - LUA_OPSHR, // LuaOperation_BitwiseRightShift - LUA_OPBXOR, // LuaOperation_BitwiseXOr - LUA_OPDIV, // LuaOperation_Division - LUA_OPPOW, // LuaOperation_Exponentiation - LUA_OPIDIV, // LuaOperation_FloorDivision - LUA_OPMUL, // LuaOperation_Multiplication - LUA_OPMOD, // LuaOperation_Modulo - LUA_OPUNM, // LuaOperation_Negation - LUA_OPSUB // LuaOperation_Substraction - }; - - static_assert(sizeof(s_operations)/sizeof(int) == LuaOperation_Max+1, "Lua operation array is incomplete"); - - int s_types[] = { - LUA_TBOOLEAN, // LuaType_Boolean - LUA_TFUNCTION, // LuaType_Function - LUA_TLIGHTUSERDATA, // LuaType_LightUserdata - LUA_TNIL, // LuaType_Nil - LUA_TNUMBER, // LuaType_Number - LUA_TNONE, // LuaType_None - LUA_TSTRING, // LuaType_String - LUA_TTABLE, // LuaType_Table - LUA_TTHREAD, // LuaType_Thread - LUA_TUSERDATA // LuaType_Userdata - }; - - static_assert(sizeof(s_types)/sizeof(int) == LuaType_Max+1, "Lua type array is incomplete"); } LuaInstance::LuaInstance() : + LuaState(this, lua_newstate(MemoryAllocator, this)), m_memoryLimit(0), m_memoryUsage(0), m_timeLimit(1000), @@ -143,744 +42,12 @@ namespace Nz luaL_openlibs(m_state); } - LuaInstance::LuaInstance(LuaInstance&& instance) noexcept : - m_memoryLimit(instance.m_memoryLimit), - m_memoryUsage(instance.m_memoryUsage), - m_timeLimit(instance.m_timeLimit), - m_clock(std::move(instance.m_clock)), - m_lastError(std::move(instance.m_lastError)), - m_state(instance.m_state), - m_level(instance.m_level) - { - instance.m_state = nullptr; - - lua_setallocf(m_state, MemoryAllocator, this); - } - LuaInstance::~LuaInstance() { if (m_state) lua_close(m_state); } - void LuaInstance::ArgCheck(bool condition, unsigned int argNum, const char* error) const - { - luaL_argcheck(m_state, condition, argNum, error); - } - - void LuaInstance::ArgCheck(bool condition, unsigned int argNum, const String& error) const - { - luaL_argcheck(m_state, condition, argNum, error.GetConstBuffer()); - } - - int LuaInstance::ArgError(unsigned int argNum, const char* error) const - { - return luaL_argerror(m_state, argNum, error); - } - - int LuaInstance::ArgError(unsigned int argNum, const String& error) const - { - return luaL_argerror(m_state, argNum, error.GetConstBuffer()); - } - - bool LuaInstance::Call(unsigned int argCount) - { - return Run(argCount, LUA_MULTRET); - } - - bool LuaInstance::Call(unsigned int argCount, unsigned int resultCount) - { - return Run(argCount, resultCount); - } - - void LuaInstance::CheckAny(int index) const - { - luaL_checkany(m_state, index); - } - - bool LuaInstance::CheckBoolean(int index) const - { - if (lua_isnoneornil(m_state, index)) - { - const char* msg = lua_pushfstring(m_state, "%s expected, got %s", lua_typename(m_state, LUA_TBOOLEAN), luaL_typename(m_state, index)); - luaL_argerror(m_state, index, msg); // Lance une exception - return false; - } - - return lua_toboolean(m_state, index) != 0; - } - - bool LuaInstance::CheckBoolean(int index, bool defValue) const - { - if (lua_isnoneornil(m_state, index)) - return defValue; - - return lua_toboolean(m_state, index) != 0; - } - - long long LuaInstance::CheckInteger(int index) const - { - return luaL_checkinteger(m_state, index); - } - - long long LuaInstance::CheckInteger(int index, long long defValue) const - { - return luaL_optinteger(m_state, index, defValue); - } - - double LuaInstance::CheckNumber(int index) const - { - return luaL_checknumber(m_state, index); - } - - double LuaInstance::CheckNumber(int index, double defValue) const - { - return luaL_optnumber(m_state, index, defValue); - } - - void LuaInstance::CheckStack(int space, const char* error) const - { - luaL_checkstack(m_state, space, error); - } - - void LuaInstance::CheckStack(int space, const String& error) const - { - CheckStack(space, error.GetConstBuffer()); - } - - const char* LuaInstance::CheckString(int index, std::size_t* length) const - { - return luaL_checklstring(m_state, index, length); - } - - const char* LuaInstance::CheckString(int index, const char* defValue, std::size_t* length) const - { - return luaL_optlstring(m_state, index, defValue, length); - } - - void LuaInstance::CheckType(int index, LuaType type) const - { - #ifdef NAZARA_DEBUG - if (type > LuaType_Max) - { - NazaraError("Lua type out of enum"); - return; - } - #endif - - luaL_checktype(m_state, index, s_types[type]); - } - - void* LuaInstance::CheckUserdata(int index, const char* tname) const - { - return luaL_checkudata(m_state, index, tname); - } - - void* LuaInstance::CheckUserdata(int index, const String& tname) const - { - return luaL_checkudata(m_state, index, tname.GetConstBuffer()); - } - - bool LuaInstance::Compare(int index1, int index2, LuaComparison comparison) const - { - #ifdef NAZARA_DEBUG - if (comparison > LuaComparison_Max) - { - NazaraError("Lua comparison out of enum"); - return false; - } - #endif - - return (lua_compare(m_state, index1, index2, s_comparisons[comparison]) != 0); - } - - void LuaInstance::Compute(LuaOperation operation) const - { - #ifdef NAZARA_DEBUG - if (operation > LuaOperation_Max) - { - NazaraError("Lua operation out of enum"); - return; - } - #endif - - lua_arith(m_state, s_operations[operation]); - } - - void LuaInstance::Concatenate(int count) const - { - lua_concat(m_state, count); - } - - int LuaInstance::CreateReference() - { - return luaL_ref(m_state, LUA_REGISTRYINDEX); - } - - void LuaInstance::DestroyReference(int ref) - { - luaL_unref(m_state, LUA_REGISTRYINDEX, ref); - } - - String LuaInstance::DumpStack() const - { - StringStream stream; - unsigned int stackTop = GetStackTop(); - stream << stackTop << " entries\n"; - - for (unsigned int i = 1; i <= stackTop; ++i) - { - stream << i << ": "; - switch (GetType(i)) - { - case LuaType_Boolean: - stream << "Boolean(" << ToBoolean(i) << ')'; - break; - - case LuaType_Function: - stream << "Function(" << ToPointer(i) << ')'; - break; - - case LuaType_LightUserdata: - case LuaType_Userdata: - stream << "Userdata(" << ToUserdata(i) << ')'; - break; - - case LuaType_Nil: - stream << "Nil"; - break; - - case LuaType_None: - stream << "None"; - break; - - case LuaType_Number: - stream << "Number(" << ToNumber(i) << ')'; - break; - - case LuaType_String: - stream << "String(" << ToString(i) << ')'; - break; - - case LuaType_Table: - stream << "Table(" << ToPointer(i) << ')'; - break; - - case LuaType_Thread: - stream << "Thread(" << ToPointer(i) << ')'; - break; - - default: - stream << "Unknown(" << ToPointer(i) << ')'; - break; - } - - stream << '\n'; - } - - return stream.ToString(); - } - - void LuaInstance::Error(const char* message) const - { - luaL_error(m_state, message); - } - - void LuaInstance::Error(const String& message) const - { - luaL_error(m_state, message.GetConstBuffer()); - } - - bool LuaInstance::Execute(const String& code) - { - if (code.IsEmpty()) - return true; - - if (luaL_loadstring(m_state, code.GetConstBuffer()) != 0) - { - m_lastError = lua_tostring(m_state, -1); - lua_pop(m_state, 1); - - return false; - } - - return Run(0, 0); - } - - bool LuaInstance::ExecuteFromFile(const String& filePath) - { - File file(filePath); - if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) - { - NazaraError("Failed to open file"); - return false; - } - - std::size_t length = static_cast(file.GetSize()); - - String source(length, '\0'); - - if (file.Read(&source[0], length) != length) - { - NazaraError("Failed to read file"); - return false; - } - - file.Close(); - - return Execute(source); - } - - bool LuaInstance::ExecuteFromMemory(const void* data, std::size_t size) - { - MemoryView stream(data, size); - return ExecuteFromStream(stream); - } - - bool LuaInstance::ExecuteFromStream(Stream& stream) - { - StreamData data; - data.stream = &stream; - - if (lua_load(m_state, StreamReader, &data, "C++", nullptr) != 0) - { - m_lastError = lua_tostring(m_state, -1); - lua_pop(m_state, 1); - - return false; - } - - return Run(0, 0); - } - - int LuaInstance::GetAbsIndex(int index) const - { - return lua_absindex(m_state, index); - } - - LuaType LuaInstance::GetField(const char* fieldName, int tableIndex) const - { - return FromLuaType(lua_getfield(m_state, tableIndex, fieldName)); - } - - LuaType LuaInstance::GetField(const String& fieldName, int tableIndex) const - { - return FromLuaType(lua_getfield(m_state, tableIndex, fieldName.GetConstBuffer())); - } - - LuaType LuaInstance::GetGlobal(const char* name) const - { - return FromLuaType(lua_getglobal(m_state, name)); - } - - LuaType LuaInstance::GetGlobal(const String& name) const - { - return FromLuaType(lua_getglobal(m_state, name.GetConstBuffer())); - } - - LuaType LuaInstance::GetMetatable(const char* tname) const - { - return FromLuaType(luaL_getmetatable(m_state, tname)); - } - - LuaType LuaInstance::GetMetatable(const String& tname) const - { - return FromLuaType(luaL_getmetatable(m_state, tname.GetConstBuffer())); - } - - bool LuaInstance::GetMetatable(int index) const - { - return lua_getmetatable(m_state, index) != 0; - } - - unsigned int LuaInstance::GetStackTop() const - { - return static_cast(lua_gettop(m_state)); - } - - LuaType LuaInstance::GetTable(int index) const - { - return FromLuaType(lua_gettable(m_state, index)); - } - - LuaType LuaInstance::GetTableRaw(int index) const - { - return FromLuaType(lua_rawget(m_state, index)); - } - - LuaType LuaInstance::GetType(int index) const - { - return FromLuaType(lua_type(m_state, index)); - } - - const char* LuaInstance::GetTypeName(LuaType type) const - { - #ifdef NAZARA_DEBUG - if (type > LuaType_Max) - { - NazaraError("Lua type out of enum"); - return nullptr; - } - #endif - - return lua_typename(m_state, s_types[type]); - } - - void LuaInstance::Insert(int index) const - { - lua_insert(m_state, index); - } - - bool LuaInstance::IsOfType(int index, LuaType type) const - { - switch (type) - { - case LuaType_Boolean: - return lua_isboolean(m_state, index) != 0; - - case LuaType_Function: - return lua_isfunction(m_state, index) != 0; - - case LuaType_LightUserdata: - return lua_islightuserdata(m_state, index) != 0; - - case LuaType_Nil: - return lua_isnil(m_state, index) != 0; - - case LuaType_None: - return lua_isnone(m_state, index) != 0; - - case LuaType_Number: - return lua_isnumber(m_state, index) != 0; - - case LuaType_String: - return lua_isstring(m_state, index) != 0; - - case LuaType_Table: - return lua_istable(m_state, index) != 0; - - case LuaType_Thread: - return lua_isthread(m_state, index) != 0; - - case LuaType_Userdata: - return lua_isuserdata(m_state, index) != 0; - } - - NazaraError("Lua type not handled (0x" + String::Number(type, 16) + ')'); - return false; - } - - bool LuaInstance::IsOfType(int index, const char* tname) const - { - void* ud = luaL_testudata(m_state, index, tname); - return ud != nullptr; - } - - bool LuaInstance::IsOfType(int index, const String& tname) const - { - return IsOfType(index, tname.GetConstBuffer()); - } - - bool LuaInstance::IsValid(int index) const - { - return lua_isnoneornil(m_state, index) == 0; - } - - long long LuaInstance::Length(int index) const - { - return luaL_len(m_state, index); - } - - std::size_t LuaInstance::LengthRaw(int index) const - { - return lua_rawlen(m_state, index); - } - - void LuaInstance::MoveTo(LuaInstance* instance, int n) const - { - lua_xmove(m_state, instance->m_state, n); - } - - bool LuaInstance::NewMetatable(const char* str) - { - return luaL_newmetatable(m_state, str) != 0; - } - - bool LuaInstance::NewMetatable(const String& str) - { - return luaL_newmetatable(m_state, str.GetConstBuffer()) != 0; - } - - bool LuaInstance::Next(int index) const - { - return lua_next(m_state, index) != 0; - } - - void LuaInstance::Pop(unsigned int n) const - { - lua_pop(m_state, static_cast(n)); - } - - void LuaInstance::PushBoolean(bool value) const - { - lua_pushboolean(m_state, (value) ? 1 : 0); - } - - void LuaInstance::PushCFunction(LuaCFunction func, unsigned int upvalueCount) const - { - lua_pushcclosure(m_state, func, upvalueCount); - } - - void LuaInstance::PushFunction(LuaFunction func) const - { - LuaFunction* luaFunc = static_cast(lua_newuserdata(m_state, sizeof(LuaFunction))); - PlacementNew(luaFunc, std::move(func)); - - lua_pushcclosure(m_state, ProxyFunc, 1); - } - - void LuaInstance::PushInteger(long long value) const - { - lua_pushinteger(m_state, value); - } - - void LuaInstance::PushLightUserdata(void* value) const - { - lua_pushlightuserdata(m_state, value); - } - - void LuaInstance::PushMetatable(const char* str) const - { - luaL_getmetatable(m_state, str); - } - - void LuaInstance::PushMetatable(const String& str) const - { - luaL_getmetatable(m_state, str.GetConstBuffer()); - } - - void LuaInstance::PushNil() const - { - lua_pushnil(m_state); - } - - void LuaInstance::PushNumber(double value) const - { - lua_pushnumber(m_state, value); - } - - void LuaInstance::PushReference(int ref) const - { - lua_rawgeti(m_state, LUA_REGISTRYINDEX, ref); - } - - void LuaInstance::PushString(const char* str) const - { - lua_pushstring(m_state, str); - } - - void LuaInstance::PushString(const char* str, std::size_t size) const - { - lua_pushlstring(m_state, str, size); - } - - void LuaInstance::PushString(const String& str) const - { - lua_pushlstring(m_state, str.GetConstBuffer(), str.GetSize()); - } - - void LuaInstance::PushTable(std::size_t sequenceElementCount, std::size_t arrayElementCount) const - { - constexpr std::size_t maxInt = std::numeric_limits::max(); - lua_createtable(m_state, static_cast(std::min(sequenceElementCount, maxInt)), static_cast(std::min(arrayElementCount, maxInt))); - } - - void* LuaInstance::PushUserdata(std::size_t size) const - { - return lua_newuserdata(m_state, size); - } - - void LuaInstance::PushValue(int index) const - { - lua_pushvalue(m_state, index); - } - - void LuaInstance::Remove(int index) const - { - lua_remove(m_state, index); - } - - void LuaInstance::Replace(int index) const - { - lua_replace(m_state, index); - } - - void LuaInstance::SetField(const char* name, int tableIndex) const - { - lua_setfield(m_state, tableIndex, name); - } - - void LuaInstance::SetField(const String& name, int tableIndex) const - { - lua_setfield(m_state, tableIndex, name.GetConstBuffer()); - } - - void LuaInstance::SetGlobal(const char* name) - { - lua_setglobal(m_state, name); - } - - void LuaInstance::SetGlobal(const String& name) - { - lua_setglobal(m_state, name.GetConstBuffer()); - } - - void LuaInstance::SetMetatable(const char* tname) const - { - luaL_setmetatable(m_state, tname); - } - - void LuaInstance::SetMetatable(const String& tname) const - { - luaL_setmetatable(m_state, tname.GetConstBuffer()); - } - - void LuaInstance::SetMetatable(int index) const - { - lua_setmetatable(m_state, index); - } - - void LuaInstance::SetMemoryLimit(std::size_t memoryLimit) - { - m_memoryLimit = memoryLimit; - } - - void LuaInstance::SetTable(int index) const - { - lua_settable(m_state, index); - } - - void LuaInstance::SetTableRaw(int index) const - { - lua_rawset(m_state, index); - } - - void LuaInstance::SetTimeLimit(UInt32 timeLimit) - { - if (m_timeLimit != timeLimit) - { - if (m_timeLimit == 0) - lua_sethook(m_state, TimeLimiter, LUA_MASKCOUNT, 1000); - else if (timeLimit == 0) - lua_sethook(m_state, TimeLimiter, 0, 1000); - - m_timeLimit = timeLimit; - } - } - - bool LuaInstance::ToBoolean(int index) const - { - return lua_toboolean(m_state, index) != 0; - } - - long long LuaInstance::ToInteger(int index, bool* succeeded) const - { - int success; - long long result = lua_tointegerx(m_state, index, &success); - - if (succeeded) - *succeeded = (success != 0); - - return result; - } - - double LuaInstance::ToNumber(int index, bool* succeeded) const - { - int success; - double result = lua_tonumberx(m_state, index, &success); - - if (succeeded) - *succeeded = (success != 0); - - return result; - } - - const void* LuaInstance::ToPointer(int index) const - { - return lua_topointer(m_state, index); - } - - const char* LuaInstance::ToString(int index, std::size_t* length) const - { - return lua_tolstring(m_state, index, length); - } - - void* LuaInstance::ToUserdata(int index) const - { - return lua_touserdata(m_state, index); - } - - void* LuaInstance::ToUserdata(int index, const char* tname) const - { - return luaL_testudata(m_state, index, tname); - } - - void* LuaInstance::ToUserdata(int index, const String& tname) const - { - return luaL_testudata(m_state, index, tname.GetConstBuffer()); - } - - LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept - { - m_clock = std::move(instance.m_clock); - m_lastError = std::move(instance.m_lastError); - m_level = instance.m_level; - m_memoryLimit = instance.m_memoryLimit; - m_memoryUsage = instance.m_memoryUsage; - m_state = instance.m_state; - m_timeLimit = instance.m_timeLimit; - - instance.m_state = nullptr; - - // Update allocator pointer - lua_setallocf(m_state, MemoryAllocator, this); - - return *this; - } - - int LuaInstance::GetIndexOfUpValue(int upValue) - { - return lua_upvalueindex(upValue); - } - - LuaInstance* LuaInstance::GetInstance(lua_State* state) - { - LuaInstance* instance; - lua_getallocf(state, reinterpret_cast(&instance)); - - return instance; - } - - bool LuaInstance::Run(int argCount, int resultCount) - { - if (m_level++ == 0) - m_clock.Restart(); - - int status = lua_pcall(m_state, argCount, resultCount, 0); - - m_level--; - - if (status != 0) - { - m_lastError = lua_tostring(m_state, -1); - lua_pop(m_state, 1); - - return false; - } - - return true; - } - void* LuaInstance::MemoryAllocator(void* ud, void* ptr, std::size_t osize, std::size_t nsize) { LuaInstance* instance = static_cast(ud); @@ -912,18 +79,14 @@ namespace Nz } } - int LuaInstance::ProxyFunc(lua_State* state) - { - LuaFunction& func = *static_cast(lua_touserdata(state, lua_upvalueindex(1))); - return func(*GetInstance(state)); - } - - void LuaInstance::TimeLimiter(lua_State* state, lua_Debug* debug) + void LuaInstance::TimeLimiter(lua_State* internalState, lua_Debug* debug) { NazaraUnused(debug); - LuaInstance* instance = GetInstance(state); + LuaInstance* instance; + lua_getallocf(internalState, reinterpret_cast(&instance)); + if (instance->m_clock.GetMilliseconds() > instance->m_timeLimit) - luaL_error(state, "maximum execution time exceeded"); + luaL_error(internalState, "maximum execution time exceeded"); } } diff --git a/src/Nazara/Lua/LuaState.cpp b/src/Nazara/Lua/LuaState.cpp new file mode 100644 index 000000000..f71504ab7 --- /dev/null +++ b/src/Nazara/Lua/LuaState.cpp @@ -0,0 +1,834 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Lua scripting module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + LuaType FromLuaType(int type) + { + switch (type) + { + case LUA_TBOOLEAN: + return LuaType_Boolean; + + case LUA_TFUNCTION: + return LuaType_Function; + + case LUA_TLIGHTUSERDATA: + return LuaType_LightUserdata; + + case LUA_TNIL: + return LuaType_Nil; + + case LUA_TNONE: + return LuaType_None; + + case LUA_TNUMBER: + return LuaType_Number; + + case LUA_TSTRING: + return LuaType_String; + + case LUA_TTABLE: + return LuaType_Table; + + case LUA_TTHREAD: + return LuaType_Thread; + + case LUA_TUSERDATA: + return LuaType_Userdata; + + default: + return LuaType_None; + } + } + + struct StreamData + { + Stream* stream; + char buffer[NAZARA_CORE_FILE_BUFFERSIZE]; + }; + + const char* StreamReader(lua_State* internalState, void* data, std::size_t* size) + { + NazaraUnused(internalState); + + StreamData* streamData = static_cast(data); + + if (streamData->stream->EndOfStream()) + return nullptr; + else + { + *size = streamData->stream->Read(streamData->buffer, NAZARA_CORE_FILE_BUFFERSIZE); + return streamData->buffer; + } + } + + int s_comparisons[] = { + LUA_OPEQ, // LuaComparison_Equality + LUA_OPLT, // LuaComparison_Less + LUA_OPLE // LuaComparison_LessOrEqual + }; + + static_assert(sizeof(s_comparisons)/sizeof(int) == LuaComparison_Max+1, "Lua comparison array is incomplete"); + + int s_operations[] = { + LUA_OPADD, // LuaOperation_Addition + LUA_OPBAND, // LuaOperation_BitwiseAnd + LUA_OPSHL, // LuaOperation_BitwiseLeftShift + LUA_OPBNOT, // LuaOperation_BitwiseNot + LUA_OPBOR, // LuaOperation_BitwiseOr + LUA_OPSHR, // LuaOperation_BitwiseRightShift + LUA_OPBXOR, // LuaOperation_BitwiseXOr + LUA_OPDIV, // LuaOperation_Division + LUA_OPPOW, // LuaOperation_Exponentiation + LUA_OPIDIV, // LuaOperation_FloorDivision + LUA_OPMUL, // LuaOperation_Multiplication + LUA_OPMOD, // LuaOperation_Modulo + LUA_OPUNM, // LuaOperation_Negation + LUA_OPSUB // LuaOperation_Substraction + }; + + static_assert(sizeof(s_operations)/sizeof(int) == LuaOperation_Max+1, "Lua operation array is incomplete"); + + int s_types[] = { + LUA_TBOOLEAN, // LuaType_Boolean + LUA_TFUNCTION, // LuaType_Function + LUA_TLIGHTUSERDATA, // LuaType_LightUserdata + LUA_TNIL, // LuaType_Nil + LUA_TNUMBER, // LuaType_Number + LUA_TNONE, // LuaType_None + LUA_TSTRING, // LuaType_String + LUA_TTABLE, // LuaType_Table + LUA_TTHREAD, // LuaType_Thread + LUA_TUSERDATA // LuaType_Userdata + }; + + static_assert(sizeof(s_types)/sizeof(int) == LuaType_Max+1, "Lua type array is incomplete"); + } + + LuaState::LuaState(LuaState&& state) noexcept : + m_lastError(state.m_lastError), + m_instance(state.m_instance), + m_state(state.m_state) + { + } + + void LuaState::ArgCheck(bool condition, unsigned int argNum, const char* error) const + { + luaL_argcheck(m_state, condition, argNum, error); + } + + void LuaState::ArgCheck(bool condition, unsigned int argNum, const String& error) const + { + luaL_argcheck(m_state, condition, argNum, error.GetConstBuffer()); + } + + int LuaState::ArgError(unsigned int argNum, const char* error) const + { + return luaL_argerror(m_state, argNum, error); + } + + int LuaState::ArgError(unsigned int argNum, const String& error) const + { + return luaL_argerror(m_state, argNum, error.GetConstBuffer()); + } + + bool LuaState::Call(unsigned int argCount) + { + return Run(argCount, LUA_MULTRET); + } + + bool LuaState::Call(unsigned int argCount, unsigned int resultCount) + { + return Run(argCount, resultCount); + } + + void LuaState::CheckAny(int index) const + { + luaL_checkany(m_state, index); + } + + bool LuaState::CheckBoolean(int index) const + { + if (lua_isnoneornil(m_state, index)) + { + const char* msg = lua_pushfstring(m_state, "%s expected, got %s", lua_typename(m_state, LUA_TBOOLEAN), luaL_typename(m_state, index)); + luaL_argerror(m_state, index, msg); // Lance une exception + return false; + } + + return lua_toboolean(m_state, index) != 0; + } + + bool LuaState::CheckBoolean(int index, bool defValue) const + { + if (lua_isnoneornil(m_state, index)) + return defValue; + + return lua_toboolean(m_state, index) != 0; + } + + long long LuaState::CheckInteger(int index) const + { + return luaL_checkinteger(m_state, index); + } + + long long LuaState::CheckInteger(int index, long long defValue) const + { + return luaL_optinteger(m_state, index, defValue); + } + + double LuaState::CheckNumber(int index) const + { + return luaL_checknumber(m_state, index); + } + + double LuaState::CheckNumber(int index, double defValue) const + { + return luaL_optnumber(m_state, index, defValue); + } + + void LuaState::CheckStack(int space, const char* error) const + { + luaL_checkstack(m_state, space, error); + } + + void LuaState::CheckStack(int space, const String& error) const + { + CheckStack(space, error.GetConstBuffer()); + } + + const char* LuaState::CheckString(int index, std::size_t* length) const + { + return luaL_checklstring(m_state, index, length); + } + + const char* LuaState::CheckString(int index, const char* defValue, std::size_t* length) const + { + return luaL_optlstring(m_state, index, defValue, length); + } + + void LuaState::CheckType(int index, LuaType type) const + { + #ifdef NAZARA_DEBUG + if (type > LuaType_Max) + { + NazaraError("Lua type out of enum"); + return; + } + #endif + + luaL_checktype(m_state, index, s_types[type]); + } + + void* LuaState::CheckUserdata(int index, const char* tname) const + { + return luaL_checkudata(m_state, index, tname); + } + + void* LuaState::CheckUserdata(int index, const String& tname) const + { + return luaL_checkudata(m_state, index, tname.GetConstBuffer()); + } + + bool LuaState::Compare(int index1, int index2, LuaComparison comparison) const + { + #ifdef NAZARA_DEBUG + if (comparison > LuaComparison_Max) + { + NazaraError("Lua comparison out of enum"); + return false; + } + #endif + + return (lua_compare(m_state, index1, index2, s_comparisons[comparison]) != 0); + } + + void LuaState::Compute(LuaOperation operation) const + { + #ifdef NAZARA_DEBUG + if (operation > LuaOperation_Max) + { + NazaraError("Lua operation out of enum"); + return; + } + #endif + + lua_arith(m_state, s_operations[operation]); + } + + void LuaState::Concatenate(int count) const + { + lua_concat(m_state, count); + } + + int LuaState::CreateReference() + { + return luaL_ref(m_state, LUA_REGISTRYINDEX); + } + + void LuaState::DestroyReference(int ref) + { + luaL_unref(m_state, LUA_REGISTRYINDEX, ref); + } + + String LuaState::DumpStack() const + { + StringStream stream; + unsigned int stackTop = GetStackTop(); + stream << stackTop << " entries\n"; + + for (unsigned int i = 1; i <= stackTop; ++i) + { + stream << i << ": "; + switch (GetType(i)) + { + case LuaType_Boolean: + stream << "Boolean(" << ToBoolean(i) << ')'; + break; + + case LuaType_Function: + stream << "Function(" << ToPointer(i) << ')'; + break; + + case LuaType_LightUserdata: + case LuaType_Userdata: + stream << "Userdata(" << ToUserdata(i) << ')'; + break; + + case LuaType_Nil: + stream << "Nil"; + break; + + case LuaType_None: + stream << "None"; + break; + + case LuaType_Number: + stream << "Number(" << ToNumber(i) << ')'; + break; + + case LuaType_String: + stream << "String(" << ToString(i) << ')'; + break; + + case LuaType_Table: + stream << "Table(" << ToPointer(i) << ')'; + break; + + case LuaType_Thread: + stream << "Thread(" << ToPointer(i) << ')'; + break; + + default: + stream << "Unknown(" << ToPointer(i) << ')'; + break; + } + + stream << '\n'; + } + + return stream.ToString(); + } + + void LuaState::Error(const char* message) const + { + luaL_error(m_state, message); + } + + void LuaState::Error(const String& message) const + { + luaL_error(m_state, message.GetConstBuffer()); + } + + bool LuaState::Execute(const String& code) + { + if (code.IsEmpty()) + return true; + + if (luaL_loadstring(m_state, code.GetConstBuffer()) != 0) + { + m_lastError = lua_tostring(m_state, -1); + lua_pop(m_state, 1); + + return false; + } + + return Run(0, 0); + } + + bool LuaState::ExecuteFromFile(const String& filePath) + { + File file(filePath); + if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) + { + NazaraError("Failed to open file"); + return false; + } + + std::size_t length = static_cast(file.GetSize()); + + String source(length, '\0'); + + if (file.Read(&source[0], length) != length) + { + NazaraError("Failed to read file"); + return false; + } + + file.Close(); + + return Execute(source); + } + + bool LuaState::ExecuteFromMemory(const void* data, std::size_t size) + { + MemoryView stream(data, size); + return ExecuteFromStream(stream); + } + + bool LuaState::ExecuteFromStream(Stream& stream) + { + StreamData data; + data.stream = &stream; + + if (lua_load(m_state, StreamReader, &data, "C++", nullptr) != 0) + { + m_lastError = lua_tostring(m_state, -1); + lua_pop(m_state, 1); + + return false; + } + + return Run(0, 0); + } + + int LuaState::GetAbsIndex(int index) const + { + return lua_absindex(m_state, index); + } + + LuaType LuaState::GetField(const char* fieldName, int tableIndex) const + { + return FromLuaType(lua_getfield(m_state, tableIndex, fieldName)); + } + + LuaType LuaState::GetField(const String& fieldName, int tableIndex) const + { + return FromLuaType(lua_getfield(m_state, tableIndex, fieldName.GetConstBuffer())); + } + + LuaType LuaState::GetGlobal(const char* name) const + { + return FromLuaType(lua_getglobal(m_state, name)); + } + + LuaType LuaState::GetGlobal(const String& name) const + { + return FromLuaType(lua_getglobal(m_state, name.GetConstBuffer())); + } + + LuaType LuaState::GetMetatable(const char* tname) const + { + return FromLuaType(luaL_getmetatable(m_state, tname)); + } + + LuaType LuaState::GetMetatable(const String& tname) const + { + return FromLuaType(luaL_getmetatable(m_state, tname.GetConstBuffer())); + } + + bool LuaState::GetMetatable(int index) const + { + return lua_getmetatable(m_state, index) != 0; + } + + unsigned int LuaState::GetStackTop() const + { + return static_cast(lua_gettop(m_state)); + } + + LuaType LuaState::GetTable(int index) const + { + return FromLuaType(lua_gettable(m_state, index)); + } + + LuaType LuaState::GetTableRaw(int index) const + { + return FromLuaType(lua_rawget(m_state, index)); + } + + LuaType LuaState::GetType(int index) const + { + return FromLuaType(lua_type(m_state, index)); + } + + const char* LuaState::GetTypeName(LuaType type) const + { + #ifdef NAZARA_DEBUG + if (type > LuaType_Max) + { + NazaraError("Lua type out of enum"); + return nullptr; + } + #endif + + return lua_typename(m_state, s_types[type]); + } + + void LuaState::Insert(int index) const + { + lua_insert(m_state, index); + } + + bool LuaState::IsOfType(int index, LuaType type) const + { + switch (type) + { + case LuaType_Boolean: + return lua_isboolean(m_state, index) != 0; + + case LuaType_Function: + return lua_isfunction(m_state, index) != 0; + + case LuaType_LightUserdata: + return lua_islightuserdata(m_state, index) != 0; + + case LuaType_Nil: + return lua_isnil(m_state, index) != 0; + + case LuaType_None: + return lua_isnone(m_state, index) != 0; + + case LuaType_Number: + return lua_isnumber(m_state, index) != 0; + + case LuaType_String: + return lua_isstring(m_state, index) != 0; + + case LuaType_Table: + return lua_istable(m_state, index) != 0; + + case LuaType_Thread: + return lua_isthread(m_state, index) != 0; + + case LuaType_Userdata: + return lua_isuserdata(m_state, index) != 0; + } + + NazaraError("Lua type not handled (0x" + String::Number(type, 16) + ')'); + return false; + } + + bool LuaState::IsOfType(int index, const char* tname) const + { + void* ud = luaL_testudata(m_state, index, tname); + return ud != nullptr; + } + + bool LuaState::IsOfType(int index, const String& tname) const + { + return IsOfType(index, tname.GetConstBuffer()); + } + + bool LuaState::IsValid(int index) const + { + return lua_isnoneornil(m_state, index) == 0; + } + + long long LuaState::Length(int index) const + { + return luaL_len(m_state, index); + } + + std::size_t LuaState::LengthRaw(int index) const + { + return lua_rawlen(m_state, index); + } + + void LuaState::MoveTo(LuaState* instance, int n) const + { + lua_xmove(m_state, instance->m_state, n); + } + + bool LuaState::NewMetatable(const char* str) + { + return luaL_newmetatable(m_state, str) != 0; + } + + bool LuaState::NewMetatable(const String& str) + { + return luaL_newmetatable(m_state, str.GetConstBuffer()) != 0; + } + + bool LuaState::Next(int index) const + { + return lua_next(m_state, index) != 0; + } + + void LuaState::Pop(unsigned int n) const + { + lua_pop(m_state, static_cast(n)); + } + + void LuaState::PushBoolean(bool value) const + { + lua_pushboolean(m_state, (value) ? 1 : 0); + } + + void LuaState::PushCFunction(LuaCFunction func, unsigned int upvalueCount) const + { + lua_pushcclosure(m_state, func, upvalueCount); + } + + void LuaState::PushFunction(LuaFunction func) const + { + LuaFunction* luaFunc = static_cast(lua_newuserdata(m_state, sizeof(LuaFunction))); + PlacementNew(luaFunc, std::move(func)); + + lua_pushcclosure(m_state, ProxyFunc, 1); + } + + void LuaState::PushInteger(long long value) const + { + lua_pushinteger(m_state, value); + } + + void LuaState::PushLightUserdata(void* value) const + { + lua_pushlightuserdata(m_state, value); + } + + void LuaState::PushMetatable(const char* str) const + { + luaL_getmetatable(m_state, str); + } + + void LuaState::PushMetatable(const String& str) const + { + luaL_getmetatable(m_state, str.GetConstBuffer()); + } + + void LuaState::PushNil() const + { + lua_pushnil(m_state); + } + + void LuaState::PushNumber(double value) const + { + lua_pushnumber(m_state, value); + } + + void LuaState::PushReference(int ref) const + { + lua_rawgeti(m_state, LUA_REGISTRYINDEX, ref); + } + + void LuaState::PushString(const char* str) const + { + lua_pushstring(m_state, str); + } + + void LuaState::PushString(const char* str, std::size_t size) const + { + lua_pushlstring(m_state, str, size); + } + + void LuaState::PushString(const String& str) const + { + lua_pushlstring(m_state, str.GetConstBuffer(), str.GetSize()); + } + + void LuaState::PushTable(std::size_t sequenceElementCount, std::size_t arrayElementCount) const + { + constexpr std::size_t maxInt = std::numeric_limits::max(); + lua_createtable(m_state, static_cast(std::min(sequenceElementCount, maxInt)), static_cast(std::min(arrayElementCount, maxInt))); + } + + void* LuaState::PushUserdata(std::size_t size) const + { + return lua_newuserdata(m_state, size); + } + + void LuaState::PushValue(int index) const + { + lua_pushvalue(m_state, index); + } + + void LuaState::Remove(int index) const + { + lua_remove(m_state, index); + } + + void LuaState::Replace(int index) const + { + lua_replace(m_state, index); + } + + void LuaState::SetField(const char* name, int tableIndex) const + { + lua_setfield(m_state, tableIndex, name); + } + + void LuaState::SetField(const String& name, int tableIndex) const + { + lua_setfield(m_state, tableIndex, name.GetConstBuffer()); + } + + void LuaState::SetGlobal(const char* name) + { + lua_setglobal(m_state, name); + } + + void LuaState::SetGlobal(const String& name) + { + lua_setglobal(m_state, name.GetConstBuffer()); + } + + void LuaState::SetMetatable(const char* tname) const + { + luaL_setmetatable(m_state, tname); + } + + void LuaState::SetMetatable(const String& tname) const + { + luaL_setmetatable(m_state, tname.GetConstBuffer()); + } + + void LuaState::SetMetatable(int index) const + { + lua_setmetatable(m_state, index); + } + + void LuaState::SetTable(int index) const + { + lua_settable(m_state, index); + } + + void LuaState::SetTableRaw(int index) const + { + lua_rawset(m_state, index); + } + + bool LuaState::ToBoolean(int index) const + { + return lua_toboolean(m_state, index) != 0; + } + + long long LuaState::ToInteger(int index, bool* succeeded) const + { + int success; + long long result = lua_tointegerx(m_state, index, &success); + + if (succeeded) + *succeeded = (success != 0); + + return result; + } + + double LuaState::ToNumber(int index, bool* succeeded) const + { + int success; + double result = lua_tonumberx(m_state, index, &success); + + if (succeeded) + *succeeded = (success != 0); + + return result; + } + + const void* LuaState::ToPointer(int index) const + { + return lua_topointer(m_state, index); + } + + const char* LuaState::ToString(int index, std::size_t* length) const + { + return lua_tolstring(m_state, index, length); + } + + void* LuaState::ToUserdata(int index) const + { + return lua_touserdata(m_state, index); + } + + void* LuaState::ToUserdata(int index, const char* tname) const + { + return luaL_testudata(m_state, index, tname); + } + + void* LuaState::ToUserdata(int index, const String& tname) const + { + return luaL_testudata(m_state, index, tname.GetConstBuffer()); + } + + LuaState& LuaState::operator=(LuaState&& state) noexcept + { + m_instance = state.m_instance; + m_lastError = std::move(state.m_lastError); + m_state = state.m_state; + + return *this; + } + + bool LuaState::Run(int argCount, int resultCount) + { + if (m_instance->m_level++ == 0) + m_instance->m_clock.Restart(); + + int status = lua_pcall(m_state, argCount, resultCount, 0); + + m_instance->m_level--; + + if (status != 0) + { + m_lastError = lua_tostring(m_state, -1); + lua_pop(m_state, 1); + + return false; + } + + return true; + } + + int LuaState::GetIndexOfUpValue(int upValue) + { + return lua_upvalueindex(upValue); + } + + LuaState LuaState::GetState(lua_State* internalState) + { + LuaInstance* instance; + lua_getallocf(internalState, reinterpret_cast(&instance)); + + return LuaState(instance, internalState); + } + + int LuaState::ProxyFunc(lua_State* internalState) + { + LuaFunction& func = *static_cast(lua_touserdata(internalState, lua_upvalueindex(1))); + LuaState state = GetState(internalState); + + return func(state); + } + +} From 01edc4fb218d670e1c561ef1f354cd5b794abef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 8 Jun 2017 15:53:17 +0200 Subject: [PATCH 219/243] Add coroutine support (WIP) --- include/Nazara/Lua/LuaCoroutine.hpp | 44 +++++++++++++++++++++++ include/Nazara/Lua/LuaCoroutine.inl | 25 +++++++++++++ include/Nazara/Lua/LuaInstance.hpp | 1 + include/Nazara/Lua/LuaState.hpp | 12 +++---- include/Nazara/Lua/LuaState.inl | 8 +++-- src/Nazara/Lua/LuaCoroutine.cpp | 55 +++++++++++++++++++++++++++++ src/Nazara/Lua/LuaInstance.cpp | 2 +- src/Nazara/Lua/LuaState.cpp | 23 ++++++++---- 8 files changed, 154 insertions(+), 16 deletions(-) create mode 100644 include/Nazara/Lua/LuaCoroutine.hpp create mode 100644 include/Nazara/Lua/LuaCoroutine.inl create mode 100644 src/Nazara/Lua/LuaCoroutine.cpp diff --git a/include/Nazara/Lua/LuaCoroutine.hpp b/include/Nazara/Lua/LuaCoroutine.hpp new file mode 100644 index 000000000..b145cfe22 --- /dev/null +++ b/include/Nazara/Lua/LuaCoroutine.hpp @@ -0,0 +1,44 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Lua scripting module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_LUACOROUTINE_HPP +#define NAZARA_LUACOROUTINE_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_LUA_API LuaCoroutine : public LuaState + { + friend class LuaState; + + public: + LuaCoroutine(const LuaCoroutine&) = delete; + inline LuaCoroutine(LuaCoroutine&& instance); + ~LuaCoroutine(); + + bool CanResume() const; + + Ternary Resume(unsigned int argCount = 0); + + LuaCoroutine& operator=(const LuaCoroutine&) = delete; + inline LuaCoroutine& operator=(LuaCoroutine&& instance); + + private: + LuaCoroutine(lua_State* internalState, int refIndex); + + bool Run(int argCount, int resultCount) override; + + int m_ref; + }; +} + +#include + +#endif // NAZARA_LUACOROUTINE_HPP diff --git a/include/Nazara/Lua/LuaCoroutine.inl b/include/Nazara/Lua/LuaCoroutine.inl new file mode 100644 index 000000000..7dcdd0e07 --- /dev/null +++ b/include/Nazara/Lua/LuaCoroutine.inl @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Lua scripting module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include + +namespace Nz +{ + inline LuaCoroutine::LuaCoroutine(LuaCoroutine&& instance) : + LuaState(std::move(instance)), + m_ref(instance.m_ref) + { + instance.m_ref = -1; + } + + inline LuaCoroutine& LuaCoroutine::operator=(LuaCoroutine&& instance) + { + LuaState::operator=(std::move(instance)); + + m_ref = instance.m_ref; + instance.m_ref = -1; + + return *this; + } +} diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index 45d19ddba..a5d631645 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -16,6 +16,7 @@ namespace Nz { class NAZARA_LUA_API LuaInstance : public LuaState { + friend class LuaCoroutine; friend class LuaState; public: diff --git a/include/Nazara/Lua/LuaState.hpp b/include/Nazara/Lua/LuaState.hpp index a34ec27fd..f3bfdc34a 100644 --- a/include/Nazara/Lua/LuaState.hpp +++ b/include/Nazara/Lua/LuaState.hpp @@ -21,6 +21,7 @@ struct lua_State; namespace Nz { + class LuaCoroutine; class LuaInstance; class LuaState; @@ -115,6 +116,7 @@ namespace Nz void MoveTo(LuaState* instance, int n) const; + LuaCoroutine NewCoroutine(); bool NewMetatable(const char* str); bool NewMetatable(const String& str); bool Next(int index = -2) const; @@ -158,10 +160,8 @@ namespace Nz void SetMetatable(const char* tname) const; void SetMetatable(const String& tname) const; void SetMetatable(int index) const; - void SetMemoryLimit(std::size_t memoryLimit); void SetTable(int index = -3) const; void SetTableRaw(int index = -3) const; - void SetTimeLimit(UInt32 timeLimit); bool ToBoolean(int index) const; long long ToInteger(int index, bool* succeeded = nullptr) const; @@ -176,18 +176,18 @@ namespace Nz LuaState& operator=(LuaState&& instance) noexcept; static int GetIndexOfUpValue(int upValue); - static LuaState GetState(lua_State* internalState); + static LuaInstance& GetInstance(lua_State* internalState); + static inline LuaState GetState(lua_State* internalState); protected: - LuaState(LuaInstance* instance, lua_State* internalState); + LuaState(lua_State* internalState); template T CheckBounds(int index, long long value) const; - bool Run(int argCount, int resultCount); + virtual bool Run(int argCount, int resultCount); static int ProxyFunc(lua_State* internalState); String m_lastError; - LuaInstance* m_instance; lua_State* m_state; }; } diff --git a/include/Nazara/Lua/LuaState.inl b/include/Nazara/Lua/LuaState.inl index dbc9016cf..fa4ecaaf0 100644 --- a/include/Nazara/Lua/LuaState.inl +++ b/include/Nazara/Lua/LuaState.inl @@ -15,8 +15,7 @@ namespace Nz { - inline LuaState::LuaState(LuaInstance* instance, lua_State* internalState) : - m_instance(instance), + inline LuaState::LuaState(lua_State* internalState) : m_state(internalState) { } @@ -785,4 +784,9 @@ namespace Nz return static_cast(value); } + + inline LuaState LuaState::GetState(lua_State* internalState) + { + return LuaState(internalState); + } } diff --git a/src/Nazara/Lua/LuaCoroutine.cpp b/src/Nazara/Lua/LuaCoroutine.cpp new file mode 100644 index 000000000..ea73af31a --- /dev/null +++ b/src/Nazara/Lua/LuaCoroutine.cpp @@ -0,0 +1,55 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Lua scripting module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + LuaCoroutine::LuaCoroutine(lua_State* internalState, int refIndex) : + LuaState(internalState), + m_ref(refIndex) + { + } + + LuaCoroutine::~LuaCoroutine() + { + if (m_ref >= 0) + DestroyReference(m_ref); + } + + bool LuaCoroutine::CanResume() const + { + return lua_status(m_state) == LUA_YIELD; + } + + Ternary LuaCoroutine::Resume(unsigned int argCount) + { + LuaInstance& instance = GetInstance(m_state); + if (instance.m_level++ == 0) + instance.m_clock.Restart(); + + int status = lua_resume(m_state, nullptr, argCount); + instance.m_level--; + + if (status == LUA_OK) + return Ternary_True; + else if (status == LUA_YIELD) + return Ternary_Unknown; + else + { + m_lastError = ToString(-1); + Pop(); + return Ternary_False; + } + } + + bool LuaCoroutine::Run(int argCount, int /*resultCount*/) + { + return Resume(argCount) != Ternary_False; + } +} diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 607edc126..a0d5d3ff7 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -30,7 +30,7 @@ namespace Nz } LuaInstance::LuaInstance() : - LuaState(this, lua_newstate(MemoryAllocator, this)), + LuaState(nullptr), m_memoryLimit(0), m_memoryUsage(0), m_timeLimit(1000), diff --git a/src/Nazara/Lua/LuaState.cpp b/src/Nazara/Lua/LuaState.cpp index f71504ab7..94170aee0 100644 --- a/src/Nazara/Lua/LuaState.cpp +++ b/src/Nazara/Lua/LuaState.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -127,7 +128,6 @@ namespace Nz LuaState::LuaState(LuaState&& state) noexcept : m_lastError(state.m_lastError), - m_instance(state.m_instance), m_state(state.m_state) { } @@ -570,6 +570,14 @@ namespace Nz lua_xmove(m_state, instance->m_state, n); } + LuaCoroutine LuaState::NewCoroutine() + { + lua_State* thread = lua_newthread(m_state); + int ref = luaL_ref(m_state, LUA_REGISTRYINDEX); + + return LuaCoroutine(thread, ref); + } + bool LuaState::NewMetatable(const char* str) { return luaL_newmetatable(m_state, str) != 0; @@ -783,7 +791,6 @@ namespace Nz LuaState& LuaState::operator=(LuaState&& state) noexcept { - m_instance = state.m_instance; m_lastError = std::move(state.m_lastError); m_state = state.m_state; @@ -792,12 +799,14 @@ namespace Nz bool LuaState::Run(int argCount, int resultCount) { - if (m_instance->m_level++ == 0) - m_instance->m_clock.Restart(); + LuaInstance& instance = GetInstance(m_state); + + if (instance.m_level++ == 0) + instance.m_clock.Restart(); int status = lua_pcall(m_state, argCount, resultCount, 0); - m_instance->m_level--; + instance.m_level--; if (status != 0) { @@ -815,12 +824,12 @@ namespace Nz return lua_upvalueindex(upValue); } - LuaState LuaState::GetState(lua_State* internalState) + LuaInstance& LuaState::GetInstance(lua_State* internalState) { LuaInstance* instance; lua_getallocf(internalState, reinterpret_cast(&instance)); - return LuaState(instance, internalState); + return *instance; } int LuaState::ProxyFunc(lua_State* internalState) From 9117deb609b927d9e7abb52bf5629218f001c96b Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 9 Jun 2017 01:46:04 +0200 Subject: [PATCH 220/243] Update global headers --- include/Nazara/Core.hpp | 1 + include/Nazara/Lua.hpp | 2 ++ include/Nazara/Network.hpp | 1 + include/Nazara/Utility.hpp | 2 ++ 4 files changed, 6 insertions(+) diff --git a/include/Nazara/Core.hpp b/include/Nazara/Core.hpp index 419ddaae9..606d6969a 100644 --- a/include/Nazara/Core.hpp +++ b/include/Nazara/Core.hpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Lua.hpp b/include/Nazara/Lua.hpp index a0e68204c..bd7ddb24c 100644 --- a/include/Nazara/Lua.hpp +++ b/include/Nazara/Lua.hpp @@ -33,6 +33,8 @@ #include #include #include +#include #include +#include #endif // NAZARA_GLOBAL_LUA_HPP diff --git a/include/Nazara/Network.hpp b/include/Nazara/Network.hpp index 41b7fce71..1b2dc72c5 100644 --- a/include/Nazara/Network.hpp +++ b/include/Nazara/Network.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Utility.hpp b/include/Nazara/Utility.hpp index 3734b919e..fbb100476 100644 --- a/include/Nazara/Utility.hpp +++ b/include/Nazara/Utility.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,7 @@ #include #include #include +#include #include #include #include From 4ce7db09d602741420d460176f095b0c6a2726cb Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 9 Jun 2017 01:47:15 +0200 Subject: [PATCH 221/243] Lua/LuaCoroutine: Fix inline include --- include/Nazara/Lua/LuaCoroutine.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Lua/LuaCoroutine.hpp b/include/Nazara/Lua/LuaCoroutine.hpp index b145cfe22..a740f635b 100644 --- a/include/Nazara/Lua/LuaCoroutine.hpp +++ b/include/Nazara/Lua/LuaCoroutine.hpp @@ -39,6 +39,6 @@ namespace Nz }; } -#include +#include #endif // NAZARA_LUACOROUTINE_HPP From 35ba78510be8ce3d4814d3c816e8cdcb14c6017b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 9 Jun 2017 02:06:14 +0200 Subject: [PATCH 222/243] Fix compilation --- src/Nazara/Lua/LuaCoroutine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Lua/LuaCoroutine.cpp b/src/Nazara/Lua/LuaCoroutine.cpp index ea73af31a..197244134 100644 --- a/src/Nazara/Lua/LuaCoroutine.cpp +++ b/src/Nazara/Lua/LuaCoroutine.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace Nz From ab1eccde8247f579184c047933796eb51b8e90c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 9 Jun 2017 02:07:51 +0200 Subject: [PATCH 223/243] Fix compilation --- src/Nazara/Lua/LuaCoroutine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Lua/LuaCoroutine.cpp b/src/Nazara/Lua/LuaCoroutine.cpp index ea73af31a..197244134 100644 --- a/src/Nazara/Lua/LuaCoroutine.cpp +++ b/src/Nazara/Lua/LuaCoroutine.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace Nz From 78182502e3db5c786c96d8d7b61973cd7b33e4f6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 10 Jun 2017 22:29:17 +0200 Subject: [PATCH 224/243] Lua/LuaInstance: Fix missing memory/time methods --- include/Nazara/Lua/LuaInstance.hpp | 9 ++++++++ include/Nazara/Lua/LuaInstance.inl | 36 ++++++++++++++++++++++-------- src/Nazara/Lua/LuaInstance.cpp | 18 ++++++++++----- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index a5d631645..93374958b 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -25,10 +25,19 @@ namespace Nz LuaInstance(LuaInstance&& instance) = default; ~LuaInstance(); + inline std::size_t GetMemoryLimit() const; + inline std::size_t GetMemoryUsage() const; + inline UInt32 GetTimeLimit() const; + + inline void SetMemoryLimit(std::size_t memoryLimit); + inline void SetTimeLimit(UInt32 limit); + LuaInstance& operator=(const LuaInstance&) = delete; LuaInstance& operator=(LuaInstance&& instance) = default; private: + inline void SetMemoryUsage(std::size_t memoryUsage); + static void* MemoryAllocator(void *ud, void *ptr, std::size_t osize, std::size_t nsize); static void TimeLimiter(lua_State* internalState, lua_Debug* debug); diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index f4394eb6b..6752eb0e0 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -3,16 +3,34 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include namespace Nz { + inline std::size_t LuaInstance::GetMemoryLimit() const + { + return m_memoryLimit; + } + + inline std::size_t LuaInstance::GetMemoryUsage() const + { + return m_memoryUsage; + } + + inline UInt32 LuaInstance::GetTimeLimit() const + { + return m_timeLimit; + } + + inline void LuaInstance::SetMemoryLimit(std::size_t memoryLimit) + { + m_memoryLimit = m_memoryLimit; + } + + inline void LuaInstance::SetTimeLimit(UInt32 limit) + { + m_timeLimit = limit; + } } + +#include diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index a0d5d3ff7..cd47ac5c7 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -48,15 +49,22 @@ namespace Nz lua_close(m_state); } + inline void LuaInstance::SetMemoryUsage(std::size_t memoryUsage) + { + m_memoryUsage = memoryUsage; + } + void* LuaInstance::MemoryAllocator(void* ud, void* ptr, std::size_t osize, std::size_t nsize) { LuaInstance* instance = static_cast(ud); - std::size_t& memoryLimit = instance->m_memoryLimit; - std::size_t& memoryUsage = instance->m_memoryUsage; + std::size_t memoryLimit = instance->GetMemoryLimit(); + std::size_t memoryUsage = instance->GetMemoryUsage(); if (nsize == 0) { - memoryUsage -= osize; + assert(memoryUsage >= osize); + + instance->SetMemoryUsage(memoryUsage - osize); std::free(ptr); return nullptr; @@ -73,7 +81,7 @@ namespace Nz return nullptr; } - memoryUsage = usage; + instance->SetMemoryUsage(usage); return std::realloc(ptr, nsize); } @@ -86,7 +94,7 @@ namespace Nz LuaInstance* instance; lua_getallocf(internalState, reinterpret_cast(&instance)); - if (instance->m_clock.GetMilliseconds() > instance->m_timeLimit) + if (instance->m_clock.GetMilliseconds() > instance->GetTimeLimit()) luaL_error(internalState, "maximum execution time exceeded"); } } From 713f7dfd5ba328cd4bef46524ebc10d517f397a1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 10 Jun 2017 22:32:51 +0200 Subject: [PATCH 225/243] SDK/LuaBinding: Fix TextureManager binding --- SDK/src/NDK/Lua/LuaBinding_Renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp b/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp index 064d21cfe..1ab24cedb 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp @@ -84,7 +84,7 @@ namespace Ndk } /*********************************** Nz::TextureManager ***********************************/ - textureManager.Reset("textureManager"); + textureManager.Reset("TextureManager"); { textureManager.BindStaticMethod("Clear", &Nz::TextureManager::Clear); textureManager.BindStaticMethod("Get", &Nz::TextureManager::Get); From 7875854e7dd16397d6f5854366fbbb0ad1b8b0dc Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Jun 2017 14:42:36 +0200 Subject: [PATCH 226/243] Lua/Binding: Fix unsigned integer binding --- include/Nazara/Lua/LuaState.hpp | 4 +++- include/Nazara/Lua/LuaState.inl | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Lua/LuaState.hpp b/include/Nazara/Lua/LuaState.hpp index f3bfdc34a..fe34d794a 100644 --- a/include/Nazara/Lua/LuaState.hpp +++ b/include/Nazara/Lua/LuaState.hpp @@ -15,6 +15,7 @@ #include #include #include +#include struct lua_Debug; struct lua_State; @@ -182,7 +183,8 @@ namespace Nz protected: LuaState(lua_State* internalState); - template T CheckBounds(int index, long long value) const; + template std::enable_if_t::value, T> CheckBounds(int index, long long value) const; + template std::enable_if_t::value, T> CheckBounds(int index, long long value) const; virtual bool Run(int argCount, int resultCount); static int ProxyFunc(lua_State* internalState); diff --git a/include/Nazara/Lua/LuaState.inl b/include/Nazara/Lua/LuaState.inl index fa4ecaaf0..da191d8a2 100644 --- a/include/Nazara/Lua/LuaState.inl +++ b/include/Nazara/Lua/LuaState.inl @@ -771,7 +771,7 @@ namespace Nz } template - T LuaState::CheckBounds(int index, long long value) const + std::enable_if_t::value, T> LuaState::CheckBounds(int index, long long value) const { constexpr long long minBounds = std::numeric_limits::min(); constexpr long long maxBounds = std::numeric_limits::max(); @@ -785,6 +785,21 @@ namespace Nz return static_cast(value); } + template + std::enable_if_t::value, T> LuaState::CheckBounds(int index, long long value) const + { + constexpr unsigned long long minBounds = 0; + constexpr unsigned long long maxBounds = std::numeric_limits::max(); + if (value < minBounds || value > maxBounds) + { + Nz::StringStream stream; + stream << "Argument #" << index << " is outside value range [" << minBounds << ", " << maxBounds << "] (" << value << ')'; + Error(stream); + } + + return static_cast(value); + } + inline LuaState LuaState::GetState(lua_State* internalState) { return LuaState(internalState); From 86fa6c50095d1350d7bd68457921785564defbf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 13 Jun 2017 15:05:55 +0200 Subject: [PATCH 227/243] SDK/LuaBinding: Bind IsValidHandle for handled types --- SDK/src/NDK/Lua/LuaBinding_SDK.cpp | 34 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp index a4ae0b792..c8411d086 100644 --- a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp @@ -69,6 +69,7 @@ namespace Ndk console.BindMethod("GetSize", &Console::GetSize); console.BindMethod("GetTextFont", &Console::GetTextFont); + console.BindMethod("IsValidHandle", &ConsoleHandle::IsValid); console.BindMethod("IsVisible", &Console::IsVisible); console.BindMethod("SendCharacter", &Console::SendCharacter); @@ -91,6 +92,7 @@ namespace Ndk entity.BindMethod("Kill", &Entity::Kill); entity.BindMethod("IsEnabled", &Entity::IsEnabled); entity.BindMethod("IsValid", &Entity::IsValid); + entity.BindMethod("IsValidHandle", &EntityHandle::IsValid); entity.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents); entity.BindMethod("__tostring", &EntityHandle::ToString); @@ -120,6 +122,8 @@ namespace Ndk /*********************************** Ndk::NodeComponent **********************************/ nodeComponent.Reset("NodeComponent"); { + nodeComponent.BindMethod("IsValidHandle", &NodeComponentHandle::IsValid); + nodeComponent.Inherit(utility.node, [] (NodeComponentHandle* handle) -> Nz::Node* { return handle->GetObject(); @@ -129,6 +133,8 @@ namespace Ndk /*********************************** Ndk::VelocityComponent **********************************/ velocityComponent.Reset("VelocityComponent"); { + velocityComponent.BindMethod("IsValidHandle", &VelocityComponentHandle::IsValid); + velocityComponent.SetGetter([] (Nz::LuaState& lua, VelocityComponentHandle& instance) { std::size_t length; @@ -165,6 +171,8 @@ namespace Ndk world.BindMethod("CreateEntity", &World::CreateEntity); world.BindMethod("CreateEntities", &World::CreateEntities); world.BindMethod("Clear", &World::Clear); + + world.BindMethod("IsValidHandle", &WorldHandle::IsValid); } #ifndef NDK_SERVER @@ -176,18 +184,20 @@ namespace Ndk return handle->GetObject(); }); - cameraComponent.BindMethod("GetFOV", &Ndk::CameraComponent::GetFOV); - cameraComponent.BindMethod("GetLayer", &Ndk::CameraComponent::GetLayer); + cameraComponent.BindMethod("GetFOV", &CameraComponent::GetFOV); + cameraComponent.BindMethod("GetLayer", &CameraComponent::GetLayer); - cameraComponent.BindMethod("SetFOV", &Ndk::CameraComponent::SetFOV); - cameraComponent.BindMethod("SetLayer", &Ndk::CameraComponent::SetLayer); - cameraComponent.BindMethod("SetProjectionType", &Ndk::CameraComponent::SetProjectionType); - cameraComponent.BindMethod("SetSize", (void(Ndk::CameraComponent::*)(const Nz::Vector2f&)) &Ndk::CameraComponent::SetSize); - //cameraComponent.BindMethod("SetTarget", &Ndk::CameraComponent::SetTarget); - cameraComponent.BindMethod("SetTargetRegion", &Ndk::CameraComponent::SetTargetRegion); - cameraComponent.BindMethod("SetViewport", &Ndk::CameraComponent::SetViewport); - cameraComponent.BindMethod("SetZFar", &Ndk::CameraComponent::SetZFar); - cameraComponent.BindMethod("SetZNear", &Ndk::CameraComponent::SetZNear); + cameraComponent.BindMethod("IsValidHandle", &CameraComponentHandle::IsValid); + + cameraComponent.BindMethod("SetFOV", &CameraComponent::SetFOV); + cameraComponent.BindMethod("SetLayer", &CameraComponent::SetLayer); + cameraComponent.BindMethod("SetProjectionType", &CameraComponent::SetProjectionType); + cameraComponent.BindMethod("SetSize", (void(CameraComponent::*)(const Nz::Vector2f&)) &CameraComponent::SetSize); + //cameraComponent.BindMethod("SetTarget", &CameraComponent::SetTarget); + cameraComponent.BindMethod("SetTargetRegion", &CameraComponent::SetTargetRegion); + cameraComponent.BindMethod("SetViewport", &CameraComponent::SetViewport); + cameraComponent.BindMethod("SetZFar", &CameraComponent::SetZFar); + cameraComponent.BindMethod("SetZNear", &CameraComponent::SetZNear); } /*********************************** Ndk::GraphicsComponent **********************************/ @@ -249,6 +259,8 @@ namespace Ndk lua.Error("No matching overload for method GetMemoryUsage"); return 0; }); + + graphicsComponent.BindMethod("IsValidHandle", &GraphicsComponentHandle::IsValid); } #endif From 6759abc878bc1ddd052f0d02a91148f31425f191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 14 Jun 2017 10:11:02 +0200 Subject: [PATCH 228/243] Core/Thread: Rework ThreadImpl:Sleep for POSIX systems (fix yield behavior) --- src/Nazara/Core/Posix/ThreadImpl.cpp | 48 ++++++++++------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/src/Nazara/Core/Posix/ThreadImpl.cpp b/src/Nazara/Core/Posix/ThreadImpl.cpp index c16424328..b3948ee5d 100644 --- a/src/Nazara/Core/Posix/ThreadImpl.cpp +++ b/src/Nazara/Core/Posix/ThreadImpl.cpp @@ -5,8 +5,9 @@ #include #include #include +#include +#include #include -#include #include namespace Nz @@ -39,37 +40,20 @@ namespace Nz void ThreadImpl::Sleep(UInt32 time) { - // code from SFML2 Unix SleepImpl.cpp source https://github.com/LaurentGomila/SFML/blob/master/src/SFML/System/Unix/SleepImpl.cpp + if (time == 0) + sched_yield(); + else + { + struct timespec ts; + ts.tv_sec = time / 1000; + ts.tv_nsec = (time - ts.tv_sec * 1000) * 1'000'000; - // usleep is not reliable enough (it might block the - // whole process instead of just the current thread) - // so we must use pthread_cond_timedwait instead - - // this implementation is inspired from Qt - - // get the current time - timeval tv; - gettimeofday(&tv, nullptr); - - // construct the time limit (current time + time to wait) - timespec ti; - ti.tv_nsec = (tv.tv_usec + (time % 1000)) * 1000; - ti.tv_sec = tv.tv_sec + (time / 1000) + (ti.tv_nsec / 1000000000); - ti.tv_nsec %= 1000000000; - - // create a mutex and thread condition - pthread_mutex_t mutex; - pthread_mutex_init(&mutex, nullptr); - pthread_cond_t condition; - pthread_cond_init(&condition, nullptr); - - // wait... - pthread_mutex_lock(&mutex); - pthread_cond_timedwait(&condition, &mutex, &ti); - pthread_mutex_unlock(&mutex); - - // destroy the mutex and condition - pthread_cond_destroy(&condition); - pthread_mutex_destroy(&mutex); + int r; + do + { + r = nanosleep(&ts, &ts); + } + while (r == -1 && errno == EINTR); + } } } From d4532ce7ff90cfe4d5c794345b9163ef59d924d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 15 Jun 2017 11:07:21 +0200 Subject: [PATCH 229/243] SDK/Lua: Bind HasComponent method --- SDK/src/NDK/Lua/LuaBinding_SDK.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp index c8411d086..8952ce7d9 100644 --- a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp @@ -103,6 +103,14 @@ namespace Ndk return bindingComponent->adder(state, handle); }); + entity.BindMethod("HasComponent", [this](Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int + { + LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); + + state.PushBoolean(handle->HasComponent(bindingComponent->index)); + return 1; + }); + entity.BindMethod("GetComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int { LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); From 5c63d305453901f333f1b56c4ae91e8c09cf8282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 15 Jun 2017 17:08:24 +0200 Subject: [PATCH 230/243] Lua/LuaInstance: Fix typo --- include/Nazara/Lua/LuaInstance.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index 6752eb0e0..59bf8d79e 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -24,7 +24,7 @@ namespace Nz inline void LuaInstance::SetMemoryLimit(std::size_t memoryLimit) { - m_memoryLimit = m_memoryLimit; + m_memoryLimit = memoryLimit; } inline void LuaInstance::SetTimeLimit(UInt32 limit) From e95d252cdeab518410d140886559a6f73a27e005 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Thu, 15 Jun 2017 18:03:19 +0200 Subject: [PATCH 231/243] Add lock file on Linux and the possibility to have two processes writing to the same one --- src/Nazara/Core/Posix/FileImpl.cpp | 48 +++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/src/Nazara/Core/Posix/FileImpl.cpp b/src/Nazara/Core/Posix/FileImpl.cpp index 5603ed79b..75b2275cc 100644 --- a/src/Nazara/Core/Posix/FileImpl.cpp +++ b/src/Nazara/Core/Posix/FileImpl.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz @@ -72,11 +73,47 @@ namespace Nz if (mode & OpenMode_Truncate) flags |= O_TRUNC; - ///TODO: lock - //if ((mode & OpenMode_Lock) == 0) - // shareMode |= FILE_SHARE_WRITE; - m_fileDescriptor = open64(filePath.GetConstBuffer(), flags, permissions); + + static struct flock lock; + + auto initialize_flock = [](struct flock& fileLock) + { + fileLock.l_type = F_WRLCK; + fileLock.l_start = 0; + fileLock.l_whence = SEEK_SET; + fileLock.l_len = 0; + fileLock.l_pid = getpid(); + }; + + initialize_flock(lock); + + if (fcntl(m_fileDescriptor, F_GETLK, &lock) == -1) + { + Close(); + NazaraError("Unable to detect presence of lock on the file"); + return false; + } + + if (lock.l_type != F_UNLCK) + { + Close(); + NazaraError("A lock is present on the file"); + return false; + } + + if (mode & OpenMode_Lock) + { + initialize_flock(lock); + + if (fcntl(m_fileDescriptor, F_SETLK, &lock) == -1) + { + Close(); + NazaraError("Unable to place a lock on the file"); + return false; + } + } + return m_fileDescriptor != -1; } @@ -128,10 +165,7 @@ namespace Nz std::size_t FileImpl::Write(const void* buffer, std::size_t size) { - lockf64(m_fileDescriptor, F_LOCK, size); ssize_t written = write(m_fileDescriptor, buffer, size); - lockf64(m_fileDescriptor, F_ULOCK, size); - m_endOfFileUpdated = false; return written; From 47a22c2785ece1cd9c8926e19f2d6735dafb3b0f Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Tue, 20 Jun 2017 06:53:39 +0200 Subject: [PATCH 232/243] Fix wrong aabb returned from PhysicsComponent2D (#127) --- src/Nazara/Physics2D/RigidBody2D.cpp | 11 +++++--- tests/SDK/NDK/Systems/PhysicsSystem2D.cpp | 34 +++++++++++++++++++++++ tests/SDK/NDK/Systems/PhysicsSystem3D.cpp | 2 +- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tests/SDK/NDK/Systems/PhysicsSystem2D.cpp diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 3b2f927f9..1ad96e0d0 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -121,11 +121,14 @@ namespace Nz Rectf RigidBody2D::GetAABB() const { - cpBB bb = cpBBNew(0.f, 0.f, 0.f, 0.f); - for (cpShape* shape : m_shapes) - bb = cpBBMerge(bb, cpShapeGetBB(shape)); + if (m_shapes.empty()) + return Rectf::Zero(); - return Rectf(Rect(bb.l, bb.t, bb.r - bb.l, bb.b - bb.t)); + cpBB bb = cpShapeGetBB(*m_shapes.begin()); + for (auto it = ++m_shapes.begin(); it != m_shapes.end(); ++it) + bb = cpBBMerge(bb, cpShapeGetBB(*it)); + + return Rectf(Rect(bb.l, bb.b, bb.r - bb.l, bb.t - bb.b)); } float RigidBody2D::GetAngularVelocity() const diff --git a/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp b/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp new file mode 100644 index 000000000..4bdb1e039 --- /dev/null +++ b/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include + +SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]") +{ + GIVEN("A world and an entity") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::NodeComponent& nodeComponent = entity->AddComponent(); + Nz::Vector2f position(2.f, 3.f); + nodeComponent.SetPosition(position); + Nz::Rectf aabb(0.f, 0.f, 16.f, 18.f); + Nz::BoxCollider2DRef collisionBox = Nz::BoxCollider2D::New(aabb); + Ndk::CollisionComponent2D& collisionComponent = entity->AddComponent(collisionBox); + Ndk::PhysicsComponent2D& physicsComponent = entity->AddComponent(); + + WHEN("We update the world") + { + world.Update(1.f); + + THEN("Entity should have correct bounding box") + { + REQUIRE(nodeComponent.GetPosition() == position); + aabb.Translate(position); + REQUIRE(physicsComponent.GetAABB() == aabb); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp b/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp index 3cb0d6bdb..b66aa89b7 100644 --- a/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp +++ b/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp @@ -5,7 +5,7 @@ #include #include -SCENARIO("PhysicsSystem", "[NDK][PHYSICSSYSTEM]") +SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]") { GIVEN("A world and a static entity & a dynamic entity") { From dfc441c2fc54249e4da2315ad893cc0da1e85918 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 06:50:37 +0200 Subject: [PATCH 233/243] Core/Flags: Rename DetailFlagOperators to FlagsOperators In case a user would need to use it --- include/Nazara/Core/Flags.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index 293a8dfa8..b7dff544b 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -56,7 +56,7 @@ namespace Nz }; // Little hack to have them in both Nz and global scope - namespace DetailFlagOperators + namespace FlagsOperators { template constexpr std::enable_if_t::value, Flags> operator~(E lhs); template constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs); @@ -64,10 +64,10 @@ namespace Nz template constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs); } - using namespace DetailFlagOperators; + using namespace FlagsOperators; } -using namespace Nz::DetailFlagOperators; +using namespace Nz::FlagsOperators; #include From 5fe782bd460a1669f0bddc0e8287f39b9f1631e8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 06:56:55 +0200 Subject: [PATCH 234/243] Core/FileImpl: Remove implicit region locking (Windows) --- src/Nazara/Core/Win32/FileImpl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Nazara/Core/Win32/FileImpl.cpp b/src/Nazara/Core/Win32/FileImpl.cpp index b7c5d0f2d..4e5d75c6c 100644 --- a/src/Nazara/Core/Win32/FileImpl.cpp +++ b/src/Nazara/Core/Win32/FileImpl.cpp @@ -191,9 +191,7 @@ namespace Nz LARGE_INTEGER cursorPos; cursorPos.QuadPart = GetCursorPos(); - LockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, static_cast(size), 0); WriteFile(m_handle, buffer, static_cast(size), &written, nullptr); - UnlockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, static_cast(size), 0); m_endOfFileUpdated = false; From dc28a9161b0d5d6899271efdd933b97f2f2615ef Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 06:57:35 +0200 Subject: [PATCH 235/243] Network/TcpClient: Fix Send hanging when used in non-blocking mode --- src/Nazara/Network/TcpClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index 54144e8fd..9e2eb7e0c 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -326,7 +326,7 @@ namespace Nz }); } - while (totalByteSent < size) + while (totalByteSent < size || !IsBlockingEnabled()) { int sendSize = static_cast(std::min(size - totalByteSent, std::numeric_limits::max())); //< Handle very large send int sentSize; From e0ede5bf2d0c10bdbe546ac6dc27f3ae3b4d8577 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 06:59:53 +0200 Subject: [PATCH 236/243] Physics2D/RigidBody2D: Little refactor --- src/Nazara/Physics2D/RigidBody2D.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 1ad96e0d0..a19107c2c 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -124,8 +124,9 @@ namespace Nz if (m_shapes.empty()) return Rectf::Zero(); - cpBB bb = cpShapeGetBB(*m_shapes.begin()); - for (auto it = ++m_shapes.begin(); it != m_shapes.end(); ++it) + auto it = m_shapes.begin(); + cpBB bb = cpShapeGetBB(*it++); + for (; it != m_shapes.end(); ++it) bb = cpBBMerge(bb, cpShapeGetBB(*it)); return Rectf(Rect(bb.l, bb.b, bb.r - bb.l, bb.t - bb.b)); From 4a1a335ceed55fcbc6a53756a4dc93bfabb97db0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 07:06:50 +0200 Subject: [PATCH 237/243] Core/Flags: Fix compilation Oops.. --- include/Nazara/Core/Flags.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 11cd22109..1899e7576 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -211,7 +211,7 @@ namespace Nz } - namespace DetailFlagOperators + namespace FlagsOperators { /*! * \brief Override binary NOT operator on enum to turns into a Flags object. From 50a3f78f91a3020dfb4bb76116006486ceea5863 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 08:16:08 +0200 Subject: [PATCH 238/243] Core/Thread: Add posibility of setting thread name --- include/Nazara/Core/Thread.hpp | 2 + src/Nazara/Core/Posix/ThreadImpl.cpp | 28 ++++++++++--- src/Nazara/Core/Posix/ThreadImpl.hpp | 7 ++++ src/Nazara/Core/Thread.cpp | 40 ++++++++++++++++++- src/Nazara/Core/Win32/ThreadImpl.cpp | 59 +++++++++++++++++++++++++--- src/Nazara/Core/Win32/ThreadImpl.hpp | 5 +++ 6 files changed, 128 insertions(+), 13 deletions(-) diff --git a/include/Nazara/Core/Thread.hpp b/include/Nazara/Core/Thread.hpp index a4b4d92f6..e129cbe40 100644 --- a/include/Nazara/Core/Thread.hpp +++ b/include/Nazara/Core/Thread.hpp @@ -32,11 +32,13 @@ namespace Nz Id GetId() const; bool IsJoinable() const; void Join(); + void SetName(const String& name); Thread& operator=(const Thread&) = delete; Thread& operator=(Thread&& thread); static unsigned int HardwareConcurrency(); + static void SetCurrentThreadName(const String& name); static void Sleep(UInt32 milliseconds); private: diff --git a/src/Nazara/Core/Posix/ThreadImpl.cpp b/src/Nazara/Core/Posix/ThreadImpl.cpp index b3948ee5d..aa0b87c5d 100644 --- a/src/Nazara/Core/Posix/ThreadImpl.cpp +++ b/src/Nazara/Core/Posix/ThreadImpl.cpp @@ -29,13 +29,22 @@ namespace Nz pthread_join(m_handle, nullptr); } - void* ThreadImpl::ThreadProc(void* userdata) + void ThreadImpl::SetName(const Nz::String& name) { - Functor* func = static_cast(userdata); - func->Run(); - delete func; +#ifdef __GNUC__ + pthread_setname_np(m_handle, name.GetConstBuffer()); +#else + NazaraWarning("Setting thread name is not supported on this platform"); +#endif + } - return nullptr; + void ThreadImpl::SetCurrentName(const Nz::String& name) + { +#ifdef __GNUC__ + pthread_setname_np(pthread_self(), name.GetConstBuffer()); +#else + NazaraWarning("Setting current thread name is not supported on this platform"); +#endif } void ThreadImpl::Sleep(UInt32 time) @@ -56,4 +65,13 @@ namespace Nz while (r == -1 && errno == EINTR); } } + + void* ThreadImpl::ThreadProc(void* userdata) + { + Functor* func = static_cast(userdata); + func->Run(); + delete func; + + return nullptr; + } } diff --git a/src/Nazara/Core/Posix/ThreadImpl.hpp b/src/Nazara/Core/Posix/ThreadImpl.hpp index 1ed6f3c8a..30d84d9d8 100644 --- a/src/Nazara/Core/Posix/ThreadImpl.hpp +++ b/src/Nazara/Core/Posix/ThreadImpl.hpp @@ -8,6 +8,11 @@ #define NAZARA_THREADIMPL_HPP #include + +#ifdef __GNUC__ +#define _GNU_SOURCE +#endif + #include namespace Nz @@ -21,7 +26,9 @@ namespace Nz void Detach(); void Join(); + void SetName(const Nz::String& name); + static void SetCurrentName(const Nz::String& name); static void Sleep(UInt32 time); private: diff --git a/src/Nazara/Core/Thread.cpp b/src/Nazara/Core/Thread.cpp index c9532ec19..d8b0ebd42 100644 --- a/src/Nazara/Core/Thread.cpp +++ b/src/Nazara/Core/Thread.cpp @@ -117,6 +117,25 @@ namespace Nz m_impl = nullptr; } + /*! + * \brief Changes the debugging name associated to a thread + * + * Changes the debugging name associated with a particular thread, and may helps with debugging tools. + * + * \param name The new name of the thread + * + * \remark Due to system limitations, thread name cannot exceed 15 characters (excluding null-terminator) + * + * \see SetCurrentThreadName + */ + void Thread::SetName(const String& name) + { + NazaraAssert(m_impl, "Invalid thread"); + NazaraAssert(name.GetSize() < 16, "Thread name is too long"); + + m_impl->SetName(name); + } + /*! * \brief Moves the other thread into this * \return A reference to this @@ -145,18 +164,35 @@ namespace Nz * \brief Gets the number of simulatenous threads that can run on the same cpu * \return The number of simulatenous threads */ - unsigned int Thread::HardwareConcurrency() { return HardwareInfo::GetProcessorCount(); } + + /*! + * \brief Changes the debugging name associated to the calling thread + * + * Changes the debugging name associated with the calling thread, and may helps with debugging tools. + * + * \param name The new name associated with this thread + * + * \remark Due to system limitations, thread name cannot exceed 15 characters (excluding null-terminator) + * + * \see SetName + */ + void Thread::SetCurrentThreadName(const String& name) + { + NazaraAssert(name.GetSize() < 16, "Thread name is too long"); + + ThreadImpl::SetCurrentName(name); + } + /*! * \brief Makes sleep this thread * * \param milliseconds The number of milliseconds to sleep */ - void Thread::Sleep(UInt32 milliseconds) { ThreadImpl::Sleep(milliseconds); diff --git a/src/Nazara/Core/Win32/ThreadImpl.cpp b/src/Nazara/Core/Win32/ThreadImpl.cpp index 5b44b94b6..e59413413 100644 --- a/src/Nazara/Core/Win32/ThreadImpl.cpp +++ b/src/Nazara/Core/Win32/ThreadImpl.cpp @@ -6,13 +6,27 @@ #include #include #include +#include #include namespace Nz { + namespace + { +#pragma pack(push,8) + struct THREADNAME_INFO + { + DWORD dwType; + LPCSTR szName; + DWORD dwThreadID; + DWORD dwFlags; + }; +#pragma pack(pop) + } + ThreadImpl::ThreadImpl(Functor* functor) { - m_handle = reinterpret_cast(_beginthreadex(nullptr, 0, &ThreadImpl::ThreadProc, functor, 0, nullptr)); + m_handle = reinterpret_cast(_beginthreadex(nullptr, 0, &ThreadImpl::ThreadProc, functor, 0, &m_threadId)); if (!m_handle) NazaraInternalError("Failed to create thread: " + Error::GetLastSystemError()); } @@ -29,6 +43,44 @@ namespace Nz CloseHandle(m_handle); } + void ThreadImpl::SetName(const Nz::String& name) + { + SetThreadName(m_threadId, name.GetConstBuffer()); + } + + void ThreadImpl::SetCurrentName(const Nz::String& name) + { + SetThreadName(::GetCurrentThreadId(), name.GetConstBuffer()); + } + + void ThreadImpl::Sleep(UInt32 time) + { + ::Sleep(time); + } + + void ThreadImpl::SetThreadName(DWORD threadId, const char* threadName) + { + // https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx + constexpr DWORD MS_VC_EXCEPTION = 0x406D1388; + + THREADNAME_INFO info; + info.dwType = 0x1000; + info.szName = threadName; + info.dwThreadID = threadId; + info.dwFlags = 0; + +#pragma warning(push) +#pragma warning(disable: 6320 6322) + __try + { + RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), reinterpret_cast(&info)); + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + } +#pragma warning(pop) + } + unsigned int __stdcall ThreadImpl::ThreadProc(void* userdata) { Functor* func = static_cast(userdata); @@ -42,9 +94,4 @@ namespace Nz return 0; } - - void ThreadImpl::Sleep(UInt32 time) - { - ::Sleep(time); - } } diff --git a/src/Nazara/Core/Win32/ThreadImpl.hpp b/src/Nazara/Core/Win32/ThreadImpl.hpp index 12e7f5c14..8070f7a22 100644 --- a/src/Nazara/Core/Win32/ThreadImpl.hpp +++ b/src/Nazara/Core/Win32/ThreadImpl.hpp @@ -10,6 +10,7 @@ #define NAZARA_THREADIMPL_HPP #include +#include #include namespace Nz @@ -23,12 +24,16 @@ namespace Nz void Detach(); void Join(); + void SetName(const Nz::String& name); + static void SetCurrentName(const Nz::String& name); static void Sleep(UInt32 time); private: + static void SetThreadName(DWORD threadId, const char* threadName); static unsigned int __stdcall ThreadProc(void* userdata); + DWORD m_threadId; HANDLE m_handle; }; } From 90d86c6eb00cfb2544b626e7a380af8062fbdc23 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 08:16:43 +0200 Subject: [PATCH 239/243] Breaks compatibility with Windows XP by default --- include/Nazara/Core/Config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Core/Config.hpp b/include/Nazara/Core/Config.hpp index 2ad2513ac..5aa9fccec 100644 --- a/include/Nazara/Core/Config.hpp +++ b/include/Nazara/Core/Config.hpp @@ -73,7 +73,7 @@ #define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096 // Optimize the Windows implementation with technologies of Windows NT 6.0 (and greater) (Break the compatibility with Windows XP) -#define NAZARA_CORE_WINDOWS_NT6 0 +#define NAZARA_CORE_WINDOWS_NT6 1 /* From 175a98c4fc53e8cf643d3e52f89f2c6c51f9eb59 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 08:28:57 +0200 Subject: [PATCH 240/243] Fix compilation --- src/Nazara/Core/Posix/ThreadImpl.hpp | 3 ++- src/Nazara/Core/Win32/ThreadImpl.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Core/Posix/ThreadImpl.hpp b/src/Nazara/Core/Posix/ThreadImpl.hpp index 30d84d9d8..ba3d4ed84 100644 --- a/src/Nazara/Core/Posix/ThreadImpl.hpp +++ b/src/Nazara/Core/Posix/ThreadImpl.hpp @@ -8,8 +8,9 @@ #define NAZARA_THREADIMPL_HPP #include +#include -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(_GNU_SOURCE) #define _GNU_SOURCE #endif diff --git a/src/Nazara/Core/Win32/ThreadImpl.cpp b/src/Nazara/Core/Win32/ThreadImpl.cpp index e59413413..cae997874 100644 --- a/src/Nazara/Core/Win32/ThreadImpl.cpp +++ b/src/Nazara/Core/Win32/ThreadImpl.cpp @@ -26,9 +26,12 @@ namespace Nz ThreadImpl::ThreadImpl(Functor* functor) { - m_handle = reinterpret_cast(_beginthreadex(nullptr, 0, &ThreadImpl::ThreadProc, functor, 0, &m_threadId)); + unsigned int threadId; + m_handle = reinterpret_cast(_beginthreadex(nullptr, 0, &ThreadImpl::ThreadProc, functor, 0, &threadId)); if (!m_handle) NazaraInternalError("Failed to create thread: " + Error::GetLastSystemError()); + + m_threadId = threadId; } void ThreadImpl::Detach() From bb512ff17a7c8e060cc08e4316747f24dfe7ca66 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jun 2017 20:50:39 +0200 Subject: [PATCH 241/243] Network/SocketPoller: Fix IsReadyTo* on Windows Vista+ --- src/Nazara/Network/Win32/SocketPollerImpl.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp index 3513ce722..b6dee66e9 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -135,6 +135,30 @@ namespace Nz #if NAZARA_NETWORK_POLL_SUPPORT activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast(msTimeout), error); + + m_readyToReadSockets.clear(); + m_readyToWriteSockets.clear(); + if (activeSockets > 0U) + { + int socketRemaining = activeSockets; + for (PollSocket& entry : m_sockets) + { + if (entry.revents != 0) + { + if (entry.revents & POLLRDNORM) + m_readyToReadSockets.insert(entry.fd); + + if (entry.revents & POLLWRNORM) + m_readyToWriteSockets.insert(entry.fd); + + entry.revents = 0; + + if (--socketRemaining == 0) + break; + } + } + } + #else fd_set* readSet = nullptr; fd_set* writeSet = nullptr; From b2e23cfb569e5918193d859b321ba616a68fd00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 21 Jun 2017 18:10:46 +0200 Subject: [PATCH 242/243] Mark every bool conversion as explicit --- include/Nazara/Core/Bitset.hpp | 2 +- include/Nazara/Core/Initializer.hpp | 2 +- include/Nazara/Core/ObjectHandle.hpp | 2 +- include/Nazara/Core/ObjectRef.hpp | 2 +- include/Nazara/Core/SparsePtr.hpp | 2 +- include/Nazara/Network/IpAddress.hpp | 2 +- include/Nazara/Utility/IndexBuffer.inl | 2 +- include/Nazara/Utility/VertexBuffer.inl | 2 +- src/Nazara/Network/RUdpConnection.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index 2ea0502a4..04fb2f3c6 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -145,7 +145,7 @@ namespace Nz template void* operator&() const; - operator bool() const; + explicit operator bool() const; Bit& operator=(bool val); Bit& operator=(const Bit& bit); diff --git a/include/Nazara/Core/Initializer.hpp b/include/Nazara/Core/Initializer.hpp index 7fb19e69e..c09ae55af 100644 --- a/include/Nazara/Core/Initializer.hpp +++ b/include/Nazara/Core/Initializer.hpp @@ -24,7 +24,7 @@ namespace Nz bool IsInitialized() const; void Uninitialize(); - operator bool() const; + explicit operator bool() const; Initializer& operator=(const Initializer&) = delete; Initializer& operator=(Initializer&&) = delete; ///TODO diff --git a/include/Nazara/Core/ObjectHandle.hpp b/include/Nazara/Core/ObjectHandle.hpp index bf22734d3..022344488 100644 --- a/include/Nazara/Core/ObjectHandle.hpp +++ b/include/Nazara/Core/ObjectHandle.hpp @@ -38,7 +38,7 @@ namespace Nz Nz::String ToString() const; - operator bool() const; + explicit operator bool() const; operator T*() const; T* operator->() const; diff --git a/include/Nazara/Core/ObjectRef.hpp b/include/Nazara/Core/ObjectRef.hpp index 1414e5d78..3a9e57628 100644 --- a/include/Nazara/Core/ObjectRef.hpp +++ b/include/Nazara/Core/ObjectRef.hpp @@ -31,7 +31,7 @@ namespace Nz bool Reset(T* object = nullptr); ObjectRef& Swap(ObjectRef& ref); - operator bool() const; + explicit operator bool() const; operator T*() const; T* operator->() const; diff --git a/include/Nazara/Core/SparsePtr.hpp b/include/Nazara/Core/SparsePtr.hpp index f4d777fa8..10e76c9c3 100644 --- a/include/Nazara/Core/SparsePtr.hpp +++ b/include/Nazara/Core/SparsePtr.hpp @@ -41,7 +41,7 @@ namespace Nz void SetPtr(VoidPtr ptr); void SetStride(int stride); - operator bool() const; + explicit operator bool() const; operator T*() const; T& operator*() const; T* operator->() const; diff --git a/include/Nazara/Network/IpAddress.hpp b/include/Nazara/Network/IpAddress.hpp index c3775effd..f5e1ca9d8 100644 --- a/include/Nazara/Network/IpAddress.hpp +++ b/include/Nazara/Network/IpAddress.hpp @@ -50,7 +50,7 @@ namespace Nz String ToString() const; inline UInt32 ToUInt32() const; - inline operator bool() const; + inline explicit operator bool() const; IpAddress& operator=(const IpAddress&) = default; IpAddress& operator=(IpAddress&&) = default; diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index b439623eb..0ae918db7 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -45,7 +45,7 @@ namespace Nz inline bool IndexBuffer::IsValid() const { - return m_buffer; + return m_buffer.IsValid(); } inline void* IndexBuffer::Map(BufferAccess access, UInt32 startIndex, UInt32 length) diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index 588289f92..09f701d12 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -39,7 +39,7 @@ namespace Nz inline bool VertexBuffer::IsValid() const { - return m_buffer && m_vertexDeclaration; + return m_buffer.IsValid() && m_vertexDeclaration.IsValid(); } template diff --git a/src/Nazara/Network/RUdpConnection.cpp b/src/Nazara/Network/RUdpConnection.cpp index f704b9568..3667eb113 100644 --- a/src/Nazara/Network/RUdpConnection.cpp +++ b/src/Nazara/Network/RUdpConnection.cpp @@ -527,7 +527,7 @@ namespace Nz } else { - NazaraNotice("Received wrong token (" + String::Number(token) + " instead of " + String::Number(~peer.stateData1) + ") from client " + peer.address); + NazaraNotice("Received wrong token (" + String::Number(token) + " instead of " + String::Number(~peer.stateData1) + ") from client " + peer.address.ToString()); return; //< Ignore } From 67dbb9e7c899a70a2b4707b1c2d6531214a9b0bd Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 28 Jun 2017 23:22:50 +0200 Subject: [PATCH 243/243] Lua/LuaState: Fix Execute not being able to return values --- src/Nazara/Lua/LuaState.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Lua/LuaState.cpp b/src/Nazara/Lua/LuaState.cpp index 94170aee0..4821b1d09 100644 --- a/src/Nazara/Lua/LuaState.cpp +++ b/src/Nazara/Lua/LuaState.cpp @@ -373,7 +373,7 @@ namespace Nz return false; } - return Run(0, 0); + return Run(0, LUA_MULTRET); } bool LuaState::ExecuteFromFile(const String& filePath) @@ -419,7 +419,7 @@ namespace Nz return false; } - return Run(0, 0); + return Run(0, LUA_MULTRET); } int LuaState::GetAbsIndex(int index) const