C4 Engine Terathon Software C4 Engine API Documentation

• Resource Manager

API Links
Developer Links

Unpacker::AddNodeLink

Defined in:  C4Packing.h
Adds a node link that will be resolved after unpacking is complete.
Prototype

void AddNodeLink(int32 index, NodeLink::LinkProc *proc, void *cookie);

Parameters
index The index of the node to be linked.
proc A pointer to the callback function.
cookie A user-defined pointer that is passed to the callback function.
Description
The AddNodeLink function registers a callback function that is called after unpacking is complete in order to resolve a node index to the actual pointer to a node. The AddNodeLink function should be called from within an overridden Packable::Unpack function or the callback passed to the Packable::UnpackChunkList function. The index parameter should be set to the node index, which would typically have just been unpacked.

The NodeLink::LinkProc type is defined as follows.

typedef void LinkProc(Node *, void *);

The proc parameter should be set to a pointer to a static function having this prototype, and the cookie parameter should be any pointer that the calling function needs. The value of the cookie parameter is passed to the callback function as its second parameter. The node pointer received in the first parameter of the callback function will be the node whose index was previously specified by the index parameter when the AddNodeLink function was called. Note that the node pointer can be nullptr if the node could not be constructed during the unpacking process.
See Also

Unpacker::AddObjectLink