diff --git a/contrib/vmap_extract_assembler_bin/vmapExtractor3.exe b/contrib/vmap_extract_assembler_bin/vmapExtractor3.exe
new file mode 100644
index 000000000..db9552732
Binary files /dev/null and b/contrib/vmap_extract_assembler_bin/vmapExtractor3.exe differ
diff --git a/contrib/vmap_extractor_v2/.gitignore b/contrib/vmap_extractor_v2/.gitignore
index 69d56e264..6128066ce 100644
--- a/contrib/vmap_extractor_v2/.gitignore
+++ b/contrib/vmap_extractor_v2/.gitignore
@@ -10,7 +10,11 @@
# MaNGOS generated files at Windows build
#
-*.ncb
-*.suo
-*.user
-bin
\ No newline at end of file
+bin
+
+# CMake files
+
+CMakeFiles
+CMakeCache.txt
+cmake_install.cmake
+
diff --git a/contrib/vmap_extractor_v2/CMakeLists.txt b/contrib/vmap_extractor_v2/CMakeLists.txt
new file mode 100644
index 000000000..8e8f6e362
--- /dev/null
+++ b/contrib/vmap_extractor_v2/CMakeLists.txt
@@ -0,0 +1,25 @@
+# Copyright (C) 2005-2009 MaNGOS project
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+cmake_minimum_required (VERSION 2.6)
+project (MANGOS_VMAP_EXTRACT_IO)
+
+
+# uncomment next line to disable debug mode
+ADD_DEFINITIONS("-DIOMAP_DEBUG")
+# build setup currently only supports libmpq 0.4.x
+ADD_DEFINITIONS("-DUSE_LIBMPQ04")
+ADD_DEFINITIONS("-Wall")
+ADD_DEFINITIONS("-ggdb")
+ADD_DEFINITIONS("-O3")
+
+include_directories(../../dep/libmpq)
+
+add_subdirectory(vmapextract)
diff --git a/contrib/vmap_extractor_v2/README b/contrib/vmap_extractor_v2/README
new file mode 100644
index 000000000..696657d05
--- /dev/null
+++ b/contrib/vmap_extractor_v2/README
@@ -0,0 +1,42 @@
+Linux:
+
+1. Building
+
+ Because vmap_extractor depends on libmpq for reading mpq files, you will have
+ to build libmpq prior to vmap_extractor. Therefore cd to dep/libmpq and execute:
+
+ $ ./autogen.sh
+ $ ./configure
+ $ make
+
+ After that, cd to contrib/vmap_extractor_v2/ and execute:
+
+ $ cmake .
+ $ make
+
+ You should now have an executable file at vmapextract/vmapextractor
+
+2. Extracting
+
+ Use the created executable to extract model information. Change the data path if
+ needed.
+
+ $ vmapextract/vmapextractor -d /mnt/windows/games/wow/Data/
+
+ Resulting files will be in ./Buildings
+
+###########################
+Windows:
+
+1. Building
+
+ Just buid the solution in contrib\vmap_extractor_v2\win
+ Resulting binaries will be in contrib\vmap_extractor_v2\bin\$(PlatformName)_$(ConfigurationName)
+
+2. Extracting
+
+ Use the created executable (from command prompt) to extract model information.
+ It should find the data path for your client installation through the windows registry,
+ but the data path can be specified with the -d option.
+
+ Resulting files will be in .\Buildings
diff --git a/contrib/vmap_extractor_v2/vmapExtractor_VC80.sln b/contrib/vmap_extractor_v2/vmapExtractor_VC80.sln
deleted file mode 100644
index cc24730b1..000000000
--- a/contrib/vmap_extractor_v2/vmapExtractor_VC80.sln
+++ /dev/null
@@ -1,19 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmapExtractor", "vmapExtractor_VC80.vcproj", "{87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug Ansi Static|Win32 = Debug Ansi Static|Win32
- Release Ansi Static|Win32 = Release Ansi Static|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Debug Ansi Static|Win32.ActiveCfg = Debug Ansi Static|Win32
- {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Debug Ansi Static|Win32.Build.0 = Debug Ansi Static|Win32
- {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Release Ansi Static|Win32.ActiveCfg = Release Ansi Static|Win32
- {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Release Ansi Static|Win32.Build.0 = Release Ansi Static|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/contrib/vmap_extractor_v2/vmapExtractor_VC80.vcproj b/contrib/vmap_extractor_v2/vmapExtractor_VC80.vcproj
deleted file mode 100644
index 5d8cdea90..000000000
--- a/contrib/vmap_extractor_v2/vmapExtractor_VC80.vcproj
+++ /dev/null
@@ -1,1000 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/contrib/vmap_extractor_v2/vmapExtractor_VC90.sln b/contrib/vmap_extractor_v2/vmapExtractor_VC90.sln
deleted file mode 100644
index 82d3e1509..000000000
--- a/contrib/vmap_extractor_v2/vmapExtractor_VC90.sln
+++ /dev/null
@@ -1,19 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmapExtractor", "vmapExtractor_VC90.vcproj", "{87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug Ansi Static|Win32 = Debug Ansi Static|Win32
- Release Ansi Static|Win32 = Release Ansi Static|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Debug Ansi Static|Win32.ActiveCfg = Debug Ansi Static|Win32
- {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Debug Ansi Static|Win32.Build.0 = Debug Ansi Static|Win32
- {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Release Ansi Static|Win32.ActiveCfg = Release Ansi Static|Win32
- {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Release Ansi Static|Win32.Build.0 = Release Ansi Static|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/contrib/vmap_extractor_v2/vmapExtractor_VC90.vcproj b/contrib/vmap_extractor_v2/vmapExtractor_VC90.vcproj
deleted file mode 100644
index ed75735c4..000000000
--- a/contrib/vmap_extractor_v2/vmapExtractor_VC90.vcproj
+++ /dev/null
@@ -1,999 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/.gitignore b/contrib/vmap_extractor_v2/vmapextract/.gitignore
new file mode 100644
index 000000000..79b30acc5
--- /dev/null
+++ b/contrib/vmap_extractor_v2/vmapextract/.gitignore
@@ -0,0 +1,18 @@
+#
+# NOTE! Don't add files that are generated in specific
+# subdirectories here. Add them in the ".gitignore" file
+# in that subdirectory instead.
+#
+# NOTE! Please use 'git-ls-files -i --exclude-standard'
+# command after changing this file, to see if there are
+# any tracked files which get ignored after the change.
+#
+# MaNGOS generated files at Windows build
+#
+
+# CMake files
+
+CMakeFiles
+CMakeCache.txt
+cmake_install.cmake
+
diff --git a/contrib/vmap_extractor_v2/vmapextract/CMakeLists.txt b/contrib/vmap_extractor_v2/vmapextract/CMakeLists.txt
new file mode 100644
index 000000000..473bd5085
--- /dev/null
+++ b/contrib/vmap_extractor_v2/vmapextract/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2005-2009 MaNGOS project
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+cmake_minimum_required (VERSION 2.6)
+project (MANGOS_IOMAP_EXTRACTOR)
+
+LINK_DIRECTORIES( ${LINK_DIRECTORIES} ../../../dep/libmpq/libmpq/.libs/ )
+add_executable(vmapextractor adtfile.cpp dbcfile.cpp model.cpp mpq_libmpq.cpp vmapexport.cpp wdtfile.cpp wmo.cpp)
+target_link_libraries(vmapextractor libmpq.a bz2 z)
diff --git a/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp b/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp
index 49717c047..314255d3a 100644
--- a/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp
@@ -1,6 +1,12 @@
+#include "vmapexport.h"
#include "adtfile.h"
#include
+#include
+
+#ifdef WIN32
+#define snprintf _snprintf
+#endif
char * GetPlainName(char * FileName)
{
@@ -23,6 +29,9 @@ void fixnamen(char *name, size_t len)
name[i] &= ~0x20;
}
}
+ //extension in lowercase
+ for(size_t i=len-3; i= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
// nothing do
- char szLocalFile[MAX_PATH];
- sprintf(szLocalFile, ".\\buildings\\%s", s);
+ char szLocalFile[1024];
+ snprintf(szLocalFile, 1024, "%s/%s", szWorkDirWmo, s);
FILE * output = fopen(szLocalFile,"rb");
if(!output)
{
- Model * m2 = new Model(path);
- if(m2->open())
- m2->ConvertToVMAPModel(szLocalFile);
- delete m2;
+ Model m2(path);
+ if(m2.open())
+ m2.ConvertToVMAPModel(szLocalFile);
}
else
fclose(output);
@@ -161,9 +169,9 @@ bool ADTFile::init(char *map_id)
nMDX = (int)size / 36;
for (int i=0; i
DBCFile::DBCFile(const std::string &filename) : filename(filename)
{
diff --git a/contrib/vmap_extractor_v2/vmapextract/dbcfile.h b/contrib/vmap_extractor_v2/vmapextract/dbcfile.h
index 002e7eeeb..7d23f2d1e 100644
--- a/contrib/vmap_extractor_v2/vmapextract/dbcfile.h
+++ b/contrib/vmap_extractor_v2/vmapextract/dbcfile.h
@@ -1,10 +1,8 @@
#ifndef DBCFILE_H
#define DBCFILE_H
-#define __STORMLIB_SELF__
#include
#include
-#include "Stormlib.h"
class DBCFile
{
@@ -80,8 +78,8 @@ public:
}
private:
Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {}
- unsigned char *offset;
DBCFile &file;
+ unsigned char *offset;
friend class DBCFile;
friend class Iterator;
diff --git a/contrib/vmap_extractor_v2/vmapextract/loadlib/loadlib.h b/contrib/vmap_extractor_v2/vmapextract/loadlib/loadlib.h
new file mode 100644
index 000000000..537317534
--- /dev/null
+++ b/contrib/vmap_extractor_v2/vmapextract/loadlib/loadlib.h
@@ -0,0 +1,59 @@
+#ifndef LOAD_LIB_H
+#define LOAD_LIB_H
+
+#ifdef WIN32
+typedef __int64 int64;
+typedef __int32 int32;
+typedef __int16 int16;
+typedef __int8 int8;
+typedef unsigned __int64 uint64;
+typedef unsigned __int32 uint32;
+typedef unsigned __int16 uint16;
+typedef unsigned __int8 uint8;
+#else
+#include
+#ifndef uint64_t
+#ifdef __linux__
+#include
+#endif
+#endif
+typedef int64_t int64;
+typedef int32_t int32;
+typedef int16_t int16;
+typedef int8_t int8;
+typedef uint64_t uint64;
+typedef uint32_t uint32;
+typedef uint16_t uint16;
+typedef uint8_t uint8;
+#endif
+
+#define FILE_FORMAT_VERSION 18
+
+//
+// File version chunk
+//
+struct file_MVER
+{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+ uint32 ver;
+};
+
+class FileLoader{
+ uint8 *data;
+ uint32 data_size;
+public:
+ virtual bool prepareLoadedData();
+ uint8 *GetData() {return data;}
+ uint32 GetDataSize() {return data_size;}
+
+ file_MVER *version;
+ FileLoader();
+ ~FileLoader();
+ bool loadFile(char *filename, bool log = true);
+ virtual void free();
+};
+#endif
diff --git a/contrib/vmap_extractor_v2/vmapextract/model.cpp b/contrib/vmap_extractor_v2/vmapextract/model.cpp
index 9605e3320..a2493f7e5 100644
--- a/contrib/vmap_extractor_v2/vmapextract/model.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/model.cpp
@@ -1,6 +1,10 @@
+#include "vmapexport.h"
#include "model.h"
+#include "wmo.h"
+#include "mpq_libmpq04.h"
#include
#include
+#include
Model::Model(std::string &filename) : filename(filename)
{
@@ -35,8 +39,8 @@ bool Model::open()
indices = new uint16[header.nBoundingTriangles];
f.read(indices,header.nBoundingTriangles*2);
f.close();
- }
- else
+ }
+ else
{
//printf("not included %s\n", filename.c_str());
f.close();
@@ -47,20 +51,22 @@ bool Model::open()
bool Model::ConvertToVMAPModel(char * outfilename)
{
- int N[] = {0x00000000};
+ int N[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
FILE * output=fopen(outfilename,"wb");
if(!output)
{
printf("Can't create the output file '%s'\n",outfilename);
return false;
}
- fwrite("VMAP002",8,1,output);
+ fwrite("VMAP003",8,1,output);
uint32 nVertices = 0;
nVertices = header.nBoundingVertices;
fwrite(&nVertices, sizeof(int), 1, output);
uint32 nofgroups = 1;
fwrite(&nofgroups,sizeof(uint32), 1, output);
- fwrite(N,4,1,output);
+ fwrite(N,4*3,1,output);// rootwmoid, flags, groupid
+ fwrite(N,sizeof(float),3*2,output);//bbox, only needed for WMO currently
+ fwrite(N,4,1,output);// liquidflags
fwrite("GRP ",4,1,output);
uint32 branches = 1;
int wsize;
@@ -115,12 +121,12 @@ Vec3D fixCoordSystem2(Vec3D v)
return Vec3D(v.x, v.z, v.y);
}
-ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*MapName, FILE *pDirfile)
+ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
{
float ff[3];
- f.read(&d1, 4);
+ f.read(&id, 4);
f.read(ff,12);
- pos = Vec3D(ff[0],ff[1],ff[2]);
+ pos = fixCoords(Vec3D(ff[0],ff[1],ff[2]));
f.read(ff,12);
rot = Vec3D(ff[0],ff[1],ff[2]);
f.read(&scale,4);
@@ -128,12 +134,15 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
sc = scale / 1024.0f;
char tempname[512];
- sprintf(tempname, ".\\buildings\\%s", ModelInstName);
+ sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName);
FILE *input;
input = fopen(tempname, "r+b");
if(!input)
+ {
+ //printf("ModelInstance::ModelInstance couldn't open %s\n", tempname);
return;
+ }
fseek(input, 8, SEEK_SET); // get the correct no of vertices
int nVertices;
@@ -143,22 +152,36 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
if(nVertices == 0)
return;
- if(pDirfile)
- {
- int realx1 = (int) ((float) pos.x / 533.333333f);
- int realy1 = (int) ((float) pos.z / 533.333333f);
- int realx2 = (int) ((float) pos.x / 533.333333f);
- int realy2 = (int) ((float) pos.z / 533.333333f);
+ uint16 adtId = 0;// not used for models
+ uint32 flags = MOD_M2;
+ if(tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
+ //write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, name
+ fwrite(&mapID, sizeof(uint32), 1, pDirfile);
+ fwrite(&tileX, sizeof(uint32), 1, pDirfile);
+ fwrite(&tileY, sizeof(uint32), 1, pDirfile);
+ fwrite(&flags, sizeof(uint32), 1, pDirfile);
+ fwrite(&adtId, sizeof(uint16), 1, pDirfile);
+ fwrite(&id, sizeof(uint32), 1, pDirfile);
+ fwrite(&pos, sizeof(float), 3, pDirfile);
+ fwrite(&rot, sizeof(float), 3, pDirfile);
+ fwrite(&sc, sizeof(float), 1, pDirfile);
+ uint32 nlen=strlen(ModelInstName);
+ fwrite(&nlen, sizeof(uint32), 1, pDirfile);
+ fwrite(ModelInstName, sizeof(char), nlen, pDirfile);
- fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n",
- MapName,
- ModelInstName,
- (float) pos.x, (float) pos.y, (float) pos.z,
- (float) rot.x, (float) rot.y, (float) rot.z,
- sc,
- nVertices,
- realx1, realy1,
- realx2, realy2
- );
- }
+ /* int realx1 = (int) ((float) pos.x / 533.333333f);
+ int realy1 = (int) ((float) pos.z / 533.333333f);
+ int realx2 = (int) ((float) pos.x / 533.333333f);
+ int realy2 = (int) ((float) pos.z / 533.333333f);
+
+ fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n",
+ MapName,
+ ModelInstName,
+ (float) pos.x, (float) pos.y, (float) pos.z,
+ (float) rot.x, (float) rot.y, (float) rot.z,
+ sc,
+ nVertices,
+ realx1, realy1,
+ realx2, realy2
+ ); */
}
diff --git a/contrib/vmap_extractor_v2/vmapextract/model.h b/contrib/vmap_extractor_v2/vmapextract/model.h
index 2bcb20b11..d1be46f3c 100644
--- a/contrib/vmap_extractor_v2/vmapextract/model.h
+++ b/contrib/vmap_extractor_v2/vmapextract/model.h
@@ -1,13 +1,15 @@
#ifndef MODEL_H
#define MODEL_H
+#include "loadlib/loadlib.h"
#include "vec3d.h"
-#include "mpq.h"
+//#include "mpq.h"
#include "modelheaders.h"
#include
class Model;
class WMOInstance;
+class MPQFile;
Vec3D fixCoordSystem(Vec3D v);
@@ -38,13 +40,13 @@ class ModelInstance
public:
Model *model;
- int id;
+ uint32 id;
Vec3D pos, rot;
unsigned int d1, scale;
float w,sc;
ModelInstance() {}
- ModelInstance(MPQFile &f,const char* ModelInstName,const char*MapName, FILE *pDirfile);
+ ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile);
};
diff --git a/contrib/vmap_extractor_v2/vmapextract/modelheaders.h b/contrib/vmap_extractor_v2/vmapextract/modelheaders.h
index 445ab3843..776a981eb 100644
--- a/contrib/vmap_extractor_v2/vmapextract/modelheaders.h
+++ b/contrib/vmap_extractor_v2/vmapextract/modelheaders.h
@@ -1,12 +1,12 @@
#ifndef MODELHEADERS_H
#define MODELHEADERS_H
-typedef unsigned char uint8;
+/* typedef unsigned char uint8;
typedef char int8;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned int uint32;
-typedef int int32;
+typedef int int32; */
#pragma pack(push,1)
diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq.cpp b/contrib/vmap_extractor_v2/vmapextract/mpq.cpp
deleted file mode 100644
index 0d72f06a7..000000000
--- a/contrib/vmap_extractor_v2/vmapextract/mpq.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-#include "mpq.h"
-//#include
-#include "Stormlib.h"
-#define __STORMLIB_SELF__
-
-MPQArchiveSet gOpenArchives;
-
-//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-MPQArchive::MPQArchive(const char* filename)
-{
- BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ);
- if (succ)
- printf("Opening %s\n", filename);
- else
- printf("Error!!!Not open archive %s\n", filename);
-}
-
-void MPQArchive::close()
-{
- SFileCloseArchive(hMPQ);
-}
-
-bool MPQArchiveSet::Open( std::vector const& archiveNames )
-{
- for (size_t i=0; i < archiveNames.size(); ++i)
- {
- MPQArchive mpqarch(archiveNames[i].c_str());
- if(mpqarch.isOpen())
- archives.push_back(mpqarch);
- }
-
- return !archives.empty();
-}
-
-MPQArchiveSet::~MPQArchiveSet()
-{
- // close archives
- for (ArchiveSet::iterator ar_itr = archives.begin(); ar_itr != archives.end(); ++ar_itr)
- ar_itr->close();
-}
-
-MPQFile::MPQFile(const char* filename):
- eof(false),
- buffer(0),
- pointer(0),
- size(0)
-{
- for(ArchiveSet::const_iterator i=gOpenArchives.archives.begin(); i!=gOpenArchives.archives.end();++i)
- {
- HANDLE hFile = "";
- hMPQ = i->hMPQ;
- BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
- if (succ)
- {
- DWORD s = SFileGetFileSize(hFile, 0);
- if (!s)
- {
- eof = true;
- buffer = 0;
- return;
- }
- size = (size_t)s;
- buffer = new char[s];
- SFileReadFile(hFile, buffer, s, 0, 0);
- SFileCloseFile(hFile);
-
- eof = false;
- return;
- }
- }
-
- eof = true;
- buffer = 0;
-}
-
-MPQFile::~MPQFile()
-{
- close();
-}
-
-size_t MPQFile::read(void* dest, size_t bytes)
-{
- if (eof)
- return 0;
-
- size_t rpos = pointer + bytes;
- if (rpos > size)
- {
- bytes = size - pointer;
- eof = true;
- }
-
- memcpy(dest, &(buffer[pointer]), bytes);
-
- pointer = rpos;
-
- return bytes;
-}
-
-bool MPQFile::isEof()
-{
- return eof;
-}
-
-void MPQFile::seek(int offset)
-{
- pointer = offset;
- eof = (pointer >= size);
-}
-
-void MPQFile::seekRelative(int offset)
-{
- pointer += offset;
- eof = (pointer >= size);
-}
-
-void MPQFile::close()
-{
- if (buffer)
- delete[] buffer;
- buffer = 0;
- eof = true;
-}
-
-size_t MPQFile::getSize()
-{
- return size;
-}
-
-size_t MPQFile::getPos()
-{
- return pointer;
-}
-
-char* MPQFile::getBuffer()
-{
- return buffer;
-}
-
-char* MPQFile::getPointer()
-{
- return buffer + pointer;
-}
diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq.h b/contrib/vmap_extractor_v2/vmapextract/mpq.h
deleted file mode 100644
index 0d1d14851..000000000
--- a/contrib/vmap_extractor_v2/vmapextract/mpq.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#define _CRT_SECURE_NO_DEPRECATE
-
-#ifndef MPQ_H
-#define MPQ_H
-
-#define __STORMLIB_SELF__
-
-#include
-#include
-#include
-#include
-#include "Stormlib.h"
-
-using namespace std;
-
-typedef unsigned int uint32;
-
-class MPQArchive
-{
- public:
- HANDLE hMPQ;
- MPQArchive(const char* filename);
- void close();
- bool isOpen() const { return hMPQ != 0; }
-};
-
-typedef std::vector ArchiveSet;
-
-class MPQArchiveSet
-{
- public:
- MPQArchiveSet() {}
- ~MPQArchiveSet();
-
- bool Open(std::vector const& archiveNames);
-
- ArchiveSet archives;
-};
-
-extern MPQArchiveSet gOpenArchives;
-
-class MPQFile
-{
- HANDLE hFile;
- HANDLE hMPQ;
- bool eof;
- char *buffer;
- size_t pointer,
- size;
-
- // 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();
-};
-
-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;
-}
-
-#endif
diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq_libmpq.cpp b/contrib/vmap_extractor_v2/vmapextract/mpq_libmpq.cpp
new file mode 100644
index 000000000..528b9679a
--- /dev/null
+++ b/contrib/vmap_extractor_v2/vmapextract/mpq_libmpq.cpp
@@ -0,0 +1,111 @@
+#include "mpq_libmpq04.h"
+#include
+#include
+
+ArchiveSet gOpenArchives;
+
+MPQArchive::MPQArchive(const char* filename)
+{
+ int result = libmpq__archive_open(&mpq_a, filename, -1);
+ printf("Opening %s\n", filename);
+ if(result) {
+ switch(result) {
+ case LIBMPQ_ERROR_OPEN :
+ printf("Error opening archive '%s': Does file really exist?\n", filename);
+ break;
+ case LIBMPQ_ERROR_FORMAT : /* bad file format */
+ printf("Error opening archive '%s': Bad file format\n", filename);
+ break;
+ case LIBMPQ_ERROR_SEEK : /* seeking in file failed */
+ printf("Error opening archive '%s': Seeking in file failed\n", filename);
+ break;
+ case LIBMPQ_ERROR_READ : /* Read error in archive */
+ printf("Error opening archive '%s': Read error in archive\n", filename);
+ break;
+ case LIBMPQ_ERROR_MALLOC : /* maybe not enough memory? :) */
+ printf("Error opening archive '%s': Maybe not enough memory\n", filename);
+ break;
+ default:
+ printf("Error opening archive '%s': Unknown error\n", filename);
+ break;
+ }
+ return;
+ }
+ gOpenArchives.push_front(this);
+}
+
+void MPQArchive::close()
+{
+ //gOpenArchives.erase(erase(&mpq_a);
+ libmpq__archive_close(mpq_a);
+}
+
+MPQFile::MPQFile(const char* filename):
+ eof(false),
+ buffer(0),
+ pointer(0),
+ size(0)
+{
+ for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i)
+ {
+ mpq_archive *mpq_a = (*i)->mpq_a;
+
+ uint32 filenum;
+ if(libmpq__file_number(mpq_a, filename, &filenum)) continue;
+ libmpq__off_t transferred;
+ libmpq__file_unpacked_size(mpq_a, filenum, &size);
+
+ // HACK: in patch.mpq some files don't want to open and give 1 for filesize
+ if (size<=1) {
+ // printf("info: file %s has size %d; considered dummy file.\n", filename, size);
+ eof = true;
+ buffer = 0;
+ return;
+ }
+ buffer = new char[size];
+
+ //libmpq_file_getdata
+ libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
+ /*libmpq_file_getdata(&mpq_a, hash, fileno, (unsigned char*)buffer);*/
+ return;
+
+ }
+ eof = true;
+ buffer = 0;
+}
+
+size_t MPQFile::read(void* dest, size_t bytes)
+{
+ if (eof) return 0;
+
+ size_t rpos = pointer + bytes;
+ if (rpos > size) {
+ bytes = size - pointer;
+ eof = true;
+ }
+
+ memcpy(dest, &(buffer[pointer]), bytes);
+
+ pointer = rpos;
+
+ return bytes;
+}
+
+void MPQFile::seek(int offset)
+{
+ pointer = offset;
+ eof = (pointer >= size);
+}
+
+void MPQFile::seekRelative(int offset)
+{
+ pointer += offset;
+ eof = (pointer >= size);
+}
+
+void MPQFile::close()
+{
+ if (buffer) delete[] buffer;
+ buffer = 0;
+ eof = true;
+}
diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq_libmpq04.h b/contrib/vmap_extractor_v2/vmapextract/mpq_libmpq04.h
new file mode 100644
index 000000000..ccbfe37cb
--- /dev/null
+++ b/contrib/vmap_extractor_v2/vmapextract/mpq_libmpq04.h
@@ -0,0 +1,91 @@
+#define _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_WARNINGS
+
+#ifndef MPQ_H
+#define MPQ_H
+
+#include "loadlib/loadlib.h"
+#include "libmpq/mpq.h"
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+class MPQArchive
+{
+
+public:
+ mpq_archive_s *mpq_a;
+
+ MPQArchive(const char* filename);
+ void close();
+
+ void GetFileListTo(vector& filelist) {
+ uint32 filenum;
+ if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
+ libmpq__off_t size, transferred;
+ libmpq__file_unpacked_size(mpq_a, filenum, &size);
+
+ char *buffer = new char[size];
+
+ libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
+
+ char seps[] = "\n";
+ char *token;
+
+ token = strtok( buffer, seps );
+ uint32 counter = 0;
+ while ((token != NULL) && (counter < size)) {
+ //cout << token << endl;
+ token[strlen(token) - 1] = 0;
+ string s = token;
+ filelist.push_back(s);
+ counter += strlen(token) + 2;
+ token = strtok(NULL, seps);
+ }
+
+ delete[] buffer;
+ }
+};
+typedef std::deque ArchiveSet;
+
+class MPQFile
+{
+ //MPQHANDLE handle;
+ bool eof;
+ char *buffer;
+ libmpq__off_t pointer,size;
+
+ // disable copying
+ MPQFile(const MPQFile &f) {}
+ void operator=(const MPQFile &f) {}
+
+public:
+ MPQFile(const char* filename); // filenames are not case sensitive
+ ~MPQFile() { close(); }
+ size_t read(void* dest, size_t bytes);
+ size_t getSize() { return size; }
+ size_t getPos() { return pointer; }
+ char* getBuffer() { return buffer; }
+ char* getPointer() { return buffer + pointer; }
+ bool isEof() { return eof; }
+ 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;
+}
+
+#endif
diff --git a/contrib/vmap_extractor_v2/vmapextract/vec3d.h b/contrib/vmap_extractor_v2/vmapextract/vec3d.h
index 405135521..d2569bc13 100644
--- a/contrib/vmap_extractor_v2/vmapextract/vec3d.h
+++ b/contrib/vmap_extractor_v2/vmapextract/vec3d.h
@@ -106,6 +106,12 @@ public:
in >> v.x >> v.y >> v.z;
return in;
}
+
+ friend std::ostream& operator<<(std::ostream& out, const Vec3D& v)
+ {
+ out << v.x << " " << v.y << " " << v.z;
+ return out;
+ }
operator float*()
{
diff --git a/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp b/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp
index a96a404f6..a11d05e37 100644
--- a/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp
@@ -1,38 +1,33 @@
-/*****************************************************************************/
-/* StormLibTest.cpp Copyright (c) Ladislav Zezula 2003 */
-/*---------------------------------------------------------------------------*/
-/* This module uses very brutal test methods for StormLib. It extracts all */
-/* files from the archive with Storm.dll and with stormlib and compares them,*/
-/* then tries to build a copy of the entire archive, then removes a few files*/
-/* from the archive and adds them back, then compares the two archives, ... */
-/*---------------------------------------------------------------------------*/
-/* Date Ver Who Comment */
-/* -------- ---- --- ------- */
-/* 25.03.03 1.00 Lad The first version of StormLibTest.cpp */
-/*****************************************************************************/
-
#define _CRT_SECURE_NO_DEPRECATE
-#include
-#include
-#include
-#include
-#include
+#include
+#include
#include
#include
+#include
+#ifdef WIN32
+ #include
+ #include
+ #include
+ #define mkdir _mkdir
+#else
+ #include
+#endif
-#define __STORMLIB_SELF__ // Don't use StormLib.lib
-#include "StormLib.h"
+#undef min
+#undef max
-#pragma warning(disable : 4505)
-#pragma comment(lib, "Winmm.lib")
+//#pragma warning(disable : 4505)
+//#pragma comment(lib, "Winmm.lib")
+
+#include