1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:23:52 +00:00

Fix a few gold conditions that I missed, trade window was affected

This commit is contained in:
scrawl 2013-03-30 18:29:21 +01:00
parent a723ad8f29
commit 0f0cc0e3e3
3 changed files with 25 additions and 26 deletions

View file

@ -23,6 +23,18 @@
#include <boost/lexical_cast.hpp>
namespace
{
bool isGold (const MWWorld::Ptr& ptr)
{
return 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");
}
}
namespace MWClass
{
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -109,25 +121,15 @@ namespace MWClass
std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>();
if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGold")->getString())
{
if (isGold(ptr))
return std::string("Item Gold Up");
}
return std::string("Item Misc Up");
}
std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>();
if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGold")->getString())
{
if (isGold(ptr))
return std::string("Item Gold Down");
}
return std::string("Item Misc Down");
}
@ -158,19 +160,15 @@ namespace MWClass
int count = ptr.getRefData().getCount();
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");
bool gold = isGold(ptr);
if (isGold && ptr.getCellRef().mGoldValue != 1)
if (gold && ptr.getCellRef().mGoldValue != 1)
count = ptr.getCellRef().mGoldValue;
else if (isGold)
else if (gold)
count *= ref->mBase->mData.mValue;
std::string countString;
if (!isGold)
if (!gold)
countString = MWGui::ToolTips::getCountString(count);
else // gold displays its count also if it's 1.
countString = " (" + boost::lexical_cast<std::string>(count) + ")";
@ -186,7 +184,7 @@ namespace MWClass
std::string text;
if (!isGold)
if (!gold)
{
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
@ -210,7 +208,7 @@ namespace MWClass
const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore();
if (MWWorld::Class::get(ptr).getName(ptr) == store.get<ESM::GameSetting>().find("sGold")->getString()) {
if (isGold(ptr)) {
int goldAmount = ptr.getRefData().getCount();
std::string base = "Gold_001";

View file

@ -144,9 +144,7 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
// the player is trying to sell an item, check if the merchant accepts it
// also, don't allow selling gold (let's be better than Morrowind at this, can we?)
if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object) ||
MWWorld::Class::get(object).getName(object) == gmst.find("sGold")->getString())
if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object))
{
// user notification "i don't buy this item"
MWBase::Environment::get().getWindowManager()->

View file

@ -135,7 +135,7 @@ namespace MWGui
for (MWWorld::ContainerStoreIterator it = playerStore.begin();
it != playerStore.end(); ++it)
{
if (MWWorld::Class::get(*it).getName(*it) == gmst.find("sGold")->getString())
if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, "gold_001"))
{
goldFound = true;
gold = *it;
@ -342,6 +342,9 @@ namespace MWGui
bool TradeWindow::npcAcceptsItem(MWWorld::Ptr item)
{
if (Misc::StringUtils::ciEqual(item.getCellRef().mRefID, "gold_001"))
return false;
int services = 0;
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
{