# HG changeset patch
# User Mark Haßelbusch
# Date 1248815949 -7200
# Branch Marky
# Node ID 9d67614f62b89d5fc471d2e49eba59dd0192b131
# Parent  20b2ce58b990e7a3c60ba48b2b86274fa959a1a1
Changed a lot of StdStrBuf to StdCopyStrBuf so that the solution compiles with MSVC

diff -r 20b2ce58b990 -r 9d67614f62b8 standard/inc/StdMesh.h
--- a/standard/inc/StdMesh.h	Tue Jul 28 20:52:07 2009 +0200
+++ b/standard/inc/StdMesh.h	Tue Jul 28 23:19:09 2009 +0200
@@ -42,7 +42,7 @@
 class StdMeshSkeletonLoader
 {
 public:
-  virtual StdStrBuf LoadSkeleton(const char* filename) = 0;
+  virtual StdCopyStrBuf LoadSkeleton(const char* filename) = 0;
 };
 
 class StdMeshMatrix
@@ -156,7 +156,7 @@
 
   StdMeshAnimation& operator=(const StdMeshAnimation& other);
 
-  StdStrBuf Name;
+  StdCopyStrBuf Name;
   float Length;
 
 private:
@@ -190,7 +190,8 @@
   const StdMeshBone& GetBone(unsigned int i) const { return *Bones[i]; }
   unsigned int GetNumBones() const { return Bones.size(); }
 
-  const StdMeshAnimation* GetAnimationByName(const StdStrBuf& name) const;
+  //const StdMeshAnimation* GetAnimationByName(const StdStrBuf& name) const;
+  const StdMeshAnimation* GetAnimationByName(StdCopyStrBuf name) const;
   const StdMeshMaterial& GetMaterial() const { return *Material; }
 
   const StdMeshBox& GetBoundingBox() const { return BoundingBox; }
@@ -212,7 +213,7 @@
   std::vector<StdMeshFace> Faces;
   std::vector<StdMeshBone*> Bones; // Master Bone Table
 
-  std::map<StdStrBuf, StdMeshAnimation> Animations;
+  std::map<StdCopyStrBuf, StdMeshAnimation> Animations;
 
   StdMeshBox BoundingBox;
   const StdMeshMaterial* Material;
@@ -232,7 +233,8 @@
   FaceOrdering GetFaceOrdering() const { return CurrentFaceOrdering; }
   void SetFaceOrdering(FaceOrdering ordering);
 
-  bool SetAnimationByName(const StdStrBuf& animation_name);
+  //bool SetAnimationByName(const StdStrBuf& animation_name);
+  bool SetAnimationByName(StdCopyStrBuf animation_name);
   void SetAnimation(const StdMeshAnimation& animation);
   void UnsetAnimation();
 
diff -r 20b2ce58b990 -r 9d67614f62b8 standard/inc/StdMeshMaterial.h
--- a/standard/inc/StdMeshMaterial.h	Tue Jul 28 20:52:07 2009 +0200
+++ b/standard/inc/StdMeshMaterial.h	Tue Jul 28 23:19:09 2009 +0200
@@ -41,7 +41,7 @@
   virtual const char* what() const throw() { return Buf.getData(); }
 
 protected:
-  StdStrBuf Buf;
+  StdCopyStrBuf Buf;
 };
 
 // Interface to load textures. Given a texture filename occuring in the
@@ -112,11 +112,11 @@
   void Load(StdMeshMaterialParserCtx& ctx);
 
   // Location the Material was loaded from
-  StdStrBuf FileName;
+  StdCopyStrBuf FileName;
   unsigned int Line;
 
   // Material name
-  StdStrBuf Name;
+  StdCopyStrBuf Name;
 
   // Not currently used in Clonk, but don't fail when we see this in a
   // Material script:
@@ -143,7 +143,7 @@
   const StdMeshMaterial* GetMaterial(const char* material_name) const;
 
 private:
-  std::map<StdStrBuf, StdMeshMaterial> Materials;
+  std::map<StdCopyStrBuf, StdMeshMaterial> Materials;
 };
 
 #endif
diff -r 20b2ce58b990 -r 9d67614f62b8 standard/src/StdMesh.cpp
--- a/standard/src/StdMesh.cpp	Tue Jul 28 20:52:07 2009 +0200
+++ b/standard/src/StdMesh.cpp	Tue Jul 28 23:19:09 2009 +0200
@@ -488,9 +488,9 @@
   // Read skeleton
   TiXmlElement* skeletonlink_elem = mesh.RequireFirstChild(mesh_elem, "skeletonlink");
   const char* name = mesh.RequireStrAttribute(skeletonlink_elem, "name");
-  StdStrBuf xml_filename(name); xml_filename.Append(".xml");
+  StdCopyStrBuf xml_filename(name); xml_filename.Append(".xml");
 
-  StdStrBuf skeleton_xml_data = skel_loader.LoadSkeleton(xml_filename.getData());
+  StdCopyStrBuf skeleton_xml_data = skel_loader.LoadSkeleton(xml_filename.getData());
   if(skeleton_xml_data.isNull()) mesh.Error(FormatString("Failed to load '%s'", xml_filename.getData()), skeletonlink_elem);
 
   StdMeshXML skeleton(xml_filename.getData(), skeleton_xml_data.getData());
@@ -620,7 +620,8 @@
   TiXmlElement* animations_elem = skeleton.RequireFirstChild(skeleton_elem, "animations");
   for(TiXmlElement* animation_elem = animations_elem->FirstChildElement("animation"); animation_elem != NULL; animation_elem = animation_elem->NextSiblingElement("animation"))
   {
-    StdStrBuf name(skeleton.RequireStrAttribute(animation_elem, "name"));
+    StdCopyStrBuf name(skeleton.RequireStrAttribute(animation_elem, "name"));
+    //StdStrBuf name(skeleton.RequireStrAttribute(animation_elem, "name"));
     if(Animations.find(name) != Animations.end())
       skeleton.Error(FormatString("There is already an animation with name '%s'", name.getData()), animation_elem);
 
@@ -727,9 +728,11 @@
     AddMasterBone(bone->Children[i]);
 }
 
-const StdMeshAnimation* StdMesh::GetAnimationByName(const StdStrBuf& name) const
+//const StdMeshAnimation* StdMesh::GetAnimationByName(const StdStrBuf& name) const
+const StdMeshAnimation* StdMesh::GetAnimationByName( StdCopyStrBuf name) const
 {
-  std::map<StdStrBuf, StdMeshAnimation>::const_iterator iter = Animations.find(name);
+	//StdCopyStrBuf name2; //=name;
+  std::map<StdCopyStrBuf, StdMeshAnimation>::const_iterator iter = Animations.find(name);
   if(iter == Animations.end()) return NULL;
   return &iter->second;
 }
@@ -753,7 +756,8 @@
   ReorderFaces();
 }
 
-bool StdMeshInstance::SetAnimationByName(const StdStrBuf& animation_name)
+//bool StdMeshInstance::SetAnimationByName(const StdStrBuf& animation_name)
+bool StdMeshInstance::SetAnimationByName(StdCopyStrBuf animation_name)
 {
   const StdMeshAnimation* animation = Mesh.GetAnimationByName(animation_name);
   if(!animation) return false;
diff -r 20b2ce58b990 -r 9d67614f62b8 standard/src/StdMeshMaterial.cpp
--- a/standard/src/StdMeshMaterial.cpp	Tue Jul 28 20:52:07 2009 +0200
+++ b/standard/src/StdMeshMaterial.cpp	Tue Jul 28 23:19:09 2009 +0200
@@ -55,7 +55,7 @@
   unsigned int Line;
   const char* Script;
 
-  StdStrBuf FileName;
+  StdCopyStrBuf FileName;
   StdMeshMaterialTextureLoader& TextureLoader;
 };
 
@@ -116,7 +116,7 @@
 Token StdMeshMaterialParserCtx::AdvanceNonEOF(StdStrBuf& name)
 {
   Token token = Advance(name);
-  if(token == TOKEN_EOF) Error(StdStrBuf("Unexpected end of file"));
+  if(token == TOKEN_EOF) Error(StdCopyStrBuf("Unexpected end of file"));
   return token;
 }
 
@@ -124,7 +124,7 @@
 {
   Token token = AdvanceNonEOF(name);
   // TODO: Explain what was actually expected
-  if(token != expect) Error(StdStrBuf("'") + name + "' unexpected");
+  if(token != expect) Error(StdCopyStrBuf("'") + name + "' unexpected");
   return token;
 }
 
@@ -133,13 +133,13 @@
   Token token = AdvanceNonEOF(name);
   // TODO: Explain what was actually expected
   if(token != expect1 && token != expect2)
-    Error(StdStrBuf("'") + name + "' unexpected");
+    Error(StdCopyStrBuf("'") + name + "' unexpected");
   return token;
 }
 
 float StdMeshMaterialParserCtx::AdvanceFloat()
 {
-  StdStrBuf buf;
+  StdCopyStrBuf buf;
   AdvanceRequired(buf, TOKEN_IDTF);
   char* end;
   float f;
@@ -150,13 +150,13 @@
 		f = strtof(buf.getData(), &end);
 	#endif
 
-  if(*end != '\0') Error(StdStrBuf("Floating point value expected"));
+  if(*end != '\0') Error(StdCopyStrBuf("Floating point value expected"));
   return f;
 }
 
 bool StdMeshMaterialParserCtx::AdvanceFloatOptional(float& value)
 {
-  StdStrBuf buf;
+  StdCopyStrBuf buf;
   Token tok = Peek(buf);
 
   if(tok == TOKEN_IDTF && isdigit(buf[0]))
@@ -170,11 +170,11 @@
 
 bool StdMeshMaterialParserCtx::AdvanceBoolean()
 {
-  StdStrBuf buf;
+  StdCopyStrBuf buf;
   AdvanceRequired(buf, TOKEN_IDTF);
   if(buf == "on") return true;
   if(buf == "off") return false;
-  Error(StdStrBuf("Expected either 'on' or 'off', but not '") + buf + "'");
+  Error(StdCopyStrBuf("Expected either 'on' or 'off', but not '") + buf + "'");
   return false; // Never reached
 }
 
@@ -185,7 +185,7 @@
 
 void StdMeshMaterialParserCtx::ErrorUnexpectedIdentifier(const StdStrBuf& identifier)
 {
-  Error(StdStrBuf("Unexpected identifier: '") + identifier + "'");
+  Error(StdCopyStrBuf("Unexpected identifier: '") + identifier + "'");
 }
 
 StdMeshMaterialTextureUnit::TexRef::TexRef(unsigned int size):
@@ -228,7 +228,7 @@
 void StdMeshMaterialTextureUnit::Load(StdMeshMaterialParserCtx& ctx)
 {
   Token token;
-  StdStrBuf token_name;
+  StdCopyStrBuf token_name;
   while((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
   {
     if(token_name == "texture")
@@ -237,10 +237,10 @@
 
       CPNGFile png;
       if(!ctx.TextureLoader.LoadTexture(token_name.getData(), png))
-        ctx.Error(StdStrBuf("Could not load texture '") + token_name + "'");
+        ctx.Error(StdCopyStrBuf("Could not load texture '") + token_name + "'");
 
       if(png.iWdt != png.iHgt)
-        ctx.Error(StdStrBuf("Texture '") + token_name + "' is not quadratic");
+        ctx.Error(StdCopyStrBuf("Texture '") + token_name + "' is not quadratic");
 
       Texture = new TexRef(png.iWdt);
 
@@ -255,7 +255,7 @@
   }
 
   if(token != TOKEN_BRACE_CLOSE)
-    ctx.Error(StdStrBuf("'") + token_name.getData() + "' unexpected");
+    ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
 }
 
 StdMeshMaterialPass::StdMeshMaterialPass()
@@ -270,7 +270,7 @@
 void StdMeshMaterialPass::Load(StdMeshMaterialParserCtx& ctx)
 {
   Token token;
-  StdStrBuf token_name;
+  StdCopyStrBuf token_name;
   while((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
   {
     if(token_name == "texture_unit")
@@ -329,13 +329,13 @@
   }
 
   if(token != TOKEN_BRACE_CLOSE)
-    ctx.Error(StdStrBuf("'") + token_name.getData() + "' unexpected");
+    ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
 }
 
 void StdMeshMaterialTechnique::Load(StdMeshMaterialParserCtx& ctx)
 {
   Token token;
-  StdStrBuf token_name;
+  StdCopyStrBuf token_name;
   while((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
   {
     if(token_name == "pass")
@@ -350,7 +350,7 @@
   }
 
   if(token != TOKEN_BRACE_CLOSE)
-    ctx.Error(StdStrBuf("'") + token_name.getData() + "' unexpected");
+    ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
 }
 
 StdMeshMaterial::StdMeshMaterial():
@@ -361,7 +361,7 @@
 void StdMeshMaterial::Load(StdMeshMaterialParserCtx& ctx)
 {
   Token token;
-  StdStrBuf token_name;
+  StdCopyStrBuf token_name;
   while((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
   {
     if(token_name == "technique")
@@ -380,7 +380,7 @@
   }
   
   if(token != TOKEN_BRACE_CLOSE)
-    ctx.Error(StdStrBuf("'") + token_name.getData() + "' unexpected");
+    ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
 }
 
 void StdMeshMatManager::Clear()
@@ -393,17 +393,17 @@
   StdMeshMaterialParserCtx ctx(mat_script, filename, tex_loader);
 
   Token token;
-  StdStrBuf token_name;
+  StdCopyStrBuf token_name;
   while((token = ctx.Advance(token_name)) == TOKEN_IDTF)
   {
     if(token_name == "material")
     {
       // Read name
-      StdStrBuf material_name;
+      StdCopyStrBuf material_name;
       ctx.AdvanceRequired(material_name, TOKEN_IDTF);
 
       // Check for uniqueness
-      std::map<StdStrBuf, StdMeshMaterial>::iterator iter = Materials.find(material_name);
+      std::map<StdCopyStrBuf, StdMeshMaterial>::iterator iter = Materials.find(material_name);
       if(iter != Materials.end())
         ctx.Error(FormatString("Material with name '%s' is already defined in %s:%u", material_name.getData(), iter->second.FileName.getData(), iter->second.Line));
 
@@ -417,13 +417,13 @@
         // already. This currently makes only sense when its defined above
         // in the same material script file or in a parent definition.
         // We could later support material scripts in the System.c4g.
-        StdStrBuf parent_name;
+        StdCopyStrBuf parent_name;
         ctx.AdvanceRequired(parent_name, TOKEN_IDTF);
         ctx.AdvanceRequired(token_name, TOKEN_BRACE_OPEN);
 
         iter = Materials.find(parent_name);
         if(iter == Materials.end())
-          ctx.Error(StdStrBuf("Parent material '") + parent_name + "' does not exist (or is not yet loaded)");
+          ctx.Error(StdCopyStrBuf("Parent material '") + parent_name + "' does not exist (or is not yet loaded)");
         parent = &iter->second;
       }
 
@@ -442,12 +442,12 @@
   }
 
   if(token != TOKEN_EOF)
-    ctx.Error(StdStrBuf("'") + token_name.getData() + "' unexpected");
+    ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
 }
 
 const StdMeshMaterial* StdMeshMatManager::GetMaterial(const char* material_name) const
 {
-  std::map<StdStrBuf, StdMeshMaterial>::const_iterator iter = Materials.find(StdStrBuf(material_name));
+  std::map<StdCopyStrBuf, StdMeshMaterial>::const_iterator iter = Materials.find(StdCopyStrBuf(material_name));
   if(iter == Materials.end()) return NULL;
   return &iter->second;
 }
