Browse Source

Attempt to suppress some of the compiler warnings from iOS 64bit build.
Something must have changed on the Travis CI Mac OS X build environment recently that causes the compiler to produce tons of warning on iOS 64-bit build. It not only slows down the CI build but also causes the log to be truncated in the Travis CI web interface.

Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
b2c2bb372b

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

@@ -439,7 +439,7 @@ public:
         const char* ptr = str;
         while (*ptr)
             ++ptr;
-        return ptr - str;
+        return (unsigned)(ptr - str);
         #endif
     }
     

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

@@ -33,50 +33,50 @@ unsigned CountElements(const char* buffer, char separator)
 {
     if (!buffer)
         return 0;
-    
+
     const char* endPos = buffer + String::CStringLength(buffer);
     const char* pos = buffer;
     unsigned ret = 0;
-    
+
     while (pos < endPos)
     {
         if (*pos != separator)
             break;
         ++pos;
     }
-    
+
     while (pos < endPos)
     {
         const char* start = pos;
-        
+
         while (start < endPos)
         {
             if (*start == separator)
                 break;
-            
+
             ++start;
         }
-        
+
         if (start == endPos)
         {
             ++ret;
             break;
         }
-        
+
         const char* end = start;
-        
+
         while (end < endPos)
         {
             if (*end != separator)
                 break;
-            
+
             ++end;
         }
-        
+
         ++ret;
         pos = end;
     }
-    
+
     return ret;
 }
 
@@ -88,7 +88,7 @@ bool ToBool(const String& source)
 bool ToBool(const char* source)
 {
     unsigned length = String::CStringLength(source);
-    
+
     for (unsigned i = 0; i < length; ++i)
     {
         char c = tolower(source[i]);
@@ -97,7 +97,7 @@ bool ToBool(const char* source)
         else if (c != ' ' && c != '\t')
             break;
     }
-    
+
     return false;
 }
 
@@ -110,7 +110,7 @@ int ToInt(const char* source)
 {
     if (!source)
         return 0;
-    
+
     // Explicitly ask for base 10 to prevent source starts with '0' or '0x' from being converted to base 8 or base 16, respectively
     return strtol(source, 0, 10);
 }
@@ -124,7 +124,7 @@ unsigned ToUInt(const char* source)
 {
     if (!source)
         return 0;
-    
+
     return strtoul(source, 0, 10);
 }
 
@@ -137,7 +137,7 @@ float ToFloat(const char* source)
 {
     if (!source)
         return 0;
-    
+
     return (float)strtod(source, 0);
 }
 
@@ -149,18 +149,18 @@ Color ToColor(const String& source)
 Color ToColor(const char* source)
 {
     Color ret;
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 3)
         return ret;
-    
+
     char* ptr = (char*)source;
     ret.r_ = (float)strtod(ptr, &ptr);
     ret.g_ = (float)strtod(ptr, &ptr);
     ret.b_ = (float)strtod(ptr, &ptr);
     if (elements > 3)
         ret.a_ = (float)strtod(ptr, &ptr);
-    
+
     return ret;
 }
 
@@ -172,17 +172,17 @@ IntRect ToIntRect(const String& source)
 IntRect ToIntRect(const char* source)
 {
     IntRect ret(IntRect::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 4)
         return ret;
-    
+
     char* ptr = (char*)source;
-    ret.left_ = strtol(ptr, &ptr, 10);
-    ret.top_ = strtol(ptr, &ptr, 10);
-    ret.right_ = strtol(ptr, &ptr, 10);
-    ret.bottom_ = strtol(ptr, &ptr, 10);
-    
+    ret.left_ = (int)strtol(ptr, &ptr, 10);
+    ret.top_ = (int)strtol(ptr, &ptr, 10);
+    ret.right_ = (int)strtol(ptr, &ptr, 10);
+    ret.bottom_ = (int)strtol(ptr, &ptr, 10);
+
     return ret;
 }
 
@@ -194,15 +194,15 @@ IntVector2 ToIntVector2(const String& source)
 IntVector2 ToIntVector2(const char* source)
 {
     IntVector2 ret(IntVector2::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 2)
         return ret;
-    
+
     char* ptr = (char*)source;
-    ret.x_ = strtol(ptr, &ptr, 10);
-    ret.y_ = strtol(ptr, &ptr, 10);
-    
+    ret.x_ = (int)strtol(ptr, &ptr, 10);
+    ret.y_ = (int)strtol(ptr, &ptr, 10);
+
     return ret;
 }
 
