1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 22:39:39 +00:00

Merge remote-tracking branch 'koncord/fix-gold-beh'

This commit is contained in:
Marc Zinnschlag 2015-07-22 08:30:43 +02:00
commit 6e3032efc1
5 changed files with 31 additions and 17 deletions

View file

@ -25,9 +25,9 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
namespace namespace MWClass
{ {
bool isGold (const MWWorld::Ptr& ptr) bool Miscellaneous::isGold (const MWWorld::Ptr& ptr) const
{ {
return Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001") return Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_005") || Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_005")
@ -35,10 +35,6 @@ bool isGold (const MWWorld::Ptr& ptr)
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025") || Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100"); || Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100");
} }
}
namespace MWClass
{
std::string Miscellaneous::getId (const MWWorld::Ptr& ptr) const std::string Miscellaneous::getId (const MWWorld::Ptr& ptr) const
{ {
return ptr.get<ESM::Miscellaneous>()->mBase->mId; return ptr.get<ESM::Miscellaneous>()->mBase->mId;

View file

@ -62,6 +62,8 @@ namespace MWClass
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
virtual bool isKey (const MWWorld::Ptr &ptr) const; virtual bool isKey (const MWWorld::Ptr &ptr) const;
virtual bool isGold (const MWWorld::Ptr& ptr) const;
}; };
} }

View file

@ -56,6 +56,12 @@ namespace MWScript
if (count == 0) if (count == 0)
return; return;
if(Misc::StringUtils::ciEqual(item, "gold_005")
|| Misc::StringUtils::ciEqual(item, "gold_010")
|| Misc::StringUtils::ciEqual(item, "gold_025")
|| Misc::StringUtils::ciEqual(item, "gold_100"))
item = "gold_001";
MWWorld::Ptr itemPtr = *ptr.getClass().getContainerStore (ptr).add (item, count, ptr); MWWorld::Ptr itemPtr = *ptr.getClass().getContainerStore (ptr).add (item, count, ptr);
// Spawn a messagebox (only for items added to player's inventory and if player is talking to someone) // Spawn a messagebox (only for items added to player's inventory and if player is talking to someone)
@ -91,6 +97,12 @@ namespace MWScript
std::string item = runtime.getStringLiteral (runtime[0].mInteger); std::string item = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop(); runtime.pop();
if(Misc::StringUtils::ciEqual(item, "gold_005")
|| Misc::StringUtils::ciEqual(item, "gold_010")
|| Misc::StringUtils::ciEqual(item, "gold_025")
|| Misc::StringUtils::ciEqual(item, "gold_100"))
item = "gold_001";
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr); MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
runtime.push (store.count(item)); runtime.push (store.count(item));
@ -119,6 +131,12 @@ namespace MWScript
if (count == 0) if (count == 0)
return; return;
if(Misc::StringUtils::ciEqual(item, "gold_005")
|| Misc::StringUtils::ciEqual(item, "gold_010")
|| Misc::StringUtils::ciEqual(item, "gold_025")
|| Misc::StringUtils::ciEqual(item, "gold_100"))
item = "gold_001";
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr); MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
std::string itemName; std::string itemName;

View file

@ -284,6 +284,8 @@ namespace MWWorld
virtual bool isKey (const MWWorld::Ptr& ptr) const { return false; } virtual bool isKey (const MWWorld::Ptr& ptr) const { return false; }
virtual bool isGold(const MWWorld::Ptr& ptr) const { return false; };
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini) /// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
virtual int getBloodTexture (const MWWorld::Ptr& ptr) const; virtual int getBloodTexture (const MWWorld::Ptr& ptr) const;

View file

@ -298,11 +298,7 @@ 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 // 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) // this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for detecting player gold)
if (Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001") if(ptr.getClass().isGold(ptr))
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_005")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_010")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100"))
{ {
int realCount = count * ptr.getClass().getValue(ptr); int realCount = count * ptr.getClass().getValue(ptr);