ReplicaNet and RNLobby  1
RNROLCompiler

Introduction

RNROLCompiler is a utility to aid in creating the files needed to enable classes to use the ReplicaNet replica object interface.

Using the RNROLCompiler

The compiler is called RNROLCompiler.exe and is in the RNROLCompiler\bin directory.

Command line parameters

The compiler takes an input file and two optional output files. If no output files are given then the input ROL filename is used to generate the output CPP and H file names. For example RNROLCompiler.exe <input.rol> <output.cpp> <output.h>
The output cpp and h files can then be included in a project.
Verbose output while compiling can be switched on using the -vx command where 'x' is a number from 0 to 3.
-v0 Turns off verbose output
-v1 Turns on compile time display
-v2 Adds class parsing and compiling status
-v3 Adds what files are being opened and closed
Additional include directories can be set by using -I
Pre-compiled header files can be added to the output cpp by using -P. For example: -Pstdafx.h will add #include "stdafx.h" to the start of the output cpp file.

The ROL Language and using it with development tools

The syntax processing of the language is fairly relaxed so that parameters can be included in brackets or not. For example:

Function AMemberFunction; 

and

Function (AMemberFunction); 

are equivalent

The preprocessor commands:

#include "Object.lang"          // This includes the file Object.lang
#includeclass object            // This includes the "object" class

Can be used to include files or class names. It is usually not neccassary to use the include directives since the RNROLCompiler will search for class definitions automatically.

The standard language include files used by the compiler for definitions of certain base types are located in RNROLCompiler\lang. The standard types can be extended and extra comands added by creating extra 'lang' files or by including the definitions in 'rol' files. For example:
In a file called MyDatablock.lang

class MyDatablock : std_datablock
{
    MyDatablock(x)                      _MY_REGISTER_MACRO(x);

    SetError(x)                         _MY_REGISTER_MACRO_SETERROR(x);

    SetDeltaV1(x)                       _MY_REGISTER_MACRO_SETDELTAV1(x);
};

And in an object rol file

object TestExtension
{
    datablock MyDatablock;

    networking
    {
        MyDatablock mPosition.x;
    }
}

Or if TestExtension is part of a C++ namespace called Foo then use

namespace Foo
{
    object TestExtension
    {
        datablock MyDatablock;

        networking
        {
            MyDatablock mPosition.x;
        }
    }
}

The worked examples in the ReplicaNet SDK show how to extend datablocks in more detail.

To use the compiler with MS VC++ you can use custom build rules per file.
Example:
To build _RO_Object.rol and include this in the project use the custom build rule:
..\RNROLCompiler\bin\RNROLCompiler.exe $(InputName).rol $(InputName).cpp $(InputName).h
Or you could use: ..\RNROLCompiler\bin\RNROLCompiler.exe $(InputPath) $(InputName).cpp $(InputName).h
Or even use: ..\RNROLCompiler\bin\RNROLCompiler.exe $(InputPath)
And for the file output box use:
$(InputName).cpp
$(InputName).h
For MS VC++ 6.0 The carriage return between the cpp and h file is important otherwise MSVC will get confused with build dependency and may rebuild the output files unnecessarily.
Note: This assumes the RNROLCompiler directory is one directory 'below' your project build directory.

The tutorial section shows in much greater how to add these build rules to a ReplicaNet project. ROL Files must end with a blank line and a carriage return.

Example scripts

To define a class called 'Test' and tell ReplicaNet that it has three floats in the form of a struct Position
First define our class. This should be defined in a file called "Test.h"

#include "_RO_Test.h"

class Test : _RO_DO_PUBLIC_RO(Test)     // Note that we include the definition for the ReplicaNet class
{
public:
    Test() {};
    virtual ~Test() {};

    struct Position
    {
        float x,y,z;
    };

    Position mPosition;
};

This section should be saved in to a file called "_RO_Test.rol" and compiled with 'RNROLCompiler _RO_Test.rol _RO_Test.cpp _RO_Test.h'

object Test
{
    datablock Predict_Float;

    networking
    {
        Predict_Float mPosition.x;
        {
            SetMaxError(0.5f);
            SetInterpolationFilter(0.5f);
        }
        Predict_Float mPosition.y;
            SetMaxError(2.0f);
        Predict_Float mPosition.z;
    }
}

This will produce a _RO_Test.cpp and _RO_Test.h that can be included in the project<br>
To link in the object in to the ReplicaNet framework then create another file and use the 'application' keyword to include a reference to the class name.
This example should be saved in a file called "_Def_App.rol" and compiled with 'RNROLCompiler _Def_App.rol _Def_App.cpp _Def_App.h'

application
{
    object Test;
}