mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 10:23:53 +00:00
Merge remote-tracking branch 'potatoesmaster/importer' into next
Conflicts: apps/openmw/mwworld/worldimp.cpp
This commit is contained in:
commit
43912f927a
4 changed files with 76 additions and 36 deletions
|
@ -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<std::string> 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<std::string>::iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
|
||||
archives.push_back(*entry);
|
||||
}
|
||||
}
|
||||
|
||||
cfg.erase("fallback-archive");
|
||||
cfg.insert( std::make_pair<std::string, std::vector<std::string> > ("fallback-archive", std::vector<std::string>()));
|
||||
|
||||
// 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<std::string>::iterator it=archives.begin(); it!=archives.end(); ++it) {
|
||||
cfg["fallback-archive"].push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) {
|
||||
std::vector<std::string> esmFiles;
|
||||
std::vector<std::string> espFiles;
|
||||
|
@ -794,7 +827,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) {
|
|||
}
|
||||
|
||||
for(std::vector<std::string>::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) {
|
||||
|
|
|
@ -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<boost::iostreams::file_sink> &out, multistrmap &cfg);
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,6 +18,7 @@ int main(int argc, char *argv[]) {
|
|||
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
|
||||
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
|
||||
("game-files,g", "import esm and esp files")
|
||||
("no-archives,A", "disable bsa archives import")
|
||||
("encoding,e", bpo::value<std::string>()-> 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<boost::iostreams::file_sink> file(outputFile);
|
||||
importer.writeToFile(file, cfg);
|
||||
|
|
|
@ -689,14 +689,15 @@ 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)
|
||||
{
|
||||
removeContainerScripts(ptr);
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue