Documentation ¶
Index ¶
- Variables
- func Decompress(compressed io.Reader, uncompressedSize int, compressionFlags byte, ...) io.ReadSeeker
- func LimitReadSeeker(r io.ReadSeeker, n int64) io.ReadSeeker
- func MakeCompressionFlags(method CompressionMethod, level CompressionLevel) int
- func NewFilter(f map[string][]string, l log.Logger) log.Logger
- func ReadCString(r io.Reader, length int) (string, error)
- func ReadNames(r io.ReadSeeker) ([][]string, error)
- type AttributeEntry
- type AttributeInfo
- type CompressionLevel
- type CompressionMethod
- type DataType
- type FileVersion
- type HeaderError
- type IdentifierDictionary
- type Ivec
- type LSBHeader
- type LSFHeader
- type LSMetadata
- type LimitedReadSeeker
- type Mat
- type Node
- type NodeAttribute
- func ReadAttribute(r io.ReadSeeker, name string, DT DataType, length uint, l log.Logger) (NodeAttribute, error)
- func ReadLSBAttr(r io.ReadSeeker, name string, dt DataType, endianness binary.ByteOrder, ...) (NodeAttribute, error)
- func ReadLSFAttribute(r io.ReadSeeker, name string, dt DataType, length uint, version FileVersion, ...) (NodeAttribute, error)
- func (na *NodeAttribute) FromString(str string) error
- func (na NodeAttribute) GetColumns() (int, error)
- func (na NodeAttribute) GetRows() (int, error)
- func (na NodeAttribute) IsNumeric() bool
- func (na NodeAttribute) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (na NodeAttribute) String() string
- type NodeEntry
- type NodeInfo
- type Resource
- type TranslatedFSString
- type TranslatedFSStringArgument
- type TranslatedString
- type Vec
- type XMLMarshaler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrVectorTooBig = errors.New("the vector is too big cannot marshal to an xml element") ErrInvalidNameKey = errors.New("invalid name key") ErrKeyDoesNotMatch = errors.New("key for this node does not match") )
View Source
var ( LSFSignature = [4]byte{0x4C, 0x53, 0x4F, 0x46} Logger log.Logger = log.NewNopLogger() )
Functions ¶
func Decompress ¶
func LimitReadSeeker ¶
func LimitReadSeeker(r io.ReadSeeker, n int64) io.ReadSeeker
LimitReadSeeker returns a Reader that reads from r but stops with EOF after n bytes. The underlying implementation is a *LimitedReader.
func MakeCompressionFlags ¶
func MakeCompressionFlags(method CompressionMethod, level CompressionLevel) int
Types ¶
type AttributeEntry ¶
type AttributeEntry struct { Long bool // (16-bit MSB: index into name hash table, 16-bit LSB: offset in hash chain) NameHashTableIndex uint32 // 26-bit MSB: Length of this attribute TypeAndLength uint32 // Note: These indexes are assigned seemingly arbitrarily, and are not necessarily indices into the node list NodeIndex int32 // Note: These indexes are assigned seemingly arbitrarily, and are not necessarily indices into the node list NextAttributeIndex int32 // Absolute position of attribute value in the value stream Offset uint32 }
attribute extension in the LSF file
func (AttributeEntry) NameIndex ¶
func (ae AttributeEntry) NameIndex() int
Index into name hash table
func (*AttributeEntry) Read ¶
func (ae *AttributeEntry) Read(r io.ReadSeeker) error
func (AttributeEntry) TypeID ¶
func (ae AttributeEntry) TypeID() DataType
Type of this attribute (see NodeAttribute.DataType)
type AttributeInfo ¶
type AttributeInfo struct { V2 bool // Index into name hash table NameIndex int // Offset in hash chain NameOffset int // Type of this attribute (see NodeAttribute.DataType) TypeID DataType // Length of this attribute Length uint // Absolute position of attribute data in the values section DataOffset uint // (-1: this is the last attribute) NextAttributeIndex int }
type CompressionLevel ¶
type CompressionLevel int
const ( FastCompression CompressionLevel = 0x10 DefaultCompression CompressionLevel = 0x20 MaxCompression CompressionLevel = 0x40 )
func CompressionFlagsToLevel ¶
func CompressionFlagsToLevel(flags byte) CompressionLevel
type CompressionMethod ¶
type CompressionMethod int
const ( CMInvalid CompressionMethod = iota - 1 CMNone CMZlib CMLZ4 )
func CompressionFlagsToMethod ¶
func CompressionFlagsToMethod(flags byte) CompressionMethod
type DataType ¶
type DataType int
const ( DTNone DataType = iota DTByte DTShort DTUShort DTInt DTUInt DTFloat DTDouble DTIVec2 DTIVec3 DTIVec4 DTVec2 DTVec3 DTVec4 DTMat2 DTMat3 DTMat3x4 DTMat4x3 DTMat4 DTBool DTString DTPath DTFixedString DTLSString DTULongLong DTScratchBuffer // Seems to be unused? DTLong DTInt8 DTTranslatedString DTWString DTLSWString DTUUID DTInt64 DTTranslatedFSString // Last supported datatype, always keep this one at the end DTMax = iota - 1 )
func (DataType) GetColumns ¶
func (*DataType) MarshalXMLAttr ¶
type FileVersion ¶
type FileVersion uint32
const ( // Initial version of the LSF format VerInitial FileVersion = iota + 1 // LSF version that added chunked compression for substreams VerChunkedCompress // LSF version that extended the node descriptors VerExtendedNodes // BG3 version, no changes found so far apart from version numbering VerBG3 // Latest version supported by this library MaxVersion = iota )
type HeaderError ¶
func (HeaderError) Error ¶
func (he HeaderError) Error() string
type IdentifierDictionary ¶
func ReadLSBDictionary ¶
func ReadLSBDictionary(r io.ReadSeeker, endianness binary.ByteOrder) (IdentifierDictionary, error)
type LSBHeader ¶
type LSBHeader struct { Signature [4]byte Size uint32 Endianness uint32 Unknown uint32 Version LSMetadata }
type LSFHeader ¶
type LSFHeader struct { // LSOF file signature Signature [4]byte // Version of the LSOF file D:OS EE is version 1/2, D:OS 2 is version 3 Version FileVersion // Possibly version number? (major, minor, rev, build) EngineVersion uint32 // Total uncompressed size of the string hash table StringsUncompressedSize uint32 // Compressed size of the string hash table StringsSizeOnDisk uint32 // Total uncompressed size of the node list NodesUncompressedSize uint32 // Compressed size of the node list NodesSizeOnDisk uint32 // Total uncompressed size of the attribute list AttributesUncompressedSize uint32 // Compressed size of the attribute list AttributesSizeOnDisk uint32 // Total uncompressed size of the raw value buffer ValuesUncompressedSize uint32 // Compressed size of the raw value buffer ValuesSizeOnDisk uint32 // Uses the same format as packages (see BinUtils.MakeCompressionFlags) CompressionFlags byte // Possibly unused, always 0 Unknown2 byte Unknown3 uint16 // Extended node/attribute format indicator, 0 for V2, 0/1 for V3 Extended uint32 }
func (LSFHeader) IsCompressed ¶
type LSMetadata ¶
type LimitedReadSeeker ¶
type LimitedReadSeeker struct { R io.ReadSeeker // underlying reader N int64 // max bytes remaining }
A LimitedReadSeeker reads from R but limits the amount of data returned to just N bytes. Each call to Read updates N to reflect the new amount remaining. Read returns EOF when N <= 0 or when the underlying R returns EOF.
type Mat ¶
func (Mat) MarshalXML ¶
type Node ¶
type Node struct { Name string `xml:"id,attr"` Parent *Node `xml:"-"` Attributes []NodeAttribute `xml:"attribute"` Children []*Node `xml:"children>node,omitempty"` RegionName string `xml:"-"` }
func ReadNode ¶
func ReadNode(r io.ReadSeeker, ni NodeInfo, names [][]string, attributeInfo []AttributeInfo, version FileVersion, engineVersion uint32) (Node, error)
func ReadRegions ¶
func ReadRegions(r io.ReadSeeker, names [][]string, nodeInfo []NodeInfo, attributeInfo []AttributeInfo, version FileVersion, engineVersion uint32) ([]*Node, error)
func (*Node) AppendChild ¶
func (Node) ChildCount ¶
func (Node) MarshalXML ¶
type NodeAttribute ¶
type NodeAttribute struct { Name string `xml:"id,attr"` Type DataType `xml:"type,attr"` Value interface{} `xml:"value,attr"` }
func ReadAttribute ¶
func ReadAttribute(r io.ReadSeeker, name string, DT DataType, length uint, l log.Logger) (NodeAttribute, error)
func ReadLSBAttr ¶
func ReadLSBAttr(r io.ReadSeeker, name string, dt DataType, endianness binary.ByteOrder, version FileVersion) (NodeAttribute, error)
func ReadLSFAttribute ¶
func ReadLSFAttribute(r io.ReadSeeker, name string, dt DataType, length uint, version FileVersion, engineVersion uint32) (NodeAttribute, error)
func (*NodeAttribute) FromString ¶
func (na *NodeAttribute) FromString(str string) error
func (NodeAttribute) GetColumns ¶
func (na NodeAttribute) GetColumns() (int, error)
func (NodeAttribute) GetRows ¶
func (na NodeAttribute) GetRows() (int, error)
func (NodeAttribute) IsNumeric ¶
func (na NodeAttribute) IsNumeric() bool
func (NodeAttribute) MarshalXML ¶
func (na NodeAttribute) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (NodeAttribute) String ¶
func (na NodeAttribute) String() string
type NodeEntry ¶
type NodeEntry struct { Long bool // (16-bit MSB: index into name hash table, 16-bit LSB: offset in hash chain) NameHashTableIndex uint32 // (-1: node has no attributes) FirstAttributeIndex int32 // (-1: this node is a root region) ParentIndex int32 // (-1: this is the last node) NextSiblingIndex int32 }
func (NodeEntry) NameOffset ¶
type NodeInfo ¶
type NodeInfo struct { // (-1: this node is a root region) ParentIndex int // Index into name hash table NameIndex int // Offset in hash chain NameOffset int // (-1: node has no attributes) FirstAttributeIndex int }
Processed node information for a node in the LSF file
type Resource ¶
type Resource struct { Metadata LSMetadata `xml:"version"` Regions []*Node `xml:"region"` }
func ReadLSBRegions ¶
func ReadLSBRegions(r io.ReadSeeker, d IdentifierDictionary, endianness binary.ByteOrder, version FileVersion) (Resource, error)
type TranslatedFSString ¶
type TranslatedFSString struct { TranslatedString Arguments []TranslatedFSStringArgument }
func ReadTranslatedFSString ¶
func ReadTranslatedFSString(r io.ReadSeeker, version FileVersion) (TranslatedFSString, error)
type TranslatedFSStringArgument ¶
type TranslatedFSStringArgument struct { String TranslatedFSString Key string Value string }
type TranslatedString ¶
func ReadTranslatedString ¶
func ReadTranslatedString(r io.ReadSeeker, version FileVersion, engineVersion uint32) (TranslatedString, error)
func (TranslatedString) MarshalXML ¶
func (ts TranslatedString) MarshalXML(e *xml.Encoder, start *xml.StartElement) error
type XMLMarshaler ¶
type XMLMarshaler interface {
MarshalXML(e *xml.Encoder, start *xml.StartElement) error
}
XMLMarshaler has a pointer to start in order to append multiple attributes to the xml element
Source Files ¶
Click to show internal directories.
Click to hide internal directories.