GBX.NET 2.2.2-nightly.20251023.ce6a6ed6

GBX.NET

NuGet Discord

A general purpose library for Gbx files - data from Nadeo games like Trackmania or Shootmania, written in C#/.NET. It supports high performance serialization and deserialization of 400+ Gbx classes.

For more details, see the main README.

Framework support

Due to the recently paced evolution of .NET, framework support has been limited only to a few ones compared to GBX.NET 1:

  • .NET 9
  • .NET 8
  • .NET 6
  • .NET Standard 2.0

You can still use GBX.NET 2 on the old .NET Framework, but the performance of the library could be degraded.

Usage

These examples expect you to have <ImplicitUsings>enable</ImplicitUsings>. If this does not work for you, add using System.Linq; at the top.

Map information

Additional package GBX.NET.LZO is required in this example.

using GBX.NET;
using GBX.NET.Engines.Game;
using GBX.NET.LZO;

Gbx.LZO = new Lzo();

var map = Gbx.ParseNode<CGameCtnChallenge>("Path/To/My.Map.Gbx");

foreach (var block in map.GetBlocks().GroupBy(x => x.Name))
{
    Console.WriteLine($"{block.Key}: {block.Count()}");
}

Map information from Gbx header

using GBX.NET;
using GBX.NET.Engines.Game;
using GBX.NET.LZO;

var map = Gbx.ParseHeaderNode<CGameCtnChallenge>("Path/To/My.Map.Gbx");

Console.WriteLine(map.MapName);
Console.WriteLine(map.Xml);

Header contains a lot less information than the full node.

Modify and save a map

using GBX.NET;
using GBX.NET.Engines.Game;
using GBX.NET.LZO;

Gbx.LZO = new Lzo();

var gbx = Gbx.Parse<CGameCtnChallenge>("Path/To/My.Map.Gbx");
var map = gbx.Node; // See Clarity section for more info

map.MapName = "My new map name";

gbx.Save("Path/To/MyNew.Map.Gbx");

The trick here is that the Gbx properties are saved in the gbx object variable (Gbx class).

If you were to go with ParseNode in this case, this would not work for TMF and older games, but it is still possible if you specify the Gbx parameters in the Save method:

map.Save("Path/To/MyNew.Map.Gbx", new()
{
    PackDescVersion = 2 // Latest known PackDesc version in TMF
});

For TMS or TMN ESWC, you would have to specify ClassIdRemapMode for example:

map.Save("Path/To/MyNew.Map.Gbx", new()
{
    ClassIdRemapMode = ClassIdRemapMode.Id2006
    PackDescVersion = 1
});

These save parameters depend on the game of choice, but since Trackmania 2, this does not matter.

Processing multiple Gbx types

Additional package GBX.NET.LZO is required in this example.

This example shows how you can retrieve ghost objects from multiple different types of Gbx:

using GBX.NET;
using GBX.NET.Engines.Game;
using GBX.NET.LZO;

Gbx.LZO = new Lzo();

var node = Gbx.ParseNode("Path/To/My.Gbx");

var ghost = node switch
{
    CGameCtnReplayRecord replay => replay.GetGhosts().FirstOrDefault(),
    CGameCtnMediaClip clip => clip.GetGhosts().FirstOrDefault(),
    CGameCtnGhost g => g,
    _ => null
};

if (ghost is null)
{
    Console.WriteLine("This Gbx file does not have any ghost.");
}
else
{
    Console.WriteLine("Time: {0}", ghost.RaceTime);
}

Using pattern matching with non-generic Parse methods is a safer approach (no exceptions on different Gbx types), but less trim-friendly.

Read a large amount of replay metadata quickly

In case you only need the most basic information about many of the most common Gbx files (maps, replays, items, ...), do not read the full Gbx file, but only the header part. It is a great performance benefit for disk scans.

using GBX.NET;
using GBX.NET.Engines.Game;

foreach (var filePath in Directory.EnumerateFiles("Path/To/My/Directory", "*.Replay.Gbx", SearchOption.AllDirectories))
{
    try
    {
        DisplayBasicReplayInfo(filePath);
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Gbx exception occurred {Path.GetFileName(filePath)}: {ex}");
    }
}

