diff --git a/CMakeLists.txt b/CMakeLists.txt index 2edd7ac5e..723d10b34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,168 +82,6 @@ ELSE() message (STATUS "OpenMW pre-built binaries not found. Using standard locations.") ENDIF() -# source directory: components -set(COMP_DIR ${CMAKE_SOURCE_DIR}/components) - -set(BSA - ${COMP_DIR}/bsa/bsa_archive.cpp - ${COMP_DIR}/bsa/bsa_file.cpp) -set(BSA_HEADER - ${COMP_DIR}/bsa/bsa_archive.hpp - ${COMP_DIR}/bsa/bsa_file.hpp) -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 - ${COMP_DIR}/nif/nif_file.cpp) -set(NIF_HEADER - ${COMP_DIR}/nif/controlled.hpp - ${COMP_DIR}/nif/effect.hpp - ${COMP_DIR}/nif/nif_types.hpp - ${COMP_DIR}/nif/record.hpp - ${COMP_DIR}/nif/controller.hpp - ${COMP_DIR}/nif/extra.hpp - ${COMP_DIR}/nif/node.hpp - ${COMP_DIR}/nif/record_ptr.hpp - ${COMP_DIR}/nif/data.hpp - ${COMP_DIR}/nif/nif_file.hpp - ${COMP_DIR}/nif/property.hpp) -source_group(components\\nif FILES ${NIF} ${NIF_HEADER}) - -set(NIFOGRE - ${COMP_DIR}/nifogre/ogre_nif_loader.cpp) -set(NIFOGRE_HEADER - ${COMP_DIR}/nifogre/ogre_nif_loader.hpp) -source_group(components\\nifogre FILES ${NIFOGRE} ${NIFOGRE_HEADER}) - -set(NIFBULLET - ${COMP_DIR}/nifbullet/bullet_nif_loader.cpp) -set(NIFBULLET_HEADER - ${COMP_DIR}/nifbullet/bullet_nif_loader.hpp) -source_group(components\\nifbullet FILES ${NIFBULLET} ${NIFBULLET_HEADER}) - -set(TO_UTF8 - ${COMP_DIR}/to_utf8/to_utf8.cpp) -set(TO_UTF8_HEADER - ${COMP_DIR}/to_utf8/to_utf8.hpp) -source_group(components\\to_utf8 FILES ${TO_UTF8} ${TO_UTF8_HEADER}) - -set(FILE_FINDER - ${COMP_DIR}/file_finder/search.cpp) -set(FILE_FINDER_HEADER - ${COMP_DIR}/file_finder/file_finder.hpp - ${COMP_DIR}/file_finder/filename_less.hpp - ${COMP_DIR}/file_finder/search.hpp) -source_group(components\\file_finder FILES ${FILE_FINDER} ${FILE_FINDER_HEADER}) - -set(ESM_STORE - ${COMP_DIR}/esm_store/store.cpp) -set(ESM_STORE_HEADER - ${COMP_DIR}/esm_store/cell_store.hpp - ${COMP_DIR}/esm_store/reclists.hpp - ${COMP_DIR}/esm_store/store.hpp) -source_group(components\\esm_store FILES ${ESM_STORE} ${ESM_STORE_HEADER}) - -file(GLOB ESM_HEADER ${COMP_DIR}/esm/*.hpp) -set(ESM - ${COMP_DIR}/esm/attr.cpp - ${COMP_DIR}/esm/esm_reader.cpp - ${COMP_DIR}/esm/loadland.cpp - ${COMP_DIR}/esm/loadacti.cpp - ${COMP_DIR}/esm/loadalch.cpp - ${COMP_DIR}/esm/loadappa.cpp - ${COMP_DIR}/esm/loadarmo.cpp - ${COMP_DIR}/esm/loadbody.cpp - ${COMP_DIR}/esm/loadbook.cpp - ${COMP_DIR}/esm/loadbsgn.cpp - ${COMP_DIR}/esm/loadcell.cpp - ${COMP_DIR}/esm/loadclas.cpp - ${COMP_DIR}/esm/loadclot.cpp - ${COMP_DIR}/esm/loadcont.cpp - ${COMP_DIR}/esm/loadcrea.cpp - ${COMP_DIR}/esm/loaddial.cpp - ${COMP_DIR}/esm/loaddoor.cpp - ${COMP_DIR}/esm/loadench.cpp - ${COMP_DIR}/esm/loadfact.cpp - ${COMP_DIR}/esm/loadglob.cpp - ${COMP_DIR}/esm/loadgmst.cpp - ${COMP_DIR}/esm/loadinfo.cpp - ${COMP_DIR}/esm/loadingr.cpp - ${COMP_DIR}/esm/loadlevlist.cpp - ${COMP_DIR}/esm/loadligh.cpp - ${COMP_DIR}/esm/loadlocks.cpp - ${COMP_DIR}/esm/loadltex.cpp - ${COMP_DIR}/esm/loadmgef.cpp - ${COMP_DIR}/esm/loadmisc.cpp - ${COMP_DIR}/esm/loadnpc.cpp - ${COMP_DIR}/esm/loadpgrd.cpp - ${COMP_DIR}/esm/loadrace.cpp - ${COMP_DIR}/esm/loadregn.cpp - ${COMP_DIR}/esm/loadscpt.cpp - ${COMP_DIR}/esm/loadskil.cpp - ${COMP_DIR}/esm/loadsndg.cpp - ${COMP_DIR}/esm/loadsoun.cpp - ${COMP_DIR}/esm/loadspel.cpp - ${COMP_DIR}/esm/loadsscr.cpp - ${COMP_DIR}/esm/loadstat.cpp - ${COMP_DIR}/esm/loadweap.cpp - -) -source_group(components\\esm FILES ${ESM_HEADER} ${ESM}) - -set(MISC - ${COMP_DIR}/misc/stringops.cpp - ) -set(MISC_HEADER - ${COMP_DIR}/misc/slice_array.hpp - ${COMP_DIR}/misc/stringops.hpp - ) -source_group(components\\misc FILES ${MISC} ${MISC_HEADER}) - -set(FILES - ${COMP_DIR}/files/linuxpath.cpp - ${COMP_DIR}/files/windowspath.cpp - ${COMP_DIR}/files/macospath.cpp - ${COMP_DIR}/files/multidircollection.cpp - ${COMP_DIR}/files/collections.cpp - ${COMP_DIR}/files/fileops.cpp - ) -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/multidircollection.hpp - ${COMP_DIR}/files/collections.hpp - ${COMP_DIR}/files/fileops.hpp - ) -source_group(components\\files FILES ${FILES} ${FILES_HEADER}) - -file(GLOB COMPILER ${COMP_DIR}/compiler/*.cpp) -file(GLOB COMPILER_HEADER ${COMP_DIR}/compiler/*.hpp) -source_group(components\\compiler FILES ${COMPILER} ${COMPILER_HEADER}) - -file(GLOB INTERPRETER ${COMP_DIR}/interpreter/*.cpp) -file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp) -source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER}) - -set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8} - ${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET} ${FILES} - ${CFG} - ) -set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER} - ${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER} - ${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER} ${FILES_HEADER} - ${CFG_HEADER} - ) - # source directory: libs set(LIBDIR ${CMAKE_SOURCE_DIR}/libs) @@ -513,6 +351,9 @@ if(DPKG_PROGRAM) include(CPack) endif(DPKG_PROGRAM) +# Components +add_subdirectory (components) + # Apps and tools add_subdirectory( apps/openmw ) diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index 583f1fabd..f2ab7bce7 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -8,13 +8,11 @@ source_group(apps\\esmtool FILES ${ESMTOOL}) # Main executable add_executable(esmtool ${ESMTOOL} - ${MISC} ${MISC_HEADER} - ${TO_UTF8} - ${ESM} ) target_link_libraries(esmtool ${Boost_LIBRARIES} + components ) #if (APPLE) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index de8f0256c..2fc3189fc 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -8,6 +8,8 @@ set(LAUNCHER playpage.cpp pluginsmodel.cpp pluginsview.cpp + + launcher.rc ) set(LAUNCHER_HEADER @@ -50,11 +52,6 @@ include(${QT_USE_FILE}) # Main executable add_executable(omwlauncher ${LAUNCHER} - ${MISC} ${MISC_HEADER} - ${FILES} ${FILES_HEADER} - ${CFG} ${CFG_HEADER} - ${TO_UTF8} - ${ESM} ${RCC_SRCS} ${MOC_SRCS} ) @@ -64,6 +61,7 @@ target_link_libraries(omwlauncher ${OGRE_LIBRARIES} ${QT_LIBRARIES} ${PNG_LIBRARY} + components ) if(DPKG_PROGRAM) @@ -78,7 +76,7 @@ if (APPLE) else() configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") - + configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg") endif() diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index ffa4d5d59..92fbf3350 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -164,6 +164,23 @@ void GraphicsPage::setupOgre() QString ogreCfg = QString::fromStdString(mCfg.getOgreConfigPath().string()); file.setFileName(ogreCfg); + //we need to check that the path to the configuration file exists before we + //try and create an instance of Ogre::Root otherwise Ogre raises an exception + QDir configDir = QFileInfo(file).dir(); + if ( !configDir.exists() && !configDir.mkpath(configDir.path()) ) + { + QMessageBox msgBox; + msgBox.setWindowTitle("Error creating config file"); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(QString(tr("
Failed to create the configuration file

