annotate Loaders/ArmyBuilderABFileLoader.cs @ 3:1a54f6afafe7

Re #84 and #85: Support Army Builder v2/v3 files * Separate out the two versions of file * Restructure file loader to load v2 files correctly * Tidy up file extractor (still not working)
author IBBoard <dev@ibboard.co.uk>
date Sun, 17 May 2009 18:40:36 +0000
parents d5ba733cd289
children ec77b60e5369
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (ArmyBuilderFileLoader.cs) is a part of the IBBoard.ArmyBuilder.API project and is copyright 2009 IBBoard
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 //
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System;
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.IO;
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.ArmyBuilder.API.Loaders
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 public class ArmyBuilderABFileLoader
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 private static byte HEADER_DELIMITER = 0x09;
3
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
14 private static byte HEADER_TYPE_DELIMITER = 0x3A;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
15 private static byte TABLE_HEADER_OFFSET_FROM = 4;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
16 private static byte FILE_TABLE_OFFSET_LENGTH = 2;
0
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 public static ABFile LoadFile(FileInfo file)
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
3
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
20 ABFile abFile = ReadFileInfo(file);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
21 ReadFileTable(abFile);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
22 return abFile;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
23 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
24
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
25 private static ABFile ReadFileInfo(FileInfo file)
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
26 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
27 BinaryReaderBigEndian reader = new BinaryReaderBigEndian(file.OpenRead());
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
28 ABFile abFile = null;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
29
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
30 try
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
31 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
32 abFile = ReadFileInfo(file, reader);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
33 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
34 finally
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
35 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
36 reader.Close();
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
37 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
38
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
39 return abFile;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
40 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
41
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
42 private static ABFile ReadFileInfo(FileInfo file, BinaryReaderBigEndian reader)
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
43 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
44 int tableOffset = reader.ReadInt();
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
45 reader.Move(tableOffset);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
46 ushort fileTableOffset = reader.ReadUShort();
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
47 string header = reader.ReadDelimitedString(HEADER_TYPE_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
48
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
49 ABFile abFile = CreateFile(file, header);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
50 ReadExtraHeaders(abFile, reader);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
51 int fileTablePosition = TABLE_HEADER_OFFSET_FROM + tableOffset + FILE_TABLE_OFFSET_LENGTH + fileTableOffset;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
52 abFile.FileTablePosition = fileTablePosition;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
53 int readerPosition = (int)reader.Position;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
54
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
55 if (fileTablePosition > readerPosition)
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
56 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
57 abFile.Comment = reader.ReadString(fileTablePosition - readerPosition);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
58 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
59
0
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 return abFile;
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 }
3
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
62
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
63 private static ABFile CreateFile(FileInfo file, string header)
0
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 {
3
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
65 ABFile abFile = null;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
66 header = header.Trim();
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
67
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
68 if ("LWDExport".Equals(header))
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
69 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
70 abFile = new ABv3File(file);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
71 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
72 else if ("ArmyBuilder".Equals(header))
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
73 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
74 abFile = new ABv2File(file);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
75 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
76 else
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
77 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
78 throw new InvalidDataException("Unsupported file table header: "+header);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
79 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
80
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
81 abFile.Header = header;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
82 return abFile;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
83 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
84
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
85 private static void ReadExtraHeaders(ABFile abFile, BinaryReaderBigEndian reader)
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
86 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
87 if (abFile is ABv3File)
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
88 {
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
89 ABv3File ab3File = (ABv3File)abFile;
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
90 ab3File.GameName = reader.ReadDelimitedString(HEADER_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
91 ab3File.FolderName = reader.ReadDelimitedString(HEADER_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
92 ab3File.ReleaseMajor = reader.ReadDelimitedString(HEADER_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
93 ab3File.ReleaseMinor = reader.ReadDelimitedString(HEADER_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
94 ab3File.RequiredMajorVersion = reader.ReadDelimitedString(HEADER_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
95 ab3File.RequiredMinorVersion = reader.ReadDelimitedString(HEADER_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
96 ab3File.UniqueID = reader.ReadDelimitedString(HEADER_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
97 ab3File.Exporter = reader.ReadDelimitedString(HEADER_DELIMITER);
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
98 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
99 }
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
100
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
101 private static void ReadFileTable(ABFile abFile)
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
102 {
0
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 BinaryReaderBigEndian reader = new BinaryReaderBigEndian(abFile.File.OpenRead());
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 try
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 {
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 ReadFileTable(abFile, reader);
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 }
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 finally
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 {
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 reader.Close();
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 }
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 }
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 private static void ReadFileTable(ABFile abFile, BinaryReaderBigEndian reader)
3
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
116 {
0
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 FileTableEntry entry = null;
3
1a54f6afafe7 Re #84 and #85: Support Army Builder v2/v3 files
IBBoard <dev@ibboard.co.uk>
parents: 2
diff changeset
118 reader.Seek(abFile.FileTablePosition);
0
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 do
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 {
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 entry = ReadFileTableEntry(reader);
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 abFile.AddFileTableEntry(entry);
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 }
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 while (entry!=null);
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 }
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 private static FileTableEntry ReadFileTableEntry(BinaryReaderBigEndian reader)
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 {
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 FileTableEntry entry = null;
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 string name = reader.ReadUShortLengthString();
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 if (name!="" && name!=null)
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 {
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 entry = new FileTableEntry(name);
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 entry.FirstBytes = reader.ReadBytes(8);
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 entry.FileSize = reader.ReadInt();
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 entry.CompressedSize = reader.ReadInt();
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 entry.MidBytes = reader.ReadBytes(4);
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 entry.Location = reader.ReadInt();
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 entry.EndBytes = reader.ReadBytes(8);
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 }
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144 return entry;
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 }
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146 }
1a5205612b72 Add initial work on ArmyBuilder API project\nno-open-ticket
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
147 }