From c5a36ad440a55ebf999a2e9d452e5437b62180ec Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 13:19:41 +0400 Subject: [PATCH 01/16] Do not cast enums to booleans --- apps/launcher/advancedpage.cpp | 2 +- apps/launcher/graphicspage.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp index 6f59ade7ab..54fbbdfe01 100644 --- a/apps/launcher/advancedpage.cpp +++ b/apps/launcher/advancedpage.cpp @@ -108,7 +108,7 @@ bool Launcher::AdvancedPage::loadSettings() loadSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game"); connect(animSourcesCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotAnimSourcesToggled(bool))); loadSettingBool(animSourcesCheckBox, "use additional anim sources", "Game"); - if (animSourcesCheckBox->checkState()) + if (animSourcesCheckBox->checkState() != Qt::Unchecked) { loadSettingBool(weaponSheathingCheckBox, "weapon sheathing", "Game"); loadSettingBool(shieldSheathingCheckBox, "shield sheathing", "Game"); diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index d1cf3aa6ff..01205043ec 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -206,7 +206,7 @@ void Launcher::GraphicsPage::saveSettings() if (cScreen != mEngineSettings.getInt("screen", "Video")) mEngineSettings.setInt("screen", "Video", cScreen); - if (framerateLimitCheckBox->checkState()) + if (framerateLimitCheckBox->checkState() != Qt::Unchecked) { float cFpsLimit = framerateLimitSpinBox->value(); if (cFpsLimit != mEngineSettings.getFloat("framerate limit", "Video")) @@ -217,7 +217,7 @@ void Launcher::GraphicsPage::saveSettings() mEngineSettings.setFloat("framerate limit", "Video", 0); } - int cShadowDist = shadowDistanceCheckBox->checkState() ? shadowDistanceSpinBox->value() : 0; + int cShadowDist = shadowDistanceCheckBox->checkState() != Qt::Unchecked ? shadowDistanceSpinBox->value() : 0; if (mEngineSettings.getInt("maximum shadow map distance", "Shadows") != cShadowDist) mEngineSettings.setInt("maximum shadow map distance", "Shadows", cShadowDist); float cFadeStart = fadeStartSpinBox->value(); From 801e2d6ad0f66ce9646c06ff6b73793c54349ce4 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 13:36:40 +0400 Subject: [PATCH 02/16] Avoid to use uninitialized variables --- apps/opencs/model/world/refidadapterimp.cpp | 2 +- apps/opencs/model/world/refidadapterimp.hpp | 2 +- components/files/constrainedfilestream.cpp | 2 +- components/nif/data.hpp | 10 +++++----- components/sceneutil/mwshadowtechnique.cpp | 2 ++ 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index d85fcc068f..d944adc23e 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -10,7 +10,7 @@ #include "nestedtablewrapper.hpp" CSMWorld::PotionColumns::PotionColumns (const InventoryColumns& columns) -: InventoryColumns (columns) {} +: InventoryColumns (columns), mEffects(nullptr) {} CSMWorld::PotionRefIdAdapter::PotionRefIdAdapter (const PotionColumns& columns, const RefIdColumn *autoCalc) diff --git a/apps/opencs/model/world/refidadapterimp.hpp b/apps/opencs/model/world/refidadapterimp.hpp index 7695e9acec..a73f76af9d 100644 --- a/apps/opencs/model/world/refidadapterimp.hpp +++ b/apps/opencs/model/world/refidadapterimp.hpp @@ -115,7 +115,7 @@ namespace CSMWorld { const RefIdColumn *mModel; - ModelColumns (const BaseColumns& base) : BaseColumns (base) {} + ModelColumns (const BaseColumns& base) : BaseColumns (base), mModel(nullptr) {} }; /// \brief Adapter for IDs with models (all but levelled lists) diff --git a/components/files/constrainedfilestream.cpp b/components/files/constrainedfilestream.cpp index baab1b081f..b9968038d1 100644 --- a/components/files/constrainedfilestream.cpp +++ b/components/files/constrainedfilestream.cpp @@ -21,7 +21,7 @@ namespace Files LowLevelFile mFile; - char mBuffer[sBufferSize]; + char mBuffer[sBufferSize]{0}; public: ConstrainedFileStreamBuf(const std::string &fname, size_t start, size_t length) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 66a391afc3..efbe138c53 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -71,7 +71,7 @@ struct NiParticlesData : public NiGeometryData { int numParticles{0}; - int activeCount; + int activeCount{0}; std::vector particleRadii, sizes, rotationAngles; std::vector rotations; @@ -119,14 +119,14 @@ struct NiPixelData : public Record NIPXFMT_DXT5, NIPXFMT_DXT5_ALT }; - Format fmt; + Format fmt{NIPXFMT_RGB8}; - unsigned int colorMask[4]; - unsigned int bpp, pixelTiling{0}; + unsigned int colorMask[4]{0}; + unsigned int bpp{0}, pixelTiling{0}; bool sRGB{false}; NiPalettePtr palette; - unsigned int numberOfMipmaps; + unsigned int numberOfMipmaps{0}; struct Mipmap { diff --git a/components/sceneutil/mwshadowtechnique.cpp b/components/sceneutil/mwshadowtechnique.cpp index c49a147776..294780cfd7 100644 --- a/components/sceneutil/mwshadowtechnique.cpp +++ b/components/sceneutil/mwshadowtechnique.cpp @@ -785,6 +785,7 @@ MWShadowTechnique::MWShadowTechnique(): _debugHud(nullptr) { _shadowRecievingPlaceholderStateSet = new osg::StateSet; + mSetDummyStateWhenDisabled = false; } MWShadowTechnique::MWShadowTechnique(const MWShadowTechnique& vdsm, const osg::CopyOp& copyop): @@ -792,6 +793,7 @@ MWShadowTechnique::MWShadowTechnique(const MWShadowTechnique& vdsm, const osg::C { _shadowRecievingPlaceholderStateSet = new osg::StateSet; _enableShadows = vdsm._enableShadows; + mSetDummyStateWhenDisabled = vdsm.mSetDummyStateWhenDisabled; } MWShadowTechnique::~MWShadowTechnique() From 7fc4c9f3f69d81be16d2294a7c390859ae63e278 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 13:52:01 +0400 Subject: [PATCH 03/16] Avoid dead code --- apps/opencs/model/filter/parser.cpp | 6 ------ apps/opencs/view/render/terraintexturemode.cpp | 8 ++------ apps/openmw/mwgui/journalwindow.cpp | 2 +- apps/openmw/mwmechanics/character.cpp | 4 ++-- components/compiler/scanner.hpp | 11 ++++------- extern/oics/ICSInputControlSystem_joystick.cpp | 2 +- 6 files changed, 10 insertions(+), 23 deletions(-) diff --git a/apps/opencs/model/filter/parser.cpp b/apps/opencs/model/filter/parser.cpp index d2a4f2a356..d363b4849d 100644 --- a/apps/opencs/model/filter/parser.cpp +++ b/apps/opencs/model/filter/parser.cpp @@ -325,12 +325,6 @@ std::shared_ptr CSMFilter::Parser::parseNAry (const Token& keyw break; } - if (nodes.empty()) - { - error(); - return std::shared_ptr(); - } - switch (keyword.mType) { case Token::Type_Keyword_And: return std::shared_ptr (new AndNode (nodes)); diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index c8d63f32e8..09d6b135a1 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -429,12 +429,8 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe { int distanceX(0); int distanceY(0); - if (i_cell < cellX) distanceX = xHitInCell + landTextureSize * abs(i_cell-cellX) - i; - if (j_cell < cellY) distanceY = yHitInCell + landTextureSize * abs(j_cell-cellY) - j; - if (i_cell > cellX) distanceX = -xHitInCell + landTextureSize* abs(i_cell-cellX) + i; - if (j_cell > cellY) distanceY = -yHitInCell + landTextureSize * abs(j_cell-cellY) + j; - if (i_cell == cellX) distanceX = abs(i-xHitInCell); - if (j_cell == cellY) distanceY = abs(j-yHitInCell); + distanceX = abs(i-xHitInCell); + distanceY = abs(j-yHitInCell); float distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2))); float rf = static_cast(mBrushSize) / 2; if (distance < rf) newTerrain[j*landTextureSize+i] = brushInt; diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 1474becf08..96c42549a5 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -561,7 +561,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/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index b9bfe6bc0f..b9ef50bf7f 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -446,9 +446,9 @@ std::string CharacterController::fallbackShortWeaponGroup(const std::string& bas const ESM::WeaponType* weapInfo = getWeaponType(mWeaponType); // For real two-handed melee weapons use 2h swords animations as fallback, otherwise use the 1h ones - if (isRealWeapon && weapInfo->mFlags & ESM::WeaponType::TwoHanded && weapInfo->mWeaponClass == ESM::WeaponType::Melee) + if (weapInfo->mFlags & ESM::WeaponType::TwoHanded && weapInfo->mWeaponClass == ESM::WeaponType::Melee) groupName += twoHandFallback; - else if (isRealWeapon) + else groupName += oneHandFallback; // Special case for crossbows - we shouls apply 1h animations a fallback only for lower body diff --git a/components/compiler/scanner.hpp b/components/compiler/scanner.hpp index 2139f04b26..9c7bd656ed 100644 --- a/components/compiler/scanner.hpp +++ b/components/compiler/scanner.hpp @@ -140,15 +140,12 @@ namespace Compiler for (int i = 0; i <= length; i++) { - if (length >= i) - { - in.get (ch); + in.get (ch); - if (!in.good()) - return false; + if (!in.good()) + return false; - mData[i] = ch; - } + mData[i] = ch; } mLength = length; diff --git a/extern/oics/ICSInputControlSystem_joystick.cpp b/extern/oics/ICSInputControlSystem_joystick.cpp index 38199436ba..697d0ed3d3 100644 --- a/extern/oics/ICSInputControlSystem_joystick.cpp +++ b/extern/oics/ICSInputControlSystem_joystick.cpp @@ -286,7 +286,7 @@ namespace ICS //ControlAxisBinderItem joystickBinderItem = mControlsJoystickAxisBinderMap[ evt.which ][ axis ]; // joystic axis start at 0 index //Control* ctrl = joystickBinderItem.control; //if(ctrl && ctrl->isAxisBindable()) - if(mDetectingBindingControl && mDetectingBindingControl->isAxisBindable()) + if(mDetectingBindingControl->isAxisBindable()) { if( abs( evt.value ) > ICS_JOYSTICK_AXIS_BINDING_MARGIN) { From 8283ec6cadef7bcafdc4a830f2d60d00b26b6c9b Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 14:03:48 +0400 Subject: [PATCH 04/16] Do not use & for boolean arguments --- apps/opencs/view/doc/view.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index be3fe51423..6fe01dc27d 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -438,8 +438,8 @@ void CSVDoc::View::updateActions() for (std::vector::iterator iter (mEditingActions.begin()); iter!=mEditingActions.end(); ++iter) (*iter)->setEnabled (editing); - mUndo->setEnabled (editing & mDocument->getUndoStack().canUndo()); - mRedo->setEnabled (editing & mDocument->getUndoStack().canRedo()); + mUndo->setEnabled (editing && mDocument->getUndoStack().canUndo()); + mRedo->setEnabled (editing && mDocument->getUndoStack().canRedo()); mSave->setEnabled (!(mDocument->getState() & CSMDoc::State_Saving) && !running); mVerify->setEnabled (!(mDocument->getState() & CSMDoc::State_Verifying)); From 56666c60d44fa7809f8e9ab811827c4c908ce6d9 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 14:17:59 +0400 Subject: [PATCH 05/16] Remove dead code --- apps/openmw/mwmechanics/weapontype.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwmechanics/weapontype.cpp b/apps/openmw/mwmechanics/weapontype.cpp index 07345557f0..2f8e45f7ff 100644 --- a/apps/openmw/mwmechanics/weapontype.cpp +++ b/apps/openmw/mwmechanics/weapontype.cpp @@ -4,8 +4,6 @@ namespace MWMechanics { - static const ESM::WeaponType *sWeaponTypeListEnd = &sWeaponTypeList[sizeof(sWeaponTypeList)/sizeof(sWeaponTypeList[0])]; - MWWorld::ContainerStoreIterator getActiveWeapon(MWWorld::Ptr actor, int *weaptype) { MWWorld::InventoryStore &inv = actor.getClass().getInventoryStore(actor); From c1512b8b6cc47a8615c8400d91ed913e0ae35a82 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 14:18:38 +0400 Subject: [PATCH 06/16] Convert loop to condition --- apps/openmw/mwworld/localscripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index 42914d4ac0..1661d6b9f7 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -76,7 +76,7 @@ void MWWorld::LocalScripts::startIteration() bool MWWorld::LocalScripts::getNext(std::pair& script) { - while (mIter!=mScripts.end()) + if (mIter!=mScripts.end()) { std::list >::iterator iter = mIter++; script = *iter; From 33648313a68efad40eebf4d218261b5d00845ea1 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 14:21:57 +0400 Subject: [PATCH 07/16] Initialize variables --- apps/openmw/mwphysics/mtphysics.cpp | 3 +++ components/nif/node.hpp | 4 ++-- components/nif/property.hpp | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index 0d1e5962a0..3e4ed9b478 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -152,6 +152,9 @@ namespace MWPhysics , mNextLOS(0) , mFrameNumber(0) , mTimer(osg::Timer::instance()) + , mTimeBegin(0) + , mTimeEnd(0) + , mFrameStart(0) { mNumThreads = Config::computeNumThreads(mThreadSafeBullet); diff --git a/components/nif/node.hpp b/components/nif/node.hpp index 1d082b8f9b..406a4d4549 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -177,7 +177,7 @@ struct Node : public Named // NiNodes (or types derived from NiNodes) can be parents. NiNode *parent; - bool isBone; + bool isBone{false}; void setBone() { @@ -378,7 +378,7 @@ struct NiCamera : Node struct NiSwitchNode : public NiNode { unsigned int switchFlags{0}; - unsigned int initialIndex; + unsigned int initialIndex{0}; void read(NIFStream *nif) override { diff --git a/components/nif/property.hpp b/components/nif/property.hpp index eccb442f7e..008e84515c 100644 --- a/components/nif/property.hpp +++ b/components/nif/property.hpp @@ -61,7 +61,7 @@ struct NiTexturingProperty : public Property 3 - hilight // These two are for PS2 only? 4 - hilight2 */ - unsigned int apply; + unsigned int apply{0}; /* * The textures in this list are as follows: @@ -193,7 +193,7 @@ struct S_MaterialProperty // The vector components are R,G,B osg::Vec3f ambient{1.f,1.f,1.f}, diffuse{1.f,1.f,1.f}; osg::Vec3f specular, emissive; - float glossiness, alpha; + float glossiness{0.f}, alpha{0.f}; void read(NIFStream *nif); }; From c9b885ffd4e3f01943d08488722abd7fbb539e61 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 14:24:04 +0400 Subject: [PATCH 08/16] Avoid possible null dereferencing --- apps/opencs/view/world/dragdroputils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/world/dragdroputils.cpp b/apps/opencs/view/world/dragdroputils.cpp index 789d4f33dc..808125a601 100644 --- a/apps/opencs/view/world/dragdroputils.cpp +++ b/apps/opencs/view/world/dragdroputils.cpp @@ -20,7 +20,8 @@ CSMWorld::UniversalId CSVWorld::DragDropUtils::getAcceptedData(const QDropEvent { if (canAcceptData(event, type)) { - return getTableMimeData(event)->returnMatching(type); + if (const CSMWorld::TableMimeData *data = getTableMimeData(event)) + return data->returnMatching(type); } return CSMWorld::UniversalId::Type_None; } From 8e5f26c109da6e1b2b5d7126e3e66b6a61ce073d Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 14:41:10 +0400 Subject: [PATCH 09/16] Code cleanup --- apps/opencs/view/world/dragrecordtable.cpp | 12 ++++-------- apps/openmw/mwgui/hud.cpp | 2 +- apps/openmw/mwrender/globalmap.cpp | 2 +- components/terrain/terraindrawable.cpp | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/opencs/view/world/dragrecordtable.cpp b/apps/opencs/view/world/dragrecordtable.cpp index d795bd5de1..f84bf639da 100644 --- a/apps/opencs/view/world/dragrecordtable.cpp +++ b/apps/opencs/view/world/dragrecordtable.cpp @@ -19,14 +19,10 @@ void CSVWorld::DragRecordTable::startDragFromTable (const CSVWorld::DragRecordTa } CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData (records, mDocument); - - if (mime) - { - QDrag* drag = new QDrag (this); - drag->setMimeData (mime); - drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str())); - drag->exec (Qt::CopyAction); - } + QDrag* drag = new QDrag (this); + drag->setMimeData (mime); + drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str())); + drag->exec (Qt::CopyAction); } CSVWorld::DragRecordTable::DragRecordTable (CSMDoc::Document& document, QWidget* parent) : diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index a4ab20fd68..45defe9a56 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -587,7 +587,7 @@ namespace MWGui // effect box can have variable width -> variable left coordinate int effectsDx = 0; if (!mMinimapBox->getVisible ()) - effectsDx = (viewSize.width - mMinimapBoxBaseRight) - (viewSize.width - mEffectBoxBaseRight); + effectsDx = mEffectBoxBaseRight - mMinimapBoxBaseRight; mMapVisible = mMinimapBox->getVisible (); if (!mMapVisible) diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index ba300accbc..366da6439c 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -583,7 +583,7 @@ namespace MWRender } mOverlayImage->copySubImage(imageDest.mX, imageDest.mY, 0, imageDest.mImage); - it = mPendingImageDest.erase(it); + mPendingImageDest.erase(it); return true; } } diff --git a/components/terrain/terraindrawable.cpp b/components/terrain/terraindrawable.cpp index 0d82be4fff..746534abb4 100644 --- a/components/terrain/terraindrawable.cpp +++ b/components/terrain/terraindrawable.cpp @@ -78,7 +78,7 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv) osg::RefMatrix& matrix = *cv->getModelViewMatrix(); - if (cv->getComputeNearFarMode() && bb.valid()) + if (cv->getComputeNearFarMode() != osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR && bb.valid()) { if (!cv->updateCalculatedNearFar(matrix, *this, false)) return; From a80ee7a76a6ad94bc17fbda46b53affeb96968a6 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 14:43:00 +0400 Subject: [PATCH 10/16] Avoid possible memory leak in the mInterMessageBoxe field --- apps/openmw/mwgui/messagebox.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index d64ec9c37a..5bd8ceb5ae 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -28,10 +28,7 @@ namespace MWGui MessageBoxManager::~MessageBoxManager () { - for (MessageBox* messageBox : mMessageBoxes) - { - delete messageBox; - } + MessageBoxManager::clear(); } int MessageBoxManager::getMessagesCount() From 33da0af1d1760f5cd6b79a853aa0a6fe3fe848ff Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 18:25:48 +0400 Subject: [PATCH 11/16] Use explicit calls for virtual methods in constructors --- apps/openmw/mwrender/water.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index b9018e0a27..e786ce9372 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -135,7 +135,7 @@ public: mClipNodeTransform = new osg::Group; mClipNodeTransform->addCullCallback(new FlipCallback(&mPlane)); - addChild(mClipNodeTransform); + osg::Group::addChild(mClipNodeTransform); mClipNode = new osg::ClipNode; @@ -240,7 +240,7 @@ public: setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); setReferenceFrame(osg::Camera::RELATIVE_RF); setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water")); - setName("RefractionCamera"); + osg::Camera::setName("RefractionCamera"); setCullCallback(new InheritViewPointCallback); setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); @@ -261,7 +261,7 @@ public: getOrCreateStateSet()->setAttributeAndModes(fog, osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE); mClipCullNode = new ClipCullNode; - addChild(mClipCullNode); + osg::Camera::addChild(mClipCullNode); mRefractionTexture = new osg::Texture2D; mRefractionTexture->setTextureSize(rttSize, rttSize); @@ -335,7 +335,7 @@ public: setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); setReferenceFrame(osg::Camera::RELATIVE_RF); setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water")); - setName("ReflectionCamera"); + osg::Camera::setName("ReflectionCamera"); setCullCallback(new InheritViewPointCallback); setInterior(isInterior); @@ -364,7 +364,7 @@ public: getOrCreateStateSet()->setAttributeAndModes(frontFace, osg::StateAttribute::ON); mClipCullNode = new ClipCullNode; - addChild(mClipCullNode); + osg::Camera::addChild(mClipCullNode); SceneUtil::ShadowManager::disableShadowsForStateSet(getOrCreateStateSet()); } From 80ee1b55ea636184ec38718fa2d7dd928e1c5306 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 18:28:26 +0400 Subject: [PATCH 12/16] Protect assignment operator from this == &src case --- apps/openmw/mwworld/inventorystore.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 38007c1cbb..fd05957034 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -120,6 +120,9 @@ MWWorld::InventoryStore::InventoryStore (const InventoryStore& store) MWWorld::InventoryStore& MWWorld::InventoryStore::operator= (const InventoryStore& store) { + if (this == &store) + return *this; + mListener = store.mListener; mInventoryListener = store.mInventoryListener; mMagicEffects = store.mMagicEffects; From 874348fb4681d4608d403e984ed9363972a19f4f Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 19:19:38 +0400 Subject: [PATCH 13/16] Remove redundant code --- apps/openmw/mwmechanics/aiwander.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index 68bcddf228..8e718061e2 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -99,7 +99,6 @@ namespace MWMechanics { AiPackage::Options options; options.mUseVariableSpeed = true; - options.mRepeat = false; return options; } From 50e4600b160174024654a8d4fe8f82b0bb1cc99b Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 20:00:51 +0400 Subject: [PATCH 14/16] Reduce code duplication --- apps/opencs/view/world/util.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp index ba9f408474..58d3d49e44 100644 --- a/apps/opencs/view/world/util.cpp +++ b/apps/opencs/view/world/util.cpp @@ -261,16 +261,10 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO return dsb; } + /// \todo implement size limit. QPlainTextEdit does not support a size limit. case CSMWorld::ColumnBase::Display_LongString: - { - QPlainTextEdit *edit = new QPlainTextEdit(parent); - edit->setUndoRedoEnabled (false); - return edit; - } - case CSMWorld::ColumnBase::Display_LongString256: { - /// \todo implement size limit. QPlainTextEdit does not support a size limit. QPlainTextEdit *edit = new QPlainTextEdit(parent); edit->setUndoRedoEnabled (false); return edit; From 1930f8f37d45c246186d996fc9edc30c74d5fab3 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 20:03:12 +0400 Subject: [PATCH 15/16] Fix copy-paste error --- apps/opencs/model/world/refidadapterimp.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/refidadapterimp.hpp b/apps/opencs/model/world/refidadapterimp.hpp index a73f76af9d..0a29afcad7 100644 --- a/apps/opencs/model/world/refidadapterimp.hpp +++ b/apps/opencs/model/world/refidadapterimp.hpp @@ -1858,18 +1858,18 @@ namespace CSMWorld break; // always save case 16: if (content.mType == ESM::AI_Travel) - content.mTravel.mZ = value.toFloat(); + content.mTravel.mX = value.toFloat(); else if (content.mType == ESM::AI_Follow || content.mType == ESM::AI_Escort) - content.mTarget.mZ = value.toFloat(); + content.mTarget.mX = value.toFloat(); else return; // return without saving break; // always save case 17: if (content.mType == ESM::AI_Travel) - content.mTravel.mZ = value.toFloat(); + content.mTravel.mY = value.toFloat(); else if (content.mType == ESM::AI_Follow || content.mType == ESM::AI_Escort) - content.mTarget.mZ = value.toFloat(); + content.mTarget.mY = value.toFloat(); else return; // return without saving From ad101de733b383c4f708079c31abe42fedc840ec Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Jan 2021 22:58:54 +0400 Subject: [PATCH 16/16] Merge declaration and initialization --- apps/opencs/view/render/terraintexturemode.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index 09d6b135a1..f4a3f461c9 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -427,10 +427,8 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe { if (i_cell == cellX && j_cell == cellY && abs(i-xHitInCell) < r && abs(j-yHitInCell) < r) { - int distanceX(0); - int distanceY(0); - distanceX = abs(i-xHitInCell); - distanceY = abs(j-yHitInCell); + int distanceX = abs(i-xHitInCell); + int distanceY = abs(j-yHitInCell); float distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2))); float rf = static_cast(mBrushSize) / 2; if (distance < rf) newTerrain[j*landTextureSize+i] = brushInt;