mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 17:45:34 +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 <cassert>
|
||||
#include <memory>
|
||||
|
||||
#include <components/misc/constants.hpp>
|
||||
|
@ -93,8 +94,10 @@ namespace
|
|||
int level = creatureStats.getLevel();
|
||||
for (const ESM::Attribute& attribute : attributes)
|
||||
{
|
||||
const ESM::Race::MaleFemale& value
|
||||
= race->mData.mAttributeValues[static_cast<size_t>(ESM::Attribute::refIdToIndex(attribute.mId))];
|
||||
auto index = 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ namespace MWMechanics
|
|||
std::string EffectKey::toString() const
|
||||
{
|
||||
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(
|
||||
*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)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "mechanicsmanagerimp.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <osg/Stats>
|
||||
|
||||
#include <components/misc/rng.hpp>
|
||||
|
@ -150,9 +152,10 @@ namespace MWMechanics
|
|||
|
||||
for (const ESM::Attribute& attribute : esmStore.get<ESM::Attribute>())
|
||||
{
|
||||
const ESM::Race::MaleFemale& value
|
||||
= race->mData.mAttributeValues[static_cast<size_t>(ESM::Attribute::refIdToIndex(attribute.mId))];
|
||||
auto index = 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -488,7 +488,12 @@ void MWMechanics::NpcStats::writeState(ESM::NpcStats& state) const
|
|||
|
||||
state.mSkillIncrease.fill(0);
|
||||
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)
|
||||
state.mSpecIncreases[i] = mSpecIncreases[i];
|
||||
|
|
|
@ -556,7 +556,7 @@ namespace MWWorld
|
|||
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)
|
||||
, mReaders(readers)
|
||||
, mCellVariant(std::move(cell))
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace MWWorld
|
|||
}
|
||||
|
||||
/// @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;
|
||||
|
||||
|
|
|
@ -159,9 +159,16 @@ MWWorld::ContainerStore::ContainerStore()
|
|||
|
||||
MWWorld::ContainerStore::~ContainerStore()
|
||||
{
|
||||
MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel();
|
||||
for (MWWorld::ContainerStoreIterator iter(begin()); iter != end(); ++iter)
|
||||
worldModel->deregisterPtr(*iter);
|
||||
try
|
||||
{
|
||||
MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel();
|
||||
for (MWWorld::ContainerStoreIterator iter(begin()); iter != end(); ++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
|
||||
|
|
|
@ -1017,11 +1017,12 @@ namespace MWWorld
|
|||
void Store<ESM::GameSetting>::setUp()
|
||||
{
|
||||
auto addSetting = [&](const std::string& key, ESM::Variant value) {
|
||||
auto id = ESM::RefId::stringRefId(key);
|
||||
ESM::GameSetting setting;
|
||||
setting.blank();
|
||||
setting.mId = ESM::RefId::stringRefId(key);
|
||||
setting.mId = id;
|
||||
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)
|
||||
mShared.push_back(&iter->second);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue