mirror of
https://github.com/celisej567/LibBSP.git
synced 2026-09-17 20:08:55 +03:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user