Fix gold bugs (Fixes #1145, Fixes #1146)

actorid
scrawl 11 years ago
parent 305e78c981
commit 2b15b8b484

@ -155,11 +155,8 @@ namespace MWClass
int count = ptr.getRefData().getCount(); int count = ptr.getRefData().getCount();
bool gold = isGold(ptr); bool gold = isGold(ptr);
if (gold)
if (gold && ptr.getCellRef().mGoldValue != 1) count *= getValue(ptr);
count = ptr.getCellRef().mGoldValue;
else if (gold)
count *= ref->mBase->mData.mValue;
std::string countString; std::string countString;
if (!gold) if (!gold)
@ -204,7 +201,7 @@ namespace MWClass
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
if (isGold(ptr)) { if (isGold(ptr)) {
int goldAmount = ptr.getRefData().getCount(); int goldAmount = getValue(ptr) * ptr.getRefData().getCount();
std::string base = "Gold_001"; std::string base = "Gold_001";
if (goldAmount >= 100) if (goldAmount >= 100)
@ -223,6 +220,7 @@ namespace MWClass
newRef.getPtr().get<ESM::Miscellaneous>(); newRef.getPtr().get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell); newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell);
newPtr.getCellRef().mGoldValue = goldAmount; newPtr.getCellRef().mGoldValue = goldAmount;
newPtr.getRefData().setCount(1);
} else { } else {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();

@ -192,13 +192,11 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImp (const Ptr& ptr,
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_025") || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_025")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_100")) || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_100"))
{ {
int realCount = ptr.getRefData().getCount(); int realCount = count * ptr.getClass().getValue(ptr);
if (ptr.getCellRef().mGoldValue > 1 && realCount == 1)
realCount = ptr.getCellRef().mGoldValue;
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter) for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
{ {
if (Misc::StringUtils::ciEqual((*iter).get<ESM::Miscellaneous>()->mRef.mRefID, MWWorld::ContainerStore::sGoldId)) if (Misc::StringUtils::ciEqual((*iter).getCellRef().mRefID, MWWorld::ContainerStore::sGoldId))
{ {
iter->getRefData().setCount(iter->getRefData().getCount() + realCount); iter->getRefData().setCount(iter->getRefData().getCount() + realCount);
flagAsModified(); flagAsModified();
@ -206,8 +204,8 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImp (const Ptr& ptr,
} }
} }
MWWorld::ManualRef ref(esmStore, MWWorld::ContainerStore::sGoldId, count); MWWorld::ManualRef ref(esmStore, MWWorld::ContainerStore::sGoldId, realCount);
return addNewStack(ref.getPtr(), count); return addNewStack(ref.getPtr(), realCount);
} }
// determine whether to stack or not // determine whether to stack or not

Loading…
Cancel
Save