From 0079f62180afe7ddf2f9ec3f2d543bca07ee2891 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 30 Mar 2013 16:27:06 +0100 Subject: [PATCH] Gold condition now always checks RefID instead of the name. This is necessary because in the french MW version, the sGold GMST is different from the name of the gold references. --- apps/openmw/mwclass/misc.cpp | 7 ++++- apps/openmw/mwworld/containerstore.cpp | 38 +++++++++++--------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index b971fa6f3..e4d7235cb 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -158,7 +158,12 @@ namespace MWClass int count = ptr.getRefData().getCount(); - bool isGold = (ref->mBase->mName == store.get().find("sGold")->getString()); + bool isGold = Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_001") + || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_005") + || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_010") + || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_025") + || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_100"); + if (isGold && ptr.getCellRef().mGoldValue != 1) count = ptr.getCellRef().mGoldValue; else if (isGold) diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index e5b68841b..a377f2bbb 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -111,34 +111,28 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImp (const Ptr& ptr) // gold needs special handling: when it is inserted into a container, the base object automatically becomes Gold_001 // this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for detecting player gold) - if (MWWorld::Class::get(ptr).getName(ptr) == esmStore.get().find("sGold")->getString()) + if (Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_001") + || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_005") + || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_010") + || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_025") + || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_100")) { - MWWorld::LiveCellRef *gold = - ptr.get(); + MWWorld::ManualRef ref(esmStore, "Gold_001"); - if (Misc::StringUtils::ciEqual(gold->mRef.mRefID, "gold_001") - || Misc::StringUtils::ciEqual(gold->mRef.mRefID, "gold_005") - || Misc::StringUtils::ciEqual(gold->mRef.mRefID, "gold_010") - || Misc::StringUtils::ciEqual(gold->mRef.mRefID, "gold_025") - || Misc::StringUtils::ciEqual(gold->mRef.mRefID, "gold_100")) + int count = MWWorld::Class::get(ptr).getValue(ptr) * ptr.getRefData().getCount(); + + ref.getPtr().getRefData().setCount(count); + for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter) { - MWWorld::ManualRef ref(esmStore, "Gold_001"); - - int count = MWWorld::Class::get(ptr).getValue(ptr) * ptr.getRefData().getCount(); - - ref.getPtr().getRefData().setCount(count); - for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter) + if (Misc::StringUtils::ciEqual((*iter).get()->mRef.mRefID, "gold_001")) { - if (Misc::StringUtils::ciEqual((*iter).get()->mRef.mRefID, "gold_001")) - { - (*iter).getRefData().setCount( (*iter).getRefData().getCount() + count); - flagAsModified(); - return iter; - } + (*iter).getRefData().setCount( (*iter).getRefData().getCount() + count); + flagAsModified(); + return iter; } - - return addImpl(ref.getPtr()); } + + return addImpl(ref.getPtr()); } // determine whether to stack or not