Files
Navmesher_old/espReader/ESPTree.h

43 lines
1.5 KiB
C

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0.If a copy of the MPL was not distributed with this
* file, You can obtain one at http ://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "ESPReader.h"
typedef struct meta_node MetaNode;
/* 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.
*
* 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.
*
* 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.
*/
struct meta_node {
Node n;
MetaNode *parent;
MetaNode *child;
MetaNode *prev;
MetaNode *next;
};