codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
// XploderCodeEditor.Form1 private void DataLoadSM38(string fullpath, bool nodeclear, byte[] databytes) { this.tsslInfo.Text = "バイナリデータの読込中です"; this.tspbInfo.Value = 0; base.Update(); this.treeView1.BeginUpdate(); if (nodeclear) { this.tsslGameCount.Text = "0"; this.tsslCodeKindCount.Text = "0"; this.tsslCodeCount.Text = "0"; this.treeView1.Nodes.Clear(); } int num = Convert.ToInt32(this.tsslGameCount.Text); int num2 = Convert.ToInt32(this.tsslCodeKindCount.Text); int num3 = Convert.ToInt32(this.tsslCodeCount.Text); byte[] array; if (fullpath != "") { FileStream fileStream = new FileStream(fullpath, FileMode.Open, FileAccess.Read); this.tspbInfo.Maximum = (int)fileStream.Length; array = new byte[fileStream.Length]; fileStream.Read(array, 0, array.Length); fileStream.Close(); } else { this.tspbInfo.Maximum = databytes.Length; array = databytes; } BitConverter.ToInt32(array, 0); int i = 20; while (i < array.Length) { short num4 = BitConverter.ToInt16(array, i); TreeNode[] array2 = new TreeNode[(int)num4]; i += 2; num2 += (int)num4; byte b = array[i]; i++; string @string = this.encSJIS.GetString(array, i, (int)(b - 1)); i += (int)b; TreeNode treeNode = new TreeNode(@string); num++; for (int j = 0; j < (int)num4; j++) { short num5 = BitConverter.ToInt16(array, i); i += 2; num3 += (int)num5; b = array[i]; i++; @string = this.encSJIS.GetString(array, i, (int)(b - 1)); i += (int)b; array2[j] = new TreeNode(@string); StringBuilder stringBuilder = new StringBuilder(); for (int k = 0; k < (int)num5; k++) { stringBuilder.Append(BitConverter.ToInt32(array, i).ToString("X8")); stringBuilder.Append(" "); i += 4; stringBuilder.Append(BitConverter.ToInt32(array, i).ToString("X8")); i += 4; stringBuilder.Append("\r\n"); } array2[j].Name = stringBuilder.ToString(); this.tspbInfo.Value = i; } treeNode.Nodes.AddRange(array2); this.treeView1.Nodes.Add(treeNode); } this.tsslGameCount.Text = num.ToString(); this.tsslCodeKindCount.Text = num2.ToString(); this.tsslCodeCount.Text = num3.ToString(); this.treeView1.EndUpdate(); if (0 < this.treeView1.Nodes.Count) { this.boolTxbCodeUpdate = true; this.treeView1.SelectedNode = this.treeView1.Nodes[0]; } this.tspbInfo.Value = this.tspbInfo.Maximum; this.tsslInfo.Text = ""; } // XploderCodeEditor.Form1 private void DataLoad(string fullpath, bool nodeclear, byte[] databytes) { this.tsslInfo.Text = "バイナリデータの読込中です"; this.tspbInfo.Value = 0; base.Update(); this.treeView1.BeginUpdate(); if (nodeclear) { this.tsslGameCount.Text = "0"; this.tsslCodeKindCount.Text = "0"; this.tsslCodeCount.Text = "0"; this.treeView1.Nodes.Clear(); } int num = Convert.ToInt32(this.tsslGameCount.Text); int num2 = Convert.ToInt32(this.tsslCodeKindCount.Text); int num3 = Convert.ToInt32(this.tsslCodeCount.Text); byte[] array; if (fullpath != "") { FileStream fileStream = new FileStream(fullpath, FileMode.Open, FileAccess.Read); this.tspbInfo.Maximum = (int)fileStream.Length; array = new byte[fileStream.Length]; fileStream.Read(array, 0, array.Length); fileStream.Close(); } else { this.tspbInfo.Maximum = databytes.Length; array = databytes; } BitConverter.ToInt32(array, 0); int i = 8; while (i < array.Length) { string text = ""; for (int j = i; j < array.Length; j += 4) { int num4 = BitConverter.ToInt32(array, j); if (num4 == 0) { i = j + 4; break; } text += this.encUni16L.GetString(array, j, 2); } TreeNode treeNode = new TreeNode(text); num++; short num5 = BitConverter.ToInt16(array, i); i += 2; num2 += (int)num5; TreeNode[] array2 = new TreeNode[(int)num5]; for (int k = 0; k < (int)num5; k++) { text = ""; for (int l = i; l < array.Length; l += 4) { int num6 = BitConverter.ToInt32(array, l); if (num6 == 0) { i = l + 4; break; } text += this.encUni16L.GetString(array, l, 2); } array2[k] = new TreeNode(text); short num7 = BitConverter.ToInt16(array, i); i += 2; num3 += (int)num7; text = ""; for (int m = 0; m < (int)num7; m++) { int num8 = BitConverter.ToInt32(array, i); i += 4; int num9 = BitConverter.ToInt32(array, i); i += 4; string text2 = text; text = string.Concat(new string[] { text2, num8.ToString("X8"), " ", num9.ToString("X8"), "\r\n" }); this.tspbInfo.Value = i; } array2[k].Name = text; } treeNode.Nodes.AddRange(array2); this.treeView1.Nodes.Add(treeNode); if (i >= array.Length - 4) { this.tsslGameCount.Text = num.ToString(); this.tsslCodeKindCount.Text = num2.ToString(); this.tsslCodeCount.Text = num3.ToString(); this.treeView1.EndUpdate(); if (this.treeView1.Nodes.Count > 0) { this.boolTxbCodeUpdate = true; this.treeView1.SelectedNode = this.treeView1.Nodes[0]; } this.tspbInfo.Value = this.tspbInfo.Maximum; this.tsslInfo.Text = ""; return; } } } // XploderCodeEditor.Form1 private byte[] MakeBinaryData(bool boolThisGame) { this.tsslInfo.Text = "バイナリデータの作成中です"; if (boolThisGame) { this.tspbInfo.Maximum = 1; } else { this.tspbInfo.Maximum = this.treeView1.Nodes.Count; } this.tspbInfo.Value = 0; base.Update(); int num = 0; if (boolThisGame) { TreeNode treeNode; if (this.treeView1.SelectedNode.Level == 0) { treeNode = this.treeView1.SelectedNode; } else { treeNode = this.treeView1.SelectedNode.Parent; } num = treeNode.Text.Length * 4 + 4; num += 2; for (int i = 0; i < treeNode.Nodes.Count; i++) { num += treeNode.Nodes[i].Text.Length * 4 + 4; num += 2; int num2 = 0; int j = 0; while (treeNode.Nodes[i].Name.IndexOf("\r\n", j) != -1) { num2++; j = treeNode.Nodes[i].Name.IndexOf("\r\n", j) + 1; } num += num2 * 8; } } else { for (int k = 0; k < this.treeView1.Nodes.Count; k++) { num += this.treeView1.Nodes[k].Text.Length * 4 + 4; num += 2; for (int l = 0; l < this.treeView1.Nodes[k].Nodes.Count; l++) { num += this.treeView1.Nodes[k].Nodes[l].Text.Length * 4 + 4; num += 2; int num2 = 0; int j = 0; while (this.treeView1.Nodes[k].Nodes[l].Name.IndexOf("\r\n", j) != -1) { num2++; j = this.treeView1.Nodes[k].Nodes[l].Name.IndexOf("\r\n", j) + 1; } num += num2 * 8; } } } num += 4; byte[] array = new byte[num]; MemoryStream memoryStream = new MemoryStream(array); string[] separator = new string[] { "\r\n", " " }; if (boolThisGame) { TreeNode treeNode2; if (this.treeView1.SelectedNode.Level == 0) { treeNode2 = this.treeView1.SelectedNode; } else { treeNode2 = this.treeView1.SelectedNode.Parent; } for (int j = 0; j < treeNode2.Text.Length; j++) { byte[] bytes = this.encUni16L.GetBytes(treeNode2.Text.Substring(j, 1)); memoryStream.Write(bytes, 0, 2); memoryStream.Write(new byte[2], 0, 2); } memoryStream.Write(new byte[4], 0, 4); memoryStream.Write(BitConverter.GetBytes(treeNode2.Nodes.Count), 0, 2); for (int m = 0; m < treeNode2.Nodes.Count; m++) { for (int j = 0; j < treeNode2.Nodes[m].Text.Length; j++) { byte[] bytes = this.encUni16L.GetBytes(treeNode2.Nodes[m].Text.Substring(j, 1)); memoryStream.Write(bytes, 0, 2); memoryStream.Write(new byte[2], 0, 2); } memoryStream.Write(new byte[4], 0, 4); int num3 = 0; int startIndex = 0; while (treeNode2.Nodes[m].Name.IndexOf("\r\n", startIndex) != -1) { num3++; startIndex = treeNode2.Nodes[m].Name.IndexOf("\r\n", startIndex) + 1; } memoryStream.Write(BitConverter.GetBytes(num3), 0, 2); string[] array2 = treeNode2.Nodes[m].Name.Split(separator, StringSplitOptions.RemoveEmptyEntries); for (int n = 0; n < array2.Length; n++) { int num2 = int.Parse(array2[n].Substring(0, 8), NumberStyles.HexNumber); memoryStream.Write(BitConverter.GetBytes(num2), 0, 4); } } this.tspbInfo.Value = 1; } else { for (int num4 = 0; num4 < this.treeView1.Nodes.Count; num4++) { for (int j = 0; j < this.treeView1.Nodes[num4].Text.Length; j++) { byte[] bytes = this.encUni16L.GetBytes(this.treeView1.Nodes[num4].Text.Substring(j, 1)); memoryStream.Write(bytes, 0, 2); memoryStream.Write(new byte[2], 0, 2); } memoryStream.Write(new byte[4], 0, 4); memoryStream.Write(BitConverter.GetBytes(this.treeView1.Nodes[num4].Nodes.Count), 0, 2); for (int num5 = 0; num5 < this.treeView1.Nodes[num4].Nodes.Count; num5++) { for (int j = 0; j < this.treeView1.Nodes[num4].Nodes[num5].Text.Length; j++) { byte[] bytes = this.encUni16L.GetBytes(this.treeView1.Nodes[num4].Nodes[num5].Text.Substring(j, 1)); memoryStream.Write(bytes, 0, 2); memoryStream.Write(new byte[2], 0, 2); } memoryStream.Write(new byte[4], 0, 4); int num6 = 0; int startIndex2 = 0; while (this.treeView1.Nodes[num4].Nodes[num5].Name.IndexOf("\r\n", startIndex2) != -1) { num6++; startIndex2 = this.treeView1.Nodes[num4].Nodes[num5].Name.IndexOf("\r\n", startIndex2) + 1; } memoryStream.Write(BitConverter.GetBytes(num6), 0, 2); string[] array3 = this.treeView1.Nodes[num4].Nodes[num5].Name.Split(separator, StringSplitOptions.RemoveEmptyEntries); for (int num7 = 0; num7 < array3.Length; num7++) { int num2 = int.Parse(array3[num7].Substring(0, 8), NumberStyles.HexNumber); memoryStream.Write(BitConverter.GetBytes(num2), 0, 4); } } this.tspbInfo.Value = num4; } } int value = int.Parse("FFFFFFFF", NumberStyles.HexNumber); memoryStream.Write(BitConverter.GetBytes(value), 0, 4); memoryStream.Close(); CRCCalc cRCCalc = new CRCCalc(); cRCCalc.Init(CRCCalc.CRCCode.CRC32); int value2 = (int)cRCCalc.crctablefast(array); byte[] array4 = new byte[8 + array.Length]; memoryStream = new MemoryStream(array4); memoryStream.Write(BitConverter.GetBytes(array.Length), 0, 4); memoryStream.Write(BitConverter.GetBytes(value2), 0, 4); memoryStream.Write(array, 0, array.Length); memoryStream.Close(); this.tspbInfo.Value = this.tspbInfo.Maximum; this.tsslInfo.Text = ""; return array4; }
Private
[
?
]
Run code
Submit