mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[7910] Resolve problems with vmaps extractor support 3.1.2 archives.
Binary in contrib/vmap_extract_assembler_bin also updated.
This commit is contained in:
parent
f84fdc6757
commit
ec1d6a3b56
8 changed files with 105 additions and 60 deletions
Binary file not shown.
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
#ifndef _WIN32 || _WIN64
|
#ifndef _WIN32
|
||||||
#include "StormPort.h"
|
#include "StormPort.h"
|
||||||
#include "StormLib.h"
|
#include "StormLib.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include "adtfile.h"
|
#include "adtfile.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
char * GetPlainName(char * FileName)
|
char * GetPlainName(char * FileName)
|
||||||
{
|
{
|
||||||
char * szTemp;
|
char * szTemp;
|
||||||
|
|
@ -67,6 +69,7 @@ bool ADTFile::init(char *map_id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (!ADT.isEof())
|
while (!ADT.isEof())
|
||||||
{
|
{
|
||||||
char fourcc[5];
|
char fourcc[5];
|
||||||
|
|
@ -79,6 +82,7 @@ bool ADTFile::init(char *map_id)
|
||||||
|
|
||||||
if (!strcmp(fourcc,"MCIN"))
|
if (!strcmp(fourcc,"MCIN"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MTEX"))
|
else if (!strcmp(fourcc,"MTEX"))
|
||||||
{
|
{
|
||||||
|
|
@ -100,25 +104,36 @@ bool ADTFile::init(char *map_id)
|
||||||
fixname2(s,strlen(s));
|
fixname2(s,strlen(s));
|
||||||
p=p+strlen(p)+1;
|
p=p+strlen(p)+1;
|
||||||
ModelInstansName[t++] = s;
|
ModelInstansName[t++] = s;
|
||||||
path.erase(path.length()-2,2);
|
|
||||||
path.append("2");
|
// < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
|
||||||
char* szLocalFile[512];
|
std::string ext3 = path.size() >= 4 ? path.substr(path.size()-4,4) : "";
|
||||||
sprintf((char*)szLocalFile, ".\\buildings\\%s", s);
|
std::transform( ext3.begin(), ext3.end(), ext3.begin(), ::tolower );
|
||||||
FILE * output = fopen((char*)szLocalFile,"rb");
|
if(ext3 == ".mdx")
|
||||||
|
{
|
||||||
|
// replace .mdx -> .m2
|
||||||
|
path.erase(path.length()-2,2);
|
||||||
|
path.append("2");
|
||||||
|
}
|
||||||
|
// >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
|
||||||
|
// nothing do
|
||||||
|
|
||||||
|
char szLocalFile[MAX_PATH];
|
||||||
|
sprintf(szLocalFile, ".\\buildings\\%s", s);
|
||||||
|
FILE * output = fopen(szLocalFile,"rb");
|
||||||
if(!output)
|
if(!output)
|
||||||
{
|
{
|
||||||
Model * m2 = new Model(path);
|
Model * m2 = new Model(path);
|
||||||
if(m2->open())
|
if(m2->open())
|
||||||
{
|
m2->ConvertToVMAPModel(szLocalFile);
|
||||||
m2->ConvertToVMAPModel((char*)szLocalFile);
|
|
||||||
}
|
|
||||||
delete m2;
|
delete m2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fclose(output);
|
fclose(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MWMO"))
|
else if (!strcmp(fourcc,"MWMO"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,17 +24,17 @@ typedef struct
|
||||||
float z;
|
float z;
|
||||||
}svec;
|
}svec;
|
||||||
|
|
||||||
typedef struct
|
struct vec
|
||||||
{
|
{
|
||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double z;
|
double z;
|
||||||
}vec;
|
};
|
||||||
|
|
||||||
typedef struc
|
struct triangle
|
||||||
{
|
{
|
||||||
vec v[3];
|
vec v[3];
|
||||||
}triangle;
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,16 @@
|
||||||
#include "Stormlib.h"
|
#include "Stormlib.h"
|
||||||
#define __STORMLIB_SELF__
|
#define __STORMLIB_SELF__
|
||||||
|
|
||||||
typedef std::vector<MPQArchive*> ArchiveSet;
|
MPQArchiveSet gOpenArchives;
|
||||||
ArchiveSet gOpenArchives;
|
|
||||||
|
|
||||||
|
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
MPQArchive::MPQArchive(const char* filename)
|
MPQArchive::MPQArchive(const char* filename)
|
||||||
{
|
{
|
||||||
BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ);
|
BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ);
|
||||||
if (succ)
|
if (succ)
|
||||||
{
|
|
||||||
MPQArchive*ar = (MPQArchive*)(hMPQ);
|
|
||||||
printf("Opening %s\n", filename);
|
printf("Opening %s\n", filename);
|
||||||
gOpenArchives.push_back(ar);
|
|
||||||
succ = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
printf("Error!!!Not open archive %s\n", filename);
|
printf("Error!!!Not open archive %s\n", filename);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MPQArchive::close()
|
void MPQArchive::close()
|
||||||
|
|
@ -27,16 +20,36 @@ void MPQArchive::close()
|
||||||
SFileCloseArchive(hMPQ);
|
SFileCloseArchive(hMPQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MPQArchiveSet::Open( std::vector<std::string> const& archiveNames )
|
||||||
|
{
|
||||||
|
for (size_t i=0; i < archiveNames.size(); ++i)
|
||||||
|
{
|
||||||
|
MPQArchive mpqarch(archiveNames[i].c_str());
|
||||||
|
if(mpqarch.isOpen())
|
||||||
|
archives.push_back(mpqarch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return !archives.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
MPQArchiveSet::~MPQArchiveSet()
|
||||||
|
{
|
||||||
|
// close archives
|
||||||
|
for (ArchiveSet::iterator ar_itr = archives.begin(); ar_itr != archives.end(); ++ar_itr)
|
||||||
|
ar_itr->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
MPQFile::MPQFile(const char* filename):
|
MPQFile::MPQFile(const char* filename):
|
||||||
eof(false),
|
eof(false),
|
||||||
buffer(0),
|
buffer(0),
|
||||||
pointer(0),
|
pointer(0),
|
||||||
size(0)
|
size(0)
|
||||||
{
|
{
|
||||||
for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i)
|
for(ArchiveSet::const_iterator i=gOpenArchives.archives.begin(); i!=gOpenArchives.archives.end();++i)
|
||||||
{
|
{
|
||||||
HANDLE hFile = "";
|
HANDLE hFile = "";
|
||||||
MPQArchive*(hMPQ) = *i;
|
hMPQ = i->hMPQ;
|
||||||
BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
|
BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
|
||||||
if (succ)
|
if (succ)
|
||||||
{
|
{
|
||||||
|
|
@ -54,11 +67,12 @@ MPQFile::MPQFile(const char* filename):
|
||||||
|
|
||||||
eof = false;
|
eof = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eof = true;
|
eof = true;
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MPQFile::~MPQFile()
|
MPQFile::~MPQFile()
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,28 @@ typedef unsigned int uint32;
|
||||||
|
|
||||||
class MPQArchive
|
class MPQArchive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HANDLE hMPQ;
|
HANDLE hMPQ;
|
||||||
MPQArchive(const char* filename);
|
MPQArchive(const char* filename);
|
||||||
void close();
|
void close();
|
||||||
|
bool isOpen() const { return hMPQ != 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::vector<MPQArchive> ArchiveSet;
|
||||||
|
|
||||||
|
class MPQArchiveSet
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MPQArchiveSet() {}
|
||||||
|
~MPQArchiveSet();
|
||||||
|
|
||||||
|
bool Open(std::vector<std::string> const& archiveNames);
|
||||||
|
|
||||||
|
ArchiveSet archives;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern MPQArchiveSet gOpenArchives;
|
||||||
|
|
||||||
class MPQFile
|
class MPQFile
|
||||||
{
|
{
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ static const char * GetPlainName(const char * szFileName)
|
||||||
|
|
||||||
static void ShowProcessedFile(const char * szFileName)
|
static void ShowProcessedFile(const char * szFileName)
|
||||||
{
|
{
|
||||||
|
/* not truncate file names in output
|
||||||
char szLine[80];
|
char szLine[80];
|
||||||
size_t nLength = strlen(szFileName);
|
size_t nLength = strlen(szFileName);
|
||||||
|
|
||||||
|
|
@ -99,13 +100,15 @@ static void ShowProcessedFile(const char * szFileName)
|
||||||
nLength = sizeof(szLine)-1;
|
nLength = sizeof(szLine)-1;
|
||||||
memcpy(szLine, szFileName, nLength);
|
memcpy(szLine, szFileName, nLength);
|
||||||
printf("\r%s\n", szLine);
|
printf("\r%s\n", szLine);
|
||||||
|
*/
|
||||||
|
printf("\r%s\n", szFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
int ExtractWmo()
|
||||||
{
|
{
|
||||||
char* szListFile = "";
|
char* szListFile = "";
|
||||||
char szLocalFile[MAX_PATH] = "";
|
char szLocalFile[MAX_PATH] = "";
|
||||||
HANDLE hMpq = "";
|
|
||||||
BOOL bResult = FALSE;
|
BOOL bResult = FALSE;
|
||||||
|
|
||||||
//const char* ParsArchiveNames[] = {"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ"};
|
//const char* ParsArchiveNames[] = {"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ"};
|
||||||
|
|
@ -113,20 +116,14 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
int nError = ERROR_SUCCESS;
|
int nError = ERROR_SUCCESS;
|
||||||
if(szListFile == NULL || *szListFile == 0)
|
if(szListFile == NULL || *szListFile == 0)
|
||||||
szListFile = NULL;
|
szListFile = NULL;
|
||||||
//char tmp[1024];
|
|
||||||
//for (size_t i=0; i<4; i++)
|
|
||||||
for (size_t i=0; i<pArchiveNames.size(); ++i)
|
|
||||||
{
|
|
||||||
//sprintf(tmp,"%s\\%s", input_path, ParsArchiveNames[i]);
|
|
||||||
//if(!SFileOpenArchive(tmp, 0, 0, &hMpq))
|
|
||||||
if(!SFileOpenArchive(pArchiveNames[i].c_str(), 0, 0, &hMpq))
|
|
||||||
printf("NOT open!!! %s\n",pArchiveNames[i].c_str());
|
|
||||||
|
|
||||||
|
for (ArchiveSet::const_iterator ar_itr = gOpenArchives.archives.begin(); ar_itr != gOpenArchives.archives.end(); ++ar_itr)
|
||||||
|
{
|
||||||
// Copy files from archive
|
// Copy files from archive
|
||||||
if(nError == ERROR_SUCCESS)
|
if(nError == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
SFILE_FIND_DATA wf;
|
SFILE_FIND_DATA wf;
|
||||||
HANDLE hFind = SFileFindFirstFile(hMpq,"*.wmo*", &wf, szListFile);
|
HANDLE hFind = SFileFindFirstFile(ar_itr->hMPQ,"*.wmo*", &wf, szListFile);
|
||||||
bResult = TRUE;
|
bResult = TRUE;
|
||||||
|
|
||||||
while(hFind != NULL && bResult == TRUE)
|
while(hFind != NULL && bResult == TRUE)
|
||||||
|
|
@ -170,10 +167,10 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
{
|
{
|
||||||
for (int i=0; i<froot->nGroups; ++i)
|
for (int i=0; i<froot->nGroups; ++i)
|
||||||
{
|
{
|
||||||
char temp[512];
|
char temp[MAX_PATH];
|
||||||
strcpy(temp, wf.cFileName);
|
strcpy(temp, wf.cFileName);
|
||||||
temp[strlen(wf.cFileName)-4] = 0;
|
temp[strlen(wf.cFileName)-4] = 0;
|
||||||
char groupFileName[512];
|
char groupFileName[MAX_PATH];
|
||||||
sprintf(groupFileName,"%s_%03d.wmo",temp, i);
|
sprintf(groupFileName,"%s_%03d.wmo",temp, i);
|
||||||
printf("%s\n",groupFileName);
|
printf("%s\n",groupFileName);
|
||||||
//printf("GroupWmo!\n");
|
//printf("GroupWmo!\n");
|
||||||
|
|
@ -211,11 +208,9 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Close both archives
|
|
||||||
if(hMpq != NULL)
|
if(nError == ERROR_SUCCESS)
|
||||||
//SFileCloseArchive(hMpq);
|
printf("\nExtract wmo complete (No errors)\n");
|
||||||
if(nError == ERROR_SUCCESS)
|
|
||||||
printf("\nExtract wmo complete (No errors)\n");
|
|
||||||
|
|
||||||
return nError;
|
return nError;
|
||||||
}
|
}
|
||||||
|
|
@ -529,26 +524,30 @@ int main(int argc, char ** argv)
|
||||||
if(nError == ERROR_ALREADY_EXISTS)
|
if(nError == ERROR_ALREADY_EXISTS)
|
||||||
nError = ERROR_SUCCESS;
|
nError = ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
// patch goes first -> fake priority handling
|
|
||||||
std::vector<MPQArchive*> archives;
|
|
||||||
|
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
// prepare archive name list
|
||||||
std::vector<std::string> archiveNames;
|
std::vector<std::string> archiveNames;
|
||||||
|
|
||||||
fillArchiveNameVector(archiveNames);
|
fillArchiveNameVector(archiveNames);
|
||||||
for (size_t i=0; i<archiveNames.size(); ++i)
|
if(!gOpenArchives.Open(archiveNames))
|
||||||
{
|
{
|
||||||
archives.push_back(new MPQArchive(archiveNames[i].c_str()));
|
printf("FATAL ERROR: None MPQ archive found by path '%s'. Use -d option with proper path.\n",input_path);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
ExtractWmo(archiveNames);
|
|
||||||
|
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
// extract data
|
||||||
|
ExtractWmo();
|
||||||
|
|
||||||
|
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
//map.dbc
|
//map.dbc
|
||||||
if(nError == ERROR_SUCCESS)
|
if(nError == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DBCFile * dbc = new DBCFile("DBFilesClient\\Map.dbc");
|
DBCFile * dbc = new DBCFile("DBFilesClient\\Map.dbc");
|
||||||
dbc->open();
|
if(!dbc->open())
|
||||||
|
{
|
||||||
|
delete dbc;
|
||||||
|
printf("FATAL ERROR: Map.dbc not found in data file.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
map_count=dbc->getRecordCount ();
|
map_count=dbc->getRecordCount ();
|
||||||
map_ids=new map_id[map_count];
|
map_ids=new map_id[map_count];
|
||||||
for(unsigned int x=0;x<map_count;++x)
|
for(unsigned int x=0;x<map_count;++x)
|
||||||
|
|
@ -570,5 +569,6 @@ int main(int argc, char ** argv)
|
||||||
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData);
|
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData);
|
||||||
_getch();
|
_getch();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Extract %s. Work complete. No errors.",versionString);
|
printf("Extract %s. Work complete. No errors.",versionString);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7909"
|
#define REVISION_NR "7910"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue