raP File Format - Elite: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Text replacement - ";[ ]+ " to "; ")
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{unsupported-doc}}
{{Feature|UnsupportedDoc}}
==Caveat==
== Caveat ==


If you are researching the nitty gritty of raP encoding for [[raP File Format - OFP|OFP]] you are in the wrong place. This document is specifically for Elite/Arma1 & 2 raPified files on the Xbox and beyond. However, if you are not too familiar with this subject, the Introduction in the [[raP File Format - OFP|OFP]] version will help you best.
If you are researching the nitty gritty of raP encoding for [[raP File Format - OFP|OFP]] you are in the wrong place. This document is specifically for Elite/Arma1 & 2 raPified files on the Xbox and beyond. However, if you are not too familiar with this subject, the Introduction in the [[raP File Format - OFP|OFP]] version will help you best.




==Changes from OFP==
== Changes from OFP ==


*Two new entry types
*Two new entry types
Line 19: Line 19:
  non-contiguous data stream. Class '''bodies''' are now located 'arbitrarily' in a file offset, as opposed to being directly after the class name.
  non-contiguous data stream. Class '''bodies''' are now located 'arbitrarily' in a file offset, as opposed to being directly after the class name.
*a rarely used sha/md5
*a rarely used sha/md5
==Changes at Arma==
== Changes at Arma ==
*Enhanced token is not used.
*Enhanced token is not used.
*sha/md5 is not used
*sha/md5 is not used


==Introduction==
== Introduction ==
<big>raP encoding for Xbox Files</big>
<big>raP encoding for Xbox Files</big>


===Conventions===
=== Conventions ===
see [[Generic FileFormat Data Types]]
see [[Generic FileFormat Data Types]]


===Mandatory PreReading===
=== Mandatory PreReading ===


====The Human====
==== The Human ====


[[BI]] use c++ class syntax to package data for almost everything. Anything configurable / alterable / makeable / editable by a player (author) involves creating a file or files consisting of class statements. The Mission Editor eg, creates several files for a mission  consisting solely of class statements. Everything is defined or declared within classes. There is no specific file extension that is or is not a rap file. an rvmat or mission.sqm can, as equally be humanly readable text, or, binarised rap. '''Any''' text file that contains class statements, is, by definition, a rapifiable file. This includes bisurf, fsm, cpp, (model).cfg, BI's world revolves around the engine's ability to work with data contained in (a series of) class {bodies}. So much so, that at run time, a file that is in humanly readable text, is automatically converted to rap binary. The engine never sees 'text'. This also applies to description.ext and some other files that cannot be SAVED as rap binary, but are, most definately, rapified by the engine before use.
[[BI]] use c++ class syntax to package data for almost everything. Anything configurable / alterable / makeable / editable by a player (author) involves creating a file or files consisting of class statements. The Mission Editor eg, creates several files for a mission  consisting solely of class statements. Everything is defined or declared within classes. There is no specific file extension that is or is not a rap file. an rvmat or mission.sqm can, as equally be humanly readable text, or, binarised rap. '''Any''' text file that contains class statements, is, by definition, a rapifiable file. This includes bisurf, fsm, cpp, (model).cfg, BI's world revolves around the engine's ability to work with data contained in (a series of) class {bodies}. So much so, that at run time, a file that is in humanly readable text, is automatically converted to rap binary. The engine never sees 'text'. This also applies to description.ext and some other files that cannot be SAVED as rap binary, but are, most definately, rapified by the engine before use.
Line 55: Line 55:
  };
  };


Any given file that contains classes, contains nothing else but classes. There aren't, classes, and ummm, err, ummm 'other' things.  
Any given file that contains classes, contains nothing else but classes. There are not, classes, and ummm, err, ummm 'other' things.  


'''The file itself is considered an implied class!'''  
'''The file itself is considered an implied class!'''  
Line 65: Line 65:
Everything within that file is embedded within the class filename {....};
Everything within that file is embedded within the class filename {....};


====The Engine====
==== The Engine ====


The class structure is used internally within the engine for all most game data and configuration. The engine holds this data in tokenised form for more efficient processing.
The class structure is used internally within the engine for all most game data and configuration. The engine holds this data in tokenised form for more efficient processing.
Line 71: Line 71:
This internal tokenised data can also be held in a file (a savegame eg). But, it is a class structure regardless.
This internal tokenised data can also be held in a file (a savegame eg). But, it is a class structure regardless.


To improve loading speed many files within the ofp tree are pre-tokenised. They were 'converted' to hold the tokenised form of the same class statements.
To improve loading speed many files within the {{ofp}} tree are pre-tokenised. They were 'converted' to hold the tokenised form of the same class statements.


In fact, the engine does not care which 'type' of file it is dealing with. A mission.sqm can be either. If it hasn't been pre-tokenised (eg contains text-readable class statements) the engine converts it on the fly.
In fact, the engine does not care which 'type' of file it is dealing with. A mission.sqm can be either. If it has not been pre-tokenised (eg contains text-readable class statements) the engine converts it on the fly.


Tokenised files have a magic signature as their first four bytes. "\0raP". The file extension is meaningless in this regard.
Tokenised files have a magic signature as their first four bytes. "\0raP". The file extension is meaningless in this regard.
Line 83: Line 83:
They are detailed here as 'raP' files because of their unique signature. This document refers to rapifying and de-rapifying files containing nothing but, class statements.
They are detailed here as 'raP' files because of their unique signature. This document refers to rapifying and de-rapifying files containing nothing but, class statements.


==Xbox/Arma==
== Xbox/Arma ==


raP encoding is an extension to Flashpoint PC raP encoding.
raP encoding is an extension to Flashpoint PC raP encoding.


==Overall Structure==
== Overall Structure ==
  struct raP
  struct raP
  {
  {
Line 93: Line 93:
   byte  AuthenticationSignature[20] // XBOX ONLY NOT ARMA
   byte  AuthenticationSignature[20] // XBOX ONLY NOT ARMA
   ulong  Always0;
   ulong  Always0;
   ushort Always8;
   ulong  Always8;
   ulong  OffsetToEnums;
   ulong  OffsetToEnums;
   
   
   ClassBody  ClassBody;              // one and one only, within which, will be more class bodies
   ClassBody  ClassBody;              // one and one only, within which, will be more class bodies
Line 106: Line 106:


''' All offsets are relative to start of file'''
''' All offsets are relative to start of file'''
===Authentication Signature===
=== Authentication Signature ===


Unique to Xbox, not known on ArmA.
Unique to Xbox, not known on ArmA.
Line 116: Line 116:
The signature is 'optional' '''only''' in the sense that not all types of files have it. A signature appears in '''.par''' files for example, but not in the official bis mission.sqms.
The signature is 'optional' '''only''' in the sense that not all types of files have it. A signature appears in '''.par''' files for example, but not in the official bis mission.sqms.


===File Offset to Enumerated list===
=== File Offset to Enumerated list ===


the offset points to points to the end of All class data and consequently the start of an enum list (if any).
the offset points to points to the end of All class data and consequently the start of an enum list (if any).


There may well be, no enumerated list, there '''will''' be a ListCount saying so!
There may well be, no enumerated list, there '''will''' be a ListCount saying so!
===ClassBody===
=== ClassBody ===
  ClassBody
  ClassBody
  {
  {
Line 136: Line 136:




==ClassEntries==
== ClassEntries ==


{| class="wikitable" border="0"
{| class="wikitable" border="0"
Line 159: Line 159:
|-
|-
|align="left"|delete||4||-||classname||-||delete thing;
|align="left"|delete||4||-||classname||-||delete thing;
|-
|align="left"|Array with flag||5||-||name[]+=||4 bytes of flag followed by {nElements Elements[nElements]}||thing[]+={1,0.2,"three",{4,5,6},{"seven"}};
|-
|-
|-
|-
|}
|}


==Entry Types==
== Entry Types ==


  0 Embedded Class
  0 Embedded Class
Line 171: Line 173:
  4 delete /*class*/ label;
  4 delete /*class*/ label;


===EntryType 0: RapClass===
=== EntryType 0: RapClass ===


  RapClass
  RapClass
Line 177: Line 179:
   byte                    Type;            // 0
   byte                    Type;            // 0
   Asciiz                  ClassName
   Asciiz                  ClassName
   ulong                    OffsetToClassBody;  
   ulong                    OffsetToClassBody;
  };
  };


'''All offsets in raP are relative to the start of file.'''
'''All offsets in raP are relative to the start of file.'''


===EntryType 1: Value Eq===
=== EntryType 1: Value Eq ===


  RapValue
  RapValue
Line 195: Line 197:
   01 04 Aname=Asciiz Variable name; // public or private
   01 04 Aname=Asciiz Variable name; // public or private


====SubType 4: Asciiz Variable Name====
==== SubType 4: Asciiz Variable Name ====


XBOX only
XBOX only
Line 204: Line 206:
  Aname=_fred;    // public or private variable
  Aname=_fred;    // public or private variable


===EntryType 2: array[]===
=== EntryType 2: array[] ===


  RapArray
  RapArray
Line 213: Line 215:
  };
  };


==ArrayStruct==
==== ArrayStruct ====
   [[#CompressedInteger]] nElements;ArrayElements[nElements];
   [[#CompressedInteger]] nElements;ArrayElements[nElements];


nElements is a declaring how many items make up the array, zero, is a legal value
nElements is a declaring how many items make up the array, zero, is a legal value


==ArrayElements==
==== ArrayElements ====


each element of the array consists of a single subtype byte followed by appropriate data for the type. Thus
each element of the array consists of a single subtype byte followed by appropriate data for the type. Thus
Line 233: Line 235:
  AnArray[]= { {1,2} , 3,4};
  AnArray[]= { {1,2} , 3,4};


===EntryType 3:ExternClass===
=== EntryType 3: ExternClass ===
   
   
  03 Asciiz Classname; // class Classname;
  03 Asciiz Classname; // class Classname;


===EntryType 4:Delete Class===
=== EntryType 4: Delete Class ===
  04 Asciiz Classname; // delete Classname;
  04 Asciiz Classname; // delete Classname;


=== Entry type 5: Array with flags ===
The only flag that exists is 1 which means the following array is supposed to be appended to a existing array. <br>
If such an array to append to isn't found it behaves like a normal array. <br>
It has the 4 byte long flag and after that is the same as ArrayElements. <br>
The engine itself does a binary and with 1 to check if the add flag is set. Meaning the other bits could be filled with arbitrary data.
<hr>
<hr>


==Extern Classes==
== Extern Classes ==


Unlike OFP, a valuable addition to the Token types has been the definition
Unlike OFP, a valuable addition to the Token types has been the definition
Line 264: Line 271:
Instead, the new types deal with all things car. (or at least the engine goes looking elsewhere, which it did, anyway, in ofp).
Instead, the new types deal with all things car. (or at least the engine goes looking elsewhere, which it did, anyway, in ofp).


The intention '''was''' that you did not need to know '''anything''' about how the underlying class (eg CfgVehicles) is constructed. The practicalities are however that you pretty much have to declare an ofp looking tree to 'get at' any of the embedded classes (or inferred, inherited, embedded classes), of the class you're inheriting. This tree structure can become quite long, and, of necessity, accurate, thus there is no real improvement to the ofp way of doing things.
The intention '''was''' that you did not need to know '''anything''' about how the underlying class (eg CfgVehicles) is constructed. The practicalities are however that you pretty much have to declare an {{ofp}} looking tree to 'get at' any of the embedded classes (or inferred, inherited, embedded classes), of the class you're inheriting. This tree structure can become quite long, and, of necessity, accurate, thus there is no real improvement to the {{ofp}} way of doing things.




===CompressedInteger===
=== CompressedInteger ===


This is the same construct as found in [[raP File Format - OFP|OFP raP files]].
This is the same construct as found in [[raP File Format - OFP|OFP raP files]].
Line 273: Line 280:
The value is used to declare the number of entries in the class body or nArrays
The value is used to declare the number of entries in the class body or nArrays


==enumerated list (optional)==
== enumerated list (optional) ==


The next four bytes after all class bodies are the enumerated list count. These defines (if any) continue until end of file.  
The next four bytes after all class bodies are the enumerated list count. These defines (if any) continue until end of file.  
Line 311: Line 318:




[[category:Operation Flashpoint Elite: Modelling|RAP]]
{{GameCategory|ofpe|Modelling}}
[[Category:BIS_File_Formats|RAP]]
[[Category:BIS_File_Formats|RAP]]

Latest revision as of 00:53, 8 August 2021

bi symbol white.png
Disclaimer: This page describes internal undocumented structures of Bohemia Interactive software.

This page contains unofficial information.

Some usage of this information may constitute a violation of the rights of Bohemia Interactive and is in no way endorsed or recommended by Bohemia Interactive.
Bohemia Interactive is not willing to tolerate use of such tools if it contravenes any general licenses granted to end users of this community wiki or BI products.

Caveat

If you are researching the nitty gritty of raP encoding for OFP you are in the wrong place. This document is specifically for Elite/Arma1 & 2 raPified files on the Xbox and beyond. However, if you are not too familiar with this subject, the Introduction in the OFP version will help you best.


Changes from OFP

  • Two new entry types
/*extern*/ class thing;
delete /*class*/ thing;
  • Enhanced TokenName
name= RealVariable (as opposed to name="variable";) Xbox mission.par's only
  • Non contiguous data file
non-contiguous data stream. Class bodies are now located 'arbitrarily' in a file offset, as opposed to being directly after the class name.
  • a rarely used sha/md5

Changes at Arma

  • Enhanced token is not used.
  • sha/md5 is not used

Introduction

raP encoding for Xbox Files

Conventions

see Generic FileFormat Data Types

Mandatory PreReading

The Human

BI use c++ class syntax to package data for almost everything. Anything configurable / alterable / makeable / editable by a player (author) involves creating a file or files consisting of class statements. The Mission Editor eg, creates several files for a mission consisting solely of class statements. Everything is defined or declared within classes. There is no specific file extension that is or is not a rap file. an rvmat or mission.sqm can, as equally be humanly readable text, or, binarised rap. Any text file that contains class statements, is, by definition, a rapifiable file. This includes bisurf, fsm, cpp, (model).cfg, BI's world revolves around the engine's ability to work with data contained in (a series of) class {bodies}. So much so, that at run time, a file that is in humanly readable text, is automatically converted to rap binary. The engine never sees 'text'. This also applies to description.ext and some other files that cannot be SAVED as rap binary, but are, most definately, rapified by the engine before use.

Class anything ultimately means raP binary


Class syntax can briefly (but accurately) be described as follows:

class thing [: InheritedClass]
{
  body
};

[: InheritedClass] is optional. It is heavily used in the config.cpp's of addons. If specified it must be referenced prior to being used.

The body of a class consists of

{
 #tokens and /or
 #arrays and /or
 #(embedded) classes and /or
 #nothing at all!  class default{};  is perfectly valid eg.
};

Any given file that contains classes, contains nothing else but classes. There are not, classes, and ummm, err, ummm 'other' things.

The file itself is considered an implied class!

The very first statement of all files is

//class filename {

Everything within that file is embedded within the class filename {....};

The Engine

The class structure is used internally within the engine for all most game data and configuration. The engine holds this data in tokenised form for more efficient processing.

This internal tokenised data can also be held in a file (a savegame eg). But, it is a class structure regardless.

To improve loading speed many files within the Operation Flashpoint tree are pre-tokenised. They were 'converted' to hold the tokenised form of the same class statements.

In fact, the engine does not care which 'type' of file it is dealing with. A mission.sqm can be either. If it has not been pre-tokenised (eg contains text-readable class statements) the engine converts it on the fly.

Tokenised files have a magic signature as their first four bytes. "\0raP". The file extension is meaningless in this regard.

In the early days of ofp, when the campaign mission.sqm's came pre-tokenised, it was assumed wrongly, this was some attempt at encryption. They were also called 'binary' files because it was noticed that the tokenised form of a config.cpp was called config.bin (config.rap would have been far more appropriate). In fact, the engine will happily work with a config.cpp that is rap encoded.

Various utilities (tools) arrived on the internet in an attempt to decode them (and conversely, encode them). cpp2bin, bin2cpp, Coc binview are the most well known of these.

They are detailed here as 'raP' files because of their unique signature. This document refers to rapifying and de-rapifying files containing nothing but, class statements.

Xbox/Arma

raP encoding is an extension to Flashpoint PC raP encoding.

Overall Structure

struct raP
{
 char   Signature[4];               // 4 byte raP signature (\0raP)
 byte   AuthenticationSignature[20] // XBOX ONLY NOT ARMA
 ulong  Always0;
 ulong  Always8;
 ulong  OffsetToEnums;

 ClassBody  ClassBody;              // one and one only, within which, will be more class bodies

 Enums
 {
  ulong  nEnums;  // generally always 0
  enumlist....    // optional
 };
};

All offsets are relative to start of file

Authentication Signature

Unique to Xbox, not known on ArmA.

Following the four byte signature "\0 r a P" is an optional 20 byte signature intended to provide a unique value to this file and to prevent tampering. This value, or 'Authentication signature' is generated from a common 'Authentication Key' plus the content of the file itself. The Authentication key for Xbox Elite is 16 bytes and not listed here.

You can obtain source code for generating signatures elsewhere.

The signature is 'optional' only in the sense that not all types of files have it. A signature appears in .par files for example, but not in the official bis mission.sqms.

File Offset to Enumerated list

the offset points to points to the end of All class data and consequently the start of an enum list (if any).

There may well be, no enumerated list, there will be a ListCount saying so!

ClassBody

ClassBody
{
 Asciiz               InheritedClassname; // can be zero
 #CompressedInteger   nEntries;           // can be zero.
 ClassEntry           ClassEntries[nEntries];
};

ClassBodies contain zero or more 'entries'. These 'entries' consist of strings, arrays, classes, etc. The 1st byte of each entry defines what 'type' of entry it is.

Note that ALL classes other than the first class body above are EMBEDDED classes within this one.

Furthermore, this unique class cannot have an inheritance (obviously), and their is no classname associated with it. In OFP raP the classname of this unique class was, the name of the file (config.cpp eg)


ClassEntries

Type ID SubID Asciiz Name Value Example
class 0 - classname 4byte OffsetToBody class thing{...};
string 1 0 name= Asciiz string thing="hello";
float 1 1 name= 4byte float thing=0.123;
long 1 2 name= 4byte long thing=123;
Array 2 - name[]= {nElements Elements[nElements]} thing[]={1,0.2,"three",{4,5,6},{"seven"}};
extern 3 - classname - class thing;
delete 4 - classname - delete thing;
Array with flag 5 - name[]+= 4 bytes of flag followed by {nElements Elements[nElements]} thing[]+={1,0.2,"three",{4,5,6},{"seven"}};

Entry Types

0 Embedded Class
1 value = (string, float, integer, variable)
2 array[]={....};
3 /*extern*/ class label;
4 delete /*class*/ label;

EntryType 0: RapClass

RapClass
{
 byte                     Type;             // 0
 Asciiz                   ClassName
 ulong                    OffsetToClassBody;
};

All offsets in raP are relative to the start of file.

EntryType 1: Value Eq

RapValue
{
  byte   Type;   //1
  byte   SubType;
  Asciiz Aname;
  01 00 Aname="AString";
  01 01 Aname= float;
  01 02 Aname= long;
//01 03 AnArray[]= { .........}; not used
  01 04 Aname=Asciiz Variable name; // public or private

SubType 4: Asciiz Variable Name

XBOX only

A variable name (as opposed to a string constant) is as follows

Aname = "fred"; // constant
Aname=_fred;    // public or private variable

EntryType 2: array[]

RapArray
{
  byte   Type;// 02
  Asciiz ArrayName;
  ArrayStruct;
};

ArrayStruct

 #CompressedInteger nElements;ArrayElements[nElements];

nElements is a declaring how many items make up the array, zero, is a legal value

ArrayElements

each element of the array consists of a single subtype byte followed by appropriate data for the type. Thus

0 Asciiz string constant;
1 float
2 long
3 recursive array  ArrayStruct;
4 Asciiz String variable

A recursive array recurses into further entries with no name attached.

A recursive array is as follows

AnArray[]= { {1,2} , 3,4};

EntryType 3: ExternClass

03 Asciiz Classname; // class Classname;

EntryType 4: Delete Class

04 Asciiz Classname; // delete Classname;

Entry type 5: Array with flags

The only flag that exists is 1 which means the following array is supposed to be appended to a existing array.
If such an array to append to isn't found it behaves like a normal array.
It has the 4 byte long flag and after that is the same as ArrayElements.
The engine itself does a binary and with 1 to check if the add flag is set. Meaning the other bits could be filled with arbitrary data.


Extern Classes

Unlike OFP, a valuable addition to the Token types has been the definition

/*extern*/ class car;

class BigCar:car {...};
class RedCar:BigCar{...};

The tedious business of listing

class All:Default{};
class Vehicle:All{};
...
class Target:Vehicle{};
class Strategic:Target{};
class car{}:Strategic{};

simply to declate a car !!! has (sometimes) been done away with.

Instead, the new types deal with all things car. (or at least the engine goes looking elsewhere, which it did, anyway, in ofp).

The intention was that you did not need to know anything about how the underlying class (eg CfgVehicles) is constructed. The practicalities are however that you pretty much have to declare an Operation Flashpoint looking tree to 'get at' any of the embedded classes (or inferred, inherited, embedded classes), of the class you're inheriting. This tree structure can become quite long, and, of necessity, accurate, thus there is no real improvement to the Operation Flashpoint way of doing things.


CompressedInteger

This is the same construct as found in OFP raP files.

The value is used to declare the number of entries in the class body or nArrays

enumerated list (optional)

The next four bytes after all class bodies are the enumerated list count. These defines (if any) continue until end of file.

Where no list exists (the very normal case), the count is zero.

A list consists of an asciiz name and an (implied) integer value as follows

(manposnoweapon) {01 00 00 00}

which equates in C to

enum {
manposweapon=1,
manshower=88,
manhungry=12,
....
}

This list is encountered in some few 'official' config.cpp's. It's use by model makers is rare.

Textually, you can have as many enum lists as required. They are ultimately congregated into one, enum list at the end of a raP encoded file.

The order in which they are presented in this list has no bearing on their text equivalent. They are (generally) iterated as encountered and always converted to lower case.

You reference enums via their stringname. Thus

thisValue=manposweapon;

and

thisValue="ManPosWeapon";

are identical in effect. Both result in an integer value of 1 being assigned at run time.