Archive for September, 2010

NRatings v3.1.0 released

0

Hey simracers !

Happy to announce the release of NRatings v3.1.0. This is a mandatory update, as the server has been updated too, so v3.0 won’t work any longer.

Grab it from the NRatings page

Changelog:

  • The application now checks for NRatings related news on startup
  • The user can now manually map a “real driver” to a carfile by means of a drop-down menu
  • The user can now revert a car to its original values (right-click on a car)
  • The copy/paste ratings function has now been moved to the contextual menu (right-click on a car)
  • NRatings now detects your NR2003 installation path automatically (from the registry)
  • Some cosmetic improvements in displaying the data in the lists
  • Some minor bug-fixes

Mathieu

Functie ter controle van Belgisch Rijksregisternummer in C#

0

Onderstaande functie kan gebruikt worden om Belgische rijksregisternummers te valideren.

De samenstelling van een rijksregisternummer wordt op deze wiki-pagina uitgelegd: http://nl.wikipedia.org/wiki/Rijksregisternummer

De code geeft een string terug. Deze bevat “M” of “F” naargelang het om een geldig mannelijk of vrouwelijk rijksregisternummer gaat, of een omschrijving van gevonden fouten indien ongeldig.

De functie laat als input ook spaties, punten (.) en dashes (-) toe om een nummer met deze karakters ook te kunnen controleren.

De namespaces System.Text.RegularExpressions en System.Globalization dienen gerefenceerd te worden.


using System.Text.RegularExpressions;
using System.Globalization;

public string CheckRRNumberValidity(string input)
{
    if (input != null)
    {
        string message = "";

        Regex nonAllowedCharacters = new Regex(@"[^0-9. -]");
        Regex nonNumeric = new Regex(@"[^0-9]");

        string rrnumber = input;

        if (nonAllowedCharacters.IsMatch(rrnumber))
            return "Non allowed character";
        else
        {
            //STRIP THE NUMBER FROM ALL NON NUMERIC CHARS
            rrnumber = nonNumeric.Replace(rrnumber, "");

            //LENGTH MUST BE 11 DIGITS
            if (rrnumber.Length != 11)
                return "Length != 11";
            else
            {

                try
                {
                    bool birthDateOK = false;
                    bool counterOK = false;
                    bool controlOK = false;

                    bool born2kOrLater = false;

                    string gender = "(unknown)";

                    //FIRST 6 DIGITS ARE BIRTHDATE IN FORMAT YYMMDD
                    string birthDatePart = rrnumber.Substring(0, 6);

                    //NEXT 3 ARE COUNTER
                    string counterPart = rrnumber.Substring(6, 3);

                    //LAST 2 ARE CONTROLNUMBER
                    string controlPart = rrnumber.Substring(9, 2);

                    /* 1. CONTROL NUMBER CHECKING */
                    /******************************/

                    //CALCULATE CONTROLNUMER (= MOD 97 OF FIRST 9 DIGITS)
                    int calculatedControl = 97 - (int)(Int64.Parse(birthDatePart + counterPart) % 97);

                    if (calculatedControl != Int32.Parse(controlPart))
                    {
                        /* IF THE CALCULATED CONTROL PART IS DIFFERENT THAN THE ONE IN THE INPUTSTRING
                         * ADD A "2" IN FRONT OF THE BIRTHDATEPART AND RECALCULATE. THIS WAS INTRODUCED TO
                         * ALLOW BIRTHDATES OF YEAR 2000 AND LATER
                        */

                        calculatedControl = 97 - (int)(Int64.Parse("2" + birthDatePart + counterPart) % 97);

                        if (calculatedControl != Int32.Parse(controlPart))
                        {
                            /* THE CALCULATION STILL DOESN'T MATCH THE CONTROLNUMER, SO THIS IS AN INVALID
                             * REGISTRY NUMBER
                            */

                            controlOK = false;
                        }
                        else
                        {
                            born2kOrLater = true;
                            controlOK = true;
                        }
                    }
                    else
                        controlOK = true;

                    /* 2. BIRTHDATE CHECKING */
                    /*************************/

                    string d = birthDatePart;
                    //BUILD THE BIRTHDATE TO CHECK
                    if (born2kOrLater == true)
                        d = "20" + birthDatePart;
                    else
                        d = "19" + birthDatePart;
                    //END BUILD

                    string format = "yyyyMMdd";
                    DateTime birthDate;

                    birthDateOK = DateTime.TryParseExact(d, format, CultureInfo.CurrentCulture, DateTimeStyles.None, out birthDate);
                    Console.WriteLine(birthDate.ToString("dd/MM/yyyy"));

                    /* 3. COUNTER CHECKING */
                    /***********************/

                    /* COUNTERPART MUST BE BETWEEN 001 AND 997
                     * EVEN FOR FEMALE
                     * ODD FOR MALE
                    */
                    int counter = Int32.Parse(counterPart);

                    if (counter < 1 || counter > 997)
                        counterOK = false;
                    else if (counter % 2 == 0) //EVEN
                    {
                        counterOK = true;
                        gender = "F"; //FEMALE
                    }
                    else
                    {
                        counterOK = true;
                        gender = "M"; //MALE
                    }

                    /* 4. RETURN GENDER OR MESSAGE */
                    /*******************************/

                    if (!birthDateOK)
                        message += "Invalid birthdate;";
                    if (!counterOK)
                        message += "Invalid counter;";
                    if (!controlOK)
                        message += "Invalid control number;";

                    if (!message.Equals("")) //THERE ARE ERRORS
                    {
                        if (message.EndsWith(";"))
                            message = message.Substring(0, message.Length - 1);

                        return message;
                    }
                    else //IF GETTING HERE, NUMBER SHOULD BE CORRECT AND GENDER FILLED IN
                        return gender;
                }
                catch (Exception ex)
                {
                    return "Exception";
                }
            }
        }
    }
    else
    {
        return "isnull";
    }
}

