From 2c9d46a60bd8d35f132cb106e5255d590b13640b Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner
Date: Tue, 17 Apr 2018 23:03:56 +0200
Subject: [PATCH 1/6] Fix build with Qt 5.11_beta3 (dropping qt5_use_modules)
---
apps/launcher/CMakeLists.txt | 2 +-
apps/opencs/CMakeLists.txt | 2 +-
apps/wizard/CMakeLists.txt | 2 +-
components/CMakeLists.txt | 2 +-
extern/osgQt/CMakeLists.txt | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt
index aec8c2533..99e7b4daa 100644
--- a/apps/launcher/CMakeLists.txt
+++ b/apps/launcher/CMakeLists.txt
@@ -106,7 +106,7 @@ if (DESIRED_QT_VERSION MATCHES 4)
target_link_libraries(openmw-launcher ${QT_QTMAIN_LIBRARY})
endif(WIN32)
else()
- qt5_use_modules(openmw-launcher Widgets Core)
+ target_link_libraries(openmw-launcher Qt5::Widgets Qt5::Core)
endif()
if (BUILD_WITH_CODE_COVERAGE)
diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt
index b9279bf91..f07b518a9 100644
--- a/apps/opencs/CMakeLists.txt
+++ b/apps/opencs/CMakeLists.txt
@@ -246,7 +246,7 @@ if (DESIRED_QT_VERSION MATCHES 4)
target_link_libraries(openmw-cs ${QT_QTMAIN_LIBRARY})
endif()
else()
- qt5_use_modules(openmw-cs Widgets Core Network OpenGL)
+ target_link_libraries(openmw-cs Qt5::Widgets Qt5::Core Qt5::Network Qt5::OpenGL)
endif()
if (WIN32)
diff --git a/apps/wizard/CMakeLists.txt b/apps/wizard/CMakeLists.txt
index 5f7338e52..8d97bbcbf 100644
--- a/apps/wizard/CMakeLists.txt
+++ b/apps/wizard/CMakeLists.txt
@@ -118,7 +118,7 @@ if (DESIRED_QT_VERSION MATCHES 4)
target_link_libraries(openmw-wizard ${QT_QTMAIN_LIBRARY})
endif()
else()
- qt5_use_modules(openmw-wizard Widgets Core)
+ target_link_libraries(openmw-wizard Qt5::Widgets Qt5::Core)
endif()
if (OPENMW_USE_UNSHIELD)
diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt
index 8256f1443..ecb844a9b 100644
--- a/components/CMakeLists.txt
+++ b/components/CMakeLists.txt
@@ -216,7 +216,7 @@ if (USE_QT)
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY})
else()
- qt5_use_modules(components Widgets Core)
+ target_link_libraries(components Qt5::Widgets Qt5::Core)
endif()
endif()
diff --git a/extern/osgQt/CMakeLists.txt b/extern/osgQt/CMakeLists.txt
index 3bd08a390..78a4e6034 100644
--- a/extern/osgQt/CMakeLists.txt
+++ b/extern/osgQt/CMakeLists.txt
@@ -12,7 +12,7 @@ if (DESIRED_QT_VERSION MATCHES 4)
include(${QT_USE_FILE})
target_link_libraries(${OSGQT_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTOPENGL_LIBRARY})
else()
- qt5_use_modules(${OSGQT_LIBRARY} Core OpenGL)
+ target_link_libraries(${OSGQT_LIBRARY} Qt5::Core Qt5::OpenGL)
endif()
link_directories(${CMAKE_CURRENT_BINARY_DIR})
From 40f6497f40ebcab4cd51dc0a92fac92d7fdea266 Mon Sep 17 00:00:00 2001
From: scrawl <720642+scrawl@users.noreply.github.com>
Date: Sat, 14 Apr 2018 20:18:48 +0000
Subject: [PATCH 2/6] Clarify how to link bugs
---
CONTRIBUTING.md | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5218c2ed9..4b2b4dfdd 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -10,8 +10,7 @@ Currently, we are focused on completing the MW game experience and general polis
Note:
* Tasks set to 'openmw-future' are usually out of the current scope of the project and can't be started yet.
* Bugs that are not 'Confirmed' should be confirmed first.
-* Larger Features should have a discussion before you start implementing.
-* In many cases, it's best to have a discussion about possible solutions before you jump into coding.
+* Often, it's best to start a discussion about possible solutions before you jump into coding, especially for larger features.
Aside from coding, you can also help by triaging the issues list. Check for bugs that are 'Unconfirmed' and try to confirm them on your end, working out any details that may be necessary. Check for bugs that do not conform to [Bug reporting guidelines](https://wiki.openmw.org/index.php?title=Bug_Reporting_Guidelines) and improve them to do so!
@@ -22,7 +21,7 @@ Pull Request Guidelines
To facilitate the review process, your pull request description should include the following, if applicable:
-* A link back to the bug report or forum discussion that prompted the change
+* A link back to the bug report or forum discussion that prompted the change. Note: when linking bugs, use the syntax ```[Bug #xyz](https://bugs.openmw.org/issues/#xyz)``` to create a clickable link. Writing only 'Bug #xyz' will unfortunately create a link to the Github pull request with that number instead.
* Summary of the changes made
* Reasoning / motivation behind the change
* What testing you have carried out to verify the change
@@ -48,7 +47,7 @@ Unfortunately, the definition of what is a "bug" is not so clear. Consider that
* Many people will actually like these "bugs" because that is what they remember the game for.
* Exploits may be part of the fun of an open-world game - they reward knowledge with power. There are too many of them to plug them all, anyway.
-OpenMW, in its default configuration, is meant to be a faithful reimplementation of Morrowind, minus things like crash bugs, stability issues and design errors. However, we try to avoid touching anything that affects the core gameplay, the balancing of the game or introduces incompatibilities with existing mod content.
+OpenMW, in its default configuration, is meant to be a faithful reimplementation of Morrowind, minus things like crash bugs, stability issues and severe design errors. However, we try to avoid touching anything that affects the core gameplay, the balancing of the game or introduces incompatibilities with existing mod content.
That said, we may sometimes evaluate such issues on an individual basis. Common exceptions to the above would be:
@@ -102,7 +101,7 @@ Merging
To be able to merge PRs, commit priviledges are required. If you do not have the priviledges, just ping someone that does have them with a short comment like "Looks good to me @user".
-The person to merge the PR may either use github's Merge button or if using the command line, use the ```--no-ff``` flag and include the pull request number in the commit description.
+The person to merge the PR may either use github's Merge button or if using the command line, use the ```--no-ff``` flag (so a merge commit is created, just like with Github's merge button) and include the pull request number in the commit description.
Other resources
From 6c79c0fb3501da68708c791df0343e9f44217c17 Mon Sep 17 00:00:00 2001
From: scrawl <720642+scrawl@users.noreply.github.com>
Date: Sun, 15 Apr 2018 12:38:03 +0000
Subject: [PATCH 3/6] Add an empty compileGLObjects implementation to
Rig/MorphGeometry to avoid unnecessary creation of display list done by osg
---
components/sceneutil/morphgeometry.hpp | 3 +++
components/sceneutil/riggeometry.hpp | 4 ++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/components/sceneutil/morphgeometry.hpp b/components/sceneutil/morphgeometry.hpp
index 122c1456c..ba3b40961 100644
--- a/components/sceneutil/morphgeometry.hpp
+++ b/components/sceneutil/morphgeometry.hpp
@@ -21,6 +21,9 @@ namespace SceneUtil
/// @note The source geometry will not be modified.
void setSourceGeometry(osg::ref_ptr sourceGeom);
+ // Currently empty as this is difficult to implement. Technically we would need to compile both internal geometries in separate frames but this method is only called once. Alternatively we could compile just the static parts of the model.
+ virtual void compileGLObjects(osg::RenderInfo& renderInfo) const {}
+
class MorphTarget
{
protected:
diff --git a/components/sceneutil/riggeometry.hpp b/components/sceneutil/riggeometry.hpp
index 64f4bf312..60b3edc9d 100644
--- a/components/sceneutil/riggeometry.hpp
+++ b/components/sceneutil/riggeometry.hpp
@@ -23,8 +23,8 @@ namespace SceneUtil
META_Object(SceneUtil, RigGeometry)
- // At this point compileGLObjects() remains unimplemented, hard to avoid race conditions
- // and there is limited value in compiling anyway since the data will change again for the next frame
+ // Currently empty as this is difficult to implement. Technically we would need to compile both internal geometries in separate frames but this method is only called once. Alternatively we could compile just the static parts of the model.
+ virtual void compileGLObjects(osg::RenderInfo& renderInfo) const {}
struct BoneInfluence
{
From 789f552ad474d734dcfacdaf59002a10afc86f42 Mon Sep 17 00:00:00 2001
From: scrawl <720642+scrawl@users.noreply.github.com>
Date: Sun, 15 Apr 2018 13:20:53 +0000
Subject: [PATCH 4/6] Delete old mygui_resource_plugin which is unlikely to be
brought back in its current form because resources can't be accessed by
MyGUI's editor if not using the Ogre resources system.
---
CMakeLists.txt | 5 -
plugins/mygui_resource_plugin/CMakeLists.txt | 31 ---
plugins/mygui_resource_plugin/plugin.cpp | 183 ------------------
plugins/mygui_resource_plugin/plugin.hpp | 52 -----
.../mygui_resource_plugin/plugin_export.cpp | 17 --
5 files changed, 288 deletions(-)
delete mode 100644 plugins/mygui_resource_plugin/CMakeLists.txt
delete mode 100644 plugins/mygui_resource_plugin/plugin.cpp
delete mode 100644 plugins/mygui_resource_plugin/plugin.hpp
delete mode 100644 plugins/mygui_resource_plugin/plugin_export.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f97323e2..dd809b58c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -545,11 +545,6 @@ endif()
# Components
add_subdirectory (components)
-# Plugins
-#if (BUILD_MYGUI_PLUGIN)
-# add_subdirectory(plugins/mygui_resource_plugin)
-#endif()
-
# Apps and tools
if (BUILD_OPENMW)
add_subdirectory( apps/openmw )
diff --git a/plugins/mygui_resource_plugin/CMakeLists.txt b/plugins/mygui_resource_plugin/CMakeLists.txt
deleted file mode 100644
index be834b17d..000000000
--- a/plugins/mygui_resource_plugin/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-set (MYGUI_RESOURCE_PLUGIN_SOURCES
- plugin.hpp
- plugin.cpp
- plugin_export.cpp
-)
-
-set (MYGUI_RESOURCE_PLUGIN_LIBRARY
- Plugin_MyGUI_OpenMW_Resources
-)
-
-add_definitions("-D_USRDLL -DMYGUI_BUILD_DLL")
-
-add_library(${MYGUI_RESOURCE_PLUGIN_LIBRARY}
- SHARED
- ${MYGUI_RESOURCE_PLUGIN_SOURCES}
- )
-
-if(WIN32)
- if(MSVC)
- # from top-level CMakelists.txt:
- # 4305 - Truncating value (double to float, for example)
- set_target_properties(${MYGUI_RESOURCE_PLUGIN_LIBRARY} PROPERTIES COMPILE_FLAGS "/wd4305")
- endif(MSVC)
-endif(WIN32)
-
-set_target_properties(${MYGUI_RESOURCE_PLUGIN_LIBRARY} PROPERTIES PREFIX "")
-
-target_link_libraries(${MYGUI_RESOURCE_PLUGIN_LIBRARY}
- ${OGRE_LIBRARIES}
- components
-)
diff --git a/plugins/mygui_resource_plugin/plugin.cpp b/plugins/mygui_resource_plugin/plugin.cpp
deleted file mode 100644
index 1b718b547..000000000
--- a/plugins/mygui_resource_plugin/plugin.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-#include "plugin.hpp"
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-
-//FIXME: code duplication
-namespace boost
-{
-struct FallbackMap {
- std::map mMap;
-};
-
-void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int)
-{
- if(v.empty())
- {
- v = boost::any(FallbackMap());
- }
-
- FallbackMap *map = boost::any_cast(&v);
-
- for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); ++it)
- {
- int sep = it->find(",");
- if(sep < 1 || sep == (int)it->length()-1)
-#if (BOOST_VERSION < 104200)
- throw boost::program_options::validation_error("invalid value");
-#else
- throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value);
-#endif
-
- std::string key(it->substr(0,sep));
- std::string value(it->substr(sep+1));
-
- if(map->mMap.find(key) == map->mMap.end())
- {
- map->mMap.insert(std::make_pair (key,value));
- }
- }
-}
-}
-
-namespace MyGUIPlugin
-{
-
- // Dummy - obsolete when using MyGUI git, because the ScrollBar there has autorepeat support added.
- class MWScrollBar : public MyGUI::ScrollBar
- {
- MYGUI_RTTI_DERIVED(MWScrollBar)
- };
-
- const std::string& ResourcePlugin::getName() const
- {
- static const std::string name = "OpenMW resource plugin";
- return name;
- }
-
- void ResourcePlugin::install()
- {
-
- }
- void ResourcePlugin::uninstall()
- {
-
- }
-
- void ResourcePlugin::registerResources()
- {
- boost::program_options::variables_map variables;
-
- boost::program_options::options_description desc("Allowed options");
- desc.add_options()
- ("data", boost::program_options::value()->default_value(Files::PathContainer(), "data")->multitoken()->composing())
- ("data-local", boost::program_options::value()->default_value(""))
- ("fs-strict", boost::program_options::value()->implicit_value(true)->default_value(false))
- ("fallback-archive", boost::program_options::value >()->
- default_value(std::vector(), "fallback-archive")->multitoken())
- ("encoding", boost::program_options::value()->default_value("win1252"))
- ("fallback", boost::program_options::value()->default_value(boost::FallbackMap(), "")
- ->multitoken()->composing(), "fallback values");
-
- boost::program_options::notify(variables);
-
- Files::ConfigurationManager cfgManager;
- cfgManager.readConfiguration(variables, desc);
-
- std::vector archives = variables["fallback-archive"].as >();
- bool fsStrict = variables["fs-strict"].as();
-
- Files::PathContainer dataDirs, dataLocal;
- if (!variables["data"].empty()) {
- dataDirs = Files::PathContainer(variables["data"].as());
- }
-
- std::string local = variables["data-local"].as();
- if (!local.empty()) {
- dataLocal.push_back(Files::PathContainer::value_type(local));
- }
-
- cfgManager.processPaths (dataDirs);
- cfgManager.processPaths (dataLocal, true);
-
- if (!dataLocal.empty())
- dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
-
- Files::Collections collections (dataDirs, !fsStrict);
-
- Bsa::registerResources(collections, archives, true, fsStrict);
-
- std::string encoding(variables["encoding"].as());
- std::cout << ToUTF8::encodingUsingMessage(encoding) << std::endl;
-
- Gui::FontLoader loader(ToUTF8::calculateEncoding(encoding));
- loader.loadAllFonts(false);
-
- mFallbackMap = variables["fallback"].as().mMap;
- }
-
- void ResourcePlugin::registerWidgets()
- {
- MyGUI::FactoryManager::getInstance().registerFactory("Widget");
-
- Gui::registerAllWidgets();
- }
-
- void ResourcePlugin::createTransparentBGTexture()
- {
- // This texture is manually created in OpenMW to be able to change its opacity at runtime in the options menu
- Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual(
- "transparent.png",
- Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
- Ogre::TEX_TYPE_2D,
- 1, 1,
- 0,
- Ogre::PF_A8R8G8B8,
- Ogre::TU_WRITE_ONLY);
- std::vector buffer;
- buffer.resize(1);
- const float val = 0.7;
- buffer[0] = (int(255*val) << 24) | (255 << 16) | (255 << 8) | 255;
- memcpy(tex->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD), &buffer[0], 1*4);
- tex->getBuffer()->unlock();
- }
-
- void ResourcePlugin::initialize()
- {
- MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "initialize");
-
- registerResources();
- registerWidgets();
- createTransparentBGTexture();
-
- MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &ResourcePlugin::onRetrieveTag);
- }
-
- void ResourcePlugin::shutdown()
- {
- /// \todo cleanup
-
- MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "shutdown");
- }
-
- void ResourcePlugin::onRetrieveTag(const MyGUI::UString& tag, MyGUI::UString& out)
- {
- if (!Gui::replaceTag(tag, out, mFallbackMap))
- out = tag;
- }
-
-}
diff --git a/plugins/mygui_resource_plugin/plugin.hpp b/plugins/mygui_resource_plugin/plugin.hpp
deleted file mode 100644
index 6a06060d9..000000000
--- a/plugins/mygui_resource_plugin/plugin.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef OPENMW_MYGUI_RESOURCE_PLUGIN_H
-#define OPENMW_MYGUI_RESOURCE_PLUGIN_H
-
-#include
-#include
-
-namespace MyGUIPlugin
-{
-
- /**
- * @brief MyGUI plugin used to register Morrowind resources, custom widgets used in OpenMW, and load Morrowind fonts.
- * @paragraph The plugin isn't used in OpenMW itself, but it is useful with the standalone MyGUI tools. To use it,
- * change EditorPlugin.xml in Media/Tools/LayoutEditor/EditorPlugin.xml and add an entry for this plugin.
- */
- class ResourcePlugin : public MyGUI::IPlugin
- {
- /*! Get the name of the plugin.
- @remarks An implementation must be supplied for this method to uniquely
- identify the plugin
- */
- virtual const std::string& getName() const;
-
- /*! Perform the plugin initial installation sequence
- */
- virtual void install();
-
- /*! Perform any tasks the plugin needs to perform on full system
- initialisation.
- */
- virtual void initialize();
-
- /*! Perform any tasks the plugin needs to perform when the system is shut down
- */
- virtual void shutdown();
-
- /*! Perform the final plugin uninstallation sequence
- */
- virtual void uninstall();
-
- private:
- void registerResources();
- void registerWidgets();
- void createTransparentBGTexture();
-
- void onRetrieveTag(const MyGUI::UString& tag, MyGUI::UString& out);
-
- std::map mFallbackMap;
- };
-
-}
-
-#endif
diff --git a/plugins/mygui_resource_plugin/plugin_export.cpp b/plugins/mygui_resource_plugin/plugin_export.cpp
deleted file mode 100644
index 0d6b4b804..000000000
--- a/plugins/mygui_resource_plugin/plugin_export.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "plugin.hpp"
-#include "MyGUI_PluginManager.h"
-
-MyGUIPlugin::ResourcePlugin* plugin_item = nullptr;
-
-extern "C" MYGUI_EXPORT_DLL void dllStartPlugin(void)
-{
- plugin_item = new MyGUIPlugin::ResourcePlugin();
- MyGUI::PluginManager::getInstance().installPlugin(plugin_item);
-}
-
-extern "C" MYGUI_EXPORT_DLL void dllStopPlugin(void)
-{
- MyGUI::PluginManager::getInstance().uninstallPlugin(plugin_item);
- delete plugin_item;
- plugin_item = nullptr;
-}
From d4d1703bcf98bc770f8703379351622c83a150cd Mon Sep 17 00:00:00 2001
From: tri4ng1e
Date: Mon, 9 Apr 2018 18:55:16 +0300
Subject: [PATCH 5/6] Some PVS-Studio and cppcheck fixes
cppcheck:
[apps/esmtool/record.cpp:697]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/esmtool/record.cpp:1126]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/esmtool/record.cpp:1138]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/niftest/niftest.cpp:36]: (performance) Function parameter 'filename' should be passed by reference.
[apps/niftest/niftest.cpp:41]: (performance) Function parameter 'filename' should be passed by reference.
[apps/opencs/model/prefs/boolsetting.cpp:25]: (warning) Possible leak in public function. The pointer 'mWidget' is not deallocated before it is allocated.
[apps/opencs/model/prefs/shortcuteventhandler.cpp:52]: (warning) Return value of std::remove() ignored. Elements remain in container.
[apps/openmw/mwstate/quicksavemanager.cpp:5]: (performance) Variable 'mSaveName' is assigned in constructor body. Consider performing initialization in initialization list.
PVS-Studio:
apps/opencs/model/filter/parser.cpp 582 warn V560 A part of conditional expression is always true: allowPredefined.
apps/opencs/view/world/referencecreator.cpp 67 warn V547 Expression '!errors.empty()' is always false.
apps/opencs/view/world/referencecreator.cpp 74 warn V547 Expression '!errors.empty()' is always false.
apps/opencs/view/doc/loader.cpp 170 warn V560 A part of conditional expression is always true: !completed.
apps/opencs/view/doc/loader.cpp 170 warn V560 A part of conditional expression is always true: !error.empty().
apps/opencs/model/tools/pathgridcheck.cpp 32 err V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 32, 34.
apps/opencs/model/world/refidadapterimp.cpp 1376 err V547 Expression 'subColIndex < 3' is always true.
apps/openmw/mwgui/widgets.hpp 318 warn V703 It is odd that the 'mEnableRepeat' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:318, MyGUI_ScrollBar.h:179.
apps/openmw/mwgui/widgets.hpp 319 warn V703 It is odd that the 'mRepeatTriggerTime' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:319, MyGUI_ScrollBar.h:180.
apps/openmw/mwgui/widgets.hpp 320 warn V703 It is odd that the 'mRepeatStepTime' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:320, MyGUI_ScrollBar.h:181
apps/openmw/mwmechanics/actors.cpp 1425 warn V547 Expression '!detected' is always true.
apps/openmw/mwmechanics/character.cpp 2155 err V547 Expression 'mode == 0' is always true.
apps/openmw/mwmechanics/character.cpp 1192 warn V592 The expression was enclosed by parentheses twice: ((expression)). One pair of parentheses is unnecessary or misprint is present.
apps/openmw/mwmechanics/character.cpp 521 warn V560 A part of conditional expression is always true: (idle == mIdleState).
apps/openmw/mwmechanics/pathfinding.cpp 317 err V547 Expression 'mPath.size() >= 2' is always true.
apps/openmw/mwscript/interpretercontext.cpp 409 warn V560 A part of conditional expression is always false: rank > 9.
apps/openmw/mwgui/windowbase.cpp 28 warn V560 A part of conditional expression is always true: !visible.
apps/openmw/mwgui/journalwindow.cpp 561 warn V547 Expression '!mAllQuests' is always false.
apps/openmw/mwgui/referenceinterface.cpp 18 warn V571 Recurring check. The '!mPtr.isEmpty()' condition was already verified in line 16.
apps/openmw/mwworld/scene.cpp 463 warn V547 Expression 'adjustPlayerPos' is always true.
apps/openmw/mwworld/worldimp.cpp 409 err V766 An item with the same key '"sCompanionShare"' has already been added.
apps/openmw/mwworld/cellstore.cpp 691 warn V519 The 'state.mWaterLevel' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 689, 691.
apps/openmw/mwworld/weather.cpp 1125 warn V519 The 'mResult.mParticleEffect' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1123, 1125.
apps/openmw/mwworld/weather.cpp 1137 warn V519 The 'mResult.mParticleEffect' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1135, 1137.
apps/wizard/unshield/unshieldworker.cpp 475 warn V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression.
apps/wizard/installationpage.cpp 163 warn V735 Possibly an incorrect HTML. The "
::print()
// loads, rather than loading and then dumping. :-( Anyone mind if
// I change this?
ESM::Dialogue::InfoContainer::iterator iit;
- for (iit = mData.mInfo.begin(); iit != mData.mInfo.end(); iit++)
+ for (iit = mData.mInfo.begin(); iit != mData.mInfo.end(); ++iit)
std::cout << "INFO!" << iit->mId << std::endl;
}
@@ -1123,7 +1123,7 @@ void Record::print()
int i = 0;
ESM::Pathgrid::PointList::iterator pit;
- for (pit = mData.mPoints.begin(); pit != mData.mPoints.end(); pit++)
+ for (pit = mData.mPoints.begin(); pit != mData.mPoints.end(); ++pit)
{
std::cout << " Point[" << i << "]:" << std::endl;
std::cout << " Coordinates: (" << pit->mX << ","
@@ -1135,7 +1135,7 @@ void Record::print()
}
i = 0;
ESM::Pathgrid::EdgeList::iterator eit;
- for (eit = mData.mEdges.begin(); eit != mData.mEdges.end(); eit++)
+ for (eit = mData.mEdges.begin(); eit != mData.mEdges.end(); ++eit)
{
std::cout << " Edge[" << i << "]: " << eit->mV0 << " -> " << eit->mV1 << std::endl;
if (eit->mV0 >= mData.mData.mS2 || eit->mV1 >= mData.mData.mS2)
diff --git a/apps/niftest/niftest.cpp b/apps/niftest/niftest.cpp
index 72393db40..572a58f26 100644
--- a/apps/niftest/niftest.cpp
+++ b/apps/niftest/niftest.cpp
@@ -33,12 +33,12 @@ bool hasExtension(std::string filename, std::string extensionToFind)
}
///See if the file has the "nif" extension.
-bool isNIF(std::string filename)
+bool isNIF(const std::string & filename)
{
return hasExtension(filename,"nif");
}
///See if the file has the "bsa" extension.
-bool isBSA(std::string filename)
+bool isBSA(const std::string & filename)
{
return hasExtension(filename,"bsa");
}
diff --git a/apps/opencs/model/filter/parser.cpp b/apps/opencs/model/filter/parser.cpp
index d2bedc666..d2a4f2a35 100644
--- a/apps/opencs/model/filter/parser.cpp
+++ b/apps/opencs/model/filter/parser.cpp
@@ -579,7 +579,7 @@ bool CSMFilter::Parser::parse (const std::string& filter, bool allowPredefined)
}
// We do not use isString() here, because there could be a pre-defined filter with an ID that is
// equal a filter keyword.
- else if (token.mType==Token::Type_String && allowPredefined)
+ else if (token.mType==Token::Type_String)
{
if (getNextToken()!=Token (Token::Type_EOS))
{
diff --git a/apps/opencs/model/prefs/boolsetting.cpp b/apps/opencs/model/prefs/boolsetting.cpp
index 6431dc6af..14fdbc818 100644
--- a/apps/opencs/model/prefs/boolsetting.cpp
+++ b/apps/opencs/model/prefs/boolsetting.cpp
@@ -22,6 +22,8 @@ CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& too
std::pair CSMPrefs::BoolSetting::makeWidgets (QWidget *parent)
{
+ if (mWidget != nullptr)
+ delete mWidget;
mWidget = new QCheckBox (QString::fromUtf8 (getLabel().c_str()), parent);
mWidget->setCheckState (mDefault ? Qt::Checked : Qt::Unchecked);
diff --git a/apps/opencs/model/prefs/shortcuteventhandler.cpp b/apps/opencs/model/prefs/shortcuteventhandler.cpp
index 93e2d85d3..e42cb5da1 100644
--- a/apps/opencs/model/prefs/shortcuteventhandler.cpp
+++ b/apps/opencs/model/prefs/shortcuteventhandler.cpp
@@ -49,7 +49,7 @@ namespace CSMPrefs
ShortcutMap::iterator shortcutListIt = mWidgetShortcuts.find(widget);
if (shortcutListIt != mWidgetShortcuts.end())
{
- std::remove(shortcutListIt->second.begin(), shortcutListIt->second.end(), shortcut);
+ shortcutListIt->second.erase(std::remove(shortcutListIt->second.begin(), shortcutListIt->second.end(), shortcut), shortcutListIt->second.end());
}
}
diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp
index 3cd4a1b09..be4d37792 100644
--- a/apps/opencs/model/tools/pathgridcheck.cpp
+++ b/apps/opencs/model/tools/pathgridcheck.cpp
@@ -29,7 +29,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Pathgrid, pathgrid.mId);
// check the number of pathgrid points
- if (pathgrid.mData.mS2 > static_cast(pathgrid.mPoints.size()))
+ if (pathgrid.mData.mS2 < static_cast(pathgrid.mPoints.size()))
messages.add (id, pathgrid.mId + " has less points than expected", "", CSMDoc::Message::Severity_Error);
else if (pathgrid.mData.mS2 > static_cast(pathgrid.mPoints.size()))
messages.add (id, pathgrid.mId + " has more points than expected", "", CSMDoc::Message::Severity_Error);
diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp
index 6b586dcec..8ecf58e84 100644
--- a/apps/opencs/model/world/refcollection.cpp
+++ b/apps/opencs/model/world/refcollection.cpp
@@ -24,7 +24,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
bool isDeleted = false;
// hack to initialise mindex
- while (!(mref.mRefNum.mIndex = 0) && ESM::Cell::getNextRef(reader, ref, isDeleted, true, &mref))
+ while (!(mref.mRefNum.mIndex == 0) && ESM::Cell::getNextRef(reader, ref, isDeleted, true, &mref))
{
// Keep mOriginalCell empty when in modified (as an indicator that the
// original cell will always be equal the current cell).
diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp
index e8f921580..3d0c874f9 100644
--- a/apps/opencs/model/world/refidadapterimp.cpp
+++ b/apps/opencs/model/world/refidadapterimp.cpp
@@ -1373,10 +1373,8 @@ QVariant CSMWorld::CreatureAttackRefIdAdapter::getNestedData (const RefIdColumn
if (subColIndex == 0)
return subRowIndex + 1;
- else if (subColIndex < 3) // 1 or 2
+ else // 1 or 2
return creature.mData.mAttack[(subRowIndex * 2) + (subColIndex - 1)];
- else
- return QVariant(); // throw an exception here?
}
void CSMWorld::CreatureAttackRefIdAdapter::setNestedData (const RefIdColumn *column,
diff --git a/apps/opencs/view/doc/loader.cpp b/apps/opencs/view/doc/loader.cpp
index 713295d70..49a53e179 100644
--- a/apps/opencs/view/doc/loader.cpp
+++ b/apps/opencs/view/doc/loader.cpp
@@ -167,7 +167,7 @@ void CSVDoc::Loader::loadingStopped (CSMDoc::Document *document, bool completed,
delete iter->second;
mDocuments.erase (iter);
}
- else if (!completed && !error.empty())
+ else
{
iter->second->abort (error);
// Leave the window open for now (wait for the user to close it)
diff --git a/apps/opencs/view/world/referencecreator.cpp b/apps/opencs/view/world/referencecreator.cpp
index 1363f489a..e939b9baf 100644
--- a/apps/opencs/view/world/referencecreator.cpp
+++ b/apps/opencs/view/world/referencecreator.cpp
@@ -63,19 +63,9 @@ std::string CSVWorld::ReferenceCreator::getErrors() const
std::string cell = mCell->text().toUtf8().constData();
if (cell.empty())
- {
- if (!errors.empty())
- errors += "
";
-
errors += "Missing Cell ID";
- }
else if (getData().getCells().searchId (cell)==-1)
- {
- if (!errors.empty())
- errors += "
";
-
errors += "Invalid Cell ID";
- }
return errors;
}
diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp
index 0776706d8..6071863b5 100644
--- a/apps/openmw/mwgui/journalwindow.cpp
+++ b/apps/openmw/mwgui/journalwindow.cpp
@@ -558,7 +558,7 @@ namespace
if (mAllQuests)
{
SetNamesInactive setInactive(list);
- mModel->visitQuestNames(!mAllQuests, setInactive);
+ mModel->visitQuestNames(false, setInactive);
}
MWBase::Environment::get().getWindowManager()->playSound("book page");
diff --git a/apps/openmw/mwgui/referenceinterface.cpp b/apps/openmw/mwgui/referenceinterface.cpp
index 6213d9e25..83221c4f4 100644
--- a/apps/openmw/mwgui/referenceinterface.cpp
+++ b/apps/openmw/mwgui/referenceinterface.cpp
@@ -15,11 +15,8 @@ namespace MWGui
// check if count of the reference has become 0
if (!mPtr.isEmpty() && mPtr.getRefData().getCount() == 0)
{
- if (!mPtr.isEmpty())
- {
- mPtr = MWWorld::Ptr();
- onReferenceUnavailable();
- }
+ mPtr = MWWorld::Ptr();
+ onReferenceUnavailable();
}
}
}
diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp
index 45767bf01..013c39b15 100644
--- a/apps/openmw/mwgui/widgets.cpp
+++ b/apps/openmw/mwgui/widgets.cpp
@@ -532,12 +532,11 @@ namespace MWGui
assignWidget(mBarTextWidget, "BarText");
}
- MWScrollBar::MWScrollBar()
- : mEnableRepeat(true)
- , mRepeatTriggerTime(0.5f)
- , mRepeatStepTime(0.1f)
- , mIsIncreasing(true)
+ MWScrollBar::MWScrollBar() : mIsIncreasing(true)
{
+ mEnableRepeat = true;
+ mRepeatTriggerTime = 0.5f;
+ mRepeatStepTime = 0.1f;
#if MYGUI_VERSION >= MYGUI_DEFINE_VERSION(3,2,2)
ScrollBar::setRepeatEnabled(false);
#endif
diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp
index 6d9c0a580..67a6d705c 100644
--- a/apps/openmw/mwgui/widgets.hpp
+++ b/apps/openmw/mwgui/widgets.hpp
@@ -315,9 +315,6 @@ namespace MWGui
virtual void initialiseOverride();
void repeatClick(MyGUI::Widget* _widget, MyGUI::ControllerItem* _controller);
- bool mEnableRepeat;
- float mRepeatTriggerTime;
- float mRepeatStepTime;
bool mIsIncreasing;
private:
diff --git a/apps/openmw/mwgui/windowbase.cpp b/apps/openmw/mwgui/windowbase.cpp
index a0e7eedde..93440a50a 100644
--- a/apps/openmw/mwgui/windowbase.cpp
+++ b/apps/openmw/mwgui/windowbase.cpp
@@ -25,7 +25,7 @@ void WindowBase::setVisible(bool visible)
if (visible)
onOpen();
- else if (wasVisible && !visible)
+ else if (wasVisible)
onClose();
// This is needed as invisible widgets can retain key focus.
diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp
index 2f32a6570..7990373a7 100644
--- a/apps/openmw/mwmechanics/actors.cpp
+++ b/apps/openmw/mwmechanics/actors.cpp
@@ -1422,7 +1422,7 @@ namespace MWMechanics
MWBase::Environment::get().getWindowManager()->setSneakVisibility(false);
break;
}
- else if (!detected)
+ else
avoidedNotice = true;
}
}
diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp
index f88b20a10..06e0a42d7 100644
--- a/apps/openmw/mwmechanics/character.cpp
+++ b/apps/openmw/mwmechanics/character.cpp
@@ -517,8 +517,7 @@ void CharacterController::refreshMovementAnims(const WeaponInfo* weap, Character
void CharacterController::refreshIdleAnims(const WeaponInfo* weap, CharacterState idle, bool force)
{
- if(force || idle != mIdleState ||
- ((idle == mIdleState) && !mAnimation->isPlaying(mCurrentIdle) && mAnimQueue.empty()))
+ if(force || idle != mIdleState || (!mAnimation->isPlaying(mCurrentIdle) && mAnimQueue.empty()))
{
mIdleState = idle;
size_t numLoops = ~0ul;
@@ -1189,7 +1188,7 @@ bool CharacterController::updateWeaponState()
std::string weapgroup;
if(weaptype == WeapType_None)
{
- if ((!isWerewolf || mWeaponType != WeapType_Spell))
+ if (!isWerewolf || mWeaponType != WeapType_Spell)
{
getWeaponGroup(mWeaponType, weapgroup);
mAnimation->play(weapgroup, priorityWeapon,
@@ -2152,7 +2151,7 @@ bool CharacterController::playGroup(const std::string &groupname, int mode, int
MWRender::Animation::BlendMask_All, false, 1.0f,
((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1, loopfallback);
}
- else if(mode == 0)
+ else
{
mAnimQueue.resize(1);
mAnimQueue.push_back(entry);
diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp
index 1dccb6c9a..9d3fa2297 100644
--- a/apps/openmw/mwmechanics/pathfinding.cpp
+++ b/apps/openmw/mwmechanics/pathfinding.cpp
@@ -314,17 +314,14 @@ namespace MWMechanics
{
const ESM::Pathgrid::Point oldStart(*getPath().begin());
buildPath(startPoint, endPoint, cell, pathgridGraph);
- if (mPath.size() >= 2)
+ // if 2nd waypoint of new path == 1st waypoint of old,
+ // delete 1st waypoint of new path.
+ std::list::iterator iter = ++mPath.begin();
+ if (iter->mX == oldStart.mX
+ && iter->mY == oldStart.mY
+ && iter->mZ == oldStart.mZ)
{
- // if 2nd waypoint of new path == 1st waypoint of old,
- // delete 1st waypoint of new path.
- std::list::iterator iter = ++mPath.begin();
- if (iter->mX == oldStart.mX
- && iter->mY == oldStart.mY
- && iter->mZ == oldStart.mZ)
- {
- mPath.pop_front();
- }
+ mPath.pop_front();
}
}
}
diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp
index d70ff5319..f4e729da1 100644
--- a/apps/openmw/mwscript/interpretercontext.cpp
+++ b/apps/openmw/mwscript/interpretercontext.cpp
@@ -406,7 +406,7 @@ namespace MWScript
const MWWorld::ESMStore &store = world->getStore();
const ESM::Faction *faction = store.get().find(factionId);
- if(rank < 0 || rank > 9)
+ if(rank < 0)
return "";
return faction->mRanks[rank];
diff --git a/apps/openmw/mwstate/quicksavemanager.cpp b/apps/openmw/mwstate/quicksavemanager.cpp
index 4bae9e674..e7d045283 100644
--- a/apps/openmw/mwstate/quicksavemanager.cpp
+++ b/apps/openmw/mwstate/quicksavemanager.cpp
@@ -1,8 +1,8 @@
#include "quicksavemanager.hpp"
MWState::QuickSaveManager::QuickSaveManager(std::string &saveName, unsigned int maxSaves)
+ : mSaveName(saveName)
{
- this->mSaveName = saveName;
this->mMaxSaves = maxSaves;
this->mOldestSlotVisited = NULL;
this->mSlotsVisited = 0;
diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp
index f33c7bb67..10a4e5fff 100644
--- a/apps/openmw/mwworld/cellstore.cpp
+++ b/apps/openmw/mwworld/cellstore.cpp
@@ -685,8 +685,8 @@ namespace MWWorld
{
state.mId = mCell->getCellId();
- if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater)
- state.mWaterLevel = mWaterLevel;
+ // if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater)
+ // state.mWaterLevel = mWaterLevel;
state.mWaterLevel = mWaterLevel;
state.mHasFogOfWar = (mFogState.get() ? 1 : 0);
diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp
index 4b844f464..2c2d401d1 100644
--- a/apps/openmw/mwworld/scene.cpp
+++ b/apps/openmw/mwworld/scene.cpp
@@ -460,8 +460,7 @@ namespace MWWorld
float z = pos.rot[2];
world->rotateObject(player, x, y, z);
- if (adjustPlayerPos)
- player.getClass().adjustPosition(player, true);
+ player.getClass().adjustPosition(player, true);
}
MWBase::MechanicsManager *mechMgr =
diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp
index c958572ca..155e4340a 100644
--- a/apps/openmw/mwworld/weather.cpp
+++ b/apps/openmw/mwworld/weather.cpp
@@ -1134,7 +1134,6 @@ inline void WeatherManager::calculateTransitionResult(const float factor, const
mResult.mIsStorm = current.mIsStorm;
mResult.mParticleEffect = current.mParticleEffect;
mResult.mRainEffect = current.mRainEffect;
- mResult.mParticleEffect = current.mParticleEffect;
mResult.mRainSpeed = current.mRainSpeed;
mResult.mRainFrequency = current.mRainFrequency;
mResult.mAmbientSoundVolume = 1-(factor*2);
@@ -1146,7 +1145,6 @@ inline void WeatherManager::calculateTransitionResult(const float factor, const
mResult.mIsStorm = other.mIsStorm;
mResult.mParticleEffect = other.mParticleEffect;
mResult.mRainEffect = other.mRainEffect;
- mResult.mParticleEffect = other.mParticleEffect;
mResult.mRainSpeed = other.mRainSpeed;
mResult.mRainFrequency = other.mRainFrequency;
mResult.mAmbientSoundVolume = 2*(factor-0.5f);
diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp
index 99eedf73d..13bfc32b3 100644
--- a/apps/openmw/mwworld/worldimp.cpp
+++ b/apps/openmw/mwworld/worldimp.cpp
@@ -406,7 +406,6 @@ namespace MWWorld
gmst["sCompanionWarningMessage"] = ESM::Variant("Warning message");
gmst["sCompanionWarningButtonOne"] = ESM::Variant("Button 1");
gmst["sCompanionWarningButtonTwo"] = ESM::Variant("Button 2");
- gmst["sCompanionShare"] = ESM::Variant("Companion Share");
gmst["sProfitValue"] = ESM::Variant("Profit Value");
gmst["sTeleportDisabled"] = ESM::Variant("Teleport disabled");
gmst["sLevitateDisabled"] = ESM::Variant("Levitate disabled");
diff --git a/apps/wizard/installationpage.cpp b/apps/wizard/installationpage.cpp
index 7a4dcbf10..3deb30f25 100644
--- a/apps/wizard/installationpage.cpp
+++ b/apps/wizard/installationpage.cpp
@@ -161,7 +161,7 @@ void Wizard::InstallationPage::showFileDialog(Wizard::Component component)
if (path.isEmpty()) {
logTextEdit->appendHtml(tr("
\
- Error: The installation was aborted by the user
"));
+ Error: The installation was aborted by the user"));
mWizard->addLogText(QLatin1String("Error: The installation was aborted by the user"));
mWizard->mError = true;
diff --git a/apps/wizard/unshield/unshieldworker.cpp b/apps/wizard/unshield/unshieldworker.cpp
index 020de9f80..9cdb4cd78 100644
--- a/apps/wizard/unshield/unshieldworker.cpp
+++ b/apps/wizard/unshield/unshieldworker.cpp
@@ -472,8 +472,8 @@ bool Wizard::UnshieldWorker::setupComponent(Component component)
if (morrowindFound) {
// Check if we have correct archive, other archives have Morrowind.bsa too
- if ((tribunalFound && bloodmoonFound)
- || (!tribunalFound && !bloodmoonFound)) {
+ if (tribunalFound == bloodmoonFound)
+ {
cabFile = file;
found = true; // We have a GoTY disk or a Morrowind-only disk
}
diff --git a/components/esm/cellref.cpp b/components/esm/cellref.cpp
index e41201d6e..f35149586 100644
--- a/components/esm/cellref.cpp
+++ b/components/esm/cellref.cpp
@@ -173,10 +173,10 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool
}
if (!inInventory)
+ {
esm.writeHNOCString ("KNAM", mKey);
-
- if (!inInventory)
esm.writeHNOCString ("TNAM", mTrap);
+ }
if (mReferenceBlocked != -1)
esm.writeHNT("UNAM", mReferenceBlocked);
@@ -188,7 +188,7 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool
void ESM::CellRef::blank()
{
mRefNum.unset();
- mRefID.clear();
+ mRefID.clear();
mScale = 1;
mOwner.clear();
mGlobalVariable.clear();
@@ -205,7 +205,7 @@ void ESM::CellRef::blank()
mTrap.clear();
mReferenceBlocked = -1;
mTeleport = false;
-
+
for (int i=0; i<3; ++i)
{
mDoorDest.pos[i] = 0;
diff --git a/components/esm/loadregn.cpp b/components/esm/loadregn.cpp
index 6e0e6db9d..e708bbb4e 100644
--- a/components/esm/loadregn.cpp
+++ b/components/esm/loadregn.cpp
@@ -109,8 +109,6 @@ namespace ESM
void Region::blank()
{
- mName.clear();
-
mData.mClear = mData.mCloudy = mData.mFoggy = mData.mOvercast = mData.mRain =
mData.mThunder = mData.mAsh, mData.mBlight = mData.mA = mData.mB = 0;
diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp
index 63efb36be..dc144d119 100644
--- a/components/esmterrain/storage.cpp
+++ b/components/esmterrain/storage.cpp
@@ -232,9 +232,9 @@ namespace ESMTerrain
// Skip the first row / column unless we're at a chunk edge,
// since this row / column is already contained in a previous cell
// This is only relevant if we're creating a chunk spanning multiple cells
- if (colStart == 0 && vertY_ != 0)
+ if (vertY_ != 0)
colStart += increment;
- if (rowStart == 0 && vertX_ != 0)
+ if (vertX_ != 0)
rowStart += increment;
// Only relevant for chunks smaller than (contained in) one cell
diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp
index d2c97953c..f19281104 100644
--- a/components/fontloader/fontloader.cpp
+++ b/components/fontloader/fontloader.cpp
@@ -448,7 +448,7 @@ namespace Gui
MyGUI::FontCodeType::Enum type;
if(i == 0)
type = MyGUI::FontCodeType::Selected;
- else if (i == 1)
+ else
type = MyGUI::FontCodeType::SelectedBack;
MyGUI::xml::ElementPtr cursorCode = codes->createChild("Code");
diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp
index 6e04c6405..0add92f29 100644
--- a/components/nifosg/nifloader.cpp
+++ b/components/nifosg/nifloader.cpp
@@ -275,7 +275,6 @@ namespace NifOsg
for (unsigned int i=0; igetNumChildren(); ++i)
skel->addChild(root->getChild(i));
root->removeChildren(0, root->getNumChildren());
- created = skel;
}
else
skel->addChild(created);
From d310d36ea3940f3feff1a0de20353246352d811c Mon Sep 17 00:00:00 2001
From: tri4ng1e
Date: Tue, 17 Apr 2018 12:11:05 +0300
Subject: [PATCH 6/6] [Fix] Some PVS-Studio and cppcheck fixes
---
apps/opencs/model/prefs/boolsetting.cpp | 2 --
apps/opencs/model/world/refcollection.cpp | 2 +-
apps/opencs/model/world/refidadapterimp.cpp | 2 +-
apps/openmw/mwgui/journalwindow.cpp | 2 +-
apps/openmw/mwgui/widgets.cpp | 9 +++++----
apps/openmw/mwgui/widgets.hpp | 3 +++
apps/openmw/mwmechanics/pathfinding.cpp | 17 ++++++++++-------
apps/openmw/mwstate/quicksavemanager.cpp | 6 +++---
apps/openmw/mwworld/cellstore.cpp | 6 ++----
components/fontloader/fontloader.cpp | 2 +-
10 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/apps/opencs/model/prefs/boolsetting.cpp b/apps/opencs/model/prefs/boolsetting.cpp
index 14fdbc818..6431dc6af 100644
--- a/apps/opencs/model/prefs/boolsetting.cpp
+++ b/apps/opencs/model/prefs/boolsetting.cpp
@@ -22,8 +22,6 @@ CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& too
std::pair CSMPrefs::BoolSetting::makeWidgets (QWidget *parent)
{
- if (mWidget != nullptr)
- delete mWidget;
mWidget = new QCheckBox (QString::fromUtf8 (getLabel().c_str()), parent);
mWidget->setCheckState (mDefault ? Qt::Checked : Qt::Unchecked);
diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp
index 8ecf58e84..6b586dcec 100644
--- a/apps/opencs/model/world/refcollection.cpp
+++ b/apps/opencs/model/world/refcollection.cpp
@@ -24,7 +24,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
bool isDeleted = false;
// hack to initialise mindex
- while (!(mref.mRefNum.mIndex == 0) && ESM::Cell::getNextRef(reader, ref, isDeleted, true, &mref))
+ while (!(mref.mRefNum.mIndex = 0) && ESM::Cell::getNextRef(reader, ref, isDeleted, true, &mref))
{
// Keep mOriginalCell empty when in modified (as an indicator that the
// original cell will always be equal the current cell).
diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp
index 3d0c874f9..ba67b4e14 100644
--- a/apps/opencs/model/world/refidadapterimp.cpp
+++ b/apps/opencs/model/world/refidadapterimp.cpp
@@ -1373,7 +1373,7 @@ QVariant CSMWorld::CreatureAttackRefIdAdapter::getNestedData (const RefIdColumn
if (subColIndex == 0)
return subRowIndex + 1;
- else // 1 or 2
+ else if (subColIndex < 3) // 1 or 2
return creature.mData.mAttack[(subRowIndex * 2) + (subColIndex - 1)];
}
diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp
index 6071863b5..0776706d8 100644
--- a/apps/openmw/mwgui/journalwindow.cpp
+++ b/apps/openmw/mwgui/journalwindow.cpp
@@ -558,7 +558,7 @@ namespace
if (mAllQuests)
{
SetNamesInactive setInactive(list);
- mModel->visitQuestNames(false, setInactive);
+ mModel->visitQuestNames(!mAllQuests, setInactive);
}
MWBase::Environment::get().getWindowManager()->playSound("book page");
diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp
index 013c39b15..024a91fc6 100644
--- a/apps/openmw/mwgui/widgets.cpp
+++ b/apps/openmw/mwgui/widgets.cpp
@@ -532,11 +532,12 @@ namespace MWGui
assignWidget(mBarTextWidget, "BarText");
}
- MWScrollBar::MWScrollBar() : mIsIncreasing(true)
+ MWScrollBar::MWScrollBar()
+ : mEnableRepeat(true)
+ , mRepeatTriggerTime(0.5f)
+ , mRepeatStepTime(0.1f)
+ , mIsIncreasing(true)
{
- mEnableRepeat = true;
- mRepeatTriggerTime = 0.5f;
- mRepeatStepTime = 0.1f;
#if MYGUI_VERSION >= MYGUI_DEFINE_VERSION(3,2,2)
ScrollBar::setRepeatEnabled(false);
#endif
diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp
index 67a6d705c..6d9c0a580 100644
--- a/apps/openmw/mwgui/widgets.hpp
+++ b/apps/openmw/mwgui/widgets.hpp
@@ -315,6 +315,9 @@ namespace MWGui
virtual void initialiseOverride();
void repeatClick(MyGUI::Widget* _widget, MyGUI::ControllerItem* _controller);
+ bool mEnableRepeat;
+ float mRepeatTriggerTime;
+ float mRepeatStepTime;
bool mIsIncreasing;
private:
diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp
index 9d3fa2297..0591667b7 100644
--- a/apps/openmw/mwmechanics/pathfinding.cpp
+++ b/apps/openmw/mwmechanics/pathfinding.cpp
@@ -314,14 +314,17 @@ namespace MWMechanics
{
const ESM::Pathgrid::Point oldStart(*getPath().begin());
buildPath(startPoint, endPoint, cell, pathgridGraph);
- // if 2nd waypoint of new path == 1st waypoint of old,
- // delete 1st waypoint of new path.
- std::list::iterator iter = ++mPath.begin();
- if (iter->mX == oldStart.mX
- && iter->mY == oldStart.mY
- && iter->mZ == oldStart.mZ)
+ if (mPath.size() >= 2)
{
- mPath.pop_front();
+ // if 2nd waypoint of new path == 1st waypoint of old,
+ // delete 1st waypoint of new path.
+ std::list::iterator iter = ++mPath.begin();
+ if (iter->mX == oldStart.mX
+ && iter->mY == oldStart.mY
+ && iter->mZ == oldStart.mZ)
+ {
+ mPath.pop_front();
+ }
}
}
}
diff --git a/apps/openmw/mwstate/quicksavemanager.cpp b/apps/openmw/mwstate/quicksavemanager.cpp
index e7d045283..9f522d7eb 100644
--- a/apps/openmw/mwstate/quicksavemanager.cpp
+++ b/apps/openmw/mwstate/quicksavemanager.cpp
@@ -2,10 +2,10 @@
MWState::QuickSaveManager::QuickSaveManager(std::string &saveName, unsigned int maxSaves)
: mSaveName(saveName)
+ , mMaxSaves(maxSaves)
+ , mOldestSlotVisited(NULL)
+ , mSlotsVisited(0)
{
- this->mMaxSaves = maxSaves;
- this->mOldestSlotVisited = NULL;
- this->mSlotsVisited = 0;
}
void MWState::QuickSaveManager::visitSave(const Slot *saveSlot)
diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp
index 10a4e5fff..1b6495c11 100644
--- a/apps/openmw/mwworld/cellstore.cpp
+++ b/apps/openmw/mwworld/cellstore.cpp
@@ -677,7 +677,6 @@ namespace MWWorld
if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater)
mWaterLevel = state.mWaterLevel;
- mWaterLevel = state.mWaterLevel;
mLastRespawn = MWWorld::TimeStamp(state.mLastRespawn);
}
@@ -685,10 +684,9 @@ namespace MWWorld
{
state.mId = mCell->getCellId();
- // if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater)
- // state.mWaterLevel = mWaterLevel;
+ if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater)
+ state.mWaterLevel = mWaterLevel;
- state.mWaterLevel = mWaterLevel;
state.mHasFogOfWar = (mFogState.get() ? 1 : 0);
state.mLastRespawn = mLastRespawn.toEsm();
}
diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp
index f19281104..080739bc1 100644
--- a/components/fontloader/fontloader.cpp
+++ b/components/fontloader/fontloader.cpp
@@ -448,7 +448,7 @@ namespace Gui
MyGUI::FontCodeType::Enum type;
if(i == 0)
type = MyGUI::FontCodeType::Selected;
- else
+ else // if (i == 1)
type = MyGUI::FontCodeType::SelectedBack;
MyGUI::xml::ElementPtr cursorCode = codes->createChild("Code");