post-merge fixes

pull/21/head
Marc Zinnschlag 13 years ago
commit 7c8853f6fe

3
.gitignore vendored

@ -4,3 +4,6 @@ Doxygen
prebuilt prebuilt
apps/openmw/config.hpp apps/openmw/config.hpp
Docs/mainpage.hpp Docs/mainpage.hpp
CMakeFiles
*/CMakeFiles
CMakeCache.txt

@ -90,6 +90,14 @@ set(BSA_HEADER
${COMP_DIR}/bsa/bsa_file.hpp) ${COMP_DIR}/bsa/bsa_file.hpp)
source_group(components\\bsa FILES ${BSA} ${BSA_HEADER}) source_group(components\\bsa FILES ${BSA} ${BSA_HEADER})
set(CFG
${COMP_DIR}/cfg/configurationmanager.cpp
)
set(CFG_HEADER
${COMP_DIR}/cfg/configurationmanager.hpp
)
source_group(components\\cfg FILES ${CFG} ${CFG_HEADER})
set(NIF set(NIF
${COMP_DIR}/nif/nif_file.cpp) ${COMP_DIR}/nif/nif_file.cpp)
set(NIF_HEADER set(NIF_HEADER
@ -189,22 +197,29 @@ source_group(components\\esm FILES ${ESM_HEADER} ${ESM})
set(MISC set(MISC
${COMP_DIR}/misc/stringops.cpp ${COMP_DIR}/misc/stringops.cpp
${COMP_DIR}/misc/fileops.cpp) )
set(MISC_HEADER set(MISC_HEADER
${COMP_DIR}/misc/fileops.hpp
${COMP_DIR}/misc/slice_array.hpp ${COMP_DIR}/misc/slice_array.hpp
${COMP_DIR}/misc/stringops.hpp) ${COMP_DIR}/misc/stringops.hpp
)
source_group(components\\misc FILES ${MISC} ${MISC_HEADER}) source_group(components\\misc FILES ${MISC} ${MISC_HEADER})
set(FILES set(FILES
${COMP_DIR}/files/path.cpp ${COMP_DIR}/files/linuxpath.cpp
${COMP_DIR}/files/windowspath.cpp
${COMP_DIR}/files/macospath.cpp
${COMP_DIR}/files/multidircollection.cpp ${COMP_DIR}/files/multidircollection.cpp
${COMP_DIR}/files/collections.cpp ${COMP_DIR}/files/collections.cpp
${COMP_DIR}/files/fileops.cpp
) )
set(FILES_HEADER set(FILES_HEADER
${COMP_DIR}/files/linuxpath.hpp
${COMP_DIR}/files/windowspath.hpp
${COMP_DIR}/files/macospath.hpp
${COMP_DIR}/files/path.hpp ${COMP_DIR}/files/path.hpp
${COMP_DIR}/files/multidircollection.hpp ${COMP_DIR}/files/multidircollection.hpp
${COMP_DIR}/files/collections.hpp ${COMP_DIR}/files/collections.hpp
${COMP_DIR}/files/fileops.hpp
) )
source_group(components\\files FILES ${FILES} ${FILES_HEADER}) source_group(components\\files FILES ${FILES} ${FILES_HEADER})
@ -217,10 +232,14 @@ file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp)
source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER}) source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER})
set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8} set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8}
${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET} ${FILES}) ${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET} ${FILES}
${CFG}
)
set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER} set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER}
${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER} ${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER}
${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER} ${FILES_HEADER}) ${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER} ${FILES_HEADER}
${CFG_HEADER}
)
# source directory: libs # source directory: libs

@ -52,6 +52,7 @@ add_executable(omwlauncher
${LAUNCHER} ${LAUNCHER}
${MISC} ${MISC_HEADER} ${MISC} ${MISC_HEADER}
${FILES} ${FILES_HEADER} ${FILES} ${FILES_HEADER}
${CFG} ${CFG_HEADER}
${TO_UTF8} ${TO_UTF8}
${ESM} ${ESM}
${RCC_SRCS} ${RCC_SRCS}

@ -1,9 +1,9 @@
#include <QtGui> #include <QtGui>
#include <components/esm/esm_reader.hpp> #include <components/esm/esm_reader.hpp>
#include <components/files/path.hpp>
#include <components/files/collections.hpp> #include <components/files/collections.hpp>
#include <components/files/multidircollection.hpp> #include <components/files/multidircollection.hpp>
#include <components/cfg/configurationmanager.hpp>
#include "datafilespage.hpp" #include "datafilespage.hpp"
#include "lineedit.hpp" #include "lineedit.hpp"
@ -127,7 +127,7 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
void DataFilesPage::setupDataFiles(const QStringList &paths, bool strict) void DataFilesPage::setupDataFiles(const QStringList &paths, bool strict)
{ {
// Put the paths in a boost::filesystem vector to use with Files::Collections // Put the paths in a boost::filesystem vector to use with Files::Collections
std::vector<boost::filesystem::path> dataDirs; Files::PathContainer dataDirs;
foreach (const QString &currentPath, paths) { foreach (const QString &currentPath, paths) {
dataDirs.push_back(boost::filesystem::path(currentPath.toStdString())); dataDirs.push_back(boost::filesystem::path(currentPath.toStdString()));
@ -142,9 +142,9 @@ void DataFilesPage::setupDataFiles(const QStringList &paths, bool strict)
for (Files::MultiDirCollection::TIter iter(esm.begin()); iter!=esm.end(); ++iter) for (Files::MultiDirCollection::TIter iter(esm.begin()); iter!=esm.end(); ++iter)
{ {
std::string filename = boost::filesystem::path (iter->second.filename()).string(); QString currentMaster = QString::fromStdString(
QString currentMaster = QString::fromStdString(filename); boost::filesystem::path (iter->second.filename()).string());
const QList<QTableWidgetItem*> itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); const QList<QTableWidgetItem*> itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly);
if (itemList.isEmpty()) // Master is not yet in the widget if (itemList.isEmpty()) // Master is not yet in the widget
@ -163,8 +163,8 @@ void DataFilesPage::setupDataFiles(const QStringList &paths, bool strict)
{ {
ESMReader fileReader; ESMReader fileReader;
QStringList availableMasters; // Will contain all found masters QStringList availableMasters; // Will contain all found masters
fileReader.setEncoding("win1252"); fileReader.setEncoding("win1252"); // FIXME: This should be configurable!
fileReader.open(iter->second.string()); fileReader.open(iter->second.string());
// First we fill the availableMasters and the mMastersWidget // First we fill the availableMasters and the mMastersWidget
@ -179,12 +179,12 @@ void DataFilesPage::setupDataFiles(const QStringList &paths, bool strict)
if (itemList.isEmpty()) // Master is not yet in the widget if (itemList.isEmpty()) // Master is not yet in the widget
{ {
mMastersWidget->insertRow(i); mMastersWidget->insertRow(i);
QTableWidgetItem *item = new QTableWidgetItem(currentMaster); QTableWidgetItem *item = new QTableWidgetItem(currentMaster);
item->setForeground(Qt::red); item->setForeground(Qt::red);
item->setFlags(item->flags() & ~(Qt::ItemIsSelectable)); item->setFlags(item->flags() & ~(Qt::ItemIsSelectable));
mMastersWidget->setItem(i, 0, item); mMastersWidget->setItem(i, 0, item);
} }
} }
@ -192,18 +192,18 @@ void DataFilesPage::setupDataFiles(const QStringList &paths, bool strict)
// Now we put the current plugin in the mDataFilesModel under its masters // Now we put the current plugin in the mDataFilesModel under its masters
QStandardItem *parent = new QStandardItem(availableMasters.join(",")); QStandardItem *parent = new QStandardItem(availableMasters.join(","));
QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string()); QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string());
QStandardItem *child = new QStandardItem(fileName); QStandardItem *child = new QStandardItem(fileName);
// Tooltip information // Tooltip information
QString author = QString::fromStdString(fileReader.getAuthor()); QString author = QString::fromStdString(fileReader.getAuthor());
float version = fileReader.getFVer(); float version = fileReader.getFVer();
QString description = QString::fromStdString(fileReader.getDesc()); QString description = QString::fromStdString(fileReader.getDesc());
// For the date created/modified // For the date created/modified
QFileInfo fi(QString::fromStdString(iter->second.string())); QFileInfo fi(QString::fromStdString(iter->second.string()));
QString toolTip= QString("<b>Author:</b> %1<br/> \ QString toolTip= QString("<b>Author:</b> %1<br/> \
<b>Version:</b> %2<br/><br/> \ <b>Version:</b> %2<br/><br/> \
<b>Description:</b><br/> \ <b>Description:</b><br/> \
@ -215,9 +215,9 @@ void DataFilesPage::setupDataFiles(const QStringList &paths, bool strict)
.arg(description) .arg(description)
.arg(fi.created().toString(Qt::TextDate)) .arg(fi.created().toString(Qt::TextDate))
.arg(fi.lastModified().toString(Qt::TextDate)); .arg(fi.lastModified().toString(Qt::TextDate));
child->setToolTip(toolTip); child->setToolTip(toolTip);
const QList<QStandardItem*> masterList = mDataFilesModel->findItems(availableMasters.join(",")); const QList<QStandardItem*> masterList = mDataFilesModel->findItems(availableMasters.join(","));
if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel
@ -236,12 +236,13 @@ void DataFilesPage::setupDataFiles(const QStringList &paths, bool strict)
void DataFilesPage::setupConfig() void DataFilesPage::setupConfig()
{ {
QString config = "./launcher.cfg"; Cfg::ConfigurationManager cfg;
QString config = (cfg.getRuntimeConfigPath() / "launcher.cfg").string().c_str();
QFile file(config); QFile file(config);
if (!file.exists()) { if (!file.exists()) {
config = QString::fromStdString(Files::getPath(Files::Path_ConfigUser, config = QString::fromStdString((cfg.getLocalConfigPath() / "launcher.cfg").string());
"openmw", "launcher.cfg"));
} }
file.setFileName(config); // Just for displaying information file.setFileName(config); // Just for displaying information
@ -672,7 +673,7 @@ void DataFilesPage::showContextMenu(const QPoint &point)
if (!mPluginsTable->selectionModel()->hasSelection()) { if (!mPluginsTable->selectionModel()->hasSelection()) {
return; return;
} }
QPoint globalPos = mPluginsTable->mapToGlobal(point); QPoint globalPos = mPluginsTable->mapToGlobal(point);
QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes();
@ -971,7 +972,7 @@ void DataFilesPage::writeConfig(QString profile)
if (mPluginsModel->rowCount() < 1) { if (mPluginsModel->rowCount() < 1) {
return; return;
} }
if (profile.isEmpty()) { if (profile.isEmpty()) {
profile = mProfilesComboBox->currentText(); profile = mProfilesComboBox->currentText();
} }

@ -1,7 +1,5 @@
#include <QtGui> #include <QtGui>
#include <components/files/path.hpp>
#include "graphicspage.hpp" #include "graphicspage.hpp"
GraphicsPage::GraphicsPage(QWidget *parent) : QWidget(parent) GraphicsPage::GraphicsPage(QWidget *parent) : QWidget(parent)
@ -149,44 +147,21 @@ void GraphicsPage::createPages()
void GraphicsPage::setupConfig() void GraphicsPage::setupConfig()
{ {
QString ogreCfg = "./ogre.cfg"; QString ogreCfg = mCfg.getOgreConfigPath().string().c_str();
QFile file(ogreCfg); QFile file(ogreCfg);
if (!file.exists()) {
ogreCfg = QString::fromStdString(Files::getPath(Files::Path_ConfigUser,
"openmw", "ogre.cfg"));
}
mOgreConfig = new QSettings(ogreCfg, QSettings::IniFormat); mOgreConfig = new QSettings(ogreCfg, QSettings::IniFormat);
} }
void GraphicsPage::setupOgre() void GraphicsPage::setupOgre()
{ {
QString pluginCfg = "./plugins.cfg"; QString pluginCfg = mCfg.getPluginsConfigPath().string().c_str();
QFile file(pluginCfg); QFile file(pluginCfg);
if (!file.exists()) {
pluginCfg = QString::fromStdString(Files::getPath(Files::Path_ConfigUser,
"openmw", "plugins.cfg"));
}
// Reopen the file from user directory
file.setFileName(pluginCfg);
if (!file.exists()) {
// There's no plugins.cfg in the user directory, use global directory
pluginCfg = QString::fromStdString(Files::getPath(Files::Path_ConfigGlobal,
"openmw", "plugins.cfg"));
}
// Create a log manager so we can surpress debug text to stdout/stderr // Create a log manager so we can surpress debug text to stdout/stderr
Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager; Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager;
logMgr->createLog("launcherOgre.log", true, false, false); logMgr->createLog((mCfg.getLogPath().string() + "/launcherOgre.log"), true, false, false);
QString ogreCfg = QString::fromStdString(Files::getPath(Files::Path_ConfigUser, QString ogreCfg = QString::fromStdString(mCfg.getOgreConfigPath().string());
"openmw", "ogre.cfg"));
file.setFileName(ogreCfg); file.setFileName(ogreCfg);
try try
@ -355,62 +330,62 @@ void GraphicsPage::writeConfig()
} else { } else {
mDirect3DRenderSystem->setConfigOption("Allow NVPerfHUD", "No"); mDirect3DRenderSystem->setConfigOption("Allow NVPerfHUD", "No");
} }
// Antialiasing // Antialiasing
mDirect3DRenderSystem->setConfigOption("FSAA", mD3DAntiAliasingComboBox->currentText().toStdString()); mDirect3DRenderSystem->setConfigOption("FSAA", mD3DAntiAliasingComboBox->currentText().toStdString());
// Full screen // Full screen
if (mD3DFullScreenCheckBox->checkState() == Qt::Checked) { if (mD3DFullScreenCheckBox->checkState() == Qt::Checked) {
mDirect3DRenderSystem->setConfigOption("Full Screen", "Yes"); mDirect3DRenderSystem->setConfigOption("Full Screen", "Yes");
} else { } else {
mDirect3DRenderSystem->setConfigOption("Full Screen", "No"); mDirect3DRenderSystem->setConfigOption("Full Screen", "No");
} }
// Rendering device // Rendering device
mDirect3DRenderSystem->setConfigOption("Rendering Device", mD3DRenderDeviceComboBox->currentText().toStdString()); mDirect3DRenderSystem->setConfigOption("Rendering Device", mD3DRenderDeviceComboBox->currentText().toStdString());
// VSync // VSync
if (mD3DVSyncCheckBox->checkState() == Qt::Checked) { if (mD3DVSyncCheckBox->checkState() == Qt::Checked) {
mDirect3DRenderSystem->setConfigOption("VSync", "Yes"); mDirect3DRenderSystem->setConfigOption("VSync", "Yes");
} else { } else {
mDirect3DRenderSystem->setConfigOption("VSync", "No"); mDirect3DRenderSystem->setConfigOption("VSync", "No");
} }
// Resolution // Resolution
mDirect3DRenderSystem->setConfigOption("Video Mode", mD3DResolutionComboBox->currentText().toStdString()); mDirect3DRenderSystem->setConfigOption("Video Mode", mD3DResolutionComboBox->currentText().toStdString());
} }
if (mOpenGLRenderSystem) { if (mOpenGLRenderSystem) {
// Display Frequency // Display Frequency
mOpenGLRenderSystem->setConfigOption("Display Frequency", mOGLFrequencyComboBox->currentText().toStdString()); mOpenGLRenderSystem->setConfigOption("Display Frequency", mOGLFrequencyComboBox->currentText().toStdString());
// Antialiasing // Antialiasing
mOpenGLRenderSystem->setConfigOption("FSAA", mOGLAntiAliasingComboBox->currentText().toStdString()); mOpenGLRenderSystem->setConfigOption("FSAA", mOGLAntiAliasingComboBox->currentText().toStdString());
// Full screen // Full screen
if (mOGLFullScreenCheckBox->checkState() == Qt::Checked) { if (mOGLFullScreenCheckBox->checkState() == Qt::Checked) {
mOpenGLRenderSystem->setConfigOption("Full Screen", "Yes"); mOpenGLRenderSystem->setConfigOption("Full Screen", "Yes");
} else { } else {
mOpenGLRenderSystem->setConfigOption("Full Screen", "No"); mOpenGLRenderSystem->setConfigOption("Full Screen", "No");
} }
// RTT mode // RTT mode
mOpenGLRenderSystem->setConfigOption("RTT Preferred Mode", mOGLRTTComboBox->currentText().toStdString()); mOpenGLRenderSystem->setConfigOption("RTT Preferred Mode", mOGLRTTComboBox->currentText().toStdString());
// VSync // VSync
if (mOGLVSyncCheckBox->checkState() == Qt::Checked) { if (mOGLVSyncCheckBox->checkState() == Qt::Checked) {
mOpenGLRenderSystem->setConfigOption("VSync", "Yes"); mOpenGLRenderSystem->setConfigOption("VSync", "Yes");
} else { } else {
mOpenGLRenderSystem->setConfigOption("VSync", "No"); mOpenGLRenderSystem->setConfigOption("VSync", "No");
} }
// Resolution // Resolution
mOpenGLRenderSystem->setConfigOption("Video Mode", mOGLResolutionComboBox->currentText().toStdString()); mOpenGLRenderSystem->setConfigOption("Video Mode", mOGLResolutionComboBox->currentText().toStdString());
} }
// Now we validate the options // Now we validate the options
QString ogreError = QString::fromStdString(mSelectedRenderSystem->validateConfigOptions()); QString ogreError = QString::fromStdString(mSelectedRenderSystem->validateConfigOptions());
if (!ogreError.isEmpty()) { if (!ogreError.isEmpty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setWindowTitle("Error validating configuration"); msgBox.setWindowTitle("Error validating configuration");
@ -421,17 +396,17 @@ void GraphicsPage::writeConfig()
Press \"Show Details...\" for more information.<br>")); Press \"Show Details...\" for more information.<br>"));
msgBox.setDetailedText(ogreError); msgBox.setDetailedText(ogreError);
msgBox.exec(); msgBox.exec();
Ogre::LogManager::getSingletonPtr()->logMessage( "Caught exception in validateConfigOptions"); Ogre::LogManager::getSingletonPtr()->logMessage( "Caught exception in validateConfigOptions");
qCritical("Error validating configuration"); qCritical("Error validating configuration");
std::exit(1); std::exit(1);
} }
// Write the settings to the config file // Write the settings to the config file
mOgre->saveConfig(); mOgre->saveConfig();
} }
QString GraphicsPage::getConfigValue(const QString &key, Ogre::RenderSystem *renderer) QString GraphicsPage::getConfigValue(const QString &key, Ogre::RenderSystem *renderer)
@ -482,4 +457,4 @@ void GraphicsPage::rendererChanged(const QString &renderer)
} }
mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString()); mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString());
} }

