Some enchanting fixes

actorid
Glorf 12 years ago
parent 6643fe789c
commit eb88463b94

@ -274,18 +274,19 @@ namespace MWClass
return ref->mBase->mEnchant;
}
MWWorld::Ptr Armor::applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const
MWWorld::Ptr Armor::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESM::Armor oldItem = *store.get<ESM::Armor>().find(ptr.getCellRef().mRefID);
ESM::Armor newItem = oldItem;
MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>();
ESM::Armor newItem = *ref->mBase;
newItem.mId="";
newItem.mName=newName;
newItem.mData.mEnchant=enchCharge;
newItem.mEnchant=enchId;
const ESM::Armor *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
return ref.getPtr();
MWWorld::ManualRef mref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
return mref.getPtr();
}
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const

@ -65,7 +65,7 @@ namespace MWClass
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const;
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const;

@ -148,19 +148,20 @@ namespace MWClass
return ref->mBase->mEnchant;
}
MWWorld::Ptr Book::applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const
MWWorld::Ptr Book::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESM::Book oldItem = *store.get<ESM::Book>().find(ptr.getCellRef().mRefID);
ESM::Book newItem = oldItem;
MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>();
ESM::Book newItem = *ref->mBase;
newItem.mId="";
newItem.mName=newName;
newItem.mData.mIsScroll = 1;
newItem.mData.mEnchant=enchCharge;
newItem.mEnchant=enchId;
const ESM::Book *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
return ref.getPtr();
MWWorld::ManualRef mref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
return mref.getPtr();
}
boost::shared_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr) const

@ -51,7 +51,7 @@ namespace MWClass
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const;
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const;
///< Generate action for using via inventory menu

@ -222,18 +222,19 @@ namespace MWClass
return ref->mBase->mEnchant;
}
MWWorld::Ptr Clothing::applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const
MWWorld::Ptr Clothing::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESM::Clothing oldItem = *store.get<ESM::Clothing>().find(ptr.getCellRef().mRefID);
ESM::Clothing newItem = oldItem;
MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>();
ESM::Clothing newItem = *ref->mBase;
newItem.mId="";
newItem.mName=newName;
newItem.mData.mEnchant=enchCharge;
newItem.mEnchant=enchId;
const ESM::Clothing *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
return ref.getPtr();
MWWorld::ManualRef mref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
return mref.getPtr();
}
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const

@ -59,7 +59,7 @@ namespace MWClass
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const;
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const;

@ -362,18 +362,19 @@ namespace MWClass
return ref->mBase->mEnchant;
}
MWWorld::Ptr Weapon::applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const
MWWorld::Ptr Weapon::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESM::Weapon oldItem = *store.get<ESM::Weapon>().find(ptr.getCellRef().mRefID);
ESM::Weapon newItem = oldItem;
MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>();
ESM::Weapon newItem = *ref->mBase;
newItem.mId="";
newItem.mName=newName;
newItem.mData.mEnchant=enchCharge;
newItem.mEnchant=enchId;
const ESM::Weapon *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
return ref.getPtr();
MWWorld::ManualRef mref (MWBase::Environment::get().getWorld()->getStore(), record->mId);
return mref.getPtr();
}
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const

@ -65,7 +65,7 @@ namespace MWClass
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const;
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const;

@ -62,8 +62,8 @@ namespace MWMechanics
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), newobj.getCellRef().mRefID);
MWWorld::Class::get (mEnchanter).getContainerStore (mEnchanter).add (ref.getPtr());
mOldItemPtr.getRefData().setCount(0);
mSoulGemPtr.getRefData().setCount(0);
mOldItemPtr.getRefData().setCount(mOldItemPtr.getRefData().getCount()-1);
mSoulGemPtr.getRefData().setCount(mSoulGemPtr.getRefData().getCount()-1);
}
void Enchanting::nextEnchantType()

@ -241,7 +241,7 @@ namespace MWWorld
return "";
}
MWWorld::Ptr Class::applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const
MWWorld::Ptr Class::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
{
throw std::runtime_error ("class can't be enchanted");
}

@ -231,7 +231,7 @@ namespace MWWorld
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, std::string enchId, int enchCharge, std::string newName) const;
virtual MWWorld::Ptr applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
virtual Ptr
copyToCell(const Ptr &ptr, CellStore &cell) const;

Loading…
Cancel
Save