CreateCheckpoint() usage leads to unexpected decal behaviour

So, this is a strange one. I was in the process of trying to debug an IPL loading resource that seemed to be causing glass not to break and bullet holes not to appear in the walls and floors (‘decals’), convinced it was somehow unloading a required texture or something like that. Not getting anywhere, I did the only logical thing and started commenting out random stuff until I found the issue. To my surprised, I found the issue, and it was not what I was expecting at all.


Part of the IPL resource created checkpoints using the CreateCheckpoint() native like so:

public static int CreateTeleportCheckpoint(Vector3 pos, Color color)
{
    int cp = API.CreateCheckpoint(45, pos.X, pos.Y, pos.Z, pos.X, pos.Y, pos.Z, 1.0f, color.R, color.G, color.B, 255, 0);
    API.SetCheckpointCylinderHeight(cp, 0.1f, 0.1f, 1.0f);
    return cp;
}

This was used 40+ times inside of this function, which is called on startup inside the Main() constructor:

public static void CreateInterior(Vector3 entranceVector, Vector3 exitVector)
{
    Interior interior = new Interior()
    {
        EntranceCheckpoint = new Checkpoint(CreateTeleportCheckpoint(entranceVector, Color.FromArgb(0, 0, 255))),
        ExitCheckpoint = new Checkpoint(CreateTeleportCheckpoint(exitVector, Color.FromArgb(0, 0, 255))),
        EntranceVector = entranceVector,
        ExitVector = exitVector
    };
    interiors.Add(interior);
}

interiors is defined as:

private static readonly List<Interior> interiors = new List<Interior>();

With Interior being:

private struct Interior
{
    public Checkpoint EntranceCheckpoint;
    public Checkpoint ExitCheckpoint;
    public Vector3 EntranceVector;
    public Vector3 ExitVector;
}

I found that by commenting out the places where CreateInterior() was called one by one, the expected functionality of decals slowly returned. Having less than ~25 checkpoints caused no apparent issues; more than 25 checkpoints caused glass break decals to hang in midair for a moment after a window is fully broken; more than 30 checkpoints causes these decals not to disappear at all (as seen here and here), even after the window is fully broken; and any more than 35 checkpoints causes windows to become completely unbreakable (you shoot right through them like they were not there), and bullet holes not to appear when you shoot a wall or the ground.

I have since replaced the checkpoint code with a simple ‘draw a marker at the closest vector’ system, so it’s no longer an issue (and this is probs a better way anyway lol), but I figured I would report this anyway.