void DisplayBasicReplayInfo(string filePath)
{
    var nodeHeader = Gbx.ParseHeaderNode(filePath);

    if (nodeHeader is CGameCtnReplayRecord replay)
    {
        Console.WriteLine($"{replay.MapInfo}: {replay.Time}");
    }
}

File types

Some of the common types to start with (a lot more are supported):

Latest extension Class Can read Can write Other extension/s
Map.Gbx CGameCtnChallenge Yes Yes Challenge.Gbx
Replay.Gbx CGameCtnReplayRecord Yes No
Ghost.Gbx CGameCtnGhost Yes Yes
Clip.Gbx CGameCtnMediaClip Yes Yes
Item.Gbx CGameItemModel Yes Yes Block.Gbx
Mat.Gbx CPlugMaterialUserInst Yes Yes
Mesh.Gbx CPlugSolid2Model Yes Yes
Shape.Gbx CPlugSurface Yes Yes
Macroblock.Gbx CGameCtnMacroBlockInfo Yes Yes
LightMapCache.Gbx CHmsLightMapCache No No
SystemConfig.Gbx CSystemConfig Yes Yes
FidCache.Gbx CMwRefBuffer Yes Yes
Profile.Gbx CGamePlayerProfile Up to TMF Up to TMF
Scores.Gbx CGamePlayerScore No No

Supported games

Many essential Gbx files from many games are supported:

  • Trackmania (2020), December 2024 update
  • ManiaPlanet 4(.1), TM2/SM
  • Trackmania Turbo
  • ManiaPlanet 3, TM2/SM
  • ManiaPlanet 2, TM2/SM
  • ManiaPlanet 1, TM2
  • TrackMania Forever, Nations/United
  • Virtual Skipper 5
  • TrackMania United
  • TrackMania Nations ESWC
  • TrackMania Sunrise eXtreme
  • TrackMania Original
  • TrackMania Sunrise
  • TrackMania Power Up
  • TrackMania (1.0)

License

GBX.NET library (this package) is MIT Licensed.

However, if you would use GBX.NET.LZO package with it (which is usually required), you'd need to follow the GNU GPL v3 License. See License section on the main README for more details.

Special thanks

Without these people, this project wouldn't be what it is today (ordered by impact):

  • Stefan Baumann (Solux)
  • Melissa (Miss)
  • florenzius
  • Kim
  • tilman
  • schadocalex
  • James Romeril
  • frolad (Juice)
  • Mika Kuijpers (TheMrMiku)
  • donadigo

And many thanks to every bug reporter!

Showing the top 20 packages that depend on GBX.NET.

