Merge branch 'master' into no_submodule

This commit is contained in:
scrawl 2012-11-13 05:13:26 +01:00
commit 32bf40e407
173 changed files with 4492 additions and 2901 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@ Makefile
makefile makefile
data data
*.kdev4 *.kdev4
CMakeLists.txt.user

View file

@ -1213,7 +1213,7 @@ void Record<ESM::Region>::print()
template<> template<>
void Record<ESM::Script>::print() void Record<ESM::Script>::print()
{ {
std::cout << " Name: " << mData.mData.mName.toString() << std::endl; std::cout << " Name: " << mData.mId << std::endl;
std::cout << " Num Shorts: " << mData.mData.mNumShorts << std::endl; std::cout << " Num Shorts: " << mData.mData.mNumShorts << std::endl;
std::cout << " Num Longs: " << mData.mData.mNumLongs << std::endl; std::cout << " Num Longs: " << mData.mData.mNumLongs << std::endl;

View file

@ -53,6 +53,7 @@ add_openmw_dir (mwworld
containerstore actiontalk actiontake manualref player cellfunctors containerstore actiontalk actiontake manualref player cellfunctors
cells localscripts customdata weather inventorystore ptr actionopen actionread cells localscripts customdata weather inventorystore ptr actionopen actionread
actionequip timestamp actionalchemy cellstore actionapply actioneat actionequip timestamp actionalchemy cellstore actionapply actioneat
esmstore store recordcmp
) )
add_openmw_dir (mwclass add_openmw_dir (mwclass

View file

@ -101,7 +101,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration()); MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration());
// update world // update world
MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame, MWBase::Environment::get().getWindowManager()->isGuiMode());
// update GUI // update GUI
Ogre::RenderWindow* window = mOgre->getWindow(); Ogre::RenderWindow* window = mOgre->getWindow();

View file

@ -40,6 +40,10 @@ namespace MWBase
virtual void keywordSelected (const std::string& keyword) = 0; virtual void keywordSelected (const std::string& keyword) = 0;
virtual void goodbyeSelected() = 0; virtual void goodbyeSelected() = 0;
virtual void questionAnswered (const std::string& answer) = 0; virtual void questionAnswered (const std::string& answer) = 0;
virtual void persuade (int type) = 0;
virtual int getTemporaryDispositionChange () const = 0;
virtual void applyTemporaryDispositionChange (int delta) = 0;
}; };
} }

View file

@ -62,7 +62,7 @@ namespace MWBase
virtual void setPlayerName (const std::string& name) = 0; virtual void setPlayerName (const std::string& name) = 0;
///< Set player name. ///< Set player name.
virtual void setPlayerRace (const std::string& id, bool male) = 0; virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair) = 0;
///< Set player race. ///< Set player race.
virtual void setPlayerBirthsign (const std::string& id) = 0; virtual void setPlayerBirthsign (const std::string& id) = 0;
@ -76,9 +76,28 @@ namespace MWBase
virtual void restoreDynamicStats() = 0; virtual void restoreDynamicStats() = 0;
///< If the player is sleeping, this should be called every hour. ///< If the player is sleeping, this should be called every hour.
virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0;
///< This is used by every service to determine the price of objects given the trading skills of the player and NPC.
virtual int getDerivedDisposition(const MWWorld::Ptr& ptr) = 0;
///< Calculate the diposition of an NPC toward the player.
virtual int countDeaths (const std::string& id) const = 0; virtual int countDeaths (const std::string& id) const = 0;
///< Return the number of deaths for actors with the given ID. ///< Return the number of deaths for actors with the given ID.
enum PersuasionType
{
PT_Admire,
PT_Intimidate,
PT_Taunt,
PT_Bribe10,
PT_Bribe100,
PT_Bribe1000
};
virtual void getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type,
float currentTemporaryDispositionDelta, bool& success, float& tempChange, float& permChange) = 0;
///< Perform a persuasion action on NPC
}; };
} }

View file

@ -29,11 +29,7 @@ namespace ESM
struct Class; struct Class;
struct Potion; struct Potion;
struct Spell; struct Spell;
} struct NPC;
namespace ESMS
{
struct ESMStore;
} }
namespace MWRender namespace MWRender
@ -48,6 +44,7 @@ namespace MWWorld
class LocalScripts; class LocalScripts;
class Ptr; class Ptr;
class TimeStamp; class TimeStamp;
class ESMStore;
} }
namespace MWBase namespace MWBase
@ -104,7 +101,7 @@ namespace MWBase
virtual MWWorld::Player& getPlayer() = 0; virtual MWWorld::Player& getPlayer() = 0;
virtual const ESMS::ESMStore& getStore() const = 0; virtual const MWWorld::ESMStore& getStore() const = 0;
virtual ESM::ESMReader& getEsmReader() = 0; virtual ESM::ESMReader& getEsmReader() = 0;
@ -234,24 +231,28 @@ namespace MWBase
///< Toggle a render mode. ///< Toggle a render mode.
///< \return Resulting mode ///< \return Resulting mode
virtual std::pair<std::string, const ESM::Potion *> createRecord (const ESM::Potion& record) virtual const ESM::Potion *createRecord (const ESM::Potion& record)
= 0; = 0;
///< Create a new recrod (of type potion) in the ESM store. ///< Create a new recrod (of type potion) in the ESM store.
/// \return ID, pointer to created record /// \return pointer to created record
virtual std::pair<std::string, const ESM::Spell *> createRecord (const ESM::Spell& record) virtual const ESM::Spell *createRecord (const ESM::Spell& record)
= 0; = 0;
///< Create a new recrod (of type spell) in the ESM store. ///< Create a new recrod (of type spell) in the ESM store.
/// \return ID, pointer to created record /// \return pointer to created record
virtual std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record) virtual const ESM::Class *createRecord (const ESM::Class& record)
= 0; = 0;
///< Create a new recrod (of type class) in the ESM store. ///< Create a new recrod (of type class) in the ESM store.
/// \return ID, pointer to created record /// \return pointer to created record
virtual const ESM::Cell *createRecord (const ESM::Cell& record) = 0; virtual const ESM::Cell *createRecord (const ESM::Cell& record) = 0;
///< Create a new recrod (of type cell) in the ESM store. ///< Create a new recrod (of type cell) in the ESM store.
/// \return ID, pointer to created record /// \return pointer to created record
virtual const ESM::NPC *createRecord(const ESM::NPC &record) = 0;
///< Create a new recrod (of type npc) in the ESM store.
/// \return pointer to created record
virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName,
int mode, int number = 1) = 0; int mode, int number = 1) = 0;
@ -265,7 +266,7 @@ namespace MWBase
///< Skip the animation for the given MW-reference for one frame. Calls to this function for ///< Skip the animation for the given MW-reference for one frame. Calls to this function for
/// references that are currently not in the rendered scene should be ignored. /// references that are currently not in the rendered scene should be ignored.
virtual void update (float duration) = 0; virtual void update (float duration, bool paused) = 0;
virtual bool placeObject(const MWWorld::Ptr& object, float cursorX, float cursorY) = 0; virtual bool placeObject(const MWWorld::Ptr& object, float cursorX, float cursorY) = 0;
///< place an object into the gameworld at the specified cursor position ///< place an object into the gameworld at the specified cursor position

View file

@ -30,18 +30,17 @@ namespace MWClass
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Activator::getModel(const MWWorld::Ptr &ptr) const std::string Activator::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Activator> *ref = MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>(); ptr.get<ESM::Activator>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -53,7 +52,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Activator> *ref = MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>(); ptr.get<ESM::Activator>();
return ref->base->mName; return ref->mBase->mName;
} }
std::string Activator::getScript (const MWWorld::Ptr& ptr) const std::string Activator::getScript (const MWWorld::Ptr& ptr) const
@ -61,7 +60,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Activator> *ref = MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>(); ptr.get<ESM::Activator>();
return ref->base->mScript; return ref->mBase->mScript;
} }
void Activator::registerSelf() void Activator::registerSelf()
@ -76,7 +75,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Activator> *ref = MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>(); ptr.get<ESM::Activator>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -85,22 +84,22 @@ namespace MWClass
ptr.get<ESM::Activator>(); ptr.get<ESM::Activator>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
std::string text; std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
info.text = text; info.text = text;
return info; return info;
} }
MWWorld::Ptr MWWorld::Ptr
Activator::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const Activator::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{ {
MWWorld::LiveCellRef<ESM::Activator> *ref = MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>(); ptr.get<ESM::Activator>();
return MWWorld::Ptr(&cell.activators.insert(*ref), &cell); return MWWorld::Ptr(&cell.mActivators.insert(*ref), &cell);
} }
} }

View file

@ -33,18 +33,17 @@ namespace MWClass
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Apparatus::getModel(const MWWorld::Ptr &ptr) const std::string Apparatus::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -56,7 +55,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
@ -75,7 +74,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
return ref->base->mScript; return ref->mBase->mScript;
} }
int Apparatus::getValue (const MWWorld::Ptr& ptr) const int Apparatus::getValue (const MWWorld::Ptr& ptr) const
@ -83,7 +82,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Apparatus::registerSelf() void Apparatus::registerSelf()
@ -108,7 +107,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const
@ -116,7 +115,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -125,17 +124,17 @@ namespace MWClass
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -154,6 +153,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
return MWWorld::Ptr(&cell.appas.insert(*ref), &cell); return MWWorld::Ptr(&cell.mAppas.insert(*ref), &cell);
} }
} }

View file

@ -36,18 +36,17 @@ namespace MWClass
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Armor::getModel(const MWWorld::Ptr &ptr) const std::string Armor::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -59,7 +58,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
@ -82,7 +81,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return ref->base->mData.mHealth; return ref->mBase->mData.mHealth;
} }
std::string Armor::getScript (const MWWorld::Ptr& ptr) const std::string Armor::getScript (const MWWorld::Ptr& ptr) const
@ -90,7 +89,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return ref->base->mScript; return ref->mBase->mScript;
} }
std::pair<std::vector<int>, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const std::pair<std::vector<int>, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const
@ -118,7 +117,7 @@ namespace MWClass
}; };
for (int i=0; i<size; ++i) for (int i=0; i<size; ++i)
if (sMapping[i][0]==ref->base->mData.mType) if (sMapping[i][0]==ref->mBase->mData.mType)
{ {
slots.push_back (int (sMapping[i][1])); slots.push_back (int (sMapping[i][1]));
break; break;
@ -134,7 +133,7 @@ namespace MWClass
std::string typeGmst; std::string typeGmst;
switch (ref->base->mData.mType) switch (ref->mBase->mData.mType)
{ {
case ESM::Armor::Helmet: typeGmst = "iHelmWeight"; break; case ESM::Armor::Helmet: typeGmst = "iHelmWeight"; break;
case ESM::Armor::Cuirass: typeGmst = "iCuirassWeight"; break; case ESM::Armor::Cuirass: typeGmst = "iCuirassWeight"; break;
@ -152,14 +151,17 @@ namespace MWClass
if (typeGmst.empty()) if (typeGmst.empty())
return -1; return -1;
float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->getInt(); const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->getFloat()>= float iWeight = gmst.find (typeGmst)->getInt();
ref->base->mData.mWeight)
if (iWeight * gmst.find ("fLightMaxMod")->getFloat()>=
ref->mBase->mData.mWeight)
return ESM::Skill::LightArmor; return ESM::Skill::LightArmor;
if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->getFloat()>= if (iWeight * gmst.find ("fMedMaxMod")->getFloat()>=
ref->base->mData.mWeight) ref->mBase->mData.mWeight)
return ESM::Skill::MediumArmor; return ESM::Skill::MediumArmor;
return ESM::Skill::HeavyArmor; return ESM::Skill::HeavyArmor;
@ -170,7 +172,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Armor::registerSelf() void Armor::registerSelf()
@ -207,7 +209,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const
@ -215,7 +217,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -224,8 +226,8 @@ namespace MWClass
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
@ -239,20 +241,20 @@ namespace MWClass
else else
typeText = "#{sHeavy}"; typeText = "#{sHeavy}";
text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->base->mData.mArmor); text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->mBase->mData.mArmor);
/// \todo store the current armor health somewhere /// \todo store the current armor health somewhere
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->mData.mHealth); text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight) + " (" + typeText + ")"; text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (" + typeText + ")";
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.enchant = ref->base->mEnchant; info.enchant = ref->mBase->mEnchant;
info.text = text; info.text = text;
@ -264,7 +266,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return ref->base->mEnchant; return ref->mBase->mEnchant;
} }
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const
@ -282,6 +284,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return MWWorld::Ptr(&cell.armors.insert(*ref), &cell); return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell);
} }
} }

View file

@ -32,18 +32,17 @@ namespace MWClass
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Book::getModel(const MWWorld::Ptr &ptr) const std::string Book::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -55,7 +54,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr,
@ -70,7 +69,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
return ref->base->mScript; return ref->mBase->mScript;
} }
int Book::getValue (const MWWorld::Ptr& ptr) const int Book::getValue (const MWWorld::Ptr& ptr) const
@ -78,7 +77,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Book::registerSelf() void Book::registerSelf()
@ -103,7 +102,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Book::hasToolTip (const MWWorld::Ptr& ptr) const bool Book::hasToolTip (const MWWorld::Ptr& ptr) const
@ -111,7 +110,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -120,20 +119,20 @@ namespace MWClass
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.enchant = ref->base->mEnchant; info.enchant = ref->mBase->mEnchant;
info.text = text; info.text = text;
@ -145,7 +144,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
return ref->base->mEnchant; return ref->mBase->mEnchant;
} }
boost::shared_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr) const boost::shared_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr) const
@ -159,6 +158,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
return MWWorld::Ptr(&cell.books.insert(*ref), &cell); return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell);
} }
} }

View file

@ -34,18 +34,17 @@ namespace MWClass
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Clothing::getModel(const MWWorld::Ptr &ptr) const std::string Clothing::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -57,7 +56,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
@ -75,7 +74,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
return ref->base->mScript; return ref->mBase->mScript;
} }
std::pair<std::vector<int>, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const std::pair<std::vector<int>, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const
@ -85,7 +84,7 @@ namespace MWClass
std::vector<int> slots; std::vector<int> slots;
if (ref->base->mData.mType==ESM::Clothing::Ring) if (ref->mBase->mData.mType==ESM::Clothing::Ring)
{ {
slots.push_back (int (MWWorld::InventoryStore::Slot_LeftRing)); slots.push_back (int (MWWorld::InventoryStore::Slot_LeftRing));
slots.push_back (int (MWWorld::InventoryStore::Slot_RightRing)); slots.push_back (int (MWWorld::InventoryStore::Slot_RightRing));
@ -108,7 +107,7 @@ namespace MWClass
}; };
for (int i=0; i<size; ++i) for (int i=0; i<size; ++i)
if (sMapping[i][0]==ref->base->mData.mType) if (sMapping[i][0]==ref->mBase->mData.mType)
{ {
slots.push_back (int (sMapping[i][1])); slots.push_back (int (sMapping[i][1]));
break; break;
@ -123,7 +122,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
if (ref->base->mData.mType==ESM::Clothing::Shoes) if (ref->mBase->mData.mType==ESM::Clothing::Shoes)
return ESM::Skill::Unarmored; return ESM::Skill::Unarmored;
return -1; return -1;
@ -134,7 +133,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Clothing::registerSelf() void Clothing::registerSelf()
@ -149,7 +148,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
if (ref->base->mData.mType == 8) if (ref->mBase->mData.mType == 8)
{ {
return std::string("Item Ring Up"); return std::string("Item Ring Up");
} }
@ -161,7 +160,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
if (ref->base->mData.mType == 8) if (ref->mBase->mData.mType == 8)
{ {
return std::string("Item Ring Down"); return std::string("Item Ring Down");
} }
@ -173,7 +172,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const
@ -181,7 +180,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -190,20 +189,20 @@ namespace MWClass
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.enchant = ref->base->mEnchant; info.enchant = ref->mBase->mEnchant;
info.text = text; info.text = text;
@ -215,7 +214,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
return ref->base->mEnchant; return ref->mBase->mEnchant;
} }
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const
@ -233,6 +232,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
return MWWorld::Ptr(&cell.clothes.insert(*ref), &cell); return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell);
} }
} }

View file

@ -65,18 +65,17 @@ namespace MWClass
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Container::getModel(const MWWorld::Ptr &ptr) const std::string Container::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Container> *ref = MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>(); ptr.get<ESM::Container>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -149,7 +148,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Container> *ref = MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>(); ptr.get<ESM::Container>();
return ref->base->mName; return ref->mBase->mName;
} }
MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr) MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr)
@ -165,7 +164,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Container> *ref = MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>(); ptr.get<ESM::Container>();
return ref->base->mScript; return ref->mBase->mScript;
} }
void Container::registerSelf() void Container::registerSelf()
@ -180,7 +179,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Container> *ref = MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>(); ptr.get<ESM::Container>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -189,17 +188,17 @@ namespace MWClass
ptr.get<ESM::Container>(); ptr.get<ESM::Container>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName; info.caption = ref->mBase->mName;
std::string text; std::string text;
if (ref->ref.mLockLevel > 0) if (ref->mRef.mLockLevel > 0)
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.mLockLevel); text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
if (ref->ref.mTrap != "") if (ref->mRef.mTrap != "")
text += "\n#{sTrapped}"; text += "\n#{sTrapped}";
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -212,7 +211,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Container> *ref = MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>(); ptr.get<ESM::Container>();
return ref->base->mWeight; return ref->mBase->mWeight;
} }
float Container::getEncumbrance (const MWWorld::Ptr& ptr) const float Container::getEncumbrance (const MWWorld::Ptr& ptr) const
@ -239,6 +238,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Container> *ref = MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>(); ptr.get<ESM::Container>();
return MWWorld::Ptr(&cell.containers.insert(*ref), &cell); return MWWorld::Ptr(&cell.mContainers.insert(*ref), &cell);
} }
} }

View file

@ -48,28 +48,28 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
// creature stats // creature stats
data->mCreatureStats.getAttribute(0).set (ref->base->mData.mStrength); data->mCreatureStats.getAttribute(0).set (ref->mBase->mData.mStrength);
data->mCreatureStats.getAttribute(1).set (ref->base->mData.mIntelligence); data->mCreatureStats.getAttribute(1).set (ref->mBase->mData.mIntelligence);
data->mCreatureStats.getAttribute(2).set (ref->base->mData.mWillpower); data->mCreatureStats.getAttribute(2).set (ref->mBase->mData.mWillpower);
data->mCreatureStats.getAttribute(3).set (ref->base->mData.mAgility); data->mCreatureStats.getAttribute(3).set (ref->mBase->mData.mAgility);
data->mCreatureStats.getAttribute(4).set (ref->base->mData.mSpeed); data->mCreatureStats.getAttribute(4).set (ref->mBase->mData.mSpeed);
data->mCreatureStats.getAttribute(5).set (ref->base->mData.mEndurance); data->mCreatureStats.getAttribute(5).set (ref->mBase->mData.mEndurance);
data->mCreatureStats.getAttribute(6).set (ref->base->mData.mPersonality); data->mCreatureStats.getAttribute(6).set (ref->mBase->mData.mPersonality);
data->mCreatureStats.getAttribute(7).set (ref->base->mData.mLuck); data->mCreatureStats.getAttribute(7).set (ref->mBase->mData.mLuck);
data->mCreatureStats.setHealth (ref->base->mData.mHealth); data->mCreatureStats.setHealth (ref->mBase->mData.mHealth);
data->mCreatureStats.setMagicka (ref->base->mData.mMana); data->mCreatureStats.setMagicka (ref->mBase->mData.mMana);
data->mCreatureStats.setFatigue (ref->base->mData.mFatigue); data->mCreatureStats.setFatigue (ref->mBase->mData.mFatigue);
data->mCreatureStats.setLevel(ref->base->mData.mLevel); data->mCreatureStats.setLevel(ref->mBase->mData.mLevel);
data->mCreatureStats.setHello(ref->base->mAiData.mHello); data->mCreatureStats.setHello(ref->mBase->mAiData.mHello);
data->mCreatureStats.setFight(ref->base->mAiData.mFight); data->mCreatureStats.setFight(ref->mBase->mAiData.mFight);
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee); data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee);
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm); data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm);
// spells // spells
for (std::vector<std::string>::const_iterator iter (ref->base->mSpells.mList.begin()); for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin());
iter!=ref->base->mSpells.mList.end(); ++iter) iter!=ref->mBase->mSpells.mList.end(); ++iter)
data->mCreatureStats.getSpells().add (*iter); data->mCreatureStats.getSpells().add (*iter);
// store // store
@ -82,7 +82,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
return ref->base->mId; return ref->mBase->mId;
} }
void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -94,9 +94,8 @@ namespace MWClass
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()){ if(!model.empty())
physics.insertActorPhysics(ptr, model); physics.addActor(ptr);
}
MWBase::Environment::get().getMechanicsManager()->addActor (ptr); MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
} }
@ -104,9 +103,9 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
assert (ref->base != NULL); assert (ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -118,7 +117,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
return ref->base->mName; return ref->mBase->mName;
} }
MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const
@ -150,7 +149,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
return ref->base->mScript; return ref->mBase->mScript;
} }
bool Creature::isEssential (const MWWorld::Ptr& ptr) const bool Creature::isEssential (const MWWorld::Ptr& ptr) const
@ -158,7 +157,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
return ref->base->mFlags & ESM::Creature::Essential; return ref->mBase->mFlags & ESM::Creature::Essential;
} }
void Creature::registerSelf() void Creature::registerSelf()
@ -181,11 +180,11 @@ namespace MWClass
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName; info.caption = ref->mBase->mName;
std::string text; std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
info.text = text; info.text = text;
return info; return info;
@ -219,6 +218,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
return MWWorld::Ptr(&cell.creatures.insert(*ref), &cell); return MWWorld::Ptr(&cell.mCreatures.insert(*ref), &cell);
} }
} }

View file

@ -35,18 +35,17 @@ namespace MWClass
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Door::getModel(const MWWorld::Ptr &ptr) const std::string Door::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Door> *ref = MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -58,10 +57,10 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref = MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
if (ref->ref.mTeleport && !ref->ref.mDestCell.empty()) // TODO doors that lead to exteriors if (ref->mRef.mTeleport && !ref->mRef.mDestCell.empty()) // TODO doors that lead to exteriors
return ref->ref.mDestCell; return ref->mRef.mDestCell;
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
@ -70,8 +69,8 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref = MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
const std::string &openSound = ref->base->mOpenSound; const std::string &openSound = ref->mBase->mOpenSound;
//const std::string &closeSound = ref->base->closeSound; //const std::string &closeSound = ref->mBase->closeSound;
const std::string lockedSound = "LockedDoor"; const std::string lockedSound = "LockedDoor";
const std::string trapActivationSound = "Disarm Trap Fail"; const std::string trapActivationSound = "Disarm Trap Fail";
@ -119,13 +118,13 @@ namespace MWClass
return action; return action;
} }
if (ref->ref.mTeleport) if (ref->mRef.mTeleport)
{ {
// teleport door // teleport door
/// \todo remove this if clause once ActionTeleport can also support other actors /// \todo remove this if clause once ActionTeleport can also support other actors
if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor)
{ {
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->ref.mDestCell, ref->ref.mDoorDest)); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->mRef.mDestCell, ref->mRef.mDoorDest));
action->setSound(openSound); action->setSound(openSound);
@ -177,7 +176,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref = MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
return ref->base->mScript; return ref->mBase->mScript;
} }
void Door::registerSelf() void Door::registerSelf()
@ -192,7 +191,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref = MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -201,31 +200,32 @@ namespace MWClass
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName; info.caption = ref->mBase->mName;
std::string text; std::string text;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
if (ref->ref.mTeleport) if (ref->mRef.mTeleport)
{ {
std::string dest; std::string dest;
if (ref->ref.mDestCell != "") if (ref->mRef.mDestCell != "")
{ {
// door leads to an interior, use interior name as tooltip // door leads to an interior, use interior name as tooltip
dest = ref->ref.mDestCell; dest = ref->mRef.mDestCell;
} }
else else
{ {
// door leads to exterior, use cell name (if any), otherwise translated region name // door leads to exterior, use cell name (if any), otherwise translated region name
int x,y; int x,y;
MWBase::Environment::get().getWorld()->positionToIndex (ref->ref.mDoorDest.pos[0], ref->ref.mDoorDest.pos[1], x, y); MWBase::Environment::get().getWorld()->positionToIndex (ref->mRef.mDoorDest.pos[0], ref->mRef.mDoorDest.pos[1], x, y);
const ESM::Cell* cell = store.cells.findExt(x,y); const ESM::Cell* cell = store.get<ESM::Cell>().find(x,y);
if (cell->mName != "") if (cell->mName != "")
dest = cell->mName; dest = cell->mName;
else else
{ {
const ESM::Region* region = store.regions.search(cell->mRegion); const ESM::Region* region =
store.get<ESM::Region>().find(cell->mRegion);
dest = region->mName; dest = region->mName;
} }
} }
@ -233,13 +233,13 @@ namespace MWClass
text += "\n"+dest; text += "\n"+dest;
} }
if (ref->ref.mLockLevel > 0) if (ref->mRef.mLockLevel > 0)
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.mLockLevel); text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
if (ref->ref.mTrap != "") if (ref->mRef.mTrap != "")
text += "\n#{sTrapped}"; text += "\n#{sTrapped}";
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
info.text = text; info.text = text;
@ -252,6 +252,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref = MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
return MWWorld::Ptr(&cell.doors.insert(*ref), &cell); return MWWorld::Ptr(&cell.mDoors.insert(*ref), &cell);
} }
} }

View file

@ -25,7 +25,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
return ref->base->mId; return ref->mBase->mId;
} }
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -41,18 +41,17 @@ namespace MWClass
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Ingredient::getModel(const MWWorld::Ptr &ptr) const std::string Ingredient::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -64,7 +63,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
@ -82,7 +81,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
return ref->base->mScript; return ref->mBase->mScript;
} }
int Ingredient::getValue (const MWWorld::Ptr& ptr) const int Ingredient::getValue (const MWWorld::Ptr& ptr) const
@ -90,7 +89,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
@ -125,7 +124,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const
@ -133,7 +132,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -142,28 +141,28 @@ namespace MWClass
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
MWGui::Widgets::SpellEffectList list; MWGui::Widgets::SpellEffectList list;
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
{ {
if (ref->base->mData.mEffectID[i] < 0) if (ref->mBase->mData.mEffectID[i] < 0)
continue; continue;
MWGui::Widgets::SpellEffectParams params; MWGui::Widgets::SpellEffectParams params;
params.mEffectID = ref->base->mData.mEffectID[i]; params.mEffectID = ref->mBase->mData.mEffectID[i];
params.mAttribute = ref->base->mData.mAttributes[i]; params.mAttribute = ref->mBase->mData.mAttributes[i];
params.mSkill = ref->base->mData.mSkills[i]; params.mSkill = ref->mBase->mData.mSkills[i];
list.push_back(params); list.push_back(params);
} }
info.effects = list; info.effects = list;
@ -179,6 +178,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
return MWWorld::Ptr(&cell.ingreds.insert(*ref), &cell); return MWWorld::Ptr(&cell.mIngreds.insert(*ref), &cell);
} }
} }

View file

@ -27,9 +27,9 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
assert (ref->base != NULL); assert (ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
@ -37,11 +37,11 @@ namespace MWClass
if (!model.empty()) if (!model.empty())
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, "meshes\\" + model);
const int color = ref->base->mData.mColor; const int color = ref->mBase->mData.mColor;
const float r = ((color >> 0) & 0xFF) / 255.0f; const float r = ((color >> 0) & 0xFF) / 255.0f;
const float g = ((color >> 8) & 0xFF) / 255.0f; const float g = ((color >> 8) & 0xFF) / 255.0f;
const float b = ((color >> 16) & 0xFF) / 255.0f; const float b = ((color >> 16) & 0xFF) / 255.0f;
const float radius = float (ref->base->mData.mRadius); const float radius = float (ref->mBase->mData.mRadius);
objects.insertLight (ptr, r, g, b, radius); objects.insertLight (ptr, r, g, b, radius);
} }
@ -49,25 +49,24 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
assert (ref->base != NULL); assert (ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, "meshes\\" + model); physics.addObject(ptr);
}
if (!ref->base->mSound.empty()) { if (!ref->mBase->mSound.empty())
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop);
}
} }
std::string Light::getModel(const MWWorld::Ptr &ptr) const std::string Light::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
assert (ref->base != NULL); assert (ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -79,10 +78,10 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
if (ref->base->mModel.empty()) if (ref->mBase->mModel.empty())
return ""; return "";
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr,
@ -91,7 +90,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
if (!(ref->base->mData.mFlags & ESM::Light::Carry)) if (!(ref->mBase->mData.mFlags & ESM::Light::Carry))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr)); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
@ -106,7 +105,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
return ref->base->mScript; return ref->mBase->mScript;
} }
std::pair<std::vector<int>, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const std::pair<std::vector<int>, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const
@ -116,7 +115,7 @@ namespace MWClass
std::vector<int> slots; std::vector<int> slots;
if (ref->base->mData.mFlags & ESM::Light::Carry) if (ref->mBase->mData.mFlags & ESM::Light::Carry)
slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedLeft)); slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedLeft));
return std::make_pair (slots, false); return std::make_pair (slots, false);
@ -127,7 +126,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Light::registerSelf() void Light::registerSelf()
@ -153,7 +152,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Light::hasToolTip (const MWWorld::Ptr& ptr) const bool Light::hasToolTip (const MWWorld::Ptr& ptr) const
@ -161,7 +160,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -170,17 +169,17 @@ namespace MWClass
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -203,6 +202,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
return MWWorld::Ptr(&cell.lights.insert(*ref), &cell); return MWWorld::Ptr(&cell.mLights.insert(*ref), &cell);
} }
} }

View file

@ -34,18 +34,17 @@ namespace MWClass
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Lockpick::getModel(const MWWorld::Ptr &ptr) const std::string Lockpick::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -57,7 +56,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
@ -75,7 +74,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
return ref->base->mScript; return ref->mBase->mScript;
} }
std::pair<std::vector<int>, bool> Lockpick::getEquipmentSlots (const MWWorld::Ptr& ptr) const std::pair<std::vector<int>, bool> Lockpick::getEquipmentSlots (const MWWorld::Ptr& ptr) const
@ -92,7 +91,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Lockpick::registerSelf() void Lockpick::registerSelf()
@ -117,7 +116,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const
@ -125,7 +124,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -134,21 +133,21 @@ namespace MWClass
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
/// \todo store remaining uses somewhere /// \todo store remaining uses somewhere
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -171,6 +170,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
return MWWorld::Ptr(&cell.lockpicks.insert(*ref), &cell); return MWWorld::Ptr(&cell.mLockpicks.insert(*ref), &cell);
} }
} }

View file

@ -37,18 +37,17 @@ namespace MWClass
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Miscellaneous::getModel(const MWWorld::Ptr &ptr) const std::string Miscellaneous::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -60,7 +59,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
@ -78,7 +77,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
return ref->base->mScript; return ref->mBase->mScript;
} }
int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const
@ -86,7 +85,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Miscellaneous::registerSelf() void Miscellaneous::registerSelf()
@ -101,7 +100,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
if (ref->base->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGold")->getString())
{ {
return std::string("Item Gold Up"); return std::string("Item Gold Up");
} }
@ -113,7 +112,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
if (ref->base->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGold")->getString())
{ {
return std::string("Item Gold Down"); return std::string("Item Gold Down");
} }
@ -125,7 +124,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const
@ -133,7 +132,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -143,13 +142,13 @@ namespace MWClass
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
int count = ptr.getRefData().getCount(); int count = ptr.getRefData().getCount();
bool isGold = (ref->base->mName == store.gameSettings.find("sGold")->getString()); bool isGold = (ref->mBase->mName == store.get<ESM::GameSetting>().find("sGold")->getString());
if (isGold && count == 1) if (isGold && count == 1)
count = ref->base->mData.mValue; count = ref->mBase->mData.mValue;
std::string countString; std::string countString;
if (!isGold) if (!isGold)
@ -157,12 +156,12 @@ namespace MWClass
else // gold displays its count also if it's 1. else // gold displays its count also if it's 1.
countString = " (" + boost::lexical_cast<std::string>(count) + ")"; countString = " (" + boost::lexical_cast<std::string>(count) + ")";
info.caption = ref->base->mName + countString; info.caption = ref->mBase->mName + countString;
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
if (ref->ref.mSoul != "") if (ref->mRef.mSoul != "")
{ {
const ESM::Creature *creature = store.creatures.search(ref->ref.mSoul); const ESM::Creature *creature = store.get<ESM::Creature>().find(ref->mRef.mSoul);
info.caption += " (" + creature->mName + ")"; info.caption += " (" + creature->mName + ")";
} }
@ -170,13 +169,13 @@ namespace MWClass
if (!isGold) if (!isGold)
{ {
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
} }
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -189,10 +188,10 @@ namespace MWClass
{ {
MWWorld::Ptr newPtr; MWWorld::Ptr newPtr;
const ESMS::ESMStore &store = const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
if (MWWorld::Class::get(ptr).getName(ptr) == store.gameSettings.find("sGold")->getString()) { if (MWWorld::Class::get(ptr).getName(ptr) == store.get<ESM::GameSetting>().find("sGold")->getString()) {
int goldAmount = ptr.getRefData().getCount(); int goldAmount = ptr.getRefData().getCount();
std::string base = "Gold_001"; std::string base = "Gold_001";
@ -210,11 +209,11 @@ namespace MWClass
MWWorld::ManualRef newRef(store, base); MWWorld::ManualRef newRef(store, base);
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
newRef.getPtr().get<ESM::Miscellaneous>(); newRef.getPtr().get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell); newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell);
} else { } else {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell); newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell);
} }
return newPtr; return newPtr;
} }

View file

@ -62,39 +62,41 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
// NPC stats // NPC stats
if (!ref->base->mFaction.empty()) if (!ref->mBase->mFaction.empty())
{ {
std::string faction = ref->base->mFaction; std::string faction = ref->mBase->mFaction;
boost::algorithm::to_lower(faction); boost::algorithm::to_lower(faction);
if(ref->base->mNpdt52.mGold != -10) if(ref->mBase->mNpdt52.mGold != -10)
{ {
data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->mNpdt52.mRank; data->mNpcStats.getFactionRanks()[faction] = (int)ref->mBase->mNpdt52.mRank;
} }
else else
{ {
data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->mNpdt12.mRank; data->mNpcStats.getFactionRanks()[faction] = (int)ref->mBase->mNpdt12.mRank;
} }
} }
// creature stats // creature stats
if(ref->base->mNpdt52.mGold != -10) if(ref->mBase->mNpdt52.mGold != -10)
{ {
for (int i=0; i<27; ++i) for (int i=0; i<27; ++i)
data->mNpcStats.getSkill (i).setBase (ref->base->mNpdt52.mSkills[i]); data->mNpcStats.getSkill (i).setBase (ref->mBase->mNpdt52.mSkills[i]);
data->mCreatureStats.getAttribute(0).set (ref->base->mNpdt52.mStrength); data->mCreatureStats.getAttribute(0).set (ref->mBase->mNpdt52.mStrength);
data->mCreatureStats.getAttribute(1).set (ref->base->mNpdt52.mIntelligence); data->mCreatureStats.getAttribute(1).set (ref->mBase->mNpdt52.mIntelligence);
data->mCreatureStats.getAttribute(2).set (ref->base->mNpdt52.mWillpower); data->mCreatureStats.getAttribute(2).set (ref->mBase->mNpdt52.mWillpower);
data->mCreatureStats.getAttribute(3).set (ref->base->mNpdt52.mAgility); data->mCreatureStats.getAttribute(3).set (ref->mBase->mNpdt52.mAgility);
data->mCreatureStats.getAttribute(4).set (ref->base->mNpdt52.mSpeed); data->mCreatureStats.getAttribute(4).set (ref->mBase->mNpdt52.mSpeed);
data->mCreatureStats.getAttribute(5).set (ref->base->mNpdt52.mEndurance); data->mCreatureStats.getAttribute(5).set (ref->mBase->mNpdt52.mEndurance);
data->mCreatureStats.getAttribute(6).set (ref->base->mNpdt52.mPersonality); data->mCreatureStats.getAttribute(6).set (ref->mBase->mNpdt52.mPersonality);
data->mCreatureStats.getAttribute(7).set (ref->base->mNpdt52.mLuck); data->mCreatureStats.getAttribute(7).set (ref->mBase->mNpdt52.mLuck);
data->mCreatureStats.setHealth (ref->base->mNpdt52.mHealth); data->mCreatureStats.setHealth (ref->mBase->mNpdt52.mHealth);
data->mCreatureStats.setMagicka (ref->base->mNpdt52.mMana); data->mCreatureStats.setMagicka (ref->mBase->mNpdt52.mMana);
data->mCreatureStats.setFatigue (ref->base->mNpdt52.mFatigue); data->mCreatureStats.setFatigue (ref->mBase->mNpdt52.mFatigue);
data->mCreatureStats.setLevel(ref->base->mNpdt52.mLevel); data->mCreatureStats.setLevel(ref->mBase->mNpdt52.mLevel);
data->mNpcStats.setBaseDisposition(ref->mBase->mNpdt52.mDisposition);
data->mNpcStats.setReputation(ref->mBase->mNpdt52.mReputation);
} }
else else
{ {
@ -108,14 +110,14 @@ namespace MWClass
data->mCreatureStats.setLevel (1); data->mCreatureStats.setLevel (1);
} }
data->mCreatureStats.setHello(ref->base->mAiData.mHello); data->mCreatureStats.setHello(ref->mBase->mAiData.mHello);
data->mCreatureStats.setFight(ref->base->mAiData.mFight); data->mCreatureStats.setFight(ref->mBase->mAiData.mFight);
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee); data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee);
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm); data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm);
// spells // spells
for (std::vector<std::string>::const_iterator iter (ref->base->mSpells.mList.begin()); for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin());
iter!=ref->base->mSpells.mList.end(); ++iter) iter!=ref->mBase->mSpells.mList.end(); ++iter)
data->mCreatureStats.getSpells().add (*iter); data->mCreatureStats.getSpells().add (*iter);
// store // store
@ -128,7 +130,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
return ref->base->mId; return ref->mBase->mId;
} }
void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -138,7 +140,7 @@ namespace MWClass
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
physics.insertActorPhysics(ptr, getModel(ptr)); physics.addActor(ptr);
MWBase::Environment::get().getMechanicsManager()->addActor(ptr); MWBase::Environment::get().getMechanicsManager()->addActor(ptr);
} }
@ -146,9 +148,9 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
std::string headID = ref->base->mHead; std::string headID = ref->mBase->mHead;
int end = headID.find_last_of("head_") - 4; int end = headID.find_last_of("head_") - 4;
std::string bodyRaceID = headID.substr(0, end); std::string bodyRaceID = headID.substr(0, end);
@ -170,7 +172,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
return ref->base->mName; return ref->mBase->mName;
} }
MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const
@ -217,7 +219,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
return ref->base->mScript; return ref->mBase->mScript;
} }
void Npc::setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const void Npc::setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const
@ -325,7 +327,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
return ref->base->mFlags & ESM::NPC::Essential; return ref->mBase->mFlags & ESM::NPC::Essential;
} }
void Npc::registerSelf() void Npc::registerSelf()
@ -347,11 +349,11 @@ namespace MWClass
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName; info.caption = ref->mBase->mName;
std::string text; std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
info.text = text; info.text = text;
return info; return info;
@ -395,8 +397,10 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( const ESM::Class *class_ =
ref->base->mClass); MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find (
ref->mBase->mClass
);
stats.useSkill (skill, *class_, usageType); stats.useSkill (skill, *class_, usageType);
} }
@ -413,6 +417,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
return MWWorld::Ptr(&cell.npcs.insert(*ref), &cell); return MWWorld::Ptr(&cell.mNpcs.insert(*ref), &cell);
} }
} }

View file

@ -34,18 +34,17 @@ namespace MWClass
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Potion::getModel(const MWWorld::Ptr &ptr) const std::string Potion::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -57,7 +56,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
@ -76,7 +75,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
return ref->base->mScript; return ref->mBase->mScript;
} }
int Potion::getValue (const MWWorld::Ptr& ptr) const int Potion::getValue (const MWWorld::Ptr& ptr) const
@ -84,7 +83,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Potion::registerSelf() void Potion::registerSelf()
@ -109,7 +108,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const
@ -117,7 +116,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -126,20 +125,20 @@ namespace MWClass
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->base->mEffects); info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->mBase->mEffects);
info.isPotion = true; info.isPotion = true;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -157,7 +156,7 @@ namespace MWClass
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
boost::shared_ptr<MWWorld::Action> action ( boost::shared_ptr<MWWorld::Action> action (
new MWWorld::ActionApply (actor, ref->base->mId)); new MWWorld::ActionApply (actor, ref->mBase->mId));
action->setSound ("Drink"); action->setSound ("Drink");
@ -170,6 +169,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
return MWWorld::Ptr(&cell.potions.insert(*ref), &cell); return MWWorld::Ptr(&cell.mPotions.insert(*ref), &cell);
} }
} }

View file

@ -34,18 +34,17 @@ namespace MWClass
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Probe::getModel(const MWWorld::Ptr &ptr) const std::string Probe::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -57,7 +56,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const const MWWorld::Ptr& actor) const
@ -74,7 +73,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
return ref->base->mScript; return ref->mBase->mScript;
} }
std::pair<std::vector<int>, bool> Probe::getEquipmentSlots (const MWWorld::Ptr& ptr) const std::pair<std::vector<int>, bool> Probe::getEquipmentSlots (const MWWorld::Ptr& ptr) const
@ -91,7 +90,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Probe::registerSelf() void Probe::registerSelf()
@ -116,7 +115,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const
@ -124,7 +123,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -133,21 +132,21 @@ namespace MWClass
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
/// \todo store remaining uses somewhere /// \todo store remaining uses somewhere
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -170,6 +169,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
return MWWorld::Ptr(&cell.probes.insert(*ref), &cell); return MWWorld::Ptr(&cell.mProbes.insert(*ref), &cell);
} }
} }

View file

@ -32,18 +32,17 @@ namespace MWClass
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Repair::getModel(const MWWorld::Ptr &ptr) const std::string Repair::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -55,7 +54,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
@ -73,7 +72,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
return ref->base->mScript; return ref->mBase->mScript;
} }
int Repair::getValue (const MWWorld::Ptr& ptr) const int Repair::getValue (const MWWorld::Ptr& ptr) const
@ -81,7 +80,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Repair::registerSelf() void Repair::registerSelf()
@ -106,7 +105,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const
@ -114,7 +113,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -123,21 +122,21 @@ namespace MWClass
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
/// \todo store remaining uses somewhere /// \todo store remaining uses somewhere
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -151,6 +150,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
return MWWorld::Ptr(&cell.repairs.insert(*ref), &cell); return MWWorld::Ptr(&cell.mRepairs.insert(*ref), &cell);
} }
} }

View file

@ -24,18 +24,17 @@ namespace MWClass
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Static::getModel(const MWWorld::Ptr &ptr) const std::string Static::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Static> *ref = MWWorld::LiveCellRef<ESM::Static> *ref =
ptr.get<ESM::Static>(); ptr.get<ESM::Static>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -60,6 +59,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Static> *ref = MWWorld::LiveCellRef<ESM::Static> *ref =
ptr.get<ESM::Static>(); ptr.get<ESM::Static>();
return MWWorld::Ptr(&cell.statics.insert(*ref), &cell); return MWWorld::Ptr(&cell.mStatics.insert(*ref), &cell);
} }
} }

View file

@ -34,18 +34,17 @@ namespace MWClass
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) { if(!model.empty())
physics.insertObjectPhysics(ptr, model); physics.addObject(ptr);
}
} }
std::string Weapon::getModel(const MWWorld::Ptr &ptr) const std::string Weapon::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
assert(ref->base != NULL); assert(ref->mBase != NULL);
const std::string &model = ref->base->mModel; const std::string &model = ref->mBase->mModel;
if (!model.empty()) { if (!model.empty()) {
return "meshes\\" + model; return "meshes\\" + model;
} }
@ -57,7 +56,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return ref->base->mName; return ref->mBase->mName;
} }
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
@ -80,7 +79,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return ref->base->mData.mHealth; return ref->mBase->mData.mHealth;
} }
std::string Weapon::getScript (const MWWorld::Ptr& ptr) const std::string Weapon::getScript (const MWWorld::Ptr& ptr) const
@ -88,7 +87,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return ref->base->mScript; return ref->mBase->mScript;
} }
std::pair<std::vector<int>, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const std::pair<std::vector<int>, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const
@ -99,12 +98,12 @@ namespace MWClass
std::vector<int> slots; std::vector<int> slots;
bool stack = false; bool stack = false;
if (ref->base->mData.mType==ESM::Weapon::Arrow || ref->base->mData.mType==ESM::Weapon::Bolt) if (ref->mBase->mData.mType==ESM::Weapon::Arrow || ref->mBase->mData.mType==ESM::Weapon::Bolt)
{ {
slots.push_back (int (MWWorld::InventoryStore::Slot_Ammunition)); slots.push_back (int (MWWorld::InventoryStore::Slot_Ammunition));
stack = true; stack = true;
} }
else if (ref->base->mData.mType==ESM::Weapon::MarksmanThrown) else if (ref->mBase->mData.mType==ESM::Weapon::MarksmanThrown)
{ {
slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedRight)); slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedRight));
stack = true; stack = true;
@ -139,7 +138,7 @@ namespace MWClass
}; };
for (int i=0; i<size; ++i) for (int i=0; i<size; ++i)
if (sMapping[i][0]==ref->base->mData.mType) if (sMapping[i][0]==ref->mBase->mData.mType)
return sMapping[i][1]; return sMapping[i][1];
return -1; return -1;
@ -150,7 +149,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return ref->base->mData.mValue; return ref->mBase->mData.mValue;
} }
void Weapon::registerSelf() void Weapon::registerSelf()
@ -165,7 +164,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
int type = ref->base->mData.mType; int type = ref->mBase->mData.mType;
// Ammo // Ammo
if (type == 12 || type == 13) if (type == 12 || type == 13)
{ {
@ -211,7 +210,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
int type = ref->base->mData.mType; int type = ref->mBase->mData.mType;
// Ammo // Ammo
if (type == 12 || type == 13) if (type == 12 || type == 13)
{ {
@ -257,7 +256,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return ref->base->mIcon; return ref->mBase->mIcon;
} }
bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const
@ -265,7 +264,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return (ref->base->mName != ""); return (ref->mBase->mName != "");
} }
MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const
@ -274,15 +273,15 @@ namespace MWClass
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->base->mIcon; info.icon = ref->mBase->mIcon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text; std::string text;
// weapon type & damage. arrows / bolts don't have his info. // weapon type & damage. arrows / bolts don't have his info.
if (ref->base->mData.mType < 12) if (ref->mBase->mData.mType < 12)
{ {
text += "\n#{sType} "; text += "\n#{sType} ";
@ -300,49 +299,49 @@ namespace MWClass
mapping[ESM::Weapon::MarksmanCrossbow] = std::make_pair("sSkillMarksman", ""); mapping[ESM::Weapon::MarksmanCrossbow] = std::make_pair("sSkillMarksman", "");
mapping[ESM::Weapon::MarksmanThrown] = std::make_pair("sSkillMarksman", ""); mapping[ESM::Weapon::MarksmanThrown] = std::make_pair("sSkillMarksman", "");
std::string type = mapping[ref->base->mData.mType].first; std::string type = mapping[ref->mBase->mData.mType].first;
std::string oneOrTwoHanded = mapping[ref->base->mData.mType].second; std::string oneOrTwoHanded = mapping[ref->mBase->mData.mType].second;
text += store.gameSettings.find(type)->getString() + text += store.get<ESM::GameSetting>().find(type)->getString() +
((oneOrTwoHanded != "") ? ", " + store.gameSettings.find(oneOrTwoHanded)->getString() : ""); ((oneOrTwoHanded != "") ? ", " + store.get<ESM::GameSetting>().find(oneOrTwoHanded)->getString() : "");
// weapon damage // weapon damage
if (ref->base->mData.mType >= 9) if (ref->mBase->mData.mType >= 9)
{ {
// marksman // marksman
text += "\n#{sAttack}: " text += "\n#{sAttack}: "
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mChop[0])) + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mChop[0]))
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mChop[1])); + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mChop[1]));
} }
else else
{ {
// Chop // Chop
text += "\n#{sChop}: " text += "\n#{sChop}: "
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mChop[0])) + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mChop[0]))
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mChop[1])); + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mChop[1]));
// Slash // Slash
text += "\n#{sSlash}: " text += "\n#{sSlash}: "
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mSlash[0])) + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mSlash[0]))
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mSlash[1])); + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mSlash[1]));
// Thrust // Thrust
text += "\n#{sThrust}: " text += "\n#{sThrust}: "
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mThrust[0])) + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mThrust[0]))
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mThrust[1])); + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mThrust[1]));
} }
} }
/// \todo store the current weapon health somewhere /// \todo store the current weapon health somewhere
if (ref->base->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity if (ref->mBase->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->mData.mHealth); text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
info.enchant = ref->base->mEnchant; info.enchant = ref->mBase->mEnchant;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }
info.text = text; info.text = text;
@ -355,7 +354,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return ref->base->mEnchant; return ref->mBase->mEnchant;
} }
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
@ -373,6 +372,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return MWWorld::Ptr(&cell.weapons.insert(*ref), &cell); return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell);
} }
} }

View file

@ -7,18 +7,18 @@
#include <components/esm/loaddial.hpp> #include <components/esm/loaddial.hpp>
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/scriptmanager.hpp" #include "../mwbase/scriptmanager.hpp"
#include "../mwbase/journal.hpp" #include "../mwbase/journal.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/refdata.hpp" #include "../mwworld/refdata.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwgui/dialogue.hpp" #include "../mwgui/dialogue.hpp"
@ -84,14 +84,15 @@ namespace
template<typename T> template<typename T>
bool checkLocal (char comp, const std::string& name, T value, const MWWorld::Ptr& actor, bool checkLocal (char comp, const std::string& name, T value, const MWWorld::Ptr& actor,
const ESMS::ESMStore& store) const MWWorld::ESMStore& store)
{ {
std::string scriptName = MWWorld::Class::get (actor).getScript (actor); std::string scriptName = MWWorld::Class::get (actor).getScript (actor);
if (scriptName.empty()) if (scriptName.empty())
return false; // no script return false; // no script
const ESM::Script *script = store.scripts.find (scriptName); const ESM::Script *script =
store.get<ESM::Script>().find (scriptName);
int i = 0; int i = 0;
@ -391,7 +392,7 @@ namespace MWDialogue
if(select.mType==ESM::VT_Int) if(select.mType==ESM::VT_Int)
{ {
MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>();
int isFaction = int(toLower(npc->base->mFaction) == toLower(name)); int isFaction = int(toLower(npc->mBase->mFaction) == toLower(name));
if(selectCompare<int,int>(comp,!isFaction,select.mI)) if(selectCompare<int,int>(comp,!isFaction,select.mI))
return false; return false;
} }
@ -408,7 +409,7 @@ namespace MWDialogue
if(select.mType==ESM::VT_Int) if(select.mType==ESM::VT_Int)
{ {
MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>();
int isClass = int(toLower(npc->base->mClass) == toLower(name)); int isClass = int(toLower(npc->mBase->mClass) == toLower(name));
if(selectCompare<int,int>(comp,!isClass,select.mI)) if(selectCompare<int,int>(comp,!isClass,select.mI))
return false; return false;
} }
@ -425,7 +426,7 @@ namespace MWDialogue
if(select.mType==ESM::VT_Int) if(select.mType==ESM::VT_Int)
{ {
MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>();
int isRace = int(toLower(npc->base->mRace) == toLower(name)); int isRace = int(toLower(npc->mBase->mRace) == toLower(name));
if(selectCompare<int,int>(comp,!isRace,select.mI)) if(selectCompare<int,int>(comp,!isRace,select.mI))
return false; return false;
} }
@ -438,7 +439,7 @@ namespace MWDialogue
case 'B'://not Cell case 'B'://not Cell
if(select.mType==ESM::VT_Int) if(select.mType==ESM::VT_Int)
{ {
int isCell = int(toLower(actor.getCell()->cell->mName) == toLower(name)); int isCell = int(toLower(actor.getCell()->mCell->mName) == toLower(name));
if(selectCompare<int,int>(comp,!isCell,select.mI)) if(selectCompare<int,int>(comp,!isCell,select.mI))
return false; return false;
} }
@ -496,7 +497,7 @@ namespace MWDialogue
if (!cellRef) if (!cellRef)
return false; return false;
if (toLower (info.mRace)!=toLower (cellRef->base->mRace)) if (toLower (info.mRace)!=toLower (cellRef->mBase->mRace))
return false; return false;
} }
@ -511,7 +512,7 @@ namespace MWDialogue
if (!cellRef) if (!cellRef)
return false; return false;
if (toLower (info.mClass)!=toLower (cellRef->base->mClass)) if (toLower (info.mClass)!=toLower (cellRef->mBase->mClass))
return false; return false;
} }
@ -557,7 +558,7 @@ namespace MWDialogue
if (!isCreature) if (!isCreature)
{ {
MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>();
if(npc->base->mFlags & npc->base->Female) if(npc->mBase->mFlags & npc->mBase->Female)
{ {
if(static_cast<int> (info.mData.mGender)==0) return false; if(static_cast<int> (info.mData.mGender)==0) return false;
} }
@ -569,7 +570,7 @@ namespace MWDialogue
// check cell // check cell
if (!info.mCell.empty()) if (!info.mCell.empty())
if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mName != info.mCell) if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mName != info.mCell)
return false; return false;
// TODO check DATAstruct // TODO check DATAstruct
@ -584,16 +585,22 @@ namespace MWDialogue
DialogueManager::DialogueManager (const Compiler::Extensions& extensions) : DialogueManager::DialogueManager (const Compiler::Extensions& extensions) :
mCompilerContext (MWScript::CompilerContext::Type_Dialgoue), mCompilerContext (MWScript::CompilerContext::Type_Dialgoue),
mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream)
, mTemporaryDispositionChange(0.f)
, mPermanentDispositionChange(0.f)
{ {
mChoice = -1; mChoice = -1;
mIsInChoice = false; mIsInChoice = false;
mCompilerContext.setExtensions (&extensions); mCompilerContext.setExtensions (&extensions);
mDialogueMap.clear(); mDialogueMap.clear();
mActorKnownTopics.clear(); mActorKnownTopics.clear();
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list;
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) const MWWorld::Store<ESM::Dialogue> &dialogs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
for (; it != dialogs.end(); ++it)
{ {
mDialogueMap[toLower(it->first)] = it->second; mDialogueMap[toLower(it->mId)] = *it;
} }
} }
@ -642,16 +649,17 @@ namespace MWDialogue
//greeting //greeting
bool greetingFound = false; bool greetingFound = false;
//ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; const MWWorld::Store<ESM::Dialogue> &dialogs =
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
for (; it != dialogs.end(); ++it)
{ {
ESM::Dialogue ndialogue = it->second; if(it->mType == ESM::Dialogue::Greeting)
if(ndialogue.mType == ESM::Dialogue::Greeting)
{ {
if (greetingFound) break; if (greetingFound) break;
for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin());
iter!=it->second.mInfo.end(); ++iter) iter!=it->mInfo.end(); ++iter)
{ {
if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true)) if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true))
{ {
@ -665,7 +673,7 @@ namespace MWDialogue
win->addText(iter->mResponse); win->addText(iter->mResponse);
executeScript(iter->mResultScript); executeScript(iter->mResultScript);
greetingFound = true; greetingFound = true;
mLastTopic = it->first; mLastTopic = it->mId;
mLastDialogue = *iter; mLastDialogue = *iter;
break; break;
} }
@ -742,22 +750,26 @@ namespace MWDialogue
mChoice = -1; mChoice = -1;
mActorKnownTopics.clear(); mActorKnownTopics.clear();
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list;
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) const MWWorld::Store<ESM::Dialogue> &dialogs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
for (; it != dialogs.end(); ++it)
{ {
ESM::Dialogue ndialogue = it->second; if(it->mType == ESM::Dialogue::Topic)
if(ndialogue.mType == ESM::Dialogue::Topic)
{ {
for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin());
iter!=it->second.mInfo.end(); ++iter) iter!=it->mInfo.end(); ++iter)
{ {
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{ {
mActorKnownTopics.push_back(toLower(it->first)); mActorKnownTopics.push_back(toLower(it->mId));
//does the player know the topic? //does the player know the topic?
if(mKnownTopics.find(toLower(it->first)) != mKnownTopics.end()) if(mKnownTopics.find(toLower(it->mId)) != mKnownTopics.end())
{ {
keywordList.push_back(it->first); keywordList.push_back(it->mId);
break; break;
} }
} }
@ -770,14 +782,14 @@ namespace MWDialogue
if (mActor.getTypeName() == typeid(ESM::NPC).name()) if (mActor.getTypeName() == typeid(ESM::NPC).name())
{ {
MWWorld::LiveCellRef<ESM::NPC>* ref = mActor.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* ref = mActor.get<ESM::NPC>();
if (ref->base->mHasAI) if (ref->mBase->mHasAI)
services = ref->base->mAiData.mServices; services = ref->mBase->mAiData.mServices;
} }
else if (mActor.getTypeName() == typeid(ESM::Creature).name()) else if (mActor.getTypeName() == typeid(ESM::Creature).name())
{ {
MWWorld::LiveCellRef<ESM::Creature>* ref = mActor.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature>* ref = mActor.get<ESM::Creature>();
if (ref->base->mHasAI) if (ref->mBase->mHasAI)
services = ref->base->mAiData.mServices; services = ref->mBase->mAiData.mServices;
} }
int windowServices = 0; int windowServices = 0;
@ -795,7 +807,7 @@ namespace MWDialogue
|| services & ESM::NPC::Misc) || services & ESM::NPC::Misc)
windowServices |= MWGui::DialogueWindow::Service_Trade; windowServices |= MWGui::DialogueWindow::Service_Trade;
if( !mActor.get<ESM::NPC>()->base->mTransport.empty()) if(mActor.getTypeName() == typeid(ESM::NPC).name() && !mActor.get<ESM::NPC>()->mBase->mTransport.empty())
windowServices |= MWGui::DialogueWindow::Service_Travel; windowServices |= MWGui::DialogueWindow::Service_Travel;
if (services & ESM::NPC::Spells) if (services & ESM::NPC::Spells)
@ -859,6 +871,15 @@ namespace MWDialogue
void DialogueManager::goodbyeSelected() void DialogueManager::goodbyeSelected()
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue); MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue);
// Apply disposition change to NPC's base disposition
if (mActor.getTypeName() == typeid(ESM::NPC).name())
{
MWMechanics::NpcStats npcStats = MWWorld::Class::get(mActor).getNpcStats(mActor);
npcStats.setBaseDisposition(npcStats.getBaseDisposition() + mPermanentDispositionChange);
}
mPermanentDispositionChange = 0;
mTemporaryDispositionChange = 0;
} }
void DialogueManager::questionAnswered (const std::string& answer) void DialogueManager::questionAnswered (const std::string& answer)
@ -935,4 +956,58 @@ namespace MWDialogue
win->goodbye(); win->goodbye();
} }
void DialogueManager::persuade(int type)
{
bool success;
float temp, perm;
MWBase::Environment::get().getMechanicsManager()->getPersuasionDispositionChange(
mActor, MWBase::MechanicsManager::PersuasionType(type), mTemporaryDispositionChange,
success, temp, perm);
mTemporaryDispositionChange += temp;
mPermanentDispositionChange += perm;
// change temp disposition so that final disposition is between 0...100
int curDisp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor);
if (curDisp + mTemporaryDispositionChange < 0)
mTemporaryDispositionChange = -curDisp;
else if (curDisp + mTemporaryDispositionChange > 100)
mTemporaryDispositionChange = 100 - curDisp;
// practice skill
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
if (success)
MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, 0);
// add status message to dialogue window
std::string text;
if (type == MWBase::MechanicsManager::PT_Admire)
text = "sAdmire";
else if (type == MWBase::MechanicsManager::PT_Taunt)
text = "sTaunt";
else if (type == MWBase::MechanicsManager::PT_Intimidate)
text = "sIntimidate";
else
text = "sBribe";
text += (success ? "Success" : "Fail");
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->addTitle(MyGUI::LanguageManager::getInstance().replaceTags("#{"+text+"}"));
/// \todo text from INFO record, how to get the ID?
}
int DialogueManager::getTemporaryDispositionChange() const
{
return mTemporaryDispositionChange;
}
void DialogueManager::applyTemporaryDispositionChange(int delta)
{
mTemporaryDispositionChange += delta;
}
} }

View file

@ -49,6 +49,9 @@ namespace MWDialogue
ESM::DialInfo mLastDialogue; ESM::DialInfo mLastDialogue;
bool mIsInChoice; bool mIsInChoice;
float mTemporaryDispositionChange;
float mPermanentDispositionChange;
public: public:
DialogueManager (const Compiler::Extensions& extensions); DialogueManager (const Compiler::Extensions& extensions);
@ -69,6 +72,9 @@ namespace MWDialogue
virtual void goodbyeSelected(); virtual void goodbyeSelected();
virtual void questionAnswered (const std::string& answer); virtual void questionAnswered (const std::string& answer);
virtual void persuade (int type);
virtual int getTemporaryDispositionChange () const;
virtual void applyTemporaryDispositionChange (int delta);
}; };
} }

View file

@ -3,11 +3,11 @@
#include <stdexcept> #include <stdexcept>
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
namespace MWDialogue namespace MWDialogue
{ {
JournalEntry::JournalEntry() {} JournalEntry::JournalEntry() {}
@ -16,9 +16,10 @@ namespace MWDialogue
: mTopic (topic), mInfoId (infoId) : mTopic (topic), mInfoId (infoId)
{} {}
std::string JournalEntry::getText (const ESMS::ESMStore& store) const std::string JournalEntry::getText (const MWWorld::ESMStore& store) const
{ {
const ESM::Dialogue *dialogue = store.dialogs.find (mTopic); const ESM::Dialogue *dialogue =
store.get<ESM::Dialogue>().find (mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)
@ -35,7 +36,8 @@ namespace MWDialogue
std::string JournalEntry::idFromIndex (const std::string& topic, int index) std::string JournalEntry::idFromIndex (const std::string& topic, int index)
{ {
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (topic); const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (topic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)

View file

@ -3,7 +3,7 @@
#include <string> #include <string>
namespace ESMS namespace MWWorld
{ {
struct ESMStore; struct ESMStore;
} }
@ -20,7 +20,7 @@ namespace MWDialogue
JournalEntry (const std::string& topic, const std::string& infoId); JournalEntry (const std::string& topic, const std::string& infoId);
std::string getText (const ESMS::ESMStore& store) const; std::string getText (const MWWorld::ESMStore& store) const;
static JournalEntry makeFromQuest (const std::string& topic, int index); static JournalEntry makeFromQuest (const std::string& topic, int index);

View file

@ -1,7 +1,7 @@
#include "journalimp.hpp" #include "journalimp.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"

View file

@ -1,7 +1,7 @@
#include "quest.hpp" #include "quest.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -18,7 +18,8 @@ namespace MWDialogue
const std::string Quest::getName() const const std::string Quest::getName() const
{ {
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic); const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)
@ -35,7 +36,8 @@ namespace MWDialogue
void Quest::setIndex (int index) void Quest::setIndex (int index)
{ {
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic); const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)
@ -63,7 +65,8 @@ namespace MWDialogue
{ {
int index = -1; int index = -1;
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (entry.mTopic); const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (entry.mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)

View file

@ -1,7 +1,7 @@
#include "topic.hpp" #include "topic.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
namespace MWDialogue namespace MWDialogue
{ {

View file

@ -3,7 +3,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include "components/esm_store/store.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -130,19 +130,18 @@ void BirthDialog::updateBirths()
{ {
mBirthList->removeAllItems(); mBirthList->removeAllItems();
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::Store<ESM::BirthSign> &signs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>();
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin();
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end();
int index = 0; int index = 0;
// sort by name // sort by name
std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns; std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns;
for (; it!=end; ++it)
MWWorld::Store<ESM::BirthSign>::iterator it = signs.begin();
for (; it != signs.end(); ++it)
{ {
std::string id = it->first; birthSigns.push_back(std::make_pair(it->mId, &(*it)));
const ESM::BirthSign* sign = &it->second;
birthSigns.push_back(std::make_pair(id, sign));
} }
std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns); std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns);
@ -170,8 +169,11 @@ void BirthDialog::updateSpells()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18); MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18);
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store =
const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId); MWBase::Environment::get().getWorld()->getStore();
const ESM::BirthSign *birth =
store.get<ESM::BirthSign>().find(mCurrentBirthId);
std::string texturePath = std::string("textures\\") + birth->mTexture; std::string texturePath = std::string("textures\\") + birth->mTexture;
fixTexturePath(texturePath); fixTexturePath(texturePath);
@ -184,7 +186,7 @@ void BirthDialog::updateSpells()
for (; it != end; ++it) for (; it != end; ++it)
{ {
const std::string &spellId = *it; const std::string &spellId = *it;
const ESM::Spell *spell = store.spells.search(spellId); const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId);
if (!spell) if (!spell)
continue; // Skip spells which cannot be found continue; // Skip spells which cannot be found
ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType); ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType);
@ -200,11 +202,17 @@ void BirthDialog::updateSpells()
} }
int i = 0; int i = 0;
struct{ const std::vector<std::string> &spells; const char *label; } categories[3] = {
struct {
const std::vector<std::string> &spells;
const char *label;
}
categories[3] = {
{abilities, "sBirthsignmenu1"}, {abilities, "sBirthsignmenu1"},
{powers, "sPowers"}, {powers, "sPowers"},
{spells, "sBirthsignmenu2"} {spells, "sBirthsignmenu2"}
}; };
for (int category = 0; category < 3; ++category) for (int category = 0; category < 3; ++category)
{ {
if (!categories[category].spells.empty()) if (!categories[category].spells.empty())

View file

@ -60,7 +60,7 @@ void BookWindow::open (MWWorld::Ptr book)
MWWorld::LiveCellRef<ESM::Book> *ref = mBook.get<ESM::Book>(); MWWorld::LiveCellRef<ESM::Book> *ref = mBook.get<ESM::Book>();
BookTextParser parser; BookTextParser parser;
std::vector<std::string> results = parser.split(ref->base->mText, mLeftPage->getSize().width, mLeftPage->getSize().height); std::vector<std::string> results = parser.split(ref->mBase->mText, mLeftPage->getSize().width, mLeftPage->getSize().height);
int i=0; int i=0;
for (std::vector<std::string>::iterator it=results.begin(); for (std::vector<std::string>::iterator it=results.begin();

View file

@ -7,6 +7,7 @@
#include "review.hpp" #include "review.hpp"
#include "dialogue.hpp" #include "dialogue.hpp"
#include "mode.hpp" #include "mode.hpp"
#include "inventorywindow.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
@ -357,7 +358,9 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow)
const std::string &classId = mPickClassDialog->getClassId(); const std::string &classId = mPickClassDialog->getClassId();
if (!classId.empty()) if (!classId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(classId);
const ESM::Class *klass =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(classId);
if (klass) if (klass)
{ {
mPlayerClass = *klass; mPlayerClass = *klass;
@ -457,9 +460,16 @@ void CharacterCreation::onRaceDialogBack()
{ {
if (mRaceDialog) if (mRaceDialog)
{ {
mPlayerRaceId = mRaceDialog->getRaceId(); const ESM::NPC &data = mRaceDialog->getResult();
if (!mPlayerRaceId.empty()) mPlayerRaceId = data.mId;
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); if (!mPlayerRaceId.empty()) {
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(
data.mId,
data.isMale(),
data.mHead,
data.mHair
);
}
mWM->removeDialog(mRaceDialog); mWM->removeDialog(mRaceDialog);
mRaceDialog = 0; mRaceDialog = 0;
} }
@ -472,10 +482,18 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
{ {
if (mRaceDialog) if (mRaceDialog)
{ {
mPlayerRaceId = mRaceDialog->getRaceId(); const ESM::NPC &data = mRaceDialog->getResult();
mWM->setValue("race", mPlayerRaceId); mPlayerRaceId = data.mRace;
if (!mPlayerRaceId.empty()) if (!mPlayerRaceId.empty()) {
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); MWBase::Environment::get().getMechanicsManager()->setPlayerRace(
data.mRace,
data.isMale(),
data.mHead,
data.mHair
);
}
mWM->getInventoryWindow()->rebuildAvatar();
mWM->removeDialog(mRaceDialog); mWM->removeDialog(mRaceDialog);
mRaceDialog = 0; mRaceDialog = 0;
} }
@ -557,6 +575,7 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
klass.mData.mSkills[i][1] = majorSkills[i]; klass.mData.mSkills[i][1] = majorSkills[i];
klass.mData.mSkills[i][0] = minorSkills[i]; klass.mData.mSkills[i][0] = minorSkills[i];
} }
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass);
mPlayerClass = klass; mPlayerClass = klass;
mWM->setPlayerClass(klass); mWM->setPlayerClass(klass);
@ -729,7 +748,10 @@ void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
mGenerateClassResultDialog = 0; mGenerateClassResultDialog = 0;
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass);
const ESM::Class *klass =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(mGenerateClass);
mPlayerClass = *klass; mPlayerClass = *klass;
mWM->setPlayerClass(mPlayerClass); mWM->setPlayerClass(mPlayerClass);

View file

@ -1,7 +1,7 @@
#ifndef CHARACTER_CREATION_HPP #ifndef CHARACTER_CREATION_HPP
#define CHARACTER_CREATION_HPP #define CHARACTER_CREATION_HPP
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"

View file

@ -5,7 +5,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -50,7 +50,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId)
{ {
mCurrentClassId = classId; mCurrentClassId = classId;
mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds"); mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds");
mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().classes.find(mCurrentClassId)->mName); mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(mCurrentClassId)->mName);
} }
// widget controls // widget controls
@ -185,20 +185,18 @@ void PickClassDialog::updateClasses()
{ {
mClassList->removeAllItems(); mClassList->removeAllItems();
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin();
ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end();
int index = 0; int index = 0;
for (; it != end; ++it) MWWorld::Store<ESM::Class>::iterator it = store.get<ESM::Class>().begin();
for (; it != store.get<ESM::Class>().end(); ++it)
{ {
const ESM::Class &klass = it->second; bool playable = (it->mData.mIsPlayable != 0);
bool playable = (klass.mData.mIsPlayable != 0);
if (!playable) // Only display playable classes if (!playable) // Only display playable classes
continue; continue;
const std::string &id = it->first; const std::string &id = it->mId;
mClassList->addItem(klass.mName, id); mClassList->addItem(it->mName, id);
if (boost::iequals(id, mCurrentClassId)) if (boost::iequals(id, mCurrentClassId))
mClassList->setIndexSelected(index); mClassList->setIndexSelected(index);
++index; ++index;
@ -209,8 +207,8 @@ void PickClassDialog::updateStats()
{ {
if (mCurrentClassId.empty()) if (mCurrentClassId.empty())
return; return;
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Class *klass = store.classes.search(mCurrentClassId); const ESM::Class *klass = store.get<ESM::Class>().search(mCurrentClassId);
if (!klass) if (!klass)
return; return;

View file

@ -4,11 +4,10 @@
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <components/esm_store/reclists.hpp>
#include <components/esm_store/store.hpp>
#include <components/compiler/exception.hpp> #include <components/compiler/exception.hpp>
#include "../mwworld/esmstore.hpp"
#include "../mwscript/extensions.hpp" #include "../mwscript/extensions.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -93,12 +92,12 @@ namespace MWGui
scanner.listKeywords (mNames); scanner.listKeywords (mNames);
// identifier // identifier
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store =
MWBase::Environment::get().getWorld()->getStore();
for (ESMS::RecListList::const_iterator iter (store.recLists.begin()); for (MWWorld::ESMStore::iterator it = store.begin(); it != store.end(); ++it)
iter!=store.recLists.end(); ++iter)
{ {
iter->second->listIdentifier (mNames); it->second->listIdentifier (mNames);
} }
// sort // sort

View file

@ -127,10 +127,13 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
if (isInventory()) if (isInventory())
{ {
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
// the player is trying to sell an item, check if the merchant accepts it // the player is trying to sell an item, check if the merchant accepts it
// also, don't allow selling gold (let's be better than Morrowind at this, can we?) // also, don't allow selling gold (let's be better than Morrowind at this, can we?)
if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object) || if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object) ||
MWWorld::Class::get(object).getName(object) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) MWWorld::Class::get(object).getName(object) == gmst.find("sGold")->getString())
{ {
// user notification "i don't buy this item" // user notification "i don't buy this item"
MWBase::Environment::get().getWindowManager()-> MWBase::Environment::get().getWindowManager()->
@ -274,7 +277,7 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
if (mPtr.getTypeName() == typeid(ESM::Container).name()) if (mPtr.getTypeName() == typeid(ESM::Container).name())
{ {
MWWorld::LiveCellRef<ESM::Container>* ref = mPtr.get<ESM::Container>(); MWWorld::LiveCellRef<ESM::Container>* ref = mPtr.get<ESM::Container>();
if (ref->base->mFlags & ESM::Container::Organic) if (ref->mBase->mFlags & ESM::Container::Organic)
{ {
// user notification // user notification
MWBase::Environment::get().getWindowManager()-> MWBase::Environment::get().getWindowManager()->

View file

@ -1,7 +1,7 @@
#ifndef MGUI_CONTAINER_H #ifndef MGUI_CONTAINER_H
#define MGUI_CONTAINER_H #define MGUI_CONTAINER_H
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "window_base.hpp" #include "window_base.hpp"
#include "referenceinterface.hpp" #include "referenceinterface.hpp"

View file

@ -6,12 +6,15 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/dialoguemanager.hpp" #include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "dialogue_history.hpp" #include "dialogue_history.hpp"
#include "widgets.hpp" #include "widgets.hpp"
@ -48,14 +51,87 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su
} }
PersuasionDialog::PersuasionDialog(MWBase::WindowManager &parWindowManager)
: WindowModal("openmw_persuasion_dialog.layout", parWindowManager)
{
getWidget(mCancelButton, "CancelButton");
getWidget(mAdmireButton, "AdmireButton");
getWidget(mIntimidateButton, "IntimidateButton");
getWidget(mTauntButton, "TauntButton");
getWidget(mBribe10Button, "Bribe10Button");
getWidget(mBribe100Button, "Bribe100Button");
getWidget(mBribe1000Button, "Bribe1000Button");
getWidget(mGoldLabel, "GoldLabel");
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onCancel);
mAdmireButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mIntimidateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mTauntButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mBribe10Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mBribe100Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mBribe1000Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
}
void PersuasionDialog::onCancel(MyGUI::Widget *sender)
{
setVisible(false);
}
void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
{
MWBase::MechanicsManager::PersuasionType type;
if (sender == mAdmireButton) type = MWBase::MechanicsManager::PT_Admire;
else if (sender == mIntimidateButton) type = MWBase::MechanicsManager::PT_Intimidate;
else if (sender == mTauntButton) type = MWBase::MechanicsManager::PT_Taunt;
else if (sender == mBribe10Button)
{
mWindowManager.getTradeWindow()->addOrRemoveGold(-10);
type = MWBase::MechanicsManager::PT_Bribe10;
}
else if (sender == mBribe100Button)
{
mWindowManager.getTradeWindow()->addOrRemoveGold(-100);
type = MWBase::MechanicsManager::PT_Bribe100;
}
else /*if (sender == mBribe1000Button)*/
{
mWindowManager.getTradeWindow()->addOrRemoveGold(-1000);
type = MWBase::MechanicsManager::PT_Bribe1000;
}
MWBase::Environment::get().getDialogueManager()->persuade(type);
setVisible(false);
}
void PersuasionDialog::open()
{
WindowModal::open();
center();
int playerGold = mWindowManager.getInventoryWindow()->getPlayerGold();
mBribe10Button->setEnabled (playerGold >= 10);
mBribe100Button->setEnabled (playerGold >= 100);
mBribe1000Button->setEnabled (playerGold >= 1000);
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
}
// --------------------------------------------------------------------------------------------------
DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager) DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_dialogue_window.layout", parWindowManager) : WindowBase("openmw_dialogue_window.layout", parWindowManager)
, mEnabled(true) , mPersuasionDialog(parWindowManager)
, mEnabled(false)
, mServices(0) , mServices(0)
{ {
// Centre dialog // Centre dialog
center(); center();
mPersuasionDialog.setVisible(false);
//History view //History view
getWidget(mHistory, "History"); getWidget(mHistory, "History");
mHistory->setOverflowToTheLeft(true); mHistory->setOverflowToTheLeft(true);
@ -127,33 +203,40 @@ void DialogueWindow::onSelectTopic(std::string topic)
{ {
if (!mEnabled) return; if (!mEnabled) return;
if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sBarter")->getString()) const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
if (topic == gmst.find("sBarter")->getString())
{ {
/// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)? /// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)?
mWindowManager.pushGuiMode(GM_Barter); mWindowManager.pushGuiMode(GM_Barter);
mWindowManager.getTradeWindow()->startTrade(mPtr); mWindowManager.getTradeWindow()->startTrade(mPtr);
} }
else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString()) if (topic == gmst.find("sPersuasion")->getString())
{
mPersuasionDialog.setVisible(true);
}
else if (topic == gmst.find("sSpells")->getString())
{ {
mWindowManager.pushGuiMode(GM_SpellBuying); mWindowManager.pushGuiMode(GM_SpellBuying);
mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr); mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr);
} }
else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()) else if (topic == gmst.find("sTravel")->getString())
{ {
mWindowManager.pushGuiMode(GM_Travel); mWindowManager.pushGuiMode(GM_Travel);
mWindowManager.getTravelWindow()->startTravel(mPtr); mWindowManager.getTravelWindow()->startTravel(mPtr);
} }
else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellMakingMenuTitle")->getString()) else if (topic == gmst.find("sSpellMakingMenuTitle")->getString())
{ {
mWindowManager.pushGuiMode(GM_SpellCreation); mWindowManager.pushGuiMode(GM_SpellCreation);
mWindowManager.startSpellMaking (mPtr); mWindowManager.startSpellMaking (mPtr);
} }
else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()) else if (topic == gmst.find("sEnchanting")->getString())
{ {
mWindowManager.pushGuiMode(GM_Enchanting); mWindowManager.pushGuiMode(GM_Enchanting);
mWindowManager.startEnchanting (mPtr); mWindowManager.startEnchanting (mPtr);
} }
else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()) else if (topic == gmst.find("sServiceTrainingTitle")->getString())
{ {
mWindowManager.pushGuiMode(GM_Training); mWindowManager.pushGuiMode(GM_Training);
mWindowManager.startTraining (mPtr); mWindowManager.startTraining (mPtr);
@ -180,23 +263,29 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords)
bool anyService = mServices > 0; bool anyService = mServices > 0;
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
mTopicsList->addItem(gmst.find("sPersuasion")->getString());
if (mServices & Service_Trade) if (mServices & Service_Trade)
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sBarter")->getString()); mTopicsList->addItem(gmst.find("sBarter")->getString());
if (mServices & Service_BuySpells) if (mServices & Service_BuySpells)
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString()); mTopicsList->addItem(gmst.find("sSpells")->getString());
if (mServices & Service_Travel) if (mServices & Service_Travel)
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()); mTopicsList->addItem(gmst.find("sTravel")->getString());
if (mServices & Service_CreateSpells) if (mServices & Service_CreateSpells)
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellmakingMenuTitle")->getString()); mTopicsList->addItem(gmst.find("sSpellmakingMenuTitle")->getString());
// if (mServices & Service_Enchant) // if (mServices & Service_Enchant)
// mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()); // mTopicsList->addItem(gmst.find("sEnchanting")->getString());
if (mServices & Service_Training) if (mServices & Service_Training)
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()); mTopicsList->addItem(gmst.find("sServiceTrainingTitle")->getString());
if (anyService) if (anyService)
mTopicsList->addSeparator(); mTopicsList->addSeparator();
@ -293,15 +382,18 @@ void DialogueWindow::updateOptions()
mTopicsList->clear(); mTopicsList->clear();
mHistory->eraseText(0, mHistory->getTextLength()); mHistory->eraseText(0, mHistory->getTextLength());
mDispositionBar->setProgressRange(100); if (mPtr.getTypeName() == typeid(ESM::NPC).name())
mDispositionBar->setProgressPosition(40); {
mDispositionText->eraseText(0, mDispositionText->getTextLength()); mDispositionBar->setProgressRange(100);
mDispositionText->addText("#B29154"+std::string("40/100")+"#B29154"); mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr));
mDispositionText->eraseText(0, mDispositionText->getTextLength());
mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100")+"#B29154");
}
} }
void DialogueWindow::goodbye() void DialogueWindow::goodbye()
{ {
mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGoodbye")->getString()); mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString());
mTopicsList->setEnabled(false); mTopicsList->setEnabled(false);
mEnabled = false; mEnabled = false;
} }
@ -310,3 +402,17 @@ void DialogueWindow::onReferenceUnavailable()
{ {
mWindowManager.removeGuiMode(GM_Dialogue); mWindowManager.removeGuiMode(GM_Dialogue);
} }
void DialogueWindow::onFrame()
{
if(mEnabled && mPtr.getTypeName() == typeid(ESM::NPC).name())
{
int disp = std::max(0, std::min(100,
MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)
+ MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange()));
mDispositionBar->setProgressRange(100);
mDispositionBar->setProgressPosition(disp);
mDispositionText->eraseText(0, mDispositionText->getTextLength());
mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(disp)+std::string("/100")+"#B29154");
}
}

View file

@ -26,6 +26,27 @@ namespace MWGui
{ {
class DialogueHistory; class DialogueHistory;
class PersuasionDialog : public WindowModal
{
public:
PersuasionDialog(MWBase::WindowManager& parWindowManager);
virtual void open();
private:
MyGUI::Button* mCancelButton;
MyGUI::Button* mAdmireButton;
MyGUI::Button* mIntimidateButton;
MyGUI::Button* mTauntButton;
MyGUI::Button* mBribe10Button;
MyGUI::Button* mBribe100Button;
MyGUI::Button* mBribe1000Button;
MyGUI::TextBox* mGoldLabel;
void onCancel (MyGUI::Widget* sender);
void onPersuade (MyGUI::Widget* sender);
};
class DialogueWindow: public WindowBase, public ReferenceInterface class DialogueWindow: public WindowBase, public ReferenceInterface
{ {
public: public:
@ -47,6 +68,7 @@ namespace MWGui
void addTitle(std::string text); void addTitle(std::string text);
void askQuestion(std::string question); void askQuestion(std::string question);
void goodbye(); void goodbye();
void onFrame();
// make sure to call these before setKeywords() // make sure to call these before setKeywords()
void setServices(int services) { mServices = services; } void setServices(int services) { mServices = services; }
@ -85,6 +107,8 @@ namespace MWGui
Widgets::MWList* mTopicsList; Widgets::MWList* mTopicsList;
MyGUI::ProgressPtr mDispositionBar; MyGUI::ProgressPtr mDispositionBar;
MyGUI::EditPtr mDispositionText; MyGUI::EditPtr mDispositionText;
PersuasionDialog mPersuasionDialog;
}; };
} }
#endif #endif

View file

@ -3,7 +3,8 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp"
#include "../mwworld/esmstore.hpp"
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>

View file

@ -341,7 +341,9 @@ void HUD::onResChange(int width, int height)
void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent) void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
std::string spellName = spell->mName; std::string spellName = spell->mName;
if (spellName != mSpellName && mSpellVisible) if (spellName != mSpellName && mSpellVisible)
{ {
@ -361,7 +363,9 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent)
mSpellBox->setUserString("Spell", spellId); mSpellBox->setUserString("Spell", spellId);
// use the icon of the first effect // use the icon of the first effect
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->mEffects.mList.front().mEffectID); const ESM::MagicEffect* effect =
MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(spell->mEffects.mList.front().mEffectID);
std::string icon = effect->mIcon; std::string icon = effect->mIcon;
int slashPos = icon.find("\\"); int slashPos = icon.find("\\");
icon.insert(slashPos+1, "b_"); icon.insert(slashPos+1, "b_");

View file

@ -28,6 +28,10 @@ namespace MWGui
MWWorld::Ptr getAvatarSelectedItem(int x, int y); MWWorld::Ptr getAvatarSelectedItem(int x, int y);
void rebuildAvatar() {
mPreview.rebuild();
}
protected: protected:
MyGUI::Widget* mAvatar; MyGUI::Widget* mAvatar;
MyGUI::ImageBox* mAvatarImage; MyGUI::ImageBox* mAvatarImage;

View file

@ -8,14 +8,12 @@
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/stat.hpp" #include "../mwmechanics/stat.hpp"
#include <components/esm_store/reclists.hpp>
#include <components/esm_store/store.hpp>
namespace MWGui namespace MWGui
{ {
@ -110,7 +108,8 @@ namespace MWGui
void LevelupDialog::open() void LevelupDialog::open()
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayer().getPlayer();
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player); MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player);
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
@ -121,17 +120,13 @@ namespace MWGui
setAttributeValues(); setAttributeValues();
const ESM::NPC *playerData = player.get<ESM::NPC>()->mBase;
// set class image // set class image
const ESM::Class& playerClass = MWBase::Environment::get().getWorld ()->getPlayer ().getClass (); const ESM::Class *cls =
// retrieve the ID to this class world->getStore().get<ESM::Class>().find(playerData->mClass);
std::string classId;
std::map<std::string, ESM::Class> list = MWBase::Environment::get().getWorld()->getStore ().classes.list; mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds");
for (std::map<std::string, ESM::Class>::iterator it = list.begin(); it != list.end(); ++it)
{
if (playerClass.mName == it->second.mName)
classId = it->first;
}
mClassImage->setImageTexture ("textures\\levelup\\" + classId + ".dds");
/// \todo replace this with INI-imported texts /// \todo replace this with INI-imported texts
int level = creatureStats.getLevel ()+1; int level = creatureStats.getLevel ()+1;

View file

@ -29,8 +29,11 @@ namespace
bool sortSpells(const std::string& left, const std::string& right) bool sortSpells(const std::string& left, const std::string& right)
{ {
const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left); const MWWorld::Store<ESM::Spell> &spells =
const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>();
const ESM::Spell* a = spells.find(left);
const ESM::Spell* b = spells.find(right);
int cmp = a->mName.compare(b->mName); int cmp = a->mName.compare(b->mName);
return cmp < 0; return cmp < 0;
@ -234,9 +237,15 @@ namespace MWGui
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default); MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore();
// use the icon of the first effect // use the icon of the first effect
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(spellId);
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->mEffects.mList.front().mEffectID);
const ESM::MagicEffect* effect =
esmStore.get<ESM::MagicEffect>().find(spell->mEffects.mList.front().mEffectID);
std::string path = effect->mIcon; std::string path = effect->mIcon;
int slashPos = path.find("\\"); int slashPos = path.find("\\");
path.insert(slashPos+1, "b_"); path.insert(slashPos+1, "b_");
@ -434,11 +443,14 @@ namespace MWGui
spellList.push_back(*it); spellList.push_back(*it);
} }
const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore();
std::vector<std::string> powers; std::vector<std::string> powers;
std::vector<std::string>::iterator it = spellList.begin(); std::vector<std::string>::iterator it = spellList.begin();
while (it != spellList.end()) while (it != spellList.end())
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
if (spell->mData.mType == ESM::Spell::ST_Power) if (spell->mData.mType == ESM::Spell::ST_Power)
{ {
powers.push_back(*it); powers.push_back(*it);
@ -465,7 +477,9 @@ namespace MWGui
if (enchantId != "") if (enchantId != "")
{ {
// only add items with "Cast once" or "Cast on use" // only add items with "Cast once" or "Cast on use"
const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId); const ESM::Enchantment* enchant =
esmStore.get<ESM::Enchantment>().find(enchantId);
int type = enchant->mData.mType; int type = enchant->mData.mType;
if (type != ESM::Enchantment::CastOnce if (type != ESM::Enchantment::CastOnce
&& type != ESM::Enchantment::WhenUsed) && type != ESM::Enchantment::WhenUsed)
@ -487,7 +501,7 @@ namespace MWGui
for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it) for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText", MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName); t->setCaption(spell->mName);
@ -504,7 +518,7 @@ namespace MWGui
addGroup("#{sSpells}", ""); addGroup("#{sSpells}", "");
for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it) for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText", MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName); t->setCaption(spell->mName);

View file

@ -6,7 +6,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -214,6 +214,29 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index)
return; return;
mCurrentRaceId = *raceId; mCurrentRaceId = *raceId;
ESM::NPC record = mPreview->getPrototype();
record.mRace = mCurrentRaceId;
record.setIsMale(mGenderIndex == 0);
std::string prefix =
"b_n_" + mCurrentRaceId + ((record.isMale()) ? "_m_" : "_f_");
record.mHead = prefix + "head_01";
record.mHair = prefix + "hair_01";
const MWWorld::Store<ESM::BodyPart> &parts =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>();
if (parts.search(record.mHair) == 0) {
record.mHair = prefix + "hair01";
}
mFaceIndex = 0;
mHairIndex = 0;
mPreview->setPrototype(record);
updateSkills(); updateSkills();
updateSpellPowers(); updateSpellPowers();
} }
@ -224,20 +247,20 @@ void RaceDialog::updateRaces()
{ {
mRaceList->removeAllItems(); mRaceList->removeAllItems();
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::Store<ESM::Race> &races =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>();
ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin();
ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end();
int index = 0; int index = 0;
for (; it != end; ++it) MWWorld::Store<ESM::Race>::iterator it = races.begin();
for (; it != races.end(); ++it)
{ {
const ESM::Race &race = it->second; bool playable = it->mData.mFlags & ESM::Race::Playable;
bool playable = race.mData.mFlags & ESM::Race::Playable;
if (!playable) // Only display playable races if (!playable) // Only display playable races
continue; continue;
mRaceList->addItem(race.mName, it->first); mRaceList->addItem(it->mName, it->mId);
if (boost::iequals(it->first, mCurrentRaceId)) if (boost::iequals(it->mId, mCurrentRaceId))
mRaceList->setIndexSelected(index); mRaceList->setIndexSelected(index);
++index; ++index;
} }
@ -258,8 +281,8 @@ void RaceDialog::updateSkills()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18);
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.races.find(mCurrentRaceId); const ESM::Race *race = store.get<ESM::Race>().find(mCurrentRaceId);
int count = sizeof(race->mData.mBonus)/sizeof(race->mData.mBonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? int count = sizeof(race->mData.mBonus)/sizeof(race->mData.mBonus[0]); // TODO: Find a portable macro for this ARRAYSIZE?
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
@ -296,8 +319,8 @@ void RaceDialog::updateSpellPowers()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18); MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18);
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.races.find(mCurrentRaceId); const ESM::Race *race = store.get<ESM::Race>().find(mCurrentRaceId);
std::vector<std::string>::const_iterator it = race->mPowers.mList.begin(); std::vector<std::string>::const_iterator it = race->mPowers.mList.begin();
std::vector<std::string>::const_iterator end = race->mPowers.mList.end(); std::vector<std::string>::const_iterator end = race->mPowers.mList.end();

View file

@ -4,7 +4,7 @@
#include <boost/array.hpp> #include <boost/array.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwrender/characterpreview.hpp" #include "../mwrender/characterpreview.hpp"
@ -34,6 +34,7 @@ namespace MWGui
GM_Female GM_Female
}; };
const ESM::NPC &getResult() const { return mPreview->getPrototype(); }
const std::string &getRaceId() const { return mCurrentRaceId; } const std::string &getRaceId() const { return mCurrentRaceId; }
Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; } Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; }
// getFace() // getFace()

View file

@ -5,7 +5,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -108,7 +108,9 @@ void ReviewDialog::setPlayerName(const std::string &name)
void ReviewDialog::setRace(const std::string &raceId) void ReviewDialog::setRace(const std::string &raceId)
{ {
mRaceId = raceId; mRaceId = raceId;
const ESM::Race *race = MWBase::Environment::get().getWorld()->getStore().races.search(mRaceId);
const ESM::Race *race =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().search(mRaceId);
if (race) if (race)
{ {
ToolTips::createRaceToolTip(mRaceWidget, race); ToolTips::createRaceToolTip(mRaceWidget, race);
@ -126,7 +128,9 @@ void ReviewDialog::setClass(const ESM::Class& class_)
void ReviewDialog::setBirthSign(const std::string& signId) void ReviewDialog::setBirthSign(const std::string& signId)
{ {
mBirthSignId = signId; mBirthSignId = signId;
const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.search(mBirthSignId);
const ESM::BirthSign *sign =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().search(mBirthSignId);
if (sign) if (sign)
{ {
mBirthSignWidget->setCaption(sign->mName); mBirthSignWidget->setCaption(sign->mName);
@ -281,7 +285,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes
continue; continue;
assert(skillId >= 0 && skillId < ESM::Skill::Length); assert(skillId >= 0 && skillId < ESM::Skill::Length);
const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId];
const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second; const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second;
float base = stat.getBase(); float base = stat.getBase();
float modified = stat.getModified(); float modified = stat.getModified();

View file

@ -36,7 +36,7 @@ void ScrollWindow::open (MWWorld::Ptr scroll)
MWWorld::LiveCellRef<ESM::Book> *ref = mScroll.get<ESM::Book>(); MWWorld::LiveCellRef<ESM::Book> *ref = mScroll.get<ESM::Book>();
BookTextParser parser; BookTextParser parser;
MyGUI::IntSize size = parser.parse(ref->base->mText, mTextView, 390); MyGUI::IntSize size = parser.parse(ref->mBase->mText, mTextView, 390);
if (size.height > mTextView->getSize().height) if (size.height > mTextView->getSize().height)
mTextView->setCanvasSize(MyGUI::IntSize(410, size.height)); mTextView->setCanvasSize(MyGUI::IntSize(410, size.height));

View file

@ -8,6 +8,7 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/manualref.hpp" #include "../mwworld/manualref.hpp"
@ -49,8 +50,12 @@ namespace MWGui
void SpellBuyingWindow::addSpell(const std::string& spellId) void SpellBuyingWindow::addSpell(const std::string& spellId)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); const MWWorld::ESMStore &store =
int price = spell->mData.mCost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat(); MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
int price = spell->mData.mCost*store.get<ESM::GameSetting>().find("fSpellValueMult")->getFloat();
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
MyGUI::Button* toAdd = MyGUI::Button* toAdd =
mSpellsView->createWidget<MyGUI::Button>( mSpellsView->createWidget<MyGUI::Button>(
@ -63,7 +68,6 @@ namespace MWGui
); );
mCurrentY += sLineHeight; mCurrentY += sLineHeight;
/// \todo price adjustment depending on merchantile skill
toAdd->setUserData(price); toAdd->setUserData(price);
toAdd->setCaptionWithReplacing(spell->mName+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); toAdd->setCaptionWithReplacing(spell->mName+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}");
@ -97,7 +101,8 @@ namespace MWGui
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 = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter);
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

View file

@ -2,14 +2,14 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <components/esm_store/store.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -29,8 +29,11 @@ namespace
bool sortMagicEffects (short id1, short id2) bool sortMagicEffects (short id1, short id2)
{ {
return MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(ESM::MagicEffect::effectIdToString (id1))->getString() const MWWorld::Store<ESM::GameSetting> &gmst =
< MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(ESM::MagicEffect::effectIdToString (id2))->getString(); MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
return gmst.find(ESM::MagicEffect::effectIdToString (id1))->getString()
< gmst.find(ESM::MagicEffect::effectIdToString (id2))->getString();
} }
} }
@ -106,7 +109,8 @@ namespace MWGui
void EditEffectDialog::editEffect (ESM::ENAMstruct effect) void EditEffectDialog::editEffect (ESM::ENAMstruct effect)
{ {
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effect.mEffectID); const ESM::MagicEffect* magicEffect =
MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectID);
setMagicEffect(magicEffect); setMagicEffect(magicEffect);
@ -333,12 +337,12 @@ namespace MWGui
MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0);
std::pair<std::string, const ESM::Spell*> result = MWBase::Environment::get().getWorld()->createRecord(mSpell); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->createRecord(mSpell);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells(); MWMechanics::Spells& spells = stats.getSpells();
spells.add (result.first); spells.add (spell->mId);
MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0);
@ -360,16 +364,23 @@ namespace MWGui
{ {
float y = 0; float y = 0;
const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore();
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
{ {
float x = 0.5 * it->mMagnMin + it->mMagnMax; float x = 0.5 * it->mMagnMin + it->mMagnMax;
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->mEffectID); const ESM::MagicEffect* effect =
store.get<ESM::MagicEffect>().find(it->mEffectID);
x *= 0.1 * effect->mData.mBaseCost; x *= 0.1 * effect->mData.mBaseCost;
x *= 1 + it->mDuration; x *= 1 + it->mDuration;
x += 0.05 * std::max(1, it->mArea) * effect->mData.mBaseCost; x += 0.05 * std::max(1, it->mArea) * effect->mData.mBaseCost;
float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fEffectCostMult")->getFloat(); float fEffectCostMult =
store.get<ESM::GameSetting>().find("fEffectCostMult")->getFloat();
y += x * fEffectCostMult; y += x * fEffectCostMult;
y = std::max(1.f,y); y = std::max(1.f,y);
@ -386,10 +397,10 @@ namespace MWGui
mMagickaCost->setCaption(boost::lexical_cast<std::string>(int(y))); mMagickaCost->setCaption(boost::lexical_cast<std::string>(int(y)));
float fSpellMakingValueMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellMakingValueMult")->getFloat(); float fSpellMakingValueMult =
store.get<ESM::GameSetting>().find("fSpellMakingValueMult")->getFloat();
/// \todo mercantile int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,int(y) * fSpellMakingValueMult,true);
int price = int(y) * fSpellMakingValueMult;
mPriceLabel->setCaption(boost::lexical_cast<std::string>(int(price))); mPriceLabel->setCaption(boost::lexical_cast<std::string>(int(price)));
@ -424,7 +435,8 @@ 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 = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*it);
// only normal spells count // only normal spells count
if (spell->mData.mType != ESM::Spell::ST_Spell) if (spell->mData.mType != ESM::Spell::ST_Spell)
@ -444,14 +456,14 @@ namespace MWGui
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it)
{ {
mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
ESM::MagicEffect::effectIdToString (*it))->getString()); ESM::MagicEffect::effectIdToString (*it))->getString());
} }
mAvailableEffectsList->adjustSize (); mAvailableEffectsList->adjustSize ();
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it)
{ {
std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( std::string name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
ESM::MagicEffect::effectIdToString (*it))->getString(); ESM::MagicEffect::effectIdToString (*it))->getString();
MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
w->setUserData(*it); w->setUserData(*it);
@ -517,7 +529,8 @@ namespace MWGui
} }
} }
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId); const ESM::MagicEffect* effect =
MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectId);
mAddEffectDialog.newEffect (effect); mAddEffectDialog.newEffect (effect);

View file

@ -4,7 +4,7 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -26,8 +26,11 @@ namespace
{ {
bool sortSpells(const std::string& left, const std::string& right) bool sortSpells(const std::string& left, const std::string& right)
{ {
const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left); const MWWorld::Store<ESM::Spell> &spells =
const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>();
const ESM::Spell* a = spells.find(left);
const ESM::Spell* b = spells.find(right);
int cmp = a->mName.compare(b->mName); int cmp = a->mName.compare(b->mName);
return cmp < 0; return cmp < 0;
@ -139,11 +142,15 @@ namespace MWGui
spellList.push_back(*it); spellList.push_back(*it);
} }
const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore();
std::vector<std::string> powers; std::vector<std::string> powers;
std::vector<std::string>::iterator it = spellList.begin(); std::vector<std::string>::iterator it = spellList.begin();
while (it != spellList.end()) while (it != spellList.end())
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
if (spell->mData.mType == ESM::Spell::ST_Power) if (spell->mData.mType == ESM::Spell::ST_Power)
{ {
powers.push_back(*it); powers.push_back(*it);
@ -170,7 +177,9 @@ namespace MWGui
if (enchantId != "") if (enchantId != "")
{ {
// only add items with "Cast once" or "Cast on use" // only add items with "Cast once" or "Cast on use"
const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId); const ESM::Enchantment* enchant =
esmStore.get<ESM::Enchantment>().find(enchantId);
int type = enchant->mData.mType; int type = enchant->mData.mType;
if (type != ESM::Enchantment::CastOnce if (type != ESM::Enchantment::CastOnce
&& type != ESM::Enchantment::WhenUsed) && type != ESM::Enchantment::WhenUsed)
@ -191,7 +200,7 @@ namespace MWGui
for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it) for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SpellText", MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SpellText",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName); t->setCaption(spell->mName);
@ -211,7 +220,7 @@ namespace MWGui
addGroup("#{sSpells}", "#{sCostChance}"); addGroup("#{sSpells}", "#{sCostChance}");
for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it) for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SpellText", MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SpellText",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName); t->setCaption(spell->mName);
@ -244,7 +253,8 @@ namespace MWGui
{ {
MWWorld::Ptr item = *it; MWWorld::Ptr item = *it;
const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(MWWorld::Class::get(item).getEnchantment(item)); const ESM::Enchantment* enchant =
esmStore.get<ESM::Enchantment>().find(MWWorld::Class::get(item).getEnchantment(item));
// check if the item is currently equipped (will display in a different color) // check if the item is currently equipped (will display in a different color)
bool equipped = false; bool equipped = false;
@ -378,7 +388,9 @@ namespace MWGui
if (MyGUI::InputManager::getInstance().isShiftPressed()) if (MyGUI::InputManager::getInstance().isShiftPressed())
{ {
// delete spell, if allowed // delete spell, if allowed
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mFlags & ESM::Spell::F_Always if (spell->mData.mFlags & ESM::Spell::F_Always
|| spell->mData.mType == ESM::Spell::ST_Power) || spell->mData.mType == ESM::Spell::ST_Power)
{ {

View file

@ -54,10 +54,10 @@ StatsWindow::StatsWindow (MWBase::WindowManager& parWindowManager)
{ 0, 0 } { 0, 0 }
}; };
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
for (int i=0; names[i][0]; ++i) for (int i=0; names[i][0]; ++i)
{ {
setText (names[i][0], store.gameSettings.find (names[i][1])->getString()); setText (names[i][0], store.get<ESM::GameSetting>().find (names[i][1])->getString());
} }
getWidget(mSkillView, "SkillView"); getWidget(mSkillView, "SkillView");
@ -253,7 +253,10 @@ void StatsWindow::onFrame ()
setFactions(PCstats.getFactionRanks()); setFactions(PCstats.getFactionRanks());
setBirthSign(MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); const std::string &signId =
MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
setBirthSign(signId);
if (mChanged) if (mChanged)
updateSkillArea(); updateSkillArea();
@ -357,18 +360,22 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes
continue; continue;
assert(skillId >= 0 && skillId < ESM::Skill::Length); assert(skillId >= 0 && skillId < ESM::Skill::Length);
const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId];
const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second; const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second;
float base = stat.getBase(); float base = stat.getBase();
float modified = stat.getModified(); float modified = stat.getModified();
int progressPercent = (modified - float(static_cast<int>(modified))) * 100; int progressPercent = (modified - float(static_cast<int>(modified))) * 100;
const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId); const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore();
const ESM::Skill* skill = esmStore.get<ESM::Skill>().find(skillId);
assert(skill); assert(skill);
std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId];
const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute); const ESM::Attribute* attr =
esmStore.get<ESM::Attribute>().find(skill->mData.mAttribute);
assert(attr); assert(attr);
std::string state = "normal"; std::string state = "normal";
@ -422,10 +429,14 @@ void StatsWindow::updateSkillArea()
if (!mMiscSkills.empty()) if (!mMiscSkills.empty())
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); MWBase::World *world = MWBase::Environment::get().getWorld();
const MWWorld::ESMStore &store = world->getStore();
const ESM::NPC *player =
world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
// race tooltip // race tooltip
const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); const ESM::Race* playerRace = store.get<ESM::Race>().find(player->mRace);
MyGUI::Widget* raceWidget; MyGUI::Widget* raceWidget;
getWidget(raceWidget, "RaceText"); getWidget(raceWidget, "RaceText");
ToolTips::createRaceToolTip(raceWidget, playerRace); ToolTips::createRaceToolTip(raceWidget, playerRace);
@ -434,11 +445,14 @@ void StatsWindow::updateSkillArea()
// class tooltip // class tooltip
MyGUI::Widget* classWidget; MyGUI::Widget* classWidget;
const ESM::Class& playerClass = MWBase::Environment::get().getWorld()->getPlayer().getClass();
const ESM::Class *playerClass =
store.get<ESM::Class>().find(player->mClass);
getWidget(classWidget, "ClassText"); getWidget(classWidget, "ClassText");
ToolTips::createClassToolTip(classWidget, playerClass); ToolTips::createClassToolTip(classWidget, *playerClass);
getWidget(classWidget, "Class_str"); getWidget(classWidget, "Class_str");
ToolTips::createClassToolTip(classWidget, playerClass); ToolTips::createClassToolTip(classWidget, *playerClass);
if (!mFactions.empty()) if (!mFactions.empty())
{ {
@ -450,7 +464,8 @@ void StatsWindow::updateSkillArea()
FactionList::const_iterator end = mFactions.end(); FactionList::const_iterator end = mFactions.end();
for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it) for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
{ {
const ESM::Faction *faction = store.factions.find(it->first); const ESM::Faction *faction =
store.get<ESM::Faction>().find(it->first);
MyGUI::Widget* w = addItem(faction->mName, coord1, coord2); MyGUI::Widget* w = addItem(faction->mName, coord1, coord2);
std::string text; std::string text;
@ -464,8 +479,8 @@ void StatsWindow::updateSkillArea()
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1]; text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1];
ESM::RankData rankData = faction->mData.mRankData[it->second+1]; ESM::RankData rankData = faction->mData.mRankData[it->second+1];
const ESM::Attribute* attr1 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->mData.mAttribute1); const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute1);
const ESM::Attribute* attr2 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->mData.mAttribute2); const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute2);
assert(attr1 && attr2); assert(attr1 && attr2);
text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute1) text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute1)
@ -501,7 +516,8 @@ void StatsWindow::updateSkillArea()
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2); addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2);
const ESM::BirthSign *sign = store.birthSigns.find(mBirthSignId); const ESM::BirthSign *sign =
store.get<ESM::BirthSign>().find(mBirthSignId);
MyGUI::Widget* w = addItem(sign->mName, coord1, coord2); MyGUI::Widget* w = addItem(sign->mName, coord1, coord2);
ToolTips::createBirthsignToolTip(w, mBirthSignId); ToolTips::createBirthsignToolTip(w, mBirthSignId);

View file

@ -1,7 +1,7 @@
#ifndef MWGUI_STATS_WINDOW_H #ifndef MWGUI_STATS_WINDOW_H
#define MWGUI_STATS_WINDOW_H #define MWGUI_STATS_WINDOW_H
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <sstream> #include <sstream>
#include <set> #include <set>

View file

@ -179,7 +179,9 @@ void ToolTips::onFrame(float frameDuration)
else if (type == "Spell") else if (type == "Spell")
{ {
ToolTipInfo info; ToolTipInfo info;
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find(focus->getUserString("Spell"));
const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(focus->getUserString("Spell"));
info.caption = spell->mName; info.caption = spell->mName;
Widgets::SpellEffectList effects; Widgets::SpellEffectList effects;
std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end(); std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end();
@ -364,11 +366,14 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
if (text.size() > 0 && text[0] == '\n') if (text.size() > 0 && text[0] == '\n')
text.erase(0, 1); text.erase(0, 1);
if(caption.size() > 0 && isalnum(caption[0]))
caption[0] = toupper(caption[0]);
const ESM::Enchantment* enchant = 0; const ESM::Enchantment* enchant = 0;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
if (info.enchant != "") if (info.enchant != "")
{ {
enchant = store.enchants.search(info.enchant); enchant = store.get<ESM::Enchantment>().find(info.enchant);
if (enchant->mData.mType == ESM::Enchantment::CastOnce) if (enchant->mData.mType == ESM::Enchantment::CastOnce)
text += "\n#{sItemCastOnce}"; text += "\n#{sItemCastOnce}";
else if (enchant->mData.mType == ESM::Enchantment::WhenStrikes) else if (enchant->mData.mType == ESM::Enchantment::WhenStrikes)
@ -571,10 +576,15 @@ void ToolTips::createSkillToolTip(MyGUI::Widget* widget, int skillId)
if (skillId == -1) if (skillId == -1)
return; return;
const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; const MWWorld::ESMStore &store =
const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId); MWBase::Environment::get().getWorld()->getStore();
const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId];
const ESM::Skill* skill = store.get<ESM::Skill>().find(skillId);
assert(skill); assert(skill);
const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute);
const ESM::Attribute* attr =
store.get<ESM::Attribute>().find(skill->mData.mAttribute);
assert(attr); assert(attr);
std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId];
@ -607,12 +617,14 @@ void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::str
widget->setUserString("Caption_CenteredCaption", name); widget->setUserString("Caption_CenteredCaption", name);
std::string specText; std::string specText;
// get all skills of this specialisation // get all skills of this specialisation
std::map<int, ESM::Skill> skills = MWBase::Environment::get().getWorld()->getStore().skills.list; const MWWorld::Store<ESM::Skill> &skills =
for (std::map<int, ESM::Skill>::const_iterator it = skills.begin(); MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
it != skills.end(); ++it)
MWWorld::Store<ESM::Skill>::iterator it = skills.begin();
for (; it != skills.end(); ++it)
{ {
if (it->second.mData.mSpecialization == specId) if (it->mData.mSpecialization == specId)
specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->second.mIndex] + "}"; specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->mIndex] + "}";
} }
widget->setUserString("Caption_CenteredCaptionText", specText); widget->setUserString("Caption_CenteredCaptionText", specText);
widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip"); widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip");
@ -621,7 +633,10 @@ void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::str
void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId) void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId)
{ {
const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.find(birthsignId); const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore();
const ESM::BirthSign *sign = store.get<ESM::BirthSign>().find(birthsignId);
widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipType", "Layout");
widget->setUserString("ToolTipLayout", "BirthSignToolTip"); widget->setUserString("ToolTipLayout", "BirthSignToolTip");
@ -640,7 +655,7 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string&
for (; it != end; ++it) for (; it != end; ++it)
{ {
const std::string &spellId = *it; const std::string &spellId = *it;
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search(spellId); const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId);
if (!spell) if (!spell)
continue; // Skip spells which cannot be found continue; // Skip spells which cannot be found
ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType); ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType);
@ -655,7 +670,11 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string&
spells.push_back(spellId); spells.push_back(spellId);
} }
struct{ const std::vector<std::string> &spells; std::string label; } categories[3] = { struct {
const std::vector<std::string> &spells;
std::string label;
}
categories[3] = {
{abilities, "sBirthsignmenu1"}, {abilities, "sBirthsignmenu1"},
{powers, "sPowers"}, {powers, "sPowers"},
{spells, "sBirthsignmenu2"} {spells, "sBirthsignmenu2"}
@ -672,7 +691,7 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string&
const std::string &spellId = *it; const std::string &spellId = *it;
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search(spellId); const ESM::Spell *spell = store.get<ESM::Spell>().find(spellId);
text += "\n#BF9959" + spell->mName; text += "\n#BF9959" + spell->mName;
} }
} }
@ -711,7 +730,8 @@ void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playe
void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id) void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id)
{ {
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld ()->getStore ().magicEffects.find(id); const ESM::MagicEffect* effect =
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(id);
const std::string &name = ESM::MagicEffect::effectIdToString (id); const std::string &name = ESM::MagicEffect::effectIdToString (id);
std::string icon = effect->mIcon; std::string icon = effect->mIcon;

View file

@ -6,10 +6,17 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/manualref.hpp" #include "../mwworld/manualref.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwworld/player.hpp"
#include "inventorywindow.hpp" #include "inventorywindow.hpp"
namespace MWGui namespace MWGui
@ -52,6 +59,8 @@ namespace MWGui
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked);
mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked); mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked);
mIncreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonClicked);
mDecreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonClicked);
setCoord(400, 0, 400, 300); setCoord(400, 0, 400, 300);
@ -63,6 +72,7 @@ namespace MWGui
setTitle(MWWorld::Class::get(actor).getName(actor)); setTitle(MWWorld::Class::get(actor).getName(actor));
mCurrentBalance = 0; mCurrentBalance = 0;
mCurrentMerchantOffer = 0;
mWindowManager.getInventoryWindow()->startTrade(); mWindowManager.getInventoryWindow()->startTrade();
@ -107,10 +117,14 @@ namespace MWGui
bool goldFound = false; bool goldFound = false;
MWWorld::Ptr gold; MWWorld::Ptr gold;
MWWorld::ContainerStore& playerStore = mWindowManager.getInventoryWindow()->getContainerStore(); MWWorld::ContainerStore& playerStore = mWindowManager.getInventoryWindow()->getContainerStore();
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
for (MWWorld::ContainerStoreIterator it = playerStore.begin(); for (MWWorld::ContainerStoreIterator it = playerStore.begin();
it != playerStore.end(); ++it) it != playerStore.end(); ++it)
{ {
if (MWWorld::Class::get(*it).getName(*it) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) if (MWWorld::Class::get(*it).getName(*it) == gmst.find("sGold")->getString())
{ {
goldFound = true; goldFound = true;
gold = *it; gold = *it;
@ -131,6 +145,9 @@ namespace MWGui
void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender) void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender)
{ {
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
// were there any items traded at all? // were there any items traded at all?
MWWorld::ContainerStore& playerBought = mWindowManager.getInventoryWindow()->getBoughtItems(); MWWorld::ContainerStore& playerBought = mWindowManager.getInventoryWindow()->getBoughtItems();
MWWorld::ContainerStore& merchantBought = getBoughtItems(); MWWorld::ContainerStore& merchantBought = getBoughtItems();
@ -156,15 +173,15 @@ namespace MWGui
if (mPtr.getTypeName() == typeid(ESM::NPC).name()) if (mPtr.getTypeName() == typeid(ESM::NPC).name())
{ {
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
if (ref->base->mNpdt52.mGold == -10) if (ref->mBase->mNpdt52.mGold == -10)
merchantgold = ref->base->mNpdt12.mGold; merchantgold = ref->mBase->mNpdt12.mGold;
else else
merchantgold = ref->base->mNpdt52.mGold; merchantgold = ref->mBase->mNpdt52.mGold;
} }
else // ESM::Creature else // ESM::Creature
{ {
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
merchantgold = ref->base->mData.mGold; merchantgold = ref->mBase->mData.mGold;
} }
if (mCurrentBalance > 0 && merchantgold < mCurrentBalance) if (mCurrentBalance > 0 && merchantgold < mCurrentBalance)
{ {
@ -174,6 +191,59 @@ namespace MWGui
return; return;
} }
if(mCurrentBalance > mCurrentMerchantOffer)
{
//if npc is a creature: reject (no haggle)
if (mPtr.getTypeName() != typeid(ESM::NPC).name())
{
MWBase::Environment::get().getWindowManager()->
messageBox("#{sNotifyMessage9}", std::vector<std::string>());
return;
}
int a = abs(mCurrentMerchantOffer);
int b = abs(mCurrentBalance);
int d = 0;
if (mCurrentMerchantOffer<0) d = int(100 * (a - b) / a);
else d = int(100 * (b - a) / a);
float clampedDisposition = std::max<int>(0,std::min<int>(int(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)
+ MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange()),100));
MWMechanics::NpcStats sellerSkill = MWWorld::Class::get(mPtr).getNpcStats(mPtr);
MWMechanics::CreatureStats sellerStats = MWWorld::Class::get(mPtr).getCreatureStats(mPtr);
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr);
float a1 = std::min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f);
float b1 = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f);
float c1 = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f);
float d1 = std::min(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f);
float e1 = std::min(0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f);
float f1 = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f);
float pcTerm = (clampedDisposition - 50 + a1 + b1 + c1) * playerStats.getFatigueTerm();
float npcTerm = (d1 + e1 + f1) * sellerStats.getFatigueTerm();
float x = gmst.find("fBargainOfferMulti")->getFloat() * d + gmst.find("fBargainOfferBase")->getFloat();
if (mCurrentMerchantOffer<0) x += abs(int(pcTerm - npcTerm));
else x += abs(int(npcTerm - pcTerm));
int roll = std::rand()%100 + 1;
if(roll > x) //trade refused
{
MWBase::Environment::get().getWindowManager()->
messageBox("#{sNotifyMessage9}", std::vector<std::string>());
int iBarterFailDisposition = gmst.find("iBarterFailDisposition")->getInt();
MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterFailDisposition);
return;
}
}
int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt();
MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition);
// success! make the item transfer. // success! make the item transfer.
transferBoughtItems(); transferBoughtItems();
mWindowManager.getInventoryWindow()->transferBoughtItems(); mWindowManager.getInventoryWindow()->transferBoughtItems();
@ -198,6 +268,20 @@ namespace MWGui
mWindowManager.removeGuiMode(GM_Barter); mWindowManager.removeGuiMode(GM_Barter);
} }
void TradeWindow::onIncreaseButtonClicked(MyGUI::Widget* _sender)
{
if(mCurrentBalance<=-1) mCurrentBalance -= 1;
if(mCurrentBalance>=1) mCurrentBalance += 1;
updateLabels();
}
void TradeWindow::onDecreaseButtonClicked(MyGUI::Widget* _sender)
{
if(mCurrentBalance<-1) mCurrentBalance += 1;
if(mCurrentBalance>1) mCurrentBalance -= 1;
updateLabels();
}
void TradeWindow::updateLabels() void TradeWindow::updateLabels()
{ {
mPlayerGold->setCaptionWithReplacing("#{sYourGold} " + boost::lexical_cast<std::string>(mWindowManager.getInventoryWindow()->getPlayerGold())); mPlayerGold->setCaptionWithReplacing("#{sYourGold} " + boost::lexical_cast<std::string>(mWindowManager.getInventoryWindow()->getPlayerGold()));
@ -217,15 +301,15 @@ namespace MWGui
if (mPtr.getTypeName() == typeid(ESM::NPC).name()) if (mPtr.getTypeName() == typeid(ESM::NPC).name())
{ {
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
if (ref->base->mNpdt52.mGold == -10) if (ref->mBase->mNpdt52.mGold == -10)
merchantgold = ref->base->mNpdt12.mGold; merchantgold = ref->mBase->mNpdt12.mGold;
else else
merchantgold = ref->base->mNpdt52.mGold; merchantgold = ref->mBase->mNpdt52.mGold;
} }
else // ESM::Creature else // ESM::Creature
{ {
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
merchantgold = ref->base->mData.mGold; merchantgold = ref->mBase->mData.mGold;
} }
mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(merchantgold)); mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(merchantgold));
@ -261,14 +345,14 @@ namespace MWGui
if (mPtr.getTypeName() == typeid(ESM::NPC).name()) if (mPtr.getTypeName() == typeid(ESM::NPC).name())
{ {
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
if (ref->base->mHasAI) if (ref->mBase->mHasAI)
services = ref->base->mAiData.mServices; services = ref->mBase->mAiData.mServices;
} }
else if (mPtr.getTypeName() == typeid(ESM::Creature).name()) else if (mPtr.getTypeName() == typeid(ESM::Creature).name())
{ {
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
if (ref->base->mHasAI) if (ref->mBase->mHasAI)
services = ref->base->mAiData.mServices; services = ref->mBase->mAiData.mServices;
} }
/// \todo what about potions, there doesn't seem to be a flag for them?? /// \todo what about potions, there doesn't seem to be a flag for them??
@ -316,19 +400,17 @@ namespace MWGui
void TradeWindow::sellToNpc(MWWorld::Ptr item, int count) void TradeWindow::sellToNpc(MWWorld::Ptr item, int count)
{ {
/// \todo price adjustment depending on merchantile skill
mCurrentBalance -= MWWorld::Class::get(item).getValue(item) * count;
mCurrentBalance -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true);
mCurrentMerchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true);
updateLabels(); updateLabels();
} }
void TradeWindow::buyFromNpc(MWWorld::Ptr item, int count) void TradeWindow::buyFromNpc(MWWorld::Ptr item, int count)
{ {
/// \todo price adjustment depending on merchantile skill
mCurrentBalance += MWWorld::Class::get(item).getValue(item) * count;
mCurrentBalance += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false);
mCurrentMerchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false);
updateLabels(); updateLabels();
} }

