View Single Post
  #1  
Old 08-28-2010, 07:06 PM
wheeljack
Fire Beetle
 
Join Date: Aug 2010
Posts: 18
Default 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.
Reply With Quote