[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:
@@ -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,8 +70,7 @@ bool ADTFile::init(char *map_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
while (!ADT.isEof ())
|
||||
while (!ADT.isEof())
|
||||
{
|
||||
char fourcc[5];
|
||||
ADT.read(&fourcc,4);
|
||||
@@ -77,18 +78,16 @@ bool ADTFile::init(char *map_id)
|
||||
flipcc(fourcc);
|
||||
fourcc[4] = 0;
|
||||
|
||||
size_t nextpos = ADT.getPos () + size;
|
||||
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;
|
||||
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);
|
||||
fclose(output);
|
||||
}
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MWMO"))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
|
||||
char *buf = new char[size];
|
||||
ADT.read(buf, size);
|
||||
char *p=buf;
|
||||
@@ -148,23 +151,21 @@ bool ADTFile::init(char *map_id)
|
||||
WmoInstansName[q++] = s;
|
||||
}
|
||||
delete[] buf;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//======================
|
||||
else if (!strcmp(fourcc,"MDDF"))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; i++)
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
ModelInstance inst(ADT,ModelInstansName[id].c_str(),map_id, dirfile);//!!!!!!!!!!!
|
||||
}
|
||||
delete[] ModelInstansName;
|
||||
delete[] ModelInstansName;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(fourcc,"MODF"))
|
||||
@@ -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);
|
||||
@@ -187,14 +188,14 @@ bool ADTFile::init(char *map_id)
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; i++)
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
ModelInstance inst(ADT,ModelInstansName[id].c_str(),AdtMapNumber.c_str(), dirfile);
|
||||
}
|
||||
delete[] ModelInstansName;
|
||||
delete[] ModelInstansName;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(fourcc,"MODF"))
|
||||
@@ -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,43 +17,48 @@ typedef unsigned int uint32;
|
||||
|
||||
class Liquid;
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
}svec;
|
||||
|
||||
typedef struct {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
}vec;
|
||||
struct vec
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
};
|
||||
|
||||
typedef struct{
|
||||
struct triangle
|
||||
{
|
||||
vec v[3];
|
||||
};
|
||||
|
||||
}triangle;
|
||||
|
||||
typedef struct{
|
||||
float v9[16*8+1][16*8+1];
|
||||
float v8[16*8][16*8];
|
||||
typedef struct
|
||||
{
|
||||
float v9[16*8+1][16*8+1];
|
||||
float v8[16*8][16*8];
|
||||
}Cell;
|
||||
|
||||
typedef struct{
|
||||
double v9[9][9];
|
||||
double v8[8][8];
|
||||
uint16 area_id;
|
||||
//Liquid *lq;
|
||||
float waterlevel[9][9];
|
||||
uint8 flag;
|
||||
typedef struct
|
||||
{
|
||||
double v9[9][9];
|
||||
double v8[8][8];
|
||||
uint16 area_id;
|
||||
//Liquid *lq;
|
||||
float waterlevel[9][9];
|
||||
uint8 flag;
|
||||
}chunk;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
chunk ch[16][16];
|
||||
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
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ bool Model::open()
|
||||
|
||||
ok = !f.isEof();
|
||||
|
||||
if (!ok)
|
||||
if (!ok)
|
||||
{
|
||||
f.close();
|
||||
printf("Error loading model %s\n", filename.c_str());
|
||||
@@ -20,20 +20,20 @@ bool Model::open()
|
||||
}
|
||||
|
||||
memcpy(&header, f.getBuffer(), sizeof(ModelHeader));
|
||||
if(header.nBoundingTriangles > 0)
|
||||
if(header.nBoundingTriangles > 0)
|
||||
{
|
||||
f.seek(0);
|
||||
f.seekRelative(header.ofsBoundingVertices);
|
||||
vertices = new Vec3D[header.nBoundingVertices];
|
||||
f.read(vertices,header.nBoundingVertices*12);
|
||||
f.seekRelative(header.ofsBoundingVertices);
|
||||
vertices = new Vec3D[header.nBoundingVertices];
|
||||
f.read(vertices,header.nBoundingVertices*12);
|
||||
for (uint32 i=0; i<header.nBoundingVertices; i++)
|
||||
{
|
||||
vertices[i] = fixCoordSystem(vertices[i]);
|
||||
}
|
||||
f.seek(0);
|
||||
f.seekRelative(header.ofsBoundingTriangles);
|
||||
indices = new uint16[header.nBoundingTriangles];
|
||||
f.read(indices,header.nBoundingTriangles*2);
|
||||
f.seekRelative(header.ofsBoundingTriangles);
|
||||
indices = new uint16[header.nBoundingTriangles];
|
||||
f.read(indices,header.nBoundingTriangles*2);
|
||||
f.close();
|
||||
}
|
||||
else
|
||||
@@ -45,10 +45,8 @@ bool Model::open()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Model::ConvertToVMAPModel(char * outfilename)
|
||||
{
|
||||
|
||||
int N[] = {0x00000000};
|
||||
FILE * output=fopen(outfilename,"wb");
|
||||
if(!output)
|
||||
@@ -76,7 +74,7 @@ bool Model::ConvertToVMAPModel(char * outfilename)
|
||||
wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
|
||||
fwrite(&wsize, sizeof(int), 1, output);
|
||||
fwrite(&nIndexes, sizeof(uint32), 1, output);
|
||||
if(nIndexes >0)
|
||||
if(nIndexes >0)
|
||||
{
|
||||
fwrite(indices, sizeof(unsigned short), nIndexes, output);
|
||||
}
|
||||
@@ -84,7 +82,7 @@ bool Model::ConvertToVMAPModel(char * outfilename)
|
||||
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
|
||||
fwrite(&wsize, sizeof(int), 1, output);
|
||||
fwrite(&nVertices, sizeof(int), 1, output);
|
||||
if(nVertices >0)
|
||||
if(nVertices >0)
|
||||
{
|
||||
for(uint32 vpos=0; vpos <nVertices; ++vpos)
|
||||
{
|
||||
@@ -133,27 +131,25 @@ 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)
|
||||
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)
|
||||
{
|
||||
int realx1 = (int) ((float) pos.x / 533.333333f);
|
||||
int realy1 = (int) ((float) pos.z / 533.333333f);
|
||||
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,
|
||||
@@ -163,7 +159,6 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
|
||||
nVertices,
|
||||
realx1, realy1,
|
||||
realx2, realy2
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,51 +11,41 @@ class WMOInstance;
|
||||
|
||||
Vec3D fixCoordSystem(Vec3D v);
|
||||
|
||||
|
||||
|
||||
|
||||
class Model
|
||||
{
|
||||
{
|
||||
public:
|
||||
ModelHeader header;
|
||||
uint32 offsBB_vertices, offsBB_indices;
|
||||
Vec3D *BB_vertices, *vertices;
|
||||
uint16 *BB_indices, *indices;
|
||||
size_t nIndices;
|
||||
|
||||
ModelHeader header;
|
||||
|
||||
public:
|
||||
bool open();
|
||||
bool ConvertToVMAPModel(char * outfilename);
|
||||
|
||||
uint32 offsBB_vertices, offsBB_indices;
|
||||
Vec3D *BB_vertices, *vertices;
|
||||
uint16 *BB_indices, *indices;
|
||||
size_t nIndices;
|
||||
|
||||
bool open();
|
||||
bool ConvertToVMAPModel(char * outfilename);
|
||||
bool ok;
|
||||
|
||||
public:
|
||||
Model(std::string &filename);
|
||||
~Model();
|
||||
|
||||
bool ok;
|
||||
|
||||
Model(std::string &filename);
|
||||
~Model();
|
||||
|
||||
private:
|
||||
std::string filename;
|
||||
char outfilename;
|
||||
std::string filename;
|
||||
char outfilename;
|
||||
};
|
||||
|
||||
class ModelInstance
|
||||
{
|
||||
public:
|
||||
Model *model;
|
||||
Model *model;
|
||||
|
||||
int id;
|
||||
Vec3D pos, rot;
|
||||
unsigned int d1, scale;
|
||||
float w,sc;
|
||||
int id;
|
||||
Vec3D pos, rot;
|
||||
unsigned int d1, scale;
|
||||
float w,sc;
|
||||
|
||||
ModelInstance() {}
|
||||
ModelInstance(MPQFile &f,const char* ModelInstName,const char*MapName, FILE *pDirfile);
|
||||
ModelInstance() {}
|
||||
ModelInstance(MPQFile &f,const char* ModelInstName,const char*MapName, FILE *pDirfile);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,74 +10,72 @@ typedef int int32;
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct ModelHeader {
|
||||
char id[4];
|
||||
uint8 version[4];
|
||||
uint32 nameLength;
|
||||
uint32 nameOfs;
|
||||
uint32 type;
|
||||
uint32 nGlobalSequences;
|
||||
uint32 ofsGlobalSequences;
|
||||
uint32 nAnimations;
|
||||
uint32 ofsAnimations;
|
||||
struct ModelHeader
|
||||
{
|
||||
char id[4];
|
||||
uint8 version[4];
|
||||
uint32 nameLength;
|
||||
uint32 nameOfs;
|
||||
uint32 type;
|
||||
uint32 nGlobalSequences;
|
||||
uint32 ofsGlobalSequences;
|
||||
uint32 nAnimations;
|
||||
uint32 ofsAnimations;
|
||||
uint32 nAnimationLookup;
|
||||
uint32 ofsAnimationLookup;
|
||||
uint32 nBones;
|
||||
uint32 ofsBones;
|
||||
uint32 nKeyBoneLookup;
|
||||
uint32 ofsKeyBoneLookup;
|
||||
uint32 nVertices;
|
||||
uint32 ofsVertices;
|
||||
uint32 nViews;
|
||||
uint32 nColors;
|
||||
uint32 ofsColors;
|
||||
uint32 nTextures;
|
||||
uint32 ofsTextures;
|
||||
uint32 nTransparency;
|
||||
uint32 ofsTransparency;
|
||||
uint32 nTextureanimations;
|
||||
uint32 ofsTextureanimations;
|
||||
uint32 nTexReplace;
|
||||
uint32 ofsTexReplace;
|
||||
uint32 nRenderFlags;
|
||||
uint32 ofsRenderFlags;
|
||||
uint32 nBoneLookupTable;
|
||||
uint32 ofsBoneLookupTable;
|
||||
uint32 nTexLookup;
|
||||
uint32 ofsTexLookup;
|
||||
uint32 nTexUnits;
|
||||
uint32 ofsTexUnits;
|
||||
uint32 nTransLookup;
|
||||
uint32 ofsTransLookup;
|
||||
uint32 nTexAnimLookup;
|
||||
uint32 ofsTexAnimLookup;
|
||||
float floats[14];
|
||||
uint32 nBoundingTriangles;
|
||||
uint32 ofsBoundingTriangles;
|
||||
uint32 nBoundingVertices;
|
||||
uint32 ofsBoundingVertices;
|
||||
uint32 nBoundingNormals;
|
||||
uint32 ofsBoundingNormals;
|
||||
uint32 nAttachments;
|
||||
uint32 ofsAttachments;
|
||||
uint32 nAttachLookup;
|
||||
uint32 ofsAttachLookup;
|
||||
uint32 nAttachments_2;
|
||||
uint32 ofsAttachments_2;
|
||||
uint32 nLights;
|
||||
uint32 ofsLights;
|
||||
uint32 nCameras;
|
||||
uint32 ofsCameras;
|
||||
uint32 nCameraLookup;
|
||||
uint32 ofsCameraLookup;
|
||||
uint32 nRibbonEmitters;
|
||||
uint32 ofsRibbonEmitters;
|
||||
uint32 nParticleEmitters;
|
||||
uint32 ofsParticleEmitters;
|
||||
uint32 nKeyBoneLookup;
|
||||
uint32 ofsKeyBoneLookup;
|
||||
uint32 nVertices;
|
||||
uint32 ofsVertices;
|
||||
uint32 nViews;
|
||||
uint32 nColors;
|
||||
uint32 ofsColors;
|
||||
uint32 nTextures;
|
||||
uint32 ofsTextures;
|
||||
uint32 nTransparency;
|
||||
uint32 ofsTransparency;
|
||||
uint32 nTextureanimations;
|
||||
uint32 ofsTextureanimations;
|
||||
uint32 nTexReplace;
|
||||
uint32 ofsTexReplace;
|
||||
uint32 nRenderFlags;
|
||||
uint32 ofsRenderFlags;
|
||||
uint32 nBoneLookupTable;
|
||||
uint32 ofsBoneLookupTable;
|
||||
uint32 nTexLookup;
|
||||
uint32 ofsTexLookup;
|
||||
uint32 nTexUnits;
|
||||
uint32 ofsTexUnits;
|
||||
uint32 nTransLookup;
|
||||
uint32 ofsTransLookup;
|
||||
uint32 nTexAnimLookup;
|
||||
uint32 ofsTexAnimLookup;
|
||||
float floats[14];
|
||||
uint32 nBoundingTriangles;
|
||||
uint32 ofsBoundingTriangles;
|
||||
uint32 nBoundingVertices;
|
||||
uint32 ofsBoundingVertices;
|
||||
uint32 nBoundingNormals;
|
||||
uint32 ofsBoundingNormals;
|
||||
uint32 nAttachments;
|
||||
uint32 ofsAttachments;
|
||||
uint32 nAttachLookup;
|
||||
uint32 ofsAttachLookup;
|
||||
uint32 nAttachments_2;
|
||||
uint32 ofsAttachments_2;
|
||||
uint32 nLights;
|
||||
uint32 ofsLights;
|
||||
uint32 nCameras;
|
||||
uint32 ofsCameras;
|
||||
uint32 nCameraLookup;
|
||||
uint32 ofsCameraLookup;
|
||||
uint32 nRibbonEmitters;
|
||||
uint32 ofsRibbonEmitters;
|
||||
uint32 nParticleEmitters;
|
||||
uint32 ofsParticleEmitters;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,24 +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()
|
||||
@@ -28,41 +20,57 @@ 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 = "";
|
||||
hMPQ = i->hMPQ;
|
||||
BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
|
||||
if (succ)
|
||||
{
|
||||
DWORD s = SFileGetFileSize(hFile, 0);
|
||||
if (!s)
|
||||
{
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
return;
|
||||
}
|
||||
size = (size_t)s;
|
||||
buffer = new char[s];
|
||||
SFileReadFile(hFile, buffer, s, 0, 0);
|
||||
SFileCloseFile(hFile);
|
||||
|
||||
HANDLE hFile = "";
|
||||
MPQArchive*(hMPQ) = *i;
|
||||
BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
|
||||
if (succ)
|
||||
{
|
||||
DWORD s = SFileGetFileSize(hFile, 0);
|
||||
if (!s)
|
||||
{
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
eof = false;
|
||||
return;
|
||||
}
|
||||
size = (size_t)s;
|
||||
buffer = new char[s];
|
||||
SFileReadFile(hFile, buffer, s, 0, 0);
|
||||
SFileCloseFile(hFile);
|
||||
|
||||
eof = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
|
||||
}
|
||||
|
||||
MPQFile::~MPQFile()
|
||||
@@ -73,7 +81,7 @@ MPQFile::~MPQFile()
|
||||
size_t MPQFile::read(void* dest, size_t bytes)
|
||||
{
|
||||
if (eof)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
size_t rpos = pointer + bytes;
|
||||
if (rpos > size)
|
||||
@@ -109,7 +117,7 @@ void MPQFile::seekRelative(int offset)
|
||||
void MPQFile::close()
|
||||
{
|
||||
if (buffer)
|
||||
delete[] buffer;
|
||||
delete[] buffer;
|
||||
buffer = 0;
|
||||
eof = true;
|
||||
}
|
||||
@@ -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();
|
||||
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))
|
||||
@@ -167,17 +160,17 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||
bResult = SFileFindNextFile(hFind, &wf);
|
||||
continue;
|
||||
}
|
||||
FILE *output=fopen(szLocalFile,"wb");
|
||||
FILE *output=fopen(szLocalFile,"wb");
|
||||
froot->ConvertToVMAPRootWmo(output);
|
||||
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");
|
||||
|
||||
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");
|
||||
@@ -490,7 +484,7 @@ bool processArgv(int argc, char ** argv, char*versionString)
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// Main
|
||||
//
|
||||
//
|
||||
// The program must be run with two command line arguments
|
||||
//
|
||||
// Arg1 - The source MPQ name (for testing reading and file find)
|
||||
@@ -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);
|
||||
|
||||
//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++)
|
||||
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,17 +19,15 @@ 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");
|
||||
return false;
|
||||
//printf("Can't find WDT file.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
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,13 +82,13 @@ 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);
|
||||
WMOInstance inst(WDT,gWmoInstansName[id].c_str(),gWMO_mapname.c_str(), dirfile);
|
||||
}
|
||||
delete[] gWmoInstansName;
|
||||
delete[] gWmoInstansName;
|
||||
}
|
||||
}
|
||||
WDT.seek((int)nextpos);
|
||||
@@ -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 ())
|
||||
{
|
||||
@@ -27,7 +24,7 @@ bool WMORoot::open()
|
||||
bbcorn1[3] = 0;
|
||||
bbcorn2[3]= 0;
|
||||
|
||||
while (!f.isEof ())
|
||||
while (!f.isEof())
|
||||
{
|
||||
f.read(fourcc,4);
|
||||
f.read(&size, 4);
|
||||
@@ -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());
|
||||
@@ -147,7 +127,7 @@ bool WMOGroup::open()
|
||||
char fourcc[5];
|
||||
bbcorn1[3] = 0;
|
||||
bbcorn2[3] = 0;
|
||||
while (!f.isEof ())
|
||||
while (!f.isEof())
|
||||
{
|
||||
f.read(fourcc,4);
|
||||
f.read(&size, 4);
|
||||
@@ -188,7 +168,6 @@ bool WMOGroup::open()
|
||||
{
|
||||
MOVI = new uint16[size/2];
|
||||
f.read(MOVI, size);
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOVT"))
|
||||
{
|
||||
@@ -222,228 +201,262 @@ 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 ();
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
{
|
||||
if(pPreciseVectorData) {
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
char GRP[] = "GRP ";
|
||||
fwrite(GRP,1,4,output);
|
||||
if(pPreciseVectorData)
|
||||
{
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
char GRP[] = "GRP ";
|
||||
fwrite(GRP,1,4,output);
|
||||
|
||||
int k = 0;
|
||||
int moba_batch = moba_size/12;
|
||||
MobaEx = new int[moba_batch*4];
|
||||
for(int i=8; i<moba_size; i+=12)
|
||||
{
|
||||
MobaEx[k++] = MOBA[i];
|
||||
}
|
||||
delete [] MOBA;
|
||||
int moba_size_grp = moba_batch*4+4;
|
||||
fwrite(&moba_size_grp,4,1,output);
|
||||
fwrite(&moba_batch,4,1,output);
|
||||
fwrite(MobaEx,4,k,output);
|
||||
delete [] MobaEx;
|
||||
int k = 0;
|
||||
int moba_batch = moba_size/12;
|
||||
MobaEx = new int[moba_batch*4];
|
||||
for(int i=8; i<moba_size; i+=12)
|
||||
{
|
||||
MobaEx[k++] = MOBA[i];
|
||||
}
|
||||
delete [] MOBA;
|
||||
int moba_size_grp = moba_batch*4+4;
|
||||
fwrite(&moba_size_grp,4,1,output);
|
||||
fwrite(&moba_batch,4,1,output);
|
||||
fwrite(MobaEx,4,k,output);
|
||||
delete [] MobaEx;
|
||||
|
||||
uint32 nIdexes = nTriangles * 3;
|
||||
uint32 nIdexes = nTriangles * 3;
|
||||
|
||||
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("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");
|
||||
// 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); }
|
||||
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("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");
|
||||
// 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)
|
||||
{
|
||||
int LIQU_h[] = {0x5551494C,LiquEx_size+8,hlq_xverts,hlq_yverts};// "LIQU"
|
||||
fwrite(LIQU_h,4,4,output);
|
||||
fwrite(LiquEx,4,LiquEx_size/4,output);
|
||||
delete [] LiquEx;
|
||||
}
|
||||
if(LiquEx_size != 0)
|
||||
{
|
||||
int LIQU_h[] = {0x5551494C,LiquEx_size+8,hlq_xverts,hlq_yverts};// "LIQU"
|
||||
fwrite(LIQU_h,4,4,output);
|
||||
fwrite(LiquEx,4,LiquEx_size/4,output);
|
||||
delete [] LiquEx;
|
||||
}
|
||||
|
||||
return nTriangles;
|
||||
} else {
|
||||
//printf("Convert GroupWmo...\n");
|
||||
//-------GRP -------------------------------------
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
char GRP[] = "GRP ";
|
||||
fwrite(GRP,1,4,output);
|
||||
int k = 0;
|
||||
int moba_batch = moba_size/12;
|
||||
MobaEx = new int[moba_batch*4];
|
||||
for(int i=8; i<moba_size; i+=12)
|
||||
{
|
||||
MobaEx[k++] = MOBA[i];
|
||||
}
|
||||
delete [] MOBA;
|
||||
int moba_size_grp = moba_batch*4+4;
|
||||
fwrite(&moba_size_grp,4,1,output);
|
||||
fwrite(&moba_batch,4,1,output);
|
||||
fwrite(MobaEx,4,k,output);
|
||||
delete [] MobaEx;
|
||||
return nTriangles;
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("Convert GroupWmo...\n");
|
||||
//-------GRP -------------------------------------
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
char GRP[] = "GRP ";
|
||||
fwrite(GRP,1,4,output);
|
||||
int k = 0;
|
||||
int moba_batch = moba_size/12;
|
||||
MobaEx = new int[moba_batch*4];
|
||||
for(int i=8; i<moba_size; i+=12)
|
||||
{
|
||||
MobaEx[k++] = MOBA[i];
|
||||
}
|
||||
delete [] MOBA;
|
||||
int moba_size_grp = moba_batch*4+4;
|
||||
fwrite(&moba_size_grp,4,1,output);
|
||||
fwrite(&moba_batch,4,1,output);
|
||||
fwrite(MobaEx,4,k,output);
|
||||
delete [] MobaEx;
|
||||
|
||||
//-------INDX------------------------------------
|
||||
//-------MOPY--------
|
||||
int n = 0;
|
||||
int j = 0;
|
||||
MopyEx = new char[mopy_size];
|
||||
IndexExTr = new int[mopy_size];
|
||||
for (int i=0; i<mopy_size; i+=2)
|
||||
{
|
||||
//-------INDX------------------------------------
|
||||
//-------MOPY--------
|
||||
int n = 0;
|
||||
int j = 0;
|
||||
MopyEx = new char[mopy_size];
|
||||
IndexExTr = new int[mopy_size];
|
||||
for (int i=0; i<mopy_size; i+=2)
|
||||
{
|
||||
// Skip no collision triangles
|
||||
if ((int)MOPY[i]&WMO_MATERIAL_NO_COLLISION)
|
||||
continue;
|
||||
// Use only this triangles
|
||||
if ((int)MOPY[i]&(WMO_MATERIAL_HINT|WMO_MATERIAL_COLLIDE_HIT))
|
||||
{
|
||||
MopyEx[n] = MOPY[i];
|
||||
MopyEx[(n+1)] = MOPY[(i+1)];
|
||||
IndexExTr[j] = i/2;
|
||||
j+=1;
|
||||
n+=2;
|
||||
}
|
||||
}
|
||||
MopyEx_size = n;
|
||||
IndexExTr_size = j;
|
||||
delete [] MOPY;
|
||||
delete [] MopyEx;
|
||||
{
|
||||
MopyEx[n] = MOPY[i];
|
||||
MopyEx[(n+1)] = MOPY[(i+1)];
|
||||
IndexExTr[j] = i/2;
|
||||
j+=1;
|
||||
n+=2;
|
||||
}
|
||||
}
|
||||
MopyEx_size = n;
|
||||
IndexExTr_size = j;
|
||||
delete [] MOPY;
|
||||
delete [] MopyEx;
|
||||
|
||||
//---------MOVI-----------
|
||||
MoviEx = new uint16[IndexExTr_size*3];
|
||||
int m = 0;
|
||||
for (int i=0; i<IndexExTr_size; i++)
|
||||
{
|
||||
int n = 0;
|
||||
n = IndexExTr[i]*3;
|
||||
for (int x=0; x<3; x++)
|
||||
{
|
||||
MoviEx[m] = MOVI[n];
|
||||
n++;
|
||||
m++;
|
||||
}
|
||||
}
|
||||
delete [] MOVI;
|
||||
//---------MOVI-----------
|
||||
MoviEx = new uint16[IndexExTr_size*3];
|
||||
int m = 0;
|
||||
for (int i=0; i<IndexExTr_size; ++i)
|
||||
{
|
||||
int n = 0;
|
||||
n = IndexExTr[i]*3;
|
||||
for (int x=0; x<3; ++x)
|
||||
{
|
||||
MoviEx[m] = MOVI[n];
|
||||
n++;
|
||||
m++;
|
||||
}
|
||||
}
|
||||
delete [] MOVI;
|
||||
|
||||
MoviExSort = new uint16[IndexExTr_size*3];
|
||||
for(int y=0; y<IndexExTr_size*3; y++)
|
||||
{
|
||||
MoviExSort[y]=MoviEx[y];
|
||||
}
|
||||
MoviExSort = new uint16[IndexExTr_size*3];
|
||||
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 i=0; i < IndexExTr_size*3-1; i++)
|
||||
{
|
||||
if (MoviExSort[i] > MoviExSort[i+1])
|
||||
{
|
||||
hold = MoviExSort[i];
|
||||
MoviExSort[i] = MoviExSort[i+1];
|
||||
MoviExSort[i+1] = hold;
|
||||
}
|
||||
//double = 65535
|
||||
else
|
||||
if (MoviExSort[i] == MoviExSort[i+1])
|
||||
MoviExSort[i+1] = 65535;
|
||||
}
|
||||
}
|
||||
// double delet
|
||||
uint16 s = 0;
|
||||
for (int i=0; i < IndexExTr_size*3; i++)
|
||||
{
|
||||
if (MoviExSort[i]!=65535)
|
||||
{
|
||||
MoviExSort[s] = MoviExSort[i];
|
||||
s++;
|
||||
}
|
||||
}
|
||||
MovtExSort = new uint16[s];
|
||||
for (int i=0; i < s; i++)
|
||||
{
|
||||
MovtExSort[i] = MoviExSort[i];
|
||||
}
|
||||
uint16 hold;
|
||||
for (int pass = 1; pass < IndexExTr_size*3; ++pass)
|
||||
{
|
||||
for (int i=0; i < IndexExTr_size*3-1; ++i)
|
||||
{
|
||||
if (MoviExSort[i] > MoviExSort[i+1])
|
||||
{
|
||||
hold = MoviExSort[i];
|
||||
MoviExSort[i] = MoviExSort[i+1];
|
||||
MoviExSort[i+1] = hold;
|
||||
}
|
||||
//double = 65535
|
||||
else
|
||||
if (MoviExSort[i] == MoviExSort[i+1])
|
||||
MoviExSort[i+1] = 65535;
|
||||
}
|
||||
}
|
||||
// double delet
|
||||
uint16 s = 0;
|
||||
for (int i=0; i < IndexExTr_size*3; ++i)
|
||||
{
|
||||
if (MoviExSort[i]!=65535)
|
||||
{
|
||||
MoviExSort[s] = MoviExSort[i];
|
||||
s++;
|
||||
}
|
||||
}
|
||||
MovtExSort = new uint16[s];
|
||||
for (int i=0; i < s; ++i)
|
||||
{
|
||||
MovtExSort[i] = MoviExSort[i];
|
||||
}
|
||||
|
||||
for (int i=0; i < IndexExTr_size*3; i++)
|
||||
{
|
||||
uint16 b = MoviEx[i];
|
||||
for (uint16 x = 0; x < s; x++)
|
||||
{
|
||||
if(MoviExSort[x] == b)
|
||||
{
|
||||
for (int i=0; i < IndexExTr_size*3; ++i)
|
||||
{
|
||||
uint16 b = MoviEx[i];
|
||||
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);
|
||||
fwrite(MoviEx,2,IndexExTr_size*3,output);
|
||||
|
||||
MoviEx[i] = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete [] MoviEx;
|
||||
delete [] MoviExSort;
|
||||
delete [] IndexExTr;
|
||||
|
||||
}
|
||||
int INDX[] = {0x58444E49,IndexExTr_size*6+4,IndexExTr_size*3};
|
||||
fwrite(INDX,4,3,output);
|
||||
fwrite(MoviEx,2,IndexExTr_size*3,output);
|
||||
//----------VERT---------
|
||||
//-----MOVT----------
|
||||
int d = 0;
|
||||
MovtEx = new float[s*3];
|
||||
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)
|
||||
{
|
||||
MovtEx[d] = MOVT[c];
|
||||
c++;
|
||||
d++;
|
||||
}
|
||||
}
|
||||
int VERT[] = {0x54524556,d*4+4,d*4/12};// "VERT"
|
||||
fwrite(VERT,4,3,output);
|
||||
fwrite(MovtEx,4,d,output);
|
||||
//------LIQU------------------------
|
||||
if(LiquEx_size != 0)
|
||||
{
|
||||
int LIQU_h[] = {0x5551494C,LiquEx_size+8,hlq_xverts,hlq_yverts};// "LIQU"
|
||||
fwrite(LIQU_h,4,4,output);
|
||||
fwrite(LiquEx,4,LiquEx_size/4,output);
|
||||
delete [] LiquEx;
|
||||
}
|
||||
|
||||
delete [] MoviEx;
|
||||
delete [] MoviExSort;
|
||||
delete [] IndexExTr;
|
||||
delete [] MOVT;
|
||||
delete [] MovtEx;
|
||||
delete [] MovtExSort;
|
||||
|
||||
//----------VERT---------
|
||||
//-----MOVT----------
|
||||
int d = 0;
|
||||
MovtEx = new float[s*3];
|
||||
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++)
|
||||
{
|
||||
MovtEx[d] = MOVT[c];
|
||||
c++;
|
||||
d++;
|
||||
}
|
||||
}
|
||||
int VERT[] = {0x54524556,d*4+4,d*4/12};// "VERT"
|
||||
fwrite(VERT,4,3,output);
|
||||
fwrite(MovtEx,4,d,output);
|
||||
//------LIQU------------------------
|
||||
if(LiquEx_size != 0)
|
||||
{
|
||||
int LIQU_h[] = {0x5551494C,LiquEx_size+8,hlq_xverts,hlq_yverts};// "LIQU"
|
||||
fwrite(LIQU_h,4,4,output);
|
||||
fwrite(LiquEx,4,LiquEx_size/4,output);
|
||||
delete [] LiquEx;
|
||||
}
|
||||
|
||||
delete [] MOVT;
|
||||
delete [] MovtEx;
|
||||
delete [] MovtExSort;
|
||||
|
||||
//---------------------------------------------
|
||||
return IndexExTr_size;
|
||||
}
|
||||
//---------------------------------------------
|
||||
return IndexExTr_size;
|
||||
}
|
||||
}
|
||||
|
||||
WMOGroup::~WMOGroup()
|
||||
@@ -486,25 +499,24 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
||||
//-----------add_in _dir_file----------------
|
||||
|
||||
char tempname[512];
|
||||
// const char dirname[] = "buildings\\dir";
|
||||
// const char dirname[] = "buildings\\dir";
|
||||
|
||||
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;
|
||||
if(nVertices == 0)
|
||||
return;
|
||||
|
||||
/* FILE *dirfile;
|
||||
dirfile = fopen(dirname, "ab");
|
||||
if(!dirfile)
|
||||
{
|
||||
@@ -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,10 +80,9 @@ public:
|
||||
private:
|
||||
std::string filename;
|
||||
char outfilename;
|
||||
|
||||
};
|
||||
|
||||
struct WMOLiquidHeader
|
||||
struct WMOLiquidHeader
|
||||
{
|
||||
int xverts, yverts, xtiles, ytiles;
|
||||
float pos_x;
|
||||
@@ -94,7 +91,7 @@ struct WMOLiquidHeader
|
||||
short type;
|
||||
};
|
||||
|
||||
class WMOInstance
|
||||
class WMOInstance
|
||||
{
|
||||
static std::set<int> ids;
|
||||
public:
|
||||
@@ -113,4 +110,3 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user