Index into a slotted object and assign a sub-object to another slot

Behaviour

  • Look up the object in slot parent_slot
  • Retrieve the sub-object at field_id
  • Place sub-object into the slot new_slot or the next available slot if new_slot is 0.
  • Return the new slot number.

Definition

int64_t slot_subfield (
    uint32_t parent_slot,
  	uint32_t field_id,
  	uint32_t new_slot
);

Example

int64_t amt_slot = 
  	slot_subfield(oslot, sfAmount, 0);

Parameters

NameTypeDescription
parent_slotuint32_tSlot the parent object is in
field_iduint32_tThe sf code of the field you are searching for.

To compute this manually take the serialized type and shift it into the 16 highest bits of uint32_t, then take the field and place it in the 16 lowest bits.

For example:
sfEmitNonce has type 5 and field 11 thus its value is 0x050BU
new_slotuint32_tNew slot number to place the object from the selected field into. If null, choose the next available slot. May be null.

Return Code

TypeDescription
int64_tThe slot number of the newly allocated object

If negative, an error:

DOESNT_EXIST
- The searched for field isn't present in the parent slot or the parent slot is unfilled.

NO_FREE_SLOTS
- The API would require a new slot to be allocated but the Hook is already at the maximum number of slots.

INVALID_FIELD
- The specified field is not a valid sf field.

NOT_AN_OBJECT
- The slotted object is not a valid STObject.