diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..4d0b8e9 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,29 @@ +image: gcc + +before_script: + - apt-get update + - apt-get install -y --no-install-recommends cmake libssl-dev libvulkan-dev xorg-dev doxygen graphviz + +build: + stage: build + script: + - mkdir build # compile + - cd build + - cmake .. + - make -j2 univerxel univerxel-client univerxel-server docs + - mkdir -p ../out/full ../out/client ../out/server/content # package artifacts + - cp -r univerxel content ../out/full + - cp -r univerxel-client content ../out/client + - rm ../out/client/content/cert.pem ../out/client/content/key.pem ../out/client/content/zstd.dict + - cp univerxel-server ../out/server + - cp content/cert.pem content/key.pem content/zstd.dict ../out/server/content + artifacts: + paths: + - out/full + - out/client + - out/server + - build/docs + expire_in: 1 week + # cache: + # paths: + # - "*.o" diff --git a/src/client.cpp b/src/client.cpp index 752f41f..dac9540 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1,5 +1,5 @@ /** - * \file server.cpp + * \file client.cpp * \brief Univerxel client * \author Maelys Bois * \version 0.0.1 diff --git a/src/client/config.hpp b/src/client/config.hpp index 2439bf5..0e8416e 100644 --- a/src/client/config.hpp +++ b/src/client/config.hpp @@ -24,6 +24,7 @@ inline std::string toHexa(const glm::vec4& rgb) { return sstr.str(); } +/// Client side configuration struct options { public: options(toml::node_view config) { diff --git a/src/client/net/Client.hpp b/src/client/net/Client.hpp index 1d6a021..60fd1cc 100644 --- a/src/client/net/Client.hpp +++ b/src/client/net/Client.hpp @@ -12,6 +12,7 @@ enum queue: uint8_t { count }; +/// Network client class Client final: public Context, public Connection { public: Client(const address& ct, diff --git a/src/client/render/Renderer.hpp b/src/client/render/Renderer.hpp index 532c973..cca13bc 100644 --- a/src/client/render/Renderer.hpp +++ b/src/client/render/Renderer.hpp @@ -10,6 +10,7 @@ class Window; class Camera; +/// Graphics pipeline namespace render { class Model; class LodModel; diff --git a/src/client/render/UI.cpp b/src/client/render/UI.cpp index 55b3673..b4c1ede 100644 --- a/src/client/render/UI.cpp +++ b/src/client/render/UI.cpp @@ -323,7 +323,7 @@ UI::Actions UI::draw(config::client::options &options, state::state &state, cons const auto flags = ImGuiInputTextFlags_EnterReturnsTrue; // | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; ImGui::GetColumnWidth(); - if (ImGui::InputText("", state.console.buffer.data(), state.console.buffer.size(), flags /*, TODO: callback, context*/) && strlen(state.console.buffer.data()) > 0) + if (ImGui::InputText("", state.console.buffer.data(), state.console.buffer.size(), flags /*TODO: completion (, callback, context)*/) && strlen(state.console.buffer.data()) > 0) actions |= Actions::Message; // Auto-focus on window apparition diff --git a/src/client/render/api/Images.cpp b/src/client/render/api/Images.cpp index b69034d..821a82f 100644 --- a/src/client/render/api/Images.cpp +++ b/src/client/render/api/Images.cpp @@ -65,7 +65,7 @@ std::optional Image::Read(const std::string& imagepath, std:: default: return {}; } - //FIXME: miplevels with size < block size (2 last) are corrupted + //WONT-FIX: miplevels with size < block size (2 last) are corrupted const uint maxMipmapLevels = 1 + std::floor(std::log2(std::max(info.size.height, info.size.width))) - 2; info.mipmapLevels = std::min(maxMipmapLevels, info.mipmapLevels); diff --git a/src/client/render/gl/Renderer.hpp b/src/client/render/gl/Renderer.hpp index b499ea1..33e0b40 100644 --- a/src/client/render/gl/Renderer.hpp +++ b/src/client/render/gl/Renderer.hpp @@ -10,6 +10,7 @@ #include "api/Images.hpp" struct windowOptions; +/// OpenGL graphics pipeline namespace render::gl { /// OpenGL rendering diff --git a/src/client/render/gl/pass/Program.hpp b/src/client/render/gl/pass/Program.hpp index 8c86afb..e078ee2 100644 --- a/src/client/render/gl/pass/Program.hpp +++ b/src/client/render/gl/pass/Program.hpp @@ -13,7 +13,6 @@ namespace render { namespace render::gl { class Renderer; } -/// OpenGL programs namespace pass { /// OpenGL shaders pipeline class Program { diff --git a/src/client/render/vk/Renderer.cpp b/src/client/render/vk/Renderer.cpp index ec46384..6e7fdd0 100644 --- a/src/client/render/vk/Renderer.cpp +++ b/src/client/render/vk/Renderer.cpp @@ -188,7 +188,7 @@ bool Renderer::Load(Window& window, const renderOptions& opt, const windowOption appInfo.applicationVersion = VK_MAKE_VERSION(0, 0, 1); appInfo.pEngineName = "No Engine"; appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); - appInfo.apiVersion = VK_API_VERSION_1_2; + appInfo.apiVersion = VK_MAKE_VERSION(1, 2, 0); VkInstanceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; diff --git a/src/client/render/vk/Renderer.hpp b/src/client/render/vk/Renderer.hpp index 23f8b83..75313b6 100644 --- a/src/client/render/vk/Renderer.hpp +++ b/src/client/render/vk/Renderer.hpp @@ -3,6 +3,7 @@ #include "forward.hpp" struct windowOptions; +/// Vulkan graphics pipeline namespace render::vk { class Allocator; class SwapChain; diff --git a/src/client/world/DistantUniverse.cpp b/src/client/world/DistantUniverse.cpp index b030849..6902d38 100644 --- a/src/client/world/DistantUniverse.cpp +++ b/src/client/world/DistantUniverse.cpp @@ -40,7 +40,7 @@ void DistantUniverse::update(voxel_pos pos, float deltaTime) { if (glm::length2(diff - it_c->first) > glm::pow2(keepDistance)) { it_c = chunks.erase(it_c); } else { - if(const auto neighbors = std::dynamic_pointer_cast(it_c->second)->update(deltaTime, true /*FIXME: rnd from contouring*/)) { + if(const auto neighbors = std::dynamic_pointer_cast(it_c->second)->update(deltaTime, true /*MAYBE: random update*/)) { contouring->onUpdate(std::make_pair(area.first, it_c->first), diff, chunks, neighbors.value()); } ++it_c; diff --git a/src/core/data/file.hpp b/src/core/data/file.hpp index b8d85fa..27f627b 100644 --- a/src/core/data/file.hpp +++ b/src/core/data/file.hpp @@ -6,9 +6,10 @@ namespace data { +/// File loader class file_content: public std::vector { public: - // Read first + /// Read first file_content(const std::vector& paths, data::out_view prefix = data::out_view(nullptr, 0)): std::vector(), prefix_size(prefix.size()) { diff --git a/src/core/data/generational.hpp b/src/core/data/generational.hpp index facaa90..103ac6b 100644 --- a/src/core/data/generational.hpp +++ b/src/core/data/generational.hpp @@ -4,7 +4,9 @@ #include #include +/// Generation indexing and containers (index, generation) namespace data::generational { + /// Generation element identifier struct id { id(size_t index, size_t generation = 0): index(index), generation(generation) { } id(): id(0) { } @@ -14,6 +16,7 @@ namespace data::generational { bool operator==(const id &i) const { return index == i.index && generation == i.generation; } }; + /// Closed generational allocator class allocator { public: allocator() { } @@ -68,6 +71,7 @@ namespace data::generational { std::vector freed; }; + /// Generational container accessible by id template class vector { public: @@ -229,6 +233,7 @@ namespace data::generational { std::vector freed; }; + /// Dummy generational container without allocation nor validation. A view to vector template class view_vector: public std::vector> { public: diff --git a/src/core/data/mem.hpp b/src/core/data/mem.hpp index 99b597b..fc8ed6f 100644 --- a/src/core/data/mem.hpp +++ b/src/core/data/mem.hpp @@ -7,12 +7,14 @@ namespace data { +/// Map vector to istream struct vec_istream: std::streambuf { vec_istream(std::vector &vec) { this->setg(&vec[0], &vec[0], &vec[0] + vec.size()); } }; +/// Abstract data with moving cursor struct view { view(size_t size): siz(size) { } @@ -22,6 +24,7 @@ struct view { constexpr size_t size() const { return siz; } constexpr bool isDone() const { return cur >= siz; } }; +/// Vector with in_view interface struct in_vector { /// 512 Mébibits static constexpr size_t MAX_SIZE = 1ul << 26; @@ -41,6 +44,7 @@ struct in_vector { memcpy(writeTo(len), data, len); } }; +// Abstract data writer struct in_view: view { in_view(uint8_t *ptr, size_t size): view(size), ptr(ptr) { assert(ptr != nullptr); @@ -57,6 +61,7 @@ struct in_view: view { memcpy(writeTo(len), data, len); } }; +/// Abstract data reader struct out_view: view { out_view(): out_view(nullptr, 0) { } out_view(const uint8_t *ptr, size_t size): view(size), ptr(ptr) { } @@ -75,7 +80,9 @@ struct out_view: view { constexpr const uint8_t* data() const { return ptr; } constexpr size_t remaining() const { return size() - cur; } }; +/// Pointer to opaque owned memory using handle_t = std::shared_ptr; +/// out_view with owned data struct out_buffer: out_view { out_buffer(): out_view() { } out_buffer(const out_view& view, const handle_t& handle): diff --git a/src/core/net/Context.hpp b/src/core/net/Context.hpp index 717dc4e..4bfc63f 100644 --- a/src/core/net/Context.hpp +++ b/src/core/net/Context.hpp @@ -7,6 +7,7 @@ namespace net { +/// Abstract stream struct stream_ctx { stream_ctx(uint64_t id): stream_id(id) { } uint64_t stream_id; @@ -17,6 +18,7 @@ struct stream_ctx { friend bool operator==(const stream_ctx &a, const stream_ctx &b) { return a.stream_id == b.stream_id; } }; +/// Outgoing stream struct out_stream_ctx: stream_ctx { out_stream_ctx(uint64_t id, uint8_t queue_id, const data::out_buffer& buf): stream_ctx(id), buffer(buf), queue_id(queue_id) { } @@ -24,10 +26,12 @@ struct out_stream_ctx: stream_ctx { data::out_buffer buffer; uint8_t queue_id; }; +/// Incoming stream struct in_stream_ctx: stream_ctx { in_stream_ctx(uint64_t id): stream_ctx(id) { } data::in_vector buffer; }; +/// Informations about packets enum class PacketFlags { NONE = 0, DATAGRAM = 1 << 0, @@ -156,7 +160,6 @@ private: std::forward_list incoming; // MAYBE: add bidirectional streams - // TODO: premanant streams: background, priority }; } \ No newline at end of file diff --git a/src/core/net/data.hpp b/src/core/net/data.hpp index 3509f51..3f9a471 100644 --- a/src/core/net/data.hpp +++ b/src/core/net/data.hpp @@ -4,11 +4,13 @@ #include "../utils/logger.hpp" #include +/// Network protocol namespace net { /// Application Protocol Negotiation constexpr auto ALPN = "univerxel_quic"; +/// Reasons for client server connection to break enum class disconnect_reason: uint16_t { UNEXPECTED = 0, // Client quit @@ -20,6 +22,7 @@ enum class disconnect_reason: uint16_t { PROTOCOL_VIOLATION = 15, }; +/// Packets from server to client enum class server_packet_type: uint8_t { /// MAYBE: HELLO = 0, @@ -50,7 +53,6 @@ enum class server_packet_type: uint8_t { /// Update entities instances position and velocity /// {size_t(entity), size_t(count), {size_t(index), ifvec3(pos), vec3(velocity)}[]}[] - /// FIXME: fromat to fit PICOQUIC_MAX_PACKET_SIZE ENTITIES = 21, /// World compression dictionary @@ -64,6 +66,7 @@ enum class server_packet_type: uint8_t { /// char[] (not null terminated) MESSAGE = 29, }; +/// Packets from client to server enum class client_packet_type: uint8_t { /// Interact with voxels /// actions::FillShape @@ -84,6 +87,7 @@ enum class client_packet_type: uint8_t { constexpr auto MAX_PENDING_CHUNK_COUNT = 256; +/// Server address as name(ip or dns name) and port struct address { std::string host; int port; @@ -103,9 +107,12 @@ struct address { return os << ct.host << ':' << ct.port; } }; +/// Server properties struct exposure: address { uint32_t max_connections; + /// TLS private key std::string key; + /// TLS public key std::string cert; }; diff --git a/src/core/net/io.hpp b/src/core/net/io.hpp index c1e19f8..f63e62e 100644 --- a/src/core/net/io.hpp +++ b/src/core/net/io.hpp @@ -7,7 +7,7 @@ namespace net { //TODO: preallocate static data pool -/// Write allocated packets +/// Helper to write allocated packets class PacketWriter final { public: PacketWriter(size_t size): buffer((uint8_t*)malloc(size), size) { } @@ -100,6 +100,7 @@ private: data::in_view buffer; }; +/// Helper to read out_view class PacketReader final { public: PacketReader(const data::out_view& buf): buffer(buf) { } diff --git a/src/core/server_handle.hpp b/src/core/server_handle.hpp index b1078a3..4a4546e 100644 --- a/src/core/server_handle.hpp +++ b/src/core/server_handle.hpp @@ -4,6 +4,7 @@ #include "world/actions.hpp" #include "geometry/Faces.hpp" +/// Link between world::server::SharedUniverse and world::client::LocalUniverse struct server_handle { bool running = false; const world::client::area_map *areas; diff --git a/src/server/config.hpp b/src/server/config.hpp index 72aa2fc..b650a5b 100644 --- a/src/server/config.hpp +++ b/src/server/config.hpp @@ -5,6 +5,7 @@ namespace config::server { +/// Server side configuration struct options { public: options(toml::node_view config): world() {