diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 077b62be1b..fc9ce417c7 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -777,6 +777,39 @@ void MwIniImporter::insertMultistrmap(multistrmap &cfg, std::string key, std::st cfg[key].push_back(value); } +void MwIniImporter::importArchives(multistrmap &cfg, multistrmap &ini) { + std::vector archives; + std::string baseArchive("Archives:Archive "); + std::string archive; + + // Search archives listed in ini file + multistrmap::iterator it = ini.begin(); + for(int i=0; it != ini.end(); i++) { + archive = baseArchive; + archive.append(this->numberToString(i)); + + it = ini.find(archive); + if(it == ini.end()) { + break; + } + + for(std::vector::iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) { + archives.push_back(*entry); + } + } + + cfg.erase("fallback-archive"); + cfg.insert( std::make_pair > ("fallback-archive", std::vector())); + + // Add Morrowind.bsa by default, since Vanilla loads this archive even if it + // does not appears in the ini file + cfg["fallback-archive"].push_back("Morrowind.bsa"); + + for(std::vector::iterator it=archives.begin(); it!=archives.end(); ++it) { + cfg["fallback-archive"].push_back(*it); + } +} + void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) { std::vector esmFiles; std::vector espFiles; @@ -794,7 +827,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) { } for(std::vector::iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) { - std::string filetype(entry->substr(entry->length()-4, 3)); + std::string filetype(entry->substr(entry->length()-3)); Misc::StringUtils::toLower(filetype); if(filetype.compare("esm") == 0) { diff --git a/apps/mwiniimporter/importer.hpp b/apps/mwiniimporter/importer.hpp index c87fd3e164..6b99810bc3 100644 --- a/apps/mwiniimporter/importer.hpp +++ b/apps/mwiniimporter/importer.hpp @@ -23,6 +23,7 @@ class MwIniImporter { void merge(multistrmap &cfg, multistrmap &ini); void mergeFallback(multistrmap &cfg, multistrmap &ini); void importGameFiles(multistrmap &cfg, multistrmap &ini); + void importArchives(multistrmap &cfg, multistrmap &ini); void writeToFile(boost::iostreams::stream &out, multistrmap &cfg); private: diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index e90f26dd2c..c9d88c0bba 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -18,6 +18,7 @@ int main(int argc, char *argv[]) { ("cfg,c", bpo::value(), "openmw.cfg file") ("output,o", bpo::value()->default_value(""), "openmw.cfg file") ("game-files,g", "import esm and esp files") + ("no-archives,A", "disable bsa archives import") ("encoding,e", bpo::value()-> default_value("win1252"), "Character encoding used in OpenMW game messages:\n" "\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n" @@ -76,6 +77,10 @@ int main(int argc, char *argv[]) { importer.importGameFiles(cfg, ini); } + if(!vm.count("no-archives")) { + importer.importArchives(cfg, ini); + } + std::cout << "write to: " << outputFile << std::endl; boost::iostreams::stream file(outputFile); importer.writeToFile(file, cfg); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 2926b76f8b..be61dc3461 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -304,26 +304,26 @@ namespace MWWorld { return mGlobalVariables->getGlobals(); } - + std::string World::getCurrentCellName () const { std::string name; Ptr::CellStore *cell = mWorldScene->getCurrentCell(); if (cell->mCell->isExterior()) - { + { if (cell->mCell->mName != "") - { + { name = cell->mCell->mName; - } - else - { + } + else + { const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().get().search(cell->mCell->mRegion); if (region) name = region->mName; else - { + { const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().get().search("sDefaultCellname"); @@ -333,13 +333,13 @@ namespace MWWorld name = "Wilderness"; } - } - } - else - { + } + } + else + { name = cell->mCell->mName; - } - + } + return name; } @@ -428,12 +428,12 @@ namespace MWWorld if (!reference.getRefData().isEnabled()) { reference.getRefData().enable(); - + if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end() && reference.getRefData().getCount()) mWorldScene->addObjectToScene (reference); } } - + void World::removeContainerScripts(const Ptr& reference) { if( reference.getTypeName()==typeid (ESM::Container).name() || @@ -458,7 +458,7 @@ namespace MWWorld if (reference.getRefData().isEnabled()) { reference.getRefData().disable(); - + if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end() && reference.getRefData().getCount()) mWorldScene->removeObjectFromScene (reference); } @@ -689,13 +689,14 @@ namespace MWWorld void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z) { ESM::Position &pos = ptr.getRefData().getPosition(); - pos.pos[0] = x, pos.pos[1] = y, pos.pos[2] = z; + pos.pos[0] = x; + pos.pos[1] = y; + pos.pos[2] = z; Ogre::Vector3 vec(x, y, z); CellStore *currCell = ptr.getCell(); bool isPlayer = ptr == mPlayer->getPlayer(); bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer; - if (*currCell != newCell) { @@ -710,7 +711,8 @@ namespace MWWorld int cellY = newCell.mCell->getGridY(); mWorldScene->changeCell(cellX, cellY, pos, false); } - else { + else + { if (!mWorldScene->isCellActive(*currCell)) copyObjectToCell(ptr, newCell, pos); else if (!mWorldScene->isCellActive(newCell)) @@ -718,6 +720,7 @@ namespace MWWorld MWWorld::Class::get(ptr).copyToCell(ptr, newCell); mWorldScene->removeObjectFromScene(ptr); mLocalScripts.remove(ptr); + removeContainerScripts (ptr); haveToMove = false; } else @@ -725,10 +728,18 @@ namespace MWWorld MWWorld::Ptr copy = MWWorld::Class::get(ptr).copyToCell(ptr, newCell); - addContainerScripts(copy, &newCell); - mRendering->moveObjectToCell(copy, vec, currCell); + std::string script = + MWWorld::Class::get(ptr).getScript(ptr); + if (!script.empty()) + { + mLocalScripts.remove(ptr); + removeContainerScripts (ptr); + mLocalScripts.add(script, copy); + addContainerScripts (copy, &newCell); + } + if (MWWorld::Class::get(ptr).isActor()) { MWBase::MechanicsManager *mechMgr = @@ -737,16 +748,6 @@ namespace MWWorld mechMgr->removeActor(ptr); mechMgr->addActor(copy); } - else - { - std::string script = - MWWorld::Class::get(ptr).getScript(ptr); - if (!script.empty()) - { - mLocalScripts.remove(ptr); - mLocalScripts.add(script, copy); - } - } } ptr.getRefData().setCount(0); } @@ -1276,8 +1277,8 @@ namespace MWWorld void World::PCDropped (const Ptr& item) { std::string script = MWWorld::Class::get(item).getScript(item); - - // Set OnPCDrop Variable on item's script, if it has a script with that variable declared + + // Set OnPCDrop Variable on item's script, if it has a script with that variable declared if(script != "") item.mRefData->getLocals().setVarByInt(script, "onpcdrop", 1); } @@ -1307,7 +1308,7 @@ namespace MWWorld Ptr dropped = copyObjectToCell(object, *cell, pos); PCDropped(dropped); object.getRefData().setCount(0); - + return true; } @@ -1322,7 +1323,7 @@ namespace MWWorld return true; } - + Ptr World::copyObjectToCell(const Ptr &object, CellStore &cell, const ESM::Position &pos) { /// \todo add searching correct cell for position specified