Browse Source

Removed errorprone string addition operations.

Lasse Öörni 14 years ago
parent
commit
f1010c683e

+ 0 - 30
Engine/Container/String.cpp

@@ -138,36 +138,6 @@ String& String::operator += (bool rhs)
     return *this += String(rhs);
 }
 
-String String::operator + (int rhs) const
-{
-    return *this + String(rhs);
-}
-
-String String::operator + (short rhs) const
-{
-    return *this + String(rhs);
-}
-
-String String::operator + (unsigned rhs) const
-{
-    return *this + String(rhs);
-}
-
-String String::operator + (unsigned short rhs) const
-{
-    return *this + String(rhs);
-}
-
-String String::operator + (float rhs) const
-{
-    return *this + String(rhs);
-}
-
-String String::operator + (bool rhs) const
-{
-    return *this + String(rhs);
-}
-
 void String::ReplaceInPlace(char replaceThis, char replaceWith)
 {
     for (unsigned i = 0; i < length_; ++i)

+ 0 - 15
Engine/Container/StringBase.h

@@ -214,21 +214,6 @@ public:
         return ret;
     }
     
-    /// Add an integer
-    String operator + (int rhs) const;
-    /// Add a short integer
-    String operator + (short rhs) const;
-    /// Add an unsigned integer
-    String operator + (unsigned rhs) const;
-    /// Add a short unsigned integer
-    String operator + (unsigned short rhs) const;
-    /// Add a float
-    String operator + (float rhs) const;
-    /// Add a bool
-    String operator + (bool rhs) const;
-    /// Add an arbitrary type
-    template <class T> String operator + (const T& rhs) const { return *this + rhs.ToString(); }
-    
     /// Test for equality with another string
     bool operator == (const String& rhs) const
     {

+ 1 - 1
Engine/Engine/DebugHud.cpp

@@ -156,7 +156,7 @@ void DebugHud::Update(float timeStep)
             mode += "Off";
         
         int shadowMapSize = renderer->GetShadowMapSize();
-        mode += " Size:" + shadowMapSize;
+        mode += " Size:" + String(shadowMapSize);
         
         bool shadowMapHiresDepth = renderer->GetShadowMapHiresDepth();
         mode += " Depth:";

+ 1 - 1
Engine/Engine/Engine.cpp

@@ -335,7 +335,7 @@ void Engine::DumpResources()
         if (num)
         {
             LOGRAW("Resource type " + i->second_.resources_.Begin()->second_->GetTypeName() +
-                ": count " + num + " memory use " + memoryUse + "\n");
+                ": count " + num + " memory use " + String(memoryUse) + "\n");
         }
     }
     

+ 1 - 1
Engine/Graphics/Graphics.cpp

@@ -1760,7 +1760,7 @@ bool Graphics::BeginImmediate(PrimitiveType type, unsigned vertexCount, unsigned
     VertexBuffer* buffer = immediatevertexBuffer_[elementMask];
     if (buffer->GetVertexCount() < newSize)
     {
-        LOGDEBUG("Resized immediate vertex buffer to " + newSize);
+        LOGDEBUG("Resized immediate vertex buffer to " + String(newSize));
         buffer->SetSize(newSize, elementMask);
         immediateVertexBufferPos_[elementMask] = 0;
     }

+ 2 - 2
Engine/Graphics/Renderer.cpp

@@ -1232,13 +1232,13 @@ bool Renderer::ResizeInstancingBuffer(unsigned numInstances)
     
     if (!instancingBuffer_->SetSize(newSize, INSTANCING_BUFFER_MASK, true))
     {
-        LOGERROR("Failed to resize instancing buffer to " + newSize);
+        LOGERROR("Failed to resize instancing buffer to " + String(newSize));
         // If failed, try to restore the old size
         instancingBuffer_->SetSize(oldSize, INSTANCING_BUFFER_MASK, true);
         return false;
     }
     
-    LOGDEBUG("Resized instancing buffer to " + newSize);
+    LOGDEBUG("Resized instancing buffer to " + String(newSize));
     return true;
 }
 

+ 6 - 6
Engine/Network/Client.cpp

@@ -194,8 +194,8 @@ String Client::GetFileTransferStatus() const
     
     for (Map<StringHash, FileTransfer>::ConstIterator i = fileTransfers_.Begin(); i != fileTransfers_.End(); ++i)
     {
-        String line = i->second_.fileName_ + " " + i->second_.bytesReceived_ + "/" + i->second_.size_
-            + " (" + String((int)(((float)i->second_.bytesReceived_ / (float)i->second_.size_) * 100.0f + 0.5f)) + "%)\n";
+        String line = i->second_.fileName_ + " " + String(i->second_.bytesReceived_) + "/" + String(i->second_.size_) +
+            " (" + String((int)(((float)i->second_.bytesReceived_ / (float)i->second_.size_) * 100.0f + 0.5f)) + "%)\n";
         ret += line;
     }
     
@@ -387,8 +387,8 @@ void Client::HandleTransferData(VectorBuffer& packet)
     {
         if (transfer.bytesReceived_ != transfer.size_)
         {
-            LOGERROR("Transfer of file " + transfer.fileName_ + " finished, expected " + transfer.size_ +
-                " bytes but got " + transfer.bytesReceived_);
+            LOGERROR("Transfer of file " + transfer.fileName_ + " finished, expected " + String(transfer.size_) +
+                " bytes but got " + String(transfer.bytesReceived_));
             
             using namespace FileTransferFailed;
             
@@ -401,7 +401,7 @@ void Client::HandleTransferData(VectorBuffer& packet)
         {
             float totalTime = transfer.receiveTimer_.GetMSec(true) * 0.001f;
             LOGINFO("Transfer of file " + transfer.fileName_ + " completed in " +
-                totalTime + " seconds, speed " + transfer.size_ / totalTime + " bytes/sec");
+                String(totalTime) + " seconds, speed " + String(transfer.size_ / totalTime) + " bytes/sec");
             using namespace FileTransferCompleted;
             
             VariantMap eventData;
@@ -708,7 +708,7 @@ bool Client::RequestFile(const String& fileName, unsigned size, unsigned checksu
     serverConnection_->SendReliable(packet);
     
     fileTransfers_[nameHash] = newTransfer;
-    LOGINFO("Started transfer of file " + fileName + ", " + size + " bytes");
+    LOGINFO("Started transfer of file " + fileName + ", " + String(size) + " bytes");
     return true;
 }
 

+ 1 - 1
Engine/Network/Connection.cpp

@@ -256,7 +256,7 @@ void Connection::ClearRemoteEvents()
 String Connection::GetIdentity() const
 {
     if (peer_)
-        return peer_->GetAddress() + ":" + peer_->GetPort();
+        return peer_->GetAddress() + ":" + String(peer_->GetPort());
     else
         return "Unknown";
 }

+ 3 - 3
Engine/Network/Network.cpp

@@ -153,12 +153,12 @@ bool Network::StartServer(unsigned short port)
         enet_host_compress_with_range_coder(serverHost_);
     else
     {
-        LOGERROR("Failed to start server on port " + port);
+        LOGERROR("Failed to start server on port " + String(port));
         return false;
     }
     
 
-    LOGINFO("Started server on port " + port);
+    LOGINFO("Started server on port " + String(port));
     return true;
 }
 
@@ -193,7 +193,7 @@ Peer* Network::Connect(const String& address, unsigned short port)
     enetPeer->data = newPeer.GetPtr();
     peers_.Push(newPeer);
     
-    LOGINFO("Connecting to " + address + ":" + port);
+    LOGINFO("Connecting to " + address + ":" + String(port));
     return newPeer;
 }
 

+ 2 - 2
Engine/Network/Peer.cpp

@@ -230,7 +230,7 @@ void Peer::OnConnect()
         eventData[P_PEER] = (void*)this;
         SendEvent(E_PEERCONNECTED, eventData);
         
-        LOGINFO(address_ + ":" + port_ + " connected");
+        LOGINFO(address_ + ":" + String(port_) + " connected");
     }
 }
 
@@ -250,7 +250,7 @@ void Peer::OnDisconnect()
         SendEvent(E_PEERDISCONNECTED, eventData);
         
         if (!address_.Empty())
-            LOGINFO(address_ + ":" + port_ + " disconnected");
+            LOGINFO(address_ + ":" + String(port_) + " disconnected");
         else
             LOGINFO("Disconnected");
     }

+ 2 - 2
Engine/Physics/CollisionShape.cpp

@@ -844,7 +844,7 @@ void CollisionShape::CreateGeometry()
     case SHAPE_CONVEXHULL:
         {
             // Check the geometry cache
-            String id = model_->GetName() + "_" + geometryScale_ + "_" + lodLevel_;
+            String id = model_->GetName() + "_" + String(geometryScale_) + "_" + String(lodLevel_);
             if (shapeType_ == SHAPE_CONVEXHULL)
                 id += "_" + String(thickness_);
             
@@ -869,7 +869,7 @@ void CollisionShape::CreateGeometry()
     case SHAPE_HEIGHTFIELD:
         {
             // Check the geometry cache
-            String id = model_->GetName() + "_" + numPoints_ + "_" + thickness_ + "_" + lodLevel_;
+            String id = model_->GetName() + "_" + String(numPoints_) + "_" + String(thickness_) + "_" + String(lodLevel_);
             
             Map<String, SharedPtr<HeightfieldData> >& cache = physicsWorld_->GetHeightfieldCache();
             Map<String, SharedPtr<HeightfieldData> >::Iterator j = cache.Find(id);

+ 1 - 1
Engine/Scene/Scene.cpp

@@ -404,7 +404,7 @@ void Scene::NodeAdded(Node* node)
     Map<unsigned, Node*>::Iterator i = allNodes_.Find(id);
     if ((i != allNodes_.End()) && (i->second_ != node))
     {
-        LOGWARNING("Overwriting node with ID " + id);
+        LOGWARNING("Overwriting node with ID " + String(id));
         i->second_->SetScene(0);
         i->second_->SetOwner(0);
     }

+ 1 - 1
Engine/Script/Script.cpp

@@ -348,7 +348,7 @@ void Script::DumpAPI()
 
 void Script::MessageCallback(const asSMessageInfo* msg)
 {
-    String message = String(msg->section) + " (" + msg->row + "," + msg->col + ") " +
+    String message = String(msg->section) + " (" + String(msg->row) + "," + String(msg->col) + ") " +
         String(msg->message);
     
     if (logMode_ == LOGMODE_IMMEDIATE)

+ 1 - 1
Engine/UI/Font.cpp

@@ -143,7 +143,7 @@ const FontFace* Font::GetFace(int pointSize)
     if (error)
     {
         FT_Done_Face(face);
-        LOGERROR("Could not set font point size " + pointSize);
+        LOGERROR("Could not set font point size " + String(pointSize));
         return 0;
     }
     

+ 2 - 2
Tools/AssetImporter/AssetImporter.cpp

@@ -854,7 +854,7 @@ void BuildAndSaveAnimations(OutModel& model)
         aiAnimation* anim = model.animations_[i];
         String animName = FromAIString(anim->mName);
         if (animName.Empty())
-            animName = "Anim" + (i + 1);
+            animName = "Anim" + String(i + 1);
         String animOutName = GetPath(model.outName_) + GetFileName(model.outName_) + "_" + SanitateAssetName(animName) + ".ani";
         
         SharedPtr<Animation> outAnim(new Animation(context_));
@@ -862,7 +862,7 @@ void BuildAndSaveAnimations(OutModel& model)
         outAnim->SetAnimationName(animName);
         outAnim->SetLength((float)anim->mDuration * tickConversion);
         
-        PrintLine("Writing animation " + animName + " length " + outAnim->GetLength());
+        PrintLine("Writing animation " + animName + " length " + String(outAnim->GetLength()));
         Vector<AnimationTrack> tracks;
         for (unsigned j = 0; j < anim->mNumChannels; ++j)
         {

+ 2 - 2
Tools/OgreImporter/OgreImporter.cpp

@@ -486,7 +486,7 @@ void LoadMesh(const String& inputFileName, bool generateTangents, bool splitSubM
                     
                     // If still too many bones_ in one subgeometry, error
                     if (usedBoneMap.Size() > MAX_SKIN_MATRICES)
-                        ErrorExit("Too many bones_ in submesh " + (subMeshIndex + 1));
+                        ErrorExit("Too many bones in submesh " + String(subMeshIndex + 1));
                     
                     // Write mapping of vertex buffer bone indices to original bone indices
                     subGeometryLodLevel.boneMapping_.Resize(usedBoneMap.Size());
@@ -738,7 +738,7 @@ void LoadMesh(const String& inputFileName, bool generateTangents, bool splitSubM
                                 ++bufIndex;
                         }
                         morphs_.Push(newMorph);
-                        PrintLine("Processed morph " + name + " with " + usedPoses.Size() + " sub-poses");
+                        PrintLine("Processed morph " + name + " with " + String(usedPoses.Size()) + " sub-poses");
                     }
                     
                     anim = anim.GetNextElement("animation");

+ 2 - 9
Urho3D/Urho3D.cpp

@@ -31,9 +31,6 @@
 #include "ScriptFile.h"
 #include "Time.h"
 
-#include <string>
-#include <vector>
-
 #include <Windows.h>
 
 #include "DebugNew.h"
@@ -77,7 +74,8 @@ void Run(const char* cmdLine)
     if (scriptFileName.Empty())
     {
         ErrorDialog("Urho3D", "Usage: Urho3D <scriptfile> [options]\n\n"
-            "The script file should implement the function void Start(), which should create the scene content and subscribe to "
+            "The script file should implement the function void Start(), "
+            "which should create the scene content and subscribe to "
             "all necessary events, such as the application update."
         );
         return;
@@ -92,11 +90,6 @@ void Run(const char* cmdLine)
         return;
     }
     
-    LOGINFO("Size of std::string " + sizeof(std::string));
-    LOGINFO("Size of String " + sizeof(String));
-    LOGINFO("Size of std::vector " + sizeof(std::vector<int>));
-    LOGINFO("Size of Vector " + sizeof (Vector<int>));
-    
     // Set 5 ms timer period to allow accurate FPS limiting up to 200 FPS
     context_->GetSubsystem<Time>()->SetTimerPeriod(5);