diff --git a/CMakeLists.txt b/CMakeLists.txt index a5d887e8..e28a5cb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,8 +19,6 @@ add_subdirectory(vendor) file(GLOB_RECURSE _ZK_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/**/*.hh") list(APPEND _ZK_SOURCES - src/__legacy_buffer.cc - src/world/BspTree.cc src/world/VobTree.cc src/world/WayNet.cc diff --git a/include/phoenix/Vfs.hh b/include/phoenix/Vfs.hh deleted file mode 100644 index 67c6c02d..00000000 --- a/include/phoenix/Vfs.hh +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Vfs.hh" - -namespace phoenix { - using VfsBrokenDiskError ZKREM("renamed to zenkit::VfsBrokenDiskError") = zenkit::VfsBrokenDiskError; - using VfsFileExistsError ZKREM("renamed to zenkit::VfsFileExistsError") = zenkit::VfsFileExistsError; - using VfsNotFoundError ZKREM("renamed to zenkit::VfsNotFoundError") = zenkit::VfsNotFoundError; - using VfsNodeType ZKREM("renamed to zenkit::VfsNodeType") = zenkit::VfsNodeType; - using VfsFileDescriptor ZKREM("renamed to zenkit::VfsFileDescriptor") = zenkit::VfsFileDescriptor; - using VfsNode ZKREM("renamed to zenkit::VfsNode") = zenkit::VfsNode; - using VfsNodeComparator ZKREM("renamed to zenkit::VfsNodeComparator") = zenkit::VfsNodeComparator; - using VfsNode ZKREM("renamed to zenkit::VfsNode") = zenkit::VfsNode; - using VfsOverwriteBehavior ZKREM("renamed to zenkit::VfsOverwriteBehavior") = zenkit::VfsOverwriteBehavior; - using Vfs ZKREM("renamed to zenkit::Vfs") = zenkit::Vfs; -} // namespace phoenix diff --git a/include/phoenix/animation.hh b/include/phoenix/animation.hh deleted file mode 100644 index 6cf40507..00000000 --- a/include/phoenix/animation.hh +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/ModelAnimation.hh" - -namespace phoenix { - using animation ZKREM("renamed to zenkit::Animation") = zenkit::ModelAnimation; - using animation_sample ZKREM("renamed to zenkit::AnimationSample") = zenkit::AnimationSample; - using animation_event ZKREM("renamed to zenkit::AnimationEvent") = zenkit::AnimationEvent; - using animation_event_type ZKREM("renamed to zenkit::AnimationEventType") = zenkit::AnimationEventType; -} // namespace phoenix diff --git a/include/phoenix/archive.hh b/include/phoenix/archive.hh deleted file mode 100644 index f921ed0a..00000000 --- a/include/phoenix/archive.hh +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Archive.hh" - -namespace phoenix { - using archive_format ZKREM("renamed to zenkit::ArchiveFormat") = zenkit::ArchiveFormat; - using archive_header ZKREM("renamed to zenkit::ArchiveHeader") = zenkit::ArchiveHeader; - using archive_object ZKREM("renamed to zenkit::ArchiveObject") = zenkit::ArchiveObject; - using archive_reader ZKREM("renamed to zenkit::ArchiveReader") = zenkit::ReadArchive; -} // namespace phoenix diff --git a/include/phoenix/buffer.hh b/include/phoenix/buffer.hh deleted file mode 100644 index 1cbba12f..00000000 --- a/include/phoenix/buffer.hh +++ /dev/null @@ -1,574 +0,0 @@ -// Copyright © 2022-2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Library.hh" -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace phoenix { - /// \brief Base class for exceptions thrown by a phoenix::buffer. - class buffer_error : public zenkit::Error { - public: - using zenkit::Error::Error; - }; - - /// \brief Exception thrown when reading too many bytes from a buffer. - /// - /// This exception is thrown if the number of bytes read from a buffer - /// is more than the number of bytes remaining. - class buffer_underflow : public buffer_error { - public: - ZKAPI buffer_underflow(std::uint64_t byte, std::uint64_t size); - ZKAPI buffer_underflow(std::uint64_t byte, std::uint64_t size, std::string&& context); - ZKAPI buffer_underflow(std::uint64_t byte, std::string&& context); - - public: - std::uint64_t const byte, size; - std::optional const context; - }; - - /// \brief Exception thrown when writing too many bytes to a buffer. - /// - /// This exception is thrown if the number of bytes written to a buffer - /// is more than the number of bytes remaining. - class buffer_overflow : public buffer_error { - public: - ZKAPI buffer_overflow(std::uint64_t byte, std::uint64_t size); - ZKAPI buffer_overflow(std::uint64_t byte, std::uint64_t size, std::string&& context); - - public: - std::uint64_t const byte, size; - std::optional const context; - }; - - /// \brief Exception thrown if a write is attempted on a readonly buffer. - class buffer_readonly : public buffer_error { - public: - ZKAPI explicit buffer_readonly() : buffer_error("buffer is not readonly") {} - }; - - /// \brief Base class for all buffer backings. - /// - /// A buffer backing contains the data behind a buffer. It can be shared by multiple buffers possibly with - /// each referencing a subsection of the backing. For this reason, buffer backings should be stateless. - class buffer_backing { - public: - ZKAPI virtual ~buffer_backing() = default; - - /// \brief Returns whether this backing considered direct or not. - /// - /// A backing is considered direct if reading from or writing to it has a side effect like causing I/O on - /// a file. An example of a direct backing would be a backing which reads from or writes to a memory-mapped - /// file. - /// - /// \return `true` if this backing is direct and `false` if not. - [[nodiscard]] ZKAPI virtual bool direct() const noexcept = 0; - - /// \brief Returns whether or not this backing is readonly or not. - /// - /// A readonly backing is a backing which can not be written to. - /// - /// \return `true` if this backing is read-only and `false` if not. - [[nodiscard]] ZKAPI virtual bool readonly() const noexcept = 0; - - /// \brief Returns the number of bytes available in this backing. - /// \return The number of bytes available in this backing. - [[nodiscard]] ZKAPI virtual std::uint64_t size() const noexcept = 0; - - /// \brief Retrieves a read-only raw byte array of this backing. - /// \return A read-only raw byte array into this backing. - [[nodiscard]] ZKAPI virtual std::byte const* array() const = 0; - - /// \brief Fills the given \p buf with bytes from this backing starting at \p offset. - /// - /// This function is idempotent; calling it never alters any internal state. - /// - /// \param buf A buffer to read into. - /// \param size The number of bytes to read. - /// \param offset The offset at which to start reading bytes into \p buf. - /// \throws buffer_underflow if filling \p buf with bytes starting at \p offset fails. - ZKAPI virtual void read(std::byte* buf, std::uint64_t size, std::uint64_t offset) const = 0; - - /// \brief Writes all bytes from \p buf into this backing beginning at \p offset. - /// - /// This function is idempotent; calling it never alters any internal state. - /// - /// \param buf The data to write. - /// \param size The number of bytes to write. - /// \param offset The offset at which to start writing. - /// \throws buffer_overflow if writing all bytes of \p buf starting at \p offset fails. - /// \throws buffer_readonly if this backing is readonly. - ZKAPI virtual void write([[maybe_unused]] std::byte const* buf, - [[maybe_unused]] std::uint64_t size, - [[maybe_unused]] std::uint64_t offset) { - throw buffer_readonly {}; - } - }; - - /// \brief A buffer implementation inspired by Java's ByteBuffer - class buffer { - private: - ZKREM("Deprecated. Use zenkit::Read instead.") - ZKINT buffer(std::shared_ptr backing, std::uint64_t begin, std::uint64_t end); - ZKREM("Deprecated. Use zenkit::Read instead.") - ZKINT buffer(std::shared_ptr backing, - std::uint64_t begin, - std::uint64_t end, - std::uint64_t capacity, - std::uint64_t position, - std::optional mark); - - /// \brief Reads a scalar of type \p T at the current #position. - /// - /// After reading the value, the #position is increased by ``sizeof(T)``. - /// - /// \tparam T The type of scalar to read. Must be a std::integral or a std::floating_point type. - /// \return The value read. - /// \throws buffer_underflow if there are not enough bytes #remaining to read the value. - /// \see buffer_backing::read - template < - typename T, - typename = typename std::enable_if::value || std::is_floating_point::value>::type> - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKINT T _get_t(); - - /// \brief Reads a scalar of type \p T at the given \p pos. - /// \tparam T The type of scalar to read. Must be a std::integral or a std::floating_point type. - /// \return The value read. - /// \throws buffer_underflow if there are not enough bytes in the backing to read the value. - /// \see buffer_backing::read - template < - typename T, - typename = typename std::enable_if::value || std::is_floating_point::value>::type> - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKINT T _get_t(std::uint64_t pos) const; - - /// \brief Writes a scalar of type \p T at the current #position. - /// - /// After writing the value, the #position is increased by ``sizeof(T)``. - /// - /// \tparam T The type of scalar to write. Must be a std::integral or a std::floating_point type. - /// \throws buffer_overflow if there are not enough bytes #remaining to write the value. - /// \see buffer_backing::write - template < - typename T, - typename = typename std::enable_if::value || std::is_floating_point::value>::type> - ZKREM("Deprecated. Use zenkit::Read instead.") - ZKINT void _put_t(T value); - - public: - /// \brief Constructs a new buffer from the given backing. - /// - /// The new buffer will encompass all bytes available in the backing. - /// To shrink the buffer, see #slice or #extract. - /// - /// \param backing The buffer backing to use. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI explicit buffer(std::shared_ptr backing); - - /// \brief Gets the current position of this buffer. - /// \return The current position of this buffer. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint64_t position() const noexcept; - - /// \brief Sets this buffer's position. - /// \param pos The new position value. - /// \throws buffer_underflow if \p pos is greater than #limit. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void position(std::uint64_t pos); - - /// \brief Returns the number of bytes available in this buffer. - /// \return The limit of this buffer. - [[nodiscard]] ZKAPI std::uint64_t limit() const noexcept; - - /// \brief Sets this buffer's limit. - /// - /// If the position is larger than the new limit then it is set to the new limit. - /// - /// \param limit The new limit to set. - /// \throws buffer_underflow if \p limit is greater than #capacity. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void limit(std::uint64_t limit); - - /// \brief Rewinds this buffer by setting the position to 0. - /// - /// This operation discards the #mark if it is set. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void rewind(); - - /// \brief Skips \p count bytes in this buffer. - /// \param count The number of bytes to skip. - /// \throws buffer_underflow if #position + \p count > #limit - /// \see #position - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void skip(std::uint64_t count); - - /// \brief Returns the number of bytes remaining in this buffer. - /// - /// The number of remaining bytes is equal to #limit - #position. - /// - /// \return The number of bytes remaining in this buffer. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint64_t remaining() const noexcept; - - /// \brief Returns the capacity of this buffer. - /// - /// The capacity is the number of bytes allocated to the buffer when it is constructed, not - /// the total number of bytes available in the backing. - /// - /// \return The capacity of this buffer. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint64_t capacity() const noexcept; - - /// \brief Returns whether this buffer is considered to be direct or not. - /// \return `true` if the backing of this buffer is considered to be direct. - /// \see buffer_backing::direct - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI bool direct() const noexcept; - - /// \brief Returns whether this buffer is read-only or not. - /// \return `true` if this buffer is read-only. - /// \see buffer_backing::readonly - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI bool readonly() const noexcept; - - /// \brief Clears this buffer by resetting #position and #limit. - /// - /// #limit is set to #capacity and #position is set to 0. The mark is discarded if - /// it is set. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void clear() noexcept; - - /// \brief Flips this buffer. - /// - /// Its limit is set to the current position and its current position is set to 0. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void flip() noexcept; - - /// \brief Sets this buffer's mark at its position. - /// \return This buffer. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void mark() noexcept; - - /// \brief Resets this buffer's position to the previously-marked position. - /// \return This buffer. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void reset(); - - /// \brief Creates a new buffer which shares its content with this buffer. - /// - /// The new buffers position, capacity and limit will be the same as this buffer's current position, - /// capacity and limit. - /// - /// \return The newly created buffer. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI buffer duplicate() const noexcept; - - /// \brief Creates a new buffer which shares a subsequence of this buffer. - /// - /// The shared subsequence starts at the current position and ends at this buffer's limit. - /// - /// \return The newly created buffer. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI buffer slice() const noexcept; - - /// \brief Creates a new buffer which shares a subsequence of this buffer. - /// - /// The shared subsequence starts at the given index in this buffer and contains the following size bytes. - /// - /// \param index The index in this buffer at which to start the new buffer. - /// \param size The number of bytes the new buffer will encompass. - /// \return The newly created buffer. - /// \throws buffer_underflow if \p index + \p size > #limit. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI buffer - slice(std::uint64_t index, std::uint64_t size) const; - - /// \brief Creates a new buffer which shares a subsequence of this buffer. - /// - /// Slices off a buffer like `slice(position(), size)` and advances the - /// position of the original buffer by `size` bytes (like `skip(size)`). - /// - /// \param size The number of bytes to extract. - /// \return The newly created buffer. - /// \throws buffer_underflow if #position + \p size > #limit. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI buffer extract(std::uint64_t size); - - /// \return A read-only view into the raw contents of this buffer. - [[nodiscard]] ZKAPI std::byte const* array() const noexcept; - - /// \brief Get bytes from the buffer, put them into buf and advance the position accordingly. - /// \param buf The buffer to write into. - /// \param size The number of bytes to get. - /// \throws buffer_underflow if the size of \p buf > #remaining. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void get(std::byte* buf, std::uint64_t size); - - /// \brief Get bytes from the buffer, put them into buf and advance the position accordingly. - /// \param buf The buffer to write into. - /// \param size The number of bytes to get. - /// \throws buffer_underflow if the size of \p buf > #remaining. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void get(std::uint8_t* buf, std::uint64_t size); - - /// \brief Get a value of type std::uint8_t from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint8_t get(); - - /// \brief Get a value of type ``char`` from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI char get_char(); - - /// \brief Get a value of type std::int16_t from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::int16_t get_short(); - - /// \brief Get a value of type std::uint16_t from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint16_t get_ushort(); - - /// \brief Get a value of type std::int32_t from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::int32_t get_int(); - - /// \brief Get a value of type std::uint32_t from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint32_t get_uint(); - - /// \brief Get a value of type std::int64_t from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::int64_t get_long(); - - /// \brief Get a value of type std::uint64_t from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint64_t get_ulong(); - - /// \brief Get a value of type float from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI float get_float(); - - /// \brief Get a value of type double from the buffer and advance the position accordingly. - /// \return The value just read. - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI double get_double(); - - /// \brief Get a string of the given size from the buffer and advance the position accordingly - /// \param size The number of characters to read. - /// \return The string just read. - /// \throws buffer_underflow if the string can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::string get_string(std::uint64_t size); - - /// \brief Get a line from the buffer and advance the position accordingly. - /// \param skip_whitespace Set to `true` to skip whitespace characters immediately following the line. - /// \return The line just read. - /// \throws buffer_underflow if the string can't be read. - /// \see isspace - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::string - get_line(bool skip_whitespace = true); - - /// \brief Get a line from the buffer and advance the position accordingly. - /// \param skip_whitespace Set to `true` to skip whitespace characters immediately following the line. - /// \return The line just read. - /// \throws buffer_underflow if the string can't be read. - /// \see isspace - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::string - get_line_and_ignore(std::string_view whitespace); - - /// \brief Get a line from the buffer, unescape all relevant escape sequences, and - /// advance the position accordingly. - /// \param skip_whitespace Set to `true` to skip whitespace characters immediately following the line. - /// \return The line just read. - /// \throws buffer_underflow if the string can't be read. - /// \see isspace - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::string - get_line_escaped(bool skip_whitespace = true); - - /// \brief Get a 2D-vector from the buffer. - /// \return The vector just read - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::vec2 get_vec2(); - - /// \brief Get a 3D-vector from the buffer. - /// \return The vector just read - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::vec3 get_vec3(); - - /// \brief Get a 3x3 column-major matrix from the buffer. - /// \return The vector just read - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::mat3x3 get_mat3x3(); - - /// \brief Get a 4x4 column-major matrix from the buffer. - /// \return The vector just read - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::mat4x4 get_mat4x4(); - - /// \brief Get a 4D-vector from the buffer. - /// \return The vector just read - /// \throws buffer_underflow if the value can't be read. - [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::vec4 get_vec4(); - - /// \brief Put bytes from buf into the buffer and advance the position accordingly. - /// \param buf The data to write. - /// \param size The number of bytes to write. - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put(std::byte const* buf, std::uint64_t size); - - /// \brief Put bytes from buf into the buffer and advance the position accordingly. - /// \param buf The data to write. - /// \param size The number of bytes to write. - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put(std::uint8_t const* buf, std::uint64_t size); - - /// \brief Put a value of type std::uint8_t into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put(std::uint8_t value); - - /// \brief Put a value of type char into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_char(char value); - - /// \brief Put a value of type std::int16_t into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_short(std::int16_t value); - - /// \brief Put a value of type std::uint16_t into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_ushort(std::uint16_t value); - - /// \brief Put a value of type std::int32_t into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_int(std::int32_t value); - - /// \brief Put a value of type std::uint32_t into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_uint(std::uint32_t value); - - /// \brief Put a value of type std::int64_t into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_long(std::int64_t value); - - /// \brief Put a value of type std::uint64_t into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_ulong(std::uint64_t value); - - /// \brief Put a value of type float into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_float(float value); - - /// \brief Put a value of type double into the buffer and advance the position accordingly - /// \param value The value to put into the buffer - /// \return This buffer. - /// \throws buffer_overflow if the value can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_double(double value); - - /// \brief Put string into the buffer and advance the position accordingly - /// \param str The string to put into the buffer. - /// \return This buffer. - /// \throws buffer_overflow if the string can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_string(std::string_view str); - - /// \brief Put string followed by into the buffer and advance the position accordingly - /// \param str The string to put into the buffer. - /// \return This buffer. - /// \throws buffer_overflow if the string can't be written. - /// \throws buffer_readonly if the buffer is read-only. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_line(std::string_view str); - - /// \brief Allocates a new buffer with the given size. - /// - /// The allocated buffer will be backed by a vector and thus it will reside on the heap. This backing - /// vector can be accessed through #array at any time. - /// - /// \param size The number of bytes to allocate. - /// \return The newly allocated buffer. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI static buffer allocate(std::uint64_t size); - - /// \brief Creates a new buffer from the given vector. - /// - /// The allocated buffer will be backed by the given vector and thus it will reside on the heap. - /// The backing vector can be accessed through #array at any time. - /// - /// \param buf A vector containing the data to be wrapped into a buffer. - /// \param readonly Set to `false` to be able to write to the buffer. - /// \return The newly created buffer. - ZKREM("Deprecated. Use zenkit::Read instead.") - ZKAPI static buffer of(std::vector&& buf, bool readonly = true); - - /// \brief Opens the given file as a direct buffer. - /// - /// The file is memory-mapped. - /// - /// \param path The path of the file to mmap. - /// \param readonly Set to `false` to be able to write to the buffer. - /// \return The newly created buffer. - ZKREM("Deprecated. Use zenkit::Read instead.") - ZKAPI static buffer mmap(std::filesystem::path const& path, bool readonly = true); - - /// \brief Opens the given file as an indirect buffer. - /// - /// The whole file is read into memory. - /// - /// \param path The path of the file to read. - /// \param readonly Set to `false` to be able to write to the buffer. - /// \note Creating a buffer using this method is generally discouraged. It might cause a small performance - /// gain for small files but it is generally slower and uses more memory. You should probably use #mmap - /// instead. - /// \return The newly created buffer. - ZKREM("Deprecated. Use zenkit::Read instead.") - ZKAPI static buffer read(std::filesystem::path const& path, bool readonly = true); - - /// \brief Returns a duplicate of the empty buffer. - /// \return The empty buffer. - ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI static buffer empty(); - - private: - static std::unique_ptr _m_empty; - ZKAPI friend bool operator==(buffer const&, buffer const&); - - std::shared_ptr _m_backing; - std::uint64_t _m_backing_begin, _m_backing_end; - std::uint64_t _m_capacity; - std::uint64_t _m_position; - - std::optional _m_mark; - }; - - ZKREM("Deprecated") ZKAPI bool operator==(buffer const&, buffer const&); -} // namespace phoenix diff --git a/include/phoenix/ext/daedalus_classes.hh b/include/phoenix/ext/daedalus_classes.hh deleted file mode 100644 index 0562b016..00000000 --- a/include/phoenix/ext/daedalus_classes.hh +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/addon/daedalus.hh" - -#include "phoenix/script.hh" - -namespace phoenix { - using c_gil_values ZKREM("renamed to zenkit::IGuildValues") = zenkit::IGuildValues; - using c_npc ZKREM("renamed to zenkit::INpc") = zenkit::INpc; - using c_item ZKREM("renamed to zenkit::IItem") = zenkit::IItem; - using c_item_react ZKREM("renamed to zenkit::IItemReact") = zenkit::IItemReact; - using c_mission ZKREM("renamed to zenkit::IMission") = zenkit::IMission; - using c_focus ZKREM("renamed to zenkit::IFocus") = zenkit::IFocus; - using c_info ZKREM("renamed to zenkit::IInfo") = zenkit::IInfo; - using c_info_choice ZKREM("renamed to zenkit::IInfoChoice") = zenkit::IInfoChoice; - using c_spell ZKREM("renamed to zenkit::ISpell") = zenkit::ISpell; - using c_svm ZKREM("renamed to zenkit::ISvm") = zenkit::ISvm; - using c_menu ZKREM("renamed to zenkit::IMenu") = zenkit::IMenu; - using c_menu_item ZKREM("renamed to zenkit::IMenuItem") = zenkit::IMenuItem; - using c_camera ZKREM("renamed to zenkit::ICamera") = zenkit::ICamera; - using c_music_system ZKREM("renamed to zenkit::IMusicSystem") = zenkit::IMusicSystem; - using c_music_theme ZKREM("renamed to zenkit::IMusicTheme") = zenkit::IMusicTheme; - using c_music_jingle ZKREM("renamed to zenkit::IMusicJingle") = zenkit::IMusicJingle; - using c_particle_fx ZKREM("renamed to zenkit::IParticleEffect") = zenkit::IParticleEffect; - using c_particle_fx_emit_key ZKREM("renamed to zenkit::IParticleEffectEmitKey") = zenkit::IParticleEffectEmitKey; - using c_fx_base ZKREM("renamed to zenkit::IEffectBase") = zenkit::IEffectBase; - using c_fight_ai ZKREM("renamed to zenkit::IFightAi") = zenkit::IFightAi; - using c_sfx ZKREM("renamed to zenkit::ISoundEffect") = zenkit::ISoundEffect; - using c_sound_system ZKREM("renamed to zenkit::ISoundSystem") = zenkit::ISoundSystem; - - namespace damage_type = zenkit::DamageType; - namespace npc_attribute = zenkit::NpcAttribute; - - using npc_type ZKREM("renamed to zenkit::NpcType") = zenkit::NpcType; - using npc_flag ZKREM("renamed to zenkit::NpcFlag") = zenkit::NpcFlag; - using item_flags ZKREM("renamed to zenkit::ItemFlag") = zenkit::ItemFlag; - using c_menu_flags ZKREM("renamed to zenkit::MenuFlag") = zenkit::MenuFlag; - using c_menu_item_flags ZKREM("renamed to zenkit::MenuItemFlag") = zenkit::MenuItemFlag; - using c_menu_item_type ZKREM("renamed to zenkit::MenuItemType") = zenkit::MenuItemType; - using c_menu_item_select_event ZKREM("renamed to zenkit::MenuItemSelectEvent") = zenkit::MenuItemSelectEvent; - using c_menu_item_select_action ZKREM("renamed to zenkit::MenuItemSelectAction") = zenkit::MenuItemSelectAction; - using music_transition_type ZKREM("renamed to zenkit::MusicTransitionEffect") = zenkit::MusicTransitionEffect; - using music_transition_subtype ZKREM("renamed to zenkit::MusicTransitionType") = zenkit::MusicTransitionType; - using c_fight_ai_move ZKREM("renamed to zenkit::FightAiMove") = zenkit::FightAiMove; - - ZKREM("renamed to zenkit::register_all_script_classes") - inline void register_all_script_classes(zenkit::DaedalusScript& s) { - zenkit::register_all_script_classes(s); - } -} // namespace phoenix diff --git a/include/phoenix/ext/dds_convert.hh b/include/phoenix/ext/dds_convert.hh deleted file mode 100644 index 4ae5b8aa..00000000 --- a/include/phoenix/ext/dds_convert.hh +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Library.hh" -#include "zenkit/addon/texcvt.hh" - -#include "phoenix/buffer.hh" - -namespace phoenix { - /// \brief Converts a texture to the DDS format. - /// \param tex The texture to convert. - /// \return A buffer containing the DDS file. - [[nodiscard]] ZKREM("use zenkit::to_dds") inline buffer texture_to_dds(zenkit::Texture const& tex) { - return buffer::of(zenkit::to_dds(tex)); - } -} // namespace phoenix diff --git a/include/phoenix/font.hh b/include/phoenix/font.hh deleted file mode 100644 index c58ddeb6..00000000 --- a/include/phoenix/font.hh +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Font.hh" - -namespace phoenix { - using glyph ZKREM("renamed to FontGlyph") = zenkit::FontGlyph; - using font ZKREM("renamed to Font") = zenkit::Font; -} // namespace phoenix diff --git a/include/phoenix/material.hh b/include/phoenix/material.hh deleted file mode 100644 index 835e874f..00000000 --- a/include/phoenix/material.hh +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Material.hh" - -namespace phoenix { - using alpha_function ZKREM("renamed to zenkit::AlphaFunction") = zenkit::AlphaFunction; - using material_group ZKREM("renamed to zenkit::MaterialGroup") = zenkit::MaterialGroup; - using wave_speed_type ZKREM("renamed to zenkit::WaveSpeed") = zenkit::WaveSpeed; - using wave_mode_type ZKREM("renamed to zenkit::WaveMode") = zenkit::WaveMode; - using animation_mapping_mode ZKREM("renamed to zenkit::AnimationMapping") = zenkit::AnimationMapping; - using material ZKREM("renamed to zenkit::Material") = zenkit::Material; -} // namespace phoenix diff --git a/include/phoenix/math.hh b/include/phoenix/math.hh deleted file mode 100644 index 70acaa81..00000000 --- a/include/phoenix/math.hh +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Boxes.hh" - -namespace phoenix { - using bounding_box ZKREM("renamed to zenkit::AxisAlignedBoundingBox") = zenkit::AxisAlignedBoundingBox; - using obb ZKREM("renamed to zenkit::OrientedBoundingBox") = zenkit::OrientedBoundingBox; -} // namespace phoenix diff --git a/include/phoenix/mesh.hh b/include/phoenix/mesh.hh deleted file mode 100644 index eedce6f1..00000000 --- a/include/phoenix/mesh.hh +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Mesh.hh" - -#include "phoenix/material.hh" -#include "phoenix/math.hh" - -namespace phoenix { - using light_map ZKREM("renamed to zenkit::LightMap") = zenkit::LightMap; - using vertex_feature ZKREM("renamed to zenkit::VertexFeature") = zenkit::VertexFeature; - using polygon_flags ZKREM("renamed to zenkit::PolygonFlags") = zenkit::PolygonFlagSet; - using polygon_list ZKREM("renamed to zenkit::PolygonList") = zenkit::PolygonList; - using mesh ZKREM("renamed to zenkit::Mesh") = zenkit::Mesh; -} // namespace phoenix diff --git a/include/phoenix/messages.hh b/include/phoenix/messages.hh deleted file mode 100644 index 9f283cb2..00000000 --- a/include/phoenix/messages.hh +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/CutsceneLibrary.hh" - -namespace phoenix { - using atomic_message ZKREM("renamed to zenkit::CutsceneMessage") = zenkit::CutsceneMessage; - using message_block ZKREM("renamed to zenkit::CutsceneBlock") = zenkit::CutsceneBlock; - using messages ZKREM("renamed to zenkit::CutsceneLibrary") = zenkit::CutsceneLibrary; -} // namespace phoenix diff --git a/include/phoenix/model.hh b/include/phoenix/model.hh deleted file mode 100644 index 3af93aed..00000000 --- a/include/phoenix/model.hh +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Model.hh" - -namespace phoenix { - using model ZKREM("renamed to zenkit::Model") = zenkit::Model; -} diff --git a/include/phoenix/model_hierarchy.hh b/include/phoenix/model_hierarchy.hh deleted file mode 100644 index 419e6f46..00000000 --- a/include/phoenix/model_hierarchy.hh +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/ModelHierarchy.hh" - -namespace phoenix { - using model_hierarchy_node ZKREM("renamed to zenkit::ModelHierarchyNode") = zenkit::ModelHierarchyNode; - using model_hierarchy ZKREM("renamed to zenkit::ModelHierarchy") = zenkit::ModelHierarchy; -} // namespace phoenix diff --git a/include/phoenix/model_mesh.hh b/include/phoenix/model_mesh.hh deleted file mode 100644 index a505d335..00000000 --- a/include/phoenix/model_mesh.hh +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/ModelMesh.hh" - -namespace phoenix { - using model_mesh ZKREM("renamed to zenkit::ModelMesh") = zenkit::ModelMesh; -} // namespace phoenix diff --git a/include/phoenix/model_script.hh b/include/phoenix/model_script.hh deleted file mode 100644 index e2110a11..00000000 --- a/include/phoenix/model_script.hh +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "phoenix.hh" -#include "zenkit/ModelScript.hh" - -namespace phoenix { - namespace mds { - ZKREM("use zenkit::AnimationFlags::NONE") static constexpr auto af_none = zenkit::AnimationFlags::NONE; - ZKREM("use zenkit::AnimationFlags::MOVE") static constexpr auto af_move = zenkit::AnimationFlags::MOVE; - ZKREM("use zenkit::AnimationFlags::ROTATE") static constexpr auto af_rotate = zenkit::AnimationFlags::ROTATE; - ZKREM("use zenkit::AnimationFlags::QUEUE") static constexpr auto af_queue = zenkit::AnimationFlags::QUEUE; - ZKREM("use zenkit::AnimationFlags::FLY") static constexpr auto af_fly = zenkit::AnimationFlags::FLY; - ZKREM("use zenkit::AnimationFlags::IDLE") static constexpr auto af_idle = zenkit::AnimationFlags::IDLE; - ZKREM("use zenkit::AnimationFlags::INPLACE") static constexpr auto af_inplace = zenkit::AnimationFlags::INPLACE; - - using animation_direction ZKREM("renamed to zenkit::AnimationDirection") = zenkit::AnimationDirection; - using animation_flags ZKREM("use zenkit::AnimationFlags instead") = zenkit::AnimationFlags; - using event_fight_mode ZKREM("renamed to zenkit::MdsFightMode") = zenkit::MdsFightMode; - using event_tag_type ZKREM("renamed to zenkit::MdsEventType") = zenkit::MdsEventType; - using skeleton ZKREM("renamed to zenkit::MdsSkeleton") = zenkit::MdsSkeleton; - using model_tag ZKREM("renamed to zenkit::MdsModelTag") = zenkit::MdsModelTag; - using event_tag ZKREM("renamed to zenkit::MdsEventTag") = zenkit::MdsEventTag; - using event_pfx ZKREM("renamed to zenkit::MdsParticleEffect") = zenkit::MdsParticleEffect; - using event_camera_tremor ZKREM("renamed to zenkit::MdsCameraTremor") = zenkit::MdsCameraTremor; - using event_pfx_stop ZKREM("renamed to zenkit::MdsParticleEffectStop") = zenkit::MdsParticleEffectStop; - using event_sfx ZKREM("renamed to zenkit::MdsSoundEffect") = zenkit::MdsSoundEffect; - using event_sfx_ground ZKREM("renamed to zenkit::MdsSoundEffectGround") = zenkit::MdsSoundEffectGround; - using event_morph_animate ZKREM("renamed to zenkit::MdsMorphAnimation") = zenkit::MdsMorphAnimation; - using animation ZKREM("renamed to zenkit::MdsAnimation") = zenkit::MdsAnimation; - using animation_alias ZKREM("renamed to zenkit::MdsAnimationAlias") = zenkit::MdsAnimationAlias; - using animation_blending ZKREM("renamed to zenkit::MdsAnimationBlend") = zenkit::MdsAnimationBlend; - using animation_combination ZKREM("renamed to zenkit::MdsAnimationCombine") = zenkit::MdsAnimationCombine; - } // namespace mds - - struct script_sytax_error final : zenkit::ParserError { - ZKINT script_sytax_error(std::string&&, std::string&&) : ParserError("") {} - }; - - using model_script ZKREM("renamed to zenkit::ModelScript") = zenkit::ModelScript; -} // namespace phoenix diff --git a/include/phoenix/morph_mesh.hh b/include/phoenix/morph_mesh.hh deleted file mode 100644 index bc537207..00000000 --- a/include/phoenix/morph_mesh.hh +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/MorphMesh.hh" - -namespace phoenix { - using morph_mesh ZKREM("using zenkit::MorphMesh") = zenkit::MorphMesh; - using morph_source ZKREM("using zenkit::MorphSource") = zenkit::MorphSource; - using morph_animation ZKREM("using zenkit::MorphAnimation") = zenkit::MorphAnimation; -} // namespace phoenix diff --git a/include/phoenix/phoenix.hh b/include/phoenix/phoenix.hh deleted file mode 100644 index 8cf42e31..00000000 --- a/include/phoenix/phoenix.hh +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright © 2022-2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Date.hh" -#include "zenkit/Error.hh" -#include "zenkit/Logger.hh" -#include "zenkit/Misc.hh" - -#include -#include -#include -#include -#include -#include -#include - -namespace phoenix { - class buffer; - - using game_version ZKREM("renamed to zenkit::GameVersion") = zenkit::GameVersion; - using error ZKREM("renamed to zenkit::Error") = zenkit::Error; - using parser_error ZKREM("renamed to zenkit::ParserError") = zenkit::ParserError; - - inline bool iequals(std::string_view a, std::string_view b) { - return zenkit::iequals(a, b); - } - - inline bool icompare(std::string_view a, std::string_view b) { - return zenkit::icompare(a, b); - } - - using date ZKREM("renamed to zenkit::Date") = zenkit::Date; - using logging ZKREM("renamed to zenkit::Logger") = zenkit::Logger; -} // namespace phoenix diff --git a/include/phoenix/proto_mesh.hh b/include/phoenix/proto_mesh.hh deleted file mode 100644 index 9fb9af0d..00000000 --- a/include/phoenix/proto_mesh.hh +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/MultiResolutionMesh.hh" - -namespace phoenix { - using triangle ZKREM("renamed to zenkit::MeshTriangle") = zenkit::MeshTriangle; - using triangle_edge ZKREM("renamed to zenkit::MeshTriangleEdge") = zenkit::MeshTriangleEdge; - using edge ZKREM("renamed to zenkit::MeshEdge") = zenkit::MeshEdge; - using wedge ZKREM("renamed to zenkit::MeshWedge") = zenkit::MeshWedge; - using plane ZKREM("renamed to zenkit::MeshPlane") = zenkit::MeshPlane; - using mesh_section ZKREM("renamed to zenkit::MeshSection") = zenkit::MeshSection; - using sub_mesh_section ZKREM("renamed to zenkit::SubMeshSection") = zenkit::SubMeshSection; - using sub_mesh ZKREM("renamed to zenkit::SubMesh") = zenkit::SubMesh; - using proto_mesh ZKREM("renamed to zenkit::MultiResolutionMesh") = zenkit::MultiResolutionMesh; -} // namespace phoenix diff --git a/include/phoenix/save_game.hh b/include/phoenix/save_game.hh deleted file mode 100644 index b26a3005..00000000 --- a/include/phoenix/save_game.hh +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/SaveGame.hh" - -namespace phoenix::unstable { - using save_info ZKREM("renamed to zenkit::unstable::SaveInfo") = zenkit::unstable::SaveInfo; - using topic_section ZKREM("renamed to zenkit::unstable::SaveTopicSection") = zenkit::unstable::SaveTopicSection; - using topic_status ZKREM("renamed to zenkit::unstable::SaveTopicStatus") = zenkit::unstable::SaveTopicStatus; - using log_topic ZKREM("renamed to zenkit::unstable::SaveLogTopic") = zenkit::unstable::SaveLogTopic; - using info_state ZKREM("renamed to zenkit::unstable::SaveInfoState") = zenkit::unstable::SaveInfoState; - using symbol_state ZKREM("renamed to zenkit::unstable::SaveSymbolState") = zenkit::unstable::SaveSymbolState; - using script_state ZKREM("renamed to zenkit::unstable::SaveScriptState") = zenkit::unstable::SaveScriptState; - using save_game ZKREM("renamed to zenkit::unstable::SaveGame") = zenkit::unstable::SaveGame; -} // namespace phoenix::unstable diff --git a/include/phoenix/script.hh b/include/phoenix/script.hh deleted file mode 100644 index a450dc51..00000000 --- a/include/phoenix/script.hh +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/DaedalusScript.hh" - -namespace phoenix { - namespace symbol_flag = zenkit::DaedalusSymbolFlag; - - using datatype ZKREM("renamed to zenkit::DaedalusDataType") = zenkit::DaedalusDataType; - using opcode ZKREM("renamed to zenkit::DaedalusOpcode") = zenkit::DaedalusOpcode; - using symbol ZKREM("renamed to zenkit::DaedalusSymbol") = zenkit::DaedalusSymbol; - using instance ZKREM("renamed to zenkit::DaedalusInstance") = zenkit::DaedalusInstance; - using script_error ZKREM("renamed to zenkit::DaedalusScriptError") = zenkit::DaedalusScriptError; - using symbol_not_found ZKREM("renamed to zenkit::DaedalusSymbolNotFound") = zenkit::DaedalusSymbolNotFound; - using member_registration_error - ZKREM("renamed to zenkit::DaedalusMemberRegistrationError") = zenkit::DaedalusMemberRegistrationError; - using invalid_registration_datatype - ZKREM("renamed to zenkit::DaedalusInvalidRegistrationDataType") = zenkit::DaedalusInvalidRegistrationDataType; - using illegal_access ZKREM("renamed to zenkit::DaedalusIllegalAccess") = zenkit::DaedalusIllegalAccess; - using illegal_type_access ZKREM("renamed to zenkit::DaedalusIllegalTypeAccess") = zenkit::DaedalusIllegalTypeAccess; - using illegal_index_access - ZKREM("renamed to zenkit::DaedalusIllegalIndexAccess") = zenkit::DaedalusIllegalIndexAccess; - using illegal_const_access - ZKREM("renamed to zenkit::DaedalusIllegalConstAccess") = zenkit::DaedalusIllegalConstAccess; - using illegal_instance_access - ZKREM("renamed to zenkit::DaedalusIllegalInstanceAccess") = zenkit::DaedalusIllegalInstanceAccess; - using unbound_member_access - ZKREM("renamed to zenkit::DaedalusUnboundMemberAccess") = zenkit::DaedalusUnboundMemberAccess; - using no_context ZKREM("renamed to zenkit::DaedalusNoContextError") = zenkit::DaedalusNoContextError; - using illegal_context_type - ZKREM("renamed to zenkit::DaedalusIllegalContextType") = zenkit::DaedalusIllegalContextType; - using instruction ZKREM("renamed to zenkit::DaedalusInstruction") = zenkit::DaedalusInstruction; - using script ZKREM("renamed to zenkit::DaedalusScript") = zenkit::DaedalusScript; - using transient_instance ZKREM("renamed to zenkit::DaedalusTransientInstance") = zenkit::DaedalusTransientInstance; - using opaque_instance ZKREM("renamed to zenkit::DaedalusOpaqueInstance") = zenkit::DaedalusOpaqueInstance; -} // namespace phoenix diff --git a/include/phoenix/softskin_mesh.hh b/include/phoenix/softskin_mesh.hh deleted file mode 100644 index 888efff5..00000000 --- a/include/phoenix/softskin_mesh.hh +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/SoftSkinMesh.hh" - -#include "phoenix/math.hh" - -namespace phoenix { - using softskin_mesh ZKREM("renamed to zenkit::SoftSkinMesh") = zenkit::SoftSkinMesh; - using wedge_normal ZKREM("renamed to zenkit::SoftSkinWedgeNormal") = zenkit::SoftSkinWedgeNormal; - using weight_entry ZKREM("renamed to zenkit::SoftSkinWeightEntry") = zenkit::SoftSkinWeightEntry; -} // namespace phoenix diff --git a/include/phoenix/texture.hh b/include/phoenix/texture.hh deleted file mode 100644 index c0505fd6..00000000 --- a/include/phoenix/texture.hh +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/Texture.hh" - -namespace phoenix { - constexpr zenkit::TextureFormat tex_B8G8R8A8 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::B8G8R8A8; - constexpr zenkit::TextureFormat tex_R8G8B8A8 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::R8G8B8A8; - constexpr zenkit::TextureFormat tex_A8B8G8R8 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::A8B8G8R8; - constexpr zenkit::TextureFormat tex_A8R8G8B8 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::A8R8G8B8; - constexpr zenkit::TextureFormat tex_B8G8R8 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::B8G8R8; - constexpr zenkit::TextureFormat tex_R8G8B8 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::R8G8B8; - constexpr zenkit::TextureFormat tex_A4R4G4B4 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::A4R4G4B4; - constexpr zenkit::TextureFormat tex_A1R5G5B5 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::A1R5G5B5; - constexpr zenkit::TextureFormat tex_R5G6B5 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::R5G6B5; - constexpr zenkit::TextureFormat tex_p8 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::P8; - constexpr zenkit::TextureFormat tex_dxt1 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::DXT1; - constexpr zenkit::TextureFormat tex_dxt2 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::DXT2; - constexpr zenkit::TextureFormat tex_dxt3 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::DXT3; - constexpr zenkit::TextureFormat tex_dxt4 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::DXT4; - constexpr zenkit::TextureFormat tex_dxt5 ZKREM("use zenkit::TextureFormat") = zenkit::TextureFormat::DXT5; - - using texture ZKREM("renamed to zenkit::Texture") = zenkit::Texture; - using texture_format ZKREM("renamed to zenkit::TextureFormat") = zenkit::TextureFormat; - using argb ZKREM("renamed to zenkit::ColorARGB") = zenkit::ColorARGB; -} // namespace phoenix diff --git a/include/phoenix/vm.hh b/include/phoenix/vm.hh deleted file mode 100644 index 3c987827..00000000 --- a/include/phoenix/vm.hh +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/DaedalusVm.hh" - -#include "phoenix/script.hh" - -namespace phoenix { - namespace execution_flag = zenkit::DaedalusVmExecutionFlag; - - using illegal_external_definition - ZKREM("renamed to zenkit::DaedalusIllegalExternalDefinition") = zenkit::DaedalusIllegalExternalDefinition; - using illegal_external_rtype - ZKREM("renamed to zenkit::DaedalusIllegalExternalReturnType") = zenkit::DaedalusIllegalExternalReturnType; - using illegal_external_param - ZKREM("renamed to zenkit::DaedalusIllegalExternalParameter") = zenkit::DaedalusIllegalExternalParameter; - using vm_exception ZKREM("renamed to zenkit::DaedalusVmException") = zenkit::DaedalusVmException; - using vm_exception_strategy - ZKREM("renamed to zenkit::DaedalusVmExceptionStrategy") = zenkit::DaedalusVmExceptionStrategy; - using daedalus_stack_frame ZKREM("renamed to zenkit::DaedalusStackFrame") = zenkit::DaedalusStackFrame; - using daedalus_call_stack_frame ZKREM("renamed to zenkit::DaedalusCallStackFrame") = zenkit::DaedalusCallStackFrame; - using vm ZKREM("renamed to zenkit::DaedalusVm") = zenkit::DaedalusVm; - using func ZKREM("renamed to zenkit::DaedalusFunction") = zenkit::DaedalusFunction; - using naked_call ZKREM("renamed to zenkit::DaedalusNakedCall") = zenkit::DaedalusNakedCall; - - inline zenkit::DaedalusVmExceptionStrategy lenient_vm_exception_handler(zenkit::DaedalusVm& v, - zenkit::DaedalusScriptError const& exc, - zenkit::DaedalusInstruction const& instr) { - return zenkit::lenient_vm_exception_handler(v, exc, instr); - } -} // namespace phoenix diff --git a/include/phoenix/vobs/camera.hh b/include/phoenix/vobs/camera.hh deleted file mode 100644 index 78847640..00000000 --- a/include/phoenix/vobs/camera.hh +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/vobs/Camera.hh" - -namespace phoenix { - namespace vobs { - using camera_trj_frame ZKREM("renamed to zenkit::VCameraTrajectoryFrame") = zenkit::VCameraTrajectoryFrame; - using cs_camera ZKREM("renamed to zenkit::VCutsceneCamera") = zenkit::VCutsceneCamera; - } // namespace vobs - - using camera_motion ZKREM("renamed to zenkit::CameraMotion") = zenkit::CameraMotion; - using camera_trajectory ZKREM("renamed to zenkit::CameraCoordinateReference") = zenkit::CameraCoordinateReference; - using camera_lerp_mode ZKREM("renamed to zenkit::CameraLerpType") = zenkit::CameraLerpType; - using camera_loop ZKREM("renamed to zenkit::CameraLoop") = zenkit::CameraLoop; -} // namespace phoenix diff --git a/include/phoenix/vobs/light.hh b/include/phoenix/vobs/light.hh deleted file mode 100644 index 6c3f06d8..00000000 --- a/include/phoenix/vobs/light.hh +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/vobs/Light.hh" - -namespace phoenix { - namespace vobs { - using light_preset ZKREM("renamed to zenkit::VLightPreset") = zenkit::LightPreset; - using light ZKREM("renamed to zenkit::VLight") = zenkit::VLight; - } // namespace vobs - - using light_mode ZKREM("renamed to zenkit::LightType") = zenkit::LightType; - using light_quality ZKREM("renamed to zenkit::LightQuality") = zenkit::LightQuality; -} // namespace phoenix diff --git a/include/phoenix/vobs/misc.hh b/include/phoenix/vobs/misc.hh deleted file mode 100644 index 0b3924b6..00000000 --- a/include/phoenix/vobs/misc.hh +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/vobs/Misc.hh" - -namespace phoenix { - namespace vobs { - using animate ZKREM("renamed to zenkit::VAnimate") = zenkit::VAnimate; - using item ZKREM("renamed to zenkit::VItem") = zenkit::VItem; - using lens_flare ZKREM("renamed to zenkit::VLensFlare") = zenkit::VLensFlare; - using pfx_controller ZKREM("renamed to zenkit::VParticleEffectController") = zenkit::VParticleEffectController; - using code_master ZKREM("renamed to zenkit::VCodeMaster") = zenkit::VCodeMaster; - using message_filter ZKREM("renamed to zenkit::VMessageFilter") = zenkit::VMessageFilter; - using mover_controller ZKREM("renamed to zenkit::VMoverController") = zenkit::VMoverController; - using touch_damage ZKREM("renamed to zenkit::VTouchDamage") = zenkit::VTouchDamage; - using earthquake ZKREM("renamed to zenkit::VEarthquake") = zenkit::VEarthquake; - using npc ZKREM("renamed to zenkit::VNpc") = zenkit::VNpc; - } // namespace vobs - - using message_filter_action ZKREM("renamed to zenkit::MessageFilterAction") = zenkit::MessageFilterAction; - using mover_message_type ZKREM("renamed to zenkit::MoverMessageType") = zenkit::MoverMessageType; - using collision_type ZKREM("renamed to zenkit::TouchCollisionType") = zenkit::TouchCollisionType; -} // namespace phoenix diff --git a/include/phoenix/vobs/mob.hh b/include/phoenix/vobs/mob.hh deleted file mode 100644 index becf16fd..00000000 --- a/include/phoenix/vobs/mob.hh +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/vobs/MovableObject.hh" - -namespace phoenix { - namespace vobs { - using mob ZKREM("renamed to zenkit::VMovableObject") = zenkit::VMovableObject; - using mob_inter ZKREM("renamed to zenkit::VInteractiveObject") = zenkit::VInteractiveObject; - using mob_fire ZKREM("renamed to zenkit::VFire") = zenkit::VFire; - using mob_container ZKREM("renamed to zenkit::VContainer") = zenkit::VContainer; - using mob_door ZKREM("renamed to zenkit::VDoor") = zenkit::VDoor; - } // namespace vobs - - using sound_material ZKREM("renamed to zenkit::SoundMaterialType") = zenkit::SoundMaterialType; -} // namespace phoenix diff --git a/include/phoenix/vobs/sound.hh b/include/phoenix/vobs/sound.hh deleted file mode 100644 index a006b432..00000000 --- a/include/phoenix/vobs/sound.hh +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/vobs/Sound.hh" - -namespace phoenix { - namespace vobs { - using sound ZKREM("renamed to zenkit::VSound") = zenkit::VSound; - using sound_daytime ZKREM("renamed to zenkit::VSoundDaytime") = zenkit::VSoundDaytime; - } // namespace vobs - - using sound_mode ZKREM("renamed to zenkit::SoundMode") = zenkit::SoundMode; - using sound_trigger_volume ZKREM("renamed to SoundTriggerVolumeType") = zenkit::SoundTriggerVolumeType; -} // namespace phoenix diff --git a/include/phoenix/vobs/trigger.hh b/include/phoenix/vobs/trigger.hh deleted file mode 100644 index 0f8a76cb..00000000 --- a/include/phoenix/vobs/trigger.hh +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/vobs/Trigger.hh" - -#include "phoenix/animation.hh" - -namespace phoenix { - namespace vobs { - using trigger ZKREM("renamed to zenkit::VTrigger") = zenkit::VTrigger; - using trigger_mover ZKREM("renamed to zenkit::VMover") = zenkit::VMover; - using trigger_list ZKREM("renamed to zenkit::VTriggerList") = zenkit::VTriggerList; - using trigger_script ZKREM("renamed to zenkit::VTriggerScript") = zenkit::VTriggerScript; - using trigger_change_level ZKREM("renamed to zenkit::VTriggerChangeLevel") = zenkit::VTriggerChangeLevel; - using trigger_world_start ZKREM("renamed to zenkit::VTriggerWorldStart") = zenkit::VTriggerWorldStart; - using trigger_untouch ZKREM("renamed to zenkit::VTriggerUntouch") = zenkit::VTriggerUntouch; - } // namespace vobs - - using mover_behavior ZKREM("renamed to zenkit::MoverBehavior") = zenkit::MoverBehavior; - using mover_lerp_mode ZKREM("renamed to zenkit::MoverLerpType") = zenkit::MoverLerpType; - using mover_speed_mode ZKREM("renamed to zenkit::MoverSpeedType") = zenkit::MoverSpeedType; - using trigger_batch_mode ZKREM("renamed to zenkit::TriggerBatchMode") = zenkit::TriggerBatchMode; -} // namespace phoenix diff --git a/include/phoenix/vobs/vob.hh b/include/phoenix/vobs/vob.hh deleted file mode 100644 index a28a407e..00000000 --- a/include/phoenix/vobs/vob.hh +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/vobs/VirtualObject.hh" - -namespace phoenix { - using vob_type ZKREM("renamed to zenkit::VirtualObjectType") = zenkit::VirtualObjectType; - using shadow_mode ZKREM("renamed to zenkit::ShadowType") = zenkit::ShadowType; - using visual_type ZKREM("renamed to zenkit::VisualType") = zenkit::VisualType; - using sprite_alignment ZKREM("renamed to zenkit::SpriteAlignment") = zenkit::SpriteAlignment; - using animation_mode ZKREM("renamed to zenkit::AnimationType") = zenkit::AnimationType; - using decal ZKREM("renamed to zenkit::VisualDecal") = zenkit::VisualDecal; - using vob ZKREM("renamed to zenkit::VirtualObject") = zenkit::VirtualObject; -} // namespace phoenix diff --git a/include/phoenix/vobs/zone.hh b/include/phoenix/vobs/zone.hh deleted file mode 100644 index ab0c5e75..00000000 --- a/include/phoenix/vobs/zone.hh +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/vobs/Zone.hh" - -namespace phoenix::vobs { - using zone_music ZKREM("renamed to zenkit::VZoneMusic") = zenkit::VZoneMusic; - using zone_far_plane ZKREM("renamed to zenkit::VZoneFarPlane") = zenkit::VZoneFarPlane; - using zone_fog ZKREM("renamed to zenkit::VZoneFog") = zenkit::VZoneFog; -} // namespace phoenix::vobs diff --git a/include/phoenix/world.hh b/include/phoenix/world.hh deleted file mode 100644 index 020a8121..00000000 --- a/include/phoenix/world.hh +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/World.hh" - -#include "phoenix/world/bsp_tree.hh" -#include "phoenix/world/vob_tree.hh" -#include "phoenix/world/way_net.hh" - -namespace phoenix { - using world ZKREM("renamed to zenkit::World") = zenkit::World; -} diff --git a/include/phoenix/world/bsp_tree.hh b/include/phoenix/world/bsp_tree.hh deleted file mode 100644 index adb32672..00000000 --- a/include/phoenix/world/bsp_tree.hh +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/world/BspTree.hh" - -namespace phoenix { - using bsp_tree ZKREM("renamed to zenkit::BspTree") = zenkit::BspTree; - using bsp_sector ZKREM("renamed to zenkit::BspSector") = zenkit::BspSector; - using bsp_node ZKREM("renamed to zenkit::BspNode") = zenkit::BspNode; - using bsp_tree_mode ZKREM("renamed to zenkit::BspTreeType") = zenkit::BspTreeType; -} // namespace phoenix diff --git a/include/phoenix/world/vob_tree.hh b/include/phoenix/world/vob_tree.hh deleted file mode 100644 index d1505c00..00000000 --- a/include/phoenix/world/vob_tree.hh +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/world/VobTree.hh" - -#include "phoenix/vobs/vob.hh" - -namespace phoenix { - ZKAPI inline std::shared_ptr parse_vob_tree(zenkit::ReadArchive& in, - zenkit::GameVersion version) { - return zenkit::parse_vob_tree(in, version); - } -} // namespace phoenix diff --git a/include/phoenix/world/way_net.hh b/include/phoenix/world/way_net.hh deleted file mode 100644 index 5ef5bb81..00000000 --- a/include/phoenix/world/way_net.hh +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright © 2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#pragma once -#include "zenkit/world/WayNet.hh" - -namespace phoenix { - using way_net ZKREM("renamed to zenkit::WayNet") = zenkit::WayNet; - using way_edge ZKREM("renamed to zenkit::WayEdge") = zenkit::WayEdge; - using way_point ZKREM("renamed to zenkit::WayPoint") = zenkit::WayPoint; -} // namespace phoenix diff --git a/include/zenkit/Archive.hh b/include/zenkit/Archive.hh index 6b54a4fe..3b5bfb8c 100644 --- a/include/zenkit/Archive.hh +++ b/include/zenkit/Archive.hh @@ -1,12 +1,11 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Boxes.hh" #include "zenkit/Library.hh" #include "zenkit/Object.hh" #include "zenkit/Stream.hh" - -#include "phoenix/buffer.hh" +#include "zenkit/Error.hh" #include #include @@ -17,10 +16,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; class ReadArchive; @@ -133,13 +128,6 @@ namespace zenkit { public: virtual ~ReadArchive() = default; - /// \brief Create a new archive reader from the given buffer. - /// \param[in] in The buffer to use. - /// \return A unique pointer containing an archive reader. - /// \throws zenkit::ParserError If the archive's header is invalid. - /// \sa ArchiveHeader#load - ZKREM("use ::from") static std::unique_ptr open(phoenix::buffer& in); - /// \brief Creates a new archive_reader from the given buffer. /// \param[in] r The buffer to use. /// \return The new archive_reader. @@ -236,12 +224,6 @@ namespace zenkit { /// \return The matrix. virtual glm::mat3x3 read_mat3x3() = 0; - /// \brief Reads a raw entry and returns the raw bytes stored within. - /// \param size The number of bytes to read (checked at runtime for ASCII and BIN_SAFE archives) - /// \return A vector containing the raw bytes of the entry. - /// \throws zenkit::ParserError if the value actually present is not raw - ZKREM("use ::read_raw()") virtual phoenix::buffer read_raw_bytes(uint32_t size) = 0; - virtual std::unique_ptr read_raw(std::size_t size) = 0; /// \brief Skips the next object in the reader and all it's children diff --git a/include/zenkit/Boxes.hh b/include/zenkit/Boxes.hh index b4d96dbd..ead290f8 100644 --- a/include/zenkit/Boxes.hh +++ b/include/zenkit/Boxes.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Library.hh" @@ -7,10 +7,6 @@ #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; class Write; @@ -27,11 +23,6 @@ namespace zenkit { /// \brief The coordinates of the maximum corner of the bounding box. glm::vec3 max; - /// \brief Parses a bounding box from the given buffer. - /// \param[in,out] in The buffer to parse from. - /// \return The bounding box parsed. - [[nodiscard]] ZKREM("use ::load()") ZKAPI static AxisAlignedBoundingBox parse(phoenix::buffer& in); - ZKAPI void load(Read* r); ZKAPI void save(Write* w) const; }; @@ -55,10 +46,5 @@ namespace zenkit { /// \todo Write a test for this. /// \return An AABB which contains this OBB. [[nodiscard]] ZKAPI AxisAlignedBoundingBox as_bbox() const; - - /// \brief Parses an oriented bounding box from a buffer. - /// \param[in,out] in The buffer to parse from. - /// \return The parsed bounding box. - [[nodiscard]] ZKREM("use ::load()") ZKAPI static OrientedBoundingBox parse(phoenix::buffer& in); }; } // namespace zenkit diff --git a/include/zenkit/CutsceneLibrary.hh b/include/zenkit/CutsceneLibrary.hh index 4ace1b33..904eb123 100644 --- a/include/zenkit/CutsceneLibrary.hh +++ b/include/zenkit/CutsceneLibrary.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Archive.hh" @@ -8,10 +8,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { struct VNpc; diff --git a/include/zenkit/DaedalusScript.hh b/include/zenkit/DaedalusScript.hh index 16a9eec7..52dd502a 100644 --- a/include/zenkit/DaedalusScript.hh +++ b/include/zenkit/DaedalusScript.hh @@ -1,12 +1,10 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Error.hh" #include "zenkit/Library.hh" #include "zenkit/Stream.hh" -#include "phoenix/buffer.hh" - #include #include #include @@ -16,10 +14,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -461,10 +455,6 @@ namespace zenkit { public: ZKINT DaedalusSymbol() = default; - /// \brief Parses a symbol from the given reader. - /// \param[in,out] in The reader to read the symbol from. - /// \return The symbol parsed. - [[nodiscard]] ZKREM("use ::load()") ZKAPI static DaedalusSymbol parse(phoenix::buffer& in); ZKAPI void load(Read* in); /// \brief Validates that the symbol is a string and retrieves it's value in the given context. @@ -750,16 +740,6 @@ namespace zenkit { ZKAPI DaedalusScript(DaedalusScript const& copy) = delete; ZKAPI DaedalusScript(DaedalusScript&& move) = default; - /// \brief Parses in a compiled daedalus script. - /// \param path The path of the script file. - /// \return The script parsed - [[nodiscard]] ZKREM("use ::load") ZKAPI static DaedalusScript parse(std::string const& path); - - /// \brief Parses in a compiled daedalus script. - /// \param buf A buffer containing the script data. - /// \return The script parsed - [[nodiscard]] ZKREM("use ::load") ZKAPI static DaedalusScript parse(phoenix::buffer& buf); - ZKAPI void load(Read* r); /// \brief Registers a member offset diff --git a/include/zenkit/Date.hh b/include/zenkit/Date.hh index 6b75f7d6..6419434e 100644 --- a/include/zenkit/Date.hh +++ b/include/zenkit/Date.hh @@ -1,22 +1,16 @@ -// Copyright © 2023 GothicKit Contributors. +// Copyright © 2023-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Library.hh" #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; class Write; /// \brief A basic date and time structure used by the *ZenGin*. struct Date { - [[nodiscard]] ZKREM("use ::load()") ZKAPI static Date parse(phoenix::buffer& buf); - ZKAPI void load(Read* r); ZKAPI void save(Write* w) const; diff --git a/include/zenkit/Font.hh b/include/zenkit/Font.hh index ac3f8a5d..e5991eea 100644 --- a/include/zenkit/Font.hh +++ b/include/zenkit/Font.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Library.hh" @@ -9,10 +9,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; class Write; @@ -53,9 +49,6 @@ namespace zenkit { /// try to load it into *ZenGin*, it will fail. ZKAPI Font(std::string name, std::uint32_t height, std::vector glyphs); - [[nodiscard]] ZKREM("use ::load()") ZKAPI static Font parse(phoenix::buffer& buf); - [[nodiscard]] ZKREM("use ::load()") ZKAPI static Font parse(phoenix::buffer&& in); - ZKAPI void load(Read* r); ZKAPI void save(Write* w) const; diff --git a/include/zenkit/Mesh.hh b/include/zenkit/Mesh.hh index 321d236d..e7355e12 100644 --- a/include/zenkit/Mesh.hh +++ b/include/zenkit/Mesh.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Boxes.hh" @@ -14,10 +14,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; class Write; @@ -91,43 +87,6 @@ namespace zenkit { /// set of polygons and accompanying data describing a static mesh in three dimensions.

class Mesh { public: - /// \brief Parses a mesh from the data in the given buffer. - /// - ///

This implementation is heavily based on the implementation found in - /// [ZenLib](https://github.com/Try/ZenLib).

- /// - /// \param[in,out] buf The buffer to read from. - /// \param include_polygons A list of polygon indices to include in the final mesh. All other polygons are - /// discarded. This is mainly used for world meshes which include level-of-detail - /// polygons. - /// \param force_wide_indices Set to true to force 32-bit vertex indices. Useful for parsing world meshes - /// with the XZEN extension (see - /// https://github.com/ThielHater/GRMFixes_Union/blob/master/GRMFixes/XZenFileFormat/Plugin_Source.hpp#L86). - /// \return The parsed mesh object. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&&, const std::vector&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static Mesh parse(phoenix::buffer& buf, - std::vector const& include_polygons = {}, - bool force_wide_indices = false); - - /// \brief Parses a mesh from the data in the given buffer. - /// - ///

This implementation is heavily based on the implementation found in - /// [ZenLib](https://github.com/Try/ZenLib).

- /// - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \param include_polygons A list of polygon indices to include in the final mesh. All other polygons are - /// discarded. This is mainly used for world meshes which include level-of-detail - /// polygons. - /// \return The parsed mesh object. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&, const std::vector&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static Mesh - parse(phoenix::buffer&& buf, std::vector const& include_polygons = {}); - ZKAPI void load(Read* r, bool force_wide_indices); ZKAPI void load(Read* r, std::vector const& leaf_polygons, bool force_wide_indices); ZKAPI void save(Write* w, GameVersion version) const; diff --git a/include/zenkit/Model.hh b/include/zenkit/Model.hh index 3b2a477f..f4423bb3 100644 --- a/include/zenkit/Model.hh +++ b/include/zenkit/Model.hh @@ -1,14 +1,10 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Library.hh" #include "zenkit/ModelHierarchy.hh" #include "zenkit/ModelMesh.hh" -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -18,23 +14,6 @@ namespace zenkit { /// typically found in files with the `MDL` extension.

class Model { public: - /// \brief Parses a model from the data in the given buffer. - /// \param[in,out] buf The buffer to read from. - /// \return The parsed model object. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static Model parse(phoenix::buffer& buf); - - /// \brief Parses a model from the data in the given buffer. - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \return The parsed model object. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static Model parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); ZKAPI void save(Write* w, GameVersion version) const; diff --git a/include/zenkit/ModelAnimation.hh b/include/zenkit/ModelAnimation.hh index a6c34190..1c3399e4 100644 --- a/include/zenkit/ModelAnimation.hh +++ b/include/zenkit/ModelAnimation.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Boxes.hh" @@ -11,10 +11,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -110,27 +106,6 @@ namespace zenkit { /// \brief Represents a model animation. class ModelAnimation { public: - /// \brief Parses an animation from the data in the given buffer. - /// - ///

This implementation is heavily based on the implementation found in - /// [ZenLib](https://github.com/Try/ZenLib). - /// - /// \param[in,out] buf The buffer to read from. - /// \return The parsed animation. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static ModelAnimation parse(phoenix::buffer& buf); - - /// \brief Parses an animation from the data in the given buffer. - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \return The parsed animation. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static ModelAnimation parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); /// \brief The name of the animation diff --git a/include/zenkit/ModelHierarchy.hh b/include/zenkit/ModelHierarchy.hh index a3e49e3b..a306c2eb 100644 --- a/include/zenkit/ModelHierarchy.hh +++ b/include/zenkit/ModelHierarchy.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Boxes.hh" @@ -10,10 +10,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -35,31 +31,6 @@ namespace zenkit { /// animals and humans in the game which is commonly referred to as rigging.

class ModelHierarchy { public: - /// \brief Parses a model hierarchy from the data in the given buffer. - /// - ///

This implementation is heavily based on the implementation found in - /// [ZenLib](https://github.com/Try/ZenLib).

- /// - /// \param[in,out] buf The buffer to read from. - /// \return The parsed model hierarchy object. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static ModelHierarchy parse(phoenix::buffer& buf); - - /// \brief Parses a model hierarchy from the data in the given buffer. - /// - ///

This implementation is heavily based on the implementation found in - /// [ZenLib](https://github.com/Try/ZenLib).

- /// - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \return The parsed model hierarchy object. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static ModelHierarchy parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); ZKAPI void save(Write* w) const; diff --git a/include/zenkit/ModelMesh.hh b/include/zenkit/ModelMesh.hh index 561f3b40..010701f9 100644 --- a/include/zenkit/ModelMesh.hh +++ b/include/zenkit/ModelMesh.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Library.hh" @@ -10,10 +10,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -23,27 +19,6 @@ namespace zenkit { /// attachments. They can be found within `MDM` files and are embedded within phoenix::model objects.

class ModelMesh { public: - /// \brief Parses a model mesh from the data in the given buffer. - /// - ///

This implementation is heavily based on the implementation found in - /// [ZenLib](https://github.com/Try/ZenLib).

- /// - /// \param[in,out] buf The buffer to read from. - /// \return The parsed model mesh object. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static ModelMesh parse(phoenix::buffer& buf); - - /// \brief Parses a model mesh from the data in the given buffer. - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \return The parsed model mesh object. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static ModelMesh parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); ZKAPI void save(Write* w, GameVersion version) const; diff --git a/include/zenkit/ModelScript.hh b/include/zenkit/ModelScript.hh index b483c308..0ef5b9b8 100644 --- a/include/zenkit/ModelScript.hh +++ b/include/zenkit/ModelScript.hh @@ -1,4 +1,4 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Library.hh" @@ -7,10 +7,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -266,23 +262,6 @@ namespace zenkit { /// or after an animation plays (such as playing a sound).

class ModelScript { public: - /// \brief Parses a model script from the data in the given buffer. - /// \param[in,out] buf The buffer to read from. - /// \return The parsed model script. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static ModelScript parse(phoenix::buffer& buf); - - /// \brief Parses a model script from the data in the given buffer. - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \return The parsed model script. - /// \throws ParserError if parsing fails. - /// \see #parse(buffer&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static ModelScript parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); private: diff --git a/include/zenkit/MorphMesh.hh b/include/zenkit/MorphMesh.hh index ec51ee3b..b0372a71 100644 --- a/include/zenkit/MorphMesh.hh +++ b/include/zenkit/MorphMesh.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Date.hh" @@ -11,10 +11,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -58,23 +54,6 @@ namespace zenkit { /// of the vertices of the underlying phoenix::proto_mesh are actually changed while an animation plays.

class MorphMesh { public: - /// \brief Parses a morph mesh from the data in the given buffer. - /// \param[in,out] buf The buffer to read from. - /// \return The parsed morph mesh. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static MorphMesh parse(phoenix::buffer& buf); - - /// \brief Parses a morph mesh from the data in the given buffer. - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \return The parsed morph mesh. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static MorphMesh parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); /// \brief The name of the mesh. diff --git a/include/zenkit/MultiResolutionMesh.hh b/include/zenkit/MultiResolutionMesh.hh index e773744b..a0312228 100644 --- a/include/zenkit/MultiResolutionMesh.hh +++ b/include/zenkit/MultiResolutionMesh.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Boxes.hh" @@ -10,10 +10,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -86,23 +82,6 @@ namespace zenkit { /// related values.

class MultiResolutionMesh { public: - /// \brief Parses a proto mesh from the data in the given buffer. - /// \param[in,out] buf The buffer to read from. - /// \return The parsed proto mesh. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static MultiResolutionMesh parse(phoenix::buffer& buf); - - /// \brief Parses a proto mesh from the data in the given buffer. - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \return The parsed proto mesh. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&) - [[nodiscard]] ZKREM("use ::load()") ZKAPI static MultiResolutionMesh parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); ZKINT void load_from_section(Read* r); ZKAPI void save(Write* w, GameVersion version) const; diff --git a/include/zenkit/SaveGame.hh b/include/zenkit/SaveGame.hh index fd236ba7..4753c0e1 100644 --- a/include/zenkit/SaveGame.hh +++ b/include/zenkit/SaveGame.hh @@ -1,4 +1,4 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "Object.hh" @@ -12,10 +12,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class World; class Read; diff --git a/include/zenkit/SoftSkinMesh.hh b/include/zenkit/SoftSkinMesh.hh index 47f1c077..6aaabf48 100644 --- a/include/zenkit/SoftSkinMesh.hh +++ b/include/zenkit/SoftSkinMesh.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Boxes.hh" @@ -10,10 +10,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; @@ -31,23 +27,6 @@ namespace zenkit { /// \brief Represents a soft-skin mesh. class SoftSkinMesh { public: - /// \brief Parses a soft-skin mesh from the data in the given buffer. - /// \param[in,out] buf The buffer to read from. - /// \return The parsed soft-skin mesh. - /// \note After this function returns the position of \p buf will be at the end of the parsed object. - /// If you would like to keep your buffer immutable, consider passing a copy of it to #parse(buffer&&) - /// using buffer::duplicate. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&&) - [[nodiscard]] ZKREM(":: load()") ZKAPI static SoftSkinMesh parse(phoenix::buffer& buf); - - /// \brief Parses a soft-skin mesh from the data in the given buffer. - /// \param[in] buf The buffer to read from (by rvalue-reference). - /// \return The parsed soft-skin mesh. - /// \throws zenkit::ParserError if parsing fails. - /// \see #parse(buffer&) - [[nodiscard]] ZKREM(":: load()") ZKAPI static SoftSkinMesh parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); ZKAPI void save(Write* w, GameVersion version) const; diff --git a/include/zenkit/Stream.hh b/include/zenkit/Stream.hh index ba55cc0c..e378c709 100644 --- a/include/zenkit/Stream.hh +++ b/include/zenkit/Stream.hh @@ -1,4 +1,4 @@ -// Copyright © 2023 GothicKit Contributors. +// Copyright © 2023-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Library.hh" @@ -15,10 +15,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { // Windows does not define ssize_t @@ -114,7 +110,6 @@ namespace zenkit { [[nodiscard]] static std::unique_ptr from(std::vector const* vector); [[nodiscard]] static std::unique_ptr from(std::vector vector); [[nodiscard]] static std::unique_ptr from(std::filesystem::path const& path); - [[nodiscard]] ZKREM("deprecated") static std::unique_ptr from(phoenix::buffer* buf); }; class Write ZKAPI { diff --git a/include/zenkit/Texture.hh b/include/zenkit/Texture.hh index 5c324186..6b430b93 100644 --- a/include/zenkit/Texture.hh +++ b/include/zenkit/Texture.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Error.hh" @@ -8,10 +8,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { class Read; class Write; @@ -65,9 +61,6 @@ namespace zenkit { Texture& operator=(Texture&&) = default; Texture& operator=(Texture const&) = default; - [[nodiscard]] ZKREM("use ::load") ZKAPI static Texture parse(phoenix::buffer& in); - [[nodiscard]] ZKREM("use ::load") ZKAPI static Texture parse(phoenix::buffer&& in); - ZKAPI void load(Read* r); ZKAPI void save(Write* r) const; diff --git a/include/zenkit/Vfs.hh b/include/zenkit/Vfs.hh index fbe8beb1..03950ed2 100644 --- a/include/zenkit/Vfs.hh +++ b/include/zenkit/Vfs.hh @@ -1,11 +1,11 @@ -// Copyright © 2023 GothicKit Contributors. +// Copyright © 2023-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "Library.hh" #include "Mmap.hh" - -#include "phoenix/buffer.hh" -#include "phoenix/phoenix.hh" +#include "Error.hh" +#include "Stream.hh" +#include "Misc.hh" #include #include @@ -73,27 +73,22 @@ namespace zenkit { ZKAPI VfsNode* create(VfsNode node); ZKAPI bool remove(std::string_view name); - [[nodiscard]] ZKREM("use ::open_read()") ZKAPI phoenix::buffer open() const; [[nodiscard]] ZKAPI std::unique_ptr open_read() const; [[nodiscard]] ZKAPI static VfsNode directory(std::string_view name); - [[nodiscard]] ZKREM("Deprecated") ZKAPI static VfsNode file(std::string_view name, phoenix::buffer dev); [[nodiscard]] ZKAPI static VfsNode file(std::string_view name, VfsFileDescriptor dev); [[nodiscard]] ZKAPI static VfsNode directory(std::string_view name, std::time_t ts); - [[nodiscard]] ZKREM("Deprecated") ZKAPI static VfsNode - file(std::string_view name, phoenix::buffer dev, std::time_t ts); [[nodiscard]] ZKAPI static VfsNode file(std::string_view name, VfsFileDescriptor dev, std::time_t ts); protected: ZKAPI explicit VfsNode(std::string_view name, std::time_t ts); - ZKREM("Deprecated") ZKAPI explicit VfsNode(std::string_view name, phoenix::buffer dev, std::time_t ts); ZKAPI explicit VfsNode(std::string_view name, VfsFileDescriptor dev, std::time_t ts); private: std::string _m_name; std::time_t _m_time; - std::variant _m_data; + std::variant _m_data; }; enum class VfsOverwriteBehavior { @@ -158,8 +153,6 @@ namespace zenkit { /// \param buf A buffer containing the disk file contents. /// \param overwrite The behavior of the system when conflicting files are found. /// \throws VfsBrokenDiskError if the disk file is corrupted or invalid and thus, can't be loaded. - ZKREM("") - ZKAPI void mount_disk(phoenix::buffer buf, VfsOverwriteBehavior overwrite = VfsOverwriteBehavior::OLDER); ZKAPI void mount_disk(Read* buf, VfsOverwriteBehavior overwrite = VfsOverwriteBehavior::OLDER); /// \brief Mount a file or directory from the host file system into the Vfs. diff --git a/include/zenkit/World.hh b/include/zenkit/World.hh index 8424a8a5..ba61a163 100644 --- a/include/zenkit/World.hh +++ b/include/zenkit/World.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Library.hh" @@ -12,10 +12,6 @@ #include #include -namespace phoenix { - class buffer; -} - namespace zenkit { struct VNpc; struct CutsceneContext; @@ -70,11 +66,6 @@ namespace zenkit { class World : public Object { ZK_OBJECT(ObjectType::oCWorld); - [[nodiscard]] ZKREM("use ::load()") ZKAPI static World parse(phoenix::buffer& buf, GameVersion version); - [[nodiscard]] ZKREM("use ::load()") ZKAPI static World parse(phoenix::buffer& buf); - [[nodiscard]] ZKREM("use ::load()") ZKAPI static World parse(phoenix::buffer&& buf, GameVersion version); - [[nodiscard]] ZKREM("use ::load()") ZKAPI static World parse(phoenix::buffer&& buf); - ZKAPI void load(Read* r); ZKAPI void load(Read* r, GameVersion version); diff --git a/src/Archive.cc b/src/Archive.cc index 6b1f100d..0c33beba 100644 --- a/src/Archive.cc +++ b/src/Archive.cc @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Archive.hh" #include "zenkit/Stream.hh" @@ -19,7 +19,6 @@ #include "archive/ArchiveBinary.hh" #include "archive/ArchiveBinsafe.hh" -#include "phoenix/buffer.hh" #include "zenkit/CutsceneLibrary.hh" #include "zenkit/SaveGame.hh" #include "zenkit/World.hh" @@ -232,29 +231,6 @@ namespace zenkit { } } - std::unique_ptr ReadArchive::open(phoenix::buffer& in) { - auto read = Read::from(&in); - - ArchiveHeader header {}; - header.load(read.get()); - - std::unique_ptr reader; - if (header.format == ArchiveFormat::ASCII) { - reader = std::make_unique(std::move(header), read.get(), std::move(read)); - } else if (header.format == ArchiveFormat::BINARY) { - reader = std::make_unique(std::move(header), read.get(), std::move(read)); - } else if (header.format == ArchiveFormat::BINSAFE) { - reader = std::make_unique(std::move(header), read.get(), std::move(read)); - } else { - throw ParserError {"ReadArchive", - "format '" + std::to_string(static_cast(header.format)) + - "' is not supported"}; - } - - reader->read_header(); - return reader; - } - std::unique_ptr ReadArchive::from(Read* r) { ArchiveHeader header {}; header.load(r); diff --git a/src/Boxes.cc b/src/Boxes.cc index 3966aa09..1e4433a9 100644 --- a/src/Boxes.cc +++ b/src/Boxes.cc @@ -1,22 +1,11 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Boxes.hh" #include "zenkit/Stream.hh" -#include "phoenix/buffer.hh" - #include namespace zenkit { - AxisAlignedBoundingBox AxisAlignedBoundingBox::parse(phoenix::buffer& in) { - AxisAlignedBoundingBox bbox {}; - - auto r = Read::from(&in); - bbox.load(r.get()); - - return bbox; - } - void AxisAlignedBoundingBox::load(Read* r) { this->min = r->read_vec3(); this->max = r->read_vec3(); @@ -27,15 +16,6 @@ namespace zenkit { w->write_vec3(this->max); } - OrientedBoundingBox OrientedBoundingBox::parse(phoenix::buffer& in) { - OrientedBoundingBox bbox {}; - - auto r = Read::from(&in); - bbox.load(r.get()); - - return bbox; - } - void OrientedBoundingBox::load(Read* r) { center = r->read_vec3(); axes[0] = r->read_vec3(); diff --git a/src/CutsceneLibrary.cc b/src/CutsceneLibrary.cc index 081467f5..11e8c2c0 100644 --- a/src/CutsceneLibrary.cc +++ b/src/CutsceneLibrary.cc @@ -1,12 +1,10 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/CutsceneLibrary.hh" #include "zenkit/Archive.hh" #include "zenkit/Stream.hh" +#include "zenkit/Error.hh" -#include "Internal.hh" - -#include "phoenix/buffer.hh" #include "zenkit/vobs/Misc.hh" #include diff --git a/src/DaedalusScript.cc b/src/DaedalusScript.cc index df4fa99f..54c43106 100644 --- a/src/DaedalusScript.cc +++ b/src/DaedalusScript.cc @@ -1,12 +1,10 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/DaedalusScript.hh" #include "zenkit/Stream.hh" #include "Internal.hh" -#include "phoenix/buffer.hh" - #include namespace zenkit { @@ -89,24 +87,6 @@ namespace zenkit { return s; } - DaedalusScript DaedalusScript::parse(std::string const& file) { - DaedalusScript scr {}; - - auto r = Read::from(file); - scr.load(r.get()); - - return scr; - } - - DaedalusScript DaedalusScript::parse(phoenix::buffer& in) { - DaedalusScript scr {}; - - auto r = Read::from(&in); - scr.load(r.get()); - - return scr; - } - void DaedalusScript::load(Read* r) { this->_m_version = r->read_ubyte(); auto symbol_count = r->read_uint(); @@ -304,15 +284,6 @@ namespace zenkit { return static_cast(size); } - DaedalusSymbol DaedalusSymbol::parse(phoenix::buffer& in) { - DaedalusSymbol sym {}; - - auto r = Read::from(&in); - sym.load(r.get()); - - return sym; - } - void zk_internal_escape(std::string& s) { for (auto i = 0u; i < s.size(); ++i) { if (s[i] == '\\') { diff --git a/src/Date.cc b/src/Date.cc index 7f2e0782..175514b5 100644 --- a/src/Date.cc +++ b/src/Date.cc @@ -1,20 +1,9 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Date.hh" #include "zenkit/Stream.hh" -#include "phoenix/buffer.hh" - namespace zenkit { - Date Date::parse(phoenix::buffer& buf) { - Date dt {}; - - auto r = Read::from(&buf); - dt.load(r.get()); - - return dt; - } - void Date::load(Read* r) { this->year = r->read_uint(); this->month = r->read_ushort(); diff --git a/src/Font.cc b/src/Font.cc index 7cf6e306..900c8a83 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -1,9 +1,8 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Font.hh" #include "zenkit/Stream.hh" - -#include "phoenix/phoenix.hh" +#include "zenkit/Error.hh" namespace zenkit { bool FontGlyph::operator==(FontGlyph const& g) const noexcept { @@ -13,19 +12,6 @@ namespace zenkit { Font::Font(std::string font_name, std::uint32_t font_height, std::vector font_glyphs) : name(std::move(font_name)), height(font_height), glyphs(std::move(font_glyphs)) {} - Font Font::parse(phoenix::buffer& in) { - Font fnt {}; - - auto r = Read::from(&in); - fnt.load(r.get()); - - return fnt; - } - - Font Font::parse(phoenix::buffer&& in) { - return parse(in); - } - void Font::load(Read* r) { if (auto version = r->read_line(true); version != "1") { throw ParserError {"Font", "version mismatch: expected version 1, got " + version}; diff --git a/src/Material.cc b/src/Material.cc index 7b0a23ec..35fd893e 100644 --- a/src/Material.cc +++ b/src/Material.cc @@ -1,9 +1,8 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Material.hh" #include "zenkit/Archive.hh" - -#include "phoenix/phoenix.hh" +#include "zenkit/Error.hh" #include "Internal.hh" diff --git a/src/Mesh.cc b/src/Mesh.cc index 1c50116f..5be66e99 100644 --- a/src/Mesh.cc +++ b/src/Mesh.cc @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Mesh.hh" #include "zenkit/Archive.hh" @@ -22,15 +22,6 @@ namespace zenkit { END = 0xB060 }; - Mesh Mesh::parse(phoenix::buffer& buf, std::vector const& leaf_polygons, bool force_wide_indices) { - Mesh msh {}; - - auto r = Read::from(&buf); - msh.load(r.get(), leaf_polygons, force_wide_indices); - - return msh; - } - bool PolygonFlagSet::operator==(PolygonFlagSet const& b) const { return is_portal == b.is_portal && is_occluder == b.is_occluder && is_sector == b.is_sector && should_relight == b.should_relight && is_outdoor == b.is_outdoor && @@ -38,10 +29,6 @@ namespace zenkit { sector_index == b.sector_index && is_lod == b.is_lod && normal_axis == b.normal_axis; } - Mesh Mesh::parse(phoenix::buffer&& buf, std::vector const& include_polygons) { - return parse(buf, include_polygons); - } - void Mesh::load(Read* r, std::vector const& leaf_polygons, bool force_wide_indices) { this->load(r, force_wide_indices); this->triangulate(leaf_polygons); diff --git a/src/Model.cc b/src/Model.cc index 83b0e169..48cb691b 100644 --- a/src/Model.cc +++ b/src/Model.cc @@ -1,18 +1,9 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Model.hh" #include "zenkit/Stream.hh" namespace zenkit { - Model Model::parse(phoenix::buffer& buf) { - Model tmp {}; - - auto r = Read::from(&buf); - tmp.load(r.get()); - - return tmp; - } - void Model::load(Read* r) { this->hierarchy.load(r); this->mesh.load(r); @@ -22,8 +13,4 @@ namespace zenkit { this->hierarchy.save(w); this->mesh.save(w, version); } - - Model Model::parse(phoenix::buffer&& buf) { - return parse(buf); - } } // namespace zenkit diff --git a/src/ModelAnimation.cc b/src/ModelAnimation.cc index ced512a2..63bc8c55 100644 --- a/src/ModelAnimation.cc +++ b/src/ModelAnimation.cc @@ -1,12 +1,8 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/ModelAnimation.hh" #include "zenkit/Stream.hh" -#include "phoenix/buffer.hh" - -#include - namespace zenkit { /// \brief The highest number representable by a single rotation component. constexpr float SAMPLE_ROTATION_RANGE = static_cast(1 << 16) - 1.0f; @@ -69,19 +65,6 @@ namespace zenkit { return this->position == other.position && this->rotation == other.rotation; } - ModelAnimation ModelAnimation::parse(phoenix::buffer& buf) { - ModelAnimation anim {}; - - auto r = Read::from(&buf); - anim.load(r.get()); - - return anim; - } - - ModelAnimation ModelAnimation::parse(phoenix::buffer&& in) { - return parse(in); - } - void ModelAnimation::load(Read* r) { proto::read_chunked(r, "ModelAnimation", [this](Read* c, AnimationChunkType type) { switch (type) { diff --git a/src/ModelHierarchy.cc b/src/ModelHierarchy.cc index c3ddb512..434a9acb 100644 --- a/src/ModelHierarchy.cc +++ b/src/ModelHierarchy.cc @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/ModelHierarchy.hh" #include "zenkit/Stream.hh" @@ -12,19 +12,6 @@ namespace zenkit { END = 0xD120, }; - ModelHierarchy ModelHierarchy::parse(phoenix::buffer& in) { - ModelHierarchy hierarchy {}; - - auto r = Read::from(&in); - hierarchy.load(r.get()); - - return hierarchy; - } - - ModelHierarchy ModelHierarchy::parse(phoenix::buffer&& in) { - return parse(in); - } - void ModelHierarchy::load(Read* r) { proto::read_chunked( // r, diff --git a/src/ModelMesh.cc b/src/ModelMesh.cc index cf1a37b5..47122c72 100644 --- a/src/ModelMesh.cc +++ b/src/ModelMesh.cc @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/ModelMesh.hh" #include "zenkit/Date.hh" @@ -17,15 +17,6 @@ namespace zenkit { PROTO = 0xB100, }; - ModelMesh ModelMesh::parse(phoenix::buffer& in) { - ModelMesh msh {}; - - auto r = Read::from(&in); - msh.load(r.get()); - - return msh; - } - void ModelMesh::load(Read* r) { std::vector attachment_names {}; proto::read_chunked( @@ -115,8 +106,4 @@ namespace zenkit { proto::write_chunk(w, ModelMeshChunkType::END, [](Write*) {}); } - - ModelMesh ModelMesh::parse(phoenix::buffer&& buf) { - return parse(buf); - } } // namespace zenkit diff --git a/src/ModelScript.cc b/src/ModelScript.cc index 664c3d15..ed6cab81 100644 --- a/src/ModelScript.cc +++ b/src/ModelScript.cc @@ -1,4 +1,4 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/ModelScript.hh" #include "zenkit/Date.hh" @@ -8,6 +8,7 @@ #include "ModelScriptDsl.hh" #include +#include namespace zenkit { enum class ModelScriptBinaryChunkType : uint16_t { @@ -432,19 +433,6 @@ namespace zenkit { }); } - ModelScript ModelScript::parse(phoenix::buffer& buf) { - ModelScript mds {}; - - auto r = Read::from(&buf); - mds.load(r.get()); - - return mds; - } - - ModelScript ModelScript::parse(phoenix::buffer&& buf) { - return parse(buf); - } - void ModelScript::load(Read* r) { auto potential_chunk_type = r->read_ushort(); r->seek(-2, Whence::CUR); diff --git a/src/ModelScriptDsl.cc b/src/ModelScriptDsl.cc index 18a51555..7cef0ef5 100644 --- a/src/ModelScriptDsl.cc +++ b/src/ModelScriptDsl.cc @@ -1,9 +1,11 @@ -// Copyright © 2023 GothicKit Contributors. +// Copyright © 2023-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "ModelScriptDsl.hh" #include "Internal.hh" +#include "zenkit/Error.hh" #include "zenkit/Stream.hh" +#include "zenkit/Misc.hh" #define WARN_SYNTAX(msg) ZKLOGW("ModelScript", "Syntax error (line %d, column %d): %s", _m_line, _m_column, msg) @@ -184,7 +186,7 @@ namespace zenkit { void MdsParser::expect_keyword(std::string_view value) { this->expect(); - if (!phoenix::iequals(_m_stream.token_value(), value)) { + if (!iequals(_m_stream.token_value(), value)) { throw ScriptSyntaxError {_m_stream.format_location(), "expected the KEYWORD \"" + std::string {value} + "\""}; } @@ -270,7 +272,7 @@ namespace zenkit { return false; } - if (!phoenix::iequals(this->_m_stream.token_value(), value)) { + if (!iequals(this->_m_stream.token_value(), value)) { this->_m_stream.backtrack(); return false; } @@ -283,7 +285,7 @@ namespace zenkit { return std::nullopt; } - if (!phoenix::iequals(this->_m_stream.token_value(), name)) { + if (!iequals(this->_m_stream.token_value(), name)) { this->_m_stream.backtrack(); return std::nullopt; } @@ -306,11 +308,11 @@ namespace zenkit { } auto kw = this->expect_keyword(); - if (phoenix::iequals(kw, "meshAndTree")) { + if (iequals(kw, "meshAndTree")) { script.skeleton = this->parse_meshAndTree(); - } else if (phoenix::iequals(kw, "registerMesh")) { + } else if (iequals(kw, "registerMesh")) { script.meshes.push_back(this->parse_registerMesh()); - } else if (phoenix::iequals(kw, "aniEnum")) { + } else if (iequals(kw, "aniEnum")) { this->parse_aniEnum(script); } else { ZKLOGW("ModelScript", @@ -343,17 +345,17 @@ namespace zenkit { } auto kw = this->expect_keyword(); - if (phoenix::iequals(kw, "ani")) { + if (iequals(kw, "ani")) { into.animations.push_back(this->parse_ani()); - } else if (phoenix::iequals(kw, "aniBlend")) { + } else if (iequals(kw, "aniBlend")) { into.blends.push_back(this->parse_aniBlend()); - } else if (phoenix::iequals(kw, "aniAlias")) { + } else if (iequals(kw, "aniAlias")) { into.aliases.push_back(this->parse_aniAlias()); - } else if (phoenix::iequals(kw, "aniComb")) { + } else if (iequals(kw, "aniComb")) { into.combinations.push_back(this->parse_aniComb()); - } else if (phoenix::iequals(kw, "aniDisable")) { + } else if (iequals(kw, "aniDisable")) { into.disabled_animations.push_back(this->parse_aniDisable()); - } else if (phoenix::iequals(kw, "modelTag")) { + } else if (iequals(kw, "modelTag")) { into.model_tags.push_back(this->parse_modelTag()); } else { throw ScriptSyntaxError {_m_stream.format_location(), "invalid KEYWORD in \"aniEnum\" block: " + kw}; @@ -368,19 +370,19 @@ namespace zenkit { } auto kw = this->expect_keyword(); - if (phoenix::iequals(kw, "*eventTag")) { + if (iequals(kw, "*eventTag")) { ani.events.push_back(this->parse_eventTag()); - } else if (phoenix::iequals(kw, "*eventSFX")) { + } else if (iequals(kw, "*eventSFX")) { ani.sfx.push_back(this->parse_eventSFX()); - } else if (phoenix::iequals(kw, "*eventSFXGrnd")) { + } else if (iequals(kw, "*eventSFXGrnd")) { ani.sfx_ground.push_back(this->parse_eventSFXGrnd()); - } else if (phoenix::iequals(kw, "*eventPFX")) { + } else if (iequals(kw, "*eventPFX")) { ani.pfx.push_back(this->parse_eventPFX()); - } else if (phoenix::iequals(kw, "*eventPFXStop")) { + } else if (iequals(kw, "*eventPFXStop")) { ani.pfx_stop.push_back(this->parse_eventPFXStop()); - } else if (phoenix::iequals(kw, "*eventMMStartAni")) { + } else if (iequals(kw, "*eventMMStartAni")) { ani.morph.push_back(this->parse_eventMMStartAni()); - } else if (phoenix::iequals(kw, "*eventCamTremor")) { + } else if (iequals(kw, "*eventCamTremor")) { ani.tremors.push_back(this->parse_eventCamTremor()); } else { throw ScriptSyntaxError {_m_stream.format_location(), "invalid KEYWORD in \"ani\" block: " + kw}; @@ -473,11 +475,11 @@ namespace zenkit { ani.model = this->expect_string(); auto kw = this->expect_keyword(); - if (!phoenix::iequals(kw, "F") && !phoenix::iequals(kw, "R")) { + if (!iequals(kw, "F") && !iequals(kw, "R")) { throw ScriptSyntaxError {_m_stream.format_location(), R"(expected "F" or "R")"}; } - ani.direction = phoenix::iequals(kw, "R") ? AnimationDirection::BACKWARD : AnimationDirection::FORWARD; + ani.direction = iequals(kw, "R") ? AnimationDirection::BACKWARD : AnimationDirection::FORWARD; ani.first_frame = this->expect_int(); ani.last_frame = this->expect_int(); ani.speed = 0; // TODO @@ -559,7 +561,7 @@ namespace zenkit { MdsModelTag tag {}; auto type = this->expect_string(); - if (!phoenix::iequals(type, "DEF_HIT_LIMB")) { + if (!iequals(type, "DEF_HIT_LIMB")) { throw ScriptSyntaxError {_m_stream.format_location(), "expected a \"DEF_HIT_LIMB\""}; } diff --git a/src/ModelScriptDsl.hh b/src/ModelScriptDsl.hh index 4ebd22f7..069ce9b2 100644 --- a/src/ModelScriptDsl.hh +++ b/src/ModelScriptDsl.hh @@ -1,11 +1,9 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once -#include "phoenix/buffer.hh" -#include "phoenix/model_script.hh" -#include "phoenix/phoenix.hh" +#include "zenkit/Stream.hh" +#include "zenkit/ModelScript.hh" -#include #include #include #include diff --git a/src/MorphMesh.cc b/src/MorphMesh.cc index 495b1b17..2e1e15a7 100644 --- a/src/MorphMesh.cc +++ b/src/MorphMesh.cc @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/MorphMesh.hh" #include "zenkit/Stream.hh" @@ -12,19 +12,6 @@ namespace zenkit { MORPH = 0xB1FF }; - MorphMesh MorphMesh::parse(phoenix::buffer& in) { - MorphMesh msh {}; - - auto r = Read::from(&in); - msh.load(r.get()); - - return msh; - } - - MorphMesh MorphMesh::parse(phoenix::buffer&& buf) { - return parse(buf); - } - void MorphMesh::load(Read* r) { proto::read_chunked(r, "MorphMesh", [this](Read* c, MorphMeshChunkType type) { switch (type) { diff --git a/src/MultiResolutionMesh.cc b/src/MultiResolutionMesh.cc index fabfec2c..58acbe3b 100644 --- a/src/MultiResolutionMesh.cc +++ b/src/MultiResolutionMesh.cc @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/MultiResolutionMesh.hh" #include "zenkit/Archive.hh" @@ -10,19 +10,6 @@ namespace zenkit { enum class MrmChunkType : std::uint16_t { MESH = 0xB100, END = 0xB1FF }; - MultiResolutionMesh MultiResolutionMesh::parse(phoenix::buffer& in) { - MultiResolutionMesh msh {}; - - auto r = Read::from(&in); - msh.load(r.get()); - - return msh; - } - - MultiResolutionMesh MultiResolutionMesh::parse(phoenix::buffer&& in) { - return parse(in); - } - void MultiResolutionMesh::load(Read* r) { proto::read_chunked(r, "MultiResolutionMesh", [this](Read* c, MrmChunkType type) { switch (type) { diff --git a/src/SaveGame.cc b/src/SaveGame.cc index db4188e2..7327e5a4 100644 --- a/src/SaveGame.cc +++ b/src/SaveGame.cc @@ -1,4 +1,4 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/SaveGame.hh" #include "zenkit/Archive.hh" @@ -253,7 +253,7 @@ namespace zenkit { std::optional find_file_matching(std::set const& choices, std::string_view filename) { auto result = std::find_if(choices.begin(), choices.end(), [filename](std::filesystem::path const& path) { - return phoenix::iequals(path.filename().string(), filename); + return iequals(path.filename().string(), filename); }); if (result == choices.end()) { diff --git a/src/SoftSkinMesh.cc b/src/SoftSkinMesh.cc index 2abf0e34..86121791 100644 --- a/src/SoftSkinMesh.cc +++ b/src/SoftSkinMesh.cc @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/SoftSkinMesh.hh" #include "zenkit/Stream.hh" @@ -16,15 +16,6 @@ namespace zenkit { NODES = 0xB1FF, }; - SoftSkinMesh SoftSkinMesh::parse(phoenix::buffer& in) { - SoftSkinMesh msh {}; - - auto r = Read::from(&in); - msh.load(r.get()); - - return msh; - } - void SoftSkinMesh::load(Read* r) { proto::read_chunked(r, "SoftSkinMesh", [this](Read* c, SoftSkinMeshChunkType type) { switch (type) { @@ -134,8 +125,4 @@ namespace zenkit { proto::write_chunk(w, SoftSkinMeshChunkType::END, [](Write*) {}); } - - SoftSkinMesh SoftSkinMesh::parse(phoenix::buffer&& in) { - return parse(in); - } } // namespace zenkit diff --git a/src/Stream.cc b/src/Stream.cc index c8b71f5f..e893a1ac 100644 --- a/src/Stream.cc +++ b/src/Stream.cc @@ -1,7 +1,6 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Stream.hh" -#include "phoenix/buffer.hh" #include "zenkit/Mmap.hh" #include "Internal.hh" @@ -290,47 +289,6 @@ namespace zenkit { size_t _m_length, _m_position {0}; }; - class ZKREM("Deprecated") ReadBuffer final ZKINT : public Read { - public: - explicit ReadBuffer(phoenix::buffer* buf) : _m_buffer(buf) {} - - size_t read(void* buf, size_t len) noexcept override { - try { - _m_buffer->get(static_cast(buf), len); - return len; - } catch (phoenix::buffer_error const&) { - return 0; - } - } - - void seek(ssize_t off, Whence whence) noexcept override { - try { - switch (whence) { - case Whence::BEG: - _m_buffer->position(static_cast(off)); - break; - case Whence::CUR: - _m_buffer->skip(static_cast(off)); - break; - case Whence::END: - _m_buffer->position(_m_buffer->limit() + static_cast(off)); - break; - } - } catch (phoenix::buffer_error const&) {} - } - - [[nodiscard]] size_t tell() const noexcept override { - return _m_buffer->position(); - } - - [[nodiscard]] bool eof() const noexcept override { - return _m_buffer->position() >= _m_buffer->limit(); - } - - private: - phoenix::buffer* _m_buffer; - }; - class ReadVector final ZKINT : public ReadMemory { public: explicit ReadVector(std::vector vec) @@ -502,10 +460,6 @@ namespace zenkit { #endif } - std::unique_ptr Read::from(phoenix::buffer* buf) { - return std::make_unique(buf); - } - std::unique_ptr Write::to(std::filesystem::path const& path) { return std::make_unique(path); } diff --git a/src/Texture.cc b/src/Texture.cc index 1a57e2bc..bc5106cc 100644 --- a/src/Texture.cc +++ b/src/Texture.cc @@ -1,10 +1,8 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Texture.hh" #include "zenkit/Stream.hh" -#include "phoenix/phoenix.hh" - #include "squish.h" #include @@ -279,19 +277,6 @@ namespace zenkit { return _ztex_from_rgba(rgba.data(), width, height, into); } - Texture Texture::parse(phoenix::buffer& in) { - Texture tex; - - auto r = Read::from(&in); - tex.load(r.get()); - - return tex; - } - - Texture Texture::parse(phoenix::buffer&& in) { - return parse(in); - } - void Texture::load(Read* r) { if (r->read_string(4) != ZTEX_SIGNATURE) { throw ParserError {"texture", "invalid signature"}; diff --git a/src/Vfs.cc b/src/Vfs.cc index 287a47d1..216480c8 100644 --- a/src/Vfs.cc +++ b/src/Vfs.cc @@ -1,16 +1,14 @@ -// Copyright © 2023 GothicKit Contributors. +// Copyright © 2023-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/Vfs.hh" +#include "zenkit/Misc.hh" #include "Internal.hh" #include "zenkit/Error.hh" #include "zenkit/Stream.hh" -#include "phoenix/buffer.hh" - #include #include -#include #include #include #include @@ -20,43 +18,6 @@ namespace zenkit { static constexpr std::string_view VFS_DISK_SIGNATURE_G2 = "PSVDSC_V2.00\n\r\n\r"; static constexpr std::string_view VFS_DISK_SIGNATURE_VDFSTOOL = "PSVDSC_V2.00\x1A\x1A\x1A\x1A"; - class ZKINT RawBufferBacking final : public phoenix::buffer_backing { - public: - RawBufferBacking(std::byte const* bytes, uint64_t length) : _m_buffer(bytes), _m_size(length) {} - - [[nodiscard]] bool direct() const noexcept override { - return false; - } - - [[nodiscard]] bool readonly() const noexcept override { - return false; - } - - [[nodiscard]] uint64_t size() const noexcept override { - return _m_size; - } - - [[nodiscard]] std::byte const* array() const override { - return _m_buffer; - } - - void read(std::byte* buf, std::uint64_t size, std::uint64_t offset) const override { - if (this->readonly()) { - throw phoenix::buffer_readonly {}; - } - - if (offset + size > this->size()) { - throw phoenix::buffer_overflow {offset, size, "in backing"}; - } - - std::copy_n(_m_buffer + static_cast(offset), size, buf); - } - - private: - std::byte const* _m_buffer; - uint64_t _m_size; - }; - VfsBrokenDiskError::VfsBrokenDiskError(std::string const& signature) : Error("VFS disk signature not recognized: \"" + signature + "\"") {} @@ -84,22 +45,19 @@ namespace zenkit { } bool VfsNodeComparator::operator()(VfsNode const& a, VfsNode const& b) const noexcept { - return phoenix::icompare(a.name(), b.name()); + return icompare(a.name(), b.name()); } bool VfsNodeComparator::operator()(VfsNode const& a, std::string_view b) const noexcept { - return phoenix::icompare(a.name(), b); + return icompare(a.name(), b); } bool VfsNodeComparator::operator()(std::string_view a, VfsNode const& b) const noexcept { - return phoenix::icompare(a, b.name()); + return icompare(a, b.name()); } VfsNode::VfsNode(std::string_view name, time_t ts) : _m_name(name), _m_time(ts), _m_data(ChildContainer {}) {} - VfsNode::VfsNode(std::string_view name, phoenix::buffer dev, time_t ts) - : _m_name(name), _m_time(ts), _m_data(std::move(dev)) {} - VfsNode::VfsNode(std::string_view name, VfsFileDescriptor dev, time_t ts) : _m_name(name), _m_time(ts), _m_data(dev) {} @@ -120,7 +78,7 @@ namespace zenkit { name = trim_trailing_whitespace(name); auto it = children.find(name); - if (it == children.end() || !phoenix::iequals(it->name(), name)) return nullptr; + if (it == children.end() || !iequals(it->name(), name)) return nullptr; return &*it; } @@ -129,7 +87,7 @@ namespace zenkit { name = trim_trailing_whitespace(name); auto it = children.find(name); - if (it == children.end() || !phoenix::iequals(it->name(), name)) return nullptr; + if (it == children.end() || !iequals(it->name(), name)) return nullptr; return const_cast(&*it); } @@ -146,27 +104,13 @@ namespace zenkit { name = trim_trailing_whitespace(name); auto it = children.find(name); - if (it == children.end() || !phoenix::iequals(it->name(), name)) return false; + if (it == children.end() || !iequals(it->name(), name)) return false; children.erase(it); return true; } - phoenix::buffer VfsNode::open() const { - if (std::holds_alternative(_m_data)) { - return std::get(_m_data).duplicate(); - } - - auto fd = std::get(_m_data); - return phoenix::buffer {std::make_shared(fd.memory, fd.size)}; - } - std::unique_ptr VfsNode::open_read() const { - if (std::holds_alternative(_m_data)) { - auto buf = std::get(_m_data); - return Read::from(buf.array(), buf.limit()); - } - auto fd = std::get(_m_data); return Read::from(fd.memory, fd.size); } @@ -175,10 +119,6 @@ namespace zenkit { return directory(name, -1); } - VfsNode VfsNode::file(std::string_view name, phoenix::buffer dev) { - return file(name, std::move(dev), -1); - } - VfsNode VfsNode::file(std::string_view name, VfsFileDescriptor dev) { return file(name, dev, -1); } @@ -187,18 +127,12 @@ namespace zenkit { return VfsNode(name, ts); } - VfsNode VfsNode::file(std::string_view name, phoenix::buffer dev, time_t ts) { - return VfsNode(name, std::move(dev), ts); - } - VfsNode VfsNode::file(std::string_view name, VfsFileDescriptor dev, std::time_t ts) { return VfsNode(name, dev, ts); } VfsNodeType VfsNode::type() const noexcept { - return (std::holds_alternative(_m_data), std::holds_alternative(_m_data)) - ? VfsNodeType::FILE - : VfsNodeType::DIRECTORY; + return std::holds_alternative(_m_data) ? VfsNodeType::FILE : VfsNodeType::DIRECTORY; } std::time_t VfsNode::time() const noexcept { @@ -396,13 +330,6 @@ namespace zenkit { return mktime(&t); } - void Vfs::mount_disk(phoenix::buffer buf, VfsOverwriteBehavior overwrite) { - auto mem = std::make_unique(buf.limit()); - memcpy(mem.get(), buf.array(), buf.limit()); - this->mount_disk(mem.get(), buf.limit(), overwrite); - _m_data.push_back(std::move(mem)); - } - void Vfs::mount_disk(Read* buf, VfsOverwriteBehavior overwrite) { buf->seek(0, Whence::END); auto size = buf->tell(); diff --git a/src/World.cc b/src/World.cc index ad047efd..26d8c5d4 100644 --- a/src/World.cc +++ b/src/World.cc @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/World.hh" #include "zenkit/Archive.hh" @@ -45,32 +45,6 @@ namespace zenkit { return GameVersion::GOTHIC_1; } - World World::parse(phoenix::buffer& buf, GameVersion version) { - World wld {}; - - auto r = Read::from(&buf); - wld.load(r.get(), version); - - return wld; - } - - World World::parse(phoenix::buffer&& buf, GameVersion version) { - return parse(buf, version); - } - - World World::parse(phoenix::buffer& buf) { - World wld {}; - - auto r = Read::from(&buf); - wld.load(r.get()); - - return wld; - } - - World World::parse(phoenix::buffer&& buf) { - return parse(buf); - } - void World::load(Read* r) { auto begin = r->tell(); auto version = determine_world_version(r); diff --git a/src/__legacy_buffer.cc b/src/__legacy_buffer.cc deleted file mode 100644 index 7733816b..00000000 --- a/src/__legacy_buffer.cc +++ /dev/null @@ -1,588 +0,0 @@ -// Copyright © 2022-2023 GothicKit Contributors. -// SPDX-License-Identifier: MIT -#include "phoenix/buffer.hh" -#include "zenkit/Mmap.hh" - -#include "Internal.hh" - -#include -#include -#include - -namespace phoenix { - namespace detail { - /// \brief A buffer backing which saves data on the heap. - class heap_backing : public buffer_backing { - public: - /// \brief Creates a new, empty heap buffer backing with the given size. - /// \param size The number of bytes in the backing. - explicit heap_backing(std::uint64_t size) : _m_readonly(false) { - _m_data.resize(size); - } - - /// \brief Creates a new heap buffer backing from the given vector. - /// \param buf The data to insert into the backing. - /// \param readonly Set to `false` to allow writing to the backing. - heap_backing(std::vector&& buf, bool readonly) - : _m_data(std::move(buf)), _m_readonly(readonly) {} - - [[nodiscard]] bool direct() const noexcept override { - return false; - } - - [[nodiscard]] bool readonly() const noexcept override { - return _m_readonly; - } - - [[nodiscard]] uint64_t size() const noexcept override { - return _m_data.size(); - } - - [[nodiscard]] std::byte const* array() const override { - return _m_data.data(); - } - - void read(std::byte* buf, std::uint64_t size, std::uint64_t offset) const override { - std::copy_n(_m_data.cbegin() + static_cast(offset), size, buf); - } - - void write([[maybe_unused]] std::byte const* buf, - [[maybe_unused]] std::uint64_t size, - [[maybe_unused]] std::uint64_t offset) override { - if (this->readonly()) { - throw buffer_readonly {}; - } - - if (offset + size > this->size()) { - throw buffer_overflow {offset, size, "in backing"}; - } - - std::copy_n(buf, size, const_cast(_m_data.data()) + static_cast(offset)); - } - - private: - std::vector _m_data; - bool _m_readonly; - }; - -#ifdef _ZK_WITH_MMAP - /// \brief A buffer backing for memory-mapped files. - class mmap_backing : public buffer_backing { - public: - /// \brief Creates a new memory-mapped buffer backing by mapping the file at the given path into memory - /// \param file The path of the file to map - explicit mmap_backing(std::filesystem::path const& file) : _m_data(file) {} - - [[nodiscard]] bool direct() const noexcept override { - return true; - } - - [[nodiscard]] bool readonly() const noexcept override { - return true; - } - - [[nodiscard]] uint64_t size() const noexcept override { - return _m_data.size(); - } - - [[nodiscard]] std::byte const* array() const noexcept override { - return _m_data.data(); - } - - void read(std::byte* buf, std::uint64_t size, std::uint64_t offset) const override { - std::copy_n(_m_data.data() + static_cast(offset), size, buf); - } - - void write([[maybe_unused]] std::byte const* buf, - [[maybe_unused]] std::uint64_t size, - [[maybe_unused]] std::uint64_t offset) override { - if (this->readonly()) { - throw buffer_readonly {}; - } - - if (offset + size > this->size()) { - throw buffer_overflow {offset, size, "in backing"}; - } - - std::copy_n(buf, size, const_cast(_m_data.data()) + static_cast(offset)); - } - - private: - zenkit::Mmap _m_data; - }; -#endif - } // namespace detail - - buffer_underflow::buffer_underflow(std::uint64_t off, std::uint64_t rsize) - : buffer_error("buffer underflow at byte " + std::to_string(off) + " while reading " + std::to_string(rsize) + - " additional bytes"), - byte(off), size(rsize), context(std::nullopt) {} - - buffer_underflow::buffer_underflow(std::uint64_t off, std::uint64_t rsize, std::string&& ctx) - : buffer_error("buffer underflow at byte " + std::to_string(off) + " while reading " + std::to_string(rsize) + - " additional bytes [context: " + ctx + "]"), - byte(off), size(rsize), context(std::move(ctx)) {} - - buffer_underflow::buffer_underflow(std::uint64_t off, std::string&& ctx) - : buffer_error("buffer underflow at byte " + std::to_string(off) + " [context: " + ctx + "]"), byte(off), - size(0), context(std::move(ctx)) {} - - buffer_overflow::buffer_overflow(std::uint64_t off, std::uint64_t wsize) - : buffer_error("buffer overflow at byte " + std::to_string(off) + " while writing " + std::to_string(wsize) + - " additional bytes"), - byte(off), size(wsize), context(std::nullopt) {} - - buffer_overflow::buffer_overflow(std::uint64_t off, std::uint64_t wsize, std::string&& ctx) - : buffer_error("buffer overflow at byte " + std::to_string(off) + " while writing " + std::to_string(wsize) + - " additional bytes [context: " + ctx + "]"), - byte(off), size(wsize), context(std::move(ctx)) {} - - std::unique_ptr buffer::_m_empty {}; - - buffer::buffer(std::shared_ptr backing) - : _m_backing(std::move(backing)), _m_backing_begin(0), _m_backing_end(_m_backing->size()), - _m_capacity(_m_backing->size()), _m_position(0) {} - - buffer::buffer(std::shared_ptr backing, std::uint64_t begin, std::uint64_t end) - : _m_backing(std::move(backing)), _m_backing_begin(begin), _m_backing_end(end), _m_capacity(end - begin), - _m_position(0) {} - - buffer::buffer(std::shared_ptr backing, - std::uint64_t begin, - std::uint64_t end, - std::uint64_t capacity, - std::uint64_t position, - std::optional mark) - : _m_backing(std::move(backing)), _m_backing_begin(begin), _m_backing_end(end), _m_capacity(capacity), - _m_position(position), _m_mark(mark) {} - - buffer buffer::allocate(std::uint64_t size) { - return buffer {std::make_shared(size)}; - } - - buffer buffer::of(std::vector&& buf, bool readonly) { - return buffer {std::make_shared(std::forward>(buf), readonly)}; - } - - buffer buffer::mmap(std::filesystem::path const& path, bool readonly) { - auto file_size = std::filesystem::file_size(path); - if (file_size == 0) return buffer::empty(); - - if (readonly) { -#ifdef _ZK_WITH_MMAP - return buffer {std::make_shared(path)}; -#else - std::vector data {}; - std::ifstream stream {path, std::ios::in | std::ios::ate | std::ios::binary}; - data.resize(static_cast(stream.tellg())); - stream.seekg(0); - stream.read(reinterpret_cast(data.data()), static_cast(data.size())); - - return buffer::of(std::move(data), true); -#endif - } - - throw error {"Unsupported operation!"}; - } - - buffer buffer::read(std::filesystem::path const& path, bool readonly) { - std::ifstream in {path, std::ios::binary | std::ios::ate | std::ios::in}; - std::vector data {static_cast(in.tellg())}; - - in.seekg(0); - in.read((char*) data.data(), static_cast(data.size())); - - return buffer::of(std::move(data), readonly); - } - - buffer buffer::empty() { - if (buffer::_m_empty == nullptr) { - // If we don't have an empty buffer yet, create one. - buffer::_m_empty = std::make_unique(buffer::allocate(0)); - } - - return buffer::_m_empty->duplicate(); - } - - void buffer::clear() noexcept { - _m_position = 0; - _m_backing_end = _m_backing_begin + _m_capacity; - _m_mark.reset(); - } - - buffer buffer::duplicate() const noexcept { - return buffer {_m_backing, _m_backing_begin, _m_backing_end, _m_capacity, _m_position, _m_mark}; - } - - void buffer::flip() noexcept { - _m_backing_end = _m_backing_begin + _m_position; - _m_position = 0; - _m_mark.reset(); - } - - void buffer::limit(std::uint64_t limit) { - if (limit > this->capacity()) { - throw buffer_underflow {limit, "setting limit"}; - } - - _m_position = std::min(limit, _m_position); - _m_backing_end = _m_backing_begin + limit; - - if (_m_mark && *_m_mark > limit) { - _m_mark.reset(); - } - } - - void buffer::position(std::uint64_t pos) { - if (pos > this->limit()) { - throw buffer_underflow {pos, "setting position"}; - } - - if (_m_mark && *_m_mark > pos) { - _m_mark.reset(); - } - - _m_position = pos; - } - - buffer buffer::slice() const noexcept { - return buffer {_m_backing, _m_backing_begin + _m_position, _m_backing_end}; - } - - buffer buffer::slice(std::uint64_t index, std::uint64_t size) const { - if (index + size > this->limit()) { - throw buffer_underflow {index, size, "slicing"}; - } - - return buffer {_m_backing, _m_backing_begin + index, _m_backing_begin + index + size}; - } - - void buffer::get(std::byte* buf, std::uint64_t size) { - if (this->remaining() < size) { - throw buffer_underflow {this->position(), size, "relative bulk get"}; - } - - _m_backing->read(buf, size, _m_backing_begin + _m_position); - _m_position += size; - } - - std::string buffer::get_string(std::uint64_t size) { - if (this->remaining() < size) { - throw buffer_overflow {position(), size, "relative string get"}; - } - - std::string tmp {}; - tmp.resize(size); - this->get((std::byte*) tmp.data(), size); - return tmp; - } - - std::string buffer::get_line(bool skip_whitespace) { - if (skip_whitespace) { - return this->get_line_and_ignore(" \f\n\r\t\v"); - } - - return this->get_line_and_ignore(""); - } - - std::string buffer::get_line_and_ignore(std::string_view whitespace) { - std::string tmp {}; - - // Fix for #70, avoid attempting to read bytes from a - // buffer which has reached its limit. - if (this->remaining() == 0) { - return ""; - } - - char c = this->get_char(); - while (c != '\n' && c != '\r' && c != '\0' && this->remaining() > 0) { - tmp.push_back(c); - c = this->get_char(); - } - - if (!whitespace.empty() && remaining() > 0) { - c = this->get_char(); - while (whitespace.find(c) != std::string_view::npos && remaining() > 0) { - c = this->get_char(); - } - - if (remaining() != 0) { - this->position(this->position() - 1); - } - } - - return tmp; - } - - std::string buffer::get_line_escaped(bool skip_whitespace) { - auto tmp = this->get_line(skip_whitespace); - - for (auto i = 0u; i < tmp.size(); ++i) { - if (tmp[i] == '\\') { - switch (tmp[i + 1]) { - case 'n': - tmp[i] = '\n'; - tmp.erase(i + 1, 1); - break; - case 't': - tmp[i] = '\t'; - tmp.erase(i + 1, 1); - break; - } - } - } - - return tmp; - } - - void buffer::put(std::byte const* buf, std::uint64_t size) { - if (this->remaining() < size) { - throw buffer_overflow {this->position(), size, "relative bulk put"}; - } - - _m_backing->write(buf, size, _m_backing_begin + _m_position); - _m_position += size; - } - - void buffer::put_string(std::string_view str) { - this->put((std::byte const*) str.data(), str.size()); - } - - void buffer::put_line(std::string_view str) { - put_string(str); - put_char('\n'); - } - - bool operator==(buffer const& self, buffer const& other) { - return &other == &self || - (other._m_backing == self._m_backing && other._m_backing_begin == self._m_backing_begin && - other._m_backing_end == self._m_backing_end && other._m_capacity == self._m_capacity && - other._m_position == self._m_position); - } - - std::uint8_t buffer::get() { - return _get_t(); - } - - char buffer::get_char() { - return _get_t(); - } - - std::int16_t buffer::get_short() { - return _get_t(); - } - - std::uint16_t buffer::get_ushort() { - return _get_t(); - } - - std::int32_t buffer::get_int() { - return _get_t(); - } - - std::uint32_t buffer::get_uint() { - return _get_t(); - } - - std::int64_t buffer::get_long() { - return _get_t(); - } - - std::uint64_t buffer::get_ulong() { - return _get_t(); - } - - float buffer::get_float() { - return _get_t(); - } - - double buffer::get_double() { - return _get_t(); - } - - glm::vec2 buffer::get_vec2() { - float content[2]; - this->get((std::byte*) content, sizeof(content)); - return {content[0], content[1]}; - } - - glm::vec3 buffer::get_vec3() { - float content[3]; - this->get((std::byte*) content, sizeof(content)); - return glm::vec3 {content[0], content[1], content[2]}; - } - - glm::mat3x3 buffer::get_mat3x3() { - float content[3 * 3]; - this->get((std::byte*) content, sizeof(content)); - return glm::transpose(glm::mat3x3 { - content[0], - content[1], - content[2], - content[3], - content[4], - content[5], - content[6], - content[7], - content[8], - }); - } - - glm::mat4x4 buffer::get_mat4x4() { - float content[4 * 4]; - this->get((std::byte*) content, sizeof(content)); - return glm::transpose(glm::mat4x4 { - content[0], - content[1], - content[2], - content[3], - content[4], - content[5], - content[6], - content[7], - content[8], - content[9], - content[10], - content[11], - content[12], - content[13], - content[14], - content[15], - }); - } - - glm::vec4 buffer::get_vec4() { - float content[4]; - this->get((std::byte*) content, sizeof(content)); - return glm::vec4 {content[0], content[1], content[2], content[3]}; - } - - void buffer::put(std::uint8_t const* buf, std::uint64_t size) { - this->put((std::byte const*) buf, size); - } - - void buffer::put(std::uint8_t value) { - _put_t(value); - } - - void buffer::put_char(char value) { - _put_t(value); - } - - void buffer::put_short(std::int16_t value) { - _put_t(value); - } - - void buffer::put_ushort(std::uint16_t value) { - _put_t(value); - } - - void buffer::put_int(std::int32_t value) { - _put_t(value); - } - - void buffer::put_uint(std::uint32_t value) { - _put_t(value); - } - - void buffer::put_long(std::int64_t value) { - _put_t(value); - } - - void buffer::put_ulong(std::uint64_t value) { - _put_t(value); - } - - void buffer::put_float(float value) { - _put_t(value); - } - - void buffer::put_double(double value) { - _put_t(value); - } - - void buffer::skip(std::uint64_t count) { - return this->position(this->position() + count); - } - - void buffer::rewind() { - _m_position = 0; - _m_mark.reset(); - } - - std::uint64_t buffer::remaining() const noexcept { - return this->limit() - this->position(); - } - - std::uint64_t buffer::capacity() const noexcept { - return _m_capacity; - } - - bool buffer::direct() const noexcept { - return _m_backing->direct(); - } - - bool buffer::readonly() const noexcept { - return _m_backing->readonly(); - } - - void buffer::reset() { - if (_m_mark) { - position(*_m_mark); - } - } - - void buffer::mark() noexcept { - _m_mark = position(); - } - - buffer buffer::extract(std::uint64_t size) { - auto sl = this->slice(position(), size); - _m_position += size; - return sl; - } - - std::byte const* buffer::array() const noexcept { - return _m_backing->array() + _m_backing_begin; - } - - void buffer::get(std::uint8_t* buf, std::uint64_t size) { - return this->get((std::byte*) buf, size); - } - - std::uint64_t buffer::position() const noexcept { - return _m_position; - } - - std::uint64_t buffer::limit() const noexcept { - return _m_backing_end - _m_backing_begin; - } - - template - void buffer::_put_t(T value) { - if (this->remaining() < sizeof(T)) { - throw buffer_overflow {this->position(), sizeof(T)}; - } - - _m_backing->write((std::byte*) &value, sizeof(T), _m_backing_begin + _m_position); - _m_position += sizeof(T); - } - - template - T buffer::_get_t(std::uint64_t pos) const { - if (pos + sizeof(T) > limit()) { - throw buffer_underflow {pos, sizeof(T)}; - } - - T tmp; - _m_backing->read((std::byte*) &tmp, sizeof(T), _m_backing_begin + pos); - return tmp; - } - - template - T buffer::_get_t() { - auto tmp = this->_get_t(this->position()); - _m_position += sizeof(T); - return tmp; - } -} // namespace phoenix diff --git a/src/addon/texcvt.cc b/src/addon/texcvt.cc index 52d237a7..8eab5d7f 100644 --- a/src/addon/texcvt.cc +++ b/src/addon/texcvt.cc @@ -1,10 +1,8 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/addon/texcvt.hh" #include "zenkit/Stream.hh" -#include "phoenix/buffer.hh" - #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ ((uint32_t) (uint8_t) (ch0) | ((uint32_t) (uint8_t) (ch1) << 8) | ((uint32_t) (uint8_t) (ch2) << 16) | \ ((uint32_t) (uint8_t) (ch3) << 24)) diff --git a/src/archive/ArchiveAscii.cc b/src/archive/ArchiveAscii.cc index 3df7d80d..244f1f67 100644 --- a/src/archive/ArchiveAscii.cc +++ b/src/archive/ArchiveAscii.cc @@ -1,8 +1,7 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "ArchiveAscii.hh" - -#include "phoenix/buffer.hh" +#include "zenkit/Error.hh" #include "../Internal.hh" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -217,31 +217,6 @@ namespace zenkit { return glm::transpose(v); } - phoenix::buffer ReadArchiveAscii::read_raw_bytes(uint32_t size) { - auto in = read_entry("raw"); - auto length = in.length() / 2; - - if (length < size) { - throw ParserError {"ReadArchive.Ascii", "not enough raw bytes to read!"}; - } - - if (length > size) { - ZKLOGW("ReadArchive.Ascii", "Reading %d bytes although %zu are actually available", size, length); - } - - std::vector out {}; - out.resize(length); - - auto beg_it = in.data(); - - for (std::byte& i : out) { - std::from_chars(beg_it + 0, beg_it + 2, reinterpret_cast(i), 16); - beg_it += 2; - } - - return phoenix::buffer::of(std::move(out)); - } - std::unique_ptr ReadArchiveAscii::read_raw(std::size_t size) { auto in = read_entry("raw"); auto length = in.length() / 2; diff --git a/src/archive/ArchiveAscii.hh b/src/archive/ArchiveAscii.hh index 40d80fbb..8b86b175 100644 --- a/src/archive/ArchiveAscii.hh +++ b/src/archive/ArchiveAscii.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Archive.hh" @@ -27,7 +27,6 @@ namespace zenkit { glm::vec2 read_vec2() override; AxisAlignedBoundingBox read_bbox() override; glm::mat3x3 read_mat3x3() override; - ZKREM("Deprecated") phoenix::buffer read_raw_bytes(uint32_t size) override; std::unique_ptr read_raw(std::size_t size) override; protected: diff --git a/src/archive/ArchiveBinary.cc b/src/archive/ArchiveBinary.cc index c5e3d87f..9d3d3d5b 100644 --- a/src/archive/ArchiveBinary.cc +++ b/src/archive/ArchiveBinary.cc @@ -1,9 +1,7 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "ArchiveBinary.hh" - -#include "phoenix/buffer.hh" -#include "phoenix/phoenix.hh" +#include "zenkit/Error.hh" #include @@ -107,12 +105,6 @@ namespace zenkit { return read->read_mat3(); } - phoenix::buffer ReadArchiveBinary::read_raw_bytes(uint32_t size) { - std::vector bytes(size, std::byte {}); - read->read(bytes.data(), bytes.size()); - return phoenix::buffer::of(std::move(bytes)); - } - std::unique_ptr ReadArchiveBinary::read_raw(std::size_t size) { std::vector bytes(size, std::byte {}); read->read(bytes.data(), bytes.size()); diff --git a/src/archive/ArchiveBinary.hh b/src/archive/ArchiveBinary.hh index 687f0f37..e6e74768 100644 --- a/src/archive/ArchiveBinary.hh +++ b/src/archive/ArchiveBinary.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Archive.hh" @@ -29,7 +29,6 @@ namespace zenkit { glm::vec2 read_vec2() override; AxisAlignedBoundingBox read_bbox() override; glm::mat3x3 read_mat3x3() override; - ZKREM("use ::read_raw") phoenix::buffer read_raw_bytes(uint32_t size) override; std::unique_ptr read_raw(std::size_t size) override; void skip_object(bool skip_current) override; diff --git a/src/archive/ArchiveBinsafe.cc b/src/archive/ArchiveBinsafe.cc index 64b41a30..a62f4326 100644 --- a/src/archive/ArchiveBinsafe.cc +++ b/src/archive/ArchiveBinsafe.cc @@ -1,8 +1,7 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "ArchiveBinsafe.hh" - -#include "phoenix/buffer.hh" +#include "zenkit/Error.hh" #include "../Internal.hh" @@ -205,22 +204,6 @@ namespace zenkit { return v; } - phoenix::buffer ReadArchiveBinsafe::read_raw_bytes(uint32_t size) { - auto length = ensure_entry_meta(); - - if (length < size) { - throw ParserError {"ReadArchive.Binsafe", "not enough raw bytes to read!"}; - } - - if (length > size) { - ZKLOGW("ReadArchive.Binsafe", "Reading %d bytes although %d are actually available", size, length); - } - - std::vector bytes(length, std::byte {}); - read->read(bytes.data(), length); - return phoenix::buffer::of(std::move(bytes)); - } - std::unique_ptr ReadArchiveBinsafe::read_raw(std::size_t size) { auto length = ensure_entry_meta(); diff --git a/src/archive/ArchiveBinsafe.hh b/src/archive/ArchiveBinsafe.hh index 3d366f9f..b9ed01d1 100644 --- a/src/archive/ArchiveBinsafe.hh +++ b/src/archive/ArchiveBinsafe.hh @@ -1,4 +1,4 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #pragma once #include "zenkit/Archive.hh" @@ -57,7 +57,6 @@ namespace zenkit { glm::vec2 read_vec2() override; AxisAlignedBoundingBox read_bbox() override; glm::mat3x3 read_mat3x3() override; - ZKREM("Deprecated") phoenix::buffer read_raw_bytes(uint32_t size) override; std::unique_ptr read_raw(std::size_t size) override; protected: diff --git a/src/world/WayNet.cc b/src/world/WayNet.cc index aa2cba84..0f8fd104 100644 --- a/src/world/WayNet.cc +++ b/src/world/WayNet.cc @@ -1,7 +1,8 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include "zenkit/world/WayNet.hh" #include "zenkit/Archive.hh" +#include "zenkit/Error.hh" #include "../Internal.hh" diff --git a/tests/TestArchive.cc b/tests/TestArchive.cc index 94f9fffb..a7c6bc3e 100644 --- a/tests/TestArchive.cc +++ b/tests/TestArchive.cc @@ -1,7 +1,8 @@ -// Copyright © 2021-2023 GothicKit Contributors. +// Copyright © 2021-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include #include +#include #include diff --git a/tests/TestModel.cc b/tests/TestModel.cc index e11a838f..876d1071 100644 --- a/tests/TestModel.cc +++ b/tests/TestModel.cc @@ -1,6 +1,5 @@ -// Copyright © 2022-2023 GothicKit Contributors. +// Copyright © 2022-2024 GothicKit Contributors. // SPDX-License-Identifier: MIT #include -#include // TODO: Stub