summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-12-26 14:50:33 +0500
committeruntodesu <kirill@untode.su>2025-12-26 14:50:33 +0500
commit6c2abde5c99a236453b795abaa6d7d70105e31f7 (patch)
treef085049b9615a7d03cca5de40adb6529d6c13e11 /src/core
parentf40d09cb8f712e87691af4912f3630d92d692779 (diff)
downloadvoxelius-6c2abde5c99a236453b795abaa6d7d70105e31f7.tar.bz2
voxelius-6c2abde5c99a236453b795abaa6d7d70105e31f7.zip
Just a big Ctrl+H refactoring
Diffstat (limited to 'src/core')
-rw-r--r--src/core/io/buffer.cc80
-rw-r--r--src/core/io/buffer.hh14
-rw-r--r--src/core/io/cmdline.cc12
-rw-r--r--src/core/io/cmdline.hh4
-rw-r--r--src/core/io/config_map.cc16
-rw-r--r--src/core/io/config_map.hh3
-rw-r--r--src/core/io/physfs.cc10
-rw-r--r--src/core/io/physfs.hh6
-rw-r--r--src/core/resource/image.cc2
-rw-r--r--src/core/threading.cc2
-rw-r--r--src/core/version.cc6
11 files changed, 70 insertions, 85 deletions
diff --git a/src/core/io/buffer.cc b/src/core/io/buffer.cc
index 0f781a0..d0fda49 100644
--- a/src/core/io/buffer.cc
+++ b/src/core/io/buffer.cc
@@ -4,43 +4,43 @@
#include "core/math/constexpr.hh"
-io::ReadBuffer::ReadBuffer(const ReadBuffer& other)
+ReadBuffer::ReadBuffer(const ReadBuffer& other)
{
reset(other.data(), other.size());
}
-io::ReadBuffer::ReadBuffer(const void* data, std::size_t size)
+ReadBuffer::ReadBuffer(const void* data, std::size_t size)
{
assert(data);
reset(data, size);
}
-io::ReadBuffer::ReadBuffer(const ENetPacket* packet)
+ReadBuffer::ReadBuffer(const ENetPacket* packet)
{
assert(packet);
reset(packet);
}
-io::ReadBuffer::ReadBuffer(PHYSFS_File* file)
+ReadBuffer::ReadBuffer(PHYSFS_File* file)
{
assert(file);
reset(file);
}
-std::size_t io::ReadBuffer::size(void) const
+std::size_t ReadBuffer::size(void) const
{
return m_vector.size();
}
-const std::byte* io::ReadBuffer::data(void) const
+const std::byte* ReadBuffer::data(void) const
{
return m_vector.data();
}
-void io::ReadBuffer::reset(const void* data, std::size_t size)
+void ReadBuffer::reset(const void* data, std::size_t size)
{
assert(data);
@@ -49,7 +49,7 @@ void io::ReadBuffer::reset(const void* data, std::size_t size)
m_position = 0U;
}
-void io::ReadBuffer::reset(const ENetPacket* packet)
+void ReadBuffer::reset(const ENetPacket* packet)
{
assert(packet);
@@ -58,7 +58,7 @@ void io::ReadBuffer::reset(const ENetPacket* packet)
m_position = 0;
}
-void io::ReadBuffer::reset(PHYSFS_File* file)
+void ReadBuffer::reset(PHYSFS_File* file)
{
assert(file);
@@ -70,7 +70,7 @@ void io::ReadBuffer::reset(PHYSFS_File* file)
}
template<>
-std::byte io::ReadBuffer::read<std::byte>(void)
+std::byte ReadBuffer::read<std::byte>(void)
{
if(m_position < m_vector.size()) {
auto result = m_vector[m_position];
@@ -83,7 +83,7 @@ std::byte io::ReadBuffer::read<std::byte>(void)
}
template<>
-std::uint8_t io::ReadBuffer::read<std::uint8_t>(void)
+std::uint8_t ReadBuffer::read<std::uint8_t>(void)
{
if((m_position + 1U) <= m_vector.size()) {
auto result = static_cast<std::uint8_t>(m_vector[m_position]);
@@ -96,7 +96,7 @@ std::uint8_t io::ReadBuffer::read<std::uint8_t>(void)
}
template<>
-std::uint16_t io::ReadBuffer::read<std::uint16_t>(void)
+std::uint16_t ReadBuffer::read<std::uint16_t>(void)
{
if((m_position + 2U) <= m_vector.size()) {
auto result = UINT16_C(0x0000);
@@ -111,7 +111,7 @@ std::uint16_t io::ReadBuffer::read<std::uint16_t>(void)
}
template<>
-std::uint32_t io::ReadBuffer::read<std::uint32_t>(void)
+std::uint32_t ReadBuffer::read<std::uint32_t>(void)
{
if((m_position + 4U) <= m_vector.size()) {
auto result = UINT32_C(0x00000000);
@@ -128,7 +128,7 @@ std::uint32_t io::ReadBuffer::read<std::uint32_t>(void)
}
template<>
-std::uint64_t io::ReadBuffer::read<std::uint64_t>(void)
+std::uint64_t ReadBuffer::read<std::uint64_t>(void)
{
if((m_position + 8U) <= m_vector.size()) {
auto result = UINT64_C(0x0000000000000000);
@@ -149,37 +149,37 @@ std::uint64_t io::ReadBuffer::read<std::uint64_t>(void)
}
template<>
-float io::ReadBuffer::read<float>(void)
+float ReadBuffer::read<float>(void)
{
return std::bit_cast<float>(read<std::uint32_t>());
}
template<>
-std::int8_t io::ReadBuffer::read<std::int8_t>(void)
+std::int8_t ReadBuffer::read<std::int8_t>(void)
{
return std::bit_cast<std::int8_t>(read<std::uint8_t>());
}
template<>
-std::int16_t io::ReadBuffer::read<std::int16_t>(void)
+std::int16_t ReadBuffer::read<std::int16_t>(void)
{
return std::bit_cast<std::int16_t>(read<std::uint16_t>());
}
template<>
-std::int32_t io::ReadBuffer::read<std::int32_t>(void)
+std::int32_t ReadBuffer::read<std::int32_t>(void)
{
return std::bit_cast<std::int32_t>(read<std::uint32_t>());
}
template<>
-std::int64_t io::ReadBuffer::read<std::int64_t>(void)
+std::int64_t ReadBuffer::read<std::int64_t>(void)
{
return std::bit_cast<std::int64_t>(read<std::uint64_t>());
}
template<>
-std::string io::ReadBuffer::read<std::string>(void)
+std::string ReadBuffer::read<std::string>(void)
{
std::string result;
result.resize(read<std::uint16_t>());
@@ -195,7 +195,7 @@ std::string io::ReadBuffer::read<std::string>(void)
return result;
}
-void io::ReadBuffer::read(void* buffer, std::size_t size)
+void ReadBuffer::read(void* buffer, std::size_t size)
{
auto bytes = reinterpret_cast<std::byte*>(buffer);
auto amount_to_read = std::min(size, m_vector.size() - m_position);
@@ -207,32 +207,32 @@ void io::ReadBuffer::read(void* buffer, std::size_t size)
m_position += size;
}
-io::WriteBuffer::WriteBuffer(const WriteBuffer& other)
+WriteBuffer::WriteBuffer(const WriteBuffer& other)
{
m_vector = other.m_vector;
}
-std::size_t io::WriteBuffer::size(void) const
+std::size_t WriteBuffer::size(void) const
{
return m_vector.size();
}
-const std::byte* io::WriteBuffer::data(void) const
+const std::byte* WriteBuffer::data(void) const
{
return m_vector.data();
}
-void io::WriteBuffer::reset(void)
+void WriteBuffer::reset(void)
{
m_vector.clear();
}
-void io::WriteBuffer::write(const WriteBuffer& other)
+void WriteBuffer::write(const WriteBuffer& other)
{
m_vector.insert(m_vector.end(), other.m_vector.begin(), other.m_vector.end());
}
-void io::WriteBuffer::write(const void* data, std::size_t size)
+void WriteBuffer::write(const void* data, std::size_t size)
{
assert(data);
@@ -241,26 +241,26 @@ void io::WriteBuffer::write(const void* data, std::size_t size)
}
template<>
-void io::WriteBuffer::write<std::byte>(const std::byte value)
+void WriteBuffer::write<std::byte>(const std::byte value)
{
m_vector.push_back(value);
}
template<>
-void io::WriteBuffer::write<std::uint8_t>(const std::uint8_t value)
+void WriteBuffer::write<std::uint8_t>(const std::uint8_t value)
{
m_vector.push_back(static_cast<std::byte>(value));
}
template<>
-void io::WriteBuffer::write<std::uint16_t>(const std::uint16_t value)
+void WriteBuffer::write<std::uint16_t>(const std::uint16_t value)
{
m_vector.push_back(static_cast<std::byte>(UINT16_C(0xFF) & ((value & UINT16_C(0xFF00)) >> 8U)));
m_vector.push_back(static_cast<std::byte>(UINT16_C(0xFF) & ((value & UINT16_C(0x00FF)) >> 0U)));
}
template<>
-void io::WriteBuffer::write<std::uint32_t>(const std::uint32_t value)
+void WriteBuffer::write<std::uint32_t>(const std::uint32_t value)
{
m_vector.push_back(static_cast<std::byte>(UINT32_C(0xFF) & ((value & UINT32_C(0xFF000000)) >> 24U)));
m_vector.push_back(static_cast<std::byte>(UINT32_C(0xFF) & ((value & UINT32_C(0x00FF0000)) >> 16U)));
@@ -269,7 +269,7 @@ void io::WriteBuffer::write<std::uint32_t>(const std::uint32_t value)
}
template<>
-void io::WriteBuffer::write<std::uint64_t>(const std::uint64_t value)
+void WriteBuffer::write<std::uint64_t>(const std::uint64_t value)
{
m_vector.push_back(static_cast<std::byte>(UINT64_C(0xFF) & ((value & UINT64_C(0xFF00000000000000)) >> 56U)));
m_vector.push_back(static_cast<std::byte>(UINT64_C(0xFF) & ((value & UINT64_C(0x00FF000000000000)) >> 48U)));
@@ -282,37 +282,37 @@ void io::WriteBuffer::write<std::uint64_t>(const std::uint64_t value)
}
template<>
-void io::WriteBuffer::write(const float value)
+void WriteBuffer::write(const float value)
{
write(std::bit_cast<std::uint32_t>(value));
}
template<>
-void io::WriteBuffer::write(const std::int8_t value)
+void WriteBuffer::write(const std::int8_t value)
{
write(std::bit_cast<std::uint8_t>(value));
}
template<>
-void io::WriteBuffer::write(const std::int16_t value)
+void WriteBuffer::write(const std::int16_t value)
{
write(std::bit_cast<std::uint16_t>(value));
}
template<>
-void io::WriteBuffer::write(const std::int32_t value)
+void WriteBuffer::write(const std::int32_t value)
{
write(std::bit_cast<std::uint32_t>(value));
}
template<>
-void io::WriteBuffer::write(const std::int64_t value)
+void WriteBuffer::write(const std::int64_t value)
{
write(std::bit_cast<std::uint64_t>(value));
}
template<>
-void io::WriteBuffer::write<std::string_view>(const std::string_view value)
+void WriteBuffer::write<std::string_view>(const std::string_view value)
{
write<std::uint16_t>(static_cast<std::uint16_t>(value.size()));
@@ -321,7 +321,7 @@ void io::WriteBuffer::write<std::string_view>(const std::string_view value)
}
}
-PHYSFS_File* io::WriteBuffer::to_file(const std::string& path, bool append) const
+PHYSFS_File* WriteBuffer::to_file(const std::string& path, bool append) const
{
PHYSFS_File* file = nullptr;
@@ -339,7 +339,7 @@ PHYSFS_File* io::WriteBuffer::to_file(const std::string& path, bool append) cons
return file;
}
-ENetPacket* io::WriteBuffer::to_packet(enet_uint32 flags) const
+ENetPacket* WriteBuffer::to_packet(enet_uint32 flags) const
{
return enet_packet_create(m_vector.data(), m_vector.size(), flags);
}
diff --git a/src/core/io/buffer.hh b/src/core/io/buffer.hh
index 96a37b1..450a86f 100644
--- a/src/core/io/buffer.hh
+++ b/src/core/io/buffer.hh
@@ -1,5 +1,3 @@
-namespace io
-{
class ReadBuffer final {
public:
ReadBuffer(void) = default;
@@ -31,10 +29,7 @@ private:
std::vector<std::byte> m_vector;
std::size_t m_position;
};
-} // namespace io
-namespace io
-{
class WriteBuffer final {
public:
WriteBuffer(void) = default;
@@ -61,27 +56,26 @@ public:
private:
std::vector<std::byte> m_vector;
};
-} // namespace io
-constexpr void io::ReadBuffer::rewind(void)
+constexpr void ReadBuffer::rewind(void)
{
m_position = 0;
}
-constexpr bool io::ReadBuffer::is_ended(void) const
+constexpr bool ReadBuffer::is_ended(void) const
{
return m_position >= m_vector.size();
}
template<typename T>
-io::ReadBuffer& io::ReadBuffer::operator>>(T& value)
+ReadBuffer& ReadBuffer::operator>>(T& value)
{
value = read<T>();
return *this;
}
template<typename T>
-io::WriteBuffer& io::WriteBuffer::operator<<(const T value)
+WriteBuffer& WriteBuffer::operator<<(const T value)
{
write<T>(value);
return *this;
diff --git a/src/core/io/cmdline.cc b/src/core/io/cmdline.cc
index 7a00f37..d206cb8 100644
--- a/src/core/io/cmdline.cc
+++ b/src/core/io/cmdline.cc
@@ -27,7 +27,7 @@ static inline std::string get_option(const std::string& string)
return std::string(string.cbegin() + i, string.cend());
}
-void io::cmdline::create(int argc, char** argv)
+void cmdline::create(int argc, char** argv)
{
for(int idx = 1; idx < argc; ++idx) {
std::string string = argv[idx];
@@ -57,17 +57,17 @@ void io::cmdline::create(int argc, char** argv)
}
}
-void io::cmdline::insert(std::string_view option)
+void cmdline::insert(std::string_view option)
{
options.insert_or_assign(std::string(option), std::string());
}
-void io::cmdline::insert(std::string_view option, std::string_view argument)
+void cmdline::insert(std::string_view option, std::string_view argument)
{
options.insert_or_assign(std::string(option), std::string(argument));
}
-std::string_view io::cmdline::get(std::string_view option, std::string_view fallback)
+std::string_view cmdline::get(std::string_view option, std::string_view fallback)
{
auto it = options.find(std::string(option));
@@ -78,7 +78,7 @@ std::string_view io::cmdline::get(std::string_view option, std::string_view fall
return it->second;
}
-const char* io::cmdline::get_cstr(std::string_view option, const char* fallback)
+const char* cmdline::get_cstr(std::string_view option, const char* fallback)
{
auto it = options.find(std::string(option));
@@ -89,7 +89,7 @@ const char* io::cmdline::get_cstr(std::string_view option, const char* fallback)
return it->second.c_str();
}
-bool io::cmdline::contains(std::string_view option)
+bool cmdline::contains(std::string_view option)
{
return options.count(std::string(option));
}
diff --git a/src/core/io/cmdline.hh b/src/core/io/cmdline.hh
index e90433c..c0d6db2 100644
--- a/src/core/io/cmdline.hh
+++ b/src/core/io/cmdline.hh
@@ -1,6 +1,6 @@
#pragma once
-namespace io::cmdline
+namespace cmdline
{
void create(int argc, char** argv);
void insert(std::string_view option);
@@ -8,4 +8,4 @@ void insert(std::string_view option, std::string_view argument);
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 io::cmdline
+} // namespace cmdline
diff --git a/src/core/io/config_map.cc b/src/core/io/config_map.cc
index 57692a7..8634fd6 100644
--- a/src/core/io/config_map.cc
+++ b/src/core/io/config_map.cc
@@ -10,16 +10,16 @@
#include "core/version.hh"
-void io::ConfigMap::load_cmdline(void)
+void ConfigMap::load_cmdline(void)
{
for(auto it : m_values) {
- if(auto value = io::cmdline::get_cstr(it.first.c_str())) {
+ if(auto value = cmdline::get_cstr(it.first.c_str())) {
it.second->set(value);
}
}
}
-bool io::ConfigMap::load_file(std::string_view path)
+bool ConfigMap::load_file(std::string_view path)
{
if(auto file = PHYSFS_openRead(std::string(path).c_str())) {
auto source = std::string(PHYSFS_fileLength(file), char(0x00));
@@ -71,7 +71,7 @@ bool io::ConfigMap::load_file(std::string_view path)
return false;
}
-bool io::ConfigMap::save_file(std::string_view path) const
+bool ConfigMap::save_file(std::string_view path) const
{
std::ostringstream stream;
@@ -96,7 +96,7 @@ bool io::ConfigMap::save_file(std::string_view path) const
return false;
}
-bool io::ConfigMap::set_value(std::string_view name, std::string_view value)
+bool ConfigMap::set_value(std::string_view name, std::string_view value)
{
auto kv_pair = m_values.find(std::string(name));
@@ -108,7 +108,7 @@ bool io::ConfigMap::set_value(std::string_view name, std::string_view value)
return false;
}
-std::string_view io::ConfigMap::get_value(std::string_view name) const
+std::string_view ConfigMap::get_value(std::string_view name) const
{
auto kv_pair = m_values.find(std::string(name));
if(kv_pair != m_values.cend()) {
@@ -118,12 +118,12 @@ std::string_view io::ConfigMap::get_value(std::string_view name) const
return std::string_view();
}
-void io::ConfigMap::add_value(std::string_view name, config::IValue& vref)
+void ConfigMap::add_value(std::string_view name, config::IValue& vref)
{
m_values.insert_or_assign(std::string(name), &vref);
}
-const config::IValue* io::ConfigMap::find(std::string_view name) const
+const config::IValue* ConfigMap::find(std::string_view name) const
{
auto kv_pair = m_values.find(std::string(name));
diff --git a/src/core/io/config_map.hh b/src/core/io/config_map.hh
index b0cd579..898103b 100644
--- a/src/core/io/config_map.hh
+++ b/src/core/io/config_map.hh
@@ -5,8 +5,6 @@ namespace config
class IValue;
} // namespace config
-namespace io
-{
class ConfigMap final {
public:
ConfigMap(void) = default;
@@ -26,4 +24,3 @@ public:
private:
std::unordered_map<std::string, config::IValue*> m_values;
};
-} // namespace io
diff --git a/src/core/io/physfs.cc b/src/core/io/physfs.cc
index 1c36f88..b9fe91e 100644
--- a/src/core/io/physfs.cc
+++ b/src/core/io/physfs.cc
@@ -2,7 +2,7 @@
#include "core/io/physfs.hh"
-bool io::read_file(std::string_view path, std::vector<std::byte>& buffer)
+bool read_file(std::string_view path, std::vector<std::byte>& buffer)
{
auto file = PHYSFS_openRead(std::string(path).c_str());
@@ -20,7 +20,7 @@ bool io::read_file(std::string_view path, std::vector<std::byte>& buffer)
return true;
}
-bool io::read_file(std::string_view path, std::string& buffer)
+bool read_file(std::string_view path, std::string& buffer)
{
auto file = PHYSFS_openRead(std::string(path).c_str());
@@ -38,7 +38,7 @@ bool io::read_file(std::string_view path, std::string& buffer)
return true;
}
-bool io::write_file(std::string_view path, const std::vector<std::byte>& buffer)
+bool write_file(std::string_view path, const std::vector<std::byte>& buffer)
{
auto file = PHYSFS_openWrite(std::string(path).c_str());
@@ -53,7 +53,7 @@ bool io::write_file(std::string_view path, const std::vector<std::byte>& buffer)
return true;
}
-bool io::write_file(std::string_view path, const std::string& buffer)
+bool write_file(std::string_view path, const std::string& buffer)
{
auto file = PHYSFS_openWrite(std::string(path).c_str());
@@ -68,7 +68,7 @@ bool io::write_file(std::string_view path, const std::string& buffer)
return true;
}
-std::string_view io::physfs_error(void)
+std::string_view physfs_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 01282ad..88f97de 100644
--- a/src/core/io/physfs.hh
+++ b/src/core/io/physfs.hh
@@ -1,14 +1,8 @@
#pragma once
-namespace io
-{
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 io
-namespace io
-{
std::string_view physfs_error(void);
-} // namespace io
diff --git a/src/core/resource/image.cc b/src/core/resource/image.cc
index 8ab98db..6a2109e 100644
--- a/src/core/resource/image.cc
+++ b/src/core/resource/image.cc
@@ -36,7 +36,7 @@ static const void* image_load_func(const char* name, std::uint32_t flags)
auto file = PHYSFS_openRead(name);
if(file == nullptr) {
- spdlog::error("image: {}: {}", name, io::physfs_error());
+ spdlog::error("image: {}: {}", name, physfs_error());
return nullptr;
}
diff --git a/src/core/threading.cc b/src/core/threading.cc
index 03c0e8e..a1ae305 100644
--- a/src/core/threading.cc
+++ b/src/core/threading.cc
@@ -35,7 +35,7 @@ void Task::set_status(task_status status)
void threading::init(void)
{
- auto argument = io::cmdline::get("threads", DEFAULT_POOL_SIZE_ARG);
+ auto argument = cmdline::get("threads", DEFAULT_POOL_SIZE_ARG);
auto num_concurrent_threads = std::thread::hardware_concurrency();
unsigned int thread_pool_size;
diff --git a/src/core/version.cc b/src/core/version.cc
index f508aa0..b03fc2a 100644
--- a/src/core/version.cc
+++ b/src/core/version.cc
@@ -8,8 +8,8 @@ const unsigned short version::minor = 0;
const unsigned short version::patch = 1;
// clang-format on
-const std::string_view version::commit = "d304b608";
-const std::string_view version::branch = "master";
+const std::string_view version::commit = "e5f6887e";
+const std::string_view version::branch = "restor";
const std::string_view version::triplet = "16.0.1";
-const std::string_view version::full = "16.0.1-d304b608";
+const std::string_view version::full = "16.0.1-e5f6887e";