Browse Source

Re-enable the unsigned/signed mismatch warning. Code cleanup.

Lasse Öörni 9 years ago
parent
commit
d9a295a595
34 changed files with 63 additions and 64 deletions
  1. 1 1
      Source/Samples/41_DatabaseDemo/DatabaseDemo.cpp
  2. 2 0
      Source/Urho3D/AngelScript/MathAPI.cpp
  3. 2 2
      Source/Urho3D/Audio/Audio.cpp
  4. 4 4
      Source/Urho3D/Core/Profiler.cpp
  5. 1 1
      Source/Urho3D/Engine/DebugHud.cpp
  6. 2 2
      Source/Urho3D/Graphics/Batch.cpp
  7. 3 5
      Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp
  8. 1 1
      Source/Urho3D/Graphics/Direct3D11/D3D11Texture2D.cpp
  9. 1 1
      Source/Urho3D/Graphics/Direct3D11/D3D11Texture3D.cpp
  10. 1 1
      Source/Urho3D/Graphics/Direct3D11/D3D11TextureCube.cpp
  11. 1 1
      Source/Urho3D/Graphics/Direct3D9/D3D9Texture2D.cpp
  12. 1 1
      Source/Urho3D/Graphics/Direct3D9/D3D9Texture3D.cpp
  13. 1 1
      Source/Urho3D/Graphics/Direct3D9/D3D9TextureCube.cpp
  14. 2 2
      Source/Urho3D/Graphics/Drawable.cpp
  15. 2 2
      Source/Urho3D/Graphics/Light.cpp
  16. 2 2
      Source/Urho3D/Graphics/Light.h
  17. 1 1
      Source/Urho3D/Graphics/Octree.cpp
  18. 1 1
      Source/Urho3D/Graphics/OpenGL/OGLTexture2D.cpp
  19. 1 1
      Source/Urho3D/Graphics/OpenGL/OGLTexture3D.cpp
  20. 1 1
      Source/Urho3D/Graphics/OpenGL/OGLTextureCube.cpp
  21. 1 1
      Source/Urho3D/Graphics/ParticleEffect.cpp
  22. 3 3
      Source/Urho3D/IO/File.cpp
  23. 1 1
      Source/Urho3D/IO/Serializer.cpp
  24. 0 1
      Source/Urho3D/Math/MathDefs.h
  25. 2 2
      Source/Urho3D/Navigation/CrowdAgent.cpp
  26. 4 4
      Source/Urho3D/Navigation/CrowdManager.cpp
  27. 2 2
      Source/Urho3D/Navigation/DynamicNavigationMesh.cpp
  28. 1 1
      Source/Urho3D/Network/Connection.cpp
  29. 5 5
      Source/Urho3D/Resource/Image.cpp
  30. 4 4
      Source/Urho3D/UI/FontFaceFreeType.cpp
  31. 2 2
      Source/Urho3D/UI/Text.cpp
  32. 4 4
      Source/Urho3D/Urho2D/ParticleEmitter2D.cpp
  33. 2 2
      Source/Urho3D/Urho2D/ParticleEmitter2D.h
  34. 1 1
      Source/Urho3D/Urho2D/Renderer2D.cpp

+ 1 - 1
Source/Samples/41_DatabaseDemo/DatabaseDemo.cpp