\ + Make sure you have write access to
%1

")).arg(configDir.path())); + msgBox.exec(); + + QApplication::exit(1); + return; + } + try { mOgre = new Ogre::Root(pluginCfg.toStdString(), file.fileName().toStdString(), "./launcherOgre.log"); @@ -183,7 +200,8 @@ void GraphicsPage::setupOgre() qCritical("Error creating Ogre::Root, the error reported was:\n %s", qPrintable(ogreError)); - std::exit(1); + QApplication::exit(1); + return; } // Get the available renderers and put them in the combobox @@ -216,7 +234,8 @@ void GraphicsPage::setupOgre() Please make sure the plugins.cfg file exists and contains a valid rendering plugin.
")); msgBox.exec(); - std::exit(1); + QApplication::exit(1); + return; } // Now fill the GUI elements @@ -388,7 +407,7 @@ void GraphicsPage::writeConfig() if (!ogreError.isEmpty()) { QMessageBox msgBox; - msgBox.setWindowTitle("Error validating configuration"); + msgBox.setWindowTitle("Error validating Ogre configuration"); msgBox.setIcon(QMessageBox::Critical); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setText(tr("
A problem occured while validating the graphics options

\ @@ -401,11 +420,34 @@ void GraphicsPage::writeConfig() qCritical("Error validating configuration"); - std::exit(1); + QApplication::exit(1); + return; } // Write the settings to the config file - mOgre->saveConfig(); + + + try + { + mOgre->saveConfig(); + } + catch(Ogre::Exception &ex) + { + QString ogreError = QString::fromStdString(ex.getFullDescription().c_str()); + QMessageBox msgBox; + msgBox.setWindowTitle("Error writing Ogre configuration file"); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(tr("
Could not write the graphics configuration

