aboutsummaryrefslogtreecommitdiff
path: root/src/shared/vmap
diff options
context:
space:
mode:
authormegamage <none@none>2008-12-12 11:21:28 -0600
committermegamage <none@none>2008-12-12 11:21:28 -0600
commitb6c288ca9fb271923f493ee39d78b5dc4b2a996f (patch)
treeec03c0dce11277c5e04f87a33ca76f1dd78687e7 /src/shared/vmap
parent135f39a5efabc12728924933056f3ea952dd2c09 (diff)
*Update to Mangos 6902. Source: Mangos.
*Skipped rev: rev 6893, some code about waypoint movement. --HG-- branch : trunk
Diffstat (limited to 'src/shared/vmap')
-rw-r--r--src/shared/vmap/CoordModelMapping.h10
-rw-r--r--src/shared/vmap/VMapManager.cpp18
2 files changed, 11 insertions, 17 deletions
diff --git a/src/shared/vmap/CoordModelMapping.h b/src/shared/vmap/CoordModelMapping.h
index 9482bd23f80..59766e5e7d5 100644
--- a/src/shared/vmap/CoordModelMapping.h
+++ b/src/shared/vmap/CoordModelMapping.h
@@ -45,8 +45,8 @@ namespace VMAP
G3D::Array<std::string> iMainFiles;
G3D::Array<std::string> iSingeFiles;
- void appendToMain(std::string pStr) { iMainFiles.append(pStr); }
- void appendToSingle(std::string pStr) { iSingeFiles.append(pStr); }
+ void appendToMain(const std::string& pStr) { iMainFiles.append(pStr); }
+ void appendToSingle(const std::string& pStr) { iSingeFiles.append(pStr); }
size_t size() { return (iMainFiles.size() + iSingeFiles.size()); }
};
@@ -115,7 +115,7 @@ namespace VMAP
const NameCollection getFilenamesForCoordinate(unsigned int pMapId, int xPos, int yPos);
- static unsigned int getMapIdFromFilename(std::string pName)
+ static unsigned int getMapIdFromFilename(const std::string& pName)
{
size_t spos;
@@ -128,8 +128,8 @@ namespace VMAP
}
const G3D::Array<unsigned int>& getMaps() const { return iMapIds; }
- inline bool isAlreadyProcessedSingleFile(std::string pName) { return(iProcesseSingleFiles.containsKey(pName)); }
- inline void addAlreadyProcessedSingleFile(std::string pName) { iProcesseSingleFiles.set(pName,pName); }
+ bool isAlreadyProcessedSingleFile(const std::string& pName) const { return iProcesseSingleFiles.containsKey(pName); }
+ void addAlreadyProcessedSingleFile(const std::string& pName) { iProcesseSingleFiles.set(pName,pName); }
inline void addWorldAreaMap(unsigned int pMapId)
{
diff --git a/src/shared/vmap/VMapManager.cpp b/src/shared/vmap/VMapManager.cpp
index fe105df1f5c..337e553f38d 100644
--- a/src/shared/vmap/VMapManager.cpp
+++ b/src/shared/vmap/VMapManager.cpp
@@ -277,10 +277,8 @@ namespace VMAP
{
dirFileName = getDirFileName(pMapId);
}
- size_t len = pBasePath.length() + dirFileName.length();
- char *filenameBuffer = new char[len+1];
- sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), dirFileName.c_str());
- FILE* df = fopen(filenameBuffer, "rb");
+ std::string fb = pBasePath + dirFileName;
+ FILE* df = fopen(fb.c_str(), "rb");
if(df)
{
char lineBuffer[FILENAMEBUFFER_SIZE];
@@ -290,8 +288,8 @@ namespace VMAP
chomp(name);
if(name.length() >1)
{
- sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), name.c_str());
- FILE* df2 = fopen(filenameBuffer, "rb");
+ std::string fb2 = pBasePath + name;
+ FILE* df2 = fopen(fb2.c_str(), "rb");
if(df2)
{
char magic[8];
@@ -304,7 +302,6 @@ namespace VMAP
}
fclose(df);
}
- delete[] filenameBuffer;
return result;
}
@@ -661,14 +658,12 @@ namespace VMAP
bool MapTree::loadMap(const std::string& pDirFileName, unsigned int pMapTileIdent)
{
bool result = true;
- size_t len = iBasePath.length() + pDirFileName.length();
- char *filenameBuffer = new char[len+1];
if(!hasDirFile(pDirFileName))
{
FilesInDir filesInDir;
result = false;
- sprintf(filenameBuffer, "%s%s", iBasePath.c_str(), pDirFileName.c_str());
- FILE* df = fopen(filenameBuffer, "rb");
+ std::string fb = iBasePath + pDirFileName;
+ FILE* df = fopen(fb.c_str(), "rb");
if(df)
{
char lineBuffer[FILENAMEBUFFER_SIZE];
@@ -728,7 +723,6 @@ namespace VMAP
filesInDir.incRefCount();
}
}
- delete [] filenameBuffer;
return (result);
}