DarkTimes
5th April 2008, 23:42
Hello,
I needed to use my MPR header parser in a separate project, so I pulled it out of my maze of spaghetti code and put it in its own .dll. I liked this idea so I also added SPR header parsing code to it as well. I figured other people might find it useful, so I've uploaded it here.
Trivial example of parsing an MPR header using the library:
using System;
using System.IO;
// You'll need this.
using DarkTimes.Lfs.Replays;
namespace LfsReplayParserExample
{
class Program
{
static void Main()
{
string path = @"X:\Path\To\Replay\Replay.mpr";
MultiPlayerReplay replay = null;
try
{
replay = MultiPlayerReplay.Parse(path);
Console.WriteLine("Track: {0}", replay.Track.ShortTrackName);
Console.WriteLine("Laps: {0}", replay.Laps);
Console.WriteLine("Start Time: {0}", replay.StartTime);
for (int i = 0, j = 1; i < replay.Results.Length; i++, j++)
{
Console.WriteLine(
"{0}. {1} | Time: {2} | Best Lap: {3}",
j,
replay.Results[i].PlayerName,
replay.Results[i].OverallTime,
replay.Results[i].BestLapTime);
}
}
catch (ReplayException ex)
{
Console.WriteLine("Error parsing replay: {0}", ex.Message);
}
}
}
}The library is completely documented with XML for intellisense, so it should be fairly straight-forward to use. As with anything I ever make I'm extremely grateful for any comments, suggestions and bug-reports.
Note: This library and its source are released under the GNU General Public License (http://www.gnu.org/copyleft/gpl.html). Please make sure you read and understand the license before you use it.
I needed to use my MPR header parser in a separate project, so I pulled it out of my maze of spaghetti code and put it in its own .dll. I liked this idea so I also added SPR header parsing code to it as well. I figured other people might find it useful, so I've uploaded it here.
Trivial example of parsing an MPR header using the library:
using System;
using System.IO;
// You'll need this.
using DarkTimes.Lfs.Replays;
namespace LfsReplayParserExample
{
class Program
{
static void Main()
{
string path = @"X:\Path\To\Replay\Replay.mpr";
MultiPlayerReplay replay = null;
try
{
replay = MultiPlayerReplay.Parse(path);
Console.WriteLine("Track: {0}", replay.Track.ShortTrackName);
Console.WriteLine("Laps: {0}", replay.Laps);
Console.WriteLine("Start Time: {0}", replay.StartTime);
for (int i = 0, j = 1; i < replay.Results.Length; i++, j++)
{
Console.WriteLine(
"{0}. {1} | Time: {2} | Best Lap: {3}",
j,
replay.Results[i].PlayerName,
replay.Results[i].OverallTime,
replay.Results[i].BestLapTime);
}
}
catch (ReplayException ex)
{
Console.WriteLine("Error parsing replay: {0}", ex.Message);
}
}
}
}The library is completely documented with XML for intellisense, so it should be fairly straight-forward to use. As with anything I ever make I'm extremely grateful for any comments, suggestions and bug-reports.
Note: This library and its source are released under the GNU General Public License (http://www.gnu.org/copyleft/gpl.html). Please make sure you read and understand the license before you use it.