\ + Please make sure you have the right permissions and try again.

\ + Press \"Show Details...\" for more information.
")); + msgBox.setDetailedText(ogreError); + msgBox.exec(); + + qCritical("Error saving Ogre configuration, the error reported was:\n %s", qPrintable(ogreError)); + + QApplication::exit(1); + } } diff --git a/apps/launcher/launcher.pro b/apps/launcher/launcher.pro deleted file mode 100644 index 0b4e4618d..000000000 --- a/apps/launcher/launcher.pro +++ /dev/null @@ -1,30 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Fri Jun 24 21:14:15 2011 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -HEADERS += combobox.hpp \ - datafilespage.hpp \ - graphicspage.hpp \ - lineedit.hpp \ - maindialog.hpp \ - naturalsort.hpp \ - playpage.hpp \ - pluginsmodel.hpp \ - pluginsview.hpp -SOURCES += datafilespage.cpp \ - graphicspage.cpp \ - lineedit.cpp \ - main.cpp \ - maindialog.cpp \ - naturalsort.cpp \ - playpage.cpp \ - pluginsmodel.cpp \ - pluginsview.cpp -RESOURCES += resources.qrc -win32:RC_FILE = launcher.rc diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 31313e7a3..4ec8b309c 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -340,7 +340,7 @@ void MainDialog::writeConfig() Please make sure you have the right permissions and try again.
").arg(file.fileName())); msgBox.exec(); - std::exit(1); + QApplication::exit(1); } QTextStream in(&file); @@ -366,7 +366,7 @@ void MainDialog::writeConfig() Please make sure you have the right permissions and try again.
").arg(file.fileName())); msgBox.exec(); - std::exit(1);; + QApplication::exit(1); } file.write(buffer); diff --git a/apps/launcher/resources/images/openmw.ico b/apps/launcher/resources/images/openmw.ico index c04fc3d9c..aa248e6ad 100644 Binary files a/apps/launcher/resources/images/openmw.ico and b/apps/launcher/resources/images/openmw.ico differ diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index c41c089c6..3608cbf14 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -59,13 +59,15 @@ add_openmw_dir (mwmechanics # Main executable add_executable(openmw - ${COMPONENTS} ${COMPONENTS_HEADER} ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} + ${CONPONENT_FILES} ${OPENMW_FILES} ${GAME} ${GAME_HEADER} ${APPLE_BUNDLE_RESOURCES} ) +target_link_libraries (openmw components) + # Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING # when we change the backend. include_directories(${SOUND_INPUT_INCLUDES} ${BULLET_INCLUDE_DIRS}) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index e8c324e9a..daa9b508e 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -295,6 +295,14 @@ void OMW::Engine::go() mOgre = new OEngine::Render::OgreRenderer; + //we need to ensure the path to the configuration exists before creating an + //instance of ogre root so that Ogre doesn't raise an exception when trying to + //access it + const boost::filesystem::path configPath = mCfgMgr.getOgreConfigPath().parent_path(); + if ( !boost::filesystem::exists(configPath) ) + { + boost::filesystem::create_directories(configPath); + } mOgre->configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()), mCfgMgr.getOgreConfigPath().string(), mCfgMgr.getLogPath().string() + std::string("/"), diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 7a72ddb8c..4d4b7aeaa 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -21,7 +21,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 2dbeae360..ddf96d1be 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index d63795641..9452fea16 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 964ccbdfe..c2d3c4aa8 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index a264f2a1c..7c69573ed 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 1da55e6f6..ad2ab8d65 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -21,7 +21,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/containerutil.hpp b/apps/openmw/mwclass/containerutil.hpp index 5f89983ac..76bdf0236 100644 --- a/apps/openmw/mwclass/containerutil.hpp +++ b/apps/openmw/mwclass/containerutil.hpp @@ -16,10 +16,7 @@ namespace MWClass { // TODO check stacking - ESMS::LiveCellRef cellRef; - - cellRef.base = ptr.get()->base; - cellRef.ref = ptr.getCellRef(); + ESMS::LiveCellRef cellRef(ptr.getCellRef(), ptr.get()->base); cellRef.mData = ptr.getRefData(); containerStore.list.push_back (cellRef); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 0bd133f21..2e223c918 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -33,7 +33,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh("meshes\\" + model); cellRender.insertActorPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 8a34d3abe..e32e3ef4e 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -28,7 +28,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index c88e1794b..e2c9b072f 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 159196eb2..f32378002 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -28,7 +28,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 9a4b98b43..3a94fce26 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 2986c812d..84560d009 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 9ef5e6f40..83161ebeb 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -64,7 +64,7 @@ namespace MWClass std::string hairModel = "meshes\\" + environment.mWorld->getStore().bodyParts.find(hairID)->model; - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); //TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 6c9889a7b..7cd6db223 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 028d8b5e3..b92f5ff26 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index b9b5036fb..d52f04e53 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index cf0be9499..5691f92ba 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -19,7 +19,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref, true); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData, true); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index a985a7e42..5dcc94fc8 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -24,7 +24,7 @@ namespace MWClass const std::string &model = ref->base->model; if (!model.empty()) { - MWRender::Rendering rendering (cellRender, ref->ref); + MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh ("meshes\\" + model); cellRender.insertObjectPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); diff --git a/apps/openmw/mwrender/cellimp.hpp b/apps/openmw/mwrender/cellimp.hpp index 664fed64f..c497b1d19 100644 --- a/apps/openmw/mwrender/cellimp.hpp +++ b/apps/openmw/mwrender/cellimp.hpp @@ -35,7 +35,7 @@ namespace MWRender virtual ~CellRenderImp() {} /// start inserting a new reference. - virtual void insertBegin (ESM::CellRef &ref, bool static_ = false) = 0; + virtual void insertBegin (ESM::CellRef& ref, MWWorld::RefData& refData, bool static_ = false) = 0; virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) = 0; /// insert a mesh related to the most recent insertBegin call. @@ -71,10 +71,10 @@ namespace MWRender public: - Rendering (CellRenderImp& cellRender, ESM::CellRef &ref, bool static_ = false) + Rendering (CellRenderImp& cellRender, ESM::CellRef& ref, MWWorld::RefData& refData, bool static_ = false) : mCellRender (cellRender), mEnd (false) { - mCellRender.insertBegin (ref, static_); + mCellRender.insertBegin (ref, refData, static_); } ~Rendering() diff --git a/apps/openmw/mwrender/exterior.cpp b/apps/openmw/mwrender/exterior.cpp index 1118156ba..d1eabe36e 100644 --- a/apps/openmw/mwrender/exterior.cpp +++ b/apps/openmw/mwrender/exterior.cpp @@ -44,7 +44,7 @@ ExteriorCellRender::ExteriorCellRender(ESMS::CellStore &_cell, -void ExteriorCellRender::insertBegin (ESM::CellRef &ref, bool static_) +void ExteriorCellRender::insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_) { assert (!mInsert); diff --git a/apps/openmw/mwrender/exterior.hpp b/apps/openmw/mwrender/exterior.hpp index c73625128..a0b86165a 100644 --- a/apps/openmw/mwrender/exterior.hpp +++ b/apps/openmw/mwrender/exterior.hpp @@ -71,7 +71,7 @@ namespace MWRender Ogre::ColourValue mAmbientColor; /// start inserting a new reference. - virtual void insertBegin (ESM::CellRef &ref, bool static_ = false); + virtual void insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_ = false); /// insert a mesh related to the most recent insertBegin call. virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements); diff --git a/apps/openmw/mwrender/interior.cpp b/apps/openmw/mwrender/interior.cpp index aa13f2292..c6bddc2f0 100644 --- a/apps/openmw/mwrender/interior.cpp +++ b/apps/openmw/mwrender/interior.cpp @@ -35,14 +35,14 @@ bool InteriorCellRender::lightOutQuadInLin = false; // start inserting a new reference. -void InteriorCellRender::insertBegin (ESM::CellRef &ref, bool static_) +void InteriorCellRender::insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_) { assert (!insert); // Create and place scene node for this object insert = base->createChildSceneNode(); - const float *f = ref.pos.pos; + const float *f = refData.getPosition().pos; insert->setPosition(f[0], f[1], f[2]); insert->setScale(ref.scale, ref.scale, ref.scale); diff --git a/apps/openmw/mwrender/interior.hpp b/apps/openmw/mwrender/interior.hpp index 237d689c4..cc94e608f 100644 --- a/apps/openmw/mwrender/interior.hpp +++ b/apps/openmw/mwrender/interior.hpp @@ -66,7 +66,7 @@ namespace MWRender Ogre::ColourValue ambientColor; /// start inserting a new reference. - virtual void insertBegin (ESM::CellRef &ref, bool static_ = false); + virtual void insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_ = false); virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); /// insert a mesh related to the most recent insertBegin call. diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 77a71a1d4..258493782 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -196,8 +196,10 @@ namespace MWScript double diff[3]; + const float* const pos1 = ref.getRefData().getPosition().pos; + const float* const pos2 = ref2.getRefData().getPosition().pos; for (int i=0; i<3; ++i) - diff[i] = ref.getCellRef().pos.pos[i] - ref2.getCellRef().pos.pos[i]; + diff[i] = pos1[i] - pos2[i]; return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]); } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index cad97c9ea..db950b00e 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -17,7 +17,10 @@ namespace MWWorld mName = player->name; mMale = !(player->flags & ESM::NPC::Female); mRace = player->race; - mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0; + + float* playerPos = mPlayer.mData.getPosition().pos; + playerPos[0] = playerPos[1] = playerPos[2] = 0; + std::cout << renderer->getHandle(); mPlayer.mData.setHandle (renderer->getHandle()); /// \todo Do not make a copy of classes defined in esm/p records. diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 0abca5ac0..062c5942e 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -43,9 +43,13 @@ namespace MWWorld boost::shared_ptr > mContainerStore; + ESM::Position mPosition; + + public: + RefData(const ESMS::CellRef& cr) : mHasLocals (false), mEnabled (true), + mCount (1), mPosition(cr.pos), mBaseNode(0) {} - RefData() : mHasLocals (false), mEnabled (true), mCount (1),mBaseNode(0) {} std::string getHandle() { @@ -114,6 +118,11 @@ namespace MWWorld { return mContainerStore; } + + ESM::Position& getPosition() + { + return mPosition; + } }; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 821179d38..fbe388427 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -552,9 +552,9 @@ namespace MWWorld void World::moveObjectImp (Ptr ptr, float x, float y, float z) { - ptr.getCellRef().pos.pos[0] = x; - ptr.getCellRef().pos.pos[1] = y; - ptr.getCellRef().pos.pos[2] = z; + ptr.getRefData().getPosition().pos[0] = x; + ptr.getRefData().getPosition().pos[1] = y; + ptr.getRefData().getPosition().pos[2] = z; if (ptr==mPlayer->getPlayer()) { @@ -571,7 +571,7 @@ namespace MWWorld if (currentCell->cell->data.gridX!=cellX || currentCell->cell->data.gridY!=cellY) { - mWorldScene->changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos, false); + mWorldScene->changeCell (cellX, cellY, mPlayer->getPlayer().getRefData().getPosition(), false); } } diff --git a/cmake/OpenMWMacros.cmake b/cmake/OpenMWMacros.cmake index 8263763a2..c40936691 100644 --- a/cmake/OpenMWMacros.cmake +++ b/cmake/OpenMWMacros.cmake @@ -2,8 +2,23 @@ macro (add_openmw_dir dir) set (files) foreach (u ${ARGN}) -list (APPEND files "${dir}/${u}.*") -list (APPEND OPENMW_FILES "${dir}/${u}") +file (GLOB ALL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.*") +foreach (f ${ALL}) +list (APPEND files "${f}") +list (APPEND OPENMW_FILES "${f}") +endforeach (f) endforeach (u) source_group ("apps\\openmw\\${dir}" FILES ${files}) endmacro (add_openmw_dir) + +macro (add_component_dir dir) +set (files) +foreach (u ${ARGN}) +file (GLOB ALL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.*") +foreach (f ${ALL}) +list (APPEND files "${f}") +list (APPEND COMPONENT_FILES "${f}") +endforeach (f) +endforeach (u) +source_group ("components\\${dir}" FILES ${files}) +endmacro (add_component_dir) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt new file mode 100644 index 000000000..76e68dd89 --- /dev/null +++ b/components/CMakeLists.txt @@ -0,0 +1,66 @@ +project (Components) + +# source files + +add_component_dir (bsa + bsa_archive bsa_file + ) + +add_component_dir (cfg + configurationmanager + ) + +add_component_dir (nif + controlled effect nif_types record controller extra node record_ptr data nif_file property + ) + +add_component_dir (nifogre + ogre_nif_loader + ) + +add_component_dir (nifbullet + bullet_nif_loader + ) + +add_component_dir (to_utf8 + to_utf8 + ) + +add_component_dir (file_finder + file_finder filename_less search + ) + +add_component_dir (esm_store + cell_store reclists store + ) + +add_component_dir (esm + attr defs esm_reader loadacti loadalch loadappa loadarmo loadbody loadbook loadbsgn loadcell + loadclas loadclot loadcont loadcrea loadcrec loaddial loaddoor loadench loadfact loadglob loadgmst + loadinfo loadingr loadland loadlevlist loadligh loadlocks loadltex loadmgef loadmisc loadnpcc + loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat + loadweap records + ) + +add_component_dir (misc + slice_array stringops + ) + +add_component_dir (files + linuxpath windowspath macospath path multidircollection collections fileops + ) + +add_component_dir (compiler + context controlparser errorhandler exception exprparser extensions fileparser generator + lineparser literals locals output parser scanner scriptparser skipparser streamerrorhandler + stringparser tokenloc + ) + +add_component_dir (interpreter + context controlopcodes genericopcodes installopcodes interpreter localopcodes mathopcodes + miscopcodes opcodes runtime scriptopcodes spatialopcodes types + ) + +include_directories(${BULLET_INCLUDE_DIRS}) + +add_library (components STATIC ${COMPONENT_FILES}) diff --git a/components/esm_store/cell_store.hpp b/components/esm_store/cell_store.hpp index 19cb34c01..12f644417 100644 --- a/components/esm_store/cell_store.hpp +++ b/components/esm_store/cell_store.hpp @@ -26,9 +26,20 @@ namespace ESMS using namespace ESM; /// A reference to one object (of any type) in a cell. + /// + /// Constructing this with a CellRef instance in the constructor means that + /// in practice (where D is RefData) the possibly mutable data is copied + /// across to mData. If later adding data (such as position) to CellRef + /// this would have to be manually copied across. template struct LiveCellRef { + LiveCellRef(const CellRef& cref, const X* b = NULL) : base(b), ref(cref), + mData(ref) {} + + + LiveCellRef(const X* b = NULL) : base(b), mData(ref) {} + // The object that this instance is based on. const X* base; @@ -59,11 +70,7 @@ namespace ESMS if(obj == NULL) throw std::runtime_error("Error resolving cell reference " + ref.refID); - LiveRef lr; - lr.ref = ref; - lr.base = obj; - - list.push_back(lr); + list.push_back(LiveRef(ref, obj)); } LiveRef *find (const std::string& name)