Browse Source

Clang-Tidy - hicpp-signed-bitwise.
However, this check is disabled because we could not cleanly modify the code everywhere to make them pass.

Yao Wei Tjong 姚伟忠 7 years ago
parent
commit
d43bf1b3d6
65 changed files with 270 additions and 286 deletions
  1. 1 1
      Source/Samples/07_Billboards/Billboards.cpp
  2. 2 1
      Source/Samples/17_SceneReplication/SceneReplication.cpp
  3. 5 5
      Source/Samples/18_CharacterDemo/Character.h
  4. 4 4
      Source/Samples/19_VehicleDemo/Vehicle.h
  5. 1 1
      Source/Samples/26_ConsoleInput/ConsoleInput.cpp
  6. 1 1
      Source/Samples/26_ConsoleInput/ConsoleInput.h
  7. 1 1
      Source/Samples/28_Urho2DPhysicsRope/Urho2DPhysicsRope.cpp
  8. 5 5
      Source/Samples/46_RaycastVehicle/Vehicle.h
  9. 2 2
      Source/Tools/AssetImporter/AssetImporter.cpp
  10. 2 2
      Source/Tools/OgreImporter/OgreImporter.cpp
  11. 2 2
      Source/Tools/OgreImporter/OgreImporterUtils.h
  12. 2 2
      Source/Tools/SpritePacker/SpritePacker.cpp
  13. 2 1
      Source/Urho3D/AngelScript/MathAPI.cpp
  14. 2 2
      Source/Urho3D/Audio/Audio.cpp
  15. 4 4
      Source/Urho3D/Audio/OggVorbisSoundStream.cpp
  16. 3 3
      Source/Urho3D/Audio/SoundSource.cpp
  17. 1 1
      Source/Urho3D/Container/Allocator.cpp
  18. 2 2
      Source/Urho3D/Container/Hash.h
  19. 1 1
      Source/Urho3D/Container/HashMap.h
  20. 1 1
      Source/Urho3D/Container/HashSet.h
  21. 28 28
      Source/Urho3D/Container/Str.cpp
  22. 1 1
      Source/Urho3D/Container/Str.h
  23. 6 6
      Source/Urho3D/Core/StringUtils.cpp
  24. 10 10
      Source/Urho3D/Graphics/Batch.cpp
  25. 2 2
      Source/Urho3D/Graphics/Drawable.h
  26. 5 5
      Source/Urho3D/Graphics/Model.cpp
  27. 9 9
      Source/Urho3D/Graphics/OcclusionBuffer.cpp
  28. 3 3
      Source/Urho3D/Graphics/Octree.cpp
  29. 8 9
      Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp
  30. 1 1
      Source/Urho3D/Graphics/OpenGL/OGLGraphicsImpl.h
  31. 1 1
      Source/Urho3D/Graphics/OpenGL/OGLShaderProgram.cpp
  32. 5 5
      Source/Urho3D/Graphics/OpenGL/OGLTexture.cpp
  33. 5 5
      Source/Urho3D/Graphics/OpenGL/OGLTexture2D.cpp
  34. 5 5
      Source/Urho3D/Graphics/OpenGL/OGLTexture2DArray.cpp
  35. 6 6
      Source/Urho3D/Graphics/OpenGL/OGLTexture3D.cpp
  36. 5 5
      Source/Urho3D/Graphics/OpenGL/OGLTextureCube.cpp
  37. 11 11
      Source/Urho3D/Graphics/Renderer.cpp
  38. 2 4
      Source/Urho3D/Graphics/Renderer.h
  39. 13 14
      Source/Urho3D/Graphics/Terrain.cpp
  40. 6 6
      Source/Urho3D/Graphics/Texture.cpp
  41. 3 3
      Source/Urho3D/Graphics/VertexBuffer.cpp
  42. 2 2
      Source/Urho3D/Graphics/View.cpp
  43. 4 4
      Source/Urho3D/IO/Deserializer.cpp
  44. 2 2
      Source/Urho3D/IO/MemoryBuffer.cpp
  45. 9 9
      Source/Urho3D/IO/Serializer.cpp
  46. 2 2
      Source/Urho3D/IO/VectorBuffer.cpp
  47. 6 6
      Source/Urho3D/Input/Input.cpp
  48. 5 5
      Source/Urho3D/Math/Color.cpp
  49. 13 24
      Source/Urho3D/Math/MathDefs.h
  50. 1 1
      Source/Urho3D/Math/Random.cpp
  51. 3 3
      Source/Urho3D/Navigation/CrowdAgent.cpp
  52. 2 2
      Source/Urho3D/Navigation/DynamicNavigationMesh.cpp
  53. 2 2
      Source/Urho3D/Navigation/NavigationMesh.cpp
  54. 1 4
      Source/Urho3D/Network/Network.h
  55. 2 2
      Source/Urho3D/Physics/CollisionShape.cpp
  56. 5 5
      Source/Urho3D/Resource/JSONValue.cpp
  57. 6 6
      Source/Urho3D/Scene/ReplicationState.h
  58. 3 3
      Source/Urho3D/Scene/Serializable.cpp
  59. 1 1
      Source/Urho3D/UI/FontFace.cpp
  60. 7 7
      Source/Urho3D/UI/FontFaceBitmap.cpp
  61. 3 3
      Source/Urho3D/UI/FontFaceFreeType.cpp
  62. 3 3
      Source/Urho3D/UI/UI.cpp
  63. 5 5
      Source/Urho3D/Urho2D/AnimationSet2D.cpp
  64. 1 1
      Source/Urho3D/Urho2D/AnimationSet2D.h
  65. 3 3
      Source/Urho3D/Urho2D/TmxFile2D.cpp

+ 1 - 1
Source/Samples/07_Billboards/Billboards.cpp

@@ -175,7 +175,7 @@ void Billboards::CreateScene()
         float angle = 0.0f;
         float angle = 0.0f;
 
 
         Vector3 position((i % 3) * 60.0f - 60.0f, 45.0f, (i / 3) * 60.0f - 60.0f);
         Vector3 position((i % 3) * 60.0f - 60.0f, 45.0f, (i / 3) * 60.0f - 60.0f);
-        Color color(((i + 1) & 1) * 0.5f + 0.5f, (((i + 1) >> 1) & 1) * 0.5f + 0.5f, (((i + 1) >> 2) & 1) * 0.5f + 0.5f);
+        Color color(((i + 1) & 1u) * 0.5f + 0.5f, (((i + 1) >> 1u) & 1u) * 0.5f + 0.5f, (((i + 1) >> 2u) & 1u) * 0.5f + 0.5f);
 
 
         lightNode->SetPosition(position);
         lightNode->SetPosition(position);
         lightNode->SetDirection(Vector3(Sin(angle), -1.5f, Cos(angle)));
         lightNode->SetDirection(Vector3(Sin(angle), -1.5f, Cos(angle)));

+ 2 - 1
Source/Samples/17_SceneReplication/SceneReplication.cpp

@@ -292,7 +292,8 @@ Node* SceneReplication::CreateControllableObject()
     // Create a random colored point light at the ball so that can see better where is going
     // Create a random colored point light at the ball so that can see better where is going
     auto* light = ballNode->CreateComponent<Light>();
     auto* light = ballNode->CreateComponent<Light>();
     light->SetRange(3.0f);
     light->SetRange(3.0f);
-    light->SetColor(Color(0.5f + (Rand() & 1) * 0.5f, 0.5f + (Rand() & 1) * 0.5f, 0.5f + (Rand() & 1) * 0.5f));
+    light->SetColor(
+        Color(0.5f + ((unsigned)Rand() & 1u) * 0.5f, 0.5f + ((unsigned)Rand() & 1u) * 0.5f, 0.5f + ((unsigned)Rand() & 1u) * 0.5f));
 
 
     return ballNode;
     return ballNode;
 }
 }

+ 5 - 5
Source/Samples/18_CharacterDemo/Character.h

@@ -27,11 +27,11 @@
 
 
 using namespace Urho3D;
 using namespace Urho3D;
 
 
-const int CTRL_FORWARD = 1;
-const int CTRL_BACK = 2;
-const int CTRL_LEFT = 4;
-const int CTRL_RIGHT = 8;
-const int CTRL_JUMP = 16;
+const unsigned CTRL_FORWARD = 1;
+const unsigned CTRL_BACK = 2;
+const unsigned CTRL_LEFT = 4;
+const unsigned CTRL_RIGHT = 8;
+const unsigned CTRL_JUMP = 16;
 
 
 const float MOVE_FORCE = 0.8f;
 const float MOVE_FORCE = 0.8f;
 const float INAIR_MOVE_FORCE = 0.02f;
 const float INAIR_MOVE_FORCE = 0.02f;

+ 4 - 4
Source/Samples/19_VehicleDemo/Vehicle.h

@@ -36,10 +36,10 @@ class RigidBody;
 
 
 using namespace Urho3D;
 using namespace Urho3D;
 
 
-const int CTRL_FORWARD = 1;
-const int CTRL_BACK = 2;
-const int CTRL_LEFT = 4;
-const int CTRL_RIGHT = 8;
+const unsigned CTRL_FORWARD = 1;
+const unsigned CTRL_BACK = 2;
+const unsigned CTRL_LEFT = 4;
+const unsigned CTRL_RIGHT = 8;
 
 
 const float YAW_SENSITIVITY = 0.1f;
 const float YAW_SENSITIVITY = 0.1f;
 const float ENGINE_POWER = 10.0f;
 const float ENGINE_POWER = 10.0f;

+ 1 - 1
Source/Samples/26_ConsoleInput/ConsoleInput.cpp

@@ -171,7 +171,7 @@ void ConsoleInput::Advance()
     if (urhoThreat_ > 0)
     if (urhoThreat_ > 0)
         Print(String(urhoThreatLevels[urhoThreat_ - 1]) + ".");
         Print(String(urhoThreatLevels[urhoThreat_ - 1]) + ".");
 
 
