A little more formatting.
This commit is contained in:
@@ -78,8 +78,8 @@ extern "C" {
|
||||
// === SIMPLE TYPES ===
|
||||
//
|
||||
|
||||
// 3 byte ID, upper byte is determined at run time and is used to reference
|
||||
// across esp/esm files
|
||||
// 3 byte ID, upper byte is determined at run time and is used to
|
||||
// reference across esp/esm files
|
||||
typedef uint32_t formid;
|
||||
|
||||
// char[4] with uint32_t access, used to access fourcc values
|
||||
@@ -190,17 +190,24 @@ extern "C" {
|
||||
|
||||
/* Given to espr_walk.
|
||||
*
|
||||
* pre is called before the children of the current node have been walked
|
||||
* post is called after the children of the current node have been walked
|
||||
* pre is called before the children of the current node have been
|
||||
* walked post is called after the children of the current node have
|
||||
* been walked
|
||||
*
|
||||
* carry_out and carry_in is a pointer to a void * on the stack that can be
|
||||
* used for passing data between pre and post for a node.
|
||||
* carry_out and carry_in is a pointer to a void * on the stack that can
|
||||
* be used for passing data between pre and post for a node.
|
||||
*
|
||||
* data is a pointer that the user can supply when calling espr_walk that
|
||||
* will be passed to pre and post when they are called.
|
||||
* data is a pointer that the user can supply when calling espr_walk
|
||||
* that will be passed to pre and post when they are called.
|
||||
*/
|
||||
struct walker_callbacks {
|
||||
void (*pre)(Node n, void *data, void **carry_out, void *from_parent, void **to_children);
|
||||
void (*pre)(
|
||||
Node n,
|
||||
void *data,
|
||||
void **carry_out,
|
||||
void *from_parent,
|
||||
void **to_children
|
||||
);
|
||||
void (*post)(Node n, void *data, void *carry_in);
|
||||
void *data;
|
||||
};
|
||||
@@ -208,25 +215,27 @@ extern "C" {
|
||||
/* Meta Nodes are used for constructing a more flexible tree structure
|
||||
* on top of the natural structure of ESP/ESM files.
|
||||
*
|
||||
* Meta Nodes do not create a pure tree structure, rather they have pointers to
|
||||
* their parent and first child, and children have pointers backwards and
|
||||
* forward through a linked list of all of the children of the parent node.
|
||||
* Meta Nodes do not create a pure tree structure, rather they have
|
||||
* pointers to their parent and first child, and children have pointers
|
||||
* backwards and forward through a linked list of all of the children of
|
||||
* the parent node.
|
||||
*
|
||||
* There is no root node as such, rather there is a root linked list for which
|
||||
* all of the Meta Nodes have no parents.
|
||||
* There is no root node as such, rather there is a root linked list for
|
||||
* which all of the Meta Nodes have no parents.
|
||||
*
|
||||
* While the ESP/ESM buffer can be modified in-place, any modification that
|
||||
* changes the size of the stored data cannot be directly written to the buffer
|
||||
* without first shifting all of the data after the point of modification.
|
||||
* While the ESP/ESM buffer can be modified in-place, any modification
|
||||
* that changes the size of the stored data cannot be directly written
|
||||
* to the buffer without first shifting all of the data after the point
|
||||
* of modification.
|
||||
*
|
||||
* Modifications that change data size are:
|
||||
* - Adding or deleting a group or record
|
||||
* - Adding or deleting a field in a record
|
||||
* - Changing a variable length field with data of different length
|
||||
*
|
||||
* With a Meta Node you can instead allocate new, arbitrarily sized memory for
|
||||
* the node data. The Meta Node tree can then be walked to reconstruct a
|
||||
* contiguous view of discontiguous memory.
|
||||
* With a Meta Node you can instead allocate new, arbitrarily sized
|
||||
* memory for the node data. The Meta Node tree can then be walked to
|
||||
* reconstruct a contiguous view of discontiguous memory.
|
||||
*/
|
||||
struct meta_node {
|
||||
Node n;
|
||||
@@ -248,7 +257,7 @@ extern "C" {
|
||||
Type4 grup; // always RT_GRUP
|
||||
uint32_t size; // uncludes the 24 byte group header
|
||||
union {
|
||||
Type4 type; // this may be mangled and should not be relied on
|
||||
Type4 type; // this may be mangled, do not rely on
|
||||
formid formid;
|
||||
int32_t number;
|
||||
int16_t coord[2];
|
||||
@@ -311,11 +320,11 @@ extern "C" {
|
||||
return rth2rt[uint32_t_msh(type, RT_HASH_BITS, RT_HASH_SEED)];
|
||||
}
|
||||
|
||||
/* `espr_walk` walks through the tree structure of the esp/esm binary data
|
||||
* starting at `data` of `size` bytes.
|
||||
/* `espr_walk` walks through the tree structure of the esp/esm binary
|
||||
* data starting at `data` of `size` bytes.
|
||||
*
|
||||
* `cb` is a callback that takes a `Node` to process. `pt` is a pointer to
|
||||
* arbitrary data that is passed on to `cb` whenever it is called.
|
||||
* `cb` is a callback that takes a `Node` to process. `pt` is a pointer
|
||||
* to arbitrary data that is passed on to `cb` whenever it is called.
|
||||
*
|
||||
* Data is walked sequentially. Nodes passed to `cb` will be strictly
|
||||
* increasing in terms of memory location within the buffer.
|
||||
@@ -327,8 +336,9 @@ extern "C" {
|
||||
*/
|
||||
void espr_print(char *data, size_t size);
|
||||
|
||||
/* Calculates the number of groups and records in the esp/esm file and the
|
||||
* size of the esp/esm if all of the compressed records were decompressed.
|
||||
/* Calculates the number of groups and records in the esp/esm file and
|
||||
* the size of the esp/esm if all of the compressed records were
|
||||
* decompressed.
|
||||
*/
|
||||
struct esp_stats espr_stats(char *data, size_t size);
|
||||
|
||||
@@ -342,14 +352,14 @@ extern "C" {
|
||||
return stats.record_count + stats.group_count;
|
||||
}
|
||||
|
||||
// Calculates the size of a MetaNode tree constructed over the esp/esm for
|
||||
// which the stats were generated.
|
||||
// Calculates the size of a MetaNode tree constructed over the esp/esm
|
||||
// for which the stats were generated.
|
||||
inline size_t espr_tree_size(struct esp_stats stats) {
|
||||
return sizeof(MetaNode) * espr_node_count(stats);
|
||||
}
|
||||
|
||||
/* Copies the data from `data` to `buf` decompressing compressed fields as
|
||||
* it does so. buf_size should be the value returned from
|
||||
/* Copies the data from `data` to `buf` decompressing compressed fields
|
||||
* as it does so. buf_size should be the value returned from
|
||||
* `espr_decompressed_size`, and `buf` should be at least of that size.
|
||||
*/
|
||||
void espr_decompress(char *data, size_t size, char *buf, size_t buf_size);
|
||||
|
||||
Reference in New Issue
Block a user