public static Packet TrockInventoryUpdate(ItemConstants.TrockMapAction action, ItemConstants.TrockType type) { Packet trockInventoryUpdatePacket = new Packet(ServerOperationCode.MapTransferResult); trockInventoryUpdatePacket .WriteByte((byte)action) .WriteByte((byte)type) .WriteBytes(type == ItemConstants.TrockType.Regular ? CharacterTrocks.RegularTrockToByteArray() : CharacterTrocks.VIPTrockToByteArray()); return(trockInventoryUpdatePacket); }
public void UpdateTrockHandler(Packet inPacket) { ItemConstants.TrockMapAction action = (ItemConstants.TrockMapAction)inPacket.ReadByte(); ItemConstants.TrockType type = (ItemConstants.TrockType)inPacket.ReadByte(); switch (action) { case ItemConstants.TrockMapAction.RemoveMapTrock: { int mapID = inPacket.ReadInt(); switch (type) { case ItemConstants.TrockType.Regular: if (!RegularTrocks.Contains(mapID)) { return; } VIPTrocks.Remove(mapID); break; case ItemConstants.TrockType.VIP: if (!VIPTrocks.Contains(mapID)) { return; } VIPTrocks.Remove(mapID); break; default: throw new ArgumentOutOfRangeException(); } } break; case ItemConstants.TrockMapAction.AddMapTrock: { int mapID = TrockParent.Map.MapleID; if (TrockParent.Map.FieldLimit != (int)MapConstants.FieldLimit.CannotUseVIPTrock) { switch (type) { case ItemConstants.TrockType.Regular: if (RegularTrocks.Contains(mapID)) { return; } RegularTrocks.Add(mapID); break; case ItemConstants.TrockType.VIP: if (VIPTrocks.Contains(mapID)) { return; } VIPTrocks.Add(mapID); break; default: throw new ArgumentOutOfRangeException(); } } else { Character.Notify(TrockParent, "[TrockHandler] This map cannot be added to teleport rock!"); } } break; default: throw new ArgumentOutOfRangeException(); } TrockParent.Client.Send(CharacterTrocksPackets.TrockInventoryUpdate(action, type)); }