@@ -214,17 +214,17 @@ Rect ToRect(const String& source)
 Rect ToRect(const char* source)
 {
     Rect ret(Rect::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 4)
         return ret;
-    
+
     char* ptr = (char*)source;
     ret.min_.x_ = (float)strtod(ptr, &ptr);
     ret.min_.y_ = (float)strtod(ptr, &ptr);
     ret.max_.x_ = (float)strtod(ptr, &ptr);
     ret.max_.y_ = (float)strtod(ptr, &ptr);
-    
+
     return ret;
 }
 
@@ -237,7 +237,7 @@ Quaternion ToQuaternion(const char* source)
 {
     unsigned elements = CountElements(source, ' ');
     char* ptr = (char*)source;
-    
+
     if (elements < 3)
         return Quaternion::IDENTITY;
     else if (elements < 4)
@@ -247,7 +247,7 @@ Quaternion ToQuaternion(const char* source)
         x = (float)strtod(ptr, &ptr);
         y = (float)strtod(ptr, &ptr);
         z = (float)strtod(ptr, &ptr);
-        
+
         return Quaternion(x, y, z);
     }
     else
@@ -258,7 +258,7 @@ Quaternion ToQuaternion(const char* source)
         ret.x_ = (float)strtod(ptr, &ptr);
         ret.y_ = (float)strtod(ptr, &ptr);
         ret.z_ = (float)strtod(ptr, &ptr);
-        
+
         return ret;
     }
 }
@@ -271,15 +271,15 @@ Vector2 ToVector2(const String& source)
 Vector2 ToVector2(const char* source)
 {
     Vector2 ret(Vector2::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 2)
         return ret;
-    
+
     char* ptr = (char*)source;
     ret.x_ = (float)strtod(ptr, &ptr);
     ret.y_ = (float)strtod(ptr, &ptr);
-    
+
     return ret;
 }
 
@@ -291,16 +291,16 @@ Vector3 ToVector3(const String& source)
 Vector3 ToVector3(const char* source)
 {
     Vector3 ret(Vector3::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 3)
         return ret;
-    
+
     char* ptr = (char*)source;
     ret.x_ = (float)strtod(ptr, &ptr);
     ret.y_ = (float)strtod(ptr, &ptr);
     ret.z_ = (float)strtod(ptr, &ptr);
-    
+
     return ret;
 }
 
@@ -312,20 +312,20 @@ Vector4 ToVector4(const String& source, bool allowMissingCoords)
 Vector4 ToVector4(const char* source, bool allowMissingCoords)
 {
     Vector4 ret(Vector4::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     char* ptr = (char*)source;
-    
+
     if (!allowMissingCoords)
     {
         if (elements < 4)
             return ret;
-        
+
         ret.x_ = (float)strtod(ptr, &ptr);
         ret.y_ = (float)strtod(ptr, &ptr);
         ret.z_ = (float)strtod(ptr, &ptr);
         ret.w_ = (float)strtod(ptr, &ptr);
-        
+
         return ret;
     }
     else
@@ -338,7 +338,7 @@ Vector4 ToVector4(const char* source, bool allowMissingCoords)
             ret.z_ = (float)strtod(ptr, &ptr);
         if (elements > 3)
             ret.w_ = (float)strtod(ptr, &ptr);
-        
+
         return ret;
     }
 }
@@ -352,25 +352,25 @@ Variant ToVectorVariant(const char* source)
 {
     Variant ret;
     unsigned elements = CountElements(source, ' ');
-    
+
     switch (elements)
     {
     case 1:
         ret.FromString(VAR_FLOAT, source);
         break;
-        
+
     case 2:
         ret.FromString(VAR_VECTOR2, source);
         break;
-        
+
     case 3:
         ret.FromString(VAR_VECTOR3, source);
         break;
-        
+
     case 4:
         ret.FromString(VAR_VECTOR4, source);
         break;
-        
+
     case 9:
         ret.FromString(VAR_MATRIX3, source);
         break;
@@ -383,7 +383,7 @@ Variant ToVectorVariant(const char* source)
         ret.FromString(VAR_MATRIX4, source);
         break;
     }
-    
+
     return ret;
 }
 
