mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 19:53:53 +00:00
Leading slashes now work, efficiency changes
This commit is contained in:
parent
45453fd7a9
commit
4d31ca2c86
2 changed files with 57 additions and 25 deletions
|
@ -118,7 +118,7 @@ namespace MWClass
|
||||||
Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75);
|
Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75);
|
||||||
|
|
||||||
if (groin){
|
if (groin){
|
||||||
cellRender.insertMesh("MeSHes\\1\\red_MJ_hat_org.NIF"); //w/W_6th_Hammer.NIF
|
cellRender.insertMesh("MeSHes\\1\\red_MJ_hat_org.NIf"); //w/W_6th_Hammer.NIF
|
||||||
//bald_MJ_hat.NIF
|
//bald_MJ_hat.NIF
|
||||||
cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers);
|
cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers);
|
||||||
addresses2[numbers] = npcName + "groin";
|
addresses2[numbers] = npcName + "groin";
|
||||||
|
|
|
@ -49,6 +49,18 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
std::map<std::string, std::vector<std::string>, ciLessBoost> m;
|
std::map<std::string, std::vector<std::string>, ciLessBoost> m;
|
||||||
int cutoff;
|
int cutoff;
|
||||||
|
|
||||||
|
bool comparePortion(std::string file1, std::string file2, int start, int size) const
|
||||||
|
{
|
||||||
|
for(int i = start; i < start+size; i++)
|
||||||
|
{
|
||||||
|
char one = file1.at(i);
|
||||||
|
char two = file2.at(i);
|
||||||
|
if(tolower(one) != tolower(two) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DirArchive(const String& name)
|
DirArchive(const String& name)
|
||||||
|
@ -93,8 +105,8 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
small = original.substr(cutoff, original.size() - cutoff);
|
small = original.substr(cutoff, original.size() - cutoff);
|
||||||
else
|
else
|
||||||
small = original.substr(cutoff - 1, original.size() - cutoff);
|
small = original.substr(cutoff - 1, original.size() - cutoff);
|
||||||
boost::filesystem::path smallp = small;
|
//boost::filesystem::path smallp = small;
|
||||||
m[smallp.string()] = filesind;
|
m[small] = filesind;
|
||||||
//std::cout << "Directory: " << smallp.string() << " " << filesind.size() << "\n";
|
//std::cout << "Directory: " << smallp.string() << " " << filesind.size() << "\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,6 +125,7 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
|
|
||||||
|
|
||||||
std::string copy = filename;
|
std::string copy = filename;
|
||||||
|
|
||||||
if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32)
|
if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -123,7 +136,17 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boost::filesystem::path p = copy;
|
|
||||||
|
if(copy.at(0) == '\\' || copy.at(0) == '/')
|
||||||
|
{
|
||||||
|
//std::cout << "Before:" << copy.size() << "\n";
|
||||||
|
copy.erase(0, 1);
|
||||||
|
//std::cout << "The copy" << copy << "\n";
|
||||||
|
//std::cout << "After:" << copy.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//boost::filesystem::path p = copy;
|
||||||
|
|
||||||
int last = copy.size() - 1;
|
int last = copy.size() - 1;
|
||||||
int i = last;
|
int i = last;
|
||||||
|
@ -134,19 +157,20 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash
|
//std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash
|
||||||
std::string folder = copy.substr(0, i); //folder with no slash
|
std::string folder = copy.substr(0, i); //folder with no slash
|
||||||
|
|
||||||
std::transform(file.begin(), file.end(), file.begin(), tolower);
|
//std::transform(file.begin(), file.end(), file.begin(), tolower);
|
||||||
boost::filesystem::path folderpath = folder;
|
//boost::filesystem::path folderpath = folder;
|
||||||
std::vector<std::string> current = m[folderpath.string()];
|
std::vector<std::string> current = m[folder];
|
||||||
|
|
||||||
for(std::vector<std::string>::iterator iter = current.begin(); iter != current.end(); iter++)
|
for(std::vector<std::string>::iterator iter = current.begin(); iter != current.end(); iter++)
|
||||||
{
|
{
|
||||||
std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash
|
//std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash
|
||||||
std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower);
|
//std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower);
|
||||||
if(file.compare(loopfile) == 0){
|
//std::string now = *iter;
|
||||||
std::cout << "Loopfile:" << loopfile << "\n";
|
if(comparePortion(*iter, copy, i + 1, copy.size() - i -1) == true){
|
||||||
|
//std::cout << "Loopfile:" << copy << "\n";
|
||||||
return FileSystemArchive::exists(*iter);
|
return FileSystemArchive::exists(*iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +180,7 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
//std::cout << "Current:" << folder << "size: " << current.size() << "\n";
|
//std::cout << "Current:" << folder << "size: " << current.size() << "\n";
|
||||||
//std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string();
|
//std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string();
|
||||||
|
|
||||||
return FileSystemArchive::exists(copy);
|
return false;//FileSystemArchive::exists(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataStreamPtr open(const String& filename, bool readonly = true) const
|
DataStreamPtr open(const String& filename, bool readonly = true) const
|
||||||
|
@ -164,6 +188,7 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
std::map<std::string, std::vector<std::string>, ciLessBoost> mlocal = m;
|
std::map<std::string, std::vector<std::string>, ciLessBoost> mlocal = m;
|
||||||
//std::cout << "Open\n";
|
//std::cout << "Open\n";
|
||||||
std::string copy = filename;
|
std::string copy = filename;
|
||||||
|
|
||||||
if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32)
|
if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -174,7 +199,15 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boost::filesystem::path p = copy;
|
|
||||||
|
if(copy.at(0) == '\\' || copy.at(0) == '/')
|
||||||
|
{
|
||||||
|
//std::cout << "Before:" << copy.size() << "\n";
|
||||||
|
copy.erase(0, 1);
|
||||||
|
//std::cout << "The copy" << copy << "\n";
|
||||||
|
//std::cout << "After:" << copy.size();
|
||||||
|
}
|
||||||
|
//boost::filesystem::path p = copy;
|
||||||
|
|
||||||
int last = copy.size() - 1;
|
int last = copy.size() - 1;
|
||||||
int i = last;
|
int i = last;
|
||||||
|
@ -185,19 +218,18 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash
|
std::string folder = copy.substr(0, i); //folder with no slash //folder with no slash
|
||||||
std::string folder = copy.substr(0, i); //folder with no slash
|
|
||||||
|
|
||||||
std::transform(file.begin(), file.end(), file.begin(), tolower);
|
//std::transform(file.begin(), file.end(), file.begin(), tolower);
|
||||||
boost::filesystem::path folderpath = folder;
|
//boost::filesystem::path folderpath = folder;
|
||||||
std::vector<std::string> current = mlocal[folderpath.string()];
|
std::vector<std::string> current = mlocal[folder];
|
||||||
|
|
||||||
for(std::vector<std::string>::iterator iter = current.begin(); iter != current.end(); iter++)
|
for(std::vector<std::string>::iterator iter = current.begin(); iter != current.end(); iter++)
|
||||||
{
|
{
|
||||||
std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash
|
//std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash
|
||||||
std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower);
|
//std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower);
|
||||||
if(file.compare(loopfile) == 0){
|
if(comparePortion(*iter, copy, i + 1, copy.size() - i -1) == true){
|
||||||
std::cout << "Loopfile:" << loopfile << "\n";
|
//std::cout << "Loopfile:" << copy << "\n";
|
||||||
return FileSystemArchive::open(*iter, readonly);
|
return FileSystemArchive::open(*iter, readonly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,8 +238,8 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
//std::cout << "Full:" << p.string() << "\n";
|
//std::cout << "Full:" << p.string() << "\n";
|
||||||
//std::cout << "Current:" << folder << "size: " << current.size() << "\n";
|
//std::cout << "Current:" << folder << "size: " << current.size() << "\n";
|
||||||
//std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string();
|
//std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string();
|
||||||
|
DataStreamPtr p;
|
||||||
return FileSystemArchive::open(copy, readonly);
|
return p;//FileSystemArchive::open(copy, readonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue