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);
|
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) {
|
void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) {
|
||||||
std::vector<std::string> esmFiles;
|
std::vector<std::string> esmFiles;
|
||||||
std::vector<std::string> espFiles;
|
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) {
|
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);
|
Misc::StringUtils::toLower(filetype);
|
||||||
|
|
||||||
if(filetype.compare("esm") == 0) {
|
if(filetype.compare("esm") == 0) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ class MwIniImporter {
|
||||||
void merge(multistrmap &cfg, multistrmap &ini);
|
void merge(multistrmap &cfg, multistrmap &ini);
|
||||||
void mergeFallback(multistrmap &cfg, multistrmap &ini);
|
void mergeFallback(multistrmap &cfg, multistrmap &ini);
|
||||||
void importGameFiles(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);
|
void writeToFile(boost::iostreams::stream<boost::iostreams::file_sink> &out, multistrmap &cfg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -18,6 +18,7 @@ int main(int argc, char *argv[]) {
|
||||||
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
|
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
|
||||||
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
|
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
|
||||||
("game-files,g", "import esm and esp files")
|
("game-files,g", "import esm and esp files")
|
||||||
|
("no-archives,A", "disable bsa archives import")
|
||||||
("encoding,e", bpo::value<std::string>()-> default_value("win1252"),
|
("encoding,e", bpo::value<std::string>()-> default_value("win1252"),
|
||||||
"Character encoding used in OpenMW game messages:\n"
|
"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"
|
"\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);
|
importer.importGameFiles(cfg, ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!vm.count("no-archives")) {
|
||||||
|
importer.importArchives(cfg, ini);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "write to: " << outputFile << std::endl;
|
std::cout << "write to: " << outputFile << std::endl;
|
||||||
boost::iostreams::stream<boost::iostreams::file_sink> file(outputFile);
|
boost::iostreams::stream<boost::iostreams::file_sink> file(outputFile);
|
||||||
importer.writeToFile(file, cfg);
|
importer.writeToFile(file, cfg);
|
||||||
|
|
|
@ -304,26 +304,26 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
return mGlobalVariables->getGlobals();
|
return mGlobalVariables->getGlobals();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string World::getCurrentCellName () const
|
std::string World::getCurrentCellName () const
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
Ptr::CellStore *cell = mWorldScene->getCurrentCell();
|
Ptr::CellStore *cell = mWorldScene->getCurrentCell();
|
||||||
if (cell->mCell->isExterior())
|
if (cell->mCell->isExterior())
|
||||||
{
|
{
|
||||||
if (cell->mCell->mName != "")
|
if (cell->mCell->mName != "")
|
||||||
{
|
{
|
||||||
name = cell->mCell->mName;
|
name = cell->mCell->mName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ESM::Region* region =
|
const ESM::Region* region =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search(cell->mCell->mRegion);
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search(cell->mCell->mRegion);
|
||||||
if (region)
|
if (region)
|
||||||
name = region->mName;
|
name = region->mName;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ESM::GameSetting *setting =
|
const ESM::GameSetting *setting =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search("sDefaultCellname");
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search("sDefaultCellname");
|
||||||
|
|
||||||
|
@ -333,13 +333,13 @@ namespace MWWorld
|
||||||
name = "Wilderness";
|
name = "Wilderness";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name = cell->mCell->mName;
|
name = cell->mCell->mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,12 +428,12 @@ namespace MWWorld
|
||||||
if (!reference.getRefData().isEnabled())
|
if (!reference.getRefData().isEnabled())
|
||||||
{
|
{
|
||||||
reference.getRefData().enable();
|
reference.getRefData().enable();
|
||||||
|
|
||||||
if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end() && reference.getRefData().getCount())
|
if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end() && reference.getRefData().getCount())
|
||||||
mWorldScene->addObjectToScene (reference);
|
mWorldScene->addObjectToScene (reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::removeContainerScripts(const Ptr& reference)
|
void World::removeContainerScripts(const Ptr& reference)
|
||||||
{
|
{
|
||||||
if( reference.getTypeName()==typeid (ESM::Container).name() ||
|
if( reference.getTypeName()==typeid (ESM::Container).name() ||
|
||||||
|
@ -458,7 +458,7 @@ namespace MWWorld
|
||||||
if (reference.getRefData().isEnabled())
|
if (reference.getRefData().isEnabled())
|
||||||
{
|
{
|
||||||
reference.getRefData().disable();
|
reference.getRefData().disable();
|
||||||
|
|
||||||
if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end() && reference.getRefData().getCount())
|
if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end() && reference.getRefData().getCount())
|
||||||
mWorldScene->removeObjectFromScene (reference);
|
mWorldScene->removeObjectFromScene (reference);
|
||||||
}
|
}
|
||||||
|
@ -689,13 +689,14 @@ namespace MWWorld
|
||||||
void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z)
|
void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z)
|
||||||
{
|
{
|
||||||
ESM::Position &pos = ptr.getRefData().getPosition();
|
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);
|
Ogre::Vector3 vec(x, y, z);
|
||||||
|
|
||||||
CellStore *currCell = ptr.getCell();
|
CellStore *currCell = ptr.getCell();
|
||||||
bool isPlayer = ptr == mPlayer->getPlayer();
|
bool isPlayer = ptr == mPlayer->getPlayer();
|
||||||
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
|
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
|
||||||
|
|
||||||
|
|
||||||
if (*currCell != newCell)
|
if (*currCell != newCell)
|
||||||
{
|
{
|
||||||
|
@ -710,7 +711,8 @@ namespace MWWorld
|
||||||
int cellY = newCell.mCell->getGridY();
|
int cellY = newCell.mCell->getGridY();
|
||||||
mWorldScene->changeCell(cellX, cellY, pos, false);
|
mWorldScene->changeCell(cellX, cellY, pos, false);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
if (!mWorldScene->isCellActive(*currCell))
|
if (!mWorldScene->isCellActive(*currCell))
|
||||||
copyObjectToCell(ptr, newCell, pos);
|
copyObjectToCell(ptr, newCell, pos);
|
||||||
else if (!mWorldScene->isCellActive(newCell))
|
else if (!mWorldScene->isCellActive(newCell))
|
||||||
|
@ -718,6 +720,7 @@ namespace MWWorld
|
||||||
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
||||||
mWorldScene->removeObjectFromScene(ptr);
|
mWorldScene->removeObjectFromScene(ptr);
|
||||||
mLocalScripts.remove(ptr);
|
mLocalScripts.remove(ptr);
|
||||||
|
removeContainerScripts (ptr);
|
||||||
haveToMove = false;
|
haveToMove = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -725,10 +728,18 @@ namespace MWWorld
|
||||||
MWWorld::Ptr copy =
|
MWWorld::Ptr copy =
|
||||||
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
||||||
|
|
||||||
addContainerScripts(copy, &newCell);
|
|
||||||
|
|
||||||
mRendering->moveObjectToCell(copy, vec, currCell);
|
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())
|
if (MWWorld::Class::get(ptr).isActor())
|
||||||
{
|
{
|
||||||
MWBase::MechanicsManager *mechMgr =
|
MWBase::MechanicsManager *mechMgr =
|
||||||
|
@ -737,16 +748,6 @@ namespace MWWorld
|
||||||
mechMgr->removeActor(ptr);
|
mechMgr->removeActor(ptr);
|
||||||
mechMgr->addActor(copy);
|
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);
|
ptr.getRefData().setCount(0);
|
||||||
}
|
}
|
||||||
|
@ -1276,8 +1277,8 @@ namespace MWWorld
|
||||||
void World::PCDropped (const Ptr& item)
|
void World::PCDropped (const Ptr& item)
|
||||||
{
|
{
|
||||||
std::string script = MWWorld::Class::get(item).getScript(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 != "")
|
if(script != "")
|
||||||
item.mRefData->getLocals().setVarByInt(script, "onpcdrop", 1);
|
item.mRefData->getLocals().setVarByInt(script, "onpcdrop", 1);
|
||||||
}
|
}
|
||||||
|
@ -1307,7 +1308,7 @@ namespace MWWorld
|
||||||
Ptr dropped = copyObjectToCell(object, *cell, pos);
|
Ptr dropped = copyObjectToCell(object, *cell, pos);
|
||||||
PCDropped(dropped);
|
PCDropped(dropped);
|
||||||
object.getRefData().setCount(0);
|
object.getRefData().setCount(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1322,7 +1323,7 @@ namespace MWWorld
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Ptr World::copyObjectToCell(const Ptr &object, CellStore &cell, const ESM::Position &pos)
|
Ptr World::copyObjectToCell(const Ptr &object, CellStore &cell, const ESM::Position &pos)
|
||||||
{
|
{
|
||||||
/// \todo add searching correct cell for position specified
|
/// \todo add searching correct cell for position specified
|
||||||
|
|
Loading…
Reference in a new issue