Refactor of BSP and BSPReader to enable lump structures to know what version of lump they represent.

As a result, fix reading v2 faces lump from Vindictus.
This commit is contained in:
Will
2016-02-15 02:57:10 -07:00
parent 75ee1e44f1
commit b8c883fd75
24 changed files with 572 additions and 410 deletions

View File

@@ -15,9 +15,10 @@ namespace LibBSP {
/// </summary>
/// <param name="data"><c>byte</c> array to parse.</param>
/// <param name="type">The map type.</param>
/// <param name="version">The version of this lump.</param>
/// <exception cref="ArgumentNullException"><paramref name="data"/> was <c>null</c>.</exception>
/// <exception cref="ArgumentException">This structure is not implemented for the given maptype.</exception>
public Edge(byte[] data, MapType type) : this() {
public Edge(byte[] data, MapType type, int version = 0) : this() {
if (data == null) {
throw new ArgumentNullException();
}
@@ -57,10 +58,11 @@ namespace LibBSP {
/// </summary>
/// <param name="data">The data to parse.</param>
/// <param name="type">The map type.</param>
/// <param name="version">The version of this lump.</param>
/// <returns>A <c>List</c> of <see cref="Edge"/> objects.</returns>
/// <exception cref="ArgumentNullException"><paramref name="data"/> was null.</exception>
/// <exception cref="ArgumentException">This structure is not implemented for the given maptype.</exception>
public static List<Edge> LumpFactory(byte[] data, MapType type) {
public static List<Edge> LumpFactory(byte[] data, MapType type, int version = 0) {
if (data == null) {
throw new ArgumentNullException();
}
@@ -96,7 +98,7 @@ namespace LibBSP {
byte[] bytes = new byte[structLength];
for (int i = 0; i < data.Length / structLength; ++i) {
Array.Copy(data, (i * structLength), bytes, 0, structLength);
lump.Add(new Edge(bytes, type));
lump.Add(new Edge(bytes, type, version));
}
return lump;
}