private static void OnTimeEvent(object source, ElapsedEventArgs e) { Dictionary <int, int> tempDic = new Dictionary <int, int>(); MacroDropMgr.m_lock.AcquireWriterLock(-1); try { foreach (KeyValuePair <int, MacroDropInfo> kvp in DropInfoMgr.DropInfo) { int templateId = kvp.Key; MacroDropInfo macroDropInfo = kvp.Value; if (macroDropInfo.SelfDropCount > 0) { tempDic.Add(templateId, macroDropInfo.SelfDropCount); macroDropInfo.SelfDropCount = 0; } } } catch (Exception ex) { //if (MacroDropMgr.log.IsErrorEnabled) { MacroDropMgr.log.Error("DropInfoMgr OnTimeEvent", ex); } } finally { MacroDropMgr.m_lock.ReleaseWriterLock(); } MacroDropMgr.SendMacroDrop(tempDic); }
public void HandleMacroDrop(GSPacketIn pkg) { Dictionary <int, MacroDropInfo> temp = new Dictionary <int, MacroDropInfo>(); int count = pkg.ReadInt(); for (int i = 0; i < count; i++) { int templateId = pkg.ReadInt(); int dropcount = pkg.ReadInt(); int maxCount = pkg.ReadInt(); MacroDropInfo mdi = new MacroDropInfo(dropcount, maxCount); temp.Add(templateId, mdi); } MacroDropMgr.UpdateDropInfo(temp); }
public void HandleMacroDrop(GSPacketIn pkg) { Dictionary <int, MacroDropInfo> dictionary = new Dictionary <int, MacroDropInfo>(); int num = pkg.ReadInt(); for (int i = 0; i < num; i++) { int key = pkg.ReadInt(); int dropCount = pkg.ReadInt(); int maxDropCount = pkg.ReadInt(); MacroDropInfo value = new MacroDropInfo(dropCount, maxDropCount); dictionary.Add(key, value); } MacroDropMgr.UpdateDropInfo(dictionary); }
//每两分钟向服务器端报告一次掉落物品数量 private static void OnTimeEvent(object source, ElapsedEventArgs e) { Dictionary <int, int> tempDic = new Dictionary <int, int>(); m_lock.AcquireWriterLock(Timeout.Infinite); try { foreach (KeyValuePair <int, MacroDropInfo> kvp in DropInfoMgr.DropInfo) { int templateId = kvp.Key; MacroDropInfo macroDropInfo = kvp.Value; if (macroDropInfo.SelfDropCount > 0) { tempDic.Add(templateId, macroDropInfo.SelfDropCount); macroDropInfo.SelfDropCount = 0; } } } catch (Exception ex) { if (log.IsErrorEnabled) { log.Error("DropInfoMgr OnTimeEvent", ex); } } finally { m_lock.ReleaseWriterLock(); } if (tempDic.Count > 0) { GSPacketIn pkg = new GSPacketIn((byte)eChatServerPacket.MACRO_DROP); pkg.WriteInt(tempDic.Count); foreach (KeyValuePair <int, int> kvp in tempDic) { pkg.WriteInt(kvp.Key); pkg.WriteInt(kvp.Value); } GameServer.Instance.LoginServer.SendPacket(pkg); } }
private static void OnTimeEvent(object source, ElapsedEventArgs e) { Dictionary <int, int> dictionary = new Dictionary <int, int>(); MacroDropMgr.m_lock.AcquireWriterLock(15000); try { foreach (KeyValuePair <int, MacroDropInfo> current in DropInfoMgr.DropInfo) { int key = current.Key; MacroDropInfo value = current.Value; if (value.SelfDropCount > 0) { dictionary.Add(key, value.SelfDropCount); value.SelfDropCount = 0; } } } catch (Exception exception) { if (MacroDropMgr.log.IsErrorEnabled) { MacroDropMgr.log.Error("DropInfoMgr OnTimeEvent", exception); } } finally { MacroDropMgr.m_lock.ReleaseWriterLock(); } if (dictionary.Count > 0) { GSPacketIn gSPacketIn = new GSPacketIn(178); gSPacketIn.WriteInt(dictionary.Count); foreach (KeyValuePair <int, int> current2 in dictionary) { gSPacketIn.WriteInt(current2.Key); gSPacketIn.WriteInt(current2.Value); } GameServer.Instance.LoginServer.SendPacket(gSPacketIn); } }