View file

@ -55,11 +55,14 @@ namespace MWGui
MyGUI::TextBox* mMerchantGold; MyGUI::TextBox* mMerchantGold;
int mCurrentBalance; int mCurrentBalance;
int mCurrentMerchantOffer;
void onWindowResize(MyGUI::Window* _sender); void onWindowResize(MyGUI::Window* _sender);
void onFilterChanged(MyGUI::Widget* _sender); void onFilterChanged(MyGUI::Widget* _sender);
void onOfferButtonClicked(MyGUI::Widget* _sender); void onOfferButtonClicked(MyGUI::Widget* _sender);
void onCancelButtonClicked(MyGUI::Widget* _sender); void onCancelButtonClicked(MyGUI::Widget* _sender);
void onIncreaseButtonClicked(MyGUI::Widget* _sender);
void onDecreaseButtonClicked(MyGUI::Widget* _sender);
// don't show items that the NPC has equipped in his trade-window. // don't show items that the NPC has equipped in his trade-window.
virtual bool ignoreEquippedItems() { return true; } virtual bool ignoreEquippedItems() { return true; }

View file

@ -7,6 +7,7 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
@ -73,10 +74,13 @@ namespace MWGui
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer (); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ();
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
for (int i=0; i<3; ++i) for (int i=0; i<3; ++i)
{ {
/// \todo mercantile skill int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer
int price = pcStats.getSkill (bestSkills[i].first).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (); (mPtr,pcStats.getSkill (bestSkills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true);
std::string skin = (price > mWindowManager.getInventoryWindow ()->getPlayerGold ()) ? "SandTextGreyedOut" : "SandTextButton"; std::string skin = (price > mWindowManager.getInventoryWindow ()->getPlayerGold ()) ? "SandTextGreyedOut" : "SandTextButton";
@ -113,8 +117,11 @@ namespace MWGui
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer (); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ();
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
/// \todo mercantile skill const MWWorld::ESMStore &store =
int price = pcStats.getSkill (skillId).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (); MWBase::Environment::get().getWorld()->getStore();
int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt ();
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
if (mWindowManager.getInventoryWindow()->getPlayerGold()<price) if (mWindowManager.getInventoryWindow()->getPlayerGold()<price)
return; return;
@ -128,8 +135,9 @@ namespace MWGui
// increase skill // increase skill
MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>();
const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find (
playerRef->base->mClass); const ESM::Class *class_ =
store.get<ESM::Class>().find(playerRef->mBase->mClass);
pcStats.increaseSkill (skillId, *class_, true); pcStats.increaseSkill (skillId, *class_, true);
// remove gold // remove gold

View file

@ -54,21 +54,25 @@ namespace MWGui
{ {
int price = 0; int price = 0;
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
if(interior) if(interior)
{ {
price = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fMagesGuildTravel")->getFloat(); price = gmst.find("fMagesGuildTravel")->getFloat();
} }
else else
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
ESM::Position PlayerPos = player.getRefData().getPosition(); ESM::Position PlayerPos = player.getRefData().getPosition();
float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) );
price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat(); price = d/gmst.find("fTravelMult")->getFloat();
} }
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default);
mCurrentY += sLineHeight; mCurrentY += sLineHeight;
/// \todo price adjustment depending on merchantile skill
if(interior) if(interior)
toAdd->setUserString("interior","y"); toAdd->setUserString("interior","y");
else else
@ -104,15 +108,15 @@ namespace MWGui
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
for(unsigned int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++) for(unsigned int i = 0;i<mPtr.get<ESM::NPC>()->mBase->mTransport.size();i++)
{ {
std::string cellname = mPtr.get<ESM::NPC>()->base->mTransport[i].mCellName; std::string cellname = mPtr.get<ESM::NPC>()->mBase->mTransport[i].mCellName;
bool interior = true; bool interior = true;
int x,y; int x,y;
MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[0], MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos.pos[0],
mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[1],x,y); mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos.pos[1],x,y);
if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->mName; interior= false;} if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->mCell->mName; interior= false;}
addDestination(cellname,mPtr.get<ESM::NPC>()->base->mTransport[i].mPos,interior); addDestination(cellname,mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos,interior);
} }
updateLabels(); updateLabels();
@ -142,7 +146,7 @@ namespace MWGui
cell = MWBase::Environment::get().getWorld()->getExterior(x,y); cell = MWBase::Environment::get().getWorld()->getExterior(x,y);
ESM::Position PlayerPos = player.getRefData().getPosition(); ESM::Position PlayerPos = player.getRefData().getPosition();
float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) );
int time = int(d /MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelTimeMult")->getFloat()); int time = int(d /MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTravelTimeMult")->getFloat());
for(int i = 0;i < time;i++) for(int i = 0;i < time;i++)
{ {
MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats (); MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats ();

View file

@ -120,9 +120,10 @@ namespace MWGui
int hour = MWBase::Environment::get().getWorld ()->getTimeStamp ().getHour (); int hour = MWBase::Environment::get().getWorld ()->getTimeStamp ().getHour ();
bool pm = hour >= 12; bool pm = hour >= 12;
if (hour >= 13) hour -= 12; if (hour >= 13) hour -= 12;
if (hour == 0) hour = 12;
std::string dateTimeText = std::string dateTimeText =
boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getDay ()+1) + " " boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getDay ()) + " "
+ month + " (#{sDay} " + boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getTimeStamp ().getDay ()+1) + month + " (#{sDay} " + boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getTimeStamp ().getDay ()+1)
+ ") " + boost::lexical_cast<std::string>(hour) + " " + (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}"); + ") " + boost::lexical_cast<std::string>(hour) + " " + (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}");

View file

@ -2,12 +2,12 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include "components/esm_store/store.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/esmstore.hpp"
#undef min #undef min
#undef max #undef max
@ -228,8 +228,10 @@ void MWSpell::setSpellId(const std::string &spellId)
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags)
{ {
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store =
const ESM::Spell *spell = store.spells.search(mId); MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell *spell = store.get<ESM::Spell>().search(mId);
MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
MWSpellEffectPtr effect = nullptr; MWSpellEffectPtr effect = nullptr;
@ -259,8 +261,10 @@ void MWSpell::updateWidgets()
{ {
if (mSpellNameWidget && mWindowManager) if (mSpellNameWidget && mWindowManager)
{ {
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store =
const ESM::Spell *spell = store.spells.search(mId); MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell *spell = store.get<ESM::Spell>().search(mId);
if (spell) if (spell)
static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->mName); static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->mName);
else else
@ -386,8 +390,14 @@ void MWSpellEffect::setSpellEffect(const SpellEffectParams& params)
void MWSpellEffect::updateWidgets() void MWSpellEffect::updateWidgets()
{ {
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); if (!mWindowManager)
const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); return;
const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore();
const ESM::MagicEffect *magicEffect =
store.get<ESM::MagicEffect>().search(mEffectParams.mEffectID);
assert(magicEffect); assert(magicEffect);
assert(mWindowManager); assert(mWindowManager);

View file

@ -1,7 +1,7 @@
#ifndef MWGUI_WIDGETS_H #ifndef MWGUI_WIDGETS_H
#define MWGUI_WIDGETS_H #define MWGUI_WIDGETS_H
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <MyGUI.h> #include <MyGUI.h>

View file

@ -83,7 +83,6 @@ WindowManager::WindowManager(
, mSpellCreationDialog(NULL) , mSpellCreationDialog(NULL)
, mEnchantingDialog(NULL) , mEnchantingDialog(NULL)
, mTrainingWindow(NULL) , mTrainingWindow(NULL)
, mPlayerClass()
, mPlayerName() , mPlayerName()
, mPlayerRaceId() , mPlayerRaceId()
, mPlayerAttributes() , mPlayerAttributes()
@ -499,8 +498,7 @@ void WindowManager::setValue (const std::string& id, int value)
void WindowManager::setPlayerClass (const ESM::Class &class_) void WindowManager::setPlayerClass (const ESM::Class &class_)
{ {
mPlayerClass = class_; mStatsWindow->setValue("class", class_.mName);
mStatsWindow->setValue("class", mPlayerClass.mName);
} }
void WindowManager::configureSkills (const SkillList& major, const SkillList& minor) void WindowManager::configureSkills (const SkillList& major, const SkillList& minor)
@ -554,7 +552,9 @@ int WindowManager::readPressedButton ()
std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_) std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
{ {
const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(id); const ESM::GameSetting *setting =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search(id);
if (setting && setting->mType == ESM::VT_String) if (setting && setting->mType == ESM::VT_String)
return setting->getString(); return setting->getString();
return default_; return default_;
@ -582,6 +582,8 @@ void WindowManager::onFrame (float frameDuration)
mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition()); mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
} }
mDialogueWindow->onFrame();
mInventoryWindow->onFrame(); mInventoryWindow->onFrame();
mStatsWindow->onFrame(); mStatsWindow->onFrame();
@ -604,17 +606,18 @@ void WindowManager::onFrame (float frameDuration)
void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
{ {
if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) if (cell->mCell->isExterior())
{ {
std::string name; std::string name;
if (cell->cell->mName != "") if (cell->mCell->mName != "")
{ {
name = cell->cell->mName; name = cell->mCell->mName;
mMap->addVisitedLocation (name, cell->cell->getGridX (), cell->cell->getGridY ()); mMap->addVisitedLocation (name, cell->mCell->getGridX (), cell->mCell->getGridY ());
} }
else else
{ {
const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->mRegion); const ESM::Region* region =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search(cell->mCell->mRegion);
if (region) if (region)
name = region->mName; name = region->mName;
else else
@ -626,15 +629,15 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
mMap->setCellPrefix("Cell"); mMap->setCellPrefix("Cell");
mHud->setCellPrefix("Cell"); mHud->setCellPrefix("Cell");
mMap->setActiveCell( cell->cell->mData.mX, cell->cell->mData.mY ); mMap->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() );
mHud->setActiveCell( cell->cell->mData.mX, cell->cell->mData.mY ); mHud->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() );
} }
else else
{ {
mMap->setCellName( cell->cell->mName ); mMap->setCellName( cell->mCell->mName );
mHud->setCellName( cell->cell->mName ); mHud->setCellName( cell->mCell->mName );
mMap->setCellPrefix( cell->cell->mName ); mMap->setCellPrefix( cell->mCell->mName );
mHud->setCellPrefix( cell->cell->mName ); mHud->setCellPrefix( cell->mCell->mName );
} }
} }
@ -717,7 +720,9 @@ void WindowManager::setDragDrop(bool dragDrop)
void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result) void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result)
{ {
const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.find(_tag); const ESM::GameSetting *setting =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(_tag);
if (setting && setting->mType == ESM::VT_String) if (setting && setting->mType == ESM::VT_String)
_result = setting->getString(); _result = setting->getString();
else else
@ -769,6 +774,13 @@ void WindowManager::pushGuiMode(GuiMode mode)
if (mode==GM_Inventory && mAllowed==GW_None) if (mode==GM_Inventory && mAllowed==GW_None)
return; return;
// If this mode already exists somewhere in the stack, just bring it to the front.
if (std::find(mGuiModes.begin(), mGuiModes.end(), mode) != mGuiModes.end())
{
mGuiModes.erase(std::find(mGuiModes.begin(), mGuiModes.end(), mode));
}
mGuiModes.push_back(mode); mGuiModes.push_back(mode);
bool gameMode = !isGuiMode(); bool gameMode = !isGuiMode();
@ -808,7 +820,10 @@ void WindowManager::removeGuiMode(GuiMode mode)
void WindowManager::setSelectedSpell(const std::string& spellId, int successChancePercent) void WindowManager::setSelectedSpell(const std::string& spellId, int successChancePercent)
{ {
mHud->setSelectedSpell(spellId, successChancePercent); mHud->setSelectedSpell(spellId, successChancePercent);
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId);
const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
mSpellWindow->setTitle(spell->mName); mSpellWindow->setTitle(spell->mName);
} }

View file

@ -261,7 +261,6 @@ namespace MWGui
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed. /// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
// Various stats about player as needed by window manager // Various stats about player as needed by window manager
ESM::Class mPlayerClass;
std::string mPlayerName; std::string mPlayerName;
std::string mPlayerRaceId; std::string mPlayerRaceId;
std::map<int, MWMechanics::Stat<int> > mPlayerAttributes; std::map<int, MWMechanics::Stat<int> > mPlayerAttributes;

View file

@ -9,7 +9,7 @@
#include <components/esm/loadmgef.hpp> #include <components/esm/loadmgef.hpp>
#include <components/esm/loadskil.hpp> #include <components/esm/loadskil.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -86,7 +86,7 @@ namespace MWMechanics
if (effects.second) if (effects.second)
{ {
const ESM::MagicEffect *magicEffect = const ESM::MagicEffect *magicEffect =
MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
iter->mEffectID); iter->mEffectID);
if (iter->mDuration==0) if (iter->mDuration==0)
@ -114,18 +114,18 @@ namespace MWMechanics
std::pair<ESM::EffectList, bool> ActiveSpells::getEffectList (const std::string& id) const std::pair<ESM::EffectList, bool> ActiveSpells::getEffectList (const std::string& id) const
{ {
if (const ESM::Spell *spell = if (const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().spells.search (id)) MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search (id))
return std::make_pair (spell->mEffects, false); return std::make_pair (spell->mEffects, false);
if (const ESM::Potion *potion = if (const ESM::Potion *potion =
MWBase::Environment::get().getWorld()->getStore().potions.search (id)) MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>().search (id))
return std::make_pair (potion->mEffects, false); return std::make_pair (potion->mEffects, false);
if (const ESM::Ingredient *ingredient = if (const ESM::Ingredient *ingredient =
MWBase::Environment::get().getWorld()->getStore().ingreds.search (id)) MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>().search (id))
{ {
const ESM::MagicEffect *magicEffect = const ESM::MagicEffect *magicEffect =
MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
ingredient->mData.mEffectID[0]); ingredient->mData.mEffectID[0]);
ESM::ENAMstruct effect; ESM::ENAMstruct effect;

View file

@ -7,7 +7,7 @@
#include <components/esm/loadnpc.hpp> #include <components/esm/loadnpc.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
@ -101,11 +101,11 @@ namespace MWMechanics
health.setCurrent (health.getCurrent() + 0.1 * endurance); health.setCurrent (health.getCurrent() + 0.1 * endurance);
stats.setHealth (health); stats.setHealth (health);
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
float fFatigueReturnBase = store.gameSettings.find("fFatigueReturnBase")->getFloat (); float fFatigueReturnBase = store.get<ESM::GameSetting>().find("fFatigueReturnBase")->getFloat ();
float fFatigueReturnMult = store.gameSettings.find("fFatigueReturnMult")->getFloat (); float fFatigueReturnMult = store.get<ESM::GameSetting>().find("fFatigueReturnMult")->getFloat ();
float fEndFatigueMult = store.gameSettings.find("fEndFatigueMult")->getFloat (); float fEndFatigueMult = store.get<ESM::GameSetting>().find("fEndFatigueMult")->getFloat ();
float capacity = MWWorld::Class::get(ptr).getCapacity(ptr); float capacity = MWWorld::Class::get(ptr).getCapacity(ptr);
float encumbrance = MWWorld::Class::get(ptr).getEncumbrance(ptr); float encumbrance = MWWorld::Class::get(ptr).getEncumbrance(ptr);
@ -122,7 +122,7 @@ namespace MWMechanics
if (!stunted) if (!stunted)
{ {
float fRestMagicMult = store.gameSettings.find("fRestMagicMult")->getFloat (); float fRestMagicMult = store.get<ESM::GameSetting>().find("fRestMagicMult")->getFloat ();
DynamicStat<float> magicka = stats.getMagicka(); DynamicStat<float> magicka = stats.getMagicka();
magicka.setCurrent (magicka.getCurrent() magicka.setCurrent (magicka.getCurrent()

View file

@ -13,11 +13,11 @@
#include <components/esm/loadgmst.hpp> #include <components/esm/loadgmst.hpp>
#include <components/esm/loadmgef.hpp> #include <components/esm/loadmgef.hpp>
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
@ -38,11 +38,11 @@ std::set<MWMechanics::EffectKey> MWMechanics::Alchemy::listEffects() const
const MWWorld::LiveCellRef<ESM::Ingredient> *ingredient = iter->get<ESM::Ingredient>(); const MWWorld::LiveCellRef<ESM::Ingredient> *ingredient = iter->get<ESM::Ingredient>();
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
if (ingredient->base->mData.mEffectID[i]!=-1) if (ingredient->mBase->mData.mEffectID[i]!=-1)
{ {
EffectKey key ( EffectKey key (
ingredient->base->mData.mEffectID[i], ingredient->base->mData.mSkills[i]!=-1 ? ingredient->mBase->mData.mEffectID[i], ingredient->mBase->mData.mSkills[i]!=-1 ?
ingredient->base->mData.mSkills[i] : ingredient->base->mData.mAttributes[i]); ingredient->mBase->mData.mSkills[i] : ingredient->mBase->mData.mAttributes[i]);
++effects[key]; ++effects[key];
} }
@ -77,9 +77,9 @@ void MWMechanics::Alchemy::applyTools (int flags, float& value) const
else else
return; return;
float toolQuality = setup==1 || setup==2 ? mTools[tool].get<ESM::Apparatus>()->base->mData.mQuality : 0; float toolQuality = setup==1 || setup==2 ? mTools[tool].get<ESM::Apparatus>()->mBase->mData.mQuality : 0;
float calcinatorQuality = setup==1 || setup==3 ? float calcinatorQuality = setup==1 || setup==3 ?
mTools[ESM::Apparatus::Calcinator].get<ESM::Apparatus>()->base->mData.mQuality : 0; mTools[ESM::Apparatus::Calcinator].get<ESM::Apparatus>()->mBase->mData.mQuality : 0;
float quality = 1; float quality = 1;
@ -130,30 +130,30 @@ void MWMechanics::Alchemy::updateEffects()
// general alchemy factor // general alchemy factor
float x = getChance(); float x = getChance();
x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->base->mData.mQuality; x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->mBase->mData.mQuality;
x *= MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionStrengthMult")->getFloat(); x *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fPotionStrengthMult")->getFloat();
// value // value
mValue = static_cast<int> ( mValue = static_cast<int> (
x * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("iAlchemyMod")->getFloat()); x * MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("iAlchemyMod")->getFloat());
// build quantified effect list // build quantified effect list
for (std::set<EffectKey>::const_iterator iter (effects.begin()); iter!=effects.end(); ++iter) for (std::set<EffectKey>::const_iterator iter (effects.begin()); iter!=effects.end(); ++iter)
{ {
const ESM::MagicEffect *magicEffect = const ESM::MagicEffect *magicEffect =
MWBase::Environment::get().getWorld()->getStore().magicEffects.find (iter->mId); MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (iter->mId);
if (magicEffect->mData.mBaseCost<=0) if (magicEffect->mData.mBaseCost<=0)
throw std::runtime_error ("invalid base cost for magic effect " + iter->mId); throw std::runtime_error ("invalid base cost for magic effect " + iter->mId);
float fPotionT1MagMul = float fPotionT1MagMul =
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionT1MagMult")->getFloat(); MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fPotionT1MagMult")->getFloat();
if (fPotionT1MagMul<=0) if (fPotionT1MagMul<=0)
throw std::runtime_error ("invalid gmst: fPotionT1MagMul"); throw std::runtime_error ("invalid gmst: fPotionT1MagMul");
float fPotionT1DurMult = float fPotionT1DurMult =
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionT1DurMult")->getFloat(); MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fPotionT1DurMult")->getFloat();
if (fPotionT1DurMult<=0) if (fPotionT1DurMult<=0)
throw std::runtime_error ("invalid gmst: fPotionT1DurMult"); throw std::runtime_error ("invalid gmst: fPotionT1DurMult");
@ -192,18 +192,20 @@ void MWMechanics::Alchemy::updateEffects()
const ESM::Potion *MWMechanics::Alchemy::getRecord() const const ESM::Potion *MWMechanics::Alchemy::getRecord() const
{ {
for (ESMS::RecListWithIDT<ESM::Potion>::MapType::const_iterator iter ( const MWWorld::Store<ESM::Potion> &potions =
MWBase::Environment::get().getWorld()->getStore().potions.list.begin()); MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>();
iter!=MWBase::Environment::get().getWorld()->getStore().potions.list.end(); ++iter)
MWWorld::Store<ESM::Potion>::iterator iter = potions.begin();
for (; iter != potions.end(); ++iter)
{ {
if (iter->second.mEffects.mList.size()!=mEffects.size()) if (iter->mEffects.mList.size() != mEffects.size())
continue; continue;
bool mismatch = false; bool mismatch = false;
for (int i=0; i<static_cast<int> (iter->second.mEffects.mList.size()); ++iter) for (int i=0; i<static_cast<int> (iter->mEffects.mList.size()); ++iter)
{ {
const ESM::ENAMstruct& first = iter->second.mEffects.mList[i]; const ESM::ENAMstruct& first = iter->mEffects.mList[i];
const ESM::ENAMstruct& second = mEffects[i]; const ESM::ENAMstruct& second = mEffects[i];
if (first.mEffectID!=second.mEffectID || if (first.mEffectID!=second.mEffectID ||
@ -221,7 +223,7 @@ const ESM::Potion *MWMechanics::Alchemy::getRecord() const
} }
if (!mismatch) if (!mismatch)
return &iter->second; return &(*iter);
} }
return 0; return 0;
@ -258,7 +260,7 @@ void MWMechanics::Alchemy::addPotion (const std::string& name)
for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter)
if (!iter->isEmpty()) if (!iter->isEmpty())
newRecord.mData.mWeight += iter->get<ESM::Ingredient>()->base->mData.mWeight; newRecord.mData.mWeight += iter->get<ESM::Ingredient>()->mBase->mData.mWeight;
newRecord.mData.mWeight /= countIngredients(); newRecord.mData.mWeight /= countIngredients();
@ -277,7 +279,7 @@ void MWMechanics::Alchemy::addPotion (const std::string& name)
newRecord.mEffects.mList = mEffects; newRecord.mEffects.mList = mEffects;
record = MWBase::Environment::get().getWorld()->createRecord (newRecord).second; record = MWBase::Environment::get().getWorld()->createRecord (newRecord);
} }
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), record->mId); MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
@ -332,13 +334,13 @@ void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc)
{ {
MWWorld::LiveCellRef<ESM::Apparatus>* ref = iter->get<ESM::Apparatus>(); MWWorld::LiveCellRef<ESM::Apparatus>* ref = iter->get<ESM::Apparatus>();
int type = ref->base->mData.mType; int type = ref->mBase->mData.mType;
if (type<0 || type>=static_cast<int> (mTools.size())) if (type<0 || type>=static_cast<int> (mTools.size()))
throw std::runtime_error ("invalid apparatus type"); throw std::runtime_error ("invalid apparatus type");
if (!mTools[type].isEmpty()) if (!mTools[type].isEmpty())
if (ref->base->mData.mQuality<=mTools[type].get<ESM::Apparatus>()->base->mData.mQuality) if (ref->mBase->mData.mQuality<=mTools[type].get<ESM::Apparatus>()->mBase->mData.mQuality)
continue; continue;
mTools[type] = *iter; mTools[type] = *iter;

View file

@ -2,7 +2,7 @@
#include <algorithm> #include <algorithm>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -41,10 +41,11 @@ namespace MWMechanics
float normalised = max==0 ? 1 : std::max (0.0f, static_cast<float> (current)/max); float normalised = max==0 ? 1 : std::max (0.0f, static_cast<float> (current)/max);
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
return store.gameSettings.find ("fFatigueBase")->getFloat() return gmst.find ("fFatigueBase")->getFloat()
- store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised); - gmst.find ("fFatigueMult")->getFloat() * (1-normalised);
} }
const Stat<int> &CreatureStats::getAttribute(int index) const const Stat<int> &CreatureStats::getAttribute(int index) const
@ -231,4 +232,14 @@ namespace MWMechanics
mDead = false; mDead = false;
} }
} }
bool CreatureStats::hasCommonDisease() const
{
return mSpells.hasCommonDisease();
}
bool CreatureStats::hasBlightDisease() const
{
return mSpells.hasBlightDisease();
}
} }

View file

@ -109,6 +109,10 @@ namespace MWMechanics
bool isDead() const; bool isDead() const;
void resurrect(); void resurrect();
bool hasCommonDisease() const;
bool hasBlightDisease() const;
}; };
} }

View file

@ -1,11 +1,12 @@
#include "mechanicsmanagerimp.hpp" #include "mechanicsmanagerimp.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
@ -19,7 +20,7 @@ namespace MWMechanics
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
const ESM::NPC *player = ptr.get<ESM::NPC>()->base; const ESM::NPC *player = ptr.get<ESM::NPC>()->mBase;
// reset // reset
creatureStats.setLevel(player->mNpdt52.mLevel); creatureStats.setLevel(player->mNpdt52.mLevel);
@ -37,15 +38,17 @@ namespace MWMechanics
creatureStats.getAttribute(5).setBase (player->mNpdt52.mEndurance); creatureStats.getAttribute(5).setBase (player->mNpdt52.mEndurance);
creatureStats.getAttribute(6).setBase (player->mNpdt52.mPersonality); creatureStats.getAttribute(6).setBase (player->mNpdt52.mPersonality);
creatureStats.getAttribute(7).setBase (player->mNpdt52.mLuck); creatureStats.getAttribute(7).setBase (player->mNpdt52.mLuck);
const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore();
// race // race
if (mRaceSelected) if (mRaceSelected)
{ {
const ESM::Race *race = const ESM::Race *race =
MWBase::Environment::get().getWorld()->getStore().races.find ( esmStore.get<ESM::Race>().find(player->mRace);
MWBase::Environment::get().getWorld()->getPlayer().getRace());
bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale(); bool male = (player->mFlags & ESM::NPC::Female) == 0;
for (int i=0; i<8; ++i) for (int i=0; i<8; ++i)
{ {
@ -88,11 +91,13 @@ namespace MWMechanics
} }
// birthsign // birthsign
if (!MWBase::Environment::get().getWorld()->getPlayer().getBirthsign().empty()) const std::string &signId =
MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
if (!signId.empty())
{ {
const ESM::BirthSign *sign = const ESM::BirthSign *sign =
MWBase::Environment::get().getWorld()->getStore().birthSigns.find ( esmStore.get<ESM::BirthSign>().find(signId);
MWBase::Environment::get().getWorld()->getPlayer().getBirthsign());
for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin()); for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin());
iter!=sign->mPowers.mList.end(); ++iter) iter!=sign->mPowers.mList.end(); ++iter)
@ -104,11 +109,12 @@ namespace MWMechanics
// class // class
if (mClassSelected) if (mClassSelected)
{ {
const ESM::Class& class_ = MWBase::Environment::get().getWorld()->getPlayer().getClass(); const ESM::Class *class_ =
esmStore.get<ESM::Class>().find(player->mClass);
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
{ {
int attribute = class_.mData.mAttribute[i]; int attribute = class_->mData.mAttribute[i];
if (attribute>=0 && attribute<8) if (attribute>=0 && attribute<8)
{ {
creatureStats.getAttribute(attribute).setBase ( creatureStats.getAttribute(attribute).setBase (
@ -122,7 +128,7 @@ namespace MWMechanics
for (int i2=0; i2<5; ++i2) for (int i2=0; i2<5; ++i2)
{ {
int index = class_.mData.mSkills[i2][i]; int index = class_->mData.mSkills[i2][i];
if (index>=0 && index<27) if (index>=0 && index<27)
{ {
@ -132,14 +138,15 @@ namespace MWMechanics
} }
} }
typedef ESMS::IndexListT<ESM::Skill>::MapType ContainerType; const MWWorld::Store<ESM::Skill> &skills =
const ContainerType& skills = MWBase::Environment::get().getWorld()->getStore().skills.list; esmStore.get<ESM::Skill>();
for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) MWWorld::Store<ESM::Skill>::iterator iter = skills.begin();
for (; iter != skills.end(); ++iter)
{ {
if (iter->second.mData.mSpecialization==class_.mData.mSpecialization) if (iter->mData.mSpecialization==class_->mData.mSpecialization)
{ {
int index = iter->first; int index = iter->mIndex;
if (index>=0 && index<27) if (index>=0 && index<27)
{ {
@ -261,12 +268,22 @@ namespace MWMechanics
if (mUpdatePlayer) if (mUpdatePlayer)
{ {
// basic player profile; should not change anymore after the creation phase is finished. // basic player profile; should not change anymore after the creation phase is finished.
MWBase::Environment::get().getWindowManager()->setValue ("name", MWBase::Environment::get().getWorld()->getPlayer().getName()); MWBase::WindowManager *winMgr =
MWBase::Environment::get().getWindowManager()->setValue ("race", MWBase::Environment::get().getWindowManager();
MWBase::Environment::get().getWorld()->getStore().races.find (MWBase::Environment::get().getWorld()->getPlayer().
getRace())->mName); MWBase::World *world = MWBase::Environment::get().getWorld();
MWBase::Environment::get().getWindowManager()->setValue ("class", const ESM::NPC *player =
MWBase::Environment::get().getWorld()->getPlayer().getClass().mName); world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
const ESM::Race *race =
world->getStore().get<ESM::Race>().find(player->mRace);
const ESM::Class *cls =
world->getStore().get<ESM::Class>().find(player->mClass);
winMgr->setValue ("name", player->mName);
winMgr->setValue ("race", race->mName);
winMgr->setValue ("class", cls->mName);
mUpdatePlayer = false; mUpdatePlayer = false;
MWBase::WindowManager::SkillList majorSkills (5); MWBase::WindowManager::SkillList majorSkills (5);
@ -274,11 +291,11 @@ namespace MWMechanics
for (int i=0; i<5; ++i) for (int i=0; i<5; ++i)
{ {
minorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().mData.mSkills[i][0]; minorSkills[i] = cls->mData.mSkills[i][0];
majorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().mData.mSkills[i][1]; majorSkills[i] = cls->mData.mSkills[i][1];
} }
MWBase::Environment::get().getWindowManager()->configureSkills (majorSkills, minorSkills); winMgr->configureSkills (majorSkills, minorSkills);
} }
mActors.update (movement, duration, paused); mActors.update (movement, duration, paused);
@ -291,14 +308,31 @@ namespace MWMechanics
void MechanicsManager::setPlayerName (const std::string& name) void MechanicsManager::setPlayerName (const std::string& name)
{ {
MWBase::Environment::get().getWorld()->getPlayer().setName (name); MWBase::World *world = MWBase::Environment::get().getWorld();
ESM::NPC player =
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
player.mName = name;
world->createRecord(player);
mUpdatePlayer = true; mUpdatePlayer = true;
} }
void MechanicsManager::setPlayerRace (const std::string& race, bool male) void MechanicsManager::setPlayerRace (const std::string& race, bool male, const std::string &head, const std::string &hair)
{ {
MWBase::Environment::get().getWorld()->getPlayer().setGender (male); MWBase::World *world = MWBase::Environment::get().getWorld();
MWBase::Environment::get().getWorld()->getPlayer().setRace (race);
ESM::NPC player =
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
player.mRace = race;
player.mHead = head;
player.mHair = hair;
player.setIsMale(male);
world->createRecord(player);
mRaceSelected = true; mRaceSelected = true;
buildPlayer(); buildPlayer();
mUpdatePlayer = true; mUpdatePlayer = true;
@ -306,29 +340,303 @@ namespace MWMechanics
void MechanicsManager::setPlayerBirthsign (const std::string& id) void MechanicsManager::setPlayerBirthsign (const std::string& id)
{ {
MWBase::Environment::get().getWorld()->getPlayer().setBirthsign (id); MWBase::Environment::get().getWorld()->getPlayer().setBirthSign(id);
buildPlayer(); buildPlayer();
mUpdatePlayer = true; mUpdatePlayer = true;
} }
void MechanicsManager::setPlayerClass (const std::string& id) void MechanicsManager::setPlayerClass (const std::string& id)
{ {
MWBase::Environment::get().getWorld()->getPlayer().setClass (*MWBase::Environment::get().getWorld()->getStore().classes.find (id)); MWBase::World *world = MWBase::Environment::get().getWorld();
ESM::NPC player =
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
player.mClass = id;
world->createRecord(player);
mClassSelected = true; mClassSelected = true;
buildPlayer(); buildPlayer();
mUpdatePlayer = true; mUpdatePlayer = true;
} }
void MechanicsManager::setPlayerClass (const ESM::Class& class_) void MechanicsManager::setPlayerClass (const ESM::Class &cls)
{ {
MWBase::Environment::get().getWorld()->getPlayer().setClass (class_); MWBase::World *world = MWBase::Environment::get().getWorld();
const ESM::Class *ptr = world->createRecord(cls);
ESM::NPC player =
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
player.mClass = ptr->mId;
world->createRecord(player);
mClassSelected = true; mClassSelected = true;
buildPlayer(); buildPlayer();
mUpdatePlayer = true; mUpdatePlayer = true;
} }
std::string toLower (const std::string& name)
{
std::string lowerCase;
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
(int(*)(int)) std::tolower);
return lowerCase;
}
int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr)
{
MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr);
float x = npcSkill.getBaseDisposition();
MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>();
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWWorld::LiveCellRef<ESM::NPC>* player = playerPtr.get<ESM::NPC>();
MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr);
MWMechanics::NpcStats playerNpcStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
if (toLower(npc->mBase->mRace) == toLower(player->mBase->mRace)) x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispRaceMod")->getFloat();
x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispPersonalityMult")->getFloat()
* (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispPersonalityBase")->getFloat());
float reaction = 0;
int rank = 0;
std::string npcFaction = "";
if(!npcSkill.getFactionRanks().empty()) npcFaction = npcSkill.getFactionRanks().begin()->first;
if (playerNpcStats.getFactionRanks().find(toLower(npcFaction)) != playerNpcStats.getFactionRanks().end())
{
for(std::vector<ESM::Faction::Reaction>::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(toLower(npcFaction))->mReactions.begin();
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(toLower(npcFaction))->mReactions.end(); it++)
{
if(toLower(it->mFaction) == toLower(npcFaction)) reaction = it->mReaction;
}
rank = playerNpcStats.getFactionRanks().find(toLower(npcFaction))->second;
}
else if (npcFaction != "")
{
for(std::vector<ESM::Faction::Reaction>::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(toLower(npcFaction))->mReactions.begin();
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(toLower(npcFaction))->mReactions.end();it++)
{
if(playerNpcStats.getFactionRanks().find(toLower(it->mFaction)) != playerNpcStats.getFactionRanks().end() )
{
if(it->mReaction<reaction) reaction = it->mReaction;
}
}
rank = 0;
}
else
{
reaction = 0;
rank = 0;
}
x += (MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispFactionRankMult")->getFloat() * rank
+ MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispFactionRankBase")->getFloat())
* MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispFactionMod")->getFloat() * reaction;
x -= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispCrimeMod")->getFloat() * playerNpcStats.getBounty();
if (playerStats.hasCommonDisease() || playerStats.hasBlightDisease())
x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispDiseaseMod")->getFloat();
if (playerNpcStats.getDrawState() == MWMechanics::DrawState_::DrawState_Weapon)
x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispWeaponDrawn")->getFloat();
int effective_disposition = std::max(0,std::min(int(x),100));//, normally clamped to [0..100] when used
return effective_disposition;
}
int MechanicsManager::getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying)
{
if (ptr.getTypeName() == typeid(ESM::Creature).name())
return basePrice;
MWMechanics::NpcStats sellerSkill = MWWorld::Class::get(ptr).getNpcStats(ptr);
MWMechanics::CreatureStats sellerStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr);
// I suppose the temporary disposition change _has_ to be considered here,
// otherwise one would get different prices when exiting and re-entering the dialogue window...
int clampedDisposition = std::max(0, std::min(getDerivedDisposition(ptr)
+ MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange(),100));
float a = std::min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f);
float b = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f);
float c = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f);
float d = std::min(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f);
float e = std::min(0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f);
float f = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f);
float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm();
float npcTerm = (d + e + f) * sellerStats.getFatigueTerm();
float buyTerm = 0.01 * (100 - 0.5 * (pcTerm - npcTerm));
float sellTerm = 0.01 * (50 - 0.5 * (npcTerm - pcTerm));
float x;
if(buying) x = buyTerm;
else x = std::min(buyTerm, sellTerm);
int offerPrice;
if (x < 1) offerPrice = int(x * basePrice);
if (x >= 1) offerPrice = basePrice + int((x - 1) * basePrice);
offerPrice = std::max(1, offerPrice);
return offerPrice;
}
int MechanicsManager::countDeaths (const std::string& id) const int MechanicsManager::countDeaths (const std::string& id) const
{ {
return mActors.countDeaths (id); return mActors.countDeaths (id);
} }
void MechanicsManager::getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type,
float currentTemporaryDispositionDelta, bool& success, float& tempChange, float& permChange)
{
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr);
MWMechanics::NpcStats npcSkill = MWWorld::Class::get(npc).getNpcStats(npc);
MWMechanics::CreatureStats npcStats = MWWorld::Class::get(npc).getCreatureStats(npc);
float persTerm = playerStats.getAttribute(ESM::Attribute::Personality).getModified()
/ gmst.find("fPersonalityMod")->getFloat();
float luckTerm = playerStats.getAttribute(ESM::Attribute::Luck).getModified()
/ gmst.find("fLuckMod")->getFloat();
float repTerm = playerSkill.getReputation() * gmst.find("fReputationMod")->getFloat();
float levelTerm = playerStats.getLevel() * gmst.find("fLevelMod")->getFloat();
float fatigueTerm = playerStats.getFatigueTerm();
float playerRating1 = (repTerm + luckTerm + persTerm + playerSkill.getSkill(ESM::Skill::Speechcraft).getModified()) * fatigueTerm;
float playerRating2 = playerRating1 + levelTerm;
float playerRating3 = (playerSkill.getSkill(ESM::Skill::Mercantile).getModified() + luckTerm + persTerm) * fatigueTerm;
float npcRating1 = (repTerm + luckTerm + persTerm + playerSkill.getSkill(ESM::Skill::Speechcraft).getModified()) * fatigueTerm;
float npcRating2 = (levelTerm + repTerm + luckTerm + persTerm + npcSkill.getSkill(ESM::Skill::Speechcraft).getModified()) * fatigueTerm;
float npcRating3 = (playerSkill.getSkill(ESM::Skill::Mercantile).getModified() + repTerm + luckTerm + persTerm) * fatigueTerm;
int currentDisposition = std::min(100, std::max(0, int(getDerivedDisposition(npc) + currentTemporaryDispositionDelta)));
float d = 1 - 0.02 * abs(currentDisposition - 50);
float target1 = d * (playerRating1 - npcRating1 + 50);
float target2 = d * (playerRating2 - npcRating2 + 50);
float bribeMod;
if (type == PT_Bribe10) bribeMod = gmst.find("fBribe10Mod")->getFloat();
if (type == PT_Bribe100) bribeMod = gmst.find("fBribe100Mod")->getFloat();
else bribeMod = gmst.find("fBribe1000Mod")->getFloat();
float target3 = d * (playerRating3 - npcRating3 + 50) + bribeMod;
float iPerMinChance = gmst.find("iPerMinChance")->getInt();
float iPerMinChange = gmst.find("iPerMinChange")->getInt();
float fPerDieRollMult = gmst.find("fPerDieRollMult")->getFloat();
float fPerTempMult = gmst.find("fPerTempMult")->getFloat();
float x,y;
float roll = static_cast<float> (std::rand()) / RAND_MAX * 100;
if (type == PT_Admire)
{
target1 = std::max(iPerMinChance, target1);
success = (roll <= target1);
float c = int(fPerDieRollMult * (target1 - roll));
x = success ? std::max(iPerMinChange, c) : c;
}
else if (type == PT_Intimidate)
{
target2 = std::max(iPerMinChance, target2);
success = (roll <= target2);
float r;
if (roll != target2)
r = int(target2 - roll);
else
r = 1;
if (roll <= target2)
{
float s = int(r * fPerDieRollMult * fPerTempMult);
npcStats.setFlee ( std::max(0, std::min(100, npcStats.getFlee() + int(std::max(iPerMinChange, s)))));
npcStats.setFight ( std::max(0, std::min(100, npcStats.getFight() + int(std::min(-iPerMinChange, -s)))));
}
float c = -std::abs(int(r * fPerDieRollMult));
if (success)
{
if (std::abs(c) < iPerMinChange)
{
x = 0;
y = -iPerMinChange;
}
else
{
x = -int(c * fPerTempMult);
y = c;
}
}
else
{
x = int(c * fPerTempMult);
y = c;
}
}
else if (type == PT_Taunt)
{
target1 = std::max(iPerMinChance, target1);
success = (roll <= target1);
float c = std::abs(int(target1 - roll));
if (roll <= target1)
{
float s = c * fPerDieRollMult * fPerTempMult;
npcStats.setFlee ( std::max(0, std::min(100, npcStats.getFlee() + std::min(-int(iPerMinChange), int(-s)))));
npcStats.setFight ( std::max(0, std::min(100, npcStats.getFight() + std::max(int(iPerMinChange), int(s)))));
}
x = int(-c * fPerDieRollMult);
if (success && std::abs(x) < iPerMinChange)
x = -iPerMinChange;
}
else // Bribe
{
target3 = std::max(iPerMinChance, target3);
success = (roll <= target3);
float c = int((target3 - roll) * fPerDieRollMult);
x = success ? std::max(iPerMinChange, c) : c;
}
tempChange = type == PT_Intimidate ? x : int(x * fPerTempMult);
float cappedDispositionChange = tempChange;
if (currentDisposition + tempChange > 100.f)
cappedDispositionChange = 100 - currentDisposition;
if (currentDisposition + tempChange < 0.f)
cappedDispositionChange = -currentDisposition;
permChange = int(cappedDispositionChange / fPerTempMult);
if (type == PT_Intimidate)
{
permChange = success ? -int(cappedDispositionChange/ fPerTempMult) : y;
}
}
} }

View file

@ -64,7 +64,7 @@ namespace MWMechanics
virtual void setPlayerName (const std::string& name); virtual void setPlayerName (const std::string& name);
///< Set player name. ///< Set player name.
virtual void setPlayerRace (const std::string& id, bool male); virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair);
///< Set player race. ///< Set player race.
virtual void setPlayerBirthsign (const std::string& id); virtual void setPlayerBirthsign (const std::string& id);
@ -79,9 +79,18 @@ namespace MWMechanics
virtual void restoreDynamicStats(); virtual void restoreDynamicStats();
///< If the player is sleeping, this should be called every hour. ///< If the player is sleeping, this should be called every hour.
virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying);
///< This is used by every service to determine the price of objects given the trading skills of the player and NPC.
virtual int getDerivedDisposition(const MWWorld::Ptr& ptr);
///< Calculate the diposition of an NPC toward the player.
virtual int countDeaths (const std::string& id) const; virtual int countDeaths (const std::string& id) const;
///< Return the number of deaths for actors with the given ID. ///< Return the number of deaths for actors with the given ID.
virtual void getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type,
float currentTemporaryDispositionDelta, bool& success, float& tempChange, float& permChange);
///< Perform a persuasion action on NPC
}; };
} }

View file

@ -10,7 +10,7 @@
#include <components/esm/loadclas.hpp> #include <components/esm/loadclas.hpp>
#include <components/esm/loadgmst.hpp> #include <components/esm/loadgmst.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -18,8 +18,9 @@
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
MWMechanics::NpcStats::NpcStats() MWMechanics::NpcStats::NpcStats()
: mMovementFlags (0), mDrawState (DrawState_Nothing) : mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0)
, mLevelProgress(0) , mLevelProgress(0), mDisposition(0), mReputation(0)
{ {
mSkillIncreases.resize (ESM::Attribute::Length); mSkillIncreases.resize (ESM::Attribute::Length);
for (int i=0; i<ESM::Attribute::Length; ++i) for (int i=0; i<ESM::Attribute::Length; ++i)
@ -36,6 +37,16 @@ void MWMechanics::NpcStats::setDrawState (DrawState_ state)
mDrawState = state; mDrawState = state;
} }
int MWMechanics::NpcStats::getBaseDisposition() const
{
return mDisposition;
}
void MWMechanics::NpcStats::setBaseDisposition(int disposition)
{
mDisposition = disposition;
}
bool MWMechanics::NpcStats::getMovementFlag (Flag flag) const bool MWMechanics::NpcStats::getMovementFlag (Flag flag) const
{ {
return mMovementFlags & flag; return mMovementFlags & flag;
@ -81,7 +92,8 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla
if (level<0) if (level<0)
level = static_cast<int> (getSkill (skillIndex).getBase()); level = static_cast<int> (getSkill (skillIndex).getBase());
const ESM::Skill *skill = MWBase::Environment::get().getWorld()->getStore().skills.find (skillIndex); const ESM::Skill *skill =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find (skillIndex);
float skillFactor = 1; float skillFactor = 1;
@ -96,14 +108,15 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla
throw std::runtime_error ("invalid skill gain factor"); throw std::runtime_error ("invalid skill gain factor");
} }
float typeFactor = const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMiscSkillBonus")->getFloat(); MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
float typeFactor = gmst.find ("fMiscSkillBonus")->getFloat();
for (int i=0; i<5; ++i) for (int i=0; i<5; ++i)
if (class_.mData.mSkills[i][0]==skillIndex) if (class_.mData.mSkills[i][0]==skillIndex)
{ {
typeFactor = typeFactor = gmst.find ("fMinorSkillBonus")->getFloat();
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMinorSkillBonus")->getFloat();
break; break;
} }
@ -111,8 +124,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla
for (int i=0; i<5; ++i) for (int i=0; i<5; ++i)
if (class_.mData.mSkills[i][1]==skillIndex) if (class_.mData.mSkills[i][1]==skillIndex)
{ {
typeFactor = typeFactor = gmst.find ("fMajorSkillBonus")->getFloat();
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMajorSkillBonus")->getFloat();
break; break;
} }
@ -124,8 +136,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla
if (skill->mData.mSpecialization==class_.mData.mSpecialization) if (skill->mData.mSpecialization==class_.mData.mSpecialization)
{ {
specialisationFactor = specialisationFactor = gmst.find ("fSpecialSkillBonus")->getFloat();
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fSpecialSkillBonus")->getFloat();
if (specialisationFactor<=0) if (specialisationFactor<=0)
throw std::runtime_error ("invalid skill specialisation factor"); throw std::runtime_error ("invalid skill specialisation factor");
@ -178,7 +189,8 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas
mLevelProgress += levelProgress; mLevelProgress += levelProgress;
// check the attribute this skill belongs to // check the attribute this skill belongs to
const ESM::Skill* skill = MWBase::Environment::get().getWorld ()->getStore ().skills.find(skillIndex); const ESM::Skill* skill =
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::Skill>().find(skillIndex);
++mSkillIncreases[skill->mData.mAttribute]; ++mSkillIncreases[skill->mData.mAttribute];
// Play sound & skill progress notification // Play sound & skill progress notification
@ -237,3 +249,23 @@ bool MWMechanics::NpcStats::hasBeenUsed (const std::string& id) const
{ {
return mUsedIds.find (id)!=mUsedIds.end(); return mUsedIds.find (id)!=mUsedIds.end();
} }
int MWMechanics::NpcStats::getBounty() const
{
return mBounty;
}
void MWMechanics::NpcStats::setBounty (int bounty)
{
mBounty = bounty;
}
int MWMechanics::NpcStats::getReputation() const
{
return mReputation;
}
void MWMechanics::NpcStats::setReputation(int reputation)
{
mReputation = reputation;
}

View file

@ -43,8 +43,11 @@ namespace MWMechanics
std::map<std::string, int> mFactionRank; std::map<std::string, int> mFactionRank;
DrawState_ mDrawState; DrawState_ mDrawState;
int mDisposition;
unsigned int mMovementFlags; unsigned int mMovementFlags;
Stat<float> mSkill[27]; Stat<float> mSkill[27];
int mBounty;
int mReputation;
int mLevelProgress; // 0-10 int mLevelProgress; // 0-10
@ -60,6 +63,14 @@ namespace MWMechanics
void setDrawState (DrawState_ state); void setDrawState (DrawState_ state);
int getBaseDisposition() const;
void setBaseDisposition(int disposition);
int getReputation() const;
void setReputation(int reputation);
bool getMovementFlag (Flag flag) const; bool getMovementFlag (Flag flag) const;
void setMovementFlag (Flag flag, bool state); void setMovementFlag (Flag flag, bool state);
@ -92,6 +103,10 @@ namespace MWMechanics
void flagAsUsed (const std::string& id); void flagAsUsed (const std::string& id);
bool hasBeenUsed (const std::string& id) const; bool hasBeenUsed (const std::string& id) const;
int getBounty() const;
void setBounty (int bounty);
}; };
} }

View file

@ -1,7 +1,7 @@
#include "spells.hpp" #include "spells.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <components/esm/loadspel.hpp> #include <components/esm/loadspel.hpp>
@ -50,7 +50,8 @@ namespace MWMechanics
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
{ {
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter);
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)
@ -74,4 +75,32 @@ namespace MWMechanics
{ {
return mSelectedSpell; return mSelectedSpell;
} }
bool Spells::hasCommonDisease() const
{
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
{
const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter);
if (spell->mData.mFlags & ESM::Spell::ST_Disease)
return true;
}
return false;
}
bool Spells::hasBlightDisease() const
{
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
{
const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter);
if (spell->mData.mFlags & ESM::Spell::ST_Blight)
return true;
}
return false;
}
} }

View file

@ -55,6 +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 hasBlightDisease() const;
}; };
} }

View file

@ -8,7 +8,7 @@
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "npcstats.hpp" #include "npcstats.hpp"
@ -40,7 +40,8 @@ namespace MWMechanics
for (std::vector<ESM::ENAMstruct>::const_iterator it = effects.begin(); for (std::vector<ESM::ENAMstruct>::const_iterator it = effects.begin();
it != effects.end(); ++it) it != effects.end(); ++it)
{ {
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->mEffectID); const ESM::MagicEffect* effect =
MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(it->mEffectID);
int _school = effect->mData.mSchool; int _school = effect->mData.mSchool;
int _skillLevel = stats.getSkill (spellSchoolToSkill(_school)).getModified(); int _skillLevel = stats.getSkill (spellSchoolToSkill(_school)).getModified();
@ -61,7 +62,8 @@ namespace MWMechanics
inline int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor) inline int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
return getSpellSchool(spell, actor); return getSpellSchool(spell, actor);
} }
@ -107,7 +109,8 @@ namespace MWMechanics
inline float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor) inline float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); const ESM::Spell* spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
return getSpellSuccessChance(spell, actor); return getSpellSuccessChance(spell, actor);
} }
} }

View file

@ -48,8 +48,9 @@ namespace MWRender
mNode->setVisible (false); mNode->setVisible (false);
mCamera->setPosition(mPosition); Ogre::Vector3 scale = mNode->getScale();
mCamera->lookAt(mLookAt); mCamera->setPosition(mPosition * scale);
mCamera->lookAt(mLookAt * scale);
mCamera->setNearClipDistance (0.01); mCamera->setNearClipDistance (0.01);
mCamera->setFarClipDistance (1000); mCamera->setFarClipDistance (1000);
@ -80,6 +81,22 @@ namespace MWRender
delete mAnimation; delete mAnimation;
} }
void CharacterPreview::rebuild()
{
assert(mAnimation);
delete mAnimation;
mAnimation = new NpcAnimation(mCharacter, mNode,
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), RV_PlayerPreview);
mNode->setVisible (false);
Ogre::Vector3 scale = mNode->getScale();
mCamera->setPosition(mPosition * scale);
mCamera->lookAt(mLookAt * scale);
onSetup();
}
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
@ -128,8 +145,10 @@ namespace MWRender
RaceSelectionPreview::RaceSelectionPreview() RaceSelectionPreview::RaceSelectionPreview()
: CharacterPreview(MWBase::Environment::get().getWorld()->getPlayer().getPlayer(), : CharacterPreview(MWBase::Environment::get().getWorld()->getPlayer().getPlayer(),
512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 120, -35), Ogre::Vector3(0,125,0)) 512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 120, -35), Ogre::Vector3(0,125,0))
, mRef(&mBase)
{ {
mBase = *mCharacter.get<ESM::NPC>()->mBase;
mCharacter = MWWorld::Ptr(&mRef, mCharacter.getCell());
} }
void RaceSelectionPreview::update(float angle) void RaceSelectionPreview::update(float angle)
@ -141,4 +160,11 @@ namespace MWRender
mNode->setVisible (false); mNode->setVisible (false);
} }
void RaceSelectionPreview::setPrototype(const ESM::NPC &proto)
{
mBase = proto;
mBase.mId = "player";
rebuild();
update(0);
}
} }

View file

@ -4,6 +4,7 @@
#include <OgreRenderTarget.h> #include <OgreRenderTarget.h>
#include <OgreMaterialManager.h> #include <OgreMaterialManager.h>
#include <components/esm/loadnpc.hpp>
#include "externalrendering.hpp" #include "externalrendering.hpp"
@ -32,6 +33,7 @@ namespace MWRender
virtual void setup (Ogre::SceneManager *sceneManager); virtual void setup (Ogre::SceneManager *sceneManager);
virtual void onSetup(); virtual void onSetup();
virtual void rebuild();
protected: protected:
Ogre::TexturePtr mTexture; Ogre::TexturePtr mTexture;
@ -77,10 +79,19 @@ namespace MWRender
class RaceSelectionPreview : public CharacterPreview class RaceSelectionPreview : public CharacterPreview
{ {
ESM::NPC mBase;
MWWorld::LiveCellRef<ESM::NPC> mRef;
public: public:
RaceSelectionPreview(); RaceSelectionPreview();
void update(float angle); void update(float angle);
const ESM::NPC &getPrototype() const {
return mBase;
}
void setPrototype(const ESM::NPC &proto);
}; };
} }

View file

@ -21,10 +21,10 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
mInsert = ptr.getRefData().getBaseNode(); mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
assert (ref->base != NULL); assert (ref->mBase != NULL);
if(!ref->base->mModel.empty()) if(!ref->mBase->mModel.empty())
{ {
std::string mesh = "meshes\\" + ref->base->mModel; std::string mesh = "meshes\\" + ref->mBase->mModel;
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh); mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh);
for(size_t i = 0;i < mEntityList.mEntities.size();i++) for(size_t i = 0;i < mEntityList.mEntities.size();i++)

View file