@@ -175,7 +175,7 @@ void DatabaseDemo::HandleInput(const String& input)
         if (input.StartsWith("set") && tokens.Size() > 1)
         if (input.StartsWith("set") && tokens.Size() > 1)
         {
         {
             if (setting == "maxrows")
             if (setting == "maxrows")
-                maxRows_ = (unsigned)Max(ToUInt(tokens[1]), 1);
+                maxRows_ = Max(ToUInt(tokens[1]), 1U);
             else if (setting == "connstr")
             else if (setting == "connstr")
             {
             {
                 String newConnectionString(input.Substring(input.Find(" ", input.Find("connstr")) + 1));
                 String newConnectionString(input.Substring(input.Find(" ", input.Find("connstr")) + 1));

+ 2 - 0
Source/Urho3D/AngelScript/MathAPI.cpp

@@ -66,8 +66,10 @@ static void RegisterMathFunctions(asIScriptEngine* engine)
     engine->RegisterGlobalFunction("float Sqrt(float)", asFUNCTION(sqrtf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Sqrt(float)", asFUNCTION(sqrtf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Pow(float, float)", asFUNCTION(powf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Pow(float, float)", asFUNCTION(powf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Min(float, float)", asFUNCTIONPR(Min, (float, float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Min(float, float)", asFUNCTIONPR(Min, (float, float), float), asCALL_CDECL);
+    engine->RegisterGlobalFunction("uint Min(uint, uint)", asFUNCTIONPR(Min, (unsigned, unsigned), unsigned), asCALL_CDECL);
     engine->RegisterGlobalFunction("int Min(int, int)", asFUNCTIONPR(Min, (int, int), int), asCALL_CDECL);
     engine->RegisterGlobalFunction("int Min(int, int)", asFUNCTIONPR(Min, (int, int), int), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Max(float, float)", asFUNCTIONPR(Max, (float, float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Max(float, float)", asFUNCTIONPR(Max, (float, float), float), asCALL_CDECL);
+    engine->RegisterGlobalFunction("uint Max(uint, uint)", asFUNCTIONPR(Max, (unsigned, unsigned), unsigned), asCALL_CDECL);
     engine->RegisterGlobalFunction("int Max(int, int)", asFUNCTIONPR(Max, (int, int), int), asCALL_CDECL);
     engine->RegisterGlobalFunction("int Max(int, int)", asFUNCTIONPR(Max, (int, int), int), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Clamp(float, float, float)", asFUNCTIONPR(Clamp, (float, float, float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Clamp(float, float, float)", asFUNCTIONPR(Clamp, (float, float, float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float SmoothStep(float, float, float)", asFUNCTION(SmoothStep<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float SmoothStep(float, float, float)", asFUNCTION(SmoothStep<float>), asCALL_CDECL);

+ 2 - 2
Source/Urho3D/Audio/Audio.cpp

@@ -128,7 +128,7 @@ bool Audio::SetMode(int bufferLengthMSec, int mixRate, bool stereo, bool interpo
     stereo_ = obtained.channels == 2;
     stereo_ = obtained.channels == 2;
     sampleSize_ = (unsigned)(stereo_ ? sizeof(int) : sizeof(short));
     sampleSize_ = (unsigned)(stereo_ ? sizeof(int) : sizeof(short));
     // Guarantee a fragment size that is low enough so that Vorbis decoding buffers do not wrap
     // Guarantee a fragment size that is low enough so that Vorbis decoding buffers do not wrap
-    fragmentSize_ = (unsigned)Min((int)NextPowerOfTwo((unsigned)(mixRate >> 6)), (int)obtained.samples);
+    fragmentSize_ = Min(NextPowerOfTwo((unsigned)(mixRate >> 6)), (unsigned)obtained.samples);
     mixRate_ = obtained.freq;
     mixRate_ = obtained.freq;
     interpolation_ = interpolation;
     interpolation_ = interpolation;
     clipBuffer_ = new int[stereo ? fragmentSize_ << 1 : fragmentSize_];
     clipBuffer_ = new int[stereo ? fragmentSize_ << 1 : fragmentSize_];
@@ -258,7 +258,7 @@ void Audio::MixOutput(void* dest, unsigned samples)
     while (samples)
     while (samples)
     {
     {
         // If sample count exceeds the fragment (clip buffer) size, split the work
         // If sample count exceeds the fragment (clip buffer) size, split the work
-        unsigned workSamples = (unsigned)Min((int)samples, (int)fragmentSize_);
+        unsigned workSamples = Min(samples, fragmentSize_);
         unsigned clipSamples = workSamples;
         unsigned clipSamples = workSamples;
         if (stereo_)
         if (stereo_)
             clipSamples <<= 1;
             clipSamples <<= 1;

+ 4 - 4
Source/Urho3D/Core/Profiler.cpp

@@ -106,7 +106,7 @@ void Profiler::PrintData(ProfilerBlock* block, String& output, unsigned depth, u
     char line[LINE_MAX_LENGTH];
     char line[LINE_MAX_LENGTH];
     char indentedName[LINE_MAX_LENGTH];
     char indentedName[LINE_MAX_LENGTH];
 
 
-    unsigned intervalFrames = Max(intervalFrames_, (unsigned)1);
+    unsigned intervalFrames = Max(intervalFrames_, 1U);
 
 
     if (depth >= maxDepth)
     if (depth >= maxDepth)
         return;
         return;
@@ -129,7 +129,7 @@ void Profiler::PrintData(ProfilerBlock* block, String& output, unsigned depth, u
                 float frame = block->intervalTime_ / intervalFrames / 1000.0f;
                 float frame = block->intervalTime_ / intervalFrames / 1000.0f;
                 float all = block->intervalTime_ / 1000.0f;
                 float all = block->intervalTime_ / 1000.0f;
 
 
-                sprintf(line, "%s %5u %8.3f %8.3f %8.3f %9.3f\n", indentedName, Min(block->intervalCount_, (unsigned)99999),
+                sprintf(line, "%s %5u %8.3f %8.3f %8.3f %9.3f\n", indentedName, Min(block->intervalCount_, 99999U),
                     avg, max, frame, all);
                     avg, max, frame, all);
             }
             }
             else
             else
@@ -142,8 +142,8 @@ void Profiler::PrintData(ProfilerBlock* block, String& output, unsigned depth, u
                 float totalMax = block->totalMaxTime_ / 1000.0f;
                 float totalMax = block->totalMaxTime_ / 1000.0f;
                 float totalAll = block->totalTime_ / 1000.0f;
                 float totalAll = block->totalTime_ / 1000.0f;
 
 
-                sprintf(line, "%s %5u %8.3f %8.3f %9.3f  %7u %9.3f %9.3f %11.3f\n", indentedName, Min(block->frameCount_, (unsigned)99999),
-                    avg, max, all, Min(block->totalCount_, 99999), totalAvg, totalMax, totalAll);
+                sprintf(line, "%s %5u %8.3f %8.3f %9.3f  %7u %9.3f %9.3f %11.3f\n", indentedName, Min(block->frameCount_, 99999U),
+                    avg, max, all, Min(block->totalCount_, 99999U), totalAvg, totalMax, totalAll);
             }
             }
 
 
             output += String(line);
             output += String(line);

+ 1 - 1
Source/Urho3D/Engine/DebugHud.cpp

@@ -224,7 +224,7 @@ void DebugHud::SetProfilerMaxDepth(unsigned depth)
 
 
 void DebugHud::SetProfilerInterval(float interval)
 void DebugHud::SetProfilerInterval(float interval)
 {
 {
-    profilerInterval_ = (unsigned)Max((int)(interval * 1000.0f), 0);
+    profilerInterval_ = Max((unsigned)(interval * 1000.0f), 0U);
 }
 }
 
 
 void DebugHud::SetUseRendererStats(bool enable)
 void DebugHud::SetUseRendererStats(bool enable)

+ 2 - 2
Source/Urho3D/Graphics/Batch.cpp

@@ -327,7 +327,7 @@ void Batch::Prepare(View* view, Camera* camera, bool setModelTransform, bool all
                 case LIGHT_DIRECTIONAL:
                 case LIGHT_DIRECTIONAL:
                     {
                     {
                         Matrix4 shadowMatrices[MAX_CASCADE_SPLITS];
                         Matrix4 shadowMatrices[MAX_CASCADE_SPLITS];
-                        unsigned numSplits = (unsigned)Min(MAX_CASCADE_SPLITS, (int)lightQueue_->shadowSplits_.Size());
+                        unsigned numSplits = Min(MAX_CASCADE_SPLITS, lightQueue_->shadowSplits_.Size());
 
 
                         for (unsigned i = 0; i < numSplits; ++i)
                         for (unsigned i = 0; i < numSplits; ++i)
                             CalculateShadowMatrix(shadowMatrices[i], lightQueue_, i, renderer, Vector3::ZERO);
                             CalculateShadowMatrix(shadowMatrices[i], lightQueue_, i, renderer, Vector3::ZERO);
@@ -387,7 +387,7 @@ void Batch::Prepare(View* view, Camera* camera, bool setModelTransform, bool all
                 case LIGHT_DIRECTIONAL:
                 case LIGHT_DIRECTIONAL:
                     {
                     {
                         Matrix4 shadowMatrices[MAX_CASCADE_SPLITS];
                         Matrix4 shadowMatrices[MAX_CASCADE_SPLITS];
-                        unsigned numSplits = (unsigned)Min(MAX_CASCADE_SPLITS, (int)lightQueue_->shadowSplits_.Size());
+                        unsigned numSplits = Min(MAX_CASCADE_SPLITS, lightQueue_->shadowSplits_.Size());
 
 
                         for (unsigned i = 0; i < numSplits; ++i)
                         for (unsigned i = 0; i < numSplits; ++i)
                         {
                         {

+ 3 - 5
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -2295,11 +2295,9 @@ bool Graphics::CreateDevice(int width, int height, int multiSample)
         URHO3D_LOGD3DERROR("Failed to create D3D11 swap chain", hr);
         URHO3D_LOGD3DERROR("Failed to create D3D11 swap chain", hr);
         return false;
         return false;
     }
     }
-    else if (impl_->swapChain_)
-    {
-        multiSample_ = multiSample;
-        return true;
-    }
+
+    multiSample_ = multiSample;
+    return true;
 }
 }
 
 
 bool Graphics::UpdateSwapChain(int width, int height)
 bool Graphics::UpdateSwapChain(int width, int height)

+ 1 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Texture2D.cpp

@@ -337,7 +337,7 @@ bool Texture2D::SetData(SharedPtr<Image> image, bool useAlpha)
         width /= (1 << mipsToSkip);
         width /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
 
 
-        SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+        SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetSize(width, height, format);
         SetSize(width, height, format);
 
 
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)

+ 1 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Texture3D.cpp

@@ -383,7 +383,7 @@ bool Texture3D::SetData(SharedPtr<Image> image, bool useAlpha)
         height /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
         depth /= (1 << mipsToSkip);
         depth /= (1 << mipsToSkip);
 
 
-        SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+        SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetSize(width, height, depth, format);
         SetSize(width, height, depth, format);
 
 
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)

+ 1 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11TextureCube.cpp

@@ -538,7 +538,7 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
         // Create the texture when face 0 is being loaded, assume rest of the faces are same size & format
         // Create the texture when face 0 is being loaded, assume rest of the faces are same size & format
         if (!face)
         if (!face)
         {
         {
-            SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+            SetNumLevels(Max((levels - mipsToSkip), 1U));
             SetSize(width, format);
             SetSize(width, format);
         }
         }
         else
         else

+ 1 - 1
Source/Urho3D/Graphics/Direct3D9/D3D9Texture2D.cpp

@@ -411,7 +411,7 @@ bool Texture2D::SetData(SharedPtr<Image> image, bool useAlpha)
         width /= (1 << mipsToSkip);
         width /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
 
 
-        SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+        SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetSize(width, height, format);
         SetSize(width, height, format);
 
 
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)

+ 1 - 1
Source/Urho3D/Graphics/Direct3D9/D3D9Texture3D.cpp

@@ -458,7 +458,7 @@ bool Texture3D::SetData(SharedPtr<Image> image, bool useAlpha)
         height /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
         depth /= (1 << mipsToSkip);
         depth /= (1 << mipsToSkip);
 
 
-        SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+        SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetSize(width, height, depth, format);
         SetSize(width, height, depth, format);
 
 
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)

+ 1 - 1
Source/Urho3D/Graphics/Direct3D9/D3D9TextureCube.cpp

@@ -609,7 +609,7 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
         // Create the texture when face 0 is being loaded, assume rest of the faces are same size & format
         // Create the texture when face 0 is being loaded, assume rest of the faces are same size & format
         if (!face)
         if (!face)
         {
         {
-            SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+            SetNumLevels(Max((levels - mipsToSkip), 1U));
             SetSize(width, format);
             SetSize(width, format);
         }
         }
         else
         else

+ 2 - 2
Source/Urho3D/Graphics/Drawable.cpp

@@ -563,11 +563,11 @@ bool WriteDrawablesToOBJ(PODVector<Drawable*> drawables, File* outputFile, bool
 
 
                 // Amount by which to offset indices in the OBJ vs their values in the Urho3D geometry, basically the lowest index value
                 // Amount by which to offset indices in the OBJ vs their values in the Urho3D geometry, basically the lowest index value
                 // Compensates for the above vertex writing which doesn't write ALL vertices, just the used ones
                 // Compensates for the above vertex writing which doesn't write ALL vertices, just the used ones
-                int indexOffset = M_MAX_INT;
+                unsigned indexOffset = M_MAX_INT;
                 for (unsigned indexIdx = indexStart; indexIdx < indexStart + indexCount; indexIdx++)
                 for (unsigned indexIdx = indexStart; indexIdx < indexStart + indexCount; indexIdx++)
                 {
                 {
                     if (indexSize == 2)
                     if (indexSize == 2)
-                        indexOffset = Min(indexOffset, *((unsigned short*)(indexData + indexIdx * indexSize)));
+                        indexOffset = Min(indexOffset, (unsigned)*((unsigned short*)(indexData + indexIdx * indexSize)));
                     else
                     else
                         indexOffset = Min(indexOffset, *((unsigned*)(indexData + indexIdx * indexSize)));
                         indexOffset = Min(indexOffset, *((unsigned*)(indexData + indexIdx * indexSize)));
                 }
                 }

+ 2 - 2
Source/Urho3D/Graphics/Light.cpp

@@ -395,7 +395,7 @@ Frustum Light::GetFrustum() const
 
 
 int Light::GetNumShadowSplits() const
 int Light::GetNumShadowSplits() const
 {
 {
-    int ret = 1;
+    unsigned ret = 1;
 
 
     if (shadowCascade_.splits_[1] > shadowCascade_.splits_[0])
     if (shadowCascade_.splits_[1] > shadowCascade_.splits_[0])
     {
     {
@@ -408,7 +408,7 @@ int Light::GetNumShadowSplits() const
         }
         }
     }
     }
 
 
-    return Min(ret, MAX_CASCADE_SPLITS);
+    return (int)Min(ret, MAX_CASCADE_SPLITS);
 }
 }
 
 
 const Matrix3x4& Light::GetVolumeTransform(Camera* camera)
 const Matrix3x4& Light::GetVolumeTransform(Camera* camera)

+ 2 - 2
Source/Urho3D/Graphics/Light.h

@@ -45,9 +45,9 @@ static const float SHADOW_MIN_QUANTIZE = 0.1f;
 static const float SHADOW_MIN_VIEW = 1.0f;
 static const float SHADOW_MIN_VIEW = 1.0f;
 static const int MAX_LIGHT_SPLITS = 6;
 static const int MAX_LIGHT_SPLITS = 6;
 #ifdef DESKTOP_GRAPHICS
 #ifdef DESKTOP_GRAPHICS
-static const int MAX_CASCADE_SPLITS = 4;
+static const unsigned MAX_CASCADE_SPLITS = 4;
 #else
 #else
-static const int MAX_CASCADE_SPLITS = 1;
+static const unsigned MAX_CASCADE_SPLITS = 1;
 #endif
 #endif
 
 
 /// Shadow depth bias parameters.
 /// Shadow depth bias parameters.

+ 1 - 1
Source/Urho3D/Graphics/Octree.cpp

@@ -370,7 +370,7 @@ void Octree::SetSize(const BoundingBox& box, unsigned numLevels)
 
 
     Initialize(box);
     Initialize(box);
     numDrawables_ = drawables_.Size();
     numDrawables_ = drawables_.Size();
-    numLevels_ = (unsigned)Max((int)numLevels, 1);
+    numLevels_ = Max(numLevels, 1U);
 }
 }
 
 
 void Octree::Update(const FrameInfo& frame)
 void Octree::Update(const FrameInfo& frame)

+ 1 - 1
Source/Urho3D/Graphics/OpenGL/OGLTexture2D.cpp

@@ -374,7 +374,7 @@ bool Texture2D::SetData(SharedPtr<Image> image, bool useAlpha)
         width /= (1 << mipsToSkip);
         width /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
 
 
-        SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+        SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetSize(width, height, format);
         SetSize(width, height, format);
 
 
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)

+ 1 - 1
Source/Urho3D/Graphics/OpenGL/OGLTexture3D.cpp

@@ -405,7 +405,7 @@ bool Texture3D::SetData(SharedPtr<Image> image, bool useAlpha)
         height /= (1 << mipsToSkip);
         height /= (1 << mipsToSkip);
         depth /= (1 << mipsToSkip);
         depth /= (1 << mipsToSkip);
 
 
-        SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+        SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetSize(width, height, depth, format);
         SetSize(width, height, depth, format);
 
 
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)
         for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)

+ 1 - 1
Source/Urho3D/Graphics/OpenGL/OGLTextureCube.cpp

@@ -578,7 +578,7 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
         // Create the texture when face 0 is being loaded, assume rest of the faces are same size & format
         // Create the texture when face 0 is being loaded, assume rest of the faces are same size & format
         if (!face)
         if (!face)
         {
         {
-            SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
+            SetNumLevels(Max((levels - mipsToSkip), 1U));
             SetSize(width, format);
             SetSize(width, format);
         }
         }
         else
         else

+ 1 - 1
Source/Urho3D/Graphics/ParticleEffect.cpp

@@ -435,7 +435,7 @@ void ParticleEffect::SetMaterial(Material* material)
 
 
 void ParticleEffect::SetNumParticles(unsigned num)
 void ParticleEffect::SetNumParticles(unsigned num)
 {
 {
-    numParticles_ = Max(0, num);
+    numParticles_ = Max(0U, num);
 }
 }
 
 
 void ParticleEffect::SetUpdateInvisible(bool enable)
 void ParticleEffect::SetUpdateInvisible(bool enable)

+ 3 - 3
Source/Urho3D/IO/File.cpp

@@ -281,12 +281,12 @@ unsigned File::Read(void* dest, unsigned size)
         {
         {
             if (readBufferOffset_ >= readBufferSize_)
             if (readBufferOffset_ >= readBufferSize_)
             {
             {
-                readBufferSize_ = Min((int)size_ - position_, (int)READ_BUFFER_SIZE);
+                readBufferSize_ = Min(size_ - position_, READ_BUFFER_SIZE);
                 readBufferOffset_ = 0;
                 readBufferOffset_ = 0;
                 SDL_RWread(assetHandle_, readBuffer_.Get(), readBufferSize_, 1);
                 SDL_RWread(assetHandle_, readBuffer_.Get(), readBufferSize_, 1);
             }
             }
 
 
-            unsigned copySize = Min((int)(readBufferSize_ - readBufferOffset_), (int)sizeLeft);
+            unsigned copySize = Min((readBufferSize_ - readBufferOffset_), sizeLeft);
             memcpy(destPtr, readBuffer_.Get() + readBufferOffset_, copySize);
             memcpy(destPtr, readBuffer_.Get() + readBufferOffset_, copySize);
             destPtr += copySize;
             destPtr += copySize;
             sizeLeft -= copySize;
             sizeLeft -= copySize;
@@ -327,7 +327,7 @@ unsigned File::Read(void* dest, unsigned size)
                 readBufferOffset_ = 0;
                 readBufferOffset_ = 0;
             }
             }
 
 
-            unsigned copySize = (unsigned)Min((int)(readBufferSize_ - readBufferOffset_), (int)sizeLeft);
+            unsigned copySize = Min((readBufferSize_ - readBufferOffset_), sizeLeft);
             memcpy(destPtr, readBuffer_.Get() + readBufferOffset_, copySize);
             memcpy(destPtr, readBuffer_.Get() + readBufferOffset_, copySize);
             destPtr += copySize;
             destPtr += copySize;
             sizeLeft -= copySize;
             sizeLeft -= copySize;

+ 1 - 1
Source/Urho3D/IO/Serializer.cpp

@@ -177,7 +177,7 @@ bool Serializer::WriteString(const String& value)
 bool Serializer::WriteFileID(const String& value)
 bool Serializer::WriteFileID(const String& value)
 {
 {
     bool success = true;
     bool success = true;
-    unsigned length = (unsigned)Min((int)value.Length(), 4);
+    unsigned length = Min(value.Length(), 4U);
 
 
     success &= Write(value.CString(), length) == length;
     success &= Write(value.CString(), length) == length;
     for (unsigned i = value.Length(); i < 4; ++i)
     for (unsigned i = value.Length(); i < 4; ++i)

+ 0 - 1
Source/Urho3D/Math/MathDefs.h

@@ -24,7 +24,6 @@
 
 
 #ifdef _MSC_VER
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(push)
-#pragma warning(disable:4018) // Signed/unsigned mismatch
 #pragma warning(disable:4244) // Conversion from 'double' to 'float'
 #pragma warning(disable:4244) // Conversion from 'double' to 'float'
 #pragma warning(disable:4702) // unreachable code
 #pragma warning(disable:4702) // unreachable code
 #endif
 #endif

+ 2 - 2
Source/Urho3D/Navigation/CrowdAgent.cpp

@@ -125,8 +125,8 @@ void CrowdAgent::ApplyAttributes()
     maxSpeed_ = Max(0.f, maxSpeed_);
     maxSpeed_ = Max(0.f, maxSpeed_);
     radius_ = Max(0.f, radius_);
     radius_ = Max(0.f, radius_);
     height_ = Max(0.f, height_);
     height_ = Max(0.f, height_);
-    queryFilterType_ = Min(queryFilterType_, DT_CROWD_MAX_QUERY_FILTER_TYPE - 1);
-    obstacleAvoidanceType_ = Min(obstacleAvoidanceType_, DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS - 1);
+    queryFilterType_ = Min(queryFilterType_, (unsigned)DT_CROWD_MAX_QUERY_FILTER_TYPE - 1);
+    obstacleAvoidanceType_ = Min(obstacleAvoidanceType_, (unsigned)DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS - 1);
 
 
     UpdateParameters();
     UpdateParameters();
 
 

+ 4 - 4
Source/Urho3D/Navigation/CrowdManager.cpp

@@ -89,7 +89,7 @@ void CrowdManager::RegisterObject(Context* context)
 void CrowdManager::ApplyAttributes()
 void CrowdManager::ApplyAttributes()
 {
 {
     // Values from Editor, saved-file, or network must be checked before applying
     // Values from Editor, saved-file, or network must be checked before applying
-    maxAgents_ = Max(1, maxAgents_);
+    maxAgents_ = Max(1U, maxAgents_);
     maxAgentRadius_ = Max(0.f, maxAgentRadius_);
     maxAgentRadius_ = Max(0.f, maxAgentRadius_);
 
 
     bool navMeshChange = false;
     bool navMeshChange = false;
@@ -251,7 +251,7 @@ void CrowdManager::SetQueryFilterTypesAttr(const VariantVector& value)
 
 
     unsigned index = 0;
     unsigned index = 0;
     unsigned queryFilterType = 0;
     unsigned queryFilterType = 0;
-    numQueryFilterTypes_ = index < value.Size() ? Min(value[index++].GetUInt(), DT_CROWD_MAX_QUERY_FILTER_TYPE) : 0;
+    numQueryFilterTypes_ = index < value.Size() ? Min(value[index++].GetUInt(), (unsigned)DT_CROWD_MAX_QUERY_FILTER_TYPE) : 0;
 
 
     while (queryFilterType < numQueryFilterTypes_)
     while (queryFilterType < numQueryFilterTypes_)
     {
     {
@@ -262,7 +262,7 @@ void CrowdManager::SetQueryFilterTypesAttr(const VariantVector& value)
             filter->setIncludeFlags((unsigned short)value[index++].GetUInt());
             filter->setIncludeFlags((unsigned short)value[index++].GetUInt());
             filter->setExcludeFlags((unsigned short)value[index++].GetUInt());
             filter->setExcludeFlags((unsigned short)value[index++].GetUInt());
             unsigned prevNumAreas = numAreas_[queryFilterType];
             unsigned prevNumAreas = numAreas_[queryFilterType];
-            numAreas_[queryFilterType] = Min(value[index++].GetUInt(), DT_MAX_AREAS);
+            numAreas_[queryFilterType] = Min(value[index++].GetUInt(), (unsigned)DT_MAX_AREAS);
 
 
             // Must loop thru based on previous number of areas, the new area cost (if any) can only be set in the next attribute get/set iteration
             // Must loop thru based on previous number of areas, the new area cost (if any) can only be set in the next attribute get/set iteration
             if (index + prevNumAreas <= value.Size())
             if (index + prevNumAreas <= value.Size())
@@ -320,7 +320,7 @@ void CrowdManager::SetObstacleAvoidanceTypesAttr(const VariantVector& value)
 
 
     unsigned index = 0;
     unsigned index = 0;
     unsigned obstacleAvoidanceType = 0;
     unsigned obstacleAvoidanceType = 0;
-    numObstacleAvoidanceTypes_ = index < value.Size() ? Min(value[index++].GetUInt(), DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS) : 0;
+    numObstacleAvoidanceTypes_ = index < value.Size() ? Min(value[index++].GetUInt(), (unsigned)DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS) : 0;
 
 
     while (obstacleAvoidanceType < numObstacleAvoidanceTypes_)
     while (obstacleAvoidanceType < numObstacleAvoidanceTypes_)
     {
     {

+ 2 - 2
Source/Urho3D/Navigation/DynamicNavigationMesh.cpp

@@ -49,7 +49,7 @@
 // DebugNew is deliberately not used because the macro 'free' conflicts with DetourTileCache's LinearAllocator interface
 // DebugNew is deliberately not used because the macro 'free' conflicts with DetourTileCache's LinearAllocator interface
 //#include "../DebugNew.h"
 //#include "../DebugNew.h"
 
 
-#define TILECACHE_MAXLAYERS 255
+static const unsigned TILECACHE_MAXLAYERS = 255;
 
 
 namespace Urho3D
 namespace Urho3D
 {
 {
@@ -668,7 +668,7 @@ void DynamicNavigationMesh::SetMaxLayers(unsigned maxLayers)
 {
 {
     // Set 3 as a minimum due to the tendency of layers to be constructed inside the hollow space of stacked objects
     // Set 3 as a minimum due to the tendency of layers to be constructed inside the hollow space of stacked objects
     // That behavior is unlikely to be expected by the end user
     // That behavior is unlikely to be expected by the end user
-    maxLayers_ = Max(3, Min(maxLayers, TILECACHE_MAXLAYERS));
+    maxLayers_ = Max(3U, Min(maxLayers, TILECACHE_MAXLAYERS));
 }
 }
 
 
 int DynamicNavigationMesh::BuildTile(Vector<NavigationGeometryInfo>& geometryList, int x, int z, TileCacheData* tiles)
 int DynamicNavigationMesh::BuildTile(Vector<NavigationGeometryInfo>& geometryList, int x, int z, TileCacheData* tiles)

+ 1 - 1
Source/Urho3D/Network/Connection.cpp

@@ -334,7 +334,7 @@ void Connection::SendPackages()
             HashMap<StringHash, PackageUpload>::Iterator current = i++;
             HashMap<StringHash, PackageUpload>::Iterator current = i++;
             PackageUpload& upload = current->second_;
             PackageUpload& upload = current->second_;
             unsigned fragmentSize =
             unsigned fragmentSize =
-                (unsigned)Min((int)(upload.file_->GetSize() - upload.file_->GetPosition()), (int)PACKAGE_FRAGMENT_SIZE);
+                Min((upload.file_->GetSize() - upload.file_->GetPosition()), PACKAGE_FRAGMENT_SIZE);
             upload.file_->Read(buffer, fragmentSize);
             upload.file_->Read(buffer, fragmentSize);
 
 
             msg_.Clear();
             msg_.Clear();

+ 5 - 5
Source/Urho3D/Resource/Image.cpp

@@ -373,20 +373,20 @@ bool Image::BeginLoad(Deserializer& source)
             unsigned z = ddsd.dwDepth_ / 2;
             unsigned z = ddsd.dwDepth_ / 2;
             for (unsigned level = ddsd.dwMipMapCount_; level > 1; x /= 2, y /= 2, z /= 2, --level)
             for (unsigned level = ddsd.dwMipMapCount_; level > 1; x /= 2, y /= 2, z /= 2, --level)
             {
             {
-                blocksWide = (Max(x, 1) + 3) / 4;
-                blocksHeight = (Max(y, 1) + 3) / 4;
-                dataSize += blockSize * blocksWide * blocksHeight * Max(z, 1);
+                blocksWide = (Max(x, 1U) + 3) / 4;
+                blocksHeight = (Max(y, 1U) + 3) / 4;
+                dataSize += blockSize * blocksWide * blocksHeight * Max(z, 1U);
             }
             }
         }
         }
         else
         else
         {
         {
-            dataSize = (ddsd.ddpfPixelFormat_.dwRGBBitCount_ / 8) * ddsd.dwWidth_ * ddsd.dwHeight_ * Max(ddsd.dwDepth_, 1);
+            dataSize = (ddsd.ddpfPixelFormat_.dwRGBBitCount_ / 8) * ddsd.dwWidth_ * ddsd.dwHeight_ * Max(ddsd.dwDepth_, 1U);
             // Calculate mip data size
             // Calculate mip data size
             unsigned x = ddsd.dwWidth_ / 2;
             unsigned x = ddsd.dwWidth_ / 2;
             unsigned y = ddsd.dwHeight_ / 2;
             unsigned y = ddsd.dwHeight_ / 2;
             unsigned z = ddsd.dwDepth_ / 2;
             unsigned z = ddsd.dwDepth_ / 2;
             for (unsigned level = ddsd.dwMipMapCount_; level > 1; x /= 2, y /= 2, z /= 2, --level)
             for (unsigned level = ddsd.dwMipMapCount_; level > 1; x /= 2, y /= 2, z /= 2, --level)
-                dataSize += (ddsd.ddpfPixelFormat_.dwRGBBitCount_ / 8) * Max(x, 1) * Max(y, 1) * Max(z, 1);
+                dataSize += (ddsd.ddpfPixelFormat_.dwRGBBitCount_ / 8) * Max(x, 1U) * Max(y, 1U) * Max(z, 1U);
         }
         }
 
 
         // Do not use a shared ptr here, in case nothing is refcounting the image outside this function.
         // Do not use a shared ptr here, in case nothing is refcounting the image outside this function.

+ 4 - 4
Source/Urho3D/UI/FontFaceFreeType.cpp

@@ -412,23 +412,23 @@ bool FontFaceFreeType::LoadCharGlyph(unsigned charCode, Image* image)
             FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
             FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
             if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO)
             if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO)
             {
             {
-                for (unsigned y = 0; y < slot->bitmap.rows; ++y)
+                for (int y = 0; y < slot->bitmap.rows; ++y)
                 {
                 {
                     unsigned char* src = slot->bitmap.buffer + slot->bitmap.pitch * y;
                     unsigned char* src = slot->bitmap.buffer + slot->bitmap.pitch * y;
                     unsigned char* rowDest = dest + y * pitch;
                     unsigned char* rowDest = dest + y * pitch;
 
 
-                    for (unsigned x = 0; x < slot->bitmap.width; ++x)
+                    for (int x = 0; x < slot->bitmap.width; ++x)
                         rowDest[x] = (unsigned char)((src[x >> 3] & (0x80 >> (x & 7))) ? 255 : 0);
                         rowDest[x] = (unsigned char)((src[x >> 3] & (0x80 >> (x & 7))) ? 255 : 0);
                 }
                 }
             }
             }
             else
             else
             {
             {
-                for (unsigned y = 0; y < slot->bitmap.rows; ++y)
+                for (int y = 0; y < slot->bitmap.rows; ++y)
                 {
                 {
                     unsigned char* src = slot->bitmap.buffer + slot->bitmap.pitch * y;
                     unsigned char* src = slot->bitmap.buffer + slot->bitmap.pitch * y;
                     unsigned char* rowDest = dest + y * pitch;
                     unsigned char* rowDest = dest + y * pitch;
 
 
-                    for (unsigned x = 0; x < slot->bitmap.width; ++x)
+                    for (int x = 0; x < slot->bitmap.width; ++x)
                         rowDest[x] = src[x];
                         rowDest[x] = src[x];
                 }
                 }
             }
             }

+ 2 - 2
Source/Urho3D/UI/Text.cpp

@@ -531,7 +531,7 @@ void Text::UpdateText(bool onResize)
                             printToText_.Pop();
                             printToText_.Pop();
                         }
                         }
                         printText_.Push('\n');
                         printText_.Push('\n');
-                        printToText_.Push((unsigned)Min((int)i, (int)unicodeText_.Size() - 1));
+                        printToText_.Push(Min(i, unicodeText_.Size() - 1));
                         rowWidth = 0;
                         rowWidth = 0;
                         nextBreak = lineStart = i;
                         nextBreak = lineStart = i;
                     }
                     }
@@ -557,7 +557,7 @@ void Text::UpdateText(bool onResize)
                 else
                 else
                 {
                 {
                     printText_.Push('\n');
                     printText_.Push('\n');
-                    printToText_.Push((unsigned)Min((int)i, (int)unicodeText_.Size() - 1));
+                    printToText_.Push(Min(i, unicodeText_.Size() - 1));
                     rowWidth = 0;
                     rowWidth = 0;
                     nextBreak = lineStart = i;
                     nextBreak = lineStart = i;
                 }
                 }

+ 4 - 4
Source/Urho3D/Urho2D/ParticleEmitter2D.cpp

@@ -128,7 +128,7 @@ void ParticleEmitter2D::SetBlendMode(BlendMode blendMode)
 
 
 void ParticleEmitter2D::SetMaxParticles(unsigned maxParticles)
 void ParticleEmitter2D::SetMaxParticles(unsigned maxParticles)
 {
 {
-    maxParticles = Max(maxParticles, 1);
+    maxParticles = Max(maxParticles, 1U);
 
 
     particles_.Resize(maxParticles);
     particles_.Resize(maxParticles);
     sourceBatches_[0].vertices_.Reserve(maxParticles * 4);
     sourceBatches_[0].vertices_.Reserve(maxParticles * 4);
@@ -228,7 +228,7 @@ void ParticleEmitter2D::UpdateSourceBatches()
     vertex2.uv_ = textureRect.max_;
     vertex2.uv_ = textureRect.max_;
     vertex3.uv_ = Vector2(textureRect.max_.x_, textureRect.min_.y_);
     vertex3.uv_ = Vector2(textureRect.max_.x_, textureRect.min_.y_);
 
 
-    for (int i = 0; i < numParticles_; ++i)
+    for (unsigned i = 0; i < numParticles_; ++i)
     {
     {
         Particle2D& p = particles_[i];
         Particle2D& p = particles_[i];
 
 
@@ -280,7 +280,7 @@ void ParticleEmitter2D::Update(float timeStep)
     boundingBoxMinPoint_ = Vector3(M_INFINITY, M_INFINITY, M_INFINITY);
     boundingBoxMinPoint_ = Vector3(M_INFINITY, M_INFINITY, M_INFINITY);
     boundingBoxMaxPoint_ = Vector3(-M_INFINITY, -M_INFINITY, -M_INFINITY);
     boundingBoxMaxPoint_ = Vector3(-M_INFINITY, -M_INFINITY, -M_INFINITY);
 
 
-    int particleIndex = 0;
+    unsigned particleIndex = 0;
     while (particleIndex < numParticles_)
     while (particleIndex < numParticles_)
     {
     {
         Particle2D& particle = particles_[particleIndex];
         Particle2D& particle = particles_[particleIndex];
@@ -323,7 +323,7 @@ void ParticleEmitter2D::Update(float timeStep)
 
 
 bool ParticleEmitter2D::EmitParticle(const Vector3& worldPosition, float worldAngle, float worldScale)
 bool ParticleEmitter2D::EmitParticle(const Vector3& worldPosition, float worldAngle, float worldScale)
 {
 {
-    if (numParticles_ >= effect_->GetMaxParticles() || numParticles_ >= (int)particles_.Size())
+    if (numParticles_ >= (unsigned)effect_->GetMaxParticles() || numParticles_ >= particles_.Size())
         return false;
         return false;
 
 
     float lifespan = effect_->GetParticleLifeSpan() + effect_->GetParticleLifespanVariance() * Random(-1.0f, 1.0f);
     float lifespan = effect_->GetParticleLifeSpan() + effect_->GetParticleLifespanVariance() * Random(-1.0f, 1.0f);

+ 2 - 2
Source/Urho3D/Urho2D/ParticleEmitter2D.h

@@ -143,8 +143,8 @@ private:
     SharedPtr<Sprite2D> sprite_;
     SharedPtr<Sprite2D> sprite_;
     /// Blend mode.
     /// Blend mode.
     BlendMode blendMode_;
     BlendMode blendMode_;
-    /// Num particles.
-    int numParticles_;
+    /// Nummber of particles.
+    unsigned numParticles_;
     /// Emission time.
     /// Emission time.
     float emissionTime_;
     float emissionTime_;
     /// Emit particle time
     /// Emit particle time

+ 1 - 1
Source/Urho3D/Urho2D/Renderer2D.cpp

@@ -134,7 +134,7 @@ void Renderer2D::UpdateGeometry(const FrameInfo& frame)
     for (HashMap<Camera*, ViewBatchInfo2D>::ConstIterator i = viewBatchInfos_.Begin(); i != viewBatchInfos_.End(); ++i)
     for (HashMap<Camera*, ViewBatchInfo2D>::ConstIterator i = viewBatchInfos_.Begin(); i != viewBatchInfos_.End(); ++i)
     {
     {
         if (i->second_.batchUpdatedFrameNumber_ == frame_.frameNumber_)
         if (i->second_.batchUpdatedFrameNumber_ == frame_.frameNumber_)
-            indexCount = (unsigned)Max((int)indexCount, (int)i->second_.indexCount_);
+            indexCount = Max(indexCount, i->second_.indexCount_);
     }
     }
 
 
     // Fill index buffer
     // Fill index buffer