mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 21:15:33 +00:00
Make scripted items not stack (bug #2969)
This commit is contained in:
parent
5e541c1ae1
commit
0ab5314755
3 changed files with 23 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
0.46.0
|
0.46.0
|
||||||
------
|
------
|
||||||
|
|
||||||
|
Bug #2969: Scripted items can stack
|
||||||
Bug #2987: Editor: some chance and AI data fields can overflow
|
Bug #2987: Editor: some chance and AI data fields can overflow
|
||||||
Bug #3623: Fix HiDPI on Windows
|
Bug #3623: Fix HiDPI on Windows
|
||||||
Bug #4411: Reloading a saved game while falling prevents damage in some cases
|
Bug #4411: Reloading a saved game while falling prevents damage in some cases
|
||||||
|
|
|
@ -64,7 +64,19 @@ namespace MWScript
|
||||||
|| ::Misc::StringUtils::ciEqual(item, "gold_100"))
|
|| ::Misc::StringUtils::ciEqual(item, "gold_100"))
|
||||||
item = "gold_001";
|
item = "gold_001";
|
||||||
|
|
||||||
MWWorld::Ptr itemPtr = *ptr.getClass().getContainerStore (ptr).add (item, count, ptr);
|
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
|
||||||
|
// Create a Ptr for the first added item to recover the item name later
|
||||||
|
MWWorld::Ptr itemPtr = *store.add (item, 1, ptr);
|
||||||
|
if (itemPtr.getClass().getScript(itemPtr).empty())
|
||||||
|
{
|
||||||
|
store.add (item, count-1, ptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Adding just one item per time to make sure there isn't a stack of scripted items
|
||||||
|
for (int i = 1; i < count; i++)
|
||||||
|
store.add (item, 1, 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)
|
||||||
if (ptr == MWBase::Environment::get().getWorld ()->getPlayerPtr() )
|
if (ptr == MWBase::Environment::get().getWorld ()->getPlayerPtr() )
|
||||||
|
@ -143,8 +155,13 @@ namespace MWScript
|
||||||
|
|
||||||
std::string itemName;
|
std::string itemName;
|
||||||
for (MWWorld::ConstContainerStoreIterator iter(store.cbegin()); iter != store.cend(); ++iter)
|
for (MWWorld::ConstContainerStoreIterator iter(store.cbegin()); iter != store.cend(); ++iter)
|
||||||
|
{
|
||||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
|
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
|
||||||
|
{
|
||||||
itemName = iter->getClass().getName(*iter);
|
itemName = iter->getClass().getName(*iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int numRemoved = store.remove(item, count, ptr);
|
int numRemoved = store.remove(item, count, ptr);
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,9 @@ bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2)
|
||||||
|
|
||||||
&& ptr1.getClass().getRemainingUsageTime(ptr1) == ptr2.getClass().getRemainingUsageTime(ptr2)
|
&& ptr1.getClass().getRemainingUsageTime(ptr1) == ptr2.getClass().getRemainingUsageTime(ptr2)
|
||||||
|
|
||||||
&& cls1.getScript(ptr1) == cls2.getScript(ptr2)
|
// Items with scripts never stack
|
||||||
|
&& cls1.getScript(ptr1).empty()
|
||||||
|
&& cls2.getScript(ptr2).empty()
|
||||||
|
|
||||||
// item that is already partly used up never stacks
|
// item that is already partly used up never stacks
|
||||||
&& (!cls1.hasItemHealth(ptr1) || (
|
&& (!cls1.hasItemHealth(ptr1) || (
|
||||||
|
@ -306,7 +308,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
|
||||||
item.getCellRef().unsetRefNum(); // destroy link to content file
|
item.getCellRef().unsetRefNum(); // destroy link to content file
|
||||||
|
|
||||||
std::string script = item.getClass().getScript(item);
|
std::string script = item.getClass().getScript(item);
|
||||||
if(script != "")
|
if (!script.empty())
|
||||||
{
|
{
|
||||||
if (actorPtr == player)
|
if (actorPtr == player)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue