fix: Fixes serious stacking issue (#1225)
* Fixes a major bug where players can stack items into their backpack infinitely even if they get a message saying they can't. * Fixes other minor issues and cleans up code.
This commit is contained in:
parent
d0ba94aa83
commit
e47b62c0ae
5 changed files with 17 additions and 23 deletions
|
|
@ -56,7 +56,7 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
Patch = pat;
|
||||
Type = type;
|
||||
|
||||
SourceString = Utility.Intern(ToStringImpl());
|
||||
SourceString = ToStringImpl().Intern();
|
||||
}
|
||||
|
||||
public ClientVersion(string fmt)
|
||||
|
|
|
|||
|
|
@ -2311,7 +2311,7 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
|
|||
|
||||
public virtual bool OnDragDrop(Mobile from, Item dropped)
|
||||
{
|
||||
var success = Parent is Container container && container.OnStackAttempt(from, this, dropped) ||
|
||||
var success = (Parent as Container)?.OnStackAttempt(from, this, dropped) ??
|
||||
StackWith(from, dropped);
|
||||
|
||||
if (success && Spawner != null)
|
||||
|
|
|
|||
|
|
@ -134,19 +134,16 @@ namespace Server.Engines.CannedEvil
|
|||
{
|
||||
from.SendLocalizedMessage(1049486); // You can only sacrifice items that are in your backpack!
|
||||
}
|
||||
else if (skull.Type == Type)
|
||||
{
|
||||
skull.Movable = false;
|
||||
skull.MoveToWorld(GetWorldTop(), Map);
|
||||
|
||||
Skull = skull;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (skull.Type == Type)
|
||||
{
|
||||
skull.Movable = false;
|
||||
skull.MoveToWorld(GetWorldTop(), Map);
|
||||
|
||||
Skull = skull;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1049488); // That is not my champions awakening skull!
|
||||
}
|
||||
SendLocalizedMessageTo(from, 1049488); // That is not my champions awakening skull!
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ namespace Server.Items;
|
|||
[SerializationGenerator(0, false)]
|
||||
public partial class WrathOfTheDryad : GnarledStaff
|
||||
{
|
||||
public override WeaponAbility PrimaryAbility => WeaponAbility.ConcussionBlow;
|
||||
public override WeaponAbility SecondaryAbility => WeaponAbility.ParalyzingBlow;
|
||||
|
||||
[Constructible]
|
||||
public WrathOfTheDryad()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -381,9 +381,7 @@ namespace Server.Items
|
|||
{
|
||||
var rand = Utility.Random(i + 1);
|
||||
|
||||
var temp = attackers[rand];
|
||||
attackers[rand] = attackers[i];
|
||||
attackers[i] = temp;
|
||||
(attackers[rand], attackers[i]) = (attackers[i], attackers[rand]);
|
||||
}
|
||||
|
||||
// stackables first, for the remaining stackables, have those be randomly added after
|
||||
|
|
@ -394,17 +392,13 @@ namespace Server.Items
|
|||
|
||||
if (item.Amount >= attackers.Count)
|
||||
{
|
||||
var amountPerAttacker = item.Amount / attackers.Count;
|
||||
var remainder = item.Amount % attackers.Count;
|
||||
var amountPerAttacker = Math.DivRem(item.Amount, attackers.Count, out var remainder);
|
||||
|
||||
for (var j = 0; j < (remainder == 0 ? attackers.Count - 1 : attackers.Count); j++)
|
||||
{
|
||||
// LiftItemDupe automagically adds it as a child item to the corpse
|
||||
var splitItem =
|
||||
Mobile.LiftItemDupe(
|
||||
item,
|
||||
item.Amount -
|
||||
amountPerAttacker
|
||||
); // LiftItemDupe automagically adds it as a child item to the corpse
|
||||
Mobile.LiftItemDupe(item, item.Amount - amountPerAttacker);
|
||||
|
||||
m_InstancedItems.Add(splitItem, new InstancedItemInfo(splitItem, attackers[j]));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue