README.md

Simresults

Simresults is an open-source, object-oriented library built using PHP. It
allows you to read out log files of a race game and transforms them to a simple
data model to easily read out this data.

This project is the core of the website simresults.net
, which allows you to upload your race log files and transform them to a
readable format. The uploaded results become saved and public, so visitors can
share them with their fellow racers. An example result can be found at
http://simresults.net/130529-X2g.

The website is a service but also a demonstration of what is possible using
this library. This library does not supply any HTML templates or whatsoever.
Any 'implementation' is up to you within your own project and is not limited
to any framework.

Assetto Corsa Server reader JSON

RaceRoom Server reader

RACE 07 reader

Also works for the following games: RACE, GTR, GTR2, GT Legends,
BMW M3 Challenge, F1 challenge 99-02 and all expansions of these games

Checks and fixes log variations like non-zero based laps and missing lap data

Requirements

PHP 5.3

Composer (for easy installing and autoloading)

Installation and example

Simresults can be installed and autoloaded using
composer. But ofcourse it will work with any
PSR-0
autoloader.

Example for Linux/OSX

Install composer:

curl -s http://getcomposer.org/installer | php

Create file composer.json:

{
"require": {
"mauserrifle/simresults":"dev-develop"
}
}

Run composer install

./composer.phar install

Create index.php:

<?php
// Load code
require(realpath('vendor/autoload.php'));
// Path to the result source file
$file = realpath(dirname(__FILE__)
.'/vendor/mauserrifle/simresults/tests/logs/rfactor2'
.DIRECTORY_SEPARATOR.'race.xml');
// Get a reader using the source file
$reader = \Simresults\Data_Reader::factory($file);
// Get the session
$session = $reader->getSession();
// Get participants sorted by their position
$participants = $session->getParticipants();
// Get the driver name of the second participant
$driver_name = $participants[1]->getDriver()->getName();
// Get the best lap of the second participant
$best_lap = $participants[1]->getBestLap();
// Get the best lap of the session
$session_best_lap = $session->getBestLap();
// Format the gap between the two laps
$helper = new \Simresults\Helper;
$best_lap_gap = $helper->formatTime($session_best_lap->getGap($best_lap));
echo $best_lap_gap;

Bugs

Known issues

Caching

Some classes like Participant do heavy caching. So changing any value after
calling sorting methods will be pointless. There are no cache invalidate
methods (yet). Most likely they will never be needed as there's no use case you
actually would want to change values after reading out all data.

When writing a reader. NEVER call methods like getVehicle() on Participant
(which uses cached methods). Re-use your own created objects (like $vehicle)
within the reading to prevent any early invalid cache. Do this for all type of
objects.

Laps missing

Logs tend to miss lap data on all games. Check the logs.

Marked as RACE session while it's not

The Race 07 reader detects qualify if all drivers are DNF. There's no session
type in these log files. This detection might be false in some cases.

Date is not right of session

GTR, GTL, F1 challenge don't have a timestamp or timezone information. So
dates are created using the default timezone.

Contributing

The project is designed to be extended with new features and game support.
Feel free to fork Simresults on GitHub
and submit a pull request!

The project is tested using PHPUnit and phpspec. If you offer any changes,
make sure all your new additions are tested.

Running simresults tests

To run the tests, use the following command:

./vendor/bin/phpunit
./vendor/bin/phpspec run

License

The Simresults library is open-sourced software licensed under the
ISC license.