1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/apps/openmw/mwmechanics/spells.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

108 lines
2.9 KiB
C++

#ifndef GAME_MWMECHANICS_SPELLS_H
#define GAME_MWMECHANICS_SPELLS_H
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "../mwworld/timestamp.hpp"
#include "spelllist.hpp"
namespace ESM
{
struct SpellState;
}
namespace MWMechanics
{
class CreatureStats;
class MagicEffects;
/// \brief Spell list
///
/// This class manages known spells as well as abilities, powers and permanent negative effects like
/// diseases. It also keeps track of used powers (which can only be used every 24h).
class Spells
{
std::shared_ptr<SpellList> mSpellList;
std::vector<const ESM::Spell*> mSpells;
// Note: this is the spell that's about to be cast, *not* the spell selected in the GUI (which may be different)
ESM::RefId mSelectedSpell;
std::vector<std::pair<const ESM::Spell*, MWWorld::TimeStamp>> mUsedPowers;
bool hasSpellType(const ESM::Spell::SpellType type) const;
using SpellFilter = bool (*)(const ESM::Spell*);
void purge(const SpellFilter& filter);
void addSpell(const ESM::Spell* spell);
void removeSpell(const ESM::Spell* spell);
void removeAllSpells();
friend class SpellList;
public:
Spells();
Spells(const Spells&);
Spells(Spells&& spells);
~Spells();
static bool hasCorprusEffect(const ESM::Spell* spell);
bool canUsePower(const ESM::Spell* spell) const;
void usePower(const ESM::Spell* spell);
void purgeCommonDisease();
void purgeBlightDisease();
void purgeCorprusDisease();
void purgeCurses();
std::vector<const ESM::Spell*>::const_iterator begin() const;
std::vector<const ESM::Spell*>::const_iterator end() const;
bool hasSpell(const ESM::RefId& spell) const;
bool hasSpell(const ESM::Spell* spell) const;
void add(const ESM::RefId& spell);
///< Adding a spell that is already listed in *this is a no-op.
void add(const ESM::Spell* spell);
///< Adding a spell that is already listed in *this is a no-op.
void remove(const ESM::RefId& spell);
///< If the spell to be removed is the selected spell, the selected spell will be changed to
/// no spell (empty string).
void clear(bool modifyBase = false);
///< Remove all spells of al types.
void setSelectedSpell(const ESM::RefId& spellId);
///< This function does not verify, if the spell is available.
const ESM::RefId& getSelectedSpell() const;
///< May return an empty string.
bool hasCommonDisease() const;
bool hasBlightDisease() const;
void readState(const ESM::SpellState& state, CreatureStats* creatureStats);
void writeState(ESM::SpellState& state) const;
bool setSpells(const ESM::RefId& id);
void addAllToInstance(const std::vector<ESM::RefId>& spells);
};
}
#endif