@ -7,6 +7,7 @@
#include <OgreRenderSystem.h> #include <OgreRenderSystem.h>
#include <OgreConfigFile.h> #include <OgreConfigFile.h>
#include <OgreConfigDialog.h> #include <OgreConfigDialog.h>
#include <components/cfg/configurationmanager.hpp>
class QComboBox; class QComboBox;
class QCheckBox; class QCheckBox;
@ -28,6 +29,7 @@ public slots:
void rendererChanged(const QString &renderer); void rendererChanged(const QString &renderer);
private: private:
Cfg::ConfigurationManager mCfg;
Ogre::Root *mOgre; Ogre::Root *mOgre;
Ogre::RenderSystem *mSelectedRenderSystem; Ogre::RenderSystem *mSelectedRenderSystem;
Ogre::RenderSystem *mOpenGLRenderSystem; Ogre::RenderSystem *mOpenGLRenderSystem;

@ -1,7 +1,5 @@
#include <QtGui> #include <QtGui>
#include <components/files/path.hpp>
#include "maindialog.hpp" #include "maindialog.hpp"
#include "playpage.hpp" #include "playpage.hpp"
#include "graphicspage.hpp" #include "graphicspage.hpp"
@ -92,7 +90,7 @@ QStringList MainDialog::readConfig(const QString &fileName)
// We can't use QSettings directly because it // We can't use QSettings directly because it
// does not support multiple keys with the same name // does not support multiple keys with the same name
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setWindowTitle("Error opening OpenMW configuration file"); msgBox.setWindowTitle("Error opening OpenMW configuration file");
@ -101,44 +99,44 @@ QStringList MainDialog::readConfig(const QString &fileName)
msgBox.setText(tr("<br><b>Could not open %0</b><br><br> \ msgBox.setText(tr("<br><b>Could not open %0</b><br><br> \
Please make sure you have the right permissions and try again.<br>").arg(file.fileName())); Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
msgBox.exec(); msgBox.exec();
QApplication::exit(); // File cannot be opened or created QApplication::exit(); // File cannot be opened or created
} }
QTextStream in(&file); QTextStream in(&file);
QStringList dataDirs; QStringList dataDirs;
QString dataLocal; QString dataLocal;
// Read the config line by line // Read the config line by line
while (!in.atEnd()) { while (!in.atEnd()) {
QString line = in.readLine(); QString line = in.readLine();
if (line.startsWith("data=")) { if (line.startsWith("data=")) {
dataDirs.append(line.remove("data=")); dataDirs.append(line.remove("data="));
} }
// Read the data-local key, if more than one are found only the last is used // Read the data-local key, if more than one are found only the last is used
if (line.startsWith("data-local=")) { if (line.startsWith("data-local=")) {
dataLocal = line.remove("data-local="); dataLocal = line.remove("data-local=");
} }
// Read fs-strict key // Read fs-strict key
if (line.startsWith("fs-strict=")) { if (line.startsWith("fs-strict=")) {
QString value = line.remove("fs-strict="); QString value = line.remove("fs-strict=");
(value.toLower() == QLatin1String("true")) (value.toLower() == QLatin1String("true"))
? mStrict = true ? mStrict = true
: mStrict = false; : mStrict = false;
} }
} }
// Add the data-local= key to the end of the dataDirs for priority reasons // Add the data-local= key to the end of the dataDirs for priority reasons
if (!dataLocal.isEmpty()) { if (!dataLocal.isEmpty()) {
dataDirs.append(dataLocal); dataDirs.append(dataLocal);
} }
if (!dataDirs.isEmpty()) if (!dataDirs.isEmpty())
{ {
// Reset the global datadirs to the newly read entries // Reset the global datadirs to the newly read entries
@ -147,7 +145,7 @@ QStringList MainDialog::readConfig(const QString &fileName)
} }
file.close(); file.close();
return mDataDirs; return mDataDirs;
} }
@ -156,31 +154,29 @@ void MainDialog::createPages()
mPlayPage = new PlayPage(this); mPlayPage = new PlayPage(this);
mGraphicsPage = new GraphicsPage(this); mGraphicsPage = new GraphicsPage(this);
mDataFilesPage = new DataFilesPage(this); mDataFilesPage = new DataFilesPage(this);
// Retrieve all data entries from the configs // Retrieve all data entries from the configs
QStringList dataDirs; QStringList dataDirs;
// Global location // Global location
QFile file(QString::fromStdString(Files::getPath(Files::Path_ConfigGlobal, QFile file(QString::fromStdString((mCfg.getGlobalConfigPath()/"openmw.cfg").string()));
"openmw", "openmw.cfg")));
if (file.exists()) { if (file.exists()) {
dataDirs = readConfig(file.fileName()); dataDirs = readConfig(file.fileName());
} }
// User location // User location
file.setFileName(QString::fromStdString(Files::getPath(Files::Path_ConfigUser, file.setFileName(QString::fromStdString((mCfg.getLocalConfigPath()/"openmw.cfg").string()));
"openmw", "openmw.cfg")));
if (file.exists()) { if (file.exists()) {
dataDirs = readConfig(file.fileName()); dataDirs = readConfig(file.fileName());
} }
// Local location // Local location
file.setFileName("./openmw.cfg"); file.setFileName("./openmw.cfg");
if (file.exists()) { if (file.exists()) {
dataDirs = readConfig(file.fileName()); dataDirs = readConfig(file.fileName());
} }
file.close(); file.close();
if (!dataDirs.isEmpty()) { if (!dataDirs.isEmpty()) {
@ -331,9 +327,8 @@ void MainDialog::writeConfig()
QStringList dataFiles = mDataFilesPage->selectedMasters(); QStringList dataFiles = mDataFilesPage->selectedMasters();
dataFiles.append(mDataFilesPage->checkedPlugins()); dataFiles.append(mDataFilesPage->checkedPlugins());
// Open the config as a QFile // Open the config as a QFile
QFile file(QString::fromStdString(Files::getPath(Files::Path_ConfigUser, QFile file(QString::fromStdString((mCfg.getLocalConfigPath()/"openmw.cfg").string()));
"openmw", "openmw.cfg")));
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
// File cannot be opened or created // File cannot be opened or created
@ -375,7 +370,7 @@ void MainDialog::writeConfig()
} }
file.write(buffer); file.write(buffer);
QTextStream out(&file); QTextStream out(&file);
// Write the list of game files to the config // Write the list of game files to the config

@ -3,6 +3,8 @@
#include <QDialog> #include <QDialog>
#include <components/cfg/configurationmanager.hpp>
class QListWidget; class QListWidget;
class QListWidgetItem; class QListWidgetItem;
class QStackedWidget; class QStackedWidget;
@ -30,12 +32,11 @@ public slots:
private: private:
void createIcons(); void createIcons();
void createPages(); void createPages();
void setupConfig();
void writeConfig(); void writeConfig();
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QStringList readConfig(const QString &fileName); QStringList readConfig(const QString &fileName);
QListWidget *mIconWidget; QListWidget *mIconWidget;
QStackedWidget *mPagesWidget; QStackedWidget *mPagesWidget;
@ -45,6 +46,8 @@ private:
QStringList mDataDirs; QStringList mDataDirs;
bool mStrict; bool mStrict;
Cfg::ConfigurationManager mCfg;
}; };
#endif #endif

@ -16,6 +16,7 @@ set(GAME_HEADER
source_group(game FILES ${GAME} ${GAME_HEADER}) source_group(game FILES ${GAME} ${GAME_HEADER})
set(GAMEREND set(GAMEREND
mwrender/rendering_manager.cpp
mwrender/mwscene.cpp mwrender/mwscene.cpp
mwrender/cellimp.cpp mwrender/cellimp.cpp
mwrender/interior.cpp mwrender/interior.cpp
@ -24,6 +25,7 @@ set(GAMEREND
mwrender/player.cpp mwrender/player.cpp
) )
set(GAMEREND_HEADER set(GAMEREND_HEADER
mwrender/rendering_manager.hpp
mwrender/cell.hpp mwrender/cell.hpp
mwrender/cellimp.hpp mwrender/cellimp.hpp
mwrender/mwscene.hpp mwrender/mwscene.hpp
@ -137,6 +139,8 @@ source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER})
set(GAMEWORLD set(GAMEWORLD
mwworld/world.cpp mwworld/world.cpp
mwworld/scene.cpp
mwworld/physicssystem.cpp
mwworld/globals.cpp mwworld/globals.cpp
mwworld/class.cpp mwworld/class.cpp
mwworld/actionteleport.cpp mwworld/actionteleport.cpp
@ -144,12 +148,13 @@ set(GAMEWORLD
mwworld/actiontake.cpp mwworld/actiontake.cpp
mwworld/containerutil.cpp mwworld/containerutil.cpp
mwworld/player.cpp mwworld/player.cpp
mwworld/doingphysics.cpp mwworld/cells.cpp
) )
set(GAMEWORLD_HEADER set(GAMEWORLD_HEADER
mwworld/refdata.hpp mwworld/refdata.hpp
mwworld/world.hpp mwworld/world.hpp
mwworld/ptr.hpp mwworld/physicssystem.hpp
mwworld/scene.hpp
mwworld/environment.hpp mwworld/environment.hpp
mwworld/globals.hpp mwworld/globals.hpp
mwworld/class.hpp mwworld/class.hpp
@ -163,8 +168,8 @@ set(GAMEWORLD_HEADER
mwworld/manualref.hpp mwworld/manualref.hpp
mwworld/containerutil.hpp mwworld/containerutil.hpp
mwworld/player.hpp mwworld/player.hpp
mwworld/doingphysics.hpp
mwworld/cellfunctors.hpp mwworld/cellfunctors.hpp
mwworld/cells.hpp
) )
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER}) source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})

@ -11,7 +11,7 @@
#include "components/esm/records.hpp" #include "components/esm/records.hpp"
#include <components/esm_store/cell_store.hpp> #include <components/esm_store/cell_store.hpp>
#include <components/misc/fileops.hpp> #include <components/files/fileops.hpp>
#include <components/bsa/bsa_archive.hpp> #include <components/bsa/bsa_archive.hpp>
#include <components/esm/loadregn.hpp> #include <components/esm/loadregn.hpp>
#include <components/esm/esm_reader.hpp> #include <components/esm/esm_reader.hpp>
@ -209,7 +209,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
return true; return true;
} }
OMW::Engine::Engine() OMW::Engine::Engine(Cfg::ConfigurationManager& configurationManager)
: mPhysicEngine (0) : mPhysicEngine (0)
, mShowFPS (false) , mShowFPS (false)
, mDebug (false) , mDebug (false)
@ -221,6 +221,7 @@ OMW::Engine::Engine()
, mScriptContext (0) , mScriptContext (0)
, mGuiManager (0) , mGuiManager (0)
, mFSStrict (false) , mFSStrict (false)
, mCfgMgr(configurationManager)
{ {
MWClass::registerClasses(); MWClass::registerClasses();
} }
@ -251,9 +252,8 @@ void OMW::Engine::loadBSA()
Bsa::addBSA (iter->second.string()); Bsa::addBSA (iter->second.string());
} }
std::string m = mDataDir.string(); std::cout << "Data dir " << mDataDir.string() << std::endl;
std::cout << "Data dir" << m << "\n"; Bsa::addDir(mDataDir.string(), mFSStrict);
Bsa::addDir(m, mFSStrict);
} }
// add resources directory // add resources directory
@ -265,19 +265,18 @@ void OMW::Engine::addResourcesDirectory (const boost::filesystem::path& path)
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
} }
void OMW::Engine::enableFSStrict() void OMW::Engine::enableFSStrict(bool fsStrict)
{ {
mFSStrict = true; mFSStrict = fsStrict;
} }
// Set data dir // Set data dir
void OMW::Engine::setDataDirs (const std::vector<boost::filesystem::path>& dataDirs) void OMW::Engine::setDataDirs (const Files::PathContainer& dataDirs)
{ {
/// \todo remove mDataDir, once resources system can handle multiple directories /// \todo remove mDataDir, once resources system can handle multiple directories
assert (!dataDirs.empty()); assert (!dataDirs.empty());
mDataDir = dataDirs[0]; mDataDir = dataDirs.back();
mFileCollections = Files::Collections (dataDirs, !mFSStrict); mFileCollections = Files::Collections (dataDirs, !mFSStrict);
} }
@ -311,19 +310,19 @@ void OMW::Engine::addMaster (const std::string& master)
} }
} }
void OMW::Engine::enableDebugMode() void OMW::Engine::setDebugMode(bool debugMode)
{ {
mDebug = true; mDebug = debugMode;
} }
void OMW::Engine::enableVerboseScripts() void OMW::Engine::setScriptsVerbosity(bool scriptsVerbosity)
{ {
mVerboseScripts = true; mVerboseScripts = scriptsVerbosity;
} }
void OMW::Engine::setNewGame() void OMW::Engine::setNewGame(bool newGame)
{ {
mNewGame = true; mNewGame = newGame;
} }
// Initialise and enter main loop. // Initialise and enter main loop.
@ -337,19 +336,10 @@ void OMW::Engine::go()
test.name = ""; test.name = "";
total = 0; total = 0;
std::string cfgDir = Files::getPath (Files::Path_ConfigGlobal, "openmw", ""); mOgre.configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()),
std::string cfgUserDir = Files::getPath (Files::Path_ConfigUser, "openmw", ""); mCfgMgr.getOgreConfigPath().string(),
std::string plugCfg = "plugins.cfg"; mCfgMgr.getLogPath().string() + std::string("/"),
std::string ogreCfg = "ogre.cfg"; mCfgMgr.getPluginsConfigPath().string(), false);
ogreCfg.insert(0, cfgUserDir);
//A local plugins.cfg will be used if it exist, otherwise look in the default path
if(!Misc::isFile(plugCfg.c_str()))
{
plugCfg.insert(0, cfgDir);
}
mOgre.configure(!Misc::isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false);
// This has to be added BEFORE MyGUI is initialized, as it needs // This has to be added BEFORE MyGUI is initialized, as it needs
// to find core.xml here. // to find core.xml here.
@ -369,7 +359,9 @@ void OMW::Engine::go()
mResDir, mNewGame, mEnvironment, mEncoding); mResDir, mNewGame, mEnvironment, mEncoding);
// Set up the GUI system // Set up the GUI system
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(), mOgre.getScene(), false, cfgDir); mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(), mOgre.getScene(), false,
mCfgMgr.getLogPath().string() + std::string("/"));
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWAttribute>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWAttribute>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpell>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpell>("Widget");
@ -516,7 +508,17 @@ void OMW::Engine::setCompileAll (bool all)
mCompileAll = all; mCompileAll = all;
} }
void OMW::Engine::setSoundUsage(bool soundUsage)
{
mUseSound = soundUsage;
}
void OMW::Engine::showFPS(bool showFps)
{
mShowFPS = showFps;
}
void OMW::Engine::setEncoding(const std::string& encoding) void OMW::Engine::setEncoding(const std::string& encoding)
{ {
mEncoding = encoding; mEncoding = encoding;
} }

