JJ2Block class
#include <Jazz2/Compatibility/JJ2Block.h>
Processes compressed or uncompressed blocks from original files (in little endian).
Buffers a single (optionally zlib-compressed) data block from an original game file and exposes sequential little-endian readers for the primitive types used by the format parsers. Used as the low-level building block by JJ2Level, JJ2Tileset and related importers.
Constructors, destructors, conversion operators
-
JJ2Block(std::
unique_ptr<Stream>& s, std:: int32_t length, std:: int32_t uncompressedLength = 0) - Creates a new instance from the specified stream, decompressing the block if needed.
Public functions
-
void SeekTo(std::
int32_t offset) - Seeks to the specified offset within the block.
-
void DiscardBytes(std::
int32_t length) - Skips the specified number of bytes.
- auto ReadBool() -> bool
- Reads a boolean value.
-
auto ReadByte() -> std::
uint8_t - Reads an unsigned 8-bit integer.
-
auto ReadInt16() -> std::
int16_t - Reads a signed 16-bit integer.
-
auto ReadUInt16() -> std::
uint16_t - Reads an unsigned 16-bit integer.
-
auto ReadInt32() -> std::
int32_t - Reads a signed 32-bit integer.
-
auto ReadUInt32() -> std::
uint32_t - Reads an unsigned 32-bit integer.
-
auto ReadUint7bitEncoded() -> std::
int32_t - Reads a 7-bit encoded integer.
- auto ReadFloat() -> float
- Reads a 32-bit floating-point value.
- auto ReadFloatEncoded() -> float
- Reads a fixed-point value encoded as an integer and returns it as floating-point.
-
void ReadRawBytes(std::
uint8_t* dst, std:: int32_t length) - Reads the specified number of raw bytes into the destination buffer.
-
auto ReadString(std::
int32_t length, bool trimToNull) -> StringView - Reads a string of the specified length, optionally trimming at the first null character.
- auto ReachedEndOfStream() -> bool
- Returns whether the end of the block has been reached.
-
auto GetLength() -> std::
int32_t - Returns the total length of the block in bytes.