@@ -395,11 +395,11 @@ Matrix3 ToMatrix3(const String& source)
 Matrix3 ToMatrix3(const char* source)
 {
     Matrix3 ret(Matrix3::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 9)
         return ret;
-    
+
     char* ptr = (char*)source;
     ret.m00_ = (float)strtod(ptr, &ptr);
     ret.m01_ = (float)strtod(ptr, &ptr);
@@ -410,7 +410,7 @@ Matrix3 ToMatrix3(const char* source)
     ret.m20_ = (float)strtod(ptr, &ptr);
     ret.m21_ = (float)strtod(ptr, &ptr);
     ret.m22_ = (float)strtod(ptr, &ptr);
-    
+
     return ret;
 }
 
@@ -422,11 +422,11 @@ Matrix3x4 ToMatrix3x4(const String& source)
 Matrix3x4 ToMatrix3x4(const char* source)
 {
     Matrix3x4 ret(Matrix3x4::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 12)
         return ret;
-    
+
     char* ptr = (char*)source;
     ret.m00_ = (float)strtod(ptr, &ptr);
     ret.m01_ = (float)strtod(ptr, &ptr);
@@ -440,7 +440,7 @@ Matrix3x4 ToMatrix3x4(const char* source)
     ret.m21_ = (float)strtod(ptr, &ptr);
     ret.m22_ = (float)strtod(ptr, &ptr);
     ret.m23_ = (float)strtod(ptr, &ptr);
-    
+
     return ret;
 }
 
@@ -452,11 +452,11 @@ Matrix4 ToMatrix4(const String& source)
 Matrix4 ToMatrix4(const char* source)
 {
     Matrix4 ret(Matrix4::ZERO);
-    
+
     unsigned elements = CountElements(source, ' ');
     if (elements < 16)
         return ret;
-    
+
     char* ptr = (char*)source;
     ret.m00_ = (float)strtod(ptr, &ptr);
     ret.m01_ = (float)strtod(ptr, &ptr);
@@ -474,7 +474,7 @@ Matrix4 ToMatrix4(const char* source)
     ret.m31_ = (float)strtod(ptr, &ptr);
     ret.m32_ = (float)strtod(ptr, &ptr);
     ret.m33_ = (float)strtod(ptr, &ptr);
-    
+
     return ret;
 }
 
@@ -500,7 +500,7 @@ void BufferToString(String& dest, const void* data, unsigned size)
         // Room for separator
         if (i)
             ++length;
-        
+
         // Room for the value
         if (bytes[i] < 10)
             ++length;
@@ -509,16 +509,16 @@ void BufferToString(String& dest, const void* data, unsigned size)
         else
             length += 3;
     }
-    
+
     dest.Resize(length);
     unsigned index = 0;
-    
+
     // Convert values
     for (unsigned i = 0; i < size; ++i)
     {
         if (i)
             dest[index++] = ' ';
-        
+
         if (bytes[i] < 10)
         {
             dest[index++] = '0' + bytes[i];
@@ -549,14 +549,14 @@ void StringToBuffer(PODVector<unsigned char>& dest, const char* source)
         dest.Clear();
         return;
     }
-    
+
     unsigned size = CountElements(source, ' ');
     dest.Resize(size);
-    
+
     bool inSpace = true;
     unsigned index = 0;
     unsigned value = 0;
-    
+
     // Parse values
     const char* ptr = source;
     while (*ptr)
@@ -576,10 +576,10 @@ void StringToBuffer(PODVector<unsigned char>& dest, const char* source)
             dest[index++] = value;
             inSpace = true;
         }
-        
+
         ++ptr;
     }
-    
+
     // Write the final value
     if (!inSpace && index < size)
         dest[index] = value;
