Jazz2::Formats::WeaponsChunk struct

Chunk with the weapons of a level.

How a level changes the weapons (see WeaponsDescription): options of the weapons of the game, weapons of its own the game fires itself, weapons its script sets up, and the images its weapons use. It's an ancillary chunk, a reader that doesn't know it plays the level with the weapons of the game. It's kept when the level is exported.

The payload is u8 version (Version), i16 argument of the hook of the weapons of the script, varuint number of weapons, and for each u8 WeaponType, varuint size and its properties, then varuint number of images, and for each varuint size and varuint width and height of the sheet, columns and rows of frames and frame count, f32 speed of the animation, i16 hotspot X and Y and the palette indices of the sheet, in the image content of the other images of the game with one channel (see Compatibility::JJ2Anims::WriteImageContent()), then varuint number of sounds, and for each varuint size, varuint length of the file name, the name and the contents of the file. Only a custom weapon has the properties of how it fires, of its shots, of its icons and ammo sprite, and of the weapon of the game it's made from. A property is u8 id, varuint size and its value, one that isn't there is as the weapon of the game has it. A reader skips a property it doesn't know, and the editor keeps it. A version newer than Version changes what properties mean, a reader leaves such a chunk alone.

Public types

enum class ReadResult { Success, Damaged, NewerVersion }
Result of Read().

Public static variables

static std::uint32_t Tag constexpr
Tag of the chunk.
static std::uint8_t Version constexpr
Version this build reads and writes.
static std::uint32_t MaxImages constexpr
Most images a level can have.
static std::int32_t MaxFrameSize constexpr
Largest width and height of a frame of an image.
static std::int32_t MaxFrameCount constexpr
Most frames of an image.
static std::int32_t MaxImageSize constexpr
Largest width and height of the sheet of an image.
static std::uint32_t MaxSounds constexpr
Most sounds a level can have.
static std::uint32_t MaxSoundSize constexpr
Largest file of a sound in bytes.

Public static functions

static auto Read(ArrayView<const std::uint8_t> data, WeaponsDescription& weapons, ArrayView<WeaponEditorData> editorData = {}) -> ReadResult
Reads the payload.
static void Write(const WeaponsDescription& weapons, SmallVectorImpl<std::uint8_t>& data, ArrayView<const WeaponEditorData> editorData = {})
Writes the payload, with editorData if given, nothing if the level doesn't change any weapon.

Constructors, destructors, conversion operators

WeaponsChunk() deleted

Enum documentation

enum class Jazz2::Formats::WeaponsChunk::ReadResult

Result of Read().

Enumerators
Success

Read

Damaged

The payload is damaged, the weapons are left as the game has them

NewerVersion

The payload is of a newer version, the weapons are left as the game has them

Function documentation

static ReadResult Jazz2::Formats::WeaponsChunk::Read(ArrayView<const std::uint8_t> data, WeaponsDescription& weapons, ArrayView<WeaponEditorData> editorData = {})

Reads the payload.

What only the editor needs is read into editorData, one for each WeaponType, if it's given, the game skips it.