All data available for NRatings

0

Hey,

just to inform you that the NRatings database now contains all (well, most of) the racing-reference data again, as it was before the release of v3.0.0 !

I’ve also added the NASCAR North Tour series results to the database.

And there’s more: I will be releasing a new client version in the next couple of days which brings some enhancements to the user interface.

Happy simracing !

Friendly Go-Karting race @ Berck-Sur-Mer, France

0

On September 12th, 2010, I took part in the 8th annual go-karting trophy of Berck-Sur-Mer, France.

It’s a coastal city in the French department of the Nord-Pas-de-Calais.

Each year, they transform part of the seaside-walk into a racing track with help of strawbales, where the participants then unleash their mean-machines. It’s very bumpy and wild, especially on these karts with no suspension. It wears you out pretty dang well after a full day of racing.

I started out good, grabbed pole position in my category, and won the first of 3 races. Was in the lead in the second one but then unfortunately I hit a swerving backmarker while trying to overtake him. It bent my rear axle and had to retire. I later found out I had a 4 second lead over the second placed driver at the time of the collision. I didn’t know that, as it is very difficult to look behind you at this track. If I had known it, I probably would have been more cautious while lapping other guys.

Anyway we managed to hammer the axle almost straight again in the pits, and I started the final race in 10th spot. I was able to quickly make up some positions, partly by overtaking, partly due to some guys in front of me crashing. By lap 5 of 17 I was in 3rd, and had a 10 lap long battle with the second placed guy until I finally was able to overtake him when he was a little held up by a backmarker. But with 2 laps to go, the leader was long gone and I could do nothing more than settle for second.

Considering the crash I had in the pre-final, 2nd place still is a good result, although I probably would have won it if I hadn’t had those problems…. but that’s racing.

Here are some of the best pictures of the day:

New seasons added to NRatings v3.0.0

0

Hey,

due to populare request, I’ve now added the seasons from 1990 to 1999 to the Sprint Cup, Nationwide and Truck Series. Please let me know if you experience any drop of performance, as the database now holds a bit more data.

Meanwhile I’m still working on automating the dataparsing, and when that’s done you will be able to use all seasons from all available series again.

Stick around !

Mathieu

Go to Top