1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 08:09:39 +00:00

Issue #479: Added additional magnitude parameter to known spells

This commit is contained in:
Marc Zinnschlag 2013-01-12 13:10:20 +01:00
parent ecdd89a4f3
commit f4ee8e2642
7 changed files with 29 additions and 29 deletions

View file

@ -440,7 +440,7 @@ namespace MWGui
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
{ {
spellList.push_back(*it); spellList.push_back (it->first);
} }
const MWWorld::ESMStore &esmStore = const MWWorld::ESMStore &esmStore =

View file

@ -98,19 +98,19 @@ namespace MWGui
MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells(); MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells();
MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells(); MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells();
for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter) for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter)
{ {
const ESM::Spell* spell = const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first);
if (spell->mData.mType!=ESM::Spell::ST_Spell) if (spell->mData.mType!=ESM::Spell::ST_Spell)
continue; // don't try to sell diseases, curses or powers continue; // don't try to sell diseases, curses or powers
if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end()) if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end())
continue; // we have that spell already continue; // we have that spell already
addSpell (*iter); addSpell (iter->first);
} }
updateLabels(); updateLabels();

View file

@ -436,7 +436,7 @@ namespace MWGui
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
{ {
const ESM::Spell* spell = const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*it); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (it->first);
// only normal spells count // only normal spells count
if (spell->mData.mType != ESM::Spell::ST_Spell) if (spell->mData.mType != ESM::Spell::ST_Spell)

View file

@ -139,7 +139,7 @@ namespace MWGui
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
{ {
spellList.push_back(*it); spellList.push_back (it->first);
} }
const MWWorld::ESMStore &esmStore = const MWWorld::ESMStore &esmStore =

View file

@ -29,13 +29,13 @@ namespace MWMechanics
void Spells::add (const std::string& spellId) void Spells::add (const std::string& spellId)
{ {
if (std::find (mSpells.begin(), mSpells.end(), spellId)==mSpells.end()) if (mSpells.find (spellId)==mSpells.end())
mSpells.push_back (spellId); mSpells.insert (std::make_pair (spellId, -1));
} }
void Spells::remove (const std::string& spellId) void Spells::remove (const std::string& spellId)
{ {
TContainer::iterator iter = std::find (mSpells.begin(), mSpells.end(), spellId); TContainer::iterator iter = mSpells.find (spellId);
if (iter!=mSpells.end()) if (iter!=mSpells.end())
mSpells.erase (iter); mSpells.erase (iter);
@ -51,7 +51,7 @@ namespace MWMechanics
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
{ {
const ESM::Spell *spell = const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first);
if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight || if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight ||
spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse) spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse)
@ -75,18 +75,18 @@ namespace MWMechanics
{ {
return mSelectedSpell; return mSelectedSpell;
} }
bool Spells::hasCommonDisease() const bool Spells::hasCommonDisease() const
{ {
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
{ {
const ESM::Spell *spell = const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first);
if (spell->mData.mFlags & ESM::Spell::ST_Disease) if (spell->mData.mFlags & ESM::Spell::ST_Disease)
return true; return true;
} }
return false; return false;
} }
@ -95,12 +95,12 @@ namespace MWMechanics
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
{ {
const ESM::Spell *spell = const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first);
if (spell->mData.mFlags & ESM::Spell::ST_Blight) if (spell->mData.mFlags & ESM::Spell::ST_Blight)
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_SPELLS_H #ifndef GAME_MWMECHANICS_SPELLS_H
#define GAME_MWMECHANICS_SPELLS_H #define GAME_MWMECHANICS_SPELLS_H
#include <vector> #include <map>
#include <string> #include <string>
namespace ESM namespace ESM
@ -21,12 +21,12 @@ namespace MWMechanics
{ {
public: public:
typedef std::vector<std::string> TContainer; typedef std::map<std::string, float> TContainer; // ID, magnitude
typedef TContainer::const_iterator TIterator; typedef TContainer::const_iterator TIterator;
private: private:
std::vector<std::string> mSpells; TContainer mSpells;
std::string mSelectedSpell; std::string mSelectedSpell;
void addSpell (const ESM::Spell *, MagicEffects& effects) const; void addSpell (const ESM::Spell *, MagicEffects& effects) const;
@ -55,10 +55,10 @@ namespace MWMechanics
const std::string getSelectedSpell() const; const std::string getSelectedSpell() const;
///< May return an empty string. ///< May return an empty string.
bool hasCommonDisease() const; bool hasCommonDisease() const;
bool hasBlightDisease() const; bool hasBlightDisease() const;
}; };
} }

View file

@ -485,7 +485,7 @@ namespace MWScript
for (MWMechanics::Spells::TIterator iter ( for (MWMechanics::Spells::TIterator iter (
MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().begin()); MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().begin());
iter!=MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().end(); ++iter) iter!=MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().end(); ++iter)
if (*iter==id) if (iter->first==id)
{ {
value = 1; value = 1;
break; break;
@ -1188,7 +1188,7 @@ namespace MWScript
extensions.registerFunction ("getpccrimelevel", 'f', "", opcodeGetPCCrimeLevel); extensions.registerFunction ("getpccrimelevel", 'f', "", opcodeGetPCCrimeLevel);
extensions.registerInstruction ("setpccrimelevel", "f", opcodeSetPCCrimeLevel); extensions.registerInstruction ("setpccrimelevel", "f", opcodeSetPCCrimeLevel);
extensions.registerInstruction ("modpccrimelevel", "f", opcodeModPCCrimeLevel); extensions.registerInstruction ("modpccrimelevel", "f", opcodeModPCCrimeLevel);
extensions.registerInstruction ("addspell", "c", opcodeAddSpell, opcodeAddSpellExplicit); extensions.registerInstruction ("addspell", "c", opcodeAddSpell, opcodeAddSpellExplicit);
extensions.registerInstruction ("removespell", "c", opcodeRemoveSpell, extensions.registerInstruction ("removespell", "c", opcodeRemoveSpell,
opcodeRemoveSpellExplicit); opcodeRemoveSpellExplicit);
@ -1286,7 +1286,7 @@ namespace MWScript
interpreter.installSegment5 (opcodeGetPCCrimeLevel, new OpGetPCCrimeLevel); interpreter.installSegment5 (opcodeGetPCCrimeLevel, new OpGetPCCrimeLevel);
interpreter.installSegment5 (opcodeSetPCCrimeLevel, new OpSetPCCrimeLevel); interpreter.installSegment5 (opcodeSetPCCrimeLevel, new OpSetPCCrimeLevel);
interpreter.installSegment5 (opcodeModPCCrimeLevel, new OpModPCCrimeLevel); interpreter.installSegment5 (opcodeModPCCrimeLevel, new OpModPCCrimeLevel);
interpreter.installSegment5 (opcodeAddSpell, new OpAddSpell<ImplicitRef>); interpreter.installSegment5 (opcodeAddSpell, new OpAddSpell<ImplicitRef>);
interpreter.installSegment5 (opcodeAddSpellExplicit, new OpAddSpell<ExplicitRef>); interpreter.installSegment5 (opcodeAddSpellExplicit, new OpAddSpell<ExplicitRef>);
interpreter.installSegment5 (opcodeRemoveSpell, new OpRemoveSpell<ImplicitRef>); interpreter.installSegment5 (opcodeRemoveSpell, new OpRemoveSpell<ImplicitRef>);