aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Commands/cs_mmaps.cpp2
-rw-r--r--src/tools/mesh_extractor/MPQManager.cpp75
-rw-r--r--src/tools/mesh_extractor/MPQManager.h5
-rw-r--r--src/tools/mesh_extractor/MeshExtractor.cpp13
4 files changed, 80 insertions, 15 deletions
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp
index e4822236a9a..d0b1fdc2abd 100644
--- a/src/server/scripts/Commands/cs_mmaps.cpp
+++ b/src/server/scripts/Commands/cs_mmaps.cpp
@@ -213,7 +213,7 @@ public:
handler->PSendSysMessage(" global mmap pathfinding is %sabled", MMAP::MMapFactory::IsPathfindingEnabled(mapId) ? "en" : "dis");
MMAP::MMapManager* manager = MMAP::MMapFactory::CreateOrGetMMapManager();
- handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount());
+ handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->GetLoadedMapsCount(), manager->GetLoadedTilesCount());
dtNavMesh const* navmesh = manager->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId());
if (!navmesh)
diff --git a/src/tools/mesh_extractor/MPQManager.cpp b/src/tools/mesh_extractor/MPQManager.cpp
index 4d3ab808a2e..950e284f92e 100644
--- a/src/tools/mesh_extractor/MPQManager.cpp
+++ b/src/tools/mesh_extractor/MPQManager.cpp
@@ -14,6 +14,12 @@ char const* MPQManager::Files[] = {
"patch-3.MPQ"
};
+char const* MPQManager::LocalePatchFiles[] = {
+ "Data/%s/patch-%s.MPQ",
+ "Data/%s/patch-%s-2.MPQ",
+ "Data/%s/patch-%s-3.MPQ"
+};
+
char const* MPQManager::Languages[] = { "enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
void MPQManager::Initialize()
@@ -31,7 +37,6 @@ void MPQManager::Initialize()
void MPQManager::InitializeDBC()
{
BaseLocale = -1;
- std::string fileName;
uint32 size = sizeof(Languages) / sizeof(char*);
MPQArchive* _baseLocale = NULL;
for (uint32 i = 0; i < size; ++i)
@@ -41,20 +46,34 @@ void MPQManager::InitializeDBC()
if (file)
{
if (BaseLocale == -1)
- {
BaseLocale = i;
- _baseLocale = new MPQArchive(_fileName.c_str());
- fileName = _fileName;
- LocaleFiles[i] = _baseLocale;
+
+ // Load the base locale file
+ MPQArchive* arch = new MPQArchive(_fileName.c_str());
+ LocaleFiles[i].push_front(arch);
+
+ Archives.push_front(arch); // For lookup in GetFile
+
+ // Load the locale patches
+ for (uint32 j = 0; j < sizeof(LocalePatchFiles) / sizeof(char*); ++j)
+ {
+ char patchName[100];
+ sprintf(patchName, LocalePatchFiles[j], Languages[i], Languages[i]);
+ FILE* patch = fopen(patchName, "rb");
+ if (file)
+ {
+ MPQArchive* archP = new MPQArchive(patchName);
+ LocaleFiles[i].push_front(archP);
+ Archives.push_front(archP); // For lookup in GetFile
+ fclose(patch);
+ }
}
- else
- LocaleFiles[i] = new MPQArchive(_fileName.c_str());
AvailableLocales.insert(i);
printf("Detected locale: %s\n", Languages[i]);
}
}
- Archives.push_front(_baseLocale);
+
if (BaseLocale == -1)
{
printf("No locale data detected. Please make sure that the executable is in the same folder as your WoW installation.\n");
@@ -79,6 +98,46 @@ DBC* MPQManager::GetDBC(const std::string& name )
return new DBC(GetFile(path));
}
+FILE* MPQManager::GetFileFromLocale( const std::string& path, uint32 locale )
+{
+ ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
+ std::deque<MPQArchive*> files = LocaleFiles[locale];
+ FILE* ret = NULL;
+ for (std::deque<MPQArchive*>::iterator itr = files.begin(); itr != files.end(); ++itr)
+ {
+ mpq_archive* mpq_a = (*itr)->mpq_a;
+
+ uint32_t filenum;
+ if(libmpq__file_number(mpq_a, path.c_str(), &filenum))
+ continue;
+ libmpq__off_t transferred;
+ libmpq__off_t size = 0;
+ 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)
+ continue;
+
+ char* buffer = new char[size];
+
+ //libmpq_file_getdata
+ libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
+
+ // Pack the return into a FILE stream
+ ret = tmpfile();
+ if (!ret)
+ {
+ printf("Could not create temporary file. Please run as Administrator or root\n");
+ exit(1);
+ }
+ fwrite(buffer, sizeof(uint8), size, ret);
+ fseek(ret, 0, SEEK_SET);
+ delete[] buffer;
+ break;
+ }
+ return ret;
+}
+
FILE* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file )
{
ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
diff --git a/src/tools/mesh_extractor/MPQManager.h b/src/tools/mesh_extractor/MPQManager.h
index 7f9d675c4d4..3514674b9bf 100644
--- a/src/tools/mesh_extractor/MPQManager.h
+++ b/src/tools/mesh_extractor/MPQManager.h
@@ -16,15 +16,18 @@ public:
void Initialize();
FILE* GetFile(const std::string& path);
FILE* GetFileFrom(const std::string& path, MPQArchive* file);
+ FILE* GetFileFromLocale(const std::string& path, uint32 locale);
+
DBC* GetDBC(const std::string& name);
std::vector<std::string> GetAllFiles(std::string extension);
std::deque<MPQArchive*> Archives;
int32 BaseLocale;
std::set<uint32> AvailableLocales;
- std::map<uint32, MPQArchive*> LocaleFiles;
+ std::map<uint32, std::deque<MPQArchive*> > LocaleFiles;
static char const* Files[];
+ static char const* LocalePatchFiles[];
static char const* Languages[];
protected:
void InitializeDBC();
diff --git a/src/tools/mesh_extractor/MeshExtractor.cpp b/src/tools/mesh_extractor/MeshExtractor.cpp
index 0d9160a610b..9cc7eea5509 100644
--- a/src/tools/mesh_extractor/MeshExtractor.cpp
+++ b/src/tools/mesh_extractor/MeshExtractor.cpp
@@ -58,9 +58,12 @@ void ExtractDBCs()
// Populate list of DBC files
// We get the DBC names by going over the (guaranteed to exist) default locale files
// Then we look in other locale files in case that they are available.
- for (std::vector<std::string>::iterator itr = MPQHandler->LocaleFiles[MPQHandler->BaseLocale]->Files.begin(); itr != MPQHandler->LocaleFiles[MPQHandler->BaseLocale]->Files.end(); ++itr)
- if (itr->rfind(".dbc") == itr->length() - extLen) // Check if the extension is ".dbc"
- DBCFiles.insert(*itr);
+ for (std::map<uint32, std::deque<MPQArchive*> >::iterator itr = MPQHandler->LocaleFiles.begin(); itr != MPQHandler->LocaleFiles.end(); ++itr)
+ for (std::deque<MPQArchive*>::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
+ for (std::vector<std::string>::iterator itr3 = (*itr2)->Files.begin(); itr3 != (*itr2)->Files.end(); ++itr3)
+ if (itr3->rfind(".dbc") == itr3->length() - extLen) // Check if the extension is ".dbc"
+ if (DBCFiles.find(*itr3) == DBCFiles.end())
+ DBCFiles.insert(*itr3);
const size_t folderLen = strlen("DBFilesClient\\");
// Iterate over all available locales
@@ -76,10 +79,10 @@ void ExtractDBCs()
std::string component = "component.wow-" + std::string(MPQManager::Languages[*itr]) + ".txt";
// Extract the component file
- Utils::SaveToDisk(MPQHandler->GetFileFrom(component, MPQHandler->LocaleFiles[*itr]), path + component);
+ Utils::SaveToDisk(MPQHandler->GetFileFromLocale(component, *itr), path + component);
// Extract the DBC files for the given locale
for (std::set<std::string>::iterator itr2 = DBCFiles.begin(); itr2 != DBCFiles.end(); ++itr2)
- Utils::SaveToDisk(MPQHandler->GetFileFrom(*itr2, MPQHandler->LocaleFiles[*itr]), path + (itr2->c_str() + folderLen));
+ Utils::SaveToDisk(MPQHandler->GetFileFromLocale(*itr2, *itr), path + (itr2->c_str() + folderLen));
}
printf("DBC extraction finished!\n");
}