Skip to content

Commit

Permalink
[c12720] Use possible changed model names with vmap extraction
Browse files Browse the repository at this point in the history
(based on commit [12527] - 94c2a73)
  • Loading branch information
Schmoozerd authored and Dramacydal committed Aug 19, 2013
1 parent bfd99e0 commit 8bf1374
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
12 changes: 6 additions & 6 deletions contrib/vmap_extractor/vmapextract/adtfile.cpp
Expand Up @@ -73,9 +73,9 @@ void fixname2(char* name, size_t len)
}
}

char* GetExtension(char* FileName)
char const* GetExtension(char const* FileName)
{
char* szTemp;
char const* szTemp;
if ((szTemp = strrchr(FileName, '.')) != NULL)
return szTemp;
return NULL;
Expand Down Expand Up @@ -149,11 +149,11 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failed
fixnamen(p, strlen(p));
char* s = GetPlainName(p);
fixname2(s, strlen(s));
string path(p); // Store copy after name fixed

ModelInstansName[t++] = s;

string path(p);
ExtractSingleModel(path, failedPaths);
std::string fixedName;
ExtractSingleModel(path, fixedName, failedPaths);
ModelInstansName[t++] = fixedName;

p = p + strlen(p) + 1;
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/vmap_extractor/vmapextract/adtfile.h
Expand Up @@ -136,7 +136,7 @@ class ADTFile

const char* GetPlainName(const char* FileName);
char* GetPlainName(char* FileName);
char* GetExtension(char* FileName);
char const* GetExtension(char const* FileName);
void fixnamen(char* name, size_t len);
void fixname2(char* name, size_t len);
//void fixMapNamen(char *name, size_t len);
Expand Down
22 changes: 12 additions & 10 deletions contrib/vmap_extractor/vmapextract/gameobject_extract.cpp
Expand Up @@ -6,29 +6,30 @@
#include <algorithm>
#include <stdio.h>

bool ExtractSingleModel(std::string& fname, StringSet& failedPaths)
bool ExtractSingleModel(std::string& origPath, std::string& fixedName, StringSet& failedPaths)
{
char* ext = GetExtension(GetPlainName((char*)fname.c_str()));
char const* ext = GetExtension(GetPlainName(origPath.c_str()));

// < 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");
origPath.erase(origPath.length() - 2, 2);
origPath.append("2");
}
// >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
// nothing do

fixedName = GetPlainName(origPath.c_str());

std::string output(szWorkDirWmo); // Stores output filename (possible changed)
output += "/";
output += GetPlainName(fname.c_str());

output += fixedName;

if (FileExists(output.c_str()))
return true;

Model mdl(fname); // Possible changed fname
Model mdl(origPath); // Possible changed fname
if (!mdl.open(failedPaths))
return false;

Expand Down Expand Up @@ -66,11 +67,11 @@ void ExtractGameobjectModels()
char* name = GetPlainName((char*)path.c_str());
fixname2(name, strlen(name));

char* ch_ext = GetExtension(name);
char const* ch_ext = GetExtension(name);
if (!ch_ext)
continue;

strToLower(ch_ext);
//strToLower(ch_ext);

bool result = false;
if (!strcmp(ch_ext, ".wmo"))
Expand All @@ -84,7 +85,8 @@ void ExtractGameobjectModels()
}
else //if (!strcmp(ch_ext, ".mdx") || !strcmp(ch_ext, ".m2"))
{
result = ExtractSingleModel(path, failedPaths);
std::string fixedName;
result = ExtractSingleModel(path, fixedName, failedPaths);
}

if (result)
Expand Down
7 changes: 6 additions & 1 deletion contrib/vmap_extractor/vmapextract/vmapexport.h
Expand Up @@ -38,7 +38,12 @@ bool FileExists(const char* file);
void strToLower(char* str);

bool ExtractSingleWmo(std::string& fname);
bool ExtractSingleModel(std::string& fname, StringSet& failedPaths);

/* @param origPath = original path of the model, cleaned with fixnamen and fixname2
* @param fixedName = will store the translated name (if changed)
* @param failedPaths = Set to collect errors
*/
bool ExtractSingleModel(std::string& origPath, std::string& fixedName, StringSet& failedPaths);

void ExtractGameobjectModels();

Expand Down
2 changes: 1 addition & 1 deletion src/game/vmap/TileAssembler.cpp
Expand Up @@ -352,7 +352,7 @@ namespace VMAP

if (name_length >= sizeof(buff))
{
std::cout << "\nFile 'temp_gameobject_models' seems to be corrupted" << std::endl;
std::cout << "\nFile '" << GAMEOBJECT_MODELS << "' seems to be corrupted" << std::endl;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12719"
#define REVISION_NR "12720"
#endif // __REVISION_NR_H__

0 comments on commit 8bf1374

Please sign in to comment.