0
|
1 // This file is a part of the Relic Tools and is copyright 2006-2018 IBBoard.
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed under the GNU GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
|
|
4 using System;
|
|
5 using System.IO;
|
|
6 using IBBoard.Relic.RelicTools.Exceptions;
|
|
7
|
|
8 namespace IBBoard.Relic.RelicTools
|
|
9 {
|
|
10 /// <summary>
|
|
11 /// Summary description for ChunkyDataDATA.
|
|
12 /// </summary>
|
|
13 public class ChunkyDataFBIF : ChunkyData
|
|
14 {
|
|
15 string pluginName, username, burntime;
|
|
16 int pluginVer;
|
|
17
|
|
18 public ChunkyDataFBIF(int version_in, string name_in, byte[] innerData):base("FBIF", version_in, name_in)
|
|
19 {
|
|
20 int pos = 0;
|
|
21 int length = innerData[0]+(innerData[1]<<8)+(innerData[2]<<16)+(innerData[3]<<24);
|
|
22 pos = 4;
|
|
23 pluginName = ByteArrayToTextString(innerData, 4, length);
|
|
24 pos += length;
|
|
25 pluginVer = innerData[pos]+(innerData[pos+1]<<8)+(innerData[pos+2]<<16)+(innerData[pos+3]<<24);
|
|
26 pos+=4;
|
|
27 length = innerData[pos]+(innerData[pos+1]<<8)+(innerData[pos+2]<<16)+(innerData[pos+3]<<24);
|
|
28 pos+=4;
|
|
29 username = ByteArrayToTextString(innerData, pos, length);
|
|
30 pos += length;
|
|
31 length = innerData[pos]+(innerData[pos+1]<<8)+(innerData[pos+2]<<16)+(innerData[pos+3]<<24);
|
|
32 pos+=4;
|
|
33 burntime = ByteArrayToTextString(innerData, pos, length);
|
|
34 }
|
|
35
|
|
36 public override string GetDisplayDetails()
|
|
37 {
|
|
38 return base.GetBaseDisplayDetails()+Environment.NewLine+
|
|
39 "------------"+Environment.NewLine+
|
|
40 "Plugin name:\t\t"+pluginName+Environment.NewLine+
|
|
41 "Plugin version:\t\t"+pluginVer+Environment.NewLine+
|
|
42 "Username:\t\t"+username+Environment.NewLine+
|
|
43 "Burn time:\t\t"+burntime;
|
|
44 }
|
|
45
|
|
46 public override int DataLength
|
|
47 {
|
|
48 get
|
|
49 {
|
|
50 return 16+pluginName.Length+username.Length+burntime.Length;
|
|
51 }
|
|
52 }
|
|
53
|
|
54 public override byte[] GetDataBytes()
|
|
55 {
|
|
56 byte[] data = new byte[DataLength];
|
|
57 int pos = 0;
|
|
58 int temp;
|
|
59
|
|
60 temp = pluginName.Length;
|
|
61 data[pos++] = (byte)temp;
|
|
62 data[pos++] = (byte)(temp>>8);
|
|
63 data[pos++] = (byte)(temp>>16);
|
|
64 data[pos++] = (byte)(temp>>24);
|
|
65
|
|
66 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
|
|
67
|
|
68 enc.GetBytes(pluginName).CopyTo(data,pos);
|
|
69 pos += temp;
|
|
70
|
|
71 data[pos++] = (byte)pluginVer;
|
|
72 data[pos++] = (byte)(pluginVer>>8);
|
|
73 data[pos++] = (byte)(pluginVer>>16);
|
|
74 data[pos++] = (byte)(pluginVer>>24);
|
|
75
|
|
76 temp = username.Length;
|
|
77 data[pos++] = (byte)temp;
|
|
78 data[pos++] = (byte)(temp>>8);
|
|
79 data[pos++] = (byte)(temp>>16);
|
|
80 data[pos++] = (byte)(temp>>24);
|
|
81
|
|
82 enc.GetBytes(username).CopyTo(data,pos);
|
|
83 pos += temp;
|
|
84
|
|
85 temp = burntime.Length;
|
|
86 data[pos++] = (byte)temp;
|
|
87 data[pos++] = (byte)(temp>>8);
|
|
88 data[pos++] = (byte)(temp>>16);
|
|
89 data[pos++] = (byte)(temp>>24);
|
|
90
|
|
91 enc.GetBytes(burntime).CopyTo(data,pos);
|
|
92 pos += temp;
|
|
93
|
|
94 return data;
|
|
95 }
|
|
96
|
|
97
|
|
98 }
|
|
99 }
|