-    if ((numTurns_ & 3) == 0 && !eatenLastTurn_)
+    if ((numTurns_ & 3u) == 0 && !eatenLastTurn_)
     {
     {
         ++hunger_;
         ++hunger_;
         if (hunger_ > 5)
         if (hunger_ > 5)

+ 1 - 1
Source/Samples/26_ConsoleInput/ConsoleInput.h

@@ -78,7 +78,7 @@ private:
     /// Whether ate on the previous turn.
     /// Whether ate on the previous turn.
     bool eatenLastTurn_{};
     bool eatenLastTurn_{};
     /// Number of turns survived.
     /// Number of turns survived.
-    int numTurns_{};
+    unsigned numTurns_{};
     /// Player's hunger level.
     /// Player's hunger level.
     int hunger_{};
     int hunger_{};
     /// Threat of Urho level.
     /// Threat of Urho level.

+ 1 - 1
Source/Samples/28_Urho2DPhysicsRope/Urho2DPhysicsRope.cpp

@@ -118,7 +118,7 @@ void Urho2DPhysicsRope::CreateScene()
         // Set friction
         // Set friction
         box->SetFriction(0.2f);
         box->SetFriction(0.2f);
         // Set mask bits.
         // Set mask bits.
-        box->SetMaskBits(0xFFFF & ~0x0002);
+        box->SetMaskBits(0xFFFFu & ~0x0002u);
 
 
         if (i == NUM_OBJECTS - 1)
         if (i == NUM_OBJECTS - 1)
         {
         {

+ 5 - 5
Source/Samples/46_RaycastVehicle/Vehicle.h

@@ -35,11 +35,11 @@ namespace Urho3D
 
 
 using namespace Urho3D;
 using namespace Urho3D;
 
 
-const int CTRL_FORWARD = (1 << 0);
-const int CTRL_BACK = (1 << 1);
-const int CTRL_LEFT = (1 << 2);
-const int CTRL_RIGHT = (1 << 3);
-const int CTRL_BRAKE = (1 << 4);
+const unsigned CTRL_FORWARD = (1u << 0u);
+const unsigned CTRL_BACK = (1u << 1u);
+const unsigned CTRL_LEFT = (1u << 2u);
+const unsigned CTRL_RIGHT = (1u << 3u);
+const unsigned CTRL_BRAKE = (1u << 4u);
 const float YAW_SENSITIVITY = 0.1f;
 const float YAW_SENSITIVITY = 0.1f;
 const float ENGINE_POWER = 10.0f;
 const float ENGINE_POWER = 10.0f;
 const float MAX_WHEEL_ANGLE = 22.5f;
 const float MAX_WHEEL_ANGLE = 22.5f;

+ 2 - 2
Source/Tools/AssetImporter/AssetImporter.cpp

@@ -588,7 +588,7 @@ void Run(const Vector<String>& arguments)
         }
         }
         if (numLodArguments < 4)
         if (numLodArguments < 4)
             ErrorExit("Must define at least 2 LOD levels");
             ErrorExit("Must define at least 2 LOD levels");
-        if (!(numLodArguments & 1))
+        if (!(numLodArguments & 1u))
             ErrorExit("No output file defined");
             ErrorExit("No output file defined");
 
 
         for (unsigned i = 1; i < numLodArguments + 1; ++i)
         for (unsigned i = 1; i < numLodArguments + 1; ++i)
@@ -597,7 +597,7 @@ void Run(const Vector<String>& arguments)
                 outFile = GetInternalPath(arguments[i]);
                 outFile = GetInternalPath(arguments[i]);
             else
             else
             {
             {
-                if (i & 1)
+                if (i & 1u)
                     lodDistances.Push(Max(ToFloat(arguments[i]), 0.0f));
                     lodDistances.Push(Max(ToFloat(arguments[i]), 0.0f));
                 else
                 else
                     modelNames.Push(GetInternalPath(arguments[i]));
                     modelNames.Push(GetInternalPath(arguments[i]));

+ 2 - 2
Source/Tools/OgreImporter/OgreImporter.cpp

@@ -908,9 +908,9 @@ void WriteOutput(const String& outputFileName, bool exportAnimations, bool rotat
             dest.Write(offsetMatrix.Data(), sizeof(Matrix3x4));
             dest.Write(offsetMatrix.Data(), sizeof(Matrix3x4));
 
 
             dest.WriteUByte(bones_[i].collisionMask_);
             dest.WriteUByte(bones_[i].collisionMask_);
-            if (bones_[i].collisionMask_ & 1)
+            if (bones_[i].collisionMask_ & 1u)
                 dest.WriteFloat(bones_[i].radius_);
                 dest.WriteFloat(bones_[i].radius_);
-            if (bones_[i].collisionMask_ & 2)
+            if (bones_[i].collisionMask_ & 2u)
                 dest.WriteBoundingBox(bones_[i].boundingBox_);
                 dest.WriteBoundingBox(bones_[i].boundingBox_);
         }
         }
 
 

+ 2 - 2
Source/Tools/OgreImporter/OgreImporterUtils.h

@@ -138,8 +138,8 @@ struct ModelVertexBuffer
         for (unsigned j = 0; j < elements.Size(); ++j)
         for (unsigned j = 0; j < elements.Size(); ++j)
         {
         {
             unsigned elementDesc = ((unsigned)elements[j].type_) |
             unsigned elementDesc = ((unsigned)elements[j].type_) |
-                (((unsigned)elements[j].semantic_) << 8) |
-                (((unsigned)elements[j].index_) << 16);
+                (((unsigned)elements[j].semantic_) << 8u) |
+                (((unsigned)elements[j].index_) << 16u);
             dest.WriteUInt(elementDesc);
             dest.WriteUInt(elementDesc);
         }
         }
 
 

+ 2 - 2
Source/Tools/SpritePacker/SpritePacker.cpp

@@ -221,7 +221,7 @@ void Run(Vector<String>& arguments)
             {
             {
                 for (int x = 0; x < imageWidth; ++x)
                 for (int x = 0; x < imageWidth; ++x)
                 {
                 {
-                    bool found = (image.GetPixelInt(x, y) & 0x000000ff) != 0;
+                    bool found = (image.GetPixelInt(x, y) & 0x000000ffu) != 0;
                     if (found) {
                     if (found) {
                         minX = Min(minX, x);
                         minX = Min(minX, x);
                         minY = Min(minY, y);
                         minY = Min(minY, y);
@@ -262,7 +262,7 @@ void Run(Vector<String>& arguments)
         for(unsigned x=2; x<11; ++x)
         for(unsigned x=2; x<11; ++x)
         {
         {
             for(unsigned y=2; y<11; ++y)
             for(unsigned y=2; y<11; ++y)
-                tries.Push(IntVector2((1<<x), (1<<y)));
+                tries.Push(IntVector2((1u<<x), (1u<<y)));
         }
         }
 
 
         // load rectangles
         // load rectangles

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

@@ -53,7 +53,8 @@ static void RegisterMathFunctions(asIScriptEngine* engine)
     engine->RegisterGlobalProperty("const uint M_MAX_UNSIGNED", (void*)&M_MAX_UNSIGNED);
     engine->RegisterGlobalProperty("const uint M_MAX_UNSIGNED", (void*)&M_MAX_UNSIGNED);
 
 
     engine->RegisterGlobalFunction("bool Equals(float, float)", asFUNCTION(Equals<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("bool Equals(float, float)", asFUNCTION(Equals<float>), asCALL_CDECL);
-    engine->RegisterGlobalFunction("bool IsNaN(float)", asFUNCTION(IsNaN), asCALL_CDECL);
+    engine->RegisterGlobalFunction("bool IsNaN(float)", asFUNCTIONPR(IsNaN, (float), bool), asCALL_CDECL);
+    engine->RegisterGlobalFunction("bool IsNaN(double)", asFUNCTIONPR(IsNaN, (double), bool), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Sin(float)", asFUNCTION(Sin<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Sin(float)", asFUNCTION(Sin<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Cos(float)", asFUNCTION(Cos<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Cos(float)", asFUNCTION(Cos<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Tan(float)", asFUNCTION(Tan<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Tan(float)", asFUNCTION(Tan<float>), asCALL_CDECL);

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

@@ -115,10 +115,10 @@ 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_ = Min(NextPowerOfTwo((unsigned)(mixRate >> 6)), (unsigned)obtained.samples);
+    fragmentSize_ = Min(NextPowerOfTwo((unsigned)mixRate >> 6u), (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_ << 1u : fragmentSize_];
 
 
     URHO3D_LOGINFO("Set audio mode " + String(mixRate_) + " Hz " + (stereo_ ? "stereo" : "mono") + " " +
     URHO3D_LOGINFO("Set audio mode " + String(mixRate_) + " Hz " + (stereo_ ? "stereo" : "mono") + " " +
             (interpolation_ ? "interpolated" : ""));
             (interpolation_ ? "interpolated" : ""));

+ 4 - 4
Source/Urho3D/Audio/OggVorbisSoundStream.cpp

@@ -77,8 +77,8 @@ unsigned OggVorbisSoundStream::GetData(signed char* dest, unsigned numBytes)
     auto* vorbis = static_cast<stb_vorbis*>(decoder_);
     auto* vorbis = static_cast<stb_vorbis*>(decoder_);
 
 
     unsigned channels = stereo_ ? 2 : 1;
     unsigned channels = stereo_ ? 2 : 1;
-    auto outSamples = (unsigned)stb_vorbis_get_samples_short_interleaved(vorbis, channels, (short*)dest, numBytes >> 1);
-    unsigned outBytes = (outSamples * channels) << 1;
+    auto outSamples = (unsigned)stb_vorbis_get_samples_short_interleaved(vorbis, channels, (short*)dest, numBytes >> 1u);
+    unsigned outBytes = (outSamples * channels) << 1u;
 
 
     // Rewind and retry if is looping and produced less output than should have
     // Rewind and retry if is looping and produced less output than should have
     if (outBytes < numBytes && !stopAtEnd_)
     if (outBytes < numBytes && !stopAtEnd_)
@@ -86,8 +86,8 @@ unsigned OggVorbisSoundStream::GetData(signed char* dest, unsigned numBytes)
         numBytes -= outBytes;
         numBytes -= outBytes;
         stb_vorbis_seek_start(vorbis);
         stb_vorbis_seek_start(vorbis);
         outSamples =
         outSamples =
-            (unsigned)stb_vorbis_get_samples_short_interleaved(vorbis, channels, (short*)(dest + outBytes), numBytes >> 1);
-        outBytes += (outSamples * channels) << 1;
+            (unsigned)stb_vorbis_get_samples_short_interleaved(vorbis, channels, (short*)(dest + outBytes), numBytes >> 1u);
+        outBytes += (outSamples * channels) << 1u;
     }
     }
 
 
     return outBytes;
     return outBytes;

+ 3 - 3
Source/Urho3D/Audio/SoundSource.cpp

@@ -64,7 +64,7 @@ namespace Urho3D
     } \
     } \
 
 
 #define INC_POS_STEREO_LOOPED() \
 #define INC_POS_STEREO_LOOPED() \
-    pos += (intAdd << 1); \
+    pos += ((unsigned)intAdd << 1u); \
     fractPos += fractAdd; \
     fractPos += fractAdd; \
     if (fractPos > 65535) \
     if (fractPos > 65535) \
     { \
     { \
@@ -75,7 +75,7 @@ namespace Urho3D
         pos -= (end - repeat); \
         pos -= (end - repeat); \
 
 
 #define INC_POS_STEREO_ONESHOT() \
 #define INC_POS_STEREO_ONESHOT() \
-    pos += (intAdd << 1); \
+    pos += ((unsigned)intAdd << 1u); \
     fractPos += fractAdd; \
     fractPos += fractAdd; \
     if (fractPos > 65535) \
     if (fractPos > 65535) \
     { \
     { \
@@ -593,7 +593,7 @@ void SoundSource::SetPlayPositionLockless(signed char* pos)
     signed char* end = sound_->GetEnd();
     signed char* end = sound_->GetEnd();
     if (pos < start)
     if (pos < start)
         pos = start;
         pos = start;
-    if (sound_->IsSixteenBit() && (pos - start) & 1)
+    if (sound_->IsSixteenBit() && (pos - start) & 1u)
         ++pos;
         ++pos;
     if (pos > end)
     if (pos > end)
         pos = end;
         pos = end;

+ 1 - 1
Source/Urho3D/Container/Allocator.cpp

@@ -92,7 +92,7 @@ void* AllocatorReserve(AllocatorBlock* allocator)
     if (!allocator->free_)
     if (!allocator->free_)
     {
     {
         // Free nodes have been exhausted. Allocate a new larger block
         // Free nodes have been exhausted. Allocate a new larger block
-        unsigned newCapacity = (allocator->capacity_ + 1) >> 1;
+        unsigned newCapacity = (allocator->capacity_ + 1) >> 1u;
         AllocatorReserveBlock(allocator, allocator->nodeSize_, newCapacity);
         AllocatorReserveBlock(allocator, allocator->nodeSize_, newCapacity);
         allocator->capacity_ += newCapacity;
         allocator->capacity_ += newCapacity;
     }
     }

+ 2 - 2
Source/Urho3D/Container/Hash.h

@@ -60,13 +60,13 @@ template <> inline unsigned MakeHash(const void* value)
 /// Long long hash function.
 /// Long long hash function.
 template <> inline unsigned MakeHash(const long long& value)
 template <> inline unsigned MakeHash(const long long& value)
 {
 {
-    return (unsigned)((value >> 32) | (value & 0xffffffff));
+    return (unsigned)((value >> 32u) | (value & 0xffffffffu));
 }
 }
 
 
 /// Unsigned long long hash function.
 /// Unsigned long long hash function.
 template <> inline unsigned MakeHash(const unsigned long long& value)
 template <> inline unsigned MakeHash(const unsigned long long& value)
 {
 {
-    return (unsigned)((value >> 32) | (value & 0xffffffff));
+    return (unsigned)((value >> 32u) | (value & 0xffffffffu));
 }
 }
 
 
 /// Int hash function.
 /// Int hash function.

+ 1 - 1
Source/Urho3D/Container/HashMap.h

@@ -496,7 +496,7 @@ public:
 
 
         // Check for being power of two
         // Check for being power of two
         unsigned check = numBuckets;
         unsigned check = numBuckets;
-        while (!(check & 1))
+        while (!(check & 1u))
             check >>= 1;
             check >>= 1;
         if (check != 1)
         if (check != 1)
             return false;
             return false;

+ 1 - 1
Source/Urho3D/Container/HashSet.h

@@ -430,7 +430,7 @@ public:
 
 
         // Check for being power of two
         // Check for being power of two
         unsigned check = numBuckets;
         unsigned check = numBuckets;
-        while (!(check & 1))
+        while (!(check & 1u))
             check >>= 1;
             check >>= 1;
         if (check != 1)
         if (check != 1)
             return false;
             return false;

+ 28 - 28
Source/Urho3D/Container/Str.cpp

@@ -436,7 +436,7 @@ void String::Resize(unsigned newLength)
         {
         {
             // Increase the capacity with half each time it is exceeded
             // Increase the capacity with half each time it is exceeded
             while (capacity_ < newLength + 1)
             while (capacity_ < newLength + 1)
-                capacity_ += (capacity_ + 1) >> 1;
+                capacity_ += (capacity_ + 1) >> 1u;
 
 
             auto* newBuffer = new char[capacity_];
             auto* newBuffer = new char[capacity_];
             // Move the existing data to the new buffer, then delete the old buffer
             // Move the existing data to the new buffer, then delete the old buffer
@@ -898,42 +898,42 @@ void String::EncodeUTF8(char*& dest, unsigned unicodeChar)
         *dest++ = unicodeChar;
         *dest++ = unicodeChar;
     else if (unicodeChar < 0x800)
     else if (unicodeChar < 0x800)
     {
     {
-        dest[0] = (char)(0xc0 | ((unicodeChar >> 6) & 0x1f));
-        dest[1] = (char)(0x80 | (unicodeChar & 0x3f));
+        dest[0] = (char)(0xc0u | ((unicodeChar >> 6u) & 0x1fu));
+        dest[1] = (char)(0x80u | (unicodeChar & 0x3fu));
         dest += 2;
         dest += 2;
     }
     }
     else if (unicodeChar < 0x10000)
     else if (unicodeChar < 0x10000)
     {
     {
-        dest[0] = (char)(0xe0 | ((unicodeChar >> 12) & 0xf));
-        dest[1] = (char)(0x80 | ((unicodeChar >> 6) & 0x3f));
-        dest[2] = (char)(0x80 | (unicodeChar & 0x3f));
+        dest[0] = (char)(0xe0u | ((unicodeChar >> 12u) & 0xfu));
+        dest[1] = (char)(0x80u | ((unicodeChar >> 6u) & 0x3fu));
+        dest[2] = (char)(0x80u | (unicodeChar & 0x3fu));
         dest += 3;
         dest += 3;
     }
     }
     else if (unicodeChar < 0x200000)
     else if (unicodeChar < 0x200000)
     {
     {
-        dest[0] = (char)(0xf0 | ((unicodeChar >> 18) & 0x7));
-        dest[1] = (char)(0x80 | ((unicodeChar >> 12) & 0x3f));
-        dest[2] = (char)(0x80 | ((unicodeChar >> 6) & 0x3f));
-        dest[3] = (char)(0x80 | (unicodeChar & 0x3f));
+        dest[0] = (char)(0xf0u | ((unicodeChar >> 18u) & 0x7u));
+        dest[1] = (char)(0x80u | ((unicodeChar >> 12u) & 0x3fu));
+        dest[2] = (char)(0x80u | ((unicodeChar >> 6u) & 0x3fu));
+        dest[3] = (char)(0x80u | (unicodeChar & 0x3fu));
         dest += 4;
         dest += 4;
     }
     }
     else if (unicodeChar < 0x4000000)
     else if (unicodeChar < 0x4000000)
     {
     {
-        dest[0] = (char)(0xf8 | ((unicodeChar >> 24) & 0x3));
-        dest[1] = (char)(0x80 | ((unicodeChar >> 18) & 0x3f));
-        dest[2] = (char)(0x80 | ((unicodeChar >> 12) & 0x3f));
-        dest[3] = (char)(0x80 | ((unicodeChar >> 6) & 0x3f));
-        dest[4] = (char)(0x80 | (unicodeChar & 0x3f));
+        dest[0] = (char)(0xf8u | ((unicodeChar >> 24u) & 0x3u));
+        dest[1] = (char)(0x80u | ((unicodeChar >> 18u) & 0x3fu));
+        dest[2] = (char)(0x80u | ((unicodeChar >> 12u) & 0x3fu));
+        dest[3] = (char)(0x80u | ((unicodeChar >> 6u) & 0x3fu));
+        dest[4] = (char)(0x80u | (unicodeChar & 0x3fu));
         dest += 5;
         dest += 5;
     }
     }
     else
     else
     {
     {
-        dest[0] = (char)(0xfc | ((unicodeChar >> 30) & 0x1));
-        dest[1] = (char)(0x80 | ((unicodeChar >> 24) & 0x3f));
-        dest[2] = (char)(0x80 | ((unicodeChar >> 18) & 0x3f));
-        dest[3] = (char)(0x80 | ((unicodeChar >> 12) & 0x3f));
-        dest[4] = (char)(0x80 | ((unicodeChar >> 6) & 0x3f));
-        dest[5] = (char)(0x80 | (unicodeChar & 0x3f));
+        dest[0] = (char)(0xfcu | ((unicodeChar >> 30u) & 0x1u));
+        dest[1] = (char)(0x80u | ((unicodeChar >> 24u) & 0x3fu));
+        dest[2] = (char)(0x80u | ((unicodeChar >> 18u) & 0x3fu));
+        dest[3] = (char)(0x80u | ((unicodeChar >> 12u) & 0x3fu));
+        dest[4] = (char)(0x80u | ((unicodeChar >> 6u) & 0x3fu));
+        dest[5] = (char)(0x80u | (unicodeChar & 0x3fu));
         dest += 6;
         dest += 6;
     }
     }
 }
 }
@@ -960,20 +960,20 @@ unsigned String::DecodeUTF8(const char*& src)
     else if (char1 < 0xe0)
     else if (char1 < 0xe0)
     {
     {
         unsigned char char2 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char2 = GET_NEXT_CONTINUATION_BYTE(src);
-        return (unsigned)((char2 & 0x3f) | ((char1 & 0x1f) << 6));
+        return (unsigned)((char2 & 0x3fu) | ((char1 & 0x1fu) << 6u));
     }
     }
     else if (char1 < 0xf0)
     else if (char1 < 0xf0)
     {
     {
         unsigned char char2 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char2 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char3 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char3 = GET_NEXT_CONTINUATION_BYTE(src);
-        return (unsigned)((char3 & 0x3f) | ((char2 & 0x3f) << 6) | ((char1 & 0xf) << 12));
+        return (unsigned)((char3 & 0x3fu) | ((char2 & 0x3fu) << 6u) | ((char1 & 0xfu) << 12u));
     }
     }
     else if (char1 < 0xf8)
     else if (char1 < 0xf8)
     {
     {
         unsigned char char2 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char2 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char3 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char3 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char4 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char4 = GET_NEXT_CONTINUATION_BYTE(src);
-        return (unsigned)((char4 & 0x3f) | ((char3 & 0x3f) << 6) | ((char2 & 0x3f) << 12) | ((char1 & 0x7) << 18));
+        return (unsigned)((char4 & 0x3fu) | ((char3 & 0x3fu) << 6u) | ((char2 & 0x3fu) << 12u) | ((char1 & 0x7u) << 18u));
     }
     }
     else if (char1 < 0xfc)
     else if (char1 < 0xfc)
     {
     {
@@ -981,8 +981,8 @@ unsigned String::DecodeUTF8(const char*& src)
         unsigned char char3 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char3 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char4 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char4 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char5 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char5 = GET_NEXT_CONTINUATION_BYTE(src);
-        return (unsigned)((char5 & 0x3f) | ((char4 & 0x3f) << 6) | ((char3 & 0x3f) << 12) | ((char2 & 0x3f) << 18) |
-                          ((char1 & 0x3) << 24));
+        return (unsigned)((char5 & 0x3fu) | ((char4 & 0x3fu) << 6u) | ((char3 & 0x3fu) << 12u) | ((char2 & 0x3fu) << 18u) |
+                          ((char1 & 0x3u) << 24u));
     }
     }
     else
     else
     {
     {
@@ -991,8 +991,8 @@ unsigned String::DecodeUTF8(const char*& src)
         unsigned char char4 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char4 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char5 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char5 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char6 = GET_NEXT_CONTINUATION_BYTE(src);
         unsigned char char6 = GET_NEXT_CONTINUATION_BYTE(src);
-        return (unsigned)((char6 & 0x3f) | ((char5 & 0x3f) << 6) | ((char4 & 0x3f) << 12) | ((char3 & 0x3f) << 18) |
-                          ((char2 & 0x3f) << 24) | ((char1 & 0x1) << 30));
+        return (unsigned)((char6 & 0x3fu) | ((char5 & 0x3fu) << 6u) | ((char4 & 0x3fu) << 12u) | ((char3 & 0x3fu) << 18u) |
+                          ((char2 & 0x3fu) << 24u) | ((char1 & 0x1u) << 30u));
     }
     }
 }
 }
 
 

+ 1 - 1
Source/Urho3D/Container/Str.h

@@ -446,7 +446,7 @@ public:
         const char* ptr = buffer_;
         const char* ptr = buffer_;
         while (*ptr)
         while (*ptr)
         {
         {
-            hash = *ptr + (hash << 6) + (hash << 16) - hash;
+            hash = *ptr + (hash << 6u) + (hash << 16u) - hash;
             ++ptr;
             ++ptr;
         }
         }
 
 

+ 6 - 6
Source/Urho3D/Core/StringUtils.cpp

@@ -811,9 +811,9 @@ PODVector<unsigned char> DecodeBase64(String encodedString)
             for (i = 0; i < 4; i++)
             for (i = 0; i < 4; i++)
                 charArray4[i] = base64_chars.Find(charArray4[i]);
                 charArray4[i] = base64_chars.Find(charArray4[i]);
 
 
-            charArray3[0] = (charArray4[0] << 2) + ((charArray4[1] & 0x30) >> 4);
-            charArray3[1] = ((charArray4[1] & 0xf) << 4) + ((charArray4[2] & 0x3c) >> 2);
-            charArray3[2] = ((charArray4[2] & 0x3) << 6) + charArray4[3];
+            charArray3[0] = (charArray4[0] << 2u) + ((charArray4[1] & 0x30u) >> 4u);
+            charArray3[1] = ((charArray4[1] & 0xfu) << 4u) + ((charArray4[2] & 0x3cu) >> 2u);
+            charArray3[2] = ((charArray4[2] & 0x3u) << 6u) + charArray4[3];
 
 
             for (i = 0; (i < 3); i++)
             for (i = 0; (i < 3); i++)
                 ret.Push(charArray3[i]);
                 ret.Push(charArray3[i]);
@@ -830,9 +830,9 @@ PODVector<unsigned char> DecodeBase64(String encodedString)
         for (j = 0; j <4; j++)
         for (j = 0; j <4; j++)
             charArray4[j] = base64_chars.Find(charArray4[j]);
             charArray4[j] = base64_chars.Find(charArray4[j]);
 
 
-        charArray3[0] = (charArray4[0] << 2) + ((charArray4[1] & 0x30) >> 4);
-        charArray3[1] = ((charArray4[1] & 0xf) << 4) + ((charArray4[2] & 0x3c) >> 2);
-        charArray3[2] = ((charArray4[2] & 0x3) << 6) + charArray4[3];
+        charArray3[0] = (charArray4[0] << 2u) + ((charArray4[1] & 0x30u) >> 4u);
+        charArray3[1] = ((charArray4[1] & 0xfu) << 4u) + ((charArray4[2] & 0x3cu) >> 2u);
+        charArray3[2] = ((charArray4[2] & 0x3u) << 6u) + charArray4[3];
 
 
         for (j = 0; (j < i - 1); j++)
         for (j = 0; (j < i - 1); j++)
             ret.Push(charArray3[j]);
             ret.Push(charArray3[j]);

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

@@ -163,16 +163,16 @@ void Batch::CalculateSortKey()
 {
 {
     auto shaderID = (unsigned)(
     auto shaderID = (unsigned)(
         ((*((unsigned*)&vertexShader_) / sizeof(ShaderVariation)) + (*((unsigned*)&pixelShader_) / sizeof(ShaderVariation))) &
         ((*((unsigned*)&vertexShader_) / sizeof(ShaderVariation)) + (*((unsigned*)&pixelShader_) / sizeof(ShaderVariation))) &
-        0x7fff);
+        0x7fffu);
     if (!isBase_)
     if (!isBase_)
         shaderID |= 0x8000;
         shaderID |= 0x8000;
 
 
-    auto lightQueueID = (unsigned)((*((unsigned*)&lightQueue_) / sizeof(LightBatchQueue)) & 0xffff);
-    auto materialID = (unsigned)((*((unsigned*)&material_) / sizeof(Material)) & 0xffff);
-    auto geometryID = (unsigned)((*((unsigned*)&geometry_) / sizeof(Geometry)) & 0xffff);
+    auto lightQueueID = (unsigned)((*((unsigned*)&lightQueue_) / sizeof(LightBatchQueue)) & 0xffffu);
+    auto materialID = (unsigned)((*((unsigned*)&material_) / sizeof(Material)) & 0xffffu);
+    auto geometryID = (unsigned)((*((unsigned*)&geometry_) / sizeof(Geometry)) & 0xffffu);
 
 
-    sortKey_ = (((unsigned long long)shaderID) << 48) | (((unsigned long long)lightQueueID) << 32) |
-               (((unsigned long long)materialID) << 16) | geometryID;
+    sortKey_ = (((unsigned long long)shaderID) << 48u) | (((unsigned long long)lightQueueID) << 32u) |
+               (((unsigned long long)materialID) << 16u) | geometryID;
 }
 }
 
 
 void Batch::Prepare(View* view, Camera* camera, bool setModelTransform, bool allowDepthWrite) const
 void Batch::Prepare(View* view, Camera* camera, bool setModelTransform, bool allowDepthWrite) const
@@ -231,7 +231,7 @@ void Batch::Prepare(View* view, Camera* camera, bool setModelTransform, bool all
     auto cameraHash = (unsigned)(size_t)camera;
     auto cameraHash = (unsigned)(size_t)camera;
     IntRect viewport = graphics->GetViewport();
     IntRect viewport = graphics->GetViewport();
     IntVector2 viewSize = IntVector2(viewport.Width(), viewport.Height());
     IntVector2 viewSize = IntVector2(viewport.Width(), viewport.Height());
-    auto viewportHash = (unsigned)(viewSize.x_ | (viewSize.y_ << 16));
+    auto viewportHash = (unsigned)viewSize.x_ | (unsigned)viewSize.y_ << 16u;
     if (graphics->NeedParameterUpdate(SP_CAMERA, reinterpret_cast<const void*>(cameraHash + viewportHash)))
     if (graphics->NeedParameterUpdate(SP_CAMERA, reinterpret_cast<const void*>(cameraHash + viewportHash)))
     {
     {
         view->SetCameraShaderParameters(camera);
         view->SetCameraShaderParameters(camera);
@@ -797,7 +797,7 @@ void BatchQueue::SortFrontToBack2Pass(PODVector<Batch*>& batches)
     {
     {
         Batch* batch = *i;
         Batch* batch = *i;
 
 
-        auto shaderID = (unsigned)(batch->sortKey_ >> 32);
+        auto shaderID = (unsigned)(batch->sortKey_ >> 32u);
         HashMap<unsigned, unsigned>::ConstIterator j = shaderRemapping_.Find(shaderID);
         HashMap<unsigned, unsigned>::ConstIterator j = shaderRemapping_.Find(shaderID);
         if (j != shaderRemapping_.End())
         if (j != shaderRemapping_.End())
             shaderID = j->second_;
             shaderID = j->second_;
@@ -817,7 +817,7 @@ void BatchQueue::SortFrontToBack2Pass(PODVector<Batch*>& batches)
             ++freeMaterialID;
             ++freeMaterialID;
         }
         }
 
 
-        auto geometryID = (unsigned short)(batch->sortKey_ & 0xffff);
+        auto geometryID = (unsigned short)(batch->sortKey_ & 0xffffu);
         HashMap<unsigned short, unsigned short>::ConstIterator l = geometryRemapping_.Find(geometryID);
         HashMap<unsigned short, unsigned short>::ConstIterator l = geometryRemapping_.Find(geometryID);
         if (l != geometryRemapping_.End())
         if (l != geometryRemapping_.End())
             geometryID = l->second_;
             geometryID = l->second_;
@@ -827,7 +827,7 @@ void BatchQueue::SortFrontToBack2Pass(PODVector<Batch*>& batches)
             ++freeGeometryID;
             ++freeGeometryID;
         }
         }
 
 
-        batch->sortKey_ = (((unsigned long long)shaderID) << 32) | (((unsigned long long)materialID) << 16) | geometryID;
+        batch->sortKey_ = (((unsigned long long)shaderID) << 32u) | (((unsigned long long)materialID) << 16u) | geometryID;
     }
     }
 
 
     shaderRemapping_.Clear();
     shaderRemapping_.Clear();

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

@@ -243,7 +243,7 @@ public:
     void LimitVertexLights(bool removeConvertedLights);
     void LimitVertexLights(bool removeConvertedLights);
 
 
     /// Set base pass flag for a batch.
     /// Set base pass flag for a batch.
-    void SetBasePass(unsigned batchIndex) { basePassFlags_ |= (1 << batchIndex); }
+    void SetBasePass(unsigned batchIndex) { basePassFlags_ |= (1u << batchIndex); }
 
 
     /// Return octree octant.
     /// Return octree octant.
     Octant* GetOctant() const { return octant_; }
     Octant* GetOctant() const { return octant_; }
@@ -267,7 +267,7 @@ public:
     bool IsInView(const FrameInfo& frame, bool anyCamera = false) const;
     bool IsInView(const FrameInfo& frame, bool anyCamera = false) const;
 
 
     /// Return whether has a base pass.
     /// Return whether has a base pass.
-    bool HasBasePass(unsigned batchIndex) const { return (basePassFlags_ & (1 << batchIndex)) != 0; }
+    bool HasBasePass(unsigned batchIndex) const { return (basePassFlags_ & (1u << batchIndex)) != 0; }
 
 
     /// Return per-pixel lights.
     /// Return per-pixel lights.
     const PODVector<Light*>& GetLights() const { return lights_; }
     const PODVector<Light*>& GetLights() const { return lights_; }

+ 5 - 5
Source/Urho3D/Graphics/Model.cpp

@@ -117,9 +117,9 @@ bool Model::BeginLoad(Deserializer& source)
             for (unsigned j = 0; j < numElements; ++j)
             for (unsigned j = 0; j < numElements; ++j)
             {
             {
                 unsigned elementDesc = source.ReadUInt();
                 unsigned elementDesc = source.ReadUInt();
-                auto type = (VertexElementType)(elementDesc & 0xff);
-                auto semantic = (VertexElementSemantic)((elementDesc >> 8) & 0xff);
-                auto index = (unsigned char)((elementDesc >> 16) & 0xff);
+                auto type = (VertexElementType)(elementDesc & 0xffu);
+                auto semantic = (VertexElementSemantic)((elementDesc >> 8u) & 0xffu);
+                auto index = (unsigned char)((elementDesc >> 16u) & 0xffu);
                 desc.vertexElements_.Push(VertexElement(type, semantic, index));
                 desc.vertexElements_.Push(VertexElement(type, semantic, index));
             }
             }
         }
         }
@@ -382,8 +382,8 @@ bool Model::Save(Serializer& dest) const
         for (unsigned j = 0; j < elements.Size(); ++j)
         for (unsigned j = 0; j < elements.Size(); ++j)
         {
         {
             unsigned elementDesc = ((unsigned)elements[j].type_) |
             unsigned elementDesc = ((unsigned)elements[j].type_) |
-                (((unsigned)elements[j].semantic_) << 8) |
-                (((unsigned)elements[j].index_) << 16);
+                (((unsigned)elements[j].semantic_) << 8u) |
+                (((unsigned)elements[j].index_) << 16u);
             dest.WriteUInt(elementDesc);
             dest.WriteUInt(elementDesc);
         }
         }
         dest.WriteUInt(morphRangeStarts_[i]);
         dest.WriteUInt(morphRangeStarts_[i]);

+ 9 - 9
Source/Urho3D/Graphics/OcclusionBuffer.cpp

@@ -57,7 +57,7 @@ OcclusionBuffer::~OcclusionBuffer() = default;
 bool OcclusionBuffer::SetSize(int width, int height, bool threaded)
 bool OcclusionBuffer::SetSize(int width, int height, bool threaded)
 {
 {
     // Force the height to an even amount of pixels for better mip generation
     // Force the height to an even amount of pixels for better mip generation
-    if (height & 1)
+    if (height & 1u)
         ++height;
         ++height;
 
 
     if (width == width_ && height == height_)
     if (width == width_ && height == height_)
@@ -894,8 +894,8 @@ void OcclusionBuffer::DrawTriangle2D(const Vector3* vertices, bool clockwise, un
         while (row < endRow)
         while (row < endRow)
         {
         {
             int invZ = topToBottom.invZ_;
             int invZ = topToBottom.invZ_;
-            int* dest = row + (topToBottom.x_ >> 16);
-            int* end = row + (topToMiddle.x_ >> 16);
+            int* dest = row + (topToBottom.x_ >> 16u);
+            int* end = row + (topToMiddle.x_ >> 16u);
             while (dest < end)
             while (dest < end)
             {
             {
                 if (invZ < *dest)
                 if (invZ < *dest)
@@ -916,8 +916,8 @@ void OcclusionBuffer::DrawTriangle2D(const Vector3* vertices, bool clockwise, un
         while (row < endRow)
         while (row < endRow)
         {
         {
             int invZ = topToBottom.invZ_;
             int invZ = topToBottom.invZ_;
-            int* dest = row + (topToBottom.x_ >> 16);
-            int* end = row + (middleToBottom.x_ >> 16);
+            int* dest = row + (topToBottom.x_ >> 16u);
+            int* end = row + (middleToBottom.x_ >> 16u);
             while (dest < end)
             while (dest < end)
             {
             {
                 if (invZ < *dest)
                 if (invZ < *dest)
@@ -940,8 +940,8 @@ void OcclusionBuffer::DrawTriangle2D(const Vector3* vertices, bool clockwise, un
         while (row < endRow)
         while (row < endRow)
         {
         {
             int invZ = topToMiddle.invZ_;
             int invZ = topToMiddle.invZ_;
-            int* dest = row + (topToMiddle.x_ >> 16);
-            int* end = row + (topToBottom.x_ >> 16);
+            int* dest = row + (topToMiddle.x_ >> 16u);
+            int* end = row + (topToBottom.x_ >> 16u);
             while (dest < end)
             while (dest < end)
             {
             {
                 if (invZ < *dest)
                 if (invZ < *dest)
@@ -962,8 +962,8 @@ void OcclusionBuffer::DrawTriangle2D(const Vector3* vertices, bool clockwise, un
         while (row < endRow)
         while (row < endRow)
         {
         {
             int invZ = middleToBottom.invZ_;
             int invZ = middleToBottom.invZ_;
-            int* dest = row + (middleToBottom.x_ >> 16);
-            int* end = row + (topToBottom.x_ >> 16);
+            int* dest = row + (middleToBottom.x_ >> 16u);
+            int* end = row + (topToBottom.x_ >> 16u);
             while (dest < end)
             while (dest < end)
             {
             {
                 if (invZ < *dest)
                 if (invZ < *dest)

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

@@ -105,17 +105,17 @@ Octant* Octant::GetOrCreateChild(unsigned index)
     Vector3 newMax = worldBoundingBox_.max_;
     Vector3 newMax = worldBoundingBox_.max_;
     Vector3 oldCenter = worldBoundingBox_.Center();
     Vector3 oldCenter = worldBoundingBox_.Center();
 
 
-    if (index & 1)
+    if (index & 1u)
         newMin.x_ = oldCenter.x_;
         newMin.x_ = oldCenter.x_;
     else
     else
         newMax.x_ = oldCenter.x_;
         newMax.x_ = oldCenter.x_;
 
 
-    if (index & 2)
+    if (index & 2u)
         newMin.y_ = oldCenter.y_;
         newMin.y_ = oldCenter.y_;
     else
     else
         newMax.y_ = oldCenter.y_;
         newMax.y_ = oldCenter.y_;
 
 
-    if (index & 4)
+    if (index & 4u)
         newMin.z_ = oldCenter.z_;
         newMin.z_ = oldCenter.z_;
     else
     else
         newMax.z_ = oldCenter.z_;
         newMax.z_ = oldCenter.z_;

+ 8 - 9
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -1710,8 +1710,8 @@ void Graphics::SetDepthStencil(RenderSurface* depthStencil)
         // Check size similarly
         // Check size similarly
         if (width <= width_ && height <= height_)
         if (width <= width_ && height <= height_)
         {
         {
-            int searchKey = (width << 16) | height;
-            HashMap<int, SharedPtr<Texture2D> >::Iterator i = impl_->depthTextures_.Find(searchKey);
+            unsigned searchKey = (width << 16u) | height;
+            HashMap<unsigned, SharedPtr<Texture2D> >::Iterator i = impl_->depthTextures_.Find(searchKey);
             if (i != impl_->depthTextures_.End())
             if (i != impl_->depthTextures_.End())
                 depthStencil = i->second_->GetRenderSurface();
                 depthStencil = i->second_->GetRenderSurface();
             else
             else
@@ -2348,7 +2348,7 @@ ConstantBuffer* Graphics::GetOrCreateConstantBuffer(ShaderType /*type*/,  unsign
     // Note: shaderType parameter is not used on OpenGL, instead binding index should already use the PS range
     // Note: shaderType parameter is not used on OpenGL, instead binding index should already use the PS range
     // for PS constant buffers
     // for PS constant buffers
 
 
-    unsigned key = (index << 16) | size;
+    unsigned key = (index << 16u) | size;
     HashMap<unsigned, SharedPtr<ConstantBuffer> >::Iterator i = impl_->allConstantBuffers_.Find(key);
     HashMap<unsigned, SharedPtr<ConstantBuffer> >::Iterator i = impl_->allConstantBuffers_.Find(key);
     if (i == impl_->allConstantBuffers_.End())
     if (i == impl_->allConstantBuffers_.End())
     {
     {
@@ -2895,8 +2895,7 @@ void Graphics::PrepareDraw()
         else if (depthStencil_)
         else if (depthStencil_)
             format = depthStencil_->GetParentTexture()->GetFormat();
             format = depthStencil_->GetParentTexture()->GetFormat();
 
 
-        unsigned long long fboKey = (rtSize.x_ << 16 | rtSize.y_) | (((unsigned long long)format) << 32);
-
+        auto fboKey = (unsigned long long)format << 32u | rtSize.x_ << 16u | rtSize.y_;
         HashMap<unsigned long long, FrameBufferObject>::Iterator i = impl_->frameBuffers_.Find(fboKey);
         HashMap<unsigned long long, FrameBufferObject>::Iterator i = impl_->frameBuffers_.Find(fboKey);
         if (i == impl_->frameBuffers_.End())
         if (i == impl_->frameBuffers_.End())
         {
         {
@@ -2924,7 +2923,7 @@ void Graphics::PrepareDraw()
         for (unsigned j = 0; j < MAX_RENDERTARGETS; ++j)
         for (unsigned j = 0; j < MAX_RENDERTARGETS; ++j)
         {
         {
             if (renderTargets_[j])
             if (renderTargets_[j])
-                newDrawBuffers |= 1 << j;
+                newDrawBuffers |= 1u << j;
         }
         }
 
 
         if (newDrawBuffers != i->second_.drawBuffers_)
         if (newDrawBuffers != i->second_.drawBuffers_)
@@ -3086,7 +3085,7 @@ void Graphics::PrepareDraw()
                 if (k != impl_->vertexAttributes_->End())
                 if (k != impl_->vertexAttributes_->End())
                 {
                 {
                     unsigned location = k->second_;
                     unsigned location = k->second_;
-                    unsigned locationMask = 1 << location;
+                    unsigned locationMask = 1u << location;
                     if (assignedLocations & locationMask)
                     if (assignedLocations & locationMask)
                         continue; // Already assigned by higher index vertex buffer
                         continue; // Already assigned by higher index vertex buffer
                     assignedLocations |= locationMask;
                     assignedLocations |= locationMask;
@@ -3131,10 +3130,10 @@ void Graphics::PrepareDraw()
         unsigned location = 0;
         unsigned location = 0;
         while (disableVertexAttributes)
         while (disableVertexAttributes)
         {
         {
-            if (disableVertexAttributes & 1)
+            if (disableVertexAttributes & 1u)
             {
             {
                 glDisableVertexAttribArray(location);
                 glDisableVertexAttribArray(location);
-                impl_->enabledVertexAttributes_ &= ~(1 << location);
+                impl_->enabledVertexAttributes_ &= ~(1u << location);
             }
             }
             ++location;
             ++location;
             disableVertexAttributes >>= 1;
             disableVertexAttributes >>= 1;

+ 1 - 1
Source/Urho3D/Graphics/OpenGL/OGLGraphicsImpl.h

@@ -151,7 +151,7 @@ private:
     /// Last used instance data offset.
     /// Last used instance data offset.
     unsigned lastInstanceOffset_{};
     unsigned lastInstanceOffset_{};
     /// Map for additional depth textures, to emulate Direct3D9 ability to mix render texture and backbuffer rendering.
     /// Map for additional depth textures, to emulate Direct3D9 ability to mix render texture and backbuffer rendering.
-    HashMap<int, SharedPtr<Texture2D> > depthTextures_;
+    HashMap<unsigned, SharedPtr<Texture2D> > depthTextures_;
     /// Shader program in use.
     /// Shader program in use.
     ShaderProgram* shaderProgram_{};
     ShaderProgram* shaderProgram_{};
     /// Linked shader programs.
     /// Linked shader programs.

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

@@ -184,7 +184,7 @@ bool ShaderProgram::Link()
 
 
         int location = glGetAttribLocation(object_.name_, name.CString());
         int location = glGetAttribLocation(object_.name_, name.CString());
         vertexAttributes_[MakePair((unsigned char)semantic, semanticIndex)] = location;
         vertexAttributes_[MakePair((unsigned char)semantic, semanticIndex)] = location;
-        usedVertexAttributes_ |= (1 << location);
+        usedVertexAttributes_ |= (1u << location);
     }
     }
 
 
     // Check for constant buffers
     // Check for constant buffers

+ 5 - 5
Source/Urho3D/Graphics/OpenGL/OGLTexture.cpp

@@ -226,22 +226,22 @@ unsigned Texture::GetRowDataSize(int width) const
 #endif
 #endif
 
 
     case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
     case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-        return (unsigned)(((width + 3) >> 2) * 8);
+        return ((unsigned)(width + 3) >> 2u) * 8;
 
 
     case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
     case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
     case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
     case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-        return (unsigned)(((width + 3) >> 2) * 16);
+        return ((unsigned)(width + 3) >> 2u) * 16;
 
 
     case GL_ETC1_RGB8_OES:
     case GL_ETC1_RGB8_OES:
-        return (unsigned)(((width + 3) >> 2) * 8);
+        return ((unsigned)(width + 3) >> 2u) * 8;
 
 
     case COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
     case COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
     case COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
     case COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
-        return (unsigned)((width * 4 + 7) >> 3);
+        return (unsigned)(width * 4 + 7) >> 3u;
 
 
     case COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
     case COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
     case COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
     case COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
-        return (unsigned)((width * 2 + 7) >> 3);
+        return (unsigned)(width * 2 + 7) >> 3u;
 
 
     default:
     default:
         return 0;
         return 0;

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

@@ -130,8 +130,8 @@ bool Texture2D::SetData(unsigned level, int x, int y, int width, int height, con
 
 
     if (IsCompressed())
     if (IsCompressed())
     {
     {
-        x &= ~3;
-        y &= ~3;
+        x &= ~3u;
+        y &= ~3u;
     }
     }
 
 
     int levelWidth = GetLevelWidth(level);
     int levelWidth = GetLevelWidth(level);
@@ -269,10 +269,10 @@ bool Texture2D::SetData(Image* image, bool useAlpha)
         unsigned mipsToSkip = mipsToSkip_[quality];
         unsigned mipsToSkip = mipsToSkip_[quality];
         if (mipsToSkip >= levels)
         if (mipsToSkip >= levels)
             mipsToSkip = levels - 1;
             mipsToSkip = levels - 1;
-        while (mipsToSkip && (width / (1 << mipsToSkip) < 4 || height / (1 << mipsToSkip) < 4))
+        while (mipsToSkip && (width / (1u << mipsToSkip) < 4 || height / (1u << mipsToSkip) < 4))
             --mipsToSkip;
             --mipsToSkip;
-        width /= (1 << mipsToSkip);
-        height /= (1 << mipsToSkip);
+        width /= (1u << mipsToSkip);
+        height /= (1u << mipsToSkip);
 
 
         SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetSize(width, height, format);
         SetSize(width, height, format);

+ 5 - 5
Source/Urho3D/Graphics/OpenGL/OGLTexture2DArray.cpp

@@ -134,8 +134,8 @@ bool Texture2DArray::SetData(unsigned layer, unsigned level, int x, int y, int w
 
 
     if (IsCompressed())
     if (IsCompressed())
     {
     {
-        x &= ~3;
-        y &= ~3;
+        x &= ~3u;
+        y &= ~3u;
     }
     }
 
 
     int levelWidth = GetLevelWidth(level);
     int levelWidth = GetLevelWidth(level);
@@ -312,10 +312,10 @@ bool Texture2DArray::SetData(unsigned layer, Image* image, bool useAlpha)
         unsigned mipsToSkip = mipsToSkip_[quality];
         unsigned mipsToSkip = mipsToSkip_[quality];
         if (mipsToSkip >= levels)
         if (mipsToSkip >= levels)
             mipsToSkip = levels - 1;
             mipsToSkip = levels - 1;
-        while (mipsToSkip && (width / (1 << mipsToSkip) < 4 || height / (1 << mipsToSkip) < 4))
+        while (mipsToSkip && (width / (1u << mipsToSkip) < 4 || height / (1u << mipsToSkip) < 4))
             --mipsToSkip;
             --mipsToSkip;
-        width /= (1 << mipsToSkip);
-        height /= (1 << mipsToSkip);
+        width /= (1u << mipsToSkip);
+        height /= (1u << mipsToSkip);
 
 
         // Create the texture array when layer 0 is being loaded, assume rest of the layers are same size & format
         // Create the texture array when layer 0 is being loaded, assume rest of the layers are same size & format
         if (!layer)
         if (!layer)

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

@@ -112,8 +112,8 @@ bool Texture3D::SetData(unsigned level, int x, int y, int z, int width, int heig
 
 
     if (IsCompressed())
     if (IsCompressed())
     {
     {
-        x &= ~3;
-        y &= ~3;
+        x &= ~3u;
+        y &= ~3u;
     }
     }
 
 
     int levelWidth = GetLevelWidth(level);
     int levelWidth = GetLevelWidth(level);
@@ -260,11 +260,11 @@ bool Texture3D::SetData(Image* image, bool useAlpha)
         unsigned mipsToSkip = mipsToSkip_[quality];
         unsigned mipsToSkip = mipsToSkip_[quality];
         if (mipsToSkip >= levels)
         if (mipsToSkip >= levels)
             mipsToSkip = levels - 1;
             mipsToSkip = levels - 1;
-        while (mipsToSkip && (width / (1 << mipsToSkip) < 4 || height / (1 << mipsToSkip) < 4 || depth / (1 << mipsToSkip) < 4))
+        while (mipsToSkip && (width / (1u << mipsToSkip) < 4 || height / (1u << mipsToSkip) < 4 || depth / (1u << mipsToSkip) < 4))
             --mipsToSkip;
             --mipsToSkip;
-        width /= (1 << mipsToSkip);
-        height /= (1 << mipsToSkip);
-        depth /= (1 << mipsToSkip);
+        width /= (1u << mipsToSkip);
+        height /= (1u << mipsToSkip);
+        depth /= (1u << mipsToSkip);
 
 
         SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetNumLevels(Max((levels - mipsToSkip), 1U));
         SetSize(width, height, depth, format);
         SetSize(width, height, depth, format);

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

@@ -135,8 +135,8 @@ bool TextureCube::SetData(CubeMapFace face, unsigned level, int x, int y, int wi
 
 
     if (IsCompressed())
     if (IsCompressed())
     {
     {
-        x &= ~3;
-        y &= ~3;
+        x &= ~3u;
+        y &= ~3u;
     }
     }
 
 
     int levelWidth = GetLevelWidth(level);
     int levelWidth = GetLevelWidth(level);
@@ -314,10 +314,10 @@ bool TextureCube::SetData(CubeMapFace face, Image* image, bool useAlpha)
         unsigned mipsToSkip = mipsToSkip_[quality];
         unsigned mipsToSkip = mipsToSkip_[quality];
         if (mipsToSkip >= levels)
         if (mipsToSkip >= levels)
             mipsToSkip = levels - 1;
             mipsToSkip = levels - 1;
-        while (mipsToSkip && (width / (1 << mipsToSkip) < 4 || height / (1 << mipsToSkip) < 4))
+        while (mipsToSkip && (width / (1u << mipsToSkip) < 4 || height / (1u << mipsToSkip) < 4))
             --mipsToSkip;
             --mipsToSkip;
-        width /= (1 << mipsToSkip);
-        height /= (1 << mipsToSkip);
+        width /= (1u << mipsToSkip);
+        height /= (1u << mipsToSkip);
 
 
         // 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)

+ 11 - 11
Source/Urho3D/Graphics/Renderer.cpp

@@ -889,7 +889,7 @@ Texture2D* Renderer::GetShadowMap(Light* light, Camera* camera, unsigned viewWid
         height *= 3;
         height *= 3;
     }
     }
 
 
-    int searchKey = (width << 16) | height;
+    int searchKey = width << 16u | height;
     if (shadowMaps_.Contains(searchKey))
     if (shadowMaps_.Contains(searchKey))
     {
     {
         // If shadow maps are reused, always return the first
         // If shadow maps are reused, always return the first
@@ -1010,19 +1010,19 @@ Texture* Renderer::GetScreenBuffer(int width, int height, unsigned format, int m
     if (multiSample == 1)
     if (multiSample == 1)
         autoResolve = false;
         autoResolve = false;
 
 
-    long long searchKey = ((long long)format << 32) | (multiSample << 24) | (width << 12) | height;
+    auto searchKey = (unsigned long long)format << 32u | multiSample << 24u | width << 12u | height;
     if (filtered)
     if (filtered)
-        searchKey |= 0x8000000000000000LL;
+        searchKey |= 0x8000000000000000ULL;
     if (srgb)
     if (srgb)
-        searchKey |= 0x4000000000000000LL;
+        searchKey |= 0x4000000000000000ULL;
     if (cubemap)
     if (cubemap)
-        searchKey |= 0x2000000000000000LL;
+        searchKey |= 0x2000000000000000ULL;
     if (autoResolve)
     if (autoResolve)
-        searchKey |= 0x1000000000000000LL;
+        searchKey |= 0x1000000000000000ULL;
 
 
     // Add persistent key if defined
     // Add persistent key if defined
     if (persistentKey)
     if (persistentKey)
-        searchKey += ((long long)persistentKey << 32);
+        searchKey += (unsigned long long)persistentKey << 32u;
 
 
     // If new size or format, initialize the allocation stats
     // If new size or format, initialize the allocation stats
     if (screenBuffers_.Find(searchKey) == screenBuffers_.End())
     if (screenBuffers_.Find(searchKey) == screenBuffers_.End())
@@ -1541,9 +1541,9 @@ void Renderer::RemoveUnusedBuffers()
         }
         }
     }
     }
 
 
-    for (HashMap<long long, Vector<SharedPtr<Texture> > >::Iterator i = screenBuffers_.Begin(); i != screenBuffers_.End();)
+    for (HashMap<unsigned long long, Vector<SharedPtr<Texture> > >::Iterator i = screenBuffers_.Begin(); i != screenBuffers_.End();)
     {
     {
-        HashMap<long long, Vector<SharedPtr<Texture> > >::Iterator current = i++;
+        HashMap<unsigned long long, Vector<SharedPtr<Texture> > >::Iterator current = i++;
         Vector<SharedPtr<Texture> >& buffers = current->second_;
         Vector<SharedPtr<Texture> >& buffers = current->second_;
         for (unsigned j = buffers.Size() - 1; j < buffers.Size(); --j)
         for (unsigned j = buffers.Size() - 1; j < buffers.Size(); --j)
         {
         {
@@ -1571,7 +1571,7 @@ void Renderer::ResetShadowMapAllocations()
 
 
 void Renderer::ResetScreenBufferAllocations()
 void Renderer::ResetScreenBufferAllocations()
 {
 {
-    for (HashMap<long long, unsigned>::Iterator i = screenBufferAllocations_.Begin(); i != screenBufferAllocations_.End(); ++i)
+    for (HashMap<unsigned long long, unsigned>::Iterator i = screenBufferAllocations_.Begin(); i != screenBufferAllocations_.End(); ++i)
         i->second_ = 0;
         i->second_ = 0;
 }
 }
 
 
@@ -1847,7 +1847,7 @@ void Renderer::SetIndirectionTextureData()
 
 
     for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
     for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
     {
     {
-        auto faceX = (unsigned char)((i & 1) * 255);
+        auto faceX = (unsigned char)((i & 1u) * 255);
         auto faceY = (unsigned char)((i / 2) * 255 / 3);
         auto faceY = (unsigned char)((i / 2) * 255 / 3);
         unsigned char* dest = data;
         unsigned char* dest = data;
         for (unsigned y = 0; y < 256; ++y)
         for (unsigned y = 0; y < 256; ++y)

+ 2 - 4
Source/Urho3D/Graphics/Renderer.h

@@ -509,11 +509,9 @@ private:
     /// Function pointer of shadow map filter
     /// Function pointer of shadow map filter
     ShadowMapFilter shadowMapFilter_{};
     ShadowMapFilter shadowMapFilter_{};
     /// Screen buffers by resolution and format.
     /// Screen buffers by resolution and format.
-    HashMap<long long, Vector<SharedPtr<Texture> > > screenBuffers_;
+    HashMap<unsigned long long, Vector<SharedPtr<Texture> > > screenBuffers_;
     /// Current screen buffer allocations by resolution and format.
     /// Current screen buffer allocations by resolution and format.
-    HashMap<long long, unsigned> screenBufferAllocations_;
-    /// Saved status of screen buffer allocations for restoring.
-    HashMap<long long, unsigned> savedScreenBufferAllocations_;
+    HashMap<unsigned long long, unsigned> screenBufferAllocations_;
     /// Cache for light scissor queries.
     /// Cache for light scissor queries.
     HashMap<Pair<Light*, Camera*>, Rect> lightScissorCache_;
     HashMap<Pair<Light*, Camera*>, Rect> lightScissorCache_;
     /// Backbuffer viewports.
     /// Backbuffer viewports.

+ 13 - 14
Source/Urho3D/Graphics/Terrain.cpp

@@ -676,12 +676,12 @@ void Terrain::CreatePatchGeometry(TerrainPatch* patch)
     if (vertexData)
     if (vertexData)
     {
     {
         const IntVector2& coords = patch->GetCoordinates();
         const IntVector2& coords = patch->GetCoordinates();
-        int lodExpand = (1 << (occlusionLevel)) - 1;
-        int halfLodExpand = (1 << (occlusionLevel)) / 2;
+        unsigned lodExpand = (1u << (occlusionLevel)) - 1;
+        unsigned halfLodExpand = (1u << (occlusionLevel)) / 2;
 
 
-        for (int z = 0; z <= patchSize_; ++z)
+        for (unsigned z = 0; z <= patchSize_; ++z)
         {
         {
-            for (int x = 0; x <= patchSize_; ++x)
+            for (unsigned x = 0; x <= patchSize_; ++x)
             {
             {
                 int xPos = coords.x_ * patchSize_ + x;
                 int xPos = coords.x_ * patchSize_ + x;
                 int zPos = coords.y_ * patchSize_ + z;
                 int zPos = coords.y_ * patchSize_ + z;
@@ -744,7 +744,7 @@ void Terrain::CreatePatchGeometry(TerrainPatch* patch)
 
 
     if (drawRanges_.Size())
     if (drawRanges_.Size())
     {
     {
-        unsigned occlusionDrawRange = occlusionLevel << 4;
+        unsigned occlusionDrawRange = occlusionLevel << 4u;
 
 
         geometry->SetIndexBuffer(indexBuffer_);
         geometry->SetIndexBuffer(indexBuffer_);
         geometry->SetDrawRange(TRIANGLE_LIST, drawRanges_[0].first_, drawRanges_[0].second_, false);
         geometry->SetDrawRange(TRIANGLE_LIST, drawRanges_[0].first_, drawRanges_[0].second_, false);
@@ -766,7 +766,7 @@ void Terrain::UpdatePatchLod(TerrainPatch* patch)
 
 
     // All LOD levels except the coarsest have 16 versions for stitching
     // All LOD levels except the coarsest have 16 versions for stitching
     unsigned lodLevel = patch->GetLodLevel();
     unsigned lodLevel = patch->GetLodLevel();
-    unsigned drawRangeIndex = lodLevel << 4;
+    unsigned drawRangeIndex = lodLevel << 4u;
     if (lodLevel < numLodLevels_ - 1)
     if (lodLevel < numLodLevels_ - 1)
     {
     {
         TerrainPatch* north = patch->GetNorthPatch();
         TerrainPatch* north = patch->GetNorthPatch();
@@ -1001,7 +1001,7 @@ void Terrain::CreateGeometry()
         // If updating a region of the heightmap, check which patches change
         // If updating a region of the heightmap, check which patches change
         if (!updateAll)
         if (!updateAll)
         {
         {
-            int lodExpand = 1 << (numLodLevels_ - 1);
+            int lodExpand = 1u << (numLodLevels_ - 1);
             // Expand the right & bottom 1 pixel more, as patches share vertices at the edge
             // Expand the right & bottom 1 pixel more, as patches share vertices at the edge
             updateRegion.left_ -= lodExpand;
             updateRegion.left_ -= lodExpand;
             updateRegion.right_ += lodExpand + 1;
             updateRegion.right_ += lodExpand + 1;
@@ -1156,7 +1156,7 @@ void Terrain::CreateIndexData()
     for (unsigned i = 0; i < numLodLevels_; ++i)
     for (unsigned i = 0; i < numLodLevels_; ++i)
     {
     {
         unsigned combinations = (i < numLodLevels_ - 1) ? 16 : 1;
         unsigned combinations = (i < numLodLevels_ - 1) ? 16 : 1;
-        int skip = 1 << i;
+        int skip = 1u << i;
 
 
         for (unsigned j = 0; j < combinations; ++j)
         for (unsigned j = 0; j < combinations; ++j)
         {
         {
@@ -1316,10 +1316,9 @@ float Terrain::GetSourceHeight(int x, int z) const
 
 
 float Terrain::GetLodHeight(int x, int z, unsigned lodLevel) const
 float Terrain::GetLodHeight(int x, int z, unsigned lodLevel) const
 {
 {
-    auto offset = (unsigned)(1 << lodLevel);
-    auto divisor = (float)offset;
-    float xFrac = (float)(x % offset) / divisor;
-    float zFrac = (float)(z % offset) / divisor;
+    unsigned offset = 1u << lodLevel;
+    auto xFrac = (float)(x % offset) / offset;
+    auto zFrac = (float)(z % offset) / offset;
     float h1, h2, h3;
     float h1, h2, h3;
 
 
     if (xFrac + zFrac >= 1.0f)
     if (xFrac + zFrac >= 1.0f)
@@ -1380,7 +1379,7 @@ void Terrain::CalculateLodErrors(TerrainPatch* patch)
     for (unsigned i = 0; i < numLodLevels_; ++i)
     for (unsigned i = 0; i < numLodLevels_; ++i)
     {
     {
         float maxError = 0.0f;
         float maxError = 0.0f;
-        int divisor = 1 << i;
+        int divisor = 1u << i;
 
 
         if (i > 0)
         if (i > 0)
         {
         {
@@ -1397,7 +1396,7 @@ void Terrain::CalculateLodErrors(TerrainPatch* patch)
             }
             }
 
 
             // Set error to be at least same as (half vertex spacing x LOD) to prevent horizontal stretches getting too inaccurate
             // Set error to be at least same as (half vertex spacing x LOD) to prevent horizontal stretches getting too inaccurate
-            maxError = Max(maxError, 0.25f * (spacing_.x_ + spacing_.z_) * (float)(1 << i));
+            maxError = Max(maxError, 0.25f * (spacing_.x_ + spacing_.z_) * (float)(1u << i));
         }
         }
 
 
         lodErrors.Push(maxError);
         lodErrors.Push(maxError);

+ 6 - 6
Source/Urho3D/Graphics/Texture.cpp

@@ -150,7 +150,7 @@ int Texture::GetLevelDepth(unsigned level) const
 unsigned Texture::GetDataSize(int width, int height) const
 unsigned Texture::GetDataSize(int width, int height) const
 {
 {
     if (IsCompressed())
     if (IsCompressed())
-        return GetRowDataSize(width) * ((height + 3) >> 2);
+        return GetRowDataSize(width) * ((height + 3) >> 2u);
     else
     else
         return GetRowDataSize(width) * height;
         return GetRowDataSize(width) * height;
 }
 }
@@ -243,8 +243,8 @@ unsigned Texture::CheckMaxLevels(int width, int height, unsigned requestedLevels
     while (width > 1 || height > 1)
     while (width > 1 || height > 1)
     {
     {
         ++maxLevels;
         ++maxLevels;
-        width = width > 1 ? (width >> 1) : 1;
-        height = height > 1 ? (height >> 1) : 1;
+        width = width > 1 ? (width >> 1u) : 1;
+        height = height > 1 ? (height >> 1u) : 1;
     }
     }
 
 
     if (!requestedLevels || maxLevels < requestedLevels)
     if (!requestedLevels || maxLevels < requestedLevels)
@@ -259,9 +259,9 @@ unsigned Texture::CheckMaxLevels(int width, int height, int depth, unsigned requ
     while (width > 1 || height > 1 || depth > 1)
     while (width > 1 || height > 1 || depth > 1)
     {
     {
         ++maxLevels;
         ++maxLevels;
-        width = width > 1 ? (width >> 1) : 1;
-        height = height > 1 ? (height >> 1) : 1;
-        depth = depth > 1 ? (depth >> 1) : 1;
+        width = width > 1 ? (width >> 1u) : 1;
+        height = height > 1 ? (height >> 1u) : 1;
+        depth = depth > 1 ? (depth >> 1u) : 1;
     }
     }
 
 
     if (!requestedLevels || maxLevels < requestedLevels)
     if (!requestedLevels || maxLevels < requestedLevels)

+ 3 - 3
Source/Urho3D/Graphics/VertexBuffer.cpp

@@ -106,7 +106,7 @@ void VertexBuffer::UpdateOffsets()
         {
         {
             const VertexElement& legacy = LEGACY_VERTEXELEMENTS[j];
             const VertexElement& legacy = LEGACY_VERTEXELEMENTS[j];
             if (i->type_ == legacy.type_ && i->semantic_ == legacy.semantic_ && i->index_ == legacy.index_)
             if (i->type_ == legacy.type_ && i->semantic_ == legacy.semantic_ && i->index_ == legacy.index_)
-                elementMask_ |= (1 << j);
+                elementMask_ |= (1u << j);
         }
         }
     }
     }
 
 
@@ -163,7 +163,7 @@ PODVector<VertexElement> VertexBuffer::GetElements(unsigned elementMask)
 
 
     for (unsigned i = 0; i < MAX_LEGACY_VERTEX_ELEMENTS; ++i)
     for (unsigned i = 0; i < MAX_LEGACY_VERTEX_ELEMENTS; ++i)
     {
     {
-        if (elementMask & (1 << i))
+        if (elementMask & (1u << i))
             ret.Push(LEGACY_VERTEXELEMENTS[i]);
             ret.Push(LEGACY_VERTEXELEMENTS[i]);
     }
     }
 
 
@@ -186,7 +186,7 @@ unsigned VertexBuffer::GetVertexSize(unsigned elementMask)
 
 
     for (unsigned i = 0; i < MAX_LEGACY_VERTEX_ELEMENTS; ++i)
     for (unsigned i = 0; i < MAX_LEGACY_VERTEX_ELEMENTS; ++i)
     {
     {
-        if (elementMask & (1 << i))
+        if (elementMask & (1u << i))
             size += ELEMENT_TYPESIZES[LEGACY_VERTEXELEMENTS[i].type_];
             size += ELEMENT_TYPESIZES[LEGACY_VERTEXELEMENTS[i].type_];
     }
     }
 
 

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

@@ -1127,7 +1127,7 @@ void View::GetLightBatches()
 
 
                 // In deferred modes, store the light volume batch now. Since light mask 8 lowest bits are output to the stencil,
                 // In deferred modes, store the light volume batch now. Since light mask 8 lowest bits are output to the stencil,
                 // lights that have all zeroes in the low 8 bits can be skipped; they would not affect geometry anyway
                 // lights that have all zeroes in the low 8 bits can be skipped; they would not affect geometry anyway
-                if (deferred_ && (light->GetLightMask() & 0xff) != 0)
+                if (deferred_ && (light->GetLightMask() & 0xffu) != 0)
                 {
                 {
                     Batch volumeBatch;
                     Batch volumeBatch;
                     volumeBatch.geometry_ = renderer_->GetLightGeometry(light);
                     volumeBatch.geometry_ = renderer_->GetLightGeometry(light);
@@ -1260,7 +1260,7 @@ void View::GetBaseBatches()
                     destBatch.lightQueue_ = nullptr;
                     destBatch.lightQueue_ = nullptr;
 
 
                 bool allowInstancing = info.allowInstancing_;
                 bool allowInstancing = info.allowInstancing_;
-                if (allowInstancing && info.markToStencil_ && destBatch.lightMask_ != (destBatch.zone_->GetLightMask() & 0xff))
+                if (allowInstancing && info.markToStencil_ && destBatch.lightMask_ != (destBatch.zone_->GetLightMask() & 0xffu))
                     allowInstancing = false;
                     allowInstancing = false;
 
 
                 AddBatchToQueue(*info.batchQueue_, destBatch, tech, allowInstancing);
                 AddBatchToQueue(*info.batchQueue_, destBatch, tech, allowInstancing);

+ 4 - 4
Source/Urho3D/IO/Deserializer.cpp

@@ -431,22 +431,22 @@ unsigned Deserializer::ReadVLE()
     unsigned char byte;
     unsigned char byte;
 
 
     byte = ReadUByte();
     byte = ReadUByte();
-    ret = (unsigned)(byte & 0x7f);
+    ret = (unsigned)(byte & 0x7fu);
     if (byte < 0x80)
     if (byte < 0x80)
         return ret;
         return ret;
 
 
     byte = ReadUByte();
     byte = ReadUByte();
-    ret |= ((unsigned)(byte & 0x7f)) << 7;
+    ret |= ((unsigned)(byte & 0x7fu)) << 7u;
     if (byte < 0x80)
     if (byte < 0x80)
         return ret;
         return ret;
 
 
     byte = ReadUByte();
     byte = ReadUByte();
-    ret |= ((unsigned)(byte & 0x7f)) << 14;
+    ret |= ((unsigned)(byte & 0x7fu)) << 14u;
     if (byte < 0x80)
     if (byte < 0x80)
         return ret;
         return ret;
 
 
     byte = ReadUByte();
     byte = ReadUByte();
-    ret |= ((unsigned)byte) << 21;
+    ret |= ((unsigned)byte) << 21u;
     return ret;
     return ret;
 }
 }
 
 

+ 2 - 2
Source/Urho3D/IO/MemoryBuffer.cpp

@@ -84,7 +84,7 @@ unsigned MemoryBuffer::Read(void* dest, unsigned size)
         srcPtr += sizeof(unsigned short);
         srcPtr += sizeof(unsigned short);
         destPtr += sizeof(unsigned short);
         destPtr += sizeof(unsigned short);
     }
     }
-    if (copySize & 1)
+    if (copySize & 1u)
         *destPtr = *srcPtr;
         *destPtr = *srcPtr;
 
 
     return size;
     return size;
@@ -124,7 +124,7 @@ unsigned MemoryBuffer::Write(const void* data, unsigned size)
         srcPtr += sizeof(unsigned short);
         srcPtr += sizeof(unsigned short);
         destPtr += sizeof(unsigned short);
         destPtr += sizeof(unsigned short);
     }
     }
-    if (copySize & 1)
+    if (copySize & 1u)
         *destPtr = *srcPtr;
         *destPtr = *srcPtr;
 
 
     return size;
     return size;

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

@@ -370,23 +370,23 @@ bool Serializer::WriteVLE(unsigned value)
         return WriteUByte((unsigned char)value);
         return WriteUByte((unsigned char)value);
     else if (value < 0x4000)
     else if (value < 0x4000)
     {
     {
-        data[0] = (unsigned char)(value | 0x80);
-        data[1] = (unsigned char)(value >> 7);
+        data[0] = (unsigned char)(value | 0x80u);
+        data[1] = (unsigned char)(value >> 7u);
         return Write(data, 2) == 2;
         return Write(data, 2) == 2;
     }
     }
     else if (value < 0x200000)
     else if (value < 0x200000)
     {
     {
-        data[0] = (unsigned char)(value | 0x80);
-        data[1] = (unsigned char)((value >> 7) | 0x80);
-        data[2] = (unsigned char)(value >> 14);
+        data[0] = (unsigned char)(value | 0x80u);
+        data[1] = (unsigned char)(value >> 7u | 0x80u);
+        data[2] = (unsigned char)(value >> 14u);
         return Write(data, 3) == 3;
         return Write(data, 3) == 3;
     }
     }
     else
     else
     {
     {
-        data[0] = (unsigned char)(value | 0x80);
-        data[1] = (unsigned char)((value >> 7) | 0x80);
-        data[2] = (unsigned char)((value >> 14) | 0x80);
-        data[3] = (unsigned char)(value >> 21);
+        data[0] = (unsigned char)(value | 0x80u);
+        data[1] = (unsigned char)(value >> 7u | 0x80u);
+        data[2] = (unsigned char)(value >> 14u | 0x80u);
+        data[3] = (unsigned char)(value >> 21u);
         return Write(data, 4) == 4;
         return Write(data, 4) == 4;
     }
     }
 }
 }

+ 2 - 2
Source/Urho3D/IO/VectorBuffer.cpp

@@ -69,7 +69,7 @@ unsigned VectorBuffer::Read(void* dest, unsigned size)
         srcPtr += sizeof(unsigned short);
         srcPtr += sizeof(unsigned short);
         destPtr += sizeof(unsigned short);
         destPtr += sizeof(unsigned short);
     }
     }
-    if (copySize & 1)
+    if (copySize & 1u)
         *destPtr = *srcPtr;
         *destPtr = *srcPtr;
 
 
     return size;
     return size;
@@ -113,7 +113,7 @@ unsigned VectorBuffer::Write(const void* data, unsigned size)
         srcPtr += sizeof(unsigned short);
         srcPtr += sizeof(unsigned short);
         destPtr += sizeof(unsigned short);
         destPtr += sizeof(unsigned short);
     }
     }
-    if (copySize & 1)
+    if (copySize & 1u)
         *destPtr = *srcPtr;
         *destPtr = *srcPtr;
 
 
     return size;
     return size;

+ 6 - 6
Source/Urho3D/Input/Input.cpp

@@ -1930,7 +1930,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
 
 
     case SDL_MOUSEBUTTONDOWN:
     case SDL_MOUSEBUTTONDOWN:
         if (!touchEmulation_)
         if (!touchEmulation_)
-            SetMouseButton(1 << (evt.button.button - 1), true);
+            SetMouseButton(1u << (evt.button.button - 1), true);
         else
         else
         {
         {
             int x, y;
             int x, y;
@@ -1953,7 +1953,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
 
 
     case SDL_MOUSEBUTTONUP:
     case SDL_MOUSEBUTTONUP:
         if (!touchEmulation_)
         if (!touchEmulation_)
-            SetMouseButton(1 << (evt.button.button - 1), false);
+            SetMouseButton(1u << (evt.button.button - 1), false);
         else
         else
         {
         {
             int x, y;
             int x, y;
@@ -2038,7 +2038,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
     case SDL_FINGERDOWN:
     case SDL_FINGERDOWN:
         if (evt.tfinger.touchId != SDL_TOUCH_MOUSEID)
         if (evt.tfinger.touchId != SDL_TOUCH_MOUSEID)
         {
         {
-            int touchID = GetTouchIndexFromID(evt.tfinger.fingerId & 0x7ffffff);
+            int touchID = GetTouchIndexFromID(evt.tfinger.fingerId & 0x7ffffffu);
             TouchState& state = touches_[touchID];
             TouchState& state = touches_[touchID];
             state.touchID_ = touchID;
             state.touchID_ = touchID;
             state.lastPosition_ = state.position_ = IntVector2((int)(evt.tfinger.x * graphics_->GetWidth()),
             state.lastPosition_ = state.position_ = IntVector2((int)(evt.tfinger.x * graphics_->GetWidth()),
@@ -2064,7 +2064,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
     case SDL_FINGERUP:
     case SDL_FINGERUP:
         if (evt.tfinger.touchId != SDL_TOUCH_MOUSEID)
         if (evt.tfinger.touchId != SDL_TOUCH_MOUSEID)
         {
         {
-            int touchID = GetTouchIndexFromID(evt.tfinger.fingerId & 0x7ffffff);
+            int touchID = GetTouchIndexFromID(evt.tfinger.fingerId & 0x7ffffffu);
             TouchState& state = touches_[touchID];
             TouchState& state = touches_[touchID];
 
 
             using namespace TouchEnd;
             using namespace TouchEnd;
@@ -2078,7 +2078,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
             SendEvent(E_TOUCHEND, eventData);
             SendEvent(E_TOUCHEND, eventData);
 
 
             // Add touch index back to list of available touch Ids
             // Add touch index back to list of available touch Ids
-            PushTouchIndex(evt.tfinger.fingerId & 0x7ffffff);
+            PushTouchIndex(evt.tfinger.fingerId & 0x7ffffffu);
 
 
             touches_.Erase(touchID);
             touches_.Erase(touchID);
         }
         }
@@ -2087,7 +2087,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
     case SDL_FINGERMOTION:
     case SDL_FINGERMOTION:
         if (evt.tfinger.touchId != SDL_TOUCH_MOUSEID)
         if (evt.tfinger.touchId != SDL_TOUCH_MOUSEID)
         {
         {
-            int touchID = GetTouchIndexFromID(evt.tfinger.fingerId & 0x7ffffff);
+            int touchID = GetTouchIndexFromID(evt.tfinger.fingerId & 0x7ffffffu);
             // We don't want this event to create a new touches_ event if it doesn't exist (touchEmulation)
             // We don't want this event to create a new touches_ event if it doesn't exist (touchEmulation)
             if (touchEmulation_ && !touches_.Contains(touchID))
             if (touchEmulation_ && !touches_.Contains(touchID))
                 break;
                 break;

+ 5 - 5
Source/Urho3D/Math/Color.cpp

@@ -37,7 +37,7 @@ unsigned Color::ToUInt() const
     auto g = (unsigned)Clamp(((int)(g_ * 255.0f)), 0, 255);
     auto g = (unsigned)Clamp(((int)(g_ * 255.0f)), 0, 255);
     auto b = (unsigned)Clamp(((int)(b_ * 255.0f)), 0, 255);
     auto b = (unsigned)Clamp(((int)(b_ * 255.0f)), 0, 255);
     auto a = (unsigned)Clamp(((int)(a_ * 255.0f)), 0, 255);
     auto a = (unsigned)Clamp(((int)(a_ * 255.0f)), 0, 255);
-    return (a << 24) | (b << 16) | (g << 8) | r;
+    return (a << 24u) | (b << 16u) | (g << 8u) | r;
 }
 }
 
 
 Vector3 Color::ToHSL() const
 Vector3 Color::ToHSL() const
@@ -66,10 +66,10 @@ Vector3 Color::ToHSV() const
 
 
 void Color::FromUInt(unsigned color)
 void Color::FromUInt(unsigned color)
 {
 {
-    a_ = ((color >> 24) & 0xff) / 255.0f;
-    b_ = ((color >> 16) & 0xff) / 255.0f;
-    g_ = ((color >> 8)  & 0xff) / 255.0f;
-    r_ = ((color >> 0)  & 0xff) / 255.0f;
+    a_ = ((color >> 24u) & 0xffu) / 255.0f;
+    b_ = ((color >> 16u) & 0xffu) / 255.0f;
+    g_ = ((color >> 8u)  & 0xffu) / 255.0f;
+    r_ = ((color >> 0u)  & 0xffu) / 255.0f;
 }
 }
 
 
 void Color::FromHSL(float h, float s, float l, float a)
 void Color::FromHSL(float h, float s, float l, float a)

+ 13 - 24
Source/Urho3D/Math/MathDefs.h

@@ -99,18 +99,7 @@ inline unsigned FloatToRawIntBits(float value)
 }
 }
 
 
 /// Check whether a floating point value is NaN.
 /// Check whether a floating point value is NaN.
-/// Use a workaround for GCC, see https://github.com/urho3d/Urho3D/issues/655
-#ifndef __GNUC__
-inline bool IsNaN(float value) { return value != value; }
-#else
-
-inline bool IsNaN(float value)
-{
-    unsigned u = FloatToRawIntBits(value);
-    return (u & 0x7fffffff) > 0x7f800000;
-}
-
-#endif
+template <class T> inline bool IsNaN(T value) { return std::isnan(value); }
 
 
 /// Clamp a number to a range.
 /// Clamp a number to a range.
 template <class T>
 template <class T>
@@ -197,11 +186,11 @@ inline unsigned NextPowerOfTwo(unsigned value)
 {
 {
     // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
     // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
     --value;
     --value;
-    value |= value >> 1;
-    value |= value >> 2;
-    value |= value >> 4;
-    value |= value >> 8;
-    value |= value >> 16;
+    value |= value >> 1u;
+    value |= value >> 2u;
+    value |= value >> 4u;
+    value |= value >> 8u;
+    value |= value >> 16u;
     return ++value;
     return ++value;
 }
 }
 
 
@@ -226,7 +215,7 @@ inline unsigned CountSetBits(unsigned value)
 }
 }
 
 
 /// Update a hash with the given 8-bit value using the SDBM algorithm.
 /// Update a hash with the given 8-bit value using the SDBM algorithm.
-inline unsigned SDBMHash(unsigned hash, unsigned char c) { return c + (hash << 6) + (hash << 16) - hash; }
+inline unsigned SDBMHash(unsigned hash, unsigned char c) { return c + (hash << 6u) + (hash << 16u) - hash; }
 
 
 /// Return a random float between 0.0 (inclusive) and 1.0 (exclusive.)
 /// Return a random float between 0.0 (inclusive) and 1.0 (exclusive.)
 inline float Random() { return Rand() / 32768.0f; }
 inline float Random() { return Rand() / 32768.0f; }
@@ -250,9 +239,9 @@ inline float RandomNormal(float meanValue, float variance) { return RandStandard
 inline unsigned short FloatToHalf(float value)
 inline unsigned short FloatToHalf(float value)
 {
 {
     unsigned inu = FloatToRawIntBits(value);
     unsigned inu = FloatToRawIntBits(value);
-    unsigned t1 = inu & 0x7fffffff;         // Non-sign bits
-    unsigned t2 = inu & 0x80000000;         // Sign bit
-    unsigned t3 = inu & 0x7f800000;         // Exponent
+    unsigned t1 = inu & 0x7fffffffu;         // Non-sign bits
+    unsigned t2 = inu & 0x80000000u;         // Sign bit
+    unsigned t3 = inu & 0x7f800000u;         // Exponent
 
 
     t1 >>= 13;                              // Align mantissa on MSB
     t1 >>= 13;                              // Align mantissa on MSB
     t2 >>= 16;                              // Shift sign bit into position
     t2 >>= 16;                              // Shift sign bit into position
@@ -271,9 +260,9 @@ inline unsigned short FloatToHalf(float value)
 /// Convert half float to float. From https://gist.github.com/martinkallman/5049614
 /// Convert half float to float. From https://gist.github.com/martinkallman/5049614
 inline float HalfToFloat(unsigned short value)
 inline float HalfToFloat(unsigned short value)
 {
 {
-    unsigned t1 = value & 0x7fff;           // Non-sign bits
-    unsigned t2 = value & 0x8000;           // Sign bit
-    unsigned t3 = value & 0x7c00;           // Exponent
+    unsigned t1 = value & 0x7fffu;           // Non-sign bits
+    unsigned t2 = value & 0x8000u;           // Sign bit
+    unsigned t3 = value & 0x7c00u;           // Exponent
 
 
     t1 <<= 13;                              // Align mantissa on MSB
     t1 <<= 13;                              // Align mantissa on MSB
     t2 <<= 16;                              // Shift sign bit into position
     t2 <<= 16;                              // Shift sign bit into position

+ 1 - 1
Source/Urho3D/Math/Random.cpp

@@ -44,7 +44,7 @@ unsigned GetRandomSeed()
 int Rand()
 int Rand()
 {
 {
     randomSeed = randomSeed * 214013 + 2531011;
     randomSeed = randomSeed * 214013 + 2531011;
-    return (randomSeed >> 16) & 32767;
+    return (randomSeed >> 16u) & 32767u;
 }
 }
 
 
 float RandStandardNormal()
 float RandStandardNormal()

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

@@ -199,13 +199,13 @@ void CrowdAgent::UpdateParameters(unsigned scope)
             switch (navQuality_)
             switch (navQuality_)
             {
             {
             case NAVIGATIONQUALITY_LOW:
             case NAVIGATIONQUALITY_LOW:
-                params.updateFlags = 0
+                params.updateFlags = 0u
                                      | DT_CROWD_OPTIMIZE_VIS
                                      | DT_CROWD_OPTIMIZE_VIS
                                      | DT_CROWD_ANTICIPATE_TURNS;
                                      | DT_CROWD_ANTICIPATE_TURNS;
                 break;
                 break;
 
 
             case NAVIGATIONQUALITY_MEDIUM:
             case NAVIGATIONQUALITY_MEDIUM:
-                params.updateFlags = 0
+                params.updateFlags = 0u
                                      | DT_CROWD_OPTIMIZE_TOPO
                                      | DT_CROWD_OPTIMIZE_TOPO
                                      | DT_CROWD_OPTIMIZE_VIS
                                      | DT_CROWD_OPTIMIZE_VIS
                                      | DT_CROWD_ANTICIPATE_TURNS
                                      | DT_CROWD_ANTICIPATE_TURNS
@@ -213,7 +213,7 @@ void CrowdAgent::UpdateParameters(unsigned scope)
                 break;
                 break;
 
 
             case NAVIGATIONQUALITY_HIGH:
             case NAVIGATIONQUALITY_HIGH:
-                params.updateFlags = 0
+                params.updateFlags = 0u
                                      // Path finding
                                      // Path finding
                                      | DT_CROWD_OPTIMIZE_TOPO
                                      | DT_CROWD_OPTIMIZE_TOPO
                                      | DT_CROWD_OPTIMIZE_VIS
                                      | DT_CROWD_OPTIMIZE_VIS

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

@@ -258,7 +258,7 @@ bool DynamicNavigationMesh::Allocate(const BoundingBox& boundingBox, unsigned ma
 
 
     // Calculate max number of polygons, 22 bits available to identify both tile & polygon within tile
     // Calculate max number of polygons, 22 bits available to identify both tile & polygon within tile
     unsigned tileBits = LogBaseTwo(maxTiles);
     unsigned tileBits = LogBaseTwo(maxTiles);
-    auto maxPolys = (unsigned)(1 << (22 - tileBits));
+    unsigned maxPolys = 1u << (22 - tileBits);
 
 
     dtNavMeshParams params;     // NOLINT(hicpp-member-init)
     dtNavMeshParams params;     // NOLINT(hicpp-member-init)
     rcVcopy(params.orig, &boundingBox_.min_.x_);
     rcVcopy(params.orig, &boundingBox_.min_.x_);
@@ -373,7 +373,7 @@ bool DynamicNavigationMesh::Build()
         // Calculate max. number of tiles and polygons, 22 bits available to identify both tile & polygon within tile
         // Calculate max. number of tiles and polygons, 22 bits available to identify both tile & polygon within tile
         unsigned maxTiles = NextPowerOfTwo((unsigned)(numTilesX_ * numTilesZ_)) * maxLayers_;
         unsigned maxTiles = NextPowerOfTwo((unsigned)(numTilesX_ * numTilesZ_)) * maxLayers_;
         unsigned tileBits = LogBaseTwo(maxTiles);
         unsigned tileBits = LogBaseTwo(maxTiles);
-        auto maxPolys = (unsigned)(1 << (22 - tileBits));
+        unsigned maxPolys = 1u << (22 - tileBits);
 
 
         dtNavMeshParams params;     // NOLINT(hicpp-member-init)
         dtNavMeshParams params;     // NOLINT(hicpp-member-init)
         rcVcopy(params.orig, &boundingBox_.min_.x_);
         rcVcopy(params.orig, &boundingBox_.min_.x_);

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

@@ -345,7 +345,7 @@ bool NavigationMesh::Allocate(const BoundingBox& boundingBox, unsigned maxTiles)
 
 
     // Calculate max number of polygons, 22 bits available to identify both tile & polygon within tile
     // Calculate max number of polygons, 22 bits available to identify both tile & polygon within tile
     unsigned tileBits = LogBaseTwo(maxTiles);
     unsigned tileBits = LogBaseTwo(maxTiles);
-    auto maxPolys = (unsigned)(1 << (22 - tileBits));
+    unsigned maxPolys = 1u << (22 - tileBits);
 
 
     dtNavMeshParams params;     // NOLINT(hicpp-member-init)
     dtNavMeshParams params;     // NOLINT(hicpp-member-init)
     rcVcopy(params.orig, &boundingBox_.min_.x_);
     rcVcopy(params.orig, &boundingBox_.min_.x_);
@@ -421,7 +421,7 @@ bool NavigationMesh::Build()
         // Calculate max. number of tiles and polygons, 22 bits available to identify both tile & polygon within tile
         // Calculate max. number of tiles and polygons, 22 bits available to identify both tile & polygon within tile
         unsigned maxTiles = NextPowerOfTwo((unsigned)(numTilesX_ * numTilesZ_));
         unsigned maxTiles = NextPowerOfTwo((unsigned)(numTilesX_ * numTilesZ_));
         unsigned tileBits = LogBaseTwo(maxTiles);
         unsigned tileBits = LogBaseTwo(maxTiles);
-        auto maxPolys = (unsigned)(1 << (22 - tileBits));
+        unsigned maxPolys = 1u << (22 - tileBits);
 
 
         dtNavMeshParams params;     // NOLINT(hicpp-member-init)
         dtNavMeshParams params;     // NOLINT(hicpp-member-init)
         rcVcopy(params.orig, &boundingBox_.min_.x_);
         rcVcopy(params.orig, &boundingBox_.min_.x_);

+ 1 - 4
Source/Urho3D/Network/Network.h

@@ -38,10 +38,7 @@ class MemoryBuffer;
 class Scene;
 class Scene;
 
 
 /// MessageConnection hash function.
 /// MessageConnection hash function.
-template <class T> unsigned MakeHash(kNet::MessageConnection* value)
-{
-    return ((unsigned)(size_t)value) >> 9;
-}
+template <class T> unsigned MakeHash(kNet::MessageConnection* value) { return (unsigned)((size_t)value >> 9u); }
 
 
 /// %Network subsystem. Manages client-server communications using the UDP protocol.
 /// %Network subsystem. Manages client-server communications using the UDP protocol.
 class URHO3D_API Network : public Object, public kNet::IMessageHandler, public kNet::INetworkServerListener
 class URHO3D_API Network : public Object, public kNet::IMessageHandler, public kNet::INetworkServerListener

+ 2 - 2
Source/Urho3D/Physics/CollisionShape.cpp

@@ -334,8 +334,8 @@ HeightfieldData::HeightfieldData(Terrain* terrain, unsigned lodLevel) :
                 skip *= 2;
                 skip *= 2;
                 lodSpacing.x_ *= 2.0f;
                 lodSpacing.x_ *= 2.0f;
                 lodSpacing.z_ *= 2.0f;
                 lodSpacing.z_ *= 2.0f;
-                int rX = lodSize.x_ & 1;
-                int rY = lodSize.y_ & 1;
+                int rX = lodSize.x_ & 1u;
+                int rY = lodSize.y_ & 1u;
                 lodSize.x_ >>= 1;
                 lodSize.x_ >>= 1;
                 lodSize.y_ >>= 1;
                 lodSize.y_ >>= 1;
                 lodSize.x_ += rX;
                 lodSize.x_ += rX;

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

@@ -67,7 +67,7 @@ JSONValue& JSONValue::operator =(bool rhs)
 JSONValue& JSONValue::operator =(int rhs)
 JSONValue& JSONValue::operator =(int rhs)
 {
 {
     SetType(JSON_NUMBER, JSONNT_INT);
     SetType(JSON_NUMBER, JSONNT_INT);
-    numberValue_ = rhs;    
+    numberValue_ = rhs;
 
 
     return *this;
     return *this;
 }
 }
@@ -165,12 +165,12 @@ JSONValue& JSONValue::operator =(const JSONValue& rhs)
 
 
 JSONValueType JSONValue::GetValueType() const
 JSONValueType JSONValue::GetValueType() const
 {
 {
-    return (JSONValueType)(type_ >> 16);
+    return (JSONValueType)(type_ >> 16u);
 }
 }
 
 
 JSONNumberType JSONValue::GetNumberType() const
 JSONNumberType JSONValue::GetNumberType() const
 {
 {
-    return (JSONNumberType)(type_ & 0xffff);
+    return (JSONNumberType)(type_ & 0xffffu);
 }
 }
 
 
 String JSONValue::GetValueTypeName() const
 String JSONValue::GetValueTypeName() const
@@ -343,7 +343,7 @@ void JSONValue::Clear()
 
 
 void JSONValue::SetType(JSONValueType valueType, JSONNumberType numberType)
 void JSONValue::SetType(JSONValueType valueType, JSONNumberType numberType)
 {
 {
-    int type = (valueType << 16) | numberType;
+    int type = valueType << 16u | numberType;
     if (type == type_)
     if (type == type_)
         return;
         return;
 
 
@@ -415,7 +415,7 @@ void JSONValue::SetVariantValue(const Variant& variant, Context* context)
     case VAR_BOOL:
     case VAR_BOOL:
         *this = variant.GetBool();
         *this = variant.GetBool();
         return;
         return;
-    
+
     case VAR_INT:
     case VAR_INT:
         *this = variant.GetInt();
         *this = variant.GetInt();
         return;
         return;

+ 6 - 6
Source/Urho3D/Scene/ReplicationState.h

@@ -67,8 +67,8 @@ struct URHO3D_API DirtyBits
     {
     {
         if (index < MAX_NETWORK_ATTRIBUTES)
         if (index < MAX_NETWORK_ATTRIBUTES)
         {
         {
-            unsigned byteIndex = index >> 3;
-            auto bit = (unsigned)(1 << (index & 7));
+            unsigned byteIndex = index >> 3u;
+            auto bit = (unsigned)(1u << (index & 7u));
             if ((data_[byteIndex] & bit) == 0)
             if ((data_[byteIndex] & bit) == 0)
             {
             {
                 data_[byteIndex] |= bit;
                 data_[byteIndex] |= bit;
@@ -82,8 +82,8 @@ struct URHO3D_API DirtyBits
     {
     {
         if (index < MAX_NETWORK_ATTRIBUTES)
         if (index < MAX_NETWORK_ATTRIBUTES)
         {
         {
-            unsigned byteIndex = index >> 3;
-            auto bit = (unsigned)(1 << (index & 7));
+            unsigned byteIndex = index >> 3u;
+            auto bit = (unsigned)(1u << (index & 7u));
             if ((data_[byteIndex] & bit) != 0)
             if ((data_[byteIndex] & bit) != 0)
             {
             {
                 data_[byteIndex] &= ~bit;
                 data_[byteIndex] &= ~bit;
@@ -104,8 +104,8 @@ struct URHO3D_API DirtyBits
     {
     {
         if (index < MAX_NETWORK_ATTRIBUTES)
         if (index < MAX_NETWORK_ATTRIBUTES)
         {
         {
-            unsigned byteIndex = index >> 3;
-            auto bit = (unsigned)(1 << (index & 7));
+            unsigned byteIndex = index >> 3u;
+            auto bit = (unsigned)(1u << (index & 7u));
             return (data_[byteIndex] & bit) != 0;
             return (data_[byteIndex] & bit) != 0;
         }
         }
         else
         else

+ 3 - 3
Source/Urho3D/Scene/Serializable.cpp

@@ -759,7 +759,7 @@ void Serializable::WriteInitialDeltaUpdate(Serializer& dest, unsigned char timeS
 
 
     // First write the change bitfield, then attribute data for non-default attributes
     // First write the change bitfield, then attribute data for non-default attributes
     dest.WriteUByte(timeStamp);
     dest.WriteUByte(timeStamp);
-    dest.Write(attributeBits.data_, (numAttributes + 7) >> 3);
+    dest.Write(attributeBits.data_, (numAttributes + 7) >> 3u);
 
 
     for (unsigned i = 0; i < numAttributes; ++i)
     for (unsigned i = 0; i < numAttributes; ++i)
     {
     {
@@ -785,7 +785,7 @@ void Serializable::WriteDeltaUpdate(Serializer& dest, const DirtyBits& attribute
     // First write the change bitfield, then attribute data for changed attributes
     // First write the change bitfield, then attribute data for changed attributes
     // Note: the attribute bits should not contain LATESTDATA attributes
     // Note: the attribute bits should not contain LATESTDATA attributes
     dest.WriteUByte(timeStamp);
     dest.WriteUByte(timeStamp);
-    dest.Write(attributeBits.data_, (numAttributes + 7) >> 3);
+    dest.Write(attributeBits.data_, (numAttributes + 7) >> 3u);
 
 
     for (unsigned i = 0; i < numAttributes; ++i)
     for (unsigned i = 0; i < numAttributes; ++i)
     {
     {
@@ -829,7 +829,7 @@ bool Serializable::ReadDeltaUpdate(Deserializer& source)
 
 
     unsigned long long interceptMask = networkState_ ? networkState_->interceptMask_ : 0;
     unsigned long long interceptMask = networkState_ ? networkState_->interceptMask_ : 0;
     unsigned char timeStamp = source.ReadUByte();
     unsigned char timeStamp = source.ReadUByte();
-    source.Read(attributeBits.data_, (numAttributes + 7) >> 3);
+    source.Read(attributeBits.data_, (numAttributes + 7) >> 3u);
 
 
     for (unsigned i = 0; i < numAttributes && !source.IsEof(); ++i)
     for (unsigned i = 0; i < numAttributes && !source.IsEof(); ++i)
     {
     {

+ 1 - 1
Source/Urho3D/UI/FontFace.cpp

@@ -75,7 +75,7 @@ float FontFace::GetKerning(unsigned c, unsigned d) const
     if (c > 0xffff || d > 0xffff)
     if (c > 0xffff || d > 0xffff)
         return 0;
         return 0;
 
 
-    unsigned value = (c << 16) + d;
+    unsigned value = (c << 16u) + d;
 
 
     HashMap<unsigned, float>::ConstIterator i = kerningMapping_.Find(value);
     HashMap<unsigned, float>::ConstIterator i = kerningMapping_.Find(value);
     if (i != kerningMapping_.End())
     if (i != kerningMapping_.End())

+ 7 - 7
Source/Urho3D/UI/FontFaceBitmap.cpp

@@ -151,9 +151,9 @@ bool FontFaceBitmap::Load(const unsigned char* fontData, unsigned fontDataSize,
         XMLElement kerningElem = kerningsElem.GetChild("kerning");
         XMLElement kerningElem = kerningsElem.GetChild("kerning");
         while (!kerningElem.IsNull())
         while (!kerningElem.IsNull())
         {
         {
-            int first = kerningElem.GetInt("first");
-            int second = kerningElem.GetInt("second");
-            auto value = (unsigned)((first << 16) + second);
+            unsigned first = kerningElem.GetInt("first");
+            unsigned second = kerningElem.GetInt("second");
+            unsigned value = first << 16u | second;
             kerningMapping_[value] = (short)kerningElem.GetInt("amount");
             kerningMapping_[value] = (short)kerningElem.GetInt("amount");
 
 
             kerningElem = kerningElem.GetNext("kerning");
             kerningElem = kerningElem.GetNext("kerning");
@@ -253,8 +253,8 @@ bool FontFaceBitmap::Load(FontFace* fontFace, bool usedGlyphs)
 
 
     for (HashMap<unsigned, float>::ConstIterator i = fontFace->kerningMapping_.Begin(); i != fontFace->kerningMapping_.End(); ++i)
     for (HashMap<unsigned, float>::ConstIterator i = fontFace->kerningMapping_.Begin(); i != fontFace->kerningMapping_.End(); ++i)
     {
     {
-        unsigned first = (i->first_) >> 16;
-        unsigned second = (i->first_) & 0xffff;
+        unsigned first = (i->first_) >> 16u;
+        unsigned second = (i->first_) & 0xffffu;
         if (glyphMapping_.Find(first) != glyphMapping_.End() && glyphMapping_.Find(second) != glyphMapping_.End())
         if (glyphMapping_.Find(first) != glyphMapping_.End() && glyphMapping_.Find(second) != glyphMapping_.End())
             kerningMapping_[i->first_] = i->second_;
             kerningMapping_[i->first_] = i->second_;
     }
     }
@@ -332,8 +332,8 @@ bool FontFaceBitmap::Save(Serializer& dest, int pointSize, const String& indenta
         for (HashMap<unsigned, float>::ConstIterator i = kerningMapping_.Begin(); i != kerningMapping_.End(); ++i)
         for (HashMap<unsigned, float>::ConstIterator i = kerningMapping_.Begin(); i != kerningMapping_.End(); ++i)
         {
         {
             XMLElement kerningElem = kerningsElem.CreateChild("kerning");
             XMLElement kerningElem = kerningsElem.CreateChild("kerning");
-            kerningElem.SetInt("first", i->first_ >> 16);
-            kerningElem.SetInt("second", i->first_ & 0xffff);
+            kerningElem.SetInt("first", i->first_ >> 16u);
+            kerningElem.SetInt("second", i->first_ & 0xffffu);
             kerningElem.SetInt("amount", i->second_);
             kerningElem.SetInt("amount", i->second_);
         }
         }
     }
     }

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

@@ -268,7 +268,7 @@ bool FontFaceFreeType::Load(const unsigned char* fontData, unsigned fontDataSize
                     deserializer.Seek((unsigned)(deserializer.GetPosition() + 3 * sizeof(unsigned short)));
                     deserializer.Seek((unsigned)(deserializer.GetPosition() + 3 * sizeof(unsigned short)));
 
 
                     // x_scale is a 16.16 fixed-point value that converts font units -> 26.6 pixels (oversampled!)
                     // x_scale is a 16.16 fixed-point value that converts font units -> 26.6 pixels (oversampled!)
-                    float xScale = face->size->metrics.x_scale / float(1 << 22) / oversampling_;
+                    auto xScale = (float)face->size->metrics.x_scale / (1u << 22u) / oversampling_;
 
 
                     for (unsigned j = 0; j < numKerningPairs; ++j)
                     for (unsigned j = 0; j < numKerningPairs; ++j)
                     {
                     {
@@ -280,7 +280,7 @@ bool FontFaceFreeType::Load(const unsigned char* fontData, unsigned fontDataSize
                         unsigned rightCharCode = rightIndex < numGlyphs ? charCodes[rightIndex + 1] : 0;
                         unsigned rightCharCode = rightIndex < numGlyphs ? charCodes[rightIndex + 1] : 0;
                         if (leftCharCode != 0 && rightCharCode != 0)
                         if (leftCharCode != 0 && rightCharCode != 0)
                         {
                         {
-                            unsigned value = (leftCharCode << 16) + rightCharCode;
+                            unsigned value = (leftCharCode << 16u) + rightCharCode;
                             kerningMapping_[value] = amount;
                             kerningMapping_[value] = amount;
                         }
                         }
                     }
                     }
@@ -509,7 +509,7 @@ bool FontFaceFreeType::LoadCharGlyph(unsigned charCode, Image* image)
 
 
                 // Don't do any oversampling, just unpack the bits directly.
                 // Don't do any oversampling, just unpack the bits directly.
                 for (unsigned x = 0; x < (unsigned)slot->bitmap.width; ++x)
                 for (unsigned x = 0; x < (unsigned)slot->bitmap.width; ++x)
-                    rowDest[x] = (unsigned char)((src[x >> 3] & (0x80 >> (x & 7))) ? 255 : 0);
+                    rowDest[x] = (unsigned char)((src[x >> 3u] & (0x80u >> (x & 7u))) ? 255 : 0);
             }
             }
         }
         }
         else
         else

+ 3 - 3
Source/Urho3D/UI/UI.cpp

@@ -67,7 +67,7 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#define TOUCHID_MASK(id) (1 << (id))
+#define TOUCHID_MASK(id) (1u << (unsigned)(id))
 
 
 namespace Urho3D
 namespace Urho3D
 {
 {
@@ -2067,9 +2067,9 @@ IntVector2 UI::SumTouchPositions(UI::DragData* dragData, const IntVector2& oldSe
         int buttons = dragData->dragButtons;
         int buttons = dragData->dragButtons;
         dragData->sumPos = IntVector2::ZERO;
         dragData->sumPos = IntVector2::ZERO;
         auto* input = GetSubsystem<Input>();
         auto* input = GetSubsystem<Input>();
-        for (int i = 0; (1 << i) <= buttons; i++)
+        for (unsigned i = 0; (1u << i) <= buttons; i++)
         {
         {
-            if ((1 << i) & buttons)
+            if ((1u << i) & buttons)
             {
             {
                 TouchState* ts = input->GetTouch((unsigned)i);
                 TouchState* ts = input->GetTouch((unsigned)i);
                 if (!ts)
                 if (!ts)

+ 5 - 5
Source/Urho3D/Urho2D/AnimationSet2D.cpp

@@ -211,8 +211,8 @@ Sprite2D* AnimationSet2D::GetSprite() const
 
 
 Sprite2D* AnimationSet2D::GetSpriterFileSprite(int folderId, int fileId) const
 Sprite2D* AnimationSet2D::GetSpriterFileSprite(int folderId, int fileId) const
 {
 {
-    int key = (folderId << 16) + fileId;
-    HashMap<int, SharedPtr<Sprite2D> >::ConstIterator i = spriterFileSprites_.Find(key);
+    unsigned key = folderId << 16u | fileId;
+    HashMap<unsigned, SharedPtr<Sprite2D> >::ConstIterator i = spriterFileSprites_.Find(key);
     if (i != spriterFileSprites_.End())
     if (i != spriterFileSprites_.End())
         return i->second_;
         return i->second_;
 
 
@@ -389,7 +389,7 @@ bool AnimationSet2D::EndLoadSpriter()
                 if (!sprite_)
                 if (!sprite_)
                     sprite_ = sprite;
                     sprite_ = sprite;
 
 
-                int key = (folder->id_ << 16) + file->id_;
+                unsigned key = folder->id_ << 16u | file->id_;
                 spriterFileSprites_[key] = sprite;
                 spriterFileSprites_[key] = sprite;
             }
             }
         }
         }
@@ -477,7 +477,7 @@ bool AnimationSet2D::EndLoadSpriter()
                 sprite->SetRectangle(IntRect(info.x, info.y, info.x + image->GetWidth(), info.y + image->GetHeight()));
                 sprite->SetRectangle(IntRect(info.x, info.y, info.x + image->GetWidth(), info.y + image->GetHeight()));
                 sprite->SetHotSpot(Vector2(info.file_->pivotX_, info.file_->pivotY_));
                 sprite->SetHotSpot(Vector2(info.file_->pivotX_, info.file_->pivotY_));
 
 
-                int key = (info.file_->folder_->id_ << 16) + info.file_->id_;
+                unsigned key = info.file_->folder_->id_ << 16u | info.file_->id_;
                 spriterFileSprites_[key] = sprite;
                 spriterFileSprites_[key] = sprite;
             }
             }
 
 
@@ -497,7 +497,7 @@ bool AnimationSet2D::EndLoadSpriter()
             sprite_->SetRectangle(IntRect(info.x, info.y, info.x + info.image_->GetWidth(), info.y + info.image_->GetHeight()));
             sprite_->SetRectangle(IntRect(info.x, info.y, info.x + info.image_->GetWidth(), info.y + info.image_->GetHeight()));
             sprite_->SetHotSpot(Vector2(info.file_->pivotX_, info.file_->pivotY_));
             sprite_->SetHotSpot(Vector2(info.file_->pivotX_, info.file_->pivotY_));
 
 
-            int key = (info.file_->folder_->id_ << 16) + info.file_->id_;
+            unsigned key = info.file_->folder_->id_ << 16u | info.file_->id_;
             spriterFileSprites_[key] = sprite_;
             spriterFileSprites_[key] = sprite_;
         }
         }
     }
     }

+ 1 - 1
Source/Urho3D/Urho2D/AnimationSet2D.h

@@ -117,7 +117,7 @@ private:
     /// Sprite sheet.
     /// Sprite sheet.
     SharedPtr<SpriteSheet2D> spriteSheet_;
     SharedPtr<SpriteSheet2D> spriteSheet_;
     /// Spriter sprites.
     /// Spriter sprites.
-    HashMap<int, SharedPtr<Sprite2D> > spriterFileSprites_;
+    HashMap<unsigned, SharedPtr<Sprite2D> > spriterFileSprites_;
 };
 };
 
 
 }
 }

+ 3 - 3
Source/Urho3D/Urho2D/TmxFile2D.cpp

@@ -193,9 +193,9 @@ bool TmxTileLayer2D::Load(const XMLElement& element, const TileMapInfo2D& info)
             for (int x = 0; x < width_; ++x)
             for (int x = 0; x < width_; ++x)
             {
             {
                 // buffer contains 32-bit integers in little-endian format
                 // buffer contains 32-bit integers in little-endian format
-                unsigned gid = ((unsigned)buffer[currentIndex+3] << 24)
-                             | ((unsigned)buffer[currentIndex+2] << 16)
-                             | ((unsigned)buffer[currentIndex+1] << 8)
+                unsigned gid = ((unsigned)buffer[currentIndex+3] << 24u)
+                             | ((unsigned)buffer[currentIndex+2] << 16u)
+                             | ((unsigned)buffer[currentIndex+1] << 8u)
                              | (unsigned)buffer[currentIndex];
                              | (unsigned)buffer[currentIndex];
                 if (gid > 0)
                 if (gid > 0)
                 {
                 {