Data Types: Difference between revisions
Battlepedia>Igorseabra4 |
Battlepedia>Seil |
||
Line 98: | Line 98: | ||
|} |
|} |
||
=== |
===Color=== |
||
Color is a set of 4 bytes, which represent a 32 bit color with red, blue, green and alpha components. |
|||
{| class="wikitable" |
{| class="wikitable" |
||
Line 106: | Line 106: | ||
! Description |
! Description |
||
|- |
|- |
||
| byte || R - red |
| byte || R - red (0-255) |
||
|- |
|- |
||
| byte || G - green |
| byte || G - green (0-255) |
||
|- |
|- |
||
| byte || B - blue |
| byte || B - blue (0-255) |
||
|- |
|- |
||
| byte || A - alpha |
| byte || A - alpha (0-255) |
||
|- |
|- |
||
|} |
|} |
Revision as of 10:41, 26 November 2018
Basic types
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
AssetID
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
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
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
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 |
Color
Color is a set of 4 bytes, which represent a 32 bit color with red, blue, green and alpha components.
Type | Description |
---|---|
byte | R - red (0-255) |
byte | G - green (0-255) |
byte | B - blue (0-255) |
byte | A - alpha (0-255) |