mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +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"
|
||||
|
||||
|
||||
char * GetPlainName(char * FileName)
|
||||
{
|
||||
char * szTemp;
|
||||
|
|
@ -12,7 +11,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;
|
||||
|
|
@ -38,7 +38,6 @@ ADTFile::ADTFile(char* filename): ADT(filename)
|
|||
|
||||
bool ADTFile::init(char *map_id)
|
||||
{
|
||||
|
||||
if(ADT.isEof ())
|
||||
return false;
|
||||
|
||||
|
|
@ -68,8 +67,7 @@ bool ADTFile::init(char *map_id)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
while (!ADT.isEof ())
|
||||
while (!ADT.isEof())
|
||||
{
|
||||
char fourcc[5];
|
||||
ADT.read(&fourcc,4);
|
||||
|
|
@ -77,18 +75,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];
|
||||
|
|
@ -111,28 +107,23 @@ bool ADTFile::init(char *map_id)
|
|||
FILE * output = fopen((char*)szLocalFile,"rb");
|
||||
if(!output)
|
||||
{
|
||||
|
||||
Model * m2 = new Model(path);
|
||||
if(m2->open())
|
||||
{
|
||||
m2->ConvertToVMAPModel((char*)szLocalFile);
|
||||
}
|
||||
delete m2;
|
||||
|
||||
}
|
||||
else
|
||||
fclose(output);
|
||||
}
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MWMO"))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
|
||||
char *buf = new char[size];
|
||||
ADT.read(buf, size);
|
||||
char *p=buf;
|
||||
|
|
@ -148,9 +139,7 @@ bool ADTFile::init(char *map_id)
|
|||
WmoInstansName[q++] = s;
|
||||
}
|
||||
delete[] buf;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//======================
|
||||
else if (!strcmp(fourcc,"MDDF"))
|
||||
|
|
@ -158,7 +147,7 @@ bool ADTFile::init(char *map_id)
|
|||
if (size)
|
||||
{
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; i++)
|
||||
for (int i=0; i<nMDX; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
|
|
@ -172,7 +161,7 @@ bool ADTFile::init(char *map_id)
|
|||
if (size)
|
||||
{
|
||||
nWMO = (int)size / 64;
|
||||
for (int i=0; i<nWMO; i++)
|
||||
for (int i=0; i<nWMO; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
|
|
@ -188,7 +177,7 @@ bool ADTFile::init(char *map_id)
|
|||
if (size)
|
||||
{
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; i++)
|
||||
for (int i=0; i<nMDX; ++i)
|
||||
{
|
||||
int id;
|
||||
ADT.read(&id, 4);
|
||||
|
|
@ -202,7 +191,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,5 +212,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;
|
||||
typedef struct
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
}vec;
|
||||
|
||||
typedef struct{
|
||||
typedef struc
|
||||
{
|
||||
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,6 +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,9 +67,9 @@ DBCFile::Iterator DBCFile::begin()
|
|||
assert(data);
|
||||
return Iterator(*this, data);
|
||||
}
|
||||
|
||||
DBCFile::Iterator DBCFile::end()
|
||||
{
|
||||
assert(data);
|
||||
return Iterator(*this, stringTable);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,10 +45,8 @@ bool Model::open()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Model::ConvertToVMAPModel(char * outfilename)
|
||||
{
|
||||
|
||||
int N[] = {0x00000000};
|
||||
FILE * output=fopen(outfilename,"wb");
|
||||
if(!output)
|
||||
|
|
@ -133,18 +131,17 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
|
|||
sprintf(tempname, ".\\buildings\\%s", ModelInstName);
|
||||
FILE *input;
|
||||
input = fopen(tempname, "r+b");
|
||||
|
||||
if(!input)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(input, 8, SEEK_SET); // get the correct no of vertices
|
||||
int nVertices;
|
||||
fread(&nVertices, sizeof (int), 1, input);
|
||||
fclose(input);
|
||||
|
||||
if(nVertices == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(pDirfile)
|
||||
{
|
||||
|
|
@ -153,7 +150,6 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
|
|||
int realx2 = (int) ((float) pos.x / 533.333333f);
|
||||
int realy2 = (int) ((float) pos.z / 533.333333f);
|
||||
|
||||
|
||||
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n",
|
||||
MapName,
|
||||
ModelInstName,
|
||||
|
|
|
|||
|
|
@ -11,17 +11,10 @@ class WMOInstance;
|
|||
|
||||
Vec3D fixCoordSystem(Vec3D v);
|
||||
|
||||
|
||||
|
||||
|
||||
class Model
|
||||
{
|
||||
public:
|
||||
|
||||
ModelHeader header;
|
||||
|
||||
public:
|
||||
|
||||
uint32 offsBB_vertices, offsBB_indices;
|
||||
Vec3D *BB_vertices, *vertices;
|
||||
uint16 *BB_indices, *indices;
|
||||
|
|
@ -30,8 +23,6 @@ public:
|
|||
bool open();
|
||||
bool ConvertToVMAPModel(char * outfilename);
|
||||
|
||||
public:
|
||||
|
||||
bool ok;
|
||||
|
||||
Model(std::string &filename);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ typedef int int32;
|
|||
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct ModelHeader {
|
||||
struct ModelHeader
|
||||
{
|
||||
char id[4];
|
||||
uint8 version[4];
|
||||
uint32 nameLength;
|
||||
|
|
@ -77,6 +78,4 @@ struct ModelHeader {
|
|||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
typedef std::vector<MPQArchive*> ArchiveSet;
|
||||
ArchiveSet gOpenArchives;
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
MPQArchive::MPQArchive(const char* filename)
|
||||
{
|
||||
BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ);
|
||||
|
|
@ -15,7 +15,6 @@ MPQArchive::MPQArchive(const char* filename)
|
|||
printf("Opening %s\n", filename);
|
||||
gOpenArchives.push_back(ar);
|
||||
succ = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -28,7 +27,6 @@ void MPQArchive::close()
|
|||
SFileCloseArchive(hMPQ);
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
MPQFile::MPQFile(const char* filename):
|
||||
eof(false),
|
||||
buffer(0),
|
||||
|
|
@ -37,7 +35,6 @@ MPQFile::MPQFile(const char* filename):
|
|||
{
|
||||
for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i)
|
||||
{
|
||||
|
||||
HANDLE hFile = "";
|
||||
MPQArchive*(hMPQ) = *i;
|
||||
BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
|
||||
|
|
@ -62,7 +59,6 @@ MPQFile::MPQFile(const char* filename):
|
|||
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
|
||||
}
|
||||
|
||||
MPQFile::~MPQFile()
|
||||
|
|
@ -133,4 +129,3 @@ char* MPQFile::getPointer()
|
|||
{
|
||||
return buffer + pointer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,8 @@ using namespace std;
|
|||
|
||||
typedef unsigned int uint32;
|
||||
|
||||
|
||||
class MPQArchive
|
||||
{
|
||||
|
||||
public:
|
||||
HANDLE hMPQ;
|
||||
MPQArchive(const char* filename);
|
||||
|
|
@ -63,7 +61,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,7 +221,4 @@ inline void rotate(float x0, float y0, float *x, float *y, float angle)
|
|||
*y = xa*sinf(angle) + ya*cosf(angle) + y0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ static const char * GetPlainName(const char * szFileName)
|
|||
szFileName = szTemp + 1;
|
||||
return szFileName;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static void ShowProcessedFile(const char * szFileName)
|
||||
{
|
||||
char szLine[80];
|
||||
|
|
@ -101,11 +101,8 @@ static void ShowProcessedFile(const char * szFileName)
|
|||
printf("\r%s\n", szLine);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
|
||||
char* szListFile = "";
|
||||
char szLocalFile[MAX_PATH] = "";
|
||||
HANDLE hMpq = "";
|
||||
|
|
@ -118,9 +115,8 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
szListFile = NULL;
|
||||
//char tmp[1024];
|
||||
//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]);
|
||||
//if(!SFileOpenArchive(tmp, 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];
|
||||
strncpy((char*)cpy,rchr,4);
|
||||
for (int i=0;i<4;i++)
|
||||
for (int i=0;i<4; ++i)
|
||||
{
|
||||
int m = cpy[i];
|
||||
if(isdigit(m))
|
||||
|
|
@ -172,7 +168,7 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
int Wmo_nVertices = 0;
|
||||
if(froot->nGroups !=0)
|
||||
{
|
||||
for (int i=0; i<froot->nGroups; i++)
|
||||
for (int i=0; i<froot->nGroups; ++i)
|
||||
{
|
||||
char temp[512];
|
||||
strcpy(temp, wf.cFileName);
|
||||
|
|
@ -196,7 +192,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;
|
||||
|
|
@ -220,29 +218,27 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
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 +246,6 @@ void ParsMapFiles()
|
|||
ADT->init(id_filename);
|
||||
delete ADT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -259,31 +254,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 +299,6 @@ void getGamePath()
|
|||
#endif
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -338,7 +328,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 +338,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 +395,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 +421,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 +434,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 +441,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");
|
||||
|
|
@ -537,7 +537,8 @@ int main(int argc, char ** argv)
|
|||
std::vector<std::string> 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()));
|
||||
}
|
||||
ExtractWmo(archiveNames);
|
||||
|
|
@ -550,7 +551,7 @@ int main(int argc, char ** argv)
|
|||
dbc->open();
|
||||
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,7 +565,8 @@ 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#include "wdtfile.h"
|
||||
#include "adtfile.h"
|
||||
|
||||
|
||||
char * wdtGetPlainName(char * FileName)
|
||||
{
|
||||
char * szTemp;
|
||||
|
|
@ -20,7 +19,6 @@ WDTFile::WDTFile(char* file_name, char* file_name1):WDT(file_name)
|
|||
|
||||
bool WDTFile::init(char *map_id)
|
||||
{
|
||||
|
||||
if (WDT.isEof())
|
||||
{
|
||||
//printf("Can't find WDT file.\n");
|
||||
|
|
@ -30,7 +28,6 @@ bool WDTFile::init(char *map_id)
|
|||
char fourcc[5];
|
||||
size_t size;
|
||||
|
||||
|
||||
const char dirname[] = "buildings\\dir";
|
||||
FILE *dirfile;
|
||||
dirfile = fopen(dirname, "ab");
|
||||
|
|
@ -40,7 +37,6 @@ bool WDTFile::init(char *map_id)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
while (!WDT.isEof())
|
||||
{
|
||||
WDT.read(fourcc,4);
|
||||
|
|
@ -75,8 +71,7 @@ bool WDTFile::init(char *map_id)
|
|||
delete[] buf;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!strcmp(fourcc,"MODF"))
|
||||
else if (!strcmp(fourcc,"MODF"))
|
||||
{
|
||||
// global wmo instance data
|
||||
if (size)
|
||||
|
|
@ -87,7 +82,7 @@ bool WDTFile::init(char *map_id)
|
|||
fake_mapname = "65 65 ";
|
||||
//gWMO_mapname = fake_mapname + filename;
|
||||
gWMO_mapname = fake_mapname + std::string(map_id);
|
||||
for (int i=0; i<gnWMO; i++)
|
||||
for (int i=0; i<gnWMO; ++i)
|
||||
{
|
||||
int id;
|
||||
WDT.read(&id, 4);
|
||||
|
|
|
|||
|
|
@ -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,26 +201,26 @@ bool WMOGroup::open()
|
|||
LiquEx = new float[sizeof(float) * 3 * noVer];
|
||||
int p = 0;
|
||||
|
||||
for (int j=0; j<hlq.yverts; j++)
|
||||
for (int j=0; j<hlq.yverts; ++j)
|
||||
{
|
||||
for (int i=0; i<hlq.xverts; i++)
|
||||
for (int i=0; i<hlq.xverts; ++i)
|
||||
{
|
||||
LiquEx[p++] = hlq.pos_x + tilesize * i;
|
||||
LiquEx[p++] = hlq.pos_z;
|
||||
LiquEx[p++] = ydir * (hlq.pos_y + tilesize * j);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
f.seek((int)nextpos);
|
||||
}
|
||||
f.close ();
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
||||
{
|
||||
if(pPreciseVectorData) {
|
||||
if(pPreciseVectorData)
|
||||
{
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
char GRP[] = "GRP ";
|
||||
fwrite(GRP,1,4,output);
|
||||
|
|
@ -262,20 +241,54 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
|||
|
||||
uint32 nIdexes = nTriangles * 3;
|
||||
|
||||
if(fwrite("INDX",4, 1, output) != 1) { printf("Error while writing file nbraches ID"); exit(0); }
|
||||
if(fwrite("INDX",4, 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nbraches ID");
|
||||
exit(0);
|
||||
}
|
||||
int wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes;
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); }
|
||||
if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1) { printf("Error while writing file nIndexes"); exit(0); }
|
||||
if(nIdexes >0) {
|
||||
if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes) { printf("Error while writing file indexarray"); exit(0); }
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file wsize");
|
||||
// no need to exit?
|
||||
}
|
||||
if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nIndexes");
|
||||
exit(0);
|
||||
}
|
||||
if(nIdexes >0)
|
||||
{
|
||||
if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes)
|
||||
{
|
||||
printf("Error while writing file indexarray");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(fwrite("VERT",4, 1, output) != 1) { printf("Error while writing file nbraches ID"); exit(0); }
|
||||
if(fwrite("VERT",4, 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nbraches ID");
|
||||
exit(0);
|
||||
}
|
||||
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); }
|
||||
if(fwrite(&nVertices, sizeof(int), 1, output) != 1) { printf("Error while writing file nVertices"); exit(0); }
|
||||
if(nVertices >0) {
|
||||
if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices) { printf("Error while writing file vectors"); exit(0); }
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file wsize");
|
||||
// no need to exit?
|
||||
}
|
||||
if(fwrite(&nVertices, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nVertices");
|
||||
exit(0);
|
||||
}
|
||||
if(nVertices >0)
|
||||
{
|
||||
if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices)
|
||||
{
|
||||
printf("Error while writing file vectors");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(LiquEx_size != 0)
|
||||
|
|
@ -287,7 +300,9 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
|||
}
|
||||
|
||||
return nTriangles;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("Convert GroupWmo...\n");
|
||||
//-------GRP -------------------------------------
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
|
|
@ -336,11 +351,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
|||
//---------MOVI-----------
|
||||
MoviEx = new uint16[IndexExTr_size*3];
|
||||
int m = 0;
|
||||
for (int i=0; i<IndexExTr_size; i++)
|
||||
for (int i=0; i<IndexExTr_size; ++i)
|
||||
{
|
||||
int n = 0;
|
||||
n = IndexExTr[i]*3;
|
||||
for (int x=0; x<3; x++)
|
||||
for (int x=0; x<3; ++x)
|
||||
{
|
||||
MoviEx[m] = MOVI[n];
|
||||
n++;
|
||||
|
|
@ -350,15 +365,15 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
|||
delete [] MOVI;
|
||||
|
||||
MoviExSort = new uint16[IndexExTr_size*3];
|
||||
for(int y=0; y<IndexExTr_size*3; y++)
|
||||
for(int y=0; y<IndexExTr_size*3; ++y)
|
||||
{
|
||||
MoviExSort[y]=MoviEx[y];
|
||||
}
|
||||
|
||||
uint16 hold;
|
||||
for (int pass = 1; pass < IndexExTr_size*3; pass++)
|
||||
for (int pass = 1; pass < IndexExTr_size*3; ++pass)
|
||||
{
|
||||
for (int i=0; i < IndexExTr_size*3-1; i++)
|
||||
for (int i=0; i < IndexExTr_size*3-1; ++i)
|
||||
{
|
||||
if (MoviExSort[i] > MoviExSort[i+1])
|
||||
{
|
||||
|
|
@ -374,7 +389,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
|||
}
|
||||
// double delet
|
||||
uint16 s = 0;
|
||||
for (int i=0; i < IndexExTr_size*3; i++)
|
||||
for (int i=0; i < IndexExTr_size*3; ++i)
|
||||
{
|
||||
if (MoviExSort[i]!=65535)
|
||||
{
|
||||
|
|
@ -383,24 +398,22 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
|||
}
|
||||
}
|
||||
MovtExSort = new uint16[s];
|
||||
for (int i=0; i < s; i++)
|
||||
for (int i=0; i < s; ++i)
|
||||
{
|
||||
MovtExSort[i] = MoviExSort[i];
|
||||
}
|
||||
|
||||
for (int i=0; i < IndexExTr_size*3; i++)
|
||||
for (int i=0; i < IndexExTr_size*3; ++i)
|
||||
{
|
||||
uint16 b = MoviEx[i];
|
||||
for (uint16 x = 0; x < s; x++)
|
||||
for (uint16 x = 0; x < s; ++x)
|
||||
{
|
||||
if(MoviExSort[x] == b)
|
||||
{
|
||||
|
||||
MoviEx[i] = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
int INDX[] = {0x58444E49,IndexExTr_size*6+4,IndexExTr_size*3};
|
||||
fwrite(INDX,4,3,output);
|
||||
|
|
@ -414,11 +427,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
|
|||
//-----MOVT----------
|
||||
int d = 0;
|
||||
MovtEx = new float[s*3];
|
||||
for (uint16 i=0; i<s; i++)
|
||||
for (uint16 i=0; i<s; ++i)
|
||||
{
|
||||
int c=0;//!!!!data in MovtExSort[i] more uint16 in great group wmo files!!!!
|
||||
c = MovtExSort[i]*3;
|
||||
for (int y=0; y<3; y++)
|
||||
for (int y=0; y<3; ++y)
|
||||
{
|
||||
MovtEx[d] = MOVT[c];
|
||||
c++;
|
||||
|
|
@ -491,18 +504,17 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
|||
sprintf(tempname, "buildings\\%s", WmoInstName);
|
||||
FILE *input;
|
||||
input = fopen(tempname, "r+b");
|
||||
|
||||
if(!input)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(input, 8, SEEK_SET); // get the correct no of vertices
|
||||
int nVertices;
|
||||
fread(&nVertices, sizeof (int), 1, input);
|
||||
fclose(input);
|
||||
|
||||
if(nVertices == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* FILE *dirfile;
|
||||
dirfile = fopen(dirname, "ab");
|
||||
|
|
@ -516,7 +528,11 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
|||
x = pos.x;
|
||||
z = pos.z;
|
||||
if(x==0 && z == 0)
|
||||
{ x = 533.33333f*32; z = 533.33333f*32; }
|
||||
{
|
||||
x = 533.33333f*32;
|
||||
z = 533.33333f*32;
|
||||
}
|
||||
|
||||
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f 1.0 %d %d %d,%d %d\n",
|
||||
MapName,
|
||||
WmoInstName,
|
||||
|
|
@ -529,7 +545,3 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
|
|||
|
||||
// fclose(dirfile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,13 +43,11 @@ public:
|
|||
private:
|
||||
std::string filename;
|
||||
char outfilename;
|
||||
|
||||
};
|
||||
|
||||
class WMOGroup
|
||||
{
|
||||
public:
|
||||
|
||||
int offsize,flag,flag1,Xid,Xid2,Xid3,zero1,Xflag,nTexture,GroupID;
|
||||
int mopy_size,moba_size,hlq_xverts,hlq_yverts;
|
||||
int MopyEx_size,IndexExTr_size,LiquEx_size;
|
||||
|
|
@ -82,7 +80,6 @@ public:
|
|||
private:
|
||||
std::string filename;
|
||||
char outfilename;
|
||||
|
||||
};
|
||||
|
||||
struct WMOLiquidHeader
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7908"
|
||||
#define REVISION_NR "7909"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue