mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[6894] Backport file name preparing code in VMapManager from 303 branch that fix also possible memory corruption.
This commit is contained in:
parent
477ba70782
commit
467090e817
2 changed files with 7 additions and 13 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "6893"
|
#define REVISION_NR "6894"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
|
|
@ -275,10 +275,8 @@ namespace VMAP
|
||||||
{
|
{
|
||||||
dirFileName = getDirFileName(pMapId);
|
dirFileName = getDirFileName(pMapId);
|
||||||
}
|
}
|
||||||
size_t len = pBasePath.length() + dirFileName.length();
|
std::string fb = pBasePath + dirFileName;
|
||||||
char *filenameBuffer = new char[len+1];
|
FILE* df = fopen(fb.c_str(), "rb");
|
||||||
sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), dirFileName.c_str());
|
|
||||||
FILE* df = fopen(filenameBuffer, "rb");
|
|
||||||
if(df)
|
if(df)
|
||||||
{
|
{
|
||||||
char lineBuffer[FILENAMEBUFFER_SIZE];
|
char lineBuffer[FILENAMEBUFFER_SIZE];
|
||||||
|
|
@ -288,8 +286,8 @@ namespace VMAP
|
||||||
chomp(name);
|
chomp(name);
|
||||||
if(name.length() >1)
|
if(name.length() >1)
|
||||||
{
|
{
|
||||||
sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), name.c_str());
|
std::string fb2 = pBasePath + name;
|
||||||
FILE* df2 = fopen(filenameBuffer, "rb");
|
FILE* df2 = fopen(fb2.c_str(), "rb");
|
||||||
if(df2)
|
if(df2)
|
||||||
{
|
{
|
||||||
char magic[8];
|
char magic[8];
|
||||||
|
|
@ -302,7 +300,6 @@ namespace VMAP
|
||||||
}
|
}
|
||||||
fclose(df);
|
fclose(df);
|
||||||
}
|
}
|
||||||
delete[] filenameBuffer;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -659,14 +656,12 @@ namespace VMAP
|
||||||
bool MapTree::loadMap(const std::string& pDirFileName, unsigned int pMapTileIdent)
|
bool MapTree::loadMap(const std::string& pDirFileName, unsigned int pMapTileIdent)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
size_t len = iBasePath.length() + pDirFileName.length();
|
|
||||||
char *filenameBuffer = new char[len+1];
|
|
||||||
if(!hasDirFile(pDirFileName))
|
if(!hasDirFile(pDirFileName))
|
||||||
{
|
{
|
||||||
FilesInDir filesInDir;
|
FilesInDir filesInDir;
|
||||||
result = false;
|
result = false;
|
||||||
sprintf(filenameBuffer, "%s%s", iBasePath.c_str(), pDirFileName.c_str());
|
std::string fb = iBasePath + pDirFileName;
|
||||||
FILE* df = fopen(filenameBuffer, "rb");
|
FILE* df = fopen(fb.c_str(), "rb");
|
||||||
if(df)
|
if(df)
|
||||||
{
|
{
|
||||||
char lineBuffer[FILENAMEBUFFER_SIZE];
|
char lineBuffer[FILENAMEBUFFER_SIZE];
|
||||||
|
|
@ -726,7 +721,6 @@ namespace VMAP
|
||||||
filesInDir.incRefCount();
|
filesInDir.incRefCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete [] filenameBuffer;
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue