Merge pull request #45 from H0zen/develop21-tools
[Tools] Fix a bug in previous commit where some wmo's were not extracted at all.
This commit is contained in:
commit
a11f1e62a0
@ -355,7 +355,8 @@ namespace VMAP
|
|||||||
{
|
{
|
||||||
if (fread(&displayId, sizeof(uint32), 1, model_list) <= 0)
|
if (fread(&displayId, sizeof(uint32), 1, model_list) <= 0)
|
||||||
{
|
{
|
||||||
std::cout << "\nFile '" << GAMEOBJECT_MODELS << "' seems to be corrupted" << std::endl;
|
if (!feof(model_list))
|
||||||
|
std::cout << "\nFile '" << GAMEOBJECT_MODELS << "' seems to be corrupted" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fread(&name_length, sizeof(uint32), 1, model_list) <= 0)
|
if (fread(&name_length, sizeof(uint32), 1, model_list) <= 0)
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "Platform/Define.h"
|
#include "Platform/Define.h"
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ add_executable(${EXECUTABLE_NAME} ${EXECUTABLE_SRCS}
|
|||||||
${CMAKE_SOURCE_DIR}/src/shared/Auth/md5.c
|
${CMAKE_SOURCE_DIR}/src/shared/Auth/md5.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${EXECUTABLE_NAME} libmpq loadlib bzip2 zlib)
|
target_link_libraries(${EXECUTABLE_NAME} loadlib libmpq bzip2 zlib)
|
||||||
|
|
||||||
#Output the compiled exes to build/bin/$(Configuration)/tools directory on windows by default
|
#Output the compiled exes to build/bin/$(Configuration)/tools directory on windows by default
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
@ -22,20 +22,14 @@
|
|||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstdio>
|
||||||
#include "vmapexport.h"
|
#include "vmapexport.h"
|
||||||
#include "adtfile.h"
|
#include "adtfile.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
ADTFile::ADTFile(char* filename): ADT(filename)
|
ADTFile::ADTFile(char* filename): ADT(filename)
|
||||||
{
|
{
|
||||||
AdtFilename.append(filename);
|
AdtFilename.assign(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failedPaths)
|
bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failedPaths)
|
||||||
@ -97,7 +91,6 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failed
|
|||||||
std::string uName;
|
std::string uName;
|
||||||
ExtractSingleModel(path, uName, failedPaths);
|
ExtractSingleModel(path, uName, failedPaths);
|
||||||
ModelInstansName[t++] = uName;
|
ModelInstansName[t++] = uName;
|
||||||
|
|
||||||
p = p + strlen(p) + 1;
|
p = p + strlen(p) + 1;
|
||||||
}
|
}
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
@ -116,7 +109,6 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failed
|
|||||||
{
|
{
|
||||||
std::string path(p);
|
std::string path(p);
|
||||||
WmoInstansName[q++] = GetUniformName(path);
|
WmoInstansName[q++] = GetUniformName(path);
|
||||||
;
|
|
||||||
p = p + strlen(p) + 1;
|
p = p + strlen(p) + 1;
|
||||||
}
|
}
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#ifndef ADT_H
|
#ifndef ADT_H
|
||||||
#define ADT_H
|
#define ADT_H
|
||||||
|
|
||||||
#include <libmpq/mpq.h>
|
|
||||||
#include <ml/mpq.h>
|
#include <ml/mpq.h>
|
||||||
#include "wmo.h"
|
#include "wmo.h"
|
||||||
#include "vmapexport.h"
|
#include "vmapexport.h"
|
||||||
@ -35,8 +34,6 @@
|
|||||||
#define CHUNKSIZE ((TILESIZE) / 16.0f)
|
#define CHUNKSIZE ((TILESIZE) / 16.0f)
|
||||||
#define UNITSIZE (CHUNKSIZE / 8.0f)
|
#define UNITSIZE (CHUNKSIZE / 8.0f)
|
||||||
|
|
||||||
class Liquid;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
@ -142,7 +139,6 @@ struct MapChunkHeader
|
|||||||
uint32 effectId; /**< TODO */
|
uint32 effectId; /**< TODO */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
|
@ -22,27 +22,15 @@
|
|||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vmapexport.h"
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include <ml/mpq.h>
|
#include <ml/mpq.h>
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "wmo.h"
|
#include "wmo.h"
|
||||||
#include "dbcfile.h"
|
#include "dbcfile.h"
|
||||||
|
#include "vmapexport.h"
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
Vec3D fixCoordSystem(Vec3D v)
|
|
||||||
{
|
|
||||||
return Vec3D(v.x, v.z, -v.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3D fixCoordSystem2(Vec3D v)
|
|
||||||
{
|
|
||||||
return Vec3D(v.x, v.z, v.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Model::Model(std::string& filename) : filename(filename), vertices(0), indices(0)
|
Model::Model(std::string& filename) : filename(filename), vertices(0), indices(0)
|
||||||
{
|
{
|
||||||
@ -101,28 +89,28 @@ bool Model::ConvertToVMAPModel(std::string& outfilename)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fwrite(szRawVMAPMagic, 8, 1, output);
|
fwrite(szRawVMAPMagic, 8, 1, output);
|
||||||
uint32 nVertices = 0;
|
uint32 nVertices = 0;
|
||||||
nVertices = header.nBoundingVertices;
|
nVertices = header.nBoundingVertices;
|
||||||
|
|
||||||
std::fwrite(&nVertices, sizeof(int), 1, output);
|
fwrite(&nVertices, sizeof(int), 1, output);
|
||||||
uint32 nofgroups = 1;
|
uint32 nofgroups = 1;
|
||||||
std::fwrite(&nofgroups, sizeof(uint32), 1, output);
|
fwrite(&nofgroups, sizeof(uint32), 1, output);
|
||||||
std::fwrite(N, 4 * 3, 1, output); // rootwmoid, flags, groupid
|
fwrite(N, 4 * 3, 1, output); // rootwmoid, flags, groupid
|
||||||
std::fwrite(N, sizeof(float), 3 * 2, output); //bbox, only needed for WMO currently
|
fwrite(N, sizeof(float), 3 * 2, output); //bbox, only needed for WMO currently
|
||||||
std::fwrite(N, 4, 1, output); // liquidflags
|
fwrite(N, 4, 1, output); // liquidflags
|
||||||
std::fwrite("GRP ", 4, 1, output);
|
fwrite("GRP ", 4, 1, output);
|
||||||
uint32 branches = 1;
|
uint32 branches = 1;
|
||||||
int wsize;
|
int wsize;
|
||||||
wsize = sizeof(branches) + sizeof(uint32) * branches;
|
wsize = sizeof(branches) + sizeof(uint32) * branches;
|
||||||
std::fwrite(&wsize, sizeof(int), 1, output);
|
fwrite(&wsize, sizeof(int), 1, output);
|
||||||
std::fwrite(&branches, sizeof(branches), 1, output);
|
fwrite(&branches, sizeof(branches), 1, output);
|
||||||
uint32 nIndexes = (uint32) nIndices;
|
uint32 nIndexes = (uint32) nIndices;
|
||||||
std::fwrite(&nIndexes, sizeof(uint32), 1, output);
|
fwrite(&nIndexes, sizeof(uint32), 1, output);
|
||||||
std::fwrite("INDX", 4, 1, output);
|
fwrite("INDX", 4, 1, output);
|
||||||
wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
|
wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
|
||||||
std::fwrite(&wsize, sizeof(int), 1, output);
|
fwrite(&wsize, sizeof(int), 1, output);
|
||||||
std::fwrite(&nIndexes, sizeof(uint32), 1, output);
|
fwrite(&nIndexes, sizeof(uint32), 1, output);
|
||||||
if (nIndexes > 0)
|
if (nIndexes > 0)
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < nIndices; ++i)
|
for (uint32 i = 0; i < nIndices; ++i)
|
||||||
@ -135,12 +123,12 @@ bool Model::ConvertToVMAPModel(std::string& outfilename)
|
|||||||
indices[i+1] = tmp;
|
indices[i+1] = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::fwrite(indices, sizeof(unsigned short), nIndexes, output);
|
fwrite(indices, sizeof(unsigned short), nIndexes, output);
|
||||||
}
|
}
|
||||||
std::fwrite("VERT", 4, 1, output);
|
fwrite("VERT", 4, 1, output);
|
||||||
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
|
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
|
||||||
std::fwrite(&wsize, sizeof(int), 1, output);
|
fwrite(&wsize, sizeof(int), 1, output);
|
||||||
std::fwrite(&nVertices, sizeof(int), 1, output);
|
fwrite(&nVertices, sizeof(int), 1, output);
|
||||||
if (nVertices > 0)
|
if (nVertices > 0)
|
||||||
{
|
{
|
||||||
for (uint32 vpos = 0; vpos < nVertices; ++vpos)
|
for (uint32 vpos = 0; vpos < nVertices; ++vpos)
|
||||||
@ -149,7 +137,7 @@ bool Model::ConvertToVMAPModel(std::string& outfilename)
|
|||||||
vertices[vpos].y = -vertices[vpos].z;
|
vertices[vpos].y = -vertices[vpos].z;
|
||||||
vertices[vpos].z = tmp;
|
vertices[vpos].z = tmp;
|
||||||
}
|
}
|
||||||
std::fwrite(vertices, sizeof(float) * 3, nVertices, output);
|
fwrite(vertices, sizeof(float) * 3, nVertices, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(output);
|
fclose(output);
|
||||||
@ -198,18 +186,18 @@ ModelInstance::ModelInstance(MPQFile& f, string& ModelInstName, uint32 mapID, ui
|
|||||||
uint32 flags = MOD_M2;
|
uint32 flags = MOD_M2;
|
||||||
if (tileX == 65 && tileY == 65) { flags |= MOD_WORLDSPAWN; }
|
if (tileX == 65 && tileY == 65) { flags |= MOD_WORLDSPAWN; }
|
||||||
//write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, name
|
//write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, name
|
||||||
std::fwrite(&mapID, sizeof(uint32), 1, pDirfile);
|
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
|
||||||
std::fwrite(&tileX, sizeof(uint32), 1, pDirfile);
|
fwrite(&tileX, sizeof(uint32), 1, pDirfile);
|
||||||
std::fwrite(&tileY, sizeof(uint32), 1, pDirfile);
|
fwrite(&tileY, sizeof(uint32), 1, pDirfile);
|
||||||
std::fwrite(&flags, sizeof(uint32), 1, pDirfile);
|
fwrite(&flags, sizeof(uint32), 1, pDirfile);
|
||||||
std::fwrite(&adtId, sizeof(uint16), 1, pDirfile);
|
fwrite(&adtId, sizeof(uint16), 1, pDirfile);
|
||||||
std::fwrite(&id, sizeof(uint32), 1, pDirfile);
|
fwrite(&id, sizeof(uint32), 1, pDirfile);
|
||||||
std::fwrite(&pos, sizeof(float), 3, pDirfile);
|
fwrite(&pos, sizeof(float), 3, pDirfile);
|
||||||
std::fwrite(&rot, sizeof(float), 3, pDirfile);
|
fwrite(&rot, sizeof(float), 3, pDirfile);
|
||||||
std::fwrite(&sc, sizeof(float), 1, pDirfile);
|
fwrite(&sc, sizeof(float), 1, pDirfile);
|
||||||
uint32 nlen = ModelInstName.length();
|
uint32 nlen = ModelInstName.length();
|
||||||
std::fwrite(&nlen, sizeof(uint32), 1, pDirfile);
|
fwrite(&nlen, sizeof(uint32), 1, pDirfile);
|
||||||
std::fwrite(ModelInstName.c_str(), sizeof(char), nlen, pDirfile);
|
fwrite(ModelInstName.c_str(), sizeof(char), nlen, pDirfile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,9 +206,9 @@ bool ExtractSingleModel(std::string& origPath, std::string& fixedName, StringSet
|
|||||||
string ext = GetExtension(origPath);
|
string ext = GetExtension(origPath);
|
||||||
|
|
||||||
// < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
|
// < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
|
||||||
if (ext == "mdx")
|
if ((ext == "mdx") || (ext=="mdl"))
|
||||||
{
|
{
|
||||||
// replace .mdx -> .m2
|
// replace .md[l,x] -> .m2
|
||||||
origPath.erase(origPath.length() - 2, 2);
|
origPath.erase(origPath.length() - 2, 2);
|
||||||
origPath.append("2");
|
origPath.append("2");
|
||||||
}
|
}
|
||||||
@ -276,25 +264,21 @@ void ExtractGameobjectModels()
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
if (ch_ext == "wmo")
|
if (ch_ext == "wmo")
|
||||||
{
|
{
|
||||||
|
name = GetUniformName(path);
|
||||||
result = ExtractSingleWmo(path);
|
result = ExtractSingleWmo(path);
|
||||||
}
|
}
|
||||||
else if (ch_ext == "mdl")
|
|
||||||
{
|
|
||||||
// TODO: extract .mdl files, if needed
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = ExtractSingleModel(path, name, failedPaths);
|
result = ExtractSingleModel(path, name, failedPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result)
|
if (result && FileExists((basepath + name).c_str()))
|
||||||
{
|
{
|
||||||
uint32 displayId = it->getUInt(0);
|
uint32 displayId = it->getUInt(0);
|
||||||
uint32 path_length = name.length();
|
uint32 path_length = name.length();
|
||||||
std::fwrite(&displayId, sizeof(uint32), 1, model_list);
|
fwrite(&displayId, sizeof(uint32), 1, model_list);
|
||||||
std::fwrite(&path_length, sizeof(uint32), 1, model_list);
|
fwrite(&path_length, sizeof(uint32), 1, model_list);
|
||||||
std::fwrite(name.c_str(), sizeof(char), path_length, model_list);
|
fwrite(name.c_str(), sizeof(char), path_length, model_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,4 +293,4 @@ void ExtractGameobjectModels()
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Done!\n");
|
printf("Done!\n");
|
||||||
}
|
}
|
||||||
|
@ -25,22 +25,11 @@
|
|||||||
#ifndef MODEL_H
|
#ifndef MODEL_H
|
||||||
#define MODEL_H
|
#define MODEL_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <ml/loadlib.h>
|
#include <ml/loadlib.h>
|
||||||
#include "vec3d.h"
|
#include "vec3d.h"
|
||||||
#include "modelheaders.h"
|
#include "modelheaders.h"
|
||||||
#include <vector>
|
#include "wmo.h"
|
||||||
#include "vmapexport.h"
|
|
||||||
|
|
||||||
class WMOInstance;
|
|
||||||
class MPQFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
* @return Vec3D
|
|
||||||
*/
|
|
||||||
Vec3D fixCoordSystem(Vec3D v);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -61,7 +50,7 @@ class Model
|
|||||||
* @param failedPaths
|
* @param failedPaths
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
bool open(StringSet& failedPaths);
|
bool open(std::set<std::string>& failedPaths);
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
@ -142,7 +131,7 @@ class ModelInstance
|
|||||||
* @param failedPaths Set to collect errors
|
* @param failedPaths Set to collect errors
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
bool ExtractSingleModel(std::string& origPath, std::string& fixedName, StringSet& failedPaths);
|
bool ExtractSingleModel(std::string& origPath, std::string& fixedName, std::set<std::string>& failedPaths);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
@ -260,210 +260,6 @@ class Vec3D
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class Vec2D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
float x, y; /**< TODO */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param x0
|
|
||||||
* @param y0
|
|
||||||
*/
|
|
||||||
Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
*/
|
|
||||||
Vec2D(const Vec2D& v) : x(v.x), y(v.y) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
* @return Vec2D &operator
|
|
||||||
*/
|
|
||||||
Vec2D& operator= (const Vec2D& v)
|
|
||||||
{
|
|
||||||
x = v.x;
|
|
||||||
y = v.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
* @return Vec2D operator
|
|
||||||
*/
|
|
||||||
Vec2D operator+ (const Vec2D& v) const
|
|
||||||
{
|
|
||||||
Vec2D r(x + v.x, y + v.y);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
* @return Vec2D operator
|
|
||||||
*/
|
|
||||||
Vec2D operator- (const Vec2D& v) const
|
|
||||||
{
|
|
||||||
Vec2D r(x - v.x, y - v.y);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
* @return float operator
|
|
||||||
*/
|
|
||||||
float operator* (const Vec2D& v) const
|
|
||||||
{
|
|
||||||
return x * v.x + y * v.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param d
|
|
||||||
* @return Vec2D operator
|
|
||||||
*/
|
|
||||||
Vec2D operator* (float d) const
|
|
||||||
{
|
|
||||||
Vec2D r(x * d, y * d);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param d
|
|
||||||
* @param v
|
|
||||||
* @return Vec2D operator
|
|
||||||
*/
|
|
||||||
friend Vec2D operator* (float d, const Vec2D& v)
|
|
||||||
{
|
|
||||||
return v * d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
* @return Vec2D &operator
|
|
||||||
*/
|
|
||||||
Vec2D& operator+= (const Vec2D& v)
|
|
||||||
{
|
|
||||||
x += v.x;
|
|
||||||
y += v.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
* @return Vec2D &operator
|
|
||||||
*/
|
|
||||||
Vec2D& operator-= (const Vec2D& v)
|
|
||||||
{
|
|
||||||
x -= v.x;
|
|
||||||
y -= v.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param d
|
|
||||||
* @return Vec2D &operator
|
|
||||||
*/
|
|
||||||
Vec2D& operator*= (float d)
|
|
||||||
{
|
|
||||||
x *= d;
|
|
||||||
y *= d;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
float lengthSquared() const
|
|
||||||
{
|
|
||||||
return x * x + y * y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
float length() const
|
|
||||||
{
|
|
||||||
return sqrt(x * x + y * y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @return Vec2D
|
|
||||||
*/
|
|
||||||
Vec2D& normalize()
|
|
||||||
{
|
|
||||||
this->operator*= (1.0f / length());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @return Vec2D operator
|
|
||||||
*/
|
|
||||||
Vec2D operator~() const
|
|
||||||
{
|
|
||||||
Vec2D r(*this);
|
|
||||||
r.normalize();
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param in
|
|
||||||
* @param v
|
|
||||||
* @return std::istream &operator >>
|
|
||||||
*/
|
|
||||||
friend std::istream& operator>>(std::istream& in, Vec2D& v)
|
|
||||||
{
|
|
||||||
in >> v.x >> v.y;
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @return operator float
|
|
||||||
*/
|
|
||||||
operator float* ()
|
|
||||||
{
|
|
||||||
return (float*)this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
@ -480,4 +276,20 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief for whatever reason a certain company just can't stick to one coordinate system...
|
||||||
|
*
|
||||||
|
* @param v
|
||||||
|
* @return Vec3D
|
||||||
|
*/
|
||||||
|
inline Vec3D fixCoords(const Vec3D& v) { return Vec3D(v.z, v.x, v.y); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @param v
|
||||||
|
* @return Vec3D
|
||||||
|
*/
|
||||||
|
inline Vec3D fixCoordSystem(const Vec3D& v) { return Vec3D(v.x, v.z, -v.y); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,7 +52,6 @@
|
|||||||
#include "dbcfile.h"
|
#include "dbcfile.h"
|
||||||
#include "wmo.h"
|
#include "wmo.h"
|
||||||
#include <ml/mpq.h>
|
#include <ml/mpq.h>
|
||||||
|
|
||||||
#include "vmapexport.h"
|
#include "vmapexport.h"
|
||||||
#include "Auth/md5.h"
|
#include "Auth/md5.h"
|
||||||
|
|
||||||
@ -126,9 +125,6 @@ std::string GetUniformName(std::string& path)
|
|||||||
}
|
}
|
||||||
else { file = tempPath = path; }
|
else { file = tempPath = path; }
|
||||||
|
|
||||||
if (tempPath == "<empty>") //GameObjectDisplayInfo, OnyxiasLair
|
|
||||||
tempPath.assign("world\\wmo\\dungeon\\kl_onyxiaslair");
|
|
||||||
|
|
||||||
if(!tempPath.empty())
|
if(!tempPath.empty())
|
||||||
compute_md5(tempPath.c_str(),digest);
|
compute_md5(tempPath.c_str(),digest);
|
||||||
else
|
else
|
||||||
@ -174,109 +170,6 @@ void ReadLiquidTypeTableDBC()
|
|||||||
printf("Success! (%u LiqTypes loaded)\n", (unsigned int)LiqType_count);
|
printf("Success! (%u LiqTypes loaded)\n", (unsigned int)LiqType_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExtractWmo()
|
|
||||||
{
|
|
||||||
bool success = true;
|
|
||||||
|
|
||||||
for (ArchiveSet::const_iterator ar_itr = gOpenArchives.begin(); ar_itr != gOpenArchives.end() && success; ++ar_itr)
|
|
||||||
{
|
|
||||||
vector<string> filelist;
|
|
||||||
|
|
||||||
(*ar_itr)->GetFileListTo(filelist);
|
|
||||||
for (vector<string>::iterator fname = filelist.begin(); fname != filelist.end() && success; ++fname)
|
|
||||||
{
|
|
||||||
if (fname->find(".wmo") != string::npos) { success = ExtractSingleWmo(*fname);}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{ printf("\nExtract wmo complete (No (fatal) errors)\n"); }
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExtractSingleWmo(std::string& fname)
|
|
||||||
{
|
|
||||||
// Copy files from archive
|
|
||||||
|
|
||||||
char szLocalFile[1024];
|
|
||||||
string plain_name = GetUniformName(fname);
|
|
||||||
|
|
||||||
sprintf(szLocalFile, "%s/%s", szWorkDirWmo, plain_name.c_str());
|
|
||||||
|
|
||||||
if (FileExists(szLocalFile))
|
|
||||||
{ return true; }
|
|
||||||
|
|
||||||
int p = 0;
|
|
||||||
//Select root wmo files
|
|
||||||
const char* rchr = strrchr(plain_name.c_str(), '_');
|
|
||||||
if (rchr != NULL)
|
|
||||||
{
|
|
||||||
char cpy[4];
|
|
||||||
strncpy((char*)cpy, rchr, 4);
|
|
||||||
for (int i = 0; i < 4; ++i)
|
|
||||||
{
|
|
||||||
int m = cpy[i];
|
|
||||||
if (isdigit(m))
|
|
||||||
{ p++; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p == 3)
|
|
||||||
{ return true; }
|
|
||||||
|
|
||||||
bool file_ok = true;
|
|
||||||
std::cout << "Extracting " << fname << std::endl;
|
|
||||||
WMORoot froot(fname);
|
|
||||||
if (!froot.open())
|
|
||||||
{
|
|
||||||
printf("Couldn't open RootWmo!!!\n");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE* output = fopen(szLocalFile, "wb");
|
|
||||||
if (!output)
|
|
||||||
{
|
|
||||||
printf("couldn't open %s for writing!\n", szLocalFile);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
froot.ConvertToVMAPRootWmo(output);
|
|
||||||
int Wmo_nVertices = 0;
|
|
||||||
if (froot.nGroups != 0)
|
|
||||||
{
|
|
||||||
for (uint32 i = 0; i < froot.nGroups; ++i)
|
|
||||||
{
|
|
||||||
char temp[1024];
|
|
||||||
strcpy(temp, fname.c_str());
|
|
||||||
temp[fname.length() - 4] = 0;
|
|
||||||
char groupFileName[1024];
|
|
||||||
sprintf(groupFileName, "%s_%03d.wmo", temp, i);
|
|
||||||
|
|
||||||
string s(groupFileName);
|
|
||||||
|
|
||||||
WMOGroup fgroup(s);
|
|
||||||
if (!fgroup.open())
|
|
||||||
{
|
|
||||||
printf("Could not open all Group file for: %s\n", plain_name.c_str());
|
|
||||||
file_ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Wmo_nVertices += fgroup.ConvertToVMAPGroupWmo(output, &froot, preciseVectorData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(output, 8, SEEK_SET); // store the correct no of vertices
|
|
||||||
fwrite(&Wmo_nVertices, sizeof(int), 1, output);
|
|
||||||
fclose(output);
|
|
||||||
|
|
||||||
// Delete the extracted file in the case of an error
|
|
||||||
if (!file_ok)
|
|
||||||
{ remove(szLocalFile); }
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsMapFiles()
|
void ParsMapFiles()
|
||||||
{
|
{
|
||||||
char fn[512];
|
char fn[512];
|
||||||
@ -538,7 +431,6 @@ int main(int argc, char** argv)
|
|||||||
printf("Map - %s\n", map_ids[x].name);
|
printf("Map - %s\n", map_ids[x].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
delete dbc;
|
delete dbc;
|
||||||
ParsMapFiles();
|
ParsMapFiles();
|
||||||
delete [] map_ids;
|
delete [] map_ids;
|
||||||
|
@ -22,14 +22,13 @@
|
|||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include "vmapexport.h"
|
#include "vmapexport.h"
|
||||||
#include "wdtfile.h"
|
#include "wdtfile.h"
|
||||||
#include "adtfile.h"
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
WDTFile::WDTFile(char* file_name, char* file_name1): WDT(file_name)
|
WDTFile::WDTFile(char* file_name, char* file_name1): WDT(file_name)
|
||||||
{
|
{
|
||||||
filename.append(file_name1, strlen(file_name1));
|
filename.assign(file_name1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WDTFile::init(char* map_id, unsigned int mapID)
|
bool WDTFile::init(char* map_id, unsigned int mapID)
|
||||||
@ -107,7 +106,6 @@ bool WDTFile::init(char* map_id, unsigned int mapID)
|
|||||||
WDT.seek((int)nextpos);
|
WDT.seek((int)nextpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
WDT.close();
|
|
||||||
fclose(dirfile);
|
fclose(dirfile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,10 @@
|
|||||||
#ifndef WDTFILE_H
|
#ifndef WDTFILE_H
|
||||||
#define WDTFILE_H
|
#define WDTFILE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <ml/mpq.h>
|
#include <ml/mpq.h>
|
||||||
#include "wmo.h"
|
#include "wmo.h"
|
||||||
#include <string>
|
#include "adtfile.h"
|
||||||
#include "stdlib.h"
|
|
||||||
|
|
||||||
class ADTFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -60,7 +58,7 @@ class WDTFile
|
|||||||
*/
|
*/
|
||||||
bool init(char* map_id, unsigned int mapID);
|
bool init(char* map_id, unsigned int mapID);
|
||||||
|
|
||||||
string* gWmoInstansName; /**< TODO */
|
std::string* gWmoInstansName; /**< TODO */
|
||||||
int gnWMO, nMaps; /**< TODO */
|
int gnWMO, nMaps; /**< TODO */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +73,7 @@ class WDTFile
|
|||||||
private:
|
private:
|
||||||
MPQFile WDT; /**< TODO */
|
MPQFile WDT; /**< TODO */
|
||||||
bool maps[64][64]; /**< TODO */
|
bool maps[64][64]; /**< TODO */
|
||||||
string filename; /**< TODO */
|
std::string filename; /**< TODO */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,10 +32,10 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
#include <ml/mpq.h>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
extern uint16* LiqType;
|
extern uint16* LiqType;
|
||||||
|
extern bool preciseVectorData;
|
||||||
|
extern ArchiveSet gOpenArchives;
|
||||||
|
|
||||||
WMORoot::WMORoot(std::string& filename) : filename(filename)
|
WMORoot::WMORoot(std::string& filename) : filename(filename)
|
||||||
{
|
{
|
||||||
@ -564,3 +564,109 @@ WMOInstance::WMOInstance(MPQFile& f, std::string& WmoInstName, uint32 mapID, uin
|
|||||||
fwrite(WmoInstName.c_str(), sizeof(char), nlen, pDirfile);
|
fwrite(WmoInstName.c_str(), sizeof(char), nlen, pDirfile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ExtractSingleWmo(std::string& fname)
|
||||||
|
{
|
||||||
|
// Copy files from archive
|
||||||
|
char szLocalFile[1024];
|
||||||
|
string plain_name = GetUniformName(fname);
|
||||||
|
|
||||||
|
sprintf(szLocalFile, "%s/%s", szWorkDirWmo, plain_name.c_str());
|
||||||
|
|
||||||
|
if (FileExists(szLocalFile))
|
||||||
|
{ return true; }
|
||||||
|
|
||||||
|
int p = 0;
|
||||||
|
//Select root wmo files
|
||||||
|
const char* rchr = strrchr(plain_name.c_str(), '_');
|
||||||
|
if (rchr != NULL)
|
||||||
|
{
|
||||||
|
char cpy[4];
|
||||||
|
strncpy((char*)cpy, rchr, 4);
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
int m = cpy[i];
|
||||||
|
if (isdigit(m))
|
||||||
|
{ p++; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p == 3)
|
||||||
|
{ return true; }
|
||||||
|
|
||||||
|
bool file_ok = true;
|
||||||
|
printf("Extracting %s\n", fname.c_str());
|
||||||
|
|
||||||
|
WMORoot froot(fname);
|
||||||
|
if (!froot.open())
|
||||||
|
{
|
||||||
|
printf("Couldn't open RootWmo!!!\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* output = fopen(szLocalFile, "wb");
|
||||||
|
if (!output)
|
||||||
|
{
|
||||||
|
printf("Couldn't open %s for writing!\n", szLocalFile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
froot.ConvertToVMAPRootWmo(output);
|
||||||
|
int Wmo_nVertices = 0;
|
||||||
|
if (froot.nGroups != 0)
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i < froot.nGroups; ++i)
|
||||||
|
{
|
||||||
|
char temp[1024];
|
||||||
|
strcpy(temp, fname.c_str());
|
||||||
|
temp[fname.length() - 4] = 0;
|
||||||
|
char groupFileName[1024];
|
||||||
|
sprintf(groupFileName, "%s_%03d.wmo", temp, i);
|
||||||
|
|
||||||
|
string s(groupFileName);
|
||||||
|
|
||||||
|
WMOGroup fgroup(s);
|
||||||
|
if (!fgroup.open())
|
||||||
|
{
|
||||||
|
printf("Could not open all Group file for: %s\n", plain_name.c_str());
|
||||||
|
file_ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wmo_nVertices += fgroup.ConvertToVMAPGroupWmo(output, &froot, preciseVectorData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek(output, 8, SEEK_SET); // store the correct no of vertices
|
||||||
|
fwrite(&Wmo_nVertices, sizeof(int), 1, output);
|
||||||
|
fclose(output);
|
||||||
|
|
||||||
|
// Delete the extracted file in the case of an error
|
||||||
|
if (!file_ok)
|
||||||
|
{ remove(szLocalFile); }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ExtractWmo()
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
|
for (ArchiveSet::const_iterator ar_itr = gOpenArchives.begin(); ar_itr != gOpenArchives.end() && success; ++ar_itr)
|
||||||
|
{
|
||||||
|
vector<std::string> filelist;
|
||||||
|
|
||||||
|
(*ar_itr)->GetFileListTo(filelist);
|
||||||
|
for (vector<std::string>::iterator fname = filelist.begin(); fname != filelist.end() && success; ++fname)
|
||||||
|
{
|
||||||
|
if (fname->find(".wmo") != string::npos)
|
||||||
|
{
|
||||||
|
ExtractSingleWmo(*fname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{ printf("\nExtract wmo complete (No (fatal) errors)\n"); }
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "vec3d.h"
|
#include "vec3d.h"
|
||||||
|
#include <ml/mpq.h>
|
||||||
#include <ml/loadlib.h>
|
#include <ml/loadlib.h>
|
||||||
|
|
||||||
// MOPY flags
|
// MOPY flags
|
||||||
@ -42,17 +43,6 @@
|
|||||||
#define WMO_MATERIAL_COLLIDE_HIT 0x20
|
#define WMO_MATERIAL_COLLIDE_HIT 0x20
|
||||||
#define WMO_MATERIAL_WALL_SURFACE 0x40
|
#define WMO_MATERIAL_WALL_SURFACE 0x40
|
||||||
|
|
||||||
class WMOInstance;
|
|
||||||
class MPQFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief for whatever reason a certain company just can't stick to one coordinate system...
|
|
||||||
*
|
|
||||||
* @param v
|
|
||||||
* @return Vec3D
|
|
||||||
*/
|
|
||||||
static inline Vec3D fixCoords(const Vec3D& v) { return Vec3D(v.z, v.x, v.y); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
@ -226,5 +216,12 @@ class WMOInstance
|
|||||||
*/
|
*/
|
||||||
bool ExtractSingleWmo(std::string& fname);
|
bool ExtractSingleWmo(std::string& fname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
bool ExtractWmo();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user