@@ -593,28 +593,28 @@ unsigned GetStringListIndex(const String& value, const String* strings, unsigned
 unsigned GetStringListIndex(const char* value, const String* strings, unsigned defaultIndex, bool caseSensitive)
 {
     unsigned i = 0;
-    
+
     while (!strings[i].Empty())
     {
         if (!strings[i].Compare(value, caseSensitive))
             return i;
         ++i;
     }
-    
+
     return defaultIndex;
 }
 
 unsigned GetStringListIndex(const char* value, const char** strings, unsigned defaultIndex, bool caseSensitive)
 {
     unsigned i = 0;
-    
+
     while (strings[i])
     {
         if (!String::Compare(value, strings[i], caseSensitive))
             return i;
         ++i;
     }
-    
+
     return defaultIndex;
 }
 

+ 23 - 23
Source/Urho3D/Core/Timer.cpp

@@ -71,19 +71,19 @@ void Time::BeginFrame(float timeStep)
     ++frameNumber_;
     if (!frameNumber_)
         ++frameNumber_;
-    
+
     timeStep_ = timeStep;
-    
+
     Profiler* profiler = GetSubsystem<Profiler>();
     if (profiler)
         profiler->BeginFrame();
-    
+
     {
         PROFILE(BeginFrame);
-        
+
         // Frame begin event
         using namespace BeginFrame;
-        
+
         VariantMap& eventData = GetEventDataMap();
         eventData[P_FRAMENUMBER] = frameNumber_;
         eventData[P_TIMESTEP] = timeStep_;
@@ -95,11 +95,11 @@ void Time::EndFrame()
 {
     {
         PROFILE(EndFrame);
-        
+
         // Frame end event
         SendEvent(E_ENDFRAME);
     }
-    
+
     Profiler* profiler = GetSubsystem<Profiler>();
     if (profiler)
         profiler->EndFrame();
@@ -110,9 +110,9 @@ void Time::SetTimerPeriod(unsigned mSec)
     #ifdef WIN32
     if (timerPeriod_ > 0)
         timeEndPeriod(timerPeriod_);
-    
+
     timerPeriod_ = mSec;
-    
+
     if (timerPeriod_ > 0)
         timeBeginPeriod(timerPeriod_);
     #endif
@@ -126,13 +126,13 @@ float Time::GetElapsedTime()
 unsigned Time::GetSystemTime()
 {
     #ifdef WIN32
-    unsigned currentTime = timeGetTime();
+    unsigned currentTime = (unsigned)timeGetTime();
     #else
     struct timeval time;
     gettimeofday(&time, NULL);
-    unsigned currentTime = time.tv_sec * 1000 + time.tv_usec / 1000;
+    unsigned currentTime = (unsigned)(time.tv_sec * 1000 + time.tv_usec / 1000);
     #endif
-    
+
     return currentTime;
 }
 
@@ -166,28 +166,28 @@ Timer::Timer()
 unsigned Timer::GetMSec(bool reset)
 {
     #ifdef WIN32
-    unsigned currentTime = timeGetTime();
+    unsigned currentTime = (unsigned)timeGetTime();
     #else
     struct timeval time;
     gettimeofday(&time, NULL);
-    unsigned currentTime = time.tv_sec * 1000 + time.tv_usec / 1000;
+    unsigned currentTime = (unsigned)(time.tv_sec * 1000 + time.tv_usec / 1000);
     #endif
-    
+
     unsigned elapsedTime = currentTime - startTime_;
     if (reset)
         startTime_ = currentTime;
-    
+
     return elapsedTime;
 }
 
 void Timer::Reset()
 {
     #ifdef WIN32
-    startTime_ = timeGetTime();
+    startTime_ = (unsigned)timeGetTime();
     #else
     struct timeval time;
     gettimeofday(&time, NULL);
-    startTime_ = time.tv_sec * 1000 + time.tv_usec / 1000;
+    startTime_ = (unsigned)(time.tv_sec * 1000 + time.tv_usec / 1000);
     #endif
 }
 
@@ -199,7 +199,7 @@ HiresTimer::HiresTimer()
 long long HiresTimer::GetUSec(bool reset)
 {
     long long currentTime;
-    
+
     #ifdef WIN32
     if (supported)
     {
@@ -214,16 +214,16 @@ long long HiresTimer::GetUSec(bool reset)
     gettimeofday(&time, NULL);
     currentTime = time.tv_sec * 1000000LL + time.tv_usec;
     #endif
-    
+
     long long elapsedTime = currentTime - startTime_;
-    
+
     // Correct for possible weirdness with changing internal frequency
     if (elapsedTime < 0)
         elapsedTime = 0;
-    
+
     if (reset)
         startTime_ = currentTime;
-    
+
     return (elapsedTime * 1000000LL) / frequency;
 }
 

+ 2 - 3
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -137,7 +137,6 @@ static const unsigned glFillMode[] =
     GL_LINE,
     GL_POINT
 };
-#endif
 
 static const unsigned glStencilOps[] =
 {
@@ -147,6 +146,7 @@ static const unsigned glStencilOps[] =
     GL_INCR_WRAP,
     GL_DECR_WRAP
 };
+#endif
 
 // Remap vertex attributes on OpenGL so that all usually needed attributes including skinning fit to the first 8.
 // This avoids a skinning bug on GLES2 devices which only support 8.
@@ -2721,9 +2721,8 @@ void Graphics::CheckFeatureSupport()
     lightPrepassSupport_ = false;
     deferredSupport_ = false;
     
-    int numSupportedRTs = 1;
-    
     #ifndef GL_ES_VERSION_2_0
+    int numSupportedRTs = 1;
     if (gl3Support)
     {
         // Work around GLEW failure to check extensions properly from a GL3 context

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

@@ -284,10 +284,10 @@ bool Texture3D::SetData(unsigned level, int x, int y, int z, int width, int heig
     
     graphics_->SetTextureForUpdate(this);
     
+    #ifndef GL_ES_VERSION_2_0
     bool wholeLevel = x == 0 && y == 0 && z == 0 && width == levelWidth && height == levelHeight && depth == levelDepth;
     unsigned format = GetSRGB() ? GetSRGBFormat(format_) : format_;
     
-    #ifndef GL_ES_VERSION_2_0
     if (!IsCompressed())
     {
         if (wholeLevel)

+ 17 - 9
Source/Urho3D/IO/File.cpp

@@ -123,7 +123,7 @@ bool File::Open(const String& fileName, FileMode mode)
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
     if (fileSystem && !fileSystem->CheckAccess(GetPath(fileName)))
     {
-        LOGERROR("Access denied to " + fileName);
+        LOGERRORF("Access denied to %s", fileName.CString());
         return false;
     }
 
@@ -139,7 +139,7 @@ bool File::Open(const String& fileName, FileMode mode)
         assetHandle_ = SDL_RWFromFile(fileName.Substring(5).CString(), "rb");
         if (!assetHandle_)
         {
-            LOGERROR("Could not open asset file " + fileName);
+            LOGERRORF("Could not open asset file %s", fileName.CString());
             return false;
         }
         else
@@ -163,7 +163,7 @@ bool File::Open(const String& fileName, FileMode mode)
         LOGERROR("Could not open file with empty name");
         return false;
     }
-    
+
     #ifdef WIN32
     handle_ = _wfopen(GetWideNativePath(fileName).CString(), openMode[mode]);
     #else
@@ -179,10 +179,10 @@ bool File::Open(const String& fileName, FileMode mode)
         handle_ = fopen(GetNativePath(fileName).CString(), openMode[mode + 1]);
         #endif
     }
-    
+
     if (!handle_)
     {
-        LOGERROR("Could not open file " + fileName);
+        LOGERRORF("Could not open file %s", fileName.CString());
         return false;
     }
 
@@ -196,8 +196,16 @@ bool File::Open(const String& fileName, FileMode mode)
     writeSyncNeeded_ = false;
 
     fseek((FILE*)handle_, 0, SEEK_END);
-    size_ = ftell((FILE*)handle_);
+    long size = ftell((FILE*)handle_);
     fseek((FILE*)handle_, 0, SEEK_SET);
+    if (size > M_MAX_UNSIGNED)
+    {
+        LOGERRORF("Could not open file %s which is larger than 4GB", fileName.CString());
+        Close();
+        size_ = 0;
+        return false;
+    }
+    size_ = (unsigned)size;
     return true;
 }
 
@@ -232,7 +240,7 @@ bool File::Open(PackageFile* package, const String& fileName)
     compressed_ = package->IsCompressed();
     readSyncNeeded_ = false;
     writeSyncNeeded_ = false;
-    
+
     fseek((FILE*)handle_, offset_, SEEK_SET);
     return true;
 }
@@ -333,7 +341,7 @@ unsigned File::Read(void* dest, unsigned size)
         fseek((FILE*)handle_, position_ + offset_, SEEK_SET);
         readSyncNeeded_ = false;
     }
-    
+
     size_t ret = fread(dest, size, 1, (FILE*)handle_);
     if (ret != 1)
     {
@@ -427,7 +435,7 @@ unsigned File::Write(const void* data, unsigned size)
         fseek((FILE*)handle_, position_ + offset_, SEEK_SET);
         writeSyncNeeded_ = false;
     }
-    
+
     if (fwrite(data, size, 1, (FILE*)handle_) != 1)
     {
         // Return to the position where the write began

+ 5 - 5
Source/Urho3D/IO/RWOpsWrapper.h

@@ -47,14 +47,14 @@ public:
 
     /// Return the RWOps structure.
     SDL_RWops* GetRWOps() { return &ops_; }
-    
+
 private:
     /// Return data size of the object.
     static Sint64 Size(SDL_RWops* context)
     {
         T* object = reinterpret_cast<T*>(context->hidden.unknown.data1);
         Deserializer* des = dynamic_cast<Deserializer*>(object);
-        return des ? des->GetSize() : 0;
+        return des ? (Sint64)des->GetSize() : 0;
     }
 
     /// Seek within the object's data.
@@ -74,7 +74,7 @@ private:
         case RW_SEEK_CUR:
             des->Seek((unsigned)(des->GetPosition() + offset));
             break;
-            
+
         case RW_SEEK_END:
             des->Seek((unsigned)(des->GetSize() + offset));
             break;
@@ -98,7 +98,7 @@ private:
     {
         T* object = reinterpret_cast<T*>(context->hidden.unknown.data1);
         Deserializer* des = dynamic_cast<Deserializer*>(object);
-        return des ? des->Read(ptr, size * maxNum) / size : 0;
+        return des ? (size_t)(des->Read(ptr, size * maxNum) / size) : 0;
     }
 
     /// Write to the object. Return number of "packets" written.
@@ -106,7 +106,7 @@ private:
     {
         T* object = reinterpret_cast<T*>(context->hidden.unknown.data1);
         Serializer* ser = dynamic_cast<Serializer*>(object);
-        return ser ? ser->Write(ptr, size * maxNum) / size : 0;
+        return ser ? (size_t)(ser->Write(ptr, size * maxNum) / size) : 0;
     }
 
     /// SDL RWOps structure associated with the object.

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

@@ -200,6 +200,7 @@ Input::Input(Context* context) :
     Object(context),
     mouseButtonDown_(0),
     mouseButtonPress_(0),
+    lastVisibleMousePosition_(MOUSE_POSITION_OFFSCREEN),
     mouseMoveWheel_(0),
     windowID_(0),
     toggleFullscreen_(true),
@@ -211,7 +212,6 @@ Input::Input(Context* context) :
     emscriptenExitingPointerLock_(false),
     emscriptenEnteredPointerLock_(false),
 #endif
-    lastVisibleMousePosition_(MOUSE_POSITION_OFFSCREEN),
     touchEmulation_(false),
     inputFocus_(false),
     minimized_(false),

+ 1 - 1
Source/Urho3D/LuaScript/LuaScriptInstance.cpp

@@ -504,7 +504,7 @@ void LuaScriptInstance::GetScriptAttributes()
     Vector<String> names;
     if (lua_istable(luaState_, -1))
     {
-        int length = lua_objlen(luaState_, -1);
+        size_t length = lua_objlen(luaState_, -1);
         for (int i = 1; i <= length; ++i)
         {
             lua_pushinteger(luaState_, i);

+ 6 - 6
Source/Urho3D/LuaScript/ToluaUtils.cpp

@@ -64,7 +64,7 @@ template<> int ToluaIsVector<String>(lua_State* L, int lo, const char* type, int
 {
     if (lua_istable(L, lo))
     {
-        int length = lua_objlen(L, lo);
+        size_t length = lua_objlen(L, lo);
         for (int i = 1; i <= length; ++i)
         {
             lua_pushinteger(L, i);
@@ -100,7 +100,7 @@ template<> void* ToluaToVector<String>(lua_State* L, int narg, void* def)
     static Vector<String> result;
     result.Clear();
 
-    int length = lua_objlen(L, narg);
+    size_t length = lua_objlen(L, narg);
     for (int i = 1; i <= length; ++i)
     {
         lua_pushinteger(L, i);
@@ -149,7 +149,7 @@ template<> int ToluaIsPODVector<unsigned>(lua_State* L, int lo, const char* type
 {
     if (lua_istable(L, lo))
     {
-        int length = lua_objlen(L, lo);
+        size_t length = lua_objlen(L, lo);
         for (int i = 1; i <= length; ++i)
         {
             lua_pushinteger(L, i);
@@ -181,7 +181,7 @@ template<> int ToluaIsPODVector<Vector2>(lua_State* L, int lo, const char* type,
 {
     if (lua_istable(L, lo))
     {
-        int length = lua_objlen(L, lo);
+        size_t length = lua_objlen(L, lo);
         for (int i = 1; i <= length; ++i)
         {
             lua_pushinteger(L, i);
@@ -212,7 +212,7 @@ template<> void* ToluaToPODVector<unsigned>(lua_State* L, int narg, void* def)
     static PODVector<unsigned> result;
     result.Clear();
 
-    int length = lua_objlen(L, narg);
+    size_t length = lua_objlen(L, narg);
     for (int i = 1; i <= length; ++i)
     {
         lua_pushinteger(L, i);
@@ -243,7 +243,7 @@ template<> void* ToluaToPODVector<Vector2>(lua_State* L, int narg, void* def)
 
     tolua_Error tolua_err;
 
-    int length = lua_objlen(L, narg);
+    size_t length = lua_objlen(L, narg);
     for (int i = 1; i <= length; ++i)
     {
         lua_pushinteger(L, i);

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

@@ -123,7 +123,7 @@ void Network::HandleMessage(kNet::MessageConnection *source, kNet::packet_id_t p
     Connection* connection = GetConnection(source);
     if (connection)
     {
-        MemoryBuffer msg(data, numBytes);
+        MemoryBuffer msg(data, (unsigned)numBytes);
         if (connection->ProcessMessage(msgId, msg))
             return;
         
@@ -152,7 +152,7 @@ u32 Network::ComputeContentID(kNet::message_id_t msgId, const char* data, size_t
     case MSG_COMPONENTLATESTDATA:
         {
             // Return the node or component ID, which is first in the message
-            MemoryBuffer msg(data, numBytes);
+            MemoryBuffer msg(data, (unsigned)numBytes);
             return msg.ReadNetID();
         }
         

+ 2 - 3
Source/Urho3D/Resource/JSONFile.cpp

@@ -93,9 +93,8 @@ bool JSONFile::Save(Serializer& dest, const String& indendation) const
     writer.SetIndent(!indendation.Empty() ?  indendation.Front() : '\0', indendation.Length());
 
     document_->Accept(writer);
-    dest.Write(buffer.GetString(), buffer.GetSize());
-
-    return true;
+    unsigned size = (unsigned)buffer.GetSize();
+    return dest.Write(buffer.GetString(), size) == size;
 }
 
 JSONValue JSONFile::CreateRoot(JSONValueType valueType)

+ 2 - 2
Source/Urho3D/Resource/XMLElement.cpp

@@ -920,7 +920,7 @@ XMLElement XPathResultSet::FirstResult()
 
 unsigned XPathResultSet::Size() const
 {
-    return resultSet_ ? resultSet_->size() : 0;
+    return resultSet_ ? (unsigned)resultSet_->size() : 0;
 }
 
 bool XPathResultSet::Empty() const
@@ -1069,7 +1069,7 @@ String XPathQuery::EvaluateToString(XMLElement element) const
 
     const pugi::xml_node& node = element.GetXPathNode() ? element.GetXPathNode()->node(): pugi::xml_node(element.GetNode());
     String result;
-    result.Reserve(query_->evaluate_string(0, 0, node));    // First call get the size
+    result.Reserve((unsigned)query_->evaluate_string(0, 0, node));    // First call get the size
     query_->evaluate_string(const_cast<pugi::char_t*>(result.CString()), result.Capacity(), node);  // Second call get the actual string
     return result;
 }

+ 2 - 2
Source/Urho3D/Resource/XMLFile.cpp

@@ -52,7 +52,7 @@ public:
     /// Write bytes to output.
     void write(const void* data, size_t size)
     {
-        if (dest_.Write(data, size) != size)
+        if (dest_.Write(data, (unsigned)size) != size)
             success_ = false;
     }
 
@@ -156,7 +156,7 @@ bool XMLFile::FromString(const String& source)
 {
     if (source.Empty())
         return false;
-    
+
     MemoryBuffer buffer(source.CString(), source.Length());
     return Load(buffer);
 }

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

@@ -126,7 +126,7 @@ void Button::OnClickEnd(const IntVector2& position, const IntVector2& screenPosi
     }
 }
 
-void Button::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
+void Button::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers, Cursor* cursor)
 {
     SetPressed(true);
 }

+ 1 - 1
Source/Urho3D/UI/Button.h

@@ -49,7 +49,7 @@ public:
     /// React to mouse click end.
     virtual void OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement);
     /// React to mouse drag motion.
-    virtual void OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
+    virtual void OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers, Cursor* cursor);
     /// React to a key press.
     virtual void OnKey(int key, int buttons, int qualifiers);
 

+ 2 - 1
Source/Urho3D/UI/Cursor.cpp

@@ -52,6 +52,7 @@ static const char* shapeNames[] =
 };
 
 /// OS cursor shape lookup table matching cursor shape enumeration
+#if !defined(ANDROID) && !defined(IOS)
 static const int osCursorLookup[CS_MAX_SHAPES] =
 {
     SDL_SYSTEM_CURSOR_ARROW,    // CS_NORMAL
@@ -67,6 +68,7 @@ static const int osCursorLookup[CS_MAX_SHAPES] =
     SDL_SYSTEM_CURSOR_WAIT,   // CS_BUSY
     SDL_SYSTEM_CURSOR_WAITARROW // CS_BUSY_ARROW
 };
+#endif
 
 extern const char* UI_CATEGORY;
 
@@ -211,7 +213,6 @@ void Cursor::SetUseSystemShapes(bool enable)
 
 void Cursor::SetShapesAttr(const VariantVector& value)
 {
-    unsigned index = 0;
     if (!value.Size())
         return;
 

+ 2 - 2
Source/Urho3D/UI/Cursor.h

@@ -80,12 +80,12 @@ struct URHO3D_API CursorShapeInfo
     IntRect imageRect_;
     /// Hotspot coordinates.
     IntVector2 hotSpot_;
-    /// System cursor index.
-    int systemCursor_;
     /// OS cursor.
     SDL_Cursor* osCursor_;
     /// Whether the OS cursor is system defined.
     bool systemDefined_;
+    /// System cursor index.
+    int systemCursor_;
 };
 
 /// Mouse cursor %UI element.

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

@@ -53,10 +53,10 @@ ScrollView::ScrollView(Context* context) :
     scrollSnapEpsilon_(M_EPSILON),
     scrollTouchDown_(false),
     barScrolling_(false),
-    scrollChildrenDisable_(false),
     autoDisableChildren_(false),
-    autoDisableThreshold_(25.0f),
-    touchDistanceSum_(0.0f)
+    scrollChildrenDisable_(false),
+    touchDistanceSum_(0.0f),
+    autoDisableThreshold_(25.0f)
 {
     clipChildren_ = true;
     SetEnabled(true);

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

@@ -88,8 +88,6 @@ UI::UI(Context* context) :
     lastMouseButtons_(0),
     qualifiers_(0),
     maxFontTextureSize_(DEFAULT_FONT_TEXTURE_MAX_SIZE),
-    dragElementsCount_(0),
-    dragConfirmedCount_(0),
     initialized_(false),
     usingTouchInput_(false),
     #ifdef WIN32
@@ -105,7 +103,10 @@ UI::UI(Context* context) :
     #endif
     useMutableGlyphs_(false),
     forceAutoHint_(false),
-    nonModalBatchSize_(0)
+    uiRendered_(false),
+    nonModalBatchSize_(0),
+    dragElementsCount_(0),
+    dragConfirmedCount_(0)
 {
     rootElement_->SetTraversalMode(TM_DEPTH_FIRST);
     rootModalElement_->SetTraversalMode(TM_DEPTH_FIRST);

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

@@ -117,6 +117,8 @@ UIElement::UIElement(Context* context) :
     indentSpacing_(16),
     position_(IntVector2::ZERO),
     positionDirty_(true),
+    dragButtonCombo_(0),
+    dragButtonCount_(0),
     size_(IntVector2::ZERO),
     minSize_(IntVector2::ZERO),
     maxSize_(M_MAX_INT, M_MAX_INT),
@@ -129,9 +131,7 @@ UIElement::UIElement(Context* context) :
     sortOrderDirty_(false),
     colorGradient_(false),
     traversalMode_(TM_BREADTH_FIRST),
-    elementEventSender_(false),
-    dragButtonCombo_(0),
-    dragButtonCount_(0)
+    elementEventSender_(false)
 {
     SetEnabled(false);
 }

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

@@ -51,8 +51,8 @@ Renderer2D::Renderer2D(Context* context) :
     indexBuffer_(new IndexBuffer(context_)),
     vertexBuffer_(new VertexBuffer(context_)),
     orderDirty_(true),
-    frustum_(0),
-    geometryCount_(0)
+    geometryCount_(0),
+    frustum_(0)
 {
     frame_.frameNumber_ = 0;
     SubscribeToEvent(E_BEGINVIEWUPDATE, HANDLER(Renderer2D, HandleBeginViewUpdate));