mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +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 "StormLib.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "adtfile.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
char * GetPlainName(char * FileName)
|
||||
{
|
||||
char * szTemp;
|
||||
|
|
@ -67,6 +69,7 @@ bool ADTFile::init(char *map_id)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
while (!ADT.isEof())
|
||||
{
|
||||
char fourcc[5];
|
||||
|
|
@ -79,6 +82,7 @@ bool ADTFile::init(char *map_id)
|
|||
|
||||
if (!strcmp(fourcc,"MCIN"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MTEX"))
|
||||
{
|
||||
|
|
@ -92,7 +96,7 @@ bool ADTFile::init(char *map_id)
|
|||
char *p=buf;
|
||||
int t=0;
|
||||
ModelInstansName = new string[size];
|
||||
while (p<buf+size)
|
||||
while (p<buf+size)
|
||||
{
|
||||
fixnamen(p,strlen(p));
|
||||
string path(p);
|
||||
|
|
@ -100,25 +104,36 @@ bool ADTFile::init(char *map_id)
|
|||
fixname2(s,strlen(s));
|
||||
p=p+strlen(p)+1;
|
||||
ModelInstansName[t++] = s;
|
||||
path.erase(path.length()-2,2);
|
||||
path.append("2");
|
||||
char* szLocalFile[512];
|
||||
sprintf((char*)szLocalFile, ".\\buildings\\%s", s);
|
||||
FILE * output = fopen((char*)szLocalFile,"rb");
|
||||
|
||||
// < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
|
||||
std::string ext3 = path.size() >= 4 ? path.substr(path.size()-4,4) : "";
|
||||
std::transform( ext3.begin(), ext3.end(), ext3.begin(), ::tolower );
|
||||
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)
|
||||
{
|
||||
Model * m2 = new Model(path);
|
||||
if(m2->open())
|
||||
{
|
||||
m2->ConvertToVMAPModel((char*)szLocalFile);
|
||||
}
|
||||
m2->ConvertToVMAPModel(szLocalFile);
|
||||
delete m2;
|
||||
}
|
||||
else
|
||||
fclose(output);
|
||||
}
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MWMO"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,17 +24,17 @@ typedef struct
|
|||
float z;
|
||||
}svec;
|
||||
|
||||
typedef struct
|
||||
struct vec
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
}vec;
|
||||
};
|
||||
|
||||
typedef struc
|
||||
struct triangle
|
||||
{
|
||||
vec v[3];
|
||||
}triangle;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,23 +3,16 @@
|
|||
#include "Stormlib.h"
|
||||
#define __STORMLIB_SELF__
|
||||
|
||||
typedef std::vector<MPQArchive*> ArchiveSet;
|
||||
ArchiveSet gOpenArchives;
|
||||
MPQArchiveSet gOpenArchives;
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
MPQArchive::MPQArchive(const char* filename)
|
||||
{
|
||||
BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ);
|
||||
if (succ)
|
||||
{
|
||||
MPQArchive*ar = (MPQArchive*)(hMPQ);
|
||||
printf("Opening %s\n", filename);
|
||||
gOpenArchives.push_back(ar);
|
||||
succ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error!!!Not open archive %s\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
void MPQArchive::close()
|
||||
|
|
@ -27,16 +20,36 @@ void MPQArchive::close()
|
|||
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):
|
||||
eof(false),
|
||||
buffer(0),
|
||||
pointer(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 = "";
|
||||
MPQArchive*(hMPQ) = *i;
|
||||
hMPQ = i->hMPQ;
|
||||
BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
|
||||
if (succ)
|
||||
{
|
||||
|
|
@ -54,11 +67,12 @@ MPQFile::MPQFile(const char* filename):
|
|||
|
||||
eof = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
|
||||
}
|
||||
|
||||
MPQFile::~MPQFile()
|
||||
|
|
|
|||
|
|
@ -17,12 +17,28 @@ typedef unsigned int uint32;
|
|||
|
||||
class MPQArchive
|
||||
{
|
||||
public:
|
||||
HANDLE hMPQ;
|
||||
MPQArchive(const char* filename);
|
||||
void close();
|
||||
public:
|
||||
HANDLE hMPQ;
|
||||
MPQArchive(const char* filename);
|
||||
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
|
||||
{
|
||||
HANDLE hFile;
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ static const char * GetPlainName(const char * szFileName)
|
|||
|
||||
static void ShowProcessedFile(const char * szFileName)
|
||||
{
|
||||
/* not truncate file names in output
|
||||
char szLine[80];
|
||||
size_t nLength = strlen(szFileName);
|
||||
|
||||
|
|
@ -99,13 +100,15 @@ static void ShowProcessedFile(const char * szFileName)
|
|||
nLength = sizeof(szLine)-1;
|
||||
memcpy(szLine, szFileName, nLength);
|
||||
printf("\r%s\n", szLine);
|
||||
*/
|
||||
printf("\r%s\n", szFileName);
|
||||
}
|
||||
|
||||
int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
int ExtractWmo()
|
||||
{
|
||||
char* szListFile = "";
|
||||
char szLocalFile[MAX_PATH] = "";
|
||||
HANDLE hMpq = "";
|
||||
BOOL bResult = FALSE;
|
||||
|
||||
//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;
|
||||
if(szListFile == NULL || *szListFile == 0)
|
||||
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
|
||||
if(nError == ERROR_SUCCESS)
|
||||
{
|
||||
SFILE_FIND_DATA wf;
|
||||
HANDLE hFind = SFileFindFirstFile(hMpq,"*.wmo*", &wf, szListFile);
|
||||
HANDLE hFind = SFileFindFirstFile(ar_itr->hMPQ,"*.wmo*", &wf, szListFile);
|
||||
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)
|
||||
{
|
||||
char temp[512];
|
||||
char temp[MAX_PATH];
|
||||
strcpy(temp, wf.cFileName);
|
||||
temp[strlen(wf.cFileName)-4] = 0;
|
||||
char groupFileName[512];
|
||||
char groupFileName[MAX_PATH];
|
||||
sprintf(groupFileName,"%s_%03d.wmo",temp, i);
|
||||
printf("%s\n",groupFileName);
|
||||
//printf("GroupWmo!\n");
|
||||
|
|
@ -211,11 +208,9 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
|
||||
}
|
||||
}
|
||||
// Close both archives
|
||||
if(hMpq != NULL)
|
||||
//SFileCloseArchive(hMpq);
|
||||
if(nError == ERROR_SUCCESS)
|
||||
printf("\nExtract wmo complete (No errors)\n");
|
||||
|
||||
if(nError == ERROR_SUCCESS)
|
||||
printf("\nExtract wmo complete (No errors)\n");
|
||||
|
||||
return nError;
|
||||
}
|
||||
|
|
@ -528,27 +523,31 @@ int main(int argc, char ** argv)
|
|||
nError = GetLastError();
|
||||
if(nError == ERROR_ALREADY_EXISTS)
|
||||
nError = ERROR_SUCCESS;
|
||||
}
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// patch goes first -> fake priority handling
|
||||
std::vector<MPQArchive*> archives;
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// prepare archive name list
|
||||
std::vector<std::string> 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
|
||||
if(nError == ERROR_SUCCESS)
|
||||
{
|
||||
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_ids=new map_id[map_count];
|
||||
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);
|
||||
_getch();
|
||||
}
|
||||
|
||||
printf("Extract %s. Work complete. No errors.",versionString);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7909"
|
||||
#define REVISION_NR "7910"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue