Revert "Merge remote-tracking branch 'mark76/multiple_esm_esp' into nif-cleanup"

This reverts commit 546b640022, reversing
changes made to fcaa8aae06.
This commit is contained in:
scrawl 2012-07-23 15:36:12 +02:00
parent f8d6a36196
commit 1fef086088
12 changed files with 48 additions and 149 deletions

View file

@ -207,32 +207,18 @@ void OMW::Engine::setCell (const std::string& cellName)
// Set master file (esm) // Set master file (esm)
// - If the given name does not have an extension, ".esm" is added automatically // - If the given name does not have an extension, ".esm" is added automatically
// - Currently OpenMW only supports one master at the same time.
void OMW::Engine::addMaster (const std::string& master) void OMW::Engine::addMaster (const std::string& master)
{ {
mMaster.push_back(master); assert (mMaster.empty());
std::string &str = mMaster.back(); mMaster = master;
// Append .esm if not already there // Append .esm if not already there
std::string::size_type sep = str.find_last_of ("."); std::string::size_type sep = mMaster.find_last_of (".");
if (sep == std::string::npos) if (sep == std::string::npos)
{ {
str += ".esm"; mMaster += ".esm";
}
}
// Add plugin file (esp)
void OMW::Engine::addPlugin (const std::string& plugin)
{
mPlugins.push_back(plugin);
std::string &str = mPlugins.back();
// Append .esp if not already there
std::string::size_type sep = str.find_last_of (".");
if (sep == std::string::npos)
{
str += ".esp";
} }
} }
@ -333,8 +319,8 @@ void OMW::Engine::go()
MWGui::CursorReplace replacer; MWGui::CursorReplace replacer;
// Create the world // Create the world
mEnvironment.setWorld( new MWWorld::World (*mOgre, mFileCollections, mMaster, mPlugins, mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster,
mResDir, mNewGame, mEncoding, mFallbackMap) ); mResDir, mNewGame, mEncoding, mFallbackMap));
// Create window manager - this manages all the MW-specific GUI windows // Create window manager - this manages all the MW-specific GUI windows
MWScript::registerExtensions (mExtensions); MWScript::registerExtensions (mExtensions);

View file

@ -64,8 +64,7 @@ namespace OMW
boost::filesystem::path mResDir; boost::filesystem::path mResDir;
OEngine::Render::OgreRenderer *mOgre; OEngine::Render::OgreRenderer *mOgre;
std::string mCellName; std::string mCellName;
std::vector<std::string> mMaster; std::string mMaster;
std::vector<std::string> mPlugins;
int mFpsLevel; int mFpsLevel;
bool mDebug; bool mDebug;
bool mVerboseScripts; bool mVerboseScripts;
@ -121,12 +120,9 @@ namespace OMW
/// Set master file (esm) /// Set master file (esm)
/// - If the given name does not have an extension, ".esm" is added automatically /// - If the given name does not have an extension, ".esm" is added automatically
/// - Currently OpenMW only supports one master at the same time.
void addMaster(const std::string& master); void addMaster(const std::string& master);
/// Same as "addMaster", but for plugin files (esp)
/// - If the given name does not have an extension, ".esp" is added automatically
void addPlugin(const std::string& plugin);
/// Enable fps counter /// Enable fps counter
void showFPS(int level); void showFPS(int level);

View file

@ -224,23 +224,19 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
master.push_back("Morrowind"); master.push_back("Morrowind");
} }
StringsVector plugin = variables["plugin"].as<StringsVector>(); if (master.size() > 1)
int cnt = master.size() + plugin.size();
if (cnt > 255)
{
std::cerr
<< "Error: Trying to load more than 255 master and plugin files! This will break all combaibility and is not supported!"
<< std::endl;
return false;
}
for (std::vector<std::string>::size_type i = 0; i < master.size(); i++)
{ {
engine.addMaster(master[i]); std::cout
} << "Ignoring all but the first master file (multiple master files not yet supported)."
for (std::vector<std::string>::size_type i = 0; i < plugin.size(); i++) << std::endl;
{ }
engine.addPlugin(plugin[i]); engine.addMaster(master[0]);
}
StringsVector plugin = variables["plugin"].as<StringsVector>();
if (!plugin.empty())
{
std::cout << "Ignoring plugin files (plugins not yet supported)." << std::endl;
}
// startup-settings // startup-settings
engine.setCell(variables["start"].as<std::string>()); engine.setCell(variables["start"].as<std::string>());

View file

@ -141,7 +141,7 @@ namespace MWRender
std::map<uint16_t, int> indexes; std::map<uint16_t, int> indexes;
initTerrainTextures(&terrainData, cellX, cellY, initTerrainTextures(&terrainData, cellX, cellY,
x * numTextures, y * numTextures, x * numTextures, y * numTextures,
numTextures, indexes, land->plugin); numTextures, indexes);
if (mTerrainGroup.getTerrain(terrainX, terrainY) == NULL) if (mTerrainGroup.getTerrain(terrainX, terrainY) == NULL)
{ {
@ -200,14 +200,8 @@ namespace MWRender
void TerrainManager::initTerrainTextures(Terrain::ImportData* terrainData, void TerrainManager::initTerrainTextures(Terrain::ImportData* terrainData,
int cellX, int cellY, int cellX, int cellY,
int fromX, int fromY, int size, int fromX, int fromY, int size,
std::map<uint16_t, int>& indexes, std::map<uint16_t, int>& indexes)
size_t plugin)
{ {
// FIXME: In a multiple esm configuration, we have multiple palettes. Since this code
// crosses cell boundaries, we no longer have a unique terrain palette. Instead, we need
// to adopt the following code for a dynamic palette. And this is evil - the current design
// does not work well for this task...
assert(terrainData != NULL && "Must have valid terrain data"); assert(terrainData != NULL && "Must have valid terrain data");
assert(fromX >= 0 && fromY >= 0 && assert(fromX >= 0 && fromY >= 0 &&
"Can't get a terrain texture on terrain outside the current cell"); "Can't get a terrain texture on terrain outside the current cell");
@ -220,16 +214,12 @@ namespace MWRender
// //
//If we don't sort the ltex indexes, the splatting order may differ between //If we don't sort the ltex indexes, the splatting order may differ between
//cells which may lead to inconsistent results when shading between cells //cells which may lead to inconsistent results when shading between cells
int num = MWBase::Environment::get().getWorld()->getStore().landTexts.getSizePlugin(plugin);
std::set<uint16_t> ltexIndexes; std::set<uint16_t> ltexIndexes;
for ( int y = fromY - 1; y < fromY + size + 1; y++ ) for ( int y = fromY - 1; y < fromY + size + 1; y++ )
{ {
for ( int x = fromX - 1; x < fromX + size + 1; x++ ) for ( int x = fromX - 1; x < fromX + size + 1; x++ )
{ {
int idx = getLtexIndexAt(cellX, cellY, x, y); ltexIndexes.insert(getLtexIndexAt(cellX, cellY, x, y));
if (idx > num)
idx = 0;
ltexIndexes.insert(idx);
} }
} }
@ -241,7 +231,7 @@ namespace MWRender
iter != ltexIndexes.end(); iter != ltexIndexes.end();
++iter ) ++iter )
{ {
uint16_t ltexIndex = *iter; const uint16_t ltexIndex = *iter;
//this is the base texture, so we can ignore this at present //this is the base texture, so we can ignore this at present
if ( ltexIndex == baseTexture ) if ( ltexIndex == baseTexture )
{ {
@ -254,10 +244,8 @@ namespace MWRender
{ {
//NB: All vtex ids are +1 compared to the ltex ids //NB: All vtex ids are +1 compared to the ltex ids
/* assert( (int)MWBase::Environment::get().getWorld()->getStore().landTexts.getSize() >= (int)ltexIndex - 1 &&
assert( (int)mEnvironment.mWorld->getStore().landTexts.getSizePlugin(plugin) >= (int)ltexIndex - 1 &&
"LAND.VTEX must be within the bounds of the LTEX array"); "LAND.VTEX must be within the bounds of the LTEX array");
*/
std::string texture; std::string texture;
if ( ltexIndex == 0 ) if ( ltexIndex == 0 )
@ -266,7 +254,7 @@ namespace MWRender
} }
else else
{ {
texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1, plugin)->texture; texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->texture;
//TODO this is needed due to MWs messed up texture handling //TODO this is needed due to MWs messed up texture handling
texture = texture.substr(0, texture.rfind(".")) + ".dds"; texture = texture.substr(0, texture.rfind(".")) + ".dds";
} }

View file

@ -71,14 +71,11 @@ namespace MWRender{
* @param size the size (number of splats) to get * @param size the size (number of splats) to get
* @param indexes a mapping of ltex index to the terrain texture layer that * @param indexes a mapping of ltex index to the terrain texture layer that
* can be used by initTerrainBlendMaps * can be used by initTerrainBlendMaps
* @param plugin the index of the plugin providing the texture list for this
* cell data; required because MW uses texture data on a per-plugin base
*/ */
void initTerrainTextures(Ogre::Terrain::ImportData* terrainData, void initTerrainTextures(Ogre::Terrain::ImportData* terrainData,
int cellX, int cellY, int cellX, int cellY,
int fromX, int fromY, int size, int fromX, int fromY, int size,
std::map<uint16_t, int>& indexes, std::map<uint16_t, int>& indexes);
size_t plugin = 0);
/** /**
* Creates the blend (splatting maps) for the given terrain from the ltex data. * Creates the blend (splatting maps) for the given terrain from the ltex data.

View file

@ -167,8 +167,7 @@ namespace MWWorld
World::World (OEngine::Render::OgreRenderer& renderer, World::World (OEngine::Render::OgreRenderer& renderer,
const Files::Collections& fileCollections, const Files::Collections& fileCollections,
const std::vector<std::string>& master, const std::string& master, const boost::filesystem::path& resDir, bool newGame,
const std::vector<std::string>& plugins, const boost::filesystem::path& resDir, bool newGame,
const std::string& encoding, std::map<std::string,std::string> fallbackMap) const std::string& encoding, std::map<std::string,std::string> fallbackMap)
: mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm), mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm),
@ -181,32 +180,15 @@ namespace MWWorld
mWeatherManager = new MWWorld::WeatherManager(mRendering); mWeatherManager = new MWWorld::WeatherManager(mRendering);
int idx = 0; boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master));
for (std::vector<std::string>::size_type i = 0; i < master.size(); i++, idx++)
{
boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master[i]));
std::cout << "Loading ESM " << masterPath.string() << "\n";
// This parses the ESM file and loads a sample cell std::cout << "Loading ESM " << masterPath.string() << "\n";
mEsm.setEncoding(encoding);
mEsm.open (masterPath.string());
mEsm.setIndex(idx);
mStore.load (mEsm);
}
for (std::vector<std::string>::size_type i = 0; i < plugins.size(); i++, idx++) // This parses the ESM file and loads a sample cell
{ mEsm.setEncoding(encoding);
boost::filesystem::path pluginPath (fileCollections.getCollection (".esp").getPath (plugins[i])); mEsm.open (masterPath.string());
mStore.load (mEsm);
std::cout << "Loading ESP " << pluginPath.string() << "\n";
// This parses the ESP file and loads a sample cell
mEsm.setEncoding(encoding);
mEsm.open (pluginPath.string());
mEsm.setIndex(idx);
mStore.load (mEsm);
}
MWRender::Player* play = &(mRendering->getPlayer()); MWRender::Player* play = &(mRendering->getPlayer());
mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this); mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this);
mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0)); mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0));

View file

@ -93,8 +93,7 @@ namespace MWWorld
World (OEngine::Render::OgreRenderer& renderer, World (OEngine::Render::OgreRenderer& renderer,
const Files::Collections& fileCollections, const Files::Collections& fileCollections,
const std::vector<std::string>& master, const std::string& master, const boost::filesystem::path& resDir, bool newGame,
const std::vector<std::string>& plugins, const boost::filesystem::path& resDir, bool newGame,
const std::string& encoding, std::map<std::string,std::string> fallbackMap); const std::string& encoding, std::map<std::string,std::string> fallbackMap);
virtual ~World(); virtual ~World();

View file

@ -189,14 +189,6 @@ public:
void openRaw(const std::string &file); void openRaw(const std::string &file);
// This is a quick hack for multiple esm/esp files. Each plugin introduces its own
// terrain palette, but ESMReader does not pass a reference to the correct plugin
// to the individual load() methods. This hack allows to pass this reference
// indirectly to the load() method.
int idx;
void setIndex(const int index) {idx = index;}
const int getIndex() {return idx;}
/************************************************************************* /*************************************************************************
* *
* Medium-level reading shortcuts * Medium-level reading shortcuts

View file

@ -23,7 +23,6 @@ Land::~Land()
void Land::load(ESMReader &esm) void Land::load(ESMReader &esm)
{ {
mEsm = &esm; mEsm = &esm;
plugin = mEsm->getIndex();
// Get the grid location // Get the grid location
esm.getSubNameIs("INTV"); esm.getSubNameIs("INTV");

View file

@ -17,7 +17,6 @@ struct Land
int flags; // Only first four bits seem to be used, don't know what int flags; // Only first four bits seem to be used, don't know what
// they mean. // they mean.
int X, Y; // Map coordinates. int X, Y; // Map coordinates.
int plugin; // Plugin index, used to reference the correct material palette.
// File context. This allows the ESM reader to be 'reset' to this // File context. This allows the ESM reader to be 'reset' to this
// location later when we are ready to load the full data set. // location later when we are ready to load the full data set.

View file

@ -26,7 +26,6 @@ namespace ESMS
virtual void load(ESMReader &esm, const std::string &id) = 0; virtual void load(ESMReader &esm, const std::string &id) = 0;
virtual int getSize() = 0; virtual int getSize() = 0;
virtual void remove(const std::string &id) {};
virtual void listIdentifier (std::vector<std::string>& identifier) const = 0; virtual void listIdentifier (std::vector<std::string>& identifier) const = 0;
static std::string toLower (const std::string& name) static std::string toLower (const std::string& name)
@ -58,14 +57,6 @@ namespace ESMS
list[id2].load(esm); list[id2].load(esm);
} }
// Delete the given object ID
void remove(const std::string &id)
{
std::string id2 = toLower (id);
list.erase(id2);
}
// Find the given object ID, or return NULL if not found. // Find the given object ID, or return NULL if not found.
const X* search(const std::string &id) const const X* search(const std::string &id) const
{ {
@ -277,57 +268,38 @@ namespace ESMS
{ {
virtual ~LTexList() {} virtual ~LTexList() {}
// For multiple ESM/ESP files we need one list per file. // TODO: For multiple ESM/ESP files we need one list per file.
typedef std::vector<LandTexture> LandTextureList; std::vector<LandTexture> ltex;
std::vector<LandTextureList> ltex;
LTexList() LTexList()
{ {
ltex.push_back(LandTextureList());
LandTextureList &ltexl = ltex[0];
// More than enough to hold Morrowind.esm. // More than enough to hold Morrowind.esm.
ltexl.reserve(128); ltex.reserve(128);
} }
const LandTexture* search(size_t index, size_t plugin) const const LandTexture* search(size_t index) const
{ {
assert(plugin < ltex.size()); assert(index < ltex.size());
const LandTextureList &ltexl = ltex[plugin]; return &ltex.at(index);
assert(index < ltexl.size());
return &ltexl.at(index);
} }
int getSize() { return ltex.size(); } int getSize() { return ltex.size(); }
int getSize() const { return ltex.size(); } int getSize() const { return ltex.size(); }
int getSizePlugin(size_t plugin) { assert(plugin < ltex.size()); return ltex[plugin].size(); } virtual void listIdentifier (std::vector<std::string>& identifier) const {}
int getSizePlugin(size_t plugin) const { assert(plugin < ltex.size()); return ltex[plugin].size(); }
virtual void listIdentifier (std::vector<std::string>& identifier) const {} void load(ESMReader &esm, const std::string &id)
void load(ESMReader &esm, const std::string &id, size_t plugin)
{ {
LandTexture lt; LandTexture lt;
lt.load(esm); lt.load(esm);
lt.id = id; lt.id = id;
// Make sure we have room for the structure // Make sure we have room for the structure
if (plugin >= ltex.size()) { if(lt.index + 1 > (int)ltex.size())
ltex.resize(plugin+1); ltex.resize(lt.index+1);
}
LandTextureList &ltexl = ltex[plugin];
if(lt.index + 1 > (int)ltexl.size())
ltexl.resize(lt.index+1);
// Store it // Store it
ltexl[lt.index] = lt; ltex[lt.index] = lt;
}
void load(ESMReader &esm, const std::string &id)
{
size_t plugin = esm.getIndex();
load(esm, id, plugin);
} }
}; };

View file

@ -67,13 +67,6 @@ void ESMStore::load(ESMReader &esm)
{ {
// Load it // Load it
std::string id = esm.getHNOString("NAME"); std::string id = esm.getHNOString("NAME");
// ... unless it got deleted!
if (esm.isNextSub("DELE")) {
esm.skipRecord();
all.erase(id);
it->second->remove(id);
continue;
}
it->second->load(esm, id); it->second->load(esm, id);
if (n.val==ESM::REC_DIAL) if (n.val==ESM::REC_DIAL)