RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

InvalidateProperties on Item and Mobile

LuxoR

Sorceror
InvalidateProperties on Item and Mobile

InvalidateProperties is called multiple times for when a single property is set (see BaseArmor.Quality), updating the OPL everytime. It should only update once, regardless of how many properties were changed. The following patches changes the logic to the desired functionality. InvalidateProperties now only sets the delta flag associated with property update. ProcessDelta updates the OPL if it is required before sending through the network. Additionally, Item.InvalidateProperties did not release the m_PropertyList packet as Mobile did, this was also changed (Highlighted in blue).

I've only done the obvious test on number of updates to the OPL after the patch, and not any thing extensive. If someone notices issues, please let me know and I'll try to get them corrected.


Code:
Index: Item.cs
===================================================================
--- Item.cs	(revision 524)
+++ Item.cs	(working copy)
@@ -1687,15 +1687,7 @@
 
 			if ( m_Map != null && m_Map != Map.Internal && !World.Loading )
 			{
[COLOR="Red"]-				ObjectPropertyList oldList = m_PropertyList;
-				m_PropertyList = null;
-				ObjectPropertyList newList = PropertyList;
-
-				if ( oldList == null || oldList.Hash != newList.Hash )
-				{
-					Packet.Release( ref m_OPLPacket );
-					Delta( ItemDelta.Properties );
-				}[/COLOR]
[COLOR="SeaGreen"]+				Delta( ItemDelta.Properties );[/COLOR]
 			}
 			else
 			{
@@ -3004,6 +2996,16 @@
 			{
 				bool sendOPLUpdate = ObjectPropertyList.Enabled && (flags & ItemDelta.Properties) != 0;
 
[COLOR="SeaGreen"]+				if ( sendOPLUpdate )
+				{
+					ObjectPropertyList oldList = m_PropertyList;
+					[COLOR="RoyalBlue"]Packet.Release( ref m_PropertyList );[/COLOR]
+					ObjectPropertyList newList = PropertyList;
+
+					if ( oldList == null || oldList.Hash != newList.Hash )
+						Packet.Release( ref m_OPLPacket );
+				}[/COLOR]
+
 				Container contParent = m_Parent as Container;
 
 				if ( contParent != null && !contParent.IsPublicContainer )
Index: Mobile.cs
===================================================================
--- Mobile.cs	(revision 524)
+++ Mobile.cs	(working copy)
@@ -8831,15 +8831,7 @@
 
 			if( m_Map != null && m_Map != Map.Internal && !World.Loading )
 			{
[COLOR="Red"]-				ObjectPropertyList oldList = m_PropertyList;
-				Packet.Release( ref m_PropertyList );
-				ObjectPropertyList newList = PropertyList;
-
-				if( oldList == null || oldList.Hash != newList.Hash )
-				{
-					Packet.Release( ref m_OPLPacket );
-					Delta( MobileDelta.Properties );
-				}[/COLOR]
[COLOR="SeaGreen"]+				Delta( MobileDelta.Properties );[/COLOR]
 			}
 			else
 			{
@@ -10000,6 +9992,16 @@
 						Packet.Release( ref cache[i][j] );
 			}
 
[COLOR="SeaGreen"]+			if ( sendOPLPacket )
+			{
+				ObjectPropertyList oldList = m_PropertyList;
+				Packet.Release( ref m_PropertyList );
+				ObjectPropertyList newList = PropertyList;
+
+				if( oldList == null || oldList.Hash != newList.Hash )
+					Packet.Release( ref m_OPLPacket );
+			}[/COLOR]
+
 			NetState ourState = m.m_NetState;
 
 			if( ourState != null )
 
Top