Pārlūkot izejas kodu

Fix warnings in samples

1vanK 3 gadi atpakaļ
vecāks
revīzija
22ded933e6

+ 1 - 3
Source/Samples/03_Sprites/Sprites.cpp

@@ -92,10 +92,8 @@ void Sprites::MoveSprites(float timeStep)
     auto height = (float)graphics->GetHeight();
 
     // Go through all sprites
-    for (unsigned i = 0; i < sprites_.Size(); ++i)
+    for (const SharedPtr<Sprite>& sprite : sprites_)
     {
-        Sprite* sprite = sprites_[i];
-
         // Rotate
         float newRot = sprite->GetRotation() + timeStep * 30.0f;
         sprite->SetRotation(newRot);

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

@@ -279,13 +279,13 @@ void Billboards::AnimateScene(float timeStep)
     const float BILLBOARD_ROTATION_SPEED = 50.0f;
 
     // Rotate the lights around the world Y-axis
-    for (unsigned i = 0; i < lightNodes.Size(); ++i)
-        lightNodes[i]->Rotate(Quaternion(0.0f, LIGHT_ROTATION_SPEED * timeStep, 0.0f), TS_WORLD);
+    for (Node* lightNode : lightNodes)
+        lightNode->Rotate(Quaternion(0.0f, LIGHT_ROTATION_SPEED * timeStep, 0.0f), TS_WORLD);
 
     // Rotate the individual billboards within the billboard sets, then recommit to make the changes visible
-    for (unsigned i = 0; i < billboardNodes.Size(); ++i)
+    for (i32 i = 0; i < billboardNodes.Size(); ++i)
     {
-        auto* billboardObject = billboardNodes[i]->GetComponent<BillboardSet>();
+        BillboardSet* billboardObject = billboardNodes[i]->GetComponent<BillboardSet>();
 
         for (unsigned j = 0; j < billboardObject->GetNumBillboards(); ++j)
         {

+ 2 - 2
Source/Samples/13_Ragdolls/CreateRagdoll.cpp

@@ -83,9 +83,9 @@ void CreateRagdoll::HandleNodeCollision(StringHash eventType, VariantMap& eventD
             Vector2(90.0f, 0.0f), Vector2::ZERO);
 
         // Disable keyframe animation from all bones so that they will not interfere with the ragdoll
-        auto* model = GetComponent<AnimatedModel>();
+        AnimatedModel* model = GetComponent<AnimatedModel>();
         Skeleton& skeleton = model->GetSkeleton();
-        for (unsigned i = 0; i < skeleton.GetNumBones(); ++i)
+        for (i32 i = 0; i < skeleton.GetNumBones(); ++i)
             skeleton.GetBone(i)->animated_ = false;
 
         // Finally remove self from the scene node. Note that this must be the last operation performed in the function

+ 1 - 1
Source/Samples/15_Navigation/Navigation.cpp

@@ -484,7 +484,7 @@ void Navigation::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventD
 
         if (currentPath_.Size() > 1)
         {
-            for (unsigned i = 0; i < currentPath_.Size() - 1; ++i)
+            for (i32 i = 0; i < currentPath_.Size() - 1; ++i)
                 debug->AddLine(currentPath_[i] + bias, currentPath_[i + 1] + bias, Color(1.0f, 1.0f, 1.0f));
         }
     }

+ 2 - 2
Source/Samples/16_Chat/Chat.cpp

@@ -147,8 +147,8 @@ void Chat::ShowChatText(const String& row)
 
     // Concatenate all the rows in history
     String allRows;
-    for (unsigned i = 0; i < chatHistory_.Size(); ++i)
-        allRows += chatHistory_[i] + "\n";
+    for (const String& row : chatHistory_)
+        allRows += row + "\n";
 
     chatHistoryText_->SetText(allRows);
 }

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

@@ -397,15 +397,14 @@ void SceneReplication::HandlePhysicsPreStep(StringHash eventType, VariantMap& ev
     {
         const Vector<SharedPtr<Connection>>& connections = network->GetClientConnections();
 
-        for (unsigned i = 0; i < connections.Size(); ++i)
+        for (Connection* connection : connections)
         {
-            Connection* connection = connections[i];
             // Get the object this connection is controlling
             Node* ballNode = serverObjects_[connection];
             if (!ballNode)
                 continue;
 
-            auto* body = ballNode->GetComponent<RigidBody>();
+            RigidBody* body = ballNode->GetComponent<RigidBody>();
 
             // Get the last controls sent by the client
             const Controls& controls = connection->GetControls();

+ 2 - 2
Source/Samples/20_HugeObjectCount/HugeObjectCount.cpp

@@ -220,8 +220,8 @@ void HugeObjectCount::AnimateObjects(float timeStep)
     // Rotate about the Z axis (roll)
     Quaternion rotateQuat(ROTATE_SPEED * timeStep, Vector3::FORWARD);
 
-    for (unsigned i = 0; i < boxNodes_.Size(); ++i)
-        boxNodes_[i]->Rotate(rotateQuat);
+    for (const SharedPtr<Node>& boxNode : boxNodes_)
+        boxNode->Rotate(rotateQuat);
 }
 
 void HugeObjectCount::HandleUpdate(StringHash eventType, VariantMap& eventData)

+ 3 - 3
Source/Samples/34_DynamicGeometry/DynamicGeometry.cpp

@@ -107,10 +107,10 @@ void DynamicGeometry::CreateScene()
 
         // Detect duplicate vertices to allow seamless animation
         vertexDuplicates_.Resize(originalVertices_.Size());
-        for (unsigned i = 0; i < originalVertices_.Size(); ++i)
+        for (i32 i = 0; i < originalVertices_.Size(); ++i)
         {
             vertexDuplicates_[i] = i; // Assume not a duplicate
-            for (unsigned j = 0; j < i; ++j)
+            for (i32 j = 0; j < i; ++j)
             {
                 if (originalVertices_[i].Equals(originalVertices_[j]))
                 {
@@ -326,7 +326,7 @@ void DynamicGeometry::AnimateObjects(float timeStep)
     time_ += timeStep * 100.0f;
 
     // Repeat for each of the cloned vertex buffers
-    for (unsigned i = 0; i < animatingBuffers_.Size(); ++i)
+    for (i32 i = 0; i < animatingBuffers_.Size(); ++i)
     {
         float startPhase = time_ + i * 30.0f;
         VertexBuffer* buffer = animatingBuffers_[i];

+ 1 - 1
Source/Samples/34_DynamicGeometry/DynamicGeometry.h

@@ -65,7 +65,7 @@ private:
     /// Original vertex positions for the sphere model.
     Vector<Vector3> originalVertices_;
     /// If the vertices are duplicates, indices to the original vertices (to allow seamless animation.)
-    Vector<unsigned> vertexDuplicates_;
+    Vector<i32> vertexDuplicates_;
     /// Animation flag.
     bool animate_;
     /// Animation's elapsed time.

+ 1 - 2
Source/Samples/39_CrowdNavigation/CrowdNavigation.cpp

@@ -275,9 +275,8 @@ void CrowdNavigation::CreateMushroom(const Vector3& pos)
 void CrowdNavigation::CreateBoxOffMeshConnections(DynamicNavigationMesh* navMesh, Node* boxGroup)
 {
     const Vector<SharedPtr<Node>>& boxes = boxGroup->GetChildren();
-    for (unsigned i=0; i < boxes.Size(); ++i)
+    for (const SharedPtr<Node>& box : boxes)
     {
-        Node* box = boxes[i];
         Vector3 boxPos = box->GetPosition();
         float boxHalfSize = box->GetScale().x_ / 2;
 

+ 1 - 1
Source/Samples/45_InverseKinematics/InverseKinematics.cpp

@@ -139,7 +139,7 @@ void InverseKinematics::CreateScene()
 
     // Set an initial position for the camera scene node above the plane
     cameraNode_->SetPosition(Vector3(0, 0, -4));
-    cameraRotateNode_->SetPosition(Vector3(0, 0.4, 0));
+    cameraRotateNode_->SetPosition(Vector3(0, 0.4f, 0));
     pitch_ = 20;
     yaw_ = 50;
 }

+ 2 - 2
Source/Samples/52_NATPunchtrough/NATPunchtrough.cpp

@@ -162,8 +162,8 @@ void NATPunchtrough::ShowLogMessage(const String& row)
 
     // Concatenate all the rows in history
     String allRows;
-    for (unsigned i = 0; i < logHistory_.Size(); ++i)
-        allRows += logHistory_[i] + "\n";
+    for (const String& row : logHistory_)
+        allRows += row + "\n";
 
     logHistoryText_->SetText(allRows);
 }

+ 1 - 1
Source/Samples/54_WindowSettingsDemo/WindowSettingsDemo.cpp

@@ -232,7 +232,7 @@ void WindowSettingsDemo::InitSettings()
             return;
 
         const auto& resolutions = graphics->GetResolutions(monitor);
-        const unsigned selectedResolution = resolutionControl_->GetSelection();
+        const i32 selectedResolution = resolutionControl_->GetSelection();
         if (selectedResolution >= resolutions.Size())
             return;
 

+ 2 - 2
Source/Samples/Utilities2D/Mover.cpp

@@ -52,8 +52,8 @@ Vector<unsigned char> Mover::GetPathAttr() const
 {
     VectorBuffer buffer;
 
-    for (unsigned i = 0; i < path_.Size(); ++i)
-        buffer.WriteVector2(path_[i]);
+    for (const Vector2& point : path_)
+        buffer.WriteVector2(point);
 
     return buffer.GetBuffer();
 }