@ -11,7 +11,7 @@
#include <components/esm/loadstat.hpp> #include <components/esm/loadstat.hpp>
#include <components/esm/loadpgrd.hpp> #include <components/esm/loadpgrd.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone #include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -228,22 +228,23 @@ void Debugging::togglePathgrid()
void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store)
{ {
ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->cell); const ESM::Pathgrid *pathgrid =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*store->mCell);
if (!pathgrid) return; if (!pathgrid) return;
Vector3 cellPathGridPos(0, 0, 0); Vector3 cellPathGridPos(0, 0, 0);
if (store->cell->isExterior()) if (store->mCell->isExterior())
{ {
cellPathGridPos.x = store->cell->mData.mX * ESM::Land::REAL_SIZE; cellPathGridPos.x = store->mCell->mData.mX * ESM::Land::REAL_SIZE;
cellPathGridPos.y = store->cell->mData.mY * ESM::Land::REAL_SIZE; cellPathGridPos.y = store->mCell->mData.mY * ESM::Land::REAL_SIZE;
} }
SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos); SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos);
cellPathGrid->attachObject(createPathgridLines(pathgrid)); cellPathGrid->attachObject(createPathgridLines(pathgrid));
cellPathGrid->attachObject(createPathgridPoints(pathgrid)); cellPathGrid->attachObject(createPathgridPoints(pathgrid));
if (store->cell->isExterior()) if (store->mCell->isExterior())
{ {
mExteriorPathgridNodes[std::make_pair(store->cell->mData.mX, store->cell->mData.mY)] = cellPathGrid; mExteriorPathgridNodes[std::make_pair(store->mCell->getGridX(), store->mCell->getGridY())] = cellPathGrid;
} }
else else
{ {
@ -254,10 +255,10 @@ void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store)
void Debugging::disableCellPathgrid(MWWorld::Ptr::CellStore *store) void Debugging::disableCellPathgrid(MWWorld::Ptr::CellStore *store)
{ {
if (store->cell->isExterior()) if (store->mCell->isExterior())
{ {
ExteriorPathgridNodes::iterator it = ExteriorPathgridNodes::iterator it =
mExteriorPathgridNodes.find(std::make_pair(store->cell->mData.mX, store->cell->mData.mY)); mExteriorPathgridNodes.find(std::make_pair(store->mCell->getGridX(), store->mCell->getGridY()));
if (it != mExteriorPathgridNodes.end()) if (it != mExteriorPathgridNodes.end())
{ {
destroyCellPathgridNode(it->second); destroyCellPathgridNode(it->second);

View file

@ -11,8 +11,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <components/esm_store/reclists.hpp>
namespace MWRender namespace MWRender
{ {
@ -29,18 +28,21 @@ namespace MWRender
{ {
Ogre::TexturePtr tex; Ogre::TexturePtr tex;
const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore();
// get the size of the world // get the size of the world
const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; MWWorld::Store<ESM::Cell>::iterator it = esmStore.get<ESM::Cell>().extBegin();
for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) for (; it != esmStore.get<ESM::Cell>().extEnd(); ++it)
{ {
if (it->first.first < mMinX) if (it->getGridX() < mMinX)
mMinX = it->first.first; mMinX = it->getGridX();
if (it->first.first > mMaxX) if (it->getGridX() > mMaxX)
mMaxX = it->first.first; mMaxX = it->getGridX();
if (it->first.second < mMinY) if (it->getGridY() < mMinY)
mMinY = it->first.second; mMinY = it->getGridY();
if (it->first.second > mMaxY) if (it->getGridY() > mMaxY)
mMaxY = it->first.second; mMaxY = it->getGridY();
} }
int cellSize = 24; int cellSize = 24;
@ -59,7 +61,7 @@ namespace MWRender
{ {
for (int y = mMinY; y <= mMaxY; ++y) for (int y = mMinY; y <= mMaxY; ++y)
{ {
ESM::Land* land = MWBase::Environment::get().getWorld ()->getStore ().lands.search (x,y); ESM::Land* land = esmStore.get<ESM::Land>().search (x,y);
if (land) if (land)
{ {

View file

@ -4,7 +4,7 @@
#include <OgreMaterialManager.h> #include <OgreMaterialManager.h>
#include <OgreHardwarePixelBuffer.h> #include <OgreHardwarePixelBuffer.h>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -108,10 +108,10 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell)
mCameraRotNode->setOrientation(Quaternion::IDENTITY); mCameraRotNode->setOrientation(Quaternion::IDENTITY);
std::string name = "Cell_"+coordStr(cell->cell->mData.mX, cell->cell->mData.mY); int x = cell->mCell->getGridX();
int y = cell->mCell->getGridY();
int x = cell->cell->mData.mX; std::string name = "Cell_"+coordStr(x, y);
int y = cell->cell->mData.mY;
mCameraPosNode->setPosition(Vector3(0,0,0)); mCameraPosNode->setPosition(Vector3(0,0,0));
@ -163,7 +163,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
const int segsX = std::ceil( length.x / sSize ); const int segsX = std::ceil( length.x / sSize );
const int segsY = std::ceil( length.y / sSize ); const int segsY = std::ceil( length.y / sSize );
mInteriorName = cell->cell->mName; mInteriorName = cell->mCell->mName;
for (int x=0; x<segsX; ++x) for (int x=0; x<segsX; ++x)
{ {
@ -173,7 +173,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
Vector2 newcenter = start + 4096; Vector2 newcenter = start + 4096;
render(newcenter.x - center.x, newcenter.y - center.y, z.y, z.x, sSize, sSize, render(newcenter.x - center.x, newcenter.y - center.y, z.y, z.x, sSize, sSize,
cell->cell->mName + "_" + coordStr(x,y)); cell->mCell->mName + "_" + coordStr(x,y));
} }
} }
} }

View file

@ -4,7 +4,7 @@
#include <OgreEntity.h> #include <OgreEntity.h>
#include <OgreSubEntity.h> #include <OgreSubEntity.h>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -17,44 +17,54 @@ using namespace NifOgre;
namespace MWRender{ namespace MWRender{
NpcAnimation::~NpcAnimation() NpcAnimation::~NpcAnimation()
{ {
removeEntities(head); removeEntities(mHead);
removeEntities(hair); removeEntities(mHair);
removeEntities(neck); removeEntities(mNeck);
removeEntities(chest); removeEntities(mChest);
removeEntities(groin); removeEntities(mGroin);
removeEntities(skirt); removeEntities(mSkirt);
removeEntities(rHand); removeEntities(mHandL);
removeEntities(lHand); removeEntities(mHandR);
removeEntities(rWrist); removeEntities(mWristL);
removeEntities(lWrist); removeEntities(mWristR);
removeEntities(rForearm); removeEntities(mForearmL);
removeEntities(lForearm); removeEntities(mForearmR);
removeEntities(rupperArm); removeEntities(mUpperArmL);
removeEntities(lupperArm); removeEntities(mUpperArmR);
removeEntities(rfoot); removeEntities(mFootL);
removeEntities(lfoot); removeEntities(mFootR);
removeEntities(rAnkle); removeEntities(mAnkleL);
removeEntities(lAnkle); removeEntities(mAnkleR);
removeEntities(rKnee); removeEntities(mKneeL);
removeEntities(lKnee); removeEntities(mKneeR);
removeEntities(rUpperLeg); removeEntities(mUpperLegL);
removeEntities(lUpperLeg); removeEntities(mUpperLegR);
removeEntities(rclavicle); removeEntities(mClavicleL);
removeEntities(lclavicle); removeEntities(mClavicleR);
removeEntities(tail); removeEntities(mTail);
} }
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& _inv, int visibilityFlags) NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags)
: Animation(), mStateID(-1), mInv(_inv), timeToChange(0), mVisibilityFlags(visibilityFlags), : Animation(),
robe(mInv.end()), helmet(mInv.end()), shirt(mInv.end()), mStateID(-1),
cuirass(mInv.end()), greaves(mInv.end()), mInv(inv),
leftpauldron(mInv.end()), rightpauldron(mInv.end()), mTimeToChange(0),
boots(mInv.end()), mVisibilityFlags(visibilityFlags),
leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()), mRobe(mInv.end()),
pants(mInv.end()) mHelmet(mInv.end()),
mShirt(mInv.end()),
mCuirass(mInv.end()),
mGreaves(mInv.end()),
mPauldronL(mInv.end()),
mPauldronR(mInv.end()),
mBoots(mInv.end()),
mPants(mInv.end()),
mGloveL(mInv.end()),
mGloveR(mInv.end()),
mSkirtIter(mInv.end())
{ {
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); mNpc = ptr.get<ESM::NPC>()->mBase;
for (int init = 0; init < 27; init++) for (int init = 0; init < 27; init++)
{ {
@ -62,25 +72,20 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
mPartPriorities[init] = 0; mPartPriorities[init] = 0;
} }
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store =
const ESM::Race *race = store.races.find(ref->base->mRace); MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.get<ESM::Race>().find(mNpc->mRace);
std::string hairID = ref->base->mHair; mHeadModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHead)->mModel;
std::string headID = ref->base->mHead; mHairModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHair)->mModel;
headModel = "meshes\\" + store.bodyParts.find(headID)->mModel;
hairModel = "meshes\\" + store.bodyParts.find(hairID)->mModel;
npcName = ref->base->mName;
isFemale = !!(ref->base->mFlags&ESM::NPC::Female);
isBeast = !!(race->mData.mFlags&ESM::Race::Beast);
bodyRaceID = "b_n_"+ref->base->mRace;
std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower);
mBodyPrefix = "b_n_" + mNpc->mRace;
std::transform(mBodyPrefix.begin(), mBodyPrefix.end(), mBodyPrefix.begin(), ::tolower);
mInsert = node; mInsert = node;
assert(mInsert); assert(mInsert);
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif"); std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, smodel); mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, smodel);
@ -124,7 +129,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
} }
float scale = race->mData.mHeight.mMale; float scale = race->mData.mHeight.mMale;
if (isFemale) { if (!mNpc->isMale()) {
scale = race->mData.mHeight.mFemale; scale = race->mData.mHeight.mFemale;
} }
mInsert->scale(scale, scale, scale); mInsert->scale(scale, scale, scale);
@ -140,18 +145,18 @@ void NpcAnimation::updateParts()
MWWorld::ContainerStoreIterator *iter; MWWorld::ContainerStoreIterator *iter;
int slot; int slot;
} slotlist[] = { } slotlist[] = {
{ &robe, MWWorld::InventoryStore::Slot_Robe }, { &mRobe, MWWorld::InventoryStore::Slot_Robe },
{ &skirtiter, MWWorld::InventoryStore::Slot_Skirt }, { &mSkirtIter, MWWorld::InventoryStore::Slot_Skirt },
{ &helmet, MWWorld::InventoryStore::Slot_Helmet }, { &mHelmet, MWWorld::InventoryStore::Slot_Helmet },
{ &cuirass, MWWorld::InventoryStore::Slot_Cuirass }, { &mCuirass, MWWorld::InventoryStore::Slot_Cuirass },
{ &greaves, MWWorld::InventoryStore::Slot_Greaves }, { &mGreaves, MWWorld::InventoryStore::Slot_Greaves },
{ &leftpauldron, MWWorld::InventoryStore::Slot_LeftPauldron }, { &mPauldronL, MWWorld::InventoryStore::Slot_LeftPauldron },
{ &rightpauldron, MWWorld::InventoryStore::Slot_RightPauldron }, { &mPauldronR, MWWorld::InventoryStore::Slot_RightPauldron },
{ &boots, MWWorld::InventoryStore::Slot_Boots }, { &mBoots, MWWorld::InventoryStore::Slot_Boots },
{ &leftglove, MWWorld::InventoryStore::Slot_LeftGauntlet }, { &mGloveL, MWWorld::InventoryStore::Slot_LeftGauntlet },
{ &rightglove, MWWorld::InventoryStore::Slot_RightGauntlet }, { &mGloveR, MWWorld::InventoryStore::Slot_RightGauntlet },
{ &shirt, MWWorld::InventoryStore::Slot_Shirt }, { &mShirt, MWWorld::InventoryStore::Slot_Shirt },
{ &pants, MWWorld::InventoryStore::Slot_Pants }, { &mPants, MWWorld::InventoryStore::Slot_Pants },
}; };
for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++) for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++)
{ {
@ -166,11 +171,11 @@ void NpcAnimation::updateParts()
if(apparelChanged) if(apparelChanged)
{ {
if(robe != mInv.end()) if(mRobe != mInv.end())
{ {
MWWorld::Ptr ptr = *robe; MWWorld::Ptr ptr = *mRobe;
const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base; const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts);
reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5); reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5);
@ -186,11 +191,11 @@ void NpcAnimation::updateParts()
reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5); reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5); reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5);
} }
if(skirtiter != mInv.end()) if(mSkirtIter != mInv.end())
{ {
MWWorld::Ptr ptr = *skirtiter; MWWorld::Ptr ptr = *mSkirtIter;
const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base; const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts); addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts);
reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4); reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4);
@ -198,103 +203,103 @@ void NpcAnimation::updateParts()
reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4); reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4);
} }
if(helmet != mInv.end()) if(mHelmet != mInv.end())
{ {
removeIndividualPart(ESM::PRT_Hair); removeIndividualPart(ESM::PRT_Hair);
const ESM::Armor *armor = (helmet->get<ESM::Armor>())->base; const ESM::Armor *armor = (mHelmet->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts);
} }
if(cuirass != mInv.end()) if(mCuirass != mInv.end())
{ {
const ESM::Armor *armor = (cuirass->get<ESM::Armor>())->base; const ESM::Armor *armor = (mCuirass->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts);
} }
if(greaves != mInv.end()) if(mGreaves != mInv.end())
{ {
const ESM::Armor *armor = (greaves->get<ESM::Armor>())->base; const ESM::Armor *armor = (mGreaves->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts);
} }
if(leftpauldron != mInv.end()) if(mPauldronL != mInv.end())
{ {
const ESM::Armor *armor = (leftpauldron->get<ESM::Armor>())->base; const ESM::Armor *armor = (mPauldronL->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts);
} }
if(rightpauldron != mInv.end()) if(mPauldronR != mInv.end())
{ {
const ESM::Armor *armor = (rightpauldron->get<ESM::Armor>())->base; const ESM::Armor *armor = (mPauldronR->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts);
} }
if(boots != mInv.end()) if(mBoots != mInv.end())
{ {
if(boots->getTypeName() == typeid(ESM::Clothing).name()) if(mBoots->getTypeName() == typeid(ESM::Clothing).name())
{ {
const ESM::Clothing *clothes = (boots->get<ESM::Clothing>())->base; const ESM::Clothing *clothes = (mBoots->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts);
} }
else if(boots->getTypeName() == typeid(ESM::Armor).name()) else if(mBoots->getTypeName() == typeid(ESM::Armor).name())
{ {
const ESM::Armor *armor = (boots->get<ESM::Armor>())->base; const ESM::Armor *armor = (mBoots->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts);
} }
} }
if(leftglove != mInv.end()) if(mGloveL != mInv.end())
{ {
if(leftglove->getTypeName() == typeid(ESM::Clothing).name()) if(mGloveL->getTypeName() == typeid(ESM::Clothing).name())
{ {
const ESM::Clothing *clothes = (leftglove->get<ESM::Clothing>())->base; const ESM::Clothing *clothes = (mGloveL->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts);
} }
else else
{ {
const ESM::Armor *armor = (leftglove->get<ESM::Armor>())->base; const ESM::Armor *armor = (mGloveL->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts);
} }
} }
if(rightglove != mInv.end()) if(mGloveR != mInv.end())
{ {
if(rightglove->getTypeName() == typeid(ESM::Clothing).name()) if(mGloveR->getTypeName() == typeid(ESM::Clothing).name())
{ {
const ESM::Clothing *clothes = (rightglove->get<ESM::Clothing>())->base; const ESM::Clothing *clothes = (mGloveR->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts);
} }
else else
{ {
const ESM::Armor *armor = (rightglove->get<ESM::Armor>())->base; const ESM::Armor *armor = (mGloveR->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts);
} }
} }
if(shirt != mInv.end()) if(mShirt != mInv.end())
{ {
const ESM::Clothing *clothes = (shirt->get<ESM::Clothing>())->base; const ESM::Clothing *clothes = (mShirt->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts);
} }
if(pants != mInv.end()) if(mPants != mInv.end())
{ {
const ESM::Clothing *clothes = (pants->get<ESM::Clothing>())->base; const ESM::Clothing *clothes = (mPants->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts);
} }
} }
if(mPartPriorities[ESM::PRT_Head] < 1) if(mPartPriorities[ESM::PRT_Head] < 1)
addOrReplaceIndividualPart(ESM::PRT_Head, -1,1, headModel); addOrReplaceIndividualPart(ESM::PRT_Head, -1,1, mHeadModel);
if(mPartPriorities[ESM::PRT_Hair] < 1 && mPartPriorities[ESM::PRT_Head] <= 1) if(mPartPriorities[ESM::PRT_Hair] < 1 && mPartPriorities[ESM::PRT_Head] <= 1)
addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, hairModel); addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, mHairModel);
static const struct { static const struct {
ESM::PartReferenceType type; ESM::PartReferenceType type;
@ -322,26 +327,27 @@ void NpcAnimation::updateParts()
{ ESM::PRT_Tail, { "tail", "" } } { ESM::PRT_Tail, { "tail", "" } }
}; };
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
for(size_t i = 0;i < sizeof(PartTypeList)/sizeof(PartTypeList[0]);i++) for(size_t i = 0;i < sizeof(PartTypeList)/sizeof(PartTypeList[0]);i++)
{ {
if(mPartPriorities[PartTypeList[i].type] < 1) if(mPartPriorities[PartTypeList[i].type] < 1)
{ {
const ESM::BodyPart *part = NULL; const ESM::BodyPart *part = NULL;
bool tryfemale = isFemale; const MWWorld::Store<ESM::BodyPart> &partStore =
int ni = 0; store.get<ESM::BodyPart>();
do {
part = store.bodyParts.search(bodyRaceID+(tryfemale?"_f_":"_m_")+PartTypeList[i].name[ni]);
if(part) break;
ni ^= 1; if (!mNpc->isMale()) {
if(ni == 0) part = partStore.search(mBodyPrefix + "_f_" + PartTypeList[i].name[0]);
{ if (part == 0) {
if(!tryfemale) part = partStore.search(mBodyPrefix + "_f_" + PartTypeList[i].name[1]);
break;
tryfemale = false;
} }
} while(1); }
if (part == 0) {
part = partStore.search(mBodyPrefix + "_m_" + PartTypeList[i].name[0]);
}
if (part == 0) {
part = partStore.search(mBodyPrefix + "_m_" + PartTypeList[i].name[1]);
}
if(part) if(part)
addOrReplaceIndividualPart(PartTypeList[i].type, -1,1, "meshes\\"+part->mModel); addOrReplaceIndividualPart(PartTypeList[i].type, -1,1, "meshes\\"+part->mModel);
@ -364,12 +370,12 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int
void NpcAnimation::runAnimation(float timepassed) void NpcAnimation::runAnimation(float timepassed)
{ {
if(timeToChange > .2) if(mTimeToChange > .2)
{ {
timeToChange = 0; mTimeToChange = 0;
updateParts(); updateParts();
} }
timeToChange += timepassed; mTimeToChange += timepassed;
Animation::runAnimation(timepassed); Animation::runAnimation(timepassed);
} }
@ -394,61 +400,61 @@ void NpcAnimation::removeIndividualPart(int type)
mPartslots[type] = -1; mPartslots[type] = -1;
if(type == ESM::PRT_Head) //0 if(type == ESM::PRT_Head) //0
removeEntities(head); removeEntities(mHead);
else if(type == ESM::PRT_Hair) //1 else if(type == ESM::PRT_Hair) //1
removeEntities(hair); removeEntities(mHair);
else if(type == ESM::PRT_Neck) //2 else if(type == ESM::PRT_Neck) //2
removeEntities(neck); removeEntities(mNeck);
else if(type == ESM::PRT_Cuirass)//3 else if(type == ESM::PRT_Cuirass)//3
removeEntities(chest); removeEntities(mChest);
else if(type == ESM::PRT_Groin)//4 else if(type == ESM::PRT_Groin)//4
removeEntities(groin); removeEntities(mGroin);
else if(type == ESM::PRT_Skirt)//5 else if(type == ESM::PRT_Skirt)//5
removeEntities(skirt); removeEntities(mSkirt);
else if(type == ESM::PRT_RHand)//6 else if(type == ESM::PRT_RHand)//6
removeEntities(rHand); removeEntities(mHandR);
else if(type == ESM::PRT_LHand)//7 else if(type == ESM::PRT_LHand)//7
removeEntities(lHand); removeEntities(mHandL);
else if(type == ESM::PRT_RWrist)//8 else if(type == ESM::PRT_RWrist)//8
removeEntities(rWrist); removeEntities(mWristR);
else if(type == ESM::PRT_LWrist) //9 else if(type == ESM::PRT_LWrist) //9
removeEntities(lWrist); removeEntities(mWristL);
else if(type == ESM::PRT_Shield) //10 else if(type == ESM::PRT_Shield) //10
{ {
} }
else if(type == ESM::PRT_RForearm) //11 else if(type == ESM::PRT_RForearm) //11
removeEntities(rForearm); removeEntities(mForearmR);
else if(type == ESM::PRT_LForearm) //12 else if(type == ESM::PRT_LForearm) //12
removeEntities(lForearm); removeEntities(mForearmL);
else if(type == ESM::PRT_RUpperarm) //13 else if(type == ESM::PRT_RUpperarm) //13
removeEntities(rupperArm); removeEntities(mUpperArmR);
else if(type == ESM::PRT_LUpperarm) //14 else if(type == ESM::PRT_LUpperarm) //14
removeEntities(lupperArm); removeEntities(mUpperArmL);
else if(type == ESM::PRT_RFoot) //15 else if(type == ESM::PRT_RFoot) //15
removeEntities(rfoot); removeEntities(mFootR);
else if(type == ESM::PRT_LFoot) //16 else if(type == ESM::PRT_LFoot) //16
removeEntities(lfoot); removeEntities(mFootL);
else if(type == ESM::PRT_RAnkle) //17 else if(type == ESM::PRT_RAnkle) //17
removeEntities(rAnkle); removeEntities(mAnkleR);
else if(type == ESM::PRT_LAnkle) //18 else if(type == ESM::PRT_LAnkle) //18
removeEntities(lAnkle); removeEntities(mAnkleL);
else if(type == ESM::PRT_RKnee) //19 else if(type == ESM::PRT_RKnee) //19
removeEntities(rKnee); removeEntities(mKneeR);
else if(type == ESM::PRT_LKnee) //20 else if(type == ESM::PRT_LKnee) //20
removeEntities(lKnee); removeEntities(mKneeL);
else if(type == ESM::PRT_RLeg) //21 else if(type == ESM::PRT_RLeg) //21
removeEntities(rUpperLeg); removeEntities(mUpperLegR);
else if(type == ESM::PRT_LLeg) //22 else if(type == ESM::PRT_LLeg) //22
removeEntities(lUpperLeg); removeEntities(mUpperLegL);
else if(type == ESM::PRT_RPauldron) //23 else if(type == ESM::PRT_RPauldron) //23
removeEntities(rclavicle); removeEntities(mClavicleR);
else if(type == ESM::PRT_LPauldron) //24 else if(type == ESM::PRT_LPauldron) //24
removeEntities(lclavicle); removeEntities(mClavicleL);
else if(type == ESM::PRT_Weapon) //25 else if(type == ESM::PRT_Weapon) //25
{ {
} }
else if(type == ESM::PRT_Tail) //26 else if(type == ESM::PRT_Tail) //26
removeEntities(tail); removeEntities(mTail);
} }
void NpcAnimation::reserveIndividualPart(int type, int group, int priority) void NpcAnimation::reserveIndividualPart(int type, int group, int priority)
@ -481,83 +487,83 @@ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority,
switch(type) switch(type)
{ {
case ESM::PRT_Head: //0 case ESM::PRT_Head: //0
head = insertBoundedPart(mesh, group, "Head"); mHead = insertBoundedPart(mesh, group, "Head");
break; break;
case ESM::PRT_Hair: //1 case ESM::PRT_Hair: //1
hair = insertBoundedPart(mesh, group, "Head"); mHair = insertBoundedPart(mesh, group, "Head");
break; break;
case ESM::PRT_Neck: //2 case ESM::PRT_Neck: //2
neck = insertBoundedPart(mesh, group, "Neck"); mNeck = insertBoundedPart(mesh, group, "Neck");
break; break;
case ESM::PRT_Cuirass: //3 case ESM::PRT_Cuirass: //3
chest = insertBoundedPart(mesh, group, "Chest"); mChest = insertBoundedPart(mesh, group, "Chest");
break; break;
case ESM::PRT_Groin: //4 case ESM::PRT_Groin: //4
groin = insertBoundedPart(mesh, group, "Groin"); mGroin = insertBoundedPart(mesh, group, "Groin");
break; break;
case ESM::PRT_Skirt: //5 case ESM::PRT_Skirt: //5
skirt = insertBoundedPart(mesh, group, "Groin"); mSkirt = insertBoundedPart(mesh, group, "Groin");
break; break;
case ESM::PRT_RHand: //6 case ESM::PRT_RHand: //6
rHand = insertBoundedPart(mesh, group, "Right Hand"); mHandR = insertBoundedPart(mesh, group, "Right Hand");
break; break;
case ESM::PRT_LHand: //7 case ESM::PRT_LHand: //7
lHand = insertBoundedPart(mesh, group, "Left Hand"); mHandL = insertBoundedPart(mesh, group, "Left Hand");
break; break;
case ESM::PRT_RWrist: //8 case ESM::PRT_RWrist: //8
rWrist = insertBoundedPart(mesh, group, "Right Wrist"); mWristR = insertBoundedPart(mesh, group, "Right Wrist");
break; break;
case ESM::PRT_LWrist: //9 case ESM::PRT_LWrist: //9
lWrist = insertBoundedPart(mesh, group, "Left Wrist"); mWristL = insertBoundedPart(mesh, group, "Left Wrist");
break; break;
case ESM::PRT_Shield: //10 case ESM::PRT_Shield: //10
break; break;
case ESM::PRT_RForearm: //11 case ESM::PRT_RForearm: //11
rForearm = insertBoundedPart(mesh, group, "Right Forearm"); mForearmR = insertBoundedPart(mesh, group, "Right Forearm");
break; break;
case ESM::PRT_LForearm: //12 case ESM::PRT_LForearm: //12
lForearm = insertBoundedPart(mesh, group, "Left Forearm"); mForearmL = insertBoundedPart(mesh, group, "Left Forearm");
break; break;
case ESM::PRT_RUpperarm: //13 case ESM::PRT_RUpperarm: //13
rupperArm = insertBoundedPart(mesh, group, "Right Upper Arm"); mUpperArmR = insertBoundedPart(mesh, group, "Right Upper Arm");
break; break;
case ESM::PRT_LUpperarm: //14 case ESM::PRT_LUpperarm: //14
lupperArm = insertBoundedPart(mesh, group, "Left Upper Arm"); mUpperArmL = insertBoundedPart(mesh, group, "Left Upper Arm");
break; break;
case ESM::PRT_RFoot: //15 case ESM::PRT_RFoot: //15
rfoot = insertBoundedPart(mesh, group, "Right Foot"); mFootR = insertBoundedPart(mesh, group, "Right Foot");
break; break;
case ESM::PRT_LFoot: //16 case ESM::PRT_LFoot: //16
lfoot = insertBoundedPart(mesh, group, "Left Foot"); mFootL = insertBoundedPart(mesh, group, "Left Foot");
break; break;
case ESM::PRT_RAnkle: //17 case ESM::PRT_RAnkle: //17
rAnkle = insertBoundedPart(mesh, group, "Right Ankle"); mAnkleR = insertBoundedPart(mesh, group, "Right Ankle");
break; break;
case ESM::PRT_LAnkle: //18 case ESM::PRT_LAnkle: //18
lAnkle = insertBoundedPart(mesh, group, "Left Ankle"); mAnkleL = insertBoundedPart(mesh, group, "Left Ankle");
break; break;
case ESM::PRT_RKnee: //19 case ESM::PRT_RKnee: //19
rKnee = insertBoundedPart(mesh, group, "Right Knee"); mKneeR = insertBoundedPart(mesh, group, "Right Knee");
break; break;
case ESM::PRT_LKnee: //20 case ESM::PRT_LKnee: //20
lKnee = insertBoundedPart(mesh, group, "Left Knee"); mKneeL = insertBoundedPart(mesh, group, "Left Knee");
break; break;
case ESM::PRT_RLeg: //21 case ESM::PRT_RLeg: //21
rUpperLeg = insertBoundedPart(mesh, group, "Right Upper Leg"); mUpperLegR = insertBoundedPart(mesh, group, "Right Upper Leg");
break; break;
case ESM::PRT_LLeg: //22 case ESM::PRT_LLeg: //22
lUpperLeg = insertBoundedPart(mesh, group, "Left Upper Leg"); mUpperLegL = insertBoundedPart(mesh, group, "Left Upper Leg");
break; break;
case ESM::PRT_RPauldron: //23 case ESM::PRT_RPauldron: //23
rclavicle = insertBoundedPart(mesh , group, "Right Clavicle"); mClavicleR = insertBoundedPart(mesh , group, "Right Clavicle");
break; break;
case ESM::PRT_LPauldron: //24 case ESM::PRT_LPauldron: //24
lclavicle = insertBoundedPart(mesh, group, "Left Clavicle"); mClavicleL = insertBoundedPart(mesh, group, "Left Clavicle");
break; break;
case ESM::PRT_Weapon: //25 case ESM::PRT_Weapon: //25
break; break;
case ESM::PRT_Tail: //26 case ESM::PRT_Tail: //26
tail = insertBoundedPart(mesh, group, "Tail"); mTail = insertBoundedPart(mesh, group, "Tail");
break; break;
} }
return true; return true;
@ -569,11 +575,14 @@ void NpcAnimation::addPartGroup(int group, int priority, std::vector<ESM::PartRe
{ {
ESM::PartReference &part = parts[i]; ESM::PartReference &part = parts[i];
const MWWorld::Store<ESM::BodyPart> &partStore =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>();
const ESM::BodyPart *bodypart = 0; const ESM::BodyPart *bodypart = 0;
if(isFemale) if(!mNpc->isMale())
bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search(part.mFemale); bodypart = partStore.search(part.mFemale);
if(!bodypart) if(!bodypart)
bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search(part.mMale); bodypart = partStore.search(part.mMale);
if(bodypart) if(bodypart)
addOrReplaceIndividualPart(part.mPart, group, priority,"meshes\\" + bodypart->mModel); addOrReplaceIndividualPart(part.mPart, group, priority,"meshes\\" + bodypart->mModel);

View file

@ -8,6 +8,11 @@
#include "../mwclass/npc.hpp" #include "../mwclass/npc.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
namespace ESM
{
struct NPC;
}
namespace MWRender{ namespace MWRender{
class NpcAnimation: public Animation{ class NpcAnimation: public Animation{
@ -19,57 +24,57 @@ private:
int mPartPriorities[27]; int mPartPriorities[27];
//Bounded Parts //Bounded Parts
NifOgre::EntityList lclavicle; NifOgre::EntityList mClavicleL;
NifOgre::EntityList rclavicle; NifOgre::EntityList mClavicleR;
NifOgre::EntityList rupperArm; NifOgre::EntityList mUpperArmL;
NifOgre::EntityList lupperArm; NifOgre::EntityList mUpperArmR;
NifOgre::EntityList rUpperLeg; NifOgre::EntityList mUpperLegL;
NifOgre::EntityList lUpperLeg; NifOgre::EntityList mUpperLegR;
NifOgre::EntityList lForearm; NifOgre::EntityList mForearmL;
NifOgre::EntityList rForearm; NifOgre::EntityList mForearmR;
NifOgre::EntityList lWrist; NifOgre::EntityList mWristL;
NifOgre::EntityList rWrist; NifOgre::EntityList mWristR;
NifOgre::EntityList rKnee; NifOgre::EntityList mKneeR;
NifOgre::EntityList lKnee; NifOgre::EntityList mKneeL;
NifOgre::EntityList neck; NifOgre::EntityList mNeck;
NifOgre::EntityList rAnkle; NifOgre::EntityList mAnkleL;
NifOgre::EntityList lAnkle; NifOgre::EntityList mAnkleR;
NifOgre::EntityList groin; NifOgre::EntityList mGroin;
NifOgre::EntityList skirt; NifOgre::EntityList mSkirt;
NifOgre::EntityList lfoot; NifOgre::EntityList mFootL;
NifOgre::EntityList rfoot; NifOgre::EntityList mFootR;
NifOgre::EntityList hair; NifOgre::EntityList mHair;
NifOgre::EntityList rHand; NifOgre::EntityList mHandL;
NifOgre::EntityList lHand; NifOgre::EntityList mHandR;
NifOgre::EntityList head; NifOgre::EntityList mHead;
NifOgre::EntityList chest; NifOgre::EntityList mChest;
NifOgre::EntityList tail; NifOgre::EntityList mTail;
bool isBeast; const ESM::NPC *mNpc;
bool isFemale; std::string mHeadModel;
std::string headModel; std::string mHairModel;
std::string hairModel; std::string mBodyPrefix;
std::string npcName;
std::string bodyRaceID;
float timeToChange; float mTimeToChange;
MWWorld::ContainerStoreIterator robe; MWWorld::ContainerStoreIterator mRobe;
MWWorld::ContainerStoreIterator helmet; MWWorld::ContainerStoreIterator mHelmet;
MWWorld::ContainerStoreIterator shirt; MWWorld::ContainerStoreIterator mShirt;
MWWorld::ContainerStoreIterator cuirass; MWWorld::ContainerStoreIterator mCuirass;
MWWorld::ContainerStoreIterator greaves; MWWorld::ContainerStoreIterator mGreaves;
MWWorld::ContainerStoreIterator leftpauldron; MWWorld::ContainerStoreIterator mPauldronL;
MWWorld::ContainerStoreIterator rightpauldron; MWWorld::ContainerStoreIterator mPauldronR;
MWWorld::ContainerStoreIterator boots; MWWorld::ContainerStoreIterator mBoots;
MWWorld::ContainerStoreIterator pants; MWWorld::ContainerStoreIterator mPants;
MWWorld::ContainerStoreIterator leftglove; MWWorld::ContainerStoreIterator mGloveL;
MWWorld::ContainerStoreIterator rightglove; MWWorld::ContainerStoreIterator mGloveR;
MWWorld::ContainerStoreIterator skirtiter; MWWorld::ContainerStoreIterator mSkirtIter;
int mVisibilityFlags; int mVisibilityFlags;
public: public:
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node,
MWWorld::InventoryStore& _inv, int visibilityFlags); MWWorld::InventoryStore& inv, int visibilityFlags);
virtual ~NpcAnimation(); virtual ~NpcAnimation();
NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename); NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename);
virtual void runAnimation(float timepassed); virtual void runAnimation(float timepassed);

View file

@ -219,18 +219,18 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f
info.radius = radius; info.radius = radius;
info.colour = Ogre::ColourValue(r, g, b); info.colour = Ogre::ColourValue(r, g, b);
if (ref->base->mData.mFlags & ESM::Light::Negative) if (ref->mBase->mData.mFlags & ESM::Light::Negative)
info.colour *= -1; info.colour *= -1;
info.interior = (ptr.getCell()->cell->mData.mFlags & ESM::Cell::Interior); info.interior = !ptr.getCell()->mCell->isExterior();
if (ref->base->mData.mFlags & ESM::Light::Flicker) if (ref->mBase->mData.mFlags & ESM::Light::Flicker)
info.type = LT_Flicker; info.type = LT_Flicker;
else if (ref->base->mData.mFlags & ESM::Light::FlickerSlow) else if (ref->mBase->mData.mFlags & ESM::Light::FlickerSlow)
info.type = LT_FlickerSlow; info.type = LT_FlickerSlow;
else if (ref->base->mData.mFlags & ESM::Light::Pulse) else if (ref->mBase->mData.mFlags & ESM::Light::Pulse)
info.type = LT_Pulse; info.type = LT_Pulse;
else if (ref->base->mData.mFlags & ESM::Light::PulseSlow) else if (ref->mBase->mData.mFlags & ESM::Light::PulseSlow)
info.type = LT_PulseSlow; info.type = LT_PulseSlow;
else else
info.type = LT_Normal; info.type = LT_Normal;

View file

@ -18,6 +18,7 @@ namespace MWRender
: mCamera(camera), : mCamera(camera),
mPlayerNode(node), mPlayerNode(node),
mCameraNode(mPlayerNode->createChildSceneNode()), mCameraNode(mPlayerNode->createChildSceneNode()),
mAnimation(0),
mFirstPersonView(true), mFirstPersonView(true),
mPreviewMode(false), mPreviewMode(false),
mFreeLook(true), mFreeLook(true),
@ -309,6 +310,9 @@ namespace MWRender
void Player::setAnimation(NpcAnimation *anim) void Player::setAnimation(NpcAnimation *anim)
{ {
if (mAnimation) {
delete mAnimation;
}
mAnimation = anim; mAnimation = anim;
} }

View file

@ -48,16 +48,6 @@ namespace MWRender
/// Updates sound manager listener data /// Updates sound manager listener data
void updateListener(); void updateListener();
void rotateCamera(const Ogre::Vector3 &rot, bool adjust);
float getYaw();
void setYaw(float angle);
float getPitch();
void setPitch(float angle);
void compensateYaw(float diff);
void setLowHeight(bool low = true); void setLowHeight(bool low = true);
public: public:
@ -69,7 +59,17 @@ namespace MWRender
/// \param rot Rotation angles in radians /// \param rot Rotation angles in radians
/// \return true if player object needs to bo rotated physically /// \return true if player object needs to bo rotated physically
bool rotate(const Ogre::Vector3 &rot, bool adjust); bool rotate(const Ogre::Vector3 &rot, bool adjust);
void rotateCamera(const Ogre::Vector3 &rot, bool adjust);
float getYaw();
void setYaw(float angle);
float getPitch();
void setPitch(float angle);
void compensateYaw(float diff);
std::string getHandle() const; std::string getHandle() const;
/// Attach camera to object /// Attach camera to object

View file

@ -13,12 +13,13 @@
#include <OgreCompositionTargetPass.h> #include <OgreCompositionTargetPass.h>
#include <OgreCompositionPass.h> #include <OgreCompositionPass.h>
#include <OgreHardwarePixelBuffer.h> #include <OgreHardwarePixelBuffer.h>
#include <OgreControllerManager.h>
#include <extern/shiny/Main/Factory.hpp> #include <extern/shiny/Main/Factory.hpp>
#include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp> #include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp>
#include <components/esm/loadstat.hpp> #include <components/esm/loadstat.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone #include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone
@ -206,7 +207,7 @@ void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store)
mObjects.removeCell(store); mObjects.removeCell(store);
mActors.removeCell(store); mActors.removeCell(store);
mDebugging->cellRemoved(store); mDebugging->cellRemoved(store);
if (store->cell->isExterior()) if (store->mCell->isExterior())
mTerrainManager->cellRemoved(store); mTerrainManager->cellRemoved(store);
} }
@ -227,7 +228,7 @@ void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store)
{ {
mObjects.buildStaticGeometry (*store); mObjects.buildStaticGeometry (*store);
mDebugging->cellAdded(store); mDebugging->cellAdded(store);
if (store->cell->isExterior()) if (store->mCell->isExterior())
mTerrainManager->cellAdded(store); mTerrainManager->cellAdded(store);
waterAdded(store); waterAdded(store);
} }
@ -236,18 +237,12 @@ void RenderingManager::addObject (const MWWorld::Ptr& ptr){
const MWWorld::Class& class_ = const MWWorld::Class& class_ =
MWWorld::Class::get (ptr); MWWorld::Class::get (ptr);
class_.insertObjectRendering(ptr, *this); class_.insertObjectRendering(ptr, *this);
} }
void RenderingManager::removeObject (const MWWorld::Ptr& ptr) void RenderingManager::removeObject (const MWWorld::Ptr& ptr)
{ {
if (!mObjects.deleteObject (ptr)) if (!mObjects.deleteObject (ptr))
{ mActors.deleteObject (ptr);
/// \todo delete non-object MW-references
}
if (!mActors.deleteObject (ptr))
{
/// \todo delete non-object MW-references
}
} }
void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position) void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position)
@ -257,39 +252,46 @@ void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3&
setPosition (position); setPosition (position);
} }
void RenderingManager::scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale){ void RenderingManager::scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale)
{
ptr.getRefData().getBaseNode()->setScale(scale);
} }
bool bool RenderingManager::rotateObject( const MWWorld::Ptr &ptr, Ogre::Vector3 &rot, bool adjust)
RenderingManager::rotateObject(
const MWWorld::Ptr &ptr,
Ogre::Vector3 &rot,
bool adjust)
{ {
bool isActive = ptr.getRefData().getBaseNode() != 0; bool isActive = ptr.getRefData().getBaseNode() != 0;
bool isPlayer = isActive && ptr.getRefData().getHandle() == "player"; bool isPlayer = isActive && ptr.getRefData().getHandle() == "player";
bool force = true; bool force = true;
if (isPlayer) { if (isPlayer)
force = mPlayer->rotate(rot, adjust); force = mPlayer->rotate(rot, adjust);
}
MWWorld::Class::get(ptr).adjustRotation(ptr, rot.x, rot.y, rot.z); MWWorld::Class::get(ptr).adjustRotation(ptr, rot.x, rot.y, rot.z);
if (adjust) { if (!isPlayer && isActive)
/// \note Stored and passed in radians {
float *f = ptr.getRefData().getPosition().rot;
rot.x += f[0], rot.y += f[1], rot.z += f[2];
}
if (!isPlayer && isActive) {
Ogre::Quaternion xr(Ogre::Radian(rot.x), Ogre::Vector3::UNIT_X); Ogre::Quaternion xr(Ogre::Radian(rot.x), Ogre::Vector3::UNIT_X);
Ogre::Quaternion yr(Ogre::Radian(rot.y), Ogre::Vector3::UNIT_Y); Ogre::Quaternion yr(Ogre::Radian(rot.y), Ogre::Vector3::UNIT_Y);
Ogre::Quaternion zr(Ogre::Radian(rot.z), Ogre::Vector3::UNIT_Z); Ogre::Quaternion zr(Ogre::Radian(rot.z), Ogre::Vector3::UNIT_Z);
Ogre::Quaternion newo = adjust ? (xr * yr * zr) * ptr.getRefData().getBaseNode()->getOrientation() : xr * yr * zr;
ptr.getRefData().getBaseNode()->setOrientation(xr * yr * zr); rot.x = newo.x;
rot.y = newo.y;
rot.z = newo.z;
ptr.getRefData().getBaseNode()->setOrientation(newo);
}
else if(isPlayer)
{
rot.x = mPlayer->getPitch();
rot.z = mPlayer->getYaw();
}
else if (adjust)
{
// Stored and passed in radians
float *f = ptr.getRefData().getPosition().rot;
rot.x += f[0];
rot.y += f[1];
rot.z += f[2];
} }
return force; return force;
} }
@ -313,7 +315,7 @@ RenderingManager::moveObjectToCell(
child->setPosition(pos); child->setPosition(pos);
} }
void RenderingManager::update (float duration) void RenderingManager::update (float duration, bool paused)
{ {
Ogre::Vector3 orig, dest; Ogre::Vector3 orig, dest;
mPlayer->setCameraDistance(); mPlayer->setCameraDistance();
@ -328,12 +330,21 @@ void RenderingManager::update (float duration)
mPlayer->setCameraDistance(test.second * orig.distance(dest), false, false); mPlayer->setCameraDistance(test.second * orig.distance(dest), false, false);
} }
} }
mOcclusionQuery->update(duration);
if(paused)
{
Ogre::ControllerManager::getSingleton().setTimeFactor(0.f);
return;
}
Ogre::ControllerManager::getSingleton().setTimeFactor(
MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f);
mPlayer->update(duration); mPlayer->update(duration);
mActors.update (duration); mActors.update (duration);
mObjects.update (duration); mObjects.update (duration);
mOcclusionQuery->update(duration);
mSkyManager->update(duration); mSkyManager->update(duration);
@ -350,7 +361,7 @@ void RenderingManager::update (float duration)
float *fpos = data.getPosition().pos; float *fpos = data.getPosition().pos;
/// \note only for LocalMap::updatePlayer() // only for LocalMap::updatePlayer()
Ogre::Vector3 pos(fpos[0], -fpos[2], -fpos[1]); Ogre::Vector3 pos(fpos[0], -fpos[2], -fpos[1]);
Ogre::SceneNode *node = data.getBaseNode(); Ogre::SceneNode *node = data.getBaseNode();
@ -366,22 +377,26 @@ void RenderingManager::update (float duration)
mWater->updateUnderwater( mWater->updateUnderwater(
world->isUnderwater( world->isUnderwater(
*world->getPlayer().getPlayer().getCell()->cell, *world->getPlayer().getPlayer().getCell()->mCell,
Ogre::Vector3(cam.x, -cam.z, cam.y)) Ogre::Vector3(cam.x, -cam.z, cam.y))
); );
mWater->update(duration); mWater->update(duration);
} }
} }
void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){ void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store)
if(store->cell->mData.mFlags & store->cell->HasWater {
|| ((!(store->cell->mData.mFlags & ESM::Cell::Interior)) const MWWorld::Store<ESM::Land> &lands =
&& !MWBase::Environment::get().getWorld()->getStore().lands.search(store->cell->mData.mX,store->cell->mData.mY) )) // always use water, if the cell does not have land. MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>();
if(store->mCell->mData.mFlags & ESM::Cell::HasWater
|| ((store->mCell->isExterior())
&& !lands.search(store->mCell->getGridX(),store->mCell->getGridY()) )) // always use water, if the cell does not have land.
{ {
if(mWater == 0) if(mWater == 0)
mWater = new MWRender::Water(mRendering.getCamera(), this, store->cell); mWater = new MWRender::Water(mRendering.getCamera(), this, store->mCell);
else else
mWater->changeCell(store->cell); mWater->changeCell(store->mCell);
mWater->setActive(true); mWater->setActive(true);
} }
else else
@ -467,9 +482,9 @@ bool RenderingManager::toggleRenderMode(int mode)
void RenderingManager::configureFog(MWWorld::Ptr::CellStore &mCell) void RenderingManager::configureFog(MWWorld::Ptr::CellStore &mCell)
{ {
Ogre::ColourValue color; Ogre::ColourValue color;
color.setAsABGR (mCell.cell->mAmbi.mFog); color.setAsABGR (mCell.mCell->mAmbi.mFog);
configureFog(mCell.cell->mAmbi.mFogDensity, color); configureFog(mCell.mCell->mAmbi.mFogDensity, color);
if (mWater) if (mWater)
mWater->setViewportBackground (Ogre::ColourValue(0.8f, 0.9f, 1.0f)); mWater->setViewportBackground (Ogre::ColourValue(0.8f, 0.9f, 1.0f));
@ -519,7 +534,7 @@ void RenderingManager::setAmbientMode()
void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell) void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell)
{ {
mAmbientColor.setAsABGR (mCell.cell->mAmbi.mAmbient); mAmbientColor.setAsABGR (mCell.mCell->mAmbi.mAmbient);
setAmbientMode(); setAmbientMode();
// Create a "sun" that shines light downwards. It doesn't look // Create a "sun" that shines light downwards. It doesn't look
@ -529,7 +544,7 @@ void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell)
mSun = mRendering.getScene()->createLight(); mSun = mRendering.getScene()->createLight();
} }
Ogre::ColourValue colour; Ogre::ColourValue colour;
colour.setAsABGR (mCell.cell->mAmbi.mSunlight); colour.setAsABGR (mCell.mCell->mAmbi.mSunlight);
mSun->setDiffuseColour (colour); mSun->setDiffuseColour (colour);
mSun->setType(Ogre::Light::LT_DIRECTIONAL); mSun->setType(Ogre::Light::LT_DIRECTIONAL);
mSun->setDirection(0,-1,0); mSun->setDirection(0,-1,0);
@ -613,7 +628,7 @@ void RenderingManager::setGlare(bool glare)
void RenderingManager::requestMap(MWWorld::Ptr::CellStore* cell) void RenderingManager::requestMap(MWWorld::Ptr::CellStore* cell)
{ {
if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) if (cell->mCell->isExterior())
mLocalMap->requestMap(cell); mLocalMap->requestMap(cell);
else else
mLocalMap->requestMap(cell, mObjects.getDimensions(cell)); mLocalMap->requestMap(cell, mObjects.getDimensions(cell));

View file

@ -125,7 +125,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
/// \param store Cell the object was in previously (\a ptr has already been updated to the new cell). /// \param store Cell the object was in previously (\a ptr has already been updated to the new cell).
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::CellStore *store); void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::CellStore *store);
void update (float duration); void update (float duration, bool paused);
void setAmbientColour(const Ogre::ColourValue& colour); void setAmbientColour(const Ogre::ColourValue& colour);
void setSunColour(const Ogre::ColourValue& colour); void setSunColour(const Ogre::ColourValue& colour);

View file

@ -4,7 +4,7 @@
#include <OgreTerrainGroup.h> #include <OgreTerrainGroup.h>
#include <OgreHardwarePixelBuffer.h> #include <OgreHardwarePixelBuffer.h>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -92,10 +92,11 @@ namespace MWRender
void TerrainManager::cellAdded(MWWorld::Ptr::CellStore *store) void TerrainManager::cellAdded(MWWorld::Ptr::CellStore *store)
{ {
const int cellX = store->cell->getGridX(); const int cellX = store->mCell->getGridX();
const int cellY = store->cell->getGridY(); const int cellY = store->mCell->getGridY();
ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(cellX, cellY);
if (land == NULL) // no land data means we're not going to create any terrain. if (land == NULL) // no land data means we're not going to create any terrain.
return; return;
@ -188,8 +189,8 @@ namespace MWRender
{ {
for ( int y = 0; y < 2; y++ ) for ( int y = 0; y < 2; y++ )
{ {
int terrainX = store->cell->getGridX() * 2 + x; int terrainX = store->mCell->getGridX() * 2 + x;
int terrainY = store->cell->getGridY() * 2 + y; int terrainY = store->mCell->getGridY() * 2 + y;
if (mTerrainGroup.getTerrain(terrainX, terrainY) != NULL) if (mTerrainGroup.getTerrain(terrainX, terrainY) != NULL)
mTerrainGroup.unloadTerrain(terrainX, terrainY); mTerrainGroup.unloadTerrain(terrainX, terrainY);
} }
@ -245,7 +246,10 @@ namespace MWRender
{ {
//NB: All vtex ids are +1 compared to the ltex ids //NB: All vtex ids are +1 compared to the ltex ids
assert( (int)MWBase::Environment::get().getWorld()->getStore().landTexts.getSize() >= (int)ltexIndex - 1 && const MWWorld::Store<ESM::LandTexture> &ltexStore =
MWBase::Environment::get().getWorld()->getStore().get<ESM::LandTexture>();
assert( (int)ltexStore.getSize() >= (int)ltexIndex - 1 &&
"LAND.VTEX must be within the bounds of the LTEX array"); "LAND.VTEX must be within the bounds of the LTEX array");
std::string texture; std::string texture;
@ -255,7 +259,7 @@ namespace MWRender
} }
else else
{ {
texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->mTexture; texture = ltexStore.search(ltexIndex-1)->mTexture;
//TODO this is needed due to MWs messed up texture handling //TODO this is needed due to MWs messed up texture handling
texture = texture.substr(0, texture.rfind(".")) + ".dds"; texture = texture.substr(0, texture.rfind(".")) + ".dds";
} }
@ -411,7 +415,8 @@ namespace MWRender
} }
ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(cellX, cellY);
if ( land != NULL ) if ( land != NULL )
{ {
if (!land->isDataLoaded(ESM::Land::DATA_VTEX)) if (!land->isDataLoaded(ESM::Land::DATA_VTEX))

View file

@ -1,7 +1,7 @@
#include "cellextensions.hpp" #include "cellextensions.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <components/compiler/extensions.hpp> #include <components/compiler/extensions.hpp>
@ -87,8 +87,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
bool interior = bool interior =
MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mData.mFlags & !MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->isExterior();
ESM::Cell::Interior;
runtime.push (interior ? 1 : 0); runtime.push (interior ? 1 : 0);
} }
@ -103,14 +102,14 @@ namespace MWScript
std::string name = runtime.getStringLiteral (runtime[0].mInteger); std::string name = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop(); runtime.pop();
const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell; const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell;
std::string current = cell->mName; std::string current = cell->mName;
if (!(cell->mData.mFlags & ESM::Cell::Interior) && current.empty()) if (!(cell->mData.mFlags & ESM::Cell::Interior) && current.empty())
{ {
const ESM::Region *region = const ESM::Region *region =
MWBase::Environment::get().getWorld()->getStore().regions.find (cell->mRegion); MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().find (cell->mRegion);
current = region->mName; current = region->mName;
} }
@ -143,7 +142,7 @@ namespace MWScript
MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell();
if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) if (cell->mCell->isExterior())
throw std::runtime_error("Can't set water level in exterior cell"); throw std::runtime_error("Can't set water level in exterior cell");
cell->mWaterLevel = level; cell->mWaterLevel = level;
@ -161,7 +160,7 @@ namespace MWScript
MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell();
if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) if (cell->mCell->isExterior())
throw std::runtime_error("Can't set water level in exterior cell"); throw std::runtime_error("Can't set water level in exterior cell");
cell->mWaterLevel +=level; cell->mWaterLevel +=level;

View file

@ -1,7 +1,7 @@
#include "compilercontext.hpp" #include "compilercontext.hpp"
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <components/compiler/locals.hpp> #include <components/compiler/locals.hpp>
@ -42,26 +42,29 @@ namespace MWScript
bool CompilerContext::isId (const std::string& name) const bool CompilerContext::isId (const std::string& name) const
{ {
const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore();
return return
MWBase::Environment::get().getWorld()->getStore().activators.search (name) || store.get<ESM::Activator>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().potions.search (name) || store.get<ESM::Potion>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().appas.search (name) || store.get<ESM::Apparatus>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().armors.search (name) || store.get<ESM::Armor>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().books.search (name) || store.get<ESM::Book>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().clothes.search (name) || store.get<ESM::Clothing>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().containers.search (name) || store.get<ESM::Container>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().creatures.search (name) || store.get<ESM::Creature>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().doors.search (name) || store.get<ESM::Door>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().ingreds.search (name) || store.get<ESM::Ingredient>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().creatureLists.search (name) || store.get<ESM::CreatureLevList>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().itemLists.search (name) || store.get<ESM::ItemLevList>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().lights.search (name) || store.get<ESM::Light>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().lockpicks.search (name) || store.get<ESM::Tool>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().miscItems.search (name) || store.get<ESM::Miscellaneous>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().npcs.search (name) || store.get<ESM::NPC>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().probes.search (name) || store.get<ESM::Probe>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().repairs.search (name) || store.get<ESM::Repair>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().statics.search (name) || store.get<ESM::Static>().search (name) ||
MWBase::Environment::get().getWorld()->getStore().weapons.search (name); store.get<ESM::Weapon>().search (name);
} }
} }

View file

@ -3,8 +3,7 @@
#include <cassert> #include <cassert>
#include <components/esm_store/reclists.hpp> #include "../mwworld/esmstore.hpp"
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/scriptmanager.hpp" #include "../mwbase/scriptmanager.hpp"
@ -13,21 +12,23 @@
namespace MWScript namespace MWScript
{ {
GlobalScripts::GlobalScripts (const ESMS::ESMStore& store) GlobalScripts::GlobalScripts (const MWWorld::ESMStore& store)
: mStore (store) : mStore (store)
{ {
addScript ("Main"); addScript ("Main");
for (ESMS::RecListT<ESM::StartScript>::MapType::const_iterator iter MWWorld::Store<ESM::StartScript>::iterator iter =
(store.startScripts.list.begin()); store.get<ESM::StartScript>().begin();
iter != store.startScripts.list.end(); ++iter)
addScript (iter->second.mScript); for (; iter != store.get<ESM::StartScript>().end(); ++iter) {
addScript (iter->mScript);
}
} }
void GlobalScripts::addScript (const std::string& name) void GlobalScripts::addScript (const std::string& name)
{ {
if (mScripts.find (name)==mScripts.end()) if (mScripts.find (name)==mScripts.end())
if (const ESM::Script *script = mStore.scripts.find (name)) if (const ESM::Script *script = mStore.get<ESM::Script>().find (name))
{ {
Locals locals; Locals locals;

View file

@ -6,7 +6,7 @@
#include "locals.hpp" #include "locals.hpp"
namespace ESMS namespace MWWorld
{ {
struct ESMStore; struct ESMStore;
} }
@ -15,12 +15,12 @@ namespace MWScript
{ {
class GlobalScripts class GlobalScripts
{ {
const ESMS::ESMStore& mStore; const MWWorld::ESMStore& mStore;
std::map<std::string, std::pair<bool, Locals> > mScripts; // running, local variables std::map<std::string, std::pair<bool, Locals> > mScripts; // running, local variables
public: public:
GlobalScripts (const ESMS::ESMStore& store); GlobalScripts (const MWWorld::ESMStore& store);
void addScript (const std::string& name); void addScript (const std::string& name);

View file

@ -9,8 +9,7 @@
#include <components/interpreter/runtime.hpp> #include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp> #include <components/interpreter/opcodes.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <components/esm_store/reclists.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -109,13 +108,20 @@ namespace MWScript
// "Will match complete or partial cells, so ShowMap, "Vivec" will show cells Vivec and Vivec, Fred's House as well." // "Will match complete or partial cells, so ShowMap, "Vivec" will show cells Vivec and Vivec, Fred's House as well."
// http://www.uesp.net/wiki/Tes3Mod:ShowMap // http://www.uesp.net/wiki/Tes3Mod:ShowMap
const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; const MWWorld::Store<ESM::Cell> &cells =
for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>();
MWWorld::Store<ESM::Cell>::iterator it = cells.extBegin();
for (; it != cells.extEnd(); ++it)
{ {
std::string name = it->second->mName; std::string name = it->mName;
boost::algorithm::to_lower(name); boost::algorithm::to_lower(name);
if (name.find(cell) != std::string::npos) if (name.find(cell) != std::string::npos)
MWBase::Environment::get().getWindowManager()->addVisitedLocation (it->second->mName, it->first.first, it->first.second); MWBase::Environment::get().getWindowManager()->addVisitedLocation (
it->mName,
it->getGridX(),
it->getGridY()
);
} }
} }
}; };
@ -126,12 +132,19 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; const MWWorld::Store<ESM::Cell> &cells =
for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) MWBase::Environment::get().getWorld ()->getStore().get<ESM::Cell>();
MWWorld::Store<ESM::Cell>::iterator it = cells.extBegin();
for (; it != cells.extEnd(); ++it)
{ {
std::string name = it->second->mName; std::string name = it->mName;
if (name != "") if (name != "")
MWBase::Environment::get().getWindowManager()->addVisitedLocation (name, it->first.first, it->first.second); MWBase::Environment::get().getWindowManager()->addVisitedLocation (
name,
it->getGridX(),
it->getGridY()
);
} }
} }
}; };

View file

@ -5,7 +5,7 @@
#include <stdexcept> #include <stdexcept>
#include <components/interpreter/types.hpp> #include <components/interpreter/types.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -278,7 +278,7 @@ namespace MWScript
int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's');
ptr.getRefData().setLocals ( ptr.getRefData().setLocals (
*MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId));
return ptr.getRefData().getLocals().mShorts[index]; return ptr.getRefData().getLocals().mShorts[index];
} }
@ -291,7 +291,7 @@ namespace MWScript
int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l');
ptr.getRefData().setLocals ( ptr.getRefData().setLocals (
*MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId));
return ptr.getRefData().getLocals().mLongs[index]; return ptr.getRefData().getLocals().mLongs[index];
} }
@ -304,7 +304,7 @@ namespace MWScript
int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f');
ptr.getRefData().setLocals ( ptr.getRefData().setLocals (
*MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId));
return ptr.getRefData().getLocals().mFloats[index]; return ptr.getRefData().getLocals().mFloats[index];
} }
@ -317,7 +317,7 @@ namespace MWScript
int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's');
ptr.getRefData().setLocals ( ptr.getRefData().setLocals (
*MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId));
ptr.getRefData().getLocals().mShorts[index] = value; ptr.getRefData().getLocals().mShorts[index] = value;
} }
@ -330,7 +330,7 @@ namespace MWScript
int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l');
ptr.getRefData().setLocals ( ptr.getRefData().setLocals (
*MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId));
ptr.getRefData().getLocals().mLongs[index] = value; ptr.getRefData().getLocals().mLongs[index] = value;
} }
@ -343,7 +343,7 @@ namespace MWScript
int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f');
ptr.getRefData().setLocals ( ptr.getRefData().setLocals (
*MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId));
ptr.getRefData().getLocals().mFloats[index] = value; ptr.getRefData().getLocals().mFloats[index] = value;
} }

View file

@ -7,7 +7,7 @@
#include <exception> #include <exception>
#include <components/esm/loadscpt.hpp> #include <components/esm/loadscpt.hpp>
#include <components/esm_store/store.hpp> #include "../mwworld/esmstore.hpp"
#include <components/compiler/scanner.hpp> #include <components/compiler/scanner.hpp>
#include <components/compiler/context.hpp> #include <components/compiler/context.hpp>
@ -17,7 +17,7 @@
namespace MWScript namespace MWScript
{ {
ScriptManager::ScriptManager (const ESMS::ESMStore& store, bool verbose, ScriptManager::ScriptManager (const MWWorld::ESMStore& store, bool verbose,
Compiler::Context& compilerContext) Compiler::Context& compilerContext)
: mErrorHandler (std::cerr), mStore (store), mVerbose (verbose), : mErrorHandler (std::cerr), mStore (store), mVerbose (verbose),
mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext), mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext),
@ -31,7 +31,7 @@ namespace MWScript
bool Success = true; bool Success = true;
if (const ESM::Script *script = mStore.scripts.find (name)) if (const ESM::Script *script = mStore.get<ESM::Script>().find (name))
{ {
if (mVerbose) if (mVerbose)
std::cout << "compiling script: " << name << std::endl; std::cout << "compiling script: " << name << std::endl;
@ -125,15 +125,14 @@ namespace MWScript
std::pair<int, int> ScriptManager::compileAll() std::pair<int, int> ScriptManager::compileAll()
{ {
typedef ESMS::ScriptListT<ESM::Script>::MapType Container;
const Container& scripts = mStore.scripts.list;
int count = 0; int count = 0;
int success = 0; int success = 0;
for (Container::const_iterator iter (scripts.begin()); iter!=scripts.end(); ++iter, ++count) const MWWorld::Store<ESM::Script>& scripts = mStore.get<ESM::Script>();
if (compile (iter->first)) MWWorld::Store<ESM::Script>::iterator it = scripts.begin();
for (; it != scripts.end(); ++it, ++count)
if (compile (it->mId))
++success; ++success;
return std::make_pair (count, success); return std::make_pair (count, success);
@ -170,7 +169,7 @@ namespace MWScript
int ScriptManager::getLocalIndex (const std::string& scriptId, const std::string& variable, int ScriptManager::getLocalIndex (const std::string& scriptId, const std::string& variable,
char type) char type)
{ {
const ESM::Script *script = mStore.scripts.find (scriptId); const ESM::Script *script = mStore.get<ESM::Script>().find (scriptId);
int offset = 0; int offset = 0;
int size = 0; int size = 0;

View file

@ -14,7 +14,7 @@
#include "globalscripts.hpp" #include "globalscripts.hpp"
namespace ESMS namespace MWWorld
{ {
struct ESMStore; struct ESMStore;
} }
@ -35,7 +35,7 @@ namespace MWScript
class ScriptManager : public MWBase::ScriptManager class ScriptManager : public MWBase::ScriptManager
{ {
Compiler::StreamErrorHandler mErrorHandler; Compiler::StreamErrorHandler mErrorHandler;
const ESMS::ESMStore& mStore; const MWWorld::ESMStore& mStore;
bool mVerbose; bool mVerbose;
Compiler::Context& mCompilerContext; Compiler::Context& mCompilerContext;
Compiler::FileParser mParser; Compiler::FileParser mParser;
@ -50,7 +50,7 @@ namespace MWScript
public: public:
ScriptManager (const ESMS::ESMStore& store, bool verbose, ScriptManager (const MWWorld::ESMStore& store, bool verbose,
Compiler::Context& compilerContext); Compiler::Context& compilerContext);
virtual void run (const std::string& name, Interpreter::Context& interpreterContext); virtual void run (const std::string& name, Interpreter::Context& interpreterContext);

Some files were not shown because too many files have changed in this diff Show more