mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 04:36:44 +00:00
Merge pull request #2172 from akortunov/pvs_fix
Fix some issues, found by PVS-Studio
This commit is contained in:
commit
212f097b3c
12 changed files with 40 additions and 37 deletions
|
@ -84,6 +84,8 @@ namespace ESSImport
|
|||
mGlobalMapState.mBounds.mMaxX = 0;
|
||||
mGlobalMapState.mBounds.mMinY = 0;
|
||||
mGlobalMapState.mBounds.mMaxY = 0;
|
||||
|
||||
mPlayerBase.blank();
|
||||
}
|
||||
|
||||
int generateActorId()
|
||||
|
|
|
@ -258,6 +258,9 @@ OMW::Engine::~Engine()
|
|||
|
||||
mViewer = nullptr;
|
||||
|
||||
delete mEncoder;
|
||||
mEncoder = nullptr;
|
||||
|
||||
if (mWindow)
|
||||
{
|
||||
SDL_DestroyWindow(mWindow);
|
||||
|
@ -657,8 +660,7 @@ void OMW::Engine::go()
|
|||
settingspath = loadSettings (settings);
|
||||
|
||||
// Create encoder
|
||||
ToUTF8::Utf8Encoder encoder (mEncoding);
|
||||
mEncoder = &encoder;
|
||||
mEncoder = new ToUTF8::Utf8Encoder(mEncoding);
|
||||
|
||||
// Setup viewer
|
||||
mViewer = new osgViewer::Viewer;
|
||||
|
|
|
@ -780,7 +780,7 @@ namespace MWClass
|
|||
MWWorld::Ptr armor = ((armorslot != inv.end()) ? *armorslot : MWWorld::Ptr());
|
||||
if(!armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name())
|
||||
{
|
||||
if (attacker.isEmpty() || (!attacker.isEmpty() && !(object.isEmpty() && !attacker.getClass().isNpc()))) // Unarmed creature attacks don't affect armor condition
|
||||
if (!object.isEmpty() || attacker.isEmpty() || attacker.getClass().isNpc()) // Unarmed creature attacks don't affect armor condition
|
||||
{
|
||||
int armorhealth = armor.getClass().getItemHealth(armor);
|
||||
armorhealth -= std::min(damageDiff, armorhealth);
|
||||
|
|
|
@ -262,7 +262,7 @@ namespace MWGui
|
|||
|
||||
if (mode == GM_Console)
|
||||
MWBase::Environment::get().getWindowManager()->setConsoleSelectedObject(object);
|
||||
else if ((mode == GM_Container) || (mode == GM_Inventory))
|
||||
else //if ((mode == GM_Container) || (mode == GM_Inventory))
|
||||
{
|
||||
// pick up object
|
||||
if (!object.isEmpty())
|
||||
|
|
|
@ -631,7 +631,7 @@ namespace
|
|||
|
||||
if (page+2 < book->pageCount())
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page", true);
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page");
|
||||
|
||||
page += 2;
|
||||
updateShowingPages ();
|
||||
|
@ -649,7 +649,7 @@ namespace
|
|||
|
||||
if(page >= 2)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page", true);
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page");
|
||||
|
||||
page -= 2;
|
||||
updateShowingPages ();
|
||||
|
|
|
@ -327,11 +327,9 @@ namespace MWGui
|
|||
|
||||
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2);
|
||||
|
||||
SkillList::const_iterator end = skills.end();
|
||||
for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
|
||||
for (const int& skillId : skills)
|
||||
{
|
||||
int skillId = *it;
|
||||
if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes
|
||||
if (skillId < 0 || skillId >= ESM::Skill::Length) // Skip unknown skill indexes
|
||||
continue;
|
||||
assert(skillId >= 0 && skillId < ESM::Skill::Length);
|
||||
const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId];
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace MWGui
|
|||
else if (skill < ESM::Skill::Length)
|
||||
setSkillId(static_cast<ESM::Skill::SkillEnum>(skill));
|
||||
else
|
||||
throw new std::runtime_error("Skill number out of range");
|
||||
throw std::runtime_error("Skill number out of range");
|
||||
}
|
||||
|
||||
void MWSkill::setSkillValue(const SkillValue& value)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "steering.hpp"
|
||||
|
||||
MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::ConstPtr& doorPtr)
|
||||
: AiPackage(), mDuration(1), mDoorPtr(doorPtr), mAdjAngle(0)
|
||||
: AiPackage(), mDuration(1), mDoorPtr(doorPtr), mLastPos(ESM::Position()), mAdjAngle(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -328,32 +328,32 @@ void ActorAnimation::updateQuiver()
|
|||
suitableAmmo = ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Arrow;
|
||||
}
|
||||
|
||||
if (ammoNode && suitableAmmo)
|
||||
if (!suitableAmmo)
|
||||
return;
|
||||
|
||||
// We should not show more ammo than equipped and more than quiver mesh has
|
||||
ammoCount = std::min(ammoCount, ammoNode->getNumChildren());
|
||||
|
||||
// Remove existing ammo nodes
|
||||
for (unsigned int i=0; i<ammoNode->getNumChildren(); ++i)
|
||||
{
|
||||
// We should not show more ammo than equipped and more than quiver mesh has
|
||||
ammoCount = std::min(ammoCount, ammoNode->getNumChildren());
|
||||
osg::ref_ptr<osg::Group> arrowNode = ammoNode->getChild(i)->asGroup();
|
||||
if (!arrowNode->getNumChildren())
|
||||
continue;
|
||||
|
||||
// Remove existing ammo nodes
|
||||
for (unsigned int i=0; i<ammoNode->getNumChildren(); ++i)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> arrowNode = ammoNode->getChild(i)->asGroup();
|
||||
if (!arrowNode->getNumChildren())
|
||||
continue;
|
||||
osg::ref_ptr<osg::Node> arrowChildNode = arrowNode->getChild(0);
|
||||
arrowNode->removeChild(arrowChildNode);
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Node> arrowChildNode = arrowNode->getChild(0);
|
||||
arrowNode->removeChild(arrowChildNode);
|
||||
}
|
||||
|
||||
// Add new ones
|
||||
osg::Vec4f glowColor = getEnchantmentColor(*ammo);
|
||||
std::string model = ammo->getClass().getModel(*ammo);
|
||||
for (unsigned int i=0; i<ammoCount; ++i)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> arrowNode = ammoNode->getChild(i)->asGroup();
|
||||
osg::ref_ptr<osg::Node> arrow = mResourceSystem->getSceneManager()->getInstance(model, arrowNode);
|
||||
if (!ammo->getClass().getEnchantment(*ammo).empty())
|
||||
addGlow(arrow, glowColor);
|
||||
}
|
||||
// Add new ones
|
||||
osg::Vec4f glowColor = getEnchantmentColor(*ammo);
|
||||
std::string model = ammo->getClass().getModel(*ammo);
|
||||
for (unsigned int i=0; i<ammoCount; ++i)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> arrowNode = ammoNode->getChild(i)->asGroup();
|
||||
osg::ref_ptr<osg::Node> arrow = mResourceSystem->getSceneManager()->getInstance(model, arrowNode);
|
||||
if (!ammo->getClass().getEnchantment(*ammo).empty())
|
||||
addGlow(arrow, glowColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace MWWorld
|
|||
Player::Player (const ESM::NPC *player)
|
||||
: mCellStore(0),
|
||||
mLastKnownExteriorPosition(0,0,0),
|
||||
mMarkedPosition(ESM::Position()),
|
||||
mMarkedCell(nullptr),
|
||||
mAutoMove(false),
|
||||
mForwardBackward(0),
|
||||
|
|
|
@ -876,7 +876,7 @@ QStringList Wizard::UnshieldWorker::findFiles(const QString &fileName, const QSt
|
|||
result.append(info.absoluteFilePath());
|
||||
break;
|
||||
case Qt::MatchEndsWith:
|
||||
if (info.fileName().endsWith(fileName), Qt::CaseInsensitive)
|
||||
if (info.fileName().endsWith(fileName, Qt::CaseInsensitive))
|
||||
result.append(info.absoluteFilePath());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -368,7 +368,7 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> v
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new std::runtime_error("Tried to package non-motion event!");
|
||||
throw std::runtime_error("Tried to package non-motion event!");
|
||||
}
|
||||
|
||||
return pack_evt;
|
||||
|
|
Loading…
Reference in a new issue