From 25cd9ebf452867ef5bc21e5a307ae8850f5c73a9 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 15 Sep 2013 21:56:47 +0400 Subject: [PATCH 001/171] Plugins are frameworks in Ogre 1.9. Version hack removed. --- components/files/ogreplugin.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/components/files/ogreplugin.cpp b/components/files/ogreplugin.cpp index c319f77589..6070c43a87 100644 --- a/components/files/ogreplugin.cpp +++ b/components/files/ogreplugin.cpp @@ -6,18 +6,12 @@ namespace Files { bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot) { -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - std::ostringstream verStream; - verStream << "." << OGRE_VERSION_MAJOR << "." << OGRE_VERSION_MINOR << "." << OGRE_VERSION_PATCH; - pluginName = pluginName + verStream.str(); -#endif - std::string pluginExt; #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 pluginExt = ".dll"; #endif #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - pluginExt = ".dylib"; + pluginExt = ".framework"; #endif #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX pluginExt = ".so"; From 36fb89c6cdb203257e65d882123c13cf6c3d9829 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 15 Sep 2013 23:03:07 +0400 Subject: [PATCH 002/171] Cleanup --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ec306e5a5..96b0e1a327 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -262,8 +262,6 @@ if (APPLE) set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) endif () - #set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/") - configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist "${APP_BUNDLE_DIR}/Contents/Info.plist") @@ -664,7 +662,7 @@ if (APPLE) set(CPACK_GENERATOR "DragNDrop") set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR}) - set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) + set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) set(APPS "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}") From a18e3c9cc17dc69d085c376435e263f139a641bb Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 15 Sep 2013 23:10:21 +0400 Subject: [PATCH 003/171] Fixed packaging when building against Ogre 1.9 --- CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96b0e1a327..fa62d508f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -283,7 +283,7 @@ endif() add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}") add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}") if (APPLE AND OPENMW_OSX_DEPLOYMENT) - add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Plugins") + add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Frameworks") else() add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}") endif() @@ -666,7 +666,7 @@ if (APPLE) set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) set(APPS "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}") - set(PLUGINS "") + set(ABSOLUTE_PLUGINS "") foreach (PLUGIN ${USED_OGRE_PLUGINS}) @@ -674,11 +674,9 @@ if (APPLE) set(ABSOLUTE_PLUGINS ${PLUGIN_ABS} ${ABSOLUTE_PLUGINS}) endforeach () - set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins") - install(FILES ${ABSOLUTE_PLUGINS} DESTINATION "${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins" COMPONENT Runtime) + set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Frameworks") foreach (PLUGIN ${ABSOLUTE_PLUGINS}) - get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME) - set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}") + install(DIRECTORY ${PLUGIN} DESTINATION "${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Frameworks" COMPONENT Runtime) endforeach () #For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail @@ -726,7 +724,7 @@ if (APPLE) cmake_policy(SET CMP0009 OLD) set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) - fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\") + fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\") " COMPONENT Runtime) include(CPack) endif (APPLE) From 99cfb8cda28217710369cda38bb18c0a51c3f3d7 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 13:48:23 +0400 Subject: [PATCH 004/171] OS X: this CMake parameters can be set in CMake invocation, no need to hardcode them in CMakeLists.txt --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6014dff6e..2665ebdabe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,6 @@ if (APPLE) set(APP_BUNDLE_NAME "${CMAKE_PROJECT_NAME}.app") set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/${APP_BUNDLE_NAME}") - - set(CMAKE_EXE_LINKER_FLAGS "-F /Library/Frameworks") - set(CMAKE_SHARED_LINKER_FLAGS "-F /Library/Frameworks") - set(CMAKE_MODULE_LINKER_FLAGS "-F /Library/Frameworks") endif (APPLE) # Macros From 87853f406626310554210976bfb84301c643cf30 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 13:52:57 +0400 Subject: [PATCH 005/171] =?UTF-8?q?OS=20X:=20consider=20Ogre=20CG=20plugin?= =?UTF-8?q?=20as=20used=20only=20if=20it=E2=80=99s=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2665ebdabe..9f4523d4fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,8 +246,12 @@ if (APPLE) # List used Ogre plugins SET(USED_OGRE_PLUGINS ${OGRE_RenderSystem_GL_LIBRARY_REL} ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} - ${OGRE_Plugin_CgProgramManager_LIBRARY_REL} ${OGRE_Plugin_ParticleFX_LIBRARY_REL}) + + if (OGRE_Plugin_CgProgramManager_FOUND) + set(USED_OGRE_PLUGINS ${USED_OGRE_PLUGINS} + ${OGRE_Plugin_CgProgramManager_LIBRARY_REL}) + endif () if (${OGRE_PLUGIN_DIR_REL}}) set(OGRE_PLUGINS_REL_FOUND TRUE) From 89c60b065c1fa4ea7e728d250af1001383c7544d Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 14:19:48 +0400 Subject: [PATCH 006/171] OS X: looks like OGRE_Plugin_CgProgramManager_FOUND is not reliable --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f4523d4fb..e1a591b27c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,7 +248,9 @@ if (APPLE) ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} ${OGRE_Plugin_ParticleFX_LIBRARY_REL}) - if (OGRE_Plugin_CgProgramManager_FOUND) + # Actually we must use OGRE_Plugin_CgProgramManager_FOUND but it's + # not reliable and equals TRUE even if there's no Ogre Cg plugin + if (Cg_FOUND) set(USED_OGRE_PLUGINS ${USED_OGRE_PLUGINS} ${OGRE_Plugin_CgProgramManager_LIBRARY_REL}) endif () From 874ecee079d509b9d173a35c724a660b380f5642 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 14:20:13 +0400 Subject: [PATCH 007/171] OS X: do not enforce static boost, this can be set externally anyway --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1a591b27c..61c6f1f58a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,10 +190,6 @@ if (MSVC10) set(PLATFORM_INCLUDE_DIR "") endif() -if (APPLE) - set(Boost_USE_STATIC_LIBS ON) -endif (APPLE) - # Dependencies # Fix for not visible pthreads functions for linker with glibc 2.15 From 73c6aba4d05370e6433c42ea4af534224e4e3377 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 15:20:04 +0400 Subject: [PATCH 008/171] OS X: Ogre plugins are now installed in OpenCS bundle too. Generalized plugin install routine. --- CMakeLists.txt | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61c6f1f58a..f53d738132 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -689,9 +689,9 @@ if (APPLE) set(OPENMW_APP "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}") - set(OPENCS_APP "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/OpenCS.app") + set(OPENCS_BUNDLE_NAME "OpenCS.app") + set(OPENCS_APP "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${OPENCS_BUNDLE_NAME}") - set(PLUGINS "") set(ABSOLUTE_PLUGINS "") foreach (PLUGIN ${USED_OGRE_PLUGINS}) @@ -699,12 +699,25 @@ if (APPLE) set(ABSOLUTE_PLUGINS ${PLUGIN_ABS} ${ABSOLUTE_PLUGINS}) endforeach () - set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins") - install(FILES ${ABSOLUTE_PLUGINS} DESTINATION "${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins" COMPONENT Runtime) - foreach (PLUGIN ${ABSOLUTE_PLUGINS}) - get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME) - set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}") - endforeach () + # installs used plugins in bundle at given path (bundle_path must be relative to ${CMAKE_INSTALL_PREFIX}) + # and returns list of install paths for all installed plugins + function (install_plugins_for_bundle bundle_path plugins_var) + set(RELATIVE_PLUGIN_INSTALL_BASE "${bundle_path}/Contents/Plugins") + install(FILES ${ABSOLUTE_PLUGINS} DESTINATION ${RELATIVE_PLUGIN_INSTALL_BASE} COMPONENT Runtime) + + set(PLUGINS "") + set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${RELATIVE_PLUGIN_INSTALL_BASE}") + + foreach (PLUGIN ${ABSOLUTE_PLUGINS}) + get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME) + set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}") + endforeach () + + set(${plugins_var} ${PLUGINS} PARENT_SCOPE) + endfunction (install_plugins_for_bundle) + + install_plugins_for_bundle("${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}" PLUGINS) + install_plugins_for_bundle("${INSTALL_SUBDIR}/${OPENCS_BUNDLE_NAME}" OPENCS_PLUGINS) #For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail set(DIRS "") @@ -752,7 +765,7 @@ if (APPLE) set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"${OPENMW_APP}\" \"${PLUGINS}\" \"${DIRS}\") - fixup_bundle(\"${OPENCS_APP}\" \"\" \"${DIRS}\") + fixup_bundle(\"${OPENCS_APP}\" \"${OPENCS_PLUGINS}\" \"${DIRS}\") " COMPONENT Runtime) include(CPack) endif (APPLE) From fc21dd1f3afc44ba13a3c868690964b6b636daf9 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 14 Dec 2013 17:21:20 +0400 Subject: [PATCH 009/171] Music playback on OS X >= 10.9 works again. Fixes bug #1041. --- apps/openmw/mwsound/openal_output.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 4ee754b35d..868b4bdbd1 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -316,8 +316,23 @@ void OpenAL_SoundStream::play() throwALerror(); mSamplesQueued = 0; - for(ALuint i = 0;i < sNumBuffers;i++) - alBufferData(mBuffers[i], mFormat, this, 0, mSampleRate); + int srate; + ChannelConfig chans; + SampleType sampleType; + + mDecoder->getInfo(&srate, &chans, &sampleType); + + // Use exactly one sample of silence. + // This is required for OpenAL implementations that don't accept empty buffer data. + // (like one in OS X 10.9) + ALuint sampleSize = framesToBytes(1, chans, sampleType); + std::vector silenceSample(sampleSize); + + if (sampleType == SampleType_UInt8) + std::fill(silenceSample.begin(), silenceSample.end(), 0x80); + + for(ALuint i = 0;i < sNumBuffers;i++) + alBufferData(mBuffers[i], mFormat, &silenceSample[0], sampleSize, mSampleRate); throwALerror(); alSourceQueueBuffers(mSource, sNumBuffers, mBuffers); From 892ff93489fc21ab731e1fe5663f2db8c3babf03 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Tue, 24 Dec 2013 23:28:12 +0400 Subject: [PATCH 010/171] OS X: attempt to fix #1045 --- CMakeLists.txt | 3 ++- components/ogreinit/ogreinit.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f53d738132..04e75e94e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,7 +288,8 @@ endif() add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}") add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}") if (APPLE AND OPENMW_OSX_DEPLOYMENT) - add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Plugins") + # make it empty so plugin loading code can check this and try to find plugins inside app bundle + add_definitions(-DOGRE_PLUGIN_DIR="") else() add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}") endif() diff --git a/components/ogreinit/ogreinit.cpp b/components/ogreinit/ogreinit.cpp index c8fc621c78..46424a29af 100644 --- a/components/ogreinit/ogreinit.cpp +++ b/components/ogreinit/ogreinit.cpp @@ -6,6 +6,10 @@ #include #include +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +#include +#endif + #include #include "ogreplugin.hpp" @@ -127,6 +131,9 @@ namespace OgreInit #endif #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE pluginDir = OGRE_PLUGIN_DIR; + // if path is not specified try to find plugins inside the app bundle + if (pluginDir.empty()) + pluginDir = Ogre::macPluginPath(); #endif #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX pluginDir = OGRE_PLUGIN_DIR_REL; From 9fabae51981ca43eca252336ab9d3bdcf5ef8190 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Tue, 24 Dec 2013 23:59:59 +0400 Subject: [PATCH 011/171] OS X: force Cocoa API for Ogre windows in OpenCS --- apps/opencs/editor.cpp | 3 +++ apps/opencs/view/render/scenewidget.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 1c1e37c2d4..a1de750535 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -225,6 +225,9 @@ int CS::Editor::run() params.insert(std::make_pair("FSAA", "0")); params.insert(std::make_pair("vsync", "false")); params.insert(std::make_pair("hidden", "true")); +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE + params.insert(std::make_pair("macAPI", "cocoa")); +#endif Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index c8b37e9bb0..8cbfc72c60 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -66,6 +66,10 @@ namespace CSVRender params.insert(std::make_pair("title", windowTitle.str())); params.insert(std::make_pair("FSAA", "0")); // TODO setting params.insert(std::make_pair("vsync", "false")); // TODO setting +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE + params.insert(std::make_pair("macAPI", "cocoa")); + params.insert(std::make_pair("macAPICocoaUseNSView", "true")); +#endif mWindow = Ogre::Root::getSingleton().createRenderWindow(windowTitle.str(), this->width(), this->height(), false, ¶ms); mWindow->addViewport(mCamera)->setBackgroundColour(Ogre::ColourValue(0.3,0.3,0.3,1)); From fe34c9cf1faf3d41cb725e1c832cfa19d0e1c434 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 1 Jan 2014 15:06:31 +0100 Subject: [PATCH 012/171] increased version number --- CMakeLists.txt | 4 ++-- readme.txt | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee4a0246b2..c1eca064e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 27) +set (OPENMW_VERSION_MINOR 28) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") @@ -323,7 +323,7 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg configure_file(${OpenMW_SOURCE_DIR}/files/opencs.cfg "${OpenMW_BINARY_DIR}/opencs.cfg") - + configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters "${OpenMW_BINARY_DIR}/resources/defaultfilters" COPYONLY) diff --git a/readme.txt b/readme.txt index 5b9aafcb34..946df64caa 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ OpenMW: A reimplementation of The Elder Scrolls III: Morrowind OpenMW is an attempt at recreating the engine for the popular role-playing game Morrowind by Bethesda Softworks. You need to own and install the original game for OpenMW to work. -Version: 0.27.0 +Version: 0.28.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org @@ -48,42 +48,42 @@ Allowed options: --version print version information and quit --data arg (=data) set data directories (later directories have higher priority) - --data-local arg set local data directory (highest + --data-local arg set local data directory (highest priority) --fallback-archive arg (=fallback-archive) - set fallback BSA archives (later + set fallback BSA archives (later archives have higher priority) --resources arg (=resources) set resources directory --start arg (=Beshara) set initial cell - --content arg content file(s): esm/esp, or + --content arg content file(s): esm/esp, or omwgame/omwaddon --anim-verbose [=arg(=1)] (=0) output animation indices files --no-sound [=arg(=1)] (=0) disable all sounds --script-verbose [=arg(=1)] (=0) verbose script output --script-all [=arg(=1)] (=0) compile all scripts (excluding dialogue scripts) at startup - --script-console [=arg(=1)] (=0) enable console-only script + --script-console [=arg(=1)] (=0) enable console-only script functionality - --script-run arg select a file containing a list of - console commands that is executed on + --script-run arg select a file containing a list of + console commands that is executed on startup --new-game [=arg(=1)] (=0) activate char gen/new game mechanics - --fs-strict [=arg(=1)] (=0) strict file system handling (no case + --fs-strict [=arg(=1)] (=0) strict file system handling (no case folding) - --encoding arg (=win1252) Character encoding used in OpenMW game + --encoding arg (=win1252) Character encoding used in OpenMW game messages: - - win1250 - Central and Eastern European - such as Polish, Czech, Slovak, - Hungarian, Slovene, Bosnian, Croatian, - Serbian (Latin script), Romanian and + + win1250 - Central and Eastern European + such as Polish, Czech, Slovak, + Hungarian, Slovene, Bosnian, Croatian, + Serbian (Latin script), Romanian and Albanian languages - - win1251 - Cyrillic alphabet such as - Russian, Bulgarian, Serbian Cyrillic + + win1251 - Cyrillic alphabet such as + Russian, Bulgarian, Serbian Cyrillic and other languages - - win1252 - Western European (Latin) + + win1252 - Western European (Latin) alphabet, used by default --fallback arg fallback values --no-grab Don't grab mouse cursor From b19b277f182ef4dbe2d2445d4d53754acc0dffb4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 1 Jan 2014 15:16:51 +0100 Subject: [PATCH 013/171] temporarily disable OGRE-integration in OpenCS (need to sort out path problem first) --- apps/opencs/editor.cpp | 3 +++ apps/opencs/main.cpp | 3 +++ apps/opencs/view/world/scenesubview.cpp | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 44926610b3..37f06c8c73 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -210,6 +210,8 @@ int CS::Editor::run() if (mLocal.empty()) return 1; +// temporarily disable OGRE-integration (need to fix path problem first) +#if 0 // TODO: setting Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName("OpenGL Rendering Subsystem")); @@ -223,6 +225,7 @@ int CS::Editor::run() params.insert(std::make_pair("hidden", "true")); Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); +#endif mStartup.show(); diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index 57eaf2d253..931d633127 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -44,8 +44,11 @@ int main(int argc, char *argv[]) // SceneWidget destructor will delete the created render window, which would be called _after_ Root has shut down :( Application mApplication (argc, argv); +// temporarily disable OGRE-integration (need to fix path problem first) +#if 0 OgreInit::OgreInit ogreInit; ogreInit.init("./opencsOgre.log"); // TODO log path? +#endif #ifdef Q_OS_MAC QDir dir(QCoreApplication::applicationDirPath()); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 83b30be133..33ae327a0d 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -43,12 +43,26 @@ toolbar->addTool (new SceneToolMode (toolbar)); toolbar->addTool (new SceneToolMode (toolbar)); layout2->addWidget (toolbar, 0); - +// temporarily disable OGRE-integration (need to fix path problem first) +#if 0 CSVRender::SceneWidget* sceneWidget = new CSVRender::SceneWidget(this); layout2->addWidget (sceneWidget, 1); layout->insertLayout (0, layout2, 1); +#endif + /// \todo replace with rendering widget + QPalette palette2 (palette()); + palette2.setColor (QPalette::Background, Qt::white); + QLabel *placeholder = new QLabel ("Here goes the 3D scene", this); + placeholder->setAutoFillBackground (true); + placeholder->setPalette (palette2); + placeholder->setAlignment (Qt::AlignHCenter); + + layout2->addWidget (placeholder, 1); + + layout->insertLayout (0, layout2, 1); + CSVFilter::FilterBox *filterBox = new CSVFilter::FilterBox (document.getData(), this); From e4c802eac402cfc77e07bc4ea233aac097eae7ed Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 2 Jan 2014 14:17:59 +0100 Subject: [PATCH 014/171] updated changelog --- readme.txt | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/readme.txt b/readme.txt index 946df64caa..132485119d 100644 --- a/readme.txt +++ b/readme.txt @@ -91,6 +91,92 @@ Allowed options: CHANGELOG +0.28.0 + +Bug #399: Inventory changes are not visible immediately +Bug #417: Apply weather instantly when teleporting +Bug #566: Global Map position marker not updated for interior cells +Bug #712: Looting corpse delay +Bug #716: Problem with the "Vurt's Ascadian Isles Mod" mod +Bug #805: Two TR meshes appear black (v0.24RC) +Bug #841: Third-person activation distance taken from camera rather than head +Bug #845: NPCs hold torches during the day +Bug #855: Vvardenfell Visages Volume I some hairs donĀ“t appear since 0,24 +Bug #856: Maormer race by Mac Kom - The heads are way up +Bug #864: Walk locks during loading in 3rd person +Bug #871: active weapon/magic item icon is not immediately made blank if item is removed during dialog +Bug #882: Hircine's Ring doesn't always work +Bug #909: [Tamriel Rebuilt] crashes in Akamora +Bug #922: Launcher writing merged openmw.cfg files +Bug #943: Random magnitude should be calculated per effect +Bug #948: Negative fatigue level should be allowed +Bug #949: Particles in world space +Bug #950: Hard crash on x64 Linux running --new-game (on startup) +Bug #951: setMagicka and setFatigue have no effect +Bug #954: Problem with equipping inventory items when using a keyboard shortcut +Bug #955: Issues with equipping torches +Bug #966: Shield is visible when casting spell +Bug #967: Game crashes when equipping silver candlestick +Bug #970: Segmentation fault when starting at Bal Isra +Bug #977: Pressing down key in console doesn't go forward in history +Bug #979: Tooltip disappears when changing inventory +Bug #980: Barter: item category is remembered, but not shown +Bug #981: Mod: replacing model has wrong position/orientation +Bug #982: Launcher: Addon unchecking is not saved +Bug #983: Fix controllers to affect objects attached to the base node +Bug #985: Player can talk to NPCs who are in combat +Bug #989: OpenMW crashes when trying to include mod with capital .ESP +Bug #991: Merchants equip items with harmful constant effect enchantments +Bug #994: Don't cap skills/attributes when set via console +Bug #998: Setting the max health should also set the current health +Bug #1005: Torches are visible when casting spells and during hand to hand combat. +Bug #1006: Many NPCs have 0 skill +Bug #1007: Console fills up with text +Bug #1013: Player randomly loses health or dies +Bug #1014: Persuasion window is not centered in maximized window +Bug #1015: Player status window scroll state resets on status change +Bug #1016: Notification window not big enough for all skill level ups +Bug #1020: Saved window positions are not rescaled appropriately on resolution change +Bug #1022: Messages stuck permanently on screen when they pile up +Bug #1023: Journals doesn't open +Bug #1026: Game loses track of torch usage. +Bug #1028: Crash on pickup of jug in Unexplored Shipwreck, Upper level +Bug #1029: Quick keys menu: Select compatible replacement when tool used up +Bug #1041: Music playback issues on OS X >= 10.9 +Bug #1042: TES3 header data wrong encoding +Bug #1045: OS X: deployed OpenCS won't launch +Bug #1046: All damaged weaponry is worth 1 gold +Bug #1048: Links in "locked" dialogue are still clickable +Bug #1052: Using color codes when naming your character actually changes the name's color +Bug #1054: Spell effects not visible in front of water +Bug #1055: Power-Spell animation starts even though you already casted it that day +Bug #1059: Cure disease potion removes all effects from player, even your race bonus and race ability +Bug #1063: Crash upon checking out game start ship area in Seyda Neen +Bug #1064: openmw binaries link to unnecessary libraries +Bug #1065: Landing from a high place in water still causes fall damage +Feature #43: Visuals for Magic Effects +Feature #51: Ranged Magic +Feature #52: Touch Range Magic +Feature #53: Self Range Magic +Feature #54: Spell Casting +Feature #70: Vampirism +Feature #100: Combat AI +Feature #171: Implement NIF record NiFlipController +Feature #410: Window to restore enchanted item charge +Feature #647: Enchanted item glow +Feature #723: Invisibility/Chameleon magic effects +Feature #737: Resist Magicka magic effect +Feature #758: GetLOS +Feature #926: Editor: Info-Record tables +Feature #958: Material controllers +Feature #959: Terrain bump, specular, & parallax mapping +Feature #990: Request: unlock mouse when in any menu +Feature #1018: Do not allow view mode switching while performing an action +Feature #1027: Vertex morph animation (NiGeomMorpherController) +Feature #1031: Handle NiBillboardNode +Feature #1051: Implement NIF texture slot DarkTexture +Task #873: Unify OGRE initialisation + 0.27.0 Bug #597: Assertion `dialogue->mId == id' failed in esmstore.cpp From 0ded85893b042cf987ddefe881d56a5ef2982ae3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 2 Jan 2014 20:47:43 +0100 Subject: [PATCH 015/171] updated changelog again --- readme.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.txt b/readme.txt index 132485119d..5a74770f2b 100644 --- a/readme.txt +++ b/readme.txt @@ -154,6 +154,8 @@ Bug #1059: Cure disease potion removes all effects from player, even your race b Bug #1063: Crash upon checking out game start ship area in Seyda Neen Bug #1064: openmw binaries link to unnecessary libraries Bug #1065: Landing from a high place in water still causes fall damage +Bug #1072: Drawing weapon increases torch brightness +Bug #1073: Merchants sell stacks of gold Feature #43: Visuals for Magic Effects Feature #51: Ranged Magic Feature #52: Touch Range Magic From 46931d85a0fcb3f84d55ac07e6dfcd1107fb8a00 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 5 Jan 2014 11:51:31 +0100 Subject: [PATCH 016/171] changed changelog --- readme.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/readme.txt b/readme.txt index 5a74770f2b..21422a8da8 100644 --- a/readme.txt +++ b/readme.txt @@ -142,9 +142,7 @@ Bug #1023: Journals doesn't open Bug #1026: Game loses track of torch usage. Bug #1028: Crash on pickup of jug in Unexplored Shipwreck, Upper level Bug #1029: Quick keys menu: Select compatible replacement when tool used up -Bug #1041: Music playback issues on OS X >= 10.9 Bug #1042: TES3 header data wrong encoding -Bug #1045: OS X: deployed OpenCS won't launch Bug #1046: All damaged weaponry is worth 1 gold Bug #1048: Links in "locked" dialogue are still clickable Bug #1052: Using color codes when naming your character actually changes the name's color From bc90443aeb0b98e18787918e3f289af84b9e39d0 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Wed, 8 Jan 2014 18:07:58 +0400 Subject: [PATCH 017/171] Revert "Music playback on OS X >= 10.9 works again. Fixes bug #1041." This reverts commit fc21dd1f3afc44ba13a3c868690964b6b636daf9. --- apps/openmw/mwsound/openal_output.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 868b4bdbd1..4ee754b35d 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -316,23 +316,8 @@ void OpenAL_SoundStream::play() throwALerror(); mSamplesQueued = 0; - int srate; - ChannelConfig chans; - SampleType sampleType; - - mDecoder->getInfo(&srate, &chans, &sampleType); - - // Use exactly one sample of silence. - // This is required for OpenAL implementations that don't accept empty buffer data. - // (like one in OS X 10.9) - ALuint sampleSize = framesToBytes(1, chans, sampleType); - std::vector silenceSample(sampleSize); - - if (sampleType == SampleType_UInt8) - std::fill(silenceSample.begin(), silenceSample.end(), 0x80); - - for(ALuint i = 0;i < sNumBuffers;i++) - alBufferData(mBuffers[i], mFormat, &silenceSample[0], sampleSize, mSampleRate); + for(ALuint i = 0;i < sNumBuffers;i++) + alBufferData(mBuffers[i], mFormat, this, 0, mSampleRate); throwALerror(); alSourceQueueBuffers(mSource, sNumBuffers, mBuffers); From 92521bd23d1d973ba31b62b24cd2db3a0f7b966c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 8 Jan 2014 20:27:33 +0100 Subject: [PATCH 018/171] updated changelog --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 21422a8da8..242dcb5c0c 100644 --- a/readme.txt +++ b/readme.txt @@ -143,6 +143,7 @@ Bug #1026: Game loses track of torch usage. Bug #1028: Crash on pickup of jug in Unexplored Shipwreck, Upper level Bug #1029: Quick keys menu: Select compatible replacement when tool used up Bug #1042: TES3 header data wrong encoding +Bug #1045: OS X: deployed OpenCS won't launch Bug #1046: All damaged weaponry is worth 1 gold Bug #1048: Links in "locked" dialogue are still clickable Bug #1052: Using color codes when naming your character actually changes the name's color From a36cc264349584a1c0f6abfa1669d109843aadb3 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 1 Feb 2014 19:06:41 +0100 Subject: [PATCH 019/171] Created new files for TableMimeData class. --- apps/opencs/model/world/tablemimedata.cpp | 1 + apps/opencs/model/world/tablemimedata.hpp | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 apps/opencs/model/world/tablemimedata.cpp create mode 100644 apps/opencs/model/world/tablemimedata.hpp diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp new file mode 100644 index 0000000000..a8947394a8 --- /dev/null +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -0,0 +1 @@ +#include "tablemimedata.hpp" diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp new file mode 100644 index 0000000000..d96263ae2f --- /dev/null +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -0,0 +1,10 @@ +#ifndef TABLEMIMEDATA_H +#define TABLEMIMEDATA_H + +#include + +class TableMimeData : public QMimeData +{ +}; + +#endif // TABLEMIMEDATA_H From 8bcdf54570bc01659d06f8691d089ad5864bc1dd Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 2 Feb 2014 13:55:03 +0100 Subject: [PATCH 020/171] added warning mode to script compiler error handler --- components/compiler/errorhandler.cpp | 16 +++++++++++++--- components/compiler/errorhandler.hpp | 6 +++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/components/compiler/errorhandler.cpp b/components/compiler/errorhandler.cpp index ee13c837d1..fe58836cca 100644 --- a/components/compiler/errorhandler.cpp +++ b/components/compiler/errorhandler.cpp @@ -5,7 +5,7 @@ namespace Compiler { // constructor - ErrorHandler::ErrorHandler() : mWarnings (0), mErrors (0) {} + ErrorHandler::ErrorHandler() : mWarnings (0), mErrors (0), mWarningsMode (1) {} // destructor @@ -36,8 +36,13 @@ namespace Compiler void ErrorHandler::warning (const std::string& message, const TokenLoc& loc) { - ++mWarnings; - report (message, loc, WarningMessage); + if (mWarningsMode==1) + { + ++mWarnings; + report (message, loc, WarningMessage); + } + else if (mWarningsMode==2) + error (message, loc); } // Generate an error message. @@ -62,4 +67,9 @@ namespace Compiler { mErrors = mWarnings = 0; } + + void ErrorHandler::setWarningsMode (int mode) + { + mWarningsMode = mode; + } } diff --git a/components/compiler/errorhandler.hpp b/components/compiler/errorhandler.hpp index 256065854a..e5922a6be5 100644 --- a/components/compiler/errorhandler.hpp +++ b/components/compiler/errorhandler.hpp @@ -16,6 +16,7 @@ namespace Compiler { int mWarnings; int mErrors; + int mWarningsMode; protected: @@ -60,8 +61,11 @@ namespace Compiler void endOfFile(); ///< Generate an error message for an unexpected EOF. - virtual void reset(); + virtual void reset(); ///< Remove all previous error/warning events + + void setWarningsMode (int mode); + ///< // 0 ignore, 1 rate as warning, 2 rate as error }; } From 4ee43612f66915ea1dc768b63a012c3cb06e9d89 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 2 Feb 2014 14:09:59 +0100 Subject: [PATCH 021/171] added new switch: --script-warn --- apps/openmw/engine.cpp | 9 +++-- apps/openmw/engine.hpp | 3 ++ apps/openmw/main.cpp | 8 +++++ apps/openmw/mwscript/scriptmanagerimp.cpp | 6 ++-- apps/openmw/mwscript/scriptmanagerimp.hpp | 2 +- readme.txt | 42 +++++++++++++---------- 6 files changed, 47 insertions(+), 23 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index bf1cca5e0f..e80bd954e3 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -155,6 +155,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mSkipMenu (false) , mUseSound (true) , mCompileAll (false) + , mWarningsMode (1) , mScriptContext (0) , mFSStrict (false) , mScriptConsoleMode (false) @@ -424,7 +425,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) mScriptContext->setExtensions (&mExtensions); mEnvironment.setScriptManager (new MWScript::ScriptManager (MWBase::Environment::get().getWorld()->getStore(), - mVerboseScripts, *mScriptContext)); + mVerboseScripts, *mScriptContext, mWarningsMode)); // Create game mechanics system MWMechanics::MechanicsManager* mechanics = new MWMechanics::MechanicsManager; @@ -612,8 +613,12 @@ void OMW::Engine::setStartupScript (const std::string& path) mStartupScript = path; } - void OMW::Engine::setActivationDistanceOverride (int distance) { mActivationDistanceOverride = distance; } + +void OMW::Engine::setWarningsMode (int mode) +{ + mWarningsMode = mode; +} \ No newline at end of file diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 8b2a65b7ed..5c15ddf6fc 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -74,6 +74,7 @@ namespace OMW bool mSkipMenu; bool mUseSound; bool mCompileAll; + int mWarningsMode; std::string mFocusName; std::map mFallbackMap; bool mScriptConsoleMode; @@ -181,6 +182,8 @@ namespace OMW /// Override the game setting specified activation distance. void setActivationDistanceOverride (int distance); + void setWarningsMode (int mode); + private: Files::ConfigurationManager& mCfgMgr; }; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 570c2b1983..764c4f39b8 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -137,6 +137,13 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("script-run", bpo::value()->default_value(""), "select a file containing a list of console commands that is executed on startup") + ("script-warn", bpo::value()->implicit_value (1) + ->default_value (1), + "handling of warnings when compiling scripts\n" + "\t0 - ignore warning\n" + "\t1 - show warning but consider script as correctly compiled anyway\n" + "\t2 - treat warnings as errors") + ("skip-menu", bpo::value()->implicit_value(true) ->default_value(false), "skip main menu on game startup") @@ -242,6 +249,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setScriptConsoleMode (variables["script-console"].as()); engine.setStartupScript (variables["script-run"].as()); engine.setActivationDistanceOverride (variables["activate-dist"].as()); + engine.setWarningsMode (variables["script-warn"].as()); return true; } diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index a3e0615467..6862b9f830 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -18,11 +18,13 @@ namespace MWScript { ScriptManager::ScriptManager (const MWWorld::ESMStore& store, bool verbose, - Compiler::Context& compilerContext) + Compiler::Context& compilerContext, int warningsMode) : mErrorHandler (std::cerr), mStore (store), mVerbose (verbose), mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext), mOpcodesInstalled (false), mGlobalScripts (store) - {} + { + mErrorHandler.setWarningsMode (warningsMode); + } bool ScriptManager::compile (const std::string& name) { diff --git a/apps/openmw/mwscript/scriptmanagerimp.hpp b/apps/openmw/mwscript/scriptmanagerimp.hpp index 1a856e0c58..da3abc60b5 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.hpp +++ b/apps/openmw/mwscript/scriptmanagerimp.hpp @@ -52,7 +52,7 @@ namespace MWScript public: ScriptManager (const MWWorld::ESMStore& store, bool verbose, - Compiler::Context& compilerContext); + Compiler::Context& compilerContext, int warningsMode); virtual void run (const std::string& name, Interpreter::Context& interpreterContext); ///< Run the script with the given name (compile first, if not compiled yet) diff --git a/readme.txt b/readme.txt index 6b388dc724..f4d0c0b8f7 100644 --- a/readme.txt +++ b/readme.txt @@ -48,42 +48,48 @@ Allowed options: --version print version information and quit --data arg (=data) set data directories (later directories have higher priority) - --data-local arg set local data directory (highest + --data-local arg set local data directory (highest priority) --fallback-archive arg (=fallback-archive) - set fallback BSA archives (later + set fallback BSA archives (later archives have higher priority) --resources arg (=resources) set resources directory --start arg (=Beshara) set initial cell - --content arg content file(s): esm/esp, or + --content arg content file(s): esm/esp, or omwgame/omwaddon --anim-verbose [=arg(=1)] (=0) output animation indices files --no-sound [=arg(=1)] (=0) disable all sounds --script-verbose [=arg(=1)] (=0) verbose script output --script-all [=arg(=1)] (=0) compile all scripts (excluding dialogue scripts) at startup - --script-console [=arg(=1)] (=0) enable console-only script + --script-console [=arg(=1)] (=0) enable console-only script functionality - --script-run arg select a file containing a list of - console commands that is executed on + --script-run arg select a file containing a list of + console commands that is executed on startup + --script-warn [=arg(=1)] (=1) handling of warnings when compiling + scripts + 0 - ignore warning + 1 - show warning but consider script as + correctly compiled anyway + 2 - treat warnings as errors --new-game [=arg(=1)] (=0) activate char gen/new game mechanics - --fs-strict [=arg(=1)] (=0) strict file system handling (no case + --fs-strict [=arg(=1)] (=0) strict file system handling (no case folding) - --encoding arg (=win1252) Character encoding used in OpenMW game + --encoding arg (=win1252) Character encoding used in OpenMW game messages: - - win1250 - Central and Eastern European - such as Polish, Czech, Slovak, - Hungarian, Slovene, Bosnian, Croatian, - Serbian (Latin script), Romanian and + + win1250 - Central and Eastern European + such as Polish, Czech, Slovak, + Hungarian, Slovene, Bosnian, Croatian, + Serbian (Latin script), Romanian and Albanian languages - - win1251 - Cyrillic alphabet such as - Russian, Bulgarian, Serbian Cyrillic + + win1251 - Cyrillic alphabet such as + Russian, Bulgarian, Serbian Cyrillic and other languages - - win1252 - Western European (Latin) + + win1252 - Western European (Latin) alphabet, used by default --fallback arg fallback values --no-grab Don't grab mouse cursor From 858dc80292a31c7359fc728f6d2c964a64f0f838 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 2 Feb 2014 14:10:57 +0100 Subject: [PATCH 022/171] corrected command line switch documentation in readme file --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index f4d0c0b8f7..b1fef2d097 100644 --- a/readme.txt +++ b/readme.txt @@ -73,7 +73,7 @@ Allowed options: 1 - show warning but consider script as correctly compiled anyway 2 - treat warnings as errors - --new-game [=arg(=1)] (=0) activate char gen/new game mechanics + --skip-menu [=arg(=1)] (=0) skip main menu on game startup --fs-strict [=arg(=1)] (=0) strict file system handling (no case folding) --encoding arg (=win1252) Character encoding used in OpenMW game From cd9b13712921be4c61968e7959cff2b287f6fc17 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 2 Feb 2014 14:24:58 +0100 Subject: [PATCH 023/171] allow elseif without matching if (grrrrr) --- components/compiler/controlparser.cpp | 6 +++++- components/compiler/scriptparser.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/compiler/controlparser.cpp b/components/compiler/controlparser.cpp index 5d74ee9d42..3be470c273 100644 --- a/components/compiler/controlparser.cpp +++ b/components/compiler/controlparser.cpp @@ -7,6 +7,7 @@ #include "scanner.hpp" #include "generator.hpp" +#include "errorhandler.hpp" namespace Compiler { @@ -186,8 +187,11 @@ namespace Compiler { if (mState==StartState) { - if (keyword==Scanner::K_if) + if (keyword==Scanner::K_if || keyword==Scanner::K_elseif) { + if (keyword==Scanner::K_elseif) + getErrorHandler().warning ("elseif without matching if", loc); + mExprParser.reset(); scanner.scan (mExprParser); diff --git a/components/compiler/scriptparser.cpp b/components/compiler/scriptparser.cpp index 5b3d244b0d..1b613595a6 100644 --- a/components/compiler/scriptparser.cpp +++ b/components/compiler/scriptparser.cpp @@ -32,7 +32,7 @@ namespace Compiler bool ScriptParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) { - if (keyword==Scanner::K_while || keyword==Scanner::K_if) + if (keyword==Scanner::K_while || keyword==Scanner::K_if || keyword==Scanner::K_elseif) { mControlParser.reset(); if (mControlParser.parseKeyword (keyword, loc, scanner)) From 914ab1b8ab689f1462d2f396d936ab0377bb2b2f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 2 Feb 2014 15:08:27 +0100 Subject: [PATCH 024/171] allow 'x' instead of 'getjournalindex x' --- apps/opencs/model/world/scriptcontext.cpp | 6 ++++++ apps/opencs/model/world/scriptcontext.hpp | 3 +++ apps/openmw/mwscript/compilercontext.cpp | 12 ++++++++++++ apps/openmw/mwscript/compilercontext.hpp | 3 +++ components/compiler/context.hpp | 3 +++ components/compiler/exprparser.cpp | 19 ++++++++++++++++++- 6 files changed, 45 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index 86689d823b..8190c68eb7 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -38,6 +38,12 @@ bool CSMWorld::ScriptContext::isId (const std::string& name) const return std::binary_search (mIds.begin(), mIds.end(), Misc::StringUtils::lowerCase (name)); } +bool CSMWorld::ScriptContext::isJournalId (const std::string& name) const +{ + /// \todo fix this after isId is fixed + return isId (name); +} + void CSMWorld::ScriptContext::invalidateIds() { mIdsUpdated = false; diff --git a/apps/opencs/model/world/scriptcontext.hpp b/apps/opencs/model/world/scriptcontext.hpp index b839b5a432..961da9143b 100644 --- a/apps/opencs/model/world/scriptcontext.hpp +++ b/apps/opencs/model/world/scriptcontext.hpp @@ -32,6 +32,9 @@ namespace CSMWorld virtual bool isId (const std::string& name) const; ///< Does \a name match an ID, that can be referenced? + virtual bool isJournalId (const std::string& name) const; + ///< Does \a name match a journal ID? + void invalidateIds(); }; } diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index 7e63a33b25..b094e54147 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -3,6 +3,8 @@ #include "../mwworld/esmstore.hpp" +#include + #include #include "../mwbase/environment.hpp" @@ -67,4 +69,14 @@ namespace MWScript store.get().search (name) || store.get().search (name); } + + bool CompilerContext::isJournalId (const std::string& name) const + { + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Dialogue *topic = store.get().search (name); + + return topic && topic->mType==ESM::Dialogue::Journal; + } } diff --git a/apps/openmw/mwscript/compilercontext.hpp b/apps/openmw/mwscript/compilercontext.hpp index 5ec98e09a7..50256f9422 100644 --- a/apps/openmw/mwscript/compilercontext.hpp +++ b/apps/openmw/mwscript/compilercontext.hpp @@ -35,6 +35,9 @@ namespace MWScript virtual bool isId (const std::string& name) const; ///< Does \a name match an ID, that can be referenced? + + virtual bool isJournalId (const std::string& name) const; + ///< Does \a name match a journal ID? }; } diff --git a/components/compiler/context.hpp b/components/compiler/context.hpp index 1b02613c59..69146e285f 100644 --- a/components/compiler/context.hpp +++ b/components/compiler/context.hpp @@ -38,6 +38,9 @@ namespace Compiler virtual bool isId (const std::string& name) const = 0; ///< Does \a name match an ID, that can be referenced? + + virtual bool isJournalId (const std::string& name) const = 0; + ///< Does \a name match a journal ID? }; } diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 94240c5eb9..42c88b75ab 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include "generator.hpp" #include "scanner.hpp" #include "errorhandler.hpp" @@ -14,7 +16,6 @@ #include "stringparser.hpp" #include "extensions.hpp" #include "context.hpp" -#include namespace Compiler { @@ -308,6 +309,22 @@ namespace Compiler return true; } + // die in a fire, Morrowind script compiler! + if (const Extensions *extensions = getContext().getExtensions()) + { + if (getContext().isJournalId (name2)) + { + // JournalID used as an argument. Use the index of that JournalID + Generator::pushString (mCode, mLiterals, name2); + int keyword = extensions->searchKeyword ("getjournalindex"); + extensions->generateFunctionCode (keyword, mCode, mLiterals, mExplicit, 0); + mNextOperand = false; + mOperands.push_back ('l'); + + return 2; + } + } + if (mExplicit.empty() && getContext().isId (name2)) { mExplicit = name2; From 32860a05e38f7b67afc8725beed30254d4c69dc1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 2 Feb 2014 15:35:18 +0100 Subject: [PATCH 025/171] added dummy implementations for getPcInJail and getPcTraveling --- apps/openmw/mwscript/docs/vmformat.txt | 4 +++- apps/openmw/mwscript/miscextensions.cpp | 24 ++++++++++++++++++++++++ components/compiler/extensions0.cpp | 4 +++- components/compiler/opcodes.hpp | 2 ++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 25f3c38aa7..2fe4c768ba 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -381,5 +381,7 @@ op 0x200023a: StartCombat op 0x200023b: StartCombatExplicit op 0x200023c: StopCombat op 0x200023d: StopCombatExplicit +op 0x200023e: GetPcInJail +op 0x200023f: GetPcTraveling -opcodes 0x200023e-0x3ffffff unused +opcodes 0x2000240-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index d117c8dede..aa0e775af2 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -818,6 +818,28 @@ namespace MWScript } }; + class OpGetPcInJail : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime &runtime) + { + /// \todo implement jail check + runtime.push (0); + } + }; + + class OpGetPcTraveling : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime &runtime) + { + /// \todo implement traveling check + runtime.push (0); + } + }; + void installOpcodes (Interpreter::Interpreter& interpreter) { interpreter.installSegment5 (Compiler::Misc::opcodeXBox, new OpXBox); @@ -888,6 +910,8 @@ namespace MWScript interpreter.installSegment5 (Compiler::Misc::opcodeCastExplicit, new OpCast); interpreter.installSegment5 (Compiler::Misc::opcodeExplodeSpell, new OpExplodeSpell); interpreter.installSegment5 (Compiler::Misc::opcodeExplodeSpellExplicit, new OpExplodeSpell); + interpreter.installSegment5 (Compiler::Misc::opcodeGetPcInJail, new OpGetPcInJail); + interpreter.installSegment5 (Compiler::Misc::opcodeGetPcTraveling, new OpGetPcTraveling); } } } diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index baec9987fa..ebe46d2826 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -190,7 +190,7 @@ namespace Compiler extensions.registerInstruction ("enableclassmenu", "", opcodeEnableClassMenu); extensions.registerInstruction ("enablenamemenu", "", opcodeEnableNameMenu); extensions.registerInstruction ("enableracemenu", "", opcodeEnableRaceMenu); - extensions.registerInstruction ("enablestatreviewmenu", "", + extensions.registerInstruction ("enablestatreviewmenu", "", opcodeEnableStatsReviewMenu); extensions.registerInstruction ("enableinventorymenu", "", opcodeEnableInventoryMenu); @@ -276,6 +276,8 @@ namespace Compiler extensions.registerInstruction("togglegodmode", "", opcodeToggleGodMode); extensions.registerInstruction ("disablelevitation", "", opcodeDisableLevitation); extensions.registerInstruction ("enablelevitation", "", opcodeEnableLevitation); + extensions.registerFunction ("getpcinjail", 'l', "", opcodeGetPcInJail); + extensions.registerFunction ("getpctraveling", 'l', "", opcodeGetPcTraveling); } } diff --git a/components/compiler/opcodes.hpp b/components/compiler/opcodes.hpp index 57d86e62bf..583cf4eea3 100644 --- a/components/compiler/opcodes.hpp +++ b/components/compiler/opcodes.hpp @@ -245,6 +245,8 @@ namespace Compiler const int opcodeCastExplicit = 0x2000228; const int opcodeExplodeSpell = 0x2000229; const int opcodeExplodeSpellExplicit = 0x200022a; + const int opcodeGetPcInJail = 0x200023e; + const int opcodeGetPcTraveling = 0x200023f; } namespace Sky From 2b2ac6f62b7db5972fbf461056d06576e9e4557f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 2 Feb 2014 15:43:48 +0100 Subject: [PATCH 026/171] allow declaration of local variables with keywords as names --- components/compiler/lineparser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 3d9ac0a93a..2904df6e1b 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -370,6 +370,12 @@ namespace Compiler mState = EndState; return true; } + else if (mState==ShortState || mState==LongState || mState==FloatState) + { + // allow keywords to be used as local variable names. MW script compiler, you suck! + /// \todo option to disable this atrocity. + return parseName (loc.mLiteral, loc, scanner); + } if (mAllowExpression) { From dc80bfff554404fa998d5b762da9afc62ed50f1d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 09:13:40 +0100 Subject: [PATCH 027/171] Attempt to get basic tablemimedata subclass. --- apps/opencs/model/world/tablemimedata.cpp | 21 +++++++++++++++++++++ apps/opencs/model/world/tablemimedata.hpp | 20 ++++++++++++++++++-- apps/opencs/view/world/table.cpp | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index a8947394a8..457f5af1b8 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -1 +1,22 @@ #include "tablemimedata.hpp" +#include "universalid.hpp" + +CSMWorld::TableMimeData::TableMimeData (CSMWorld::UniversalId& UniversalId) : +mUniversalId(UniversalId) +{ + mSupportedFormats << UniversalId.toString().c_str(); +} + +QStringList CSMWorld::TableMimeData::formats() const +{ + return QMimeData::formats(); +} + +CSMWorld::TableMimeData::~TableMimeData() +{ +} + +CSMWorld::UniversalId& CSMWorld::TableMimeData::getId() +{ + return mUniversalId; +} diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index d96263ae2f..d142c66c1c 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -1,10 +1,26 @@ +/*This class provides way to construct mimedata object holding the reference to the +* universalid. universalid is used in the majority of the tables to store type, id, argument types*/ + #ifndef TABLEMIMEDATA_H #define TABLEMIMEDATA_H #include +#include -class TableMimeData : public QMimeData +namespace CSMWorld { -}; + class UniversalId; + class TableMimeData : public QMimeData + { + public: + TableMimeData(UniversalId& UniversalId); + ~TableMimeData(); + virtual QStringList formats() const; + UniversalId& getId(); + private: + QStringList mSupportedFormats; + UniversalId& mUniversalId; + }; +} #endif // TABLEMIMEDATA_H diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 71bdb9000e..7d02555292 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -13,6 +13,7 @@ #include "../../model/world/idtable.hpp" #include "../../model/world/record.hpp" #include "../../model/world/columns.hpp" +#include "../../model/world/tablemimedata.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" From 423b2906be19ad6a448fd9fda1e338972090510b Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 11:40:48 +0100 Subject: [PATCH 028/171] Yes, you can drag. But not drop. --- CMakeLists.txt | 2 +- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/world/tablemimedata.cpp | 8 ++++---- apps/opencs/model/world/tablemimedata.hpp | 10 +++++++--- apps/opencs/view/world/table.cpp | 21 +++++++++++++++++++++ apps/opencs/view/world/table.hpp | 3 +++ 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cb2fd5b2d..c4981841a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,7 +324,7 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg configure_file(${OpenMW_SOURCE_DIR}/files/opencs.cfg "${OpenMW_BINARY_DIR}/opencs.cfg") - + configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters "${OpenMW_BINARY_DIR}/resources/defaultfilters" COPYONLY) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index e2dffdbde4..2c53e2fdd1 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -24,7 +24,7 @@ opencs_units (model/world opencs_units_noqt (model/world universalid record commands columnbase scriptcontext cell refidcollection - refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection + refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata ) opencs_hdrs_noqt (model/world diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 457f5af1b8..5f04d316ab 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -1,10 +1,10 @@ #include "tablemimedata.hpp" #include "universalid.hpp" -CSMWorld::TableMimeData::TableMimeData (CSMWorld::UniversalId& UniversalId) : -mUniversalId(UniversalId) +CSMWorld::TableMimeData::TableMimeData (UniversalId id) : +mUniversalId(id) { - mSupportedFormats << UniversalId.toString().c_str(); + mSupportedFormats << QString::fromStdString("application/Type_" + id.getTypeName()); } QStringList CSMWorld::TableMimeData::formats() const @@ -19,4 +19,4 @@ CSMWorld::TableMimeData::~TableMimeData() CSMWorld::UniversalId& CSMWorld::TableMimeData::getId() { return mUniversalId; -} +} \ No newline at end of file diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index d142c66c1c..5883966cd0 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -5,7 +5,11 @@ #define TABLEMIMEDATA_H #include -#include +#include + +#include "universalid.hpp" + +class QStringList; namespace CSMWorld { @@ -13,14 +17,14 @@ namespace CSMWorld class TableMimeData : public QMimeData { public: - TableMimeData(UniversalId& UniversalId); + TableMimeData(UniversalId id); ~TableMimeData(); virtual QStringList formats() const; UniversalId& getId(); private: QStringList mSupportedFormats; - UniversalId& mUniversalId; + UniversalId mUniversalId; }; } #endif // TABLEMIMEDATA_H diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 7d02555292..450af191e8 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -412,3 +412,24 @@ void CSVWorld::Table::recordFilterChanged (boost::shared_ptr fi { mProxyModel->setFilter (filter); } + +void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) +{ + if (event->buttons() & Qt::LeftButton) + { + QModelIndexList selectedRows = selectionModel()->selectedRows(); + + if (selectedRows.size() == 0) + { + return; + } + + if (selectedRows.size() == 1) //tmp solution + { + CSMWorld::TableMimeData *mime = new CSMWorld::TableMimeData(getUniversalId(selectedRows.begin()->row())); + QDrag *drag = new QDrag(this); + drag->setMimeData(mime); + drag->start(); + } + } +} \ No newline at end of file diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 889e2847ac..ec08e4e2b4 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -5,6 +5,7 @@ #include #include +#include #include "../../model/filter/node.hpp" @@ -49,6 +50,8 @@ namespace CSVWorld std::vector listDeletableSelectedIds() const; + void mouseMoveEvent(QMouseEvent *event); + public: Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting); From 3439940a8e3fd63e594ca631f30e3390c1bb45d2 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 18:30:47 +0100 Subject: [PATCH 029/171] Tablemimedata able to handle vector of objects and return icon. --- apps/opencs/model/world/tablemimedata.cpp | 56 ++++++++++++++++++++--- apps/opencs/model/world/tablemimedata.hpp | 12 +++-- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 5f04d316ab..b501ce2ea0 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -1,22 +1,64 @@ #include "tablemimedata.hpp" #include "universalid.hpp" +#include -CSMWorld::TableMimeData::TableMimeData (UniversalId id) : -mUniversalId(id) +CSMWorld::TableMimeData::TableMimeData (UniversalId id) { - mSupportedFormats << QString::fromStdString("application/Type_" + id.getTypeName()); + mUniversalId.push_back(id); + mObjectsFormats << QString::fromStdString("application/Type_" + id.getTypeName()); +} + +CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) +{ + mUniversalId = id; + for (std::vector::iterator it(mUniversalId.begin()); it != mUniversalId.end(); ++it) + { + mObjectsFormats << QString::fromStdString("application/Type_" + it->getTypeName()); + } } QStringList CSMWorld::TableMimeData::formats() const { - return QMimeData::formats(); + return mObjectsFormats; } CSMWorld::TableMimeData::~TableMimeData() { } -CSMWorld::UniversalId& CSMWorld::TableMimeData::getId() +CSMWorld::UniversalId CSMWorld::TableMimeData::getId(unsigned int index) const { - return mUniversalId; -} \ No newline at end of file + if (mUniversalId.empty()) + { + throw("TableMimeData holds no UniversalId"); + } + return mUniversalId[index]; +} + +std::string CSMWorld::TableMimeData::getIcon() const +{ + if (mUniversalId.empty()) + { + throw("TableMimeData holds no UniversalId"); + } + + std::string tmpIcon; + bool firstIteration = true; + for (unsigned i = 0; i < mUniversalId.size(); ++i) + { + if (firstIteration) + { + firstIteration = false; + tmpIcon = mUniversalId[i].getIcon(); + continue; + } + + if (tmpIcon != mUniversalId[i].getIcon()) + { + return ""; //should return multiple types icon, but at the moment we don't have one + } + + tmpIcon = mUniversalId[i].getIcon(); + } + return mUniversalId.begin()->getIcon(); //All objects are of the same type; +} diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 5883966cd0..789f4b524b 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -4,27 +4,29 @@ #ifndef TABLEMIMEDATA_H #define TABLEMIMEDATA_H +#include + #include #include #include "universalid.hpp" -class QStringList; namespace CSMWorld { - class UniversalId; class TableMimeData : public QMimeData { public: TableMimeData(UniversalId id); + TableMimeData(std::vector& id); ~TableMimeData(); virtual QStringList formats() const; - UniversalId& getId(); + UniversalId getId(unsigned int index) const; + std::string getIcon() const; private: - QStringList mSupportedFormats; - UniversalId mUniversalId; + std::vector mUniversalId; + QStringList mObjectsFormats; }; } #endif // TABLEMIMEDATA_H From 8b799683c1e41dd87d2af6bfaa7fe6ed74e44133 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 18:48:18 +0100 Subject: [PATCH 030/171] Display QPixMap with dragged object. --- apps/opencs/view/world/table.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 450af191e8..e7ae62e024 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -421,7 +421,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) if (selectedRows.size() == 0) { - return; + return; } if (selectedRows.size() == 1) //tmp solution @@ -429,6 +429,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) CSMWorld::TableMimeData *mime = new CSMWorld::TableMimeData(getUniversalId(selectedRows.begin()->row())); QDrag *drag = new QDrag(this); drag->setMimeData(mime); + drag->setPixmap(QString::fromStdString(mime->getIcon())); drag->start(); } } From 04287cb87ab01b7458d842b26ae289887c798ca8 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 19:42:52 +0100 Subject: [PATCH 031/171] Provide method to return whole data vector from tablemimedata. --- apps/opencs/model/world/tablemimedata.cpp | 5 +++++ apps/opencs/model/world/tablemimedata.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index b501ce2ea0..7ca287521f 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -62,3 +62,8 @@ std::string CSMWorld::TableMimeData::getIcon() const } return mUniversalId.begin()->getIcon(); //All objects are of the same type; } + +std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const +{ + return mUniversalId; +} \ No newline at end of file diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 789f4b524b..90f7aefe2c 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -23,6 +23,7 @@ namespace CSMWorld virtual QStringList formats() const; UniversalId getId(unsigned int index) const; std::string getIcon() const; + std::vector getData() const; private: std::vector mUniversalId; From 76b729ac9baf57049e8b1e50ba7ca67e7a9371bc Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 5 Feb 2014 11:19:55 +0100 Subject: [PATCH 032/171] Removed getUniversalid interface. --- apps/opencs/model/world/tablemimedata.cpp | 9 --------- apps/opencs/model/world/tablemimedata.hpp | 3 +-- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 7ca287521f..1be694dac4 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -26,15 +26,6 @@ CSMWorld::TableMimeData::~TableMimeData() { } -CSMWorld::UniversalId CSMWorld::TableMimeData::getId(unsigned int index) const -{ - if (mUniversalId.empty()) - { - throw("TableMimeData holds no UniversalId"); - } - return mUniversalId[index]; -} - std::string CSMWorld::TableMimeData::getIcon() const { if (mUniversalId.empty()) diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 90f7aefe2c..193c621221 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -21,7 +21,6 @@ namespace CSMWorld TableMimeData(std::vector& id); ~TableMimeData(); virtual QStringList formats() const; - UniversalId getId(unsigned int index) const; std::string getIcon() const; std::vector getData() const; @@ -30,4 +29,4 @@ namespace CSMWorld QStringList mObjectsFormats; }; } -#endif // TABLEMIMEDATA_H +#endif // TABLEMIMEDATA_H \ No newline at end of file From f01b02c42d2272e0596e31e72bd6113a1d2e2253 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 5 Feb 2014 11:24:33 +0100 Subject: [PATCH 033/171] Changed format. --- apps/opencs/model/world/tablemimedata.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 1be694dac4..0cdcdba3ae 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -5,7 +5,7 @@ CSMWorld::TableMimeData::TableMimeData (UniversalId id) { mUniversalId.push_back(id); - mObjectsFormats << QString::fromStdString("application/Type_" + id.getTypeName()); + mObjectsFormats << QString::fromStdString("tabledata/" + id.getTypeName()); } CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) @@ -13,7 +13,7 @@ CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id mUniversalId = id; for (std::vector::iterator it(mUniversalId.begin()); it != mUniversalId.end(); ++it) { - mObjectsFormats << QString::fromStdString("application/Type_" + it->getTypeName()); + mObjectsFormats << QString::fromStdString("tabledata/" + it->getTypeName()); } } From 3b8f04c0f345ddd4588321d2e43b6ff132774f40 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 5 Feb 2014 11:44:08 +0100 Subject: [PATCH 034/171] Allow multi-item drag. --- apps/opencs/view/world/table.cpp | 42 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index e7ae62e024..ff0eabf27e 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -415,22 +415,36 @@ void CSVWorld::Table::recordFilterChanged (boost::shared_ptr fi void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) { - if (event->buttons() & Qt::LeftButton) - { - QModelIndexList selectedRows = selectionModel()->selectedRows(); + if (event->buttons() & Qt::LeftButton) + { + QModelIndexList selectedRows = selectionModel()->selectedRows(); - if (selectedRows.size() == 0) - { - return; - } + if (selectedRows.size() == 0) + { + return; + } - if (selectedRows.size() == 1) //tmp solution - { - CSMWorld::TableMimeData *mime = new CSMWorld::TableMimeData(getUniversalId(selectedRows.begin()->row())); - QDrag *drag = new QDrag(this); - drag->setMimeData(mime); - drag->setPixmap(QString::fromStdString(mime->getIcon())); + QDrag* drag = new QDrag (this); + CSMWorld::TableMimeData* mime = NULL; + + if (selectedRows.size() == 1) + { + mime = new CSMWorld::TableMimeData (getUniversalId (selectedRows.begin()->row())); + } + else + { + std::vector idToDrag; + + foreach (QModelIndex it, selectedRows) + { + idToDrag.push_back (getUniversalId (it.row())); + } + + mime = new CSMWorld::TableMimeData (idToDrag); + } + + drag->setMimeData (mime); + drag->setPixmap (QString::fromStdString (mime->getIcon())); drag->start(); - } } } \ No newline at end of file From b5006c5dbd7f2840b3907ae59f367bc4a19b87ad Mon Sep 17 00:00:00 2001 From: gus Date: Sun, 9 Feb 2014 15:33:00 +0100 Subject: [PATCH 035/171] compile fix --- apps/opencs/model/world/tablemimedata.hpp | 2 +- apps/opencs/view/world/table.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 193c621221..7509bd905d 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include "universalid.hpp" diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index ec08e4e2b4..db45a96328 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include "../../model/filter/node.hpp" From 3147aebf7501cc1fc7c64d3b93832261c2eed47c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 10 Feb 2014 13:01:52 +0100 Subject: [PATCH 036/171] factored out declaration parser --- components/CMakeLists.txt | 2 +- components/compiler/declarationparser.cpp | 79 +++++++++++++++++++++++ components/compiler/declarationparser.hpp | 41 ++++++++++++ components/compiler/lineparser.cpp | 64 +++++++----------- components/compiler/lineparser.hpp | 1 - 5 files changed, 144 insertions(+), 43 deletions(-) create mode 100644 components/compiler/declarationparser.cpp create mode 100644 components/compiler/declarationparser.hpp diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index f2b16d4d53..4f6639e9bc 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -55,7 +55,7 @@ add_component_dir (files add_component_dir (compiler context controlparser errorhandler exception exprparser extensions fileparser generator lineparser literals locals output parser scanner scriptparser skipparser streamerrorhandler - stringparser tokenloc nullerrorhandler opcodes extensions0 + stringparser tokenloc nullerrorhandler opcodes extensions0 declarationparser ) add_component_dir (interpreter diff --git a/components/compiler/declarationparser.cpp b/components/compiler/declarationparser.cpp new file mode 100644 index 0000000000..586b28bc29 --- /dev/null +++ b/components/compiler/declarationparser.cpp @@ -0,0 +1,79 @@ + +#include "declarationparser.hpp" + +#include + +#include "scanner.hpp" +#include "errorhandler.hpp" +#include "skipparser.hpp" +#include "locals.hpp" + +Compiler::DeclarationParser::DeclarationParser (ErrorHandler& errorHandler, Context& context, + Locals& locals) +: Parser (errorHandler, context), mLocals (locals), mState (State_Begin), mType (0) +{} + +bool Compiler::DeclarationParser::parseName (const std::string& name, const TokenLoc& loc, + Scanner& scanner) +{ + if (mState==State_Name) + { + std::string name2 = Misc::StringUtils::lowerCase (name); + + char type = mLocals.getType (name2); + + if (type!=' ') + { + /// \todo add option to make re-declared local variables an error + getErrorHandler().warning ("can't re-declare local variable (ignoring declaration)", + loc); + SkipParser skip (getErrorHandler(), getContext()); + scanner.scan (skip); + mState = State_End; + return true; + } + + mLocals.declare (mType, name2); + + mState = State_End; + return true; + } + + return Parser::parseName (name, loc, scanner); +} + +bool Compiler::DeclarationParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) +{ + if (mState==State_Begin) + { + switch (keyword) + { + case Scanner::K_short: mType = 's'; break; + case Scanner::K_long: mType = 'l'; break; + case Scanner::K_float: mType = 'f'; break; + default: mType = 0; + } + + if (mType) + { + mState = State_Name; + return true; + } + } + else if (mState==State_Name) + { + // allow keywords to be used as local variable names. MW script compiler, you suck! + /// \todo option to disable this atrocity. + return parseName (loc.mLiteral, loc, scanner); + } + + return Parser::parseKeyword (keyword, loc, scanner); +} + +bool Compiler::DeclarationParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner) +{ + if (code==Scanner::S_newline && mState==State_End) + return false; + + return Parser::parseSpecial (code, loc, scanner); +} \ No newline at end of file diff --git a/components/compiler/declarationparser.hpp b/components/compiler/declarationparser.hpp new file mode 100644 index 0000000000..3e0ac57c34 --- /dev/null +++ b/components/compiler/declarationparser.hpp @@ -0,0 +1,41 @@ +#ifndef COMPILER_DECLARATIONPARSER_H_INCLUDED +#define COMPILER_DECLARATIONPARSER_H_INCLUDED + +#include "parser.hpp" + +namespace Compiler +{ + class Locals; + + class DeclarationParser : public Parser + { + enum State + { + State_Begin, State_Name, State_End + }; + + Locals& mLocals; + State mState; + char mType; + + public: + + DeclarationParser (ErrorHandler& errorHandler, Context& context, Locals& locals); + + virtual bool parseName (const std::string& name, const TokenLoc& loc, + Scanner& scanner); + ///< Handle a name token. + /// \return fetch another token? + + virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner); + ///< Handle a keyword token. + /// \return fetch another token? + + virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner); + ///< Handle a special character token. + /// \return fetch another token? + + }; +} + +#endif diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 2904df6e1b..368152fd93 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -1,6 +1,8 @@ #include "lineparser.hpp" +#include + #include "scanner.hpp" #include "context.hpp" #include "errorhandler.hpp" @@ -8,7 +10,7 @@ #include "locals.hpp" #include "generator.hpp" #include "extensions.hpp" -#include +#include "declarationparser.hpp" namespace Compiler { @@ -82,37 +84,6 @@ namespace Compiler bool LineParser::parseName (const std::string& name, const TokenLoc& loc, Scanner& scanner) { - if (mState==ShortState || mState==LongState || mState==FloatState) - { - if (!getContext().canDeclareLocals()) - { - getErrorHandler().error ("local variables can't be declared in this context", loc); - SkipParser skip (getErrorHandler(), getContext()); - scanner.scan (skip); - return false; - } - - std::string name2 = Misc::StringUtils::lowerCase (name); - - char type = mLocals.getType (name2); - - if (type!=' ') - { - /// \todo add option to make re-declared local variables an error - getErrorHandler().warning ("can't re-declare local variable", loc); - SkipParser skip (getErrorHandler(), getContext()); - scanner.scan (skip); - mState = EndState; - return true; - } - - mLocals.declare (mState==ShortState ? 's' : (mState==LongState ? 'l' : 'f'), - name2); - - mState = EndState; - return true; - } - if (mState==SetState) { std::string name2 = Misc::StringUtils::lowerCase (name); @@ -303,9 +274,26 @@ namespace Compiler { switch (keyword) { - case Scanner::K_short: mState = ShortState; return true; - case Scanner::K_long: mState = LongState; return true; - case Scanner::K_float: mState = FloatState; return true; + case Scanner::K_short: + case Scanner::K_long: + case Scanner::K_float: + { + if (!getContext().canDeclareLocals()) + { + getErrorHandler().error ( + "local variables can't be declared in this context", loc); + SkipParser skip (getErrorHandler(), getContext()); + scanner.scan (skip); + return true; + } + + DeclarationParser declaration (getErrorHandler(), getContext(), mLocals); + if (declaration.parseKeyword (keyword, loc, scanner)) + scanner.scan (declaration); + + return true; + } + case Scanner::K_set: mState = SetState; return true; case Scanner::K_messagebox: mState = MessageState; return true; @@ -370,12 +358,6 @@ namespace Compiler mState = EndState; return true; } - else if (mState==ShortState || mState==LongState || mState==FloatState) - { - // allow keywords to be used as local variable names. MW script compiler, you suck! - /// \todo option to disable this atrocity. - return parseName (loc.mLiteral, loc, scanner); - } if (mAllowExpression) { diff --git a/components/compiler/lineparser.hpp b/components/compiler/lineparser.hpp index aa74cd232f..cf72f26a83 100644 --- a/components/compiler/lineparser.hpp +++ b/components/compiler/lineparser.hpp @@ -20,7 +20,6 @@ namespace Compiler enum State { BeginState, - ShortState, LongState, FloatState, SetState, SetLocalVarState, SetGlobalVarState, SetPotentialMemberVarState, SetMemberVarState, SetMemberVarState2, MessageState, MessageCommaState, MessageButtonState, MessageButtonCommaState, From 3b990795c4da85fcbf7373b47ff4914aa17b5635 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 10 Feb 2014 14:45:55 +0100 Subject: [PATCH 037/171] added access to remote access of local variables of global scripts --- apps/opencs/model/world/scriptcontext.cpp | 5 +- apps/opencs/model/world/scriptcontext.hpp | 8 +- apps/openmw/mwscript/compilercontext.cpp | 27 ++++- apps/openmw/mwscript/compilercontext.hpp | 8 +- apps/openmw/mwscript/globalscripts.cpp | 21 ++++ apps/openmw/mwscript/globalscripts.hpp | 4 + apps/openmw/mwscript/interpretercontext.cpp | 123 +++++++++++++------- apps/openmw/mwscript/interpretercontext.hpp | 44 ++++--- components/compiler/context.hpp | 8 +- components/compiler/exprparser.cpp | 9 +- components/compiler/generator.cpp | 41 +++---- components/compiler/generator.hpp | 6 +- components/compiler/lineparser.cpp | 10 +- components/compiler/lineparser.hpp | 1 + components/interpreter/context.hpp | 36 +++--- components/interpreter/docs/vmformat.txt | 8 +- components/interpreter/installopcodes.cpp | 18 ++- components/interpreter/localopcodes.hpp | 36 +++++- 18 files changed, 277 insertions(+), 136 deletions(-) diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index 8190c68eb7..1b30281595 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -19,9 +19,10 @@ char CSMWorld::ScriptContext::getGlobalType (const std::string& name) const return ' '; } -char CSMWorld::ScriptContext::getMemberType (const std::string& name, const std::string& id) const +std::pair CSMWorld::ScriptContext::getMemberType (const std::string& name, + const std::string& id) const { - return ' '; + return std::make_pair (' ', false); } bool CSMWorld::ScriptContext::isId (const std::string& name) const diff --git a/apps/opencs/model/world/scriptcontext.hpp b/apps/opencs/model/world/scriptcontext.hpp index 961da9143b..3baca99b24 100644 --- a/apps/opencs/model/world/scriptcontext.hpp +++ b/apps/opencs/model/world/scriptcontext.hpp @@ -26,8 +26,12 @@ namespace CSMWorld virtual char getGlobalType (const std::string& name) const; ///< 'l: long, 's': short, 'f': float, ' ': does not exist. - virtual char getMemberType (const std::string& name, const std::string& id) const; - ///< 'l: long, 's': short, 'f': float, ' ': does not exist. + virtual std::pair getMemberType (const std::string& name, + const std::string& id) const; + ///< Return type of member variable \a name in script \a id or in script of reference of + /// \a id + /// \return first: 'l: long, 's': short, 'f': float, ' ': does not exist. + /// second: true: script of reference virtual bool isId (const std::string& name) const; ///< Does \a name match an ID, that can be referenced? diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index b094e54147..8018b86e02 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -30,16 +30,31 @@ namespace MWScript return MWBase::Environment::get().getWorld()->getGlobalVariableType (name); } - char CompilerContext::getMemberType (const std::string& name, const std::string& id) const + std::pair CompilerContext::getMemberType (const std::string& name, + const std::string& id) const { - MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtr (id, false); + std::string script; + bool reference = false; - std::string script = MWWorld::Class::get (ptr).getScript (ptr); + if (const ESM::Script *scriptRecord = + MWBase::Environment::get().getWorld()->getStore().get().search (id)) + { + script = scriptRecord->mId; + } + else + { + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtr (id, false); - if (script.empty()) - return ' '; + script = MWWorld::Class::get (ptr).getScript (ptr); + reference = true; + } - return MWBase::Environment::get().getScriptManager()->getLocals (script).getType (name); + char type = ' '; + + if (!script.empty()) + type = MWBase::Environment::get().getScriptManager()->getLocals (script).getType (name); + + return std::make_pair (type, reference); } bool CompilerContext::isId (const std::string& name) const diff --git a/apps/openmw/mwscript/compilercontext.hpp b/apps/openmw/mwscript/compilercontext.hpp index 50256f9422..95719ab692 100644 --- a/apps/openmw/mwscript/compilercontext.hpp +++ b/apps/openmw/mwscript/compilercontext.hpp @@ -30,8 +30,12 @@ namespace MWScript /// 'l: long, 's': short, 'f': float, ' ': does not exist. virtual char getGlobalType (const std::string& name) const; - virtual char getMemberType (const std::string& name, const std::string& id) const; - ///< 'l: long, 's': short, 'f': float, ' ': does not exist. + virtual std::pair getMemberType (const std::string& name, + const std::string& id) const; + ///< Return type of member variable \a name in script \a id or in script of reference of + /// \a id + /// \return first: 'l: long, 's': short, 'f': float, ' ': does not exist. + /// second: true: script of reference virtual bool isId (const std::string& name) const; ///< Does \a name match an ID, that can be referenced? diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 8f269a0153..179e2bb0bb 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -148,4 +148,25 @@ namespace MWScript return false; } + + Locals& GlobalScripts::getLocals (const std::string& name) + { + std::string name2 = Misc::StringUtils::lowerCase (name); + std::map >::iterator iter = + mScripts.find (name2); + + if (iter==mScripts.end()) + { + if (const ESM::Script *script = mStore.get().find (name)) + { + Locals locals; + + locals.configure (*script); + + iter = mScripts.insert (std::make_pair (name, std::make_pair (false, locals))).first; + } + } + + return iter->second.second; + } } diff --git a/apps/openmw/mwscript/globalscripts.hpp b/apps/openmw/mwscript/globalscripts.hpp index cf716c8e42..a4a7662263 100644 --- a/apps/openmw/mwscript/globalscripts.hpp +++ b/apps/openmw/mwscript/globalscripts.hpp @@ -52,6 +52,10 @@ namespace MWScript ///< Records for variables that do not exist are dropped silently. /// /// \return Known type? + + Locals& getLocals (const std::string& name); + ///< If the script \a name has not been added as a global script yet, it is added + /// automatically, but is not set to running state. }; } diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 10e98e3988..17092b41ca 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -54,6 +54,47 @@ namespace MWScript } } + const Locals& InterpreterContext::getMemberLocals (std::string& id, bool global) + const + { + if (global) + { + return MWBase::Environment::get().getScriptManager()->getGlobalScripts(). + getLocals (id); + } + else + { + const MWWorld::Ptr ptr = getReference (id, false); + + std::string id = MWWorld::Class::get (ptr).getScript (ptr); + + ptr.getRefData().setLocals ( + *MWBase::Environment::get().getWorld()->getStore().get().find (id)); + + return ptr.getRefData().getLocals(); + } + } + + Locals& InterpreterContext::getMemberLocals (std::string& id, bool global) + { + if (global) + { + return MWBase::Environment::get().getScriptManager()->getGlobalScripts(). + getLocals (id); + } + else + { + const MWWorld::Ptr ptr = getReference (id, false); + + std::string id = MWWorld::Class::get (ptr).getScript (ptr); + + ptr.getRefData().setLocals ( + *MWBase::Environment::get().getWorld()->getStore().get().find (id)); + + return ptr.getRefData().getLocals(); + } + } + InterpreterContext::InterpreterContext ( MWScript::Locals *locals, MWWorld::Ptr reference) : mLocals (locals), mReference (reference), @@ -407,82 +448,80 @@ namespace MWScript MWBase::Environment::get().getWorld()->disable (ref); } - int InterpreterContext::getMemberShort (const std::string& id, const std::string& name) const + int InterpreterContext::getMemberShort (const std::string& id, const std::string& name, + bool global) const { - const MWWorld::Ptr ptr = getReference (id, false); + std::string scriptId (id); - std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + const Locals& locals = getMemberLocals (scriptId, global); - int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex ( + scriptId, name, 's'); - ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().get().find (scriptId)); - return ptr.getRefData().getLocals().mShorts[index]; + return locals.mShorts[index]; } - int InterpreterContext::getMemberLong (const std::string& id, const std::string& name) const + int InterpreterContext::getMemberLong (const std::string& id, const std::string& name, + bool global) const { - const MWWorld::Ptr ptr = getReference (id, false); + std::string scriptId (id); - std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + const Locals& locals = getMemberLocals (scriptId, global); - int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex ( + scriptId, name, 'l'); - ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().get().find (scriptId)); - return ptr.getRefData().getLocals().mLongs[index]; + return locals.mLongs[index]; } - float InterpreterContext::getMemberFloat (const std::string& id, const std::string& name) const + float InterpreterContext::getMemberFloat (const std::string& id, const std::string& name, + bool global) const { - const MWWorld::Ptr ptr = getReference (id, false); + std::string scriptId (id); - std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + const Locals& locals = getMemberLocals (scriptId, global); - int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex ( + scriptId, name, 'f'); - ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().get().find (scriptId)); - return ptr.getRefData().getLocals().mFloats[index]; + return locals.mFloats[index]; } - void InterpreterContext::setMemberShort (const std::string& id, const std::string& name, int value) + void InterpreterContext::setMemberShort (const std::string& id, const std::string& name, + int value, bool global) { - const MWWorld::Ptr ptr = getReference (id, false); + std::string scriptId (id); - std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + Locals& locals = getMemberLocals (scriptId, global); - int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); + int index = + MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); - ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().get().find (scriptId)); - ptr.getRefData().getLocals().mShorts[index] = value; + locals.mShorts[index] = value; } - void InterpreterContext::setMemberLong (const std::string& id, const std::string& name, int value) + void InterpreterContext::setMemberLong (const std::string& id, const std::string& name, int value, bool global) { - const MWWorld::Ptr ptr = getReference (id, false); + std::string scriptId (id); - std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + Locals& locals = getMemberLocals (scriptId, global); - int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); + int index = + MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); - ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().get().find (scriptId)); - ptr.getRefData().getLocals().mLongs[index] = value; + locals.mLongs[index] = value; } - void InterpreterContext::setMemberFloat (const std::string& id, const std::string& name, float value) + void InterpreterContext::setMemberFloat (const std::string& id, const std::string& name, float value, bool global) { - const MWWorld::Ptr ptr = getReference (id, false); + std::string scriptId (id); - std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + Locals& locals = getMemberLocals (scriptId, global); - int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); + int index = + MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); - ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().get().find (scriptId)); - ptr.getRefData().getLocals().mFloats[index] = value; + locals.mFloats[index] = value; } MWWorld::Ptr InterpreterContext::getReference(bool required) diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index 04546faed7..9fb7fa2bf8 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -37,6 +37,12 @@ namespace MWScript const MWWorld::Ptr getReference (const std::string& id, bool activeOnly, bool doThrow=true) const; + const Locals& getMemberLocals (std::string& id, bool global) const; + ///< \a id is changed to the respective script ID, if \a id wasn't a script ID before + + Locals& getMemberLocals (std::string& id, bool global); + ///< \a id is changed to the respective script ID, if \a id wasn't a script ID before + public: InterpreterContext (MWScript::Locals *locals, MWWorld::Ptr reference); @@ -75,35 +81,35 @@ namespace MWScript virtual void setGlobalLong (const std::string& name, int value); virtual void setGlobalFloat (const std::string& name, float value); - + virtual std::vector getGlobals () const; virtual char getGlobalType (const std::string& name) const; - + virtual std::string getActionBinding(const std::string& action) const; - + virtual std::string getNPCName() const; - + virtual std::string getNPCRace() const; - + virtual std::string getNPCClass() const; - + virtual std::string getNPCFaction() const; virtual std::string getNPCRank() const; - + virtual std::string getPCName() const; - + virtual std::string getPCRace() const; - + virtual std::string getPCClass() const; - + virtual std::string getPCRank() const; - + virtual std::string getPCNextRank() const; - + virtual int getPCBounty() const; - + virtual std::string getCurrentCellName() const; virtual bool isScriptRunning (const std::string& name) const; @@ -138,17 +144,17 @@ namespace MWScript virtual void disable (const std::string& id = ""); - virtual int getMemberShort (const std::string& id, const std::string& name) const; + virtual int getMemberShort (const std::string& id, const std::string& name, bool global) const; - virtual int getMemberLong (const std::string& id, const std::string& name) const; + virtual int getMemberLong (const std::string& id, const std::string& name, bool global) const; - virtual float getMemberFloat (const std::string& id, const std::string& name) const; + virtual float getMemberFloat (const std::string& id, const std::string& name, bool global) const; - virtual void setMemberShort (const std::string& id, const std::string& name, int value); + virtual void setMemberShort (const std::string& id, const std::string& name, int value, bool global); - virtual void setMemberLong (const std::string& id, const std::string& name, int value); + virtual void setMemberLong (const std::string& id, const std::string& name, int value, bool global); - virtual void setMemberFloat (const std::string& id, const std::string& name, float value); + virtual void setMemberFloat (const std::string& id, const std::string& name, float value, bool global); MWWorld::Ptr getReference(bool required=true); ///< Reference, that the script is running from (can be empty) diff --git a/components/compiler/context.hpp b/components/compiler/context.hpp index 69146e285f..84bb89bdc4 100644 --- a/components/compiler/context.hpp +++ b/components/compiler/context.hpp @@ -33,8 +33,12 @@ namespace Compiler virtual char getGlobalType (const std::string& name) const = 0; ///< 'l: long, 's': short, 'f': float, ' ': does not exist. - virtual char getMemberType (const std::string& name, const std::string& id) const = 0; - ///< 'l: long, 's': short, 'f': float, ' ': does not exist. + virtual std::pair getMemberType (const std::string& name, + const std::string& id) const = 0; + ///< Return type of member variable \a name in script \a id or in script of reference of + /// \a id + /// \return first: 'l: long, 's': short, 'f': float, ' ': does not exist. + /// second: true: script of reference virtual bool isId (const std::string& name) const = 0; ///< Does \a name match an ID, that can be referenced? diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 42c88b75ab..283da854c9 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -204,14 +204,15 @@ namespace Compiler std::string name2 = Misc::StringUtils::lowerCase (name); std::string id = Misc::StringUtils::lowerCase (mExplicit); - char type = getContext().getMemberType (name2, id); + std::pair type = getContext().getMemberType (name2, id); - if (type!=' ') + if (type.first!=' ') { - Generator::fetchMember (mCode, mLiterals, type, name2, id); + Generator::fetchMember (mCode, mLiterals, type.first, name2, id, !type.second); + mNextOperand = false; mExplicit.clear(); - mOperands.push_back (type=='f' ? 'f' : 'l'); + mOperands.push_back (type.first=='f' ? 'f' : 'l'); return true; } diff --git a/components/compiler/generator.cpp b/components/compiler/generator.cpp index 9b02e4273f..83e46d5f7b 100644 --- a/components/compiler/generator.cpp +++ b/components/compiler/generator.cpp @@ -260,34 +260,34 @@ namespace code.push_back (Compiler::Generator::segment5 (44)); } - void opStoreMemberShort (Compiler::Generator::CodeContainer& code) + void opStoreMemberShort (Compiler::Generator::CodeContainer& code, bool global) { - code.push_back (Compiler::Generator::segment5 (59)); + code.push_back (Compiler::Generator::segment5 (global ? 65 : 59)); } - void opStoreMemberLong (Compiler::Generator::CodeContainer& code) + void opStoreMemberLong (Compiler::Generator::CodeContainer& code, bool global) { - code.push_back (Compiler::Generator::segment5 (60)); + code.push_back (Compiler::Generator::segment5 (global ? 66 : 60)); } - void opStoreMemberFloat (Compiler::Generator::CodeContainer& code) + void opStoreMemberFloat (Compiler::Generator::CodeContainer& code, bool global) { - code.push_back (Compiler::Generator::segment5 (61)); + code.push_back (Compiler::Generator::segment5 (global ? 67 : 61)); } - void opFetchMemberShort (Compiler::Generator::CodeContainer& code) + void opFetchMemberShort (Compiler::Generator::CodeContainer& code, bool global) { - code.push_back (Compiler::Generator::segment5 (62)); + code.push_back (Compiler::Generator::segment5 (global ? 68 : 62)); } - void opFetchMemberLong (Compiler::Generator::CodeContainer& code) + void opFetchMemberLong (Compiler::Generator::CodeContainer& code, bool global) { - code.push_back (Compiler::Generator::segment5 (63)); + code.push_back (Compiler::Generator::segment5 (global ? 69 : 63)); } - void opFetchMemberFloat (Compiler::Generator::CodeContainer& code) + void opFetchMemberFloat (Compiler::Generator::CodeContainer& code, bool global) { - code.push_back (Compiler::Generator::segment5 (64)); + code.push_back (Compiler::Generator::segment5 (global ? 70 : 64)); } void opRandom (Compiler::Generator::CodeContainer& code) @@ -738,7 +738,8 @@ namespace Compiler } void assignToMember (CodeContainer& code, Literals& literals, char localType, - const std::string& name, const std::string& id, const CodeContainer& value, char valueType) + const std::string& name, const std::string& id, const CodeContainer& value, + char valueType, bool global) { int index = literals.addString (name); @@ -766,17 +767,17 @@ namespace Compiler { case 'f': - opStoreMemberFloat (code); + opStoreMemberFloat (code, global); break; case 's': - opStoreMemberShort (code); + opStoreMemberShort (code, global); break; case 'l': - opStoreMemberLong (code); + opStoreMemberLong (code, global); break; default: @@ -786,7 +787,7 @@ namespace Compiler } void fetchMember (CodeContainer& code, Literals& literals, char localType, - const std::string& name, const std::string& id) + const std::string& name, const std::string& id, bool global) { int index = literals.addString (name); @@ -800,17 +801,17 @@ namespace Compiler { case 'f': - opFetchMemberFloat (code); + opFetchMemberFloat (code, global); break; case 's': - opFetchMemberShort (code); + opFetchMemberShort (code, global); break; case 'l': - opFetchMemberLong (code); + opFetchMemberLong (code, global); break; default: diff --git a/components/compiler/generator.hpp b/components/compiler/generator.hpp index feab26c93d..b511161225 100644 --- a/components/compiler/generator.hpp +++ b/components/compiler/generator.hpp @@ -102,10 +102,12 @@ namespace Compiler const std::string& name); void assignToMember (CodeContainer& code, Literals& literals, char memberType, - const std::string& name, const std::string& id, const CodeContainer& value, char valueType); + const std::string& name, const std::string& id, const CodeContainer& value, char valueType, bool global); + ///< \param global Member of a global script instead of a script of a reference. void fetchMember (CodeContainer& code, Literals& literals, char memberType, - const std::string& name, const std::string& id); + const std::string& name, const std::string& id, bool global); + ///< \param global Member of a global script instead of a script of a reference. void random (CodeContainer& code); diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 368152fd93..5987a48031 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -113,12 +113,13 @@ namespace Compiler if (mState==SetMemberVarState) { mMemberName = name; - char type = getContext().getMemberType (mMemberName, mName); + std::pair type = getContext().getMemberType (mMemberName, mName); - if (type!=' ') + if (type.first!=' ') { mState = SetMemberVarState2; - mType = type; + mType = type.first; + mReferenceMember = type.second; return true; } @@ -353,7 +354,8 @@ namespace Compiler std::vector code; char type = mExprParser.append (code); - Generator::assignToMember (mCode, mLiterals, mType, mMemberName, mName, code, type); + Generator::assignToMember (mCode, mLiterals, mType, mMemberName, mName, code, type, + !mReferenceMember); mState = EndState; return true; diff --git a/components/compiler/lineparser.hpp b/components/compiler/lineparser.hpp index cf72f26a83..0aba30d4b5 100644 --- a/components/compiler/lineparser.hpp +++ b/components/compiler/lineparser.hpp @@ -33,6 +33,7 @@ namespace Compiler State mState; std::string mName; std::string mMemberName; + bool mReferenceMember; int mButtons; std::string mExplicit; char mType; diff --git a/components/interpreter/context.hpp b/components/interpreter/context.hpp index bdba7b6af9..97e4fad4fc 100644 --- a/components/interpreter/context.hpp +++ b/components/interpreter/context.hpp @@ -50,33 +50,33 @@ namespace Interpreter virtual void setGlobalFloat (const std::string& name, float value) = 0; virtual std::vector getGlobals () const = 0; - + virtual char getGlobalType (const std::string& name) const = 0; virtual std::string getActionBinding(const std::string& action) const = 0; - + virtual std::string getNPCName() const = 0; - + virtual std::string getNPCRace() const = 0; - + virtual std::string getNPCClass() const = 0; - + virtual std::string getNPCFaction() const = 0; - + virtual std::string getNPCRank() const = 0; virtual std::string getPCName() const = 0; - + virtual std::string getPCRace() const = 0; - + virtual std::string getPCClass() const = 0; - + virtual std::string getPCRank() const = 0; - + virtual std::string getPCNextRank() const = 0; - + virtual int getPCBounty() const = 0; - + virtual std::string getCurrentCellName() const = 0; virtual bool isScriptRunning (const std::string& name) const = 0; @@ -96,17 +96,17 @@ namespace Interpreter virtual void disable (const std::string& id = "") = 0; - virtual int getMemberShort (const std::string& id, const std::string& name) const = 0; + virtual int getMemberShort (const std::string& id, const std::string& name, bool global) const = 0; - virtual int getMemberLong (const std::string& id, const std::string& name) const = 0; + virtual int getMemberLong (const std::string& id, const std::string& name, bool global) const = 0; - virtual float getMemberFloat (const std::string& id, const std::string& name) const = 0; + virtual float getMemberFloat (const std::string& id, const std::string& name, bool global) const = 0; - virtual void setMemberShort (const std::string& id, const std::string& name, int value) = 0; + virtual void setMemberShort (const std::string& id, const std::string& name, int value, bool global) = 0; - virtual void setMemberLong (const std::string& id, const std::string& name, int value) = 0; + virtual void setMemberLong (const std::string& id, const std::string& name, int value, bool global) = 0; - virtual void setMemberFloat (const std::string& id, const std::string& name, float value) + virtual void setMemberFloat (const std::string& id, const std::string& name, float value, bool global) = 0; }; } diff --git a/components/interpreter/docs/vmformat.txt b/components/interpreter/docs/vmformat.txt index 91e0c060e7..990762268f 100644 --- a/components/interpreter/docs/vmformat.txt +++ b/components/interpreter/docs/vmformat.txt @@ -127,5 +127,11 @@ op 61: store stack[0] in member float stack[2] of object with ID stack[1] op 62: replace stack[0] with member short stack[1] of object with ID stack[0] op 63: replace stack[0] with member short stack[1] of object with ID stack[0] op 64: replace stack[0] with member short stack[1] of object with ID stack[0] -opcodes 65-33554431 unused +op 65: store stack[0] in member short stack[2] of global script with ID stack[1] +op 66: store stack[0] in member long stack[2] of global script with ID stack[1] +op 67: store stack[0] in member float stack[2] of global script with ID stack[1] +op 68: replace stack[0] with member short stack[1] of global script with ID stack[0] +op 69: replace stack[0] with member short stack[1] of global script with ID stack[0] +op 70: replace stack[0] with member short stack[1] of global script with ID stack[0] +opcodes 71-33554431 unused opcodes 33554432-67108863 reserved for extensions diff --git a/components/interpreter/installopcodes.cpp b/components/interpreter/installopcodes.cpp index 05f71f1cca..721cde3d8d 100644 --- a/components/interpreter/installopcodes.cpp +++ b/components/interpreter/installopcodes.cpp @@ -40,12 +40,18 @@ namespace Interpreter interpreter.installSegment5 (42, new OpFetchGlobalShort); interpreter.installSegment5 (43, new OpFetchGlobalLong); interpreter.installSegment5 (44, new OpFetchGlobalFloat); - interpreter.installSegment5 (59, new OpStoreMemberShort); - interpreter.installSegment5 (60, new OpStoreMemberLong); - interpreter.installSegment5 (61, new OpStoreMemberFloat); - interpreter.installSegment5 (62, new OpFetchMemberShort); - interpreter.installSegment5 (63, new OpFetchMemberLong); - interpreter.installSegment5 (64, new OpFetchMemberFloat); + interpreter.installSegment5 (59, new OpStoreMemberShort (false)); + interpreter.installSegment5 (60, new OpStoreMemberLong (false)); + interpreter.installSegment5 (61, new OpStoreMemberFloat (false)); + interpreter.installSegment5 (62, new OpFetchMemberShort (false)); + interpreter.installSegment5 (63, new OpFetchMemberLong (false)); + interpreter.installSegment5 (64, new OpFetchMemberFloat (false)); + interpreter.installSegment5 (65, new OpStoreMemberShort (true)); + interpreter.installSegment5 (66, new OpStoreMemberLong (true)); + interpreter.installSegment5 (67, new OpStoreMemberFloat (true)); + interpreter.installSegment5 (68, new OpFetchMemberShort (true)); + interpreter.installSegment5 (69, new OpFetchMemberLong (true)); + interpreter.installSegment5 (70, new OpFetchMemberFloat (true)); // math interpreter.installSegment5 (9, new OpAddInt); diff --git a/components/interpreter/localopcodes.hpp b/components/interpreter/localopcodes.hpp index 731c16276d..7844a9ea73 100644 --- a/components/interpreter/localopcodes.hpp +++ b/components/interpreter/localopcodes.hpp @@ -208,8 +208,12 @@ namespace Interpreter class OpStoreMemberShort : public Opcode0 { + bool mGlobal; + public: + OpStoreMemberShort (bool global) : mGlobal (global) {} + virtual void execute (Runtime& runtime) { Type_Integer data = runtime[0].mInteger; @@ -218,7 +222,7 @@ namespace Interpreter index = runtime[2].mInteger; std::string variable = runtime.getStringLiteral (index); - runtime.getContext().setMemberShort (id, variable, data); + runtime.getContext().setMemberShort (id, variable, data, mGlobal); runtime.pop(); runtime.pop(); @@ -228,8 +232,12 @@ namespace Interpreter class OpStoreMemberLong : public Opcode0 { + bool mGlobal; + public: + OpStoreMemberLong (bool global) : mGlobal (global) {} + virtual void execute (Runtime& runtime) { Type_Integer data = runtime[0].mInteger; @@ -238,7 +246,7 @@ namespace Interpreter index = runtime[2].mInteger; std::string variable = runtime.getStringLiteral (index); - runtime.getContext().setMemberLong (id, variable, data); + runtime.getContext().setMemberLong (id, variable, data, mGlobal); runtime.pop(); runtime.pop(); @@ -248,8 +256,12 @@ namespace Interpreter class OpStoreMemberFloat : public Opcode0 { + bool mGlobal; + public: + OpStoreMemberFloat (bool global) : mGlobal (global) {} + virtual void execute (Runtime& runtime) { Type_Float data = runtime[0].mFloat; @@ -258,7 +270,7 @@ namespace Interpreter index = runtime[2].mInteger; std::string variable = runtime.getStringLiteral (index); - runtime.getContext().setMemberFloat (id, variable, data); + runtime.getContext().setMemberFloat (id, variable, data, mGlobal); runtime.pop(); runtime.pop(); @@ -268,8 +280,12 @@ namespace Interpreter class OpFetchMemberShort : public Opcode0 { + bool mGlobal; + public: + OpFetchMemberShort (bool global) : mGlobal (global) {} + virtual void execute (Runtime& runtime) { Type_Integer index = runtime[0].mInteger; @@ -278,15 +294,19 @@ namespace Interpreter std::string variable = runtime.getStringLiteral (index); runtime.pop(); - int value = runtime.getContext().getMemberShort (id, variable); + int value = runtime.getContext().getMemberShort (id, variable, mGlobal); runtime[0].mInteger = value; } }; class OpFetchMemberLong : public Opcode0 { + bool mGlobal; + public: + OpFetchMemberLong (bool global) : mGlobal (global) {} + virtual void execute (Runtime& runtime) { Type_Integer index = runtime[0].mInteger; @@ -295,15 +315,19 @@ namespace Interpreter std::string variable = runtime.getStringLiteral (index); runtime.pop(); - int value = runtime.getContext().getMemberLong (id, variable); + int value = runtime.getContext().getMemberLong (id, variable, mGlobal); runtime[0].mInteger = value; } }; class OpFetchMemberFloat : public Opcode0 { + bool mGlobal; + public: + OpFetchMemberFloat (bool global) : mGlobal (global) {} + virtual void execute (Runtime& runtime) { Type_Integer index = runtime[0].mInteger; @@ -312,7 +336,7 @@ namespace Interpreter std::string variable = runtime.getStringLiteral (index); runtime.pop(); - float value = runtime.getContext().getMemberFloat (id, variable); + float value = runtime.getContext().getMemberFloat (id, variable, mGlobal); runtime[0].mFloat = value; } }; From 5c0071f3205b1e796bcb27a83e451d043a24bd6e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 10 Feb 2014 14:59:20 +0100 Subject: [PATCH 038/171] fixed spelling of an error message --- components/compiler/generator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/compiler/generator.cpp b/components/compiler/generator.cpp index 83e46d5f7b..c67e51e572 100644 --- a/components/compiler/generator.cpp +++ b/components/compiler/generator.cpp @@ -593,7 +593,7 @@ namespace Compiler else if (offset<0) opJumpBackward (code, -offset); else - throw std::logic_error ("inifite loop"); + throw std::logic_error ("infinite loop"); } void jumpOnZero (CodeContainer& code, int offset) From df46218acc9132e034e54af788b1f2c2b83f4084 Mon Sep 17 00:00:00 2001 From: gus Date: Mon, 10 Feb 2014 16:48:04 +0100 Subject: [PATCH 039/171] try droping --- apps/opencs/view/world/table.cpp | 32 +++++++++++++++++++++++++------- apps/opencs/view/world/table.hpp | 4 ++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index ff0eabf27e..1a9499f52b 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -85,7 +85,7 @@ std::vector CSVWorld::Table::listRevertableSelectedIds() const QModelIndexList selectedRows = selectionModel()->selectedRows(); for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end(); - ++iter) + ++iter) { QModelIndex index = mProxyModel->mapToSource (mProxyModel->index (iter->row(), 0)); @@ -228,6 +228,8 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT (selectionSizeUpdate ())); + + setAcceptDrops(true); } void CSVWorld::Table::setEditLock (bool locked) @@ -384,10 +386,10 @@ void CSVWorld::Table::tableSizeUpdate() switch (state) { - case CSMWorld::RecordBase::State_BaseOnly: ++size; break; - case CSMWorld::RecordBase::State_Modified: ++size; ++modified; break; - case CSMWorld::RecordBase::State_ModifiedOnly: ++size; ++modified; break; - case CSMWorld::RecordBase:: State_Deleted: ++deleted; ++modified; break; + case CSMWorld::RecordBase::State_BaseOnly: ++size; break; + case CSMWorld::RecordBase::State_Modified: ++size; ++modified; break; + case CSMWorld::RecordBase::State_ModifiedOnly: ++size; ++modified; break; + case CSMWorld::RecordBase:: State_Deleted: ++deleted; ++modified; break; } } } @@ -445,6 +447,22 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); - drag->start(); - } + drag->exec(); + std::cout << "startdrag"; + } + +} + +void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) +{ + //if (event->mimeData()->hasFormat("text/plain")) + std::cout << "accept drag event"; + event->acceptProposedAction(); + +} + +void CSVWorld::Table::dropEvent(QDropEvent *event) +{ + std::cout << "drop"; + event->acceptProposedAction(); } \ No newline at end of file diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index db45a96328..44d72f7fb3 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -52,6 +52,10 @@ namespace CSVWorld void mouseMoveEvent(QMouseEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + + void dropEvent(QDropEvent *event); + public: Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting); From 53e2e8415d9c6d0c61d87d09b93a18f575f255b5 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 11 Feb 2014 12:25:21 +0100 Subject: [PATCH 040/171] replaced start with exec --- apps/opencs/view/world/table.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index ff0eabf27e..d343440f13 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -435,7 +435,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) { std::vector idToDrag; - foreach (QModelIndex it, selectedRows) + foreach (QModelIndex it, selectedRows) //I had a dream. Dream where you could use C++11 in OpenMW. { idToDrag.push_back (getUniversalId (it.row())); } @@ -445,6 +445,6 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); - drag->start(); + drag->exec(); } } \ No newline at end of file From f26aa4f6455fe5e8b2fe110ba1a5df3a95a200db Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 11 Feb 2014 13:31:04 +0100 Subject: [PATCH 041/171] fixed while loop implementation --- components/compiler/controlparser.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/compiler/controlparser.cpp b/components/compiler/controlparser.cpp index 3be470c273..ba2db62b66 100644 --- a/components/compiler/controlparser.cpp +++ b/components/compiler/controlparser.cpp @@ -9,6 +9,7 @@ #include "generator.hpp" #include "errorhandler.hpp" +#include namespace Compiler { bool ControlParser::parseIfBody (int keyword, const TokenLoc& loc, Scanner& scanner) @@ -107,7 +108,7 @@ namespace Compiler Codes expr; mExprParser.append (expr); - Generator::jump (loop, -static_cast (mCodeBlock.size()-expr.size())); + Generator::jump (loop, -static_cast (mCodeBlock.size()+expr.size())); std::copy (expr.begin(), expr.end(), std::back_inserter (mCode)); @@ -121,7 +122,7 @@ namespace Compiler Codes loop2; - Generator::jump (loop2, -static_cast (mCodeBlock.size()-expr.size()-skip.size())); + Generator::jump (loop2, -static_cast (mCodeBlock.size()+expr.size()+skip.size())); if (loop.size()!=loop2.size()) throw std::logic_error ( From 9de2922d22c310ae41a6d80ae5374bc4e6296c2f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 11 Feb 2014 13:56:56 +0100 Subject: [PATCH 042/171] fixed case problem in remote member variable access --- apps/openmw/mwscript/scriptmanagerimp.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 6862b9f830..11e094a843 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -7,12 +7,15 @@ #include #include -#include "../mwworld/esmstore.hpp" + +#include #include #include #include +#include "../mwworld/esmstore.hpp" + #include "extensions.hpp" namespace MWScript @@ -140,15 +143,17 @@ namespace MWScript Compiler::Locals& ScriptManager::getLocals (const std::string& name) { + std::string name2 = Misc::StringUtils::lowerCase (name); + { - ScriptCollection::iterator iter = mScripts.find (name); + ScriptCollection::iterator iter = mScripts.find (name2); if (iter!=mScripts.end()) return iter->second.second; } { - std::map::iterator iter = mOtherLocals.find (name); + std::map::iterator iter = mOtherLocals.find (name2); if (iter!=mOtherLocals.end()) return iter->second; @@ -156,7 +161,7 @@ namespace MWScript Compiler::Locals locals; - if (const ESM::Script *script = mStore.get().find (name)) + if (const ESM::Script *script = mStore.get().find (name2)) { int index = 0; @@ -170,7 +175,7 @@ namespace MWScript locals.declare ('f', script->mVarNames[index++]); std::map::iterator iter = - mOtherLocals.insert (std::make_pair (name, locals)).first; + mOtherLocals.insert (std::make_pair (name2, locals)).first; return iter->second; } From 697bda63719add550ef35d3144592f278b1b86c6 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 11 Feb 2014 14:55:31 +0100 Subject: [PATCH 043/171] allow (and discard) explicit reference on instructions that do not accept explicit references --- components/compiler/extensions.cpp | 4 ++-- components/compiler/extensions.hpp | 4 +++- components/compiler/lineparser.cpp | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/compiler/extensions.cpp b/components/compiler/extensions.cpp index c6a74b234b..6f5c2fc897 100644 --- a/components/compiler/extensions.cpp +++ b/components/compiler/extensions.cpp @@ -38,7 +38,7 @@ namespace Compiler } bool Extensions::isInstruction (int keyword, std::string& argumentType, - bool explicitReference) const + bool& explicitReference) const { std::map::const_iterator iter = mInstructions.find (keyword); @@ -46,7 +46,7 @@ namespace Compiler return false; if (explicitReference && iter->second.mCodeExplicit==-1) - return false; + explicitReference = false; argumentType = iter->second.mArguments; return true; diff --git a/components/compiler/extensions.hpp b/components/compiler/extensions.hpp index 53ebfa31b5..585c42681c 100644 --- a/components/compiler/extensions.hpp +++ b/components/compiler/extensions.hpp @@ -52,8 +52,10 @@ namespace Compiler /// types. bool isInstruction (int keyword, std::string& argumentType, - bool explicitReference) const; + bool& explicitReference) const; ///< Is this keyword registered with a function? If yes, return argument types. + /// \param explicitReference In: has explicit reference; Out: set to false, if + /// explicit reference is not available for this instruction. void registerFunction (const std::string& keyword, char returnType, const std::string& argumentType, int code, int codeExplicit = -1); diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 5987a48031..3b27905d46 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -234,8 +234,15 @@ namespace Compiler { std::string argumentType; - if (extensions->isInstruction (keyword, argumentType, mState==ExplicitState)) + bool hasExplicit = mState==ExplicitState; + if (extensions->isInstruction (keyword, argumentType, hasExplicit)) { + if (!hasExplicit && mState==ExplicitState) + { + getErrorHandler().warning ("stray explicit reference (ignoring it)", loc); + mExplicit.clear(); + } + int optionals = mExprParser.parseArguments (argumentType, scanner, mCode, true); extensions->generateInstructionCode (keyword, mCode, mLiterals, mExplicit, optionals); @@ -271,6 +278,14 @@ namespace Compiler } } + if (mState==ExplicitState) + { + // drop stray explicit reference + getErrorHandler().warning ("stray explicit reference (ignoring it)", loc); + mState = BeginState; + mExplicit.clear(); + } + if (mState==BeginState) { switch (keyword) From 6a5d88b640c0ba26f8431e14e891411dcca505c2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 08:42:42 +0100 Subject: [PATCH 044/171] ignore stray else and endif in scripts --- components/compiler/lineparser.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 3b27905d46..4a5e1cbd09 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -332,6 +332,18 @@ namespace Compiler Generator::stopScript (mCode); mState = EndState; return true; + + case Scanner::K_else: + + getErrorHandler().warning ("stay else (ignoring it)", loc); + mState = EndState; + return true; + + case Scanner::K_endif: + + getErrorHandler().warning ("stay endif (ignoring it)", loc); + mState = EndState; + return true; } } else if (mState==SetLocalVarState && keyword==Scanner::K_to) From 61626e90da98641db5da0e33457977311ec30c6f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 08:53:37 +0100 Subject: [PATCH 045/171] allow additional string argument for stopcombat and addspell (ignored) --- components/compiler/exprparser.cpp | 25 ++++++++++++++----------- components/compiler/exprparser.hpp | 1 + components/compiler/extensions0.cpp | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 283da854c9..4af11ec2be 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -705,11 +705,11 @@ namespace Compiler { optional = true; } - else if (*iter=='S' || *iter=='c') + else if (*iter=='S' || *iter=='c' || *iter=='x') { stringParser.reset(); - if (optional) + if (optional || *iter=='x') stringParser.setOptional (true); if (*iter=='c') stringParser.smashCase(); @@ -718,18 +718,21 @@ namespace Compiler if (optional && stringParser.isEmpty()) break; - if (invert) + if (*iter!='x') { - std::vector tmp; - stringParser.append (tmp); + if (invert) + { + std::vector tmp; + stringParser.append (tmp); - stack.push (tmp); + stack.push (tmp); + } + else + stringParser.append (code); + + if (optional) + ++optionalCount; } - else - stringParser.append (code); - - if (optional) - ++optionalCount; } else { diff --git a/components/compiler/exprparser.hpp b/components/compiler/exprparser.hpp index 8ce5409d23..905f0d454f 100644 --- a/components/compiler/exprparser.hpp +++ b/components/compiler/exprparser.hpp @@ -101,6 +101,7 @@ namespace Compiler /// \param arguments Each character represents one arguments ('l': integer, /// 'f': float, 'S': string, 'c': string (case smashed), '/': following arguments are /// optional) + /// 'x': optional string that will be ignored (die in a fire, MW script compiler!) /// \param invert Store arguments in reverted order. /// \return number of optional arguments }; diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index ebe46d2826..53f1baaf9d 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -62,7 +62,7 @@ namespace Compiler extensions.registerInstruction ("toggleai", "", opcodeToggleAI, opcodeToggleAI); extensions.registerInstruction ("tai", "", opcodeToggleAI, opcodeToggleAI); extensions.registerInstruction("startcombat", "c", opcodeStartCombat, opcodeStartCombatExplicit); - extensions.registerInstruction("stopcombat", "", opcodeStopCombat, opcodeStopCombatExplicit); + extensions.registerInstruction("stopcombat", "x", opcodeStopCombat, opcodeStopCombatExplicit); extensions.registerFunction ("gethello", 'l', "", opcodeGetHello, opcodeGetHelloExplicit); extensions.registerFunction ("getfight", 'l', "", opcodeGetFight, opcodeGetFightExplicit); extensions.registerFunction ("getflee", 'l', "", opcodeGetFlee, opcodeGetFleeExplicit); @@ -398,7 +398,7 @@ namespace Compiler extensions.registerInstruction ("setpccrimelevel", "f", opcodeSetPCCrimeLevel); extensions.registerInstruction ("modpccrimelevel", "f", opcodeModPCCrimeLevel); - extensions.registerInstruction ("addspell", "c", opcodeAddSpell, opcodeAddSpellExplicit); + extensions.registerInstruction ("addspell", "cx", opcodeAddSpell, opcodeAddSpellExplicit); extensions.registerInstruction ("removespell", "c", opcodeRemoveSpell, opcodeRemoveSpellExplicit); extensions.registerInstruction ("removespelleffects", "c", opcodeRemoveSpellEffects, From fc135fbfee090ae37f89b8cfd80d4668dd968624 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 12 Feb 2014 09:04:52 +0100 Subject: [PATCH 046/171] Added new Display types --- apps/opencs/model/world/columnbase.hpp | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 70f38c5341..be5a427b80 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -27,6 +27,71 @@ namespace CSMWorld enum Display { Display_String, + + //CONCRETE TYPES STARTS HERE + Display_Globals, + Display_Global, + Display_VerificationResults, + Display_Gmsts, + Display_Gmst, + Display_Skills, + Display_Skill, + Display_Classes, + Display_Class, + Display_Factions, + Display_Faction, + Display_Races, + Display_Race, + Display_Sounds, + Display_Sound, + Display_Scripts, + Display_Script, + Display_Regions, + Display_Region, + Display_Birthsigns, + Display_Birthsign, + Display_Spells, + Display_Spell, + Display_Cells, + Display_Cell, + Display_Referenceables, + Display_Referenceable, + Display_Activator, + Display_Potion, + Display_Apparatus, + Display_Armor, + Display_Book, + Display_Clothing, + Display_Container, + Display_Creature, + Display_Door, + Display_Ingredient, + Display_CreatureLevelledList, + Display_ItemLevelledList, + Display_Light, + Display_Lockpick, + Display_Miscellaneous, + Display_Npc, + Display_Probe, + Display_Repair, + Display_Static, + Display_Weapon, + Display_References, + Display_Reference, + Display_RegionMap, + Display_Filter, + Display_Filters, + Display_Topics, + Display_Topic, + Display_Journals, + Display_Journal, + Display_TopicInfos, + Display_TopicInfo, + Display_JournalInfos, + Display_JournalInfo, + Display_Scene, + //CONCRETE TYPES ENDS HERE + Display_Integer, Display_Float, Display_Var, From bfb0e62c4ab2fc3b6cb391e40ba8a70adc6c3c28 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 09:10:05 +0100 Subject: [PATCH 047/171] ignore additional string argument after enable/disable --- components/compiler/lineparser.cpp | 14 +++++++++++--- components/compiler/lineparser.hpp | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 4a5e1cbd09..3b2b1f11b3 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -84,6 +84,13 @@ namespace Compiler bool LineParser::parseName (const std::string& name, const TokenLoc& loc, Scanner& scanner) { + if (mState==PotentialEndState) + { + getErrorHandler().warning ("stay string argument (ignoring it)", loc); + mState = EndState; + return true; + } + if (mState==SetState) { std::string name2 = Misc::StringUtils::lowerCase (name); @@ -219,13 +226,13 @@ namespace Compiler case Scanner::K_enable: Generator::enable (mCode, mLiterals, mExplicit); - mState = EndState; + mState = PotentialEndState; return true; case Scanner::K_disable: Generator::disable (mCode, mLiterals, mExplicit); - mState = EndState; + mState = PotentialEndState; return true; } @@ -406,7 +413,8 @@ namespace Compiler bool LineParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner) { - if (code==Scanner::S_newline && (mState==EndState || mState==BeginState)) + if (code==Scanner::S_newline && + (mState==EndState || mState==BeginState || mState==PotentialEndState)) return false; if (code==Scanner::S_comma && mState==MessageState) diff --git a/components/compiler/lineparser.hpp b/components/compiler/lineparser.hpp index 0aba30d4b5..c54c764bce 100644 --- a/components/compiler/lineparser.hpp +++ b/components/compiler/lineparser.hpp @@ -23,7 +23,7 @@ namespace Compiler SetState, SetLocalVarState, SetGlobalVarState, SetPotentialMemberVarState, SetMemberVarState, SetMemberVarState2, MessageState, MessageCommaState, MessageButtonState, MessageButtonCommaState, - EndState, + EndState, PotentialEndState /* may have a stray string argument */, PotentialExplicitState, ExplicitState, MemberState }; From b1b0877122a21d48898b46ef49c3062168a5b8fc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 09:14:32 +0100 Subject: [PATCH 048/171] allow additional numeric argument for AiFollow and ignore it --- components/compiler/extensions0.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index 53f1baaf9d..5079a6064e 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -41,7 +41,7 @@ namespace Compiler opcodeAiEscortCellExplicit); extensions.registerInstruction ("aiwander", "fff/llllllllll", opcodeAiWander, opcodeAiWanderExplicit); - extensions.registerInstruction ("aifollow", "cffff/l", opcodeAiFollow, + extensions.registerInstruction ("aifollow", "cffff/ll", opcodeAiFollow, opcodeAiFollowExplicit); extensions.registerInstruction ("aifollowcell", "ccffff/l", opcodeAiFollowCell, opcodeAiFollowCellExplicit); From c0a6acfe6cb7cf3ea6277c2539de571d6e55ad1e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 09:23:23 +0100 Subject: [PATCH 049/171] allow the use of keywords as variable names in more places --- components/compiler/lineparser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 3b2b1f11b3..3ae24bfb75 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -219,6 +219,12 @@ namespace Compiler bool LineParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) { + if (mState==SetState) + { + // allow keywords to be used as variable names when assigning a value to a variable. + return parseName (loc.mLiteral, loc, scanner); + } + if (mState==BeginState || mState==ExplicitState) { switch (keyword) From e1a39b83884cfd9ac45025533cb9af9adfeb0fcd Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 12 Feb 2014 09:24:08 +0100 Subject: [PATCH 050/171] Replaced some display_string with specific type. Damn, i wish this is correct ;-) --- apps/opencs/model/world/columnimp.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 18aac9e0be..0490421092 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -373,7 +373,7 @@ namespace CSMWorld SkillsColumn (int index, bool typePrefix = false, bool major = false) : Column ((typePrefix ? ( major ? Columns::ColumnId_MajorSkill1 : Columns::ColumnId_MinorSkill1) : - Columns::ColumnId_Skill1) + index, ColumnBase::Display_String), + Columns::ColumnId_Skill1) + index, ColumnBase::Display_Skills), mIndex (index), mMajor (major) {} @@ -598,7 +598,7 @@ namespace CSMWorld struct SoundFileColumn : public Column { SoundFileColumn() - : Column (Columns::ColumnId_SoundFile, ColumnBase::Display_String) + : Column (Columns::ColumnId_SoundFile, ColumnBase::Display_Sound) {} virtual QVariant get (const Record& record) const @@ -811,7 +811,7 @@ namespace CSMWorld template struct CellColumn : public Column { - CellColumn() : Column (Columns::ColumnId_Cell, ColumnBase::Display_String) {} + CellColumn() : Column (Columns::ColumnId_Cell, ColumnBase::Display_Cell) {} virtual QVariant get (const Record& record) const { @@ -890,7 +890,7 @@ namespace CSMWorld template struct OwnerColumn : public Column { - OwnerColumn() : Column (Columns::ColumnId_Owner, ColumnBase::Display_String) {} + OwnerColumn() : Column (Columns::ColumnId_Owner, ColumnBase::Display_Npc) {} virtual QVariant get (const Record& record) const { @@ -915,7 +915,7 @@ namespace CSMWorld template struct SoulColumn : public Column { - SoulColumn() : Column (Columns::ColumnId_Soul, ColumnBase::Display_String) {} + SoulColumn() : Column (Columns::ColumnId_Soul, ColumnBase::Display_Creature) {} virtual QVariant get (const Record& record) const { @@ -940,7 +940,7 @@ namespace CSMWorld template struct FactionColumn : public Column { - FactionColumn() : Column (Columns::ColumnId_Faction, ColumnBase::Display_String) {} + FactionColumn() : Column (Columns::ColumnId_Faction, ColumnBase::Display_Faction) {} virtual QVariant get (const Record& record) const { @@ -1090,7 +1090,7 @@ namespace CSMWorld struct TeleportCellColumn : public Column { TeleportCellColumn() - : Column (Columns::ColumnId_TeleportCell, ColumnBase::Display_String) + : Column (Columns::ColumnId_TeleportCell, ColumnBase::Display_Cell) {} virtual QVariant get (const Record& record) const @@ -1146,7 +1146,7 @@ namespace CSMWorld template struct KeyColumn : public Column { - KeyColumn() : Column (Columns::ColumnId_Key, ColumnBase::Display_String) {} + KeyColumn() : Column (Columns::ColumnId_Key, ColumnBase::Display_Miscellaneous) {} virtual QVariant get (const Record& record) const { @@ -1510,7 +1510,7 @@ namespace CSMWorld template struct ClassColumn : public Column { - ClassColumn() : Column (Columns::ColumnId_Class, ColumnBase::Display_String) {} + ClassColumn() : Column (Columns::ColumnId_Class, ColumnBase::Display_Class) {} virtual QVariant get (const Record& record) const { @@ -1535,7 +1535,7 @@ namespace CSMWorld template struct PcFactionColumn : public Column { - PcFactionColumn() : Column (Columns::ColumnId_PcFaction, ColumnBase::Display_String) {} + PcFactionColumn() : Column (Columns::ColumnId_PcFaction, ColumnBase::Display_Faction) {} virtual QVariant get (const Record& record) const { From 93d47430125be4d766d6937541ba826138a790a2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 09:56:25 +0100 Subject: [PATCH 051/171] interpret instruction keywords as names within expressions --- components/compiler/exprparser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 4af11ec2be..319bb44988 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -344,6 +344,17 @@ namespace Compiler bool ExprParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) { + if (const Extensions *extensions = getContext().getExtensions()) + { + std::string argumentType; // ignored + bool hasExplicit = false; // ignored + if (extensions->isInstruction (keyword, argumentType, hasExplicit)) + { + // pretend this is not a keyword + return parseName (loc.mLiteral, loc, scanner); + } + } + mFirst = false; if (!mExplicit.empty()) From 2e33ab3a13b61e846155e9b8bf889c8725d4f015 Mon Sep 17 00:00:00 2001 From: gus Date: Wed, 12 Feb 2014 11:16:12 +0100 Subject: [PATCH 052/171] droping somewhat works --- apps/opencs/view/world/table.cpp | 5 +++++ apps/opencs/view/world/table.hpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 1a9499f52b..15f946f718 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -465,4 +465,9 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) { std::cout << "drop"; event->acceptProposedAction(); +} + +void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) +{ + event->accept(); } \ No newline at end of file diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 44d72f7fb3..fd28396880 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -56,6 +56,9 @@ namespace CSVWorld void dropEvent(QDropEvent *event); + void dragMoveEvent(QDragMoveEvent *event); + + public: Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting); From 6cf561f713d54ede7e4e4d5ffb34da962c097bb0 Mon Sep 17 00:00:00 2001 From: gus Date: Wed, 12 Feb 2014 11:32:01 +0100 Subject: [PATCH 053/171] get index to where we are dropping --- apps/opencs/view/world/table.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 15f946f718..fe79ab2ff6 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -465,6 +465,8 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) { std::cout << "drop"; event->acceptProposedAction(); + QModelIndex index = indexAt(event->pos()); + std::cout << index.row(); } void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) From 62c9c77ddf734b0f4cbb97842d855e776e4fc0f2 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 12 Feb 2014 11:42:19 +0100 Subject: [PATCH 054/171] Compiles now. --- apps/opencs/model/world/columnbase.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index be5a427b80..d0419289fe 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -44,8 +44,6 @@ namespace CSMWorld Display_Race, Display_Sounds, Display_Sound, - Display_Scripts, - Display_Script, Display_Regions, Display_Region, Display_Birthsigns, From c00834a8de88e1042b2f046c9532270dc5da1ddc Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 12 Feb 2014 13:12:58 +0100 Subject: [PATCH 055/171] added some iostream garbage. --- apps/opencs/model/world/universalid.cpp | 3 ++- apps/opencs/view/world/table.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index e633f4f696..88674c4ce1 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace { @@ -186,7 +187,7 @@ CSMWorld::UniversalId::UniversalId (Type type, const std::string& id) mClass = sIdArg[i].mClass; return; } - + std::cout<setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); drag->exec(); - std::cout << "startdrag"; + std::cout << "startdrag\n"; } } @@ -456,14 +456,14 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) { //if (event->mimeData()->hasFormat("text/plain")) - std::cout << "accept drag event"; + std::cout << "accept drag event\n"; event->acceptProposedAction(); } void CSVWorld::Table::dropEvent(QDropEvent *event) { - std::cout << "drop"; + std::cout << "drop\n"; event->acceptProposedAction(); QModelIndex index = indexAt(event->pos()); std::cout << index.row(); From 388735046fdb75b34744f1c292a8a349f4ab4f40 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 13:35:24 +0100 Subject: [PATCH 056/171] fixed broken remote member variable access --- apps/openmw/mwscript/interpretercontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 17092b41ca..b79808d08b 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -66,7 +66,7 @@ namespace MWScript { const MWWorld::Ptr ptr = getReference (id, false); - std::string id = MWWorld::Class::get (ptr).getScript (ptr); + id = MWWorld::Class::get (ptr).getScript (ptr); ptr.getRefData().setLocals ( *MWBase::Environment::get().getWorld()->getStore().get().find (id)); @@ -86,7 +86,7 @@ namespace MWScript { const MWWorld::Ptr ptr = getReference (id, false); - std::string id = MWWorld::Class::get (ptr).getScript (ptr); + id = MWWorld::Class::get (ptr).getScript (ptr); ptr.getRefData().setLocals ( *MWBase::Environment::get().getWorld()->getStore().get().find (id)); From dc433a3c093c1a060e2c71c31a9d09a061834093 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 13:38:16 +0100 Subject: [PATCH 057/171] fixed case handling problem for local variable access --- apps/openmw/mwscript/scriptmanagerimp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 11e094a843..5e18151da4 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -221,8 +221,10 @@ namespace MWScript throw std::runtime_error ("invalid variable type"); } + std::string variable2 = Misc::StringUtils::lowerCase (variable); + for (int i=0; imVarNames.at (i+offset)==variable) + if (Misc::StringUtils::lowerCase (script->mVarNames.at (i+offset))==variable2) return i; throw std::runtime_error ("unable to access local variable " + variable + " of " + scriptId); From 6e2e4d1adf9000a81a49c3f7f1bee2245edf933d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 13:45:01 +0100 Subject: [PATCH 058/171] ignore stray begin --- components/compiler/lineparser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 3ae24bfb75..1407d0e956 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -357,6 +357,12 @@ namespace Compiler getErrorHandler().warning ("stay endif (ignoring it)", loc); mState = EndState; return true; + + case Scanner::K_begin: + + getErrorHandler().warning ("stay begin (ignoring it)", loc); + mState = EndState; + return true; } } else if (mState==SetLocalVarState && keyword==Scanner::K_to) From a85d3c7dcb52db79ad8ab0314063e134153e6742 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 13:53:59 +0100 Subject: [PATCH 059/171] ignore unused explicit references for functions --- components/compiler/exprparser.cpp | 13 +++++++++++-- components/compiler/extensions.cpp | 4 ++-- components/compiler/extensions.hpp | 4 +++- components/compiler/lineparser.cpp | 11 +++++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 319bb44988..07f576006f 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -397,8 +397,15 @@ namespace Compiler char returnType; std::string argumentType; - if (extensions->isFunction (keyword, returnType, argumentType, true)) + bool hasExplicit = true; + if (extensions->isFunction (keyword, returnType, argumentType, hasExplicit)) { + if (!hasExplicit) + { + getErrorHandler().warning ("stray explicit reference (ignoring it)", loc); + mExplicit.clear(); + } + start(); mTokenLoc = loc; @@ -519,7 +526,9 @@ namespace Compiler char returnType; std::string argumentType; - if (extensions->isFunction (keyword, returnType, argumentType, false)) + bool hasExplicit = false; + + if (extensions->isFunction (keyword, returnType, argumentType, hasExplicit)) { mTokenLoc = loc; int optionals = parseArguments (argumentType, scanner); diff --git a/components/compiler/extensions.cpp b/components/compiler/extensions.cpp index 6f5c2fc897..c09abcbafd 100644 --- a/components/compiler/extensions.cpp +++ b/components/compiler/extensions.cpp @@ -22,7 +22,7 @@ namespace Compiler } bool Extensions::isFunction (int keyword, char& returnType, std::string& argumentType, - bool explicitReference) const + bool& explicitReference) const { std::map::const_iterator iter = mFunctions.find (keyword); @@ -30,7 +30,7 @@ namespace Compiler return false; if (explicitReference && iter->second.mCodeExplicit==-1) - return false; + explicitReference = false; returnType = iter->second.mReturn; argumentType = iter->second.mArguments; diff --git a/components/compiler/extensions.hpp b/components/compiler/extensions.hpp index 585c42681c..79cfed9e86 100644 --- a/components/compiler/extensions.hpp +++ b/components/compiler/extensions.hpp @@ -47,9 +47,11 @@ namespace Compiler /// - keyword must be all lower case. bool isFunction (int keyword, char& returnType, std::string& argumentType, - bool explicitReference) const; + bool& explicitReference) const; ///< Is this keyword registered with a function? If yes, return return and argument /// types. + /// \param explicitReference In: has explicit reference; Out: set to false, if + /// explicit reference is not available for this instruction. bool isInstruction (int keyword, std::string& argumentType, bool& explicitReference) const; diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 1407d0e956..e435b936c3 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -279,9 +279,16 @@ namespace Compiler char returnType; std::string argumentType; - if (extensions->isFunction (keyword, returnType, argumentType, - !mExplicit.empty())) + bool hasExplicit = !mExplicit.empty(); + + if (extensions->isFunction (keyword, returnType, argumentType, hasExplicit)) { + if (!hasExplicit && !mExplicit.empty()) + { + getErrorHandler().warning ("stray explicit reference (ignoring it)", loc); + mExplicit.clear(); + } + scanner.putbackKeyword (keyword, loc); parseExpression (scanner, loc); mState = EndState; From b3412b7eec1c19ae427201c544d778d18cff7a1a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 15:22:17 +0100 Subject: [PATCH 060/171] another case fix (remote member access again) --- apps/openmw/mwscript/compilercontext.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index 8018b86e02..1b3e769bf1 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -52,7 +52,8 @@ namespace MWScript char type = ' '; if (!script.empty()) - type = MWBase::Environment::get().getScriptManager()->getLocals (script).getType (name); + type = MWBase::Environment::get().getScriptManager()->getLocals (script).getType ( + Misc::StringUtils::lowerCase (name)); return std::make_pair (type, reference); } From 749136bf3394df4498eb1f672313124b3365c1cc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 12 Feb 2014 20:23:47 +0100 Subject: [PATCH 061/171] ignore attempts to set non-existing variables --- components/compiler/lineparser.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index e435b936c3..495e7e25e5 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -219,6 +219,14 @@ namespace Compiler bool LineParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) { + if (mState==SetPotentialMemberVarState && keyword==Scanner::K_to) + { + getErrorHandler().warning ("unknown variable (ignoring set instruction)", loc); + SkipParser skip (getErrorHandler(), getContext()); + scanner.scan (skip); + return false; + } + if (mState==SetState) { // allow keywords to be used as variable names when assigning a value to a variable. From 2eeb0eb4f3fcc60ee206b7fb53786a66a3d2d04c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 08:38:26 +0100 Subject: [PATCH 062/171] allow lines to continue with other instructions after an legit else --- components/compiler/controlparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/compiler/controlparser.cpp b/components/compiler/controlparser.cpp index ba2db62b66..60d17a8216 100644 --- a/components/compiler/controlparser.cpp +++ b/components/compiler/controlparser.cpp @@ -72,7 +72,7 @@ namespace Compiler } else if (keyword==Scanner::K_else) { - mState = IfElseEndState; + mState = IfElseBodyState; /// \todo should be IfElseEndState; add an option for that } return true; From 0313876d88f9eb55c8ed43a9b79787ec17866b05 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 08:49:40 +0100 Subject: [PATCH 063/171] allow leaving out if in a top-level if-statement --- components/compiler/scriptparser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/compiler/scriptparser.cpp b/components/compiler/scriptparser.cpp index 1b613595a6..f34313969a 100644 --- a/components/compiler/scriptparser.cpp +++ b/components/compiler/scriptparser.cpp @@ -71,6 +71,12 @@ namespace Compiler if (code==Scanner::S_newline) // empty line return true; + if (code==Scanner::S_open) /// \todo Option to switch this off + { + scanner.putbackSpecial (code, loc); + return parseKeyword (Scanner::K_if, loc, scanner); + } + mLineParser.reset(); if (mLineParser.parseSpecial (code, loc, scanner)) scanner.scan (mLineParser); From c03bd8ebb6c3b18869c75350f1c276ed03dfdb0e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 08:59:33 +0100 Subject: [PATCH 064/171] allow [] as aliases for () --- components/compiler/scanner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/compiler/scanner.cpp b/components/compiler/scanner.cpp index 816443c447..46e50a2e9b 100644 --- a/components/compiler/scanner.cpp +++ b/components/compiler/scanner.cpp @@ -370,9 +370,9 @@ namespace Compiler if (c=='\n') special = S_newline; - else if (c=='(') + else if (c=='(' || c=='[') /// \todo option to disable the use of [ as alias for ( special = S_open; - else if (c==')') + else if (c==')' || c==']') /// \todo option to disable the use of ] as alias for ) special = S_close; else if (c=='.') { From 87b51e47a9d1357d3e1c6968ea3add6ddd58d8d5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 09:40:07 +0100 Subject: [PATCH 065/171] fixed another case issue in remote member access --- components/compiler/controlparser.cpp | 1 - components/compiler/locals.cpp | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/compiler/controlparser.cpp b/components/compiler/controlparser.cpp index 60d17a8216..499358ca02 100644 --- a/components/compiler/controlparser.cpp +++ b/components/compiler/controlparser.cpp @@ -9,7 +9,6 @@ #include "generator.hpp" #include "errorhandler.hpp" -#include namespace Compiler { bool ControlParser::parseIfBody (int keyword, const TokenLoc& loc, Scanner& scanner) diff --git a/components/compiler/locals.cpp b/components/compiler/locals.cpp index e2b1c5c966..60a5704bf3 100644 --- a/components/compiler/locals.cpp +++ b/components/compiler/locals.cpp @@ -7,6 +7,8 @@ #include #include +#include + namespace Compiler { const std::vector& Locals::get (char type) const @@ -97,7 +99,7 @@ namespace Compiler void Locals::declare (char type, const std::string& name) { - get (type).push_back (name); + get (type).push_back (Misc::StringUtils::lowerCase (name)); } void Locals::clear() From dde4fbd8184211700be7d5e5bd1651acafeeb1cb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 09:52:44 +0100 Subject: [PATCH 066/171] allow one more integer argument in RemoveSoulGem and up to 6 more in AiFollow and then throw them all away --- apps/openmw/mwscript/docs/vmformat.txt | 8 +++++--- apps/openmw/mwscript/miscextensions.cpp | 12 ++++++++---- components/compiler/extensions0.cpp | 4 ++-- components/compiler/opcodes.hpp | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 2fe4c768ba..70186a089b 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -52,7 +52,9 @@ op 0x20023: AiFollow, explicit reference op 0x20024: AiFollowCell op 0x20025: AiFollowCell, explicit reference op 0x20026: ModRegion -opcodes 0x20027-0x3ffff unused +op 0x20027: RemoveSoulGem +op 0x20028: RemoveSoulGem, explicit reference +opcodes 0x20029-0x3ffff unused Segment 4: (not implemented yet) @@ -308,8 +310,8 @@ op 0x20001f1: GetDetected op 0x20001f2: GetDetected, explicit reference op 0x20001f3: AddSoulGem op 0x20001f4: AddSoulGem, explicit reference -op 0x20001f5: RemoveSoulGem -op 0x20001f6: RemoveSoulGem, explicit reference +op 0x20001f5: unused +op 0x20001f6: unused op 0x20001f7: PlayBink op 0x20001f8: Drop op 0x20001f9: Drop, explicit reference diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index aa0e775af2..0c60e1c940 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -365,17 +365,21 @@ namespace MWScript }; template - class OpRemoveSoulGem : public Interpreter::Opcode0 + class OpRemoveSoulGem : public Interpreter::Opcode1 { public: - virtual void execute (Interpreter::Runtime& runtime) + virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { MWWorld::Ptr ptr = R()(runtime); std::string soul = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); + // throw away additional arguments + for (unsigned int i=0; i); interpreter.installSegment5 (Compiler::Misc::opcodeAddSoulGem, new OpAddSoulGem); interpreter.installSegment5 (Compiler::Misc::opcodeAddSoulGemExplicit, new OpAddSoulGem); - interpreter.installSegment5 (Compiler::Misc::opcodeRemoveSoulGem, new OpRemoveSoulGem); - interpreter.installSegment5 (Compiler::Misc::opcodeRemoveSoulGemExplicit, new OpRemoveSoulGem); + interpreter.installSegment3 (Compiler::Misc::opcodeRemoveSoulGem, new OpRemoveSoulGem); + interpreter.installSegment3 (Compiler::Misc::opcodeRemoveSoulGemExplicit, new OpRemoveSoulGem); interpreter.installSegment5 (Compiler::Misc::opcodeDrop, new OpDrop); interpreter.installSegment5 (Compiler::Misc::opcodeDropExplicit, new OpDrop); interpreter.installSegment5 (Compiler::Misc::opcodeDropSoulGem, new OpDropSoulGem); diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index 5079a6064e..78b6409f22 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -41,7 +41,7 @@ namespace Compiler opcodeAiEscortCellExplicit); extensions.registerInstruction ("aiwander", "fff/llllllllll", opcodeAiWander, opcodeAiWanderExplicit); - extensions.registerInstruction ("aifollow", "cffff/ll", opcodeAiFollow, + extensions.registerInstruction ("aifollow", "cffff/llllllll", opcodeAiFollow, opcodeAiFollowExplicit); extensions.registerInstruction ("aifollowcell", "ccffff/l", opcodeAiFollowCell, opcodeAiFollowCellExplicit); @@ -253,7 +253,7 @@ namespace Compiler extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit); extensions.registerFunction ("geteffect", 'l', "S", opcodeGetEffect, opcodeGetEffectExplicit); extensions.registerInstruction ("addsoulgem", "cc", opcodeAddSoulGem, opcodeAddSoulGemExplicit); - extensions.registerInstruction ("removesoulgem", "c", opcodeRemoveSoulGem, opcodeRemoveSoulGemExplicit); + extensions.registerInstruction ("removesoulgem", "c/l", opcodeRemoveSoulGem, opcodeRemoveSoulGemExplicit); extensions.registerInstruction ("drop", "cl", opcodeDrop, opcodeDropExplicit); extensions.registerInstruction ("dropsoulgem", "c", opcodeDropSoulGem, opcodeDropSoulGemExplicit); extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit); diff --git a/components/compiler/opcodes.hpp b/components/compiler/opcodes.hpp index 583cf4eea3..1dbdbf7e72 100644 --- a/components/compiler/opcodes.hpp +++ b/components/compiler/opcodes.hpp @@ -203,8 +203,8 @@ namespace Compiler const int opcodeGetEffectExplicit = 0x20001d0; const int opcodeAddSoulGem = 0x20001f3; const int opcodeAddSoulGemExplicit = 0x20001f4; - const int opcodeRemoveSoulGem = 0x20001f5; - const int opcodeRemoveSoulGemExplicit = 0x20001f6; + const int opcodeRemoveSoulGem = 0x20027; + const int opcodeRemoveSoulGemExplicit = 0x20028; const int opcodeDrop = 0x20001f8; const int opcodeDropExplicit = 0x20001f9; const int opcodeDropSoulGem = 0x20001fa; From ac8290c4d3b329073a49369fde82a33d023998a2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 09:59:22 +0100 Subject: [PATCH 067/171] fixed problem with line endings in case of a local variable redeclaration --- components/compiler/declarationparser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/compiler/declarationparser.cpp b/components/compiler/declarationparser.cpp index 586b28bc29..9c4e4f631b 100644 --- a/components/compiler/declarationparser.cpp +++ b/components/compiler/declarationparser.cpp @@ -27,8 +27,7 @@ bool Compiler::DeclarationParser::parseName (const std::string& name, const Toke /// \todo add option to make re-declared local variables an error getErrorHandler().warning ("can't re-declare local variable (ignoring declaration)", loc); - SkipParser skip (getErrorHandler(), getContext()); - scanner.scan (skip); + mState = State_End; return true; } From 5f3f867a10cde649afd4d749680e12aba180da83 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 10:21:49 +0100 Subject: [PATCH 068/171] Implemented convertEnums function --- apps/opencs/model/world/columnbase.hpp | 22 -- apps/opencs/model/world/columnimp.hpp | 2 +- apps/opencs/model/world/tablemimedata.cpp | 234 +++++++++++++++++++++- apps/opencs/model/world/tablemimedata.hpp | 9 +- apps/opencs/view/world/table.cpp | 6 - 5 files changed, 234 insertions(+), 39 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index d0419289fe..e689c6a3f5 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -29,30 +29,15 @@ namespace CSMWorld Display_String, //CONCRETE TYPES STARTS HERE - Display_Globals, - Display_Global, - Display_VerificationResults, - Display_Gmsts, - Display_Gmst, - Display_Skills, Display_Skill, - Display_Classes, Display_Class, - Display_Factions, Display_Faction, - Display_Races, Display_Race, - Display_Sounds, Display_Sound, - Display_Regions, Display_Region, - Display_Birthsigns, Display_Birthsign, - Display_Spells, Display_Spell, - Display_Cells, Display_Cell, - Display_Referenceables, Display_Referenceable, Display_Activator, Display_Potion, @@ -74,18 +59,11 @@ namespace CSMWorld Display_Repair, Display_Static, Display_Weapon, - Display_References, Display_Reference, - Display_RegionMap, Display_Filter, - Display_Filters, - Display_Topics, Display_Topic, - Display_Journals, Display_Journal, - Display_TopicInfos, Display_TopicInfo, - Display_JournalInfos, Display_JournalInfo, Display_Scene, //CONCRETE TYPES ENDS HERE diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 0490421092..9e9bedcf87 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -373,7 +373,7 @@ namespace CSMWorld SkillsColumn (int index, bool typePrefix = false, bool major = false) : Column ((typePrefix ? ( major ? Columns::ColumnId_MajorSkill1 : Columns::ColumnId_MinorSkill1) : - Columns::ColumnId_Skill1) + index, ColumnBase::Display_Skills), + Columns::ColumnId_Skill1) + index, ColumnBase::Display_Skill), mIndex (index), mMajor (major) {} diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 0cdcdba3ae..45305431e4 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -1,19 +1,21 @@ #include "tablemimedata.hpp" -#include "universalid.hpp" #include +#include "universalid.hpp" +#include "columnbase.hpp" + CSMWorld::TableMimeData::TableMimeData (UniversalId id) { - mUniversalId.push_back(id); - mObjectsFormats << QString::fromStdString("tabledata/" + id.getTypeName()); + mUniversalId.push_back (id); + mObjectsFormats << QString::fromStdString ("tabledata/" + id.getTypeName()); } -CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) +CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) : + mUniversalId (id) { - mUniversalId = id; - for (std::vector::iterator it(mUniversalId.begin()); it != mUniversalId.end(); ++it) + for (std::vector::iterator it (mUniversalId.begin()); it != mUniversalId.end(); ++it) { - mObjectsFormats << QString::fromStdString("tabledata/" + it->getTypeName()); + mObjectsFormats << QString::fromStdString ("tabledata/" + it->getTypeName()); } } @@ -30,11 +32,12 @@ std::string CSMWorld::TableMimeData::getIcon() const { if (mUniversalId.empty()) { - throw("TableMimeData holds no UniversalId"); + throw ("TableMimeData holds no UniversalId"); } std::string tmpIcon; bool firstIteration = true; + for (unsigned i = 0; i < mUniversalId.size(); ++i) { if (firstIteration) @@ -51,10 +54,223 @@ std::string CSMWorld::TableMimeData::getIcon() const tmpIcon = mUniversalId[i].getIcon(); } + return mUniversalId.begin()->getIcon(); //All objects are of the same type; } std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const { return mUniversalId; -} \ No newline at end of file +} + +bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const +{ + for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) + { + if (it->getType() == type) + { + return true; + } + } + + return false; +} + +bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) +{ + for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) + { + if (it->getType() == convertEnums (type)) + { + return true; + } + } + + return false; +} + +CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::UniversalId::Type type) const +{ + for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) + { + if (it->getType() == type) + { + return *it; + } + } + + throw ("TableMimeData object does not hold object of the seeked type"); +} + +CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) +{ + for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) + { + if (it->getType() == convertEnums (type)) + { + return *it; + } + } + + throw ("TableMimeData object does not hold object of the seeked type"); +} + +CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) +{ + switch (type) + { + default: + throw ("This type is not handled"); + return CSMWorld::UniversalId::Type_None; + break; + + case CSMWorld::ColumnBase::Display_Race: + return CSMWorld::UniversalId::Type_Race; + break; + + case CSMWorld::ColumnBase::Display_Skill: + return CSMWorld::UniversalId::Type_Skill; + break; + + case CSMWorld::ColumnBase::Display_Class: + return CSMWorld::UniversalId::Type_Class; + break; + + case CSMWorld::ColumnBase::Display_Faction: + return CSMWorld::UniversalId::Type_Faction; + break; + + case CSMWorld::ColumnBase::Display_Sound: + return CSMWorld::UniversalId::Type_Sound; + break; + + case CSMWorld::ColumnBase::Display_Region: + return CSMWorld::UniversalId::Type_Region; + break; + + case CSMWorld::ColumnBase::Display_Birthsign: + return CSMWorld::UniversalId::Type_Birthsign; + break; + + case CSMWorld::ColumnBase::Display_Spell: + return CSMWorld::UniversalId::Type_Spell; + break; + + case CSMWorld::ColumnBase::Display_Cell: + return CSMWorld::UniversalId::Type_Cell; + break; + + case CSMWorld::ColumnBase::Display_Referenceable: + return CSMWorld::UniversalId::Type_Referenceable; + break; + + case CSMWorld::ColumnBase::Display_Activator: + return CSMWorld::UniversalId::Type_Activator; + break; + + case CSMWorld::ColumnBase::Display_Potion: + return CSMWorld::UniversalId::Type_Potion; + break; + + case CSMWorld::ColumnBase::Display_Apparatus: + return CSMWorld::UniversalId::Type_Apparatus; + break; + + case CSMWorld::ColumnBase::Display_Armor: + return CSMWorld::UniversalId::Type_Armor; + break; + + case CSMWorld::ColumnBase::Display_Book: + return CSMWorld::UniversalId::Type_Book; + break; + + case CSMWorld::ColumnBase::Display_Clothing: + return CSMWorld::UniversalId::Type_Clothing; + break; + + case CSMWorld::ColumnBase::Display_Container: + return CSMWorld::UniversalId::Type_Container; + break; + + case CSMWorld::ColumnBase::Display_Creature: + return CSMWorld::UniversalId::Type_Creature; + break; + + case CSMWorld::ColumnBase::Display_Door: + return CSMWorld::UniversalId::Type_Door; + break; + + case CSMWorld::ColumnBase::Display_Ingredient: + return CSMWorld::UniversalId::Type_Ingredient; + break; + + case CSMWorld::ColumnBase::Display_CreatureLevelledList: + return CSMWorld::UniversalId::Type_CreatureLevelledList; + break; + + case CSMWorld::ColumnBase::Display_ItemLevelledList: + return CSMWorld::UniversalId::Type_ItemLevelledList; + break; + + case CSMWorld::ColumnBase::Display_Light: + return CSMWorld::UniversalId::Type_Light; + break; + + case CSMWorld::ColumnBase::Display_Lockpick: + return CSMWorld::UniversalId::Type_Lockpick; + break; + + case CSMWorld::ColumnBase::Display_Miscellaneous: + return CSMWorld::UniversalId::Type_Miscellaneous; + break; + + case CSMWorld::ColumnBase::Display_Npc: + return CSMWorld::UniversalId::Type_Npc; + break; + + case CSMWorld::ColumnBase::Display_Probe: + return CSMWorld::UniversalId::Type_Probe; + break; + + case CSMWorld::ColumnBase::Display_Repair: + return CSMWorld::UniversalId::Type_Repair; + break; + + case CSMWorld::ColumnBase::Display_Static: + return CSMWorld::UniversalId::Type_Static; + break; + + case CSMWorld::ColumnBase::Display_Weapon: + return CSMWorld::UniversalId::Type_Weapon; + break; + + case CSMWorld::ColumnBase::Display_Reference: + return CSMWorld::UniversalId::Type_Reference; + break; + + case CSMWorld::ColumnBase::Display_Filter: + return CSMWorld::UniversalId::Type_Filter; + break; + + case CSMWorld::ColumnBase::Display_Topic: + return CSMWorld::UniversalId::Type_Topic; + break; + + case CSMWorld::ColumnBase::Display_Journal: + return CSMWorld::UniversalId::Type_Journal; + break; + + case CSMWorld::ColumnBase::Display_TopicInfo: + return CSMWorld::UniversalId::Type_TopicInfo; + break; + + case CSMWorld::ColumnBase::Display_JournalInfo: + return CSMWorld::UniversalId::Type_JournalInfo; + break; + + case CSMWorld::ColumnBase::Display_Scene: + return CSMWorld::UniversalId::Type_Scene; + break; + } +} +// kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 7509bd905d..d2e5d3ecb0 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -10,6 +10,7 @@ #include #include "universalid.hpp" +#include "columnbase.hpp" namespace CSMWorld @@ -23,10 +24,16 @@ namespace CSMWorld virtual QStringList formats() const; std::string getIcon() const; std::vector getData() const; + bool holdsType(UniversalId::Type type) const; + bool holdsType(CSMWorld::ColumnBase::Display type); + UniversalId returnMatching(UniversalId::Type type) const; + UniversalId returnMatching(CSMWorld::ColumnBase::Display type); private: std::vector mUniversalId; QStringList mObjectsFormats; + + CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type); }; } -#endif // TABLEMIMEDATA_H \ No newline at end of file +#endif // TABLEMIMEDATA_H diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 7ac5946c85..c39ed34690 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -469,25 +469,19 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); drag->exec(); - std::cout << "startdrag\n"; } } void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) { - //if (event->mimeData()->hasFormat("text/plain")) - std::cout << "accept drag event\n"; event->acceptProposedAction(); - } void CSVWorld::Table::dropEvent(QDropEvent *event) { - std::cout << "drop\n"; event->acceptProposedAction(); QModelIndex index = indexAt(event->pos()); - std::cout << index.row(); } void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) From 71b2fc1c7024242209022e646b0cfe1ac9be65da Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 10:54:39 +0100 Subject: [PATCH 069/171] Introduced method to access display type. --- apps/opencs/model/world/idtable.cpp | 5 +++++ apps/opencs/model/world/idtable.hpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index bea307aa21..b509f6b9d5 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -188,4 +188,9 @@ void CSMWorld::IdTable::reorderRows (int baseIndex, const std::vector& newO CSMWorld::IdTable::Reordering CSMWorld::IdTable::getReordering() const { return mReordering; +} + +CSMWorld::ColumnBase::Display CSMWorld::IdTable::getColumnDisplay (int index) const +{ + return mIdCollection->getColumn(index).mDisplayType; } \ No newline at end of file diff --git a/apps/opencs/model/world/idtable.hpp b/apps/opencs/model/world/idtable.hpp index 74923867d6..aee49a961e 100644 --- a/apps/opencs/model/world/idtable.hpp +++ b/apps/opencs/model/world/idtable.hpp @@ -11,6 +11,7 @@ namespace CSMWorld { class CollectionBase; + class ColumnsBase; class RecordBase; class IdTable : public QAbstractItemModel @@ -86,6 +87,8 @@ namespace CSMWorld /// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex). Reordering getReordering() const; + + CSMWorld::ColumnBase::Display getColumnDisplay(int index) const; }; } From d4a755d1aa53bc37661bc41ac390ce682e821346 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 11:15:55 +0100 Subject: [PATCH 070/171] Fix some hardcoded literals --- components/terrain/quadtreenode.cpp | 12 +++++++----- components/terrain/world.cpp | 10 ++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/components/terrain/quadtreenode.cpp b/components/terrain/quadtreenode.cpp index a4fdd5e13f..82ccc7c89a 100644 --- a/components/terrain/quadtreenode.cpp +++ b/components/terrain/quadtreenode.cpp @@ -168,7 +168,8 @@ QuadTreeNode::QuadTreeNode(World* terrain, ChildDirection dir, float size, const if (mParent) pos = mParent->getCenter(); pos = mCenter - pos; - mSceneNode->setPosition(Ogre::Vector3(pos.x*8192, pos.y*8192, 0)); + float cellWorldSize = mTerrain->getStorage()->getCellWorldSize(); + mSceneNode->setPosition(Ogre::Vector3(pos.x*cellWorldSize, pos.y*cellWorldSize, 0)); mMaterialGenerator = new MaterialGenerator(mTerrain->getShadersEnabled()); } @@ -203,6 +204,7 @@ void QuadTreeNode::initNeighbours() void QuadTreeNode::initAabb() { + float cellWorldSize = mTerrain->getStorage()->getCellWorldSize(); if (hasChildren()) { for (int i=0; i<4; ++i) @@ -210,11 +212,11 @@ void QuadTreeNode::initAabb() mChildren[i]->initAabb(); mBounds.merge(mChildren[i]->getBoundingBox()); } - mBounds = Ogre::AxisAlignedBox (Ogre::Vector3(-mSize/2*8192, -mSize/2*8192, mBounds.getMinimum().z), - Ogre::Vector3(mSize/2*8192, mSize/2*8192, mBounds.getMaximum().z)); + mBounds = Ogre::AxisAlignedBox (Ogre::Vector3(-mSize/2*cellWorldSize, -mSize/2*cellWorldSize, mBounds.getMinimum().z), + Ogre::Vector3(mSize/2*cellWorldSize, mSize/2*cellWorldSize, mBounds.getMaximum().z)); } - mWorldBounds = Ogre::AxisAlignedBox(mBounds.getMinimum() + Ogre::Vector3(mCenter.x*8192, mCenter.y*8192, 0), - mBounds.getMaximum() + Ogre::Vector3(mCenter.x*8192, mCenter.y*8192, 0)); + mWorldBounds = Ogre::AxisAlignedBox(mBounds.getMinimum() + Ogre::Vector3(mCenter.x*cellWorldSize, mCenter.y*cellWorldSize, 0), + mBounds.getMaximum() + Ogre::Vector3(mCenter.x*cellWorldSize, mCenter.y*cellWorldSize, 0)); } void QuadTreeNode::setBoundingBox(const Ogre::AxisAlignedBox &box) diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index dac960fbb6..f4070393d7 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -113,9 +113,10 @@ namespace Terrain // We arrived at a leaf float minZ,maxZ; Ogre::Vector2 center = node->getCenter(); + float cellWorldSize = getStorage()->getCellWorldSize(); if (mStorage->getMinMaxHeights(node->getSize(), center, minZ, maxZ)) - node->setBoundingBox(Ogre::AxisAlignedBox(Ogre::Vector3(-halfSize*8192, -halfSize*8192, minZ), - Ogre::Vector3(halfSize*8192, halfSize*8192, maxZ))); + node->setBoundingBox(Ogre::AxisAlignedBox(Ogre::Vector3(-halfSize*cellWorldSize, -halfSize*cellWorldSize, minZ), + Ogre::Vector3(halfSize*cellWorldSize, halfSize*cellWorldSize, maxZ))); else node->markAsDummy(); // no data available for this node, skip it return; @@ -168,8 +169,9 @@ namespace Terrain return Ogre::AxisAlignedBox::BOX_NULL; QuadTreeNode* node = findNode(center, mRootNode); Ogre::AxisAlignedBox box = node->getBoundingBox(); - box.setExtents(box.getMinimum() + Ogre::Vector3(center.x, center.y, 0) * 8192, - box.getMaximum() + Ogre::Vector3(center.x, center.y, 0) * 8192); + float cellWorldSize = getStorage()->getCellWorldSize(); + box.setExtents(box.getMinimum() + Ogre::Vector3(center.x, center.y, 0) * cellWorldSize, + box.getMaximum() + Ogre::Vector3(center.x, center.y, 0) * cellWorldSize); return box; } From 4e6507248bf58e552f331e26fb3c5cc03fa55745 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 12:19:21 +0100 Subject: [PATCH 071/171] Fix travis build --- .travis.yml | 2 +- CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04d019c0d8..693db6f116 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ branches: - next before_install: - pwd - - git submodule update --init --recursive + - git fetch --tags - echo "yes" | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" - echo "yes" | sudo apt-add-repository ppa:openmw/openmw - sudo apt-get update -qq diff --git a/CMakeLists.txt b/CMakeLists.txt index 01ac9b23f3..6f209552cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ include(OpenMWMacros) include(GetGitRevisionDescription) -get_git_tag_revision(TAGHASH --tags --max-count=1) +get_git_tag_revision(TAGHASH --tags --max-count=1 "HEAD...") get_git_head_revision(REFSPEC COMMITHASH) git_describe(VERSION --tags ${TAGHASH}) From 0fcec24c9b02b9a5924907891f5fa34296f16c12 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 12:24:15 +0100 Subject: [PATCH 072/171] Remove some bogus dependencies for travis build --- .travis.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 693db6f116..bc60f3ca63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,17 +4,16 @@ compiler: branches: only: - master - - next before_install: - pwd - git fetch --tags - echo "yes" | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" - echo "yes" | sudo apt-add-repository ppa:openmw/openmw - sudo apt-get update -qq - - sudo apt-get install -qq libboost-all-dev libgtest-dev google-mock libzzip-dev uuid-dev - - sudo apt-get install -qq libqt4-dev libxaw7-dev libxrandr-dev libfreeimage-dev libpng-dev - - sudo apt-get install -qq libopenal-dev libmpg123-dev libsndfile1-dev - - sudo apt-get install -qq libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libswscale-dev libpostproc-dev + - sudo apt-get install -qq libboost-all-dev libgtest-dev google-mock + - sudo apt-get install -qq libqt4-dev + - sudo apt-get install -qq libopenal-dev + - sudo apt-get install -qq libavcodec-dev libavformat-dev libavutil-dev libswscale-dev - sudo apt-get install -qq libbullet-dev libogre-1.9-dev libmygui-dev libsdl2-dev libunshield-dev - sudo mkdir /usr/src/gtest/build - cd /usr/src/gtest/build From 1ed1b432961223122346d4ea0e4304d28a5d1578 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 12:30:53 +0100 Subject: [PATCH 073/171] Enable release branches in Travis CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bc60f3ca63..b7a5d61ad4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ compiler: branches: only: - master + - /openmw-.*$/ before_install: - pwd - git fetch --tags From ea90035eca1892a503666ab988eaba2eac0a3fb7 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 12:35:33 +0100 Subject: [PATCH 074/171] Enable irc notification for travis --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index b7a5d61ad4..39a02de63e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,3 +37,9 @@ notifications: email: on_success: change on_failure: always + irc: + channels: + - "chat.freenode.net#openmw" + on_success: change + on_failure: always + From 09d3c7a44659a4ca466d88124628791227287074 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 13:54:09 +0100 Subject: [PATCH 075/171] Attempt to match types. Does not work at the moment. --- apps/opencs/model/world/columnimp.hpp | 2 +- apps/opencs/model/world/idtable.cpp | 5 ----- apps/opencs/model/world/idtable.hpp | 3 --- apps/opencs/model/world/tablemimedata.cpp | 21 +++++++++++++-------- apps/opencs/model/world/tablemimedata.hpp | 6 +++--- apps/opencs/view/world/table.cpp | 19 ++++++++++++++++--- 6 files changed, 33 insertions(+), 23 deletions(-) diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 9e9bedcf87..def225018f 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -1485,7 +1485,7 @@ namespace CSMWorld template struct RaceColumn : public Column { - RaceColumn() : Column (Columns::ColumnId_Race, ColumnBase::Display_String) {} + RaceColumn() : Column (Columns::ColumnId_Race, ColumnBase::Display_Race) {} virtual QVariant get (const Record& record) const { diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index b509f6b9d5..bea307aa21 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -188,9 +188,4 @@ void CSMWorld::IdTable::reorderRows (int baseIndex, const std::vector& newO CSMWorld::IdTable::Reordering CSMWorld::IdTable::getReordering() const { return mReordering; -} - -CSMWorld::ColumnBase::Display CSMWorld::IdTable::getColumnDisplay (int index) const -{ - return mIdCollection->getColumn(index).mDisplayType; } \ No newline at end of file diff --git a/apps/opencs/model/world/idtable.hpp b/apps/opencs/model/world/idtable.hpp index aee49a961e..74923867d6 100644 --- a/apps/opencs/model/world/idtable.hpp +++ b/apps/opencs/model/world/idtable.hpp @@ -11,7 +11,6 @@ namespace CSMWorld { class CollectionBase; - class ColumnsBase; class RecordBase; class IdTable : public QAbstractItemModel @@ -87,8 +86,6 @@ namespace CSMWorld /// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex). Reordering getReordering() const; - - CSMWorld::ColumnBase::Display getColumnDisplay(int index) const; }; } diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 45305431e4..07c9999b98 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -3,6 +3,7 @@ #include "universalid.hpp" #include "columnbase.hpp" +#include CSMWorld::TableMimeData::TableMimeData (UniversalId id) { @@ -76,8 +77,9 @@ bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const return false; } -bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) +bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) const { + std::cout<::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) { if (it->getType() == convertEnums (type)) @@ -102,7 +104,7 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::Univers throw ("TableMimeData object does not hold object of the seeked type"); } -CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) +CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) const { for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) { @@ -115,15 +117,10 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnB throw ("TableMimeData object does not hold object of the seeked type"); } -CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) +CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) const { switch (type) { - default: - throw ("This type is not handled"); - return CSMWorld::UniversalId::Type_None; - break; - case CSMWorld::ColumnBase::Display_Race: return CSMWorld::UniversalId::Type_Race; break; @@ -271,6 +268,14 @@ CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::Col case CSMWorld::ColumnBase::Display_Scene: return CSMWorld::UniversalId::Type_Scene; break; + + case CSMWorld::ColumnBase::Display_Script: + return CSMWorld::UniversalId::Type_Script; + break; + + default: + return CSMWorld::UniversalId::Type_None; + break; } } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index d2e5d3ecb0..1b6c5e635e 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -25,15 +25,15 @@ namespace CSMWorld std::string getIcon() const; std::vector getData() const; bool holdsType(UniversalId::Type type) const; - bool holdsType(CSMWorld::ColumnBase::Display type); + bool holdsType(CSMWorld::ColumnBase::Display type) const; UniversalId returnMatching(UniversalId::Type type) const; - UniversalId returnMatching(CSMWorld::ColumnBase::Display type); + UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const; private: std::vector mUniversalId; QStringList mObjectsFormats; - CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type); + CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const; }; } #endif // TABLEMIMEDATA_H diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index c39ed34690..bfd58fb864 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -17,6 +17,8 @@ #include "recordstatusdelegate.hpp" #include "util.hpp" +#include +#include "../../model/world/tablemimedata.hpp" void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) { @@ -475,13 +477,24 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) { - event->acceptProposedAction(); +// QModelIndex index = indexAt (event->pos()); + +// if (dynamic_cast (event->mimeData())->holdsType (mModel->getColumnDisplay (index.column()))) +// { + event->acceptProposedAction(); +// } } void CSVWorld::Table::dropEvent(QDropEvent *event) { - event->acceptProposedAction(); - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt (event->pos()); + + CSMWorld::ColumnBase::Display display = static_cast(mModel->headerData(index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + if (dynamic_cast(event->mimeData())->holdsType(display)) + { + event->acceptProposedAction(); + std::cout<<"Dropped/n"; + } else {std::cout<<"Not Dropped\n";} } void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) From 309573a3ac01f38fe27ce3a3d00b2e0e90187814 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 14:15:48 +0100 Subject: [PATCH 076/171] allow the use of the keyword end as a variable name in an expression --- components/compiler/exprparser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 07f576006f..474de856a4 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -355,6 +355,11 @@ namespace Compiler } } + if (keyword==Scanner::K_end) + { + return parseName (loc.mLiteral, loc, scanner); + } + mFirst = false; if (!mExplicit.empty()) From e9238b456d8e830421b140f0bdb60552144ab2a2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 15:01:10 +0100 Subject: [PATCH 077/171] use case-insensitive sorting in columns --- apps/opencs/model/world/idtableproxymodel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index 2b757adfe5..f51b7f818f 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -33,7 +33,9 @@ bool CSMWorld::IdTableProxyModel::filterAcceptsRow (int sourceRow, const QModelI CSMWorld::IdTableProxyModel::IdTableProxyModel (QObject *parent) : QSortFilterProxyModel (parent) -{} +{ + setSortCaseSensitivity (Qt::CaseInsensitive); +} QModelIndex CSMWorld::IdTableProxyModel::getModelIndex (const std::string& id, int column) const { From f7ff4fbd51178825a1199ae4b5a5b7cabc765e16 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Feb 2014 15:31:07 +0100 Subject: [PATCH 078/171] allow disable as an alias for getDisabled (in most cases) --- components/compiler/exprparser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 474de856a4..6b451292a9 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -366,7 +366,8 @@ namespace Compiler { if (mRefOp && mNextOperand) { - if (keyword==Scanner::K_getdisabled) + if (keyword==Scanner::K_getdisabled || + keyword==Scanner::K_disable) /// \todo add option to disable this { start(); @@ -509,7 +510,8 @@ namespace Compiler mNextOperand = false; return true; } - else if (keyword==Scanner::K_getdisabled) + else if (keyword==Scanner::K_getdisabled || + keyword==Scanner::K_disable) /// \todo add option to disable this { start(); From 6662560cbca7d892dd774da29f5fcf067222a379 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 15:43:19 +0100 Subject: [PATCH 079/171] new displays for referencable table columns --- apps/opencs/model/world/refidcollection.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 8a1af35092..89a917139b 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -59,7 +59,7 @@ CSMWorld::RefIdCollection::RefIdCollection() mColumns.push_back (RefIdColumn (Columns::ColumnId_Name, ColumnBase::Display_String)); nameColumns.mName = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Script, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Script, ColumnBase::Display_Script)); nameColumns.mScript = &mColumns.back(); InventoryColumns inventoryColumns (nameColumns); @@ -214,10 +214,10 @@ CSMWorld::RefIdCollection::RefIdCollection() creatureColumns.mFlags.insert (std::make_pair (respawn, ESM::Creature::Respawn)); - mColumns.push_back (RefIdColumn (Columns::ColumnId_OpenSound, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_OpenSound, ColumnBase::Display_Sound)); const RefIdColumn *openSound = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_CloseSound, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_CloseSound, ColumnBase::Display_Sound)); const RefIdColumn *closeSound = &mColumns.back(); LightColumns lightColumns (inventoryColumns); @@ -231,7 +231,7 @@ CSMWorld::RefIdCollection::RefIdCollection() mColumns.push_back (RefIdColumn (Columns::ColumnId_Colour, ColumnBase::Display_Integer)); lightColumns.mColor = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Sound, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Sound, ColumnBase::Display_Sound)); lightColumns.mSound = &mColumns.back(); static const struct @@ -263,13 +263,13 @@ CSMWorld::RefIdCollection::RefIdCollection() NpcColumns npcColumns (actorsColumns); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Race, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Race, ColumnBase::Display_Race)); npcColumns.mRace = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Class, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Class, ColumnBase::Display_Class)); npcColumns.mClass = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Faction, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Faction, ColumnBase::Display_Faction)); npcColumns.mFaction = &mColumns.back(); mColumns.push_back (RefIdColumn (Columns::Columnid_Hair, ColumnBase::Display_String)); From 2afe3f3e5735bb369826e2ad8542dc661f47ae24 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 19:00:35 +0100 Subject: [PATCH 080/171] Introduced multitype icon. --- apps/opencs/model/world/tablemimedata.cpp | 2 -- apps/opencs/view/world/genericcreator.cpp | 4 ++-- apps/opencs/view/world/table.cpp | 22 ++++++++++++---------- files/opencs/multitype.png | Bin 0 -> 1708 bytes files/opencs/resources.qrc | 1 + 5 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 files/opencs/multitype.png diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 07c9999b98..87bd67ce91 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -3,7 +3,6 @@ #include "universalid.hpp" #include "columnbase.hpp" -#include CSMWorld::TableMimeData::TableMimeData (UniversalId id) { @@ -79,7 +78,6 @@ bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) const { - std::cout<::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) { if (it->getType() == convertEnums (type)) diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index cd7a5fa189..31c216e2cb 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -133,9 +133,9 @@ void CSVWorld::GenericCreator::create() std::string id = getId(); std::auto_ptr command (new CSMWorld::CloneCommand ( dynamic_cast (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); - + mUndoStack.push(command.release()); - + emit done(); emit requestFocus(id); } else { diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index bfd58fb864..48b5339924 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "../../model/world/data.hpp" #include "../../model/world/commands.hpp" @@ -477,27 +478,28 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) { -// QModelIndex index = indexAt (event->pos()); - -// if (dynamic_cast (event->mimeData())->holdsType (mModel->getColumnDisplay (index.column()))) -// { event->acceptProposedAction(); -// } } void CSVWorld::Table::dropEvent(QDropEvent *event) { QModelIndex index = indexAt (event->pos()); - CSMWorld::ColumnBase::Display display = static_cast(mModel->headerData(index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + CSMWorld::ColumnBase::Display display = static_cast + (mModel->headerData(index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + if (dynamic_cast(event->mimeData())->holdsType(display)) { - event->acceptProposedAction(); - std::cout<<"Dropped/n"; - } else {std::cout<<"Not Dropped\n";} + const CSMWorld::TableMimeData* mime = dynamic_cast(event->mimeData()); + CSMWorld::UniversalId record(mime->returnMatching(display)); + mUndoStack.push (new CSMWorld::ModifyCommand ( *mModel, + index, + QVariant(record.getId().c_str()) + )); + } } void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) { - event->accept(); + event->accept(); } diff --git a/files/opencs/multitype.png b/files/opencs/multitype.png new file mode 100644 index 0000000000000000000000000000000000000000..05676e2de06f52ed563842c0d8d5fe888e771a70 GIT binary patch literal 1708 zcmV;d22=ToP)Ekc{Xm)1$i(h%(W|y+oEr<7?dfwtd#j#`W=aP>d z{Klc7H5<=7{e+;hy*X@yKVZUq?i4 zwO3e@!G|P^!(or}?!k~`kEAO{$F}cz#3sg{3&0P1(d=|*h1f=?&#>o%AFaH$e$%&( zCcpYbeo!8L>X@CoEdYlP$VMk_e_E;SmyycuyWV|&ckAwbwN+#9acONB=QAe%`g85g zH&E@iod6;bn-{oqZ9N@%@ZheOe*Kfv-#ZvS|D|L3b4wE8w?86b)mZh-T_4^*G%~g$ zYpfX~Bq?T~8c|g$Bb#~Y@B^Is*HscP?7XYa=6&BGojHTWoS3(ZU(D&M1C7<|2DaS${;V-n#adHzn{ShMW>FI)Q~}3ey~f9%Ji_B&dzPWK zTZmWA5(YOQJ|NB^;t?Qdi|sq#n|cZRmn6b8Ngv;K--l|2#|kb1pCO@A7*DDgAeu8f z^-tQD|IXUGKfvTGFYw0rPl>*cq_qNsbBH(^!-K(v{_7~09e%z5%qC6DP1+f;|v)6^AAy?KhWT4UYl2y54^&(gnT2X6_$JOAlM zqY+M>_!B2zyF^81@e)xSleP&p2O_Mh3{a5_!=VIBk|G(47@`O&fp%EUwdr>_e(D?# z@7+z_?e2c&A<3S4!P*Pd0b5n8X576Y<({$4xFkh`+!8k(t3f2FBiuD-Sav3;*upcBMI}oUzpb00mn@`^GyL18u-r*S=7+t zfR-MD|0e#6fK%<<`a~om0t!CNqd(3QWSnrDo zP6WmEW+KjEIE)goD41YkD2k~s!)Il&fMy3LB4TD1ZuB09h&Z1i&f_DP12I9=VNSs! z4#Pw+bAY1iu7|DY;g~nX6y}ImPym_jTxUMa^FCmRgcK2nx&pB?K}$ZwT;Yi*Vg{y& z7>Xh0vEp!69?}fM3h|lt1O85n(BpJIfPSKi^GIpb6uei=9EO#Ki_Iy|1me zH!ISwq&|qlK(4k(04E{^fRcUzQbPpI5pg&dzzp$L9K}S6%?yfuXGn>mXT+h!6tf~6 zW_`su?=eHJG^vyc5a%-Bfr=Rp%jshhK?Iz+UZcPSyjmZSi2yoBt%{j|7;~`Uo$qNN zEA8cBUP>nIs1`d-sv}!5F)YSDomea@RV+iHn3maMiii?b3bCnTQnW}ZQ#y89#2Ed= zH0@pq2sidYy1#ohKjVM!-5uA7TfQL}uU_XFlKfBGWrvVStfP3p1E6w$lx?ICV zh*z6j0Zs!`K;HjjA|kE?k(A6VKLv%?InV_nVE+cordT0F3*6fP0000spell.png static.png weapon.png + multitype.png raster/startup/big/create-addon.png raster/startup/big/new-game.png raster/startup/big/edit-content.png From 1bcc6d6918e323834552d68c8e4023908e4566d2 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 19:14:17 +0100 Subject: [PATCH 081/171] using new icon. --- apps/opencs/model/world/tablemimedata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 87bd67ce91..b0cf0abcc2 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -49,7 +49,7 @@ std::string CSMWorld::TableMimeData::getIcon() const if (tmpIcon != mUniversalId[i].getIcon()) { - return ""; //should return multiple types icon, but at the moment we don't have one + return ":/multitype.png"; //icon stolen from gnome } tmpIcon = mUniversalId[i].getIcon(); From 40cc108e54e09ddee979c9296637c592d6c800a7 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 20:19:51 +0100 Subject: [PATCH 082/171] drag and drop works. --- apps/opencs/view/world/table.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 48b5339924..4d5554d863 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -490,12 +490,11 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) if (dynamic_cast(event->mimeData())->holdsType(display)) { - const CSMWorld::TableMimeData* mime = dynamic_cast(event->mimeData()); - CSMWorld::UniversalId record(mime->returnMatching(display)); - mUndoStack.push (new CSMWorld::ModifyCommand ( *mModel, - index, - QVariant(record.getId().c_str()) - )); + const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + CSMWorld::UniversalId record (mime->returnMatching (display)); + std::auto_ptr command (new CSMWorld::ModifyCommand + (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + mUndoStack.push (command.release()); } } From e597328b6b6ae483f69adcc4878ca3ff92c0f50f Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Thu, 13 Feb 2014 20:24:27 +0100 Subject: [PATCH 083/171] Make enable/disable a no-op for items in containers --- apps/openmw/mwworld/worldimp.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 4e240195ad..95bf65d088 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -610,6 +610,10 @@ namespace MWWorld void World::enable (const Ptr& reference) { + // enable is a no-op for items in containers + if (!reference.isInCell()) + return; + if (!reference.getRefData().isEnabled()) { reference.getRefData().enable(); @@ -640,6 +644,10 @@ namespace MWWorld void World::disable (const Ptr& reference) { + // disable is a no-op for items in containers + if (!reference.isInCell()) + return; + if (reference.getRefData().isEnabled()) { reference.getRefData().disable(); From 7c981587fca5b2671dd59e9cf9b6b2ccdcf83627 Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Thu, 13 Feb 2014 22:58:12 +0100 Subject: [PATCH 084/171] When searching object by id, search in active cells before searching in the player's inventory --- apps/openmw/mwworld/worldimp.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 95bf65d088..be6c0b338f 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -529,12 +529,6 @@ namespace MWWorld return mPlayer->getPlayer(); } - Ptr ptr = Class::get (mPlayer->getPlayer()). - getContainerStore (mPlayer->getPlayer()).search (name); - - if (!ptr.isEmpty()) - return ptr; - std::string lowerCaseName = Misc::StringUtils::lowerCase(name); // active cells @@ -548,6 +542,12 @@ namespace MWWorld return ptr; } + Ptr ptr = Class::get (mPlayer->getPlayer()). + getContainerStore (mPlayer->getPlayer()).search (lowerCaseName); + + if (!ptr.isEmpty()) + return ptr; + if (!activeOnly) { ret = mCells.getPtr (lowerCaseName); From b01c6dad375375864f5b667b9d31ce8b310ff482 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 08:29:18 +0100 Subject: [PATCH 085/171] Revert "allow disable as an alias for getDisabled (in most cases)" This reverts commit f7ff4fbd51178825a1199ae4b5a5b7cabc765e16. --- components/compiler/exprparser.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 6b451292a9..474de856a4 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -366,8 +366,7 @@ namespace Compiler { if (mRefOp && mNextOperand) { - if (keyword==Scanner::K_getdisabled || - keyword==Scanner::K_disable) /// \todo add option to disable this + if (keyword==Scanner::K_getdisabled) { start(); @@ -510,8 +509,7 @@ namespace Compiler mNextOperand = false; return true; } - else if (keyword==Scanner::K_getdisabled || - keyword==Scanner::K_disable) /// \todo add option to disable this + else if (keyword==Scanner::K_getdisabled) { start(); From 2086ebe4104a00d00ede72c174138640a43948fa Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 08:48:26 +0100 Subject: [PATCH 086/171] fix for inappropriate disable (2nd attempt) --- components/compiler/exprparser.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 474de856a4..7d310617ce 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -355,7 +355,16 @@ namespace Compiler } } - if (keyword==Scanner::K_end) + if (keyword==Scanner::K_end || keyword==Scanner::K_begin || + keyword==Scanner::K_short || keyword==Scanner::K_long || + keyword==Scanner::K_float || keyword==Scanner::K_if || + keyword==Scanner::K_endif || keyword==Scanner::K_else || + keyword==Scanner::K_elseif || keyword==Scanner::K_while || + keyword==Scanner::K_endwhile || keyword==Scanner::K_return || + keyword==Scanner::K_messagebox || keyword==Scanner::K_set || + keyword==Scanner::K_to || keyword==Scanner::K_startscript || + keyword==Scanner::K_stopscript || keyword==Scanner::K_enable || + keyword==Scanner::K_disable) { return parseName (loc.mLiteral, loc, scanner); } From e76ef9266995a83fad40f3ebc2b74a54d5d6ff17 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 09:06:06 +0100 Subject: [PATCH 087/171] also allow the use of keywords as remote local variables in set statements --- components/compiler/lineparser.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 495e7e25e5..b1956e6283 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -219,6 +219,20 @@ namespace Compiler bool LineParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) { + if (mState==SetMemberVarState) + { + mMemberName = loc.mLiteral; + std::pair type = getContext().getMemberType (mMemberName, mName); + + if (type.first!=' ') + { + mState = SetMemberVarState2; + mType = type.first; + mReferenceMember = type.second; + return true; + } + } + if (mState==SetPotentialMemberVarState && keyword==Scanner::K_to) { getErrorHandler().warning ("unknown variable (ignoring set instruction)", loc); From 451e1f413ba33170ba01e96788443a51b1c5a113 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 11:15:16 +0100 Subject: [PATCH 088/171] instead of using pre-compiled variable lists for remote member access get the variable list from the remote script on the fly --- apps/openmw/mwscript/scriptmanagerimp.cpp | 17 +++----- components/CMakeLists.txt | 1 + components/compiler/declarationparser.cpp | 5 +++ components/compiler/declarationparser.hpp | 2 + components/compiler/quickfileparser.cpp | 52 +++++++++++++++++++++++ components/compiler/quickfileparser.hpp | 39 +++++++++++++++++ 6 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 components/compiler/quickfileparser.cpp create mode 100644 components/compiler/quickfileparser.hpp diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 5e18151da4..74c85dbbf7 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include "../mwworld/esmstore.hpp" @@ -159,20 +160,14 @@ namespace MWScript return iter->second; } - Compiler::Locals locals; - if (const ESM::Script *script = mStore.get().find (name2)) { - int index = 0; + Compiler::Locals locals; - for (int i=0; imData.mNumShorts; ++i) - locals.declare ('s', script->mVarNames[index++]); - - for (int i=0; imData.mNumLongs; ++i) - locals.declare ('l', script->mVarNames[index++]); - - for (int i=0; imData.mNumFloats; ++i) - locals.declare ('f', script->mVarNames[index++]); + std::istringstream stream (script->mScriptText); + Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals); + Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions()); + scanner.scan (parser); std::map::iterator iter = mOtherLocals.insert (std::make_pair (name2, locals)).first; diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index fbe9ad5bd3..45a91f368c 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -60,6 +60,7 @@ add_component_dir (compiler context controlparser errorhandler exception exprparser extensions fileparser generator lineparser literals locals output parser scanner scriptparser skipparser streamerrorhandler stringparser tokenloc nullerrorhandler opcodes extensions0 declarationparser + quickfileparser ) add_component_dir (interpreter diff --git a/components/compiler/declarationparser.cpp b/components/compiler/declarationparser.cpp index 9c4e4f631b..357f0259be 100644 --- a/components/compiler/declarationparser.cpp +++ b/components/compiler/declarationparser.cpp @@ -75,4 +75,9 @@ bool Compiler::DeclarationParser::parseSpecial (int code, const TokenLoc& loc, S return false; return Parser::parseSpecial (code, loc, scanner); +} + +void Compiler::DeclarationParser::reset() +{ + mState = State_Begin; } \ No newline at end of file diff --git a/components/compiler/declarationparser.hpp b/components/compiler/declarationparser.hpp index 3e0ac57c34..f85b31ba15 100644 --- a/components/compiler/declarationparser.hpp +++ b/components/compiler/declarationparser.hpp @@ -35,6 +35,8 @@ namespace Compiler ///< Handle a special character token. /// \return fetch another token? + void reset(); + }; } diff --git a/components/compiler/quickfileparser.cpp b/components/compiler/quickfileparser.cpp new file mode 100644 index 0000000000..157e152490 --- /dev/null +++ b/components/compiler/quickfileparser.cpp @@ -0,0 +1,52 @@ + +#include "quickfileparser.hpp" + +#include "skipparser.hpp" +#include "scanner.hpp" + +Compiler::QuickFileParser::QuickFileParser (ErrorHandler& errorHandler, Context& context, + Locals& locals) +: Parser (errorHandler, context), mDeclarationParser (errorHandler, context, locals) +{} + +bool Compiler::QuickFileParser::parseName (const std::string& name, const TokenLoc& loc, + Scanner& scanner) +{ + SkipParser skip (getErrorHandler(), getContext()); + scanner.scan (skip); + return true; +} + +bool Compiler::QuickFileParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) +{ + if (keyword==Scanner::K_end) + return false; + + if (keyword==Scanner::K_short || keyword==Scanner::K_long || keyword==Scanner::K_float) + { + mDeclarationParser.reset(); + scanner.putbackKeyword (keyword, loc); + scanner.scan (mDeclarationParser); + return true; + } + + SkipParser skip (getErrorHandler(), getContext()); + scanner.scan (skip); + return true; +} + +bool Compiler::QuickFileParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner) +{ + if (code!=Scanner::S_newline) + { + SkipParser skip (getErrorHandler(), getContext()); + scanner.scan (skip); + } + + return true; +} + +void Compiler::QuickFileParser::parseEOF (Scanner& scanner) +{ + +} \ No newline at end of file diff --git a/components/compiler/quickfileparser.hpp b/components/compiler/quickfileparser.hpp new file mode 100644 index 0000000000..d2dfafb346 --- /dev/null +++ b/components/compiler/quickfileparser.hpp @@ -0,0 +1,39 @@ +#ifndef COMPILER_QUICKFILEPARSER_H_INCLUDED +#define COMPILER_QUICKFILEPARSER_H_INCLUDED + +#include "parser.hpp" +#include "declarationparser.hpp" + +namespace Compiler +{ + class Locals; + + /// \brief File parser variant that ignores everything but variable declarations + class QuickFileParser : public Parser + { + DeclarationParser mDeclarationParser; + + public: + + QuickFileParser (ErrorHandler& errorHandler, Context& context, Locals& locals); + + virtual bool parseName (const std::string& name, const TokenLoc& loc, + Scanner& scanner); + ///< Handle a name token. + /// \return fetch another token? + + virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner); + ///< Handle a keyword token. + /// \return fetch another token? + + virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner); + ///< Handle a special character token. + /// \return fetch another token? + + virtual void parseEOF (Scanner& scanner); + ///< Handle EOF token. + }; +} + +#endif + From 910d62e4b84e701e4da58ac83e0d882804eb6c6f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 11:59:33 +0100 Subject: [PATCH 089/171] added missing implementation for CSMWorld::ScriptContext::getGlobalType --- apps/opencs/model/world/scriptcontext.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index 1b30281595..2627c49f3e 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -16,6 +16,20 @@ bool CSMWorld::ScriptContext::canDeclareLocals() const char CSMWorld::ScriptContext::getGlobalType (const std::string& name) const { + int index = mData.getGlobals().searchId (name); + + if (index!=-1) + { + switch (mData.getGlobals().getRecord (index).get().mValue.getType()) + { + case ESM::VT_Short: return 's'; + case ESM::VT_Long: return 'l'; + case ESM::VT_Float: return 'f'; + + default: return ' '; + } + } + return ' '; } From d213c6c36a48f3435e1b42aa9d4101eb0618ebc0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 12:23:00 +0100 Subject: [PATCH 090/171] fixed a constness-issue --- components/compiler/controlparser.cpp | 2 +- components/compiler/controlparser.hpp | 2 +- components/compiler/declarationparser.cpp | 2 +- components/compiler/declarationparser.hpp | 2 +- components/compiler/exprparser.cpp | 2 +- components/compiler/exprparser.hpp | 2 +- components/compiler/lineparser.cpp | 2 +- components/compiler/lineparser.hpp | 2 +- components/compiler/parser.cpp | 4 ++-- components/compiler/parser.hpp | 6 +++--- components/compiler/quickfileparser.cpp | 2 +- components/compiler/quickfileparser.hpp | 2 +- components/compiler/scriptparser.cpp | 2 +- components/compiler/scriptparser.hpp | 14 +++++++------- components/compiler/skipparser.cpp | 4 ++-- components/compiler/skipparser.hpp | 8 ++++---- components/compiler/stringparser.cpp | 2 +- components/compiler/stringparser.hpp | 18 +++++++++--------- 18 files changed, 39 insertions(+), 39 deletions(-) diff --git a/components/compiler/controlparser.cpp b/components/compiler/controlparser.cpp index 499358ca02..58542bd739 100644 --- a/components/compiler/controlparser.cpp +++ b/components/compiler/controlparser.cpp @@ -154,7 +154,7 @@ namespace Compiler } } - ControlParser::ControlParser (ErrorHandler& errorHandler, Context& context, Locals& locals, + ControlParser::ControlParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, Literals& literals) : Parser (errorHandler, context), mLocals (locals), mLiterals (literals), mLineParser (errorHandler, context, locals, literals, mCodeBlock), diff --git a/components/compiler/controlparser.hpp b/components/compiler/controlparser.hpp index 50fd2d1f9e..24bc7bec75 100644 --- a/components/compiler/controlparser.hpp +++ b/components/compiler/controlparser.hpp @@ -47,7 +47,7 @@ namespace Compiler public: - ControlParser (ErrorHandler& errorHandler, Context& context, Locals& locals, + ControlParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, Literals& literals); void appendCode (std::vector& code) const; diff --git a/components/compiler/declarationparser.cpp b/components/compiler/declarationparser.cpp index 357f0259be..d17f49caf0 100644 --- a/components/compiler/declarationparser.cpp +++ b/components/compiler/declarationparser.cpp @@ -8,7 +8,7 @@ #include "skipparser.hpp" #include "locals.hpp" -Compiler::DeclarationParser::DeclarationParser (ErrorHandler& errorHandler, Context& context, +Compiler::DeclarationParser::DeclarationParser (ErrorHandler& errorHandler, const Context& context, Locals& locals) : Parser (errorHandler, context), mLocals (locals), mState (State_Begin), mType (0) {} diff --git a/components/compiler/declarationparser.hpp b/components/compiler/declarationparser.hpp index f85b31ba15..43dd835705 100644 --- a/components/compiler/declarationparser.hpp +++ b/components/compiler/declarationparser.hpp @@ -20,7 +20,7 @@ namespace Compiler public: - DeclarationParser (ErrorHandler& errorHandler, Context& context, Locals& locals); + DeclarationParser (ErrorHandler& errorHandler, const Context& context, Locals& locals); virtual bool parseName (const std::string& name, const TokenLoc& loc, Scanner& scanner); diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 7d310617ce..6d26ef403c 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -219,7 +219,7 @@ namespace Compiler return false; } - ExprParser::ExprParser (ErrorHandler& errorHandler, Context& context, Locals& locals, + ExprParser::ExprParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, Literals& literals, bool argument) : Parser (errorHandler, context), mLocals (locals), mLiterals (literals), mNextOperand (true), mFirst (true), mArgument (argument), mRefOp (false), mMemberOp (false) diff --git a/components/compiler/exprparser.hpp b/components/compiler/exprparser.hpp index 905f0d454f..6a4e1be2ff 100644 --- a/components/compiler/exprparser.hpp +++ b/components/compiler/exprparser.hpp @@ -58,7 +58,7 @@ namespace Compiler public: - ExprParser (ErrorHandler& errorHandler, Context& context, Locals& locals, + ExprParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, Literals& literals, bool argument = false); ///< constructor /// \param argument Parser is used to parse function- or instruction- diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index b1956e6283..5457d76255 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -50,7 +50,7 @@ namespace Compiler } } - LineParser::LineParser (ErrorHandler& errorHandler, Context& context, Locals& locals, + LineParser::LineParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, Literals& literals, std::vector& code, bool allowExpression) : Parser (errorHandler, context), mLocals (locals), mLiterals (literals), mCode (code), mState (BeginState), mExprParser (errorHandler, context, locals, literals), diff --git a/components/compiler/lineparser.hpp b/components/compiler/lineparser.hpp index c54c764bce..4f2d33bde5 100644 --- a/components/compiler/lineparser.hpp +++ b/components/compiler/lineparser.hpp @@ -44,7 +44,7 @@ namespace Compiler public: - LineParser (ErrorHandler& errorHandler, Context& context, Locals& locals, + LineParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, Literals& literals, std::vector& code, bool allowExpression = false); ///< \param allowExpression Allow lines consisting of a naked expression diff --git a/components/compiler/parser.cpp b/components/compiler/parser.cpp index 8d11c4086d..781fbad8cb 100644 --- a/components/compiler/parser.cpp +++ b/components/compiler/parser.cpp @@ -52,7 +52,7 @@ namespace Compiler // Return context - Context& Parser::getContext() + const Context& Parser::getContext() const { return mContext; } @@ -64,7 +64,7 @@ namespace Compiler return lowerCase; } - Parser::Parser (ErrorHandler& errorHandler, Context& context) + Parser::Parser (ErrorHandler& errorHandler, const Context& context) : mErrorHandler (errorHandler), mContext (context), mOptional (false), mEmpty (true) {} diff --git a/components/compiler/parser.hpp b/components/compiler/parser.hpp index 4fec570e9f..54e913b202 100644 --- a/components/compiler/parser.hpp +++ b/components/compiler/parser.hpp @@ -17,7 +17,7 @@ namespace Compiler class Parser { ErrorHandler& mErrorHandler; - Context& mContext; + const Context& mContext; bool mOptional; bool mEmpty; @@ -38,14 +38,14 @@ namespace Compiler ErrorHandler& getErrorHandler(); ///< Return error handler - Context& getContext(); + const Context& getContext() const; ///< Return context static std::string toLower (const std::string& name); public: - Parser (ErrorHandler& errorHandler, Context& context); + Parser (ErrorHandler& errorHandler, const Context& context); ///< constructor virtual ~Parser(); diff --git a/components/compiler/quickfileparser.cpp b/components/compiler/quickfileparser.cpp index 157e152490..f3d8063b2f 100644 --- a/components/compiler/quickfileparser.cpp +++ b/components/compiler/quickfileparser.cpp @@ -4,7 +4,7 @@ #include "skipparser.hpp" #include "scanner.hpp" -Compiler::QuickFileParser::QuickFileParser (ErrorHandler& errorHandler, Context& context, +Compiler::QuickFileParser::QuickFileParser (ErrorHandler& errorHandler, const Context& context, Locals& locals) : Parser (errorHandler, context), mDeclarationParser (errorHandler, context, locals) {} diff --git a/components/compiler/quickfileparser.hpp b/components/compiler/quickfileparser.hpp index d2dfafb346..440d910387 100644 --- a/components/compiler/quickfileparser.hpp +++ b/components/compiler/quickfileparser.hpp @@ -15,7 +15,7 @@ namespace Compiler public: - QuickFileParser (ErrorHandler& errorHandler, Context& context, Locals& locals); + QuickFileParser (ErrorHandler& errorHandler, const Context& context, Locals& locals); virtual bool parseName (const std::string& name, const TokenLoc& loc, Scanner& scanner); diff --git a/components/compiler/scriptparser.cpp b/components/compiler/scriptparser.cpp index f34313969a..ea11be5f03 100644 --- a/components/compiler/scriptparser.cpp +++ b/components/compiler/scriptparser.cpp @@ -7,7 +7,7 @@ namespace Compiler { - ScriptParser::ScriptParser (ErrorHandler& errorHandler, Context& context, + ScriptParser::ScriptParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, bool end) : Parser (errorHandler, context), mOutput (locals), mLineParser (errorHandler, context, locals, mOutput.getLiterals(), mOutput.getCode()), diff --git a/components/compiler/scriptparser.hpp b/components/compiler/scriptparser.hpp index bb4809dabd..000244c793 100644 --- a/components/compiler/scriptparser.hpp +++ b/components/compiler/scriptparser.hpp @@ -12,7 +12,7 @@ namespace Compiler class Locals; // Script parser, to be used in dialogue scripts and as part of FileParser - + class ScriptParser : public Parser { Output mOutput; @@ -21,14 +21,14 @@ namespace Compiler bool mEnd; public: - + /// \param end of script is marked by end keyword. - ScriptParser (ErrorHandler& errorHandler, Context& context, Locals& locals, + ScriptParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, bool end = false); - + void getCode (std::vector& code) const; ///< store generated code in \Ʀ code. - + virtual bool parseName (const std::string& name, const TokenLoc& loc, Scanner& scanner); ///< Handle a name token. @@ -43,8 +43,8 @@ namespace Compiler /// \return fetch another token? virtual void parseEOF (Scanner& scanner); - ///< Handle EOF token. - + ///< Handle EOF token. + void reset(); ///< Reset parser to clean state. }; diff --git a/components/compiler/skipparser.cpp b/components/compiler/skipparser.cpp index 2d09b63ba0..c7cb31f58e 100644 --- a/components/compiler/skipparser.cpp +++ b/components/compiler/skipparser.cpp @@ -5,7 +5,7 @@ namespace Compiler { - SkipParser::SkipParser (ErrorHandler& errorHandler, Context& context) + SkipParser::SkipParser (ErrorHandler& errorHandler, const Context& context) : Parser (errorHandler, context) {} @@ -34,7 +34,7 @@ namespace Compiler { if (code==Scanner::S_newline) return false; - + return true; } } diff --git a/components/compiler/skipparser.hpp b/components/compiler/skipparser.hpp index 17f1c8d988..239c8bb02c 100644 --- a/components/compiler/skipparser.hpp +++ b/components/compiler/skipparser.hpp @@ -8,13 +8,13 @@ namespace Compiler // \brief Skip parser for skipping a line // // This parser is mainly intended for skipping the rest of a faulty line. - + class SkipParser : public Parser { public: - - SkipParser (ErrorHandler& errorHandler, Context& context); - + + SkipParser (ErrorHandler& errorHandler, const Context& context); + virtual bool parseInt (int value, const TokenLoc& loc, Scanner& scanner); ///< Handle an int token. /// \return fetch another token? diff --git a/components/compiler/stringparser.cpp b/components/compiler/stringparser.cpp index 09c902131a..a86c15794f 100644 --- a/components/compiler/stringparser.cpp +++ b/components/compiler/stringparser.cpp @@ -10,7 +10,7 @@ namespace Compiler { - StringParser::StringParser (ErrorHandler& errorHandler, Context& context, Literals& literals) + StringParser::StringParser (ErrorHandler& errorHandler, const Context& context, Literals& literals) : Parser (errorHandler, context), mLiterals (literals), mState (StartState), mSmashCase (false) { diff --git a/components/compiler/stringparser.hpp b/components/compiler/stringparser.hpp index f692c650b8..3859a24965 100644 --- a/components/compiler/stringparser.hpp +++ b/components/compiler/stringparser.hpp @@ -10,22 +10,22 @@ namespace Compiler { class Literals; - + class StringParser : public Parser { enum State { StartState, CommaState }; - + Literals& mLiterals; State mState; std::vector mCode; bool mSmashCase; - + public: - - StringParser (ErrorHandler& errorHandler, Context& context, Literals& literals); + + StringParser (ErrorHandler& errorHandler, const Context& context, Literals& literals); virtual bool parseName (const std::string& name, const TokenLoc& loc, Scanner& scanner); @@ -35,15 +35,15 @@ namespace Compiler virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner); ///< Handle a special character token. /// \return fetch another token? - + void append (std::vector& code); ///< Append code for parsed string. - + void smashCase(); ///< Transform all scanned strings to lower case - + void reset(); - ///< Reset parser to clean state (this includes the smashCase function). + ///< Reset parser to clean state (this includes the smashCase function). }; } From ace42520138b4d8280fab3a0f421b4d8d806bf57 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 14 Feb 2014 12:46:15 +0100 Subject: [PATCH 091/171] nicer formatting --- apps/opencs/view/world/table.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 4d5554d863..32d692be64 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -490,10 +490,14 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) if (dynamic_cast(event->mimeData())->holdsType(display)) { - const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + const CSMWorld::TableMimeData* mime = dynamic_cast + (event->mimeData()); + CSMWorld::UniversalId record (mime->returnMatching (display)); + std::auto_ptr command (new CSMWorld::ModifyCommand (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + mUndoStack.push (command.release()); } } From 0a8ffbfb1d67080b1e22b0f7756794fa6134b94c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 12:46:54 +0100 Subject: [PATCH 092/171] added missing implementation for CSMWorld::ScriptContext::getMemberType --- apps/opencs/model/world/scriptcontext.cpp | 56 ++++++++++++++++++++++- apps/opencs/model/world/scriptcontext.hpp | 3 ++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index 2627c49f3e..ee95f06c86 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -5,6 +5,10 @@ #include +#include +#include +#include + #include "data.hpp" CSMWorld::ScriptContext::ScriptContext (const Data& data) : mData (data), mIdsUpdated (false) {} @@ -36,7 +40,57 @@ char CSMWorld::ScriptContext::getGlobalType (const std::string& name) const std::pair CSMWorld::ScriptContext::getMemberType (const std::string& name, const std::string& id) const { - return std::make_pair (' ', false); + /// \todo invalidate locals cache on change to scripts + + std::string id2 = Misc::StringUtils::lowerCase (id); + + int index = mData.getScripts().searchId (id2); + bool reference = false; + + if (index!=-1) + { + // ID is not a script ID. Search for a matching referenceable instead. + index = mData.getReferenceables().searchId (id2); + + if (index!=-1) + { + // Referenceable found. + int columnIndex = mData.getReferenceables().searchColumnIndex (Columns::ColumnId_Script); + + if (columnIndex!=-1) + { + id2 = Misc::StringUtils::lowerCase (mData.getReferenceables(). + getData (index, columnIndex).toString().toUtf8().constData()); + + if (!id2.empty()) + { + // Referenceable has a script -> use it. + index = mData.getScripts().searchId (id2); + reference = true; + } + } + } + } + + if (index==-1) + return std::make_pair (' ', false); + + std::map::iterator iter = mLocals.find (id2); + + if (iter==mLocals.end()) + { + Compiler::Locals locals; + + Compiler::NullErrorHandler errorHandler; + std::istringstream stream (mData.getScripts().getRecord (index).get().mScriptText); + Compiler::QuickFileParser parser (errorHandler, *this, locals); + Compiler::Scanner scanner (errorHandler, stream, getExtensions()); + scanner.scan (parser); + + iter = mLocals.insert (std::make_pair (id2, locals)).first; + } + + return std::make_pair (iter->second.getType (Misc::StringUtils::lowerCase (name)), reference); } bool CSMWorld::ScriptContext::isId (const std::string& name) const diff --git a/apps/opencs/model/world/scriptcontext.hpp b/apps/opencs/model/world/scriptcontext.hpp index 3baca99b24..400748e5fa 100644 --- a/apps/opencs/model/world/scriptcontext.hpp +++ b/apps/opencs/model/world/scriptcontext.hpp @@ -3,8 +3,10 @@ #include #include +#include #include +#include namespace CSMWorld { @@ -15,6 +17,7 @@ namespace CSMWorld const Data& mData; mutable std::vector mIds; mutable bool mIdsUpdated; + mutable std::map mLocals; public: From ae418f2538435484f852da126baaf21c85667a1d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 14 Feb 2014 12:46:15 +0100 Subject: [PATCH 093/171] nicer formatting --- apps/opencs/view/world/table.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 4d5554d863..7819a75c08 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -410,10 +410,10 @@ void CSVWorld::Table::tableSizeUpdate() switch (state) { - case CSMWorld::RecordBase::State_BaseOnly: ++size; break; - case CSMWorld::RecordBase::State_Modified: ++size; ++modified; break; - case CSMWorld::RecordBase::State_ModifiedOnly: ++size; ++modified; break; - case CSMWorld::RecordBase:: State_Deleted: ++deleted; ++modified; break; + case CSMWorld::RecordBase::State_BaseOnly: ++size; break; + case CSMWorld::RecordBase::State_Modified: ++size; ++modified; break; + case CSMWorld::RecordBase::State_ModifiedOnly: ++size; ++modified; break; + case CSMWorld::RecordBase:: State_Deleted: ++deleted; ++modified; break; } } } @@ -490,10 +490,14 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) if (dynamic_cast(event->mimeData())->holdsType(display)) { - const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + const CSMWorld::TableMimeData* mime = dynamic_cast + (event->mimeData()); + CSMWorld::UniversalId record (mime->returnMatching (display)); + std::auto_ptr command (new CSMWorld::ModifyCommand (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + mUndoStack.push (command.release()); } } From 0ff744c2ff801aee8bd635924d4eaaeca5f25b03 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 12:56:05 +0100 Subject: [PATCH 094/171] fixed CSMWorld::ScriptContext::isJournalId --- apps/opencs/model/world/scriptcontext.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index ee95f06c86..688c33d308 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -109,8 +109,7 @@ bool CSMWorld::ScriptContext::isId (const std::string& name) const bool CSMWorld::ScriptContext::isJournalId (const std::string& name) const { - /// \todo fix this after isId is fixed - return isId (name); + return mData.getJournals().searchId (name)!=-1; } void CSMWorld::ScriptContext::invalidateIds() From e17af4231a9e16eb554a7b2fa56d3ca18fb99ead Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 14 Feb 2014 13:38:30 +0100 Subject: [PATCH 095/171] added script verifier --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/tools/scriptcheck.cpp | 98 +++++++++++++++++++++++ apps/opencs/model/tools/scriptcheck.hpp | 40 +++++++++ apps/opencs/model/tools/tools.cpp | 3 + apps/opencs/model/world/scriptcontext.cpp | 9 ++- apps/opencs/model/world/scriptcontext.hpp | 3 + 6 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 apps/opencs/model/tools/scriptcheck.cpp create mode 100644 apps/opencs/model/tools/scriptcheck.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 5c3cd0dcc1..82313b7ed1 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -38,7 +38,7 @@ opencs_units (model/tools opencs_units_noqt (model/tools mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck - birthsigncheck spellcheck referenceablecheck + birthsigncheck spellcheck referenceablecheck scriptcheck ) diff --git a/apps/opencs/model/tools/scriptcheck.cpp b/apps/opencs/model/tools/scriptcheck.cpp new file mode 100644 index 0000000000..8ed41ec02d --- /dev/null +++ b/apps/opencs/model/tools/scriptcheck.cpp @@ -0,0 +1,98 @@ + +#include "scriptcheck.hpp" + +#include +#include +#include +#include +#include + +#include "../world/data.hpp" + +void CSMTools::ScriptCheckStage::report (const std::string& message, const Compiler::TokenLoc& loc, + Type type) +{ + std::ostringstream stream; + + CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); + + stream << id.toString() << "|"; + + if (type==ErrorMessage) + stream << "error "; + else + stream << "warning "; + + stream + << "line " << loc.mLine << ", column " << loc.mColumn + << " (" << loc.mLiteral << "): " << message; + + mMessages->push_back (stream.str()); +} + +void CSMTools::ScriptCheckStage::report (const std::string& message, Type type) +{ + std::ostringstream stream; + + CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); + + stream << id.toString() << "|"; + + if (type==ErrorMessage) + stream << "error: "; + else + stream << "warning: "; + + stream << message; + + mMessages->push_back (stream.str()); +} + +CSMTools::ScriptCheckStage::ScriptCheckStage (const CSMWorld::Data& data) +: mData (data), mContext (data), mMessages (0) +{ + Compiler::registerExtensions (mExtensions); + mContext.setExtensions (&mExtensions); +} + +int CSMTools::ScriptCheckStage::setup() +{ + mContext.clear(); + mMessages = 0; + mId.clear(); + + return mData.getScripts().getSize(); +} + +void CSMTools::ScriptCheckStage::perform (int stage, std::vector& messages) +{ + mMessages = &messages; + mId = mData.getScripts().getId (stage); + + try + { + std::istringstream input (mData.getScripts().getRecord (stage).get().mScriptText); + + Compiler::Scanner scanner (*this, input, mContext.getExtensions()); + + Compiler::FileParser parser (*this, mContext); + + scanner.scan (parser); + } + catch (const Compiler::SourceException&) + { + // error has already been reported via error handler + } + catch (const std::exception& error) + { + std::ostringstream stream; + + CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); + + stream << id.toString() << "|Critical compile error: " << error.what(); + + messages.push_back (stream.str()); + } + + mMessages = 0; +} \ No newline at end of file diff --git a/apps/opencs/model/tools/scriptcheck.hpp b/apps/opencs/model/tools/scriptcheck.hpp new file mode 100644 index 0000000000..325280d7ff --- /dev/null +++ b/apps/opencs/model/tools/scriptcheck.hpp @@ -0,0 +1,40 @@ +#ifndef CSM_TOOLS_SCRIPTCHECK_H +#define CSM_TOOLS_SCRIPTCHECK_H + +#include +#include + +#include "../doc/stage.hpp" + +#include "../world/scriptcontext.hpp" + +namespace CSMTools +{ + /// \brief VerifyStage: make sure that scripts compile + class ScriptCheckStage : public CSMDoc::Stage, private Compiler::ErrorHandler + { + const CSMWorld::Data& mData; + Compiler::Extensions mExtensions; + CSMWorld::ScriptContext mContext; + std::string mId; + std::vector *mMessages; + + virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type); + ///< Report error to the user. + + virtual void report (const std::string& message, Type type); + ///< Report a file related error + + public: + + ScriptCheckStage (const CSMWorld::Data& data); + + virtual int setup(); + ///< \return number of steps + + virtual void perform (int stage, std::vector& messages); + ///< Messages resulting from this tage will be appended to \a messages. + }; +} + +#endif diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 64e39ad2f6..79a09dcb48 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -20,6 +20,7 @@ #include "birthsigncheck.hpp" #include "spellcheck.hpp" #include "referenceablecheck.hpp" +#include "scriptcheck.hpp" CSMDoc::Operation *CSMTools::Tools::get (int type) { @@ -77,6 +78,8 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier() mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions())); + + mVerifier->appendStage (new ScriptCheckStage (mData)); } return mVerifier; diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index 688c33d308..8a4670ed2e 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -15,7 +15,7 @@ CSMWorld::ScriptContext::ScriptContext (const Data& data) : mData (data), mIdsUp bool CSMWorld::ScriptContext::canDeclareLocals() const { - return false; + return true; } char CSMWorld::ScriptContext::getGlobalType (const std::string& name) const @@ -115,4 +115,11 @@ bool CSMWorld::ScriptContext::isJournalId (const std::string& name) const void CSMWorld::ScriptContext::invalidateIds() { mIdsUpdated = false; +} + +void CSMWorld::ScriptContext::clear() +{ + mIds.clear(); + mIdsUpdated = false; + mLocals.clear(); } \ No newline at end of file diff --git a/apps/opencs/model/world/scriptcontext.hpp b/apps/opencs/model/world/scriptcontext.hpp index 400748e5fa..29ee42645a 100644 --- a/apps/opencs/model/world/scriptcontext.hpp +++ b/apps/opencs/model/world/scriptcontext.hpp @@ -43,6 +43,9 @@ namespace CSMWorld ///< Does \a name match a journal ID? void invalidateIds(); + + void clear(); + ///< Remove all cached data. }; } From aafde926d34008e0413c2c16178f4c144b8c7f73 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 14 Feb 2014 14:04:36 +0100 Subject: [PATCH 096/171] Documentation, corrections. --- apps/opencs/model/world/tablemimedata.hpp | 10 ++++++++-- apps/opencs/model/world/universalid.cpp | 1 - apps/opencs/view/world/table.cpp | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 1b6c5e635e..2829a07547 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -1,5 +1,3 @@ -/*This class provides way to construct mimedata object holding the reference to the -* universalid. universalid is used in the majority of the tables to store type, id, argument types*/ #ifndef TABLEMIMEDATA_H #define TABLEMIMEDATA_H @@ -15,6 +13,14 @@ namespace CSMWorld { + +/// \brief Subclass of QmimeData, augmented to contain and transport UniversalIds. +/// +/// This class provides way to construct mimedata object holding the universalid copy +/// Universalid is used in the majority of the tables to store type, id, argument types. +/// This way universalid grants a way to retrive record from the concrete table. +/// Please note, that tablemimedata object can hold multiple universalIds in the vector. + class TableMimeData : public QMimeData { public: diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index 88674c4ce1..8301ebfd36 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -187,7 +187,6 @@ CSMWorld::UniversalId::UniversalId (Type type, const std::string& id) mClass = sIdArg[i].mClass; return; } - std::cout< #include #include +#include #include "../../model/world/data.hpp" #include "../../model/world/commands.hpp" @@ -15,11 +16,10 @@ #include "../../model/world/record.hpp" #include "../../model/world/columns.hpp" #include "../../model/world/tablemimedata.hpp" +#include "../../model/world/tablemimedata.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" -#include -#include "../../model/world/tablemimedata.hpp" void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) { From 37d262b1477f6da0cb4e624bfd3fe1bebf62e211 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 14 Feb 2014 15:12:34 +0100 Subject: [PATCH 097/171] Splited very long line. --- apps/opencs/model/doc/document.hpp | 5 ++++- apps/opencs/model/world/tablemimedata.hpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index 437b0c5131..201fb4342a 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -71,7 +71,10 @@ namespace CSMDoc public: - Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, bool new_); + Document (const Files::ConfigurationManager& configuration, + const std::vector< boost::filesystem::path >& files, + const boost::filesystem::path& savePath, + const boost::filesystem::path& resDir, bool new_); ~Document(); diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 2829a07547..51785714ed 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -42,4 +42,4 @@ namespace CSMWorld CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const; }; } -#endif // TABLEMIMEDATA_H +#endif // TABLEMIMEDATA_H \ No newline at end of file From f3dc45f1ec735159be0b3e387b4dafde46b1db25 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 14 Feb 2014 15:29:10 +0100 Subject: [PATCH 098/171] long line split. --- apps/opencs/model/doc/documentmanager.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/doc/documentmanager.hpp b/apps/opencs/model/doc/documentmanager.hpp index b80a186429..b969862e99 100644 --- a/apps/opencs/model/doc/documentmanager.hpp +++ b/apps/opencs/model/doc/documentmanager.hpp @@ -29,7 +29,9 @@ namespace CSMDoc ~DocumentManager(); - Document *addDocument (const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, bool new_); + Document *addDocument (const std::vector< boost::filesystem::path >& files, + const boost::filesystem::path& savePath, + bool new_); ///< The ownership of the returned document is not transferred to the caller. /// /// \param new_ Do not load the last content file in \a files and instead create in an From d6820b977ead88e15b838d168e9324261f4f58ee Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 12:22:32 +0100 Subject: [PATCH 099/171] store const ref to the document in the table. --- apps/opencs/view/world/table.cpp | 4 ++-- apps/opencs/view/world/table.hpp | 12 +++++++++++- apps/opencs/view/world/tablesubview.cpp | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index c077d5f7fe..4199359912 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -162,8 +162,8 @@ std::vector CSVWorld::Table::listDeletableSelectedIds() const } CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, - bool createAndDelete, bool sorting) - : mUndoStack (undoStack), mCreateAction (0), mCloneAction(0), mEditLock (false), mRecordStatusDisplay (0) + bool createAndDelete, bool sorting, const CSMDoc::Document& document) + : mUndoStack (undoStack), mCreateAction (0), mCloneAction(0), mEditLock (false), mRecordStatusDisplay (0), mDocument(document) { mModel = &dynamic_cast (*data.getTableModel (id)); diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 6102a133ad..ff08db06fa 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -9,6 +9,10 @@ #include "../../model/filter/node.hpp" +namespace CSMDoc { + class Document; +} + class QUndoStack; class QAction; @@ -43,6 +47,10 @@ namespace CSVWorld bool mEditLock; int mRecordStatusDisplay; + /// \brief This variable is used exclusivly for checking if dropEvents came from the same document. Most likely you + /// should NOT use it for anything else. + const CSMDoc::Document& mDocument; + private: void contextMenuEvent (QContextMenuEvent *event); @@ -62,7 +70,9 @@ namespace CSVWorld public: - Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting); + Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, + bool sorting, const CSMDoc::Document& document); + ///< \param createAndDelete Allow creation and deletion of records. /// \param sorting Allow changing order of rows in the view via column headers. diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 981faaf591..d379db51a5 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -22,7 +22,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), id, this), 0); layout->insertWidget (0, mTable = - new Table (id, document.getData(), document.getUndoStack(), mBottom->canCreateAndDelete(), sorting), 2); + new Table (id, document.getData(), document.getUndoStack(), mBottom->canCreateAndDelete(), sorting, document), 2); CSVFilter::FilterBox *filterBox = new CSVFilter::FilterBox (document.getData(), this); From b1f63947e8a74d0fdce58b511cb588401dd0c4b4 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 12:40:07 +0100 Subject: [PATCH 100/171] Checking if the drop comes from same document. --- apps/opencs/model/world/tablemimedata.cpp | 12 +++++++--- apps/opencs/model/world/tablemimedata.hpp | 20 ++++++++++++++-- apps/opencs/view/world/table.cpp | 29 +++++++++++++---------- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index b0cf0abcc2..ee37dfce6a 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -4,14 +4,15 @@ #include "universalid.hpp" #include "columnbase.hpp" -CSMWorld::TableMimeData::TableMimeData (UniversalId id) +CSMWorld::TableMimeData::TableMimeData (UniversalId id, const CSMDoc::Document& document) : +mDocument(document) { mUniversalId.push_back (id); mObjectsFormats << QString::fromStdString ("tabledata/" + id.getTypeName()); } -CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) : - mUniversalId (id) +CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id, const CSMDoc::Document& document) : + mUniversalId (id), mDocument(document) { for (std::vector::iterator it (mUniversalId.begin()); it != mUniversalId.end(); ++it) { @@ -115,6 +116,11 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnB throw ("TableMimeData object does not hold object of the seeked type"); } +bool CSMWorld::TableMimeData::fromDocument (const CSMDoc::Document& document) const +{ + return &document == &mDocument; +} + CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) const { switch (type) diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 51785714ed..7c05386fb1 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -10,6 +10,10 @@ #include "universalid.hpp" #include "columnbase.hpp" +namespace CSMDoc +{ + class Document; +} namespace CSMWorld { @@ -24,21 +28,33 @@ namespace CSMWorld class TableMimeData : public QMimeData { public: - TableMimeData(UniversalId id); - TableMimeData(std::vector& id); + TableMimeData(UniversalId id, const CSMDoc::Document& document); + + TableMimeData(std::vector& id, const CSMDoc::Document& document); + ~TableMimeData(); + virtual QStringList formats() const; + std::string getIcon() const; + std::vector getData() const; + bool holdsType(UniversalId::Type type) const; + bool holdsType(CSMWorld::ColumnBase::Display type) const; + + bool fromDocument(const CSMDoc::Document& document) const; + UniversalId returnMatching(UniversalId::Type type) const; + UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const; private: std::vector mUniversalId; QStringList mObjectsFormats; + const CSMDoc::Document& mDocument; CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const; }; } diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 4199359912..79700458d5 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -455,7 +455,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) if (selectedRows.size() == 1) { - mime = new CSMWorld::TableMimeData (getUniversalId (selectedRows.begin()->row())); + mime = new CSMWorld::TableMimeData (getUniversalId (selectedRows.begin()->row()), mDocument); } else { @@ -466,7 +466,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) idToDrag.push_back (getUniversalId (it.row())); } - mime = new CSMWorld::TableMimeData (idToDrag); + mime = new CSMWorld::TableMimeData (idToDrag, mDocument); } drag->setMimeData (mime); @@ -485,21 +485,24 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) { QModelIndex index = indexAt (event->pos()); - CSMWorld::ColumnBase::Display display = static_cast - (mModel->headerData(index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); - - if (dynamic_cast(event->mimeData())->holdsType(display)) + if (dynamic_cast (event->mimeData())->fromDocument (mDocument)) { - const CSMWorld::TableMimeData* mime = dynamic_cast - (event->mimeData()); + CSMWorld::ColumnBase::Display display = static_cast + (mModel->headerData (index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); - CSMWorld::UniversalId record (mime->returnMatching (display)); + if (dynamic_cast (event->mimeData())->holdsType (display)) + { + const CSMWorld::TableMimeData* mime = dynamic_cast + (event->mimeData()); - std::auto_ptr command (new CSMWorld::ModifyCommand - (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + CSMWorld::UniversalId record (mime->returnMatching (display)); - mUndoStack.push (command.release()); - } + std::auto_ptr command (new CSMWorld::ModifyCommand + (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + + mUndoStack.push (command.release()); + } + } //TODO handle drops from different document } void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) From fd665a19941d072b6bdc3a44eab9aa26b74e1f40 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 15 Feb 2014 12:45:50 +0100 Subject: [PATCH 101/171] ignore conditions after an else (only works if condition is put in parentheses) --- components/compiler/controlparser.cpp | 15 ++++++++++++--- components/compiler/controlparser.hpp | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/compiler/controlparser.cpp b/components/compiler/controlparser.cpp index 58542bd739..aefe6d16da 100644 --- a/components/compiler/controlparser.cpp +++ b/components/compiler/controlparser.cpp @@ -8,6 +8,7 @@ #include "scanner.hpp" #include "generator.hpp" #include "errorhandler.hpp" +#include "skipparser.hpp" namespace Compiler { @@ -71,7 +72,7 @@ namespace Compiler } else if (keyword==Scanner::K_else) { - mState = IfElseBodyState; /// \todo should be IfElseEndState; add an option for that + mState = IfElseJunkState; /// \todo should be IfElseEndState; add an option for that } return true; @@ -207,7 +208,8 @@ namespace Compiler return true; } } - else if (mState==IfBodyState || mState==IfElseifBodyState || mState==IfElseBodyState) + else if (mState==IfBodyState || mState==IfElseifBodyState || mState==IfElseBodyState || + mState==IfElseJunkState) { if (parseIfBody (keyword, loc, scanner)) return true; @@ -230,6 +232,7 @@ namespace Compiler case IfEndState: mState = IfBodyState; return true; case IfElseifEndState: mState = IfElseifBodyState; return true; case IfElseEndState: mState = IfElseBodyState; return true; + case IfElseJunkState: mState = IfElseBodyState; return true; case WhileEndState: mState = WhileBodyState; return true; @@ -247,7 +250,13 @@ namespace Compiler default: ; } - + } + else if (code==Scanner::S_open && mState==IfElseJunkState) + { + SkipParser skip (getErrorHandler(), getContext()); + scanner.scan (skip); + mState = IfElseBodyState; + return true; } return Parser::parseSpecial (code, loc, scanner); diff --git a/components/compiler/controlparser.hpp b/components/compiler/controlparser.hpp index 24bc7bec75..1175a0ed58 100644 --- a/components/compiler/controlparser.hpp +++ b/components/compiler/controlparser.hpp @@ -26,7 +26,8 @@ namespace Compiler IfElseEndState, IfElseBodyState, IfEndifState, WhileEndState, WhileBodyState, - WhileEndwhileState + WhileEndwhileState, + IfElseJunkState }; typedef std::vector Codes; From 0d84adb2c601345bb9a782624a9caaa88d0fedbb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 15 Feb 2014 12:50:40 +0100 Subject: [PATCH 102/171] allow x->(y) instead of (x->y) --- components/compiler/exprparser.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 6d26ef403c..0c013b18f1 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -570,6 +570,14 @@ namespace Compiler { if (!mExplicit.empty()) { + if (mRefOp && code==Scanner::S_open) + { + /// \todo add option to disable this workaround + mOperators.push_back ('('); + mTokenLoc = loc; + return true; + } + if (!mRefOp && code==Scanner::S_ref) { mRefOp = true; From 2130ec39d698ad92994b216185cf9fbc238ef944 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 15 Feb 2014 12:58:34 +0100 Subject: [PATCH 103/171] disable warnings by default in script verifier --- apps/opencs/model/tools/scriptcheck.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/opencs/model/tools/scriptcheck.cpp b/apps/opencs/model/tools/scriptcheck.cpp index 8ed41ec02d..2ed8fe6579 100644 --- a/apps/opencs/model/tools/scriptcheck.cpp +++ b/apps/opencs/model/tools/scriptcheck.cpp @@ -51,6 +51,9 @@ void CSMTools::ScriptCheckStage::report (const std::string& message, Type type) CSMTools::ScriptCheckStage::ScriptCheckStage (const CSMWorld::Data& data) : mData (data), mContext (data), mMessages (0) { + /// \todo add an option to configure warning mode + setWarningsMode (0); + Compiler::registerExtensions (mExtensions); mContext.setExtensions (&mExtensions); } From 4e041319578a310e2d6be5be4c118d0e83155b27 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 15 Feb 2014 13:09:43 +0100 Subject: [PATCH 104/171] fixing case broke sorting in script context --- apps/opencs/model/world/scriptcontext.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index 8a4670ed2e..9da49defe7 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -100,6 +100,7 @@ bool CSMWorld::ScriptContext::isId (const std::string& name) const mIds = mData.getIds(); std::for_each (mIds.begin(), mIds.end(), &Misc::StringUtils::lowerCase); + std::sort (mIds.begin(), mIds.end()); mIdsUpdated = true; } From 4ee90c24e58778ab73262af8b099c0ced4f5de83 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 13:22:14 +0100 Subject: [PATCH 105/171] more readable code. --- apps/opencs/view/world/table.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 79700458d5..73b1fd226d 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -485,16 +485,14 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) { QModelIndex index = indexAt (event->pos()); - if (dynamic_cast (event->mimeData())->fromDocument (mDocument)) + const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + if (mime->fromDocument (mDocument)) { CSMWorld::ColumnBase::Display display = static_cast (mModel->headerData (index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); - if (dynamic_cast (event->mimeData())->holdsType (display)) + if (mime->holdsType (display)) { - const CSMWorld::TableMimeData* mime = dynamic_cast - (event->mimeData()); - CSMWorld::UniversalId record (mime->returnMatching (display)); std::auto_ptr command (new CSMWorld::ModifyCommand From 56be62b95644789d24568618098bf451aec51667 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 13:23:51 +0100 Subject: [PATCH 106/171] small reformatting --- apps/opencs/model/world/tablemimedata.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 7c05386fb1..010a18acb2 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -53,8 +53,8 @@ namespace CSMWorld private: std::vector mUniversalId; QStringList mObjectsFormats; - const CSMDoc::Document& mDocument; + CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const; }; } From 2007a3e9027c640f1dc6d5ad4259ed632f04d1b8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 15 Feb 2014 13:25:38 +0100 Subject: [PATCH 107/171] improved script check error messages --- apps/opencs/model/tools/scriptcheck.cpp | 4 +++- apps/opencs/model/tools/scriptcheck.hpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/scriptcheck.cpp b/apps/opencs/model/tools/scriptcheck.cpp index 2ed8fe6579..a5154d2926 100644 --- a/apps/opencs/model/tools/scriptcheck.cpp +++ b/apps/opencs/model/tools/scriptcheck.cpp @@ -24,7 +24,8 @@ void CSMTools::ScriptCheckStage::report (const std::string& message, const Compi stream << "warning "; stream - << "line " << loc.mLine << ", column " << loc.mColumn + << "script " << mFile + << ", line " << loc.mLine << ", column " << loc.mColumn << " (" << loc.mLiteral << "): " << message; mMessages->push_back (stream.str()); @@ -74,6 +75,7 @@ void CSMTools::ScriptCheckStage::perform (int stage, std::vector& m try { + mFile = mData.getScripts().getRecord (stage).get().mId; std::istringstream input (mData.getScripts().getRecord (stage).get().mScriptText); Compiler::Scanner scanner (*this, input, mContext.getExtensions()); diff --git a/apps/opencs/model/tools/scriptcheck.hpp b/apps/opencs/model/tools/scriptcheck.hpp index 325280d7ff..8de8e1a667 100644 --- a/apps/opencs/model/tools/scriptcheck.hpp +++ b/apps/opencs/model/tools/scriptcheck.hpp @@ -17,6 +17,7 @@ namespace CSMTools Compiler::Extensions mExtensions; CSMWorld::ScriptContext mContext; std::string mId; + std::string mFile; std::vector *mMessages; virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type); From 0afa61eed56264fea4af81fcfe78502700e2711c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 15 Feb 2014 15:50:17 +0100 Subject: [PATCH 108/171] fixed referenceable-loading in case of more than one content file --- apps/opencs/model/world/refidcollection.cpp | 8 +++---- apps/opencs/model/world/refiddata.cpp | 4 ++-- apps/opencs/model/world/refiddata.hpp | 23 ++++++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 89a917139b..f515e34d8e 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -432,7 +432,7 @@ void CSMWorld::RefIdCollection::removeRows (int index, int count) void CSMWorld::RefIdCollection::appendBlankRecord (const std::string& id, UniversalId::Type type) { - mData.appendRecord (type, id); + mData.appendRecord (type, id, false); } int CSMWorld::RefIdCollection::searchId (const std::string& id) const @@ -450,7 +450,7 @@ void CSMWorld::RefIdCollection::replace (int index, const RecordBase& record) mData.getRecord (mData.globalToLocalIndex (index)).assign (record); } -void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin, +void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin, const std::string& destination, const CSMWorld::UniversalId::Type type) { @@ -467,7 +467,7 @@ void CSMWorld::RefIdCollection::appendRecord (const RecordBase& record, int index = mData.getAppendIndex (type); - mData.appendRecord (type, id); + mData.appendRecord (type, id, false); mData.getRecord (mData.globalToLocalIndex (index)).assign (record); } @@ -515,7 +515,7 @@ void CSMWorld::RefIdCollection::load (ESM::ESMReader& reader, bool base, Univers { // new record int index = mData.getAppendIndex (type); - mData.appendRecord (type, id); + mData.appendRecord (type, id, base); RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (index); diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 9d980a99cd..f67ab21526 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -131,7 +131,7 @@ CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord (const LocalIndex& index) return iter->second->getRecord (index.first); } -void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::string& id) +void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::string& id, bool base) { std::map::iterator iter = mRecordContainers.find (type); @@ -139,7 +139,7 @@ void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::strin if (iter==mRecordContainers.end()) throw std::logic_error ("invalid local index type"); - iter->second->appendRecord (id); + iter->second->appendRecord (id, base); mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id), LocalIndex (iter->second->getSize()-1, type))); diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index cf98fee213..1b600364c7 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -45,8 +45,8 @@ namespace CSMWorld virtual RecordBase& getRecord (int index)= 0; - virtual void appendRecord (const std::string& id) = 0; - + virtual void appendRecord (const std::string& id, bool base) = 0; + virtual void insertRecord (RecordBase& record) = 0; virtual void load (int index, ESM::ESMReader& reader, bool base) = 0; @@ -69,8 +69,8 @@ namespace CSMWorld virtual RecordBase& getRecord (int index); - virtual void appendRecord (const std::string& id); - + virtual void appendRecord (const std::string& id, bool base); + virtual void insertRecord (RecordBase& record); virtual void load (int index, ESM::ESMReader& reader, bool base); @@ -88,7 +88,7 @@ namespace CSMWorld Record& newRecord = dynamic_cast& >(record); mContainer.push_back(newRecord); } - + template int RefIdDataContainer::getSize() const { @@ -108,12 +108,15 @@ namespace CSMWorld } template - void RefIdDataContainer::appendRecord (const std::string& id) + void RefIdDataContainer::appendRecord (const std::string& id, bool base) { Record record; + + record.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; + + record.mBase.mId = id; record.mModified.mId = id; - record.mModified.blank(); - record.mState = RecordBase::State_ModifiedOnly; + (base ? record.mBase : record.mModified).blank(); mContainer.push_back (record); } @@ -206,14 +209,14 @@ namespace CSMWorld LocalIndex searchId (const std::string& id) const; void erase (int index, int count); - + void insertRecord(CSMWorld::RecordBase& record, CSMWorld::UniversalId::Type type, const std::string& id); const RecordBase& getRecord (const LocalIndex& index) const; RecordBase& getRecord (const LocalIndex& index); - void appendRecord (UniversalId::Type type, const std::string& id); + void appendRecord (UniversalId::Type type, const std::string& id, bool base); int getAppendIndex (UniversalId::Type type) const; From 3d8ca02479d42d9bd856d31254512dfb70f2428c Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Sat, 15 Feb 2014 17:39:11 +0100 Subject: [PATCH 109/171] Fix breaking of enchanted items casting --- apps/openmw/mwinput/inputmanagerimp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 7ed3007ffd..66d93469c7 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -17,6 +17,7 @@ #include "../mwworld/player.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/inventorystore.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/soundmanager.hpp" @@ -647,7 +648,9 @@ namespace MWInput return; // Not allowed if no spell selected - if (MWBase::Environment::get().getWindowManager()->getSelectedSpell().empty()) + MWWorld::InventoryStore& inventory = MWWorld::Class::get(mPlayer->getPlayer()).getInventoryStore(mPlayer->getPlayer()); + if (MWBase::Environment::get().getWindowManager()->getSelectedSpell().empty() && + inventory.getSelectedEnchantItem() == inventory.end()) return; MWMechanics::DrawState_ state = mPlayer->getDrawState(); From 97fe5465bf4bf6ec2c72a622eb5c226f1b7a547d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 17:55:18 +0100 Subject: [PATCH 110/171] created new files --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/view/world/scriptedit.cpp | 39 ++++++++++++++++++++++++++ apps/opencs/view/world/scriptedit.hpp | 40 +++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 apps/opencs/view/world/scriptedit.cpp create mode 100644 apps/opencs/view/world/scriptedit.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 318cc49129..cd89240c2b 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -60,7 +60,7 @@ opencs_hdrs_noqt (view/doc opencs_units (view/world table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator cellcreator referenceablecreator referencecreator scenesubview scenetoolbar scenetool - scenetoolmode infocreator + scenetoolmode infocreator scriptedit ) opencs_units (view/render diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp new file mode 100644 index 0000000000..3a71d8f0cc --- /dev/null +++ b/apps/opencs/view/world/scriptedit.cpp @@ -0,0 +1,39 @@ +/* + * + * Copyright 2014 Marek Kochanowicz + * + * 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 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * 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 . + * + */ + +#include "scriptedit.hpp" + +void CSVWorld::ScriptEdit::dragEnterEvent (QDragEnterEvent* event) +{ + event->acceptProposedAction(); +} + +void CSVWorld::ScriptEdit::dragMoveEvent (QDragMoveEvent* event) +{ + event->accept(); +} + +void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event) +{ + +} +// kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp new file mode 100644 index 0000000000..74e15ecbfe --- /dev/null +++ b/apps/opencs/view/world/scriptedit.hpp @@ -0,0 +1,40 @@ +/* + * + * Copyright 2014 Marek Kochanowicz + * + * 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 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * 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 . + * + */ + +#ifndef SCRIPTEDIT_H +#define SCRIPTEDIT_H + +#include + +namespace CSVWorld +{ + class ScriptEdit : public QTextEdit + { + void dragEnterEvent (QDragEnterEvent* event); + + void dropEvent (QDropEvent* event); + + void dragMoveEvent (QDragMoveEvent* event); + }; +} +#endif // SCRIPTEDIT_H +// kate: indent-mode cstyle; indent-width 4; replace-tabs on; \ No newline at end of file From 930b77e60a1d7afb00a6a5766e009d0e49d28e56 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 19:52:40 +0100 Subject: [PATCH 111/171] allow drag and drop into the script edit window. --- apps/opencs/view/world/scriptedit.cpp | 42 +++++++++++------------- apps/opencs/view/world/scriptedit.hpp | 33 +++++-------------- apps/opencs/view/world/scriptsubview.cpp | 3 +- 3 files changed, 31 insertions(+), 47 deletions(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 3a71d8f0cc..4eb652add2 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -1,27 +1,18 @@ -/* - * - * Copyright 2014 Marek Kochanowicz - * - * 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 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * 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 . - * - */ - #include "scriptedit.hpp" +#include + +#include + +#include "../../model/world/universalid.hpp" +#include "../../model/world/tablemimedata.hpp" + +CSVWorld::ScriptEdit::ScriptEdit (QWidget* parent) : +QTextEdit(parent) +{ + +} + void CSVWorld::ScriptEdit::dragEnterEvent (QDragEnterEvent* event) { event->acceptProposedAction(); @@ -34,6 +25,13 @@ void CSVWorld::ScriptEdit::dragMoveEvent (QDragMoveEvent* event) void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event) { + const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + std::vector records (mime->getData()); + + for (std::vector::iterator it = records.begin(); it != records.end(); ++it) + { + insertPlainText (QString::fromStdString (it->getId())); + } } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index 74e15ecbfe..6df4acc5f6 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -1,34 +1,19 @@ -/* - * - * Copyright 2014 Marek Kochanowicz - * - * 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 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * 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 . - * - */ - #ifndef SCRIPTEDIT_H #define SCRIPTEDIT_H -#include +#include + +class QWidget; namespace CSVWorld { class ScriptEdit : public QTextEdit { + Q_OBJECT + public: + ScriptEdit (QWidget* parent); + + private: void dragEnterEvent (QDragEnterEvent* event); void dropEvent (QDropEvent* event); @@ -37,4 +22,4 @@ namespace CSVWorld }; } #endif // SCRIPTEDIT_H -// kate: indent-mode cstyle; indent-width 4; replace-tabs on; \ No newline at end of file +// kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/view/world/scriptsubview.cpp b/apps/opencs/view/world/scriptsubview.cpp index 446c34e5f0..4fe5aafac6 100644 --- a/apps/opencs/view/world/scriptsubview.cpp +++ b/apps/opencs/view/world/scriptsubview.cpp @@ -13,6 +13,7 @@ #include "../../model/world/idtable.hpp" #include "scripthighlighter.hpp" +#include "scriptedit.hpp" CSVWorld::ScriptSubView::ChangeLock::ChangeLock (ScriptSubView& view) : mView (view) { @@ -27,7 +28,7 @@ CSVWorld::ScriptSubView::ChangeLock::~ChangeLock() CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id), mDocument (document), mColumn (-1), mChangeLocked (0) { - setWidget (mEditor = new QTextEdit (this)); + setWidget (mEditor = new ScriptEdit (this)); mEditor->setAcceptRichText (false); mEditor->setLineWrapMode (QTextEdit::NoWrap); From 41606a67e4bad4184841ac2f492f309fa2f233a5 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 20:49:09 +0100 Subject: [PATCH 112/171] implemented whitelist of allowed types in the scripts --- apps/opencs/view/world/scriptedit.cpp | 41 +++++++++++++++++++++++---- apps/opencs/view/world/scriptedit.hpp | 5 ++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 4eb652add2..20b76ad722 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -1,25 +1,51 @@ #include "scriptedit.hpp" -#include - #include #include "../../model/world/universalid.hpp" #include "../../model/world/tablemimedata.hpp" CSVWorld::ScriptEdit::ScriptEdit (QWidget* parent) : -QTextEdit(parent) + QTextEdit (parent) { - + mAllowedTypes <pos())); event->acceptProposedAction(); } void CSVWorld::ScriptEdit::dragMoveEvent (QDragMoveEvent* event) { + setTextCursor (cursorForPosition (event->pos())); event->accept(); } @@ -27,11 +53,16 @@ void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event) { const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + setTextCursor (cursorForPosition (event->pos())); + std::vector records (mime->getData()); for (std::vector::iterator it = records.begin(); it != records.end(); ++it) { - insertPlainText (QString::fromStdString (it->getId())); + if (mAllowedTypes.contains (it->getType())) + { + insertPlainText (QString::fromStdString (it->getId() + " ")); + } } } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index 6df4acc5f6..5355b57ce6 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -2,6 +2,9 @@ #define SCRIPTEDIT_H #include +#include + +#include "../../model/world/universalid.hpp" class QWidget; @@ -14,6 +17,8 @@ namespace CSVWorld ScriptEdit (QWidget* parent); private: + QVector mAllowedTypes; + void dragEnterEvent (QDragEnterEvent* event); void dropEvent (QDropEvent* event); From ec8c8a9d88292eee2c34ed50d680b7632b750f30 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 22:05:42 +0100 Subject: [PATCH 113/171] -journalinfo +topic --- apps/opencs/view/world/scriptedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 20b76ad722..c3e38052c7 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -9,8 +9,8 @@ CSVWorld::ScriptEdit::ScriptEdit (QWidget* parent) : QTextEdit (parent) { mAllowedTypes < Date: Sat, 15 Feb 2014 22:14:27 +0100 Subject: [PATCH 114/171] Put the id in the quote. --- apps/opencs/view/world/scriptedit.cpp | 5 ++--- apps/opencs/view/world/scriptedit.hpp | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index c3e38052c7..88e990c10b 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -61,8 +61,7 @@ void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event) { if (mAllowedTypes.contains (it->getType())) { - insertPlainText (QString::fromStdString (it->getId() + " ")); + QString::fromStdString ('"' + it->getId() + '"')); } } -} -// kate: indent-mode cstyle; indent-width 4; replace-tabs on; +} \ No newline at end of file diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index 5355b57ce6..a110f58c89 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -26,5 +26,4 @@ namespace CSVWorld void dragMoveEvent (QDragMoveEvent* event); }; } -#endif // SCRIPTEDIT_H -// kate: indent-mode cstyle; indent-width 4; replace-tabs on; +#endif // SCRIPTEDIT_H \ No newline at end of file From cbe1fe2f9581b1a458b59360c7902b0d6ebd923c Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 15 Feb 2014 22:38:59 +0100 Subject: [PATCH 115/171] removed misplaced bracket --- apps/opencs/view/world/scriptedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 88e990c10b..f7f82c9781 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -61,7 +61,7 @@ void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event) { if (mAllowedTypes.contains (it->getType())) { - QString::fromStdString ('"' + it->getId() + '"')); + QString::fromStdString ('"' + it->getId() + '"'); } } } \ No newline at end of file From 17af865a9fcbb6ebf88f39e6accb4a8fa4840833 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 16 Feb 2014 09:51:33 +0100 Subject: [PATCH 116/171] checking for the source of the drop, reject those from other files for now --- apps/opencs/view/world/scriptedit.cpp | 18 +++++++++++------- apps/opencs/view/world/scriptedit.hpp | 8 +++++++- apps/opencs/view/world/scriptsubview.cpp | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index f7f82c9781..ecfaa3ba87 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -5,8 +5,9 @@ #include "../../model/world/universalid.hpp" #include "../../model/world/tablemimedata.hpp" -CSVWorld::ScriptEdit::ScriptEdit (QWidget* parent) : - QTextEdit (parent) +CSVWorld::ScriptEdit::ScriptEdit (QWidget* parent, const CSMDoc::Document& document) : + QTextEdit (parent), + mDocument (document) { mAllowedTypes <pos())); - std::vector records (mime->getData()); - - for (std::vector::iterator it = records.begin(); it != records.end(); ++it) + if (mime->fromDocument (mDocument)) { - if (mAllowedTypes.contains (it->getType())) + std::vector records (mime->getData()); + + for (std::vector::iterator it = records.begin(); it != records.end(); ++it) { - QString::fromStdString ('"' + it->getId() + '"'); + if (mAllowedTypes.contains (it->getType())) + { + QString::fromStdString ('"' + it->getId() + '"'); + } } } } \ No newline at end of file diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index a110f58c89..dc97382b34 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -8,16 +8,22 @@ class QWidget; +namespace CSMDoc +{ + class Document; +} + namespace CSVWorld { class ScriptEdit : public QTextEdit { Q_OBJECT public: - ScriptEdit (QWidget* parent); + ScriptEdit (QWidget* parent, const CSMDoc::Document& document); private: QVector mAllowedTypes; + const CSMDoc::Document& mDocument; void dragEnterEvent (QDragEnterEvent* event); diff --git a/apps/opencs/view/world/scriptsubview.cpp b/apps/opencs/view/world/scriptsubview.cpp index 4fe5aafac6..fa41151ca3 100644 --- a/apps/opencs/view/world/scriptsubview.cpp +++ b/apps/opencs/view/world/scriptsubview.cpp @@ -28,7 +28,7 @@ CSVWorld::ScriptSubView::ChangeLock::~ChangeLock() CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id), mDocument (document), mColumn (-1), mChangeLocked (0) { - setWidget (mEditor = new ScriptEdit (this)); + setWidget (mEditor = new ScriptEdit (this, mDocument)); mEditor->setAcceptRichText (false); mEditor->setLineWrapMode (QTextEdit::NoWrap); From 3c281c6a62e0fd000245956b89737ae1997472b3 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 16 Feb 2014 14:12:45 +0400 Subject: [PATCH 117/171] OS X: specify path to framework binary, not to framework directory --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9d5329107..e279109583 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -680,7 +680,8 @@ if (APPLE) foreach (PLUGIN ${ABSOLUTE_PLUGINS}) get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME) - set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}") + get_filename_component(PLUGIN_RELATIVE_WE ${PLUGIN} NAME_WE) + set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}/${PLUGIN_RELATIVE_WE}") endforeach () set(${plugins_var} ${PLUGINS} PARENT_SCOPE) From 8f99da084b11036793dd4154802792fd98f29fc2 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 16 Feb 2014 14:12:59 +0400 Subject: [PATCH 118/171] OS X: plugins are now in Frameworks dir, not in Plugins --- components/ogreinit/ogreinit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ogreinit/ogreinit.cpp b/components/ogreinit/ogreinit.cpp index 46424a29af..840cf4bb05 100644 --- a/components/ogreinit/ogreinit.cpp +++ b/components/ogreinit/ogreinit.cpp @@ -133,7 +133,7 @@ namespace OgreInit pluginDir = OGRE_PLUGIN_DIR; // if path is not specified try to find plugins inside the app bundle if (pluginDir.empty()) - pluginDir = Ogre::macPluginPath(); + pluginDir = Ogre::macFrameworksPath(); #endif #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX pluginDir = OGRE_PLUGIN_DIR_REL; From e4017b8bfe706f881b5aa9c41edea2225491b880 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 16 Feb 2014 14:16:45 +0400 Subject: [PATCH 119/171] It seems that OctreeSceneManager is not required anymore --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e279109583..024527ae55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,7 +252,6 @@ link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MY if (APPLE) # List used Ogre plugins SET(USED_OGRE_PLUGINS ${OGRE_RenderSystem_GL_LIBRARY_REL} - ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} ${OGRE_Plugin_ParticleFX_LIBRARY_REL}) # Actually we must use OGRE_Plugin_CgProgramManager_FOUND but it's From 9f721fd14463bf849133514b60217b4411d736d8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 16 Feb 2014 12:54:27 +0100 Subject: [PATCH 120/171] store list of known topics in saved game files --- apps/openmw/mwbase/dialoguemanager.hpp | 14 ++++++++ apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 36 +++++++++++++++++++ apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 6 ++++ apps/openmw/mwstate/statemanagerimp.cpp | 9 ++++- components/CMakeLists.txt | 2 +- components/esm/defs.hpp | 1 + components/esm/dialoguestate.cpp | 21 +++++++++++ components/esm/dialoguestate.hpp | 23 ++++++++++++ 8 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 components/esm/dialoguestate.cpp create mode 100644 components/esm/dialoguestate.hpp diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index 971bc3b4e9..33bba07e15 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -3,6 +3,14 @@ #include +#include + +namespace ESM +{ + class ESMReader; + class ESMWriter; +} + namespace MWWorld { class Ptr; @@ -52,6 +60,12 @@ namespace MWBase virtual void persuade (int type) = 0; virtual int getTemporaryDispositionChange () const = 0; virtual void applyDispositionChange (int delta) = 0; + + virtual int countSavedGameRecords() const = 0; + + virtual void write (ESM::ESMWriter& writer) const = 0; + + virtual void readRecord (ESM::ESMReader& reader, int32_t type) = 0; }; } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 845c3c07be..c9e8ad9551 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -591,6 +592,41 @@ namespace MWDialogue } } + int DialogueManager::countSavedGameRecords() const + { + return 1; // known topics + } + + void DialogueManager::write (ESM::ESMWriter& writer) const + { + ESM::DialogueState state; + + for (std::map::const_iterator iter (mKnownTopics.begin()); + iter!=mKnownTopics.end(); ++iter) + if (iter->second) + state.mKnownTopics.push_back (iter->first); + + writer.startRecord (ESM::REC_DIAS); + state.save (writer); + writer.endRecord (ESM::REC_DIAS); + } + + void DialogueManager::readRecord (ESM::ESMReader& reader, int32_t type) + { + if (type==ESM::REC_DIAS) + { + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + + ESM::DialogueState state; + state.load (reader); + + for (std::vector::const_iterator iter (state.mKnownTopics.begin()); + iter!=state.mKnownTopics.end(); ++iter) + if (store.get().search (*iter)) + mKnownTopics.insert (std::make_pair (*iter, true)); + } + } + std::vector ParseHyperText(const std::string& text) { diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index c32a5dbd89..cf8ea11764 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -78,6 +78,12 @@ namespace MWDialogue virtual void persuade (int type); virtual int getTemporaryDispositionChange () const; virtual void applyDispositionChange (int delta); + + virtual int countSavedGameRecords() const; + + virtual void write (ESM::ESMWriter& writer) const; + + virtual void readRecord (ESM::ESMReader& reader, int32_t type); }; diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index f68a01bf4f..ba0e1d056f 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -193,7 +193,8 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot +MWBase::Environment::get().getJournal()->countSavedGameRecords() +MWBase::Environment::get().getWorld()->countSavedGameRecords() +MWBase::Environment::get().getScriptManager()->getGlobalScripts().countSavedGameRecords() - + 1 // global map + +MWBase::Environment::get().getDialogueManager()->countSavedGameRecords() + +1 // global map ); writer.save (stream); @@ -203,6 +204,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot writer.endRecord (ESM::REC_SAVE); MWBase::Environment::get().getJournal()->write (writer); + MWBase::Environment::get().getDialogueManager()->write (writer); MWBase::Environment::get().getWorld()->write (writer); MWBase::Environment::get().getScriptManager()->getGlobalScripts().write (writer); MWBase::Environment::get().getWindowManager()->write(writer); @@ -245,6 +247,11 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl MWBase::Environment::get().getJournal()->readRecord (reader, n.val); break; + case ESM::REC_DIAS: + + MWBase::Environment::get().getDialogueManager()->readRecord (reader, n.val); + break; + case ESM::REC_ALCH: case ESM::REC_ARMO: case ESM::REC_BOOK: diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 45a91f368c..e6b89c08e9 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -44,7 +44,7 @@ add_component_dir (esm loadinfo loadingr loadland loadlevlist loadligh loadlock loadprob loadrepa loadltex loadmgef loadmisc loadnpcc loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter - savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate + savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate dialoguestate ) add_component_dir (misc diff --git a/components/esm/defs.hpp b/components/esm/defs.hpp index 1b0125e78b..c1f1679924 100644 --- a/components/esm/defs.hpp +++ b/components/esm/defs.hpp @@ -91,6 +91,7 @@ enum RecNameInts REC_PLAY = 0x59414c50, REC_CSTA = 0x41545343, REC_GMAP = 0x50414d47, + REC_DIAS = 0x53414944, // format 1 REC_FILT = 0x544C4946 diff --git a/components/esm/dialoguestate.cpp b/components/esm/dialoguestate.cpp new file mode 100644 index 0000000000..b3544c85ce --- /dev/null +++ b/components/esm/dialoguestate.cpp @@ -0,0 +1,21 @@ + +#include "dialoguestate.hpp" + +#include "esmreader.hpp" +#include "esmwriter.hpp" + +void ESM::DialogueState::load (ESMReader &esm) +{ + while (esm.isNextSub ("TOPI")) + mKnownTopics.push_back (esm.getHString()); +} + +void ESM::DialogueState::save (ESMWriter &esm) const +{ + for (std::vector::const_iterator iter (mKnownTopics.begin()); + iter!=mKnownTopics.end(); ++iter) + { + esm.writeHNString ("TOPI", *iter); + + } +} \ No newline at end of file diff --git a/components/esm/dialoguestate.hpp b/components/esm/dialoguestate.hpp new file mode 100644 index 0000000000..9aa9eaefd3 --- /dev/null +++ b/components/esm/dialoguestate.hpp @@ -0,0 +1,23 @@ +#ifndef OPENMW_ESM_DIALOGUESTATE_H +#define OPENMW_ESM_DIALOGUESTATE_H + +#include +#include + +namespace ESM +{ + class ESMReader; + class ESMWriter; + + // format 0, saved games only + + struct DialogueState + { + std::vector mKnownTopics; + + void load (ESMReader &esm); + void save (ESMWriter &esm) const; + }; +} + +#endif \ No newline at end of file From b0532e0c8528828bcaf6d3af5ffdaccf00dc509b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 16 Feb 2014 15:06:34 +0100 Subject: [PATCH 121/171] store NPC state in saved game files --- apps/openmw/mwclass/npc.cpp | 12 ++- apps/openmw/mwmechanics/npcstats.cpp | 77 ++++++++++++++++ apps/openmw/mwmechanics/npcstats.hpp | 5 + apps/openmw/mwmechanics/stat.cpp | 29 ++++++ apps/openmw/mwmechanics/stat.hpp | 10 ++ components/CMakeLists.txt | 3 +- components/esm/npcstate.cpp | 8 ++ components/esm/npcstate.hpp | 4 + components/esm/npcstats.cpp | 133 +++++++++++++++++++++++++++ components/esm/npcstats.hpp | 54 +++++++++++ components/esm/statstate.hpp | 53 +++++++++++ 11 files changed, 383 insertions(+), 5 deletions(-) create mode 100644 apps/openmw/mwmechanics/stat.cpp create mode 100644 components/esm/npcstats.cpp create mode 100644 components/esm/npcstats.hpp create mode 100644 components/esm/statstate.hpp diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 34ea515bab..7e67738d44 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1278,8 +1278,10 @@ namespace MWClass ensureCustomData (ptr); - dynamic_cast (*ptr.getRefData().getCustomData()).mInventoryStore. - readState (state2.mInventory); + CustomData& customData = dynamic_cast (*ptr.getRefData().getCustomData()); + + customData.mInventoryStore.readState (state2.mInventory); + customData.mNpcStats.readState (state2.mNpcStats); } void Npc::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) @@ -1289,8 +1291,10 @@ namespace MWClass ensureCustomData (ptr); - dynamic_cast (*ptr.getRefData().getCustomData()).mInventoryStore. - writeState (state2.mInventory); + CustomData& customData = dynamic_cast (*ptr.getRefData().getCustomData()); + + customData.mInventoryStore.writeState (state2.mInventory); + customData.mNpcStats.writeState (state2.mNpcStats); } const ESM::GameSetting *Npc::fMinWalkSpeed; diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 63b4467f6d..786d35b9cb 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "../mwworld/class.hpp" #include "../mwworld/esmstore.hpp" @@ -423,3 +424,79 @@ void MWMechanics::NpcStats::setTimeToStartDrowning(float time) assert(time>=0 && time<=20); mTimeToStartDrowning=time; } + +void MWMechanics::NpcStats::writeState (ESM::NpcStats& state) const +{ + for (std::map::const_iterator iter (mFactionRank.begin()); + iter!=mFactionRank.end(); ++iter) + state.mFactions[iter->first].mRank = iter->second; + + state.mDisposition = mDisposition; + + for (int i=0; i<27; ++i) + { + mSkill[i].writeState (state.mSkills[i].mRegular); + mWerewolfSkill[i].writeState (state.mSkills[i].mWerewolf); + state.mSkills[i].mIncrease = mSkillIncreases[i]; + } + + state.mBounty = mBounty; + + for (std::set::const_iterator iter (mExpelled.begin()); + iter!=mExpelled.end(); ++iter) + state.mFactions[*iter].mExpelled = true; + + for (std::map::const_iterator iter (mFactionReputation.begin()); + iter!=mFactionReputation.end(); ++iter) + state.mFactions[iter->first].mReputation = iter->second; + + state.mReputation = mReputation; + state.mWerewolfKills = mWerewolfKills; + state.mProfit = mProfit; + state.mAttackStrength = mAttackStrength; + state.mLevelProgress = mLevelProgress; + + std::copy (mUsedIds.begin(), mUsedIds.end(), std::back_inserter (state.mUsedIds)); + + state.mTimeToStartDrowning = mTimeToStartDrowning; + state.mLastDrowningHit = mLastDrowningHit; + state.mLevelHealthBonus = mLevelHealthBonus; +} + +void MWMechanics::NpcStats::readState (const ESM::NpcStats& state) +{ + for (std::map::const_iterator iter (state.mFactions.begin()); + iter!=state.mFactions.end(); ++iter) + { + if (iter->second.mExpelled) + mExpelled.insert (iter->first); + + if (iter->second.mRank) + mFactionRank.insert (std::make_pair (iter->first, iter->second.mRank)); + + if (iter->second.mReputation) + mFactionReputation.insert (std::make_pair (iter->first, iter->second.mReputation)); + } + + mDisposition = state.mDisposition; + + for (int i=0; i<27; ++i) + { + mSkill[i].readState (state.mSkills[i].mRegular); + mWerewolfSkill[i].readState (state.mSkills[i].mWerewolf); + mSkillIncreases[i] = state.mSkills[i].mIncrease; + } + + mBounty = state.mBounty; + mReputation = state.mReputation; + mWerewolfKills = state.mWerewolfKills; + mProfit = state.mProfit; + mAttackStrength = state.mAttackStrength; + mLevelProgress = state.mLevelProgress; + + std::copy (state.mUsedIds.begin(), state.mUsedIds.end(), std::inserter (mUsedIds, mUsedIds.begin())); + + mTimeToStartDrowning = state.mTimeToStartDrowning; + mLastDrowningHit = state.mLastDrowningHit; + mLevelHealthBonus = state.mLevelHealthBonus; +} \ No newline at end of file diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index d7db999e45..ad493be3c1 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -13,6 +13,7 @@ namespace ESM { struct Class; + struct NpcStats; } namespace MWMechanics @@ -128,6 +129,10 @@ namespace MWMechanics /// Sets time left for the creature to drown if it stays underwater. /// @param time value from [0,20] void setTimeToStartDrowning(float time); + + void writeState (ESM::NpcStats& state) const; + + void readState (const ESM::NpcStats& state); }; } diff --git a/apps/openmw/mwmechanics/stat.cpp b/apps/openmw/mwmechanics/stat.cpp new file mode 100644 index 0000000000..61b6d60ad4 --- /dev/null +++ b/apps/openmw/mwmechanics/stat.cpp @@ -0,0 +1,29 @@ + +#include "stat.hpp" + +void MWMechanics::AttributeValue::writeState (ESM::StatState& state) const +{ + state.mBase = mBase; + state.mMod = mModifier; + state.mDamage = mDamage; +} + +void MWMechanics::AttributeValue::readState (const ESM::StatState& state) +{ + mBase = state.mBase; + mModifier = state.mMod; + mDamage = state.mDamage; +} + + +void MWMechanics::SkillValue::writeState (ESM::StatState& state) const +{ + AttributeValue::writeState (state); + state.mProgress = mProgress; +} + +void MWMechanics::SkillValue::readState (const ESM::StatState& state) +{ + AttributeValue::readState (state); + mProgress = state.mProgress; +} \ No newline at end of file diff --git a/apps/openmw/mwmechanics/stat.hpp b/apps/openmw/mwmechanics/stat.hpp index 75ac6939aa..28005966a0 100644 --- a/apps/openmw/mwmechanics/stat.hpp +++ b/apps/openmw/mwmechanics/stat.hpp @@ -6,6 +6,8 @@ #include +#include + namespace MWMechanics { template @@ -225,6 +227,10 @@ namespace MWMechanics void damage(int damage) { mDamage += damage; } void restore(int amount) { mDamage -= std::min(mDamage, amount); } int getDamage() const { return mDamage; } + + void writeState (ESM::StatState& state) const; + + void readState (const ESM::StatState& state); }; class SkillValue : public AttributeValue @@ -234,6 +240,10 @@ namespace MWMechanics SkillValue() : mProgress(0) {} float getProgress() const { return mProgress; } void setProgress(float progress) { mProgress = progress; } + + void writeState (ESM::StatState& state) const; + + void readState (const ESM::StatState& state); }; inline bool operator== (const AttributeValue& left, const AttributeValue& right) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index e6b89c08e9..8665938630 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -44,7 +44,8 @@ add_component_dir (esm loadinfo loadingr loadland loadlevlist loadligh loadlock loadprob loadrepa loadltex loadmgef loadmisc loadnpcc loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter - savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate dialoguestate + savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate dialoguestate statstate + npcstats ) add_component_dir (misc diff --git a/components/esm/npcstate.cpp b/components/esm/npcstate.cpp index c452611a0a..e59ec3e268 100644 --- a/components/esm/npcstate.cpp +++ b/components/esm/npcstate.cpp @@ -6,6 +6,10 @@ void ESM::NpcState::load (ESMReader &esm) ObjectState::load (esm); mInventory.load (esm); + + mNpcStats.load (esm); + + mCreatureStats.load (esm); } void ESM::NpcState::save (ESMWriter &esm, bool inInventory) const @@ -13,4 +17,8 @@ void ESM::NpcState::save (ESMWriter &esm, bool inInventory) const ObjectState::save (esm, inInventory); mInventory.save (esm); + + mNpcStats.save (esm); + + mCreatureStats.save (esm); } \ No newline at end of file diff --git a/components/esm/npcstate.hpp b/components/esm/npcstate.hpp index ceb18b88b6..39858d5533 100644 --- a/components/esm/npcstate.hpp +++ b/components/esm/npcstate.hpp @@ -3,6 +3,8 @@ #include "objectstate.hpp" #include "inventorystate.hpp" +#include "npcstats.hpp" +#include "creaturestats.hpp" namespace ESM { @@ -11,6 +13,8 @@ namespace ESM struct NpcState : public ObjectState { InventoryState mInventory; + NpcStats mNpcStats; + CreatureStats mCreatureStats; virtual void load (ESMReader &esm); virtual void save (ESMWriter &esm, bool inInventory = false) const; diff --git a/components/esm/npcstats.cpp b/components/esm/npcstats.cpp new file mode 100644 index 0000000000..531424ab23 --- /dev/null +++ b/components/esm/npcstats.cpp @@ -0,0 +1,133 @@ + +#include "npcstats.hpp" + +#include "esmreader.hpp" +#include "esmwriter.hpp" + +ESM::NpcStats::Faction::Faction() : mExpelled (false), mRank (0), mReputation (0) {} + +void ESM::NpcStats::load (ESMReader &esm) +{ + while (esm.isNextSub ("FACT")) + { + std::string id = esm.getHString(); + + Faction faction; + + int expelled = 0; + esm.getHNOT (expelled, "FAEX"); + + if (expelled) + faction.mExpelled = true; + + esm.getHNOT (faction.mRank, "FARA"); + + esm.getHNOT (faction.mReputation, "FARE"); + + mFactions.insert (std::make_pair (id, faction)); + } + + mDisposition = 0; + esm.getHNOT (mDisposition, "DISP"); + + for (int i=0; i<27; ++i) + { + mSkills[i].mRegular.load (esm); + mSkills[i].mWerewolf.load (esm); + } + + mBounty = 0; + esm.getHNOT (mBounty, "BOUN"); + + mReputation = 0; + esm.getHNOT (mReputation, "REPU"); + + mWerewolfKills = 0; + esm.getHNOT (mWerewolfKills, "WKIL"); + + mProfit = 0; + esm.getHNOT (mProfit, "PROF"); + + mAttackStrength = 0; + esm.getHNOT (mAttackStrength, "ASTR"); + + mLevelProgress = 0; + esm.getHNOT (mLevelProgress, "LPRO"); + + esm.getHNT (mSkillIncrease, "INCR"); + + while (esm.isNextSub ("USED")) + mUsedIds.push_back (esm.getHString()); + + mTimeToStartDrowning = 0; + esm.getHNOT (mTimeToStartDrowning, "DRTI"); + + mLastDrowningHit = 0; + esm.getHNOT (mLastDrowningHit, "DRLH"); + + mLevelHealthBonus = 0; + esm.getHNOT (mLevelHealthBonus, "LVLH"); +} + +void ESM::NpcStats::save (ESMWriter &esm) const +{ + for (std::map::const_iterator iter (mFactions.begin()); + iter!=mFactions.end(); ++iter) + { + esm.writeHNString ("FACT", iter->first); + + if (iter->second.mExpelled) + { + int expelled = 1; + esm.writeHNT ("FAEX", expelled); + } + + if (iter->second.mRank) + esm.writeHNT ("FARA", iter->second.mRank); + + if (iter->second.mReputation) + esm.writeHNT ("FARE", iter->second.mReputation); + } + + if (mDisposition) + esm.writeHNT ("DISP", mDisposition); + + for (int i=0; i<27; ++i) + { + mSkills[i].mRegular.save (esm); + mSkills[i].mWerewolf.save (esm); + } + + if (mBounty) + esm.writeHNT ("BOUN", mBounty); + + if (mReputation) + esm.writeHNT ("REPU", mReputation); + + if (mWerewolfKills) + esm.writeHNT ("WKIL", mWerewolfKills); + + if (mProfit) + esm.writeHNT ("PROF", mProfit); + + if (mAttackStrength) + esm.writeHNT ("ASTR", mAttackStrength); + + if (mLevelProgress) + esm.writeHNT ("LPRO", mLevelProgress); + + esm.writeHNT ("INCR", mSkillIncrease); + + for (std::vector::const_iterator iter (mUsedIds.begin()); iter!=mUsedIds.end(); + ++iter) + esm.writeHNT ("USED", *iter); + + if (mTimeToStartDrowning) + esm.writeHNT ("DRTI", mTimeToStartDrowning); + + if (mLastDrowningHit) + esm.writeHNT ("DRLH", mLastDrowningHit); + + if (mLevelHealthBonus) + esm.writeHNT ("LVLH", mLevelHealthBonus); +} \ No newline at end of file diff --git a/components/esm/npcstats.hpp b/components/esm/npcstats.hpp new file mode 100644 index 0000000000..b3f70db252 --- /dev/null +++ b/components/esm/npcstats.hpp @@ -0,0 +1,54 @@ +#ifndef OPENMW_ESM_NPCSTATS_H +#define OPENMW_ESM_NPCSTATS_H + +#include +#include +#include + +#include "statstate.hpp" + +namespace ESM +{ + class ESMReader; + class ESMWriter; + + // format 0, saved games only + + struct NpcStats + { + struct Skill + { + StatState mRegular; + StatState mWerewolf; + }; + + struct Faction + { + bool mExpelled; + int mRank; + int mReputation; + + Faction(); + }; + + std::map mFactions; + int mDisposition; + Skill mSkills[27]; + int mBounty; + int mReputation; + int mWerewolfKills; + int mProfit; + float mAttackStrength; + int mLevelProgress; + int mSkillIncrease[8]; + std::vector mUsedIds; + float mTimeToStartDrowning; + float mLastDrowningHit; + float mLevelHealthBonus; + + void load (ESMReader &esm); + void save (ESMWriter &esm) const; + }; +} + +#endif \ No newline at end of file diff --git a/components/esm/statstate.hpp b/components/esm/statstate.hpp new file mode 100644 index 0000000000..c8b0d6a4d9 --- /dev/null +++ b/components/esm/statstate.hpp @@ -0,0 +1,53 @@ +#ifndef OPENMW_ESM_STATSTATE_H +#define OPENMW_ESM_STATSTATE_H + +#include "esmreader.hpp" +#include "esmwriter.hpp" + +namespace ESM +{ + // format 0, saved games only + + template + struct StatState + { + T mBase; + T mMod; + T mDamage; + float mProgress; + + StatState(); + + void load (ESMReader &esm); + void save (ESMWriter &esm) const; + }; + + template + StatState::StatState() : mBase (0), mMod (0), mDamage (0), mProgress (0) {} + + template + void StatState::load (ESMReader &esm) + { + esm.getHNT (mBase, "STBA"); + esm.getHNT (mMod, "STMO"); + mDamage = 0; + esm.getHNOT (mDamage, "STDA"); + mProgress = 0; + esm.getHNOT (mProgress, "STPR"); + } + + template + void StatState::save (ESMWriter &esm) const + { + esm.writeHNT ("STBA", mBase); + esm.writeHNT ("STMO", mMod); + + if (mDamage) + esm.writeHNT ("STDA", mDamage); + + if (mProgress) + esm.writeHNT ("STPR", mProgress); + } +} + +#endif \ No newline at end of file From 9788bbcab962b8d72f91c3b762ed6d90035e2bec Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 16 Feb 2014 15:56:36 +0100 Subject: [PATCH 122/171] partially store creature state in saved game files (only attributes and dynamics for now) --- apps/openmw/mwclass/creature.cpp | 13 +++++++---- apps/openmw/mwclass/npc.cpp | 2 ++ apps/openmw/mwmechanics/creaturestats.cpp | 19 ++++++++++++++++ apps/openmw/mwmechanics/creaturestats.hpp | 9 ++++++++ apps/openmw/mwmechanics/npcstats.cpp | 8 +++++-- apps/openmw/mwmechanics/stat.hpp | 24 ++++++++++++++++++++ components/CMakeLists.txt | 2 +- components/esm/creaturestate.cpp | 4 ++++ components/esm/creaturestate.hpp | 2 ++ components/esm/creaturestats.cpp | 20 +++++++++++++++++ components/esm/creaturestats.hpp | 27 +++++++++++++++++++++++ components/esm/statstate.hpp | 8 ++++++- 12 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 components/esm/creaturestats.cpp create mode 100644 components/esm/creaturestats.hpp diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 6af8373c55..81ca0ce2bf 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -766,8 +766,11 @@ namespace MWClass ensureCustomData (ptr); - dynamic_cast (*ptr.getRefData().getCustomData()).mContainerStore-> - readState (state2.mInventory); + CustomData& customData = dynamic_cast (*ptr.getRefData().getCustomData()); + + customData.mContainerStore->readState (state2.mInventory); + customData.mCreatureStats.readState (state2.mCreatureStats); + } void Creature::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) @@ -777,8 +780,10 @@ namespace MWClass ensureCustomData (ptr); - dynamic_cast (*ptr.getRefData().getCustomData()).mContainerStore-> - writeState (state2.mInventory); + CustomData& customData = dynamic_cast (*ptr.getRefData().getCustomData()); + + customData.mContainerStore->writeState (state2.mInventory); + customData.mCreatureStats.writeState (state2.mCreatureStats); } const ESM::GameSetting* Creature::fMinWalkSpeedCreature; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 7e67738d44..3a95f3c294 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1282,6 +1282,7 @@ namespace MWClass customData.mInventoryStore.readState (state2.mInventory); customData.mNpcStats.readState (state2.mNpcStats); + static_cast (customData.mNpcStats).readState (state2.mCreatureStats); } void Npc::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) @@ -1295,6 +1296,7 @@ namespace MWClass customData.mInventoryStore.writeState (state2.mInventory); customData.mNpcStats.writeState (state2.mNpcStats); + static_cast (customData.mNpcStats).writeState (state2.mCreatureStats); } const ESM::GameSetting *Npc::fMinWalkSpeed; diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 8f890befba..d61b967390 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -2,6 +2,8 @@ #include +#include + #include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" @@ -457,4 +459,21 @@ namespace MWMechanics mAttackStrength = value; } + void CreatureStats::writeState (ESM::CreatureStats& state) const + { + for (int i=0; i<8; ++i) + mAttributes[i].writeState (state.mAttributes[i]); + + for (int i=0; i<3; ++i) + mDynamic[i].writeState (state.mDynamic[i]); + } + + void CreatureStats::readState (const ESM::CreatureStats& state) + { + for (int i=0; i<8; ++i) + mAttributes[i].readState (state.mAttributes[i]); + + for (int i=0; i<3; ++i) + mDynamic[i].readState (state.mDynamic[i]); + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index bb95833015..94e506fc4f 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -12,6 +12,11 @@ #include "aisequence.hpp" #include "drawstate.hpp" +namespace ESM +{ + struct CreatureStats; +} + namespace MWMechanics { /// \brief Common creature stats @@ -212,6 +217,10 @@ namespace MWMechanics std::set mBoundItems; // Same as above std::map mSummonedCreatures; + + void writeState (ESM::CreatureStats& state) const; + + void readState (const ESM::CreatureStats& state); }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 786d35b9cb..eee27272aa 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -437,7 +437,6 @@ void MWMechanics::NpcStats::writeState (ESM::NpcStats& state) const { mSkill[i].writeState (state.mSkills[i].mRegular); mWerewolfSkill[i].writeState (state.mSkills[i].mWerewolf); - state.mSkills[i].mIncrease = mSkillIncreases[i]; } state.mBounty = mBounty; @@ -456,6 +455,9 @@ void MWMechanics::NpcStats::writeState (ESM::NpcStats& state) const state.mAttackStrength = mAttackStrength; state.mLevelProgress = mLevelProgress; + for (int i=0; i<8; ++i) + state.mSkillIncrease[i] = mSkillIncreases[i]; + std::copy (mUsedIds.begin(), mUsedIds.end(), std::back_inserter (state.mUsedIds)); state.mTimeToStartDrowning = mTimeToStartDrowning; @@ -484,7 +486,6 @@ void MWMechanics::NpcStats::readState (const ESM::NpcStats& state) { mSkill[i].readState (state.mSkills[i].mRegular); mWerewolfSkill[i].readState (state.mSkills[i].mWerewolf); - mSkillIncreases[i] = state.mSkills[i].mIncrease; } mBounty = state.mBounty; @@ -494,6 +495,9 @@ void MWMechanics::NpcStats::readState (const ESM::NpcStats& state) mAttackStrength = state.mAttackStrength; mLevelProgress = state.mLevelProgress; + for (int i=0; i<8; ++i) + mSkillIncreases[i] = state.mSkillIncrease[i]; + std::copy (state.mUsedIds.begin(), state.mUsedIds.end(), std::inserter (mUsedIds, mUsedIds.begin())); mTimeToStartDrowning = state.mTimeToStartDrowning; diff --git a/apps/openmw/mwmechanics/stat.hpp b/apps/openmw/mwmechanics/stat.hpp index 28005966a0..0fb4c57328 100644 --- a/apps/openmw/mwmechanics/stat.hpp +++ b/apps/openmw/mwmechanics/stat.hpp @@ -88,6 +88,18 @@ namespace MWMechanics { mModified = mBase + modifier; } + + void writeState (ESM::StatState& state) const + { + state.mBase = mBase; + state.mMod = mModified; + } + + void readState (const ESM::StatState& state) + { + mBase = state.mBase; + mModified = state.mMod; + } }; template @@ -192,6 +204,18 @@ namespace MWMechanics mStatic.setModifier (modifier); setCurrent (getCurrent()+diff); } + + void writeState (ESM::StatState& state) const + { + mStatic.writeState (state); + state.mCurrent = mCurrent; + } + + void readState (const ESM::StatState& state) + { + mStatic.readState (state); + mCurrent = state.mCurrent; + } }; template diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8665938630..831b140575 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -45,7 +45,7 @@ add_component_dir (esm loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate dialoguestate statstate - npcstats + npcstats creaturestats ) add_component_dir (misc diff --git a/components/esm/creaturestate.cpp b/components/esm/creaturestate.cpp index 43cde30251..9e9b561026 100644 --- a/components/esm/creaturestate.cpp +++ b/components/esm/creaturestate.cpp @@ -6,6 +6,8 @@ void ESM::CreatureState::load (ESMReader &esm) ObjectState::load (esm); mInventory.load (esm); + + mCreatureStats.load (esm); } void ESM::CreatureState::save (ESMWriter &esm, bool inInventory) const @@ -13,4 +15,6 @@ void ESM::CreatureState::save (ESMWriter &esm, bool inInventory) const ObjectState::save (esm, inInventory); mInventory.save (esm); + + mCreatureStats.save (esm); } \ No newline at end of file diff --git a/components/esm/creaturestate.hpp b/components/esm/creaturestate.hpp index f7f9b80380..604c2f3a70 100644 --- a/components/esm/creaturestate.hpp +++ b/components/esm/creaturestate.hpp @@ -3,6 +3,7 @@ #include "objectstate.hpp" #include "inventorystate.hpp" +#include "creaturestats.hpp" namespace ESM { @@ -11,6 +12,7 @@ namespace ESM struct CreatureState : public ObjectState { InventoryState mInventory; + CreatureStats mCreatureStats; virtual void load (ESMReader &esm); virtual void save (ESMWriter &esm, bool inInventory = false) const; diff --git a/components/esm/creaturestats.cpp b/components/esm/creaturestats.cpp new file mode 100644 index 0000000000..fe250089aa --- /dev/null +++ b/components/esm/creaturestats.cpp @@ -0,0 +1,20 @@ + +#include "creaturestats.hpp" + +void ESM::CreatureStats::load (ESMReader &esm) +{ + for (int i=0; i<8; ++i) + mAttributes[i].load (esm); + + for (int i=0; i<3; ++i) + mDynamic[i].load (esm); +} + +void ESM::CreatureStats::save (ESMWriter &esm) const +{ + for (int i=0; i<8; ++i) + mAttributes[i].save (esm); + + for (int i=0; i<3; ++i) + mDynamic[i].save (esm); +} \ No newline at end of file diff --git a/components/esm/creaturestats.hpp b/components/esm/creaturestats.hpp new file mode 100644 index 0000000000..540044f389 --- /dev/null +++ b/components/esm/creaturestats.hpp @@ -0,0 +1,27 @@ +#ifndef OPENMW_ESM_CREATURESTATS_H +#define OPENMW_ESM_CREATURESTATS_H + +#include +#include +#include + +#include "statstate.hpp" + +namespace ESM +{ + class ESMReader; + class ESMWriter; + + // format 0, saved games only + + struct CreatureStats + { + StatState mAttributes[8]; + StatState mDynamic[3]; + + void load (ESMReader &esm); + void save (ESMWriter &esm) const; + }; +} + +#endif \ No newline at end of file diff --git a/components/esm/statstate.hpp b/components/esm/statstate.hpp index c8b0d6a4d9..4b4023bc22 100644 --- a/components/esm/statstate.hpp +++ b/components/esm/statstate.hpp @@ -13,6 +13,7 @@ namespace ESM { T mBase; T mMod; + T mCurrent; T mDamage; float mProgress; @@ -23,13 +24,15 @@ namespace ESM }; template - StatState::StatState() : mBase (0), mMod (0), mDamage (0), mProgress (0) {} + StatState::StatState() : mBase (0), mMod (0), mCurrent (0), mDamage (0), mProgress (0) {} template void StatState::load (ESMReader &esm) { esm.getHNT (mBase, "STBA"); esm.getHNT (mMod, "STMO"); + mCurrent = 0; + esm.getHNOT (mCurrent, "STCU"); mDamage = 0; esm.getHNOT (mDamage, "STDA"); mProgress = 0; @@ -42,6 +45,9 @@ namespace ESM esm.writeHNT ("STBA", mBase); esm.writeHNT ("STMO", mMod); + if (mCurrent) + esm.writeHNT ("STCU", mCurrent); + if (mDamage) esm.writeHNT ("STDA", mDamage); From 4a6186852129332ad34dbb79118a10729d6e8b4f Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 16 Feb 2014 19:01:28 +0400 Subject: [PATCH 123/171] OS X: fixed Ogre plugin packaging --- CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 024527ae55..a9d1f20172 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -668,11 +668,15 @@ if (APPLE) set(ABSOLUTE_PLUGINS ${PLUGIN_ABS} ${ABSOLUTE_PLUGINS}) endforeach () + install(CODE " + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + " COMPONENT Runtime) + # installs used plugins in bundle at given path (bundle_path must be relative to ${CMAKE_INSTALL_PREFIX}) # and returns list of install paths for all installed plugins function (install_plugins_for_bundle bundle_path plugins_var) set(RELATIVE_PLUGIN_INSTALL_BASE "${bundle_path}/Contents/Frameworks") - install(DIRECTORY ${ABSOLUTE_PLUGINS} DESTINATION ${RELATIVE_PLUGIN_INSTALL_BASE} COMPONENT Runtime) set(PLUGINS "") set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${RELATIVE_PLUGIN_INSTALL_BASE}") @@ -680,7 +684,13 @@ if (APPLE) foreach (PLUGIN ${ABSOLUTE_PLUGINS}) get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME) get_filename_component(PLUGIN_RELATIVE_WE ${PLUGIN} NAME_WE) - set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}/${PLUGIN_RELATIVE_WE}") + + set(PLUGIN_DYLIB_IN_BUNDLE "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}/${PLUGIN_RELATIVE_WE}") + set(PLUGINS ${PLUGINS} "${PLUGIN_DYLIB_IN_BUNDLE}") + + install(CODE " + copy_resolved_framework_into_bundle(\"${PLUGIN}/${PLUGIN_RELATIVE_WE}\" \"${PLUGIN_DYLIB_IN_BUNDLE}\") + " COMPONENT Runtime) endforeach () set(${plugins_var} ${PLUGINS} PARENT_SCOPE) @@ -700,6 +710,7 @@ if (APPLE) # Current limitations: # 1. Handles only frameworks, not simple libs INSTALL(CODE " + cmake_policy(SET CMP0009 OLD) set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES}) set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) set(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_SYSTEM_FRAMEWORK_PATH}) @@ -731,9 +742,6 @@ if (APPLE) endif() endfunction(gp_resolve_item_override) - cmake_policy(SET CMP0009 OLD) - set(BU_CHMOD_BUNDLE_ITEMS ON) - include(BundleUtilities) fixup_bundle(\"${OPENMW_APP}\" \"${PLUGINS}\" \"${DIRS}\") fixup_bundle(\"${OPENCS_APP}\" \"${OPENCS_PLUGINS}\" \"${DIRS}\") " COMPONENT Runtime) From c18c3e51ee81e50247fdfa5e8a945a3b0660dc90 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 16 Feb 2014 16:22:09 +0100 Subject: [PATCH 124/171] handle IDs that don't exist anymore after loading --- apps/openmw/mwmechanics/npcstats.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index eee27272aa..8918bfbe70 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -467,18 +467,21 @@ void MWMechanics::NpcStats::writeState (ESM::NpcStats& state) const void MWMechanics::NpcStats::readState (const ESM::NpcStats& state) { + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + for (std::map::const_iterator iter (state.mFactions.begin()); iter!=state.mFactions.end(); ++iter) - { - if (iter->second.mExpelled) - mExpelled.insert (iter->first); + if (store.get().search (iter->first)) + { + if (iter->second.mExpelled) + mExpelled.insert (iter->first); - if (iter->second.mRank) - mFactionRank.insert (std::make_pair (iter->first, iter->second.mRank)); + if (iter->second.mRank) + mFactionRank.insert (std::make_pair (iter->first, iter->second.mRank)); - if (iter->second.mReputation) - mFactionReputation.insert (std::make_pair (iter->first, iter->second.mReputation)); - } + if (iter->second.mReputation) + mFactionReputation.insert (std::make_pair (iter->first, iter->second.mReputation)); + } mDisposition = state.mDisposition; @@ -498,7 +501,10 @@ void MWMechanics::NpcStats::readState (const ESM::NpcStats& state) for (int i=0; i<8; ++i) mSkillIncreases[i] = state.mSkillIncrease[i]; - std::copy (state.mUsedIds.begin(), state.mUsedIds.end(), std::inserter (mUsedIds, mUsedIds.begin())); + for (std::vector::const_iterator iter (state.mUsedIds.begin()); + iter!=state.mUsedIds.end(); ++iter) + if (store.find (*iter)) + mUsedIds.insert (*iter); mTimeToStartDrowning = state.mTimeToStartDrowning; mLastDrowningHit = state.mLastDrowningHit; From 4e28fd85a39782f2c220e3d5804148b2ca072296 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 16 Feb 2014 20:22:46 +0400 Subject: [PATCH 125/171] Fixed build on OS X --- apps/opencs/view/world/table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index c077d5f7fe..3ce90d3a78 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "../../model/world/data.hpp" #include "../../model/world/commands.hpp" From 3cc23a9cb3660347f55008d9c801dcfef3240c7a Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 16 Feb 2014 18:41:42 +0100 Subject: [PATCH 126/171] very basic, but safe putting down " " --- apps/opencs/view/world/scriptedit.cpp | 21 +++++++++++++++++++-- apps/opencs/view/world/scriptedit.hpp | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index ecfaa3ba87..5d80d29047 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -1,6 +1,10 @@ #include "scriptedit.hpp" +#include + #include +#include +#include #include "../../model/world/universalid.hpp" #include "../../model/world/tablemimedata.hpp" @@ -64,8 +68,21 @@ void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event) { if (mAllowedTypes.contains (it->getType())) { - QString::fromStdString ('"' + it->getId() + '"'); + if (stringNeedsQuote(it->getId())) + { + insertPlainText(QString::fromStdString ('"' + it->getId() + '"')); + } else { + insertPlainText(QString::fromStdString (it->getId())); + } } } } -} \ No newline at end of file +} + +bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) +{ + QString string(QString::fromStdString(id)); // is only for c++11, so let's use qregexp for now. + //I'm not quite sure when do we need to put quotes. To be safe we will use quotes for anything other thanā€¦ + QRegExp regexp("^[a-z]{1}[a-z|0-9]{0,}$", Qt::CaseInsensitive); + return !(string.contains(regexp)); +} diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index dc97382b34..afad120485 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -30,6 +30,8 @@ namespace CSVWorld void dropEvent (QDropEvent* event); void dragMoveEvent (QDragMoveEvent* event); + + bool stringNeedsQuote(const std::string& id); }; } #endif // SCRIPTEDIT_H \ No newline at end of file From b83817e05e7f2dd9e519edb1f71be9c0ae7ca602 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 16 Feb 2014 20:18:28 +0100 Subject: [PATCH 127/171] May only include alphanumeric characters and underscores and may not start with a number. --- apps/opencs/view/world/scriptedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 5d80d29047..1e1bb0e2e3 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -83,6 +83,6 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) { QString string(QString::fromStdString(id)); // is only for c++11, so let's use qregexp for now. //I'm not quite sure when do we need to put quotes. To be safe we will use quotes for anything other thanā€¦ - QRegExp regexp("^[a-z]{1}[a-z|0-9]{0,}$", Qt::CaseInsensitive); + QRegExp regexp("^[a-z]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive); return !(string.contains(regexp)); } From e1a0f60041f5ff0d2f7a8970cab33a3c551e904c Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 16 Feb 2014 20:26:22 +0100 Subject: [PATCH 128/171] allow _foo ids without qoute --- apps/opencs/view/world/scriptedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 1e1bb0e2e3..79b123ee47 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -83,6 +83,6 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) { QString string(QString::fromStdString(id)); // is only for c++11, so let's use qregexp for now. //I'm not quite sure when do we need to put quotes. To be safe we will use quotes for anything other thanā€¦ - QRegExp regexp("^[a-z]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive); + QRegExp regexp("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive); return !(string.contains(regexp)); } From 5e8cb2e4667abe4dfded326897347b7a124623f6 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Mon, 17 Feb 2014 02:35:13 +0400 Subject: [PATCH 129/171] Another attempt to fix #1041. This time I'm sending real data from decoder once after playback started. --- apps/openmw/mwsound/openal_output.cpp | 33 +++++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 9dc0b8c5db..7563ad0150 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -172,6 +172,7 @@ class OpenAL_SoundStream : public Sound DecoderPtr mDecoder; volatile bool mIsFinished; + volatile bool mIsInitialBatchEnqueued; void updateAll(bool local); @@ -264,7 +265,7 @@ private: OpenAL_SoundStream::OpenAL_SoundStream(OpenAL_Output &output, ALuint src, DecoderPtr decoder, float basevol, float pitch, int flags) : Sound(Ogre::Vector3(0.0f), 1.0f, basevol, pitch, 1.0f, 1000.0f, flags) - , mOutput(output), mSource(src), mSamplesQueued(0), mDecoder(decoder), mIsFinished(true) + , mOutput(output), mSource(src), mSamplesQueued(0), mDecoder(decoder), mIsFinished(true), mIsInitialBatchEnqueued(false) { throwALerror(); @@ -315,16 +316,8 @@ void OpenAL_SoundStream::play() alSourcei(mSource, AL_BUFFER, 0); throwALerror(); mSamplesQueued = 0; - - for(ALuint i = 0;i < sNumBuffers;i++) - alBufferData(mBuffers[i], mFormat, this, 0, mSampleRate); - throwALerror(); - - alSourceQueueBuffers(mSource, sNumBuffers, mBuffers); - alSourcePlay(mSource); - throwALerror(); - mIsFinished = false; + mIsInitialBatchEnqueued = false; mOutput.mStreamThread->add(this); } @@ -332,6 +325,7 @@ void OpenAL_SoundStream::stop() { mOutput.mStreamThread->remove(this); mIsFinished = true; + mIsInitialBatchEnqueued = false; alSourceStop(mSource); alSourcei(mSource, AL_BUFFER, 0); @@ -444,6 +438,24 @@ bool OpenAL_SoundStream::process() } while(processed > 0); throwALerror(); } + else if (!mIsInitialBatchEnqueued) { // nothing enqueued yet + std::vector data(mBufferSize); + + for(ALuint i = 0;i < sNumBuffers && !finished;i++) + { + size_t got = mDecoder->read(&data[0], data.size()); + finished = (got < data.size()); + if(got > 0) + { + ALuint bufid = mBuffers[i]; + alBufferData(bufid, mFormat, &data[0], got, mSampleRate); + alSourceQueueBuffers(mSource, 1, &bufid); + throwALerror(); + mSamplesQueued += getBufferSampleCount(bufid); + } + } + mIsInitialBatchEnqueued = true; + } if(state != AL_PLAYING && state != AL_PAUSED) { @@ -461,6 +473,7 @@ bool OpenAL_SoundStream::process() std::cout<< "Error updating stream \""<getName()<<"\"" < Date: Mon, 17 Feb 2014 02:59:23 +0400 Subject: [PATCH 130/171] #1041 in progress: decode first sample batch right in OpenAL_SoundStream::play() --- apps/openmw/mwsound/openal_output.cpp | 45 +++++++++++++-------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 7563ad0150..58566225bd 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -172,7 +172,6 @@ class OpenAL_SoundStream : public Sound DecoderPtr mDecoder; volatile bool mIsFinished; - volatile bool mIsInitialBatchEnqueued; void updateAll(bool local); @@ -265,7 +264,7 @@ private: OpenAL_SoundStream::OpenAL_SoundStream(OpenAL_Output &output, ALuint src, DecoderPtr decoder, float basevol, float pitch, int flags) : Sound(Ogre::Vector3(0.0f), 1.0f, basevol, pitch, 1.0f, 1000.0f, flags) - , mOutput(output), mSource(src), mSamplesQueued(0), mDecoder(decoder), mIsFinished(true), mIsInitialBatchEnqueued(false) + , mOutput(output), mSource(src), mSamplesQueued(0), mDecoder(decoder), mIsFinished(true) { throwALerror(); @@ -316,8 +315,26 @@ void OpenAL_SoundStream::play() alSourcei(mSource, AL_BUFFER, 0); throwALerror(); mSamplesQueued = 0; - mIsFinished = false; - mIsInitialBatchEnqueued = false; + + std::vector data(mBufferSize); + + bool finished = false; + for(ALuint i = 0;i < sNumBuffers && !finished;i++) + { + size_t got = mDecoder->read(&data[0], data.size()); + finished = (got < data.size()); + if(got > 0) + { + ALuint bufid = mBuffers[i]; + alBufferData(bufid, mFormat, &data[0], got, mSampleRate); + alSourceQueueBuffers(mSource, 1, &bufid); + throwALerror(); + mSamplesQueued += getBufferSampleCount(bufid); + } + } + + mIsFinished = finished; + alSourcePlay(mSource); mOutput.mStreamThread->add(this); } @@ -325,7 +342,6 @@ void OpenAL_SoundStream::stop() { mOutput.mStreamThread->remove(this); mIsFinished = true; - mIsInitialBatchEnqueued = false; alSourceStop(mSource); alSourcei(mSource, AL_BUFFER, 0); @@ -438,24 +454,6 @@ bool OpenAL_SoundStream::process() } while(processed > 0); throwALerror(); } - else if (!mIsInitialBatchEnqueued) { // nothing enqueued yet - std::vector data(mBufferSize); - - for(ALuint i = 0;i < sNumBuffers && !finished;i++) - { - size_t got = mDecoder->read(&data[0], data.size()); - finished = (got < data.size()); - if(got > 0) - { - ALuint bufid = mBuffers[i]; - alBufferData(bufid, mFormat, &data[0], got, mSampleRate); - alSourceQueueBuffers(mSource, 1, &bufid); - throwALerror(); - mSamplesQueued += getBufferSampleCount(bufid); - } - } - mIsInitialBatchEnqueued = true; - } if(state != AL_PLAYING && state != AL_PAUSED) { @@ -473,7 +471,6 @@ bool OpenAL_SoundStream::process() std::cout<< "Error updating stream \""<getName()<<"\"" < Date: Mon, 17 Feb 2014 08:58:55 +0100 Subject: [PATCH 131/171] Improvements. --- apps/opencs/view/world/scriptedit.cpp | 10 +++++----- apps/opencs/view/world/scriptedit.hpp | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 79b123ee47..fccac75b41 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -11,7 +11,8 @@ CSVWorld::ScriptEdit::ScriptEdit (QWidget* parent, const CSMDoc::Document& document) : QTextEdit (parent), - mDocument (document) + mDocument (document), + mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive) { mAllowedTypes < is only for c++11, so let's use qregexp for now. + const QString string(QString::fromStdString(id)); // is only for c++11, so let's use qregexp for now. //I'm not quite sure when do we need to put quotes. To be safe we will use quotes for anything other thanā€¦ - QRegExp regexp("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive); - return !(string.contains(regexp)); + return !(string.contains(mWhiteListQoutes)); } diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index afad120485..b4627c2fee 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -7,6 +7,7 @@ #include "../../model/world/universalid.hpp" class QWidget; +class QRegExp; namespace CSMDoc { @@ -24,6 +25,7 @@ namespace CSVWorld private: QVector mAllowedTypes; const CSMDoc::Document& mDocument; + const QRegExp mWhiteListQoutes; void dragEnterEvent (QDragEnterEvent* event); @@ -31,7 +33,7 @@ namespace CSVWorld void dragMoveEvent (QDragMoveEvent* event); - bool stringNeedsQuote(const std::string& id); + bool stringNeedsQuote(const std::string& id) const; }; } #endif // SCRIPTEDIT_H \ No newline at end of file From e9664d80bd7db5b3d6d4a24a55497faaeb1be271 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 19 Feb 2014 11:22:47 +0100 Subject: [PATCH 132/171] make convert enumns public static --- apps/opencs/model/world/tablemimedata.cpp | 2 +- apps/opencs/model/world/tablemimedata.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index ee37dfce6a..062996a88d 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -121,7 +121,7 @@ bool CSMWorld::TableMimeData::fromDocument (const CSMDoc::Document& document) co return &document == &mDocument; } -CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) const +CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) { switch (type) { diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 010a18acb2..7244b4f2ee 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -50,12 +50,13 @@ namespace CSMWorld UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const; + static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type); + private: std::vector mUniversalId; QStringList mObjectsFormats; const CSMDoc::Document& mDocument; - CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const; }; } #endif // TABLEMIMEDATA_H \ No newline at end of file From ae5d25ac58ad7aeeea5fc1b02ea170904cd758a1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 14:23:27 +0100 Subject: [PATCH 133/171] FindSDL.cmake is unused --- cmake/FindSDL.cmake | 177 -------------------------------------------- 1 file changed, 177 deletions(-) delete mode 100644 cmake/FindSDL.cmake diff --git a/cmake/FindSDL.cmake b/cmake/FindSDL.cmake deleted file mode 100644 index 0dc02f5b60..0000000000 --- a/cmake/FindSDL.cmake +++ /dev/null @@ -1,177 +0,0 @@ -# Locate SDL library -# This module defines -# SDL_LIBRARY, the name of the library to link against -# SDL_FOUND, if false, do not try to link to SDL -# SDL_INCLUDE_DIR, where to find SDL.h -# -# This module responds to the the flag: -# SDL_BUILDING_LIBRARY -# If this is defined, then no SDL_main will be linked in because -# only applications need main(). -# Otherwise, it is assumed you are building an application and this -# module will attempt to locate and set the the proper link flags -# as part of the returned SDL_LIBRARY variable. -# -# Don't forget to include SDLmain.h and SDLmain.m your project for the -# OS X framework based version. (Other versions link to -lSDLmain which -# this module will try to find on your behalf.) Also for OS X, this -# module will automatically add the -framework Cocoa on your behalf. -# -# -# Additional Note: If you see an empty SDL_LIBRARY_TEMP in your configuration -# and no SDL_LIBRARY, it means CMake did not find your SDL library -# (SDL.dll, libsdl.so, SDL.framework, etc). -# Set SDL_LIBRARY_TEMP to point to your SDL library, and configure again. -# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this value -# as appropriate. These values are used to generate the final SDL_LIBRARY -# variable, but when these values are unset, SDL_LIBRARY does not get created. -# -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# l.e.galup 9-20-02 -# -# Modified by Eric Wing. -# Added code to assist with automated building by using environmental variables -# and providing a more controlled/consistent search behavior. -# Added new modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). -# Also corrected the header search path to follow "proper" SDL guidelines. -# Added a search for SDLmain which is needed by some platforms. -# Added a search for threads which is needed by some platforms. -# Added needed compile switches for MinGW. -# -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# SDL_LIBRARY to override this selection or set the CMake environment -# CMAKE_INCLUDE_PATH to modify the search paths. -# -# Note that the header path has changed from SDL/SDL.h to just SDL.h -# This needed to change because "proper" SDL convention -# is #include "SDL.h", not . This is done for portability -# reasons because not all systems place things in SDL/ (see FreeBSD). - -#============================================================================= -# Copyright 2003-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -FIND_PATH(SDL_INCLUDE_DIR SDL.h - HINTS - $ENV{SDLDIR} - PATH_SUFFIXES include/SDL include - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local/include/SDL12 - /usr/local/include/SDL11 # FreeBSD ports - /usr/include/SDL12 - /usr/include/SDL11 - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt -) -#MESSAGE("SDL_INCLUDE_DIR is ${SDL_INCLUDE_DIR}") - -# SDL-1.1 is the name used by FreeBSD ports... -# don't confuse it for the version number. -FIND_LIBRARY(SDL_LIBRARY_TEMP - NAMES SDL SDL-1.1 - HINTS - $ENV{SDLDIR} - PATH_SUFFIXES lib64 lib - PATHS - /sw - /opt/local - /opt/csw - /opt -) - -#MESSAGE("SDL_LIBRARY_TEMP is ${SDL_LIBRARY_TEMP}") - -IF(NOT SDL_BUILDING_LIBRARY) - IF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework") - # Non-OS X framework versions expect you to also dynamically link to - # SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms - # seem to provide SDLmain for compatibility even though they don't - # necessarily need it. - FIND_LIBRARY(SDLMAIN_LIBRARY - NAMES SDLmain SDLmain-1.1 - HINTS - $ENV{SDLDIR} - PATH_SUFFIXES lib64 lib - PATHS - /sw - /opt/local - /opt/csw - /opt - ) - ENDIF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework") -ENDIF(NOT SDL_BUILDING_LIBRARY) - -# SDL may require threads on your system. -# The Apple build may not need an explicit flag because one of the -# frameworks may already provide it. -# But for non-OSX systems, I will use the CMake Threads package. -IF(NOT APPLE) - FIND_PACKAGE(Threads) -ENDIF(NOT APPLE) - -# MinGW needs an additional library, mwindows -# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows -# (Actually on second look, I think it only needs one of the m* libraries.) -IF(MINGW) - SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") -ENDIF(MINGW) - -SET(SDL_FOUND "NO") -IF(SDL_LIBRARY_TEMP) - # For SDLmain - IF(NOT SDL_BUILDING_LIBRARY) - IF(SDLMAIN_LIBRARY) - SET(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP}) - ENDIF(SDLMAIN_LIBRARY) - ENDIF(NOT SDL_BUILDING_LIBRARY) - - # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa. - # CMake doesn't display the -framework Cocoa string in the UI even - # though it actually is there if I modify a pre-used variable. - # I think it has something to do with the CACHE STRING. - # So I use a temporary variable until the end so I can set the - # "real" variable in one-shot. - IF(APPLE) - SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa") - ENDIF(APPLE) - - # For threads, as mentioned Apple doesn't need this. - # In fact, there seems to be a problem if I used the Threads package - # and try using this line, so I'm just skipping it entirely for OS X. - IF(NOT APPLE) - SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) - ENDIF(NOT APPLE) - - # For MinGW library - IF(MINGW) - SET(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP}) - ENDIF(MINGW) - - # Set the final string here so the GUI reflects the final state. - SET(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found") - # Set the temp variable to INTERNAL so it is not seen in the CMake GUI - SET(SDL_LIBRARY_TEMP "${SDL_LIBRARY_TEMP}" CACHE INTERNAL "") - - SET(SDL_FOUND "YES") -ENDIF(SDL_LIBRARY_TEMP) - -#MESSAGE("SDL_LIBRARY is ${SDL_LIBRARY}") - From 90f6cda4cc4781c014352f79230a97a35a5d4a4f Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 14:33:30 +0100 Subject: [PATCH 134/171] Moved includes to appropriate place --- apps/openmw/mwrender/terrainstorage.hpp | 3 +++ components/terrain/storage.hpp | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/terrainstorage.hpp b/apps/openmw/mwrender/terrainstorage.hpp index 5c20359527..f2c4ecae34 100644 --- a/apps/openmw/mwrender/terrainstorage.hpp +++ b/apps/openmw/mwrender/terrainstorage.hpp @@ -1,6 +1,9 @@ #ifndef MWRENDER_TERRAINSTORAGE_H #define MWRENDER_TERRAINSTORAGE_H +#include +#include + #include namespace MWRender diff --git a/components/terrain/storage.hpp b/components/terrain/storage.hpp index 021e01c7e0..9864e9825c 100644 --- a/components/terrain/storage.hpp +++ b/components/terrain/storage.hpp @@ -1,9 +1,6 @@ #ifndef COMPONENTS_TERRAIN_STORAGE_H #define COMPONENTS_TERRAIN_STORAGE_H -#include -#include - #include #include From 439018e7067015975fcca25772838d65730521d5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 15:08:40 +0100 Subject: [PATCH 135/171] Get rid of useless return values --- apps/openmw/mwinput/inputmanagerimp.cpp | 21 ++++++------------- apps/openmw/mwinput/inputmanagerimp.hpp | 10 ++++----- extern/oics/ICSInputControlSystem.h | 18 ++++++++-------- .../oics/ICSInputControlSystem_joystick.cpp | 19 +++++------------ .../oics/ICSInputControlSystem_keyboard.cpp | 10 +++------ extern/oics/ICSInputControlSystem_mouse.cpp | 12 +++-------- extern/sdl4ogre/events.h | 18 ++++++++-------- 7 files changed, 40 insertions(+), 68 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 66d93469c7..8bc6facea0 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -452,7 +452,7 @@ namespace MWInput mInputBinder->adjustMouseRegion(width, height); } - bool InputManager::keyPressed( const SDL_KeyboardEvent &arg ) + void InputManager::keyPressed( const SDL_KeyboardEvent &arg ) { // Cut, copy & paste MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget(); @@ -498,7 +498,6 @@ namespace MWInput if (kc != OIS::KC_UNASSIGNED) MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0); - return true; } void InputManager::textInput(const SDL_TextInputEvent &arg) @@ -509,23 +508,21 @@ namespace MWInput MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::None, *it); } - bool InputManager::keyReleased(const SDL_KeyboardEvent &arg ) + void InputManager::keyReleased(const SDL_KeyboardEvent &arg ) { mInputBinder->keyReleased (arg); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)); - - return true; } - bool InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) + void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) { mInputBinder->mousePressed (arg, id); if (id != SDL_BUTTON_LEFT && id != SDL_BUTTON_RIGHT) - return true; // MyGUI has no use for these events + return; // MyGUI has no use for these events MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id)); if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0) @@ -536,20 +533,16 @@ namespace MWInput MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f); } } - - return true; } - bool InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) + void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) { mInputBinder->mouseReleased (arg, id); MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI(id)); - - return true; } - bool InputManager::mouseMoved(const SFO::MouseMotionEvent &arg ) + void InputManager::mouseMoved(const SFO::MouseMotionEvent &arg ) { mInputBinder->mouseMoved (arg); @@ -597,8 +590,6 @@ namespace MWInput MWBase::Environment::get().getWorld()->setCameraDistance(arg.zrel, true, true); } } - - return true; } void InputManager::windowFocusChange(bool have_focus) diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index d41b4c3f3b..bd3f4954b1 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -86,13 +86,13 @@ namespace MWInput virtual void resetToDefaultBindings(); public: - virtual bool keyPressed(const SDL_KeyboardEvent &arg ); - virtual bool keyReleased( const SDL_KeyboardEvent &arg ); + virtual void keyPressed(const SDL_KeyboardEvent &arg ); + virtual void keyReleased( const SDL_KeyboardEvent &arg ); virtual void textInput (const SDL_TextInputEvent &arg); - virtual bool mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ); - virtual bool mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ); - virtual bool mouseMoved( const SFO::MouseMotionEvent &arg ); + virtual void mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ); + virtual void mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ); + virtual void mouseMoved( const SFO::MouseMotionEvent &arg ); virtual void windowVisibilityChange( bool visible ); virtual void windowFocusChange( bool have_focus ); diff --git a/extern/oics/ICSInputControlSystem.h b/extern/oics/ICSInputControlSystem.h index 907cba5fc0..a83ae539ef 100644 --- a/extern/oics/ICSInputControlSystem.h +++ b/extern/oics/ICSInputControlSystem.h @@ -102,19 +102,19 @@ namespace ICS JoystickIDList& getJoystickIdList(){ return mJoystickIDList; }; // MouseListener - bool mouseMoved(const SFO::MouseMotionEvent &evt); - bool mousePressed(const SDL_MouseButtonEvent &evt, Uint8); - bool mouseReleased(const SDL_MouseButtonEvent &evt, Uint8); + void mouseMoved(const SFO::MouseMotionEvent &evt); + void mousePressed(const SDL_MouseButtonEvent &evt, Uint8); + void mouseReleased(const SDL_MouseButtonEvent &evt, Uint8); // KeyListener - bool keyPressed(const SDL_KeyboardEvent &evt); - bool keyReleased(const SDL_KeyboardEvent &evt); + void keyPressed(const SDL_KeyboardEvent &evt); + void keyReleased(const SDL_KeyboardEvent &evt); // JoyStickListener - bool buttonPressed(const SDL_JoyButtonEvent &evt, int button); - bool buttonReleased(const SDL_JoyButtonEvent &evt, int button); - bool axisMoved(const SDL_JoyAxisEvent &evt, int axis); - bool povMoved(const SDL_JoyHatEvent &evt, int index); + void buttonPressed(const SDL_JoyButtonEvent &evt, int button); + void buttonReleased(const SDL_JoyButtonEvent &evt, int button); + void axisMoved(const SDL_JoyAxisEvent &evt, int axis); + void povMoved(const SDL_JoyHatEvent &evt, int index); //TODO: does this have an SDL equivalent? //bool sliderMoved(const OIS::JoyStickEvent &evt, int index); diff --git a/extern/oics/ICSInputControlSystem_joystick.cpp b/extern/oics/ICSInputControlSystem_joystick.cpp index 8e501d5018..21adc9f74a 100644 --- a/extern/oics/ICSInputControlSystem_joystick.cpp +++ b/extern/oics/ICSInputControlSystem_joystick.cpp @@ -318,7 +318,7 @@ namespace ICS } // joyStick listeners - bool InputControlSystem::buttonPressed(const SDL_JoyButtonEvent &evt, int button) + void InputControlSystem::buttonPressed(const SDL_JoyButtonEvent &evt, int button) { if(mActive) { @@ -354,11 +354,9 @@ namespace ICS mDetectingBindingControl, evt.which, button, mDetectingBindingDirection); } } - - return true; } - bool InputControlSystem::buttonReleased(const SDL_JoyButtonEvent &evt, int button) + void InputControlSystem::buttonReleased(const SDL_JoyButtonEvent &evt, int button) { if(mActive) { @@ -371,10 +369,9 @@ namespace ICS } } } - return true; } - bool InputControlSystem::axisMoved(const SDL_JoyAxisEvent &evt, int axis) + void InputControlSystem::axisMoved(const SDL_JoyAxisEvent &evt, int axis) { if(mActive) { @@ -417,12 +414,10 @@ namespace ICS } } } - - return true; } //Here be dragons, apparently - bool InputControlSystem::povMoved(const SDL_JoyHatEvent &evt, int index) + void InputControlSystem::povMoved(const SDL_JoyHatEvent &evt, int index) { if(mActive) { @@ -542,13 +537,11 @@ namespace ICS } } } - - return true; } //TODO: does this have an SDL equivalent? /* - bool InputControlSystem::sliderMoved(const OIS::JoyStickEvent &evt, int index) + void InputControlSystem::sliderMoved(const OIS::JoyStickEvent &evt, int index) { if(mActive) { @@ -590,8 +583,6 @@ namespace ICS } } } - - return true; } */ diff --git a/extern/oics/ICSInputControlSystem_keyboard.cpp b/extern/oics/ICSInputControlSystem_keyboard.cpp index 01d68f7843..0a9a34d63c 100644 --- a/extern/oics/ICSInputControlSystem_keyboard.cpp +++ b/extern/oics/ICSInputControlSystem_keyboard.cpp @@ -85,7 +85,7 @@ namespace ICS return SDLK_UNKNOWN; } - bool InputControlSystem::keyPressed(const SDL_KeyboardEvent &evt) + void InputControlSystem::keyPressed(const SDL_KeyboardEvent &evt) { if(mActive) { @@ -118,11 +118,9 @@ namespace ICS mDetectingBindingControl, evt.keysym.sym, mDetectingBindingDirection); } } - - return true; - } + } - bool InputControlSystem::keyReleased(const SDL_KeyboardEvent &evt) + void InputControlSystem::keyReleased(const SDL_KeyboardEvent &evt) { if(mActive) { @@ -132,8 +130,6 @@ namespace ICS it->second.control->setChangingDirection(Control::STOP); } } - - return true; } void DetectingBindingListener::keyBindingDetected(InputControlSystem* ICS, Control* control diff --git a/extern/oics/ICSInputControlSystem_mouse.cpp b/extern/oics/ICSInputControlSystem_mouse.cpp index 52eb894ed5..be18ebbc0e 100644 --- a/extern/oics/ICSInputControlSystem_mouse.cpp +++ b/extern/oics/ICSInputControlSystem_mouse.cpp @@ -219,7 +219,7 @@ namespace ICS } // mouse Listeners - bool InputControlSystem::mouseMoved(const SFO::MouseMotionEvent& evt) + void InputControlSystem::mouseMoved(const SFO::MouseMotionEvent& evt) { if(mActive) { @@ -304,11 +304,9 @@ namespace ICS } } } - - return true; } - bool InputControlSystem::mousePressed(const SDL_MouseButtonEvent &evt, Uint8 btn) + void InputControlSystem::mousePressed(const SDL_MouseButtonEvent &evt, Uint8 btn) { if(mActive) { @@ -341,11 +339,9 @@ namespace ICS mDetectingBindingControl, btn, mDetectingBindingDirection); } } - - return true; } - bool InputControlSystem::mouseReleased(const SDL_MouseButtonEvent &evt, Uint8 btn) + void InputControlSystem::mouseReleased(const SDL_MouseButtonEvent &evt, Uint8 btn) { if(mActive) { @@ -355,8 +351,6 @@ namespace ICS it->second.control->setChangingDirection(Control::STOP); } } - - return true; } // mouse auto bindings diff --git a/extern/sdl4ogre/events.h b/extern/sdl4ogre/events.h index 48adb45456..0fb4d6f060 100644 --- a/extern/sdl4ogre/events.h +++ b/extern/sdl4ogre/events.h @@ -26,9 +26,9 @@ class MouseListener { public: virtual ~MouseListener() {} - virtual bool mouseMoved( const MouseMotionEvent &arg ) = 0; - virtual bool mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) = 0; - virtual bool mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) = 0; + virtual void mouseMoved( const MouseMotionEvent &arg ) = 0; + virtual void mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) = 0; + virtual void mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) = 0; }; class KeyListener @@ -36,8 +36,8 @@ class KeyListener public: virtual ~KeyListener() {} virtual void textInput (const SDL_TextInputEvent& arg) {} - virtual bool keyPressed(const SDL_KeyboardEvent &arg) = 0; - virtual bool keyReleased(const SDL_KeyboardEvent &arg) = 0; + virtual void keyPressed(const SDL_KeyboardEvent &arg) = 0; + virtual void keyReleased(const SDL_KeyboardEvent &arg) = 0; }; class JoyListener @@ -45,18 +45,18 @@ class JoyListener public: virtual ~JoyListener() {} /** @remarks Joystick button down event */ - virtual bool buttonPressed( const SDL_JoyButtonEvent &evt, int button ) = 0; + virtual void buttonPressed( const SDL_JoyButtonEvent &evt, int button ) = 0; /** @remarks Joystick button up event */ - virtual bool buttonReleased( const SDL_JoyButtonEvent &evt, int button ) = 0; + virtual void buttonReleased( const SDL_JoyButtonEvent &evt, int button ) = 0; /** @remarks Joystick axis moved event */ - virtual bool axisMoved( const SDL_JoyAxisEvent &arg, int axis ) = 0; + virtual void axisMoved( const SDL_JoyAxisEvent &arg, int axis ) = 0; //-- Not so common control events, so are not required --// //! Joystick Event, and povID - virtual bool povMoved( const SDL_JoyHatEvent &arg, int index) {return true;} + virtual void povMoved( const SDL_JoyHatEvent &arg, int index) {} }; class WindowListener From bc376e6649b9d0f6e9f1da01b3410c2b5b9127db Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Feb 2014 17:41:24 +0100 Subject: [PATCH 136/171] Closes #888: Treat "Bip 01" as animation root if existing --- apps/openmw/mwrender/animation.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 44bba90d07..b3aa0cd858 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -285,6 +285,17 @@ void Animation::addAnimSource(const std::string &model) } } + if (grp == 0 && dstval->getNode()->getName() == "Bip01") + { + mNonAccumRoot = dstval->getNode(); + mAccumRoot = mNonAccumRoot->getParent(); + if(!mAccumRoot) + { + std::cerr<< "Non-Accum root for "< Date: Sun, 16 Feb 2014 13:07:32 +0100 Subject: [PATCH 137/171] Terrain: change world bounds from AABB to 4 floats --- apps/openmw/mwrender/terrainstorage.cpp | 6 ++--- apps/openmw/mwrender/terrainstorage.hpp | 2 +- components/terrain/storage.hpp | 2 +- components/terrain/world.cpp | 31 ++++++++++++++----------- components/terrain/world.hpp | 2 +- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwrender/terrainstorage.cpp b/apps/openmw/mwrender/terrainstorage.cpp index 197572db9d..750441f6a7 100644 --- a/apps/openmw/mwrender/terrainstorage.cpp +++ b/apps/openmw/mwrender/terrainstorage.cpp @@ -16,9 +16,9 @@ namespace MWRender { - Ogre::AxisAlignedBox TerrainStorage::getBounds() + void TerrainStorage::getBounds(float& minX, float& maxX, float& minY, float& maxY) { - int minX = 0, minY = 0, maxX = 0, maxY = 0; + minX = 0, minY = 0, maxX = 0, maxY = 0; const MWWorld::ESMStore &esmStore = MWBase::Environment::get().getWorld()->getStore(); @@ -39,8 +39,6 @@ namespace MWRender // since grid coords are at cell origin, we need to add 1 cell maxX += 1; maxY += 1; - - return Ogre::AxisAlignedBox(minX, minY, 0, maxX, maxY, 0); } ESM::Land* TerrainStorage::getLand(int cellX, int cellY) diff --git a/apps/openmw/mwrender/terrainstorage.hpp b/apps/openmw/mwrender/terrainstorage.hpp index f2c4ecae34..2ef014aaf1 100644 --- a/apps/openmw/mwrender/terrainstorage.hpp +++ b/apps/openmw/mwrender/terrainstorage.hpp @@ -17,7 +17,7 @@ namespace MWRender public: /// Get bounds of the whole terrain in cell units - virtual Ogre::AxisAlignedBox getBounds(); + virtual void getBounds(float& minX, float& maxX, float& minY, float& maxY); /// Get the minimum and maximum heights of a terrain chunk. /// @note Should only be called for chunks <= 1 cell, i.e. leafs of the quad tree. diff --git a/components/terrain/storage.hpp b/components/terrain/storage.hpp index 9864e9825c..d8cdab9ec1 100644 --- a/components/terrain/storage.hpp +++ b/components/terrain/storage.hpp @@ -24,7 +24,7 @@ namespace Terrain public: /// Get bounds of the whole terrain in cell units - virtual Ogre::AxisAlignedBox getBounds() = 0; + virtual void getBounds(float& minX, float& maxX, float& minY, float& maxY) = 0; /// Get the minimum and maximum heights of a terrain chunk. /// @note Should only be called for chunks <= 1 cell, i.e. leafs of the quad tree. diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index f4070393d7..4273f227d6 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -62,6 +62,10 @@ namespace Terrain , mShaders(shaders) , mVisible(true) , mLoadingListener(loadingListener) + , mMaxX(0) + , mMinX(0) + , mMaxY(0) + , mMinY(0) { loadingListener->setLabel("Creating terrain"); loadingListener->indicateProgress(); @@ -76,20 +80,21 @@ namespace Terrain mCompositeMapRenderTarget->setAutoUpdated(false); mCompositeMapRenderTarget->addViewport(compositeMapCam); - mBounds = storage->getBounds(); + storage->getBounds(mMinX, mMaxX, mMinY, mMaxY); - int origSizeX = mBounds.getSize().x; - int origSizeY = mBounds.getSize().y; + int origSizeX = mMaxX-mMinX; + int origSizeY = mMaxY-mMinY; // Dividing a quad tree only works well for powers of two, so round up to the nearest one int size = nextPowerOfTwo(std::max(origSizeX, origSizeY)); // Adjust the center according to the new size - Ogre::Vector3 center = mBounds.getCenter() + Ogre::Vector3((size-origSizeX)/2.f, (size-origSizeY)/2.f, 0); + float centerX = (mMinX+mMaxX)/2.f + (size-origSizeX)/2.f; + float centerY = (mMinY+mMaxY)/2.f + (size-origSizeY)/2.f; mRootSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); - mRootNode = new QuadTreeNode(this, Root, size, Ogre::Vector2(center.x, center.y), NULL); + mRootNode = new QuadTreeNode(this, Root, size, Ogre::Vector2(centerX, centerY), NULL); buildQuadTree(mRootNode); loadingListener->indicateProgress(); mRootNode->initAabb(); @@ -122,10 +127,10 @@ namespace Terrain return; } - if (node->getCenter().x - halfSize > mBounds.getMaximum().x - || node->getCenter().x + halfSize < mBounds.getMinimum().x - || node->getCenter().y - halfSize > mBounds.getMaximum().y - || node->getCenter().y + halfSize < mBounds.getMinimum().y ) + if (node->getCenter().x - halfSize > mMaxX + || node->getCenter().x + halfSize < mMinX + || node->getCenter().y - halfSize > mMaxY + || node->getCenter().y + halfSize < mMinY ) // Out of bounds of the actual terrain - this will happen because // we rounded the size up to the next power of two { @@ -162,10 +167,10 @@ namespace Terrain Ogre::AxisAlignedBox World::getWorldBoundingBox (const Ogre::Vector2& center) { - if (center.x > mBounds.getMaximum().x - || center.x < mBounds.getMinimum().x - || center.y > mBounds.getMaximum().y - || center.y < mBounds.getMinimum().y) + if (center.x > mMaxX + || center.x < mMinX + || center.y > mMaxY + || center.y < mMinY) return Ogre::AxisAlignedBox::BOX_NULL; QuadTreeNode* node = findNode(center, mRootNode); Ogre::AxisAlignedBox box = node->getBoundingBox(); diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index b8c1b0a7d6..bf733b889a 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -105,7 +105,7 @@ namespace Terrain Ogre::SceneManager* mCompositeMapSceneMgr; /// Bounds in cell units - Ogre::AxisAlignedBox mBounds; + float mMinX, mMaxX, mMinY, mMaxY; /// Minimum size of a terrain batch along one side (in cell units) float mMinBatchSize; From ebc67a82cf7fda16943353ac834cfeff6ed4e6ca Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 16 Feb 2014 13:12:31 +0100 Subject: [PATCH 138/171] Don't list unnamed quests in the quest book --- apps/openmw/mwgui/journalviewmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/journalviewmodel.cpp b/apps/openmw/mwgui/journalviewmodel.cpp index a0d67b0256..c6bd6d15d2 100644 --- a/apps/openmw/mwgui/journalviewmodel.cpp +++ b/apps/openmw/mwgui/journalviewmodel.cpp @@ -206,9 +206,9 @@ struct JournalViewModelImpl : JournalViewModel const MWDialogue::Quest& quest = i->second; // Unfortunately Morrowind.esm has no quest names, since the quest book was added with tribunal. - if (quest.getName().empty()) - visitor (reinterpret_cast (&i->second), toUtf8Span (i->first)); - else + // Note that even with Tribunal, some quests still don't have quest names. I'm assuming those are not supposed + // to appear in the quest book. + if (!quest.getName().empty()) visitor (reinterpret_cast (&i->second), toUtf8Span (quest.getName())); } } From d25b3ad9cb969967cb7e87b37651668815871130 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 16 Feb 2014 18:48:03 +0100 Subject: [PATCH 139/171] Fix AiCombat for creatures with weapons --- apps/openmw/mwmechanics/aicombat.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 3653587f88..6a49f2f5e0 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -13,7 +13,7 @@ #include "../mwbase/dialoguemanager.hpp" -#include "npcstats.hpp" +#include "creaturestats.hpp" #include "steering.hpp" #include "movement.hpp" #include "character.hpp" // fixme: for getActiveWeapon @@ -138,11 +138,11 @@ namespace MWMechanics { MWMechanics::DrawState_ state = actor.getClass().getCreatureStats(actor).getDrawState(); if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing) - actor.getClass().getNpcStats(actor).setDrawState(MWMechanics::DrawState_Weapon); + actor.getClass().getCreatureStats(actor).setDrawState(MWMechanics::DrawState_Weapon); //Get weapon speed and range MWWorld::ContainerStoreIterator weaponSlot = - MWMechanics::getActiveWeapon(cls.getNpcStats(actor), cls.getInventoryStore(actor), &weaptype); + MWMechanics::getActiveWeapon(cls.getCreatureStats(actor), cls.getInventoryStore(actor), &weaptype); if (weaptype == WeapType_HandToHand) { const MWWorld::Store &gmst = From dd95ed8e4c197ff5b9c51767c9c89b05020bba74 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 19 Feb 2014 12:32:48 +0100 Subject: [PATCH 140/171] Accept drops on the filterbox --- apps/opencs/view/filter/filterbox.cpp | 18 ++++++++++++++++++ apps/opencs/view/filter/filterbox.hpp | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index 2731708841..e1fb0c6164 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -2,6 +2,7 @@ #include "filterbox.hpp" #include +#include #include "recordfilterbox.hpp" @@ -21,4 +22,21 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) connect (recordFilterBox, SIGNAL (filterChanged (boost::shared_ptr)), this, SIGNAL (recordFilterChanged (boost::shared_ptr))); + + setAcceptDrops(true); +} + +void CSVFilter::FilterBox::dropEvent (QDropEvent* event) +{ + +} + +void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event) +{ + event->acceptProposedAction(); +} + +void CSVFilter::FilterBox::dragMoveEvent (QDragMoveEvent* event) +{ + event->accept(); } \ No newline at end of file diff --git a/apps/opencs/view/filter/filterbox.hpp b/apps/opencs/view/filter/filterbox.hpp index 2524fa0a38..6268643f36 100644 --- a/apps/opencs/view/filter/filterbox.hpp +++ b/apps/opencs/view/filter/filterbox.hpp @@ -16,6 +16,12 @@ namespace CSVFilter { Q_OBJECT + void dragEnterEvent (QDragEnterEvent* event); + + void dropEvent (QDropEvent* event); + + void dragMoveEvent(QDragMoveEvent *event); + public: FilterBox (CSMWorld::Data& data, QWidget *parent = 0); @@ -28,3 +34,4 @@ namespace CSVFilter } #endif + From d7a1abb30bb95bc55d9e60783622f0ae05aeeceb Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 19 Feb 2014 12:55:39 +0100 Subject: [PATCH 141/171] emit signal with types (will be connected to the tablesubview) --- apps/opencs/view/filter/filterbox.cpp | 13 +++++++++++++ apps/opencs/view/filter/filterbox.hpp | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index e1fb0c6164..b191c065f5 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -6,6 +6,8 @@ #include "recordfilterbox.hpp" +#include + CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) : QWidget (parent) { @@ -28,7 +30,18 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) void CSVFilter::FilterBox::dropEvent (QDropEvent* event) { + const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + std::vector records = mime->getData(); + + std::vector types; + + for (std::vector::iterator it = records.begin(); it != records.end(); ++it) + { + types.push_back(it->getType()); + } + + emit recordDropped(types); } void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event) diff --git a/apps/opencs/view/filter/filterbox.hpp b/apps/opencs/view/filter/filterbox.hpp index 6268643f36..a96e7203e9 100644 --- a/apps/opencs/view/filter/filterbox.hpp +++ b/apps/opencs/view/filter/filterbox.hpp @@ -1,9 +1,12 @@ #ifndef CSV_FILTER_FILTERBOX_H #define CSV_FILTER_FILTERBOX_H +#include + #include #include "../../model/filter/node.hpp" +#include "../../model/world/universalid.hpp" namespace CSMWorld { @@ -29,6 +32,7 @@ namespace CSVFilter signals: void recordFilterChanged (boost::shared_ptr filter); + void recordDropped (const std::vector& types); }; } From 85b72409481622c1f29e779f61f61f2f0a9bc64a Mon Sep 17 00:00:00 2001 From: pvdk Date: Wed, 19 Feb 2014 13:43:14 +0100 Subject: [PATCH 142/171] Made the git version retrieval more reliable --- CMakeLists.txt | 44 +++++++++++++++++---------- cmake/GetGitRevisionDescription.cmake | 21 ++++++++++--- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9d1f20172..5451fd1312 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,27 +13,39 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) include(OpenMWMacros) # Version +set(OPENMW_VERSION_MAJOR 0) +set(OPENMW_VERSION_MINOR 29) +set(OPENMW_VERSION_RELEASE 0) -include(GetGitRevisionDescription) +set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") -get_git_tag_revision(TAGHASH --tags --max-count=1 "HEAD...") -get_git_head_revision(REFSPEC COMMITHASH) -git_describe(VERSION --tags ${TAGHASH}) +if(EXISTS ${PROJECT_SOURCE_DIR}/.git) + find_package(Git) -string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" MATCH "${VERSION}") -if (MATCH) - string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${VERSION}") - string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${VERSION}") - string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${VERSION}") + if(GIT_FOUND) + include(GetGitRevisionDescription) + get_git_tag_revision(TAGHASH --tags --max-count=1) + get_git_head_revision(REFSPEC COMMITHASH) + git_describe(VERSION --tags ${TAGHASH}) - set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") - set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}") - set(OPENMW_VERSION_TAGHASH "${TAGHASH}") + string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" MATCH "${VERSION}") + if(MATCH) + string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${VERSION}") + string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${VERSION}") + string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${VERSION}") - message(STATUS "Configuring OpenMW ${OPENMW_VERSION}...") -else (MATCH) - message(FATAL_ERROR "Failed to get valid version information from Git") -endif (MATCH) + set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") + set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}") + set(OPENMW_VERSION_TAGHASH "${TAGHASH}") + + message(STATUS "Configuring OpenMW ${OPENMW_VERSION}...") + else(MATCH) + message(WARNING "Failed to get valid version information from Git") + endif(MATCH) + else(GIT_FOUND) + message(WARNING "Git executable not found") + endif(GIT_FOUND) +endif(EXISTS ${PROJECT_SOURCE_DIR}/.git) # doxygen main page diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake index fecd1654db..216eeb9fb0 100644 --- a/cmake/GetGitRevisionDescription.cmake +++ b/cmake/GetGitRevisionDescription.cmake @@ -85,10 +85,6 @@ function(get_git_head_revision _refspecvar _hashvar) endfunction() function(git_describe _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - #get_git_head_revision(refspec hash) if(NOT GIT_FOUND) @@ -124,6 +120,20 @@ function(git_describe _var) out OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + "--always" + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + if(NOT res EQUAL 0) set(out "${out}-${res}-NOTFOUND") endif() @@ -133,7 +143,8 @@ endfunction() function(get_git_tag_revision _var) if(NOT GIT_FOUND) - find_package(Git QUIET) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() endif() execute_process(COMMAND From b43325119a72009868901f96bea19bca5359fc5e Mon Sep 17 00:00:00 2001 From: pvdk Date: Wed, 19 Feb 2014 14:19:08 +0100 Subject: [PATCH 143/171] Some changes to the version retrieval: ignore shallow clones --- CMakeLists.txt | 58 +++++++++++++++------------ apps/launcher/maindialog.cpp | 23 ++++++----- cmake/GetGitRevisionDescription.cmake | 14 ------- 3 files changed, 46 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5451fd1312..7886168117 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,47 +6,55 @@ if (APPLE) set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/${APP_BUNDLE_NAME}") endif (APPLE) -# Macros - set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) -include(OpenMWMacros) - # Version +message(STATUS "Configuring OpenMW...") + set(OPENMW_VERSION_MAJOR 0) set(OPENMW_VERSION_MINOR 29) set(OPENMW_VERSION_RELEASE 0) +set(OPENMW_VERSION_COMMITHASH "") +set(OPENMW_VERSION_TAGHASH "") + set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") if(EXISTS ${PROJECT_SOURCE_DIR}/.git) - find_package(Git) + if(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git/shallow) + find_package(Git) - if(GIT_FOUND) - include(GetGitRevisionDescription) - get_git_tag_revision(TAGHASH --tags --max-count=1) - get_git_head_revision(REFSPEC COMMITHASH) - git_describe(VERSION --tags ${TAGHASH}) + if(GIT_FOUND) + include(GetGitRevisionDescription) + get_git_tag_revision(TAGHASH --tags --max-count=1) + get_git_head_revision(REFSPEC COMMITHASH) + git_describe(VERSION --tags ${TAGHASH}) - string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" MATCH "${VERSION}") - if(MATCH) - string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${VERSION}") - string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${VERSION}") - string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${VERSION}") + string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" MATCH "${VERSION}") + if(MATCH) + string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${VERSION}") + string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${VERSION}") + string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${VERSION}") - set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") - set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}") - set(OPENMW_VERSION_TAGHASH "${TAGHASH}") + set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") + set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}") + set(OPENMW_VERSION_TAGHASH "${TAGHASH}") - message(STATUS "Configuring OpenMW ${OPENMW_VERSION}...") - else(MATCH) - message(WARNING "Failed to get valid version information from Git") - endif(MATCH) - else(GIT_FOUND) - message(WARNING "Git executable not found") - endif(GIT_FOUND) + message(STATUS "OpenMW version ${OPENMW_VERSION}") + else(MATCH) + message(WARNING "Failed to get valid version information from Git") + endif(MATCH) + else(GIT_FOUND) + message(WARNING "Git executable not found") + endif(GIT_FOUND) + else(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git/shallow) + message(STATUS "Shallow Git clone detected, not attempting to retrieve version info") + endif(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git/shallow) endif(EXISTS ${PROJECT_SOURCE_DIR}/.git) +# Macros +include(OpenMWMacros) + # doxygen main page configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp") diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 56b3186ff3..5cf8f8a892 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -76,17 +76,20 @@ Launcher::MainDialog::MainDialog(QWidget *parent) QString revision(OPENMW_VERSION_COMMITHASH); QString tag(OPENMW_VERSION_TAGHASH); - if (revision == tag) { - versionLabel->setText(tr("OpenMW %0 release").arg(OPENMW_VERSION)); - } else { - versionLabel->setText(tr("OpenMW development (%0)").arg(revision.left(10))); - } + if (!revision.isEmpty() && !tag.isEmpty()) + { + if (revision == tag) { + versionLabel->setText(tr("OpenMW %0 release").arg(OPENMW_VERSION)); + } else { + versionLabel->setText(tr("OpenMW development (%0)").arg(revision.left(10))); + } - // Add the compile date and time - versionLabel->setToolTip(tr("Compiled on %0 %1").arg(QLocale(QLocale::C).toDate(QString(__DATE__).simplified(), - QLatin1String("MMM d yyyy")).toString(Qt::SystemLocaleLongDate), - QLocale(QLocale::C).toTime(QString(__TIME__).simplified(), - QLatin1String("hh:mm:ss")).toString(Qt::SystemLocaleShortDate))); + // Add the compile date and time + versionLabel->setToolTip(tr("Compiled on %0 %1").arg(QLocale(QLocale::C).toDate(QString(__DATE__).simplified(), + QLatin1String("MMM d yyyy")).toString(Qt::SystemLocaleLongDate), + QLocale(QLocale::C).toTime(QString(__TIME__).simplified(), + QLatin1String("hh:mm:ss")).toString(Qt::SystemLocaleShortDate))); + } createIcons(); } diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake index 216eeb9fb0..56ff1d5459 100644 --- a/cmake/GetGitRevisionDescription.cmake +++ b/cmake/GetGitRevisionDescription.cmake @@ -120,20 +120,6 @@ function(git_describe _var) out OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - execute_process(COMMAND - "${GIT_EXECUTABLE}" - describe - "--always" - WORKING_DIRECTORY - "${CMAKE_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - OUTPUT_STRIP_TRAILING_WHITESPACE) - endif() - if(NOT res EQUAL 0) set(out "${out}-${res}-NOTFOUND") endif() From 56d537e23ddd48eca6b9d7c44472f94ab6e616be Mon Sep 17 00:00:00 2001 From: pvdk Date: Wed, 19 Feb 2014 14:37:27 +0100 Subject: [PATCH 144/171] Added some sanity checking: compare git version with manual version --- CMakeLists.txt | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7886168117..ae9ec8ac02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) message(STATUS "Configuring OpenMW...") set(OPENMW_VERSION_MAJOR 0) -set(OPENMW_VERSION_MINOR 29) +set(OPENMW_VERSION_MINOR 28) set(OPENMW_VERSION_RELEASE 0) set(OPENMW_VERSION_COMMITHASH "") @@ -32,13 +32,22 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/.git) string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" MATCH "${VERSION}") if(MATCH) - string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${VERSION}") - string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${VERSION}") - string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${VERSION}") + string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" GIT_VERSION_MAJOR "${VERSION}") + string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" GIT_VERSION_MINOR "${VERSION}") + string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" GIT_VERSION_RELEASE "${VERSION}") - set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") - set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}") - set(OPENMW_VERSION_TAGHASH "${TAGHASH}") + set(GIT_VERSION "${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR}.${GIT_VERSION_RELEASE}") + + if(NOT ${OPENMW_VERSION} STREQUAL ${GIT_VERSION}) + message(FATAL_ERROR "Silly Zini forgot to update the version again...") + else(NOT ${OPENMW_VERSION} STREQUAL ${GIT_VERSION}) + set(OPENMW_VERSION_MAJOR ${GIT_VERSION_MAJOR}) + set(OPENMW_VERSION_MINOR ${GIT_VERSION_MINOR}) + set(OPENMW_VERSION_RELEASE ${GIT_VERSION_RELEASE}) + + set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}") + set(OPENMW_VERSION_TAGHASH "${TAGHASH}") + endif(NOT ${OPENMW_VERSION} STREQUAL ${GIT_VERSION}) message(STATUS "OpenMW version ${OPENMW_VERSION}") else(MATCH) From c0631187c6836b490cbe6268ed37da50ff11de63 Mon Sep 17 00:00:00 2001 From: pvdk Date: Wed, 19 Feb 2014 14:48:33 +0100 Subject: [PATCH 145/171] Removed git tag retrieval for Travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39a02de63e..5d0326a070 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ branches: - /openmw-.*$/ before_install: - pwd - - git fetch --tags - echo "yes" | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" - echo "yes" | sudo apt-add-repository ppa:openmw/openmw - sudo apt-get update -qq From fca7701359473c1320cc782126f1224720edbb7a Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 19 Feb 2014 16:15:51 +0100 Subject: [PATCH 146/171] Column titles retrived and passed to the filterbox. --- apps/opencs/model/world/tablemimedata.cpp | 164 +++++++++++++++++++++- apps/opencs/model/world/tablemimedata.hpp | 1 + apps/opencs/view/filter/filterbox.cpp | 29 ++-- apps/opencs/view/filter/filterbox.hpp | 5 +- apps/opencs/view/world/table.cpp | 18 +++ apps/opencs/view/world/table.hpp | 3 + apps/opencs/view/world/tablesubview.cpp | 21 +++ apps/opencs/view/world/tablesubview.hpp | 2 + 8 files changed, 229 insertions(+), 14 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 062996a88d..6daf9d5542 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -64,6 +64,7 @@ std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const return mUniversalId; } + bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const { for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) @@ -282,4 +283,165 @@ CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::Col break; } } -// kate: indent-mode cstyle; indent-width 4; replace-tabs on; + +CSMWorld::ColumnBase::Display CSMWorld::TableMimeData::convertEnums (CSMWorld::UniversalId::Type type) +{ + switch (type) + { + case CSMWorld::UniversalId::Type_Race: + return CSMWorld::ColumnBase::Display_Race; + break; + + case CSMWorld::UniversalId::Type_Skill: + return CSMWorld::ColumnBase::Display_Skill; + break; + + case CSMWorld::UniversalId::Type_Class: + return CSMWorld::ColumnBase::Display_Class; + break; + + case CSMWorld::UniversalId::Type_Faction: + return CSMWorld::ColumnBase::Display_Faction; + break; + + case CSMWorld::UniversalId::Type_Sound: + return CSMWorld::ColumnBase::Display_Sound; + break; + + case CSMWorld::UniversalId::Type_Region: + return CSMWorld::ColumnBase::Display_Region; + break; + + case CSMWorld::UniversalId::Type_Birthsign: + return CSMWorld::ColumnBase::Display_Birthsign; + break; + + case CSMWorld::UniversalId::Type_Spell: + return CSMWorld::ColumnBase::Display_Spell; + break; + + case CSMWorld::UniversalId::Type_Cell: + return CSMWorld::ColumnBase::Display_Cell; + break; + + case CSMWorld::UniversalId::Type_Referenceable: + return CSMWorld::ColumnBase::Display_Referenceable; + break; + + case CSMWorld::UniversalId::Type_Activator: + return CSMWorld::ColumnBase::Display_Activator; + break; + + case CSMWorld::UniversalId::Type_Potion: + return CSMWorld::ColumnBase::Display_Potion; + break; + + case CSMWorld::UniversalId::Type_Apparatus: + return CSMWorld::ColumnBase::Display_Apparatus; + break; + + case CSMWorld::UniversalId::Type_Armor: + return CSMWorld::ColumnBase::Display_Armor; + break; + + case CSMWorld::UniversalId::Type_Book: + return CSMWorld::ColumnBase::Display_Book; + break; + + case CSMWorld::UniversalId::Type_Clothing: + return CSMWorld::ColumnBase::Display_Clothing; + break; + + case CSMWorld::UniversalId::Type_Container: + return CSMWorld::ColumnBase::Display_Container; + break; + + case CSMWorld::UniversalId::Type_Creature: + return CSMWorld::ColumnBase::Display_Creature; + break; + + case CSMWorld::UniversalId::Type_Door: + return CSMWorld::ColumnBase::Display_Door; + break; + + case CSMWorld::UniversalId::Type_Ingredient: + return CSMWorld::ColumnBase::Display_Ingredient; + break; + + case CSMWorld::UniversalId::Type_CreatureLevelledList: + return CSMWorld::ColumnBase::Display_CreatureLevelledList; + break; + + case CSMWorld::UniversalId::Type_ItemLevelledList: + return CSMWorld::ColumnBase::Display_ItemLevelledList; + break; + + case CSMWorld::UniversalId::Type_Light: + return CSMWorld::ColumnBase::Display_Light; + break; + + case CSMWorld::UniversalId::Type_Lockpick: + return CSMWorld::ColumnBase::Display_Lockpick; + break; + + case CSMWorld::UniversalId::Type_Miscellaneous: + return CSMWorld::ColumnBase::Display_Miscellaneous; + break; + + case CSMWorld::UniversalId::Type_Npc: + return CSMWorld::ColumnBase::Display_Npc; + break; + + case CSMWorld::UniversalId::Type_Probe: + return CSMWorld::ColumnBase::Display_Probe; + break; + + case CSMWorld::UniversalId::Type_Repair: + return CSMWorld::ColumnBase::Display_Repair; + break; + + case CSMWorld::UniversalId::Type_Static: + return CSMWorld::ColumnBase::Display_Static; + break; + + case CSMWorld::UniversalId::Type_Weapon: + return CSMWorld::ColumnBase::Display_Weapon; + break; + + case CSMWorld::UniversalId::Type_Reference: + return CSMWorld::ColumnBase::Display_Reference; + break; + + case CSMWorld::UniversalId::Type_Filter: + return CSMWorld::ColumnBase::Display_Filter; + break; + + case CSMWorld::UniversalId::Type_Topic: + return CSMWorld::ColumnBase::Display_Topic; + break; + + case CSMWorld::UniversalId::Type_Journal: + return CSMWorld::ColumnBase::Display_Journal; + break; + + case CSMWorld::UniversalId::Type_TopicInfo: + return CSMWorld::ColumnBase::Display_TopicInfo; + break; + + case CSMWorld::UniversalId::Type_JournalInfo: + return CSMWorld::ColumnBase::Display_JournalInfo; + break; + + case CSMWorld::UniversalId::Type_Scene: + return CSMWorld::ColumnBase::Display_Scene; + break; + + case CSMWorld::UniversalId::Type_Script: + return CSMWorld::ColumnBase::Display_Script; + break; + + default: + return CSMWorld::ColumnBase::Display_String; + break; + } +} \ No newline at end of file diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 7244b4f2ee..7687f3555f 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -51,6 +51,7 @@ namespace CSMWorld UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const; static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type); + static CSMWorld::ColumnBase::Display convertEnums(CSMWorld::UniversalId::Type type); private: std::vector mUniversalId; diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index b191c065f5..8996060c33 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -30,18 +30,9 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) void CSVFilter::FilterBox::dropEvent (QDropEvent* event) { - const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + std::vector data = dynamic_cast (event->mimeData())->getData(); - std::vector records = mime->getData(); - - std::vector types; - - for (std::vector::iterator it = records.begin(); it != records.end(); ++it) - { - types.push_back(it->getType()); - } - - emit recordDropped(types); + emit recordDropped(data); } void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event) @@ -52,4 +43,18 @@ void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event) void CSVFilter::FilterBox::dragMoveEvent (QDragMoveEvent* event) { event->accept(); -} \ No newline at end of file +} + +void CSVFilter::FilterBox::createFilter (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource) +{ + for (unsigned i = 0; i < filterSource.size(); ++i) //test + { + std::cout< > >& filterSource); + signals: void recordFilterChanged (boost::shared_ptr filter); - void recordDropped (const std::vector& types); + void recordDropped (std::vector& types); }; } diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index f1d89e22cc..2642777cf7 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -507,3 +507,21 @@ void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) { event->accept(); } + +std::vector CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const +{ + int count = mModel->columnCount(); + + std::vector titles; + for (int i = 0; i < count; ++i) + { + CSMWorld::ColumnBase::Display columndisplay = static_cast + (mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + + if (display == columndisplay) + { + titles.push_back(mModel->headerData (i, Qt::Horizontal).toString().toStdString()); + } + } + return titles; +} \ No newline at end of file diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index ff08db06fa..3b72c36d5b 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -8,6 +8,7 @@ #include #include "../../model/filter/node.hpp" +#include "../../model/world/columnbase.hpp" namespace CSMDoc { class Document; @@ -82,6 +83,8 @@ namespace CSVWorld void updateEditorSetting (const QString &settingName, const QString &settingValue); + std::vector getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const; + signals: void editRequest (int row); diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index d379db51a5..e57016d34e 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -4,6 +4,7 @@ #include #include "../../model/doc/document.hpp" +#include "../../model/world/tablemimedata.hpp" #include "../filter/filterbox.hpp" #include "table.hpp" @@ -60,6 +61,12 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D connect (filterBox, SIGNAL (recordFilterChanged (boost::shared_ptr)), mTable, SLOT (recordFilterChanged (boost::shared_ptr))); + + connect(filterBox, SIGNAL(recordDropped(std::vector&)), + this, SLOT(createFilterRequest(std::vector&))); + + connect(this, SIGNAL(createFilterRequest(std::vector > >&)), + filterBox, SLOT(createFilter(std::vector > >&))); } void CSVWorld::TableSubView::setEditLock (bool locked) @@ -87,3 +94,17 @@ void CSVWorld::TableSubView::cloneRequest(const CSMWorld::UniversalId& toClone) { emit cloneRequest(toClone.getId(), toClone.getType()); } + +void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::UniversalId>& types) +{ + std::vector > > filterSource; + + for (std::vector::iterator it = types.begin(); it != types.end(); ++it) + { + std::pair > pair( //splited long line + std::make_pair(it->getId(), mTable->getColumnsWithDisplay(CSMWorld::TableMimeData::convertEnums(it->getType())))); + + filterSource.push_back(pair); + } + emit createFilterRequest(filterSource); +} \ No newline at end of file diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index d728dc2f38..23b62bcd9d 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -42,11 +42,13 @@ namespace CSVWorld signals: void cloneRequest(const std::string&, const CSMWorld::UniversalId::Type); + void createFilterRequest(std::vector > >& filterSource); private slots: void editRequest (int row); void cloneRequest (const CSMWorld::UniversalId& toClone); + void createFilterRequest(std::vector< CSMWorld::UniversalId >& types); }; } From c7b3e139aa622488fd169183483ec13320a6b7b4 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 20 Feb 2014 11:07:04 +0100 Subject: [PATCH 147/171] Propagate signal to the edit widget --- apps/opencs/view/filter/editwidget.cpp | 14 ++++++++++++++ apps/opencs/view/filter/editwidget.hpp | 2 ++ apps/opencs/view/filter/filterbox.cpp | 17 +++-------------- apps/opencs/view/filter/filterbox.hpp | 4 +--- apps/opencs/view/filter/recordfilterbox.cpp | 3 +++ apps/opencs/view/filter/recordfilterbox.hpp | 1 + apps/opencs/view/world/tablesubview.cpp | 2 +- 7 files changed, 25 insertions(+), 18 deletions(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 708d450325..997ecf546d 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -56,3 +56,17 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s { textChanged (text()); } + +void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource) +{ + for (unsigned i = 0; i < filterSource.size(); ++i) //test + { + std::cout< > >& filterSource); }; } diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index 8996060c33..b07df550e4 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -25,6 +25,9 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) SIGNAL (filterChanged (boost::shared_ptr)), this, SIGNAL (recordFilterChanged (boost::shared_ptr))); + connect(this, SIGNAL(createFilterRequest(std::vector > >&)), + recordFilterBox, SIGNAL(createFilterRequest(std::vector > >&))); + setAcceptDrops(true); } @@ -44,17 +47,3 @@ void CSVFilter::FilterBox::dragMoveEvent (QDragMoveEvent* event) { event->accept(); } - -void CSVFilter::FilterBox::createFilter (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource) -{ - for (unsigned i = 0; i < filterSource.size(); ++i) //test - { - std::cout< > >& filterSource); - signals: void recordFilterChanged (boost::shared_ptr filter); void recordDropped (std::vector& types); + void createFilterRequest(std::vector > >& filterSource); }; } diff --git a/apps/opencs/view/filter/recordfilterbox.cpp b/apps/opencs/view/filter/recordfilterbox.cpp index c405177b01..2eaf45ad9c 100644 --- a/apps/opencs/view/filter/recordfilterbox.cpp +++ b/apps/opencs/view/filter/recordfilterbox.cpp @@ -24,4 +24,7 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare connect ( editWidget, SIGNAL (filterChanged (boost::shared_ptr)), this, SIGNAL (filterChanged (boost::shared_ptr))); + + connect(this, SIGNAL(createFilterRequest(std::vector > >&)), + editWidget, SLOT(createFilterRequest(std::vector > >&))); } diff --git a/apps/opencs/view/filter/recordfilterbox.hpp b/apps/opencs/view/filter/recordfilterbox.hpp index 057d69518d..454e341297 100644 --- a/apps/opencs/view/filter/recordfilterbox.hpp +++ b/apps/opencs/view/filter/recordfilterbox.hpp @@ -27,6 +27,7 @@ namespace CSVFilter signals: void filterChanged (boost::shared_ptr filter); + void createFilterRequest(std::vector > >& filterSource); }; } diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index e57016d34e..581daba68d 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -66,7 +66,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D this, SLOT(createFilterRequest(std::vector&))); connect(this, SIGNAL(createFilterRequest(std::vector > >&)), - filterBox, SLOT(createFilter(std::vector > >&))); + filterBox, SIGNAL(createFilterRequest(std::vector > >&))); } void CSVWorld::TableSubView::setEditLock (bool locked) From eb3cbaa4e189b734ab1a454cfb220fc30c8ae294 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 20 Feb 2014 12:25:47 +0100 Subject: [PATCH 148/171] Create filter on droping record. --- apps/opencs/view/filter/editwidget.cpp | 46 +++++++++++++++++++++++++- apps/opencs/view/filter/editwidget.hpp | 3 ++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 997ecf546d..4d77ff02ff 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -2,6 +2,7 @@ #include "editwidget.hpp" #include +#include #include "../../model/world/data.hpp" @@ -59,6 +60,11 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource) { + clear(); + + std::string filter(generateFilter(*filterSource.begin())); + insert(QString::fromStdString(filter)); + for (unsigned i = 0; i < filterSource.size(); ++i) //test { std::cout< >& seekedString) +{ + const unsigned columns = seekedString.second.size(); + + bool multipleColumns = false; + switch (columns) + { + case 0: //empty + return ""; //no column to filter + break; + + case 1: //one column to look for + multipleColumns = false; + break; + + default: + multipleColumns = true; + break; + } + + std::stringstream ss; + if (multipleColumns) + { + ss<<"!or("; + for (unsigned i = 0; i < columns; ++i) + { + ss<<"string("<<'"'< filter); + private: + std::string generateFilter(std::pair >& seekedString); + private slots: void textChanged (const QString& text); From 736644de05555d9e5b9771a63f35ba28e0b228ff Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 20 Feb 2014 12:31:40 +0100 Subject: [PATCH 149/171] Revert "#1041 in progress: decode first sample batch right in OpenAL_SoundStream::play()" This reverts commit 51fb9f65ea5086433fa0d1db12197b133a9b27fd. --- apps/openmw/mwsound/openal_output.cpp | 45 ++++++++++++++------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 58566225bd..7563ad0150 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -172,6 +172,7 @@ class OpenAL_SoundStream : public Sound DecoderPtr mDecoder; volatile bool mIsFinished; + volatile bool mIsInitialBatchEnqueued; void updateAll(bool local); @@ -264,7 +265,7 @@ private: OpenAL_SoundStream::OpenAL_SoundStream(OpenAL_Output &output, ALuint src, DecoderPtr decoder, float basevol, float pitch, int flags) : Sound(Ogre::Vector3(0.0f), 1.0f, basevol, pitch, 1.0f, 1000.0f, flags) - , mOutput(output), mSource(src), mSamplesQueued(0), mDecoder(decoder), mIsFinished(true) + , mOutput(output), mSource(src), mSamplesQueued(0), mDecoder(decoder), mIsFinished(true), mIsInitialBatchEnqueued(false) { throwALerror(); @@ -315,26 +316,8 @@ void OpenAL_SoundStream::play() alSourcei(mSource, AL_BUFFER, 0); throwALerror(); mSamplesQueued = 0; - - std::vector data(mBufferSize); - - bool finished = false; - for(ALuint i = 0;i < sNumBuffers && !finished;i++) - { - size_t got = mDecoder->read(&data[0], data.size()); - finished = (got < data.size()); - if(got > 0) - { - ALuint bufid = mBuffers[i]; - alBufferData(bufid, mFormat, &data[0], got, mSampleRate); - alSourceQueueBuffers(mSource, 1, &bufid); - throwALerror(); - mSamplesQueued += getBufferSampleCount(bufid); - } - } - - mIsFinished = finished; - alSourcePlay(mSource); + mIsFinished = false; + mIsInitialBatchEnqueued = false; mOutput.mStreamThread->add(this); } @@ -342,6 +325,7 @@ void OpenAL_SoundStream::stop() { mOutput.mStreamThread->remove(this); mIsFinished = true; + mIsInitialBatchEnqueued = false; alSourceStop(mSource); alSourcei(mSource, AL_BUFFER, 0); @@ -454,6 +438,24 @@ bool OpenAL_SoundStream::process() } while(processed > 0); throwALerror(); } + else if (!mIsInitialBatchEnqueued) { // nothing enqueued yet + std::vector data(mBufferSize); + + for(ALuint i = 0;i < sNumBuffers && !finished;i++) + { + size_t got = mDecoder->read(&data[0], data.size()); + finished = (got < data.size()); + if(got > 0) + { + ALuint bufid = mBuffers[i]; + alBufferData(bufid, mFormat, &data[0], got, mSampleRate); + alSourceQueueBuffers(mSource, 1, &bufid); + throwALerror(); + mSamplesQueued += getBufferSampleCount(bufid); + } + } + mIsInitialBatchEnqueued = true; + } if(state != AL_PLAYING && state != AL_PAUSED) { @@ -471,6 +473,7 @@ bool OpenAL_SoundStream::process() std::cout<< "Error updating stream \""<getName()<<"\"" < Date: Thu, 20 Feb 2014 12:35:57 +0100 Subject: [PATCH 150/171] fix broken esm writer header code --- components/esm/esmwriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esm/esmwriter.cpp b/components/esm/esmwriter.cpp index f38591b7bf..a29b876e76 100644 --- a/components/esm/esmwriter.cpp +++ b/components/esm/esmwriter.cpp @@ -80,8 +80,8 @@ namespace ESM rec.name = name; rec.position = mStream->tellp(); rec.size = 0; - writeT(0); // Size goes here - writeT(0); // Unused header? + writeT(0); // Size goes here + writeT(0); // Unused header? writeT(flags); mRecords.push_back(rec); From 4fe21dc38f54f49d23a8d5fed641e73e512d2584 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 20 Feb 2014 12:43:09 +0100 Subject: [PATCH 151/171] Const correctness --- apps/opencs/view/filter/editwidget.cpp | 2 +- apps/opencs/view/filter/editwidget.hpp | 2 +- apps/opencs/view/world/table.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 4d77ff02ff..fb1e5bcb2c 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -77,7 +77,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st } } -std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std::vector< std::string > >& seekedString) +std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std::vector< std::string > >& seekedString) const { const unsigned columns = seekedString.second.size(); diff --git a/apps/opencs/view/filter/editwidget.hpp b/apps/opencs/view/filter/editwidget.hpp index f39b0f8e3d..da99c40316 100644 --- a/apps/opencs/view/filter/editwidget.hpp +++ b/apps/opencs/view/filter/editwidget.hpp @@ -34,7 +34,7 @@ namespace CSVFilter void filterChanged (boost::shared_ptr filter); private: - std::string generateFilter(std::pair >& seekedString); + std::string generateFilter(std::pair >& seekedString) const; private slots: diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 2642777cf7..fd0ba0f192 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -510,7 +510,7 @@ void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) std::vector CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const { - int count = mModel->columnCount(); + const int count = mModel->columnCount(); std::vector titles; for (int i = 0; i < count; ++i) From ee7364a8a32d70bb1d0e16df02debf742fd9720f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 20 Feb 2014 12:43:49 +0100 Subject: [PATCH 152/171] updated changelog --- readme.txt | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/readme.txt b/readme.txt index 045b18b8ba..07e89affa1 100644 --- a/readme.txt +++ b/readme.txt @@ -97,6 +97,72 @@ Allowed options: CHANGELOG +0.29.0 + +Bug #556: Video soundtrack not played when music volume is set to zero +Bug #848: Wrong amount of footsteps playing in 1st person +Bug #888: Ascended Sleepers have movement issues +Bug #892: Explicit references are allowed on all script functions +Bug #999: Graphic Herbalism (mod): sometimes doesn't activate properly +Bug #1009: Lake Fjalding AI related slowdown. +Bug #1041: Music playback issues on OS X >= 10.9 +Bug #1043: No message box when advancing skill "Speechcraft" while in dialog window +Bug #1060: Some message boxes are cut off at the bottom +Bug #1062: Bittercup script does not work ('end' variable) +Bug #1074: Inventory paperdoll obscures armour rating +Bug #1077: Message after killing an essential NPC disappears too fast +Bug #1078: "Clutterbane" shows empty charge bar +Bug #1083: UndoWerewolf fails +Bug #1088: Better Clothes Bloodmoon Plus 1.5 by Spirited Treasure pants are not rendered +Bug #1090: Start scripts fail when going to a non-predefined cell +Bug #1091: Crash: Assertion `!q.isNaN() && "Invalid orientation supplied as parameter"' failed. +Bug #1093: Weapons of aggressive NPCs are invisible after you exit and re-enter interior +Bug #1105: Magicka is depleted when using uncastable spells +Bug #1106: Creatures should be able to run +Bug #1107: TR cliffs have way too huge collision boxes in OpenMW +Bug #1109: Cleaning True Light and Darkness with Tes3cmd makes Addamasartus , Zenarbael and Yasamsi flooded. +Bug #1114: Bad output for desktop-file-validate on openmw.desktop (and opencs.desktop) +Bug #1115: Memory leak when spying on Fargoth +Bug #1137: Script execution fails (drenSlaveOwners script) +Bug #1143: Mehra Milo quest (vivec informants) is broken +Bug #1145: Issues with moving gold between inventory and containers +Bug #1146: Issues with picking up stacks of gold +Bug #1147: Dwemer Crossbows are held incorrectly +Bug #1158: Armor rating should always stay below inventory mannequin +Bug #1159: Quick keys can be set during character generation +Bug #1160: Crash on equip lockpick when +Bug #1167: Editor: Referenceables are not correctly loaded when dealing with more than one content file +Feature #30: Loading/Saving (still missing a few parts) +Feature #101: AI Package: Activate +Feature #103: AI Package: Follow, FollowCell +Feature #138: Editor: Drag & Drop +Feature #428: Player death +Feature #505: Editor: Record Cloning +Feature #701: Levelled creatures +Feature #708: Improved Local Variable handling +Feature #709: Editor: Script verifier +Feature #764: Missing journal backend features +Feature #777: Creature weapons/shields +Feature #789: Editor: Referenceable record verifier +Feature #924: Load/Save GUI (still missing loading screen and progress bars) +Feature #946: Knockdown +Feature #947: Decrease fatigue when running, swimming and attacking +Feature #956: Melee Combat: Blocking +Feature #957: Area magic +Feature #960: Combat/AI combat for creatures +Feature #962: Combat-Related AI instructions +Feature #1075: Damage/Restore skill/attribute magic effects +Feature #1076: Soultrap magic effect +Feature #1081: Disease contraction +Feature #1086: Blood particles +Feature #1092: Interrupt resting +Feature #1101: Inventory equip scripts +Feature #1116: Version/Build number in Launcher window +Feature #1119: Resistance/weakness to normal weapons magic effect +Feature #1123: Slow Fall magic effect +Feature #1130: Auto-calculate spells +Feature #1164: Editor: Case-insensitive sorting in tables + 0.28.0 Bug #399: Inventory changes are not visible immediately From c5b2c154f8b3dc69afbefcd2b40cc53577c4d913 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 20 Feb 2014 12:49:56 +0100 Subject: [PATCH 153/171] another esm writer fix --- components/esm/esmwriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esm/esmwriter.cpp b/components/esm/esmwriter.cpp index a29b876e76..ff7bd765d6 100644 --- a/components/esm/esmwriter.cpp +++ b/components/esm/esmwriter.cpp @@ -105,7 +105,7 @@ namespace ESM rec.name = name; rec.position = mStream->tellp(); rec.size = 0; - writeT(0); // Size goes here + writeT(0); // Size goes here mRecords.push_back(rec); assert(mRecords.back().size == 0); From b788ab8b4c0d3870d5020449e7df4aad9d7e93e1 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 20 Feb 2014 14:10:03 +0100 Subject: [PATCH 154/171] correcting --- apps/opencs/model/world/tablemimedata.cpp | 156 +++++++++++----------- apps/opencs/view/filter/editwidget.cpp | 3 +- apps/opencs/view/world/table.cpp | 2 +- 3 files changed, 80 insertions(+), 81 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 6daf9d5542..de7875cc2a 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -128,159 +128,159 @@ CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::Col { case CSMWorld::ColumnBase::Display_Race: return CSMWorld::UniversalId::Type_Race; - break; + case CSMWorld::ColumnBase::Display_Skill: return CSMWorld::UniversalId::Type_Skill; - break; + case CSMWorld::ColumnBase::Display_Class: return CSMWorld::UniversalId::Type_Class; - break; + case CSMWorld::ColumnBase::Display_Faction: return CSMWorld::UniversalId::Type_Faction; - break; + case CSMWorld::ColumnBase::Display_Sound: return CSMWorld::UniversalId::Type_Sound; - break; + case CSMWorld::ColumnBase::Display_Region: return CSMWorld::UniversalId::Type_Region; - break; + case CSMWorld::ColumnBase::Display_Birthsign: return CSMWorld::UniversalId::Type_Birthsign; - break; + case CSMWorld::ColumnBase::Display_Spell: return CSMWorld::UniversalId::Type_Spell; - break; + case CSMWorld::ColumnBase::Display_Cell: return CSMWorld::UniversalId::Type_Cell; - break; + case CSMWorld::ColumnBase::Display_Referenceable: return CSMWorld::UniversalId::Type_Referenceable; - break; + case CSMWorld::ColumnBase::Display_Activator: return CSMWorld::UniversalId::Type_Activator; - break; + case CSMWorld::ColumnBase::Display_Potion: return CSMWorld::UniversalId::Type_Potion; - break; + case CSMWorld::ColumnBase::Display_Apparatus: return CSMWorld::UniversalId::Type_Apparatus; - break; + case CSMWorld::ColumnBase::Display_Armor: return CSMWorld::UniversalId::Type_Armor; - break; + case CSMWorld::ColumnBase::Display_Book: return CSMWorld::UniversalId::Type_Book; - break; + case CSMWorld::ColumnBase::Display_Clothing: return CSMWorld::UniversalId::Type_Clothing; - break; + case CSMWorld::ColumnBase::Display_Container: return CSMWorld::UniversalId::Type_Container; - break; + case CSMWorld::ColumnBase::Display_Creature: return CSMWorld::UniversalId::Type_Creature; - break; + case CSMWorld::ColumnBase::Display_Door: return CSMWorld::UniversalId::Type_Door; - break; + case CSMWorld::ColumnBase::Display_Ingredient: return CSMWorld::UniversalId::Type_Ingredient; - break; + case CSMWorld::ColumnBase::Display_CreatureLevelledList: return CSMWorld::UniversalId::Type_CreatureLevelledList; - break; + case CSMWorld::ColumnBase::Display_ItemLevelledList: return CSMWorld::UniversalId::Type_ItemLevelledList; - break; + case CSMWorld::ColumnBase::Display_Light: return CSMWorld::UniversalId::Type_Light; - break; + case CSMWorld::ColumnBase::Display_Lockpick: return CSMWorld::UniversalId::Type_Lockpick; - break; + case CSMWorld::ColumnBase::Display_Miscellaneous: return CSMWorld::UniversalId::Type_Miscellaneous; - break; + case CSMWorld::ColumnBase::Display_Npc: return CSMWorld::UniversalId::Type_Npc; - break; + case CSMWorld::ColumnBase::Display_Probe: return CSMWorld::UniversalId::Type_Probe; - break; + case CSMWorld::ColumnBase::Display_Repair: return CSMWorld::UniversalId::Type_Repair; - break; + case CSMWorld::ColumnBase::Display_Static: return CSMWorld::UniversalId::Type_Static; - break; + case CSMWorld::ColumnBase::Display_Weapon: return CSMWorld::UniversalId::Type_Weapon; - break; + case CSMWorld::ColumnBase::Display_Reference: return CSMWorld::UniversalId::Type_Reference; - break; + case CSMWorld::ColumnBase::Display_Filter: return CSMWorld::UniversalId::Type_Filter; - break; + case CSMWorld::ColumnBase::Display_Topic: return CSMWorld::UniversalId::Type_Topic; - break; + case CSMWorld::ColumnBase::Display_Journal: return CSMWorld::UniversalId::Type_Journal; - break; + case CSMWorld::ColumnBase::Display_TopicInfo: return CSMWorld::UniversalId::Type_TopicInfo; - break; + case CSMWorld::ColumnBase::Display_JournalInfo: return CSMWorld::UniversalId::Type_JournalInfo; - break; + case CSMWorld::ColumnBase::Display_Scene: return CSMWorld::UniversalId::Type_Scene; - break; + case CSMWorld::ColumnBase::Display_Script: return CSMWorld::UniversalId::Type_Script; - break; + default: return CSMWorld::UniversalId::Type_None; - break; + } } @@ -290,158 +290,158 @@ CSMWorld::ColumnBase::Display CSMWorld::TableMimeData::convertEnums (CSMWorld::U { case CSMWorld::UniversalId::Type_Race: return CSMWorld::ColumnBase::Display_Race; - break; + case CSMWorld::UniversalId::Type_Skill: return CSMWorld::ColumnBase::Display_Skill; - break; + case CSMWorld::UniversalId::Type_Class: return CSMWorld::ColumnBase::Display_Class; - break; + case CSMWorld::UniversalId::Type_Faction: return CSMWorld::ColumnBase::Display_Faction; - break; + case CSMWorld::UniversalId::Type_Sound: return CSMWorld::ColumnBase::Display_Sound; - break; + case CSMWorld::UniversalId::Type_Region: return CSMWorld::ColumnBase::Display_Region; - break; + case CSMWorld::UniversalId::Type_Birthsign: return CSMWorld::ColumnBase::Display_Birthsign; - break; + case CSMWorld::UniversalId::Type_Spell: return CSMWorld::ColumnBase::Display_Spell; - break; + case CSMWorld::UniversalId::Type_Cell: return CSMWorld::ColumnBase::Display_Cell; - break; + case CSMWorld::UniversalId::Type_Referenceable: return CSMWorld::ColumnBase::Display_Referenceable; - break; + case CSMWorld::UniversalId::Type_Activator: return CSMWorld::ColumnBase::Display_Activator; - break; + case CSMWorld::UniversalId::Type_Potion: return CSMWorld::ColumnBase::Display_Potion; - break; + case CSMWorld::UniversalId::Type_Apparatus: return CSMWorld::ColumnBase::Display_Apparatus; - break; + case CSMWorld::UniversalId::Type_Armor: return CSMWorld::ColumnBase::Display_Armor; - break; + case CSMWorld::UniversalId::Type_Book: return CSMWorld::ColumnBase::Display_Book; - break; + case CSMWorld::UniversalId::Type_Clothing: return CSMWorld::ColumnBase::Display_Clothing; - break; + case CSMWorld::UniversalId::Type_Container: return CSMWorld::ColumnBase::Display_Container; - break; + case CSMWorld::UniversalId::Type_Creature: return CSMWorld::ColumnBase::Display_Creature; - break; + case CSMWorld::UniversalId::Type_Door: return CSMWorld::ColumnBase::Display_Door; - break; + case CSMWorld::UniversalId::Type_Ingredient: return CSMWorld::ColumnBase::Display_Ingredient; - break; + case CSMWorld::UniversalId::Type_CreatureLevelledList: return CSMWorld::ColumnBase::Display_CreatureLevelledList; - break; + case CSMWorld::UniversalId::Type_ItemLevelledList: return CSMWorld::ColumnBase::Display_ItemLevelledList; - break; + case CSMWorld::UniversalId::Type_Light: return CSMWorld::ColumnBase::Display_Light; - break; + case CSMWorld::UniversalId::Type_Lockpick: return CSMWorld::ColumnBase::Display_Lockpick; - break; + case CSMWorld::UniversalId::Type_Miscellaneous: return CSMWorld::ColumnBase::Display_Miscellaneous; - break; + case CSMWorld::UniversalId::Type_Npc: return CSMWorld::ColumnBase::Display_Npc; - break; + case CSMWorld::UniversalId::Type_Probe: return CSMWorld::ColumnBase::Display_Probe; - break; + case CSMWorld::UniversalId::Type_Repair: return CSMWorld::ColumnBase::Display_Repair; - break; + case CSMWorld::UniversalId::Type_Static: return CSMWorld::ColumnBase::Display_Static; - break; + case CSMWorld::UniversalId::Type_Weapon: return CSMWorld::ColumnBase::Display_Weapon; - break; + case CSMWorld::UniversalId::Type_Reference: return CSMWorld::ColumnBase::Display_Reference; - break; + case CSMWorld::UniversalId::Type_Filter: return CSMWorld::ColumnBase::Display_Filter; - break; + case CSMWorld::UniversalId::Type_Topic: return CSMWorld::ColumnBase::Display_Topic; - break; + case CSMWorld::UniversalId::Type_Journal: return CSMWorld::ColumnBase::Display_Journal; - break; + case CSMWorld::UniversalId::Type_TopicInfo: return CSMWorld::ColumnBase::Display_TopicInfo; - break; + case CSMWorld::UniversalId::Type_JournalInfo: return CSMWorld::ColumnBase::Display_JournalInfo; - break; + case CSMWorld::UniversalId::Type_Scene: return CSMWorld::ColumnBase::Display_Scene; - break; + case CSMWorld::UniversalId::Type_Script: return CSMWorld::ColumnBase::Display_Script; - break; + default: return CSMWorld::ColumnBase::Display_String; - break; + } } \ No newline at end of file diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index fb1e5bcb2c..2ccef17a86 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -63,7 +63,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st clear(); std::string filter(generateFilter(*filterSource.begin())); - insert(QString::fromStdString(filter)); + insert(QString::fromUtf8(filter.c_str())); for (unsigned i = 0; i < filterSource.size(); ++i) //test { @@ -86,7 +86,6 @@ std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std:: { case 0: //empty return ""; //no column to filter - break; case 1: //one column to look for multipleColumns = false; diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index fd0ba0f192..e242365fed 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -496,7 +496,7 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) CSMWorld::UniversalId record (mime->returnMatching (display)); std::auto_ptr command (new CSMWorld::ModifyCommand - (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + (*mProxyModel, index, QVariant (QString::fromUtf8 (record.getId().c_str())))); mUndoStack.push (command.release()); } From 38a86b5015c2d126d968fc37e025c4df57770184 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 20 Feb 2014 14:13:12 +0100 Subject: [PATCH 155/171] We can handle droping multiple records --- apps/opencs/view/filter/editwidget.cpp | 70 +++++++++++++++++++++----- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 2ccef17a86..5ea99c5dcc 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -60,20 +60,66 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource) { - clear(); + const unsigned count = filterSource.size(); + bool multipleElements = false; - std::string filter(generateFilter(*filterSource.begin())); - insert(QString::fromUtf8(filter.c_str())); - - for (unsigned i = 0; i < filterSource.size(); ++i) //test + switch (count) { - std::cout< Date: Thu, 20 Feb 2014 16:55:51 +0100 Subject: [PATCH 156/171] try with the passing action --- apps/opencs/view/filter/editwidget.cpp | 54 +++++++++++++++++---- apps/opencs/view/filter/editwidget.hpp | 4 +- apps/opencs/view/filter/filterbox.cpp | 6 +-- apps/opencs/view/filter/filterbox.hpp | 6 ++- apps/opencs/view/filter/recordfilterbox.cpp | 4 +- apps/opencs/view/filter/recordfilterbox.hpp | 4 +- apps/opencs/view/world/table.cpp | 16 +++++- apps/opencs/view/world/tablesubview.cpp | 12 ++--- apps/opencs/view/world/tablesubview.hpp | 8 ++- 9 files changed, 87 insertions(+), 27 deletions(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 5ea99c5dcc..0668634930 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "../../model/world/data.hpp" @@ -58,7 +59,8 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s textChanged (text()); } -void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource) +void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource, + Qt::DropAction action) { const unsigned count = filterSource.size(); bool multipleElements = false; @@ -77,9 +79,34 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st break; } + Qt::KeyboardModifiers key = QApplication::keyboardModifiers(); QString oldContent(text()); - bool replaceMode = oldContent.isEmpty() or !oldContent.contains(QRegExp("^!.*$", Qt::CaseInsensitive)); - bool orMode = true; //not orMode = andMode, + + bool replaceMode = false; + bool orMode = true; + + switch (key) + { + case Qt::ShiftModifier: + orMode = true; + replaceMode = false; + break; + + case Qt::ControlModifier: + orMode = false; + replaceMode = false; + break; + + default: + replaceMode = true; + break; + } + + if (oldContent.isEmpty() || + !oldContent.contains(QRegExp("^!.*$", Qt::CaseInsensitive))) + { + replaceMode = true; + } std::string orAnd; if (orMode) @@ -89,12 +116,12 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st orAnd = "and"; } - if (multipleElements) //TODO Currently only 'or' is handled, we should be able to handle 'and' as well and be able to drag records into the EditWidget already filled with the filter + if (multipleElements) //TODO appending to the existing filter { std::stringstream ss; if (replaceMode) { - ss<<'!'<2) + { + clear(); + insert (QString::fromUtf8 (ss.str().c_str())); + } } else { //not handled (yet) TODO } } else { if (replaceMode) { - clear(); - insert ('!' + QString::fromUtf8 (generateFilter(filterSource[0]).c_str())); + std::string filter(generateFilter(filterSource[0])); + + if (!filter.empty()) + { + clear(); + insert ('!' + QString::fromUtf8 (generateFilter(filterSource[0]).c_str())); + } } else { //not handled (yet) TODO } diff --git a/apps/opencs/view/filter/editwidget.hpp b/apps/opencs/view/filter/editwidget.hpp index da99c40316..59fb898837 100644 --- a/apps/opencs/view/filter/editwidget.hpp +++ b/apps/opencs/view/filter/editwidget.hpp @@ -5,6 +5,7 @@ #include #include +#include #include "../../model/filter/parser.hpp" #include "../../model/filter/node.hpp" @@ -46,7 +47,8 @@ namespace CSVFilter void filterRowsInserted (const QModelIndex& parent, int start, int end); - void createFilterRequest(std::vector > >& filterSource); + void createFilterRequest(std::vector > >& filterSource, + Qt::DropAction action); }; } diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index b07df550e4..132beca228 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -25,8 +25,8 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) SIGNAL (filterChanged (boost::shared_ptr)), this, SIGNAL (recordFilterChanged (boost::shared_ptr))); - connect(this, SIGNAL(createFilterRequest(std::vector > >&)), - recordFilterBox, SIGNAL(createFilterRequest(std::vector > >&))); + connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), + recordFilterBox, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction))); setAcceptDrops(true); } @@ -35,7 +35,7 @@ void CSVFilter::FilterBox::dropEvent (QDropEvent* event) { std::vector data = dynamic_cast (event->mimeData())->getData(); - emit recordDropped(data); + emit recordDropped(data, event->proposedAction()); } void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event) diff --git a/apps/opencs/view/filter/filterbox.hpp b/apps/opencs/view/filter/filterbox.hpp index 66de340b4f..0c5ba667bd 100644 --- a/apps/opencs/view/filter/filterbox.hpp +++ b/apps/opencs/view/filter/filterbox.hpp @@ -4,6 +4,7 @@ #include #include +#include #include "../../model/filter/node.hpp" #include "../../model/world/universalid.hpp" @@ -32,8 +33,9 @@ namespace CSVFilter signals: void recordFilterChanged (boost::shared_ptr filter); - void recordDropped (std::vector& types); - void createFilterRequest(std::vector > >& filterSource); + void recordDropped (std::vector& types, Qt::DropAction action); + void createFilterRequest(std::vector > >& filterSource, + Qt::DropAction action); }; } diff --git a/apps/opencs/view/filter/recordfilterbox.cpp b/apps/opencs/view/filter/recordfilterbox.cpp index 2eaf45ad9c..530ce87145 100644 --- a/apps/opencs/view/filter/recordfilterbox.cpp +++ b/apps/opencs/view/filter/recordfilterbox.cpp @@ -25,6 +25,6 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare editWidget, SIGNAL (filterChanged (boost::shared_ptr)), this, SIGNAL (filterChanged (boost::shared_ptr))); - connect(this, SIGNAL(createFilterRequest(std::vector > >&)), - editWidget, SLOT(createFilterRequest(std::vector > >&))); + connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), + editWidget, SLOT(createFilterRequest(std::vector > >&, Qt::DropAction))); } diff --git a/apps/opencs/view/filter/recordfilterbox.hpp b/apps/opencs/view/filter/recordfilterbox.hpp index 454e341297..ac21c840f7 100644 --- a/apps/opencs/view/filter/recordfilterbox.hpp +++ b/apps/opencs/view/filter/recordfilterbox.hpp @@ -4,6 +4,7 @@ #include #include +#include #include @@ -27,7 +28,8 @@ namespace CSVFilter signals: void filterChanged (boost::shared_ptr filter); - void createFilterRequest(std::vector > >& filterSource); + void createFilterRequest(std::vector > >& filterSource, + Qt::DropAction action); }; } diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index e242365fed..f2999bbbde 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -471,7 +472,20 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); - drag->exec(); + + Qt::DropActions action = Qt::IgnoreAction; + switch (QApplication::keyboardModifiers()) + { + case Qt::ControlModifier: + action = Qt::CopyAction; + break; + + case Qt::ShiftModifier: + action = Qt::MoveAction; + break; + } + + drag->exec(action); } } diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 581daba68d..21496dab73 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -62,11 +62,11 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D SIGNAL (recordFilterChanged (boost::shared_ptr)), mTable, SLOT (recordFilterChanged (boost::shared_ptr))); - connect(filterBox, SIGNAL(recordDropped(std::vector&)), - this, SLOT(createFilterRequest(std::vector&))); + connect(filterBox, SIGNAL(recordDropped(std::vector&, Qt::DropAction)), + this, SLOT(createFilterRequest(std::vector&, Qt::DropAction))); - connect(this, SIGNAL(createFilterRequest(std::vector > >&)), - filterBox, SIGNAL(createFilterRequest(std::vector > >&))); + connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), + filterBox, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction))); } void CSVWorld::TableSubView::setEditLock (bool locked) @@ -95,7 +95,7 @@ void CSVWorld::TableSubView::cloneRequest(const CSMWorld::UniversalId& toClone) emit cloneRequest(toClone.getId(), toClone.getType()); } -void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::UniversalId>& types) +void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::UniversalId>& types, Qt::DropAction action) { std::vector > > filterSource; @@ -106,5 +106,5 @@ void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::Univers filterSource.push_back(pair); } - emit createFilterRequest(filterSource); + emit createFilterRequest(filterSource, action); } \ No newline at end of file diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index 23b62bcd9d..e8c75d3a34 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -3,6 +3,8 @@ #include "../doc/subview.hpp" +#include + class QModelIndex; namespace CSMWorld @@ -42,13 +44,15 @@ namespace CSVWorld signals: void cloneRequest(const std::string&, const CSMWorld::UniversalId::Type); - void createFilterRequest(std::vector > >& filterSource); + void createFilterRequest(std::vector > >& filterSource, + Qt::DropAction action); private slots: void editRequest (int row); void cloneRequest (const CSMWorld::UniversalId& toClone); - void createFilterRequest(std::vector< CSMWorld::UniversalId >& types); + void createFilterRequest(std::vector< CSMWorld::UniversalId >& types, + Qt::DropAction action); }; } From 7dff34ebf1f8d4c9b2fcba94dbd3fd4358ffc6de Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 20 Feb 2014 19:15:09 +0100 Subject: [PATCH 157/171] Features implemented. Time to debug. --- apps/opencs/view/filter/editwidget.cpp | 82 +++++++++++++++----------- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 0668634930..624fe3cde3 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -60,7 +60,7 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s } void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource, - Qt::DropAction action) + Qt::DropAction action) { const unsigned count = filterSource.size(); bool multipleElements = false; @@ -80,7 +80,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st } Qt::KeyboardModifiers key = QApplication::keyboardModifiers(); - QString oldContent(text()); + QString oldContent (text()); bool replaceMode = false; bool orMode = true; @@ -103,59 +103,73 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st } if (oldContent.isEmpty() || - !oldContent.contains(QRegExp("^!.*$", Qt::CaseInsensitive))) + !oldContent.contains (QRegExp ("^!.*$", Qt::CaseInsensitive))) { replaceMode = true; } + if (!replaceMode) + { + int index = oldContent.indexOf ('('); + + if (index != 0) + { + oldContent.remove ('!'); + } + } + std::string orAnd; + if (orMode) { - orAnd = "or"; + orAnd = "!or("; } else { - orAnd = "and"; + orAnd = "!and("; } + clear(); + std::stringstream ss; + if (multipleElements) //TODO appending to the existing filter { - std::stringstream ss; if (replaceMode) { ss<<"!or("; - - for (unsigned i = 0; i < count; ++i) - { - ss<2) - { - clear(); - insert (QString::fromUtf8 (ss.str().c_str())); - } } else { - //not handled (yet) TODO + ss << orAnd << oldContent.toStdString() << ','; + } + + for (unsigned i = 0; i < count; ++i) + { + ss<5) + { + insert (QString::fromUtf8 (ss.str().c_str())); } } else { - if (replaceMode) + if (!replaceMode) { - std::string filter(generateFilter(filterSource[0])); - - if (!filter.empty()) - { - clear(); - insert ('!' + QString::fromUtf8 (generateFilter(filterSource[0]).c_str())); - } + ss << orAnd << oldContent.toStdString()<<','; } else { - //not handled (yet) TODO + ss<<'!'; } + + ss << generateFilter (filterSource[0]); + if (!replaceMode) + { + ss<<')'; + } + + insert (QString::fromStdString (ss.str().c_str())); } } From 1c35a85adfef75fae749accac051f0359694d175 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 20 Feb 2014 19:27:51 +0100 Subject: [PATCH 158/171] fixed bugs, added extra display_type --- apps/opencs/model/world/columnbase.hpp | 1 + apps/opencs/model/world/tablemimedata.cpp | 3 +-- apps/opencs/view/filter/editwidget.cpp | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index e689c6a3f5..e043336080 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -26,6 +26,7 @@ namespace CSMWorld enum Display { + Display_None, //Do not use Display_String, //CONCRETE TYPES STARTS HERE diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index de7875cc2a..b56c9c8c25 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -441,7 +441,6 @@ CSMWorld::ColumnBase::Display CSMWorld::TableMimeData::convertEnums (CSMWorld::U default: - return CSMWorld::ColumnBase::Display_String; - + return CSMWorld::ColumnBase::Display_None; } } \ No newline at end of file diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 624fe3cde3..d3a2c50a44 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -130,7 +130,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st clear(); std::stringstream ss; - if (multipleElements) //TODO appending to the existing filter + if (multipleElements) { if (replaceMode) { @@ -169,7 +169,10 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st ss<<')'; } - insert (QString::fromStdString (ss.str().c_str())); + if (ss.str().length() >4) + { + insert (QString::fromStdString (ss.str().c_str())); + } } } From 55e908357021300088f22a21bff5835cd1865e7f Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 21 Feb 2014 10:27:23 +0100 Subject: [PATCH 159/171] refactorisation --- apps/opencs/view/filter/editwidget.cpp | 48 ++++++++------------------ 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index d3a2c50a44..b6a5618a1a 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -65,7 +65,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st const unsigned count = filterSource.size(); bool multipleElements = false; - switch (count) + switch (count) //setting multipleElements; { case 0: //empty return; //nothing to do here @@ -83,17 +83,17 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st QString oldContent (text()); bool replaceMode = false; - bool orMode = true; + std::string orAnd; - switch (key) + switch (key) //setting replaceMode and string used to glue expressions { case Qt::ShiftModifier: - orMode = true; + orAnd = "!or("; replaceMode = false; break; case Qt::ControlModifier: - orMode = false; + orAnd = "!and("; replaceMode = false; break; @@ -102,32 +102,16 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st break; } - if (oldContent.isEmpty() || - !oldContent.contains (QRegExp ("^!.*$", Qt::CaseInsensitive))) + if (oldContent.isEmpty() || !oldContent.contains (QRegExp ("^!.*$", Qt::CaseInsensitive))) //if line edit is empty or it does not contain one shot filter go into replace mode { replaceMode = true; } if (!replaceMode) { - int index = oldContent.indexOf ('('); - - if (index != 0) - { - oldContent.remove ('!'); - } + oldContent.remove ('!'); } - std::string orAnd; - - if (orMode) - { - orAnd = "!or("; - } else { - orAnd = "!and("; - } - - clear(); std::stringstream ss; if (multipleElements) @@ -150,29 +134,27 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st } ss<<')'; - - if (ss.str().length() >5) - { - insert (QString::fromUtf8 (ss.str().c_str())); - } } else { if (!replaceMode) { - ss << orAnd << oldContent.toStdString()<<','; + ss << orAnd << oldContent.toStdString() <<','; } else { ss<<'!'; } ss << generateFilter (filterSource[0]); + if (!replaceMode) { ss<<')'; } - if (ss.str().length() >4) - { - insert (QString::fromStdString (ss.str().c_str())); - } + } + + if (ss.str().length() >4) + { + clear(); + insert (QString::fromStdString (ss.str().c_str())); } } From fcf17805a0215b699b6aeaf84f804ab816b6916b Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 21 Feb 2014 12:48:39 +0100 Subject: [PATCH 160/171] Installing basic event filter --- apps/opencs/view/world/tablesubview.cpp | 14 +++++++++++++- apps/opencs/view/world/tablesubview.hpp | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 21496dab73..ec509ae134 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -44,6 +44,9 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D mTable->tableSizeUpdate(); mTable->selectionSizeUpdate(); + mTable->installEventFilter(this); + mBottom->installEventFilter(this); + filterBox->installEventFilter(this); if (mBottom->canCreateAndDelete()) { @@ -107,4 +110,13 @@ void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::Univers filterSource.push_back(pair); } emit createFilterRequest(filterSource, action); -} \ No newline at end of file +} + +bool CSVWorld::TableSubView::eventFilter (QObject* object, QEvent* event) +{ + return false; +} + +void CSVWorld::TableSubView::dropEvent (QDropEvent* event) +{ +} diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index e8c75d3a34..399d6ce0ba 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -41,6 +41,9 @@ namespace CSVWorld virtual void setStatusBar (bool show); + bool eventFilter(QObject* object, QEvent *event); + void dropEvent(QDropEvent *event); + signals: void cloneRequest(const std::string&, const CSMWorld::UniversalId::Type); From e2dce535433e5f0cbcb04a57ce54f7430ec3c07f Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 21 Feb 2014 12:55:01 +0100 Subject: [PATCH 161/171] additional check on droping to prevent exception --- apps/opencs/view/world/table.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index f2999bbbde..edf3bc6dea 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -499,6 +499,11 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) { QModelIndex index = indexAt (event->pos()); + if (!index.isValid()) + { + return; + } + const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); if (mime->fromDocument (mDocument)) { From e348c6baa9e2714d7393d3af4b0a9dd80f1af1b2 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 21 Feb 2014 13:30:52 +0100 Subject: [PATCH 162/171] =?UTF-8?q?accept=20drops=20from=20filters=20table?= =?UTF-8?q?.=20Cool.=20=E2=98=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/opencs/view/filter/editwidget.cpp | 9 ++++++++- apps/opencs/view/filter/editwidget.hpp | 2 ++ apps/opencs/view/filter/filterbox.cpp | 1 + apps/opencs/view/filter/filterbox.hpp | 1 + apps/opencs/view/filter/recordfilterbox.cpp | 2 ++ apps/opencs/view/filter/recordfilterbox.hpp | 1 + apps/opencs/view/world/table.hpp | 3 +-- apps/opencs/view/world/tablesubview.cpp | 22 +++++++++++++++------ apps/opencs/view/world/tablesubview.hpp | 3 ++- 9 files changed, 34 insertions(+), 10 deletions(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index b6a5618a1a..cc1578bdd9 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -154,7 +154,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st if (ss.str().length() >4) { clear(); - insert (QString::fromStdString (ss.str().c_str())); + insert (QString::fromUtf8(ss.str().c_str())); } } @@ -194,3 +194,10 @@ std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std:: return ss.str(); } + +void CSVFilter::EditWidget::useFilterRequest (const std::string& idOfFilter) +{ + clear(); + insert(QString::fromUtf8(idOfFilter.c_str())); +} + diff --git a/apps/opencs/view/filter/editwidget.hpp b/apps/opencs/view/filter/editwidget.hpp index 59fb898837..555b6d3602 100644 --- a/apps/opencs/view/filter/editwidget.hpp +++ b/apps/opencs/view/filter/editwidget.hpp @@ -49,6 +49,8 @@ namespace CSVFilter void createFilterRequest(std::vector > >& filterSource, Qt::DropAction action); + + void useFilterRequest(const std::string& idOfFilter); }; } diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index 132beca228..a332880252 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -28,6 +28,7 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), recordFilterBox, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction))); + connect(this, SIGNAL(useFilterRequest(const std::string&)), recordFilterBox, SIGNAL(useFilterRequest(const std::string&))); setAcceptDrops(true); } diff --git a/apps/opencs/view/filter/filterbox.hpp b/apps/opencs/view/filter/filterbox.hpp index 0c5ba667bd..3817d5e709 100644 --- a/apps/opencs/view/filter/filterbox.hpp +++ b/apps/opencs/view/filter/filterbox.hpp @@ -36,6 +36,7 @@ namespace CSVFilter void recordDropped (std::vector& types, Qt::DropAction action); void createFilterRequest(std::vector > >& filterSource, Qt::DropAction action); + void useFilterRequest(const std::string& idOfFilter); }; } diff --git a/apps/opencs/view/filter/recordfilterbox.cpp b/apps/opencs/view/filter/recordfilterbox.cpp index 530ce87145..2a1a1407fa 100644 --- a/apps/opencs/view/filter/recordfilterbox.cpp +++ b/apps/opencs/view/filter/recordfilterbox.cpp @@ -27,4 +27,6 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), editWidget, SLOT(createFilterRequest(std::vector > >&, Qt::DropAction))); + + connect(this, SIGNAL(useFilterRequest(const std::string&)), editWidget, SLOT(useFilterRequest(const std::string&))); } diff --git a/apps/opencs/view/filter/recordfilterbox.hpp b/apps/opencs/view/filter/recordfilterbox.hpp index ac21c840f7..3638dc6c34 100644 --- a/apps/opencs/view/filter/recordfilterbox.hpp +++ b/apps/opencs/view/filter/recordfilterbox.hpp @@ -30,6 +30,7 @@ namespace CSVFilter void filterChanged (boost::shared_ptr filter); void createFilterRequest(std::vector > >& filterSource, Qt::DropAction action); + void useFilterRequest(const std::string& idOfFilter); }; } diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 3b72c36d5b..615a31b4d7 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -64,10 +64,9 @@ namespace CSVWorld void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); - void dragMoveEvent(QDragMoveEvent *event); + void dropEvent(QDropEvent *event); public: diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index ec509ae134..e330d47758 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -2,6 +2,7 @@ #include "tablesubview.hpp" #include +#include #include "../../model/doc/document.hpp" #include "../../model/world/tablemimedata.hpp" @@ -44,7 +45,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D mTable->tableSizeUpdate(); mTable->selectionSizeUpdate(); - mTable->installEventFilter(this); + mTable->viewport()->installEventFilter(this); mBottom->installEventFilter(this); filterBox->installEventFilter(this); @@ -68,6 +69,8 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D connect(filterBox, SIGNAL(recordDropped(std::vector&, Qt::DropAction)), this, SLOT(createFilterRequest(std::vector&, Qt::DropAction))); + connect(this, SIGNAL(useFilterRequest(const std::string&)), filterBox, SIGNAL(useFilterRequest(const std::string&))); + connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), filterBox, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction))); } @@ -114,9 +117,16 @@ void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::Univers bool CSVWorld::TableSubView::eventFilter (QObject* object, QEvent* event) { + if (event->type() == QEvent::Drop) + { + QDropEvent* drop = dynamic_cast(event); + const CSMWorld::TableMimeData* data = dynamic_cast(drop->mimeData()); + bool handled = data->holdsType(CSMWorld::UniversalId::Type_Filter); + if (handled) + { + emit useFilterRequest(data->returnMatching(CSMWorld::UniversalId::Type_Filter).getId()); + } + return handled; + } return false; -} - -void CSVWorld::TableSubView::dropEvent (QDropEvent* event) -{ -} +} \ No newline at end of file diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index 399d6ce0ba..1f67e0262a 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -41,14 +41,15 @@ namespace CSVWorld virtual void setStatusBar (bool show); + protected: bool eventFilter(QObject* object, QEvent *event); - void dropEvent(QDropEvent *event); signals: void cloneRequest(const std::string&, const CSMWorld::UniversalId::Type); void createFilterRequest(std::vector > >& filterSource, Qt::DropAction action); + void useFilterRequest(const std::string& idOfFilter); private slots: From c3f350e3fb1b7936ad1d78bc79c04054d5489dac Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 22 Feb 2014 12:06:50 +1100 Subject: [PATCH 163/171] Allow MinGW64 compilation in Windows/msys --- .gitignore | 1 + apps/openmw/mwrender/videoplayer.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 2 +- components/files/configurationmanager.hpp | 2 +- extern/sdl4ogre/sdlwindowhelper.cpp | 4 ++++ libs/platform/string.h | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3975c4521b..ca58fc0064 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ Doxygen ## ides/editors *~ +*.bak *.kdev4 *.swp *.swo diff --git a/apps/openmw/mwrender/videoplayer.cpp b/apps/openmw/mwrender/videoplayer.cpp index adf20dc633..4209fb9781 100644 --- a/apps/openmw/mwrender/videoplayer.cpp +++ b/apps/openmw/mwrender/videoplayer.cpp @@ -385,7 +385,7 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder } void open(const std::string&) -#ifdef _WIN32 +#ifdef _MSC_VER { fail(std::string("Invalid call to ")+__FUNCSIG__); } #else { fail(std::string("Invalid call to ")+__PRETTY_FUNCTION__); } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index be6c0b338f..21780fd5c9 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1,5 +1,5 @@ #include "worldimp.hpp" -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include #elif defined HAVE_UNORDERED_MAP #include diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 35144fe04f..9f31a7f2d5 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -1,7 +1,7 @@ #ifndef COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP #define COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include #elif defined HAVE_UNORDERED_MAP #include diff --git a/extern/sdl4ogre/sdlwindowhelper.cpp b/extern/sdl4ogre/sdlwindowhelper.cpp index f819043cfd..2a54a86369 100644 --- a/extern/sdl4ogre/sdlwindowhelper.cpp +++ b/extern/sdl4ogre/sdlwindowhelper.cpp @@ -31,7 +31,11 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, #ifdef WIN32 case SDL_SYSWM_WINDOWS: // Windows code +#ifdef __MINGW64__ + winHandle = Ogre::StringConverter::toString((DWORD_PTR)wmInfo.info.win.window); +#else winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.win.window); +#endif /* __MINGW64__ */ break; #elif __MACOSX__ case SDL_SYSWM_COCOA: diff --git a/libs/platform/string.h b/libs/platform/string.h index 5368d757cc..7f08765879 100644 --- a/libs/platform/string.h +++ b/libs/platform/string.h @@ -9,7 +9,7 @@ #include #if (defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1070) || defined(__MINGW32__) // need our own implementation of strnlen -#ifdef __MINGW32__ +#ifdef __MINGW32__ && !__MINGW64__ static size_t strnlen(const char *s, size_t n) { const char *p = (const char *)memchr(s, 0, n); From c241405d91bfa7dff7cd7149c7b81e1989b345be Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 22 Feb 2014 12:15:20 +1100 Subject: [PATCH 164/171] Fix Windows save & load. --- apps/openmw/engine.cpp | 5 ++++- apps/openmw/mwstate/statemanagerimp.cpp | 2 +- components/esm/esmwriter.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index e80bd954e3..09757786b0 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -2,6 +2,7 @@ #include +#include #include #include @@ -339,8 +340,10 @@ std::string OMW::Engine::loadSettings (Settings::Manager & settings) void OMW::Engine::prepareEngine (Settings::Manager & settings) { + boost::filesystem::path saves(mCfgMgr.getUserDataPath() / "saves"); + mEnvironment.setStateManager ( - new MWState::StateManager (mCfgMgr.getUserDataPath() / "saves", mContentFiles.at (0))); + new MWState::StateManager (saves.make_preferred(), mContentFiles.at (0))); Nif::NIFFile::CacheLock cachelock; diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index ba0e1d056f..265069dc46 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -176,7 +176,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot else slot = mCharacterManager.getCurrentCharacter()->updateSlot (slot, profile); - std::ofstream stream (slot->mPath.string().c_str()); + std::ofstream stream (slot->mPath.string().c_str(), std::ios::binary); ESM::ESMWriter writer; diff --git a/components/esm/esmwriter.cpp b/components/esm/esmwriter.cpp index f38591b7bf..91f123eb71 100644 --- a/components/esm/esmwriter.cpp +++ b/components/esm/esmwriter.cpp @@ -80,8 +80,8 @@ namespace ESM rec.name = name; rec.position = mStream->tellp(); rec.size = 0; - writeT(0); // Size goes here - writeT(0); // Unused header? + writeT(0); // Size goes here + writeT(0); // Unused header? writeT(flags); mRecords.push_back(rec); @@ -105,7 +105,7 @@ namespace ESM rec.name = name; rec.position = mStream->tellp(); rec.size = 0; - writeT(0); // Size goes here + writeT(0); // Size goes here mRecords.push_back(rec); assert(mRecords.back().size == 0); @@ -120,7 +120,7 @@ namespace ESM mStream->seekp(rec.position); mCounting = false; - write (reinterpret_cast (&rec.size), sizeof(int)); + write (reinterpret_cast (&rec.size), sizeof(uint32_t)); mCounting = true; mStream->seekp(0, std::ios::end); From 29a33364cc4f72fc86b3cbb3b6617bf13983388c Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 22 Feb 2014 17:21:19 +1100 Subject: [PATCH 165/171] Another attempt at fixing MinGW64 --- libs/platform/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/platform/string.h b/libs/platform/string.h index 7f08765879..be2e976b2d 100644 --- a/libs/platform/string.h +++ b/libs/platform/string.h @@ -9,7 +9,7 @@ #include #if (defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1070) || defined(__MINGW32__) // need our own implementation of strnlen -#ifdef __MINGW32__ && !__MINGW64__ +#if defined(__MINGW32__) && !defined(__MINGW64__) static size_t strnlen(const char *s, size_t n) { const char *p = (const char *)memchr(s, 0, n); From 2ca28f40bef740aa489d31e6bcada2ab8f4682ac Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 22 Feb 2014 12:55:14 +0100 Subject: [PATCH 166/171] minor addition to change log --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 07e89affa1..a23cd1077e 100644 --- a/readme.txt +++ b/readme.txt @@ -100,6 +100,7 @@ CHANGELOG 0.29.0 Bug #556: Video soundtrack not played when music volume is set to zero +Bug #829: OpenMW uses up all available vram, when playing for extended time Bug #848: Wrong amount of footsteps playing in 1st person Bug #888: Ascended Sleepers have movement issues Bug #892: Explicit references are allowed on all script functions From ac606a865c5fa2ffbf1dfe521ae0bf5f1384a786 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 22 Feb 2014 23:22:23 +1100 Subject: [PATCH 167/171] Back out unnecessary change. --- apps/openmw/engine.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 09757786b0..e80bd954e3 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -2,7 +2,6 @@ #include -#include #include #include @@ -340,10 +339,8 @@ std::string OMW::Engine::loadSettings (Settings::Manager & settings) void OMW::Engine::prepareEngine (Settings::Manager & settings) { - boost::filesystem::path saves(mCfgMgr.getUserDataPath() / "saves"); - mEnvironment.setStateManager ( - new MWState::StateManager (saves.make_preferred(), mContentFiles.at (0))); + new MWState::StateManager (mCfgMgr.getUserDataPath() / "saves", mContentFiles.at (0))); Nif::NIFFile::CacheLock cachelock; From fcfc8fcccb90a9cd7429eeb7209bc447ea59879d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 22 Feb 2014 23:45:13 +1100 Subject: [PATCH 168/171] Revert "Allow MinGW64 compilation in Windows/msys" This reverts commit c3f350e3fb1b7936ad1d78bc79c04054d5489dac. Conflicts: libs/platform/string.h --- .gitignore | 1 - apps/openmw/mwrender/videoplayer.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 2 +- components/files/configurationmanager.hpp | 2 +- extern/sdl4ogre/sdlwindowhelper.cpp | 4 ---- libs/platform/string.h | 2 +- 6 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index ca58fc0064..3975c4521b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ Doxygen ## ides/editors *~ -*.bak *.kdev4 *.swp *.swo diff --git a/apps/openmw/mwrender/videoplayer.cpp b/apps/openmw/mwrender/videoplayer.cpp index 4209fb9781..adf20dc633 100644 --- a/apps/openmw/mwrender/videoplayer.cpp +++ b/apps/openmw/mwrender/videoplayer.cpp @@ -385,7 +385,7 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder } void open(const std::string&) -#ifdef _MSC_VER +#ifdef _WIN32 { fail(std::string("Invalid call to ")+__FUNCSIG__); } #else { fail(std::string("Invalid call to ")+__PRETTY_FUNCTION__); } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 21780fd5c9..be6c0b338f 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1,5 +1,5 @@ #include "worldimp.hpp" -#if defined(_WIN32) && !defined(__MINGW32__) +#ifdef _WIN32 #include #elif defined HAVE_UNORDERED_MAP #include diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 9f31a7f2d5..35144fe04f 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -1,7 +1,7 @@ #ifndef COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP #define COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP -#if defined(_WIN32) && !defined(__MINGW32__) +#ifdef _WIN32 #include #elif defined HAVE_UNORDERED_MAP #include diff --git a/extern/sdl4ogre/sdlwindowhelper.cpp b/extern/sdl4ogre/sdlwindowhelper.cpp index 2a54a86369..f819043cfd 100644 --- a/extern/sdl4ogre/sdlwindowhelper.cpp +++ b/extern/sdl4ogre/sdlwindowhelper.cpp @@ -31,11 +31,7 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, #ifdef WIN32 case SDL_SYSWM_WINDOWS: // Windows code -#ifdef __MINGW64__ - winHandle = Ogre::StringConverter::toString((DWORD_PTR)wmInfo.info.win.window); -#else winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.win.window); -#endif /* __MINGW64__ */ break; #elif __MACOSX__ case SDL_SYSWM_COCOA: diff --git a/libs/platform/string.h b/libs/platform/string.h index be2e976b2d..5368d757cc 100644 --- a/libs/platform/string.h +++ b/libs/platform/string.h @@ -9,7 +9,7 @@ #include #if (defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1070) || defined(__MINGW32__) // need our own implementation of strnlen -#if defined(__MINGW32__) && !defined(__MINGW64__) +#ifdef __MINGW32__ static size_t strnlen(const char *s, size_t n) { const char *p = (const char *)memchr(s, 0, n); From d780364842974a201876610eb58093fa659e9cc2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 22 Feb 2014 17:31:44 +0100 Subject: [PATCH 169/171] fixed record size type --- components/esm/esmwriter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esm/esmwriter.hpp b/components/esm/esmwriter.hpp index 94f0a10048..33650e6784 100644 --- a/components/esm/esmwriter.hpp +++ b/components/esm/esmwriter.hpp @@ -17,7 +17,7 @@ class ESMWriter { std::string name; std::streampos position; - size_t size; + uint32_t size; }; public: From 1bd2664cb04b8b0a6c64f1312d43cf9195b07cf4 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 23 Feb 2014 18:42:40 +1100 Subject: [PATCH 170/171] aicombat pathfinding workaround --- apps/openmw/mwmechanics/aicombat.cpp | 35 ++++++++++++++++--------- apps/openmw/mwmechanics/pathfinding.cpp | 2 ++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 6a49f2f5e0..91c77702e2 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -240,16 +240,20 @@ namespace MWMechanics //target is at far distance: build path to target OR follow target (if previously actor had reached it once) mFollowTarget = false; - buildNewPath(actor); + buildNewPath(actor); //not guaranteed, check before use //delete visited path node mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2]); - //try shortcut - if(vDir.length() < mPathFinder.getDistToNext(pos.pos[0],pos.pos[1],pos.pos[2]) && MWBase::Environment::get().getWorld()->getLOS(actor, mTarget)) - mTargetAngle = Ogre::Radian( Ogre::Math::ACos(vDir.y / vDir.length()) * sgn(Ogre::Math::ASin(vDir.x / vDir.length())) ).valueDegrees(); - else - mTargetAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]); + //if buildNewPath() failed leave mTargetAngle unchanged + if(!mPathFinder.getPath().empty()) + { + //try shortcut + if(vDir.length() < mPathFinder.getDistToNext(pos.pos[0],pos.pos[1],pos.pos[2]) && MWBase::Environment::get().getWorld()->getLOS(actor, mTarget)) + mTargetAngle = Ogre::Radian( Ogre::Math::ACos(vDir.y / vDir.length()) * sgn(Ogre::Math::ASin(vDir.x / vDir.length())) ).valueDegrees(); + else + mTargetAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]); + } mRotate = true; mMovement.mPosition[1] = 1; @@ -300,9 +304,13 @@ namespace MWMechanics dest.mZ = mTarget.getRefData().getPosition().pos[2]; Ogre::Vector3 newPathTarget = Ogre::Vector3(dest.mX, dest.mY, dest.mZ); - ESM::Pathgrid::Point lastPt = mPathFinder.getPath().back(); - Ogre::Vector3 currPathTarget(lastPt.mX, lastPt.mY, lastPt.mZ); - float dist = Ogre::Math::Abs((newPathTarget - currPathTarget).length()); + float dist = -1; //hack to indicate first time, to construct a new path + if(!mPathFinder.getPath().empty()) + { + ESM::Pathgrid::Point lastPt = mPathFinder.getPath().back(); + Ogre::Vector3 currPathTarget(lastPt.mX, lastPt.mY, lastPt.mZ); + dist = Ogre::Math::Abs((newPathTarget - currPathTarget).length()); + } float targetPosThreshold; bool isOutside = actor.getCell()->mCell->isExterior(); @@ -311,7 +319,7 @@ namespace MWMechanics else targetPosThreshold = 100; - if(dist > targetPosThreshold) + if((dist < 0) || (dist > targetPosThreshold)) { //construct new path only if target has moved away more than on ESM::Position pos = actor.getRefData().getPosition(); @@ -332,8 +340,11 @@ namespace MWMechanics //maybe here is a mistake (?): PathFinder::getPathSize() returns number of grid points in the path, //not the actual path length. Here we should know if the new path is actually more effective. //if(pathFinder2.getPathSize() < mPathFinder.getPathSize()) - newPathFinder.syncStart(mPathFinder.getPath()); - mPathFinder = newPathFinder; + if(!mPathFinder.getPath().empty()) + { + newPathFinder.syncStart(mPathFinder.getPath()); + mPathFinder = newPathFinder; + } } } } diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 4407363a61..5996eb0793 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -391,6 +391,8 @@ namespace MWMechanics void PathFinder::syncStart(const std::list &path) { + if (path.size() < 2) + return; //nothing to pop std::list::const_iterator oldStart = path.begin(); std::list::iterator iter = ++mPath.begin(); From 424617225118546b18220e3752f02f243580d3cb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 23 Feb 2014 11:52:13 +0100 Subject: [PATCH 171/171] updated credits file --- credits.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/credits.txt b/credits.txt index 561931cde9..6012557638 100644 --- a/credits.txt +++ b/credits.txt @@ -20,6 +20,7 @@ Artem Kotsynyak (greye) athile Britt Mathis (galdor557) BrotherBrick +cc9cii Chris Robinson (KittyCat) Cory F. Cohen (cfcohen) Cris Mihalache (Mirceam)