Browse Source

Wrong Casting

Fixed some casting warnings
cosmy 10 years ago
parent
commit
1b9f1f7fd9

+ 1 - 0
.gitignore

@@ -18,6 +18,7 @@ generated/
 /Source/Urho3D/Urho3D.h
 /Source/Urho3D/Urho3D.pc
 /Source/Urho3D/librevision.h
+/Source/Urho3D/Precompiled.cpp
 
 # Compiled shaders
 *.vs2

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

@@ -559,7 +559,7 @@ Vector<String> String::Split(char separator) const
     return Split(CString(), separator);
 }
 
-void String::Join(const Vector<String>& subStrings, String glue)
+void String::Join(const Vector<String>& subStrings, const String& glue)
 {
     *this = Joined(subStrings, glue);
 }
@@ -1085,7 +1085,7 @@ Vector<String> String::Split(const char* str, char separator)
     return ret;
 }
 
-String String::Joined(const Vector<String>& subStrings, String glue)
+String String::Joined(const Vector<String>& subStrings, const String& glue)
 {
     if (subStrings.Empty())
         return String();

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

@@ -390,7 +390,7 @@ public:
     /// Return substrings split by a separator char.
     Vector<String> Split(char separator) const;
     /// Join substrings with a 'glue' string.
-    void Join(const Vector<String>& subStrings, String glue);
+    void Join(const Vector<String>& subStrings, const String& glue);
     /// Return index to the first occurrence of a string, or NPOS if not found.
     unsigned Find(const String& str, unsigned startPos = 0, bool caseSensitive = true) const;
     /// Return index to the first occurrence of a character, or NPOS if not found.
@@ -465,7 +465,7 @@ public:
     /// Return substrings split by a separator char.
     static Vector<String> Split(const char* str, char separator);
     /// Return a string by joining substrings with a 'glue' string.
-    static String Joined(const Vector<String>& subStrings, String glue);
+    static String Joined(const Vector<String>& subStrings, const String& glue);
     /// Encode Unicode character to UTF8. Pointer will be incremented.
     static void EncodeUTF8(char*& dest, unsigned unicodeChar);
     /// Decode Unicode character from UTF8. Pointer will be incremented.

+ 1 - 1
Source/Urho3D/Core/Spline.cpp

@@ -203,7 +203,7 @@ Variant Spline::CatmullRomInterpolation(const Vector<Variant>& knots, float t) c
         if (t >= 1.f)
             return knots[knots.Size() - 2];
 
-        int originIndex = t * (knots.Size() - 3);
+        int originIndex = static_cast<int>(t * (knots.Size() - 3));
         t = fmodf(t * (knots.Size() - 3), 1.f);
         float t2 = t * t;
         float t3 = t2 * t;

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

@@ -1195,7 +1195,7 @@ void Input::ResetJoysticks()
     joysticks_.Clear();
 
     // Open each detected joystick automatically on startup
-    int size = SDL_NumJoysticks();
+    unsigned size = static_cast<unsigned>(SDL_NumJoysticks());
     for (unsigned i = 0; i < size; ++i)
         OpenJoystick(i);
 }

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

@@ -1659,7 +1659,7 @@ SharedPtr<Image> Image::ConvertToRGBA() const
     switch (components_)
     {
     case 1:
-        for (unsigned i = 0; i < width_ * height_ * depth_; ++i)
+        for (unsigned i = 0; i < static_cast<unsigned>(width_ * height_ * depth_); ++i)
         {
             unsigned char pixel = *src++;
             *dest++ = pixel;
@@ -1670,7 +1670,7 @@ SharedPtr<Image> Image::ConvertToRGBA() const
         break;
 
     case 2:
-        for (unsigned i = 0; i < width_ * height_ * depth_; ++i)
+        for (unsigned i = 0; i < static_cast<unsigned>(width_ * height_ * depth_); ++i)
         {
             unsigned char pixel = *src++;
             *dest++ = pixel;
@@ -1681,7 +1681,7 @@ SharedPtr<Image> Image::ConvertToRGBA() const
         break;
 
     case 3:
-        for (unsigned i = 0; i < width_ * height_ * depth_; ++i)
+        for (unsigned i = 0; i < static_cast<unsigned>(width_ * height_ * depth_); ++i)
         {
             *dest++ = *src++;
             *dest++ = *src++;

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

@@ -221,7 +221,7 @@ bool FontFaceBitmap::Load(FontFace* fontFace, bool usedGlyphs)
         oldImages.Push(SaveFaceTexture(fontFace->textures_[i]));
 
     Vector<SharedPtr<Image> > newImages(numPages);
-    for (int i = 0; i < numPages; ++i)
+    for (unsigned i = 0; i < numPages; ++i)
     {
         SharedPtr<Image> image(new Image(font_->GetContext()));
 

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

@@ -1877,7 +1877,7 @@ int UIElement::CalculateLayoutParentSize(const PODVector<int>& sizes, int begin,
 void UIElement::CalculateLayout(PODVector<int>& positions, PODVector<int>& sizes, const PODVector<int>& minSizes,
     const PODVector<int>& maxSizes, const PODVector<float>& flexScales, int targetSize, int begin, int end, int spacing)
 {
-    int numChildren = sizes.Size();
+    unsigned numChildren = sizes.Size();
     if (!numChildren)
         return;
     int targetTotalSize = targetSize - begin - end - (numChildren - 1) * spacing;
@@ -1889,7 +1889,7 @@ void UIElement::CalculateLayout(PODVector<int>& positions, PODVector<int>& sizes
     float acc = 0.0f;
 
     // Initial pass
-    for (int i = 0; i < numChildren; ++i)
+    for (unsigned i = 0; i < numChildren; ++i)
     {
         int targetSize = (int)(targetChildSize * flexScales[i]);
         if (remainder)
@@ -1909,7 +1909,7 @@ void UIElement::CalculateLayout(PODVector<int>& positions, PODVector<int>& sizes
     for (;;)
     {
         int actualTotalSize = 0;
-        for (int i = 0; i < numChildren; ++i)
+        for (unsigned i = 0; i < numChildren; ++i)
             actualTotalSize += sizes[i];
         int error = targetTotalSize - actualTotalSize;
         // Break if no error
@@ -1957,7 +1957,7 @@ void UIElement::CalculateLayout(PODVector<int>& positions, PODVector<int>& sizes
     layoutMinSize_ = M_MAX_INT;
     layoutMaxSize_ = 0;
     int position = begin;
-    for (int i = 0; i < numChildren; ++i)
+    for (unsigned i = 0; i < numChildren; ++i)
     {
         positions[i] = position;
         position += sizes[i] + spacing;