1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 03:35:27 +00:00

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

318 lines
9.9 KiB
C++
Raw Normal View History

2012-04-11 18:29:36 +02:00
#include "spells.hpp"
#include <components/debug/debuglog.hpp>
#include <components/esm3/loadspel.hpp>
#include <components/esm3/spellstate.hpp>
2012-04-11 18:29:36 +02:00
#include <components/esm3/loadmgef.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
2012-04-11 18:29:36 +02:00
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "actorutil.hpp"
#include "creaturestats.hpp"
#include "stat.hpp"
2012-04-11 18:29:36 +02:00
namespace MWMechanics
{
Spells::Spells() {}
2021-03-14 19:32:03 +01:00
Spells::Spells(const Spells& spells)
: mSpellList(spells.mSpellList)
, mSpells(spells.mSpells)
, mSelectedSpell(spells.mSelectedSpell)
, mUsedPowers(spells.mUsedPowers)
2021-03-14 19:32:03 +01:00
{
if (mSpellList)
mSpellList->addListener(this);
}
Spells::Spells(Spells&& spells)
: mSpellList(std::move(spells.mSpellList))
, mSpells(std::move(spells.mSpells))
, mSelectedSpell(std::move(spells.mSelectedSpell))
, mUsedPowers(std::move(spells.mUsedPowers))
{
if (mSpellList)
mSpellList->updateListener(&spells, this);
}
std::vector<const ESM::Spell*>::const_iterator Spells::begin() const
2012-04-11 18:29:36 +02:00
{
2012-04-11 19:40:42 +02:00
return mSpells.begin();
2012-04-11 18:29:36 +02:00
}
std::vector<const ESM::Spell*>::const_iterator Spells::end() const
2012-04-11 18:29:36 +02:00
{
2012-04-11 19:40:42 +02:00
return mSpells.end();
2012-04-11 18:29:36 +02:00
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
bool Spells::hasSpell(const ESM::RefId& spell) const
{
return hasSpell(SpellList::getSpell(spell));
}
bool Spells::hasSpell(const ESM::Spell* spell) const
{
return std::find(mSpells.begin(), mSpells.end(), spell) != mSpells.end();
}
void Spells::add(const ESM::Spell* spell)
{
mSpellList->add(spell);
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
void Spells::add(const ESM::RefId& spellId)
{
add(SpellList::getSpell(spellId));
}
void Spells::addSpell(const ESM::Spell* spell)
2012-04-11 18:29:36 +02:00
{
if (!hasSpell(spell))
mSpells.emplace_back(spell);
2012-04-11 18:29:36 +02:00
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
void Spells::remove(const ESM::RefId& spellId)
{
const auto spell = SpellList::getSpell(spellId);
removeSpell(spell);
mSpellList->remove(spell);
if (spellId == mSelectedSpell)
mSelectedSpell = ESM::RefId();
}
void Spells::removeSpell(const ESM::Spell* spell)
2012-04-11 18:29:36 +02:00
{
const auto it = std::find(mSpells.begin(), mSpells.end(), spell);
if (it != mSpells.end())
mSpells.erase(it);
2012-04-11 18:29:36 +02:00
}
void Spells::removeAllSpells()
2012-04-11 18:29:36 +02:00
{
2012-04-11 19:40:42 +02:00
mSpells.clear();
2012-04-11 18:29:36 +02:00
}
void Spells::clear(bool modifyBase)
{
removeAllSpells();
if (modifyBase)
mSpellList->clear();
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
void Spells::setSelectedSpell(const ESM::RefId& spellId)
{
mSelectedSpell = spellId;
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
const ESM::RefId& Spells::getSelectedSpell() const
{
return mSelectedSpell;
}
bool Spells::hasSpellType(const ESM::Spell::SpellType type) const
2012-11-09 18:16:29 +01:00
{
auto it = std::find_if(std::begin(mSpells), std::end(mSpells),
[=](const ESM::Spell* spell) { return spell->mData.mType == type; });
return it != std::end(mSpells);
2012-11-09 18:16:29 +01:00
}
bool Spells::hasCommonDisease() const
2012-11-09 18:16:29 +01:00
{
return hasSpellType(ESM::Spell::ST_Disease);
}
bool Spells::hasBlightDisease() const
{
return hasSpellType(ESM::Spell::ST_Blight);
2012-11-09 18:16:29 +01:00
}
void Spells::purge(const SpellFilter& filter)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
std::vector<ESM::RefId> purged;
for (auto iter = mSpells.begin(); iter != mSpells.end();)
{
const ESM::Spell* spell = *iter;
if (filter(spell))
{
2021-08-31 19:59:55 +02:00
iter = mSpells.erase(iter);
purged.push_back(spell->mId);
}
else
++iter;
}
if (!purged.empty())
mSpellList->removeAll(purged);
}
void Spells::purgeCommonDisease()
{
purge([](auto spell) { return spell->mData.mType == ESM::Spell::ST_Disease; });
}
void Spells::purgeBlightDisease()
{
purge([](auto spell) { return spell->mData.mType == ESM::Spell::ST_Blight && !hasCorprusEffect(spell); });
}
void Spells::purgeCorprusDisease()
{
purge(&hasCorprusEffect);
}
void Spells::purgeCurses()
{
purge([](auto spell) { return spell->mData.mType == ESM::Spell::ST_Curse; });
}
bool Spells::hasCorprusEffect(const ESM::Spell* spell)
{
for (const auto& effectIt : spell->mEffects.mList)
{
if (effectIt.mEffectID == ESM::MagicEffect::Corprus)
{
return true;
}
}
return false;
}
bool Spells::canUsePower(const ESM::Spell* spell) const
2014-05-12 21:04:02 +02:00
{
const auto it = std::find_if(
std::begin(mUsedPowers), std::end(mUsedPowers), [&](auto& pair) { return pair.first == spell; });
return it == mUsedPowers.end() || it->second + 24 <= MWBase::Environment::get().getWorld()->getTimeStamp();
2014-05-12 21:04:02 +02:00
}
void Spells::usePower(const ESM::Spell* spell)
2014-05-12 21:04:02 +02:00
{
// Updates or inserts a new entry with the current timestamp.
const auto it = std::find_if(
std::begin(mUsedPowers), std::end(mUsedPowers), [&](auto& pair) { return pair.first == spell; });
const auto timestamp = MWBase::Environment::get().getWorld()->getTimeStamp();
if (it == mUsedPowers.end())
mUsedPowers.emplace_back(spell, timestamp);
else
it->second = timestamp;
2014-05-12 21:04:02 +02:00
}
void Spells::readState(const ESM::SpellState& state, CreatureStats* creatureStats)
2014-05-12 21:04:02 +02:00
{
const auto& baseSpells = mSpellList->getSpells();
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
for (const ESM::RefId& id : state.mSpells)
2014-05-12 21:04:02 +02:00
{
// Discard spells that are no longer available due to changed content files
2023-04-20 21:07:53 +02:00
const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(id);
if (spell)
2014-05-12 21:04:02 +02:00
{
2021-08-31 19:59:55 +02:00
addSpell(spell);
if (id == state.mSelectedSpell)
mSelectedSpell = id;
2014-05-12 21:04:02 +02:00
}
}
// Add spells from the base record
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
for (const ESM::RefId& id : baseSpells)
{
2023-04-20 21:07:53 +02:00
const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(id);
if (spell)
addSpell(spell);
}
2014-05-12 21:04:02 +02:00
for (auto it = state.mUsedPowers.begin(); it != state.mUsedPowers.end(); ++it)
{
2023-04-20 21:07:53 +02:00
const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(it->first);
if (!spell)
continue;
mUsedPowers.emplace_back(spell, MWWorld::TimeStamp(it->second));
}
// Permanent effects are used only to keep the custom magnitude of corprus spells effects (after cure too), and
// only in old saves. Convert data to the new approach.
for (auto it = state.mPermanentSpellEffects.begin(); it != state.mPermanentSpellEffects.end(); ++it)
{
2023-04-20 21:07:53 +02:00
const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(it->first);
if (!spell)
continue;
// Import data only for player, other actors should not suffer from corprus worsening.
MWWorld::Ptr player = getPlayer();
if (creatureStats->getActorId() != player.getClass().getCreatureStats(player).getActorId())
return;
2023-05-09 20:07:08 -04:00
// Note: if target actor has the Restore attribute effects, stats will be restored.
for (std::vector<ESM::SpellState::PermanentSpellEffectInfo>::const_iterator effectIt = it->second.begin();
effectIt != it->second.end(); ++effectIt)
{
// Applied corprus effects are already in loaded stats modifiers
if (effectIt->mId == ESM::MagicEffect::FortifyAttribute)
{
AttributeValue attr = creatureStats->getAttribute(effectIt->mArg);
attr.setModifier(attr.getModifier() - effectIt->mMagnitude);
attr.damage(-effectIt->mMagnitude);
creatureStats->setAttribute(effectIt->mArg, attr);
}
else if (effectIt->mId == ESM::MagicEffect::DrainAttribute)
{
AttributeValue attr = creatureStats->getAttribute(effectIt->mArg);
attr.setModifier(attr.getModifier() + effectIt->mMagnitude);
attr.damage(effectIt->mMagnitude);
creatureStats->setAttribute(effectIt->mArg, attr);
}
}
}
2014-05-12 21:04:02 +02:00
}
void Spells::writeState(ESM::SpellState& state) const
{
const auto& baseSpells = mSpellList->getSpells();
for (const auto spell : mSpells)
{
2020-08-07 16:36:59 +02:00
// Don't save spells and powers stored in the base record
if ((spell->mData.mType != ESM::Spell::ST_Spell && spell->mData.mType != ESM::Spell::ST_Power)
|| std::find(baseSpells.begin(), baseSpells.end(), spell->mId) == baseSpells.end())
{
state.mSpells.emplace_back(spell->mId);
}
}
2014-05-12 21:04:02 +02:00
state.mSelectedSpell = mSelectedSpell;
for (const auto& it : mUsedPowers)
state.mUsedPowers[it.first->mId] = it.second.toEsm();
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
bool Spells::setSpells(const ESM::RefId& actorId)
{
bool result;
2023-04-20 21:07:53 +02:00
std::tie(mSpellList, result) = MWBase::Environment::get().getESMStore()->getSpellList(actorId);
mSpellList->addListener(this);
addAllToInstance(mSpellList->getSpells());
return result;
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
void Spells::addAllToInstance(const std::vector<ESM::RefId>& spells)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
for (const ESM::RefId& id : spells)
{
2023-04-20 21:07:53 +02:00
const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(id);
if (spell)
addSpell(spell);
else
2023-04-03 11:23:47 +04:00
Log(Debug::Warning) << "Warning: ignoring nonexistent spell " << id;
}
}
Spells::~Spells()
{
if (mSpellList)
mSpellList->removeListener(this);
2014-05-12 21:04:02 +02:00
}
2012-04-11 18:29:36 +02:00
}