Fandom

武装突袭 Wiki

RaP File Format - Elite

简体 | 繁體

4,827个页面创建
于此维基上
添加新页面
评论0 Share

您使用了广告屏蔽软件!


Wikia通过广告运营为用户提供免费的服务。我们对用户通过嵌入广告屏蔽软件访问网站进行了使用调整。

如果您使用了广告屏蔽软件,将无法使用我们的服务。请您移除广告屏蔽软件,以确保页面正常加载。

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 aren't, 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 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.

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
class0-classname4byte OffsetToBodyclass thing{...};
string10name=Asciiz stringthing="hello";
float11name=4byte floatthing=0.123;
long12name=4byte longthing=123;
Array2-name[]={nElements Elements[nElements]}thing[]={1,0.2,"three",{4,5,6},{"seven"}};
extern3-classname-class thing;
delete4-classname-delete thing;

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;

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 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编辑

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.

更多维基

随机维基