From 8a36442c3848af415cc4600e33358ea48657edbc Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 20:40:02 +0200 Subject: [PATCH] Clean up some code Former-commit-id: d1d166225cc95474130e59645f9397b6a4130267 [formerly 10b948f0d7e08992d86cecb54a1931de50d0abd4] [formerly a23d07003f7c7583a900b532119d9402a77b1830 [formerly 8418fb742937775772c79e6546b617382f0cb22a]] Former-commit-id: e628a175a930f2390cedfd3b26831826514b265f [formerly fa8c6a19f29e64e4cd90b212e01a5acf97f1740f] Former-commit-id: 795328aea7f39068b6575c948b5c51fc5adf9f12 --- include/Nazara/Physics/Geom.hpp | 2 +- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 +- src/Nazara/Physics/Geom.cpp | 21 +++++++-------------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/include/Nazara/Physics/Geom.hpp b/include/Nazara/Physics/Geom.hpp index 23a02c72b..e228c3d07 100644 --- a/include/Nazara/Physics/Geom.hpp +++ b/include/Nazara/Physics/Geom.hpp @@ -134,7 +134,7 @@ namespace Nz class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom { public: - CompoundGeom(PhysGeom** geoms, unsigned int geomCount); + CompoundGeom(PhysGeom** geoms, std::size_t geomCount); const std::vector& GetGeoms() const; GeomType GetType() const override; diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index cbcebb83b..0097227ef 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -56,7 +56,7 @@ namespace Nz std::array hostnameBuffer; std::array serviceBuffer; - int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); + int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); if (result == 0) { if (hostname) diff --git a/src/Nazara/Physics/Geom.cpp b/src/Nazara/Physics/Geom.cpp index e814b8618..48d6f0090 100644 --- a/src/Nazara/Physics/Geom.cpp +++ b/src/Nazara/Physics/Geom.cpp @@ -125,16 +125,7 @@ namespace Nz PhysGeomRef PhysGeom::Build(const PrimitiveList& list) { - unsigned int primitiveCount = list.GetSize(); - - #if NAZARA_PHYSICS_SAFE - if (primitiveCount == 0) - { - NazaraError("PrimitiveList must have at least one primitive"); - return nullptr; - } - #endif - + std::size_t primitiveCount = list.GetSize(); if (primitiveCount > 1) { std::vector geoms(primitiveCount); @@ -144,8 +135,10 @@ namespace Nz return CompoundGeom::New(&geoms[0], primitiveCount); } - else + else if (primitiveCount > 0) return CreateGeomFromPrimitive(list.GetPrimitive(0)); + else + return NullGeom::New(); } bool PhysGeom::Initialize() @@ -246,10 +239,10 @@ namespace Nz /******************************* CompoundGeom ********************************/ - CompoundGeom::CompoundGeom(PhysGeom** geoms, unsigned int geomCount) + CompoundGeom::CompoundGeom(PhysGeom** geoms, std::size_t geomCount) { m_geoms.reserve(geomCount); - for (unsigned int i = 0; i < geomCount; ++i) + for (std::size_t i = 0; i < geomCount; ++i) m_geoms.emplace_back(geoms[i]); } @@ -349,7 +342,7 @@ namespace Nz NewtonCollision* ConvexHullGeom::CreateHandle(PhysWorld* world) const { - return NewtonCreateConvexHull(world->GetHandle(), m_vertices.size(), reinterpret_cast(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); + return NewtonCreateConvexHull(world->GetHandle(), static_cast(m_vertices.size()), reinterpret_cast(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); } /******************************* CylinderGeom ********************************/