1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/apps/openmw/mwmechanics/spelllist.hpp
fteppe 125b21de20 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-12-27 19:15:54 +01:00

66 lines
2.0 KiB
C++

#ifndef GAME_MWMECHANICS_SPELLLIST_H
#define GAME_MWMECHANICS_SPELLLIST_H
#include <functional>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <components/esm3/loadspel.hpp>
namespace ESM
{
struct SpellState;
}
namespace MWMechanics
{
class Spells;
/// Multiple instances of the same actor share the same spell list in Morrowind.
/// The most obvious result of this is that adding a spell or ability to one instance adds it to all instances.
/// @note The original game will only update visual effects associated with any added abilities for the originally
/// targeted actor,
/// changing cells applies the update to all actors.
/// Aside from sharing the same active spell list, changes made to this list are also written to the actor's base
/// record. Interestingly, it is not just scripted changes that are persisted to the base record. Curing one
/// instance's disease will cure all instances.
/// @note The original game is inconsistent in persisting this example;
/// saving and loading the game might reapply the cured disease depending on which instance was cured.
class SpellList
{
ESM::RefId mId;
const int mType;
std::vector<Spells*> mListeners;
bool withBaseRecord(const std::function<bool(std::vector<ESM::RefId>&)>& function);
public:
SpellList(const ESM::RefId& id, int type);
/// Get spell from ID, throws exception if not found
static const ESM::Spell* getSpell(const ESM::RefId& id);
void add(const ESM::Spell* spell);
///< Adding a spell that is already listed in *this is a no-op.
void remove(const ESM::Spell* spell);
void removeAll(const std::vector<ESM::RefId>& spells);
void clear();
///< Remove all spells of all types.
void addListener(Spells* spells);
void removeListener(Spells* spells);
void updateListener(Spells* before, Spells* after);
const std::vector<ESM::RefId> getSpells() const;
};
}
#endif