Page 1 of 1

[Possible Fix] - Sending Stacked Items

Posted: Sun Jan 18, 2015 10:48 pm
by akanieski
I found the following issue in the WarBugs issue tracker.

https://github.com/WarEmu/WarBugs/issues/541

It described a bug in which people cannot send stacks of items to each other via mail. I posted a fix in the comments of that issue.

What is the process for getting it tested/reviewed by others?

I'd like to move on to another bug, I just want to make sure i'm following the proper process.



Cheers! :P
--
Andrew K

Re: [Possible Fix] - Sending Stacked Items

Posted: Mon Jan 19, 2015 9:15 am
by Shevarash
Good job m8, im sure that some of the devs will contact you

Re: [Possible Fix] - Sending Stacked Items

Posted: Tue Jan 20, 2015 1:24 am
by akanieski
I noticed the other devs posted there code in the forums. I figured I'd do the same.

The item count is being persisted down to the database. However in memory the count gets zero'd out. Notice here in MailInterface.cs` line 114-116:

Code: Select all

CMail.ItemsReqInfo.Add(itm.CharItem);
                    Plr.ItmInterface.DeleteItem(itmslot, itm.CharItem.Counts, false);
                    itm.Owner = null;
DeleteItem has a third parameter which indicates if it should actually delete or not. However the second parameter seems to be the quantity that are deleted. In this case the quantity should be zero since none are actually being deleted. However the existing logic would only null the slot in inventory when the count was set to zero.

The below fixes will address this by allowing the count to be persisted in memory as well.

MailInterface.cs

Code: Select all

CMail.ItemsReqInfo.Add(itm.CharItem);
                    Plr.ItmInterface.DeleteItem(itmslot, 0, false);
                    itm.Owner = null;

ItemsInterface.cs

Code: Select all

public void DeleteItem(UInt16 SlotId,UInt16 Count,bool Delete)
        {
            //Log.Success("DeleteItem", "SlotId=" + SlotId);
            Item IFrom = GetItemInSlot(SlotId);
            if (IFrom != null)
            {
                if (Count == 0) // Remove from inventory but retain count (added to persist count when sending stacks)
                {
                    Items[SlotId] = null;
                    if (Delete)
                        IFrom.Delete();
                    Count = IFrom.Count;
                }
                else
                {
                    IFrom.Count -= Count;
                    if (IFrom.Count <= 0)
                    {
                        Items[SlotId] = null;

                        if (Delete)
                            IFrom.Delete();
                    }
                }

                if (_Owner.IsPlayer())
                {
                    SendItems(_Owner.GetPlayer(), SlotId);
                    _Owner.GetPlayer().QtsInterface.HandleEvent(Objective_Type.QUEST_GET_ITEM, IFrom.Info.Entry, Count, false);
                }

                if (IsEquipedSlot(SlotId))
                    SendEquiped(null, SlotId);
            }
        }

Re: [Possible Fix] - Sending Stacked Items

Posted: Tue Jan 20, 2015 7:21 am
by Tesq
you should contact max & comp on war emu irc chat:
http://www.war-emu.com/index.php?sid=17 ... 9c141b1b7b