Merge branch 'master' into 4.x

Conflicts:
	sql/base/auth_database.sql
	src/server/authserver/Server/AuthSocket.cpp
	src/server/game/AI/CoreAI/CombatAI.cpp
	src/server/game/AuctionHouse/AuctionHouseMgr.cpp
	src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
	src/server/game/DataStores/DBCStructure.h
	src/server/game/DataStores/DBCfmt.h
	src/server/game/Entities/Unit/Unit.cpp
	src/server/game/Entities/Vehicle/Vehicle.cpp
	src/server/game/Globals/ObjectMgr.cpp
	src/server/game/Globals/ObjectMgr.h
	src/server/game/Handlers/AuctionHouseHandler.cpp
	src/server/game/Miscellaneous/SharedDefines.h
	src/server/game/Movement/MotionMaster.cpp
	src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
	src/server/game/Quests/QuestDef.cpp
	src/server/game/Server/Protocol/Opcodes.cpp
	src/server/game/Server/WorldSocket.cpp
	src/server/game/Spells/Spell.cpp
	src/server/game/Spells/SpellEffects.cpp
	src/server/game/Spells/SpellInfo.cpp
	src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp
	src/server/scripts/Spells/spell_quest.cpp
	src/server/shared/Logging/Log.h
	src/server/worldserver/worldserver.conf.dist
	src/tools/vmap3_extractor/model.h
	src/tools/vmap4_extractor/CMakeLists.txt
	src/tools/vmap4_extractor/dbcfile.cpp
	src/tools/vmap4_extractor/dbcfile.h
	src/tools/vmap4_extractor/loadlib/loadlib.h
This commit is contained in:
Spp
2012-02-23 13:06:35 +01:00
530 changed files with 42084 additions and 9652 deletions
+2 -2
View File
@@ -9,5 +9,5 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
add_subdirectory(map_extractor)
add_subdirectory(vmap3_assembler)
add_subdirectory(vmap3_extractor)
add_subdirectory(vmap4_assembler)
add_subdirectory(vmap4_extractor)
-52
View File
@@ -1,52 +0,0 @@
#ifndef MODEL_H
#define MODEL_H
#include "vec3d.h"
//#include "mpq.h"
#include "modelheaders.h"
#include <vector>
class Model;
class WMOInstance;
class MPQFile;
Vec3D fixCoordSystem(Vec3D v);
class Model
{
public:
ModelHeader header;
uint32 offsBB_vertices, offsBB_indices;
Vec3D *BB_vertices, *vertices;
uint16 *BB_indices, *indices;
size_t nIndices;
bool open();
bool ConvertToVMAPModel(char * outfilename);
bool ok;
Model(std::string &filename);
~Model();
private:
std::string filename;
char outfilename;
};
class ModelInstance
{
public:
Model *model;
uint32 id;
Vec3D pos, rot;
unsigned int d1, scale;
float w,sc;
ModelInstance() {}
ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile);
};
#endif
-13
View File
@@ -1,13 +0,0 @@
#ifndef VMAPEXPORT_H
#define VMAPEXPORT_H
enum ModelFlags
{
MOD_M2 = 1,
MOD_WORLDSPAWN = 1<<1,
MOD_HAS_BOUND = 1<<2
};
extern const char * szWorkDirWmo;
#endif
@@ -13,6 +13,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
${CMAKE_SOURCE_DIR}/src/server/shared
${CMAKE_SOURCE_DIR}/src/server/shared/Debugging
${CMAKE_SOURCE_DIR}/src/server/collision
${CMAKE_SOURCE_DIR}/src/server/collision/Maps
${CMAKE_SOURCE_DIR}/src/server/collision/Models
${ACE_INCLUDE_DIR}
@@ -20,21 +21,21 @@ include_directories(
)
add_definitions(-DNO_CORE_FUNCS)
add_executable(vmap3assembler VMapAssembler.cpp)
add_dependencies(vmap3assembler mpq)
add_executable(vmap4assembler VMapAssembler.cpp)
add_dependencies(vmap4assembler mpq)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set_target_properties(vmap3assembler PROPERTIES LINK_FLAGS "-framework Carbon")
set_target_properties(vmap4assembler PROPERTIES LINK_FLAGS "-framework Carbon")
endif()
target_link_libraries(vmap3assembler
target_link_libraries(vmap4assembler
collision
g3dlib
${ZLIB_LIBRARIES}
)
if( UNIX )
install(TARGETS vmap3assembler DESTINATION bin)
install(TARGETS vmap4assembler DESTINATION bin)
elseif( WIN32 )
install(TARGETS vmap3assembler DESTINATION "${CMAKE_INSTALL_PREFIX}")
install(TARGETS vmap4assembler DESTINATION "${CMAKE_INSTALL_PREFIX}")
endif()
@@ -23,18 +23,18 @@ include_directories(
${CMAKE_SOURCE_DIR}/dep/StormLib/src
)
add_executable(vmap3extractor ${sources})
add_executable(vmap4extractor ${sources})
target_link_libraries(vmap3extractor
target_link_libraries(vmap4extractor
${BZIP2_LIBRARIES}
${ZLIB_LIBRARIES}
storm
)
add_dependencies(vmap3extractor storm)
add_dependencies(vmap4extractor mpq)
if( UNIX )
install(TARGETS vmap3extractor DESTINATION bin)
install(TARGETS vmap4extractor DESTINATION bin)
elseif( WIN32 )
install(TARGETS vmap3extractor DESTINATION "${CMAKE_INSTALL_PREFIX}")
install(TARGETS vmap4extractor DESTINATION "${CMAKE_INSTALL_PREFIX}")
endif()
@@ -1,13 +1,40 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "vmapexport.h"
#include "adtfile.h"
#include <algorithm>
#include <cstdio>
#ifdef _WIN32
#ifdef WIN32
#define snprintf _snprintf
#endif
const char * GetPlainName(const char * FileName)
{
const char * szTemp;
if((szTemp = strrchr(FileName, '\\')) != NULL)
FileName = szTemp + 1;
return FileName;
}
char * GetPlainName(char * FileName)
{
char * szTemp;
@@ -43,6 +70,14 @@ void fixname2(char *name, size_t len)
}
}
char * GetExtension(char * FileName)
{
char * szTemp;
if((szTemp = strrchr(FileName, '.')) != NULL)
return szTemp;
return NULL;
}
ADTFile::ADTFile(char* filename): ADT(filename)
{
Adtfilename.append(filename);
@@ -107,35 +142,15 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
while (p<buf+size)
{
fixnamen(p,strlen(p));
string path(p);
char* s=GetPlainName(p);
char* s = GetPlainName(p);
fixname2(s,strlen(s));
p=p+strlen(p)+1;
ModelInstansName[t++] = s;
// < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
std::string ext3 = path.size() >= 4 ? path.substr(path.size()-4,4) : "";
std::transform( ext3.begin(), ext3.end(), ext3.begin(), ::tolower );
if(ext3 == ".mdx")
{
// replace .mdx -> .m2
path.erase(path.length()-2,2);
path.append("2");
}
// >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
// nothing do
string path(p);
ExtractSingleModel(path);
char szLocalFile[1024];
snprintf(szLocalFile, 1024, "%s/%s", szWorkDirWmo, s);
FILE * output = fopen(szLocalFile,"rb");
if(!output)
{
Model m2(path);
if(m2.open())
m2.ConvertToVMAPModel(szLocalFile);
}
else
fclose(output);
p = p+strlen(p)+1;
}
delete[] buf;
}
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ADT_H
#define ADT_H
@@ -115,7 +133,11 @@ private:
string Adtfilename;
};
const char * GetPlainName(const char * FileName);
char * GetPlainName(char * FileName);
char * GetExtension(char * FileName);
void fixnamen(char *name, size_t len);
void fixname2(char *name, size_t len);
//void fixMapNamen(char *name, size_t len);
#endif
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define _CRT_SECURE_NO_DEPRECATE
#include "dbcfile.h"
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DBCFILE_H
#define DBCFILE_H
#include <cassert>
@@ -0,0 +1,99 @@
#include "model.h"
#include "dbcfile.h"
#include "adtfile.h"
#include "vmapexport.h"
#include <algorithm>
#include <stdio.h>
bool ExtractSingleModel(std::string& fname)
{
char * name = GetPlainName((char*)fname.c_str());
char * ext = GetExtension(name);
// < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
if (!strcmp(ext, ".mdx"))
{
// replace .mdx -> .m2
fname.erase(fname.length()-2,2);
fname.append("2");
}
// >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
// nothing do
std::string output(szWorkDirWmo);
output += "/";
output += name;
if (FileExists(output.c_str()))
return true;
Model mdl(fname);
if (!mdl.open())
return false;
return mdl.ConvertToVMAPModel(output.c_str());
}
void ExtractGameobjectModels()
{
printf("Extracting GameObject models...");
DBCFile dbc("DBFilesClient\\GameObjectDisplayInfo.dbc");
if(!dbc.open())
{
printf("Fatal error: Invalid GameObjectDisplayInfo.dbc file format!\n");
exit(1);
}
std::string basepath = szWorkDirWmo;
basepath += "/";
std::string path;
FILE * model_list = fopen((basepath + "temp_gameobject_models").c_str(), "wb");
for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it)
{
path = it->getString(1);
if (path.length() < 4)
continue;
fixnamen((char*)path.c_str(), path.size());
char * name = GetPlainName((char*)path.c_str());
fixname2(name, strlen(name));
char * ch_ext = GetExtension(name);
if (!ch_ext)
continue;
strToLower(ch_ext);
bool result = false;
if (!strcmp(ch_ext, ".wmo"))
{
result = ExtractSingleWmo(path);
}
else if (!strcmp(ch_ext, ".mdl"))
{
// TODO: extract .mdl files, if needed
continue;
}
else //if (!strcmp(ch_ext, ".mdx") || !strcmp(ch_ext, ".m2"))
{
result = ExtractSingleModel(path);
}
if (result)
{
uint32 displayId = it->getUInt(0);
uint32 path_length = strlen(name);
fwrite(&displayId, sizeof(uint32), 1, model_list);
fwrite(&path_length, sizeof(uint32), 1, model_list);
fwrite(name, sizeof(char), path_length, model_list);
}
}
fclose(model_list);
printf("Done!\n");
}
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "vmapexport.h"
#include "model.h"
#include "wmo.h"
@@ -6,7 +24,7 @@
#include <algorithm>
#include <cstdio>
Model::Model(std::string &filename) : filename(filename)
Model::Model(std::string &filename) : filename(filename), vertices(0), indices(0)
{
}
@@ -19,10 +37,13 @@ bool Model::open()
if (!ok)
{
f.close();
printf("Error loading model %s\n", filename.c_str());
// Do not show this error on console to avoid confusion, the extractor can continue working even if some models fail to load
//printf("Error loading model %s\n", filename.c_str());
return false;
}
_unload();
memcpy(&header, f.getBuffer(), sizeof(ModelHeader));
if(header.nBoundingTriangles > 0)
{
@@ -49,7 +70,7 @@ bool Model::open()
return true;
}
bool Model::ConvertToVMAPModel(char * outfilename)
bool Model::ConvertToVMAPModel(const char * outfilename)
{
int N[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
FILE * output=fopen(outfilename,"wb");
@@ -58,7 +79,7 @@ bool Model::ConvertToVMAPModel(char * outfilename)
printf("Can't create the output file '%s'\n",outfilename);
return false;
}
fwrite("VMAP003",8,1,output);
fwrite(szRawVMAPMagic,8,1,output);
uint32 nVertices = 0;
nVertices = header.nBoundingVertices;
fwrite(&nVertices, sizeof(int), 1, output);
@@ -92,24 +113,16 @@ bool Model::ConvertToVMAPModel(char * outfilename)
{
for(uint32 vpos=0; vpos <nVertices; ++vpos)
{
float sy = vertices[vpos].y;
vertices[vpos].y = vertices[vpos].z;
vertices[vpos].z = sy;
std::swap(vertices[vpos].y, vertices[vpos].z);
}
fwrite(vertices, sizeof(float)*3, nVertices, output);
}
delete[] vertices;
delete[] indices;
fclose(output);
return true;
}
Model::~Model()
{
}
Vec3D fixCoordSystem(Vec3D v)
{
@@ -154,7 +167,7 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID,
uint16 adtId = 0;// not used for models
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
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
fwrite(&tileX, sizeof(uint32), 1, pDirfile);
+77
View File
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MODEL_H
#define MODEL_H
#include "vec3d.h"
//#include "mpq.h"
#include "modelheaders.h"
#include <vector>
class Model;
class WMOInstance;
class MPQFile;
Vec3D fixCoordSystem(Vec3D v);
class Model
{
public:
ModelHeader header;
uint32 offsBB_vertices, offsBB_indices;
Vec3D *BB_vertices, *vertices;
uint16 *BB_indices, *indices;
size_t nIndices;
bool open();
bool ConvertToVMAPModel(const char * outfilename);
bool ok;
Model(std::string &filename);
~Model() {_unload();}
private:
void _unload()
{
delete[] vertices;
delete[] indices;
vertices = NULL;
indices = NULL;
}
std::string filename;
char outfilename;
};
class ModelInstance
{
public:
Model *model;
uint32 id;
Vec3D pos, rot;
unsigned int d1, scale;
float w,sc;
ModelInstance() {}
ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile);
};
#endif
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MODELHEADERS_H
#define MODELHEADERS_H
@@ -1,3 +1,6 @@
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#ifndef MPQ_H
#define MPQ_H
@@ -20,14 +23,14 @@ public:
void close();
void GetFileListTo(vector<string>& 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);
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);
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
char seps[] = "\n";
char *token;
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <iostream>
@@ -5,7 +23,7 @@
#include <list>
#include <errno.h>
#ifdef _WIN32
#ifdef WIN32
#include <Windows.h>
#include <sys/stat.h>
#include <direct.h>
@@ -29,6 +47,8 @@
#include "wmo.h"
#include "mpq_libmpq04.h"
#include "vmapexport.h"
//------------------------------------------------------------------------------
// Defines
@@ -55,13 +75,19 @@ bool preciseVectorData = false;
// Constants
//static const char * szWorkDirMaps = ".\\Maps";
const char * szWorkDirWmo = "./Buildings";
const char* szWorkDirWmo = "./Buildings";
const char* szRawVMAPMagic = "VMAP004";
// Local testing functions
static void clreol()
bool FileExists(const char* file)
{
printf("\r \r");
if (FILE* n = fopen(file, "rb"))
{
fclose(n);
return true;
}
return false;
}
void strToLower(char* str)
@@ -73,15 +99,6 @@ void strToLower(char* str)
}
}
static const char * GetPlainName(const char * szFileName)
{
const char * szTemp;
if((szTemp = strrchr(szFileName, '\\')) != NULL)
szFileName = szTemp + 1;
return szFileName;
}
// copied from contrib/extractor/System.cpp
void ReadLiquidTypeTableDBC()
{
@@ -104,10 +121,9 @@ void ReadLiquidTypeTableDBC()
printf("Done! (%u LiqTypes loaded)\n", (unsigned int)LiqType_count);
}
int ExtractWmo()
bool ExtractWmo()
{
char szLocalFile[1024] = "";
bool success=true;
bool success = true;
//const char* ParsArchiveNames[] = {"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ"};
@@ -116,99 +132,98 @@ int ExtractWmo()
vector<string> filelist;
(*ar_itr)->GetFileListTo(filelist);
for (vector<string>::iterator fname=filelist.begin(); fname != filelist.end() && success; ++fname)
for (vector<string>::iterator fname = filelist.begin(); fname != filelist.end() && success; ++fname)
{
bool file_ok=true;
if (fname->find(".wmo") != string::npos)
{
// Copy files from archive
//std::cout << "found *.wmo file " << *fname << std::endl;
sprintf(szLocalFile, "%s/%s", szWorkDirWmo, GetPlainName(fname->c_str()));
fixnamen(szLocalFile,strlen(szLocalFile));
FILE * n;
if ((n = fopen(szLocalFile, "rb"))== NULL)
{
int p = 0;
//Select root wmo files
const char * rchr = strrchr(GetPlainName(fname->c_str()),0x5f);
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)
{
std::cout << "Extracting " << *fname << std::endl;
WMORoot * froot = new WMORoot(*fname);
if(!froot->open())
{
printf("Couldn't open RootWmo!!!\n");
delete froot;
continue;
}
FILE *output=fopen(szLocalFile,"wb");
if(!output)
{
printf("couldn't open %s for writing!\n", szLocalFile);
success=false;
}
froot->ConvertToVMAPRootWmo(output);
int Wmo_nVertices = 0;
//printf("root has %d groups\n", froot->nGroups);
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);
//printf("Trying to open groupfile %s\n",groupFileName);
string s = groupFileName;
WMOGroup * fgroup = new WMOGroup(s);
if(!fgroup->open())
{
printf("Could not open all Group file for: %s\n",GetPlainName(fname->c_str()));
file_ok=false;
break;
}
Wmo_nVertices += fgroup->ConvertToVMAPGroupWmo(output, froot, preciseVectorData);
delete fgroup;
}
}
fseek(output, 8, SEEK_SET); // store the correct no of vertices
fwrite(&Wmo_nVertices,sizeof(int),1,output);
fclose(output);
delete froot;
}
}
else
{
fclose(n);
}
}
// Delete the extracted file in the case of an error
if(!file_ok)
remove(szLocalFile);
success = ExtractSingleWmo(*fname);
}
}
if(success)
if (success)
printf("\nExtract wmo complete (No (fatal) errors)\n");
return success;
}
void ExtractMapsFromMpq()
bool ExtractSingleWmo(std::string& fname)
{
// Copy files from archive
char szLocalFile[1024];
const char * plain_name = GetPlainName(fname.c_str());
sprintf(szLocalFile, "%s/%s", szWorkDirWmo, plain_name);
fixnamen(szLocalFile,strlen(szLocalFile));
if (FileExists(szLocalFile))
return true;
int p = 0;
//Select root wmo files
const char * rchr = strrchr(plain_name, '_');
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;
//printf("root has %d groups\n", froot->nGroups);
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);
//printf("Trying to open groupfile %s\n",groupFileName);
string s = groupFileName;
WMOGroup fgroup(s);
if(!fgroup.open())
{
printf("Could not open all Group file for: %s\n", plain_name);
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()
@@ -251,8 +266,9 @@ void getGamePath()
LONG l;
s = sizeof(input_path);
memset(input_path,0,s);
l = RegOpenKeyExA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Blizzard Entertainment\\World of Warcraft",0,KEY_QUERY_VALUE,&key);
l = RegQueryValueExA(key,"InstallPath",0,&t,(LPBYTE)input_path,&s);
l = RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Blizzard Entertainment\\World of Warcraft",0,KEY_QUERY_VALUE,&key);
//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)
{
@@ -379,16 +395,17 @@ bool processArgv(int argc, char ** argv, const char *versionString)
{
bool result = true;
hasInputPathParam = false;
bool preciseVectorData = false;
for (int i=1; i < argc; ++i)
for(int i=1; i< argc; ++i)
{
if (strcmp("-s", argv[i]) == 0)
if(strcmp("-s",argv[i]) == 0)
{
preciseVectorData = false;
}
else if (strcmp("-d", argv[i]) == 0)
else if(strcmp("-d",argv[i]) == 0)
{
if ((i + 1) < argc)
if((i+1)<argc)
{
hasInputPathParam = true;
strcpy(input_path, argv[i+1]);
@@ -401,11 +418,11 @@ bool processArgv(int argc, char ** argv, const char *versionString)
result = false;
}
}
else if (strcmp("-?", argv[1]) == 0)
else if(strcmp("-?",argv[1]) == 0)
{
result = false;
}
else if (strcmp("-l", argv[i]) == 0)
else if(strcmp("-l",argv[i]) == 0)
{
preciseVectorData = true;
}
@@ -427,6 +444,7 @@ bool processArgv(int argc, char ** argv, const char *versionString)
return result;
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Main
//
@@ -439,7 +457,7 @@ bool processArgv(int argc, char ** argv, const char *versionString)
int main(int argc, char ** argv)
{
bool success=true;
const char *versionString = "V3.00 2010_07";
const char *versionString = "V4.00 2012_02";
// Use command line arguments, when some
if(!processArgv(argc, argv, versionString))
@@ -465,7 +483,7 @@ int main(int argc, char ** argv)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Create the working directory
if(mkdir(szWorkDirWmo
#ifdef _XOPEN_UNIX
#ifdef __linux__
, 0711
#endif
))
@@ -517,9 +535,11 @@ int main(int argc, char ** argv)
ParsMapFiles();
delete [] map_ids;
//nError = ERROR_SUCCESS;
// Extract models, listed in DameObjectDisplayInfo.dbc
ExtractGameobjectModels();
}
clreol();
printf("\n");
if(!success)
{
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData);
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef VMAPEXPORT_H
#define VMAPEXPORT_H
#include <string>
enum ModelFlags
{
MOD_M2 = 1,
MOD_WORLDSPAWN = 1<<1,
MOD_HAS_BOUND = 1<<2
};
extern const char * szWorkDirWmo;
extern const char * szRawVMAPMagic; // vmap magic string for extracted raw vmap data
bool FileExists(const char * file);
void strToLower(char* str);
bool ExtractSingleWmo(std::string& fname);
bool ExtractSingleModel(std::string& fname);
void ExtractGameobjectModels();
#endif
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "vmapexport.h"
#include "wdtfile.h"
#include "adtfile.h"
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "vmapexport.h"
#include "wmo.h"
#include "vec3d.h"
@@ -106,7 +124,7 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
{
//printf("Convert RootWmo...\n");
fwrite("VMAP003",1,8,pOutfile);
fwrite(szRawVMAPMagic,1,8,pOutfile);
unsigned int nVectors = 0;
fwrite(&nVectors,sizeof(nVectors),1,pOutfile); // will be filled later
fwrite(&nGroups,4,1,pOutfile);
@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef WMO_H
#define WMO_H
#define TILESIZE (533.33333f)