Overview
The `SMTK_WnA_Code` is a 32-bit unsigned integer that uniquely identifies any combination of weapon system and ammunition. By using bitwise operations, three critical pieces of information—weapon category (Type), the specific weapon system, and the ammunition type—are encoded into a single, compact field. This documentation outlines the structure of the WnA code and provides the necessary definitions for each field.
WnA Code Bitfield Structure
| TYPE | WEAPON | AMMO | |||||||||||||||||||||||||||||
| 31-28 | 27-15 | 14-0 | |||||||||||||||||||||||||||||
Field Descriptions
| Field | Bits | Description |
|---|---|---|
| TYPE | 4 | Defines the general category of the weapon system (e.g., Handgun, Rifle). |
| WEAPON | 13 | A unique code identifying the specific weapon system. |
| AMMO | 15 | A unique code identifying the specific type of ammunition. |
C Structure Definition (`SMTK_WnA_Code_t`)
typedef struct
{
uint32_t wna_code; // The full 32-bit WnA code
uint8_t type; // 4 bits for weapon type
uint16_t weapon; // 13 bits for the weapon code
uint16_t ammo; // 15 bits for the ammunition code
} SMTK_WnA_Code_t;
The Core Logic: Encoding and Decoding
The API provides macros to seamlessly compose the 32-bit code from its parts (encoding) and extract the parts from the code (decoding) using bitwise operations.
Encoding Process
Type Code
+
Weapon Code
+
Ammo Code
↓
SMTK_WnA_MSK_32bit_CODE(t, w, a)
(Bitwise Shifts & OR operations)
↓
32-bit WnA Code
Decoding Process
32-bit WnA Code
↓
SMTK_WnA_GET_...(x)
(Bitwise Masking & Right Shifts)
↓
Type Code
Weapon Code
Ammo Code
`TYPE` Field Definitions
| Macro | Value (Hex) | Description |
|---|---|---|
| WNA_TYPE_CODE_MED | 0x0 | Medical |
| WNA_TYPE_CODE_HGUN | 0x1 | Handgun |
| WNA_TYPE_CODE_RIFLE | 0x2 | Rifle |
| WNA_TYPE_CODE_CREW | 0x3 | Crew Served |
| WNA_TYPE_CODE_AT | 0x4 | Anti-Tank |
| WNA_TYPE_CODE_MORTAR | 0x5 | Mortar |
| WNA_TYPE_CODE_DRONE | 0x6 | Drone Payload |
| WNA_TYPE_CODE_MISSILE | 0x7 | Missile |
| WNA_TYPE_CODE_EW | 0x8 | Electronic Warfare |
| WNA_TYPE_CODE_PYRO | 0x9 | Pyrotechnic |
| WNA_TYPE_CODE_DEMO | 0xA | Demolition |
| WNA_TYPE_CODE_DE | 0xB | Directed Energy |
| WNA_TYPE_CODE_RESERVED_1 | 0xC | Reserved |
| WNA_TYPE_CODE_RESERVED_2 | 0xD | Reserved |
| WNA_TYPE_CODE_RESERVED_3 | 0xE | Reserved |
| WNA_TYPE_CODE_RESERVED_4 | 0xF | Reserved |