goldforge 0.8.1

Library for handling file formats used by GoldSrc and related engines.
Documentation
// Copyright 2025-2026 Gabriel Bjørnager Jensen.
//
// 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:
// <https://mozilla.org/MPL/2.0/>.

//! DOOM items.
//!
//! Taken from <https://github.com/id-Software/DOOM/>.

use oct::{FromOcts, Immutable, Init, Zeroable};

/// The `wadinfo_t` structure.
///
/// # Synopsis
///
/// ```c
/// // DOOM/linuxdoom-1.10/w_wad.h
///
/// typedef struct
/// {
///     // Should be "IWAD" or "PWAD".
///     char        identification[4];
///     int         numlumps;
///     int         infotableofs;
///
/// } wadinfo_t;
/// ```
#[allow(clippy::missing_docs_in_private_items)]
#[allow(non_camel_case_types)]
#[repr(C, packed)]
#[derive(
	Clone,
	Copy,
	Debug,
	FromOcts,
	Immutable,
	Zeroable,
)]
pub(in crate::wad) struct wadinfo_t {
	pub identification: [i8; 4],
	pub numlumps:       i32,
	pub infotableofs:   i32,
}

impl Default for wadinfo_t {
	/// Equivalent to [`Bytes::zeroed`].
	#[inline(always)]
	fn default() -> Self {
		Self::zeroed()
	}
}

unsafe impl Init for wadinfo_t {}

/// The `filelump_t` structure.
///
/// # Synopsis
///
/// ```c
/// // DOOM/linuxdoom-1.10/w_wad.h
///
/// typedef struct
/// {
///     int         filepos;
///     int         size;
///     char        name[8];
///
/// } filelump_t;
/// ```
#[allow(clippy::missing_docs_in_private_items)]
#[allow(non_camel_case_types)]
#[repr(C, packed)]
#[derive(
	Clone,
	Copy,
	Debug,
	FromOcts,
	Immutable,
	Zeroable,
)]
pub(in crate::wad) struct filelump_t {
	pub filepos: i32,
	pub size:    i32,
	pub name:    [i8; 8],
}

impl Default for filelump_t {
	/// Equivalent to [`Bytes::zeroed`].
	#[inline(always)]
	fn default() -> Self {
		Self::zeroed()
	}
}

unsafe impl Init for filelump_t {}