EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   COMMITTED: Fix for losing items in world containers (https://www.eqemulator.org/forums/showthread.php?t=31957)

wheeljack 08-28-2010 07:06 PM

COMMITTED: Fix for losing items in world containers
 
Problem: If you put an item in a world container such as a forge or an aug sealer, walk away or go linkdead, then somebody else uses the world container or the zone shuts down, your items are gone. See http://www.eqemulator.org/forums/showthread.php?t=25547

Solution: This patch will put any remaining items from a world container onto the user's cursor when the world container is closed. I *think* that live might only put the no drop items from a world container onto your cursor if you walk away with the window up and leave the tradeable items in there for the next person, but I believe that it returns them all to you if you go linkdead while using a world container. I don't have a live account to verify all the different scenarios and it seemed safest to always just put them on the cursor rather than missing some bizarre edge case and have people potentially lose items.

Code:

Index: zone/Object.cpp
===================================================================
--- zone/Object.cpp        (revision 1634)
+++ zone/Object.cpp        (working copy)
@@ -357,6 +357,22 @@
        m_inuse = false;
        if(user != NULL) {
                last_user = user;
+
+                // put any remaining items from the world container onto the user's cursor to avoid item loss
+                //  if they close the container without removing all items
+                ItemInst* container = this->m_inst;
+                if(container != NULL)
+                {
+                        for (uint8 i = 0; i < MAX_ITEMS_PER_BAG; i++)
+                        {
+                                ItemInst* inst = container->PopItem(i);
+                                if(inst != NULL)
+                                {
+                                        user->PushItemOnCursor(*inst, true);
+                                }
+                        }
+                }
+
                user->SetTradeskillObject(NULL);
        }
        user = NULL;

I tested walking away from the container while open, going linkdead with a container open, zoning with a container open, and dieing with a container open and all worked quite well.

ChaosSlayerZ 08-28-2010 08:37 PM

awesome! I must say many players inadvertently cause zone crashes by simply hitting their ESc key accidentally or trying to change their mind about what they want to put into container.

This will solve a lot of problems!
Great work!

Derision 09-11-2010 10:22 AM

Thanks. I committed this, but I had the items placed directly into the player's inventory as I checked on Live and that is what happens.


All times are GMT -4. The time now is 12:25 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.