@ -15,7 +15,7 @@
#include "mwworld/environment.hpp" #include "mwworld/environment.hpp"
#include "mwworld/ptr.hpp" #include "mwworld/ptr.hpp"
#include <boost/timer.hpp> #include <boost/timer.hpp>
#include <components/cfg/configurationmanager.hpp>
namespace Compiler namespace Compiler
{ {
@ -53,7 +53,6 @@ namespace OEngine
namespace OMW namespace OMW
{ {
/// \brief Main engine class, that brings together all the components of OpenMW /// \brief Main engine class, that brings together all the components of OpenMW
class Engine : private Ogre::FrameListener class Engine : private Ogre::FrameListener
{ {
std::string mEncoding; std::string mEncoding;
@ -106,49 +105,44 @@ namespace OMW
/// Process pending commands /// Process pending commands
public: public:
Engine(Cfg::ConfigurationManager& configurationManager);
Engine(); virtual ~Engine();
~Engine();
/// Enable strict filesystem mode (do not fold case) /// Enable strict filesystem mode (do not fold case)
/// ///
/// \attention The strict mode must be specified before any path-related settings /// \attention The strict mode must be specified before any path-related settings
/// are given to the engine. /// are given to the engine.
void enableFSStrict(); void enableFSStrict(bool fsStrict);
/// Set data dirs /// Set data dirs
void setDataDirs (const std::vector<boost::filesystem::path>& dataDirs); void setDataDirs(const Files::PathContainer& dataDirs);
/// Set resource dir /// Set resource dir
void setResourceDir (const boost::filesystem::path& parResDir); void setResourceDir(const boost::filesystem::path& parResDir);
/// Set start cell name (only interiors for now) /// Set start cell name (only interiors for now)
void setCell (const std::string& cellName); void 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. /// - Currently OpenMW only supports one master at the same time.
void addMaster (const std::string& master); void addMaster(const std::string& master);
/// Enable fps counter /// Enable fps counter
void showFPS() { mShowFPS = true; } void showFPS(bool showFps);
/// Enable debug mode: /// Enable debug mode:
/// - non-exclusive input /// - non-exclusive input
void enableDebugMode(); void setDebugMode(bool debugMode);
/// Enable the command server so external apps can send commands to the console.
/// Must be set before go().
/// Enable verbose script output /// Enable or disable verbose script output
void enableVerboseScripts(); void setScriptsVerbosity(bool scriptsVerbosity);
/// Disable all sound /// Disable or enable all sounds
void disableSound() { mUseSound = false; } void setSoundUsage(bool soundUsage);
/// Start as a new game. /// Start as a new game.
void setNewGame(); void setNewGame(bool newGame);
/// Initialise and enter main loop. /// Initialise and enter main loop.
void go(); void go();
@ -161,7 +155,10 @@ namespace OMW
/// Font encoding /// Font encoding
void setEncoding(const std::string& encoding); void setEncoding(const std::string& encoding);
private:
Cfg::ConfigurationManager& mCfgMgr;
}; };
} }
#endif #endif /* ENGINE_H */

@ -5,8 +5,10 @@
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <components/misc/fileops.hpp> #include <components/files/fileops.hpp>
#include <components/files/path.hpp> #include <components/files/path.hpp>
#include <components/files/collections.hpp>
#include <components/cfg/configurationmanager.hpp>
#include "engine.hpp" #include "engine.hpp"
@ -35,56 +37,64 @@
using namespace std; using namespace std;
/// Parse command line options and openmw.cfg file (if one exists). Results are directly /**
/// written to \a engine. * \brief Parses application command line and calls \ref Cfg::ConfigurationManager
/// \return Run OpenMW? * to parse configuration files.
*
bool parseOptions (int argc, char**argv, OMW::Engine& engine) * Results are directly written to \ref Engine class.
*
* \retval true - Everything goes OK
* \retval false - Error
*/
bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::ConfigurationManager& cfgMgr)
{ {
// Create a local alias for brevity // Create a local alias for brevity
namespace bpo = boost::program_options; namespace bpo = boost::program_options;
typedef std::vector<std::string> StringsVector;
bpo::options_description desc ( bpo::options_description desc("Syntax: openmw <options>\nAllowed options");
"Syntax: openmw <options>\nAllowed options");
desc.add_options() desc.add_options()
("help", "print help message and quit") ("help", "print help message")
("version", "print version information and quit") ("version", "print version information and quit")
("data", bpo::value<std::vector<std::string> >() ("data", bpo::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")
->default_value (std::vector<std::string>(), "data") ->multitoken(), "set data directories (later directories have higher priority)")
->multitoken(),
"set data directories (later directories have higher priority)") ("data-local", bpo::value<std::string>()->default_value(""),
("data-local", bpo::value<std::string>()->default_value (""),
"set local data directory (highest priority)") "set local data directory (highest priority)")
("resources", bpo::value<std::string>()->default_value ("resources"),
("resources", bpo::value<std::string>()->default_value("resources"),
"set resources directory") "set resources directory")
("start", bpo::value<std::string>()->default_value ("Beshara"),
("start", bpo::value<std::string>()->default_value("Beshara"),
"set initial cell") "set initial cell")
("master", bpo::value<std::vector<std::string> >()
->default_value (std::vector<std::string>(), "") ("master", bpo::value<StringsVector>()->default_value(StringsVector(), "")
->multitoken(), ->multitoken(), "master file(s)")
"master file(s)")
("plugin", bpo::value<std::vector<std::string> >() ("plugin", bpo::value<StringsVector>()->default_value(StringsVector(), "")
->default_value (std::vector<std::string>(), "") ->multitoken(), "plugin file(s)")
->multitoken(),
"plugin file(s)") ("fps", boost::program_options::value<bool>()->implicit_value(true)
( "fps", boost::program_options::value<bool>()-> ->default_value(false), "show fps counter")
implicit_value (true)->default_value (false), "show fps counter")
( "debug", boost::program_options::value<bool>()-> ("debug", boost::program_options::value<bool>()->implicit_value(true)
implicit_value (true)->default_value (false), "debug mode" ) ->default_value(false), "debug mode")
( "nosound", boost::program_options::value<bool>()->
implicit_value (true)->default_value (false), "disable all sound" ) ("nosound", boost::program_options::value<bool>()->implicit_value(true)
( "script-verbose", boost::program_options::value<bool>()-> ->default_value(false), "disable all sounds")
implicit_value (true)->default_value (false), "verbose script output" )
( "new-game", boost::program_options::value<bool>()-> ("script-verbose", boost::program_options::value<bool>()->implicit_value(true)
implicit_value (true)->default_value (false), ->default_value(false), "verbose script output")
"activate char gen/new game mechanics" )
( "script-all", boost::program_options::value<bool>()-> ("new-game", boost::program_options::value<bool>()->implicit_value(true)
implicit_value (true)->default_value (false), ->default_value(false), "activate char gen/new game mechanics")
"compile all scripts (excluding dialogue scripts) at startup")
( "fs-strict", boost::program_options::value<bool>()-> ("script-all", boost::program_options::value<bool>()->implicit_value(true)
implicit_value (true)->default_value (false), ->default_value(false), "compile all scripts (excluding dialogue scripts) at startup")
"strict file system handling (no case folding)")
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)
->default_value(false), "strict file system handling (no case folding)")
( "encoding", boost::program_options::value<std::string>()-> ( "encoding", boost::program_options::value<std::string>()->
default_value("win1252"), default_value("win1252"),
@ -94,31 +104,16 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
"\n\twin1252 - Western European (Latin) alphabet, used by default") "\n\twin1252 - Western European (Latin) alphabet, used by default")
; ;
bpo::variables_map variables; bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
.options(desc).allow_unregistered().run();
//If there is an openmw.cfg in the current path use that as global config
//Otherwise try getPath
std::string cfgFile = "openmw.cfg";
if(!Misc::isFile(cfgFile.c_str()))
{
cfgFile = Files::getPath (Files::Path_ConfigGlobal, "openmw", "openmw.cfg");
}
std::cout << "Using global config file: " << cfgFile << std::endl;
std::ifstream globalConfigFile(cfgFile.c_str());
cfgFile = Files::getPath (Files::Path_ConfigUser, "openmw", "openmw.cfg"); bpo::variables_map variables;
std::cout << "Using user config file: " << cfgFile << std::endl;
std::ifstream userConfigFile(cfgFile.c_str());
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
// Runtime options override settings from all configs
bpo::store(valid_opts, variables); bpo::store(valid_opts, variables);
bpo::notify(variables); bpo::notify(variables);
if (userConfigFile.is_open()) cfgMgr.readConfiguration(variables, desc);
bpo::store ( bpo::parse_config_file (userConfigFile, desc), variables);
if (globalConfigFile.is_open())
bpo::store ( bpo::parse_config_file (globalConfigFile, desc), variables);
bool run = true; bool run = true;
@ -156,63 +151,57 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
} }
// directory settings // directory settings
if (variables["fs-strict"].as<bool>()==true) engine.enableFSStrict(variables["fs-strict"].as<bool>());
engine.enableFSStrict();
std::vector<std::string> dataDirs = variables["data"].as<std::vector<std::string> >(); Files::PathContainer dataDirs(variables["data"].as<Files::PathContainer>());
std::vector<boost::filesystem::path> dataDirs2 (dataDirs.begin(), dataDirs.end());
std::string local = variables["data-local"].as<std::string>(); std::string local(variables["data-local"].as<std::string>());
if (!local.empty()) if (!local.empty())
dataDirs.push_back (local); {
dataDirs.push_back(Files::PathContainer::value_type(local));
}
engine.setDataDirs (dataDirs2); if (dataDirs.empty())
{
dataDirs.push_back(cfgMgr.getLocalDataPath());
}
engine.setResourceDir (variables["resources"].as<std::string>()); engine.setDataDirs(dataDirs);
engine.setResourceDir(variables["resources"].as<std::string>());
// master and plugin // master and plugin
std::vector<std::string> master = variables["master"].as<std::vector<std::string> >(); StringsVector master = variables["master"].as<StringsVector>();
if (master.empty()) if (master.empty())
{ {
std::cout << "No master file given. Assuming Morrowind.esm" << std::endl; std::cout << "No master file given. Assuming Morrowind.esm" << std::endl;
master.push_back ("Morrowind"); master.push_back("Morrowind");
} }
if (master.size()>1) if (master.size() > 1)
{ {
std::cout std::cout
<< "Ignoring all but the first master file (multiple master files not yet supported)." << "Ignoring all but the first master file (multiple master files not yet supported)."
<< std::endl; << std::endl;
} }
engine.addMaster(master[0]);
engine.addMaster (master[0]); StringsVector plugin = variables["plugin"].as<StringsVector>();
std::vector<std::string> plugin = variables["plugin"].as<std::vector<std::string> >();
if (!plugin.empty()) if (!plugin.empty())
{
std::cout << "Ignoring plugin files (plugins not yet supported)." << std::endl; 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>());
engine.setNewGame(variables["new-game"].as<bool>());
if (variables["new-game"].as<bool>()==true)
engine.setNewGame();
// other settings // other settings
if (variables["fps"].as<bool>()==true) engine.showFPS(variables["fps"].as<bool>());
engine.showFPS(); engine.setDebugMode(variables["debug"].as<bool>());
engine.setSoundUsage(!variables["nosound"].as<bool>());
if (variables["debug"].as<bool>()==true) engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());
engine.enableDebugMode(); engine.setCompileAll(variables["script-all"].as<bool>());
if (variables["nosound"].as<bool>()==true)
engine.disableSound();
if (variables["script-verbose"].as<bool>()==true)
engine.enableVerboseScripts();
if (variables["script-all"].as<bool>()==true)
engine.setCompileAll (true);
return true; return true;
} }
@ -227,16 +216,17 @@ int main(int argc, char**argv)
try try
{ {
OMW::Engine engine; Cfg::ConfigurationManager cfgMgr;
OMW::Engine engine(cfgMgr);
if (parseOptions (argc, argv, engine)) if (parseOptions(argc, argv, engine, cfgMgr))
{ {
engine.go(); engine.go();
} }
} }
catch(exception &e) catch (std::exception &e)
{ {
cout << "\nERROR: " << e.what() << endl; std::cout << "\nERROR: " << e.what() << std::endl;
return 1; return 1;
} }

@ -34,8 +34,8 @@ bool ExteriorCellRender::lightOutQuadInLin = false;
int ExteriorCellRender::uniqueID = 0; int ExteriorCellRender::uniqueID = 0;
ExteriorCellRender::ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment, ExteriorCellRender::ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
MWScene &_scene) MWScene &_scene, MWWorld::PhysicsSystem *physics)
: mCell(_cell), mEnvironment (environment), mScene(_scene), mBase(NULL), mInsert(NULL), mAmbientMode (0) : mCell(_cell), mEnvironment (environment), mScene(_scene), mPhysics(physics), mBase(NULL), mInsert(NULL), mAmbientMode (0)
{ {
uniqueID = uniqueID +1; uniqueID = uniqueID +1;
sg = mScene.getMgr()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); sg = mScene.getMgr()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
@ -233,13 +233,15 @@ void ExteriorCellRender::insertMesh(const std::string &mesh)
void ExteriorCellRender::insertObjectPhysics() void ExteriorCellRender::insertObjectPhysics()
{ {
if (!mInsertMesh.empty()) if (!mInsertMesh.empty())
mScene.addObject (mInsert->getName(), mInsertMesh, mInsert->getOrientation(), {
mPhysics->addObject (mInsert->getName(), mInsertMesh, mInsert->getOrientation(),
mInsert->getScale().x, mInsert->getPosition()); mInsert->getScale().x, mInsert->getPosition());
}
} }
void ExteriorCellRender::insertActorPhysics() void ExteriorCellRender::insertActorPhysics()
{ {
mScene.addActor (mInsert->getName(), mInsertMesh, mInsert->getPosition()); mPhysics->addActor (mInsert->getName(), mInsertMesh, mInsert->getPosition());
} }
// insert a light related to the most recent insertBegin call. // insert a light related to the most recent insertBegin call.
@ -348,13 +350,14 @@ void ExteriorCellRender::setAmbientMode()
void ExteriorCellRender::show() void ExteriorCellRender::show()
{ {
// FIXME: this one may be the bug
mBase = mScene.getRoot()->createChildSceneNode(); mBase = mScene.getRoot()->createChildSceneNode();
configureAmbient(); configureAmbient();
configureFog(); configureFog();
insertCell(mCell, mEnvironment); insertCell(mCell, mEnvironment);
sg->build(); sg->build();
} }

@ -3,6 +3,7 @@
#include "cell.hpp" #include "cell.hpp"
#include "cellimp.hpp" #include "cellimp.hpp"
#include "../mwworld/physicssystem.hpp"
#include "OgreColourValue.h" #include "OgreColourValue.h"
#include <OgreMath.h> #include <OgreMath.h>
@ -49,6 +50,7 @@ namespace MWRender
ESMS::CellStore<MWWorld::RefData> &mCell; ESMS::CellStore<MWWorld::RefData> &mCell;
MWWorld::Environment &mEnvironment; MWWorld::Environment &mEnvironment;
MWScene &mScene; MWScene &mScene;
MWWorld::PhysicsSystem *mPhysics;
/// The scene node that contains all objects belonging to this /// The scene node that contains all objects belonging to this
/// cell. /// cell.
@ -101,7 +103,7 @@ namespace MWRender
public: public:
ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment, ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
MWScene &_scene); MWScene &_scene, MWWorld::PhysicsSystem *physics);
virtual ~ExteriorCellRender() { destroy(); } virtual ~ExteriorCellRender() { destroy(); }

@ -195,13 +195,15 @@ void InteriorCellRender::insertMesh(const std::string &mesh)
void InteriorCellRender::insertObjectPhysics() void InteriorCellRender::insertObjectPhysics()
{ {
if (!mInsertMesh.empty()) if (!mInsertMesh.empty())
scene.addObject (insert->getName(), mInsertMesh, insert->getOrientation(), {
mPhysics->addObject (insert->getName(), mInsertMesh, insert->getOrientation(),
insert->getScale().x, insert->getPosition()); insert->getScale().x, insert->getPosition());
}
} }
void InteriorCellRender::insertActorPhysics() void InteriorCellRender::insertActorPhysics()
{ {
scene.addActor (insert->getName(), mInsertMesh, insert->getPosition()); mPhysics->addActor (insert->getName(), mInsertMesh, insert->getPosition());
} }
// insert a light related to the most recent insertBegin call. // insert a light related to the most recent insertBegin call.

@ -3,6 +3,7 @@
#include "cell.hpp" #include "cell.hpp"
#include "cellimp.hpp" #include "cellimp.hpp"
#include "../mwworld/physicssystem.hpp"
#include "OgreColourValue.h" #include "OgreColourValue.h"
#include <OgreSceneNode.h> #include <OgreSceneNode.h>
@ -48,6 +49,7 @@ namespace MWRender
ESMS::CellStore<MWWorld::RefData> &cell; ESMS::CellStore<MWWorld::RefData> &cell;
MWWorld::Environment &mEnvironment; MWWorld::Environment &mEnvironment;
MWScene &scene; MWScene &scene;
MWWorld::PhysicsSystem *mPhysics;
/// The scene node that contains all objects belonging to this /// The scene node that contains all objects belonging to this
/// cell. /// cell.
@ -93,8 +95,11 @@ namespace MWRender
public: public:
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment, InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
MWScene &_scene) MWScene &_scene, MWWorld::PhysicsSystem *physics)
: cell(_cell), mEnvironment (environment), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {} : cell(_cell), mEnvironment (environment), scene(_scene), base(NULL), insert(NULL), ambientMode (0)
{
mPhysics = physics;
}
virtual ~InteriorCellRender() { destroy(); } virtual ~InteriorCellRender() { destroy(); }

