/// <summary> /// Writes the log. /// </summary> /// <param name="context">The context.</param> /// <param name="stream">The stream.</param> /// <param name="callback">The callback for UI updates.</param> public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback) { Hashtable items = new Hashtable(); using (StreamWriter s = new StreamWriter(stream)) { foreach (PacketLog log in context.LogManager.Logs) { for (int i = 0; i < log.Count; i++) { if (callback != null && (i & 0xFFF) == 0) // update progress every 4096th packet { callback(i, log.Count - 1); } Packet pak = log[i]; if (pak is StoC_0x1F_MarketMerchant) { StoC_0x1F_MarketMerchant market = pak as StoC_0x1F_MarketMerchant; for (int j = 0; j < market.ItemCount; j++) { StoC_0x1F_MarketMerchant.MerchantItem markeditem = market.Items[j]; markeditem.name = markeditem.name.Substring(6); if (!items.Contains(markeditem.name)) { Item item = new Item(); item.level = markeditem.level; item.value1 = markeditem.value1; item.value2 = markeditem.value2; item.hand = markeditem.hand; item.damageAndObjectType = markeditem.damageAndObjectType; item.weight = markeditem.weight; item.condition = markeditem.condition; item.durability = markeditem.durability; item.quality = markeditem.quality; item.bonus = markeditem.bonus; item.model = markeditem.model; item.color = markeditem.color; item.effect = markeditem.effect; item.name = markeditem.name; items.Add(item.name, item); } } } else if (pak is StoC_0x17_MerchantWindow) { StoC_0x17_MerchantWindow merchant = pak as StoC_0x17_MerchantWindow; for (int j = 0; j < merchant.ItemCount; j++) { StoC_0x17_MerchantWindow.MerchantItem merchantitem = merchant.Items[j]; if (!items.Contains(merchantitem.name)) { Item item = new Item(); item.level = merchantitem.level; item.value1 = merchantitem.value1; item.value2 = merchantitem.value2; item.hand = merchantitem.hand; item.damageAndObjectType = merchantitem.damageAndObjectType; item.weight = merchantitem.weight; // item.condition = merchantitem.condition; // item.durability = merchantitem.durability; // item.quality = merchantitem.quality; // item.bonus = merchantitem.bonus; item.model = merchantitem.model; // item.color = merchantitem.color; // item.effect = merchantitem.effect; item.name = merchantitem.name; items.Add(item.name, item); } } } else if (pak is StoC_0xC4_CustomTextWindow) { StoC_0xC4_CustomTextWindow custom = pak as StoC_0xC4_CustomTextWindow; string name = custom.Caption; if (name[4] == ':') { name = name.Substring(6); } if (items.Contains(name)) { Item item = items[name] as Item; StringBuilder str = new StringBuilder(); str.AppendFormat("\tcaption: \"{0}\"", name); for (int j = 0; j < custom.Lines.Length; j++) { StoC_0xC4_CustomTextWindow.LineEntry line = custom.Lines[j]; str.AppendFormat("\n\t{0,2}: \"{1}\"", line.number, line.text); } str.Append('\n'); item.description = str.ToString(); items[name] = item; } } } // for (log.packets) } // foreach (context.logs) foreach (DictionaryEntry entry in items) { Item item = (Item)entry.Value; if (item.description == null || item.description == "") { s.WriteLine(string.Format("level:{0,-2} value1:{1,-3} value2:{2,-3} hand:0x{3:X2} damageType:{4,-1} objectType:0x{5:X2} weigh:{6,-4} condition:{7,3} durability:{8,3} quality:{9,3} bonus:{10,2} model:0x{11:X4} color:0x{12:X4} effect:0x{13:X4} name:\"{14}\"", item.level, item.value1, item.value2, item.hand, item.damageAndObjectType >> 6, item.damageAndObjectType & 0x3F, item.weight / 10f, item.condition, item.durability, item.quality, item.bonus, item.model, item.color, item.effect, item.name)); } } foreach (DictionaryEntry entry in items) { Item item = (Item)entry.Value; if (item.description != null && item.description != "") { s.WriteLine(string.Format("level:{0,-2} value1:{1,-3} value2:{2,-3} hand:0x{3:X2} damageType:{4,-1} objectType:0x{5:X2} weigh:{6,-4} condition:{7,3} durability:{8,3} quality:{9,3} bonus:{10,2} model:0x{11:X4} color:0x{12:X4} effect:0x{13:X4} name:\"{14}\"", item.level, item.value1, item.value2, item.hand, item.damageAndObjectType >> 6, item.damageAndObjectType & 0x3F, item.weight / 10f, item.condition, item.durability, item.quality, item.bonus, item.model, item.color, item.effect, item.name)); s.WriteLine(item.description); } } } }
private void CheckItemsHitsBonus(PacketLog log, int selectedIndex, StringBuilder str, ref int bonusHits, ref int bonusHitCap, ref int bonusPower, ref int bonusPowerPool, ref int bonusPowerPoolCap) { SortedList m_inventoryItems = new SortedList(); int VisibleSlots = 0xFF; for (int i = 0; i <= selectedIndex; i++) { Packet pak = log[i]; if (pak is StoC_0x20_PlayerPositionAndObjectID_171) { VisibleSlots = 0xFF; m_inventoryItems.Clear(); } else if (pak is StoC_0x02_InventoryUpdate) { StoC_0x02_InventoryUpdate invPack = (StoC_0x02_InventoryUpdate)pak; if ((invPack.PreAction >= 0 && invPack.PreAction <= 1) || (invPack.PreAction >= 10 && invPack.PreAction <= 11)) { VisibleSlots = invPack.VisibleSlots; } if ((invPack.PreAction >= 0 && invPack.PreAction <= 2) || (invPack.PreAction >= 10 && invPack.PreAction <= 12)) { for (int j = 0; j < invPack.SlotsCount; j++) { StoC_0x02_InventoryUpdate.Item item = (StoC_0x02_InventoryUpdate.Item)invPack.Items[j]; if (item.slot >= 10 && item.slot < 40) // Only equiped slot { if (item.name == null || item.name == "") { if (m_inventoryItems.ContainsKey(item.slot)) { m_inventoryItems.Remove(item.slot); } } else { m_inventoryItems[item.slot] = new BonusItem(item); } } } } } } for (int i = 0; i < log.Count; i++) { Packet pak = log[i]; if (pak is StoC_0xC4_CustomTextWindow) { foreach (BonusItem item in m_inventoryItems.Values) { if (item.slot < 40) { if (item.slot >= 10 && item.slot <= 13) { if (!(((item.slot - 10) == (VisibleSlots & 0x0F)) || ((item.slot - 10) == ((VisibleSlots >> 4) & 0x0F)))) { continue; } } if (item.delvePack == null && item.name == (pak as StoC_0xC4_CustomTextWindow).Caption) { item.delvePack = pak as StoC_0xC4_CustomTextWindow; } } } } } foreach (BonusItem item in m_inventoryItems.Values) { if (item.slot < 40) { if (item.slot >= 10 && item.slot <= 13) { if (!(((item.slot - 10) == (VisibleSlots & 0x0F)) || ((item.slot - 10) == ((VisibleSlots >> 4) & 0x0F)))) { continue; } } str.AppendFormat("\nslot:{0,-3} objectType:0x{1:X2} \"{2}\" ({3})", item.slot, item.objectType, item.name, (StoC_0x02_InventoryUpdate.eObjectType)item.objectType); if (item.delvePack == null) { str.Append(" - delve not found"); } else { int flagDelveShowed = 0; bool flagArtifact = false; for (int i = 0; i < item.delvePack.Lines.Length; i++) { StoC_0xC4_CustomTextWindow.LineEntry line = item.delvePack.Lines[i]; string text = line.text; if (flagArtifact) { int artLevelDescBegin = line.text.IndexOf("[L"); if (artLevelDescBegin >= 0) { text = line.text.Substring(0, artLevelDescBegin) + line.text.Substring(line.text.IndexOf("]: ") + 3); } } if (line.text.StartsWith("Artifact (Current level:")) { flagArtifact = true; } else if (text.StartsWith("- Hits: ")) { if (flagDelveShowed++ > 0) { str.Append(','); } str.Append(' '); str.Append(line.text); bonusHits += int.Parse(text.Substring(8, text.IndexOf(" pts") - 8)); } else if (text.StartsWith("Bonus to hit points bonus cap:")) { if (flagDelveShowed++ > 0) { str.Append(','); } str.Append(' '); str.Append(line.text); bonusHitCap += int.Parse(text.Substring(31)); } else if (text.StartsWith("- Power: ")) { if (flagDelveShowed++ > 0) { str.Append(','); } str.Append(' '); str.Append(line.text); if (text.IndexOf(" % of power pool") >= 0) { bonusPowerPool += int.Parse(text.Substring(9, text.IndexOf(" % of power pool") - 9)); } else if (text.IndexOf(" pts") >= 0) { bonusPower += int.Parse(text.Substring(9, text.IndexOf(" pts") - 9)); } } } } } } }