diff options
Diffstat (limited to 'src/core')
34 files changed, 277 insertions, 19 deletions
diff --git a/src/core/config/boolean.cc b/src/core/config/boolean.cc index 45d5a38..74c7b07 100644 --- a/src/core/config/boolean.cc +++ b/src/core/config/boolean.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: boolean.cc +// Description: Boolean config value + #include "core/pch.hh" #include "core/config/boolean.hh" diff --git a/src/core/config/boolean.hh b/src/core/config/boolean.hh index cfd8b0b..238b978 100644 --- a/src/core/config/boolean.hh +++ b/src/core/config/boolean.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: boolean.hh +// Description: Boolean config value + +#ifndef CORE_CONFIG_BOOLEAN_HH +#define CORE_CONFIG_BOOLEAN_HH #pragma once #include "core/config/ivalue.hh" @@ -23,3 +30,5 @@ public: static bool from_string(std::string_view value); }; } // namespace config + +#endif diff --git a/src/core/config/ivalue.hh b/src/core/config/ivalue.hh index 13e9a3a..088276a 100644 --- a/src/core/config/ivalue.hh +++ b/src/core/config/ivalue.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: ivalue.hh +// Description: Base config value interface + +#ifndef CORE_CONFIG_IVALUE_HH +#define CORE_CONFIG_IVALUE_HH #pragma once namespace config @@ -9,3 +16,5 @@ public: virtual std::string_view get(void) const = 0; }; } // namespace config + +#endif diff --git a/src/core/config/number.hh b/src/core/config/number.hh index 4f185e1..eb1f462 100644 --- a/src/core/config/number.hh +++ b/src/core/config/number.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: number.hh +// Description: Arithmetic config value + +#ifndef CORE_CONFIG_NUMBER_HH +#define CORE_CONFIG_NUMBER_HH #pragma once #include "core/config/ivalue.hh" @@ -128,3 +135,5 @@ inline void config::Number<T>::set_limits(T min_value, T max_value) m_value = std::clamp(m_value, m_min_value, m_max_value); m_string = std::to_string(m_value); } + +#endif diff --git a/src/core/config/string.cc b/src/core/config/string.cc index 198b448..e5820f6 100644 --- a/src/core/config/string.cc +++ b/src/core/config/string.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: string.cc +// Description: String config value + #include "core/pch.hh" #include "core/config/string.hh" diff --git a/src/core/config/string.hh b/src/core/config/string.hh index 8fd3901..faecb67 100644 --- a/src/core/config/string.hh +++ b/src/core/config/string.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: string.hh +// Description: String config value + +#ifndef CORE_CONFIG_STRING_HH +#define CORE_CONFIG_STRING_HH #pragma once #include "core/config/ivalue.hh" @@ -29,3 +36,5 @@ constexpr const char* config::String::c_str(void) const noexcept { return m_value.c_str(); } + +#endif diff --git a/src/core/io/buffer.cc b/src/core/io/buffer.cc index d0fda49..dffd9bc 100644 --- a/src/core/io/buffer.cc +++ b/src/core/io/buffer.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: buffer.cc +// Description: QDataStream-esque buffer + #include "core/pch.hh" #include "core/io/buffer.hh" diff --git a/src/core/io/buffer.hh b/src/core/io/buffer.hh index 450a86f..100a933 100644 --- a/src/core/io/buffer.hh +++ b/src/core/io/buffer.hh @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: buffer.hh +// Description: QDataStream-esque buffer + +#ifndef CORE_IO_BUFFER_HH +#define CORE_IO_BUFFER_HH +#pragma once + class ReadBuffer final { public: ReadBuffer(void) = default; @@ -80,3 +89,5 @@ WriteBuffer& WriteBuffer::operator<<(const T value) write<T>(value); return *this; } + +#endif diff --git a/src/core/io/cmdline.cc b/src/core/io/cmdline.cc index d206cb8..0d1206a 100644 --- a/src/core/io/cmdline.cc +++ b/src/core/io/cmdline.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: cmdline.cc +// Description: Command-line arguments parser + #include "core/pch.hh" #include "core/io/cmdline.hh" diff --git a/src/core/io/cmdline.hh b/src/core/io/cmdline.hh index c0d6db2..452072f 100644 --- a/src/core/io/cmdline.hh +++ b/src/core/io/cmdline.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: cmdline.hh +// Description: Command-line arguments parser + +#ifndef CORE_IO_CMDLINE_HH +#define CORE_IO_CMDLINE_HH #pragma once namespace cmdline @@ -9,3 +16,5 @@ std::string_view get(std::string_view option, std::string_view fallback = ""); const char* get_cstr(std::string_view option, const char* fallback = nullptr); bool contains(std::string_view option); } // namespace cmdline + +#endif diff --git a/src/core/io/config_map.cc b/src/core/io/config_map.cc index 8634fd6..93fab2b 100644 --- a/src/core/io/config_map.cc +++ b/src/core/io/config_map.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: config_map.cc +// Description: Config parser + #include "core/pch.hh" #include "core/io/config_map.hh" diff --git a/src/core/io/config_map.hh b/src/core/io/config_map.hh index 898103b..2e3f18f 100644 --- a/src/core/io/config_map.hh +++ b/src/core/io/config_map.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: config_map.hh +// Description: Config parser + +#ifndef CORE_IO_CONFIG_MAP_HH +#define CORE_IO_CONFIG_MAP_HH #pragma once namespace config @@ -24,3 +31,5 @@ public: private: std::unordered_map<std::string, config::IValue*> m_values; }; + +#endif diff --git a/src/core/io/physfs.cc b/src/core/io/physfs.cc index b9fe91e..04aaf64 100644 --- a/src/core/io/physfs.cc +++ b/src/core/io/physfs.cc @@ -1,13 +1,18 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: physfs.cc +// Description: PhysFS utilities + #include "core/pch.hh" #include "core/io/physfs.hh" -bool read_file(std::string_view path, std::vector<std::byte>& buffer) +bool physfs::read_file(std::string_view path, std::vector<std::byte>& buffer) { auto file = PHYSFS_openRead(std::string(path).c_str()); if(file == nullptr) { - spdlog::error("physfs: {}: {}", path, physfs_error()); + spdlog::error("physfs: {}: {}", path, physfs::last_error()); return false; } @@ -20,12 +25,12 @@ bool read_file(std::string_view path, std::vector<std::byte>& buffer) return true; } -bool read_file(std::string_view path, std::string& buffer) +bool physfs::read_file(std::string_view path, std::string& buffer) { auto file = PHYSFS_openRead(std::string(path).c_str()); if(file == nullptr) { - spdlog::error("physfs: {}: {}", path, physfs_error()); + spdlog::error("physfs: {}: {}", path, physfs::last_error()); return false; } @@ -38,12 +43,12 @@ bool read_file(std::string_view path, std::string& buffer) return true; } -bool write_file(std::string_view path, const std::vector<std::byte>& buffer) +bool physfs::write_file(std::string_view path, const std::vector<std::byte>& buffer) { auto file = PHYSFS_openWrite(std::string(path).c_str()); if(file == nullptr) { - spdlog::error("physfs: {}: {}", path, physfs_error()); + spdlog::error("physfs: {}: {}", path, physfs::last_error()); return false; } @@ -53,12 +58,12 @@ bool write_file(std::string_view path, const std::vector<std::byte>& buffer) return true; } -bool write_file(std::string_view path, const std::string& buffer) +bool physfs::write_file(std::string_view path, const std::string& buffer) { auto file = PHYSFS_openWrite(std::string(path).c_str()); if(file == nullptr) { - spdlog::error("physfs: {}: {}", path, physfs_error()); + spdlog::error("physfs: {}: {}", path, physfs::last_error()); return false; } @@ -68,7 +73,7 @@ bool write_file(std::string_view path, const std::string& buffer) return true; } -std::string_view physfs_error(void) +std::string_view physfs::last_error(void) { auto error_code = PHYSFS_getLastErrorCode(); auto error_string = PHYSFS_getErrorByCode(error_code); diff --git a/src/core/io/physfs.hh b/src/core/io/physfs.hh index 88f97de..8cf84be 100644 --- a/src/core/io/physfs.hh +++ b/src/core/io/physfs.hh @@ -1,8 +1,23 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: physfs.hh +// Description: PhysFS utilities + +#ifndef CORE_IO_PHYSFS_HH +#define CORE_IO_PHYSFS_HH #pragma once +namespace physfs +{ bool read_file(std::string_view path, std::vector<std::byte>& buffer); bool read_file(std::string_view path, std::string& buffer); bool write_file(std::string_view path, const std::vector<std::byte>& buffer); bool write_file(std::string_view path, const std::string& buffer); +} // namespace physfs + +namespace physfs +{ +std::string_view last_error(void); +} // namespace physfs -std::string_view physfs_error(void); +#endif diff --git a/src/core/math/aabb.hh b/src/core/math/aabb.hh index f3eb7bd..79f814a 100644 --- a/src/core/math/aabb.hh +++ b/src/core/math/aabb.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: aabb.hh +// Description: Axis-aligned bounding box + +#ifndef CORE_MATH_AABB_HH +#define CORE_MATH_AABB_HH #pragma once #include "core/math/concepts.hh" @@ -109,3 +116,5 @@ constexpr math::AABB<T> math::AABB<T>::push(const vector_type& vector) const result.max = max + vector; return result; } + +#endif diff --git a/src/core/math/angles.hh b/src/core/math/angles.hh index 174f320..b339323 100644 --- a/src/core/math/angles.hh +++ b/src/core/math/angles.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: angles.hh +// Description: Angle utilities + +#ifndef CORE_MATH_ANGLES_HH +#define CORE_MATH_ANGLES_HH #pragma once #include "core/math/constexpr.hh" @@ -101,3 +108,5 @@ inline void math::vectors(const glm::fvec3& angles, glm::fvec3* forward, glm::fv up->z = nsv.x * ncv.y * pcv.z + psv.y * psv.z; } } + +#endif diff --git a/src/core/math/concepts.hh b/src/core/math/concepts.hh index 6ad5cb7..5d1ef7d 100644 --- a/src/core/math/concepts.hh +++ b/src/core/math/concepts.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: concepts.hh +// Description: C++20 concepts that should be in standard library but are not + +#ifndef CORE_MATH_CONCEPTS_HH +#define CORE_MATH_CONCEPTS_HH #pragma once namespace math @@ -9,3 +16,5 @@ concept signed_arithmetic = std::is_arithmetic_v<type> && std::is_signed_v<type> template<typename type> concept unsigned_arithmetic = std::is_arithmetic_v<type> && std::is_unsigned_v<type>; } // namespace math + +#endif diff --git a/src/core/math/constexpr.hh b/src/core/math/constexpr.hh index 4158803..7aba4d2 100644 --- a/src/core/math/constexpr.hh +++ b/src/core/math/constexpr.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: constexpr.hh +// Description: Compile-time expressions + +#ifndef CORE_MATH_CONSTEXPR_HH +#define CORE_MATH_CONSTEXPR_HH #pragma once #include "core/math/concepts.hh" @@ -70,3 +77,5 @@ constexpr scalar math::radians(const scalar x) { return static_cast<scalar>(static_cast<double>(x) * M_PI / 180.0); } + +#endif diff --git a/src/core/math/crc64.cc b/src/core/math/crc64.cc index 99a4b20..ce1e1db 100644 --- a/src/core/math/crc64.cc +++ b/src/core/math/crc64.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: crc64.cc +// Description: Client-server synchronized CRC64 + #include "core/pch.hh" #include "core/math/crc64.hh" diff --git a/src/core/math/crc64.hh b/src/core/math/crc64.hh index 3ece0df..f593dc9 100644 --- a/src/core/math/crc64.hh +++ b/src/core/math/crc64.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: crc64.hh +// Description: Client-server synchronized CRC64 + +#ifndef CORE_MATH_CRC64_HH +#define CORE_MATH_CRC64_HH #pragma once namespace math @@ -7,3 +14,5 @@ std::uint64_t crc64(const std::vector<std::byte>& buffer, std::uint64_t combine std::uint64_t crc64(const std::string& buffer, std::uint64_t combine = UINT64_C(0)); std::uint64_t crc64(std::string_view buffer, std::uint64_t combine = UINT64_C(0)); } // namespace math + +#endif diff --git a/src/core/math/vectors.hh b/src/core/math/vectors.hh index bc11dd0..2934bb6 100644 --- a/src/core/math/vectors.hh +++ b/src/core/math/vectors.hh @@ -1,11 +1,14 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: vectors.hh +// Description: because NO ONE would POSSIBLY need integer-based distance calculations in a VOXEL game + +#ifndef CORE_MATH_VECTORS_HH +#define CORE_MATH_VECTORS_HH #pragma once #include "core/math/concepts.hh" -// core/vectors.hh - because NO ONE would POSSIBLY -// need integer-based distance calculations in a -// game about voxels. That would be INSANE! :D - namespace math { template<math::arithmetic T> @@ -41,3 +44,5 @@ constexpr static inline const T math::distance2(const glm::vec<3, T>& vector_a, { return math::length2(vector_a - vector_b); } + +#endif diff --git a/src/core/pch.hh b/src/core/pch.hh index 17417a5..9a99be7 100644 --- a/src/core/pch.hh +++ b/src/core/pch.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: pch.hh +// Description: Precompiled header + +#ifndef CORE_PCH_HH +#define CORE_PCH_HH #pragma once #include <cinttypes> @@ -47,3 +54,5 @@ #include <stb_image.h> #include <stb_image_write.h> + +#endif diff --git a/src/core/resource/image.cc b/src/core/resource/image.cc index 6a2109e..aded098 100644 --- a/src/core/resource/image.cc +++ b/src/core/resource/image.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: image.cc +// Description: Image resource + #include "core/pch.hh" #include "core/resource/image.hh" @@ -31,18 +36,18 @@ static const void* image_load_func(const char* name, std::uint32_t flags) callbacks.skip = &stbi_physfs_skip; callbacks.eof = &stbi_physfs_eof; - stbi_set_flip_vertically_on_load(bool(flags & IMAGE_LOAD_FLIP)); + stbi_set_flip_vertically_on_load(bool(flags & IMGFLAG_FLIP)); auto file = PHYSFS_openRead(name); if(file == nullptr) { - spdlog::error("image: {}: {}", name, physfs_error()); + spdlog::error("image: {}: {}", name, physfs::last_error()); return nullptr; } int desired_channels; - if(flags & IMAGE_LOAD_GRAY) { + if(flags & IMGFLAG_GRAY) { desired_channels = STBI_grey; } else { diff --git a/src/core/resource/image.hh b/src/core/resource/image.hh index 575591f..4f93da6 100644 --- a/src/core/resource/image.hh +++ b/src/core/resource/image.hh @@ -1,7 +1,14 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: image.hh +// Description: Image resource + +#ifndef CORE_RESOURCE_IMAGE_HH +#define CORE_RESOURCE_IMAGE_HH #pragma once -constexpr static unsigned int IMAGE_LOAD_GRAY = 0x0001U; -constexpr static unsigned int IMAGE_LOAD_FLIP = 0x0002U; +constexpr static unsigned int IMGFLAG_GRAY = 0x0001U; +constexpr static unsigned int IMGFLAG_FLIP = 0x0002U; struct Image final { static void register_resource(void); @@ -9,3 +16,5 @@ struct Image final { stbi_uc* pixels; glm::ivec2 size; }; + +#endif diff --git a/src/core/resource/resource.cc b/src/core/resource/resource.cc index 926dfc5..6a9539f 100644 --- a/src/core/resource/resource.cc +++ b/src/core/resource/resource.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: resource.cc +// Description: Resource management + #include "core/pch.hh" #include "core/resource/resource.hh" diff --git a/src/core/resource/resource.hh b/src/core/resource/resource.hh index 105c7ff..e2a5659 100644 --- a/src/core/resource/resource.hh +++ b/src/core/resource/resource.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: resource.hh +// Description: Resource management + +#ifndef CORE_RESOURCE_RESOURCE_HH +#define CORE_RESOURCE_RESOURCE_HH #pragma once template<typename T> @@ -51,3 +58,5 @@ resource_ptr<T> resource::find(std::string_view name) auto result = resource::detail::find_resource(typeid(T), name); return std::reinterpret_pointer_cast<const T>(result); } + +#endif diff --git a/src/core/threading.cc b/src/core/threading.cc index a1ae305..1e469ad 100644 --- a/src/core/threading.cc +++ b/src/core/threading.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: threading.cc +// Description: Thread pool wrapper + #include "core/pch.hh" #include "core/threading.hh" diff --git a/src/core/threading.hh b/src/core/threading.hh index 14f17f8..ea4e11b 100644 --- a/src/core/threading.hh +++ b/src/core/threading.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: threading.hh +// Description: Thread pool wrapper + +#ifndef CORE_THREADING_HH +#define CORE_THREADING_HH #pragma once enum class task_status : unsigned int { @@ -44,3 +51,5 @@ inline void threading::submit(AT&&... args) { threading::detail::submit_new(new T(args...)); } + +#endif diff --git a/src/core/utils/epoch.cc b/src/core/utils/epoch.cc index 36bdb79..9d66399 100644 --- a/src/core/utils/epoch.cc +++ b/src/core/utils/epoch.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: epoch.cc +// Description: UNIX time utilities + #include "core/pch.hh" #include "core/utils/epoch.hh" diff --git a/src/core/utils/epoch.hh b/src/core/utils/epoch.hh index 4bf5460..5210e22 100644 --- a/src/core/utils/epoch.hh +++ b/src/core/utils/epoch.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: epoch.hh +// Description: UNIX time utilities + +#ifndef CORE_UTILS_EPOCH_HH +#define CORE_UTILS_EPOCH_HH #pragma once namespace utils @@ -13,3 +20,5 @@ std::int64_t signed_unix_seconds(void); std::int64_t signed_unix_milliseconds(void); std::int64_t signed_unix_microseconds(void); } // namespace utils + +#endif diff --git a/src/core/utils/string.cc b/src/core/utils/string.cc index dd3d567..154b04b 100644 --- a/src/core/utils/string.cc +++ b/src/core/utils/string.cc @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: string.cc +// Description: String utilities + #include "core/pch.hh" #include "core/utils/string.hh" diff --git a/src/core/utils/string.hh b/src/core/utils/string.hh index 827c3ca..36c83ce 100644 --- a/src/core/utils/string.hh +++ b/src/core/utils/string.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: string.hh +// Description: String utilities + +#ifndef CORE_UTILS_STRING_HH +#define CORE_UTILS_STRING_HH #pragma once namespace utils @@ -15,3 +22,5 @@ namespace utils { std::string trim_whitespace(const std::string& string); } // namespace utils + +#endif diff --git a/src/core/version.cc.in b/src/core/version.cc.in index 5424a73..d791149 100644 --- a/src/core/version.cc.in +++ b/src/core/version.cc.in @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: version.cc.in +// Description: Version template + #include "core/pch.hh" #include "core/version.hh" diff --git a/src/core/version.hh b/src/core/version.hh index c033a3e..d040fa5 100644 --- a/src/core/version.hh +++ b/src/core/version.hh @@ -1,3 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: version.hh +// Description: Version information + +#ifndef CORE_VERSION_HH +#define CORE_VERSION_HH #pragma once namespace version @@ -18,3 +25,5 @@ namespace version { extern const std::string_view full; } // namespace version + +#endif |
