mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[7909] Applied coding style. (cherry picked from commit ed7e72975f4d4f95f5c429f1af6a2c021adfd5a1)
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
84464e5f3f
commit
f84fdc6757
16 changed files with 1433 additions and 1467 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
#include "adtfile.h"
|
#include "adtfile.h"
|
||||||
|
|
||||||
|
|
||||||
char * GetPlainName(char * FileName)
|
char * GetPlainName(char * FileName)
|
||||||
{
|
{
|
||||||
char * szTemp;
|
char * szTemp;
|
||||||
|
|
@ -12,7 +11,8 @@ char * GetPlainName(char * FileName)
|
||||||
|
|
||||||
void fixnamen(char *name, size_t len)
|
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]))
|
if (i>0 && name[i]>='A' && name[i]<='Z' && isalpha(name[i-1]))
|
||||||
{
|
{
|
||||||
name[i] |= 0x20;
|
name[i] |= 0x20;
|
||||||
|
|
@ -38,7 +38,6 @@ ADTFile::ADTFile(char* filename): ADT(filename)
|
||||||
|
|
||||||
bool ADTFile::init(char *map_id)
|
bool ADTFile::init(char *map_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(ADT.isEof ())
|
if(ADT.isEof ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -68,8 +67,7 @@ bool ADTFile::init(char *map_id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (!ADT.isEof())
|
||||||
while (!ADT.isEof ())
|
|
||||||
{
|
{
|
||||||
char fourcc[5];
|
char fourcc[5];
|
||||||
ADT.read(&fourcc,4);
|
ADT.read(&fourcc,4);
|
||||||
|
|
@ -77,18 +75,16 @@ bool ADTFile::init(char *map_id)
|
||||||
flipcc(fourcc);
|
flipcc(fourcc);
|
||||||
fourcc[4] = 0;
|
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,"MTEX"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MMDX"))
|
else if (!strcmp(fourcc,"MMDX"))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
char *buf = new char[size];
|
char *buf = new char[size];
|
||||||
|
|
@ -111,28 +107,23 @@ bool ADTFile::init(char *map_id)
|
||||||
FILE * output = fopen((char*)szLocalFile,"rb");
|
FILE * output = fopen((char*)szLocalFile,"rb");
|
||||||
if(!output)
|
if(!output)
|
||||||
{
|
{
|
||||||
|
|
||||||
Model * m2 = new Model(path);
|
Model * m2 = new Model(path);
|
||||||
if(m2->open())
|
if(m2->open())
|
||||||
{
|
{
|
||||||
m2->ConvertToVMAPModel((char*)szLocalFile);
|
m2->ConvertToVMAPModel((char*)szLocalFile);
|
||||||
}
|
}
|
||||||
delete m2;
|
delete m2;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fclose(output);
|
fclose(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MWMO"))
|
else if (!strcmp(fourcc,"MWMO"))
|
||||||
{
|
{
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *buf = new char[size];
|
char *buf = new char[size];
|
||||||
ADT.read(buf, size);
|
ADT.read(buf, size);
|
||||||
char *p=buf;
|
char *p=buf;
|
||||||
|
|
@ -148,9 +139,7 @@ bool ADTFile::init(char *map_id)
|
||||||
WmoInstansName[q++] = s;
|
WmoInstansName[q++] = s;
|
||||||
}
|
}
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//======================
|
//======================
|
||||||
else if (!strcmp(fourcc,"MDDF"))
|
else if (!strcmp(fourcc,"MDDF"))
|
||||||
|
|
@ -158,7 +147,7 @@ bool ADTFile::init(char *map_id)
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
nMDX = (int)size / 36;
|
nMDX = (int)size / 36;
|
||||||
for (int i=0; i<nMDX; i++)
|
for (int i=0; i<nMDX; ++i)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
ADT.read(&id, 4);
|
ADT.read(&id, 4);
|
||||||
|
|
@ -172,7 +161,7 @@ bool ADTFile::init(char *map_id)
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
nWMO = (int)size / 64;
|
nWMO = (int)size / 64;
|
||||||
for (int i=0; i<nWMO; i++)
|
for (int i=0; i<nWMO; ++i)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
ADT.read(&id, 4);
|
ADT.read(&id, 4);
|
||||||
|
|
@ -188,7 +177,7 @@ bool ADTFile::init(char *map_id)
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
nMDX = (int)size / 36;
|
nMDX = (int)size / 36;
|
||||||
for (int i=0; i<nMDX; i++)
|
for (int i=0; i<nMDX; ++i)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
ADT.read(&id, 4);
|
ADT.read(&id, 4);
|
||||||
|
|
@ -202,7 +191,7 @@ bool ADTFile::init(char *map_id)
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
nWMO = (int)size / 64;
|
nWMO = (int)size / 64;
|
||||||
for (int i=0; i<nWMO; i++)
|
for (int i=0; i<nWMO; ++i)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
ADT.read(&id, 4);
|
ADT.read(&id, 4);
|
||||||
|
|
@ -223,5 +212,3 @@ ADTFile::~ADTFile()
|
||||||
{
|
{
|
||||||
ADT.close();
|
ADT.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,43 +17,48 @@ typedef unsigned int uint32;
|
||||||
|
|
||||||
class Liquid;
|
class Liquid;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
float x;
|
{
|
||||||
float y;
|
float x;
|
||||||
float z;
|
float y;
|
||||||
|
float z;
|
||||||
}svec;
|
}svec;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
double x;
|
{
|
||||||
double y;
|
double x;
|
||||||
double z;
|
double y;
|
||||||
|
double z;
|
||||||
}vec;
|
}vec;
|
||||||
|
|
||||||
typedef struct{
|
typedef struc
|
||||||
|
{
|
||||||
vec v[3];
|
vec v[3];
|
||||||
|
|
||||||
}triangle;
|
}triangle;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct
|
||||||
float v9[16*8+1][16*8+1];
|
{
|
||||||
float v8[16*8][16*8];
|
float v9[16*8+1][16*8+1];
|
||||||
|
float v8[16*8][16*8];
|
||||||
}Cell;
|
}Cell;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct
|
||||||
double v9[9][9];
|
{
|
||||||
double v8[8][8];
|
double v9[9][9];
|
||||||
uint16 area_id;
|
double v8[8][8];
|
||||||
//Liquid *lq;
|
uint16 area_id;
|
||||||
float waterlevel[9][9];
|
//Liquid *lq;
|
||||||
uint8 flag;
|
float waterlevel[9][9];
|
||||||
|
uint8 flag;
|
||||||
}chunk;
|
}chunk;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
chunk ch[16][16];
|
chunk ch[16][16];
|
||||||
}mcell;
|
}mcell;
|
||||||
|
|
||||||
struct MapChunkHeader {
|
struct MapChunkHeader
|
||||||
|
{
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
uint32 ix;
|
uint32 ix;
|
||||||
uint32 iy;
|
uint32 iy;
|
||||||
|
|
@ -119,6 +124,4 @@ private:
|
||||||
void fixnamen(char *name, size_t len);
|
void fixnamen(char *name, size_t len);
|
||||||
//void fixMapNamen(char *name, size_t len);
|
//void fixMapNamen(char *name, size_t len);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ bool DBCFile::open()
|
||||||
|
|
||||||
f.read(header,4); // File Header
|
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();
|
f.close();
|
||||||
data = NULL;
|
data = NULL;
|
||||||
printf("Critical Error: An error occured while trying to read the DBCFile %s.", filename.c_str());
|
printf("Critical Error: An error occured while trying to read the DBCFile %s.", filename.c_str());
|
||||||
|
|
@ -67,9 +67,9 @@ DBCFile::Iterator DBCFile::begin()
|
||||||
assert(data);
|
assert(data);
|
||||||
return Iterator(*this, data);
|
return Iterator(*this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBCFile::Iterator DBCFile::end()
|
DBCFile::Iterator DBCFile::end()
|
||||||
{
|
{
|
||||||
assert(data);
|
assert(data);
|
||||||
return Iterator(*this, stringTable);
|
return Iterator(*this, stringTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,8 @@ bool Model::open()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Model::ConvertToVMAPModel(char * outfilename)
|
bool Model::ConvertToVMAPModel(char * outfilename)
|
||||||
{
|
{
|
||||||
|
|
||||||
int N[] = {0x00000000};
|
int N[] = {0x00000000};
|
||||||
FILE * output=fopen(outfilename,"wb");
|
FILE * output=fopen(outfilename,"wb");
|
||||||
if(!output)
|
if(!output)
|
||||||
|
|
@ -133,18 +131,17 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
|
||||||
sprintf(tempname, ".\\buildings\\%s", ModelInstName);
|
sprintf(tempname, ".\\buildings\\%s", ModelInstName);
|
||||||
FILE *input;
|
FILE *input;
|
||||||
input = fopen(tempname, "r+b");
|
input = fopen(tempname, "r+b");
|
||||||
|
|
||||||
if(!input)
|
if(!input)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
fseek(input, 8, SEEK_SET); // get the correct no of vertices
|
fseek(input, 8, SEEK_SET); // get the correct no of vertices
|
||||||
int nVertices;
|
int nVertices;
|
||||||
fread(&nVertices, sizeof (int), 1, input);
|
fread(&nVertices, sizeof (int), 1, input);
|
||||||
fclose(input);
|
fclose(input);
|
||||||
|
|
||||||
if(nVertices == 0)
|
if(nVertices == 0)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if(pDirfile)
|
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 realx2 = (int) ((float) pos.x / 533.333333f);
|
||||||
int realy2 = (int) ((float) pos.z / 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",
|
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n",
|
||||||
MapName,
|
MapName,
|
||||||
ModelInstName,
|
ModelInstName,
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,10 @@ class WMOInstance;
|
||||||
|
|
||||||
Vec3D fixCoordSystem(Vec3D v);
|
Vec3D fixCoordSystem(Vec3D v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ModelHeader header;
|
ModelHeader header;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
uint32 offsBB_vertices, offsBB_indices;
|
uint32 offsBB_vertices, offsBB_indices;
|
||||||
Vec3D *BB_vertices, *vertices;
|
Vec3D *BB_vertices, *vertices;
|
||||||
uint16 *BB_indices, *indices;
|
uint16 *BB_indices, *indices;
|
||||||
|
|
@ -30,8 +23,6 @@ public:
|
||||||
bool open();
|
bool open();
|
||||||
bool ConvertToVMAPModel(char * outfilename);
|
bool ConvertToVMAPModel(char * outfilename);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
Model(std::string &filename);
|
Model(std::string &filename);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ typedef int int32;
|
||||||
|
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
|
|
||||||
struct ModelHeader {
|
struct ModelHeader
|
||||||
|
{
|
||||||
char id[4];
|
char id[4];
|
||||||
uint8 version[4];
|
uint8 version[4];
|
||||||
uint32 nameLength;
|
uint32 nameLength;
|
||||||
|
|
@ -77,6 +78,4 @@ struct ModelHeader {
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
typedef std::vector<MPQArchive*> ArchiveSet;
|
typedef std::vector<MPQArchive*> ArchiveSet;
|
||||||
ArchiveSet gOpenArchives;
|
ArchiveSet gOpenArchives;
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
MPQArchive::MPQArchive(const char* filename)
|
MPQArchive::MPQArchive(const char* filename)
|
||||||
{
|
{
|
||||||
BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ);
|
BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ);
|
||||||
|
|
@ -15,7 +15,6 @@ MPQArchive::MPQArchive(const char* filename)
|
||||||
printf("Opening %s\n", filename);
|
printf("Opening %s\n", filename);
|
||||||
gOpenArchives.push_back(ar);
|
gOpenArchives.push_back(ar);
|
||||||
succ = true;
|
succ = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -28,7 +27,6 @@ void MPQArchive::close()
|
||||||
SFileCloseArchive(hMPQ);
|
SFileCloseArchive(hMPQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
MPQFile::MPQFile(const char* filename):
|
MPQFile::MPQFile(const char* filename):
|
||||||
eof(false),
|
eof(false),
|
||||||
buffer(0),
|
buffer(0),
|
||||||
|
|
@ -37,7 +35,6 @@ MPQFile::MPQFile(const char* filename):
|
||||||
{
|
{
|
||||||
for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i)
|
for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
HANDLE hFile = "";
|
HANDLE hFile = "";
|
||||||
MPQArchive*(hMPQ) = *i;
|
MPQArchive*(hMPQ) = *i;
|
||||||
BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
|
BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
|
||||||
|
|
@ -62,7 +59,6 @@ MPQFile::MPQFile(const char* filename):
|
||||||
|
|
||||||
eof = true;
|
eof = true;
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MPQFile::~MPQFile()
|
MPQFile::~MPQFile()
|
||||||
|
|
@ -133,4 +129,3 @@ char* MPQFile::getPointer()
|
||||||
{
|
{
|
||||||
return buffer + pointer;
|
return buffer + pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,8 @@ using namespace std;
|
||||||
|
|
||||||
typedef unsigned int uint32;
|
typedef unsigned int uint32;
|
||||||
|
|
||||||
|
|
||||||
class MPQArchive
|
class MPQArchive
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HANDLE hMPQ;
|
HANDLE hMPQ;
|
||||||
MPQArchive(const char* filename);
|
MPQArchive(const char* filename);
|
||||||
|
|
@ -63,7 +61,4 @@ inline void flipcc(char *fcc)
|
||||||
fcc[2]=t;
|
fcc[2]=t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
class Vec3D
|
||||||
|
{
|
||||||
class Vec3D {
|
|
||||||
public:
|
public:
|
||||||
float x,y,z;
|
float x,y,z;
|
||||||
|
|
||||||
|
|
@ -112,11 +111,11 @@ public:
|
||||||
{
|
{
|
||||||
return (float*)this;
|
return (float*)this;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Vec2D {
|
class Vec2D
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
float x,y;
|
float x,y;
|
||||||
|
|
||||||
|
|
@ -213,10 +212,8 @@ public:
|
||||||
{
|
{
|
||||||
return (float*)this;
|
return (float*)this;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void rotate(float x0, float y0, float *x, float *y, float angle)
|
inline void rotate(float x0, float y0, float *x, float *y, float angle)
|
||||||
{
|
{
|
||||||
float xa = *x - x0, ya = *y - y0;
|
float xa = *x - x0, ya = *y - y0;
|
||||||
|
|
@ -224,7 +221,4 @@ inline void rotate(float x0, float y0, float *x, float *y, float angle)
|
||||||
*y = xa*sinf(angle) + ya*cosf(angle) + y0;
|
*y = xa*sinf(angle) + ya*cosf(angle) + y0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ static const char * GetPlainName(const char * szFileName)
|
||||||
szFileName = szTemp + 1;
|
szFileName = szTemp + 1;
|
||||||
return szFileName;
|
return szFileName;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
static void ShowProcessedFile(const char * szFileName)
|
static void ShowProcessedFile(const char * szFileName)
|
||||||
{
|
{
|
||||||
char szLine[80];
|
char szLine[80];
|
||||||
|
|
@ -101,11 +101,8 @@ static void ShowProcessedFile(const char * szFileName)
|
||||||
printf("\r%s\n", szLine);
|
printf("\r%s\n", szLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
{
|
{
|
||||||
|
|
||||||
char* szListFile = "";
|
char* szListFile = "";
|
||||||
char szLocalFile[MAX_PATH] = "";
|
char szLocalFile[MAX_PATH] = "";
|
||||||
HANDLE hMpq = "";
|
HANDLE hMpq = "";
|
||||||
|
|
@ -118,9 +115,8 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
szListFile = NULL;
|
szListFile = NULL;
|
||||||
//char tmp[1024];
|
//char tmp[1024];
|
||||||
//for (size_t i=0; i<4; i++)
|
//for (size_t i=0; i<4; i++)
|
||||||
for (size_t i=0; i<pArchiveNames.size(); i++)
|
for (size_t i=0; i<pArchiveNames.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
//sprintf(tmp,"%s\\%s", input_path, ParsArchiveNames[i]);
|
//sprintf(tmp,"%s\\%s", input_path, ParsArchiveNames[i]);
|
||||||
//if(!SFileOpenArchive(tmp, 0, 0, &hMpq))
|
//if(!SFileOpenArchive(tmp, 0, 0, &hMpq))
|
||||||
if(!SFileOpenArchive(pArchiveNames[i].c_str(), 0, 0, &hMpq))
|
if(!SFileOpenArchive(pArchiveNames[i].c_str(), 0, 0, &hMpq))
|
||||||
|
|
@ -149,7 +145,7 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
{
|
{
|
||||||
char cpy[4];
|
char cpy[4];
|
||||||
strncpy((char*)cpy,rchr,4);
|
strncpy((char*)cpy,rchr,4);
|
||||||
for (int i=0;i<4;i++)
|
for (int i=0;i<4; ++i)
|
||||||
{
|
{
|
||||||
int m = cpy[i];
|
int m = cpy[i];
|
||||||
if(isdigit(m))
|
if(isdigit(m))
|
||||||
|
|
@ -172,7 +168,7 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
int Wmo_nVertices = 0;
|
int Wmo_nVertices = 0;
|
||||||
if(froot->nGroups !=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[512];
|
||||||
strcpy(temp, wf.cFileName);
|
strcpy(temp, wf.cFileName);
|
||||||
|
|
@ -196,7 +192,9 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
fwrite(&Wmo_nVertices,sizeof(int),1,output);
|
fwrite(&Wmo_nVertices,sizeof(int),1,output);
|
||||||
fclose(output);
|
fclose(output);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
fclose(n);
|
fclose(n);
|
||||||
}
|
}
|
||||||
wf.dwFileFlags &= ~MPQ_FILE_HAS_EXTRA;
|
wf.dwFileFlags &= ~MPQ_FILE_HAS_EXTRA;
|
||||||
|
|
@ -220,29 +218,27 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||||
printf("\nExtract wmo complete (No errors)\n");
|
printf("\nExtract wmo complete (No errors)\n");
|
||||||
|
|
||||||
return nError;
|
return nError;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtractMapsFromMpq()
|
void ExtractMapsFromMpq()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void ParsMapFiles()
|
void ParsMapFiles()
|
||||||
{
|
{
|
||||||
char fn[512];
|
char fn[512];
|
||||||
char id_filename[64];
|
char id_filename[64];
|
||||||
char id[10];
|
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(id,"%03u",map_ids[i].id);
|
||||||
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
||||||
WDTFile WDT(fn,map_ids[i].name);
|
WDTFile WDT(fn,map_ids[i].name);
|
||||||
if(WDT.init(id))
|
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))
|
if (ADTFile*ADT = WDT.GetMap(x,y))
|
||||||
{
|
{
|
||||||
|
|
@ -250,7 +246,6 @@ void ParsMapFiles()
|
||||||
ADT->init(id_filename);
|
ADT->init(id_filename);
|
||||||
delete ADT;
|
delete ADT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -259,31 +254,28 @@ void ParsMapFiles()
|
||||||
#if 0
|
#if 0
|
||||||
void ParsMapFiles()
|
void ParsMapFiles()
|
||||||
{
|
{
|
||||||
|
|
||||||
char fn[512];
|
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);
|
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
||||||
WDTFile WDT(fn,map_ids[i].name);
|
WDTFile WDT(fn,map_ids[i].name);
|
||||||
if(WDT.init())
|
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))
|
if (ADTFile*ADT = WDT.GetMap(x,y))
|
||||||
{
|
{
|
||||||
ADT->init();
|
ADT->init();
|
||||||
delete ADT;
|
delete ADT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
|
|
||||||
void getGamePath()
|
void getGamePath()
|
||||||
{
|
{
|
||||||
|
|
@ -307,8 +299,6 @@ void getGamePath()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
|
|
||||||
bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -338,7 +328,7 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
matches.reverse();
|
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());
|
pArchiveNames.push_back(i->c_str());
|
||||||
}
|
}
|
||||||
|
|
@ -348,11 +338,8 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
|
||||||
|
{
|
||||||
bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
|
||||||
//srand((unsigned int)time(0));
|
|
||||||
|
|
||||||
if(!hasInputPathParam)
|
if(!hasInputPathParam)
|
||||||
getGamePath();
|
getGamePath();
|
||||||
|
|
||||||
|
|
@ -408,11 +395,12 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
||||||
// now, scan for the patch levels in the core dir
|
// now, scan for the patch levels in the core dir
|
||||||
printf("Loading patch levels from data directory.\n");
|
printf("Loading patch levels from data directory.\n");
|
||||||
sprintf(path, "%spatch", input_path);
|
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
|
// now, scan for the patch levels in locale dirs
|
||||||
printf("Loading patch levels from locale directories.\n");
|
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());
|
printf("Locale: %s\n", i->c_str());
|
||||||
sprintf(path, "%s%s\\patch-%s", input_path, i->c_str(), i->c_str());
|
sprintf(path, "%s%s\\patch-%s", input_path, i->c_str(), i->c_str());
|
||||||
|
|
@ -433,7 +421,7 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
||||||
|
|
||||||
// open locale expansion and common files
|
// open locale expansion and common files
|
||||||
printf("Opening data files from locale directories.\n");
|
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());
|
printf("Locale: %s\n", i->c_str());
|
||||||
sprintf(path, "%s%s\\lichking-locale-%s.mpq", input_path, i->c_str(), i->c_str());
|
sprintf(path, "%s%s\\lichking-locale-%s.mpq", input_path, i->c_str(), i->c_str());
|
||||||
|
|
@ -446,8 +434,6 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
// return false it normal processing can not proceed
|
|
||||||
|
|
||||||
bool processArgv(int argc, char ** argv, char*versionString)
|
bool processArgv(int argc, char ** argv, char*versionString)
|
||||||
{
|
{
|
||||||
|
|
@ -455,29 +441,43 @@ bool processArgv(int argc, char ** argv, char*versionString)
|
||||||
hasInputPathParam = false;
|
hasInputPathParam = false;
|
||||||
bool preciseVectorData = false;
|
bool preciseVectorData = false;
|
||||||
|
|
||||||
for(int i=1; i< argc; ++i) {
|
for(int i=1; i< argc; ++i)
|
||||||
if(strcmp("-s",argv[i]) == 0) {
|
{
|
||||||
|
if(strcmp("-s",argv[i]) == 0)
|
||||||
|
{
|
||||||
preciseVectorData = false;
|
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;
|
hasInputPathParam = true;
|
||||||
strcpy(input_path, argv[i+1]);
|
strcpy(input_path, argv[i+1]);
|
||||||
if (input_path[strlen(input_path) - 1] != '\\' || input_path[strlen(input_path) - 1] != '/')
|
if (input_path[strlen(input_path) - 1] != '\\' || input_path[strlen(input_path) - 1] != '/')
|
||||||
strcat(input_path, "\\");
|
strcat(input_path, "\\");
|
||||||
++i;
|
++i;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
} else if(strcmp("-?",argv[1]) == 0) {
|
}
|
||||||
|
else if(strcmp("-?",argv[1]) == 0)
|
||||||
|
{
|
||||||
result = false;
|
result = false;
|
||||||
} else if(strcmp("-l",argv[i]) == 0) {
|
}
|
||||||
|
else if(strcmp("-l",argv[i]) == 0)
|
||||||
|
{
|
||||||
preciseVectorData = true;
|
preciseVectorData = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!result) {
|
if(!result)
|
||||||
|
{
|
||||||
printf("Extract %s.\n",versionString);
|
printf("Extract %s.\n",versionString);
|
||||||
printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
|
printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
|
||||||
printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n");
|
printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n");
|
||||||
|
|
@ -537,7 +537,8 @@ int main(int argc, char ** argv)
|
||||||
std::vector<std::string> archiveNames;
|
std::vector<std::string> archiveNames;
|
||||||
|
|
||||||
fillArchiveNameVector(archiveNames);
|
fillArchiveNameVector(archiveNames);
|
||||||
for (size_t i=0; i<archiveNames.size(); i++) {
|
for (size_t i=0; i<archiveNames.size(); ++i)
|
||||||
|
{
|
||||||
archives.push_back(new MPQArchive(archiveNames[i].c_str()));
|
archives.push_back(new MPQArchive(archiveNames[i].c_str()));
|
||||||
}
|
}
|
||||||
ExtractWmo(archiveNames);
|
ExtractWmo(archiveNames);
|
||||||
|
|
@ -550,7 +551,7 @@ int main(int argc, char ** argv)
|
||||||
dbc->open();
|
dbc->open();
|
||||||
map_count=dbc->getRecordCount ();
|
map_count=dbc->getRecordCount ();
|
||||||
map_ids=new map_id[map_count];
|
map_ids=new map_id[map_count];
|
||||||
for(unsigned int x=0;x<map_count;x++)
|
for(unsigned int x=0;x<map_count;++x)
|
||||||
{
|
{
|
||||||
map_ids[x].id=dbc->getRecord (x).getUInt(0);
|
map_ids[x].id=dbc->getRecord (x).getUInt(0);
|
||||||
strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
|
strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
|
||||||
|
|
@ -564,7 +565,8 @@ int main(int argc, char ** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
clreol();
|
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);
|
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData);
|
||||||
_getch();
|
_getch();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include "wdtfile.h"
|
#include "wdtfile.h"
|
||||||
#include "adtfile.h"
|
#include "adtfile.h"
|
||||||
|
|
||||||
|
|
||||||
char * wdtGetPlainName(char * FileName)
|
char * wdtGetPlainName(char * FileName)
|
||||||
{
|
{
|
||||||
char * szTemp;
|
char * szTemp;
|
||||||
|
|
@ -20,7 +19,6 @@ WDTFile::WDTFile(char* file_name, char* file_name1):WDT(file_name)
|
||||||
|
|
||||||
bool WDTFile::init(char *map_id)
|
bool WDTFile::init(char *map_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (WDT.isEof())
|
if (WDT.isEof())
|
||||||
{
|
{
|
||||||
//printf("Can't find WDT file.\n");
|
//printf("Can't find WDT file.\n");
|
||||||
|
|
@ -30,7 +28,6 @@ bool WDTFile::init(char *map_id)
|
||||||
char fourcc[5];
|
char fourcc[5];
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
|
|
||||||
const char dirname[] = "buildings\\dir";
|
const char dirname[] = "buildings\\dir";
|
||||||
FILE *dirfile;
|
FILE *dirfile;
|
||||||
dirfile = fopen(dirname, "ab");
|
dirfile = fopen(dirname, "ab");
|
||||||
|
|
@ -40,7 +37,6 @@ bool WDTFile::init(char *map_id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (!WDT.isEof())
|
while (!WDT.isEof())
|
||||||
{
|
{
|
||||||
WDT.read(fourcc,4);
|
WDT.read(fourcc,4);
|
||||||
|
|
@ -75,8 +71,7 @@ bool WDTFile::init(char *map_id)
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (!strcmp(fourcc,"MODF"))
|
||||||
if (!strcmp(fourcc,"MODF"))
|
|
||||||
{
|
{
|
||||||
// global wmo instance data
|
// global wmo instance data
|
||||||
if (size)
|
if (size)
|
||||||
|
|
@ -87,7 +82,7 @@ bool WDTFile::init(char *map_id)
|
||||||
fake_mapname = "65 65 ";
|
fake_mapname = "65 65 ";
|
||||||
//gWMO_mapname = fake_mapname + filename;
|
//gWMO_mapname = fake_mapname + filename;
|
||||||
gWMO_mapname = fake_mapname + std::string(map_id);
|
gWMO_mapname = fake_mapname + std::string(map_id);
|
||||||
for (int i=0; i<gnWMO; i++)
|
for (int i=0; i<gnWMO; ++i)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
WDT.read(&id, 4);
|
WDT.read(&id, 4);
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,12 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
WMORoot::WMORoot(std::string &filename) : filename(filename)
|
WMORoot::WMORoot(std::string &filename) : filename(filename)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
|
|
||||||
bool WMORoot::open()
|
bool WMORoot::open()
|
||||||
{
|
{
|
||||||
|
|
||||||
MPQFile f(filename.c_str());
|
MPQFile f(filename.c_str());
|
||||||
if(f.isEof ())
|
if(f.isEof ())
|
||||||
{
|
{
|
||||||
|
|
@ -27,7 +24,7 @@ bool WMORoot::open()
|
||||||
bbcorn1[3] = 0;
|
bbcorn1[3] = 0;
|
||||||
bbcorn2[3]= 0;
|
bbcorn2[3]= 0;
|
||||||
|
|
||||||
while (!f.isEof ())
|
while (!f.isEof())
|
||||||
{
|
{
|
||||||
f.read(fourcc,4);
|
f.read(fourcc,4);
|
||||||
f.read(&size, 4);
|
f.read(&size, 4);
|
||||||
|
|
@ -39,7 +36,6 @@ bool WMORoot::open()
|
||||||
|
|
||||||
if (!strcmp(fourcc,"MOHD"))//header
|
if (!strcmp(fourcc,"MOHD"))//header
|
||||||
{
|
{
|
||||||
|
|
||||||
f.read(&nTextures, 4);
|
f.read(&nTextures, 4);
|
||||||
f.read(&nGroups, 4);
|
f.read(&nGroups, 4);
|
||||||
f.read(&nP, 4);
|
f.read(&nP, 4);
|
||||||
|
|
@ -56,55 +52,42 @@ bool WMORoot::open()
|
||||||
/*
|
/*
|
||||||
else if (!strcmp(fourcc,"MOTX"))
|
else if (!strcmp(fourcc,"MOTX"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOMT"))
|
else if (!strcmp(fourcc,"MOMT"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOGN"))
|
else if (!strcmp(fourcc,"MOGN"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOGI"))
|
else if (!strcmp(fourcc,"MOGI"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOLT"))
|
else if (!strcmp(fourcc,"MOLT"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MODN"))
|
else if (!strcmp(fourcc,"MODN"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MODS"))
|
else if (!strcmp(fourcc,"MODS"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MODD"))
|
else if (!strcmp(fourcc,"MODD"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOSB"))
|
else if (!strcmp(fourcc,"MOSB"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOPV"))
|
else if (!strcmp(fourcc,"MOPV"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOPT"))
|
else if (!strcmp(fourcc,"MOPT"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOPR"))
|
else if (!strcmp(fourcc,"MOPR"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MFOG"))
|
else if (!strcmp(fourcc,"MFOG"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
f.seek((int)nextpos);
|
f.seek((int)nextpos);
|
||||||
|
|
@ -112,7 +95,6 @@ bool WMORoot::open()
|
||||||
f.close ();
|
f.close ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
|
bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
|
||||||
{
|
{
|
||||||
|
|
@ -125,16 +107,14 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
WMORoot::~WMORoot()
|
WMORoot::~WMORoot()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
|
|
||||||
WMOGroup::WMOGroup(std::string &filename) : filename(filename)
|
WMOGroup::WMOGroup(std::string &filename) : filename(filename)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
bool WMOGroup::open()
|
bool WMOGroup::open()
|
||||||
{
|
{
|
||||||
MPQFile f(filename.c_str());
|
MPQFile f(filename.c_str());
|
||||||
|
|
@ -147,7 +127,7 @@ bool WMOGroup::open()
|
||||||
char fourcc[5];
|
char fourcc[5];
|
||||||
bbcorn1[3] = 0;
|
bbcorn1[3] = 0;
|
||||||
bbcorn2[3] = 0;
|
bbcorn2[3] = 0;
|
||||||
while (!f.isEof ())
|
while (!f.isEof())
|
||||||
{
|
{
|
||||||
f.read(fourcc,4);
|
f.read(fourcc,4);
|
||||||
f.read(&size, 4);
|
f.read(&size, 4);
|
||||||
|
|
@ -188,7 +168,6 @@ bool WMOGroup::open()
|
||||||
{
|
{
|
||||||
MOVI = new uint16[size/2];
|
MOVI = new uint16[size/2];
|
||||||
f.read(MOVI, size);
|
f.read(MOVI, size);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(fourcc,"MOVT"))
|
else if (!strcmp(fourcc,"MOVT"))
|
||||||
{
|
{
|
||||||
|
|
@ -222,26 +201,26 @@ bool WMOGroup::open()
|
||||||
LiquEx = new float[sizeof(float) * 3 * noVer];
|
LiquEx = new float[sizeof(float) * 3 * noVer];
|
||||||
int p = 0;
|
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_x + tilesize * i;
|
||||||
LiquEx[p++] = hlq.pos_z;
|
LiquEx[p++] = hlq.pos_z;
|
||||||
LiquEx[p++] = ydir * (hlq.pos_y + tilesize * j);
|
LiquEx[p++] = ydir * (hlq.pos_y + tilesize * j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
f.seek((int)nextpos);
|
f.seek((int)nextpos);
|
||||||
}
|
}
|
||||||
f.close ();
|
f.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||||
{
|
{
|
||||||
if(pPreciseVectorData) {
|
if(pPreciseVectorData)
|
||||||
|
{
|
||||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||||
char GRP[] = "GRP ";
|
char GRP[] = "GRP ";
|
||||||
fwrite(GRP,1,4,output);
|
fwrite(GRP,1,4,output);
|
||||||
|
|
@ -262,20 +241,54 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||||
|
|
||||||
uint32 nIdexes = nTriangles * 3;
|
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;
|
int wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes;
|
||||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); }
|
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||||
if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1) { printf("Error while writing file nIndexes"); exit(0); }
|
{
|
||||||
if(nIdexes >0) {
|
printf("Error while writing file wsize");
|
||||||
if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes) { printf("Error while writing file indexarray"); exit(0); }
|
// 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;
|
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
|
||||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); }
|
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||||
if(fwrite(&nVertices, sizeof(int), 1, output) != 1) { printf("Error while writing file nVertices"); exit(0); }
|
{
|
||||||
if(nVertices >0) {
|
printf("Error while writing file wsize");
|
||||||
if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices) { printf("Error while writing file vectors"); exit(0); }
|
// 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)
|
if(LiquEx_size != 0)
|
||||||
|
|
@ -287,7 +300,9 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nTriangles;
|
return nTriangles;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//printf("Convert GroupWmo...\n");
|
//printf("Convert GroupWmo...\n");
|
||||||
//-------GRP -------------------------------------
|
//-------GRP -------------------------------------
|
||||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||||
|
|
@ -336,11 +351,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||||
//---------MOVI-----------
|
//---------MOVI-----------
|
||||||
MoviEx = new uint16[IndexExTr_size*3];
|
MoviEx = new uint16[IndexExTr_size*3];
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for (int i=0; i<IndexExTr_size; i++)
|
for (int i=0; i<IndexExTr_size; ++i)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
n = IndexExTr[i]*3;
|
n = IndexExTr[i]*3;
|
||||||
for (int x=0; x<3; x++)
|
for (int x=0; x<3; ++x)
|
||||||
{
|
{
|
||||||
MoviEx[m] = MOVI[n];
|
MoviEx[m] = MOVI[n];
|
||||||
n++;
|
n++;
|
||||||
|
|
@ -350,15 +365,15 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||||
delete [] MOVI;
|
delete [] MOVI;
|
||||||
|
|
||||||
MoviExSort = new uint16[IndexExTr_size*3];
|
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];
|
MoviExSort[y]=MoviEx[y];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 hold;
|
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])
|
if (MoviExSort[i] > MoviExSort[i+1])
|
||||||
{
|
{
|
||||||
|
|
@ -374,7 +389,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||||
}
|
}
|
||||||
// double delet
|
// double delet
|
||||||
uint16 s = 0;
|
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)
|
if (MoviExSort[i]!=65535)
|
||||||
{
|
{
|
||||||
|
|
@ -383,24 +398,22 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MovtExSort = new uint16[s];
|
MovtExSort = new uint16[s];
|
||||||
for (int i=0; i < s; i++)
|
for (int i=0; i < s; ++i)
|
||||||
{
|
{
|
||||||
MovtExSort[i] = MoviExSort[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];
|
uint16 b = MoviEx[i];
|
||||||
for (uint16 x = 0; x < s; x++)
|
for (uint16 x = 0; x < s; ++x)
|
||||||
{
|
{
|
||||||
if(MoviExSort[x] == b)
|
if(MoviExSort[x] == b)
|
||||||
{
|
{
|
||||||
|
|
||||||
MoviEx[i] = x;
|
MoviEx[i] = x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
int INDX[] = {0x58444E49,IndexExTr_size*6+4,IndexExTr_size*3};
|
int INDX[] = {0x58444E49,IndexExTr_size*6+4,IndexExTr_size*3};
|
||||||
fwrite(INDX,4,3,output);
|
fwrite(INDX,4,3,output);
|
||||||
|
|
@ -414,11 +427,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||||
//-----MOVT----------
|
//-----MOVT----------
|
||||||
int d = 0;
|
int d = 0;
|
||||||
MovtEx = new float[s*3];
|
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!!!!
|
int c=0;//!!!!data in MovtExSort[i] more uint16 in great group wmo files!!!!
|
||||||
c = MovtExSort[i]*3;
|
c = MovtExSort[i]*3;
|
||||||
for (int y=0; y<3; y++)
|
for (int y=0; y<3; ++y)
|
||||||
{
|
{
|
||||||
MovtEx[d] = MOVT[c];
|
MovtEx[d] = MOVT[c];
|
||||||
c++;
|
c++;
|
||||||
|
|
@ -491,18 +504,17 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
||||||
sprintf(tempname, "buildings\\%s", WmoInstName);
|
sprintf(tempname, "buildings\\%s", WmoInstName);
|
||||||
FILE *input;
|
FILE *input;
|
||||||
input = fopen(tempname, "r+b");
|
input = fopen(tempname, "r+b");
|
||||||
|
|
||||||
if(!input)
|
if(!input)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
fseek(input, 8, SEEK_SET); // get the correct no of vertices
|
fseek(input, 8, SEEK_SET); // get the correct no of vertices
|
||||||
int nVertices;
|
int nVertices;
|
||||||
fread(&nVertices, sizeof (int), 1, input);
|
fread(&nVertices, sizeof (int), 1, input);
|
||||||
fclose(input);
|
fclose(input);
|
||||||
|
|
||||||
if(nVertices == 0)
|
if(nVertices == 0)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* FILE *dirfile;
|
/* FILE *dirfile;
|
||||||
dirfile = fopen(dirname, "ab");
|
dirfile = fopen(dirname, "ab");
|
||||||
|
|
@ -516,7 +528,11 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
||||||
x = pos.x;
|
x = pos.x;
|
||||||
z = pos.z;
|
z = pos.z;
|
||||||
if(x==0 && z == 0)
|
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",
|
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f 1.0 %d %d %d,%d %d\n",
|
||||||
MapName,
|
MapName,
|
||||||
WmoInstName,
|
WmoInstName,
|
||||||
|
|
@ -529,7 +545,3 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
||||||
|
|
||||||
// fclose(dirfile);
|
// fclose(dirfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,13 +43,11 @@ public:
|
||||||
private:
|
private:
|
||||||
std::string filename;
|
std::string filename;
|
||||||
char outfilename;
|
char outfilename;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WMOGroup
|
class WMOGroup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int offsize,flag,flag1,Xid,Xid2,Xid3,zero1,Xflag,nTexture,GroupID;
|
int offsize,flag,flag1,Xid,Xid2,Xid3,zero1,Xflag,nTexture,GroupID;
|
||||||
int mopy_size,moba_size,hlq_xverts,hlq_yverts;
|
int mopy_size,moba_size,hlq_xverts,hlq_yverts;
|
||||||
int MopyEx_size,IndexExTr_size,LiquEx_size;
|
int MopyEx_size,IndexExTr_size,LiquEx_size;
|
||||||
|
|
@ -82,7 +80,6 @@ public:
|
||||||
private:
|
private:
|
||||||
std::string filename;
|
std::string filename;
|
||||||
char outfilename;
|
char outfilename;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WMOLiquidHeader
|
struct WMOLiquidHeader
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7908"
|
#define REVISION_NR "7909"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue