diff --git a/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp b/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp index b798263ca..2de3aa751 100644 --- a/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp @@ -1,6 +1,5 @@ #include "adtfile.h" - char * GetPlainName(char * FileName) { char * szTemp; @@ -12,159 +11,149 @@ char * GetPlainName(char * FileName) void fixnamen(char *name, size_t len) { - for (size_t i=0; i0 && name[i]>='A' && name[i]<='Z' && isalpha(name[i-1])) - { - name[i] |= 0x20; - } else if ((i==0 || !isalpha(name[i-1])) && name[i]>='a' && name[i]<='z') - { - name[i] &= ~0x20; - } - } + for (size_t i=0; i0 && name[i]>='A' && name[i]<='Z' && isalpha(name[i-1])) + { + name[i] |= 0x20; + } else if ((i==0 || !isalpha(name[i-1])) && name[i]>='a' && name[i]<='z') + { + name[i] &= ~0x20; + } + } } void fixname2(char *name, size_t len) { - for (size_t i=0; iopen()) - { - 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; - int q = 0; - WmoInstansName = new string[size]; - while (popen()) + { + 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; + int q = 0; + WmoInstansName = new string[size]; + while (p= recordSize); - f.read(&na,4); // Number of records - f.read(&nb,4); // Number of fields - f.read(&es,4); // Size of a record - f.read(&ss,4); // String size - - recordSize = es; - recordCount = na; - fieldCount = nb; - stringSize = ss; - //assert(fieldCount*4 == recordSize); - assert(fieldCount*4 >= recordSize); - - data = new unsigned char[recordSize*recordCount+stringSize]; - stringTable = data + recordSize*recordCount; - f.read(data,recordSize*recordCount+stringSize); - f.close(); - return true; + data = new unsigned char[recordSize*recordCount+stringSize]; + stringTable = data + recordSize*recordCount; + f.read(data,recordSize*recordCount+stringSize); + f.close(); + return true; } DBCFile::~DBCFile() { - delete [] data; + delete [] data; } DBCFile::Record DBCFile::getRecord(size_t id) { - assert(data); - return Record(*this, data + id*recordSize); + assert(data); + return Record(*this, data + id*recordSize); } DBCFile::Iterator DBCFile::begin() { - assert(data); - return Iterator(*this, data); -} -DBCFile::Iterator DBCFile::end() -{ - assert(data); - return Iterator(*this, stringTable); + assert(data); + return Iterator(*this, data); } +DBCFile::Iterator DBCFile::end() +{ + assert(data); + return Iterator(*this, stringTable); +} diff --git a/contrib/vmap_extractor_v2/vmapextract/dbcfile.h b/contrib/vmap_extractor_v2/vmapextract/dbcfile.h index bf6b8635a..63081bca4 100644 --- a/contrib/vmap_extractor_v2/vmapextract/dbcfile.h +++ b/contrib/vmap_extractor_v2/vmapextract/dbcfile.h @@ -9,131 +9,131 @@ class DBCFile { public: - DBCFile(const std::string &filename); - ~DBCFile(); + DBCFile(const std::string &filename); + ~DBCFile(); - // Open database. It must be openened before it can be used. - bool open(); + // Open database. It must be openened before it can be used. + bool open(); - // TODO: Add a close function? + // TODO: Add a close function? - // Database exceptions - class Exception - { - public: - Exception(const std::string &message): message(message) - { } - virtual ~Exception() - { } - const std::string &getMessage() {return message;} - private: - std::string message; - }; + // Database exceptions + class Exception + { + public: + Exception(const std::string &message): message(message) + { } + virtual ~Exception() + { } + const std::string &getMessage() {return message;} + private: + std::string message; + }; - // - class NotFound: public Exception - { - public: - NotFound(): Exception("Key was not found") - { } - }; + // + class NotFound: public Exception + { + public: + NotFound(): Exception("Key was not found") + { } + }; - // Iteration over database - class Iterator; - class Record - { - public: - Record& operator= (const Record& r) - { + // Iteration over database + class Iterator; + class Record + { + public: + Record& operator= (const Record& r) + { file = r.file; - offset = r.offset; - return *this; - } - float getFloat(size_t field) const - { - assert(field < file.fieldCount); - return *reinterpret_cast(offset+field*4); - } - unsigned int getUInt(size_t field) const - { - assert(field < file.fieldCount); - return *reinterpret_cast(offset+(field*4)); - } - int getInt(size_t field) const - { - assert(field < file.fieldCount); - return *reinterpret_cast(offset+field*4); - } - unsigned char getByte(size_t ofs) const - { - assert(ofs < file.recordSize); - return *reinterpret_cast(offset+ofs); - } - const char *getString(size_t field) const - { - assert(field < file.fieldCount); - size_t stringOffset = getUInt(field); - assert(stringOffset < file.stringSize); - //char * tmp = (char*)file.stringTable + stringOffset; - //unsigned char * tmp2 = file.stringTable + stringOffset; - return reinterpret_cast(file.stringTable + stringOffset); - } - private: - Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {} - unsigned char *offset; - DBCFile &file; + offset = r.offset; + return *this; + } + float getFloat(size_t field) const + { + assert(field < file.fieldCount); + return *reinterpret_cast(offset+field*4); + } + unsigned int getUInt(size_t field) const + { + assert(field < file.fieldCount); + return *reinterpret_cast(offset+(field*4)); + } + int getInt(size_t field) const + { + assert(field < file.fieldCount); + return *reinterpret_cast(offset+field*4); + } + unsigned char getByte(size_t ofs) const + { + assert(ofs < file.recordSize); + return *reinterpret_cast(offset+ofs); + } + const char *getString(size_t field) const + { + assert(field < file.fieldCount); + size_t stringOffset = getUInt(field); + assert(stringOffset < file.stringSize); + //char * tmp = (char*)file.stringTable + stringOffset; + //unsigned char * tmp2 = file.stringTable + stringOffset; + return reinterpret_cast(file.stringTable + stringOffset); + } + private: + Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {} + unsigned char *offset; + DBCFile &file; - friend class DBCFile; - friend class Iterator; - }; + friend class DBCFile; + friend class Iterator; + }; - /* Iterator that iterates over records */ - class Iterator - { - public: - Iterator(DBCFile &file, unsigned char *offset): - record(file, offset) {} - /// Advance (prefix only) - Iterator & operator++() { - record.offset += record.file.recordSize; - return *this; - } - /// Return address of current instance - Record const & operator*() const { return record; } - const Record* operator->() const { - return &record; - } - /// Comparison - bool operator==(const Iterator &b) const - { - return record.offset == b.record.offset; - } - bool operator!=(const Iterator &b) const - { - return record.offset != b.record.offset; - } - private: - Record record; - }; + /* Iterator that iterates over records */ + class Iterator + { + public: + Iterator(DBCFile &file, unsigned char *offset): + record(file, offset) {} + /// Advance (prefix only) + Iterator & operator++() { + record.offset += record.file.recordSize; + return *this; + } + /// Return address of current instance + Record const & operator*() const { return record; } + const Record* operator->() const { + return &record; + } + /// Comparison + bool operator==(const Iterator &b) const + { + return record.offset == b.record.offset; + } + bool operator!=(const Iterator &b) const + { + return record.offset != b.record.offset; + } + private: + Record record; + }; - // Get record by id - Record getRecord(size_t id); - /// Get begin iterator over records - Iterator begin(); - /// Get begin iterator over records - Iterator end(); - /// Trivial - size_t getRecordCount() const { return recordCount;} - size_t getFieldCount() const { return fieldCount; } + // Get record by id + Record getRecord(size_t id); + /// Get begin iterator over records + Iterator begin(); + /// Get begin iterator over records + Iterator end(); + /// Trivial + size_t getRecordCount() const { return recordCount;} + size_t getFieldCount() const { return fieldCount; } private: - std::string filename; - size_t recordSize; - size_t recordCount; - size_t fieldCount; - size_t stringSize; - unsigned char *data; - unsigned char *stringTable; + std::string filename; + size_t recordSize; + size_t recordCount; + size_t fieldCount; + size_t stringSize; + unsigned char *data; + unsigned char *stringTable; }; #endif diff --git a/contrib/vmap_extractor_v2/vmapextract/model.cpp b/contrib/vmap_extractor_v2/vmapextract/model.cpp index 1d0c17d52..9605e3320 100644 --- a/contrib/vmap_extractor_v2/vmapextract/model.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/model.cpp @@ -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; i0) + 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 ArchiveSet; ArchiveSet 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); + 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); - } + } + else + { + printf("Error!!!Not open archive %s\n", filename); + } } void MPQArchive::close() { - SFileCloseArchive(hMPQ); + SFileCloseArchive(hMPQ); } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx MPQFile::MPQFile(const char* filename): - eof(false), - buffer(0), - pointer(0), - size(0) + eof(false), + buffer(0), + pointer(0), + size(0) { - for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i) - { - - 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; - return; - } - size = (size_t)s; - buffer = new char[s]; - SFileReadFile(hFile, buffer, s, 0, 0); - SFileCloseFile(hFile); - - eof = false; - return; - } - } - - eof = true; - buffer = 0; - + for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i) + { + 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; + 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() { - close(); + close(); } size_t MPQFile::read(void* dest, size_t bytes) { - if (eof) - return 0; + if (eof) + return 0; - size_t rpos = pointer + bytes; - if (rpos > size) - { - bytes = size - pointer; - eof = true; - } + size_t rpos = pointer + bytes; + if (rpos > size) + { + bytes = size - pointer; + eof = true; + } - memcpy(dest, &(buffer[pointer]), bytes); + memcpy(dest, &(buffer[pointer]), bytes); - pointer = rpos; + pointer = rpos; - return bytes; + return bytes; } bool MPQFile::isEof() @@ -96,41 +92,40 @@ bool MPQFile::isEof() void MPQFile::seek(int offset) { - pointer = offset; - eof = (pointer >= size); + pointer = offset; + eof = (pointer >= size); } void MPQFile::seekRelative(int offset) { - pointer += offset; - eof = (pointer >= size); + pointer += offset; + eof = (pointer >= size); } void MPQFile::close() { - if (buffer) - delete[] buffer; - buffer = 0; - eof = true; + if (buffer) + delete[] buffer; + buffer = 0; + eof = true; } size_t MPQFile::getSize() { - return size; + return size; } size_t MPQFile::getPos() { - return pointer; + return pointer; } char* MPQFile::getBuffer() { - return buffer; + return buffer; } char* MPQFile::getPointer() { - return buffer + pointer; + return buffer + pointer; } - diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq.h b/contrib/vmap_extractor_v2/vmapextract/mpq.h index 79f30afc7..8fc885667 100644 --- a/contrib/vmap_extractor_v2/vmapextract/mpq.h +++ b/contrib/vmap_extractor_v2/vmapextract/mpq.h @@ -3,7 +3,7 @@ #ifndef MPQ_H #define MPQ_H -#define __STORMLIB_SELF__ +#define __STORMLIB_SELF__ #include #include @@ -15,55 +15,50 @@ using namespace std; typedef unsigned int uint32; - class MPQArchive { - public: - HANDLE hMPQ; - MPQArchive(const char* filename); - void close(); + HANDLE hMPQ; + MPQArchive(const char* filename); + void close(); }; - + class MPQFile { - HANDLE hFile; + HANDLE hFile; HANDLE hMPQ; - bool eof; - char *buffer; - size_t pointer, - size; + bool eof; + char *buffer; + size_t pointer, + size; - // disable copying - //MPQFile(const MPQFile &f) {} - //void operator=(const MPQFile &f) {} + // disable copying + //MPQFile(const MPQFile &f) {} + //void operator=(const MPQFile &f) {} public: - MPQFile(const char* filename); - ~MPQFile(); - size_t read(void* dest, size_t bytes); - size_t getSize(); - size_t getPos(); - char* getBuffer(); - char* getPointer(); - bool isEof(); - void seek(int offset); - void seekRelative(int offset); - void close(); + MPQFile(const char* filename); + ~MPQFile(); + size_t read(void* dest, size_t bytes); + size_t getSize(); + size_t getPos(); + char* getBuffer(); + char* getPointer(); + bool isEof(); + void seek(int offset); + void seekRelative(int offset); + void close(); }; inline void flipcc(char *fcc) { - char t; - t=fcc[0]; - fcc[0]=fcc[3]; - fcc[3]=t; - t=fcc[1]; - fcc[1]=fcc[2]; - fcc[2]=t; + char t; + t=fcc[0]; + fcc[0]=fcc[3]; + fcc[3]=t; + t=fcc[1]; + fcc[1]=fcc[2]; + fcc[2]=t; } - - #endif - diff --git a/contrib/vmap_extractor_v2/vmapextract/vec3d.h b/contrib/vmap_extractor_v2/vmapextract/vec3d.h index 88b8e1c4f..fd966138d 100644 --- a/contrib/vmap_extractor_v2/vmapextract/vec3d.h +++ b/contrib/vmap_extractor_v2/vmapextract/vec3d.h @@ -4,227 +4,221 @@ #include #include - - -class Vec3D { +class Vec3D +{ public: - float x,y,z; + float x,y,z; - Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {} + Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {} - Vec3D(const Vec3D& v) : x(v.x), y(v.y), z(v.z) {} + Vec3D(const Vec3D& v) : x(v.x), y(v.y), z(v.z) {} - Vec3D& operator= (const Vec3D &v) { + Vec3D& operator= (const Vec3D &v) { x = v.x; - y = v.y; - z = v.z; - return *this; - } + y = v.y; + z = v.z; + return *this; + } - Vec3D operator+ (const Vec3D &v) const - { - Vec3D r(x+v.x,y+v.y,z+v.z); + Vec3D operator+ (const Vec3D &v) const + { + Vec3D r(x+v.x,y+v.y,z+v.z); return r; - } + } - Vec3D operator- (const Vec3D &v) const - { - Vec3D r(x-v.x,y-v.y,z-v.z); - return r; - } + Vec3D operator- (const Vec3D &v) const + { + Vec3D r(x-v.x,y-v.y,z-v.z); + return r; + } - float operator* (const Vec3D &v) const - { + float operator* (const Vec3D &v) const + { return x*v.x + y*v.y + z*v.z; - } + } - Vec3D operator* (float d) const - { - Vec3D r(x*d,y*d,z*d); + Vec3D operator* (float d) const + { + Vec3D r(x*d,y*d,z*d); return r; - } + } - friend Vec3D operator* (float d, const Vec3D& v) - { - return v * d; - } + friend Vec3D operator* (float d, const Vec3D& v) + { + return v * d; + } - Vec3D operator% (const Vec3D &v) const - { + Vec3D operator% (const Vec3D &v) const + { Vec3D r(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x); - return r; - } + return r; + } - Vec3D& operator+= (const Vec3D &v) - { - x += v.x; - y += v.y; - z += v.z; - return *this; - } + Vec3D& operator+= (const Vec3D &v) + { + x += v.x; + y += v.y; + z += v.z; + return *this; + } - Vec3D& operator-= (const Vec3D &v) - { - x -= v.x; - y -= v.y; - z -= v.z; - return *this; - } + Vec3D& operator-= (const Vec3D &v) + { + x -= v.x; + y -= v.y; + z -= v.z; + return *this; + } - Vec3D& operator*= (float d) - { - x *= d; - y *= d; - z *= d; - return *this; - } + Vec3D& operator*= (float d) + { + x *= d; + y *= d; + z *= d; + return *this; + } - float lengthSquared() const - { - return x*x+y*y+z*z; - } + float lengthSquared() const + { + return x*x+y*y+z*z; + } - float length() const - { + float length() const + { return sqrt(x*x+y*y+z*z); - } + } - Vec3D& normalize() - { - this->operator*= (1.0f/length()); - return *this; - } + Vec3D& normalize() + { + this->operator*= (1.0f/length()); + return *this; + } - Vec3D operator~ () const - { - Vec3D r(*this); + Vec3D operator~ () const + { + Vec3D r(*this); r.normalize(); - return r; - } + return r; + } - friend std::istream& operator>>(std::istream& in, Vec3D& v) - { - in >> v.x >> v.y >> v.z; - return in; - } - - operator float*() - { - return (float*)this; - } + friend std::istream& operator>>(std::istream& in, Vec3D& v) + { + in >> v.x >> v.y >> v.z; + return in; + } + operator float*() + { + return (float*)this; + } }; -class Vec2D { +class Vec2D +{ public: - float x,y; - - Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {} + float x,y; + + Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {} - Vec2D(const Vec2D& v) : x(v.x), y(v.y) {} + Vec2D(const Vec2D& v) : x(v.x), y(v.y) {} - Vec2D& operator= (const Vec2D &v) { + Vec2D& operator= (const Vec2D &v) { x = v.x; - y = v.y; - return *this; - } + y = v.y; + return *this; + } - Vec2D operator+ (const Vec2D &v) const - { - Vec2D r(x+v.x,y+v.y); + Vec2D operator+ (const Vec2D &v) const + { + Vec2D r(x+v.x,y+v.y); return r; - } + } - Vec2D operator- (const Vec2D &v) const - { - Vec2D r(x-v.x,y-v.y); - return r; - } + Vec2D operator- (const Vec2D &v) const + { + Vec2D r(x-v.x,y-v.y); + return r; + } - float operator* (const Vec2D &v) const - { + float operator* (const Vec2D &v) const + { return x*v.x + y*v.y; - } + } - Vec2D operator* (float d) const - { - Vec2D r(x*d,y*d); + Vec2D operator* (float d) const + { + Vec2D r(x*d,y*d); return r; - } + } - friend Vec2D operator* (float d, const Vec2D& v) - { - return v * d; - } + friend Vec2D operator* (float d, const Vec2D& v) + { + return v * d; + } - Vec2D& operator+= (const Vec2D &v) - { - x += v.x; - y += v.y; - return *this; - } + Vec2D& operator+= (const Vec2D &v) + { + x += v.x; + y += v.y; + return *this; + } - Vec2D& operator-= (const Vec2D &v) - { - x -= v.x; - y -= v.y; - return *this; - } + Vec2D& operator-= (const Vec2D &v) + { + x -= v.x; + y -= v.y; + return *this; + } - Vec2D& operator*= (float d) - { - x *= d; - y *= d; - return *this; - } + Vec2D& operator*= (float d) + { + x *= d; + y *= d; + return *this; + } - float lengthSquared() const - { - return x*x+y*y; - } + float lengthSquared() const + { + return x*x+y*y; + } - float length() const - { + float length() const + { return sqrt(x*x+y*y); - } + } - Vec2D& normalize() - { - this->operator*= (1.0f/length()); - return *this; - } + Vec2D& normalize() + { + this->operator*= (1.0f/length()); + return *this; + } - Vec2D operator~ () const - { - Vec2D r(*this); + Vec2D operator~ () const + { + Vec2D r(*this); r.normalize(); - return r; - } + return r; + } - friend std::istream& operator>>(std::istream& in, Vec2D& v) - { + friend std::istream& operator>>(std::istream& in, Vec2D& v) + { in >> v.x >> v.y; - return in; - } - - operator float*() - { - return (float*)this; - } + return in; + } + operator float*() + { + return (float*)this; + } }; - inline void rotate(float x0, float y0, float *x, float *y, float angle) { - float xa = *x - x0, ya = *y - y0; - *x = xa*cosf(angle) - ya*sinf(angle) + x0; - *y = xa*sinf(angle) + ya*cosf(angle) + y0; + float xa = *x - x0, ya = *y - y0; + *x = xa*cosf(angle) - ya*sinf(angle) + x0; + *y = xa*sinf(angle) + ya*cosf(angle) + y0; } - - #endif - diff --git a/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp b/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp index 0d2b39f8d..32ff7970c 100644 --- a/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp @@ -58,7 +58,7 @@ char input_path[1024]="."; bool hasInputPathParam = false; char tmp[512]; bool preciseVectorData = false; -//char gamepath[1024]; +//char gamepath[1024]; //Convert function //bool ConvertADT(char*,char*); @@ -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,14 +101,11 @@ static void ShowProcessedFile(const char * szFileName) printf("\r%s\n", szLine); } - -//---------------------------------------------------------------------------------------------------------------------------------------------------------------------- int ExtractWmo(const std::vector& pArchiveNames) { - - char* szListFile = ""; + char* szListFile = ""; char szLocalFile[MAX_PATH] = ""; - HANDLE hMpq = ""; + HANDLE hMpq = ""; BOOL bResult = FALSE; //const char* ParsArchiveNames[] = {"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ"}; @@ -118,9 +115,8 @@ int ExtractWmo(const std::vector& pArchiveNames) szListFile = NULL; //char tmp[1024]; //for (size_t i=0; i<4; i++) - for (size_t i=0; i& pArchiveNames) // Copy files from archive if(nError == ERROR_SUCCESS) - { + { SFILE_FIND_DATA wf; HANDLE hFind = SFileFindFirstFile(hMpq,"*.wmo*", &wf, szListFile); bResult = TRUE; @@ -149,11 +145,11 @@ int ExtractWmo(const std::vector& 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)) - p++; + p++; } } if(p != 3) @@ -167,12 +163,12 @@ int ExtractWmo(const std::vector& 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; inGroups; i++) + for (int i=0; inGroups; ++i) { char temp[512]; strcpy(temp, wf.cFileName); @@ -189,14 +185,16 @@ int ExtractWmo(const std::vector& pArchiveNames) bResult = SFileFindNextFile(hFind, &wf); break; } - Wmo_nVertices += fgroup->ConvertToVMAPGroupWmo(output, preciseVectorData); + Wmo_nVertices += fgroup->ConvertToVMAPGroupWmo(output, preciseVectorData); } } fseek(output, 8, SEEK_SET); // store the correct no of vertices fwrite(&Wmo_nVertices,sizeof(int),1,output); - fclose(output); + fclose(output); } - } else { + } + else + { fclose(n); } wf.dwFileFlags &= ~MPQ_FILE_HAS_EXTRA; @@ -220,29 +218,27 @@ int ExtractWmo(const std::vector& 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; iinit(id_filename); delete ADT; } - } } } @@ -259,31 +254,28 @@ void ParsMapFiles() #if 0 void ParsMapFiles() { - char fn[512]; - for (unsigned int i=0; iinit(); delete ADT; } - } } } } } #endif -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx void getGamePath() { @@ -297,18 +289,16 @@ void getGamePath() //l = RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Blizzard Entertainment\\Burning Crusade Closed Beta",0,KEY_QUERY_VALUE,&key); l = RegQueryValueEx(key,"InstallPath",0,&t,(LPBYTE)input_path,&s); RegCloseKey(key); - if (strlen(input_path) > 0) - { - if (input_path[strlen(input_path) - 1] != '\\') strcat(input_path, "\\"); - } + if (strlen(input_path) > 0) + { + if (input_path[strlen(input_path) - 1] != '\\') strcat(input_path, "\\"); + } strcat(input_path,"Data\\"); #else strcpy(input_path,"data/"); #endif } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - bool scan_patches(char* scanmatch, std::vector& pArchiveNames) { int i; @@ -338,7 +328,7 @@ bool scan_patches(char* scanmatch, std::vector& pArchiveNames) } matches.reverse(); - for (std::list::iterator i = matches.begin(); i != matches.end(); i++) + for (std::list::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& pArchiveNames) return(true); } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - -bool fillArchiveNameVector(std::vector& pArchiveNames) { - //srand((unsigned int)time(0)); - +bool fillArchiveNameVector(std::vector& pArchiveNames) +{ if(!hasInputPathParam) getGamePath(); @@ -408,11 +395,12 @@ bool fillArchiveNameVector(std::vector& 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::iterator i = locales.begin(); i != locales.end(); i++) + for (std::vector::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& pArchiveNames) { // open locale expansion and common files printf("Opening data files from locale directories.\n"); - for (std::vector::iterator i = locales.begin(); i != locales.end(); i++) + for (std::vector::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& 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) { - preciseVectorData = false; - } else if(strcmp("-d",argv[i]) == 0) { - if((i+1)]\n", argv[0]); printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n"); @@ -512,9 +512,9 @@ int main(int argc, char ** argv) char *versionString = "V2.4 2007_07_12"; // Use command line arguments, when some - if(!processArgv(argc, argv, versionString)) + if(!processArgv(argc, argv, versionString)) return 1; - + printf("Extract %s. Beginning work ....\n",versionString); // Set the lowest priority to allow running in the background SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); @@ -528,7 +528,7 @@ int main(int argc, char ** argv) nError = GetLastError(); if(nError == ERROR_ALREADY_EXISTS) nError = ERROR_SUCCESS; - } + } //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // patch goes first -> fake priority handling std::vector archives; @@ -537,7 +537,8 @@ int main(int argc, char ** argv) std::vector archiveNames; fillArchiveNameVector(archiveNames); - for (size_t i=0; iopen(); map_count=dbc->getRecordCount (); map_ids=new map_id[map_count]; - for(unsigned int x=0;xgetRecord (x).getUInt(0); strcpy(map_ids[x].name,dbc->getRecord(x).getString(1)); - printf("Map - %s\n",map_ids[x].name); + printf("Map - %s\n",map_ids[x].name); } delete dbc; @@ -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(); } diff --git a/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp b/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp index 831cdaae7..8d3fb6358 100644 --- a/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp @@ -1,9 +1,8 @@ -#define __STORMLIB_SELF__ +#define __STORMLIB_SELF__ #include "wdtfile.h" #include "adtfile.h" - char * wdtGetPlainName(char * FileName) { char * szTemp; @@ -15,106 +14,102 @@ char * wdtGetPlainName(char * FileName) WDTFile::WDTFile(char* file_name, char* file_name1):WDT(file_name) { - filename.append(file_name1,strlen(file_name1)); + filename.append(file_name1,strlen(file_name1)); } bool WDTFile::init(char *map_id) { + if (WDT.isEof()) + { + //printf("Can't find WDT file.\n"); + return false; + } - if (WDT.isEof()) - { - //printf("Can't find WDT file.\n"); - return false; - } - - char fourcc[5]; - size_t size; - + char fourcc[5]; + size_t size; - const char dirname[] = "buildings\\dir"; - FILE *dirfile; + const char dirname[] = "buildings\\dir"; + FILE *dirfile; dirfile = fopen(dirname, "ab"); - if(!dirfile) - { - printf("Can't open dirfile!'%s'\n"); - return false; - } + if(!dirfile) + { + printf("Can't open dirfile!'%s'\n"); + return false; + } + while (!WDT.isEof()) + { + WDT.read(fourcc,4); + WDT.read(&size, 4); - while (!WDT.isEof()) - { - WDT.read(fourcc,4); - WDT.read(&size, 4); + flipcc(fourcc); + fourcc[4] = 0; - flipcc(fourcc); - fourcc[4] = 0; + size_t nextpos = WDT.getPos() + size; - size_t nextpos = WDT.getPos() + size; - - if (!strcmp(fourcc,"MAIN")) - { - } - if (!strcmp(fourcc,"MWMO")) - { - // global map objects - if (size) - { - char *buf = new char[size]; - WDT.read(buf, size); - char *p=buf; - int q = 0; - gWmoInstansName = new string[size]; - while (p=0 && z >= 0 && x<64 && z<64)) return NULL; - - char name[512]; + if(!(x>=0 && z >= 0 && x<64 && z<64)) return NULL; - sprintf(name,"World\\Maps\\%s\\%s_%d_%d.adt", filename.c_str(), filename.c_str(), x, z); - return new ADTFile(name); + char name[512]; + + sprintf(name,"World\\Maps\\%s\\%s_%d_%d.adt", filename.c_str(), filename.c_str(), x, z); + return new ADTFile(name); } diff --git a/contrib/vmap_extractor_v2/vmapextract/wdtfile.h b/contrib/vmap_extractor_v2/vmapextract/wdtfile.h index 7a7002a2e..0baef22f1 100644 --- a/contrib/vmap_extractor_v2/vmapextract/wdtfile.h +++ b/contrib/vmap_extractor_v2/vmapextract/wdtfile.h @@ -1,7 +1,7 @@ #ifndef WDTFILE_H #define WDTFILE_H -#define __STORMLIB_SELF__ +#define __STORMLIB_SELF__ #include "mpq.h" #include "adtfile.h" @@ -12,19 +12,19 @@ class WDTFile { public: - WDTFile(char* file_name, char* file_name1); - ~WDTFile(void); - bool init(char *map_id); - - string* gWmoInstansName; - int gnWMO, nMaps; - - ADTFile* GetMap(int x, int z); + WDTFile(char* file_name, char* file_name1); + ~WDTFile(void); + bool init(char *map_id); + + string* gWmoInstansName; + int gnWMO, nMaps; + + ADTFile* GetMap(int x, int z); private: - MPQFile WDT; - bool maps[64][64]; - string filename; + MPQFile WDT; + bool maps[64][64]; + string filename; }; #endif diff --git a/contrib/vmap_extractor_v2/vmapextract/wmo.cpp b/contrib/vmap_extractor_v2/vmapextract/wmo.cpp index a0deab1eb..b56a79477 100644 --- a/contrib/vmap_extractor_v2/vmapextract/wmo.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/wmo.cpp @@ -6,444 +6,457 @@ using namespace std; - WMORoot::WMORoot(std::string &filename) : filename(filename) { } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx bool WMORoot::open() { + MPQFile f(filename.c_str()); + if(f.isEof ()) + { + printf("No such file.\n"); + return false; + } - MPQFile f(filename.c_str()); - if(f.isEof ()) - { - printf("No such file.\n"); - return false; - } + size_t size; + char fourcc[5]; + bbcorn1[3] = 0; + bbcorn2[3]= 0; - size_t size; - char fourcc[5]; - bbcorn1[3] = 0; - bbcorn2[3]= 0; + while (!f.isEof()) + { + f.read(fourcc,4); + f.read(&size, 4); - while (!f.isEof ()) - { - f.read(fourcc,4); - f.read(&size, 4); + flipcc(fourcc); + fourcc[4] = 0; - flipcc(fourcc); - fourcc[4] = 0; + size_t nextpos = f.getPos() + size; - size_t nextpos = f.getPos() + size; - - if (!strcmp(fourcc,"MOHD"))//header - { - - f.read(&nTextures, 4); - f.read(&nGroups, 4); - f.read(&nP, 4); - f.read(&nLights, 4); - f.read(&nModels, 4); - f.read(&nDoodads, 4); - f.read(&nDoodadSets, 4); - f.read(&col, 4); - f.read(&RootID, 4); - f.read(bbcorn1,12); - f.read(bbcorn2,12); - break; - } - /* - 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); - } - f.close (); - return true; + if (!strcmp(fourcc,"MOHD"))//header + { + f.read(&nTextures, 4); + f.read(&nGroups, 4); + f.read(&nP, 4); + f.read(&nLights, 4); + f.read(&nModels, 4); + f.read(&nDoodads, 4); + f.read(&nDoodadSets, 4); + f.read(&col, 4); + f.read(&RootID, 4); + f.read(bbcorn1,12); + f.read(bbcorn2,12); + break; + } + /* + 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); + } + f.close (); + return true; } -//--------------------------------------------------------------------------- bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile) { - //printf("Convert RootWmo...\n"); + //printf("Convert RootWmo...\n"); - fwrite("VMAP002",1,8,pOutfile); - unsigned int nVectors = 0; - fwrite(&nVectors,sizeof(nVectors),1,pOutfile); // will be filled later - fwrite(&nGroups,4,1,pOutfile); - return true; + fwrite("VMAP002",1,8,pOutfile); + unsigned int nVectors = 0; + fwrite(&nVectors,sizeof(nVectors),1,pOutfile); // will be filled later + fwrite(&nGroups,4,1,pOutfile); + return true; } -//---------------------------------------------------------------------------- WMORoot::~WMORoot() { } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx WMOGroup::WMOGroup(std::string &filename) : filename(filename) { } -//--------------------------------------------------------------------------- + bool WMOGroup::open() { - MPQFile f(filename.c_str()); - if(f.isEof ()) - { - printf("No such file.\n"); - return false; - } - size_t size; - char fourcc[5]; - bbcorn1[3] = 0; - bbcorn2[3] = 0; - while (!f.isEof ()) - { - f.read(fourcc,4); - f.read(&size, 4); - flipcc(fourcc); - if (!strcmp(fourcc,"MOGP"))//Fix sizeoff = Data size. - { - size = 68; - } - fourcc[4] = 0; - size_t nextpos = f.getPos() + size; - LiquEx_size = 0; - liquflags = 0; + MPQFile f(filename.c_str()); + if(f.isEof ()) + { + printf("No such file.\n"); + return false; + } + size_t size; + char fourcc[5]; + bbcorn1[3] = 0; + bbcorn2[3] = 0; + while (!f.isEof()) + { + f.read(fourcc,4); + f.read(&size, 4); + flipcc(fourcc); + if (!strcmp(fourcc,"MOGP"))//Fix sizeoff = Data size. + { + size = 68; + } + fourcc[4] = 0; + size_t nextpos = f.getPos() + size; + LiquEx_size = 0; + liquflags = 0; - if (!strcmp(fourcc,"MOGP"))//header - { - f.seekRelative(-4); - f.read(&offsize, 4); - f.read(&flag, 4); - f.read(&flag1, 4); - f.read(&Xid, 4); - f.read(bbcorn1, 12); - f.read(bbcorn2, 12); - f.read(&Xid2, 4); - f.read(&Xid3, 4); - f.read(&zero1, 4); - f.read(&Xflag, 4); - f.read(&nTexture,4); - f.read(&GroupID,4); - } - else if (!strcmp(fourcc,"MOPY")) - { - MOPY = new char[size]; - mopy_size = size; - nTriangles = (int)size / 2; - f.read(MOPY, size); - } - else if (!strcmp(fourcc,"MOVI")) - { - MOVI = new uint16[size/2]; - f.read(MOVI, size); + if (!strcmp(fourcc,"MOGP"))//header + { + f.seekRelative(-4); + f.read(&offsize, 4); + f.read(&flag, 4); + f.read(&flag1, 4); + f.read(&Xid, 4); + f.read(bbcorn1, 12); + f.read(bbcorn2, 12); + f.read(&Xid2, 4); + f.read(&Xid3, 4); + f.read(&zero1, 4); + f.read(&Xflag, 4); + f.read(&nTexture,4); + f.read(&GroupID,4); + } + else if (!strcmp(fourcc,"MOPY")) + { + MOPY = new char[size]; + mopy_size = size; + nTriangles = (int)size / 2; + f.read(MOPY, size); + } + else if (!strcmp(fourcc,"MOVI")) + { + MOVI = new uint16[size/2]; + f.read(MOVI, size); + } + else if (!strcmp(fourcc,"MOVT")) + { + MOVT = new float[size/4]; + f.read(MOVT, size); + nVertices = (int)size / 12; + } + else if (!strcmp(fourcc,"MONR")) + { + } + else if (!strcmp(fourcc,"MOTV")) + { + } + else if (!strcmp(fourcc,"MOBA")) + { + MOBA = new uint16[size/2]; + moba_size = size/2; + f.read(MOBA, size); + } + else if (!strcmp(fourcc,"MLIQ")) + { + liquflags |= 1; + WMOLiquidHeader hlq; + f.read(&hlq, 0x1E); + float ydir = -1.0f; + hlq_xverts = hlq.xverts; + hlq_yverts = hlq.yverts; + int noVer = hlq.xverts * hlq.yverts; + float tilesize = CHUNKSIZE / 8.0f; + LiquEx_size = sizeof(float) * 3 * noVer; + LiquEx = new float[sizeof(float) * 3 * noVer]; + int p = 0; - } - else if (!strcmp(fourcc,"MOVT")) - { - MOVT = new float[size/4]; - f.read(MOVT, size); - nVertices = (int)size / 12; - } - else if (!strcmp(fourcc,"MONR")) - { - } - else if (!strcmp(fourcc,"MOTV")) - { - } - else if (!strcmp(fourcc,"MOBA")) - { - MOBA = new uint16[size/2]; - moba_size = size/2; - f.read(MOBA, size); - } - else if (!strcmp(fourcc,"MLIQ")) - { - liquflags |= 1; - WMOLiquidHeader hlq; - f.read(&hlq, 0x1E); - float ydir = -1.0f; - hlq_xverts = hlq.xverts; - hlq_yverts = hlq.yverts; - int noVer = hlq.xverts * hlq.yverts; - float tilesize = CHUNKSIZE / 8.0f; - LiquEx_size = sizeof(float) * 3 * noVer; - LiquEx = new float[sizeof(float) * 3 * noVer]; - int p = 0; - - for (int j=0; j0) { - 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 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> 16; + doodadset = (d2 & 0xFFFF0000) >> 16; - int realx1 = (int) ((float) pos2.x / 533.333333f); - int realy1 = (int) ((float) pos2.z / 533.333333f); - int realx2 = (int) ((float) pos3.x / 533.333333f); - int realy2 = (int) ((float) pos3.z / 533.333333f); + int realx1 = (int) ((float) pos2.x / 533.333333f); + int realy1 = (int) ((float) pos2.z / 533.333333f); + int realx2 = (int) ((float) pos3.x / 533.333333f); + int realy2 = (int) ((float) pos3.z / 533.333333f); - if(realx1 < 0) - { - realx1 +=20; realx2+=20; - } - if(realy1 < 0) - { - realy1 +=20; realy2+=20; - } // hack to prevent neg. values + if(realx1 < 0) + { + realx1 +=20; realx2+=20; + } + if(realy1 < 0) + { + realy1 +=20; realy2+=20; + } // hack to prevent neg. values - //-----------add_in _dir_file---------------- + //-----------add_in _dir_file---------------- - char tempname[512]; - // const char dirname[] = "buildings\\dir"; + char tempname[512]; + // 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; - } + sprintf(tempname, "buildings\\%s", WmoInstName); + FILE *input; + input = fopen(tempname, "r+b"); - /* FILE *dirfile; - dirfile = fopen(dirname, "ab"); - if(!dirfile) - { - printf("Can't open dirfile!'%s'\n"); - return; - } - */ - float x,z; - x = pos.x; - z = pos.z; - if(x==0 && z == 0) - { 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, - (float) x, (float) pos.y, (float) z, - (float) rot.x, (float) rot.y, (float) rot.z, - nVertices, - realx1, realy1, - realx2, realy2 - ); + if(!input) + return; - // fclose(dirfile); -} + 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"); + if(!dirfile) + { + printf("Can't open dirfile!'%s'\n"); + return; + } + */ + float x,z; + x = pos.x; + z = pos.z; + if(x==0 && z == 0) + { + 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, + (float) x, (float) pos.y, (float) z, + (float) rot.x, (float) rot.y, (float) rot.z, + nVertices, + realx1, realy1, + realx2, realy2 + ); + // fclose(dirfile); +} diff --git a/contrib/vmap_extractor_v2/vmapextract/wmo.h b/contrib/vmap_extractor_v2/vmapextract/wmo.h index 589e9113a..d57340855 100644 --- a/contrib/vmap_extractor_v2/vmapextract/wmo.h +++ b/contrib/vmap_extractor_v2/vmapextract/wmo.h @@ -30,86 +30,83 @@ typedef unsigned int uint32; class WMORoot { public: - int nTextures, nGroups, nP, nLights, nModels, nDoodads, nDoodadSets, RootID; - unsigned int col; - int bbcorn1[3]; - int bbcorn2[3]; + int nTextures, nGroups, nP, nLights, nModels, nDoodads, nDoodadSets, RootID; + unsigned int col; + int bbcorn1[3]; + int bbcorn2[3]; - WMORoot(std::string &filename); - ~WMORoot(); - - bool open(); - bool ConvertToVMAPRootWmo(FILE *output); + WMORoot(std::string &filename); + ~WMORoot(); + + bool open(); + bool ConvertToVMAPRootWmo(FILE *output); private: - std::string filename; - char outfilename; - + 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; - unsigned int nVertices; // number when loaded - int nTriangles; // number when loaded - int bbcorn1[3]; - int bbcorn2[3]; - int * IndexExTr; - char* MOPY; - char* MopyEx; - uint16* MOVI; - uint16* MoviEx; - uint16* MoviExSort; - float* MOVT; - float* MovtEx; - uint16* MovtExSort; - float* MONR; - float* MonrEx; - uint16* MOBA; - int* MobaEx; - float* LiquEx; - uint32 liquflags; - - WMOGroup(std::string &filename); - ~WMOGroup(); + 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; + unsigned int nVertices; // number when loaded + int nTriangles; // number when loaded + int bbcorn1[3]; + int bbcorn2[3]; + int * IndexExTr; + char* MOPY; + char* MopyEx; + uint16* MOVI; + uint16* MoviEx; + uint16* MoviExSort; + float* MOVT; + float* MovtEx; + uint16* MovtExSort; + float* MONR; + float* MonrEx; + uint16* MOBA; + int* MobaEx; + float* LiquEx; + uint32 liquflags; - bool open(); - int ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData); + WMOGroup(std::string &filename); + ~WMOGroup(); + + bool open(); + int ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData); private: - std::string filename; - char outfilename; - + std::string filename; + char outfilename; }; struct WMOLiquidHeader { - int xverts, yverts, xtiles, ytiles; - float pos_x; - float pos_y; - float pos_z; - short type; + int xverts, yverts, xtiles, ytiles; + float pos_x; + float pos_y; + float pos_z; + short type; }; class WMOInstance { - static std::set ids; + static std::set ids; public: string MapName; int currx; - int curry; - WMOGroup *wmo; - Vec3D pos; - Vec3D pos2, pos3, rot; - int indx,id, d2, d3; - int doodadset; + int curry; + WMOGroup *wmo; + Vec3D pos; + Vec3D pos2, pos3, rot; + int indx,id, d2, d3; + int doodadset; - WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName, FILE *pDirfile); + WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName, FILE *pDirfile); - static void reset(); + static void reset(); }; -#endif \ No newline at end of file +#endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 649859178..71cf82c94 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7908" + #define REVISION_NR "7909" #endif // __REVISION_NR_H__