@ -11,7 +11,6 @@
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone #include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/doingphysics.hpp"
#include <components/esm/loadstat.hpp> #include <components/esm/loadstat.hpp>
#include "player.hpp" #include "player.hpp"
@ -43,7 +42,7 @@ MWScene::MWScene(OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicE
//used to obtain ingame information of ogre objects (which are faced or selected) //used to obtain ingame information of ogre objects (which are faced or selected)
mRaySceneQuery = rend.getScene()->createRayQuery(Ray()); mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode(); Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode ("player");
playerNode->pitch(Degree(90)); playerNode->pitch(Degree(90));
Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode(); Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode();
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode(); Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
@ -51,8 +50,6 @@ MWScene::MWScene(OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicE
mPlayer = new MWRender::Player (getCamera(), playerNode->getName()); mPlayer = new MWRender::Player (getCamera(), playerNode->getName());
mFreeFly = true;
} }
MWScene::~MWScene() MWScene::~MWScene()
@ -76,149 +73,6 @@ std::pair<std::string, float> MWScene::getFacedHandle (MWWorld::World& world)
return eng->rayTest(from,to); return eng->rayTest(from,to);
} }
void MWScene::doPhysics (float duration, MWWorld::World& world,
const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
{
// stop changes to world from being reported back to the physics system
MWWorld::DoingPhysics scopeGuard;
//set the DebugRenderingMode. To disable it,set it to 0
//eng->setDebugRenderingMode(1);
//set the walkdirection to 0 (no movement) for every actor)
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
{
OEngine::Physic::PhysicActor* act = it->second;
act->setWalkDirection(btVector3(0,0,0));
}
for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (actors.begin());
iter!=actors.end(); ++iter)
{
OEngine::Physic::PhysicActor* act = eng->getCharacter(iter->first);
//dirty stuff to get the camera orientation. Must be changed!
Ogre::SceneNode *sceneNode = rend.getScene()->getSceneNode (iter->first);
Ogre::Vector3 dir;
Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();
if(mFreeFly)
{
Ogre::Quaternion yawQuat = yawNode->getOrientation();
Ogre::Quaternion pitchQuat = pitchNode->getOrientation();
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
dir = 0.07*(yawQuat*pitchQuat*dir1);
}
else
{
Ogre::Quaternion quat = yawNode->getOrientation();
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
dir = 0.025*(quat*dir1);
}
//set the walk direction
act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y));
}
eng->stepSimulation(duration);
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
{
OEngine::Physic::PhysicActor* act = it->second;
btVector3 newPos = act->getPosition();
MWWorld::Ptr ptr = world.getPtrViaHandle (it->first);
world.moveObject (ptr, newPos.x(), newPos.y(), newPos.z());
}
}
void MWScene::addObject (const std::string& handle, const std::string& mesh,
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
{
OEngine::Physic::RigidBody* body = eng->createRigidBody(mesh,handle);
eng->addRigidBody(body);
btTransform tr;
tr.setOrigin(btVector3(position.x,position.y,position.z));
tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w));
body->setWorldTransform(tr);
}
void MWScene::addActor (const std::string& handle, const std::string& mesh,
const Ogre::Vector3& position)
{
//TODO:optimize this. Searching the std::map isn't very efficient i think.
eng->addCharacter(handle);
OEngine::Physic::PhysicActor* act = eng->getCharacter(handle);
act->setPosition(btVector3(position.x,position.y,position.z));
}
void MWScene::removeObject (const std::string& handle)
{
//TODO:check if actor???
eng->removeCharacter(handle);
eng->removeRigidBody(handle);
eng->deleteRigidBody(handle);
}
void MWScene::moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics)
{
rend.getScene()->getSceneNode(handle)->setPosition(position);
if(updatePhysics)//TODO: is it an actor? Done?
{
if (OEngine::Physic::RigidBody* body = eng->getRigidBody(handle))
{
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
// start positions others than 0, 0, 0
btTransform tr = body->getWorldTransform();
tr.setOrigin(btVector3(position.x,position.y,position.z));
body->setWorldTransform(tr);
}
if (OEngine::Physic::PhysicActor* act = eng->getCharacter(handle))
{
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
// start positions others than 0, 0, 0
act->setPosition(btVector3(position.x,position.y,position.z));
}
}
}
void MWScene::rotateObject (const std::string& handle, const Ogre::Quaternion& rotation)
{
}
void MWScene::scaleObject (const std::string& handle, float scale)
{
}
bool MWScene::toggleCollisionMode()
{
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
{
OEngine::Physic::PhysicActor* act = it->second;
bool cmode = act->getCollisionMode();
if(cmode)
{
act->enableCollisions(false);
act->setGravity(0.);
act->setVerticalVelocity(0);
mFreeFly = true;
return false;
}
else
{
mFreeFly = false;
act->enableCollisions(true);
act->setGravity(4.);
act->setVerticalVelocity(0);
return true;
}
}
return false; // This should never happen, but it shall not bother us now, since
// this part of the code needs a rewrite anyway.
}
bool MWScene::toggleRenderMode (int mode) bool MWScene::toggleRenderMode (int mode)
{ {
switch (mode) switch (mode)

@ -44,8 +44,6 @@ namespace MWRender
MWRender::Player *mPlayer; MWRender::Player *mPlayer;
bool mFreeFly;
public: public:
MWScene (OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng); MWScene (OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng);
@ -65,35 +63,6 @@ namespace MWRender
/// can be faced /// can be faced
std::pair<std::string, float> getFacedHandle (MWWorld::World& world); std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
/// Run physics simulation and modify \a world accordingly.
void doPhysics (float duration, MWWorld::World& world,
const std::vector<std::pair<std::string, Ogre::Vector3> >& actors);
/// Add object to physics system.
void addObject (const std::string& handle, const std::string& mesh,
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position);
/// Add actor to physics system.
void addActor (const std::string& handle, const std::string& mesh,
const Ogre::Vector3& position);
/// Remove object from physic systems.
void removeObject (const std::string& handle);
/// Move object.
void moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics);
/// Change object's orientation.
void rotateObject (const std::string& handle, const Ogre::Quaternion& rotation);
/// Change object's scale.
void scaleObject (const std::string& handle, float scale);
/// Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity.
/// \return Resulting mode
bool toggleCollisionMode();
/// Toggle render mode /// Toggle render mode
/// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed /// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed
/// when the mw*-refactoring is done. /// when the mw*-refactoring is done.

@ -0,0 +1,52 @@
#include "rendering_manager.hpp"
namespace MWRender {
RenderingManager::RenderingManager (SkyManager *skyManager) :
mSkyManager(skyManager)
{
}
RenderingManager::~RenderingManager ()
{
delete mSkyManager;
}
void RenderingManager::skyEnable ()
{
mSkyManager->enable();
}
void RenderingManager::skyDisable ()
{
mSkyManager->disable();
}
void RenderingManager::skySetHour (double hour)
{
mSkyManager->setHour(hour);
}
void RenderingManager::skySetDate (int day, int month)
{
mSkyManager->setDate(day, month);
}
int RenderingManager::skyGetMasserPhase() const
{
return mSkyManager->getMasserPhase();
}
int RenderingManager::skyGetSecundaPhase() const
{
return mSkyManager->getSecundaPhase();
}
void RenderingManager::skySetMoonColour (bool red)
{
mSkyManager->setMoonColour(red);
}
}

@ -0,0 +1,51 @@
#ifndef _GAME_RENDERING_MANAGER_H
#define _GAME_RENDERING_MANAGER_H
#include "sky.hpp"
#include "../mwworld/ptr.hpp"
#include <openengine/ogre/renderer.hpp>
#include <openengine/bullet/physic.hpp>
namespace MWRender
{
class RenderingManager {
public:
RenderingManager(SkyManager *skyManager);
~RenderingManager();
void removeCell (MWWorld::Ptr::CellStore *store); // TODO do we want this?
void addObject (const MWWorld::Ptr& ptr, MWWorld::Ptr::CellStore *store);
void removeObject (const MWWorld::Ptr& ptr, MWWorld::Ptr::CellStore *store);
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation);
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store);
void setPhysicsDebugRendering (bool);
bool getPhysicsDebugRendering() const;
void update (float duration);
void skyEnable ();
void skyDisable ();
void skySetHour (double hour);
void skySetDate (int day, int month);
int skyGetMasserPhase() const;
int skyGetSecundaPhase() const;
void skySetMoonColour (bool red);
private:
SkyManager* mSkyManager;
};
}
#endif

@ -0,0 +1,198 @@
#include "cells.hpp"
#include <cctype>
#include <algorithm>
MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
{
if (cell->data.flags & ESM::Cell::Interior)
{
std::map<std::string, Ptr::CellStore>::iterator result = mInteriors.find (cell->name);
if (result==mInteriors.end())
{
result = mInteriors.insert (std::make_pair (cell->name, Ptr::CellStore (cell))).first;
}
return &result->second;
}
else
{
std::map<std::pair<int, int>, Ptr::CellStore>::iterator result =
mExteriors.find (std::make_pair (cell->data.gridX, cell->data.gridY));
if (result==mExteriors.end())
{
result = mExteriors.insert (std::make_pair (
std::make_pair (cell->data.gridX, cell->data.gridY), Ptr::CellStore (cell))).first;
}
return &result->second;
}
}
MWWorld::Cells::Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader)
: mStore (store), mReader (reader) {}
MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y)
{
std::map<std::pair<int, int>, Ptr::CellStore>::iterator result =
mExteriors.find (std::make_pair (x, y));
if (result==mExteriors.end())
{
const ESM::Cell *cell = mStore.cells.findExt (x, y);
result = mExteriors.insert (std::make_pair (
std::make_pair (x, y), Ptr::CellStore (cell))).first;
result->second.load (mStore, mReader);
}
return &result->second;
}
MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name)
{
std::map<std::string, Ptr::CellStore>::iterator result = mInteriors.find (name);
if (result==mInteriors.end())
{
const ESM::Cell *cell = mStore.cells.findInt (name);
result = mInteriors.insert (std::make_pair (name, Ptr::CellStore (cell))).first;
result->second.load (mStore, mReader);
}
return &result->second;
}
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& cell)
{
if (cell.mState==Ptr::CellStore::State_Unloaded)
cell.preload (mStore, mReader);
if (cell.mState==Ptr::CellStore::State_Preloaded)
{
std::string lowerCase;
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
(int(*)(int)) std::tolower);
if (std::binary_search (cell.mIds.begin(), cell.mIds.end(), lowerCase))
cell.load (mStore, mReader);
else
return Ptr();
}
if (ESMS::LiveCellRef<ESM::Activator, RefData> *ref = cell.activators.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Potion, RefData> *ref = cell.potions.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Apparatus, RefData> *ref = cell.appas.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Armor, RefData> *ref = cell.armors.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Book, RefData> *ref = cell.books.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Clothing, RefData> *ref = cell.clothes.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Container, RefData> *ref = cell.containers.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Creature, RefData> *ref = cell.creatures.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Door, RefData> *ref = cell.doors.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Ingredient, RefData> *ref = cell.ingreds.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::CreatureLevList, RefData> *ref = cell.creatureLists.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::ItemLevList, RefData> *ref = cell.itemLists.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Light, RefData> *ref = cell.lights.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.lockpicks.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Miscellaneous, RefData> *ref = cell.miscItems.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = cell.npcs.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Probe, RefData> *ref = cell.probes.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Repair, RefData> *ref = cell.repairs.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Static, RefData> *ref = cell.statics.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Weapon, RefData> *ref = cell.weapons.find (name))
return Ptr (ref, &cell);
return Ptr();
}
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name)
{
// First check cells that are already listed
for (std::map<std::string, Ptr::CellStore>::iterator iter = mInteriors.begin();
iter!=mInteriors.end(); ++iter)
{
Ptr ptr = getPtr (name, iter->second);
if (!ptr.isEmpty())
return ptr;
}
for (std::map<std::pair<int, int>, Ptr::CellStore>::iterator iter = mExteriors.begin();
iter!=mExteriors.end(); ++iter)
{
Ptr ptr = getPtr (name, iter->second);
if (!ptr.isEmpty())
return ptr;
}
// Now try the other cells
for (ESMS::CellList::IntCells::const_iterator iter = mStore.cells.intCells.begin();
iter!=mStore.cells.intCells.end(); ++iter)
{
Ptr::CellStore *cellStore = getCellStore (iter->second);
Ptr ptr = getPtr (name, *cellStore);
if (!ptr.isEmpty())
return ptr;
}
for (ESMS::CellList::ExtCells::const_iterator iter = mStore.cells.extCells.begin();
iter!=mStore.cells.extCells.end(); ++iter)
{
Ptr::CellStore *cellStore = getCellStore (iter->second);
Ptr ptr = getPtr (name, *cellStore);
if (!ptr.isEmpty())
return ptr;
}
// giving up
return Ptr();
}

@ -0,0 +1,48 @@
#ifndef GAME_MWWORLD_CELLS_H
#define GAME_MWWORLD_CELLS_H
#include <map>
#include <string>
#include "ptr.hpp"
namespace ESM
{
class ESMReader;
}
namespace ESM
{
class ESMStore;
}
namespace MWWorld
{
/// \brief Cell container
class Cells
{
const ESMS::ESMStore& mStore;
ESM::ESMReader& mReader;
std::map<std::string, Ptr::CellStore> mInteriors;
std::map<std::pair<int, int>, Ptr::CellStore> mExteriors;
Cells (const Cells&);
Cells& operator= (const Cells&);
Ptr::CellStore *getCellStore (const ESM::Cell *cell);
public:
Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader);
Ptr::CellStore *getExterior (int x, int y);
Ptr::CellStore *getInterior (const std::string& name);
Ptr getPtr (const std::string& name, Ptr::CellStore& cellStore);
Ptr getPtr (const std::string& name);
};
}
#endif

@ -1,33 +0,0 @@
#include "doingphysics.hpp"
namespace MWWorld
{
int DoingPhysics::sCounter = 0;
int DoingPhysics::sSuppress = 0;
DoingPhysics::DoingPhysics()
{
++sCounter;
}
DoingPhysics::~DoingPhysics()
{
--sCounter;
}
bool DoingPhysics::isDoingPhysics()
{
return sCounter>0 && sSuppress==0;
}
SuppressDoingPhysics::SuppressDoingPhysics()
{
++DoingPhysics::sSuppress;
}
SuppressDoingPhysics::~SuppressDoingPhysics()
{
--DoingPhysics::sSuppress;
}
}

@ -1,46 +0,0 @@
#ifndef GAME_MWWORLD_DOINGPHYSICS_H
#define GAME_MWWORLD_DOINGPHYSICS_H
namespace MWWorld
{
class SuppressDoingPhysics;
/// Scope guard for blocking physics updates during physics simulation.
class DoingPhysics
{
static int sCounter;
static int sSuppress;
private:
DoingPhysics (const DoingPhysics&);
DoingPhysics& operator= (const DoingPhysics&);
public:
DoingPhysics();
~DoingPhysics();
static bool isDoingPhysics();
friend class SuppressDoingPhysics;
};
/// Scope guard for temporarily lifting the block issues by DoingPhysics
class SuppressDoingPhysics
{
private:
SuppressDoingPhysics (const SuppressDoingPhysics&);
SuppressDoingPhysics& operator= (const SuppressDoingPhysics&);
public:
SuppressDoingPhysics();
~SuppressDoingPhysics();
};
}
#endif

@ -0,0 +1,164 @@
#include "physicssystem.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/world.hpp" // FIXME
#include "OgreRoot.h"
#include "OgreRenderWindow.h"
#include "OgreSceneManager.h"
#include "OgreViewport.h"
#include "OgreCamera.h"
#include "OgreTextureManager.h"
namespace MWWorld
{
PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng) :
mRender(_rend), mEngine(physEng), mFreeFly (true)
{
}
PhysicsSystem::~PhysicsSystem()
{
}
std::vector< std::pair<std::string, Ogre::Vector3> > PhysicsSystem::doPhysics (float duration,
const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
{
//set the DebugRenderingMode. To disable it,set it to 0
//eng->setDebugRenderingMode(1);
//set the walkdirection to 0 (no movement) for every actor)
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
{
OEngine::Physic::PhysicActor* act = it->second;
act->setWalkDirection(btVector3(0,0,0));
}
for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (actors.begin());
iter!=actors.end(); ++iter)
{
OEngine::Physic::PhysicActor* act = mEngine->getCharacter(iter->first);
//dirty stuff to get the camera orientation. Must be changed!
Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first);
Ogre::Vector3 dir;
Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();
if(mFreeFly)
{
Ogre::Quaternion yawQuat = yawNode->getOrientation();
Ogre::Quaternion pitchQuat = pitchNode->getOrientation();
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
dir = 0.07*(yawQuat*pitchQuat*dir1);
}
else
{
Ogre::Quaternion quat = yawNode->getOrientation();
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
dir = 0.025*(quat*dir1);
}
//set the walk direction
act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y));
}
mEngine->stepSimulation(duration);
std::vector< std::pair<std::string, Ogre::Vector3> > response;
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
{
btVector3 newPos = it->second->getPosition();
Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z());
response.push_back(std::pair<std::string, Ogre::Vector3>(it->first, coord));
}
return response;
}
void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh,
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
{
OEngine::Physic::RigidBody* body = mEngine->createRigidBody(mesh,handle);
mEngine->addRigidBody(body);
btTransform tr;
tr.setOrigin(btVector3(position.x,position.y,position.z));
tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w));
body->setWorldTransform(tr);
}
void PhysicsSystem::addActor (const std::string& handle, const std::string& mesh,
const Ogre::Vector3& position)
{
//TODO:optimize this. Searching the std::map isn't very efficient i think.
mEngine->addCharacter(handle);
OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle);
act->setPosition(btVector3(position.x,position.y,position.z));
}
void PhysicsSystem::removeObject (const std::string& handle)
{
//TODO:check if actor???
mEngine->removeCharacter(handle);
mEngine->removeRigidBody(handle);
mEngine->deleteRigidBody(handle);
}
void PhysicsSystem::moveObject (const std::string& handle, const Ogre::Vector3& position)
{
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
{
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
// start positions others than 0, 0, 0
btTransform tr = body->getWorldTransform();
tr.setOrigin(btVector3(position.x,position.y,position.z));
body->setWorldTransform(tr);
}
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
{
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
// start positions others than 0, 0, 0
act->setPosition(btVector3(position.x,position.y,position.z));
}
}
void PhysicsSystem::rotateObject (const std::string& handle, const Ogre::Quaternion& rotation)
{
}
void PhysicsSystem::scaleObject (const std::string& handle, float scale)
{
}
bool PhysicsSystem::toggleCollisionMode()
{
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
{
OEngine::Physic::PhysicActor* act = it->second;
bool cmode = act->getCollisionMode();
if(cmode)
{
act->enableCollisions(false);
act->setGravity(0.);
act->setVerticalVelocity(0);
mFreeFly = true;
return false;
}
else
{
mFreeFly = false;
act->enableCollisions(true);
act->setGravity(4.);
act->setVerticalVelocity(0);
return true;
}
}
return false; // This should never happen, but it shall not bother us now, since
// this part of the code needs a rewrite anyway.
}
}

@ -0,0 +1,47 @@
#ifndef GAME_MWWORLD_PHYSICSSYSTEM_H
#define GAME_MWWORLD_PHYSICSSYSTEM_H
#include <vector>
#include <openengine/ogre/renderer.hpp>
#include <openengine/bullet/physic.hpp>
namespace MWWorld
{
class PhysicsSystem
{
public:
PhysicsSystem (OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng);
~PhysicsSystem ();
std::vector< std::pair<std::string, Ogre::Vector3> > doPhysics (float duration,
const std::vector<std::pair<std::string, Ogre::Vector3> >& actors);
void addObject (const std::string& handle, const std::string& mesh,
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position);
void addActor (const std::string& handle, const std::string& mesh,
const Ogre::Vector3& position);
void removeObject (const std::string& handle);
void moveObject (const std::string& handle, const Ogre::Vector3& position);
void rotateObject (const std::string& handle, const Ogre::Quaternion& rotation);
void scaleObject (const std::string& handle, float scale);
bool toggleCollisionMode();
private:
OEngine::Render::OgreRenderer &mRender;
OEngine::Physic::PhysicEngine* mEngine;
bool mFreeFly;
PhysicsSystem (const PhysicsSystem&);
PhysicsSystem& operator= (const PhysicsSystem&);
};
}
#endif

@ -13,11 +13,14 @@ namespace MWWorld
mAutoMove (false), mForwardBackward (0) mAutoMove (false), mForwardBackward (0)
{ {
mPlayer.base = player; mPlayer.base = player;
mPlayer.ref.refID = "player";
mName = player->name; mName = player->name;
mMale = !(player->flags & ESM::NPC::Female); mMale = !(player->flags & ESM::NPC::Female);
mRace = player->race; mRace = player->race;
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0; mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
std::cout << renderer->getHandle();
mPlayer.mData.setHandle (renderer->getHandle()); mPlayer.mData.setHandle (renderer->getHandle());
/// \todo Do not make a copy of classes defined in esm/p records.
mClass = new ESM::Class (*world.getStore().classes.find (player->cls)); mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
} }
@ -26,15 +29,10 @@ namespace MWWorld
delete mClass; delete mClass;
} }
void Player::setPos(float x, float y, float z, bool updateCamera) void Player::setPos(float x, float y, float z)
{ {
/// \todo This fcuntion should be removed during the mwrender-refactoring.
mWorld.moveObject (getPlayer(), x, y, z); mWorld.moveObject (getPlayer(), x, y, z);
if (updateCamera)
mRenderer->getCamera()->setPosition (Ogre::Vector3 (
mPlayer.ref.pos.pos[0],
mPlayer.ref.pos.pos[2],
-mPlayer.ref.pos.pos[1]));
} }
void Player::setClass (const ESM::Class& class_) void Player::setClass (const ESM::Class& class_)

