private void OnSendData(SendDataEventArgs args) { if (args.MsgId != PacketTypes.ItemDrop) { return; } int number = args.number; if (this._playerDropsPending.Count > 0 && number < 400) { Item item = Main.item[number]; ItemDrop itemDrop = this._playerDropsPending.FirstOrDefault((ItemDrop x) => x.NetworkId == item.netID && x.Stack == item.stack && x.Prefix == item.prefix); if (itemDrop != null) { lock (this._dropLocker) { this._drops[number] = itemDrop; } lock (this._pendingLocker) { this._playerDropsPending.Remove(itemDrop); } } } }
private void OnGetData(GetDataEventArgs args) { if ((int)args.MsgID == (int)PacketTypes.ItemDrop) { TSPlayer tSPlayer = TShock.Players[args.Msg.whoAmI]; using (MemoryStream memoryStream = new MemoryStream(args.Msg.readBuffer, args.Index, args.Length)) { using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8, true)) { int num = (int)binaryReader.ReadInt16(); float num2 = binaryReader.ReadSingle(); float num3 = binaryReader.ReadSingle(); binaryReader.ReadSingle(); binaryReader.ReadSingle(); int num4 = (int)binaryReader.ReadInt16(); int num5 = (int)binaryReader.ReadByte(); binaryReader.ReadBoolean(); int num6 = (int)binaryReader.ReadInt16(); if (num == 400) { Item itemById = TShock.Utils.GetItemById(num6); string name = tSPlayer.Name; string sourceIP = tSPlayer.IP.Split(new char[] { ':' })[0]; lock (this._pendingLocker) { float dropX = num2 / 16f; float dropY = num3 / 16f; this._playerDropsPending.Add(new ItemDrop(name, itemById.netID, num4, num5, dropX, dropY)); if (this.CheckItem(itemById)) { ItemDropLogger.CreateItemEntry(new ItemDropLogInfo("PlayerDrop", name, string.Empty, itemById.netID, num4, num5, dropX, dropY) { SourceIP = sourceIP }); } } } if (num < 400 && num6 == 0) { Item item = Main.item[num]; if (item.netID != 0) { string name2 = tSPlayer.Name; string targetIP = tSPlayer.IP.Split(new char[] { ':' })[0]; lock (this._dropLocker) { ItemDrop itemDrop = this._drops[num]; if (this._drops[num] != null && this._drops[num].NetworkId != 0) { if (this.CheckItem(item)) { ItemDropLogger.UpdateItemEntry(new ItemDropLogInfo("Pickup", itemDrop.SourceName, name2, itemDrop.NetworkId, itemDrop.Stack, (int)itemDrop.Prefix) { TargetIP = targetIP }); } this._drops[num] = null; } } } } } } } }