GBX.NET 2.1.0-nightly.20241109.e8ee7e0

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 200+ 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 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 Yes No

Supported games

Many essential Gbx files from many games are supported:

  • Trackmania (2020), July 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.Hashing
Hashing features (CRC32) for GBX.NET 2.
102
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.
99
GBX.NET.Crypto
Cryptographic features for GBX.NET 2.
93
GBX.NET.Imaging.SkiaSharp
Provides extensions for image handling in GBX.NET (Google's Skia with SkiaSharp).
93
GBX.NET.Imaging.SkiaSharp
Provides extensions for image handling in GBX.NET (Google's Skia with SkiaSharp).
87
GBX.NET.NewtonsoftJson
Better and easier JSON serialization with polymorphic support for GBX.NET objects.
85
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.
77
GBX.NET.PAK
Support for Pak (NadeoPak) package files, integrated with GBX.NET.
74
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
73
GBX.NET.ZLib
Support for zlib compressed parts of Gbx, integrated with GBX.NET. This official implementation uses Iconic.Zlib.Netstandard.
66
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
58
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
57
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
56
GBX.NET.Tool
Base library for creating rich tools for different environments 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.
52
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
52
GBX.NET.Hashing
Hashing features (CRC32) for GBX.NET 2.
52
GBX.NET.Tool
Base library for creating rich tools for different environments with GBX.NET.
51

Version Downloads Last updated
2.1.1 30 01/22/2025
2.1.1-nightly.20250410.5dafd02 1 04/10/2025
2.1.1-nightly.20250409.5dafd02 2 04/09/2025
2.1.1-nightly.20250408.5dafd02 4 04/08/2025
2.1.1-nightly.20250407.5dafd02 4 04/07/2025
2.1.1-nightly.20250406.5dafd02 4 04/06/2025
2.1.1-nightly.20250405.5dafd02 5 04/05/2025
2.1.1-nightly.20250404.5dafd02 6 04/04/2025
2.1.1-nightly.20250403.5dafd02 5 04/03/2025
2.1.1-nightly.20250402.5dafd02 6 04/02/2025
2.1.1-nightly.20250401.5dafd02 7 04/01/2025
2.1.1-nightly.20250331.5dafd02 9 03/31/2025
2.1.1-nightly.20250330.5dafd02 8 03/30/2025
2.1.1-nightly.20250329.5dafd02 7 03/29/2025
2.1.1-nightly.20250328.5dafd02 11 03/28/2025
2.1.1-nightly.20250327.5dafd02 9 03/27/2025
2.1.1-nightly.20250326.5dafd02 7 03/26/2025
2.1.1-nightly.20250325.5dafd02 10 03/25/2025
2.1.1-nightly.20250324.5dafd02 8 03/24/2025
2.1.1-nightly.20250323.5dafd02 9 03/23/2025
2.1.1-nightly.20250322.014a2f7 9 03/22/2025
2.1.1-nightly.20250321.014a2f7 10 03/21/2025
2.1.1-nightly.20250320.014a2f7 10 03/20/2025
2.1.1-nightly.20250319.014a2f7 9 03/19/2025
2.1.1-nightly.20250318.014a2f7 11 03/18/2025
2.1.1-nightly.20250317.014a2f7 9 03/17/2025
2.1.1-nightly.20250316.014a2f7 9 03/16/2025
2.1.1-nightly.20250315.014a2f7 11 03/15/2025
2.1.1-nightly.20250314.014a2f7 11 03/14/2025
2.1.1-nightly.20250313.014a2f7 19 03/13/2025
2.1.1-nightly.20250312.014a2f7 12 03/12/2025
2.1.1-nightly.20250311.014a2f7 20 03/11/2025
2.1.1-nightly.20250310.014a2f7 11 03/10/2025
2.1.1-nightly.20250309.014a2f7 12 03/09/2025
2.1.1-nightly.20250308.014a2f7 15 03/08/2025
2.1.1-nightly.20250307.014a2f7 13 03/07/2025
2.1.1-nightly.20250306.014a2f7 14 03/06/2025
2.1.1-nightly.20250305.014a2f7 13 03/05/2025
2.1.1-nightly.20250304.014a2f7 17 03/04/2025
2.1.1-nightly.20250303.014a2f7 14 03/03/2025
2.1.1-nightly.20250302.4b887f5 16 03/02/2025
2.1.1-nightly.20250301.2caca5a 15 03/01/2025
2.1.1-nightly.20250228.2caca5a 13 02/28/2025
2.1.1-nightly.20250227.2caca5a 15 02/27/2025
2.1.1-nightly.20250226.2caca5a 12 02/26/2025
2.1.1-nightly.20250225.2caca5a 14 02/25/2025
2.1.1-nightly.20250224.2caca5a 20 02/24/2025
2.1.1-nightly.20250223.2caca5a 13 02/23/2025
2.1.1-nightly.20250222.2caca5a 20 02/22/2025
2.1.1-nightly.20250221.2caca5a 21 02/21/2025
2.1.1-nightly.20250220.2caca5a 16 02/20/2025
2.1.1-nightly.20250219.2caca5a 17 02/19/2025
2.1.1-nightly.20250218.2caca5a 19 02/18/2025
2.1.1-nightly.20250217.2caca5a 20 02/17/2025
2.1.1-nightly.20250216.2caca5a 19 02/16/2025
2.1.1-nightly.20250215.2caca5a 23 02/15/2025
2.1.1-nightly.20250214.2caca5a 16 02/14/2025
2.1.1-nightly.20250212.2caca5a 18 02/12/2025
2.1.1-nightly.20250211.2caca5a 15 02/11/2025
2.1.1-nightly.20250210.2caca5a 21 02/10/2025
2.1.1-nightly.20250209.2caca5a 22 02/09/2025
2.1.1-nightly.20250208.2caca5a 29 02/08/2025
2.1.1-nightly.20250207.f3adb17 20 02/07/2025
2.1.1-nightly.20250206.64e8ce1 28 02/06/2025
2.1.1-nightly.20250205.64e8ce1 19 02/05/2025
2.1.1-nightly.20250204.c697731 22 02/04/2025
2.1.1-nightly.20250203.f092940 20 02/03/2025
2.1.1-nightly.20250202.f092940 18 02/02/2025
2.1.1-nightly.20250201.f092940 18 02/01/2025
2.1.1-nightly.20250131.f092940 30 01/31/2025
2.1.1-nightly.20250130.f092940 30 01/30/2025
2.1.1-nightly.20250129.f092940 31 01/29/2025
2.1.1-nightly.20250128.51b0057 30 01/28/2025
2.1.1-nightly.20250127.51b0057 28 01/27/2025
2.1.1-nightly.20250126.51b0057 31 01/26/2025
2.1.1-nightly.20250125.51b0057 31 01/25/2025
2.1.1-nightly.20250124.51b0057 19 01/24/2025
2.1.1-nightly.20250123.5299e59 21 01/23/2025
2.1.1-nightly.20250122.e879e94 20 01/22/2025
2.1.1-nightly.20250121.eca3bc1 19 01/21/2025
2.1.1-nightly.20250120.878fbec 34 01/20/2025
2.1.1-nightly.20250119.878fbec 22 01/19/2025
2.1.0 91 12/31/2024
2.1.0-nightly.20250118.17b9973 21 01/18/2025
2.1.0-nightly.20250117.52f4005 19 01/17/2025
2.1.0-nightly.20250116.52f4005 25 01/16/2025
2.1.0-nightly.20250115.52f4005 20 01/15/2025
2.1.0-nightly.20250114.52f4005 20 01/14/2025
2.1.0-nightly.20250113.8f44eff 23 01/13/2025
2.1.0-nightly.20250112.8f44eff 18 01/12/2025
2.1.0-nightly.20250111.3d6d76b 19 01/11/2025
2.1.0-nightly.20250110.b7035f4 24 01/10/2025
2.1.0-nightly.20250109.9e4811a 21 01/09/2025
2.1.0-nightly.20250108.9e4811a 24 01/08/2025
2.1.0-nightly.20250107.9e4811a 37 01/07/2025
2.1.0-nightly.20250106.9e4811a 22 01/06/2025
2.1.0-nightly.20250105.9e4811a 23 01/05/2025
2.1.0-nightly.20250104.f23ed36 24 01/04/2025
2.1.0-nightly.20250103.2a85c39 24 01/03/2025
2.1.0-nightly.20250102.2a85c39 24 01/02/2025
2.1.0-nightly.20250101.0cb2f89 25 01/01/2025
2.1.0-nightly.20241231.b52bf90 35 12/31/2024
2.1.0-nightly.20241230.e1bc0ba 32 12/30/2024
2.1.0-nightly.20241230.773ff0a 27 12/30/2024
2.1.0-nightly.20241229.54be67b 70 12/29/2024
2.1.0-nightly.20241228.0a759de 23 12/28/2024
2.1.0-nightly.20241227.402ef16 25 12/27/2024
2.1.0-nightly.20241226.7c81acb 26 12/26/2024
2.1.0-nightly.20241226.0fc7d1f 30 12/26/2024
2.1.0-nightly.20241225.e7a99b6 30 12/25/2024
2.1.0-nightly.20241224.e293b64 31 12/24/2024
2.1.0-nightly.20241223.e293b64 45 12/23/2024
2.1.0-nightly.20241222.e293b64 43 12/22/2024
2.1.0-nightly.20241221.e293b64 29 12/21/2024
2.1.0-nightly.20241220.e293b64 45 12/20/2024
2.1.0-nightly.20241220.e0c54b9 25 12/20/2024
2.1.0-nightly.20241220.c45aaa8 31 12/20/2024
2.1.0-nightly.20241219.e0c54b9 39 12/19/2024
2.1.0-nightly.20241218.7ff3ff1 32 12/18/2024
2.1.0-nightly.20241217.1279c7b 30 12/17/2024
2.1.0-nightly.20241216.9ff62e8 39 12/16/2024
2.1.0-nightly.20241215.9ff62e8 32 12/15/2024
2.1.0-nightly.20241214.9ff62e8 26 12/14/2024
2.1.0-nightly.20241213.9ff62e8 31 12/13/2024
2.1.0-nightly.20241212.9ff62e8 33 12/12/2024
2.1.0-nightly.20241211.9ff62e8 33 12/11/2024
2.1.0-nightly.20241210.ba792c4 39 12/10/2024
2.1.0-nightly.20241209.69b3821 39 12/09/2024
2.1.0-nightly.20241208.c435869 41 12/08/2024
2.1.0-nightly.20241207.82b53c8 37 12/07/2024
2.1.0-nightly.20241206.82b53c8 35 12/06/2024
2.1.0-nightly.20241205.82b53c8 39 12/05/2024
2.1.0-nightly.20241204.82b53c8 38 12/04/2024
2.1.0-nightly.20241203.82b53c8 26 12/03/2024
2.1.0-nightly.20241130.82b53c8 26 11/30/2024
2.1.0-nightly.20241129.82b53c8 40 11/29/2024
2.1.0-nightly.20241128.82b53c8 38 11/28/2024
2.1.0-nightly.20241127.82b53c8 35 11/27/2024
2.1.0-nightly.20241126.82b53c8 44 11/26/2024
2.1.0-nightly.20241125.82b53c8 36 11/25/2024
2.1.0-nightly.20241124.82b53c8 68 11/24/2024
2.1.0-nightly.20241123.8c6b466 40 11/23/2024
2.1.0-nightly.20241122.8c6b466 40 11/22/2024
2.1.0-nightly.20241121.8c6b466 25 11/21/2024
2.1.0-nightly.20241120.8b1a087 37 11/20/2024
2.1.0-nightly.20241119.93c22eb 42 11/19/2024
2.1.0-nightly.20241118.93c22eb 26 11/18/2024
2.1.0-nightly.20241117.93c22eb 43 11/17/2024
2.1.0-nightly.20241116.93c22eb 41 11/16/2024
2.1.0-nightly.20241115.93c22eb 46 11/15/2024
2.1.0-nightly.20241114.93c22eb 23 11/14/2024
2.1.0-nightly.20241113.93c22eb 43 11/13/2024
2.1.0-nightly.20241112.248d1cd 45 11/12/2024
2.1.0-nightly.20241111.248d1cd 46 11/11/2024
2.1.0-nightly.20241110.e8ee7e0 45 11/10/2024
2.1.0-nightly.20241109.e8ee7e0 44 11/09/2024
2.1.0-nightly.20241108.8ba35d0 47 11/08/2024
2.1.0-nightly.20241108.8477567 52 11/08/2024
2.1.0-nightly.20241107.25e6fd7 42 11/07/2024
2.1.0-nightly.20241106.25e6fd7 44 11/06/2024
2.1.0-nightly.20241105.4d6adf5 46 11/05/2024
2.1.0-nightly.20241105.25e6fd7 47 11/05/2024
2.1.0-nightly.20241104.4d6adf5 26 11/04/2024
2.1.0-nightly.20241104.3fd0f4f 26 11/04/2024
2.1.0-nightly.20241103.3fd0f4f 43 11/03/2024
2.1.0-nightly.20241102.3fd0f4f 43 11/02/2024
2.1.0-nightly.20241101.3fd0f4f 41 11/01/2024
2.1.0-nightly.20241031.3fd0f4f 47 10/31/2024
2.1.0-nightly.20241030.3fd0f4f 47 10/30/2024
2.1.0-nightly.20241029.3fd0f4f 47 10/29/2024
2.1.0-nightly.20241028.3fd0f4f 47 10/28/2024
2.1.0-nightly.20241027.3fd0f4f 46 10/27/2024
2.1.0-nightly.20241026.3fd0f4f 43 10/26/2024
2.1.0-nightly.20241025.3fd0f4f 36 10/25/2024
2.1.0-nightly.20241024.9bb5282 48 10/24/2024
2.1.0-nightly.20241023.9bb5282 44 10/23/2024
2.1.0-nightly.20241022.9bb5282 48 10/22/2024
2.1.0-nightly.20241021.9bb5282 47 10/21/2024
2.1.0-nightly.20241020.9bb5282 51 10/20/2024
2.1.0-nightly.20241019.9bb5282 48 10/19/2024
2.1.0-nightly.20241018.9bb5282 50 10/18/2024
2.1.0-nightly.20241017.9bb5282 51 10/17/2024
2.1.0-nightly.20241016.9bb5282 52 10/16/2024
2.1.0-nightly.20241015.9bb5282 26 10/15/2024
2.1.0-nightly.20241014.9bb5282 26 10/14/2024
2.1.0-nightly.20241013.9bb5282 48 10/13/2024
2.1.0-nightly.20241012.9bb5282 25 10/12/2024
2.1.0-nightly.20241011.9bb5282 33 10/11/2024
2.1.0-nightly.20241009.9bb5282 48 10/09/2024
2.1.0-nightly.20241008.9bb5282 48 10/08/2024
2.1.0-nightly.20241007.9bb5282 49 10/07/2024
2.1.0-nightly.20241006.4099e01 49 10/06/2024
2.0.9 101 10/01/2024
2.0.9-nightly.20241006.119dd40 48 10/06/2024
2.0.9-nightly.20241005.119dd40 48 10/05/2024
2.0.9-nightly.20241004.119dd40 48 10/04/2024
2.0.9-nightly.20241003.119dd40 48 10/03/2024
2.0.9-nightly.20241002.119dd40 47 10/02/2024
2.0.9-nightly.20241001.bedb272 50 10/01/2024
2.0.9-nightly.20240930.006258e 50 09/30/2024
2.0.8 94 09/29/2024
2.0.8-nightly.20240930.13d122d 49 09/30/2024
2.0.8-nightly.20240929.cf61d64 50 09/29/2024
2.0.8-nightly.20240928.cf61d64 49 09/28/2024
2.0.8-nightly.20240927.cf61d64 52 09/27/2024
2.0.8-nightly.20240926.cf61d64 49 09/26/2024
2.0.8-nightly.20240925.cf61d64 53 09/25/2024
2.0.8-nightly.20240924.cf61d64 48 09/24/2024
2.0.8-nightly.20240923.cf61d64 25 09/23/2024
2.0.8-nightly.20240922.47ec8ee 54 09/22/2024
2.0.8-nightly.20240921.47ec8ee 51 09/21/2024
2.0.8-nightly.20240920.47ec8ee 50 09/20/2024
2.0.8-nightly.20240919.47ec8ee 51 09/19/2024
2.0.8-nightly.20240918.47ec8ee 25 09/18/2024
2.0.8-nightly.20240917.47ec8ee 50 09/17/2024
2.0.8-nightly.20240916.47ec8ee 51 09/16/2024
2.0.8-nightly.20240915.ceae473 48 09/15/2024
2.0.8-nightly.20240914.0f65302 98 09/14/2024
2.0.8-nightly.20240913.f82616f 50 09/13/2024
2.0.8-nightly.20240913.7bb81bd 49 09/13/2024
2.0.8-nightly.20240913.606d5ba 52 09/13/2024
2.0.8-nightly.20240912.322c516 51 09/12/2024