mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[c12536] Happy New Year 2013
Update authorship information and prepare for easier ways next year Signed-off-by: Schmoozerd <schmoozerd@cmangos> (based on commit [12325] - b7dbcda)
This commit is contained in:
parent
86a243c910
commit
a05738717a
542 changed files with 3274 additions and 1846 deletions
111
contrib/vmap_extractor/vmapextract/gameobject_extract.cpp
Normal file
111
contrib/vmap_extractor/vmapextract/gameobject_extract.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#include "model.h"
|
||||
#include "dbcfile.h"
|
||||
#include "adtfile.h"
|
||||
#include "vmapexport.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
|
||||
bool ExtractSingleModel(std::string& fname, StringSet& failedPaths)
|
||||
{
|
||||
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(failedPaths))
|
||||
return false;
|
||||
|
||||
return mdl.ConvertToVMAPModel(output.c_str());
|
||||
}
|
||||
|
||||
extern HANDLE LocaleMpq;
|
||||
|
||||
void ExtractGameobjectModels()
|
||||
{
|
||||
printf("\n");
|
||||
printf("Extracting GameObject models...\n");
|
||||
DBCFile dbc(LocaleMpq, "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;
|
||||
StringSet failedPaths;
|
||||
|
||||
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, failedPaths);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!failedPaths.empty())
|
||||
{
|
||||
printf("Warning: Some models could not be extracted, see below\n");
|
||||
for (StringSet::const_iterator itr = failedPaths.begin(); itr != failedPaths.end(); ++itr)
|
||||
printf("Could not find file of model %s\n", itr->c_str());
|
||||
printf("A few of these warnings are expected to happen, so be not alarmed!\n");
|
||||
}
|
||||
|
||||
printf("Done!\n");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue