Recent Topics

Ads

[Possible Fix] - Sending Stacked Items

Talk about the development of the emulator and related services.
Check out new and upcoming features to be implemented onto the server.
Forum rules
Before posting on this forum, be sure to read the Terms of Use
User avatar
akanieski
Posts: 12

[Possible Fix] - Sending Stacked Items

Post#1 » Sun Jan 18, 2015 10:48 pm

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
--
Andrew K | Software Developer & WAR Fan

Ads
Shevarash
Posts: 40

Re: [Possible Fix] - Sending Stacked Items

Post#2 » Mon Jan 19, 2015 9:15 am

Good job m8, im sure that some of the devs will contact you
Image

User avatar
akanieski
Posts: 12

Re: [Possible Fix] - Sending Stacked Items

Post#3 » Tue Jan 20, 2015 1:24 am

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);
            }
        }
--
Andrew K | Software Developer & WAR Fan

User avatar
Tesq
Posts: 5704

Re: [Possible Fix] - Sending Stacked Items

Post#4 » Tue Jan 20, 2015 7:21 am

you should contact max & comp on war emu irc chat:
http://www.war-emu.com/index.php?sid=17 ... 9c141b1b7b
Image

Who is online

Users browsing this forum: No registered users and 54 guests