mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-23 19:39:42 +00:00
Fix faction rank not being set on items in faction-owned containers
This commit is contained in:
parent
0081a68376
commit
3912ee2b1d
7 changed files with 28 additions and 17 deletions
|
@ -59,7 +59,7 @@ namespace MWClass
|
||||||
ptr.get<ESM::Container>();
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
data->mContainerStore.fill(
|
data->mContainerStore.fill(
|
||||||
ref->mBase->mInventory, ptr.getCellRef().getOwner(), ptr.getCellRef().getFaction(), MWBase::Environment::get().getWorld()->getStore());
|
ref->mBase->mInventory, ptr.getCellRef().getOwner(), ptr.getCellRef().getFaction(), ptr.getCellRef().getFactionRank(), MWBase::Environment::get().getWorld()->getStore());
|
||||||
|
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData (data.release());
|
ptr.getRefData().setCustomData (data.release());
|
||||||
|
@ -81,7 +81,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
|
MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
|
||||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||||
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
||||||
store.restock(list, ptr, ptr.getCellRef().getOwner(), ptr.getCellRef().getFaction());
|
store.restock(list, ptr, ptr.getCellRef().getOwner(), ptr.getCellRef().getFaction(), ptr.getCellRef().getFactionRank());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace MWClass
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData(data.release());
|
ptr.getRefData().setCustomData(data.release());
|
||||||
|
|
||||||
getContainerStore(ptr).fill(ref->mBase->mInventory, getId(ptr), "",
|
getContainerStore(ptr).fill(ref->mBase->mInventory, getId(ptr), "", -1,
|
||||||
MWBase::Environment::get().getWorld()->getStore());
|
MWBase::Environment::get().getWorld()->getStore());
|
||||||
|
|
||||||
if (ref->mBase->mFlags & ESM::Creature::Weapon)
|
if (ref->mBase->mFlags & ESM::Creature::Weapon)
|
||||||
|
@ -888,7 +888,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
||||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||||
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
||||||
store.restock(list, ptr, ptr.getCellRef().getRefId(), ptr.getCellRef().getFaction());
|
store.restock(list, ptr, ptr.getCellRef().getRefId(), "", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Creature::getBaseFightRating(const MWWorld::Ptr &ptr) const
|
int Creature::getBaseFightRating(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -403,7 +403,7 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
|
|
||||||
// inventory
|
// inventory
|
||||||
data->mInventoryStore.fill(ref->mBase->mInventory, getId(ptr), "",
|
data->mInventoryStore.fill(ref->mBase->mInventory, getId(ptr), "", -1,
|
||||||
MWBase::Environment::get().getWorld()->getStore());
|
MWBase::Environment::get().getWorld()->getStore());
|
||||||
|
|
||||||
data->mNpcStats.setGoldPool(gold);
|
data->mNpcStats.setGoldPool(gold);
|
||||||
|
@ -1376,7 +1376,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
||||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||||
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
||||||
store.restock(list, ptr, ptr.getCellRef().getRefId(), ptr.getCellRef().getFaction());
|
store.restock(list, ptr, ptr.getCellRef().getRefId(), "", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Npc::getBaseFightRating (const MWWorld::Ptr& ptr) const
|
int Npc::getBaseFightRating (const MWWorld::Ptr& ptr) const
|
||||||
|
|
|
@ -99,6 +99,15 @@ namespace MWWorld
|
||||||
return mCellRef.mGlobalVariable;
|
return mCellRef.mGlobalVariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CellRef::setFactionRank(int factionRank)
|
||||||
|
{
|
||||||
|
if (factionRank != mCellRef.mFactionRank)
|
||||||
|
{
|
||||||
|
mChanged = true;
|
||||||
|
mCellRef.mFactionRank = factionRank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int CellRef::getFactionRank() const
|
int CellRef::getFactionRank() const
|
||||||
{
|
{
|
||||||
return mCellRef.mFactionRank;
|
return mCellRef.mFactionRank;
|
||||||
|
|
|
@ -79,6 +79,7 @@ namespace MWWorld
|
||||||
void setFaction (const std::string& faction);
|
void setFaction (const std::string& faction);
|
||||||
|
|
||||||
// PC faction rank required to use the item. Sometimes is -1, which means "any rank".
|
// PC faction rank required to use the item. Sometimes is -1, which means "any rank".
|
||||||
|
void setFactionRank(int factionRank);
|
||||||
int getFactionRank() const;
|
int getFactionRank() const;
|
||||||
|
|
||||||
// Lock level for doors and containers
|
// Lock level for doors and containers
|
||||||
|
|
|
@ -396,19 +396,19 @@ int MWWorld::ContainerStore::remove(const Ptr& item, int count, const Ptr& actor
|
||||||
return count - toRemove;
|
return count - toRemove;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const std::string& owner, const std::string& faction, const MWWorld::ESMStore& store)
|
void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const std::string& owner, const std::string& faction, int factionRank, const MWWorld::ESMStore& store)
|
||||||
{
|
{
|
||||||
for (std::vector<ESM::ContItem>::const_iterator iter (items.mList.begin()); iter!=items.mList.end();
|
for (std::vector<ESM::ContItem>::const_iterator iter (items.mList.begin()); iter!=items.mList.end();
|
||||||
++iter)
|
++iter)
|
||||||
{
|
{
|
||||||
std::string id = Misc::StringUtils::lowerCase(iter->mItem.toString());
|
std::string id = Misc::StringUtils::lowerCase(iter->mItem.toString());
|
||||||
addInitialItem(id, owner, faction, iter->mCount);
|
addInitialItem(id, owner, faction, factionRank, iter->mCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::string& owner, const std::string& faction,
|
void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::string& owner, const std::string& faction, int factionRank,
|
||||||
int count, bool topLevel, const std::string& levItem)
|
int count, bool topLevel, const std::string& levItem)
|
||||||
{
|
{
|
||||||
ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), id, count);
|
ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), id, count);
|
||||||
|
@ -420,7 +420,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
|
||||||
if (topLevel && std::abs(count) > 1 && levItem->mFlags & ESM::ItemLevList::Each)
|
if (topLevel && std::abs(count) > 1 && levItem->mFlags & ESM::ItemLevList::Each)
|
||||||
{
|
{
|
||||||
for (int i=0; i<std::abs(count); ++i)
|
for (int i=0; i<std::abs(count); ++i)
|
||||||
addInitialItem(id, owner, faction, count > 0 ? 1 : -1, true, levItem->mId);
|
addInitialItem(id, owner, faction, factionRank, count > 0 ? 1 : -1, true, levItem->mId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -428,7 +428,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
|
||||||
std::string id = MWMechanics::getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, false);
|
std::string id = MWMechanics::getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, false);
|
||||||
if (id.empty())
|
if (id.empty())
|
||||||
return;
|
return;
|
||||||
addInitialItem(id, owner, faction, count, false, levItem->mId);
|
addInitialItem(id, owner, faction, factionRank, count, false, levItem->mId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -445,11 +445,12 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
|
||||||
|
|
||||||
ref.getPtr().getCellRef().setOwner(owner);
|
ref.getPtr().getCellRef().setOwner(owner);
|
||||||
ref.getPtr().getCellRef().setFaction(faction);
|
ref.getPtr().getCellRef().setFaction(faction);
|
||||||
|
ref.getPtr().getCellRef().setFactionRank(factionRank);
|
||||||
addImp (ref.getPtr(), count);
|
addImp (ref.getPtr(), count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MWWorld::Ptr& ptr, const std::string& owner, const std::string& faction)
|
void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MWWorld::Ptr& ptr, const std::string& owner, const std::string& faction, int factionRank)
|
||||||
{
|
{
|
||||||
// Remove the items already spawned by levelled items that will restock
|
// Remove the items already spawned by levelled items that will restock
|
||||||
for (std::map<std::string, int>::iterator it = mLevelledItemMap.begin(); it != mLevelledItemMap.end(); ++it)
|
for (std::map<std::string, int>::iterator it = mLevelledItemMap.begin(); it != mLevelledItemMap.end(); ++it)
|
||||||
|
@ -468,13 +469,13 @@ void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MW
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::ItemLevList>().search(it->mItem.toString()))
|
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::ItemLevList>().search(it->mItem.toString()))
|
||||||
{
|
{
|
||||||
addInitialItem(item, owner, faction, it->mCount, true);
|
addInitialItem(item, owner, faction, factionRank, it->mCount, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int currentCount = count(item);
|
int currentCount = count(item);
|
||||||
if (currentCount < std::abs(it->mCount))
|
if (currentCount < std::abs(it->mCount))
|
||||||
addInitialItem(item, owner, faction, std::abs(it->mCount) - currentCount, true);
|
addInitialItem(item, owner, faction, factionRank, std::abs(it->mCount) - currentCount, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace MWWorld
|
||||||
mutable float mCachedWeight;
|
mutable float mCachedWeight;
|
||||||
mutable bool mWeightUpToDate;
|
mutable bool mWeightUpToDate;
|
||||||
ContainerStoreIterator addImp (const Ptr& ptr, int count);
|
ContainerStoreIterator addImp (const Ptr& ptr, int count);
|
||||||
void addInitialItem (const std::string& id, const std::string& owner, const std::string& faction, int count, bool topLevel=true, const std::string& levItem = "");
|
void addInitialItem (const std::string& id, const std::string& owner, const std::string& faction, int factionRank, int count, bool topLevel=true, const std::string& levItem = "");
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ContainerStoreIterator getState (CellRefList<T>& collection,
|
ContainerStoreIterator getState (CellRefList<T>& collection,
|
||||||
|
@ -153,10 +153,10 @@ namespace MWWorld
|
||||||
virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2);
|
virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2);
|
||||||
///< @return true if the two specified objects can stack with each other
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
|
||||||
void fill (const ESM::InventoryList& items, const std::string& owner, const std::string& faction, const MWWorld::ESMStore& store);
|
void fill (const ESM::InventoryList& items, const std::string& owner, const std::string& faction, int factionRank, const MWWorld::ESMStore& store);
|
||||||
///< Insert items into *this.
|
///< Insert items into *this.
|
||||||
|
|
||||||
void restock (const ESM::InventoryList& items, const MWWorld::Ptr& ptr, const std::string& owner, const std::string& faction);
|
void restock (const ESM::InventoryList& items, const MWWorld::Ptr& ptr, const std::string& owner, const std::string& faction, int factionRank);
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
///< Empty container.
|
///< Empty container.
|
||||||
|
|
Loading…
Reference in a new issue