1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-23 22:11:38 +00:00

Address review comments.

This commit is contained in:
cc9cii 2015-06-26 07:48:48 +10:00
parent 67b6c86a59
commit 273ff1cccb
8 changed files with 16 additions and 22 deletions

View file

@ -130,7 +130,7 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
} }
CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager) CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager)
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells), mReferenceables(self()), : mEncoder (encoding), mPathgrids (mCells), mReferenceables(self()), mRefs (mCells),
mResourcesManager (resourcesManager), mReader (0), mDialogue (0), mReaderIndex(0) mResourcesManager (resourcesManager), mReader (0), mDialogue (0), mReaderIndex(0)
{ {
int index = 0; int index = 0;
@ -1526,7 +1526,7 @@ CSMWorld::NpcStats* CSMWorld::Data::npcAutoCalculate(const ESM::NPC& npc) const
if (autoCalc) if (autoCalc)
level = npc.mNpdt12.mLevel; level = npc.mNpdt12.mLevel;
CSMWorld::NpcStats *stats = new CSMWorld::NpcStats(); std::auto_ptr<CSMWorld::NpcStats> stats (new CSMWorld::NpcStats());
CSStore store(mGmsts, mSkills, mMagicEffects, mSpells); CSStore store(mGmsts, mSkills, mMagicEffects, mSpells);
@ -1547,7 +1547,7 @@ CSMWorld::NpcStats* CSMWorld::Data::npcAutoCalculate(const ESM::NPC& npc) const
for (std::vector<std::string>::const_iterator it = npc.mSpells.mList.begin(); for (std::vector<std::string>::const_iterator it = npc.mSpells.mList.begin();
it != npc.mSpells.mList.end(); ++it) it != npc.mSpells.mList.end(); ++it)
{ {
stats->addSpells(*it); stats->addSpell(*it);
} }
} }
@ -1605,8 +1605,11 @@ CSMWorld::NpcStats* CSMWorld::Data::npcAutoCalculate(const ESM::NPC& npc) const
} }
} }
emit cacheNpcStats (npc.mId, stats); if (stats.get() == 0)
return stats; return 0;
emit cacheNpcStats (npc.mId, stats.release());
return stats.release();
} }
void CSMWorld::Data::cacheNpcStatsEvent (const std::string& id, CSMWorld::NpcStats *stats) void CSMWorld::Data::cacheNpcStatsEvent (const std::string& id, CSMWorld::NpcStats *stats)

View file

@ -45,7 +45,7 @@ namespace CSMWorld
mAttr[index] = value; mAttr[index] = value;
} }
void NpcStats::addSpells(std::string id) void NpcStats::addSpell(const std::string& id)
{ {
struct SpellInfo info; struct SpellInfo info;
info.mName = id; info.mName = id;

View file

@ -43,7 +43,7 @@ namespace CSMWorld
virtual void setAttribute(int index, unsigned char value); virtual void setAttribute(int index, unsigned char value);
virtual void addSpells(std::string id); virtual void addSpell(const std::string& id);
void addPowers(const std::string& id, int type); void addPowers(const std::string& id, int type);

View file

@ -74,7 +74,7 @@ namespace
virtual void setAttribute(int index, unsigned char value) { mNpcStats.setAttribute(index, value); } virtual void setAttribute(int index, unsigned char value) { mNpcStats.setAttribute(index, value); }
virtual void addSpells(std::string id) { mNpcStats.getSpells().add(id); } virtual void addSpell(const std::string& id) { mNpcStats.getSpells().add(id); }
virtual unsigned char getBaseSkill(int index) const { return mNpcStats.getSkill(index).getBase(); } virtual unsigned char getBaseSkill(int index) const { return mNpcStats.getSkill(index).getBase(); }

View file

@ -11,7 +11,6 @@
#include "autocalcspell.hpp" #include "autocalcspell.hpp"
// Most of the code in this file was moved from apps/openmw/mwclass/npc.cpp
namespace namespace
{ {
int is_even(double d) int is_even(double d)
@ -117,7 +116,7 @@ namespace AutoCalc
int index = class_->mData.mSkills[i2][i]; int index = class_->mData.mSkills[i2][i];
if (index >= 0 && index < ESM::Skill::Length) if (index >= 0 && index < ESM::Skill::Length)
{ {
stats.setBaseSkill (index, stats.getBaseSkill(index) + bonus); stats.setBaseSkill (index, bonus);
} }
} }
} }
@ -168,7 +167,7 @@ namespace AutoCalc
} }
} }
unsigned short autoCalculateHealth(int level, const ESM::Class *class_, StatsBase& stats) unsigned short autoCalculateHealth(int level, const ESM::Class *class_, const StatsBase& stats)
{ {
// initial health // initial health
int strength = stats.getBaseAttribute(ESM::Attribute::Strength); int strength = stats.getBaseAttribute(ESM::Attribute::Strength);
@ -200,7 +199,7 @@ namespace AutoCalc
std::vector<std::string> spells = autoCalcNpcSpells(skills, attributes, race, store); std::vector<std::string> spells = autoCalcNpcSpells(skills, attributes, race, store);
for (std::vector<std::string>::iterator it = spells.begin(); it != spells.end(); ++it) for (std::vector<std::string>::iterator it = spells.begin(); it != spells.end(); ++it)
stats.addSpells(*it); stats.addSpell(*it);
} }
StatsBase::StatsBase() {} StatsBase::StatsBase() {}

View file

@ -27,7 +27,7 @@ namespace AutoCalc
virtual void setAttribute(int index, unsigned char value) = 0; virtual void setAttribute(int index, unsigned char value) = 0;
virtual void addSpells(std::string id) = 0; virtual void addSpell(const std::string& id) = 0;
virtual unsigned char getBaseSkill(int index) const = 0; virtual unsigned char getBaseSkill(int index) const = 0;
@ -40,7 +40,7 @@ namespace AutoCalc
void autoCalcSkillsImpl (const ESM::NPC* npc, void autoCalcSkillsImpl (const ESM::NPC* npc,
const ESM::Race *race, const ESM::Class *class_, int level, StatsBase& stats, StoreCommon *store); const ESM::Race *race, const ESM::Class *class_, int level, StatsBase& stats, StoreCommon *store);
unsigned short autoCalculateHealth(int level, const ESM::Class *class_, StatsBase& stats); unsigned short autoCalculateHealth(int level, const ESM::Class *class_, const StatsBase& stats);
void autoCalculateSpells(const ESM::Race *race, StatsBase& stats, StoreCommon *store); void autoCalculateSpells(const ESM::Race *race, StatsBase& stats, StoreCommon *store);
} }

View file

@ -13,7 +13,6 @@
#include "autocalc.hpp" #include "autocalc.hpp"
// Most of the code in this file was moved from apps/openmw/mwmechanics/autocalcspell.cpp
namespace AutoCalc namespace AutoCalc
{ {

View file

@ -4,15 +4,8 @@
#include <vector> #include <vector>
#include <string> #include <string>
namespace Loading
{
class Listener;
}
namespace ESM namespace ESM
{ {
class ESMWriter;
class ESMReader;
struct Spell; struct Spell;
struct Skill; struct Skill;
struct MagicEffect; struct MagicEffect;