private void ParseItemNano(int rectype, int recnum, byte[] data) { this.BR = new Parser.BufferedReader(rectype,recnum,data, this.Tracing); bool flag; flag = !Parser.Output.ItemNano_Begin(XR.RecordNum, XR.RecordType == 1040005, CS); if (flag) { return; } br.SkipBytes(16, "Pre-Attr"); int num = br.ReadCNum("AttrCount"); Plugin.ItemNanoInfo info = default(Plugin.ItemNanoInfo); List<Plugin.ItemNanoKeyVal> list = new List<Plugin.ItemNanoKeyVal>(); bool flag2 = false; int arg_C0_0 = 0; short num5; short num6; checked { int num2 = num - 1; int num3 = arg_C0_0; while (true) { int arg_1C2_0 = num3; int num4 = num2; if (arg_1C2_0 > num4) { break; } Plugin.ItemNanoKeyVal item = default(Plugin.ItemNanoKeyVal); item.AttrKey = br.ReadInt32("AttrKey" + Conversions.ToString(num3)); item.AttrVal = br.ReadInt32("AttrVal" + Conversions.ToString(num3)); list.Add(item); int attrKey = item.AttrKey; flag = (attrKey == 54); if (flag) { info.QL = item.AttrVal; } else { flag = (attrKey == 76); if (flag) { info.EquipPage = item.AttrVal; } else { flag = (attrKey == 88); if (flag) { info.DefaultSlot = item.AttrVal; } else { flag = (attrKey == 298); if (flag) { info.EquipSlots = item.AttrVal; } else { flag = (attrKey == 388); if (flag) { flag2 = true; } } } } } num3++; } br.SkipBytes(8, "Post-Attr"); num5 = br.ReadInt16("NameLen"); num6 = br.ReadInt16("DescLen"); } bool arg_222_0; if (num5 >= 0 && num6 >= 0) { if ((long)num5 <= 4095L) { if ((long)num6 <= 4095L) { arg_222_0 = false; goto IL_222; } } } arg_222_0 = true; IL_222: flag = arg_222_0; if (flag) { br.DebugDump("NameLen or DescLen is invalid", Parser.ParserReturns.Failed); } flag = (num5 > 0); if (flag) { info.Name = br.ReadString((int)num5, "Name"); } else { info.Name = ""; } flag = (num6 > 0); if (flag) { info.Description = br.ReadString((int)num6, "Description"); } else { info.Description = ""; } BitManipulation bitManipulation = new BitManipulation(); info.Type = info.EquipPage; flag = (Strings.InStr(info.Name, "_", CompareMethod.Binary) != 0 || Strings.InStr(Strings.UCase(info.Name), "BOSS", CompareMethod.Binary) != 0); if (flag) { info.Type = 4; } else { flag = flag2; if (flag) { info.Type = 7; } else { flag = (info.EquipPage == 1); if (flag) { bool flag3 = bitManipulation.CheckBit((long)info.EquipSlots, 6) || bitManipulation.CheckBit((long)info.EquipSlots, 8); if (flag3) { info.Type = 1; } else { info.Type = 6; } } } } try { Parser.Output.ItemNano(info, list.ToArray()); } catch (SQLiteException expr_371) { ProjectData.SetProjectError(expr_371); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_387) { ProjectData.SetProjectError(expr_387); Exception ex3 = expr_387; CustomException ex4 = new CustomException(ex3.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } bool flag4 = true; checked { while (br.Ptr < br.Buffer.Length - 8 && flag4) { switch (br.ReadInt32("ParseSetsKeyNum")) { case 2: this.ParseFunctionSet(ref flag4); break; case 3: case 5: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 15: case 16: case 17: case 18: case 19: case 21: goto IL_4BF; case 4: this.ParseAtkDefSet(ref flag4); break; case 6: { br.SkipBytes(4, "Pre-SkipSet"); int count = br.ReadCNum("SkipSet") * 8; br.SkipBytes(count, "Post-SkipSet"); break; } case 14: this.ParseAnimSoundSet(1, ref flag4); break; case 20: this.ParseAnimSoundSet(2, ref flag4); break; case 22: this.ParseActionSet(ref flag4); break; case 23: this.ParseShopHash(ref flag4); break; default: goto IL_4BF; } continue; IL_4BF: flag4 = this.CritError("Invalid KeyNum"); } try { Parser.Output.ItemNano_End(); } catch (SQLiteException expr_50A) { ProjectData.SetProjectError(expr_50A); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_520) { ProjectData.SetProjectError(expr_520); Exception ex5 = expr_520; CustomException ex6 = new CustomException(ex5.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } } }
private void GetCRCs() { this.lblStat.Text = "Reading Checksums..."; Parser.GZB = new gzbFile(this.OldDF, FileMode.Open, CompressionMode.Decompress); Parser.GZB.ReadHeader(); while (Parser.ReturnCode == Parser.ParserReturns.Parsing) { gzbFile.FileXRDB4Record fileXRDB4Record = Parser.GZB.ReadRecord(); bool flag = fileXRDB4Record.MarkerTag != -559038242; if (flag) { CustomException ex = new CustomException(string.Format("{0}{1}{0}{2}is corrupt!", '"', Parser.GZB.FileStream.Name, "\r\n"), "Corrupted data file detected"); Parser.ReturnCode = Parser.ParserReturns.Failed; return; } flag = (fileXRDB4Record.RecordType == 0); if (flag) { break; } string key = Conversions.ToString(fileXRDB4Record.RecordType) + ":" + Conversions.ToString(fileXRDB4Record.RecordNum); this.Checksums.Add(key, fileXRDB4Record.RecordCRC); this.pbProg.Value = checked((int)Math.Round(unchecked((double)Parser.GZB.FileStream.Position / (double)Parser.GZB.FileStream.Length * 100.0))); Main.DoEvents(); } Parser.GZB.Close(); Parser.GZB = null; }
private void DoParse() { checked { while (Parser.ReturnCode == Parser.ParserReturns.Parsing) { gzbFile.FileXRDB4Record xR = Parser.GZB.ReadRecord(); bool flag = xR.MarkerTag != -559038242; if (flag) { CustomException ex = new CustomException(string.Format("{0}{1}{0}{2}is corrupt!", '"', Parser.GZB.FileStream.Name, "\r\n"), "Corrupted data file detected"); Parser.Abort("Corrupt Datafile"); Parser.ReturnCode = Parser.ParserReturns.Failed; break; } string key = Conversions.ToString(xR.RecordType) + ":" + Conversions.ToString(xR.RecordNum); flag = this.Blacklist.ContainsKey(key); if (!flag) { Plugin.ChangeStates changeStates = Plugin.ChangeStates.NewRecord; flag = this.Checksums.ContainsKey(key); bool flag2; if (flag) { flag2 = Operators.ConditionalCompareObjectNotEqual(this.Checksums[key], xR.RecordCRC, false); if (flag2) { changeStates = Plugin.ChangeStates.ModifiedRecord; } else { changeStates = Plugin.ChangeStates.NoChange; } } Application.DoEvents(); this.AOID = xR.RecordNum; int recordType = xR.RecordType; flag2 = (recordType == 0); if (flag2) { Parser.ReturnCode = Parser.ParserReturns.Success; break; } flag2 = (recordType == 1000020 || recordType == 1040005); if (flag2) { this.ParseItemNano(xR, changeStates); } else { try { flag2 = !Parser.Output.OtherData_Begin(xR.RecordNum, xR.RecordType, changeStates); if (flag2) { continue; } Parser.Output.OtherData(xR.RecordData); Parser.Output.OtherData_End(); } catch (SQLiteException expr_197) { ProjectData.SetProjectError(expr_197); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_1AD) { ProjectData.SetProjectError(expr_1AD); Exception ex2 = expr_1AD; CustomException ex3 = new CustomException(ex2.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } } Main.TotalParsed++; } } } }
private int CleanReturn() { try { bool flag = Parser.GZB != null; if (flag) { Parser.GZB.Close(); } Parser.GZB = null; } catch (SQLiteException expr_24) { ProjectData.SetProjectError(expr_24); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_39) { ProjectData.SetProjectError(expr_39); ProjectData.ClearProjectError(); } return (int)Parser.ReturnCode; }
public Parser.ParserReturns Parse() { Parser.SkipCompare = (Operators.CompareString(this.OldDF, "", false) == 0); Parser.ReturnCode = Parser.ParserReturns.Parsing; Main.TotalParsed = 0; bool flag = Parser.SkipCompare & !Main.JobParse; if (flag) { this.lblStat.Text = "Full Parse?"; flag = (Interaction.MsgBox(string.Format("You're about to perform a full parse.{0}This operation could take a long time.{0}Are you sure you want to do this?", "\r\n"), MsgBoxStyle.YesNo | MsgBoxStyle.Critical | MsgBoxStyle.Question, null) == MsgBoxResult.No); if (flag) { Parser.ParserReturns result = Parser.ParserReturns.Aborted; return result; } } else { flag = !Parser.SkipCompare; if (flag) { this.GetCRCs(); } flag = (Parser.ReturnCode != Parser.ParserReturns.Parsing); if (flag) { Parser.ParserReturns result = (Parser.ParserReturns)this.CleanReturn(); return result; } } Parser.GZB = new gzbFile(this.NewDF, FileMode.Open, CompressionMode.Decompress); Parser.XH = Parser.GZB.ReadHeader(); this.lblStat.Text = "Initializing Plugin..."; Main.DoEvents(); Parser.cThread = new Thread(new ThreadStart(this.PreParse)); Parser.cThread.IsBackground = false; Parser.cThread.Priority = Parser.Pri; Parser.cThread.Start(); int pri = (int)Parser.Pri; checked { while (Parser.cThread.IsAlive) { flag = (Parser.Pri != (ThreadPriority)pri); if (flag) { pri = (int)Parser.Pri; Parser.cmbPrior.SelectedIndex = (int)(ThreadPriority.Highest - Parser.Pri); } Main.DoEvents(); } flag = (Parser.ReturnCode != Parser.ParserReturns.Parsing); Parser.ParserReturns result; if (flag) { result = (Parser.ParserReturns)this.CleanReturn(); } else { this.LoadFunctionSets(Parser.XH.FileVer); this.lblStat.Text = "Parsing..."; Main.DoEvents(); Parser.pThread = new Thread(new ThreadStart(this.DoParse)); Parser.pThread.IsBackground = false; Parser.pThread.Priority = Parser.Pri; Parser.pThread.Start(); while (Parser.ReturnCode == Parser.ParserReturns.Parsing) { this.pbProg.Value = (int)Math.Round(unchecked((double)Parser.GZB.FileStream.Position / (double)Parser.GZB.FileStream.Length * 100.0)); this.pbProg.Refresh(); flag = (Parser.Pri != (ThreadPriority)pri); if (flag) { pri = (int)Parser.Pri; Parser.cmbPrior.SelectedIndex = (int)(ThreadPriority.Highest - Parser.Pri); } Main.DoEvents(); } int num = this.CleanReturn(); flag = (Parser.ReturnCode != Parser.ParserReturns.Success); if (flag) { result = (Parser.ParserReturns)num; } else { this.lblStat.Text = "Finalizing..."; Parser.cThread = new Thread(new ThreadStart(this.PostParse)); Parser.cThread.IsBackground = false; Parser.cThread.Priority = Parser.Pri; Parser.cThread.Start(); while (Parser.cThread.IsAlive) { flag = (Parser.Pri != (ThreadPriority)pri); if (flag) { pri = (int)Parser.Pri; Parser.cmbPrior.SelectedIndex = (int)(ThreadPriority.Highest - Parser.Pri); } Main.DoEvents(); } result = (Parser.ParserReturns)this.CleanReturn(); } } return result; } }
private void PreParse() { try { Parser.Output.Parse_Begin(Main.ParsePath, Main.pvStr(Parser.XH.FileVer, "."), Parser.SkipCompare, Main.PCMD); } catch (SQLiteException expr_32) { ProjectData.SetProjectError(expr_32); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_47) { ProjectData.SetProjectError(expr_47); Exception ex = expr_47; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } }
private void PostParse() { try { Parser.Output.Parse_End(false); } catch (SQLiteException expr_10) { ProjectData.SetProjectError(expr_10); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_25) { ProjectData.SetProjectError(expr_25); Exception ex = expr_25; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } }
public void ForceAbort(string Msg) { Parser.myAbortMsg = Msg; Parser.ReturnCode = Parser.ParserReturns.Aborted; bool flag = Parser.GZB != null; if (flag) { Parser.GZB.Close(); } }
private static void Abort(string Msg) { try { Parser.myAbortMsg = Msg; Parser.Output.Parse_End(true); } catch (SQLiteException expr_16) { ProjectData.SetProjectError(expr_16); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_2B) { ProjectData.SetProjectError(expr_2B); Exception ex = expr_2B; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } Parser.ReturnCode = Parser.ParserReturns.Aborted; bool flag = Parser.pThread != null; if (flag) { Parser.pThread.Abort(); } }
private void ParseAtkDefSet(ref bool R) { List<Plugin.ItemNanoKeyVal> list = new List<Plugin.ItemNanoKeyVal>(); List<Plugin.ItemNanoKeyVal> list2 = new List<Plugin.ItemNanoKeyVal>(); br.SkipBytes(4, "AtkDefSkip"); int num = br.ReadCNum("MaxSet"); int arg_34_0 = 1; int num2 = num; int num3 = arg_34_0; checked { while (true) { int arg_163_0 = num3; int num4 = num2; if (arg_163_0 > num4) { break; } int value = br.ReadInt32("Key"); int num5 = br.ReadCNum("Sets"); int arg_63_0 = 1; int num6 = num5; int num7 = arg_63_0; while (true) { int arg_152_0 = num7; num4 = num6; if (arg_152_0 > num4) { break; } Plugin.ItemNanoKeyVal item = default(Plugin.ItemNanoKeyVal); item.AttrKey = br.ReadInt32("AttrKey"); item.AttrVal = br.ReadInt32("AttrVal"); while (true) { switch (value) { case 3: { bool flag = Parser.XH.FileVer == 15000100 && this.AOID == 213413; if (flag) { value = 13; continue; } goto IL_10D; } case 12: goto IL_110; case 13: goto IL_11C; } goto Block_1; } IL_142: num7++; continue; IL_10D: goto IL_142; IL_110: list.Add(item); goto IL_142; IL_11C: list2.Add(item); goto IL_142; IL_128: R = this.CritError("Unhandled AtkDef Set: " + Conversions.ToString(value)); goto IL_142; Block_1: goto IL_128; } num3++; } try { Parser.Output.ItemNanoAttackAndDefense(list.ToArray(), list2.ToArray()); } catch (SQLiteException expr_182) { ProjectData.SetProjectError(expr_182); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_198) { ProjectData.SetProjectError(expr_198); Exception ex = expr_198; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } } }
private void ParseFunctionSet(ref bool R) { int eventNum = br.ReadInt32("EventNum"); int num = br.ReadCNum("NumFuncs"); List<Plugin.ItemNanoFunction> list = new List<Plugin.ItemNanoFunction>(); int arg_2F_0 = 0; checked { int num2 = num - 1; int num3 = arg_2F_0; while (true) { int arg_1C3_0 = num3; int num4 = num2; if (arg_1C3_0 > num4) { goto Block_4; } Plugin.ItemNanoFunction item = default(Plugin.ItemNanoFunction); item.FunctionReqs = new Plugin.ItemNanoRequirement[0]; item.FunctionArgs = new string[0]; item.FunctionNum = br.ReadInt32("FuncNum"); br.SkipBytes(8, "FuncHeaderPreSkip"); int num5 = br.ReadInt32("NumReqs"); bool flag = num5 > 0; if (flag) { List<Parser.ReqsStruc> list2 = new List<Parser.ReqsStruc>(); int arg_AE_0 = 0; int num6 = num5 - 1; int num7 = arg_AE_0; while (true) { int arg_118_0 = num7; num4 = num6; if (arg_118_0 > num4) { break; } list2.Add(new Parser.ReqsStruc { AttrNum = br.ReadInt32("RawReqsNum"), AttrVal = br.ReadInt32("RawReqsVal"), AttrOp = br.ReadInt32("RawReqsOp") }); num7++; } item.FunctionReqs = this.ParseReqs(list2.ToArray()); } item.TickCount = br.ReadInt32("TickCount"); item.TickInterval = br.ReadInt32("TickInterval"); item.Target = br.ReadInt32("Target"); br.SkipBytes(4, "FuncHeaderPostSkip"); item.FunctionArgs = this.ParseArgs(Conversions.ToString(item.FunctionNum), ref R); flag = (R == 0); if (flag) { break; } list.Add(item); num3++; } return; Block_4: try { Parser.Output.ItemNanoEventAndFunctions(eventNum, list.ToArray()); } catch (SQLiteException expr_1DD) { ProjectData.SetProjectError(expr_1DD); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_1F3) { ProjectData.SetProjectError(expr_1F3); Exception ex = expr_1F3; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } } }
private void ParseAnimSoundSet(int TypeN, ref bool R) { int num = br.ReadInt32("SetType"); int num2 = br.ReadCNum("NumFunc"); int arg_27_0 = 1; int num3 = num2; int num4 = arg_27_0; checked { while (true) { int arg_13B_0 = num4; int num5 = num3; if (arg_13B_0 > num5) { break; } List<int> list = new List<int>(); int actionNum = br.ReadInt32("actionNum"); int num6 = br.ReadCNum("maxSets"); int arg_5C_0 = 1; int num7 = num6; int num8 = arg_5C_0; while (true) { int arg_96_0 = num8; num5 = num7; if (arg_96_0 > num5) { break; } int item = br.ReadInt32("animNum" + Conversions.ToString(num8)); list.Add(item); num8++; } try { switch (TypeN) { case 1: Parser.Output.ItemNanoAnimSets(actionNum, list.ToArray()); break; case 2: Parser.Output.ItemNanoSoundSets(actionNum, list.ToArray()); break; default: throw new Exception("Xyphos, you're an idiot!"); } } catch (SQLiteException expr_E9) { ProjectData.SetProjectError(expr_E9); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_FF) { ProjectData.SetProjectError(expr_FF); Exception ex = expr_FF; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } num4++; } } }
private void ParseActionSet(ref bool R) { bool flag = br.ReadInt32("&H24 Check") != 36; if (flag) { throw new Exception("Why am I here?"); } int arg_3D_0 = 1; int num = br.ReadCNum("MaxSets"); int num2 = arg_3D_0; checked { while (true) { int arg_160_0 = num2; int num3 = num; if (arg_160_0 > num3) { break; } int actionNum = br.ReadInt32("actionNum"); int num4 = br.ReadCNum("NumReqs"); Plugin.ItemNanoRequirement[] requirements = new Plugin.ItemNanoRequirement[0]; flag = (num4 > 0); if (flag) { List<Parser.ReqsStruc> list = new List<Parser.ReqsStruc>(); int arg_86_0 = 0; int num5 = num4 - 1; int num6 = arg_86_0; while (true) { int arg_F0_0 = num6; num3 = num5; if (arg_F0_0 > num3) { break; } list.Add(new Parser.ReqsStruc { AttrNum = br.ReadInt32("RawReqsNum"), AttrVal = br.ReadInt32("RawReqsVal"), AttrOp = br.ReadInt32("RawReqsOp") }); num6++; } requirements = this.ParseReqs(list.ToArray()); } try { Parser.Output.ItemNanoAction(actionNum, requirements); } catch (SQLiteException expr_111) { ProjectData.SetProjectError(expr_111); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_127) { ProjectData.SetProjectError(expr_127); Exception ex = expr_127; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } num2++; } } }
private void ParseShopHash(ref bool R) { List<Plugin.ItemNanoFunction> list = new List<Plugin.ItemNanoFunction>(); int eventNum = br.ReadInt32("EventNum"); int num = br.ReadCNum("NumFuncs"); int arg_2D_0 = 1; int num2 = num; int num3 = arg_2D_0; checked { while (true) { int arg_151_0 = num3; int num4 = num2; if (arg_151_0 > num4) { break; } string text = br.ReadString(4, "StrArg"); int num5 = (int)br.ReadByte("numA"); int num6 = (int)br.ReadByte("numB"); bool flag = num5 == 0 && num6 == 0; if (flag) { num5 = (int)br.ReadInt16("numA2"); num6 = (int)br.ReadInt16("numB2"); } int count = Math.Min(11, br.Buffer.Length - br.Ptr); br.SkipBytes(count, "ShopHashSkip"); list.Add(new Plugin.ItemNanoFunction { FunctionArgs = new string[] { text, Conversions.ToString(num5), Conversions.ToString(num6) }, FunctionReqs = new Plugin.ItemNanoRequirement[0], Target = 255, TickCount = 1, TickInterval = 0 }); num3++; } try { Parser.Output.ItemNanoEventAndFunctions(eventNum, list.ToArray()); } catch (SQLiteException expr_16B) { ProjectData.SetProjectError(expr_16B); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_181) { ProjectData.SetProjectError(expr_181); Exception ex = expr_181; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } } }