wavelength 1.0.0
Loading...
Searching...
No Matches
Tools::Ark::DataFile Class Reference

A compiled DataArray file (.txt.bin, .ui.bin), the form DataArray::ReadFile loads. More...

#include <datafile.h>

Collaboration diagram for Tools::Ark::DataFile:

Public Member Functions

std::vector< std::uint8_t > serialize () const
 Write the file in compiled form, encrypted with the seed when there is one.
std::int32_t fileIndex (const std::string &name)
 Find the index of a source file name, adding the name when missing.

Static Public Member Functions

static std::expected< DataFile, Error > parse (std::span< const std::uint8_t > data)
 Parse a compiled file, plain or encrypted.

Public Attributes

std::optional< std::uint32_t > seed
std::vector< std::string > files
DataNode root

Static Public Attributes

static constexpr std::uint8_t kVersion = 2
 The version of the compiled format.

Detailed Description

A compiled DataArray file (.txt.bin, .ui.bin), the form DataArray::ReadFile loads.

The file is a version byte, the table of source file names, and the root array. The European release and the P.O.D. demo encrypt everything after a leading 32-bit seed with the lagged Fibonacci generator of the game's Rand class.

Member Function Documentation

◆ parse()

std::expected< DataFile, Error > Tools::Ark::DataFile::parse ( std::span< const std::uint8_t > data)
static

Parse a compiled file, plain or encrypted.

Parameters
dataThe file.
Returns
The parsed file, or an ErrorCode::InvalidInput error when neither form parses to the end of the data.

◆ serialize()

std::vector< std::uint8_t > Tools::Ark::DataFile::serialize ( ) const
nodiscard

Write the file in compiled form, encrypted with the seed when there is one.

Returns
The file.

◆ fileIndex()

std::int32_t Tools::Ark::DataFile::fileIndex ( const std::string & name)

Find the index of a source file name, adding the name when missing.

Parameters
nameThe source file name.
Returns
The index in files.

Member Data Documentation

◆ kVersion

std::uint8_t Tools::Ark::DataFile::kVersion = 2
staticconstexpr

The version of the compiled format.

◆ seed

std::optional<std::uint32_t> Tools::Ark::DataFile::seed

The encryption seed, when the file is encrypted.

◆ files

std::vector<std::string> Tools::Ark::DataFile::files

The source file names that arrays refer to.

◆ root

DataNode Tools::Ark::DataFile::root

The root array.


The documentation for this class was generated from the following file: