mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 05:10:26 +00:00
Merge branch 'more_coverity' into 'master'
More Coverity fixes See merge request OpenMW/openmw!3391
This commit is contained in:
commit
b79c40c11c
8 changed files with 33 additions and 14 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <MyGUI_TextIterator.h>
|
#include <MyGUI_TextIterator.h>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <components/misc/constants.hpp>
|
#include <components/misc/constants.hpp>
|
||||||
|
@ -93,8 +94,10 @@ namespace
|
||||||
int level = creatureStats.getLevel();
|
int level = creatureStats.getLevel();
|
||||||
for (const ESM::Attribute& attribute : attributes)
|
for (const ESM::Attribute& attribute : attributes)
|
||||||
{
|
{
|
||||||
const ESM::Race::MaleFemale& value
|
auto index = ESM::Attribute::refIdToIndex(attribute.mId);
|
||||||
= race->mData.mAttributeValues[static_cast<size_t>(ESM::Attribute::refIdToIndex(attribute.mId))];
|
assert(index >= 0);
|
||||||
|
|
||||||
|
const ESM::Race::MaleFemale& value = race->mData.mAttributeValues[static_cast<size_t>(index)];
|
||||||
creatureStats.setAttribute(attribute.mId, male ? value.mMale : value.mFemale);
|
creatureStats.setAttribute(attribute.mId, male ? value.mMale : value.mFemale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,9 @@ namespace MWMechanics
|
||||||
std::string EffectKey::toString() const
|
std::string EffectKey::toString() const
|
||||||
{
|
{
|
||||||
const auto& store = MWBase::Environment::get().getESMStore();
|
const auto& store = MWBase::Environment::get().getESMStore();
|
||||||
const ESM::MagicEffect* magicEffect = store->get<ESM::MagicEffect>().search(mId);
|
const ESM::MagicEffect* magicEffect = store->get<ESM::MagicEffect>().find(mId);
|
||||||
return getMagicEffectString(
|
return getMagicEffectString(
|
||||||
*magicEffect, store->get<ESM::Attribute>().search(mArg), store->get<ESM::Skill>().search(mArg));
|
*magicEffect, store->get<ESM::Attribute>().find(mArg), store->get<ESM::Skill>().find(mArg));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const EffectKey& left, const EffectKey& right)
|
bool operator<(const EffectKey& left, const EffectKey& right)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "mechanicsmanagerimp.hpp"
|
#include "mechanicsmanagerimp.hpp"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include <osg/Stats>
|
#include <osg/Stats>
|
||||||
|
|
||||||
#include <components/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
@ -150,9 +152,10 @@ namespace MWMechanics
|
||||||
|
|
||||||
for (const ESM::Attribute& attribute : esmStore.get<ESM::Attribute>())
|
for (const ESM::Attribute& attribute : esmStore.get<ESM::Attribute>())
|
||||||
{
|
{
|
||||||
const ESM::Race::MaleFemale& value
|
auto index = ESM::Attribute::refIdToIndex(attribute.mId);
|
||||||
= race->mData.mAttributeValues[static_cast<size_t>(ESM::Attribute::refIdToIndex(attribute.mId))];
|
assert(index >= 0);
|
||||||
|
|
||||||
|
const ESM::Race::MaleFemale& value = race->mData.mAttributeValues[static_cast<size_t>(index)];
|
||||||
creatureStats.setAttribute(attribute.mId, male ? value.mMale : value.mFemale);
|
creatureStats.setAttribute(attribute.mId, male ? value.mMale : value.mFemale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -488,7 +488,12 @@ void MWMechanics::NpcStats::writeState(ESM::NpcStats& state) const
|
||||||
|
|
||||||
state.mSkillIncrease.fill(0);
|
state.mSkillIncrease.fill(0);
|
||||||
for (const auto& [key, value] : mSkillIncreases)
|
for (const auto& [key, value] : mSkillIncreases)
|
||||||
state.mSkillIncrease[static_cast<size_t>(ESM::Attribute::refIdToIndex(key))] = value;
|
{
|
||||||
|
// TODO extend format
|
||||||
|
auto index = ESM::Attribute::refIdToIndex(key);
|
||||||
|
assert(index >= 0);
|
||||||
|
state.mSkillIncrease[static_cast<size_t>(index)] = value;
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < state.mSpecIncreases.size(); ++i)
|
for (size_t i = 0; i < state.mSpecIncreases.size(); ++i)
|
||||||
state.mSpecIncreases[i] = mSpecIncreases[i];
|
state.mSpecIncreases[i] = mSpecIncreases[i];
|
||||||
|
|
|
@ -556,7 +556,7 @@ namespace MWWorld
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellStore::CellStore(MWWorld::Cell cell, const MWWorld::ESMStore& esmStore, ESM::ReadersCache& readers)
|
CellStore::CellStore(MWWorld::Cell&& cell, const MWWorld::ESMStore& esmStore, ESM::ReadersCache& readers)
|
||||||
: mStore(esmStore)
|
: mStore(esmStore)
|
||||||
, mReaders(readers)
|
, mReaders(readers)
|
||||||
, mCellVariant(std::move(cell))
|
, mCellVariant(std::move(cell))
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param readerList The readers to use for loading of the cell on-demand.
|
/// @param readerList The readers to use for loading of the cell on-demand.
|
||||||
CellStore(MWWorld::Cell cell, const MWWorld::ESMStore& store, ESM::ReadersCache& readers);
|
CellStore(MWWorld::Cell&& cell, const MWWorld::ESMStore& store, ESM::ReadersCache& readers);
|
||||||
|
|
||||||
CellStore(const CellStore&) = delete;
|
CellStore(const CellStore&) = delete;
|
||||||
|
|
||||||
|
|
|
@ -159,9 +159,16 @@ MWWorld::ContainerStore::ContainerStore()
|
||||||
|
|
||||||
MWWorld::ContainerStore::~ContainerStore()
|
MWWorld::ContainerStore::~ContainerStore()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel();
|
MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel();
|
||||||
for (MWWorld::ContainerStoreIterator iter(begin()); iter != end(); ++iter)
|
for (MWWorld::ContainerStoreIterator iter(begin()); iter != end(); ++iter)
|
||||||
worldModel->deregisterPtr(*iter);
|
worldModel->deregisterPtr(*iter);
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
Log(Debug::Error) << "Failed to deregister container store: " << e.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cbegin(int mask) const
|
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cbegin(int mask) const
|
||||||
|
|
|
@ -1017,11 +1017,12 @@ namespace MWWorld
|
||||||
void Store<ESM::GameSetting>::setUp()
|
void Store<ESM::GameSetting>::setUp()
|
||||||
{
|
{
|
||||||
auto addSetting = [&](const std::string& key, ESM::Variant value) {
|
auto addSetting = [&](const std::string& key, ESM::Variant value) {
|
||||||
|
auto id = ESM::RefId::stringRefId(key);
|
||||||
ESM::GameSetting setting;
|
ESM::GameSetting setting;
|
||||||
setting.blank();
|
setting.blank();
|
||||||
setting.mId = ESM::RefId::stringRefId(key);
|
setting.mId = id;
|
||||||
setting.mValue = std::move(value);
|
setting.mValue = std::move(value);
|
||||||
auto [iter, inserted] = mStatic.insert_or_assign(setting.mId, std::move(setting));
|
auto [iter, inserted] = mStatic.insert_or_assign(id, std::move(setting));
|
||||||
if (inserted)
|
if (inserted)
|
||||||
mShared.push_back(&iter->second);
|
mShared.push_back(&iter->second);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue