Data Types

From BFBB Wiki
Jump to: navigation, search

Basic types[edit]

Type Description
int, int32 32-bit signed integer
uint, uint32 32-bit unsigned integer
short, int16 16-bit signed integer
ushort, uint16 16-bit unsigned integer
byte 8-bit signed integer
char 8-bit unsigned ASCII integer
float IEEE 754 floating point number

Structs[edit]

AssetID[edit]

Asset ID is a type derived from uint32 (unsigned integer). It is considered its own type due to how the game uses Asset IDs to uniquely identify an asset and manage communication between them.

Type Description
uint 32-bit unsigned integer

To calculate the asset ID for the original game's assets, the game runs the BKDR hash algorithm on the asset's name converted to upper case. This is specially important to know when editing RWTX assets; to be able to refer to them from MODL, BSP and JSP assets, the game calculates the hash at runtime and finds the textures based on that.

This is HipHopTool's implementation of the algorithm in C#:

   public static uint BKDRHash(string str)
   {
       str = str.ToUpper();
       uint seed = 131;
       uint hash = 0;
       int length = str.Length;
       
       if (length > 31)
           length = 31;
       
        for (int i = 0; i < length; i++)
           hash = (hash * seed) + str[i];
       
       return hash;
   }

Vector2[edit]

Vector2 is a set of 2 floats, which usually represent a 2D vector on the world; it is used mostly for texture coordinates.

Type Description
float X - The X coordinate of this vector
float Y - The Y coordinate of this vector

Vector3[edit]

Vector3 is a set of 3 floats, which usually represent a 3D vector on the world, be it position, rotation or scale.

Type Description
float X - The X coordinate of this vector
float Y - The Y coordinate of this vector
float Z - The Z coordinate of this vector

Vector4[edit]

Vector4 is a set of 4 floats. They can represent a vector in 4D space, and also a color with R, G, B, A components ranging from 0 to 1.

Type Description
float X - The X coordinate of this vector
float Y - The Y coordinate of this vector
float Z - The Z coordinate of this vector
float W - The W coordinate of this vector

UIColor[edit]

UIColor is a set of 4 bytes, which represent a 32 bit color with red, blue, green and alpha components.

Type Description
byte R - red component of this color
byte G - green component of this color
byte B - blue component of this color
byte A - alpha component of this color