|
|
|
@ -89,20 +89,11 @@ CPipelinePluginMax::~CPipelinePluginMax()
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
std::set<std::string> MissingFiles;
|
|
|
|
|
std::map<std::string, std::string> KnownFileCache;
|
|
|
|
|
|
|
|
|
|
class CMaxRewritePathsCommand : public NLMISC::IRunnable
|
|
|
|
|
// COPY FROM PIPELINE_SERVICE.CPP WITH BACKSLASHES INSTEAD OF FORWARD SLASHES
|
|
|
|
|
std::string standardizePath(const std::string &path, bool addFinalSlash)
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
NLMISC::CLog *Log;
|
|
|
|
|
std::string SrcDirectoryRecursive;
|
|
|
|
|
std::string DatabaseDirectory;
|
|
|
|
|
|
|
|
|
|
virtual void getName(std::string &result) const
|
|
|
|
|
{ result = "CMaxRewritePathsCommand"; }
|
|
|
|
|
|
|
|
|
|
// COPY FROM PIPELINE_SERVICE.CPP WITH BACKSLASHES INSTEAD OF FORWARD SLASHES
|
|
|
|
|
static std::string standardizePath(const std::string &path, bool addFinalSlash)
|
|
|
|
|
{
|
|
|
|
|
// check empty path
|
|
|
|
|
if (path.empty())
|
|
|
|
|
return "";
|
|
|
|
@ -141,15 +132,15 @@ public:
|
|
|
|
|
newPath += '\\';
|
|
|
|
|
|
|
|
|
|
return newPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool isCharacter(char c)
|
|
|
|
|
{
|
|
|
|
|
inline bool isCharacter(char c)
|
|
|
|
|
{
|
|
|
|
|
return (32 <= c /*&& c <= 127) || (161 <= c*/ && c <= 255);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline char stripFrenchLocale(char c)
|
|
|
|
|
{
|
|
|
|
|
inline char stripFrenchLocale(char c)
|
|
|
|
|
{
|
|
|
|
|
if (192 <= c && c <= 197) return 'a';
|
|
|
|
|
if (200 <= c && c <= 203) return 'e';
|
|
|
|
|
if (204 <= c && c <= 207) return 'i';
|
|
|
|
@ -163,12 +154,12 @@ public:
|
|
|
|
|
if (249 <= c && c <= 252) return 'u';
|
|
|
|
|
if (c == 253 || c == 255) return 'y';
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// maxRewritePaths W:/database/interfaces/anims_max
|
|
|
|
|
// maxRewritePaths W:/database/interfaces/anims_max
|
|
|
|
|
|
|
|
|
|
static std::string rewritePath(const std::string &path, const std::string &databaseDirectory)
|
|
|
|
|
{
|
|
|
|
|
std::string rewritePath(const std::string &path, const std::string &databaseDirectory)
|
|
|
|
|
{
|
|
|
|
|
static std::set<std::string> fileNameCache;
|
|
|
|
|
|
|
|
|
|
std::string stdPath = standardizePath(path, false);
|
|
|
|
@ -180,26 +171,60 @@ public:
|
|
|
|
|
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "w:\\database\\", databaseDirectory);
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "\\\\amiga\\3d\\database\\", databaseDirectory);
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "tr_hof_underwear_torso", "tr_hof_underwear_torse");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "tr_hof_underwear_hand-", "tr_hof_underwear_hand_");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "ma_hom_armor_01", "ma_hom_armor01");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "spec_yeux", "spec_eye_tryker");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "ma_hof_armor_01", "ma_hof_armor01");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "ma_hom_armor_00", "ma_hom_armor00");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "ma_hof_armor_00", "ma_hof_armor00");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "zo_hom_armor_00", "zo_hom_armor00");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "zo_hof_armor_00", "zo_hof_armor00");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hof_cheveux_shave01", "fy_hof_cheveux_shave");
|
|
|
|
|
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "matis\\agents\\_textures\\actors\\ma_hom_underwear_avtbras", "tryker\\agents\\_textures\\actors\\tr_hom_underwear_avtbras");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "matis\\agents\\_textures\\actors\\ma_hom_underwear_epaule", "tryker\\agents\\_textures\\actors\\tr_hom_underwear_epaule");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "matis\\agents\\_textures\\actors\\ma_hom_underwear_hand-downside", "tryker\\agents\\_textures\\actors\\tr_hom_underwear_hand-downside");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "matis\\agents\\_textures\\actors\\ma_hom_underwear_hand-upside", "tryker\\agents\\_textures\\actors\\tr_hom_underwear_hand-upside");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "matis\\agents\\_textures\\actors\\ma_hom_underwear_molet", "tryker\\agents\\_textures\\actors\\tr_hom_underwear_molet");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "matis\\agents\\_textures\\actors\\ma_hof_underwear_hand-downside", "tryker\\agents\\_textures\\actors\\tr_hof_underwear_hand-downside");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "matis\\agents\\_textures\\actors\\ma_hof_underwear_hand-upside", "tryker\\agents\\_textures\\actors\\tr_hof_underwear_hand-upside");
|
|
|
|
|
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "tr_hof_underwear_torso", "tr_hof_underwear_torse");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "tr_hof_underwear_hand-", "tr_hof_underwear_hand_");
|
|
|
|
|
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_avbras.", "fy_hom_armor00_avbras_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_bottes.", "fy_hom_armor00_bottes_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_bras.", "fy_hom_armor00_bras_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_cuissear.", "fy_hom_armor00_cuissear_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_cuisseav.", "fy_hom_armor00_cuisseav_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_dos.", "fy_hom_armor00_dos_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_hand-downside.", "fy_hom_armor00_hand-downside_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_hand-upside.", "fy_hom_armor00_hand-upside_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_pieds.", "fy_hom_armor00_pieds_c1.");
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "fy_hom_armor00_torse.", "fy_hom_armor00_torse_c1.");
|
|
|
|
|
|
|
|
|
|
NLMISC::strFindReplace(stdPath, "interfaces_visage", "visage_interface");
|
|
|
|
|
|
|
|
|
|
if (stdPath.find("\\trame.") != std::string::npos)
|
|
|
|
|
stdPath = standardizePath(databaseDirectory + "/stuff/lod_actors/texture_lod/trame.png", false);
|
|
|
|
|
if (stdPath.find("\\tr_hof_visage_c1.") != std::string::npos)
|
|
|
|
|
stdPath = standardizePath(databaseDirectory + "/stuff/tryker/agents/_textures/actors/tr_hof_visage_c1.png", false);
|
|
|
|
|
if (stdPath.find("\\tr_hof_visage_c2.") != std::string::npos)
|
|
|
|
|
stdPath = standardizePath(databaseDirectory + "/stuff/tryker/agents/_textures/actors/tr_hof_visage_c2.png", false);
|
|
|
|
|
if (stdPath.find("\\tr_hof_visage_c3.") != std::string::npos)
|
|
|
|
|
stdPath = standardizePath(databaseDirectory + "/stuff/tryker/agents/_textures/actors/tr_hof_visage_c3.png", false);
|
|
|
|
|
if (stdPath.find("\\ma_hof_cheveux_medium02.") != std::string::npos)
|
|
|
|
|
stdPath = standardizePath(databaseDirectory + "/stuff/matis/agents/_textures/actors/ma_hof_cheveux_medium02.png", false);
|
|
|
|
|
|
|
|
|
|
if (stdPath.size() > path.size())
|
|
|
|
|
/*if (stdPath.size() > path.size())
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Path size becomes too large: '%s' -> '%s'", path.c_str(), stdPath.c_str());
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
if (NLMISC::CFile::getFilename(stdPath) == stdPath)
|
|
|
|
|
{
|
|
|
|
|
breakable
|
|
|
|
|
{
|
|
|
|
|
if (fileNameCache.find(stdPath) == fileNameCache.end())
|
|
|
|
|
if (fileNameCache.find(stdPath) == fileNameCache.end() || KnownFileCache.find(stdPath) == KnownFileCache.end())
|
|
|
|
|
{
|
|
|
|
|
if (stdPath[stdPath.size() - 3] == 't' && stdPath[stdPath.size() - 2] == 'g' && stdPath[stdPath.size() - 1] == 'a')
|
|
|
|
|
{
|
|
|
|
@ -221,6 +246,19 @@ public:
|
|
|
|
|
{
|
|
|
|
|
if (stdPath[1] == ':' || (stdPath[0] == '\\' && stdPath[1] == '\\'))
|
|
|
|
|
{
|
|
|
|
|
if (KnownFileCache.find(NLMISC::CFile::getFilename(stdPath)) != KnownFileCache.end())
|
|
|
|
|
return KnownFileCache[NLMISC::CFile::getFilename(stdPath)];
|
|
|
|
|
|
|
|
|
|
if (stdPath[stdPath.size() - 3] == 't' && stdPath[stdPath.size() - 2] == 'g' && stdPath[stdPath.size() - 1] == 'a')
|
|
|
|
|
{ stdPath[stdPath.size() - 3] = 'p'; stdPath[stdPath.size() - 2] = 'n'; stdPath[stdPath.size() - 1] = 'g'; }
|
|
|
|
|
if (KnownFileCache.find(NLMISC::CFile::getFilename(stdPath)) != KnownFileCache.end())
|
|
|
|
|
return KnownFileCache[NLMISC::CFile::getFilename(stdPath)];
|
|
|
|
|
|
|
|
|
|
if (stdPath[stdPath.size() - 3] == 'p' && stdPath[stdPath.size() - 2] == 'n' && stdPath[stdPath.size() - 1] == 'g')
|
|
|
|
|
{ stdPath[stdPath.size() - 3] = 't'; stdPath[stdPath.size() - 2] = 'g'; stdPath[stdPath.size() - 1] = 'a'; }
|
|
|
|
|
if (KnownFileCache.find(NLMISC::CFile::getFilename(stdPath)) != KnownFileCache.end())
|
|
|
|
|
return KnownFileCache[NLMISC::CFile::getFilename(stdPath)];
|
|
|
|
|
|
|
|
|
|
nlwarning("Path not in database: '%s' ('%s')", path.c_str(), stdPath.c_str());
|
|
|
|
|
MissingFiles.insert(path);
|
|
|
|
|
return stdPath;
|
|
|
|
@ -267,18 +305,32 @@ public:
|
|
|
|
|
if (vv2works)
|
|
|
|
|
{
|
|
|
|
|
// try with vv2
|
|
|
|
|
if (stdPathVv2.size() > path.size())
|
|
|
|
|
/*if (stdPathVv2.size() > path.size())
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Path with vv2 size becomes too large: '%s' -> '%s'", path.c_str(), stdPathVv2.c_str());
|
|
|
|
|
return stdPath;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
{*/
|
|
|
|
|
stdPath = stdPathVv2;
|
|
|
|
|
break;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// try find
|
|
|
|
|
if (KnownFileCache.find(NLMISC::CFile::getFilename(stdPath)) != KnownFileCache.end())
|
|
|
|
|
return KnownFileCache[NLMISC::CFile::getFilename(stdPath)];
|
|
|
|
|
|
|
|
|
|
if (stdPath[stdPath.size() - 3] == 't' && stdPath[stdPath.size() - 2] == 'g' && stdPath[stdPath.size() - 1] == 'a')
|
|
|
|
|
{ stdPath[stdPath.size() - 3] = 'p'; stdPath[stdPath.size() - 2] = 'n'; stdPath[stdPath.size() - 1] = 'g'; }
|
|
|
|
|
if (KnownFileCache.find(NLMISC::CFile::getFilename(stdPath)) != KnownFileCache.end())
|
|
|
|
|
return KnownFileCache[NLMISC::CFile::getFilename(stdPath)];
|
|
|
|
|
|
|
|
|
|
if (stdPath[stdPath.size() - 3] == 'p' && stdPath[stdPath.size() - 2] == 'n' && stdPath[stdPath.size() - 1] == 'g')
|
|
|
|
|
{ stdPath[stdPath.size() - 3] = 't'; stdPath[stdPath.size() - 2] = 'g'; stdPath[stdPath.size() - 1] = 'a'; }
|
|
|
|
|
if (KnownFileCache.find(NLMISC::CFile::getFilename(stdPath)) != KnownFileCache.end())
|
|
|
|
|
return KnownFileCache[NLMISC::CFile::getFilename(stdPath)];
|
|
|
|
|
|
|
|
|
|
nlwarning("Path file does not exist: '%s' ('%s')", path.c_str(), stdPath.c_str());
|
|
|
|
|
MissingFiles.insert(path);
|
|
|
|
|
return stdPath;
|
|
|
|
@ -288,7 +340,17 @@ public:
|
|
|
|
|
|
|
|
|
|
fileNameCache.insert(NLMISC::CFile::getFilename(stdPath));
|
|
|
|
|
return stdPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CMaxRewritePathsCommand : public NLMISC::IRunnable
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
NLMISC::CLog *Log;
|
|
|
|
|
std::string SrcDirectoryRecursive;
|
|
|
|
|
std::string DatabaseDirectory;
|
|
|
|
|
|
|
|
|
|
virtual void getName(std::string &result) const
|
|
|
|
|
{ result = "CMaxRewritePathsCommand"; }
|
|
|
|
|
|
|
|
|
|
void doFile(const std::string &filePath)
|
|
|
|
|
{
|
|
|
|
@ -359,17 +421,20 @@ public:
|
|
|
|
|
{
|
|
|
|
|
nldebug("Directory: '%s'", directoryPath.c_str());
|
|
|
|
|
|
|
|
|
|
std::string dirPath = standardizePath(SrcDirectoryRecursive, true);
|
|
|
|
|
std::string dirPath = standardizePath(directoryPath, true);
|
|
|
|
|
std::vector<std::string> dirContents;
|
|
|
|
|
|
|
|
|
|
NLMISC::CPath::getPathContent(dirPath, false, true, true, dirContents);
|
|
|
|
|
|
|
|
|
|
for (std::vector<std::string>::iterator it = dirContents.begin(), end = dirContents.end(); it != end; ++it)
|
|
|
|
|
{
|
|
|
|
|
const std::string &subPath = *it;
|
|
|
|
|
const std::string &subPath = standardizePath(*it, false);
|
|
|
|
|
|
|
|
|
|
if (NLMISC::CFile::isDirectory(subPath))
|
|
|
|
|
{
|
|
|
|
|
if (subPath.find("\\.") == std::string.npos)
|
|
|
|
|
doDirectory(subPath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
doFile(subPath);
|
|
|
|
|
|
|
|
|
@ -394,10 +459,79 @@ public:
|
|
|
|
|
};
|
|
|
|
|
CMaxRewritePathsCommand s_MaxRewritePathsCommand;
|
|
|
|
|
|
|
|
|
|
class CMaxRewriteInitCacheCommand : public NLMISC::IRunnable
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
NLMISC::CLog *Log;
|
|
|
|
|
std::string SrcDirectoryRecursive;
|
|
|
|
|
std::string DatabaseDirectory;
|
|
|
|
|
|
|
|
|
|
virtual void getName(std::string &result) const
|
|
|
|
|
{ result = "CMaxRewriteInitCacheCommand"; }
|
|
|
|
|
|
|
|
|
|
void doFile(const std::string &filePath)
|
|
|
|
|
{
|
|
|
|
|
KnownFileCache[NLMISC::CFile::getFilename(filePath)] = standardizePath(filePath, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// maxRewritePaths W:/database/interfaces/anims_max
|
|
|
|
|
|
|
|
|
|
void doDirectory(const std::string &directoryPath)
|
|
|
|
|
{
|
|
|
|
|
nldebug("Directory: '%s'", directoryPath.c_str());
|
|
|
|
|
|
|
|
|
|
std::string dirPath = standardizePath(directoryPath, true);
|
|
|
|
|
std::vector<std::string> dirContents;
|
|
|
|
|
|
|
|
|
|
NLMISC::CPath::getPathContent(dirPath, false, true, true, dirContents);
|
|
|
|
|
|
|
|
|
|
for (std::vector<std::string>::iterator it = dirContents.begin(), end = dirContents.end(); it != end; ++it)
|
|
|
|
|
{
|
|
|
|
|
const std::string &subPath = standardizePath(*it, false);
|
|
|
|
|
|
|
|
|
|
if (NLMISC::CFile::isDirectory(subPath))
|
|
|
|
|
{
|
|
|
|
|
if (subPath.find("\\.") == std::string.npos)
|
|
|
|
|
doDirectory(subPath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
doFile(subPath);
|
|
|
|
|
|
|
|
|
|
if (PIPELINE::IPipelineInterface::getInstance()->isExiting())
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void run()
|
|
|
|
|
{
|
|
|
|
|
std::string tempDirectory = PIPELINE::IPipelineProcess::getInstance()->getTempDirectory();
|
|
|
|
|
DatabaseDirectory = standardizePath(PIPELINE::IPipelineInterface::getInstance()->getConfigFile().getVar("DatabaseDirectory").asString(0), true);
|
|
|
|
|
nlinfo("DatabaseDirectory: '%s'", DatabaseDirectory.c_str());
|
|
|
|
|
|
|
|
|
|
doDirectory(SrcDirectoryRecursive);
|
|
|
|
|
|
|
|
|
|
PIPELINE::IPipelineInterface::getInstance()->endedRunnableTask();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
CMaxRewriteInitCacheCommand s_MaxRewriteInitCacheCommand;
|
|
|
|
|
|
|
|
|
|
} /* anonymous namespace */
|
|
|
|
|
|
|
|
|
|
} /* namespace PIPELINE */
|
|
|
|
|
|
|
|
|
|
NLMISC_CATEGORISED_COMMAND(max, maxRewriteInitCache, "Find all .tga, .png and .max files", "<srcDirectoryRecursive>")
|
|
|
|
|
{
|
|
|
|
|
if(args.size() != 1) return false;
|
|
|
|
|
PIPELINE::s_MaxRewriteInitCacheCommand.Log = &log;
|
|
|
|
|
PIPELINE::s_MaxRewriteInitCacheCommand.SrcDirectoryRecursive = args[0];
|
|
|
|
|
if (!PIPELINE::IPipelineInterface::getInstance()->tryRunnableTask("COMMAND_MAX_REWRITE_INIT_CACHE", &PIPELINE::s_MaxRewriteInitCacheCommand))
|
|
|
|
|
{
|
|
|
|
|
log.displayNL("Busy.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NLMISC_CATEGORISED_COMMAND(max, maxRewritePaths, "Rewrite all paths to .tga, .png and .max files found in a max file", "<srcDirectoryRecursive>")
|
|
|
|
|
{
|
|
|
|
|
if(args.size() != 1) return false;
|
|
|
|
|