diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6a186b92e..8eaa9d614 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("Meshes\\joker\\bald_MJ_hat.nif"); //w/W_6th_Hammer.NIF + cellRender.insertMesh("MeSHes\\1\\red_MJ_hat_org.NIF"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 5b5ff6511..13858d405 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -33,12 +33,21 @@ using namespace Ogre; using namespace Mangle::Stream; +struct ciLessBoost : std::binary_function +{ + bool operator() (const std::string & s1, const std::string & s2) const { + //case insensitive version of is_less + return lexicographical_compare(s1, s2, boost::algorithm::is_iless()); + } +}; + /// An OGRE Archive wrapping a BSAFile archive class DirArchive: public Ogre::FileSystemArchive { boost::filesystem::path currentdir; - std::map > m; + std::map, ciLessBoost> m; + int cutoff; public: @@ -46,6 +55,9 @@ class DirArchive: public Ogre::FileSystemArchive : FileSystemArchive(name, "Dir") { mType = "Dir"; currentdir = name; + std::string s = name; + cutoff = s.size() + 1; + //std::cout << "Cut off:" << cutoff; populateMap(currentdir); @@ -64,12 +76,26 @@ class DirArchive: public Ogre::FileSystemArchive f = *dir_iter; std::string s = f.string(); - filesind.push_back(s); - //std::cout << "File: " << s << "\n"; + + std::string small; + if(cutoff < s.size()) + small = s.substr(cutoff, s.size() - cutoff); + else + small = s.substr(cutoff - 1, s.size() - cutoff); + + filesind.push_back(small); + //std::cout << "File: " << small << "f\n"; } } - m[d.string()] = filesind; - std::cout << "Directory: " << d.string() << filesind.size() << "\n"; + std::string small; + std::string original = d.string(); + if(cutoff < original.size()) + small = original.substr(cutoff, original.size() - cutoff); + else + small = original.substr(cutoff - 1, original.size() - cutoff); + boost::filesystem::path smallp = small; + m[smallp.string()] = filesind; + //std::cout << "Directory: " << smallp.string() << " " << filesind.size() << "\n"; } @@ -80,6 +106,7 @@ class DirArchive: public Ogre::FileSystemArchive void unload() {} bool exists(const String& filename) { + //std::cout << "exists\n"; //String s = filename; //FileSystemArchive::findFiles(s, true, false, filenames.getPointer(), f.getPointer()); // std::cout << "Filenames" << filenames.useCount() << "\n"; @@ -106,21 +133,40 @@ class DirArchive: public Ogre::FileSystemArchive if(copy.at(i) == '/' || copy.at(i) == '\\') break; } - std::string folder; - folder = copy.substr(0, i); + 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::transform(file.begin(), file.end(), file.begin(), tolower); boost::filesystem::path folderpath = folder; - std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); + std::vector current = m[folderpath.string()]; + + for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) + { + std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash + std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); + if(file.compare(loopfile) == 0){ + std::cout << "Loopfile:" << loopfile << "\n"; + return FileSystemArchive::exists(*iter); + } + } + + //std::cout << "Filename:" << file << "\n"; + //std::cout << "Full:" << p.string() << "\n"; + //std::cout << "Current:" << folder << "size: " << current.size() << "\n"; + //std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); return FileSystemArchive::exists(copy); } DataStreamPtr open(const String& filename, bool readonly = true) const { - std::string copy = filename; - if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32){ - //std::cout << "In Open\n"; + std::map, ciLessBoost> mlocal = m; + //std::cout << "Open\n"; + std::string copy = filename; + if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32) + { + for (int i = 0; i < filename.size(); i++) { if(copy.at(i) == '\\' ){ @@ -128,6 +174,39 @@ class DirArchive: public Ogre::FileSystemArchive } } } + boost::filesystem::path p = copy; + + int last = copy.size() - 1; + int i = last; + + for (;last >= 0; i--) + { + if(copy.at(i) == '/' || copy.at(i) == '\\') + 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 + + std::transform(file.begin(), file.end(), file.begin(), tolower); + boost::filesystem::path folderpath = folder; + std::vector current = mlocal[folderpath.string()]; + + for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) + { + std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash + std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); + if(file.compare(loopfile) == 0){ + std::cout << "Loopfile:" << loopfile << "\n"; + return FileSystemArchive::open(*iter, readonly); + } + } + + //std::cout << "Filename:" << file << "\n"; + //std::cout << "Full:" << p.string() << "\n"; + //std::cout << "Current:" << folder << "size: " << current.size() << "\n"; + //std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); + return FileSystemArchive::open(copy, readonly); } diff --git a/components/bsa/bsa_archive.hpp b/components/bsa/bsa_archive.hpp index 405856e8c..a72f638e3 100644 --- a/components/bsa/bsa_archive.hpp +++ b/components/bsa/bsa_archive.hpp @@ -23,6 +23,8 @@ #include #include +#include +#include #ifndef _BSA_ARCHIVE_H_ #define _BSA_ARCHIVE_H_