Skip to content

Commit 652e26f

Browse files
authored
Merge pull request #128 from CreepNT/topic/correct_spline_ids
Assign proper ID to Splines when parsing a level
2 parents a398817 + 76ffdcb commit 652e26f

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

LibReplanetizer/Level Objects/Gameplay/Spline.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public class Spline : LevelObject, ITransformable, IRenderable
2121
[Category("Attributes"), DisplayName("offset")]
2222
public long offset { get; set; }
2323

24-
static int CNT = 0;
25-
2624
/*public override Vector3 position
2725
{
2826
get { return _position; }
@@ -57,20 +55,20 @@ public Spline(int name, float[] vertexBuffer)
5755
}
5856
}
5957

60-
public Spline(byte[] splineBlock, int offset)
58+
public Spline(byte[] splineBlock, int offset, int id)
6159
{
60+
this.id = id;
6261
this.offset = offset;
6362
LoadFromByteArray(splineBlock, offset);
6463
}
6564

66-
public static LevelObject CreateFromByteArray(byte[] splineBlock, int offset)
65+
public static LevelObject CreateFromByteArray(byte[] splineBlock, int offset, int id)
6766
{
68-
return new Spline(splineBlock, offset);
67+
return new Spline(splineBlock, offset, id);
6968
}
7069

7170
public void LoadFromByteArray(byte[] splineBlock, int offset)
7271
{
73-
id = CNT;
7472
int count = ReadInt(splineBlock, offset);
7573
vertexBuffer = new float[count * 3];
7674
wVals = new float[count];
@@ -86,8 +84,6 @@ public void LoadFromByteArray(byte[] splineBlock, int offset)
8684
{
8785
//_position = new Vector3(vertexBuffer[0], vertexBuffer[1], vertexBuffer[2]);
8886
}
89-
90-
CNT++;
9187
}
9288

9389
public override byte[] ToByteArray()

LibReplanetizer/Parsers/GameplayParser.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public List<Spline> GetSplines()
4343
for (int i = 0; i < splineCount; i++)
4444
{
4545
int offset = ReadInt(splineHeadBlock, (i * 4));
46-
splines.Add(new Spline(splineBlock, offset));
46+
splines.Add(new Spline(splineBlock, offset, i));
4747
}
4848
return splines;
4949
}
@@ -332,8 +332,12 @@ public List<GrindPath> GetGrindPaths()
332332

333333
for (int i = 0; i < count; i++)
334334
{
335+
/*
336+
* Use ID -1 for the Spline objects created here
337+
* as they are used only for rendering.
338+
*/
335339
int offset = ReadInt(splineHeadBlock, i * 0x04);
336-
splines.Add(new Spline(splineBlock, offset));
340+
splines.Add(new Spline(splineBlock, offset, -1));
337341
}
338342

339343
for (int i = 0; i < count; i++)

0 commit comments

Comments
 (0)