From b6c288ca9fb271923f493ee39d78b5dc4b2a996f Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 12 Dec 2008 11:21:28 -0600 Subject: *Update to Mangos 6902. Source: Mangos. *Skipped rev: rev 6893, some code about waypoint movement. --HG-- branch : trunk --- src/shared/vmap/CoordModelMapping.h | 10 +++++----- src/shared/vmap/VMapManager.cpp | 18 ++++++------------ 2 files changed, 11 insertions(+), 17 deletions(-) (limited to 'src/shared/vmap') 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 iMainFiles; G3D::Array 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& 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); } -- cgit v1.2.3