@ -39,7 +39,7 @@ namespace MWWorld
~Player(); ~Player();
/// Set the player position. Uses Morrowind coordinates. /// Set the player position. Uses Morrowind coordinates.
void setPos(float _x, float _y, float _z, bool updateCamera = false); void setPos(float x, float y, float z);
void setCell (MWWorld::Ptr::CellStore *cellStore) void setCell (MWWorld::Ptr::CellStore *cellStore)
{ {

@ -0,0 +1,273 @@
#include "scene.hpp"
#include "world.hpp"
#include "../mwrender/interior.hpp"
#include "../mwrender/exterior.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwsound/soundmanager.hpp"
#include "ptr.hpp"
#include "environment.hpp"
#include "player.hpp"
#include "class.hpp"
#include "cellfunctors.hpp"
namespace {
template<typename T>
void insertCellRefList (T& cellRefList, ESMS::CellStore<MWWorld::RefData> &cell)
{
if (!cellRefList.list.empty())
{
//const MWWorld::Class& class_ = MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell));
for (typename T::List::iterator it = cellRefList.list.begin();
it != cellRefList.list.end(); it++)
{
if (it->mData.getCount() || it->mData.isEnabled())
{
MWWorld::Ptr ptr (&*it, &cell);
/* TODO: call
* RenderingManager.insertObject
* class_.insertObjectPhysic
* class_.insertObjectMechanics
*/
}
}
}
}
}
namespace MWWorld
{
void Scene::unloadCell (CellRenderCollection::iterator iter)
{
ListHandles functor;
iter->first->forEach<ListHandles>(functor);
{ // silence annoying g++ warning
for (std::vector<std::string>::const_iterator iter (functor.mHandles.begin());
iter!=functor.mHandles.end(); ++iter)
mPhysics->removeObject (*iter);
}
mWorld->removeScripts (iter->first);
mEnvironment.mMechanicsManager->dropActors (iter->first);
mEnvironment.mSoundManager->stopSound (iter->first);
delete iter->second;
mActiveCells.erase (iter);
}
void Scene::loadCell (Ptr::CellStore *cell, MWRender::CellRender *render)
{
// register local scripts
mWorld->insertInteriorScripts (*cell);
// This connects the cell data with the rendering scene.
std::pair<CellRenderCollection::iterator, bool> result =
mActiveCells.insert (std::make_pair (cell, render));
if (result.second)
{
// Load the cell and insert it into the renderer
result.first->second->show();
}
}
void Scene::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
bool adjustPlayerPos)
{
if (adjustPlayerPos)
mWorld->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2]);
mWorld->getPlayer().setCell (cell);
// TODO orientation
mEnvironment.mMechanicsManager->addActor (mWorld->getPlayer().getPlayer());
mEnvironment.mMechanicsManager->watchActor (mWorld->getPlayer().getPlayer());
}
void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos)
{
// remove active
mEnvironment.mMechanicsManager->removeActor (mWorld->getPlayer().getPlayer());
CellRenderCollection::iterator active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
if (!(active->first->cell->data.flags & ESM::Cell::Interior))
{
if (std::abs (X-active->first->cell->data.gridX)<=1 &&
std::abs (Y-active->first->cell->data.gridY)<=1)
{
// keep cells within the new 3x3 grid
++active;
continue;
}
}
unloadCell (active++);
}
// Load cells
for (int x=X-1; x<=X+1; ++x)
for (int y=Y-1; y<=Y+1; ++y)
{
CellRenderCollection::iterator iter = mActiveCells.begin();
while (iter!=mActiveCells.end())
{
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
if (x==iter->first->cell->data.gridX &&
y==iter->first->cell->data.gridY)
break;
++iter;
}
if (iter==mActiveCells.end())
{
Ptr::CellStore *cell = mWorld->getExterior(x, y);
loadCell (cell, new MWRender::ExteriorCellRender (*cell, mEnvironment, mScene, mPhysics));
}
}
// find current cell
CellRenderCollection::iterator iter = mActiveCells.begin();
while (iter!=mActiveCells.end())
{
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
if (X==iter->first->cell->data.gridX &&
Y==iter->first->cell->data.gridY)
break;
++iter;
}
assert (iter!=mActiveCells.end());
mCurrentCell = iter->first;
// adjust player
playerCellChange (mWorld->getExterior(X, Y), position, adjustPlayerPos);
// Sky system
mWorld->adjustSky();
mCellChanged = true;
}
Scene::Scene (Environment& environment, World *world, MWRender::MWScene& scene, PhysicsSystem *physics)
: mScene (scene), mCurrentCell (0),
mCellChanged (false), mEnvironment (environment), mWorld(world), mPhysics(physics)
{
}
Scene::~Scene()
{
for (CellRenderCollection::iterator iter (mActiveCells.begin());
iter!=mActiveCells.end(); ++iter)
delete iter->second;
}
bool Scene::hasCellChanged() const
{
return mCellChanged;
}
const Scene::CellRenderCollection& Scene::getActiveCells() const
{
return mActiveCells;
}
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
{
// remove active
CellRenderCollection::iterator active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
unloadCell (active++);
}
// Load cell.
std::cout << "cellName:" << cellName << std::endl;
Ptr::CellStore *cell = mWorld->getInterior(cellName);
loadCell (cell, new MWRender::InteriorCellRender (*cell, mEnvironment, mScene, mPhysics));
// adjust player
mCurrentCell = cell;
playerCellChange (cell, position);
// Sky system
mWorld->adjustSky();
mCellChanged = true;
//currentRegion->name = "";
}
void Scene::changeToExteriorCell (const ESM::Position& position)
{
int x = 0;
int y = 0;
mWorld->positionToIndex (position.pos[0], position.pos[1], x, y);
changeCell (x, y, position, true);
}
Ptr::CellStore* Scene::getCurrentCell ()
{
return mCurrentCell;
}
void Scene::markCellAsUnchanged()
{
mCellChanged = false;
}
/*#include <cassert>
#include <iostream>
#include <exception>
#include "../mwworld/class.hpp"
#include "../mwworld/ptr.hpp"*/
void Scene::insertCell(ESMS::CellStore<MWWorld::RefData> &cell)
{
// Loop through all references in the cell
insertCellRefList (cell.activators, cell);
insertCellRefList (cell.potions, cell);
insertCellRefList (cell.appas, cell);
insertCellRefList (cell.armors, cell);
insertCellRefList (cell.books, cell);
insertCellRefList (cell.clothes, cell);
insertCellRefList (cell.containers, cell);
insertCellRefList (cell.creatures, cell);
insertCellRefList (cell.doors, cell);
insertCellRefList (cell.ingreds, cell);
insertCellRefList (cell.creatureLists, cell);
insertCellRefList (cell.itemLists, cell);
insertCellRefList (cell.lights, cell);
insertCellRefList (cell.lockpicks, cell);
insertCellRefList (cell.miscItems, cell);
insertCellRefList (cell.npcs, cell);
insertCellRefList (cell.probes, cell);
insertCellRefList (cell.repairs, cell);
insertCellRefList (cell.statics, cell);
insertCellRefList (cell.weapons, cell);
}
}

@ -0,0 +1,105 @@
#ifndef GAME_MWWORLD_SCENE_H
#define GAME_MWWORLD_SCENE_H
#include <vector>
#include <map>
#include <boost/filesystem.hpp>
#include <components/esm_store/cell_store.hpp>
#include "../mwrender/mwscene.hpp"
#include "physicssystem.hpp"
#include "refdata.hpp"
#include "ptr.hpp"
#include "globals.hpp"
#include <openengine/bullet/physic.hpp>
namespace Ogre
{
class Vector3;
}
namespace ESM
{
struct Position;
}
namespace Files
{
class Collections;
}
namespace Render
{
class OgreRenderer;
}
namespace MWRender
{
class SkyManager;
class CellRender;
}
namespace MWWorld
{
class Environment;
class Player;
class Scene
{
public:
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
private:
MWRender::MWScene& mScene;
Ptr::CellStore *mCurrentCell; // the cell, the player is in
CellRenderCollection mActiveCells;
bool mCellChanged;
Environment& mEnvironment;
World *mWorld;
PhysicsSystem *mPhysics;
void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
bool adjustPlayerPos = true);
public:
Scene (Environment& environment, World *world, MWRender::MWScene& scene, PhysicsSystem *physics);
~Scene();
void unloadCell (CellRenderCollection::iterator iter);
void loadCell (Ptr::CellStore *cell, MWRender::CellRender *render);
void changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos);
///< Move from exterior to interior or from interior cell to a different
/// interior cell.
Ptr::CellStore* getCurrentCell ();
const CellRenderCollection& getActiveCells () const;
bool hasCellChanged() const;
///< Has the player moved to a different cell, since the last frame?
void changeToInteriorCell (const std::string& cellName, const ESM::Position& position);
///< Move to interior cell.
void changeToExteriorCell (const ESM::Position& position);
///< Move to exterior cell.
void markCellAsUnchanged();
// std::string getFacedHandle();
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell);
};
}
#endif

@ -1,4 +1,3 @@
#include "world.hpp" #include "world.hpp"
#include <cmath> #include <cmath>
@ -22,7 +21,6 @@
#include "refdata.hpp" #include "refdata.hpp"
#include "globals.hpp" #include "globals.hpp"
#include "doingphysics.hpp"
#include "cellfunctors.hpp" #include "cellfunctors.hpp"
namespace namespace
@ -91,71 +89,6 @@ namespace MWWorld
listCellScripts (mStore, cell.weapons, mLocalScripts, &cell); listCellScripts (mStore, cell.weapons, mLocalScripts, &cell);
} }
Ptr World::getPtr (const std::string& name, Ptr::CellStore& cell)
{
if (ESMS::LiveCellRef<ESM::Activator, RefData> *ref = cell.activators.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Potion, RefData> *ref = cell.potions.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Apparatus, RefData> *ref = cell.appas.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Armor, RefData> *ref = cell.armors.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Book, RefData> *ref = cell.books.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Clothing, RefData> *ref = cell.clothes.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Container, RefData> *ref = cell.containers.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Creature, RefData> *ref = cell.creatures.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Door, RefData> *ref = cell.doors.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Ingredient, RefData> *ref = cell.ingreds.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::CreatureLevList, RefData> *ref = cell.creatureLists.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::ItemLevList, RefData> *ref = cell.itemLists.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Light, RefData> *ref = cell.lights.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.lockpicks.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Miscellaneous, RefData> *ref = cell.miscItems.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = cell.npcs.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Probe, RefData> *ref = cell.probes.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Repair, RefData> *ref = cell.repairs.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Static, RefData> *ref = cell.statics.find (name))
return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Weapon, RefData> *ref = cell.weapons.find (name))
return Ptr (ref, &cell);
return Ptr();
}
Ptr World::getPtrViaHandle (const std::string& handle, Ptr::CellStore& cell) Ptr World::getPtrViaHandle (const std::string& handle, Ptr::CellStore& cell)
{ {
if (ESMS::LiveCellRef<ESM::Activator, RefData> *ref = if (ESMS::LiveCellRef<ESM::Activator, RefData> *ref =
@ -221,18 +154,12 @@ namespace MWWorld
MWRender::CellRender *World::searchRender (Ptr::CellStore *store) MWRender::CellRender *World::searchRender (Ptr::CellStore *store)
{ {
CellRenderCollection::iterator iter = mActiveCells.find (store); Scene::CellRenderCollection::const_iterator iter = mWorldScene->getActiveCells().find (store);
if (iter!=mActiveCells.end()) if (iter!=mWorldScene->getActiveCells().end())
{ {
return iter->second; return iter->second;
} }
else
{
iter = mBufferedCells.find (store);
if (iter!=mBufferedCells.end())
return iter->second;
}
return 0; return 0;
} }
@ -271,52 +198,6 @@ namespace MWWorld
} }
} }
void World::unloadCell (CellRenderCollection::iterator iter)
{
ListHandles functor;
iter->first->forEach<ListHandles>(functor);
{ // silence annoying g++ warning
for (std::vector<std::string>::const_iterator iter (functor.mHandles.begin());
iter!=functor.mHandles.end(); ++iter)
mScene.removeObject (*iter);
}
removeScripts (iter->first);
mEnvironment.mMechanicsManager->dropActors (iter->first);
mEnvironment.mSoundManager->stopSound (iter->first);
delete iter->second;
mActiveCells.erase (iter);
}
void World::loadCell (Ptr::CellStore *cell, MWRender::CellRender *render)
{
// register local scripts
insertInteriorScripts (*cell);
// This connects the cell data with the rendering scene.
std::pair<CellRenderCollection::iterator, bool> result =
mActiveCells.insert (std::make_pair (cell, render));
if (result.second)
{
// Load the cell and insert it into the renderer
result.first->second->show();
}
}
void World::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
bool adjustPlayerPos)
{
if (adjustPlayerPos)
mPlayer->setPos (position.pos[0], position.pos[1], position.pos[2], false);
mPlayer->setCell (cell);
// TODO orientation
mEnvironment.mMechanicsManager->addActor (mPlayer->getPlayer());
mEnvironment.mMechanicsManager->watchActor (mPlayer->getPlayer());
}
void World::adjustSky() void World::adjustSky()
{ {
@ -328,93 +209,17 @@ namespace MWWorld
} }
} }
void World::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos)
{
SuppressDoingPhysics scopeGuard;
// remove active
mEnvironment.mMechanicsManager->removeActor (mPlayer->getPlayer());
CellRenderCollection::iterator active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
if (!(active->first->cell->data.flags & ESM::Cell::Interior))
{
if (std::abs (X-active->first->cell->data.gridX)<=1 &&
std::abs (Y-active->first->cell->data.gridY)<=1)
{
// keep cells within the new 3x3 grid
++active;
continue;
}
}
unloadCell (active++);
}
// Load cells
for (int x=X-1; x<=X+1; ++x)
for (int y=Y-1; y<=Y+1; ++y)
{
CellRenderCollection::iterator iter = mActiveCells.begin();
while (iter!=mActiveCells.end())
{
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
if (x==iter->first->cell->data.gridX &&
y==iter->first->cell->data.gridY)
break;
++iter;
}
if (iter==mActiveCells.end())
{
mExteriors[std::make_pair (x, y)].loadExt (x, y, mStore, mEsm);
Ptr::CellStore *cell = &mExteriors[std::make_pair (x, y)];
loadCell (cell, new MWRender::ExteriorCellRender (*cell, mEnvironment, mScene));
}
}
// find current cell
CellRenderCollection::iterator iter = mActiveCells.begin();
while (iter!=mActiveCells.end())
{
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
if (X==iter->first->cell->data.gridX &&
Y==iter->first->cell->data.gridY)
break;
++iter;
}
assert (iter!=mActiveCells.end());
mCurrentCell = iter->first;
// adjust player
playerCellChange (&mExteriors[std::make_pair (X, Y)], position, adjustPlayerPos);
// Sky system
adjustSky();
mCellChanged = true;
}
World::World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng, World::World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng,
const Files::Collections& fileCollections, const Files::Collections& fileCollections,
const std::string& master, const boost::filesystem::path& resDir, const std::string& master, const boost::filesystem::path& resDir,
bool newGame, Environment& environment, const std::string& encoding) bool newGame, Environment& environment, const std::string& encoding)
: mSkyManager (0), mScene (renderer,physEng), mPlayer (0), mCurrentCell (0), mGlobalVariables (0), : mScene (renderer,physEng), mPlayer (0), mGlobalVariables (0),
mSky (false), mCellChanged (false), mEnvironment (environment), mNextDynamicRecord (0) mSky (false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm)
{ {
mPhysEngine = physEng; mPhysEngine = physEng;
mPhysics = new PhysicsSystem(renderer, physEng);
boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master)); boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master));
std::cout << "Loading ESM " << masterPath.string() << "\n"; std::cout << "Loading ESM " << masterPath.string() << "\n";
@ -425,7 +230,7 @@ namespace MWWorld
mStore.load (mEsm); mStore.load (mEsm);
mPlayer = new MWWorld::Player (mScene.getPlayer(), mStore.npcs.find ("player"), *this); mPlayer = new MWWorld::Player (mScene.getPlayer(), mStore.npcs.find ("player"), *this);
mScene.addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0)); mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0));
// global variables // global variables
mGlobalVariables = new Globals (mStore); mGlobalVariables = new Globals (mStore);
@ -436,25 +241,54 @@ namespace MWWorld
mGlobalVariables->setInt ("chargenstate", 1); mGlobalVariables->setInt ("chargenstate", 1);
} }
mSkyManager =
MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera(), resDir);
mPhysEngine = physEng; mPhysEngine = physEng;
mWorldScene = new Scene(environment, this, mScene, mPhysics);
mRenderingManager = new MWRender::RenderingManager(
MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera(), resDir)
);
} }
World::~World() World::~World()
{ {
for (CellRenderCollection::iterator iter (mActiveCells.begin()); delete mWorldScene;
iter!=mActiveCells.end(); ++iter) delete mGlobalVariables;
delete iter->second; delete mPlayer;
delete mPhysics;
}
for (CellRenderCollection::iterator iter (mBufferedCells.begin()); const ESM::Cell *World::getExterior (const std::string& cellName) const
iter!=mBufferedCells.end(); ++iter) {
delete iter->second; // first try named cells
if (const ESM::Cell *cell = mStore.cells.searchExtByName (cellName))
return cell;
delete mPlayer; // didn't work -> now check for regions
delete mSkyManager; std::string cellName2 = ESMS::RecListT<ESM::Region>::toLower (cellName);
delete mGlobalVariables;
for (ESMS::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin());
iter!=mStore.regions.list.end(); ++iter)
{
if (ESMS::RecListT<ESM::Region>::toLower (iter->second.name)==cellName2)
{
if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first))
return cell;
break;
}
}
return 0;
}
Ptr::CellStore *World::getExterior (int x, int y)
{
return mCells.getExterior (x, y);
}
Ptr::CellStore *World::getInterior (const std::string& name)
{
return mCells.getInterior (name);
} }
MWWorld::Player& World::getPlayer() MWWorld::Player& World::getPlayer()
@ -467,6 +301,11 @@ namespace MWWorld
return mStore; return mStore;
} }
ESM::ESMReader& World::getEsmReader()
{
return mEsm;
}
const World::ScriptList& World::getLocalScripts() const const World::ScriptList& World::getLocalScripts() const
{ {
return mLocalScripts; return mLocalScripts;
@ -474,7 +313,7 @@ namespace MWWorld
bool World::hasCellChanged() const bool World::hasCellChanged() const
{ {
return mCellChanged; return mWorldScene->hasCellChanged();
} }
Globals::Data& World::getGlobalVariable (const std::string& name) Globals::Data& World::getGlobalVariable (const std::string& name)
@ -501,10 +340,10 @@ namespace MWWorld
} }
// active cells // active cells
for (CellRenderCollection::iterator iter (mActiveCells.begin()); for (Scene::CellRenderCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
iter!=mActiveCells.end(); ++iter) iter!=mWorldScene->getActiveCells().end(); ++iter)
{ {
Ptr ptr = getPtr (name, *iter->first); Ptr ptr = mCells.getPtr (name, *iter->first);
if (!ptr.isEmpty()) if (!ptr.isEmpty())
return ptr; return ptr;
@ -512,7 +351,10 @@ namespace MWWorld
if (!activeOnly) if (!activeOnly)
{ {
// TODO: inactive cells Ptr ptr = mCells.getPtr (name);
if (!ptr.isEmpty())
return ptr;
} }
throw std::runtime_error ("unknown ID: " + name); throw std::runtime_error ("unknown ID: " + name);
@ -523,8 +365,8 @@ namespace MWWorld
if (mPlayer->getPlayer().getRefData().getHandle()==handle) if (mPlayer->getPlayer().getRefData().getHandle()==handle)
return mPlayer->getPlayer(); return mPlayer->getPlayer();
for (CellRenderCollection::iterator iter (mActiveCells.begin()); for (Scene::CellRenderCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
iter!=mActiveCells.end(); ++iter) iter!=mWorldScene->getActiveCells().end(); ++iter)
{ {
Ptr ptr = getPtrViaHandle (handle, *iter->first); Ptr ptr = getPtrViaHandle (handle, *iter->first);
@ -545,7 +387,7 @@ namespace MWWorld
{ {
render->enable (reference.getRefData().getHandle()); render->enable (reference.getRefData().getHandle());
if (mActiveCells.find (reference.getCell())!=mActiveCells.end()) if (mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end())
Class::get (reference).enable (reference, mEnvironment); Class::get (reference).enable (reference, mEnvironment);
} }
} }
@ -561,7 +403,7 @@ namespace MWWorld
{ {
render->disable (reference.getRefData().getHandle()); render->disable (reference.getRefData().getHandle());
if (mActiveCells.find (reference.getCell())!=mActiveCells.end()) if (mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end())
{ {
Class::get (reference).disable (reference, mEnvironment); Class::get (reference).disable (reference, mEnvironment);
mEnvironment.mSoundManager->stopSound3D (reference); mEnvironment.mSoundManager->stopSound3D (reference);
@ -593,7 +435,7 @@ namespace MWWorld
mGlobalVariables->setFloat ("gamehour", hour); mGlobalVariables->setFloat ("gamehour", hour);
mSkyManager->setHour (hour); mRenderingManager->skySetHour (hour);
if (days>0) if (days>0)
setDay (days + mGlobalVariables->getInt ("day")); setDay (days + mGlobalVariables->getInt ("day"));
@ -628,7 +470,7 @@ namespace MWWorld
mGlobalVariables->setInt ("day", day); mGlobalVariables->setInt ("day", day);
mGlobalVariables->setInt ("month", month); mGlobalVariables->setInt ("month", month);
mSkyManager->setDate (day, month); mRenderingManager->skySetDate (day, month);
} }
void World::setMonth (int month) void World::setMonth (int month)
@ -649,7 +491,7 @@ namespace MWWorld
if (years>0) if (years>0)
mGlobalVariables->setInt ("year", years+mGlobalVariables->getInt ("year")); mGlobalVariables->setInt ("year", years+mGlobalVariables->getInt ("year"));
mSkyManager->setDate (mGlobalVariables->getInt ("day"), month); mRenderingManager->skySetDate (mGlobalVariables->getInt ("day"), month);
} }
bool World::toggleSky() bool World::toggleSky()
@ -657,34 +499,34 @@ namespace MWWorld
if (mSky) if (mSky)
{ {
mSky = false; mSky = false;
mSkyManager->disable(); mRenderingManager->skyDisable();
return false; return false;
} }
else else
{ {
mSky = true; mSky = true;
// TODO check for extorior or interior with sky. // TODO check for extorior or interior with sky.
mSkyManager->setHour (mGlobalVariables->getFloat ("gamehour")); mRenderingManager->skySetHour (mGlobalVariables->getFloat ("gamehour"));
mSkyManager->setDate (mGlobalVariables->getInt ("day"), mRenderingManager->skySetDate (mGlobalVariables->getInt ("day"),
mGlobalVariables->getInt ("month")); mGlobalVariables->getInt ("month"));
mSkyManager->enable(); mRenderingManager->skyEnable();
return true; return true;
} }
} }
int World::getMasserPhase() const int World::getMasserPhase() const
{ {
return mSkyManager->getMasserPhase(); return mRenderingManager->skyGetMasserPhase();
} }
int World::getSecundaPhase() const int World::getSecundaPhase() const
{ {
return mSkyManager->getSecundaPhase(); return mRenderingManager->skyGetSecundaPhase();
} }
void World::setMoonColour (bool red) void World::setMoonColour (bool red)
{ {
mSkyManager->setMoonColour (red); mRenderingManager->skySetMoonColour (red);
} }
float World::getTimeScaleFactor() const float World::getTimeScaleFactor() const
@ -694,70 +536,17 @@ namespace MWWorld
void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
{ {
SuppressDoingPhysics scopeGuard; return mWorldScene->changeToInteriorCell(cellName, position);
// remove active
CellRenderCollection::iterator active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
unloadCell (active++);
}
// Load cell.
mInteriors[cellName].loadInt (cellName, mStore, mEsm);
Ptr::CellStore *cell = &mInteriors[cellName];
loadCell (cell, new MWRender::InteriorCellRender (*cell, mEnvironment, mScene));
// adjust player
mCurrentCell = cell;
playerCellChange (cell, position);
// Sky system
adjustSky();
mCellChanged = true;
//currentRegion->name = "";
} }
void World::changeToExteriorCell (const ESM::Position& position) void World::changeToExteriorCell (const ESM::Position& position)
{ {
int x = 0; return mWorldScene->changeToExteriorCell(position);
int y = 0;
positionToIndex (position.pos[0], position.pos[1], x, y);
changeCell (x, y, position, true);
}
const ESM::Cell *World::getExterior (const std::string& cellName) const
{
// first try named cells
if (const ESM::Cell *cell = mStore.cells.searchExtByName (cellName))
return cell;
// didn't work -> now check for regions
std::string cellName2 = ESMS::RecListT<ESM::Region>::toLower (cellName);
for (ESMS::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin());
iter!=mStore.regions.list.end(); ++iter)
{
if (ESMS::RecListT<ESM::Region>::toLower (iter->second.name)==cellName2)
{
if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first))
return cell;
break;
}
}
return 0;
} }
void World::markCellAsUnchanged() void World::markCellAsUnchanged()
{ {
mCellChanged = false; return mWorldScene->markCellAsUnchanged();
} }
std::string World::getFacedHandle() std::string World::getFacedHandle()
@ -779,13 +568,12 @@ namespace MWWorld
if (MWRender::CellRender *render = searchRender (ptr.getCell())) if (MWRender::CellRender *render = searchRender (ptr.getCell()))
{ {
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end()) if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end())
{ {
Class::get (ptr).disable (ptr, mEnvironment); Class::get (ptr).disable (ptr, mEnvironment);
mEnvironment.mSoundManager->stopSound3D (ptr); mEnvironment.mSoundManager->stopSound3D (ptr);
if (!DoingPhysics::isDoingPhysics()) mPhysics->removeObject (ptr.getRefData().getHandle());
mScene.removeObject (ptr.getRefData().getHandle());
} }
render->deleteObject (ptr.getRefData().getHandle()); render->deleteObject (ptr.getRefData().getHandle());
@ -794,7 +582,7 @@ namespace MWWorld
} }
} }
void World::moveObject (Ptr ptr, float x, float y, float z) void World::moveObjectImp (Ptr ptr, float x, float y, float z)
{ {
ptr.getCellRef().pos.pos[0] = x; ptr.getCellRef().pos.pos[0] = x;
ptr.getCellRef().pos.pos[1] = y; ptr.getCellRef().pos.pos[1] = y;
@ -802,9 +590,10 @@ namespace MWWorld
if (ptr==mPlayer->getPlayer()) if (ptr==mPlayer->getPlayer())
{ {
if (mCurrentCell) Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
if (currentCell)
{ {
if (!(mCurrentCell->cell->data.flags & ESM::Cell::Interior)) if (!(currentCell->cell->data.flags & ESM::Cell::Interior))
{ {
// exterior -> adjust loaded cells // exterior -> adjust loaded cells
int cellX = 0; int cellX = 0;
@ -812,19 +601,27 @@ namespace MWWorld
positionToIndex (x, y, cellX, cellY); positionToIndex (x, y, cellX, cellY);
if (mCurrentCell->cell->data.gridX!=cellX || mCurrentCell->cell->data.gridY!=cellY) if (currentCell->cell->data.gridX!=cellX || currentCell->cell->data.gridY!=cellY)
{ {
changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos, false); mWorldScene->changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos, false);
} }
} }
} }
} }
mScene.moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z), // \todo cell change for non-player ref
!DoingPhysics::isDoingPhysics());
// \todo this should go into the new scene class and eventually into the objects/actors classes.
mScene.getMgr()->getSceneNode (ptr.getRefData().getHandle())->
setPosition (Ogre::Vector3 (x, y, z));
}
void World::moveObject (Ptr ptr, float x, float y, float z)
{
moveObjectImp(ptr, x, y, z);
// TODO cell change for non-player ref mPhysics->moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z));
} }
void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const
@ -859,12 +656,34 @@ namespace MWWorld
void World::doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors, void World::doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
float duration) float duration)
{ {
mScene.doPhysics (duration, *this, actors); std::vector< std::pair<std::string, Ogre::Vector3> > vectors = mPhysics->doPhysics (duration, actors);
std::vector< std::pair<std::string, Ogre::Vector3> >::iterator player = vectors.end();
for (std::vector< std::pair<std::string, Ogre::Vector3> >::iterator it = vectors.begin();
it!= vectors.end(); ++it)
{
if (it->first=="player")
{
player = it;
}
else
{
MWWorld::Ptr ptr = getPtrViaHandle (it->first);
moveObjectImp (ptr, it->second.x, it->second.y, it->second.z);
}
}
// Make sure player is moved last (otherwise the cell might change in the middle of an update
// loop)
if (player!=vectors.end())
moveObjectImp (getPtrViaHandle (player->first),
player->second.x, player->second.y, player->second.z);
} }
bool World::toggleCollisionMode() bool World::toggleCollisionMode()
{ {
return mScene.toggleCollisionMode(); return mPhysics->toggleCollisionMode();
} }
bool World::toggleRenderMode (RenderMode mode) bool World::toggleRenderMode (RenderMode mode)

@ -9,10 +9,14 @@
#include <components/esm_store/cell_store.hpp> #include <components/esm_store/cell_store.hpp>
#include "../mwrender/mwscene.hpp" #include "../mwrender/mwscene.hpp"
#include "../mwrender/rendering_manager.hpp"
#include "refdata.hpp" #include "refdata.hpp"
#include "ptr.hpp" #include "ptr.hpp"
#include "globals.hpp" #include "globals.hpp"
#include "scene.hpp"
#include "physicssystem.hpp"
#include "cells.hpp"
#include <openengine/bullet/physic.hpp> #include <openengine/bullet/physic.hpp>
@ -62,55 +66,35 @@ namespace MWWorld
private: private:
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
MWRender::SkyManager* mSkyManager;
MWRender::MWScene mScene; MWRender::MWScene mScene;
MWWorld::Scene *mWorldScene;
MWWorld::Player *mPlayer; MWWorld::Player *mPlayer;
Ptr::CellStore *mCurrentCell; // the cell, the player is in
CellRenderCollection mActiveCells;
CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet)
ESM::ESMReader mEsm; ESM::ESMReader mEsm;
ESMS::ESMStore mStore; ESMS::ESMStore mStore;
std::map<std::string, Ptr::CellStore> mInteriors;
std::map<std::pair<int, int>, Ptr::CellStore> mExteriors;
ScriptList mLocalScripts; ScriptList mLocalScripts;
MWWorld::Globals *mGlobalVariables; MWWorld::Globals *mGlobalVariables;
MWWorld::PhysicsSystem *mPhysics;
bool mSky; bool mSky;
bool mCellChanged;
Environment& mEnvironment; Environment& mEnvironment;
MWRender::RenderingManager *mRenderingManager;
int mNextDynamicRecord; int mNextDynamicRecord;
Cells mCells;
OEngine::Physic::PhysicEngine* mPhysEngine; OEngine::Physic::PhysicEngine* mPhysEngine;
// not implemented // not implemented
World (const World&); World (const World&);
World& operator= (const World&); World& operator= (const World&);
void insertInteriorScripts (ESMS::CellStore<RefData>& cell);
Ptr getPtr (const std::string& name, Ptr::CellStore& cellStore);
Ptr getPtrViaHandle (const std::string& handle, Ptr::CellStore& cellStore); Ptr getPtrViaHandle (const std::string& handle, Ptr::CellStore& cellStore);
MWRender::CellRender *searchRender (Ptr::CellStore *store); MWRender::CellRender *searchRender (Ptr::CellStore *store);
int getDaysPerMonth (int month) const; int getDaysPerMonth (int month) const;
void removeScripts (Ptr::CellStore *cell); void moveObjectImp (Ptr ptr, float x, float y, float z);
void unloadCell (CellRenderCollection::iterator iter);
void loadCell (Ptr::CellStore *cell, MWRender::CellRender *render);
void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
bool adjustPlayerPos = true);
void adjustSky();
void changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos);
///< Move from exterior to interior or from interior cell to a different
/// interior cell.
public: public:
World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng, World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng,
@ -120,10 +104,22 @@ namespace MWWorld
~World(); ~World();
Ptr::CellStore *getExterior (int x, int y);
Ptr::CellStore *getInterior (const std::string& name);
void removeScripts (Ptr::CellStore *cell);
void insertInteriorScripts (ESMS::CellStore<RefData>& cell);
void adjustSky();
MWWorld::Player& getPlayer(); MWWorld::Player& getPlayer();
const ESMS::ESMStore& getStore() const; const ESMS::ESMStore& getStore() const;
ESM::ESMReader& getEsmReader();
const ScriptList& getLocalScripts() const; const ScriptList& getLocalScripts() const;
///< Names and local variable state of all local scripts in active cells. ///< Names and local variable state of all local scripts in active cells.

@ -0,0 +1,157 @@
#include "configurationmanager.hpp"
#include <string>
#include <fstream>
#include <iostream>
namespace Cfg
{
static const char* const openmwCfgFile = "openmw.cfg";
static const char* const ogreCfgFile = "ogre.cfg";
static const char* const pluginsCfgFile = "plugins.cfg";
ConfigurationManager::ConfigurationManager()
: mPath("openmw")
{
/**
* According to task #168 plugins.cfg file shall be located in global
* configuration path or in runtime configuration path.
*/
mPluginsCfgPath = mPath.getGlobalConfigPath() / pluginsCfgFile;
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
{
mPluginsCfgPath = mPath.getRuntimeConfigPath() / pluginsCfgFile;
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
{
std::cerr << "Failed to find " << pluginsCfgFile << " file!" << std::endl;
mPluginsCfgPath.clear();
}
}
/**
* According to task #168 ogre.cfg file shall be located only
* in user configuration path.
*/
mOgreCfgPath = mPath.getLocalConfigPath() / ogreCfgFile;
mLogPath = mPath.getLocalConfigPath();
}
ConfigurationManager::~ConfigurationManager()
{
}
void ConfigurationManager::readConfiguration(boost::program_options::variables_map& variables,
boost::program_options::options_description& description)
{
loadConfig(mPath.getLocalConfigPath(), variables, description);
boost::program_options::notify(variables);
loadConfig(mPath.getRuntimeConfigPath(), variables, description);
boost::program_options::notify(variables);
loadConfig(mPath.getGlobalConfigPath(), variables, description);
boost::program_options::notify(variables);
}
void ConfigurationManager::loadConfig(const boost::filesystem::path& path,
boost::program_options::variables_map& variables,
boost::program_options::options_description& description)
{
boost::filesystem::path cfgFile(path);
cfgFile /= std::string(openmwCfgFile);
if (boost::filesystem::is_regular_file(cfgFile))
{
std::cout << "Loading config file: " << cfgFile.string() << "... ";
std::ifstream configFileStream(cfgFile.string().c_str());
if (configFileStream.is_open())
{
boost::program_options::store(boost::program_options::parse_config_file(
configFileStream, description), variables);
std::cout << "done." << std::endl;
}
else
{
std::cout << "failed." << std::endl;
}
}
}
const boost::filesystem::path& ConfigurationManager::getGlobalConfigPath() const
{
return mPath.getGlobalConfigPath();
}
void ConfigurationManager::setGlobalConfigPath(const boost::filesystem::path& newPath)
{
mPath.setGlobalConfigPath(newPath);
}
const boost::filesystem::path& ConfigurationManager::getLocalConfigPath() const
{
return mPath.getLocalConfigPath();
}
void ConfigurationManager::setLocalConfigPath(const boost::filesystem::path& newPath)
{
mPath.setLocalConfigPath(newPath);
}
const boost::filesystem::path& ConfigurationManager::getRuntimeConfigPath() const
{
return mPath.getRuntimeConfigPath();
}
void ConfigurationManager::setRuntimeConfigPath(const boost::filesystem::path& newPath)
{
mPath.setRuntimeConfigPath(newPath);
}
const boost::filesystem::path& ConfigurationManager::getGlobalDataPath() const
{
return mPath.getGlobalDataPath();
}
void ConfigurationManager::setGlobalDataPath(const boost::filesystem::path& newPath)
{
mPath.setGlobalDataPath(newPath);
}
const boost::filesystem::path& ConfigurationManager::getLocalDataPath() const
{
return mPath.getLocalDataPath();
}
void ConfigurationManager::setLocalDataPath(const boost::filesystem::path& newPath)
{
mPath.setLocalDataPath(newPath);
}
const boost::filesystem::path& ConfigurationManager::getRuntimeDataPath() const
{
return mPath.getRuntimeDataPath();
}
void ConfigurationManager::setRuntimeDataPath(const boost::filesystem::path& newPath)
{
mPath.setRuntimeDataPath(newPath);
}
const boost::filesystem::path& ConfigurationManager::getOgreConfigPath() const
{
return mOgreCfgPath;
}
const boost::filesystem::path& ConfigurationManager::getPluginsConfigPath() const
{
return mPluginsCfgPath;
}
const boost::filesystem::path& ConfigurationManager::getLogPath() const
{
return mLogPath;
}
} /* namespace Cfg */