Packages Downloads
GBX.NET.LZO
An LZO compression plugin for GBX.NET to allow de/serialization of compressed Gbx bodies. This official implementation uses lzo 2.10 from NativeSharpLzo and minilzo 2.06 port by zzattack.
91
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
88
GBX.NET.Imaging.SkiaSharp
Provides extensions for image handling in GBX.NET (Google's Skia with SkiaSharp).
79
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
62
GBX.NET.ZLib
Support for zlib compressed parts of Gbx, integrated with GBX.NET. This official implementation uses Iconic.Zlib.Netstandard.
62
GBX.NET.ZLib
Support for zlib compressed parts of Gbx, integrated with GBX.NET. This official implementation uses Iconic.Zlib.Netstandard.
57
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
56
GBX.NET.PAK
Support for reading Pak (NadeoPak) package files, integrated with GBX.NET.
53
GBX.NET.ZLib
Support for zlib compressed parts of Gbx, integrated with GBX.NET. This official implementation uses Iconic.Zlib.Netstandard.
53
GBX.NET.PAK
Support for reading Pak (NadeoPak) package files, integrated with GBX.NET.
52
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
51
GBX.NET.ZLib
Support for zlib compressed parts of Gbx, integrated with GBX.NET. This official implementation uses Iconic.Zlib.Netstandard.
51
GBX.NET.Hashing
Hashing features (CRC32) for GBX.NET 2.
51
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
50
GBX.NET.ZLib
Support for zlib compressed parts of Gbx, integrated with GBX.NET. This official implementation uses Iconic.Zlib.Netstandard.
49
GBX.NET.PAK
Support for reading Pak (NadeoPak) package files, integrated with GBX.NET.
49
GBX.NET.ZLib
Support for zlib compressed parts of Gbx, integrated with GBX.NET. This official implementation uses Iconic.Zlib.Netstandard.
48
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
48
GBX.NET.PAK
Support for reading Pak (NadeoPak) package files, integrated with GBX.NET.
48

Version Downloads Last updated
2.2.2 104 09/12/2025
2.2.2-nightly.20251025.ce6a6ed6 1 10/25/2025
2.2.2-nightly.20251024.ce6a6ed6 1 10/24/2025
2.2.2-nightly.20251023.ce6a6ed6 5 10/23/2025
2.2.2-nightly.20251022.ce6a6ed6 5 10/22/2025
2.2.2-nightly.20251021.ce6a6ed6 6 10/21/2025
2.2.2-nightly.20251020.cd56d4a7 5 10/20/2025
2.2.2-nightly.20251019.cf7d66e0 7 10/19/2025
2.2.2-nightly.20251018.cf7d66e0 8 10/18/2025
2.2.2-nightly.20251017.c5a52eb9 9 10/17/2025
2.2.2-nightly.20251016.c5a52eb9 9 10/16/2025
2.2.2-nightly.20251015.c5a52eb9 10 10/15/2025
2.2.2-nightly.20251014.c5a52eb9 11 10/14/2025
2.2.2-nightly.20251013.c5a52eb9 10 10/13/2025
2.2.2-nightly.20251012.c5a52eb9 11 10/12/2025
2.2.2-nightly.20251011.c5a52eb9 11 10/11/2025
2.2.2-nightly.20251010.c5a52eb9 12 10/10/2025
2.2.2-nightly.20251009.c5a52eb9 13 10/09/2025
2.2.2-nightly.20251008.c5a52eb9 11 10/08/2025
2.2.2-nightly.20251007.c55d6ba0 12 10/07/2025
2.2.2-nightly.20251006.c55d6ba0 14 10/06/2025
2.2.2-nightly.20251005.c2c8c81e 16 10/05/2025
2.2.2-nightly.20251004.c2c8c81e 17 10/04/2025
2.2.2-nightly.20251003.cce76ab7 16 10/03/2025
2.2.2-nightly.20251002.cce76ab7 18 10/02/2025
2.2.2-nightly.20251001.cce76ab7 19 10/01/2025
2.2.2-nightly.20250930.cce76ab7 18 09/30/2025
2.2.2-nightly.20250929.cce76ab7 15 09/29/2025
2.2.2-nightly.20250928.cce76ab7 15 09/28/2025
2.2.2-nightly.20250927.cce76ab7 19 09/27/2025
2.2.2-nightly.20250926.cce76ab7 13 09/26/2025
2.2.2-nightly.20250925.cce76ab7 18 09/25/2025
2.2.2-nightly.20250924.cce76ab7 15 09/24/2025
2.2.2-nightly.20250923.cce76ab7 19 09/23/2025
2.2.2-nightly.20250922.cce76ab7 19 09/22/2025
2.2.2-nightly.20250921.cce76ab7 21 09/21/2025
2.2.2-nightly.20250920.cce76ab7 20 09/20/2025
2.2.2-nightly.20250919.cce76ab7 16 09/19/2025
2.2.2-nightly.20250918.cce76ab7 15 09/18/2025
2.2.2-nightly.20250917.cce76ab7 18 09/17/2025
2.2.2-nightly.20250916.cce76ab7 15 09/16/2025
2.2.2-nightly.20250915.cce76ab7 16 09/15/2025
2.2.2-nightly.20250914.cce76ab7 27 09/14/2025
2.2.2-nightly.20250913.cce76ab7 21 09/13/2025
2.2.2-nightly.20250912.cba11d3c 19 09/12/2025
2.2.2-nightly.20250911.cba11d3c 20 09/11/2025
2.2.2-nightly.20250910.cba11d3c 24 09/10/2025
2.2.2-nightly.20250909.cba11d3c 27 09/09/2025
2.2.2-nightly.20250908.cba11d3c 25 09/08/2025
2.2.2-nightly.20250907.cba11d3c 20 09/07/2025
2.2.2-nightly.20250906.cba11d3c 23 09/06/2025
2.2.2-nightly.20250905.cba11d3c 29 09/05/2025
2.2.2-nightly.20250904.cba11d3c 27 09/04/2025
2.2.2-nightly.20250903.cba11d3c 33 09/03/2025
2.2.2-nightly.20250902.cba11d3c 31 09/02/2025
2.2.2-nightly.20250901.cba11d3c 32 09/01/2025
2.2.2-nightly.20250831.cba11d3c 33 08/31/2025
2.2.2-nightly.20250830.cba11d3c 31 08/30/2025
2.2.2-nightly.20250829.cba11d3c 25 08/29/2025
2.2.2-nightly.20250828.cde940d2 30 08/28/2025
2.2.2-nightly.20250827.c8257ead 31 08/27/2025
2.2.1-nightly.20250826.c1aa6590 43 08/26/2025
2.2.1-nightly.20250825.c3a861aa 31 08/25/2025
2.2.1-nightly.20250824.c3a861aa 34 08/24/2025
2.2.1-nightly.20250823.c3a861aa 35 08/23/2025
2.2.1-nightly.20250822.c3a861aa 23 08/22/2025
2.2.1-nightly.20250821.c3a861aa 34 08/21/2025
2.2.1-nightly.20250820.c3a861aa 30 08/20/2025
2.2.1-nightly.20250819.c3a861aa 30 08/19/2025
2.2.1-nightly.20250818.c5bbab68 36 08/18/2025
2.2.1-nightly.20250817.ce814990 28 08/17/2025
2.2.1-nightly.20250817.c6817f0a 36 08/17/2025
2.2.1-nightly.20250816.c6817f0a 27 08/16/2025
2.2.1-nightly.20250815.c6817f0a 39 08/15/2025
2.2.1-nightly.20250814.c6817f0a 29 08/14/2025
2.2.1-nightly.20250813.c6817f0a 39 08/13/2025
2.2.1-nightly.20250812.c6817f0a 39 08/12/2025
2.2.1-nightly.20250811.c6817f0a 31 08/11/2025
2.2.1-nightly.20250810.c6817f0a 32 08/10/2025
2.2.1-nightly.20250809.c6817f0a 31 08/09/2025
2.2.1-nightly.20250808.c6817f0a 29 08/08/2025
2.2.1-nightly.20250807.c6817f0a 30 08/07/2025
2.2.1-nightly.20250806.c6817f0a 29 08/06/2025
2.2.1-nightly.20250805.c6817f0a 33 08/05/2025
2.2.1-nightly.20250804.c6817f0a 68 08/04/2025
2.2.1-nightly.20250803.c6817f0a 44 08/03/2025
2.2.1-nightly.20250802.c6817f0a 30 08/02/2025
2.2.1-nightly.20250801.c6817f0a 32 08/01/2025
2.2.1-nightly.20250731.c6817f0a 32 07/31/2025
2.2.1-nightly.20250730.c6817f0a 44 07/30/2025
2.2.1-nightly.20250729.c6817f0a 35 07/29/2025
2.2.1-nightly.20250728.ca7f9be8 43 07/28/2025
2.2.1-nightly.20250727.cd7b47aa 36 07/27/2025
2.2.1-nightly.20250726.cd7b47aa 42 07/26/2025
2.2.1-nightly.20250725.cd7b47aa 41 07/25/2025
2.2.1-nightly.20250724.cd7b47aa 42 07/24/2025
2.2.1-nightly.20250723.cd7b47aa 41 07/23/2025
2.2.1-nightly.20250722.cd7b47aa 43 07/22/2025
2.2.1-nightly.20250721.cd7b47aa 52 07/21/2025