mirror of
https://github.com/celisej567/LibBSP.git
synced 2026-09-23 20:08:40 +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:
@@ -19,9 +19,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 BrushSide(byte[] data, MapType type) : this() {
|
||||
public BrushSide(byte[] data, MapType type, int version = 0) : this() {
|
||||
if (data == null) {
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
@@ -107,10 +108,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="BrushSide"/> objects.</returns>
|
||||
/// <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 static List<BrushSide> LumpFactory(byte[] data, MapType type) {
|
||||
public static List<BrushSide> LumpFactory(byte[] data, MapType type, int version = 0) {
|
||||
if (data == null) {
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
@@ -161,7 +163,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 BrushSide(bytes, type));
|
||||
lump.Add(new BrushSide(bytes, type, version));
|
||||
}
|
||||
return lump;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user