public static void WriteDataUpdate(BinWriter w, BinaryTree values, object obj, bool clear, bool isClient) { try { //Console.WriteLine("Type: "+obj.GetType()); UpdateObjectInfo info = (UpdateObjectInfo)m_updateObjectInfos[obj.GetType()]; if (info == null) { throw new ObjectUpdateManagerException("UpdateObjectInfo is missing for type " + obj.GetType()); } if (!isClient && obj.GetType() == typeof(PlayerObject)) { info.MaxFields = (int)PLAYERFIELDS.MAX_NOTCLIENT; info.BlockSize = (byte)((info.MaxFields + 31) / 32); } w.Write(info.BlockSize); byte[] mask = new byte[info.BlockSize * 4]; IEnumerator e = values.GetEnumerator(); Hashtable tbl = info.tbl; long maskPos = w.BaseStream.Position; w.BaseStream.Position += mask.Length; while (e.MoveNext()) { if ((!isClient && ((int)e.Current <= (int)PLAYERFIELDS.MAX_NOTCLIENT)) || (isClient)) { IUpdateValue updater = (IUpdateValue)tbl[(int)e.Current]; if (updater == null) { throw new ObjectUpdateManagerException("UpdateValue Handler is missing for field " + e.Current + " in " + obj.GetType().ToString()); } updater.WriteValue(obj, w, mask); } } long pos = w.BaseStream.Position; w.BaseStream.Position = maskPos; w.Write(mask, 0, mask.Length); w.BaseStream.Position = pos; if (clear) { values.Clear(); } else { e.Reset(); } } catch (Exception exp) { DebugLogger.Log("", exp); } }
public static void WriteDataUpdate(BinWriter w, BinaryTree values, object obj, bool clear) { UpdateObjectInfo info = (UpdateObjectInfo)m_updateObjectInfos[obj.GetType()]; if (info == null) { throw new ObjectUpdateManagerException("UpdateObjectInfo is missing for type " + obj.GetType()); } w.Write(info.BlockSize); byte[] mask = new byte[info.BlockSize * 4]; IEnumerator e = values.GetEnumerator(); Hashtable tbl = info.tbl; long maskPos = w.BaseStream.Position; w.BaseStream.Position += mask.Length; while (e.MoveNext()) { IUpdateValue updater = (IUpdateValue)tbl[(int)e.Current]; if (updater == null) { throw new ObjectUpdateManagerException("UpdateValue Handler is missing for field " + e.Current + " in " + obj.GetType().ToString()); } updater.WriteValue(obj, w, mask); } long pos = w.BaseStream.Position; w.BaseStream.Position = maskPos; w.Write(mask, 0, mask.Length); w.BaseStream.Position = pos; if (clear) { values.Clear(); } else { e.Reset(); } }