forked from mirror/openmw-tes3mp
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>();
|
||||
|
||||
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
|
||||
ptr.getRefData().setCustomData (data.release());
|
||||
|
@ -81,7 +81,7 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
|
||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||
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
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace MWClass
|
|||
// store
|
||||
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());
|
||||
|
||||
if (ref->mBase->mFlags & ESM::Creature::Weapon)
|
||||
|
@ -888,7 +888,7 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||
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
|
||||
|
|
|
@ -403,7 +403,7 @@ namespace MWClass
|
|||
}
|
||||
|
||||
// inventory
|
||||
data->mInventoryStore.fill(ref->mBase->mInventory, getId(ptr), "",
|
||||
data->mInventoryStore.fill(ref->mBase->mInventory, getId(ptr), "", -1,
|
||||
MWBase::Environment::get().getWorld()->getStore());
|
||||
|
||||
data->mNpcStats.setGoldPool(gold);
|
||||
|
@ -1376,7 +1376,7 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||
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
|
||||
|
|
|
@ -99,6 +99,15 @@ namespace MWWorld
|
|||
return mCellRef.mGlobalVariable;
|
||||
}
|
||||
|
||||
void CellRef::setFactionRank(int factionRank)
|
||||
{
|
||||
if (factionRank != mCellRef.mFactionRank)
|
||||
{
|
||||
mChanged = true;
|
||||
mCellRef.mFactionRank = factionRank;
|
||||
}
|
||||
}
|
||||
|
||||
int CellRef::getFactionRank() const
|
||||
{
|
||||
return mCellRef.mFactionRank;
|
||||
|
|
|
@ -79,6 +79,7 @@ namespace MWWorld
|
|||
void setFaction (const std::string& faction);
|
||||
|
||||
// PC faction rank required to use the item. Sometimes is -1, which means "any rank".
|
||||
void setFactionRank(int factionRank);
|
||||
int getFactionRank() const;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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();
|
||||
++iter)
|
||||
{
|
||||
std::string id = Misc::StringUtils::lowerCase(iter->mItem.toString());
|
||||
addInitialItem(id, owner, faction, iter->mCount);
|
||||
addInitialItem(id, owner, faction, factionRank, iter->mCount);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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);
|
||||
if (id.empty())
|
||||
return;
|
||||
addInitialItem(id, owner, faction, count, false, levItem->mId);
|
||||
addInitialItem(id, owner, faction, factionRank, count, false, levItem->mId);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -445,11 +445,12 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
|
|||
|
||||
ref.getPtr().getCellRef().setOwner(owner);
|
||||
ref.getPtr().getCellRef().setFaction(faction);
|
||||
ref.getPtr().getCellRef().setFactionRank(factionRank);
|
||||
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
|
||||
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()))
|
||||
{
|
||||
addInitialItem(item, owner, faction, it->mCount, true);
|
||||
addInitialItem(item, owner, faction, factionRank, it->mCount, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int currentCount = count(item);
|
||||
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();
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace MWWorld
|
|||
mutable float mCachedWeight;
|
||||
mutable bool mWeightUpToDate;
|
||||
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>
|
||||
ContainerStoreIterator getState (CellRefList<T>& collection,
|
||||
|
@ -153,10 +153,10 @@ namespace MWWorld
|
|||
virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2);
|
||||
///< @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.
|
||||
|
||||
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();
|
||||
///< Empty container.
|
||||
|
|
Loading…
Reference in a new issue