private static DropReq DequeueDropFor(Serial s) { DropReq dr = null; if (m_DropReqs.TryGetValue(s, out var q) && q != null) { if (q.Count > 0) { dr = q.Dequeue(); } if (q.Count <= 0) { m_DropReqs.Remove(s); } } return(dr); }
private static DropReq DequeueDropFor(Serial s) { DropReq dr = null; Queue q = (Queue)m_DropReqs[s]; if (q != null) { if (q.Count > 0) { dr = q.Dequeue() as DropReq; } if (q.Count <= 0) { m_DropReqs.Remove(s); } } return(dr); }
private static DropReq DequeueDropFor(Serial s) { if (!m_DropReqs.ContainsKey(s)) { return(null); } DropReq dr = null; Queue <DropReq> q = m_DropReqs[s]; if (q.Count > 0) { dr = q.Dequeue(); } if (q.Count <= 0) { m_DropReqs.Remove(s); } return(dr); }
public static ProcStatus ProcessNext(int numPending) { if (m_Pending != Serial.Zero) { if (m_Lifted + TimeSpan.FromMinutes(2) < DateTime.UtcNow) { Item i = World.FindItem(m_Pending); Log("Lift timeout, forced drop to pack for {0}", m_Pending); if (World.Player != null) { World.Player.SendMessage(MsgLevel.Force, LocString.ForceEndHolding); if (World.Player.Backpack != null) { Client.Instance.SendToServer(new DropRequest(m_Pending, Point3D.MinusOne, World.Player.Backpack.Serial)); } else { Client.Instance.SendToServer(new DropRequest(m_Pending, World.Player.Position, Serial.Zero)); } } m_Holding = m_Pending = Serial.Zero; m_HoldingItem = null; m_Lifted = DateTime.MinValue; } else { return(ProcStatus.KeepWaiting); } } if (m_Front == m_Back) { m_Front = m_Back = 0; return(ProcStatus.Nothing); } LiftReq lr = m_LiftReqs[m_Front]; if (numPending > 0 && lr != null && lr.DoLast) { return(ProcStatus.ReQueue); } m_LiftReqs[m_Front] = null; m_Front++; if (lr != null) { Log("Lifting {0}", lr); Item item = World.FindItem(lr.Serial); if (item != null && item.Container == null) { // if the item is on the ground and out of range then dont grab it if (Utility.Distance(item.GetWorldPosition(), World.Player.Position) > 3) { Log("Item is too far away... uncaching."); ScavengerAgent.Instance.Uncache(item.Serial); return(ProcStatus.Nothing); } } Client.Instance.SendToServer(new LiftRequest(lr.Serial, lr.Amount)); m_LastID = lr.Id; m_Holding = lr.Serial; m_HoldingItem = World.FindItem(lr.Serial); m_ClientLiftReq = lr.FromClient; DropReq dr = DequeueDropFor(lr.Serial); if (dr != null) { m_Pending = Serial.Zero; m_Lifted = DateTime.MinValue; Log("Dropping {0} to {1}", lr, dr.Serial); if (dr.Serial.IsMobile && dr.Layer > Layer.Invalid && dr.Layer <= Layer.LastUserValid) { Client.Instance.SendToServer(new EquipRequest(lr.Serial, dr.Serial, dr.Layer)); } else { Client.Instance.SendToServer(new DropRequest(lr.Serial, dr.Point, dr.Serial)); } } else { m_Pending = lr.Serial; m_Lifted = DateTime.UtcNow; } return(ProcStatus.Success); } else { Log("No lift to be done?!"); return(ProcStatus.Nothing); } }