@ -0,0 +1,62 @@
#ifndef COMPONENTS_CFG_CONFIGURATIONMANAGER_HPP
#define COMPONENTS_CFG_CONFIGURATIONMANAGER_HPP
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <components/files/path.hpp>
/**
* \namespace Cfg
*/
namespace Cfg
{
/**
* \struct ConfigurationManager
*/
struct ConfigurationManager
{
ConfigurationManager();
virtual ~ConfigurationManager();
void readConfiguration(boost::program_options::variables_map& variables,
boost::program_options::options_description& description);
const boost::filesystem::path& getGlobalConfigPath() const;
void setGlobalConfigPath(const boost::filesystem::path& newPath);
const boost::filesystem::path& getLocalConfigPath() const;
void setLocalConfigPath(const boost::filesystem::path& newPath);
const boost::filesystem::path& getRuntimeConfigPath() const;
void setRuntimeConfigPath(const boost::filesystem::path& newPath);
const boost::filesystem::path& getGlobalDataPath() const;
void setGlobalDataPath(const boost::filesystem::path& newPath);
const boost::filesystem::path& getLocalDataPath() const;
void setLocalDataPath(const boost::filesystem::path& newPath);
const boost::filesystem::path& getRuntimeDataPath() const;
void setRuntimeDataPath(const boost::filesystem::path& newPath);
const boost::filesystem::path& getOgreConfigPath() const;
const boost::filesystem::path& getPluginsConfigPath() const;
const boost::filesystem::path& getLogPath() const;
private:
void loadConfig(const boost::filesystem::path& path,
boost::program_options::variables_map& variables,
boost::program_options::options_description& description);
Files::Path<> mPath;
boost::filesystem::path mOgreCfgPath;
boost::filesystem::path mPluginsCfgPath;
boost::filesystem::path mLogPath;
};
} /* namespace Cfg */
#endif /* COMPONENTS_CFG_CONFIGURATIONMANAGER_HPP */

@ -1,5 +1,8 @@
#include "loadcell.hpp" #include "loadcell.hpp"
#include <string>
#include <sstream>
namespace ESM namespace ESM
{ {
@ -47,6 +50,20 @@ void Cell::restore(ESMReader &esm) const
esm.restoreContext(context); esm.restoreContext(context);
} }
std::string Cell::getDescription() const
{
if (data.flags & Interior)
{
return name;
}
else
{
std::ostringstream stream;
stream << data.gridX << ", " << data.gridY;
return stream.str();
}
}
bool Cell::getNextRef(ESMReader &esm, CellRef &ref) bool Cell::getNextRef(ESMReader &esm, CellRef &ref)
{ {
if (!esm.hasMoreSubs()) if (!esm.hasMoreSubs())

@ -126,6 +126,9 @@ struct Cell
// exactly. // exactly.
void restore(ESMReader &esm) const; void restore(ESMReader &esm) const;
std::string getDescription() const;
///< Return a short string describing the cell (mostly used for debugging/logging purpose)
/* Get the next reference in this cell, if any. Returns false when /* Get the next reference in this cell, if any. Returns false when
there are no more references in the cell. there are no more references in the cell.

@ -13,8 +13,10 @@
#include "store.hpp" #include "store.hpp"
#include "components/esm/records.hpp" #include "components/esm/records.hpp"
#include "components/esm/loadcell.hpp" #include "components/esm/loadcell.hpp"
#include <list>
#include <list>
#include <string>
#include <vector>
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include <algorithm> #include <algorithm>
@ -81,9 +83,17 @@ namespace ESMS
class CellStore class CellStore
{ {
public: public:
CellStore() : cell (0) {}
enum State
{
State_Unloaded, State_Preloaded, State_Loaded
};
CellStore (const ESM::Cell *cell_) : cell (cell_), mState (State_Unloaded) {}
const ESM::Cell *cell; const ESM::Cell *cell;
State mState;
std::vector<std::string> mIds;
// Lists for each individual object type // Lists for each individual object type
CellRefList<Activator, D> activators; CellRefList<Activator, D> activators;
@ -107,31 +117,29 @@ namespace ESMS
CellRefList<Static, D> statics; CellRefList<Static, D> statics;
CellRefList<Weapon, D> weapons; CellRefList<Weapon, D> weapons;
/** Look up and load an interior cell from the given ESM data void load (const ESMStore &store, ESMReader &esm)
storage. */
void loadInt(const std::string &name, const ESMStore &store, ESMReader &esm)
{ {
std::cout << "loading cell '" << name << "'\n"; if (mState!=State_Loaded)
{
if (mState==State_Preloaded)
mIds.clear();
cell = store.cells.findInt(name); std::cout << "loading cell " << cell->getDescription() << std::endl;
if(cell == NULL) loadRefs (store, esm);
throw std::runtime_error("Cell not found - " + name);
loadRefs(store, esm); mState = State_Loaded;
}
} }
/** Ditto for exterior cell. */ void preload (const ESMStore &store, ESMReader &esm)
void loadExt(int X, int Y, const ESMStore &store, ESMReader &esm)
{ {
std::cout << "loading exterior cell '" << X << ", " << Y << "'\n"; if (mState==State_Unloaded)
{
cell = store.cells.searchExt (X, Y); listRefs (store, esm);
if(cell == NULL)
throw std::runtime_error("Exterior cell not found");
loadRefs(store, esm); mState = State_Preloaded;
}
} }
/// Call functor (ref) for each reference. functor must return a bool. Returning /// Call functor (ref) for each reference. functor must return a bool. Returning
@ -176,6 +184,30 @@ namespace ESMS
return true; return true;
} }
/// Run through references and store IDs
void listRefs(const ESMStore &store, ESMReader &esm)
{
assert (cell);
// Reopen the ESM reader and seek to the right position.
cell->restore (esm);
CellRef ref;
// Get each reference in turn
while (cell->getNextRef (esm, ref))
{
std::string lowerCase;
std::transform (ref.refID.begin(), ref.refID.end(), std::back_inserter (lowerCase),
(int(*)(int)) std::tolower);
mIds.push_back (lowerCase);
}
std::sort (mIds.begin(), mIds.end());
}
void loadRefs(const ESMStore &store, ESMReader &esm) void loadRefs(const ESMStore &store, ESMReader &esm)
{ {
assert (cell); assert (cell);

@ -287,8 +287,7 @@ namespace ESMS
IntCells intCells; IntCells intCells;
// List of exterior cells. Indexed as extCells[gridX][gridY]. // List of exterior cells. Indexed as extCells[gridX][gridY].
typedef std::map<int, ESM::Cell*> ExtCellsCol; typedef std::map<std::pair<int, int>, ESM::Cell*> ExtCells;
typedef std::map<int, ExtCellsCol> ExtCells;
ExtCells extCells; ExtCells extCells;
virtual void listIdentifier (std::vector<std::string>& identifier) const virtual void listIdentifier (std::vector<std::string>& identifier) const
@ -303,13 +302,7 @@ namespace ESMS
delete it->second; delete it->second;
for (ExtCells::iterator it = extCells.begin(); it!=extCells.end(); ++it) for (ExtCells::iterator it = extCells.begin(); it!=extCells.end(); ++it)
{
ExtCellsCol& col = it->second;
for (ExtCellsCol::iterator it = col.begin(); it!=col.end(); ++it)
{
delete it->second; delete it->second;
}
}
} }
@ -318,36 +311,36 @@ namespace ESMS
IntCells::const_iterator it = intCells.find(id); IntCells::const_iterator it = intCells.find(id);
if(it == intCells.end()) if(it == intCells.end())
return NULL; throw std::runtime_error ("Interior cell not found - " + id);
return it->second; return it->second;
} }
const ESM::Cell *searchExt (int x, int y) const const ESM::Cell *searchExt (int x, int y) const
{ {
ExtCells::const_iterator it = extCells.find (x); ExtCells::const_iterator it = extCells.find (std::make_pair (x, y));
if (it==extCells.end()) if (it==extCells.end())
return 0; return 0;
ExtCellsCol::const_iterator it2 = it->second.find (y); return it->second;
}
if (it2 == it->second.end()) const ESM::Cell *findExt (int x, int y) const
return 0; {
const ESM::Cell *cell = searchExt (x, y);
return it2->second; if (!cell)
} throw std::runtime_error ("Exterior cell not found");
return cell;
}
const ESM::Cell *searchExtByName (const std::string& id) const const ESM::Cell *searchExtByName (const std::string& id) const
{ {
for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter)
{ {
const ExtCellsCol& column = iter->second; if (toLower (iter->second->name) == toLower (id))
for (ExtCellsCol::const_iterator iter = column.begin(); iter!=column.end(); ++iter) return iter->second;
{
if ( toLower(iter->second->name) == toLower(id))
return iter->second;
}
} }
return 0; return 0;
@ -358,14 +351,8 @@ namespace ESMS
std::string id2 = toLower (id); std::string id2 = toLower (id);
for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter)
{ if (toLower (iter->second->region)==id)
const ExtCellsCol& column = iter->second; return iter->second;
for (ExtCellsCol::const_iterator iter = column.begin(); iter!=column.end(); ++iter)
{
if (toLower (iter->second->region)==id)
return iter->second;
}
}
return 0; return 0;
} }
@ -389,7 +376,7 @@ namespace ESMS
else else
{ {
// Store exterior cells by grid position // Store exterior cells by grid position
extCells[cell->data.gridX][cell->data.gridY] = cell; extCells[std::make_pair (cell->data.gridX, cell->data.gridY)] = cell;
} }
} }
}; };

@ -3,21 +3,27 @@
namespace Files namespace Files
{ {
Collections::Collections() : mFoldCase (false) {} Collections::Collections()
: mDirectories()
Collections::Collections (const std::vector<boost::filesystem::path>& directories, bool foldCase) , mFoldCase(false)
: mDirectories (directories), mFoldCase (foldCase) , mCollections()
{} {
}
const MultiDirCollection& Collections::getCollection (const std::string& extension) const Collections::Collections(const Files::PathContainer& directories, bool foldCase)
: mDirectories(directories)
, mFoldCase(foldCase)
, mCollections()
{ {
std::map<std::string, MultiDirCollection>::iterator iter = mCollections.find (extension); }
const MultiDirCollection& Collections::getCollection(const std::string& extension) const
{
MultiDirCollectionContainer::iterator iter = mCollections.find(extension);
if (iter==mCollections.end()) if (iter==mCollections.end())
{ {
std::pair<std::map<std::string, MultiDirCollection>::iterator, bool> result = std::pair<MultiDirCollectionContainer::iterator, bool> result =
mCollections.insert (std::make_pair (extension, mCollections.insert(std::make_pair(extension, MultiDirCollection(mDirectories, extension, mFoldCase)));
MultiDirCollection (mDirectories, extension, mFoldCase)));
iter = result.first; iter = result.first;
} }

@ -1,27 +1,32 @@
#ifndef COMPONENTS_FILES_COLLECTION_HPP #ifndef COMPONENTS_FILES_COLLECTION_HPP
#define COMPONENTS_FILES_COLLECTION_HPP #define COMPONENTS_FILES_COLLECTION_HPP
#include <string>
#include <map>
#include <boost/filesystem.hpp>
#include "multidircollection.hpp" #include "multidircollection.hpp"
namespace Files namespace Files
{ {
class Collections class Collections
{ {
std::vector<boost::filesystem::path> mDirectories;
bool mFoldCase;
mutable std::map<std::string, MultiDirCollection> mCollections;
public: public:
Collections(); Collections();
Collections (const std::vector<boost::filesystem::path>& directories, bool foldCase);
///< Directories are listed with increasing priority. ///< Directories are listed with increasing priority.
Collections(const Files::PathContainer& directories, bool foldCase);
const MultiDirCollection& getCollection (const std::string& extension) const;
///< Return a file collection for the given extension. Extension must contain the ///< Return a file collection for the given extension. Extension must contain the
/// leading dot and must be all lower-case. /// leading dot and must be all lower-case.
const MultiDirCollection& getCollection(const std::string& extension) const;
private:
typedef std::map<std::string, MultiDirCollection> MultiDirCollectionContainer;
Files::PathContainer mDirectories;
bool mFoldCase;
mutable MultiDirCollectionContainer mCollections;
}; };
} }

@ -0,0 +1,12 @@
#include "fileops.hpp"
#include <boost/filesystem.hpp>
namespace Files
{
bool isFile(const char *name)
{
return boost::filesystem::exists(boost::filesystem::path(name));
}
}

@ -0,0 +1,13 @@
#ifndef COMPONENTS_FILES_FILEOPS_HPP
#define COMPONENTS_FILES_FILEOPS_HPP
namespace Files
{
///\brief Check if a given path is an existing file (not a directory)
///\param [in] name - filename
bool isFile(const char *name);
}
#endif /* COMPONENTS_FILES_FILEOPS_HPP */

@ -0,0 +1,160 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/linuxpath.cpp */
#include "linuxpath.hpp"
#if defined(__linux__)
#include <cstdlib>
#include <cstring>
#include <pwd.h>
#include <unistd.h>
/**
* \namespace Files
*/
namespace Files
{
boost::filesystem::path LinuxPath::getLocalConfigPath() const
{
boost::filesystem::path localConfigPath(".");
boost::filesystem::path suffix("/");
const char* theDir = getenv("OPENMW_CONFIG");
if (theDir == NULL)
{
theDir = getenv("XDG_CONFIG_HOME");
if (theDir == NULL)
{
theDir = getenv("HOME");
if (theDir == NULL)
{
struct passwd* pwd = getpwuid(getuid());
if (pwd != NULL)
{
theDir = pwd->pw_dir;
}
}
if (theDir != NULL)
{
suffix = boost::filesystem::path("/.config/");
}
}
}
if (theDir != NULL) {
localConfigPath = boost::filesystem::path(theDir);
}
localConfigPath /= suffix;
return localConfigPath;
}
boost::filesystem::path LinuxPath::getGlobalConfigPath() const
{
boost::filesystem::path globalConfigPath("/etc/xdg/");
char* theDir = getenv("XDG_CONFIG_DIRS");
if (theDir != NULL)
{
// We take only first path from list
char* ptr = strtok(theDir, ":");
if (ptr != NULL)
{
globalConfigPath = boost::filesystem::path(ptr);
globalConfigPath /= boost::filesystem::path("/");
}
}
return globalConfigPath;
}
boost::filesystem::path LinuxPath::getRuntimeConfigPath() const
{
return boost::filesystem::path("./");
}
boost::filesystem::path LinuxPath::getLocalDataPath() const
{
boost::filesystem::path localDataPath(".");
boost::filesystem::path suffix("/");
const char* theDir = getenv("OPENMW_DATA");
if (theDir == NULL)
{
theDir = getenv("XDG_DATA_HOME");
if (theDir == NULL)
{
theDir = getenv("HOME");
if (theDir == NULL)
{
struct passwd* pwd = getpwuid(getuid());
if (pwd != NULL)
{
theDir = pwd->pw_dir;
}
}
if (theDir != NULL)
{
suffix = boost::filesystem::path("/.local/share/");
}
}
}
if (theDir != NULL) {
localDataPath = boost::filesystem::path(theDir);
}
localDataPath /= suffix;
return localDataPath;
}
boost::filesystem::path LinuxPath::getGlobalDataPath() const
{
boost::filesystem::path globalDataPath("/usr/local/share/");
char* theDir = getenv("XDG_DATA_DIRS");
if (theDir != NULL)
{
// We take only first path from list
char* ptr = strtok(theDir, ":");
if (ptr != NULL)
{
globalDataPath = boost::filesystem::path(ptr);
globalDataPath /= boost::filesystem::path("/");
}
}
return globalDataPath;
}
boost::filesystem::path LinuxPath::getRuntimeDataPath() const
{
return boost::filesystem::path("./data/");
}
} /* namespace Files */
#endif /* defined(__linux__) */

@ -0,0 +1,90 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/linuxpath.hpp */
#ifndef COMPONENTS_FILES_LINUXPATH_H
#define COMPONENTS_FILES_LINUXPATH_H
#if defined(__linux__)
#include <boost/filesystem.hpp>
/**
* \namespace Files
*/
namespace Files
{
/**
* \struct LinuxPath
*/
struct LinuxPath
{
/**
* \brief Return path to the local configuration directory.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getLocalConfigPath() const;
/**
* \brief Return path to the global (system) configuration directory.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getGlobalConfigPath() const;
/**
* \brief Return path to the runtime configuration directory which is the
* place where an application was started.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getRuntimeConfigPath() const;
/**
* \brief Return path to the local data directory.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getLocalDataPath() const;
/**
* \brief Return path to the global (system) data directory.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getGlobalDataPath() const;
/**
* \brief Return runtime data path which is a location where
* an application was started with 'data' suffix.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getRuntimeDataPath() const;
};
} /* namespace Files */
#endif /* defined(__linux__) */
#endif /* COMPONENTS_FILES_LINUXPATH_H */

@ -0,0 +1,118 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/macospath.cpp */
#include "macospath.hpp"
#if defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__)
#include <cstdlib>
#include <pwd.h>
#include <unistd.h>
/**
* \namespace Files
*/
namespace Files
{
boost::filesystem::path MacOsPath::getLocalConfigPath() const
{
boost::filesystem::path localConfigPath(".");
boost::filesystem::path suffix("/");
const char* theDir = getenv("HOME");
if (theDir == NULL)
{
struct passwd* pwd = getpwuid(getuid());
if (pwd != NULL)
{
theDir = pwd->pw_dir;
}
}
if (theDir != NULL)
{
localConfigPath = boost::filesystem::path(theDir) / "Library/Preferences/";
}
localConfigPath /= suffix;
return localConfigPath;
}
boost::filesystem::path MacOsPath::getGlobalConfigPath() const
{
boost::filesystem::path globalConfigPath("/Library/Preferences/");
return globalConfigPath;
}
boost::filesystem::path MacOsPath::getRuntimeConfigPath() const
{
return boost::filesystem::path("./");
}
boost::filesystem::path MacOsPath::getLocalDataPath() const
{
boost::filesystem::path localDataPath(".");
boost::filesystem::path suffix("/");
const char* theDir = getenv("OPENMW_DATA");
if (theDir == NULL)
{
theDir = getenv("HOME");
if (theDir == NULL)
{
struct passwd* pwd = getpwuid(getuid());
if (pwd != NULL)
{
theDir = pwd->pw_dir;
}
}
if (theDir != NULL)
{
suffix = boost::filesystem::path("/Library/Application Support/");
}
}
if (theDir != NULL)
{
localDataPath = boost::filesystem::path(theDir);
}
localDataPath /= suffix;
return localDataPath;
}
boost::filesystem::path MacOsPath::getGlobalDataPath() const
{
boost::filesystem::path globalDataPath("/Library/Application Support/");
return globalDataPath;
}
boost::filesystem::path MacOsPath::getRuntimeDataPath() const
{
return boost::filesystem::path("./data/");
}
} /* namespace Files */
#endif /* defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__) */

@ -0,0 +1,90 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/macospath.hpp */
#ifndef COMPONENTS_FILES_MACOSPATH_H
#define COMPONENTS_FILES_MACOSPATH_H
#if defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__)
#include <boost/filesystem.hpp>
/**
* \namespace Files
*/
namespace Files
{
/**
* \struct MacOsPath
*/
struct MacOsPath
{
/**
* \brief Return path to the local configuration directory.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getLocalConfigPath() const;
/**
* \brief Return path to the global (system) configuration directory.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getGlobalConfigPath() const;
/**
* \brief Return path to the runtime configuration directory which is the
* place where an application was started.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getRuntimeConfigPath() const;
/**
* \brief Return path to the local data directory.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getLocalDataPath() const;
/**
* \brief Return path to the global (system) data directory.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getGlobalDataPath() const;
/**
* \brief Return runtime data path which is a location where
* an application was started with 'data' suffix.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getRuntimeDataPath() const;
};
} /* namespace Files */
#endif /* defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__) */
#endif /* COMPONENTS_FILES_MACOSPATH_H */

@ -5,6 +5,7 @@
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
#include <iostream>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@ -39,21 +40,25 @@ namespace Files
} }
}; };
MultiDirCollection::MultiDirCollection (const std::vector<boost::filesystem::path>& directories, MultiDirCollection::MultiDirCollection(const Files::PathContainer& directories,
const std::string& extension, bool foldCase) const std::string& extension, bool foldCase)
: mFiles (NameLess (!foldCase)) : mFiles (NameLess (!foldCase))
{ {
NameEqual equal (!foldCase); NameEqual equal (!foldCase);
for (std::vector<boost::filesystem::path>::const_iterator iter = directories.begin(); for (PathContainer::const_iterator iter = directories.begin();
iter!=directories.end(); ++iter) iter!=directories.end(); ++iter)
{ {
boost::filesystem::path dataDirectory = *iter; if (!boost::filesystem::is_directory(*iter))
{
std::cout << "Skipping invalid directory: " << (*iter).string() << std::endl;
continue;
}
for (boost::filesystem::directory_iterator iter (dataDirectory); for (boost::filesystem::directory_iterator dirIter(*iter);
iter!=boost::filesystem::directory_iterator(); ++iter) dirIter != boost::filesystem::directory_iterator(); ++dirIter)
{ {
boost::filesystem::path path = *iter; boost::filesystem::path path = *dirIter;
if (!equal (extension, boost::filesystem::path (path.extension()).string())) if (!equal (extension, boost::filesystem::path (path.extension()).string()))
continue; continue;

@ -11,6 +11,8 @@
namespace Files namespace Files
{ {
typedef std::vector<boost::filesystem::path> PathContainer;
struct NameLess struct NameLess
{ {
bool mStrict; bool mStrict;
@ -58,7 +60,7 @@ namespace Files
public: public:
MultiDirCollection (const std::vector<boost::filesystem::path>& directories, MultiDirCollection (const Files::PathContainer& directories,
const std::string& extension, bool foldCase); const std::string& extension, bool foldCase);
///< Directories are listed with increasing priority. ///< Directories are listed with increasing priority.
/// \param extension The extension that should be listed in this collection. Must /// \param extension The extension that should be listed in this collection. Must

@ -1,61 +0,0 @@
#include "path.hpp"
#include <boost/filesystem.hpp>
#include <OgrePlatform.h>
#include <string>
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
#include <OSX/macUtils.h>
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE
#include <stdlib.h> //getenv
#endif
std::string Files::getPath (PathTypeEnum parType, const std::string parApp, const std::string parFile)
{
std::string theBasePath;
if (parType==Path_ConfigGlobal)
{
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
boost::filesystem::path path(Ogre::macBundlePath());
path = path.parent_path();
theBasePath = path.string() + "/";
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
theBasePath = "/etc/"+parApp+"/";
#else
theBasePath = "";
#endif
}
else if (parType==Path_ConfigUser)
{
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE
const char* theDir;
if ((theDir = getenv("OPENMW_HOME")) != NULL)
{
theBasePath = std::string(theDir)+"/";
}
else
{
if ((theDir = getenv("XDG_CONFIG_HOME")))
{
theBasePath = std::string(theDir)+"/"+parApp+"/";
}
else
{
if ((theDir = getenv("HOME")) == NULL)
return parFile;
theBasePath = std::string(theDir)+"/.config/"+parApp+"/";
}
}
boost::filesystem::create_directories(boost::filesystem::path(theBasePath));
#else
theBasePath = "";
#endif
}
theBasePath.append(parFile);
return theBasePath;
}

@ -1,17 +1,232 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/path.hpp */
#ifndef COMPONENTS_FILES_PATH_HPP #ifndef COMPONENTS_FILES_PATH_HPP
#define COMPONENTS_FILES_PATH_HPP #define COMPONENTS_FILES_PATH_HPP
#include <string> #include <string>
#include <boost/filesystem.hpp>
#if defined(__linux__)
#include <components/files/linuxpath.hpp>
namespace Files { typedef LinuxPath TargetPathType; }
#elif defined(__WIN32) || defined(__WINDOWS__)
#include <components/files/windowspath.hpp>
namespace Files { typedef WindowsPath TargetPathType; }
#elif defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__)
#include <components/files/macospath.hpp>
namespace Files { typedef MacOsPath TargetPathType; }
#else
#error "Unknown platform!"
#endif
/**
* \namespace Files
*/
namespace Files namespace Files
{ {
enum PathTypeEnum
/**
* \struct Path
*
* \tparam P - Path strategy class type (depends on target system)
*
*/
template
<
class P = TargetPathType
>
struct Path
{
typedef P PathType;
/**
* \brief Path constructor.
*
* \param [in] application_name - Name of the application
*/
Path(const std::string& application_name)
: mPath()
, mLocalConfigPath(mPath.getLocalConfigPath())
, mGlobalConfigPath(mPath.getGlobalConfigPath())
, mRuntimeConfigPath(mPath.getRuntimeConfigPath())
, mLocalDataPath(mPath.getLocalDataPath())
, mGlobalDataPath(mPath.getGlobalDataPath())
, mRuntimeDataPath(mPath.getRuntimeDataPath())
{ {
Path_ConfigUser, if (!application_name.empty())
Path_ConfigGlobal {
}; boost::filesystem::path suffix(application_name + std::string("/"));
std::string getPath (PathTypeEnum parType, const std::string parApp, const std::string parFile); mLocalConfigPath /= suffix;
} mGlobalConfigPath /= suffix;
#endif mLocalDataPath /= suffix;
mGlobalDataPath /= suffix;
}
}
/**
* \brief Return path pointing to the user local configuration directory.
*
* \return boost::filesystem::path
*/
const boost::filesystem::path& getLocalConfigPath() const
{
return mLocalConfigPath;
}
/**
* \brief Sets new local configuration path.
*
* \param [in] path - New path
*/
void setLocalConfigPath(const boost::filesystem::path& path)
{
mLocalConfigPath = path;
}
/**
* \brief Return path pointing to the global (system) configuration directory.
*
* \return boost::filesystem::path
*/
const boost::filesystem::path& getGlobalConfigPath() const
{
return mGlobalConfigPath;
}
/**
* \brief Sets new global configuration path.
*
* \param [in] path - New path
*/
void setGlobalConfigPath(const boost::filesystem::path& path)
{
mGlobalConfigPath = path;
}
/**
* \brief Return path pointing to the directory where application was started.
*
* \return boost::filesystem::path
*/
const boost::filesystem::path& getRuntimeConfigPath() const
{
return mRuntimeConfigPath;
}
/**
* \brief Sets new runtime configuration path.
*
* \param [in] path - New path
*/
void setRuntimeConfigPath(const boost::filesystem::path& path)
{
mRuntimeConfigPath = path;
}
/**
* \brief Return path pointing to the user local data directory.
*
* \return boost::filesystem::path
*/
const boost::filesystem::path& getLocalDataPath() const
{
return mLocalDataPath;
}
/**
* \brief Sets new local data path.
*
* \param [in] path - New path
*/
void setLocalDataPath(const boost::filesystem::path& path)
{
mLocalDataPath = path;
}
/**
* \brief Return path pointing to the global (system) data directory.
*
* \return boost::filesystem::path
*/
const boost::filesystem::path& getGlobalDataPath() const
{
return mGlobalDataPath;
}
/**
* \brief Sets new global (system) data directory.
*
* \param [in] path - New path
*/
void setGlobalDataPath(const boost::filesystem::path& path)
{
mGlobalDataPath = path;
}
/**
* \brief Return path pointing to the directory where application was started.
*
* \return boost::filesystem::path
*/
const boost::filesystem::path& getRuntimeDataPath() const
{
return mRuntimeDataPath;
}
/**
* \brief Sets new runtime data directory.
*
* \param [in] path - New path
*/
void setRuntimeDataPath(const boost::filesystem::path& path)
{
mRuntimeDataPath = path;
}
private:
PathType mPath;
boost::filesystem::path mLocalConfigPath; /**< User local path to the configuration files */
boost::filesystem::path mGlobalConfigPath; /**< Global path to the configuration files */
boost::filesystem::path mRuntimeConfigPath; /**< Runtime path to the configuration files.
By default it is the same directory where
application was run */
boost::filesystem::path mLocalDataPath; /**< User local application data path (user plugins / mods / etc.) */
boost::filesystem::path mGlobalDataPath; /**< Global application data path */
boost::filesystem::path mRuntimeDataPath; /**< Runtime path to the configuration files.
By default it is a 'data' directory in same
directory where application was run */
};
} /* namespace Files */
#endif /* COMPONENTS_FILES_PATH_HPP */

@ -0,0 +1,72 @@
#include "windowspath.hpp"
#if defined(_WIN32) || defined(__WINDOWS__)
#include <cstring>
#include <windows.h>
#include <shobj.h>
namespace Files
{
boost::filesystem::path WindowsPath::getLocalConfigPath() const
{
boost::filesystem::path localConfigPath(".");
boost::filesystem::path suffix("/");
TCHAR path[MAX_PATH];
memset(path, 0, sizeof(path));
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path)))
{
PathAppend(path, TEXT("My Games"));
localConfigPath = boost::filesystem::path(path);
}
localConfigPath /= suffix;
return localConfigPath;
}
boost::filesystem::path WindowsPath::getGlobalConfigPath() const
{
boost::filesystem::path globalConfigPath(".");
boost::filesystem::path suffix("/");
TCHAR path[MAX_PATH];
memset(path, 0, sizeof(path));
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, NULL, 0, path)))
{
globalConfigPath = boost::filesystem::path(path);
}
globalConfigPath /= suffix;
return globalConfigPath;
}
boost::filesystem::path WindowsPath::getRuntimeConfigPath() const
{
return boost::filesystem::path("./");
}
boost::filesystem::path WindowsPath::getLocalDataPath() const
{
return getLocalConfigPath();
}
boost::filesystem::path WindowsPath::getGlobalDataPath() const
{
return getGlobalConfigPath();
}
boost::filesystem::path WindowsPath::getRuntimeDataPath() const
{
return boost::filesystem::path("./data/");
}
} /* namespace Files */
#endif /* defined(_WIN32) || defined(__WINDOWS__) */

@ -0,0 +1,90 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/windowspath.hpp */
#ifndef COMPONENTS_FILES_WINDOWSPATH_HPP
#define COMPONENTS_FILES_WINDOWSPATH_HPP
#if defined(_WIN32) || defined(__WINDOWS__)
#include <boost/filesystem.hpp>
/**
* \namespace Files
*/
namespace Files
{
/**
* \struct WindowsPath
*/
struct WindowsPath
{
/**
* \brief Returns "X:\Documents And Settings\<User name>\My Documents\My Games\"
*
* \return boost::filesystem::path
*/
boost::filesystem::path getLocalConfigPath() const;
/**
* \brief Returns "X:\Program Files\"
*
* \return boost::filesystem::path
*/
boost::filesystem::path getGlobalConfigPath() const;
/**
* \brief Return runtime configuration path which is a location where
* an application was started
*
* \return boost::filesystem::path
*/
boost::filesystem::path getRuntimeConfigPath() const;
/**
* \brief Return same path like getLocalConfigPath
*
* \return boost::filesystem::path
*/
boost::filesystem::path getLocalDataPath() const;
/**
* \brief Return same path like getGlobalConfigPath
*
* \return boost::filesystem::path
*/
boost::filesystem::path getGlobalDataPath() const;
/**
* \brief Return runtime data path which is a location where
* an application was started with 'data' suffix.
*
* \return boost::filesystem::path
*/
boost::filesystem::path getRuntimeDataPath() const;
};
} /* namespace Files */
#endif /* defined(_WIN32) || defined(__WINDOWS__) */
#endif /* COMPONENTS_FILES_WINDOWSPATH_HPP */

@ -1,16 +0,0 @@
#include "fileops.hpp"
#include <boost/filesystem.hpp>
#include <string>
#include <OgrePrerequisites.h>
namespace Misc
{
bool isFile(const char *name)
{
boost::filesystem::path cfg_file_path(name);
return boost::filesystem::exists(cfg_file_path);
}
}

@ -1,18 +0,0 @@
#ifndef MISC_FILEOPS_H
#define MISC_FILEOPS_H
#include <string>
namespace Misc
{
/// Check if a given path is an existing file (not a directory)
bool isFile(const char *name);
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
std::string macBundlePath();
#endif
}
#endif

@ -88,8 +88,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
resourceName = cShape->getName(); resourceName = cShape->getName();
cShape->collide = false; cShape->collide = false;
currentShape = new btCompoundShape(); mTriMesh = new btTriangleMesh();
cShape->Shape = currentShape;
if (!vfs) vfs = new OgreVFS(resourceGroup); if (!vfs) vfs = new OgreVFS(resourceGroup);
@ -135,6 +134,9 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
{ {
handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,true); handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,true);
} }
currentShape = new btBvhTriangleMeshShape(mTriMesh,true);
cShape->Shape = currentShape;
} }
bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node* node) bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node* node)
@ -247,7 +249,6 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags
bool raycastingOnly) bool raycastingOnly)
{ {
assert(shape != NULL); assert(shape != NULL);
btCollisionShape* NodeShape;
// Interpret flags // Interpret flags
bool hidden = (flags & 0x01) != 0; // Not displayed bool hidden = (flags & 0x01) != 0; // Not displayed
@ -289,7 +290,6 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags
/* Do in-place transformation.the only needed transfo is the scale. (maybe not in fact) /* Do in-place transformation.the only needed transfo is the scale. (maybe not in fact)
*/ */
btTriangleMesh *mTriMesh = new btTriangleMesh();
Nif::NiTriShapeData *data = shape->data.getPtr(); Nif::NiTriShapeData *data = shape->data.getPtr();
@ -303,8 +303,6 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags
btVector3 b3(vertices[triangles[i+2]*3]*parentScale,vertices[triangles[i+2]*3+1]*parentScale,vertices[triangles[i+2]*3+2]*parentScale); btVector3 b3(vertices[triangles[i+2]*3]*parentScale,vertices[triangles[i+2]*3+1]*parentScale,vertices[triangles[i+2]*3+2]*parentScale);
mTriMesh->addTriangle(b1,b2,b3); mTriMesh->addTriangle(b1,b2,b3);
} }
NodeShape = new btBvhTriangleMeshShape(mTriMesh,true);
currentShape->addChildShape(tr,NodeShape);
} }
void ManualBulletShapeLoader::load(const std::string &name,const std::string &group) void ManualBulletShapeLoader::load(const std::string &name,const std::string &group)

@ -125,7 +125,8 @@ private:
std::string resourceGroup; std::string resourceGroup;
BulletShape* cShape;//current shape BulletShape* cShape;//current shape
btCompoundShape* currentShape;//the shape curently under construction btTriangleMesh *mTriMesh;
btBvhTriangleMeshShape* currentShape;//the shape curently under construction
}; };
} }

@ -1 +1 @@
Subproject commit 0f7d59b4fb742c6479d988f6fc4ec9cdb4330b53 Subproject commit 26b9d0fdc374fac648f6293e1d4a4abdc2c20c19
Loading…
Cancel
Save