[7913] Fixed vmap_assambler sources. Updated binary. Author: VladimirMangos
* Fixed week ago added bugs into vmap code that break vmap_assambler sources work.
Note: vmap_assambler binary not updated from nov 2008 until this commit and it has been correct working.
* Add to vmap assambler process show output and add appropriate error messages output.
* vmap_assambler binary updated.
--HG--
branch : trunk
This commit is contained in:
@@ -78,15 +78,18 @@ bool readConfigFile(char *pConffile, VMAP::TileAssembler* pTa)
|
||||
//=======================================================
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc == 3 || argc == 4)
|
||||
if(argc != 3 && argc != 4)
|
||||
{
|
||||
bool ok = true;
|
||||
printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *src = argv[1];
|
||||
char *dest = argv[2];
|
||||
char *conffile = NULL;
|
||||
if(argc >= 4) {
|
||||
if(argc >= 4)
|
||||
conffile = argv[3];
|
||||
}
|
||||
|
||||
VMAP::TileAssembler* ta = new VMAP::TileAssembler(std::string(src), std::string(dest));
|
||||
ta->setModelNameFilterMethod(modelNameFilter);
|
||||
|
||||
@@ -94,26 +97,25 @@ int main(int argc, char* argv[])
|
||||
All the names in the list are considered to be world maps or huge instances.
|
||||
These maps will be spilt into tiles in the vmap assemble process
|
||||
*/
|
||||
if(conffile != NULL) {
|
||||
ok = readConfigFile(conffile, ta);
|
||||
if(!ok) {
|
||||
printf("Can not open file config file: %s\n", conffile);
|
||||
}
|
||||
}
|
||||
if(ok) { ok = ta->convertWorld(); }
|
||||
if(ok) {
|
||||
printf("Ok, all done\n");
|
||||
} else {
|
||||
printf("exit with errors\n");
|
||||
return 1;
|
||||
}
|
||||
delete ta;
|
||||
}
|
||||
else
|
||||
if(conffile != NULL)
|
||||
{
|
||||
printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]);
|
||||
if(!readConfigFile(conffile, ta))
|
||||
{
|
||||
printf("Can not open file config file: %s\n", conffile);
|
||||
delete ta;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!ta->convertWorld())
|
||||
{
|
||||
printf("exit with errors\n");
|
||||
delete ta;
|
||||
return 1;
|
||||
}
|
||||
|
||||
delete ta;
|
||||
printf("Ok, all done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -115,4 +115,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbI
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,4 +65,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pb
|
||||
#endif
|
||||
|
||||
#endif // __STORM_H__
|
||||
|
||||
|
||||
@@ -695,4 +695,3 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1072,4 +1072,3 @@ void FreeMPQArchive(TMPQArchive *& ha)
|
||||
ha = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,4 +86,3 @@ int SListFileSaveToMpq(TMPQArchive * ha);
|
||||
|
||||
#endif // __SCOMMON_H__
|
||||
|
||||
|
||||
|
||||
@@ -713,4 +713,3 @@ int WINAPI SCompSetDataCompression(int nDataCompression)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -689,4 +689,3 @@ BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile, BOOL /* bR
|
||||
CompactCB = NULL;
|
||||
return (nError == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -528,4 +528,3 @@ BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szFileName, const char * s
|
||||
return (nError == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,4 +61,3 @@ BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char *
|
||||
SetLastError(nError);
|
||||
return (BOOL)(nError == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -289,4 +289,3 @@ BOOL WINAPI SFileFindClose(HANDLE hFind)
|
||||
FreeMPQSearch(hs);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -495,4 +495,3 @@ BOOL WINAPI SFileCloseArchive(HANDLE hMPQ)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -401,4 +401,3 @@ BOOL WINAPI SFileCloseFile(HANDLE hFile)
|
||||
FreeMPQFile(hf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -824,4 +824,3 @@ DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType)
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
|
||||
@@ -559,4 +559,3 @@ BOOL SListFileFindClose(HANDLE hFind)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,4 +65,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pb
|
||||
#endif
|
||||
|
||||
#endif // __STORM_H__
|
||||
|
||||
|
||||
@@ -577,4 +577,3 @@ BYTE ** WINAPI cl2GetDirData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT
|
||||
BYTE * WINAPI pcxGetData(BYTE *filebuf, DWORD filesize, BYTE transcol, USHORT *xsize, USHORT *ysize);
|
||||
|
||||
#endif // __STORMLIB_H_
|
||||
|
||||
|
||||
@@ -276,4 +276,3 @@
|
||||
#endif
|
||||
|
||||
#endif // __STORMPORT_H__
|
||||
|
||||
|
||||
@@ -166,4 +166,3 @@ BOOL MoveFile(const char *lpExistingFileName, const char *lpNewFileName)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
********************************************************************/
|
||||
|
||||
#ifndef _WIN32 || _WIN64
|
||||
#ifndef _WIN32
|
||||
#include "StormPort.h"
|
||||
#include "StormLib.h"
|
||||
|
||||
@@ -760,4 +760,3 @@ DWORD GetFileAttributes(const char * szFileName)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -321,4 +321,3 @@ BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end bzlib.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -535,4 +535,3 @@ BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end bzlib_private.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -1451,4 +1451,3 @@ unsigned char THuffmannTree::Table1502A630[] =
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00
|
||||
};
|
||||
|
||||
|
||||
@@ -140,4 +140,3 @@ class THuffmannTree
|
||||
};
|
||||
|
||||
#endif // __HUFFMAN_H__
|
||||
|
||||
|
||||
@@ -135,4 +135,3 @@ unsigned long PKEXPORT crc32pk(char *buffer, unsigned int *size, unsigned long *
|
||||
#endif
|
||||
|
||||
#endif // __PKLIB_H__
|
||||
|
||||
|
||||
@@ -354,4 +354,3 @@ int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char *
|
||||
}
|
||||
return (int)(out.pb - pbOutBuffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,4 +20,3 @@ int CompressWave (unsigned char * pbOutBuffer, int dwOutLength, short * pwInBu
|
||||
int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels);
|
||||
|
||||
#endif // __WAVE_H__
|
||||
|
||||
|
||||
@@ -15,4 +15,3 @@ USEUNIT("trees.c");
|
||||
|
||||
// To add a file to the library use the Project menu 'Add to Project'.
|
||||
|
||||
|
||||
|
||||
@@ -20,4 +20,3 @@ USEUNIT("zutil.c");
|
||||
|
||||
// To add a file to the library use the Project menu 'Add to Project'.
|
||||
|
||||
|
||||
|
||||
@@ -40,4 +40,3 @@ int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,4 +22,3 @@ int main() {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -327,4 +327,3 @@ gzofstream::gzofstream( int fd, int io_mode ) :
|
||||
}
|
||||
|
||||
gzofstream::~gzofstream() { }
|
||||
|
||||
|
||||
@@ -140,4 +140,3 @@ inline gzomanip<int> setcompressionstrategy(int l)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -305,4 +305,3 @@ inline ostream& operator<<(ozstream& zs, const T& x) {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,4 +23,3 @@ void main() {
|
||||
|
||||
delete[] x; delete[] y;
|
||||
}
|
||||
|
||||
|
||||
@@ -273,4 +273,3 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
||||
|
||||
|
||||
@@ -148,4 +148,3 @@ extern int ZEXPORT zipClose OF((zipFile file,
|
||||
#endif
|
||||
|
||||
#endif /* _zip_H */
|
||||
|
||||
|
||||
@@ -316,4 +316,3 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,4 +37,3 @@ extern void inflate_set_dictionary OF((
|
||||
|
||||
extern int inflate_blocks_sync_point OF((
|
||||
inflate_blocks_statef *s));
|
||||
|
||||
|
||||
@@ -25,4 +25,3 @@ extern void inflate_codes_free OF((
|
||||
inflate_codes_statef *,
|
||||
z_streamp ));
|
||||
|
||||
|
||||
|
||||
@@ -15,4 +15,3 @@ extern int inflate_fast OF((
|
||||
inflate_huft *,
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ));
|
||||
|
||||
|
||||
@@ -149,4 +149,3 @@ local inflate_huft fixed_td[] = {
|
||||
{{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
|
||||
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
|
||||
};
|
||||
|
||||
|
||||
@@ -56,4 +56,3 @@ extern int inflate_trees_fixed OF((
|
||||
inflate_huft * FAR *, /* literal/length tree result */
|
||||
inflate_huft * FAR *, /* distance tree result */
|
||||
z_streamp)); /* for memory allocation */
|
||||
|
||||
|
||||
@@ -96,4 +96,3 @@ extern int inflate_flush OF((
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -126,4 +126,3 @@ local const int base_dist[D_CODES] = {
|
||||
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -277,4 +277,3 @@ typedef uLong FAR uLongf;
|
||||
#endif
|
||||
|
||||
#endif /* _ZCONF_H */
|
||||
|
||||
|
||||
@@ -891,4 +891,3 @@ ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
||||
#endif
|
||||
|
||||
#endif /* _ZLIB_H */
|
||||
|
||||
|
||||
@@ -218,4 +218,3 @@ void zcfree OF((voidpf opaque, voidpf ptr));
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
|
||||
#endif /* _Z_UTIL_H */
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "adtfile.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
char * GetPlainName(char * FileName)
|
||||
{
|
||||
@@ -12,7 +13,8 @@ char * GetPlainName(char * FileName)
|
||||
|
||||
void fixnamen(char *name, size_t len)
|
||||
{
|
||||
for (size_t i=0; i<len-3; i++) {
|
||||
for (size_t i=0; i<len-3; i++)
|
||||
{
|
||||
if (i>0 && name[i]>='A' && name[i]<='Z' && isalpha(name[i-1]))
|
||||
{
|
||||
name[i] |= 0x20;
|
||||
@@ -22,6 +24,7 @@ void fixnamen(char *name, size_t len)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fixname2(char *name, size_t len)
|
||||
{
|
||||
for (size_t i=0; i<len-3; i++)
|
||||
@@ -38,7 +41,6 @@ ADTFile::ADTFile(char* filename): ADT(filename)
|
||||
|
||||
bool ADTFile::init(char *map_id)
|
||||
{
|
||||
|
||||
if(ADT.isEof ())
|
||||
return false;
|
||||
|
||||
@@ -68,7 +70,6 @@ bool ADTFile::init(char *map_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
while (!ADT.isEof())
|
||||
{
|
||||
char fourcc[5];
|
||||
@@ -79,16 +80,14 @@ bool ADTFile::init(char *map_id)
|
||||
|
||||
size_t nextpos = ADT.getPos() + size;
|
||||
|
||||
if (!strcmp(fourcc,"MCIN"))//MCIN
|
||||
if (!strcmp(fourcc,"MCIN"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MTEX"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(fourcc,"MMDX"))
|
||||
{
|
||||
|
||||
if (size)
|
||||
{
|
||||
char *buf = new char[size];
|
||||
@@ -104,35 +103,39 @@ bool ADTFile::init(char *map_id)
|
||||
fixname2(s,strlen(s));
|
||||
p=p+strlen(p)+1;
|
||||
ModelInstansName[t++] = s;
|
||||
|
||||
// < 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");
|
||||
char* szLocalFile[512];
|
||||
sprintf((char*)szLocalFile, ".\\buildings\\%s", s);
|
||||
FILE * output = fopen((char*)szLocalFile,"rb");
|
||||
}
|
||||
// >= 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"))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
|
||||
char *buf = new char[size];
|
||||
ADT.read(buf, size);
|
||||
char *p=buf;
|
||||
@@ -148,9 +151,7 @@ bool ADTFile::init(char *map_id)
|
||||
WmoInstansName[q++] = s;
|
||||
}
|
||||
delete[] buf;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//======================
|
||||
else if (!strcmp(fourcc,"MDDF"))
|
||||
@@ -158,7 +159,7 @@ bool ADTFile::init(char *map_id)
|
||||
if (size)
|
||||
{
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; i++)
|
||||
for (int i=0; i<nMDX; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
@@ -172,7 +173,7 @@ bool ADTFile::init(char *map_id)
|
||||
if (size)
|
||||
{
|
||||
nWMO = (int)size / 64;
|
||||
for (int i=0; i<nWMO; i++)
|
||||
for (int i=0; i<nWMO; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
@@ -188,7 +189,7 @@ bool ADTFile::init(char *map_id)
|
||||
if (size)
|
||||
{
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; i++)
|
||||
for (int i=0; i<nMDX; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
@@ -202,7 +203,7 @@ bool ADTFile::init(char *map_id)
|
||||
if (size)
|
||||
{
|
||||
nWMO = (int)size / 64;
|
||||
for (int i=0; i<nWMO; i++)
|
||||
for (int i=0; i<nWMO; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
@@ -223,6 +224,3 @@ ADTFile::~ADTFile()
|
||||
{
|
||||
ADT.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,29 +17,33 @@ typedef unsigned int uint32;
|
||||
|
||||
class Liquid;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
}svec;
|
||||
|
||||
typedef struct {
|
||||
struct vec
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
}vec;
|
||||
};
|
||||
|
||||
typedef struct{
|
||||
struct triangle
|
||||
{
|
||||
vec v[3];
|
||||
};
|
||||
|
||||
}triangle;
|
||||
|
||||
typedef struct{
|
||||
typedef struct
|
||||
{
|
||||
float v9[16*8+1][16*8+1];
|
||||
float v8[16*8][16*8];
|
||||
}Cell;
|
||||
|
||||
typedef struct{
|
||||
typedef struct
|
||||
{
|
||||
double v9[9][9];
|
||||
double v8[8][8];
|
||||
uint16 area_id;
|
||||
@@ -53,7 +57,8 @@ typedef struct
|
||||
chunk ch[16][16];
|
||||
}mcell;
|
||||
|
||||
struct MapChunkHeader {
|
||||
struct MapChunkHeader
|
||||
{
|
||||
uint32 flags;
|
||||
uint32 ix;
|
||||
uint32 iy;
|
||||
@@ -119,7 +124,4 @@ private:
|
||||
void fixnamen(char *name, size_t len);
|
||||
//void fixMapNamen(char *name, size_t len);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ bool DBCFile::open()
|
||||
|
||||
f.read(header,4); // File Header
|
||||
|
||||
if (header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3] != 'C') {
|
||||
|
||||
if (header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3] != 'C')
|
||||
{
|
||||
f.close();
|
||||
data = NULL;
|
||||
printf("Critical Error: An error occured while trying to read the DBCFile %s.", filename.c_str());
|
||||
@@ -67,10 +67,9 @@ DBCFile::Iterator DBCFile::begin()
|
||||
assert(data);
|
||||
return Iterator(*this, data);
|
||||
}
|
||||
|
||||
DBCFile::Iterator DBCFile::end()
|
||||
{
|
||||
assert(data);
|
||||
return Iterator(*this, stringTable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -137,4 +137,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -45,10 +45,8 @@ bool Model::open()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Model::ConvertToVMAPModel(char * outfilename)
|
||||
{
|
||||
|
||||
int N[] = {0x00000000};
|
||||
FILE * output=fopen(outfilename,"wb");
|
||||
if(!output)
|
||||
@@ -133,18 +131,17 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
|
||||
sprintf(tempname, ".\\buildings\\%s", ModelInstName);
|
||||
FILE *input;
|
||||
input = fopen(tempname, "r+b");
|
||||
|
||||
if(!input)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(input, 8, SEEK_SET); // get the correct no of vertices
|
||||
int nVertices;
|
||||
fread(&nVertices, sizeof (int), 1, input);
|
||||
fclose(input);
|
||||
|
||||
if(nVertices == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(pDirfile)
|
||||
{
|
||||
@@ -153,7 +150,6 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
|
||||
int realx2 = (int) ((float) pos.x / 533.333333f);
|
||||
int realy2 = (int) ((float) pos.z / 533.333333f);
|
||||
|
||||
|
||||
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n",
|
||||
MapName,
|
||||
ModelInstName,
|
||||
@@ -166,4 +162,3 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,17 +11,10 @@ class WMOInstance;
|
||||
|
||||
Vec3D fixCoordSystem(Vec3D v);
|
||||
|
||||
|
||||
|
||||
|
||||
class Model
|
||||
{
|
||||
public:
|
||||
|
||||
ModelHeader header;
|
||||
|
||||
public:
|
||||
|
||||
uint32 offsBB_vertices, offsBB_indices;
|
||||
Vec3D *BB_vertices, *vertices;
|
||||
uint16 *BB_indices, *indices;
|
||||
@@ -30,8 +23,6 @@ public:
|
||||
bool open();
|
||||
bool ConvertToVMAPModel(char * outfilename);
|
||||
|
||||
public:
|
||||
|
||||
bool ok;
|
||||
|
||||
Model(std::string &filename);
|
||||
@@ -58,4 +49,3 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ typedef int int32;
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct ModelHeader {
|
||||
struct ModelHeader
|
||||
{
|
||||
char id[4];
|
||||
uint8 version[4];
|
||||
uint32 nameLength;
|
||||
@@ -77,7 +78,4 @@ struct ModelHeader {
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,43 +3,52 @@
|
||||
#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()
|
||||
{
|
||||
SFileCloseArchive(hMPQ);
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
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();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -62,7 +71,6 @@ MPQFile::MPQFile(const char* filename):
|
||||
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
|
||||
}
|
||||
|
||||
MPQFile::~MPQFile()
|
||||
@@ -133,5 +141,3 @@ char* MPQFile::getPointer()
|
||||
{
|
||||
return buffer + pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,16 +15,30 @@ using namespace std;
|
||||
|
||||
typedef unsigned int uint32;
|
||||
|
||||
|
||||
class MPQArchive
|
||||
{
|
||||
|
||||
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;
|
||||
@@ -63,8 +77,4 @@ inline void flipcc(char *fcc)
|
||||
fcc[2]=t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
|
||||
class Vec3D {
|
||||
class Vec3D
|
||||
{
|
||||
public:
|
||||
float x,y,z;
|
||||
|
||||
@@ -112,11 +111,11 @@ public:
|
||||
{
|
||||
return (float*)this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Vec2D {
|
||||
class Vec2D
|
||||
{
|
||||
public:
|
||||
float x,y;
|
||||
|
||||
@@ -213,10 +212,8 @@ public:
|
||||
{
|
||||
return (float*)this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void rotate(float x0, float y0, float *x, float *y, float angle)
|
||||
{
|
||||
float xa = *x - x0, ya = *y - y0;
|
||||
@@ -224,8 +221,4 @@ inline void rotate(float x0, float y0, float *x, float *y, float angle)
|
||||
*y = xa*sinf(angle) + ya*cosf(angle) + y0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef struct{
|
||||
typedef struct
|
||||
{
|
||||
char name[64];
|
||||
unsigned int id;
|
||||
}map_id;
|
||||
@@ -86,9 +87,10 @@ static const char * GetPlainName(const char * szFileName)
|
||||
szFileName = szTemp + 1;
|
||||
return szFileName;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static void ShowProcessedFile(const char * szFileName)
|
||||
{
|
||||
/* not truncate file names in output
|
||||
char szLine[80];
|
||||
size_t nLength = strlen(szFileName);
|
||||
|
||||
@@ -99,16 +101,14 @@ 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"};
|
||||
@@ -116,21 +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++)
|
||||
|
||||
for (ArchiveSet::const_iterator ar_itr = gOpenArchives.archives.begin(); ar_itr != gOpenArchives.archives.end(); ++ar_itr)
|
||||
{
|
||||
|
||||
//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());
|
||||
|
||||
// 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)
|
||||
@@ -149,7 +142,7 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
char cpy[4];
|
||||
strncpy((char*)cpy,rchr,4);
|
||||
for (int i=0;i<4;i++)
|
||||
for (int i=0;i<4; ++i)
|
||||
{
|
||||
int m = cpy[i];
|
||||
if(isdigit(m))
|
||||
@@ -172,12 +165,12 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||
int Wmo_nVertices = 0;
|
||||
if(froot->nGroups !=0)
|
||||
{
|
||||
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);
|
||||
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");
|
||||
@@ -196,7 +189,9 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||
fwrite(&Wmo_nVertices,sizeof(int),1,output);
|
||||
fclose(output);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(n);
|
||||
}
|
||||
wf.dwFileFlags &= ~MPQ_FILE_HAS_EXTRA;
|
||||
@@ -210,39 +205,34 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||
// Close the search handle
|
||||
if(hFind != NULL)
|
||||
SFileFindClose(hFind);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// Close both archives
|
||||
if(hMpq != NULL)
|
||||
//SFileCloseArchive(hMpq);
|
||||
if(nError == ERROR_SUCCESS)
|
||||
printf("\nExtract wmo complete (No errors)\n");
|
||||
|
||||
return nError;
|
||||
|
||||
}
|
||||
|
||||
void ExtractMapsFromMpq()
|
||||
{
|
||||
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ParsMapFiles()
|
||||
{
|
||||
char fn[512];
|
||||
char id_filename[64];
|
||||
char id[10];
|
||||
for (unsigned int i=0; i<map_count; i++)
|
||||
for (unsigned int i=0; i<map_count; ++i)
|
||||
{
|
||||
sprintf(id,"%03u",map_ids[i].id);
|
||||
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
||||
WDTFile WDT(fn,map_ids[i].name);
|
||||
if(WDT.init(id))
|
||||
{
|
||||
for (int x=0; x<64; x++)
|
||||
for (int x=0; x<64; ++x)
|
||||
{
|
||||
for (int y=0; y<64; y++)
|
||||
for (int y=0; y<64; ++y)
|
||||
{
|
||||
if (ADTFile*ADT = WDT.GetMap(x,y))
|
||||
{
|
||||
@@ -250,7 +240,6 @@ void ParsMapFiles()
|
||||
ADT->init(id_filename);
|
||||
delete ADT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,31 +248,28 @@ void ParsMapFiles()
|
||||
#if 0
|
||||
void ParsMapFiles()
|
||||
{
|
||||
|
||||
char fn[512];
|
||||
for (unsigned int i=0; i<map_count; i++)
|
||||
for (unsigned int i=0; i<map_count; ++i)
|
||||
{
|
||||
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
||||
WDTFile WDT(fn,map_ids[i].name);
|
||||
if(WDT.init())
|
||||
{
|
||||
for (int x=0; x<64; x++)
|
||||
for (int x=0; x<64; ++x)
|
||||
{
|
||||
for (int y=0; y<64; y++)
|
||||
for (int y=0; y<64; ++y)
|
||||
{
|
||||
if (ADTFile*ADT = WDT.GetMap(x,y))
|
||||
{
|
||||
ADT->init();
|
||||
delete ADT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
void getGamePath()
|
||||
{
|
||||
@@ -307,8 +293,6 @@ void getGamePath()
|
||||
#endif
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
int i;
|
||||
@@ -338,7 +322,7 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||
}
|
||||
|
||||
matches.reverse();
|
||||
for (std::list<std::string>::iterator i = matches.begin(); i != matches.end(); i++)
|
||||
for (std::list<std::string>::iterator i = matches.begin(); i != matches.end(); ++i)
|
||||
{
|
||||
pArchiveNames.push_back(i->c_str());
|
||||
}
|
||||
@@ -348,11 +332,8 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||
return(true);
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
||||
//srand((unsigned int)time(0));
|
||||
|
||||
bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
if(!hasInputPathParam)
|
||||
getGamePath();
|
||||
|
||||
@@ -408,11 +389,12 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
||||
// now, scan for the patch levels in the core dir
|
||||
printf("Loading patch levels from data directory.\n");
|
||||
sprintf(path, "%spatch", input_path);
|
||||
if (!scan_patches(path, pArchiveNames)) return(false);
|
||||
if (!scan_patches(path, pArchiveNames))
|
||||
return(false);
|
||||
|
||||
// now, scan for the patch levels in locale dirs
|
||||
printf("Loading patch levels from locale directories.\n");
|
||||
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); i++)
|
||||
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i)
|
||||
{
|
||||
printf("Locale: %s\n", i->c_str());
|
||||
sprintf(path, "%s%s\\patch-%s", input_path, i->c_str(), i->c_str());
|
||||
@@ -433,7 +415,7 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
||||
|
||||
// open locale expansion and common files
|
||||
printf("Opening data files from locale directories.\n");
|
||||
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); i++)
|
||||
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i)
|
||||
{
|
||||
printf("Locale: %s\n", i->c_str());
|
||||
sprintf(path, "%s%s\\lichking-locale-%s.mpq", input_path, i->c_str(), i->c_str());
|
||||
@@ -446,8 +428,6 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// return false it normal processing can not proceed
|
||||
|
||||
bool processArgv(int argc, char ** argv, char*versionString)
|
||||
{
|
||||
@@ -455,29 +435,43 @@ bool processArgv(int argc, char ** argv, char*versionString)
|
||||
hasInputPathParam = false;
|
||||
bool preciseVectorData = false;
|
||||
|
||||
for(int i=1; i< argc; ++i) {
|
||||
if(strcmp("-s",argv[i]) == 0) {
|
||||
for(int i=1; i< argc; ++i)
|
||||
{
|
||||
if(strcmp("-s",argv[i]) == 0)
|
||||
{
|
||||
preciseVectorData = false;
|
||||
} else if(strcmp("-d",argv[i]) == 0) {
|
||||
if((i+1)<argc) {
|
||||
}
|
||||
else if(strcmp("-d",argv[i]) == 0)
|
||||
{
|
||||
if((i+1)<argc)
|
||||
{
|
||||
hasInputPathParam = true;
|
||||
strcpy(input_path, argv[i+1]);
|
||||
if (input_path[strlen(input_path) - 1] != '\\' || input_path[strlen(input_path) - 1] != '/')
|
||||
strcat(input_path, "\\");
|
||||
++i;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
} else if(strcmp("-?",argv[1]) == 0) {
|
||||
}
|
||||
else if(strcmp("-?",argv[1]) == 0)
|
||||
{
|
||||
result = false;
|
||||
} else if(strcmp("-l",argv[i]) == 0) {
|
||||
}
|
||||
else if(strcmp("-l",argv[i]) == 0)
|
||||
{
|
||||
preciseVectorData = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!result) {
|
||||
if(!result)
|
||||
{
|
||||
printf("Extract %s.\n",versionString);
|
||||
printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
|
||||
printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n");
|
||||
@@ -529,28 +523,33 @@ int main(int argc, char ** argv)
|
||||
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++) {
|
||||
archives.push_back(new MPQArchive(archiveNames[i].c_str()));
|
||||
if(!gOpenArchives.Open(archiveNames))
|
||||
{
|
||||
printf("FATAL ERROR: None MPQ archive found by path '%s'. Use -d option with proper path.\n",input_path);
|
||||
return 1;
|
||||
}
|
||||
ExtractWmo(archiveNames);
|
||||
|
||||
// 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++)
|
||||
for(unsigned int x=0;x<map_count;++x)
|
||||
{
|
||||
map_ids[x].id=dbc->getRecord (x).getUInt(0);
|
||||
strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
|
||||
@@ -564,10 +563,11 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
|
||||
clreol();
|
||||
if(nError != ERROR_SUCCESS) {
|
||||
if(nError != ERROR_SUCCESS)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "wdtfile.h"
|
||||
#include "adtfile.h"
|
||||
|
||||
|
||||
char * wdtGetPlainName(char * FileName)
|
||||
{
|
||||
char * szTemp;
|
||||
@@ -20,7 +19,6 @@ WDTFile::WDTFile(char* file_name, char* file_name1):WDT(file_name)
|
||||
|
||||
bool WDTFile::init(char *map_id)
|
||||
{
|
||||
|
||||
if (WDT.isEof())
|
||||
{
|
||||
//printf("Can't find WDT file.\n");
|
||||
@@ -30,7 +28,6 @@ bool WDTFile::init(char *map_id)
|
||||
char fourcc[5];
|
||||
size_t size;
|
||||
|
||||
|
||||
const char dirname[] = "buildings\\dir";
|
||||
FILE *dirfile;
|
||||
dirfile = fopen(dirname, "ab");
|
||||
@@ -40,7 +37,6 @@ bool WDTFile::init(char *map_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
while (!WDT.isEof())
|
||||
{
|
||||
WDT.read(fourcc,4);
|
||||
@@ -75,8 +71,7 @@ bool WDTFile::init(char *map_id)
|
||||
delete[] buf;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!strcmp(fourcc,"MODF"))
|
||||
else if (!strcmp(fourcc,"MODF"))
|
||||
{
|
||||
// global wmo instance data
|
||||
if (size)
|
||||
@@ -87,7 +82,7 @@ bool WDTFile::init(char *map_id)
|
||||
fake_mapname = "65 65 ";
|
||||
//gWMO_mapname = fake_mapname + filename;
|
||||
gWMO_mapname = fake_mapname + std::string(map_id);
|
||||
for (int i=0; i<gnWMO; i++)
|
||||
for (int i=0; i<gnWMO; ++i)
|
||||
{
|
||||
int id;
|
||||
WDT.read(&id, 4);
|
||||
@@ -111,11 +106,11 @@ WDTFile::~WDTFile(void)
|
||||
|
||||
ADTFile* WDTFile::GetMap(int x, int z)
|
||||
{
|
||||
if(!(x>=0 && z >= 0 && x<64 && z<64)) return NULL;
|
||||
if(!(x>=0 && z >= 0 && x<64 && z<64))
|
||||
return NULL;
|
||||
|
||||
char name[512];
|
||||
|
||||
sprintf(name,"World\\Maps\\%s\\%s_%d_%d.adt", filename.c_str(), filename.c_str(), x, z);
|
||||
return new ADTFile(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,4 +28,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
WMORoot::WMORoot(std::string &filename) : filename(filename)
|
||||
{
|
||||
}
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
bool WMORoot::open()
|
||||
{
|
||||
|
||||
MPQFile f(filename.c_str());
|
||||
if(f.isEof ())
|
||||
{
|
||||
@@ -39,7 +36,6 @@ bool WMORoot::open()
|
||||
|
||||
if (!strcmp(fourcc,"MOHD"))//header
|
||||
{
|
||||
|
||||
f.read(&nTextures, 4);
|
||||
f.read(&nGroups, 4);
|
||||
f.read(&nP, 4);
|
||||
@@ -56,55 +52,42 @@ bool WMORoot::open()
|
||||
/*
|
||||
else if (!strcmp(fourcc,"MOTX"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOMT"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOGN"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOGI"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOLT"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MODN"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MODS"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MODD"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOSB"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOPV"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOPT"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOPR"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MFOG"))
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
f.seek((int)nextpos);
|
||||
@@ -112,7 +95,6 @@ bool WMORoot::open()
|
||||
f.close ();
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
|
||||
{
|
||||
@@ -125,16 +107,14 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
WMORoot::~WMORoot()
|
||||
{
|
||||
}
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
WMOGroup::WMOGroup(std::string &filename) : filename(filename)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool WMOGroup::open()
|
||||
{
|
||||
MPQFile f(filename.c_str());
|
||||
@@ -188,7 +168,6 @@ bool WMOGroup::open()
|
||||
{
|
||||
MOVI = new uint16[size/2];
|
||||
f.read(MOVI, size);
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOVT"))
|
||||
{
|
||||
@@ -222,26 +201,26 @@ bool WMOGroup::open()
|
||||
LiquEx = new float[sizeof(float) * 3 * noVer];
|
||||
int p = 0;
|
||||
|
||||
for (int j=0; j<hlq.yverts; j++)
|
||||
for (int j=0; j<hlq.yverts; ++j)
|
||||
{
|
||||
for (int i=0; i<hlq.xverts; i++)
|
||||
for (int i=0; i<hlq.xverts; ++i)
|
||||
{
|
||||
LiquEx[p++] = hlq.pos_x + tilesize * i;
|
||||
LiquEx[p++] = hlq.pos_z;
|
||||
LiquEx[p++] = ydir * (hlq.pos_y + tilesize * j);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
f.seek((int)nextpos);
|
||||
}
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
{
|
||||
if(pPreciseVectorData) {
|
||||
if(pPreciseVectorData)
|
||||
{
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
char GRP[] = "GRP ";
|
||||
fwrite(GRP,1,4,output);
|
||||
@@ -262,20 +241,54 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
|
||||
uint32 nIdexes = nTriangles * 3;
|
||||
|
||||
if(fwrite("INDX",4, 1, output) != 1) { printf("Error while writing file nbraches ID"); exit(0); }
|
||||
if(fwrite("INDX",4, 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nbraches ID");
|
||||
exit(0);
|
||||
}
|
||||
int wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes;
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); }
|
||||
if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1) { printf("Error while writing file nIndexes"); exit(0); }
|
||||
if(nIdexes >0) {
|
||||
if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes) { printf("Error while writing file indexarray"); exit(0); }
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file wsize");
|
||||
// no need to exit?
|
||||
}
|
||||
if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nIndexes");
|
||||
exit(0);
|
||||
}
|
||||
if(nIdexes >0)
|
||||
{
|
||||
if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes)
|
||||
{
|
||||
printf("Error while writing file indexarray");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(fwrite("VERT",4, 1, output) != 1) { printf("Error while writing file nbraches ID"); exit(0); }
|
||||
if(fwrite("VERT",4, 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nbraches ID");
|
||||
exit(0);
|
||||
}
|
||||
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); }
|
||||
if(fwrite(&nVertices, sizeof(int), 1, output) != 1) { printf("Error while writing file nVertices"); exit(0); }
|
||||
if(nVertices >0) {
|
||||
if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices) { printf("Error while writing file vectors"); exit(0); }
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file wsize");
|
||||
// no need to exit?
|
||||
}
|
||||
if(fwrite(&nVertices, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nVertices");
|
||||
exit(0);
|
||||
}
|
||||
if(nVertices >0)
|
||||
{
|
||||
if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices)
|
||||
{
|
||||
printf("Error while writing file vectors");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(LiquEx_size != 0)
|
||||
@@ -287,7 +300,9 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
}
|
||||
|
||||
return nTriangles;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("Convert GroupWmo...\n");
|
||||
//-------GRP -------------------------------------
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
@@ -336,11 +351,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
//---------MOVI-----------
|
||||
MoviEx = new uint16[IndexExTr_size*3];
|
||||
int m = 0;
|
||||
for (int i=0; i<IndexExTr_size; i++)
|
||||
for (int i=0; i<IndexExTr_size; ++i)
|
||||
{
|
||||
int n = 0;
|
||||
n = IndexExTr[i]*3;
|
||||
for (int x=0; x<3; x++)
|
||||
for (int x=0; x<3; ++x)
|
||||
{
|
||||
MoviEx[m] = MOVI[n];
|
||||
n++;
|
||||
@@ -350,15 +365,15 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
delete [] MOVI;
|
||||
|
||||
MoviExSort = new uint16[IndexExTr_size*3];
|
||||
for(int y=0; y<IndexExTr_size*3; y++)
|
||||
for(int y=0; y<IndexExTr_size*3; ++y)
|
||||
{
|
||||
MoviExSort[y]=MoviEx[y];
|
||||
}
|
||||
|
||||
uint16 hold;
|
||||
for (int pass = 1; pass < IndexExTr_size*3; pass++)
|
||||
for (int pass = 1; pass < IndexExTr_size*3; ++pass)
|
||||
{
|
||||
for (int i=0; i < IndexExTr_size*3-1; i++)
|
||||
for (int i=0; i < IndexExTr_size*3-1; ++i)
|
||||
{
|
||||
if (MoviExSort[i] > MoviExSort[i+1])
|
||||
{
|
||||
@@ -374,7 +389,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
}
|
||||
// double delet
|
||||
uint16 s = 0;
|
||||
for (int i=0; i < IndexExTr_size*3; i++)
|
||||
for (int i=0; i < IndexExTr_size*3; ++i)
|
||||
{
|
||||
if (MoviExSort[i]!=65535)
|
||||
{
|
||||
@@ -383,24 +398,22 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
}
|
||||
}
|
||||
MovtExSort = new uint16[s];
|
||||
for (int i=0; i < s; i++)
|
||||
for (int i=0; i < s; ++i)
|
||||
{
|
||||
MovtExSort[i] = MoviExSort[i];
|
||||
}
|
||||
|
||||
for (int i=0; i < IndexExTr_size*3; i++)
|
||||
for (int i=0; i < IndexExTr_size*3; ++i)
|
||||
{
|
||||
uint16 b = MoviEx[i];
|
||||
for (uint16 x = 0; x < s; x++)
|
||||
for (uint16 x = 0; x < s; ++x)
|
||||
{
|
||||
if(MoviExSort[x] == b)
|
||||
{
|
||||
|
||||
MoviEx[i] = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
int INDX[] = {0x58444E49,IndexExTr_size*6+4,IndexExTr_size*3};
|
||||
fwrite(INDX,4,3,output);
|
||||
@@ -414,11 +427,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
//-----MOVT----------
|
||||
int d = 0;
|
||||
MovtEx = new float[s*3];
|
||||
for (uint16 i=0; i<s; i++)
|
||||
for (uint16 i=0; i<s; ++i)
|
||||
{
|
||||
int c=0;//!!!!data in MovtExSort[i] more uint16 in great group wmo files!!!!
|
||||
c = MovtExSort[i]*3;
|
||||
for (int y=0; y<3; y++)
|
||||
for (int y=0; y<3; ++y)
|
||||
{
|
||||
MovtEx[d] = MOVT[c];
|
||||
c++;
|
||||
@@ -491,18 +504,17 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
||||
sprintf(tempname, "buildings\\%s", WmoInstName);
|
||||
FILE *input;
|
||||
input = fopen(tempname, "r+b");
|
||||
|
||||
if(!input)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(input, 8, SEEK_SET); // get the correct no of vertices
|
||||
int nVertices;
|
||||
fread(&nVertices, sizeof (int), 1, input);
|
||||
fclose(input);
|
||||
|
||||
if(nVertices == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* FILE *dirfile;
|
||||
dirfile = fopen(dirname, "ab");
|
||||
@@ -516,7 +528,11 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
||||
x = pos.x;
|
||||
z = pos.z;
|
||||
if(x==0 && z == 0)
|
||||
{ x = 533.33333f*32; z = 533.33333f*32; }
|
||||
{
|
||||
x = 533.33333f*32;
|
||||
z = 533.33333f*32;
|
||||
}
|
||||
|
||||
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f 1.0 %d %d %d,%d %d\n",
|
||||
MapName,
|
||||
WmoInstName,
|
||||
@@ -529,8 +545,3 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
||||
|
||||
// fclose(dirfile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,13 +43,11 @@ public:
|
||||
private:
|
||||
std::string filename;
|
||||
char outfilename;
|
||||
|
||||
};
|
||||
|
||||
class WMOGroup
|
||||
{
|
||||
public:
|
||||
|
||||
int offsize,flag,flag1,Xid,Xid2,Xid3,zero1,Xflag,nTexture,GroupID;
|
||||
int mopy_size,moba_size,hlq_xverts,hlq_yverts;
|
||||
int MopyEx_size,IndexExTr_size,LiquEx_size;
|
||||
@@ -82,7 +80,6 @@ public:
|
||||
private:
|
||||
std::string filename;
|
||||
char outfilename;
|
||||
|
||||
};
|
||||
|
||||
struct WMOLiquidHeader
|
||||
@@ -113,4 +110,3 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user