diff --git a/src/AABB.cpp b/src/AABB.cpp index 53a5292..f5a176e 100644 --- a/src/AABB.cpp +++ b/src/AABB.cpp @@ -1,6 +1,6 @@ #include "AABB.hpp" -namespace Diggler { +namespace diggler { template class AABB<>; diff --git a/src/AABB.hpp b/src/AABB.hpp index 66d5070..ea4050e 100644 --- a/src/AABB.hpp +++ b/src/AABB.hpp @@ -6,7 +6,7 @@ #include "platform/types/vec3.hpp" -namespace Diggler { +namespace diggler { /// /// @brief Axis-Aligned Bounding Box. diff --git a/src/Audio.cpp b/src/Audio.cpp index 40258c1..aa20463 100644 --- a/src/Audio.cpp +++ b/src/Audio.cpp @@ -14,7 +14,7 @@ #define AUDIO_GC_DEBUG 0 -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; diff --git a/src/Audio.hpp b/src/Audio.hpp index 0681d8a..fed3f7e 100644 --- a/src/Audio.hpp +++ b/src/Audio.hpp @@ -7,7 +7,7 @@ #include "Sound.hpp" #include "SoundBuffer.hpp" -namespace Diggler { +namespace diggler { class Game; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b4343d..6012cb7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,11 +17,9 @@ diggler_add_sources( ${CSD}/Chunk.cpp ${CSD}/Clouds.cpp ${CSD}/Config.cpp - ${CSD}/ConnectingState.cpp ${CSD}/EscMenu.cpp ${CSD}/Frustum.cpp ${CSD}/Game.cpp - ${CSD}/GameState.cpp ${CSD}/GameWindow.cpp ${CSD}/GLFWHandler.cpp ${CSD}/GlobalProperties.cpp @@ -31,7 +29,6 @@ diggler_add_sources( ${CSD}/KeyBinds.cpp ${CSD}/LocalPlayer.cpp ${CSD}/main.cpp - ${CSD}/MessageState.cpp ${CSD}/network/client/BlockUpdateHandler.cpp ${CSD}/network/client/ChatHandler.cpp ${CSD}/network/client/ChunkTransferHandler.cpp @@ -60,13 +57,16 @@ diggler_add_sources( ${CSD}/Skybox.cpp ${CSD}/SoundBuffer.cpp ${CSD}/Sound.cpp + ${CSD}/states/ConnectingState.cpp + ${CSD}/states/GameState.cpp + ${CSD}/states/MessageState.cpp + ${CSD}/states/UITestState.cpp ${CSD}/Texture.cpp ${CSD}/ui/Button.cpp ${CSD}/ui/Element.cpp ${CSD}/ui/Font.cpp ${CSD}/ui/FontManager.cpp ${CSD}/ui/Manager.cpp - ${CSD}/UITestState.cpp ${CSD}/ui/Text.cpp ${CSD}/Universe.cpp ${CSD}/World.cpp diff --git a/src/Camera.cpp b/src/Camera.cpp index 601aea4..08c9878 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -3,7 +3,7 @@ #include #include -namespace Diggler { +namespace diggler { Camera::Camera() { m_worldUp = vec3(0, 1, 0); diff --git a/src/Camera.hpp b/src/Camera.hpp index 5e297e8..55a7389 100644 --- a/src/Camera.hpp +++ b/src/Camera.hpp @@ -6,7 +6,7 @@ #include "Frustum.hpp" -namespace Diggler { +namespace diggler { class Camera { friend class LocalPlayer; diff --git a/src/CaveGenerator.cpp b/src/CaveGenerator.cpp index 2f2daee..41839f6 100644 --- a/src/CaveGenerator.cpp +++ b/src/CaveGenerator.cpp @@ -6,7 +6,7 @@ #include "Platform.hpp" #include -namespace Diggler { +namespace diggler { CaveGenerator::GenConf::GenConf() : groundLevel(0.9), oreFactor(0.5) { @@ -62,11 +62,11 @@ void CaveGenerator::Generate(WorldRef wr, const GenConf &gc, ChunkRef cr) { for (int y = 0; y < CY; ++y) for (int x = 0; x < CX; ++x) for (int z = 0; z < CZ; ++z) - c.setBlock(x, y, z, y < 8 ? Content::BlockUnknownId : Content::BlockAirId); + c.setBlock(x, y, z, y < 8 ? content::BlockUnknownId : content::BlockAirId); for (int y = CY; y > 8; --y) for (int x = 0; x < CX; ++x) { - c.setBlock(x, y, 0, Content::BlockUnknownId); - c.setBlock(x, y, CZ-1, Content::BlockUnknownId); + c.setBlock(x, y, 0, content::BlockUnknownId); + c.setBlock(x, y, CZ-1, content::BlockUnknownId); }*/ constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ; @@ -78,9 +78,9 @@ void CaveGenerator::Generate(WorldRef wr, const GenConf &gc, ChunkRef cr) { for (int lz = 0; lz < CZ; ++lz) { int z = cp.z + lz; if (y >= -8) { - c.setBlock(lx, ly, lz, y < raw_noise_3d(x/16.f, 0, z/16.f)*8 ? Content::BlockUnknownId : Content::BlockAirId); + c.setBlock(lx, ly, lz, y < raw_noise_3d(x/16.f, 0, z/16.f)*8 ? content::BlockUnknownId : content::BlockAirId); } else { - c.setBlock(lx, ly, lz, raw_noise_3d(x/16.f, y/16.f, z/16.f) > 0.7 ? Content::BlockAirId : Content::BlockUnknownId); + c.setBlock(lx, ly, lz, raw_noise_3d(x/16.f, y/16.f, z/16.f) > 0.7 ? content::BlockAirId : content::BlockUnknownId); } } } diff --git a/src/CaveGenerator.hpp b/src/CaveGenerator.hpp index 00fdf49..78558b7 100644 --- a/src/CaveGenerator.hpp +++ b/src/CaveGenerator.hpp @@ -4,7 +4,7 @@ #include "World.hpp" #include "WorldGenerator.hpp" -namespace Diggler { +namespace diggler { class CaveGenerator : public WorldGenerator { private: diff --git a/src/Chatbox.cpp b/src/Chatbox.cpp index 3a8caf5..b442792 100644 --- a/src/Chatbox.cpp +++ b/src/Chatbox.cpp @@ -9,16 +9,16 @@ #include "render/gl/ProgramManager.hpp" #include "ui/Manager.hpp" -namespace Diggler { +namespace diggler { -const Render::gl::Program *Chatbox::RenderProgram = nullptr; +const render::gl::Program *Chatbox::RenderProgram = nullptr; GLint Chatbox::RenderProgram_coord = -1; GLint Chatbox::RenderProgram_color = -1; GLint Chatbox::RenderProgram_mvp = -1; Chatbox::Chatbox(Game *G) : m_isChatting(false), G(G), m_posX(0), m_posY(0) { - m_chatText = G->UIM->addManual("", 2, 2); + m_chatText = G->UIM->addManual("", 2, 2); m_chatText->setPos(0, 0); if (RenderProgram == nullptr) { RenderProgram = G->PM->getProgram("2d", "color0"); @@ -35,7 +35,7 @@ Chatbox::Chatbox(Game *G) : m_isChatting(false), G(G), {0.f, 100.f, 0.f, 0.f, 0.f, .5f} }; m_vbo.setData(verts, 6); - { Render::gl::VAO::Config cfg = m_vao.configure(); + { render::gl::VAO::Config cfg = m_vao.configure(); cfg.vertexAttrib(m_vbo, RenderProgram_coord, 2, GL_FLOAT, sizeof(Vertex), 0); cfg.vertexAttrib(m_vbo, RenderProgram_color, 4, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, r)); cfg.commit(); @@ -64,7 +64,7 @@ void Chatbox::addChatEntry(const std::string &text) { m_chatEntries.emplace_back(); ChatEntry &entry = m_chatEntries.back(); entry.date = system_clock::now(); - entry.text = G->UIM->addManual(text); + entry.text = G->UIM->addManual(text); entry.height = entry.text->getSize().y; } diff --git a/src/Chatbox.hpp b/src/Chatbox.hpp index 15f336c..dd6a089 100644 --- a/src/Chatbox.hpp +++ b/src/Chatbox.hpp @@ -12,9 +12,9 @@ #include "render/gl/VBO.hpp" #include "ui/Text.hpp" -namespace Diggler { +namespace diggler { -namespace Render { +namespace render { namespace gl { class Program; } @@ -28,7 +28,7 @@ public: using time_point = std::chrono::time_point; private: - static const Render::gl::Program *RenderProgram; + static const render::gl::Program *RenderProgram; static GLint RenderProgram_coord, RenderProgram_color, RenderProgram_mvp; bool m_isChatting; @@ -36,7 +36,7 @@ private: struct ChatEntry { time_point date; int height; - std::shared_ptr text; + std::shared_ptr text; ~ChatEntry(); }; @@ -44,12 +44,12 @@ private: // TODO: Update when libstdc++ supports locale codecvt facets //std::u32string m_chatString; std::string m_chatString; - std::shared_ptr m_chatText; + std::shared_ptr m_chatText; struct Vertex { float x, y, r, g, b, a; }; - Render::gl::VBO m_vbo; - Render::gl::VAO m_vao; + render::gl::VBO m_vbo; + render::gl::VAO m_vao; int m_posX, m_posY; public: diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 657c796..30a8814 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -24,7 +24,7 @@ #define SHOW_CHUNK_UPDATES 1 -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; @@ -52,7 +52,7 @@ void Chunk::ChangeHelper::add(int x, int y, int z) { m_changes.emplace_back(x, y, z); } -using Net::MsgTypes::BlockUpdateNotify; +using net::MsgTypes::BlockUpdateNotify; void Chunk::ChangeHelper::flush(BlockUpdateNotify &bun) { for (glm::ivec3 &c : m_changes) { bun.updates.emplace_back(); @@ -284,7 +284,7 @@ void Chunk::updateClient() { imcUncompress(); #endif mut.lock(); - Content::Registry &CR = *G->CR; + content::Registry &CR = *G->CR; Vertex vertex[CX * CY * CZ * 6 /* faces */ * 4 /* vertices */ / 2 /* face removing (HSR) makes a lower vert max */]; ushort idxOpaque[CX * CY * CZ * 6 /* faces */ * 6 /* indices */ / 2 /* HSR */], idxTransp[CX*CY*CZ*6*6/2]; @@ -299,8 +299,8 @@ void Chunk::updateClient() { bt = data->id[I(x,y,z)]; // Empty block? - if (bt == Content::BlockAirId || - bt == Content::BlockIgnoreId) + if (bt == content::BlockAirId || + bt == content::BlockIgnoreId) continue; #if 0 @@ -429,7 +429,7 @@ void Chunk::updateClient() { mut.unlock(); } -void Chunk::write(IO::OutStream &os) const { +void Chunk::write(io::OutStream &os) const { const uint dataSize = Chunk::AllocaSize; uint compressedSize; byte *compressed = new byte[dataSize]; @@ -448,7 +448,7 @@ void Chunk::write(IO::OutStream &os) const { delete[] compressed; } -void Chunk::read(IO::InStream &is) { +void Chunk::read(io::InStream &is) { uint compressedSize = is.readU16(); const uint targetDataSize = Chunk::AllocaSize; byte *compressedData = new byte[compressedSize]; diff --git a/src/Chunk.hpp b/src/Chunk.hpp index 4343027..9a0db4a 100644 --- a/src/Chunk.hpp +++ b/src/Chunk.hpp @@ -13,18 +13,18 @@ #define CHUNK_INMEM_COMPRESS 1 #define CHUNK_INMEM_COMPRESS_DELAY 2000 /* ms */ -namespace Diggler { +namespace diggler { class CaveGenerator; class Game; class World; using WorldRef = std::shared_ptr; -namespace Render { +namespace render { class WorldRenderer; } -namespace Net { +namespace net { namespace MsgTypes { struct BlockUpdateNotify; } @@ -34,7 +34,7 @@ class Chunk { private: friend World; friend CaveGenerator; - friend class Render::WorldRenderer; + friend class render::WorldRenderer; uintptr_t rendererData; public: @@ -119,7 +119,7 @@ public: void add(int x, int y, int z); bool empty() const; int count() const; - void flush(Net::MsgTypes::BlockUpdateNotify&); + void flush(net::MsgTypes::BlockUpdateNotify&); void discard(); } CH; @@ -240,8 +240,8 @@ public: /* ============ Serialization ============ */ - void write(IO::OutStream&) const; - void read(IO::InStream&); + void write(io::OutStream&) const; + void read(io::InStream&); }; using ChunkRef = std::shared_ptr; diff --git a/src/Clouds.cpp b/src/Clouds.cpp index a40c509..82b32f4 100644 --- a/src/Clouds.cpp +++ b/src/Clouds.cpp @@ -9,7 +9,7 @@ #include "render/Renderer.hpp" #include "Texture.hpp" -namespace Diggler { +namespace diggler { Clouds::Renderer Clouds::R = {0}; diff --git a/src/Clouds.hpp b/src/Clouds.hpp index d22515e..88ec671 100644 --- a/src/Clouds.hpp +++ b/src/Clouds.hpp @@ -9,12 +9,12 @@ #include "platform/Types.hpp" #include "render/gl/VBO.hpp" -namespace Diggler { +namespace diggler { class Game; class Texture; -namespace Render { +namespace render { namespace gl { class Program; } @@ -23,11 +23,11 @@ class Program; class Clouds { private: static struct Renderer { - const Render::gl::Program *prog; + const render::gl::Program *prog; GLint att_coord, att_texcoord, uni_mvp, uni_texshift; } R; std::vector> m_tex; - Render::gl::VBO m_vbo; + render::gl::VBO m_vbo; int m_layers; Game *G; struct Coord { uint8 x, y, z, u, v; }; diff --git a/src/Config.cpp b/src/Config.cpp index a69123b..4f5f0d2 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -1,6 +1,6 @@ #include "Config.hpp" -namespace Diggler { +namespace diggler { Config::Config() { diff --git a/src/Config.hpp b/src/Config.hpp index bbaa9bd..b54f649 100644 --- a/src/Config.hpp +++ b/src/Config.hpp @@ -2,7 +2,7 @@ #define SETTINGS_HPP #include -namespace Diggler { +namespace diggler { class Config { private: diff --git a/src/Entity.hpp b/src/Entity.hpp index 5f226bd..2cce278 100644 --- a/src/Entity.hpp +++ b/src/Entity.hpp @@ -2,7 +2,7 @@ #define ENTITY_HPP #include "Platform.hpp" -namespace Diggler { +namespace diggler { class Entity { public: diff --git a/src/EscMenu.cpp b/src/EscMenu.cpp index 84b9d25..b3ec2a0 100644 --- a/src/EscMenu.cpp +++ b/src/EscMenu.cpp @@ -10,17 +10,17 @@ #include "ui/Manager.hpp" #include "ui/Text.hpp" -namespace Diggler { +namespace diggler { struct EscMenu::MenuEntryImpl { Area inputArea; - std::shared_ptr txtText; + std::shared_ptr txtText; }; -EscMenu::EscMenu(UI::Manager *UIM) : - UI::Element(UIM), +EscMenu::EscMenu(ui::Manager *UIM) : + ui::Element(UIM), G(UIM->G) { - txtMenuTitle = G->UIM->addManual(" Menu", 3, 3); + txtMenuTitle = G->UIM->addManual(" Menu", 3, 3); //m_button = new UIButton(G, glm::mat); for (int i=0;i<10;++i) addMenuEntry("hello " + std::to_string(i)); @@ -43,7 +43,7 @@ void EscMenu::refresh() { void EscMenu::addMenuEntry(const std::string &text) { entries.emplace_back(MenuEntry { text, std::make_unique() }); - entries.back().impl->txtText = G->UIM->addManual(text, 2, 2); + entries.back().impl->txtText = G->UIM->addManual(text, 2, 2); refresh(); } @@ -62,7 +62,7 @@ void EscMenu::onInputAreaChanged() { } void EscMenu::setVisible(bool v) { - UI::Element::setVisible(v); + ui::Element::setVisible(v); if (v) { m_transition.start = G->Time; m_transition.duration = .3; @@ -89,7 +89,7 @@ void EscMenu::render(const glm::mat4 &baseMatrix) const { const int width = renderArea().w; const int pxScroll = (1 - scroll) * width; - G->UIM->drawRect(baseMatrix, UI::Element::Area { pxScroll, 0, width, renderArea().h }, + G->UIM->drawRect(baseMatrix, ui::Element::Area { pxScroll, 0, width, renderArea().h }, glm::vec4(0.f, 0.f, 0.f, 0.8f)); int y = renderArea().h; diff --git a/src/EscMenu.hpp b/src/EscMenu.hpp index 787d2c5..a0248c3 100644 --- a/src/EscMenu.hpp +++ b/src/EscMenu.hpp @@ -8,23 +8,23 @@ #include "render/gl/Program.hpp" #include "ui/Element.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace UI { +namespace ui { class Button; class Text; } -class EscMenu : public UI::Element { +class EscMenu : public ui::Element { private: Game *G; mutable struct { double start, duration; bool active; } m_transition; - std::shared_ptr txtMenuTitle; - std::shared_ptr m_button; + std::shared_ptr txtMenuTitle; + std::shared_ptr m_button; struct MenuEntryImpl; struct MenuEntry { std::string text; @@ -35,7 +35,7 @@ private: void refresh(); public: - EscMenu(UI::Manager*); + EscMenu(ui::Manager*); ~EscMenu(); void addMenuEntry(const std::string &text); @@ -46,7 +46,7 @@ public: void setVisible(bool) override; void render(const glm::mat4&) const override; - using UI::Element::render; + using ui::Element::render; }; } diff --git a/src/Frustum.cpp b/src/Frustum.cpp index 117a658..a3c8c35 100644 --- a/src/Frustum.cpp +++ b/src/Frustum.cpp @@ -2,7 +2,7 @@ #include #include -namespace Diggler { +namespace diggler { void Frustum::setCamInternals(vec3vt rad, vec3vt ratio, vec3vt nearD, vec3vt farD) { this->ratio = ratio; diff --git a/src/Frustum.hpp b/src/Frustum.hpp index 31eccb8..33c797a 100644 --- a/src/Frustum.hpp +++ b/src/Frustum.hpp @@ -9,7 +9,7 @@ #undef NEAR #undef FAR -namespace Diggler { +namespace diggler { class Frustum { private: diff --git a/src/GLFWHandler.cpp b/src/GLFWHandler.cpp index ddd369d..7da7974 100644 --- a/src/GLFWHandler.cpp +++ b/src/GLFWHandler.cpp @@ -1,7 +1,7 @@ #include "GLFWHandler.hpp" #include "GameWindow.hpp" -namespace Diggler { +namespace diggler { void GLFWHandler::mouseButtonImpl(GLFWwindow *window, int key, int action, int mods) { (void)window; diff --git a/src/GLFWHandler.hpp b/src/GLFWHandler.hpp index ec5c74d..dd1c2d5 100644 --- a/src/GLFWHandler.hpp +++ b/src/GLFWHandler.hpp @@ -3,7 +3,7 @@ struct GLFWwindow; -namespace Diggler { +namespace diggler { class GameWindow; diff --git a/src/Game.cpp b/src/Game.cpp index 95f03db..ecd4aff 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1,18 +1,19 @@ #include "Game.hpp" -#include "Audio.hpp" #include "content/AssetManager.hpp" #include "content/ModManager.hpp" #include "content/Registry.hpp" -#include "GlobalProperties.hpp" -#include "KeyBinds.hpp" -#include "LocalPlayer.hpp" +#include "gfx/Device.hpp" #include "render/gl/ProgramManager.hpp" #include "render/gl/Renderer.hpp" #include "scripting/lua/State.hpp" #include "ui/FontManager.hpp" +#include "Audio.hpp" +#include "GlobalProperties.hpp" +#include "KeyBinds.hpp" +#include "LocalPlayer.hpp" -namespace Diggler { +namespace diggler { Game::Game() : C(nullptr), @@ -35,9 +36,9 @@ Game::Game() : } void Game::init() { - AM = std::make_unique(this); - MM = std::make_unique(this); - LS = new Scripting::Lua::State(this); + AM = std::make_unique(this); + MM = std::make_unique(this); + LS = new scripting::lua::State(this); if (GlobalProperties::IsClient) { initClient(); } @@ -47,7 +48,7 @@ void Game::init() { } void Game::initClient() { - PM = new Render::gl::ProgramManager(*this); + PM = new render::gl::ProgramManager(*this); LP = new LocalPlayer(this); RP = new RenderProperties; { // TODO move somewhere else? RP->bloom = true; @@ -55,9 +56,9 @@ void Game::initClient() { RP->fogStart = 16; RP->fogEnd = 24; } - R = new Render::gl::GLRenderer(this); - CR = new Content::Registry(*this); - FM = std::make_unique(*this); + R = new render::gl::GLRenderer(this); + CR = new content::Registry(*this); + FM = std::make_unique(*this); A = new Audio(*this); KB = new KeyBinds; LP = new LocalPlayer(this); @@ -65,7 +66,7 @@ void Game::initClient() { } void Game::initServer() { - CR = new Content::Registry(*this); + CR = new content::Registry(*this); } void Game::finalize() { diff --git a/src/Game.hpp b/src/Game.hpp index ef26f97..eca63d8 100644 --- a/src/Game.hpp +++ b/src/Game.hpp @@ -8,28 +8,32 @@ using std::shared_ptr; -namespace Diggler { +namespace diggler { -namespace Content { +namespace content { class AssetManager; class ModManager; class Registry; } -namespace Render { +namespace gfx { +class Device; +} + +namespace render { class Renderer; namespace gl { class ProgramManager; } } -namespace Scripting { -namespace Lua { +namespace scripting { +namespace lua { class State; } } -namespace UI { +namespace ui { class FontManager; class Manager; } @@ -50,30 +54,31 @@ public: // Shared Config *C; double Time; uint64 TimeMs; - Net::Host H; + net::Host H; Universe *U; PlayerList players; - Content::Registry *CR; - ptr AM; - ptr MM; - Scripting::Lua::State *LS; + content::Registry *CR; + ptr AM; + ptr MM; + scripting::lua::State *LS; // Server Server *S; // Client + ptr GD; GameWindow *GW; - UI::Manager *UIM; + ui::Manager *UIM; LocalPlayer *LP; - Render::gl::ProgramManager *PM; - Render::Renderer *R; - ptr FM; + render::gl::ProgramManager *PM; + render::Renderer *R; + ptr FM; struct RenderProperties { bool bloom, wavingLiquids; float fogStart, fogEnd; } *RP; Audio *A; - Net::Peer *NS; + net::Peer *NS; KeyBinds *KB; int PlayerPosUpdateFreq; diff --git a/src/GameWindow.cpp b/src/GameWindow.cpp index 417e907..8124be0 100644 --- a/src/GameWindow.cpp +++ b/src/GameWindow.cpp @@ -10,8 +10,8 @@ #include "Game.hpp" #include "GlobalProperties.hpp" #include "GLFWHandler.hpp" -#include "GameState.hpp" -#include "MessageState.hpp" +#include "states/GameState.hpp" +#include "states/MessageState.hpp" #include "Audio.hpp" #include "ui/FontManager.hpp" #include "ui/Manager.hpp" @@ -19,7 +19,7 @@ #include "util/Log.hpp" #include "util/MemoryTracker.hpp" -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; @@ -50,10 +50,10 @@ GameWindow::GameWindow(Game *G) : G(G) { m_w = 640; m_h = 480; - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API /*GLFW_OPENGL_ES_API*/); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); + //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); glfwWindowHint(GLFW_SAMPLES, 0); // Gimme aliasing everywhere //glfwWindowHint(GLFW_STENCIL_BITS, 8); @@ -68,10 +68,10 @@ GameWindow::GameWindow(Game *G) : G(G) { } glfwMakeContextCurrent(m_window); - Render::gl::OpenGL::init(); + render::gl::OpenGL::init(); #ifdef DEBUG - Render::gl::Debug::enable(); + render::gl::Debug::enable(); #endif glfwSetFramebufferSizeCallback(m_window, GLFWHandler::resize); glfwSetCursorPosCallback(m_window, GLFWHandler::cursorPos); @@ -111,9 +111,9 @@ GameWindow::GameWindow(Game *G) : G(G) { #endif ; - auto glver = Render::gl::OpenGL::version(); - Log(Info, TAG) << Render::gl::OpenGL::loaderName() << ' ' << - Render::gl::OpenGL::loaderVersion() << " -- GL" << + auto glver = render::gl::OpenGL::version(); + Log(Info, TAG) << render::gl::OpenGL::loaderName() << ' ' << + render::gl::OpenGL::loaderVersion() << " -- GL" << (glver.isGLES ? "ES" : "") << ' ' << glver.major << '.' << glver.minor << (glver.isCore ? " Core" : "") << @@ -127,7 +127,7 @@ GameWindow::GameWindow(Game *G) : G(G) { } { Util::MemoryTracker::ScopedCategory sc(nullptr); - UIM = new UI::Manager; + UIM = new ui::Manager; UIM->onResize(m_w, m_h); G->init(); @@ -203,7 +203,11 @@ void GameWindow::cbResize(int w, int h) { m_currentState->onResize(w, h); } -void GameWindow::setNextState(std::unique_ptr &&next) { +states::State& GameWindow::state() const { + return *m_currentState; +} + +void GameWindow::setNextState(std::unique_ptr &&next) { m_nextState = std::move(next); } @@ -230,7 +234,7 @@ void GameWindow::run() { } void GameWindow::showMessage(const std::string &msg, const std::string &submsg) { - setNextState(std::make_unique(this, msg, submsg)); + setNextState(std::make_unique(this, msg, submsg)); } } diff --git a/src/GameWindow.hpp b/src/GameWindow.hpp index 5720630..efa7a5d 100644 --- a/src/GameWindow.hpp +++ b/src/GameWindow.hpp @@ -13,13 +13,13 @@ #include "StateMachine.hpp" #include "Platform.hpp" +#include "platform/Types.hpp" -namespace Diggler { +namespace diggler { class Game; -class State; -namespace UI { +namespace ui { class Manager; } @@ -30,15 +30,15 @@ private: GLFWwindow *m_window; int m_w, m_h; - std::unique_ptr m_currentState, m_nextState; + std::unique_ptr m_currentState, m_nextState; public: - UI::Manager *UIM; + ui::Manager *UIM; Game *G; GameWindow(Game*); - ~GameWindow(); + ~GameWindow() override; operator GLFWwindow&() const { return *m_window; } operator GLFWwindow*() const { return m_window; } @@ -60,7 +60,9 @@ public: void updateViewport(); - void setNextState(std::unique_ptr &&next) override; + states::State& state() const override; + void setNextState(std::unique_ptr &&next) override; + void run(); void showMessage(const std::string &msg, const std::string &submsg = ""); diff --git a/src/GlobalProperties.cpp b/src/GlobalProperties.cpp index f3b11cb..96fcad3 100644 --- a/src/GlobalProperties.cpp +++ b/src/GlobalProperties.cpp @@ -1,6 +1,6 @@ #include "GlobalProperties.hpp" -namespace Diggler { +namespace diggler { bool GlobalProperties::IsClient = true; bool GlobalProperties::IsServer = false; diff --git a/src/GlobalProperties.hpp b/src/GlobalProperties.hpp index 0fdcdd2..c9f97f5 100644 --- a/src/GlobalProperties.hpp +++ b/src/GlobalProperties.hpp @@ -1,7 +1,7 @@ #ifndef GLOBAL_PROPERTIES_HPP #define GLOBAL_PROPERTIES_HPP -namespace Diggler { +namespace diggler { namespace GlobalProperties { extern bool IsClient; diff --git a/src/KeyBinds.cpp b/src/KeyBinds.cpp index 4d6b305..8add2d1 100644 --- a/src/KeyBinds.cpp +++ b/src/KeyBinds.cpp @@ -7,7 +7,7 @@ using std::fwrite; using std::fread; using std::fclose; -namespace Diggler { +namespace diggler { KeyBinds::KeyBinds() { loadDefaults(); diff --git a/src/KeyBinds.hpp b/src/KeyBinds.hpp index 87be936..4271374 100644 --- a/src/KeyBinds.hpp +++ b/src/KeyBinds.hpp @@ -2,7 +2,7 @@ #define KEY_BINDS_HPP #include -namespace Diggler { +namespace diggler { class KeyBinds { public: diff --git a/src/LocalPlayer.cpp b/src/LocalPlayer.cpp index e02e3cc..262a393 100644 --- a/src/LocalPlayer.cpp +++ b/src/LocalPlayer.cpp @@ -15,7 +15,7 @@ #include "render/gl/ProgramManager.hpp" #include "util/Log.hpp" -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; @@ -148,7 +148,7 @@ void LocalPlayer::update(float delta) { for (int cz = min.z; cz < max.z; ++cz) { blockBox.v1.z = cz; blockBox.v2.z = cz + 1; BlockId id = W->getBlockId(cx, cy, cz); - if (id != Content::BlockAirId) { + if (id != content::BlockAirId) { glm::vec3 normal; float d = plrBox.sweptCollision(blockBox, dtvel.x, dtvel.y, dtvel.z, normal.x, normal.y, normal.z); if (d < pdelta) { @@ -210,10 +210,10 @@ void LocalPlayer::render(const glm::mat4 &transform) const { { min.x, min.y, max.z, 0, 1, 0 }, }; vbo.setDataGrow(pts, sizeof(pts)/sizeof(Coord), GL_STREAM_DRAW); - const Render::gl::Program &P = *G->PM->getProgram("3d", "color0"); + const render::gl::Program &P = *G->PM->getProgram("3d", "color0"); if (!vaoConfigured) { vaoConfigured = true; - Render::gl::VAO::Config cfg = vao.configure(); + render::gl::VAO::Config cfg = vao.configure(); cfg.vertexAttrib(vbo, P.att("coord"), 3, GL_FLOAT, sizeof(Coord), 0); cfg.vertexAttrib(vbo, P.att("color"), 3, GL_UNSIGNED_BYTE, sizeof(Coord), offsetof(Coord, r)); cfg.commit(); diff --git a/src/LocalPlayer.hpp b/src/LocalPlayer.hpp index 7239067..b57026d 100644 --- a/src/LocalPlayer.hpp +++ b/src/LocalPlayer.hpp @@ -10,7 +10,7 @@ #include "render/gl/VAO.hpp" #include "render/gl/VBO.hpp" -namespace Diggler { +namespace diggler { class Game; @@ -20,8 +20,8 @@ private: bool hasGravity, hasNoclip, onGround, onRoad; // debugging - mutable Render::gl::VBO vbo; - mutable Render::gl::VAO vao; + mutable render::gl::VBO vbo; + mutable render::gl::VAO vao; mutable bool vaoConfigured = false; public: diff --git a/src/Particles.cpp b/src/Particles.cpp index c194dbe..0f499d4 100644 --- a/src/Particles.cpp +++ b/src/Particles.cpp @@ -4,7 +4,7 @@ #include "Game.hpp" #include "render/Renderer.hpp" -namespace Diggler { +namespace diggler { ParticleEmitter::ParticleEmitter(Game *G) : G(G) { diff --git a/src/Particles.hpp b/src/Particles.hpp index db34fba..f2b4c67 100644 --- a/src/Particles.hpp +++ b/src/Particles.hpp @@ -7,9 +7,9 @@ #include #include -namespace Diggler { +namespace diggler { -namespace Render { +namespace render { class ParticlesRenderer; } class Game; @@ -22,7 +22,7 @@ struct Particle { }; class ParticleEmitter { - friend class Render::ParticlesRenderer; + friend class render::ParticlesRenderer; uintptr_t rendererData; Game *G; diff --git a/src/PixelFormat.hpp b/src/PixelFormat.hpp index c9da155..9532cdd 100644 --- a/src/PixelFormat.hpp +++ b/src/PixelFormat.hpp @@ -3,7 +3,7 @@ #include "platform/Types.hpp" -namespace Diggler { +namespace diggler { enum class PixelFormat : uint8 { RGB, diff --git a/src/Platform.cpp b/src/Platform.cpp index d4ac535..171c9d0 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -4,12 +4,12 @@ #include "util/Log.hpp" -using Diggler::Util::Log; -using namespace Diggler::Util::Logging::LogLevels; +using diggler::Util::Log; +using namespace diggler::Util::Logging::LogLevels; static const char *TAG = "Platform"; -const char *Diggler::UserdataDirsName = "Diggler"; +const char *diggler::UserdataDirsName = "Diggler"; static struct PathCache { std::string @@ -27,7 +27,7 @@ static struct PathCache { #include #include "platform/Fixes.hpp" -std::string Diggler::proc::getExecutablePath() { +std::string diggler::proc::getExecutablePath() { if (pathCache.executableBin.length() == 0) { HMODULE hModule = GetModuleHandleW(NULL); WCHAR path[MAX_PATH]; @@ -39,7 +39,7 @@ std::string Diggler::proc::getExecutablePath() { return pathCache.executableBin; } -std::string Diggler::proc::getExecutableDirectory() { +std::string diggler::proc::getExecutableDirectory() { if (pathCache.executableDir.length() == 0) { std::string filename(getExecutablePath()); const size_t last_sep_idx = filename.rfind('\\'); @@ -53,7 +53,7 @@ std::string Diggler::proc::getExecutableDirectory() { return pathCache.executableDir; } -std::string Diggler::getCacheDirectory() { +std::string diggler::getCacheDirectory() { if (pathCache.cacheDir.length() == 0) { WCHAR ucs2Path[MAX_PATH]; SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, ucs2Path); @@ -64,7 +64,7 @@ std::string Diggler::getCacheDirectory() { return pathCache.cacheDir; } -std::string Diggler::getConfigDirectory() { +std::string diggler::getConfigDirectory() { if (pathCache.cacheDir.length() == 0) { WCHAR ucs2Path[MAX_PATH]; SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, ucs2Path); @@ -86,7 +86,7 @@ std::string do_readlink(const char *path); std::string do_readlink(const std::string &path); #if defined(BUILDINFO_PLATFORM_LINUX) -std::string Diggler::proc::getExecutablePath() { +std::string diggler::proc::getExecutablePath() { if (pathCache.executableBin.length() == 0) { pid_t pid = getpid(); // Assuming 32-bit pid -> max of 10 digits, we need only "/proc/xxxxxxxxxx/exe" space @@ -100,7 +100,7 @@ std::string Diggler::proc::getExecutablePath() { // TODO: getExecutablePath for those without procfs #endif -std::string Diggler::proc::getExecutableDirectory() { +std::string diggler::proc::getExecutableDirectory() { if (pathCache.executableDir.length() == 0) { std::string filename(getExecutablePath()); const size_t last_slash_idx = filename.rfind('/'); @@ -114,7 +114,7 @@ std::string Diggler::proc::getExecutableDirectory() { return pathCache.executableDir; } -std::string Diggler::getCacheDirectory() { +std::string diggler::getCacheDirectory() { if (pathCache.cacheDir.length() == 0) { const char *xdgCache = std::getenv("XDG_CACHE_HOME"); if (xdgCache) { @@ -126,7 +126,7 @@ std::string Diggler::getCacheDirectory() { return pathCache.cacheDir; } -std::string Diggler::getConfigDirectory() { +std::string diggler::getConfigDirectory() { if (pathCache.configDir.length() == 0) { const char *xdgCache = std::getenv("XDG_CONFIG_HOME"); if (xdgCache) { @@ -148,7 +148,7 @@ std::string Diggler::getConfigDirectory() { #endif -namespace Diggler { +namespace diggler { std::string getAssetsDirectory() { return proc::getExecutableDirectory() + "/assets"; diff --git a/src/Platform.hpp b/src/Platform.hpp index e46a046..782cd29 100644 --- a/src/Platform.hpp +++ b/src/Platform.hpp @@ -12,7 +12,7 @@ #include "platform/Math.hpp" #include "platform/Types.hpp" -namespace Diggler { +namespace diggler { namespace proc { /// @returns The executable's absolute path diff --git a/src/Player.cpp b/src/Player.cpp index 59f626d..465f25a 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -10,7 +10,7 @@ #include "render/gl/ProgramManager.hpp" #include "render/gl/VBO.hpp" -namespace Diggler { +namespace diggler { Player::Renderer Player::R = {}; @@ -38,7 +38,7 @@ Player::Player(Game *G) : -sz, .0f, 0.0f, sz, szH, 0.0f, }; - R.vbo = std::make_unique(); + R.vbo = std::make_unique(); R.vbo->setData(coords, 6*3); } } diff --git a/src/Player.hpp b/src/Player.hpp index e66fa13..ec3d0be 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -13,9 +13,9 @@ #include "network/Network.hpp" #include "World.hpp" -namespace Diggler { +namespace diggler { -namespace Render { +namespace render { class PlayerRenderer; namespace gl { class Program; @@ -29,17 +29,17 @@ using PlayerGameID = uint32; class Player { protected: - friend class Render::PlayerRenderer; + friend class render::PlayerRenderer; uintptr_t rendererData; static struct Renderer { - const Render::gl::Program *prog; + const render::gl::Program *prog; GLint att_coord, uni_mvp, uni_unicolor, uni_fogStart, uni_fogEnd; - std::unique_ptr vbo; + std::unique_ptr vbo; } R; double m_lastPosTime; glm::vec3 m_predictPos; @@ -60,7 +60,7 @@ public: using SessionID = uint32; SessionID sessId; bool isAlive; - Net::Peer *peer; + net::Peer *peer; std::list pendingChunks; Player(Game *G = nullptr); diff --git a/src/PlayerList.cpp b/src/PlayerList.cpp index ca3d5c6..115c395 100644 --- a/src/PlayerList.cpp +++ b/src/PlayerList.cpp @@ -5,7 +5,7 @@ #include "Game.hpp" #include "LocalPlayer.hpp" -namespace Diggler { +namespace diggler { PlayerList::PlayerList(Game *G) : G(G) { } @@ -58,7 +58,7 @@ Player* PlayerList::getByName(const std::string &name) { return nullptr; } -Player* PlayerList::getByPeer(const Net::Peer &peer) { +Player* PlayerList::getByPeer(const net::Peer &peer) { for (auto it = begin(); it != end(); ++it) { if (*it->peer == peer) { diff --git a/src/PlayerList.hpp b/src/PlayerList.hpp index fc94738..8d1e026 100644 --- a/src/PlayerList.hpp +++ b/src/PlayerList.hpp @@ -5,7 +5,7 @@ #include #include "Player.hpp" -namespace Diggler { +namespace diggler { class Game; @@ -42,7 +42,7 @@ public: * @brief Gets a Player using its network peer object * @return Pointer to Player, may be nullptr if not found */ - Player* getByPeer(const Net::Peer&); + Player* getByPeer(const net::Peer&); Player& add(); void remove(const Player&); diff --git a/src/Server.cpp b/src/Server.cpp index bb95e3f..c97a281 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -24,9 +24,9 @@ using std::cout; using std::endl; -using namespace Diggler::Net; +using namespace diggler::net; -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; @@ -135,8 +135,8 @@ void Server::handleDisconnect(Peer &peer) { handlePlayerQuit(peer, QuitReason::Timeout); } -void Server::handleContentMessage(Net::InMessage &msg, Net::Peer &peer) { - using namespace Net::MsgTypes; +void Server::handleContentMessage(net::InMessage &msg, net::Peer &peer) { + using namespace net::MsgTypes; using S = ContentSubtype; switch (msg.getSubtype()) { case S::ModListRequest: { @@ -152,7 +152,7 @@ void Server::handleContentMessage(Net::InMessage &msg, Net::Peer &peer) { } void Server::handleChat(InMessage &msg, Player *plr) { - using namespace Net::MsgTypes; + using namespace net::MsgTypes; using S = ChatSubtype; switch (msg.getSubtype()) { case S::Send: { @@ -178,7 +178,7 @@ void Server::handleCommand(Player *plr, const std::string &command, const std::v } void Server::handlePlayerUpdate(InMessage &msg, Player &plr) { - using namespace Net::MsgTypes; + using namespace net::MsgTypes; using S = PlayerUpdateSubtype; switch (msg.getSubtype()) { case S::Move: { @@ -207,9 +207,9 @@ void Server::schedSendChunk(ChunkRef C, Player &P) { } void Server::sendChunks(const std::list &cs, Player &P) { - using namespace Net::MsgTypes; + using namespace net::MsgTypes; ChunkTransferResponse ctr; - std::vector chunkBufs(cs.size()); + std::vector chunkBufs(cs.size()); size_t i = 0; for (const ChunkRef &cr : cs) { ctr.chunks.emplace_back(); @@ -228,7 +228,7 @@ void Server::sendChunks(const std::list &cs, Player &P) { } void Server::handlePlayerChunkRequest(InMessage &msg, Player &plr) { - using namespace Net::MsgTypes; + using namespace net::MsgTypes; using S = ChunkTransferSubtype; switch (msg.getSubtype()) { case S::Request: { @@ -251,7 +251,7 @@ void Server::handlePlayerChunkRequest(InMessage &msg, Player &plr) { void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) { // TODO: distance & tool check, i.e. legitimate update - using namespace Net::MsgTypes; + using namespace net::MsgTypes; using S = BlockUpdateSubtype; constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ; switch (msg.getSubtype()) { @@ -285,7 +285,7 @@ void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) { ChunkRef c = w->getChunkAtCoords(bub.pos); if (c) { c->setBlock(rmod(bub.pos.x, CX), rmod(bub.pos.y, CY), rmod(bub.pos.z, CZ), - Content::BlockAirId, 0); + content::BlockAirId, 0); if (!c->CH.empty()) { BlockUpdateNotify bun; c->CH.flush(bun); @@ -300,7 +300,7 @@ void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) { } void Server::handlePlayerDeath(InMessage &msg, Player &plr) { - using namespace Net::MsgTypes; + using namespace net::MsgTypes; PlayerUpdateDie pud; pud.readFromMsg(msg); pud.plrSessId = plr.sessId; @@ -340,7 +340,7 @@ Server::Server(Game &G, uint16 port) : G(G) { try { H.create(port); - } catch (Net::Exception &e) { + } catch (net::Exception &e) { Log(Error, TAG) << "Couldn't open port " << port << " for listening\n" << "Make sure no other server instance is running"; if (port <= 1024) { @@ -392,7 +392,7 @@ void Server::chunkUpdater(WorldRef WR, bool &continueUpdate) { for (auto pair : W) { if ((c = pair.second.lock()) && !c->CH.empty()) { // TODO: view range - Net::MsgTypes::BlockUpdateNotify bun; + net::MsgTypes::BlockUpdateNotify bun; c->CH.flush(bun); OutMessage msg; bun.writeToMsg(msg); @@ -481,7 +481,7 @@ bool Server::isPlayerOnline(const std::string &playername) const { return false; } -void Server::kick(Player &p, Net::QuitReason r, const std::string &message) { +void Server::kick(Player &p, net::QuitReason r, const std::string &message) { OutMessage msg(MessageType::PlayerQuit, r); msg.writeU32(p.sessId); msg.writeString(message); diff --git a/src/Server.hpp b/src/Server.hpp index 6677df0..9b11faa 100644 --- a/src/Server.hpp +++ b/src/Server.hpp @@ -8,7 +8,7 @@ using std::unique_ptr; -namespace Diggler { +namespace diggler { class Game; @@ -21,18 +21,18 @@ private: void handleCommand(Player*, const std::string &command, const std::vector &args); - void handlePlayerJoin(Net::InMessage&, Net::Peer&); - void handlePlayerQuit(Net::Peer&, Net::QuitReason reason = Net::QuitReason::Quit); - void handleDisconnect(Net::Peer&); + void handlePlayerJoin(net::InMessage&, net::Peer&); + void handlePlayerQuit(net::Peer&, net::QuitReason reason = net::QuitReason::Quit); + void handleDisconnect(net::Peer&); - void handleContentMessage(Net::InMessage&, Net::Peer&); + void handleContentMessage(net::InMessage&, net::Peer&); - void handleChat(Net::InMessage&, Player*); + void handleChat(net::InMessage&, Player*); - void handlePlayerUpdate(Net::InMessage&, Player&); - void handlePlayerDeath(Net::InMessage&, Player&); - void handlePlayerChunkRequest(Net::InMessage&, Player&); - void handlePlayerMapUpdate(Net::InMessage&, Player&); + void handlePlayerUpdate(net::InMessage&, Player&); + void handlePlayerDeath(net::InMessage&, Player&); + void handlePlayerChunkRequest(net::InMessage&, Player&); + void handlePlayerMapUpdate(net::InMessage&, Player&); void schedSendChunk(ChunkRef, Player&); void sendChunks(const std::list&, Player&); @@ -40,7 +40,7 @@ private: void chunkUpdater(WorldRef WR, bool &continueUpdate); public: - Net::Host H; + net::Host H; Server(Game &G, uint16 port); ~Server(); @@ -53,9 +53,9 @@ public: bool isPlayerOnline(const std::string &playername) const; bool isIPOnline(const std::string &ip) const; Player* getPlayerBySessId(uint32 id); - Player* getPlayerByPeer(const Net::Peer &peer); + Player* getPlayerByPeer(const net::Peer &peer); Player* getPlayerByName(const std::string &name); - void kick(Player &p, Net::QuitReason r = Net::QuitReason::Kicked, const std::string& message = ""); + void kick(Player &p, net::QuitReason r = net::QuitReason::Kicked, const std::string& message = ""); }; } diff --git a/src/Skybox.cpp b/src/Skybox.cpp index 2de7a71..c3d4afb 100644 --- a/src/Skybox.cpp +++ b/src/Skybox.cpp @@ -5,9 +5,9 @@ #include "render/gl/ProgramManager.hpp" #include "Texture.hpp" -namespace Diggler { +namespace diggler { -const Render::gl::Program *Skybox::RenderProgram = nullptr; +const render::gl::Program *Skybox::RenderProgram = nullptr; GLint Skybox::RenderProgram_attrib_texcoord = -1; GLint Skybox::RenderProgram_attrib_coord = -1; GLint Skybox::RenderProgram_uni_mvp = -1; diff --git a/src/Skybox.hpp b/src/Skybox.hpp index 49e112a..3e66fc9 100644 --- a/src/Skybox.hpp +++ b/src/Skybox.hpp @@ -6,9 +6,9 @@ #include "render/gl/VBO.hpp" #include "Game.hpp" -namespace Diggler { +namespace diggler { -namespace Render { +namespace render { namespace gl { class Program; } @@ -18,9 +18,9 @@ class Texture; class Skybox { private: - static const Render::gl::Program *RenderProgram; + static const render::gl::Program *RenderProgram; static GLint RenderProgram_attrib_coord, RenderProgram_attrib_texcoord, RenderProgram_uni_mvp; - Render::gl::VBO m_vbo; + render::gl::VBO m_vbo; Texture *m_top, *m_w, *m_e, *m_n, *m_s, *m_bottom; Game *G; struct Coord { int8 x, y, z, u, v; }; diff --git a/src/Sound.cpp b/src/Sound.cpp index ae49f3e..f9db3ae 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -1,7 +1,7 @@ #include "Sound.hpp" #include "Platform.hpp" -namespace Diggler { +namespace diggler { Sound::Sound(const SoundBuffer *buffer) : buffer(buffer), createdRelative(true) { alGenSources(1, &id); diff --git a/src/Sound.hpp b/src/Sound.hpp index 1277416..d15a74b 100644 --- a/src/Sound.hpp +++ b/src/Sound.hpp @@ -4,7 +4,7 @@ #include "SoundBuffer.hpp" #include -namespace Diggler { +namespace diggler { class Sound { private: diff --git a/src/SoundBuffer.cpp b/src/SoundBuffer.cpp index 957aa17..5fdbefa 100644 --- a/src/SoundBuffer.cpp +++ b/src/SoundBuffer.cpp @@ -5,7 +5,7 @@ #include "platform/Types.hpp" #include "util/Log.hpp" -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; diff --git a/src/SoundBuffer.hpp b/src/SoundBuffer.hpp index ba0486c..2873314 100644 --- a/src/SoundBuffer.hpp +++ b/src/SoundBuffer.hpp @@ -3,7 +3,7 @@ #include #include -namespace Diggler { +namespace diggler { class SoundBuffer { private: diff --git a/src/StateMachine.hpp b/src/StateMachine.hpp index ff9b656..9b73617 100644 --- a/src/StateMachine.hpp +++ b/src/StateMachine.hpp @@ -3,13 +3,16 @@ #include -#include "State.hpp" +#include "states/State.hpp" -namespace Diggler { +namespace diggler { class StateMachine { public: - virtual void setNextState(std::unique_ptr &&next) = 0; + virtual ~StateMachine() {} + + virtual states::State& state() const = 0; + virtual void setNextState(std::unique_ptr &&next) = 0; }; } diff --git a/src/Texture.cpp b/src/Texture.cpp index d640998..d84c084 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -1,6 +1,6 @@ #include "Texture.hpp" -namespace Diggler { +namespace diggler { uint Texture::requiredBufferSize() { uint texelSize; diff --git a/src/Texture.hpp b/src/Texture.hpp index d4a3b2b..e4a1584 100644 --- a/src/Texture.hpp +++ b/src/Texture.hpp @@ -10,7 +10,7 @@ // TODO: remove me #include "render/gl/OpenGL.hpp" -namespace Diggler { +namespace diggler { class Texture { public: diff --git a/src/Universe.cpp b/src/Universe.cpp index 8d68818..3856309 100644 --- a/src/Universe.cpp +++ b/src/Universe.cpp @@ -1,6 +1,6 @@ #include "Universe.hpp" -namespace Diggler { +namespace diggler { Universe::Universe(Game *G, bool remote) : G(G), isRemote(remote) { @@ -33,7 +33,7 @@ WorldRef Universe::createWorld(WorldId id) { return w; } -void Universe::recv(Net::InMessage &msg) { +void Universe::recv(net::InMessage &msg) { } diff --git a/src/Universe.hpp b/src/Universe.hpp index 6a314c3..200accf 100644 --- a/src/Universe.hpp +++ b/src/Universe.hpp @@ -3,7 +3,7 @@ #include #include "World.hpp" -namespace Diggler { +namespace diggler { using UniverseWorldMap = std::map; @@ -47,10 +47,10 @@ public: /* ============ Serialization ============ */ - void write(IO::OutStream&) const; - void read(IO::InStream&); + void write(io::OutStream&) const; + void read(io::InStream&); - void recv(Net::InMessage&); + void recv(net::InMessage&); }; } diff --git a/src/VersionInfo.hpp b/src/VersionInfo.hpp index e45f887..7ae5e51 100644 --- a/src/VersionInfo.hpp +++ b/src/VersionInfo.hpp @@ -1,7 +1,7 @@ #ifndef DIGGLER_VERSION_INFO_HPP #define DIGGLER_VERSION_INFO_HPP -namespace Diggler { +namespace diggler { const char* VersionString = "0.1.0"; int VersionMajor = 0; int VersionMinor = 1; diff --git a/src/World.cpp b/src/World.cpp index ea702f7..de37038 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -11,7 +11,7 @@ #include "Universe.hpp" #include "util/Log.hpp" -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; @@ -156,7 +156,7 @@ BlockId World::getBlockId(int x, int y, int z) { return cr->getBlockId(rmod(x, CX), rmod(y, CY), rmod(z, CZ)); } } - return Content::BlockIgnoreId; + return content::BlockIgnoreId; } BlockData World::getBlockData(int x, int y, int z) { @@ -191,7 +191,7 @@ bool World::raytrace(glm::vec3 pos, glm::vec3 dir, float range, glm::ivec3 *poin do { BlockId testBlock = getBlockId(xPos, yPos, zPos); /// @todo Actual block non-solidity (cursorwise) check - if (testBlock != Content::BlockAirId) { + if (testBlock != content::BlockAirId) { if (pointed) *pointed = glm::ivec3(xPos, yPos, zPos); if (facing) @@ -308,7 +308,7 @@ void World::refresh() { c->markAsDirty(); } -void World::write(IO::OutStream &msg) const { +void World::write(io::OutStream &msg) const { const void *chunkData = nullptr; const uint dataSize = Chunk::AllocaSize; uint compressedSize; @@ -336,7 +336,7 @@ void World::write(IO::OutStream &msg) const { delete[] compressed; } -void World::read(IO::InStream &M) { +void World::read(io::InStream &M) { int bytesRead = 0; uint size = M.readU16(); for (uint n=0; n < size; ++n) { diff --git a/src/World.hpp b/src/World.hpp index 352453b..ad97f36 100644 --- a/src/World.hpp +++ b/src/World.hpp @@ -16,10 +16,10 @@ #include "network/Network.hpp" #include "Particles.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Net { +namespace net { class InMessage; class OutMessage; } @@ -165,10 +165,10 @@ public: /* ============ Serialization ============ */ - void write(IO::OutStream&) const; - void read(IO::InStream&); - void send(Net::OutMessage&) const; - void recv(Net::InMessage&); + void write(io::OutStream&) const; + void read(io::InStream&); + void send(net::OutMessage&) const; + void recv(net::InMessage&); }; using WorldRef = std::shared_ptr; diff --git a/src/WorldGenerator.hpp b/src/WorldGenerator.hpp index 467bf6a..4d75414 100644 --- a/src/WorldGenerator.hpp +++ b/src/WorldGenerator.hpp @@ -3,7 +3,7 @@ #include -namespace Diggler { +namespace diggler { class World; diff --git a/src/content/Asset.cpp b/src/content/Asset.cpp index 23dc7b4..d29e345 100644 --- a/src/content/Asset.cpp +++ b/src/content/Asset.cpp @@ -4,8 +4,8 @@ #include "AssetManager.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { Asset::Asset(const std::shared_ptr &acm) : m_contentMetadata(acm) { diff --git a/src/content/Asset.hpp b/src/content/Asset.hpp index 4d3e827..4089e0c 100644 --- a/src/content/Asset.hpp +++ b/src/content/Asset.hpp @@ -6,8 +6,8 @@ #include "../crypto/SHA256.hpp" #include "AssetContentMetadata.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { class AssetManager; diff --git a/src/content/AssetContentMetadata.cpp b/src/content/AssetContentMetadata.cpp index 2235849..02aef00 100644 --- a/src/content/AssetContentMetadata.cpp +++ b/src/content/AssetContentMetadata.cpp @@ -4,8 +4,8 @@ #include -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { AssetContentMetadata::AssetContentMetadata(AssetManager &am) : m_assetManager(am) { diff --git a/src/content/AssetContentMetadata.hpp b/src/content/AssetContentMetadata.hpp index 6cfd217..e707bf0 100644 --- a/src/content/AssetContentMetadata.hpp +++ b/src/content/AssetContentMetadata.hpp @@ -6,8 +6,8 @@ #include "../crypto/SHA256.hpp" #include "../platform/Types.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { class AssetManager; diff --git a/src/content/AssetManager.cpp b/src/content/AssetManager.cpp index e798e9a..e855f56 100644 --- a/src/content/AssetManager.cpp +++ b/src/content/AssetManager.cpp @@ -2,8 +2,8 @@ #include "../Game.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { AssetManager::AssetManager(Game *G) : G(G) { diff --git a/src/content/AssetManager.hpp b/src/content/AssetManager.hpp index 16a30a8..7cb9201 100644 --- a/src/content/AssetManager.hpp +++ b/src/content/AssetManager.hpp @@ -7,11 +7,11 @@ #include "Asset.hpp" #include "Mod.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Content { +namespace content { class AssetManager final { private: diff --git a/src/content/BlockDef.hpp b/src/content/BlockDef.hpp index 40e9f39..fecebe7 100644 --- a/src/content/BlockDef.hpp +++ b/src/content/BlockDef.hpp @@ -8,15 +8,15 @@ #include "../util/TexturePacker.hpp" //#include "../AABB.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { class BlockDef : public ObjectDef { public: struct Appearance { Variability variability; struct Texture { - Diggler::Texture *tex; + diggler::Texture *tex; Util::TexturePacker::Coord coord; std::vector divCoords; struct Repeat { diff --git a/src/content/Content.hpp b/src/content/Content.hpp index ab5aac8..566914b 100644 --- a/src/content/Content.hpp +++ b/src/content/Content.hpp @@ -6,7 +6,7 @@ #include #include -namespace Diggler { +namespace diggler { using BlockId = uint16; using BlockData = uint16; @@ -36,7 +36,7 @@ struct LightData { static_assert(sizeof(LightData) == 2, "LightData has extra padding"); static_assert(std::is_pod::value, "LightData is not POD"); -namespace Content { +namespace content { const BlockId BlockAirId = 0; const BlockId BlockIgnoreId = std::numeric_limits::max(); const BlockId BlockUnknownId = 1; diff --git a/src/content/Mod.hpp b/src/content/Mod.hpp index 054a0dc..ba1f092 100644 --- a/src/content/Mod.hpp +++ b/src/content/Mod.hpp @@ -6,8 +6,8 @@ #include "../Platform.hpp" #include "../crypto/Sign.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { union ModId { struct Parts { diff --git a/src/content/ModManager.cpp b/src/content/ModManager.cpp index 93ae27f..fa599c6 100644 --- a/src/content/ModManager.cpp +++ b/src/content/ModManager.cpp @@ -2,8 +2,8 @@ #include "../Game.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { ModManager::ModManager(Game *G) : G(G) { diff --git a/src/content/ModManager.hpp b/src/content/ModManager.hpp index 14fb60c..9638d75 100644 --- a/src/content/ModManager.hpp +++ b/src/content/ModManager.hpp @@ -3,11 +3,11 @@ #include "Mod.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Content { +namespace content { class ModManager final { private: diff --git a/src/content/ObjectDef.hpp b/src/content/ObjectDef.hpp index c7b4b5d..5c14b1e 100644 --- a/src/content/ObjectDef.hpp +++ b/src/content/ObjectDef.hpp @@ -2,8 +2,8 @@ #define DIGGLER_CONTENT_OBJECT_DEF_HPP #include "../Platform.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { class ObjectDef { public: diff --git a/src/content/Registry.cpp b/src/content/Registry.cpp index a4acf78..974c346 100644 --- a/src/content/Registry.cpp +++ b/src/content/Registry.cpp @@ -6,8 +6,8 @@ #define PRINT_BLOCK_REGISTRATIONS 1 -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { using Util::Log; using namespace Util::Logging::LogLevels; @@ -82,7 +82,7 @@ static const DefBlocksInfo DefBlocksInfos[] = { }; bool Registry::isTransparent(BlockId id) const { - if (id == Content::BlockAirId) + if (id == content::BlockAirId) return true; return false; // TODO return getBlockDef(id).isTransparent; @@ -98,7 +98,7 @@ bool Registry::isFaceVisible(BlockId id1, BlockId id2) const { } bool Registry::canEntityGoThrough(BlockId id/* , Entity& ent*/) const { - if (id == Content::BlockAirId) + if (id == content::BlockAirId) return true; return false; /*return (t == BlockType::TransRed && team == Player::Team::Red) || @@ -110,13 +110,13 @@ static Coord unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8; #define AddTex(b, t) Coord b = m_texturePacker->add(getAssetPath("blocks", t)); Registry::Registry(Game &G) : m_atlas(nullptr), - m_nextMaxBlockId(Content::BlockUnknownId + 1) { - { Registry::BlockRegistration br(registerBlock(Content::BlockAirId, "air")); + m_nextMaxBlockId(content::BlockUnknownId + 1) { + { Registry::BlockRegistration br(registerBlock(content::BlockAirId, "air")); br.def.appearance.look.type = BlockDef::Appearance::Look::Type::Hidden; br.def.phys.hasCollision = false; br.commit(); } - { Registry::BlockRegistration br(registerBlock(Content::BlockUnknownId, "unknown")); + { Registry::BlockRegistration br(registerBlock(content::BlockUnknownId, "unknown")); br.def.appearance.look.type = BlockDef::Appearance::Look::Type::Hidden; br.def.phys.hasCollision = true; br.commit(); @@ -158,7 +158,7 @@ Util::TexturePacker::Coord Registry::addTexture(const std::string &texName, const Util::TexturePacker::Coord* Registry::blockTexCoord(BlockId t, FaceDirection d, const glm::ivec3 &pos) const { - if (t == Content::BlockUnknownId) { + if (t == content::BlockUnknownId) { const Coord *unk[] = { &unk1, &unk2, &unk3, &unk4, &unk5, &unk6, &unk7, &unk8 }; @@ -226,7 +226,7 @@ Registry::BlockRegistration Registry::registerBlock(BlockId id, const char *name } Registry::BlockRegistration Registry::registerBlock(const char *name) { - BlockId id = Content::BlockUnknownId; + BlockId id = content::BlockUnknownId; if (m_freedBlockIds.empty()) { id = m_nextMaxBlockId; ++m_nextMaxBlockId; diff --git a/src/content/Registry.hpp b/src/content/Registry.hpp index 5dd88d7..9c33dba 100644 --- a/src/content/Registry.hpp +++ b/src/content/Registry.hpp @@ -11,7 +11,7 @@ #include "../Texture.hpp" #include "../util/TexturePacker.hpp" -namespace Diggler { +namespace diggler { enum class FaceDirection : uint8_t { XInc = 0, @@ -24,7 +24,7 @@ enum class FaceDirection : uint8_t { class Game; -namespace Content { +namespace content { class Registry { public: diff --git a/src/content/font/formats/bdf/BDFLoader.cpp b/src/content/font/formats/bdf/BDFLoader.cpp index 71a3a54..bfc511d 100644 --- a/src/content/font/formats/bdf/BDFLoader.cpp +++ b/src/content/font/formats/bdf/BDFLoader.cpp @@ -2,8 +2,8 @@ #include "../../../../util/StringUtil.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Font { namespace Formats { namespace BDF { diff --git a/src/content/image/ImageFormat.hpp b/src/content/image/ImageFormat.hpp index f132dc1..753ea24 100644 --- a/src/content/image/ImageFormat.hpp +++ b/src/content/image/ImageFormat.hpp @@ -3,8 +3,8 @@ #include "../../platform/FourCC.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { using Format = FourCC; diff --git a/src/content/image/ImageLoader.cpp b/src/content/image/ImageLoader.cpp index 9a5977f..b12cee6 100644 --- a/src/content/image/ImageLoader.cpp +++ b/src/content/image/ImageLoader.cpp @@ -7,11 +7,11 @@ #include "formats/png/PNGLoader.hpp" #include "formats/ImageLoader.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { -ImageLoader::Loading::Loading(std::unique_ptr &&stream, const LoadParams &lp) : +ImageLoader::Loading::Loading(std::unique_ptr &&stream, const LoadParams &lp) : stream(std::move(stream)), loadParams(lp), w(0), @@ -40,7 +40,7 @@ std::shared_ptr ImageLoader::load(Format format, const std } std::shared_ptr ImageLoader::load(Format format, - std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) { + std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) { return getFormatLoader(format)->load(format, std::move(stream), pixFormat, lp); } diff --git a/src/content/image/ImageLoader.hpp b/src/content/image/ImageLoader.hpp index 5a19f23..2d88cb5 100644 --- a/src/content/image/ImageLoader.hpp +++ b/src/content/image/ImageLoader.hpp @@ -8,8 +8,8 @@ #include "../../PixelFormat.hpp" #include "ImageFormat.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { class ImageLoader final { @@ -60,12 +60,12 @@ public: class Loading { protected: - Loading(std::unique_ptr&&, const LoadParams&); + Loading(std::unique_ptr&&, const LoadParams&); public: virtual ~Loading(); - std::unique_ptr stream; + std::unique_ptr stream; LoadParams loadParams; uint w, h; byte *pixels; @@ -74,7 +74,7 @@ public: static std::shared_ptr load(Format, const std::string &path, PixelFormat pixFormat, const LoadParams&); - static std::shared_ptr load(Format, std::unique_ptr &&stream, + static std::shared_ptr load(Format, std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams&); }; diff --git a/src/content/image/formats/ImageLoader.cpp b/src/content/image/formats/ImageLoader.cpp index ffc3376..d2b6e31 100644 --- a/src/content/image/formats/ImageLoader.cpp +++ b/src/content/image/formats/ImageLoader.cpp @@ -1,7 +1,7 @@ #include "ImageLoader.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { diff --git a/src/content/image/formats/ImageLoader.hpp b/src/content/image/formats/ImageLoader.hpp index 4f19110..330af94 100644 --- a/src/content/image/formats/ImageLoader.hpp +++ b/src/content/image/formats/ImageLoader.hpp @@ -7,8 +7,8 @@ #include "../../../PixelFormat.hpp" #include "../ImageLoader.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { @@ -22,7 +22,7 @@ public: virtual std::shared_ptr load(Format, const std::string &path, PixelFormat pixFormat, const LoadParams&) const = 0; - virtual std::shared_ptr load(Format, std::unique_ptr &&stream, + virtual std::shared_ptr load(Format, std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams&) const = 0; }; diff --git a/src/content/image/formats/STBImageLoader.cpp b/src/content/image/formats/STBImageLoader.cpp index f712f3e..8e23f2c 100644 --- a/src/content/image/formats/STBImageLoader.cpp +++ b/src/content/image/formats/STBImageLoader.cpp @@ -4,30 +4,30 @@ #include -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { static int stream_read(void *user, char *data, int size) { - IO::InStream &stream = *reinterpret_cast(user); + io::InStream &stream = *reinterpret_cast(user); stream.readData(data, size); return size; } static void stream_skip(void *user, int n) { - IO::InStream &stream = *reinterpret_cast(user); + io::InStream &stream = *reinterpret_cast(user); stream.skip(n); } static int stream_eof(void *user) { - IO::InStream &stream = *reinterpret_cast(user); + io::InStream &stream = *reinterpret_cast(user); return stream.eos(); } class STBILoading final : public STBImageLoader::Loading { public: - STBILoading(std::unique_ptr &&stream, const ImageLoader::LoadParams &lp) : + STBILoading(std::unique_ptr &&stream, const ImageLoader::LoadParams &lp) : Loading(std::move(stream), lp) { } @@ -41,7 +41,7 @@ STBILoading::~STBILoading() { } std::shared_ptr STBImageLoader::load(Format format, - std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) const { + std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) const { auto loading = std::make_shared(std::move(stream), lp); loading->thread = std::thread([pixFormat, loading]() { stbi_io_callbacks cbs; diff --git a/src/content/image/formats/STBImageLoader.hpp b/src/content/image/formats/STBImageLoader.hpp index 8b5171d..d96b707 100644 --- a/src/content/image/formats/STBImageLoader.hpp +++ b/src/content/image/formats/STBImageLoader.hpp @@ -8,8 +8,8 @@ #include "../../../io/FileStream.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { @@ -17,10 +17,10 @@ class STBImageLoader final : public ImageLoader { public: std::shared_ptr load(Format format, const std::string &path, PixelFormat pixFormat, const LoadParams &lp) const override { - return load(format, std::make_unique(path), pixFormat, lp); + return load(format, std::make_unique(path), pixFormat, lp); } - std::shared_ptr load(Format, std::unique_ptr &&stream, PixelFormat format, + std::shared_ptr load(Format, std::unique_ptr &&stream, PixelFormat format, const LoadParams&) const override; }; diff --git a/src/content/image/formats/flif/FLIFLoader.cpp b/src/content/image/formats/flif/FLIFLoader.cpp index f7deddf..79264b5 100644 --- a/src/content/image/formats/flif/FLIFLoader.cpp +++ b/src/content/image/formats/flif/FLIFLoader.cpp @@ -1,13 +1,13 @@ #include "FLIFLoader.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { namespace FLIF { std::shared_ptr FLIFLoader::load(Format format, - std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) const { + std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) const { // TODO } diff --git a/src/content/image/formats/flif/FLIFLoader.hpp b/src/content/image/formats/flif/FLIFLoader.hpp index c0c9e85..2ba5128 100644 --- a/src/content/image/formats/flif/FLIFLoader.hpp +++ b/src/content/image/formats/flif/FLIFLoader.hpp @@ -5,8 +5,8 @@ #include "../../../../io/FileStream.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { namespace FLIF { @@ -15,10 +15,10 @@ class FLIFLoader final : public ImageLoader { public: std::shared_ptr load(Format format, const std::string &path, PixelFormat pixFormat, const LoadParams &lp) const override { - return load(format, std::make_unique(path), pixFormat, lp); + return load(format, std::make_unique(path), pixFormat, lp); } - std::shared_ptr load(Format, std::unique_ptr &&stream, + std::shared_ptr load(Format, std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams&) const override; }; diff --git a/src/content/image/formats/jpeg/JPEGLoader.cpp b/src/content/image/formats/jpeg/JPEGLoader.cpp index 0fbd305..b5988cb 100644 --- a/src/content/image/formats/jpeg/JPEGLoader.cpp +++ b/src/content/image/formats/jpeg/JPEGLoader.cpp @@ -1,7 +1,7 @@ #include "JPEGLoader.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { namespace JPEG { diff --git a/src/content/image/formats/jpeg/JPEGLoader.hpp b/src/content/image/formats/jpeg/JPEGLoader.hpp index fb090df..052377e 100644 --- a/src/content/image/formats/jpeg/JPEGLoader.hpp +++ b/src/content/image/formats/jpeg/JPEGLoader.hpp @@ -5,8 +5,8 @@ #include "../../../../io/FileStream.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { namespace JPEG { @@ -15,10 +15,10 @@ class JPEGLoader final : public ImageLoader { public: std::shared_ptr load(Format format, const std::string &path, PixelFormat pixFormat, const LoadParams &lp) const override { - return load(format, std::make_unique(path), pixFormat, lp); + return load(format, std::make_unique(path), pixFormat, lp); } - std::shared_ptr load(Format, std::unique_ptr &&stream, + std::shared_ptr load(Format, std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams&) const override; }; diff --git a/src/content/image/formats/jpeg/JPEGLoader.stbi.cpp b/src/content/image/formats/jpeg/JPEGLoader.stbi.cpp index 53bb291..4768ff1 100644 --- a/src/content/image/formats/jpeg/JPEGLoader.stbi.cpp +++ b/src/content/image/formats/jpeg/JPEGLoader.stbi.cpp @@ -2,14 +2,14 @@ #include "../STBImageLoader.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { namespace JPEG { std::shared_ptr JPEGLoader::load(Format format, - std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) const { + std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) const { return STBImageLoader().load(format, std::move(stream), pixFormat, lp); } diff --git a/src/content/image/formats/png/PNGLoader.cpp b/src/content/image/formats/png/PNGLoader.cpp index 1daa4ab..1c49f9f 100644 --- a/src/content/image/formats/png/PNGLoader.cpp +++ b/src/content/image/formats/png/PNGLoader.cpp @@ -1,7 +1,7 @@ #include "PNGLoader.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { namespace PNG { diff --git a/src/content/image/formats/png/PNGLoader.hpp b/src/content/image/formats/png/PNGLoader.hpp index 1f52d8d..67ed61a 100644 --- a/src/content/image/formats/png/PNGLoader.hpp +++ b/src/content/image/formats/png/PNGLoader.hpp @@ -5,8 +5,8 @@ #include "../../../../io/FileStream.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { namespace PNG { @@ -15,10 +15,10 @@ class PNGLoader final : public ImageLoader { public: std::shared_ptr load(Format format, const std::string &path, PixelFormat pixFormat, const LoadParams &lp) const override { - return load(format, std::make_unique(path), pixFormat, lp); + return load(format, std::make_unique(path), pixFormat, lp); } - std::shared_ptr load(Format format, std::unique_ptr &&stream, + std::shared_ptr load(Format format, std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams&) const override; }; diff --git a/src/content/image/formats/png/PNGLoader.stbi.cpp b/src/content/image/formats/png/PNGLoader.stbi.cpp index 74d1d34..a91c931 100644 --- a/src/content/image/formats/png/PNGLoader.stbi.cpp +++ b/src/content/image/formats/png/PNGLoader.stbi.cpp @@ -2,14 +2,14 @@ #include "../STBImageLoader.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Image { namespace Formats { namespace PNG { std::shared_ptr PNGLoader::load(Format format, - std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) const { + std::unique_ptr &&stream, PixelFormat pixFormat, const LoadParams &lp) const { return STBImageLoader().load(format, std::move(stream), pixFormat, lp); } diff --git a/src/content/texture/TextureLoader.cpp b/src/content/texture/TextureLoader.cpp index b0a83c0..66af093 100644 --- a/src/content/texture/TextureLoader.cpp +++ b/src/content/texture/TextureLoader.cpp @@ -4,8 +4,8 @@ #include "../../render/Renderer.hpp" #include "../../util/ColorUtil.hpp" -namespace Diggler { -namespace Content { +namespace diggler { +namespace content { namespace Texture { using Loading = TextureLoader::Loading; @@ -57,7 +57,7 @@ std::shared_ptr TextureLoader::load(Game &G, Image::Format format, cons } std::shared_ptr TextureLoader::load(Game &G, Image::Format format, - std::unique_ptr &&stream, PixelFormat pixFormat) { + std::unique_ptr &&stream, PixelFormat pixFormat) { LoadParams lp = getLoadParams(pixFormat); std::shared_ptr l = std::make_shared(); lp.userdata = l; diff --git a/src/content/texture/TextureLoader.hpp b/src/content/texture/TextureLoader.hpp index cb9f84d..3b8ee81 100644 --- a/src/content/texture/TextureLoader.hpp +++ b/src/content/texture/TextureLoader.hpp @@ -6,11 +6,11 @@ #include "../../Texture.hpp" #include "../image/ImageLoader.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Content { +namespace content { namespace Texture { class TextureLoader { @@ -20,13 +20,13 @@ public: using LoadParams = Image::ImageLoader::LoadParams; std::shared_ptr imageLoading; - std::shared_ptr texture; + std::shared_ptr texture; }; static std::shared_ptr load(Game&, Image::Format, const std::string &path, PixelFormat pixFormat); - static std::shared_ptr load(Game&, Image::Format, std::unique_ptr &&stream, + static std::shared_ptr load(Game&, Image::Format, std::unique_ptr &&stream, PixelFormat pixFormat); }; diff --git a/src/crypto/CryptoData.hpp b/src/crypto/CryptoData.hpp index 99d91a4..6c51436 100644 --- a/src/crypto/CryptoData.hpp +++ b/src/crypto/CryptoData.hpp @@ -8,7 +8,7 @@ #include -namespace Diggler { +namespace diggler { namespace Crypto { template diff --git a/src/crypto/DiffieHellman.hpp b/src/crypto/DiffieHellman.hpp index d3b327c..c266af1 100644 --- a/src/crypto/DiffieHellman.hpp +++ b/src/crypto/DiffieHellman.hpp @@ -5,7 +5,7 @@ #include "CryptoData.hpp" -namespace Diggler { +namespace diggler { namespace Crypto { namespace DiffieHellman { diff --git a/src/crypto/Random.hpp b/src/crypto/Random.hpp index 6d18382..1701ea6 100644 --- a/src/crypto/Random.hpp +++ b/src/crypto/Random.hpp @@ -6,7 +6,7 @@ #include "CryptoData.hpp" #include "../platform/Types.hpp" -namespace Diggler { +namespace diggler { namespace Crypto { namespace Random { diff --git a/src/crypto/SHA256.hpp b/src/crypto/SHA256.hpp index 38e6f35..ae1a01e 100644 --- a/src/crypto/SHA256.hpp +++ b/src/crypto/SHA256.hpp @@ -5,7 +5,7 @@ #include "CryptoData.hpp" -namespace Diggler { +namespace diggler { namespace Crypto { struct SHA256 { diff --git a/src/crypto/Sign.hpp b/src/crypto/Sign.hpp index f47f4a8..a8576ce 100644 --- a/src/crypto/Sign.hpp +++ b/src/crypto/Sign.hpp @@ -5,7 +5,7 @@ #include "CryptoData.hpp" -namespace Diggler { +namespace diggler { namespace Crypto { namespace Sign { diff --git a/src/crypto/Sodium.hpp b/src/crypto/Sodium.hpp index 3e976e0..a6d557e 100644 --- a/src/crypto/Sodium.hpp +++ b/src/crypto/Sodium.hpp @@ -1,7 +1,7 @@ #ifndef DIGGLER_CRYPTO_SODIUM_HPP #define DIGGLER_CRYPTO_SODIUM_HPP -namespace Diggler { +namespace diggler { namespace Crypto { class Sodium { diff --git a/src/gfx/Command.hpp b/src/gfx/Command.hpp new file mode 100644 index 0000000..1b33c72 --- /dev/null +++ b/src/gfx/Command.hpp @@ -0,0 +1,45 @@ +#ifndef DIGGLER_GFX_COMMAND_HPP +#define DIGGLER_GFX_COMMAND_HPP + +#include + +#include "../platform/Types.hpp" + +namespace diggler { +namespace gfx { + +struct Command { + enum class Class : uint8 { + CommandBuffer, + RenderPass, + Framebuffer, + ShaderModule, + Pipeline, + Buffer, + Texture, + Clear, + Draw, + } klass; + uint8 cmd; +}; + +template +struct ReturnCommand : public Command { + std::promise returnValue; +}; + +namespace cmd { +struct Draw : public Command { + enum class Opacity { + Opaque, + Translucent, + Transparent + } opacity = Opacity::Opaque; // Reorderability + +}; +} + +} +} + +#endif /* DIGGLER_GFX_COMMAND_HPP */ diff --git a/src/gfx/Device.hpp b/src/gfx/Device.hpp new file mode 100644 index 0000000..bad5ec0 --- /dev/null +++ b/src/gfx/Device.hpp @@ -0,0 +1,19 @@ +#ifndef DIGGLER_GFX_DEVICE_HPP +#define DIGGLER_GFX_DEVICE_HPP + +#include "Command.hpp" + +namespace diggler { +namespace gfx { + +class Device { +public: + virtual ~Device() = 0; + + virtual void queue(Command&&); +}; + +} +} + +#endif /* DIGGLER_GFX_DEVICE_HPP */ diff --git a/src/gfx/Texture.hpp b/src/gfx/Texture.hpp new file mode 100644 index 0000000..483819c --- /dev/null +++ b/src/gfx/Texture.hpp @@ -0,0 +1,29 @@ +#ifndef DIGGLER_GFX_TEXTURE_HPP +#define DIGGLER_GFX_TEXTURE_HPP + +namespace diggler { +namespace gfx { + +class Texture { +public: + enum class PixelFormat { + RGB888, + RGBA8888 + }; + + Texture& operator=(const Texture&) = delete; + Texture& operator=(Texture&&) = delete; + + virtual ~Texture() = 0; +}; + +namespace cmd { +struct TextureCreate : public ReturnCommand { + unsigned +}; +} + +} +} + +#endif /* DIGGLER_GFX_TEXTURE_HPP */ diff --git a/src/gfx/gl/.gitkeep b/src/gfx/gl/.gitkeep new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/src/gfx/gl/.gitkeep @@ -0,0 +1 @@ + diff --git a/src/gfx/vk/.gitkeep b/src/gfx/vk/.gitkeep new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/src/gfx/vk/.gitkeep @@ -0,0 +1 @@ + diff --git a/src/io/FileStream.cpp b/src/io/FileStream.cpp index 49c7445..aab426a 100644 --- a/src/io/FileStream.cpp +++ b/src/io/FileStream.cpp @@ -1,7 +1,7 @@ #include "FileStream.hpp" -namespace Diggler { -namespace IO { +namespace diggler { +namespace io { inline std::ios::seekdir getSeekDir(SeekableStream::Whence whence) { switch (whence) { diff --git a/src/io/FileStream.hpp b/src/io/FileStream.hpp index ed4841c..40f12df 100644 --- a/src/io/FileStream.hpp +++ b/src/io/FileStream.hpp @@ -5,8 +5,8 @@ #include "Stream.hpp" -namespace Diggler { -namespace IO { +namespace diggler { +namespace io { class InFileStream : public InSeekableStream, public SizedStream { protected: @@ -14,7 +14,7 @@ protected: public: InFileStream(const std::string &path); - ~InFileStream(); + ~InFileStream() override; SizeT length() const override; @@ -29,7 +29,7 @@ protected: public: OutFileStream(const std::string &path); - ~OutFileStream(); + ~OutFileStream() override; virtual bool eos() const override { return false; diff --git a/src/io/MemoryStream.cpp b/src/io/MemoryStream.cpp index 6493f99..41bfe71 100644 --- a/src/io/MemoryStream.cpp +++ b/src/io/MemoryStream.cpp @@ -4,8 +4,8 @@ #include #include -namespace Diggler { -namespace IO { +namespace diggler { +namespace io { MemoryStream::MemoryStream(void *data, SizeT len) : m_data(static_cast(data)), diff --git a/src/io/MemoryStream.hpp b/src/io/MemoryStream.hpp index aa1381e..c1d619b 100644 --- a/src/io/MemoryStream.hpp +++ b/src/io/MemoryStream.hpp @@ -3,8 +3,8 @@ #include "Stream.hpp" -namespace Diggler { -namespace IO { +namespace diggler { +namespace io { class MemoryStream : public virtual SeekableStream { protected: diff --git a/src/io/Stream.cpp b/src/io/Stream.cpp index bcada42..44832c1 100644 --- a/src/io/Stream.cpp +++ b/src/io/Stream.cpp @@ -19,8 +19,8 @@ * - Backward absolute seekable : can go back anywhere in the stream. Implies Tellable. */ -namespace Diggler { -namespace IO { +namespace diggler { +namespace io { Stream::~Stream() { } diff --git a/src/io/Stream.hpp b/src/io/Stream.hpp index 0b94fec..bcfbd15 100644 --- a/src/io/Stream.hpp +++ b/src/io/Stream.hpp @@ -3,8 +3,8 @@ #include "../Platform.hpp" -namespace Diggler { -namespace IO { +namespace diggler { +namespace io { class Stream { public: diff --git a/src/main.cpp b/src/main.cpp index 528af78..dd86c30 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,10 +4,10 @@ #include #include -#include "ConnectingState.hpp" +#include "states/ConnectingState.hpp" #include "Game.hpp" #include "GameWindow.hpp" -#include "MessageState.hpp" +#include "states/MessageState.hpp" #include "GlobalProperties.hpp" #include "Server.hpp" #include "network/Network.hpp" @@ -15,9 +15,9 @@ #include "util/Log.hpp" #include "util/MemoryTracker.hpp" -#include "UITestState.hpp" +#include "states/UITestState.hpp" -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; @@ -27,8 +27,8 @@ static const char *TAG = "main()"; using std::string; static bool InitNetwork() { - std::cout << Net::GetNetworkLibVersion() << std::endl; - return Net::Init(); + std::cout << net::GetNetworkLibVersion() << std::endl; + return net::Init(); } static void InitRand() { @@ -139,7 +139,7 @@ int main(int argc, char **argv) { /*/GW.setNextState(std::make_shared(&GW));/*/ if (networkSuccess) - GW.setNextState(std::make_unique(&GW, host, port)); + GW.setNextState(std::make_unique(&GW, host, port)); else GW.showMessage("Network init failed!"); /**/ @@ -178,13 +178,13 @@ int wmain(int argc, wchar_t **argv) { WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, u8args[i].get(), len, nullptr, nullptr); u8argv[i] = u8args[i].get(); } - return Diggler::main(argc, u8argv.get()); + return diggler::main(argc, u8argv.get()); } #endif int main(int argc, char **argv) { //try { - return Diggler::main(argc, argv); + return diggler::main(argc, argv); /*} catch (std::exception &e) { std::cerr << "==== CRASHED (std::exception) ===" << std::endl << e.what() << std::endl; } catch (std::string &e) { diff --git a/src/network/ClientMessageHandler.cpp b/src/network/ClientMessageHandler.cpp index aef0d12..44db28a 100644 --- a/src/network/ClientMessageHandler.cpp +++ b/src/network/ClientMessageHandler.cpp @@ -1,6 +1,6 @@ #include "ClientMessageHandler.hpp" -#include "../GameState.hpp" +#include "../states/GameState.hpp" #include "client/BlockUpdateHandler.hpp" #include "client/ContentHandler.hpp" #include "client/ChatHandler.hpp" @@ -9,35 +9,36 @@ #include "client/PlayerUpdateHandler.hpp" #include "client/PlayerQuitHandler.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { -ClientMessageHandler::ClientMessageHandler(GameState &gameState) : +ClientMessageHandler::ClientMessageHandler(states::GameState &gameState) : GS(gameState) { } bool ClientMessageHandler::handleMessage(InMessage &msg) { - using namespace Net::MsgTypes; + using namespace net::MsgTypes; + Game &G = *GS.G; switch (msg.getType()) { case MessageType::NetDisconnect: GS.GW->showMessage("Disconnected", "Timed out"); return false; case MessageType::ChunkTransfer: - return Client::ChunkTransferHandler::handle(GS, msg); + return Client::ChunkTransferHandler::handle(G, msg); case MessageType::Chat: - return Client::ChatHandler::handle(GS, msg); + return Client::ChatHandler::handle(G, msg); case MessageType::PlayerJoin: - return Client::PlayerJoinHandler::handle(GS, msg); + return Client::PlayerJoinHandler::handle(G, msg); case MessageType::PlayerQuit: - return Client::PlayerQuitHandler::handle(GS, msg); + return Client::PlayerQuitHandler::handle(G, msg); case MessageType::PlayerUpdate: - return Client::PlayerUpdateHandler::handle(GS, msg); + return Client::PlayerUpdateHandler::handle(G, msg); case MessageType::BlockUpdate: - return Client::BlockUpdateHandler::handle(GS, msg); + return Client::BlockUpdateHandler::handle(G, msg); case MessageType::ServerInfo: case MessageType::NetConnect: diff --git a/src/network/ClientMessageHandler.hpp b/src/network/ClientMessageHandler.hpp index 8494c50..a672244 100644 --- a/src/network/ClientMessageHandler.hpp +++ b/src/network/ClientMessageHandler.hpp @@ -3,17 +3,19 @@ #include "Network.hpp" -namespace Diggler { +namespace diggler { +namespace states { class GameState; +} -namespace Net { +namespace net { class ClientMessageHandler { public: - GameState &GS; + states::GameState &GS; - ClientMessageHandler(GameState&); + ClientMessageHandler(states::GameState&); bool handleMessage(InMessage&); }; diff --git a/src/network/NetHelper.cpp b/src/network/NetHelper.cpp index 9b0ae2e..a2bb299 100644 --- a/src/network/NetHelper.cpp +++ b/src/network/NetHelper.cpp @@ -7,9 +7,9 @@ #include "../Player.hpp" #include "../Server.hpp" -namespace Diggler { +namespace diggler { -using namespace Net; +using namespace net; namespace NetHelper { @@ -24,7 +24,7 @@ void Broadcast(Game &G, const OutMessage &msg, Tfer tfer, Channels chan) { } void SendChat(Game *G, const std::string &str) { - Net::MsgTypes::ChatSend cs; + net::MsgTypes::ChatSend cs; cs.msg = meiose::variant::map { {"plaintext", str} }; diff --git a/src/network/NetHelper.hpp b/src/network/NetHelper.hpp index 8119f4e..2b3ce41 100644 --- a/src/network/NetHelper.hpp +++ b/src/network/NetHelper.hpp @@ -3,7 +3,7 @@ #include #include "Network.hpp" -namespace Diggler { +namespace diggler { class Player; class Game; @@ -11,13 +11,13 @@ class Game; namespace NetHelper { // Server only -void Broadcast(Game*, const Net::OutMessage&, Net::Tfer = Net::Tfer::Rel, Net::Channels = Net::Channels::Base); -void Broadcast(Game&, const Net::OutMessage&, Net::Tfer = Net::Tfer::Rel, Net::Channels = Net::Channels::Base); -void MakeEvent(Net::OutMessage&, Net::EventType, const glm::vec3&); -void MakeEvent(Net::OutMessage&, Net::EventType, const Player&); +void Broadcast(Game*, const net::OutMessage&, net::Tfer = net::Tfer::Rel, net::Channels = net::Channels::Base); +void Broadcast(Game&, const net::OutMessage&, net::Tfer = net::Tfer::Rel, net::Channels = net::Channels::Base); +void MakeEvent(net::OutMessage&, net::EventType, const glm::vec3&); +void MakeEvent(net::OutMessage&, net::EventType, const Player&); // Client only -void SendEvent(Game*, Net::EventType); +void SendEvent(Game*, net::EventType); void SendChat(Game*, const std::string&); diff --git a/src/network/Network.cpp b/src/network/Network.cpp index e4a9c45..47d0405 100644 --- a/src/network/Network.cpp +++ b/src/network/Network.cpp @@ -28,9 +28,9 @@ struct membuf : std::streambuf { }; class omsgbuf : public std::streambuf { protected: - Diggler::Net::OutMessage &omsg; + diggler::net::OutMessage &omsg; public: - omsgbuf(Diggler::Net::OutMessage &o) : omsg(o) {} + omsgbuf(diggler::net::OutMessage &o) : omsg(o) {} protected: std::streamsize xsputn(const char_type* s, std::streamsize n) override { omsg.writeData(s, n); @@ -42,8 +42,8 @@ protected: } }; -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { using Util::Log; using namespace Util::Logging::LogLevels; diff --git a/src/network/Network.hpp b/src/network/Network.hpp index 40ccba5..cc36d12 100644 --- a/src/network/Network.hpp +++ b/src/network/Network.hpp @@ -15,8 +15,8 @@ namespace meiose { class variant; } -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { bool Init(); void DeInit(); @@ -71,7 +71,7 @@ enum QuitReason : uint8 { using EventType = uint32; -class Message : public virtual IO::MemoryStream { +class Message : public virtual io::MemoryStream { protected: friend class Host; MessageType m_type; @@ -95,7 +95,7 @@ public: inline T getSubtype() const { return static_cast(m_subtype); } }; -class InMessage : public Message, public IO::InMemoryStream { +class InMessage : public Message, public io::InMemoryStream { protected: friend class Host; Channels m_chan; @@ -122,7 +122,7 @@ public: Channels getChannel() const; }; -class OutMessage : public Message, public IO::OutMemoryStream { +class OutMessage : public Message, public io::OutMemoryStream { protected: friend class Host; mutable uint8 *m_actualData; diff --git a/src/network/client/BlockUpdateHandler.cpp b/src/network/client/BlockUpdateHandler.cpp index 804b091..475995a 100644 --- a/src/network/client/BlockUpdateHandler.cpp +++ b/src/network/client/BlockUpdateHandler.cpp @@ -1,16 +1,15 @@ #include "BlockUpdateHandler.hpp" #include "../../Game.hpp" -#include "../../GameState.hpp" #include "../msgtypes/BlockUpdate.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { -using namespace Net::MsgTypes; +using namespace net::MsgTypes; -bool BlockUpdateHandler::handle(GameState &GS, InMessage &msg) { +bool BlockUpdateHandler::handle(Game &G, InMessage &msg) { // TODO handle that in Chunk's ChangeHelper using S = BlockUpdateSubtype; constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ; @@ -19,7 +18,7 @@ bool BlockUpdateHandler::handle(GameState &GS, InMessage &msg) { BlockUpdateNotify bun; bun.readFromMsg(msg); for (const BlockUpdateNotify::UpdateData &upd : bun.updates) { - WorldRef w = GS.G->U->getWorld(upd.worldId); + WorldRef w = G.U->getWorld(upd.worldId); if (w) { ChunkRef c = w->getChunkAtCoords(upd.pos); if (c) { diff --git a/src/network/client/BlockUpdateHandler.hpp b/src/network/client/BlockUpdateHandler.hpp index ece7215..f6fb888 100644 --- a/src/network/client/BlockUpdateHandler.hpp +++ b/src/network/client/BlockUpdateHandler.hpp @@ -3,13 +3,13 @@ #include "Handler.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { class BlockUpdateHandler : public Handler { public: - static bool handle(GameState&, InMessage&); + static bool handle(Game&, InMessage&); }; } diff --git a/src/network/client/ChatHandler.cpp b/src/network/client/ChatHandler.cpp index 73fecac..a82af81 100644 --- a/src/network/client/ChatHandler.cpp +++ b/src/network/client/ChatHandler.cpp @@ -2,16 +2,18 @@ #include "../../Chatbox.hpp" #include "../../Game.hpp" -#include "../../GameState.hpp" +#include "../../states/GameState.hpp" #include "../msgtypes/Chat.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { -using namespace Net::MsgTypes; +using namespace net::MsgTypes; -bool ChatHandler::handle(GameState &GS, InMessage &msg) { +bool ChatHandler::handle(Game &G, InMessage &msg) { + // TODO: get rid of + states::GameState &GS = static_cast(G.GW->state()); using S = ChatSubtype; switch (msg.getSubtype()) { case S::Send: { @@ -32,7 +34,7 @@ bool ChatHandler::handle(GameState &GS, InMessage &msg) { if (cpt.msg.isStr()) { std::string playerName; if (cpt.player.display.isNil()) { - const Player *blabbermouth = GS.G->players.getBySessId(cpt.player.id); + const Player *blabbermouth = G.players.getBySessId(cpt.player.id); if (blabbermouth != nullptr) { playerName = blabbermouth->name + "> "; } else { diff --git a/src/network/client/ChatHandler.hpp b/src/network/client/ChatHandler.hpp index 232c472..c994606 100644 --- a/src/network/client/ChatHandler.hpp +++ b/src/network/client/ChatHandler.hpp @@ -3,13 +3,13 @@ #include "Handler.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { class ChatHandler : public Handler { public: - static bool handle(GameState&, InMessage&); + static bool handle(Game&, InMessage&); }; } diff --git a/src/network/client/ChunkTransferHandler.cpp b/src/network/client/ChunkTransferHandler.cpp index d63991c..185b24a 100644 --- a/src/network/client/ChunkTransferHandler.cpp +++ b/src/network/client/ChunkTransferHandler.cpp @@ -1,16 +1,16 @@ #include "ChunkTransferHandler.hpp" #include "../../Game.hpp" -#include "../../GameState.hpp" +#include "../../states/GameState.hpp" #include "../msgtypes/ChunkTransfer.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { -using namespace Net::MsgTypes; +using namespace net::MsgTypes; -bool ChunkTransferHandler::handle(GameState &GS, InMessage &msg) { +bool ChunkTransferHandler::handle(Game &G, InMessage &msg) { using S = ChunkTransferSubtype; switch (msg.getSubtype()) { case S::Request: { @@ -20,11 +20,11 @@ bool ChunkTransferHandler::handle(GameState &GS, InMessage &msg) { ChunkTransferResponse ctr; ctr.readFromMsg(msg); for (const ChunkTransferResponse::ChunkData &cd : ctr.chunks) { - ChunkRef c = GS.G->U->getLoadWorld(cd.worldId)->getNewEmptyChunk( + ChunkRef c = G.U->getLoadWorld(cd.worldId)->getNewEmptyChunk( cd.chunkPos.x, cd.chunkPos.y, cd.chunkPos.z); - IO::InMemoryStream ims(cd.data, cd.dataLength); + io::InMemoryStream ims(cd.data, cd.dataLength); c->read(ims); - GS.holdChunksInMem.push_back(c); + static_cast(G.GW->state()).holdChunksInMem.push_back(c); } } break; case S::Denied: { diff --git a/src/network/client/ChunkTransferHandler.hpp b/src/network/client/ChunkTransferHandler.hpp index eef8460..ecae1e2 100644 --- a/src/network/client/ChunkTransferHandler.hpp +++ b/src/network/client/ChunkTransferHandler.hpp @@ -3,13 +3,13 @@ #include "Handler.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { class ChunkTransferHandler : public Handler { public: - static bool handle(GameState&, InMessage&); + static bool handle(Game&, InMessage&); }; } diff --git a/src/network/client/ContentHandler.cpp b/src/network/client/ContentHandler.cpp index faf6eda..5c7f400 100644 --- a/src/network/client/ContentHandler.cpp +++ b/src/network/client/ContentHandler.cpp @@ -1,15 +1,14 @@ #include "ContentHandler.hpp" -#include "../../GameState.hpp" #include "../msgtypes/Content.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { -using namespace Net::MsgTypes; +using namespace net::MsgTypes; -bool ContentHandler::handle(GameState &GS, InMessage &msg) { +bool ContentHandler::handle(Game &G, InMessage &msg) { using S = ContentSubtype; switch (msg.getSubtype()) { case S::AssetResponse: { diff --git a/src/network/client/ContentHandler.hpp b/src/network/client/ContentHandler.hpp index addcac4..a472fea 100644 --- a/src/network/client/ContentHandler.hpp +++ b/src/network/client/ContentHandler.hpp @@ -3,13 +3,13 @@ #include "Handler.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { class ContentHandler : public Handler { public: - static bool handle(GameState&, InMessage&); + static bool handle(Game&, InMessage&); }; } diff --git a/src/network/client/Handler.hpp b/src/network/client/Handler.hpp index e9cec27..1121e07 100644 --- a/src/network/client/Handler.hpp +++ b/src/network/client/Handler.hpp @@ -1,11 +1,11 @@ #ifndef DIGGLER_NET_CLIENT_HANDLER_HPP #define DIGGLER_NET_CLIENT_HANDLER_HPP -namespace Diggler { +namespace diggler { -class GameState; +class Game; -namespace Net { +namespace net { class InMessage; diff --git a/src/network/client/PlayerJoinHandler.cpp b/src/network/client/PlayerJoinHandler.cpp index e6042d7..7293911 100644 --- a/src/network/client/PlayerJoinHandler.cpp +++ b/src/network/client/PlayerJoinHandler.cpp @@ -1,27 +1,26 @@ #include "PlayerJoinHandler.hpp" #include "../../Game.hpp" -#include "../../GameState.hpp" #include "../../util/Log.hpp" #include "../msgtypes/PlayerJoin.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { -using namespace Net::MsgTypes; +using namespace net::MsgTypes; using Util::Log; using namespace Util::Logging::LogLevels; static const char *TAG = "CNH:PlayerJoin"; -bool PlayerJoinHandler::handle(GameState &GS, InMessage &msg) { +bool PlayerJoinHandler::handle(Game &G, InMessage &msg) { using S = PlayerJoinSubtype; switch (msg.getSubtype()) { case S::Broadcast: { PlayerJoinBroadcast pjb; pjb.readFromMsg(msg); - Player &plr = GS.G->players.add(); + Player &plr = G.players.add(); plr.sessId = pjb.sessId; plr.name = pjb.name; Log(Info, TAG) << "Player " << pjb.name << '(' << pjb.sessId << ") joined the party!"; diff --git a/src/network/client/PlayerJoinHandler.hpp b/src/network/client/PlayerJoinHandler.hpp index 5774b42..e3acc41 100644 --- a/src/network/client/PlayerJoinHandler.hpp +++ b/src/network/client/PlayerJoinHandler.hpp @@ -3,13 +3,13 @@ #include "Handler.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { class PlayerJoinHandler : public Handler { public: - static bool handle(GameState&, InMessage&); + static bool handle(Game&, InMessage&); }; } diff --git a/src/network/client/PlayerQuitHandler.cpp b/src/network/client/PlayerQuitHandler.cpp index d4b4d65..77e0e5a 100644 --- a/src/network/client/PlayerQuitHandler.cpp +++ b/src/network/client/PlayerQuitHandler.cpp @@ -1,26 +1,25 @@ #include "PlayerQuitHandler.hpp" #include "../../Game.hpp" -#include "../../GameState.hpp" #include "../../util/Log.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { -using namespace Net::MsgTypes; +using namespace net::MsgTypes; using Util::Log; using namespace Util::Logging::LogLevels; static const char *TAG = "CNH:PlayerQuit"; -bool PlayerQuitHandler::handle(GameState &GS, InMessage &msg) { +bool PlayerQuitHandler::handle(Game &G, InMessage &msg) { uint32 id = msg.readU32(); try { - Player *plr = GS.G->players.getBySessId(id); + Player *plr = G.players.getBySessId(id); if (plr != nullptr) { Log(Debug, TAG) << plr->name << " is gone :("; - GS.G->players.remove(*plr); + G.players.remove(*plr); } } catch (const std::out_of_range &e) { Log(Debug, TAG) << "Phantom player #" << id << " disconnected"; diff --git a/src/network/client/PlayerQuitHandler.hpp b/src/network/client/PlayerQuitHandler.hpp index b1db079..18b5f1c 100644 --- a/src/network/client/PlayerQuitHandler.hpp +++ b/src/network/client/PlayerQuitHandler.hpp @@ -3,13 +3,13 @@ #include "Handler.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { class PlayerQuitHandler : public Handler { public: - static bool handle(GameState&, InMessage&); + static bool handle(Game&, InMessage&); }; } diff --git a/src/network/client/PlayerUpdateHandler.cpp b/src/network/client/PlayerUpdateHandler.cpp index e16d4fd..450467b 100644 --- a/src/network/client/PlayerUpdateHandler.cpp +++ b/src/network/client/PlayerUpdateHandler.cpp @@ -1,21 +1,20 @@ #include "PlayerUpdateHandler.hpp" #include "../../Game.hpp" -#include "../../GameState.hpp" #include "../../util/Log.hpp" #include "../msgtypes/PlayerUpdate.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { -using namespace Net::MsgTypes; +using namespace net::MsgTypes; using Util::Log; using namespace Util::Logging::LogLevels; static const char *TAG = "CNH:PlayerUpdate"; -bool PlayerUpdateHandler::handle(GameState &GS, InMessage &msg) { +bool PlayerUpdateHandler::handle(Game &G, InMessage &msg) { using S = PlayerUpdateSubtype; switch (msg.getSubtype()) { case S::Move: { @@ -25,7 +24,7 @@ bool PlayerUpdateHandler::handle(GameState &GS, InMessage &msg) { Log(Debug, TAG) << "Move without player session ID"; return true; } - Player *plr = GS.G->players.getBySessId(*pum.plrSessId); + Player *plr = G.players.getBySessId(*pum.plrSessId); if (!plr) { Log(Debug, TAG) <<"Move: sess#" << *pum.plrSessId << " is not on server"; @@ -40,7 +39,7 @@ bool PlayerUpdateHandler::handle(GameState &GS, InMessage &msg) { case S::Die: { PlayerUpdateDie pud; pud.readFromMsg(msg); - Player *plr = GS.G->players.getBySessId(pud.plrSessId); + Player *plr = G.players.getBySessId(pud.plrSessId); if (!plr) { Log(Debug, TAG) << "Die: sess#" << pud.plrSessId << " is not on server"; @@ -51,7 +50,7 @@ bool PlayerUpdateHandler::handle(GameState &GS, InMessage &msg) { case S::Respawn: { PlayerUpdateRespawn pur; pur.readFromMsg(msg); - Player *plr = GS.G->players.getBySessId(pur.plrSessId); + Player *plr = G.players.getBySessId(pur.plrSessId); if (!plr) { Log(Debug, TAG) << "Respawn: sess#" << pur.plrSessId << " is not on server"; diff --git a/src/network/client/PlayerUpdateHandler.hpp b/src/network/client/PlayerUpdateHandler.hpp index 5574532..c28255f 100644 --- a/src/network/client/PlayerUpdateHandler.hpp +++ b/src/network/client/PlayerUpdateHandler.hpp @@ -3,13 +3,13 @@ #include "Handler.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace Client { class PlayerUpdateHandler : public Handler { public: - static bool handle(GameState&, InMessage&); + static bool handle(Game&, InMessage&); }; } diff --git a/src/network/msgtypes/BlockUpdate.cpp b/src/network/msgtypes/BlockUpdate.cpp index a3d01d1..f67373c 100644 --- a/src/network/msgtypes/BlockUpdate.cpp +++ b/src/network/msgtypes/BlockUpdate.cpp @@ -3,8 +3,8 @@ #include #include -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { void BlockUpdateNotify::writeToMsg(OutMessage &msg) const { diff --git a/src/network/msgtypes/BlockUpdate.hpp b/src/network/msgtypes/BlockUpdate.hpp index 3b2aa61..358fe46 100644 --- a/src/network/msgtypes/BlockUpdate.hpp +++ b/src/network/msgtypes/BlockUpdate.hpp @@ -8,8 +8,8 @@ #include "../../content/Content.hpp" #include "../../World.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum class BlockUpdateSubtype : uint8 { diff --git a/src/network/msgtypes/Chat.cpp b/src/network/msgtypes/Chat.cpp index a730d63..045c5ed 100644 --- a/src/network/msgtypes/Chat.cpp +++ b/src/network/msgtypes/Chat.cpp @@ -1,7 +1,7 @@ #include "Chat.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { void ChatSend::writeToMsg(OutMessage &omsg) const { diff --git a/src/network/msgtypes/Chat.hpp b/src/network/msgtypes/Chat.hpp index a8a76c1..f6bf5e3 100644 --- a/src/network/msgtypes/Chat.hpp +++ b/src/network/msgtypes/Chat.hpp @@ -7,8 +7,8 @@ #include "../../Player.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum class ChatSubtype : uint8 { diff --git a/src/network/msgtypes/ChunkTransfer.cpp b/src/network/msgtypes/ChunkTransfer.cpp index 13cd51a..af11086 100644 --- a/src/network/msgtypes/ChunkTransfer.cpp +++ b/src/network/msgtypes/ChunkTransfer.cpp @@ -1,7 +1,7 @@ #include "ChunkTransfer.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { void ChunkTransferRequest::writeToMsg(OutMessage &msg) const { diff --git a/src/network/msgtypes/ChunkTransfer.hpp b/src/network/msgtypes/ChunkTransfer.hpp index deb6a53..b887b47 100644 --- a/src/network/msgtypes/ChunkTransfer.hpp +++ b/src/network/msgtypes/ChunkTransfer.hpp @@ -8,8 +8,8 @@ #include "../../Chunk.hpp" #include "../../World.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum class ChunkTransferSubtype : uint8 { diff --git a/src/network/msgtypes/ConnectionParam.cpp b/src/network/msgtypes/ConnectionParam.cpp index a93f3d1..4956226 100644 --- a/src/network/msgtypes/ConnectionParam.cpp +++ b/src/network/msgtypes/ConnectionParam.cpp @@ -1,7 +1,7 @@ #include "ConnectionParam.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { void ConnectionParamDHKeyExchange::writeToMsg(OutMessage &msg) const { diff --git a/src/network/msgtypes/ConnectionParam.hpp b/src/network/msgtypes/ConnectionParam.hpp index a25b863..2dc92a9 100644 --- a/src/network/msgtypes/ConnectionParam.hpp +++ b/src/network/msgtypes/ConnectionParam.hpp @@ -5,8 +5,8 @@ #include "../../crypto/DiffieHellman.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum class ConnectionParamSubtype : uint8 { diff --git a/src/network/msgtypes/Content.cpp b/src/network/msgtypes/Content.cpp index c378426..a7fa0d2 100644 --- a/src/network/msgtypes/Content.cpp +++ b/src/network/msgtypes/Content.cpp @@ -1,7 +1,7 @@ #include "Content.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { void ContentModListRequest::writeToMsg(OutMessage&) const { @@ -15,7 +15,7 @@ void ContentModListRequest::readFromMsg(InMessage&) { void ContentModListResponse::writeToMsg(OutMessage &msg) const { msg.writeI32(modsIds.size()); - for (const Content::ModId &modId : modsIds) { + for (const content::ModId &modId : modsIds) { msg.writeData(&modId, sizeof(modId)); } } diff --git a/src/network/msgtypes/Content.hpp b/src/network/msgtypes/Content.hpp index c9c538b..88a8021 100644 --- a/src/network/msgtypes/Content.hpp +++ b/src/network/msgtypes/Content.hpp @@ -8,8 +8,8 @@ #include "../../content/Mod.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum class ContentSubtype : uint8 { @@ -33,7 +33,7 @@ struct ContentModListRequest : public MsgType { }; struct ContentModListResponse : public MsgType { - std::vector modsIds; + std::vector modsIds; void writeToMsg(OutMessage&) const override; void readFromMsg(InMessage&) override; @@ -44,7 +44,7 @@ struct ContentModInfoRequest : public ContentModListResponse { }; struct ContentModInfoResponse : public MsgType { - // TODO std::map mods; + // TODO std::map mods; void writeToMsg(OutMessage&) const override; void readFromMsg(InMessage&) override; diff --git a/src/network/msgtypes/MsgType.hpp b/src/network/msgtypes/MsgType.hpp index 4d5dd3b..f232d69 100644 --- a/src/network/msgtypes/MsgType.hpp +++ b/src/network/msgtypes/MsgType.hpp @@ -3,8 +3,8 @@ #include "../Network.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { struct MsgType { diff --git a/src/network/msgtypes/PlayerJoin.cpp b/src/network/msgtypes/PlayerJoin.cpp index 3206463..24a0915 100644 --- a/src/network/msgtypes/PlayerJoin.cpp +++ b/src/network/msgtypes/PlayerJoin.cpp @@ -1,7 +1,7 @@ #include "PlayerJoin.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { void PlayerJoinRequest::writeToMsg(OutMessage &msg) const { diff --git a/src/network/msgtypes/PlayerJoin.hpp b/src/network/msgtypes/PlayerJoin.hpp index a3c66ec..624c55d 100644 --- a/src/network/msgtypes/PlayerJoin.hpp +++ b/src/network/msgtypes/PlayerJoin.hpp @@ -4,8 +4,8 @@ #include "MsgType.hpp" #include "../../Player.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum class PlayerJoinSubtype : uint8 { diff --git a/src/network/msgtypes/PlayerUpdate.cpp b/src/network/msgtypes/PlayerUpdate.cpp index 9d92bc4..1545c00 100644 --- a/src/network/msgtypes/PlayerUpdate.cpp +++ b/src/network/msgtypes/PlayerUpdate.cpp @@ -1,7 +1,7 @@ #include "PlayerUpdate.hpp" -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum FieldFlags { diff --git a/src/network/msgtypes/PlayerUpdate.hpp b/src/network/msgtypes/PlayerUpdate.hpp index a373390..a31c3c5 100644 --- a/src/network/msgtypes/PlayerUpdate.hpp +++ b/src/network/msgtypes/PlayerUpdate.hpp @@ -6,8 +6,8 @@ #include "MsgType.hpp" #include "../../Player.hpp" // for DeathReason -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum class PlayerUpdateSubtype : uint8 { diff --git a/src/network/msgtypes/ServerInfo.cpp b/src/network/msgtypes/ServerInfo.cpp index 74c85e2..b1fd8b7 100644 --- a/src/network/msgtypes/ServerInfo.cpp +++ b/src/network/msgtypes/ServerInfo.cpp @@ -3,8 +3,8 @@ #include #include -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { void ServerInfoRequest::readFromMsg(InMessage &msg) { diff --git a/src/network/msgtypes/ServerInfo.hpp b/src/network/msgtypes/ServerInfo.hpp index 91cdcbe..2007e2d 100644 --- a/src/network/msgtypes/ServerInfo.hpp +++ b/src/network/msgtypes/ServerInfo.hpp @@ -5,8 +5,8 @@ #include -namespace Diggler { -namespace Net { +namespace diggler { +namespace net { namespace MsgTypes { enum class ServerInfoSubtype : uint8 { diff --git a/src/platform/Endian.hpp b/src/platform/Endian.hpp index 609fed7..6cad94d 100644 --- a/src/platform/Endian.hpp +++ b/src/platform/Endian.hpp @@ -3,7 +3,7 @@ #include -namespace Diggler { +namespace diggler { constexpr uint16_t byteSwap16(uint16_t x) { #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) diff --git a/src/platform/FastRand.cpp b/src/platform/FastRand.cpp index 384dc3e..d016469 100644 --- a/src/platform/FastRand.cpp +++ b/src/platform/FastRand.cpp @@ -2,7 +2,7 @@ #include -namespace Diggler { +namespace diggler { uint FastRandInit() { static std::random_device rd; diff --git a/src/platform/FastRand.hpp b/src/platform/FastRand.hpp index f6d0d06..0fccdf0 100644 --- a/src/platform/FastRand.hpp +++ b/src/platform/FastRand.hpp @@ -3,7 +3,7 @@ #include "Types.hpp" -namespace Diggler { +namespace diggler { uint FastRandInit(); static thread_local uint FastRand_Seed = FastRandInit(); diff --git a/src/platform/FourCC.hpp b/src/platform/FourCC.hpp index 1d10343..846c613 100644 --- a/src/platform/FourCC.hpp +++ b/src/platform/FourCC.hpp @@ -3,7 +3,7 @@ #include "Types.hpp" -namespace Diggler { +namespace diggler { using FourCC = uint32; diff --git a/src/platform/Math.hpp b/src/platform/Math.hpp index 6eecf30..a9b2df2 100644 --- a/src/platform/Math.hpp +++ b/src/platform/Math.hpp @@ -1,7 +1,7 @@ #ifndef DIGGLER_PLATFORM_MATH_HPP #define DIGGLER_PLATFORM_MATH_HPP -namespace Diggler { +namespace diggler { /// /// Real Modulus diff --git a/src/platform/Types.hpp b/src/platform/Types.hpp index e41c060..e229e47 100644 --- a/src/platform/Types.hpp +++ b/src/platform/Types.hpp @@ -4,7 +4,7 @@ #include #include -namespace Diggler { +namespace diggler { using uint = std::uint32_t; using uint32 = std::uint32_t; diff --git a/src/platform/fs.cpp b/src/platform/fs.cpp index 152cbfd..5831b59 100644 --- a/src/platform/fs.cpp +++ b/src/platform/fs.cpp @@ -10,12 +10,12 @@ #include #include "Fixes.hpp" -std::string Diggler::fs::getParent(const std::string &path) { +std::string diggler::fs::getParent(const std::string &path) { auto slash = path.find_last_of('/'), backslash = path.find_last_of('\\'); return path.substr(std::max(slash, backslash)); } -std::vector Diggler::fs::getContents(const std::string &path) { +std::vector diggler::fs::getContents(const std::string &path) { WIN32_FIND_DATA fdFile; HANDLE hFind = NULL; wchar_t sPath[2048]; @@ -38,7 +38,7 @@ std::vector Diggler::fs::getContents(const std::string &path) { return entities; } -std::vector Diggler::fs::getDirs(const std::string &path) { +std::vector diggler::fs::getDirs(const std::string &path) { WIN32_FIND_DATA fdFile; HANDLE hFind = NULL; wchar_t sPath[2048]; @@ -63,7 +63,7 @@ std::vector Diggler::fs::getDirs(const std::string &path) { return entities; } -std::vector Diggler::fs::getFiles(const std::string &path) { +std::vector diggler::fs::getFiles(const std::string &path) { WIN32_FIND_DATA fdFile; HANDLE hFind = NULL; wchar_t sPath[2048]; @@ -88,7 +88,7 @@ std::vector Diggler::fs::getFiles(const std::string &path) { return entities; } -inline bool Diggler::fs::isDir(const std::string &path) { +inline bool diggler::fs::isDir(const std::string &path) { wchar_t szPath[2048]; MultiByteToWideChar(CP_UTF8, 0, path.data(), path.size(), szPath, 2048); DWORD dwAttrib = GetFileAttributes(szPath); @@ -119,17 +119,17 @@ std::string do_readlink(const std::string &path) { return do_readlink(path.c_str()); } -std::string Diggler::fs::pathCat(const std::string &first, const std::string &second) { +std::string diggler::fs::pathCat(const std::string &first, const std::string &second) { if(first.at(first.length()-1) == '/') return first + second; return first + '/' + second; } -std::string Diggler::fs::getParent(const std::string &path) { +std::string diggler::fs::getParent(const std::string &path) { return path.substr(path.find_last_of('/')); } -std::vector Diggler::fs::getContents(const std::string &path) { +std::vector diggler::fs::getContents(const std::string &path) { DIR *dir = opendir(path.c_str()); if(dir == 0) return std::vector(); @@ -144,7 +144,7 @@ std::vector Diggler::fs::getContents(const std::string &path) { return entitys; } -std::vector Diggler::fs::getDirs(const std::string &path) { +std::vector diggler::fs::getDirs(const std::string &path) { DIR *dir = opendir(path.c_str()); if(dir == 0) return std::vector(); @@ -160,7 +160,7 @@ std::vector Diggler::fs::getDirs(const std::string &path) { return entitys; } -std::vector Diggler::fs::getFiles(const std::string &path) { +std::vector diggler::fs::getFiles(const std::string &path) { DIR *dir = opendir(path.c_str()); if(dir == 0) return std::vector(); @@ -176,7 +176,7 @@ std::vector Diggler::fs::getFiles(const std::string &path) { return entitys; } -inline bool Diggler::fs::isDir(const std::string &path) { +inline bool diggler::fs::isDir(const std::string &path) { DIR *dir = opendir(path.c_str()); if(dir) { @@ -192,7 +192,7 @@ inline bool Diggler::fs::isDir(const std::string &path) { #endif -namespace Diggler { +namespace diggler { namespace fs { std::string readFile(const std::string &path) { diff --git a/src/platform/fs.hpp b/src/platform/fs.hpp index 264f7c7..d523fa5 100644 --- a/src/platform/fs.hpp +++ b/src/platform/fs.hpp @@ -4,7 +4,7 @@ #include #include -namespace Diggler { +namespace diggler { namespace fs { /** diff --git a/src/platform/types/mat2.hpp b/src/platform/types/mat2.hpp index efcf0dc..e9c3418 100644 --- a/src/platform/types/mat2.hpp +++ b/src/platform/types/mat2.hpp @@ -5,7 +5,7 @@ #include "../Types.hpp" -namespace Diggler { +namespace diggler { using mat2f = glm::tmat2x2; using mat2d = glm::tmat2x2; diff --git a/src/platform/types/mat3.hpp b/src/platform/types/mat3.hpp index af9999c..2bb27fd 100644 --- a/src/platform/types/mat3.hpp +++ b/src/platform/types/mat3.hpp @@ -5,7 +5,7 @@ #include "../Types.hpp" -namespace Diggler { +namespace diggler { using mat3f = glm::tmat3x3; using mat3d = glm::tmat3x3; diff --git a/src/platform/types/mat4.hpp b/src/platform/types/mat4.hpp index 583a8e1..7bd9313 100644 --- a/src/platform/types/mat4.hpp +++ b/src/platform/types/mat4.hpp @@ -5,7 +5,7 @@ #include "../Types.hpp" -namespace Diggler { +namespace diggler { using mat4f = glm::tmat4x4; using mat4d = glm::tmat4x4; diff --git a/src/platform/types/vec2.hpp b/src/platform/types/vec2.hpp index 40a5bcd..1b3c5e9 100644 --- a/src/platform/types/vec2.hpp +++ b/src/platform/types/vec2.hpp @@ -5,7 +5,7 @@ #include "../Types.hpp" -namespace Diggler { +namespace diggler { using vec2u8 = glm::tvec2; using vec2u16 = glm::tvec2; diff --git a/src/platform/types/vec3.hpp b/src/platform/types/vec3.hpp index 6320b58..421c3fa 100644 --- a/src/platform/types/vec3.hpp +++ b/src/platform/types/vec3.hpp @@ -5,7 +5,7 @@ #include "../Types.hpp" -namespace Diggler { +namespace diggler { using vec3u8 = glm::tvec3; using vec3u16 = glm::tvec3; diff --git a/src/platform/types/vec4.hpp b/src/platform/types/vec4.hpp index dea8fac..275fcc9 100644 --- a/src/platform/types/vec4.hpp +++ b/src/platform/types/vec4.hpp @@ -5,7 +5,7 @@ #include "../Types.hpp" -namespace Diggler { +namespace diggler { using vec4u8 = glm::tvec4; using vec4u16 = glm::tvec4; diff --git a/src/render/FontRenderer.hpp b/src/render/FontRenderer.hpp index 8eb3667..4d78bd3 100644 --- a/src/render/FontRenderer.hpp +++ b/src/render/FontRenderer.hpp @@ -8,8 +8,8 @@ #include "../platform/PreprocUtils.hpp" #include "../ui/Font.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { class FontRendererTextBuffer { protected: @@ -30,10 +30,10 @@ inline FontRendererTextBuffer::~FontRendererTextBuffer() {} class FontRenderer { protected: - inline uintptr_t getRendererData(const UI::Font &f) const { + inline uintptr_t getRendererData(const ui::Font &f) const { return f.rendererData; } - inline void setRendererData(UI::Font &f, uintptr_t data) const { + inline void setRendererData(ui::Font &f, uintptr_t data) const { f.rendererData = data; } @@ -44,15 +44,15 @@ public: FontRenderer() {} virtual ~FontRenderer() = 0; - virtual void registerFont(UI::Font&) = 0; - virtual void unregisterFont(UI::Font&) = 0; + virtual void registerFont(ui::Font&) = 0; + virtual void unregisterFont(ui::Font&) = 0; virtual TextBufferRef createTextBuffer( FontRendererTextBufferUsage = FontRendererTextBufferUsage::Default) = 0; virtual void updateTextBuffer(TextBufferRef&, const TextBuffer::Vertex *vertices, uint vertexCount) = 0; - virtual void render(const UI::Font&, const TextBufferRef&, const glm::mat4&) = 0; + virtual void render(const ui::Font&, const TextBufferRef&, const glm::mat4&) = 0; }; inline FontRenderer::~FontRenderer() {} diff --git a/src/render/FontRendererFwd.hpp b/src/render/FontRendererFwd.hpp index 4b190e0..18e9b42 100644 --- a/src/render/FontRendererFwd.hpp +++ b/src/render/FontRendererFwd.hpp @@ -5,8 +5,8 @@ #include "../platform/Types.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { enum class FontRendererTextBufferUsage : uint8 { Static, diff --git a/src/render/ParticlesRenderer.hpp b/src/render/ParticlesRenderer.hpp index 1804c92..4a48221 100644 --- a/src/render/ParticlesRenderer.hpp +++ b/src/render/ParticlesRenderer.hpp @@ -4,8 +4,8 @@ #include "RenderParams.hpp" #include "../Particles.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { class ParticlesRenderer { protected: diff --git a/src/render/RenderParams.hpp b/src/render/RenderParams.hpp index 5811bfc..f31ebaf 100644 --- a/src/render/RenderParams.hpp +++ b/src/render/RenderParams.hpp @@ -6,8 +6,8 @@ #include "../Frustum.hpp" #include "../World.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { class RenderParams { public: diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index a3ed228..c816500 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -6,11 +6,11 @@ #include "TextureManager.hpp" #include "WorldRenderer.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Render { +namespace render { class Renderer { protected: diff --git a/src/render/TextureManager.hpp b/src/render/TextureManager.hpp index be46ad0..c646bec 100644 --- a/src/render/TextureManager.hpp +++ b/src/render/TextureManager.hpp @@ -6,8 +6,8 @@ #include "../platform/Types.hpp" #include "../Texture.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { using TextureRef = std::shared_ptr; using TextureWeakref = std::weak_ptr; diff --git a/src/render/WorldRenderer.hpp b/src/render/WorldRenderer.hpp index 5284030..d1b451e 100644 --- a/src/render/WorldRenderer.hpp +++ b/src/render/WorldRenderer.hpp @@ -4,8 +4,8 @@ #include "RenderParams.hpp" #include "../World.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { class WorldRenderer { protected: diff --git a/src/render/gl/Debug.cpp b/src/render/gl/Debug.cpp index 112610f..d186e54 100644 --- a/src/render/gl/Debug.cpp +++ b/src/render/gl/Debug.cpp @@ -2,8 +2,8 @@ #include "../../util/Log.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { void Debug::glDebugCallback(GLenum source, GLenum type, GLuint id, diff --git a/src/render/gl/Debug.hpp b/src/render/gl/Debug.hpp index f67e17f..b89cd77 100644 --- a/src/render/gl/Debug.hpp +++ b/src/render/gl/Debug.hpp @@ -3,8 +3,8 @@ #include "OpenGL.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class Debug { diff --git a/src/render/gl/DelegateGL.cpp b/src/render/gl/DelegateGL.cpp index 25a7e6d..5a34a9f 100644 --- a/src/render/gl/DelegateGL.cpp +++ b/src/render/gl/DelegateGL.cpp @@ -4,8 +4,8 @@ #include "../../util/BitmapDumper.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { DelegateGL DelegateGL::instance; diff --git a/src/render/gl/DelegateGL.hpp b/src/render/gl/DelegateGL.hpp index 6b338d8..0d7b1f1 100644 --- a/src/render/gl/DelegateGL.hpp +++ b/src/render/gl/DelegateGL.hpp @@ -12,8 +12,8 @@ #include "../../util/unique_function.hpp" #include "OpenGL.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class DelegateGL { diff --git a/src/render/gl/FBO.cpp b/src/render/gl/FBO.cpp index a331685..789a7a5 100644 --- a/src/render/gl/FBO.cpp +++ b/src/render/gl/FBO.cpp @@ -4,8 +4,8 @@ #include "FeatureSupport.hpp" #include "Util.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { using Util::Log; diff --git a/src/render/gl/FBO.hpp b/src/render/gl/FBO.hpp index 596fd8c..98f0de1 100644 --- a/src/render/gl/FBO.hpp +++ b/src/render/gl/FBO.hpp @@ -9,8 +9,8 @@ #include "OpenGL.hpp" #include "Texture.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class FBO { diff --git a/src/render/gl/FeatureSupport.cpp b/src/render/gl/FeatureSupport.cpp index 045389c..52f633d 100644 --- a/src/render/gl/FeatureSupport.cpp +++ b/src/render/gl/FeatureSupport.cpp @@ -4,8 +4,8 @@ #include "OpenGL.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { using F = FeatureSupport; diff --git a/src/render/gl/FeatureSupport.hpp b/src/render/gl/FeatureSupport.hpp index d648a99..8729572 100644 --- a/src/render/gl/FeatureSupport.hpp +++ b/src/render/gl/FeatureSupport.hpp @@ -3,8 +3,8 @@ #include "../../platform/Types.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class FeatureSupport { diff --git a/src/render/gl/FontRenderer.cpp b/src/render/gl/FontRenderer.cpp index deac122..026d8df 100644 --- a/src/render/gl/FontRenderer.cpp +++ b/src/render/gl/FontRenderer.cpp @@ -5,8 +5,8 @@ #include "../../Game.hpp" #include "ProgramManager.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { GLFontRenderer::GLTextBuffer::GLTextBuffer(const GLFontRenderer &parent, @@ -40,11 +40,11 @@ GLFontRenderer::TextBufferRef GLFontRenderer::createTextBuffer(FontRendererTextB return std::make_unique(*this, use); } -void GLFontRenderer::registerFont(UI::Font&) { +void GLFontRenderer::registerFont(ui::Font&) { } -void GLFontRenderer::unregisterFont(UI::Font&) { +void GLFontRenderer::unregisterFont(ui::Font&) { } @@ -67,7 +67,7 @@ void GLFontRenderer::updateTextBuffer(TextBufferRef &buf, const TextBuffer::Vert glbuf.vertexCount = static_cast(vertexCount); } -void GLFontRenderer::render(const UI::Font &font, const TextBufferRef &buf, +void GLFontRenderer::render(const ui::Font &font, const TextBufferRef &buf, const glm::mat4 &matrix) { const GLTextBuffer &glbuf = *reinterpret_cast(buf.get()); prog->bind(); diff --git a/src/render/gl/FontRenderer.hpp b/src/render/gl/FontRenderer.hpp index 5fea37c..066fb16 100644 --- a/src/render/gl/FontRenderer.hpp +++ b/src/render/gl/FontRenderer.hpp @@ -7,11 +7,11 @@ #include "VAO.hpp" #include "VBO.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Render { +namespace render { namespace gl { class GLFontRenderer : public FontRenderer { @@ -39,14 +39,14 @@ public: GLFontRenderer(Game*); ~GLFontRenderer(); - void registerFont(UI::Font&) final override; - void unregisterFont(UI::Font&) final override; + void registerFont(ui::Font&) final override; + void unregisterFont(ui::Font&) final override; TextBufferRef createTextBuffer(FontRendererTextBufferUsage) final override; void updateTextBuffer(TextBufferRef&, const TextBuffer::Vertex *vertices, uint vertexCount) final override; - void render(const UI::Font&, const TextBufferRef&, const glm::mat4&) final override; + void render(const ui::Font&, const TextBufferRef&, const glm::mat4&) final override; }; } diff --git a/src/render/gl/OpenGL.cpp b/src/render/gl/OpenGL.cpp index 16571c3..3a98922 100644 --- a/src/render/gl/OpenGL.cpp +++ b/src/render/gl/OpenGL.cpp @@ -2,8 +2,8 @@ #include -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { static std::set extensionsSet; diff --git a/src/render/gl/OpenGL.glad.cpp b/src/render/gl/OpenGL.glad.cpp index 32a81db..740c9f2 100644 --- a/src/render/gl/OpenGL.glad.cpp +++ b/src/render/gl/OpenGL.glad.cpp @@ -2,8 +2,8 @@ #include -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { void OpenGL::init() { diff --git a/src/render/gl/OpenGL.glbinding.cpp b/src/render/gl/OpenGL.glbinding.cpp index afb900a..9cbe29c 100644 --- a/src/render/gl/OpenGL.glbinding.cpp +++ b/src/render/gl/OpenGL.glbinding.cpp @@ -6,8 +6,8 @@ #include #include -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { void OpenGL::init() { diff --git a/src/render/gl/OpenGL.glew.cpp b/src/render/gl/OpenGL.glew.cpp index 555917d..ffc6ac9 100644 --- a/src/render/gl/OpenGL.glew.cpp +++ b/src/render/gl/OpenGL.glew.cpp @@ -2,8 +2,8 @@ #include -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { void OpenGL::init() { diff --git a/src/render/gl/OpenGL.hpp b/src/render/gl/OpenGL.hpp index 2c16771..9c7d9b6 100644 --- a/src/render/gl/OpenGL.hpp +++ b/src/render/gl/OpenGL.hpp @@ -20,8 +20,8 @@ #error "No OpenGL loader selected" #endif -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class OpenGL { diff --git a/src/render/gl/OpenGL.libepoxy.cpp b/src/render/gl/OpenGL.libepoxy.cpp index f71dc9b..528a881 100644 --- a/src/render/gl/OpenGL.libepoxy.cpp +++ b/src/render/gl/OpenGL.libepoxy.cpp @@ -2,8 +2,8 @@ #include -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { void OpenGL::init() { diff --git a/src/render/gl/ParticlesRenderer.cpp b/src/render/gl/ParticlesRenderer.cpp index d84583b..5fd3b97 100644 --- a/src/render/gl/ParticlesRenderer.cpp +++ b/src/render/gl/ParticlesRenderer.cpp @@ -5,8 +5,8 @@ #include "../../Game.hpp" #include "ProgramManager.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { using GLParticle = ParticleEmitter::ParticleRenderData; diff --git a/src/render/gl/ParticlesRenderer.hpp b/src/render/gl/ParticlesRenderer.hpp index f147ddc..c6aaf02 100644 --- a/src/render/gl/ParticlesRenderer.hpp +++ b/src/render/gl/ParticlesRenderer.hpp @@ -7,11 +7,11 @@ #include "VAO.hpp" #include "VBO.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Render { +namespace render { namespace gl { class GLParticlesRenderer : public ParticlesRenderer { diff --git a/src/render/gl/Program.cpp b/src/render/gl/Program.cpp index 2a88f6e..1701672 100644 --- a/src/render/gl/Program.cpp +++ b/src/render/gl/Program.cpp @@ -5,8 +5,8 @@ #include "../../Platform.hpp" #include "../../util/Log.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { using Util::Log; diff --git a/src/render/gl/Program.hpp b/src/render/gl/Program.hpp index d91a77c..552cbab 100644 --- a/src/render/gl/Program.hpp +++ b/src/render/gl/Program.hpp @@ -3,8 +3,8 @@ #include "Shader.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class Program { diff --git a/src/render/gl/ProgramManager.cpp b/src/render/gl/ProgramManager.cpp index 6f2a1c2..22959a7 100644 --- a/src/render/gl/ProgramManager.cpp +++ b/src/render/gl/ProgramManager.cpp @@ -8,8 +8,8 @@ #define PROGRAM_MANAGER_DEBUG 0 -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { using Util::Log; diff --git a/src/render/gl/ProgramManager.hpp b/src/render/gl/ProgramManager.hpp index c42224f..e767ebb 100644 --- a/src/render/gl/ProgramManager.hpp +++ b/src/render/gl/ProgramManager.hpp @@ -9,11 +9,11 @@ #include "Program.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Render { +namespace render { namespace gl { struct ProgramMetadata { @@ -32,9 +32,9 @@ struct ProgramMetadata { namespace std { template <> -class hash { +class hash { public: -size_t operator()(const Diggler::Render::gl::ProgramMetadata &meta) const { +size_t operator()(const diggler::render::gl::ProgramMetadata &meta) const { std::size_t hash = std::hash{}(meta.name); for (const std::string &s : meta.enabledBindings) { hash ^= (std::hash{}(s) << 1); @@ -45,8 +45,8 @@ size_t operator()(const Diggler::Render::gl::ProgramMetadata &meta) const { } -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class ProgramManager { diff --git a/src/render/gl/Renderer.cpp b/src/render/gl/Renderer.cpp index 6a7a600..9f7337f 100644 --- a/src/render/gl/Renderer.cpp +++ b/src/render/gl/Renderer.cpp @@ -8,8 +8,8 @@ #include "TextureManager.hpp" #include "WorldRenderer.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { using Util::Log; diff --git a/src/render/gl/Renderer.hpp b/src/render/gl/Renderer.hpp index 218b089..05c2f3c 100644 --- a/src/render/gl/Renderer.hpp +++ b/src/render/gl/Renderer.hpp @@ -3,8 +3,8 @@ #include "../Renderer.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class GLRenderer : public Renderer { diff --git a/src/render/gl/Shader.cpp b/src/render/gl/Shader.cpp index 9cdd574..95008df 100644 --- a/src/render/gl/Shader.cpp +++ b/src/render/gl/Shader.cpp @@ -7,8 +7,8 @@ #include "../../platform/fs.hpp" #include "../../util/Log.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { using Util::Log; diff --git a/src/render/gl/Shader.hpp b/src/render/gl/Shader.hpp index a9c425b..69d73ae 100644 --- a/src/render/gl/Shader.hpp +++ b/src/render/gl/Shader.hpp @@ -6,8 +6,8 @@ #include "OpenGL.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class Shader { diff --git a/src/render/gl/Texture.cpp b/src/render/gl/Texture.cpp index fa47545..5d56f8a 100644 --- a/src/render/gl/Texture.cpp +++ b/src/render/gl/Texture.cpp @@ -11,8 +11,8 @@ #define PushBoundTex() GLint currentBoundTex; glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤tBoundTex); #define PopBoundTex() glBindTexture(GL_TEXTURE_2D, currentBoundTex); -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { static GLenum getGlTexFormat(PixelFormat fmt) { @@ -28,7 +28,7 @@ static GLenum getGlTexFormat(PixelFormat fmt) { } Texture::Texture(uint w, uint h, PixelFormat format, const uint8 *data) : - Diggler::Texture(w, h, format) { + diggler::Texture(w, h, format) { PushBoundTex(); glGenTextures(1, &m_id); glBindTexture(GL_TEXTURE_2D, m_id); diff --git a/src/render/gl/Texture.hpp b/src/render/gl/Texture.hpp index 79c1185..acfa207 100644 --- a/src/render/gl/Texture.hpp +++ b/src/render/gl/Texture.hpp @@ -7,11 +7,11 @@ #include "../../Texture.hpp" #include "OpenGL.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { -class Texture : public Diggler::Texture { +class Texture : public diggler::Texture { private: // maybe ? TextureManager &TM; GLuint m_id; @@ -36,7 +36,7 @@ public: void setFiltering(Filter min, Filter mag) override; void setWrapping(Wrapping s, Wrapping t) override; - using Diggler::Texture::setWrapping; + using diggler::Texture::setWrapping; void bind() const { glBindTexture(GL_TEXTURE_2D, m_id); diff --git a/src/render/gl/TextureManager.cpp b/src/render/gl/TextureManager.cpp index 8218f82..125ffbd 100644 --- a/src/render/gl/TextureManager.cpp +++ b/src/render/gl/TextureManager.cpp @@ -3,8 +3,8 @@ #include "../../util/ColorUtil.hpp" #include "Texture.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { TextureManager::TextureManager(Game &G) : diff --git a/src/render/gl/TextureManager.hpp b/src/render/gl/TextureManager.hpp index 8831f1b..28f4f94 100644 --- a/src/render/gl/TextureManager.hpp +++ b/src/render/gl/TextureManager.hpp @@ -5,14 +5,14 @@ #include "../TextureManager.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Render { +namespace render { namespace gl { -class TextureManager : public Render::TextureManager { +class TextureManager : public render::TextureManager { private: Game &G; diff --git a/src/render/gl/Util.cpp b/src/render/gl/Util.cpp index 4deccc8..84cab44 100644 --- a/src/render/gl/Util.cpp +++ b/src/render/gl/Util.cpp @@ -1,7 +1,7 @@ #include "Util.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { const char* getErrorString(GLenum code) { diff --git a/src/render/gl/Util.hpp b/src/render/gl/Util.hpp index 706c84b..77dc212 100644 --- a/src/render/gl/Util.hpp +++ b/src/render/gl/Util.hpp @@ -5,8 +5,8 @@ #include "OpenGL.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { const char* getErrorString(GLenum code); diff --git a/src/render/gl/VAO.hpp b/src/render/gl/VAO.hpp index 4038dba..1c21953 100644 --- a/src/render/gl/VAO.hpp +++ b/src/render/gl/VAO.hpp @@ -11,8 +11,8 @@ #include "Util.hpp" #include "VBO.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class VAO { diff --git a/src/render/gl/VBO.cpp b/src/render/gl/VBO.cpp index a0cb671..0fd849e 100644 --- a/src/render/gl/VBO.cpp +++ b/src/render/gl/VBO.cpp @@ -3,8 +3,8 @@ #include "FeatureSupport.hpp" #include "Util.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { VBO::VBO() : diff --git a/src/render/gl/VBO.hpp b/src/render/gl/VBO.hpp index 54b04f7..0ac5306 100644 --- a/src/render/gl/VBO.hpp +++ b/src/render/gl/VBO.hpp @@ -8,8 +8,8 @@ #include "../../platform/PreprocUtils.hpp" #include "../../platform/Types.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { class VBO { diff --git a/src/render/gl/WorldRenderer.cpp b/src/render/gl/WorldRenderer.cpp index 3a8501f..6638f92 100644 --- a/src/render/gl/WorldRenderer.cpp +++ b/src/render/gl/WorldRenderer.cpp @@ -10,8 +10,8 @@ #include "../../World.hpp" #include "ProgramManager.hpp" -namespace Diggler { -namespace Render { +namespace diggler { +namespace render { namespace gl { using GLCoord = Chunk::Vertex; diff --git a/src/render/gl/WorldRenderer.hpp b/src/render/gl/WorldRenderer.hpp index fa2a5db..9931978 100644 --- a/src/render/gl/WorldRenderer.hpp +++ b/src/render/gl/WorldRenderer.hpp @@ -9,11 +9,11 @@ #include "VAO.hpp" #include "VBO.hpp" -namespace Diggler { +namespace diggler { class Game; -namespace Render { +namespace render { namespace gl { class GLWorldRenderer : public WorldRenderer { diff --git a/src/scripting/lua/State.cpp b/src/scripting/lua/State.cpp index 2cacf63..150517e 100644 --- a/src/scripting/lua/State.cpp +++ b/src/scripting/lua/State.cpp @@ -9,9 +9,9 @@ extern "C" { #include } -namespace Diggler { -namespace Scripting { -namespace Lua { +namespace diggler { +namespace scripting { +namespace lua { static int wrap_exceptions(lua_State *L, lua_CFunction f) { try { diff --git a/src/scripting/lua/State.hpp b/src/scripting/lua/State.hpp index 31cede6..0ca9573 100644 --- a/src/scripting/lua/State.hpp +++ b/src/scripting/lua/State.hpp @@ -7,9 +7,9 @@ extern "C" { #include "../../Game.hpp" -namespace Diggler { -namespace Scripting { -namespace Lua { +namespace diggler { +namespace scripting { +namespace lua { class State { private: diff --git a/src/scripting/lua/api/content/Registry.cpp b/src/scripting/lua/api/content/Registry.cpp index 72cc4b8..295eaf5 100644 --- a/src/scripting/lua/api/content/Registry.cpp +++ b/src/scripting/lua/api/content/Registry.cpp @@ -4,11 +4,11 @@ #include "../../../../content/Registry.hpp" #include "../../../../Game.hpp" -using namespace Diggler; +using namespace diggler; void Diggler_Content_Registry_registerBlock(struct Diggler_Game *cG, const char *name, struct Diggler_Content_BlockDef *cBdef) { - using namespace Content; + using namespace content; Game &G = *reinterpret_cast(cG); Registry::BlockRegistration br(G.CR->registerBlock(name)); { decltype(cBdef->appearance) &cApp = cBdef->appearance; diff --git a/src/ConnectingState.cpp b/src/states/ConnectingState.cpp similarity index 81% rename from src/ConnectingState.cpp rename to src/states/ConnectingState.cpp index dd93741..f573229 100644 --- a/src/ConnectingState.cpp +++ b/src/states/ConnectingState.cpp @@ -5,24 +5,26 @@ #include -#include "Game.hpp" +#include "../Game.hpp" #include "GameState.hpp" -#include "GlobalProperties.hpp" -#include "LocalPlayer.hpp" -#include "network/msgtypes/PlayerJoin.hpp" -#include "render/Renderer.hpp" -#include "ui/Manager.hpp" -#include "ui/Text.hpp" -#include "util/Log.hpp" +#include "../GlobalProperties.hpp" +#include "../LocalPlayer.hpp" +#include "../network/msgtypes/PlayerJoin.hpp" +#include "../render/Renderer.hpp" +#include "../ui/Manager.hpp" +#include "../ui/Text.hpp" +#include "../util/Log.hpp" // TODO: move elsewhere -#include "scripting/lua/State.hpp" +#include "../scripting/lua/State.hpp" -namespace Diggler { +namespace diggler { using Util::Log; using namespace Util::Logging::LogLevels; +namespace states { + static const char *TAG = "ConnectingState"; ConnectingState::ConnectingState(GameWindow *W, const std::string &servHost, int servPort) : @@ -37,8 +39,8 @@ ConnectingState::~ConnectingState() { } void ConnectingState::setupUI() { - txtConnecting = W->G->UIM->addManual("Connecting"); - txtDot = W->G->UIM->addManual("."); + txtConnecting = W->G->UIM->addManual("Connecting"); + txtDot = W->G->UIM->addManual("."); updateViewport(); } @@ -72,20 +74,20 @@ void ConnectingState::onLogicTick() { LocalPlayer &LP = *G->LP; LP.name = GlobalProperties::PlayerName; - Net::MsgTypes::PlayerJoinRequest pjr; + net::MsgTypes::PlayerJoinRequest pjr; pjr.name = G->LP->name; - Net::OutMessage join; pjr.writeToMsg(join); - G->H.send(*G->NS, join, Net::Tfer::Rel, Net::Channels::Base); + net::OutMessage join; pjr.writeToMsg(join); + G->H.send(*G->NS, join, net::Tfer::Rel, net::Channels::Base); - Net::InMessage m_msg; + net::InMessage m_msg; bool received = G->H.recv(m_msg, 5000); if (!received) { W->showMessage("Connected but got no response", "after 5 seconds"); return; } bool msgGood = false; - if (m_msg.getType() == Net::MessageType::PlayerJoin) { - using PJS = Net::MsgTypes::PlayerJoinSubtype; + if (m_msg.getType() == net::MessageType::PlayerJoin) { + using PJS = net::MsgTypes::PlayerJoinSubtype; switch (m_msg.getSubtype()) { case PJS::Success: msgGood = true; @@ -128,7 +130,7 @@ void ConnectingState::onFrameTick() { Game *const G = W->G; glm::mat4 mat; - UI::Text::Size sz = txtConnecting->getSize(); + ui::Text::Size sz = txtConnecting->getSize(); const glm::mat4 textMat = glm::scale(glm::translate(*G->UIM->PM, glm::vec3(W->getW()/2-sz.x, W->getH()/2, 0.f)), glm::vec3(2.f, 2.f, 1.f)); @@ -158,3 +160,4 @@ void ConnectingState::onResize(int w, int h) { } } +} diff --git a/src/ConnectingState.hpp b/src/states/ConnectingState.hpp similarity index 63% rename from src/ConnectingState.hpp rename to src/states/ConnectingState.hpp index 30f1145..1878864 100644 --- a/src/ConnectingState.hpp +++ b/src/states/ConnectingState.hpp @@ -1,25 +1,27 @@ -#ifndef DIGGLER_CONNECTING_STATE_HPP -#define DIGGLER_CONNECTING_STATE_HPP +#ifndef DIGGLER_STATES_CONNECTING_STATE_HPP +#define DIGGLER_STATES_CONNECTING_STATE_HPP +#include "State.hpp" #include #include #include -#include "State.hpp" -#include "GameWindow.hpp" -#include "ui/Text.hpp" +#include "../GameWindow.hpp" +#include "../ui/Text.hpp" -namespace Diggler { +namespace diggler { -namespace UI { +namespace ui { class Text; } +namespace states { + class ConnectingState : public State { private: GameWindow *W; - std::shared_ptr txtConnecting, txtDot; + std::shared_ptr txtConnecting, txtDot; std::string m_serverHost; int m_serverPort; @@ -32,7 +34,7 @@ private: public: ConnectingState(GameWindow *W, const std::string &servHost, int servPort); - ~ConnectingState(); + ~ConnectingState() override; void onStart() override; void onLogicTick() override; @@ -41,11 +43,12 @@ public: //void onMouseButton(int key, int action, int mods); //void onCursorPos(double x, double y); - void onResize(int w, int h); + void onResize(int w, int h) override; void updateViewport(); }; +} } -#endif /* DIGGLER_CONNECTING_STATE_HPP */ +#endif /* DIGGLER_STATES_CONNECTING_STATE_HPP */ diff --git a/src/GameState.cpp b/src/states/GameState.cpp similarity index 88% rename from src/GameState.cpp rename to src/states/GameState.cpp index 46554ef..b28c407 100644 --- a/src/GameState.cpp +++ b/src/states/GameState.cpp @@ -11,34 +11,35 @@ #include #include -#include "Audio.hpp" -#include "CaveGenerator.hpp" -#include "Chatbox.hpp" -#include "Clouds.hpp" -#include "content/Registry.hpp" -#include "content/texture/TextureLoader.hpp" -#include "EscMenu.hpp" -#include "Game.hpp" -#include "GlobalProperties.hpp" -#include "KeyBinds.hpp" -#include "LocalPlayer.hpp" -#include "network/msgtypes/BlockUpdate.hpp" -#include "network/msgtypes/PlayerJoin.hpp" -#include "network/msgtypes/PlayerUpdate.hpp" -#include "network/NetHelper.hpp" -#include "Particles.hpp" -#include "render/gl/FBO.hpp" -#include "render/gl/ProgramManager.hpp" -#include "render/Renderer.hpp" -#include "scripting/lua/State.hpp" -#include "Skybox.hpp" -#include "ui/FontManager.hpp" -#include "ui/Manager.hpp" -#include "util/MemoryTracker.hpp" +#include "../Audio.hpp" +#include "../CaveGenerator.hpp" +#include "../Chatbox.hpp" +#include "../Clouds.hpp" +#include "../content/Registry.hpp" +#include "../content/texture/TextureLoader.hpp" +#include "../EscMenu.hpp" +#include "../Game.hpp" +#include "../GlobalProperties.hpp" +#include "../KeyBinds.hpp" +#include "../LocalPlayer.hpp" +#include "../network/msgtypes/BlockUpdate.hpp" +#include "../network/msgtypes/PlayerJoin.hpp" +#include "../network/msgtypes/PlayerUpdate.hpp" +#include "../network/NetHelper.hpp" +#include "../Particles.hpp" +#include "../render/gl/FBO.hpp" +#include "../render/gl/ProgramManager.hpp" +#include "../render/Renderer.hpp" +#include "../scripting/lua/State.hpp" +#include "../Skybox.hpp" +#include "../ui/FontManager.hpp" +#include "../ui/Manager.hpp" +#include "../util/MemoryTracker.hpp" using std::unique_ptr; -namespace Diggler { +namespace diggler { +namespace states { GameState::GameState(GameWindow *GW) : GW(GW), @@ -99,14 +100,14 @@ GameState::GameState(GameWindow *GW) : m_highlightBox.att_coord = m_highlightBox.program->att("coord"); m_highlightBox.uni_unicolor = m_highlightBox.program->uni("unicolor"); m_highlightBox.uni_mvp = m_highlightBox.program->uni("mvp"); - { Render::gl::VAO::Config cfg = m_highlightBox.vao.configure(); + { render::gl::VAO::Config cfg = m_highlightBox.vao.configure(); cfg.vertexAttrib(m_highlightBox.vbo, m_highlightBox.att_coord, 3, GL_FLOAT, 0); cfg.commit(); } - m_3dFbo = new Render::gl::FBO(w, h, PixelFormat::RGB, true); + m_3dFbo = new render::gl::FBO(w, h, PixelFormat::RGB, true); m_3dFbo->tex->setWrapping(Texture::Wrapping::ClampEdge); - m_3dRenderVBO = new Render::gl::VBO(); + m_3dRenderVBO = new render::gl::VBO(); m_clouds = new Clouds(G, 32, 32, 4); //m_sky = new Skybox(G, getAssetPath("alpine")); m_3dFboRenderer = G->PM->getProgram("2d", "texture0", "texcoord0"); //getSpecialProgram("effect3dRender"); @@ -125,7 +126,7 @@ GameState::GameState(GameWindow *GW) : }; m_3dRenderVBO->setData(renderQuad, 6*sizeof(Coord2DTex)); - m_crossHair.tex = Content::Texture::TextureLoader::load(*G, Content::Image::ImageFormats::PNG, + m_crossHair.tex = content::Texture::TextureLoader::load(*G, content::Image::ImageFormats::PNG, getAssetPath("crosshair.png"), PixelFormat::RGBA)->texture; //"\f0H\f1e\f2l\f3l\f4l\f5o \f6d\f7e\f8m\f9b\faa\fbz\fcz\fde\fes\ff,\n\f0ye see,it werks purrfektly :D\n(and also; it's optimized)" @@ -140,7 +141,7 @@ GameState::Bloom::Bloom(Game &G) { enable = true; scale = 4; - extractor.fbo = new Render::gl::FBO(G.GW->getW()/scale, G.GW->getH()/scale, PixelFormat::RGBA); + extractor.fbo = new render::gl::FBO(G.GW->getW()/scale, G.GW->getH()/scale, PixelFormat::RGBA); extractor.fbo->tex->setFiltering(Texture::Filter::Linear, Texture::Filter::Linear); extractor.fbo->tex->setWrapping(Texture::Wrapping::ClampEdge); extractor.prog = G.PM->getProgram("bloomExtractor"); @@ -148,7 +149,7 @@ GameState::Bloom::Bloom(Game &G) { extractor.att_texcoord = extractor.prog->att("texcoord"); extractor.uni_mvp = extractor.prog->uni("mvp"); - renderer.fbo = new Render::gl::FBO(G.GW->getW()/scale, G.GW->getH()/scale, PixelFormat::RGBA); + renderer.fbo = new render::gl::FBO(G.GW->getW()/scale, G.GW->getH()/scale, PixelFormat::RGBA); renderer.fbo->tex->setFiltering(Texture::Filter::Linear, Texture::Filter::Linear); renderer.fbo->tex->setWrapping(Texture::Wrapping::ClampEdge); renderer.prog = G.PM->getProgram("bloom"); @@ -164,12 +165,12 @@ GameState::Bloom::~Bloom() { } void GameState::setupUI() { - UI.FPS = G->UIM->add(); - UI.FPS->setUpdateFrequencyHint(Render::FontRendererTextBufferUsage::Dynamic); + UI.FPS = G->UIM->add(); + UI.FPS->setUpdateFrequencyHint(render::FontRendererTextBufferUsage::Dynamic); UI.FPS->setScale(2, 2); - UI.DebugInfo = G->UIM->add(); - UI.DebugInfo->setUpdateFrequencyHint(Render::FontRendererTextBufferUsage::Stream); + UI.DebugInfo = G->UIM->add(); + UI.DebugInfo->setUpdateFrequencyHint(render::FontRendererTextBufferUsage::Stream); UI.DebugInfo->setVisible(false); UI.EM = G->UIM->add(); @@ -325,21 +326,21 @@ void GameState::onMouseButton(int key, int action, int mods) { if (action == GLFW_PRESS) { glm::ivec3 pointed, face; if (G->LP->raytracePointed(32, &pointed, &face)) { - Net::OutMessage msg; + net::OutMessage msg; if (key == GLFW_MOUSE_BUTTON_LEFT) { - Net::MsgTypes::BlockUpdateBreak bub; + net::MsgTypes::BlockUpdateBreak bub; bub.worldId = G->LP->W->id; bub.pos = pointed; bub.writeToMsg(msg); } else { - Net::MsgTypes::BlockUpdatePlace bup; + net::MsgTypes::BlockUpdatePlace bup; bup.worldId = G->LP->W->id; bup.pos = face; - bup.id = 2; //Content::BlockUnknownId; + bup.id = 2; //content::BlockUnknownId; bup.data = 0; bup.writeToMsg(msg); } - sendMsg(msg, Net::Tfer::Rel, Net::Channels::MapUpdate); + sendMsg(msg, net::Tfer::Rel, net::Channels::MapUpdate); } } } @@ -384,7 +385,7 @@ void GameState::onMouseScroll(double x, double y) { void GameState::updateViewport() { int w = GW->getW(), h = GW->getH(); - UI::Manager &UIM = *G->UIM; + ui::Manager &UIM = *G->UIM; G->LP->camera.setPersp((float)M_PI/180*75.0f, (float)w / h, 0.1f, 32.0f); m_3dFbo->resize(w, h); bloom.extractor.fbo->resize(w/bloom.scale, h/bloom.scale); @@ -403,13 +404,13 @@ void GameState::updateViewport() { UI.FPS->setPos(16, 16); UI.DebugInfo->setPos(0, h-(lineHeight+UI.DebugInfo->getSize().y)); const int menuWidth = G->UIM->scale*128; - UI.EM->setArea(UI::Element::Area(w - menuWidth, 0, menuWidth, h)); + UI.EM->setArea(ui::Element::Area(w - menuWidth, 0, menuWidth, h)); m_chatBox->setPosition(4, 64); updateUI(); } -void GameState::sendMsg(Net::OutMessage &msg, Net::Tfer mode, Net::Channels chan) { +void GameState::sendMsg(net::OutMessage &msg, net::Tfer mode, net::Channels chan) { G->H.send(*G->NS, msg, mode, chan); } @@ -452,15 +453,15 @@ void GameState::onFrameTick() { LocalPlayer *LP = G->LP; double T = G->Time; if (runTime() > nextNetUpdate) { - Net::MsgTypes::PlayerUpdateMove pum; + net::MsgTypes::PlayerUpdateMove pum; pum.position = LP->position; if (LP->velocity != glm::vec3()) { pum.velocity = LP->velocity; pum.accel = LP->accel; } pum.angle = LP->angle; - Net::OutMessage msg; pum.writeToMsg(msg); - sendMsg(msg, Net::Tfer::Unrel, Net::Channels::Movement); + net::OutMessage msg; pum.writeToMsg(msg); + sendMsg(msg, net::Tfer::Unrel, net::Channels::Movement); nextNetUpdate = T+1.0/G->PlayerPosUpdateFreq; } @@ -485,7 +486,7 @@ void GameState::onFrameTick() { glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); - Render::RenderParams rp; + render::RenderParams rp; rp.world = WR.get(); rp.transform = m_transform; rp.frustum = G->LP->camera.frustum; @@ -513,7 +514,7 @@ void GameState::onFrameTick() { pe.velAmpl = glm::vec3(0, 2, 0); rain pe.update(deltaT); - Render::RenderParams rp; + render::RenderParams rp; rp.transform = m_transform; G->R->PR->render(rp);*/ @@ -545,8 +546,8 @@ void GameState::onFrameTick() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (!bloom.vao) { - bloom.vao = std::make_unique(); - Render::gl::VAO::Config cfg = bloom.vao->configure(); + bloom.vao = std::make_unique(); + render::gl::VAO::Config cfg = bloom.vao->configure(); cfg.vertexAttrib(*m_3dRenderVBO, bloom.extractor.att_coord, 2, GL_SHORT, sizeof(Coord2DTex), 0); cfg.vertexAttrib(*m_3dRenderVBO, bloom.extractor.att_texcoord, 2, GL_BYTE, sizeof(Coord2DTex), offsetof(Coord2DTex, u)); cfg.commit(); @@ -590,8 +591,8 @@ void GameState::onFrameTick() { } void GameState::onStop() { - Net::OutMessage quit(Net::MessageType::PlayerQuit); - sendMsg(quit, Net::Tfer::Rel); + net::OutMessage quit(net::MessageType::PlayerQuit); + sendMsg(quit, net::Tfer::Rel); G->LS->finalize(); } @@ -655,7 +656,7 @@ void GameState::drawUI() { G->UIM->drawTex(m_crossHair.mat, *m_crossHair.tex); // TODO render weapon - G->UIM->drawTex(*G->UIM->PM, UI::Element::Area{0,0,128,128}, *G->CR->getAtlas()); + G->UIM->drawTex(*G->UIM->PM, ui::Element::Area{0,0,128,128}, *G->CR->getAtlas()); } bool GameState::processNetwork() { @@ -668,3 +669,4 @@ bool GameState::processNetwork() { } } +} diff --git a/src/GameState.hpp b/src/states/GameState.hpp similarity index 67% rename from src/GameState.hpp rename to src/states/GameState.hpp index 7d147a7..deef9c1 100644 --- a/src/GameState.hpp +++ b/src/states/GameState.hpp @@ -1,6 +1,5 @@ -#ifndef GAME_STATE_HPP -#define GAME_STATE_HPP - +#ifndef DIGGLER_STATES_GAME_STATE_HPP +#define DIGGLER_STATES_GAME_STATE_HPP #include "State.hpp" #include @@ -10,67 +9,70 @@ #include #include -#include "GameWindow.hpp" -#include "render/gl/FBO.hpp" -#include "render/gl/VBO.hpp" -#include "render/gl/VAO.hpp" -#include "content/Content.hpp" -#include "network/Network.hpp" -#include "network/ClientMessageHandler.hpp" +#include "../GameWindow.hpp" +#include "../render/gl/FBO.hpp" +#include "../render/gl/VBO.hpp" +#include "../render/gl/VAO.hpp" +#include "../content/Content.hpp" +#include "../network/Network.hpp" +#include "../network/ClientMessageHandler.hpp" // TODO strip? -#include "Chunk.hpp" +#include "../Chunk.hpp" -namespace Diggler { +namespace diggler { +class EscMenu; class Skybox; class KeyBindings; class Font; class Clouds; class Game; class Chatbox; -namespace Render { +namespace render { namespace gl { class Program; } } -namespace UI { +namespace ui { class Text; } +namespace states { + class GameState : public State { public: GameWindow *GW; Game *G; private: - Net::ClientMessageHandler CMH; + net::ClientMessageHandler CMH; glm::vec3 m_lookat; glm::vec2 m_angles; - Render::gl::FBO *m_3dFbo; - const Render::gl::Program *m_3dFboRenderer; + render::gl::FBO *m_3dFbo; + const render::gl::Program *m_3dFboRenderer; GLuint m_3dFboRenderer_coord, m_3dFboRenderer_texcoord, m_3dFboRenderer_mvp; struct Bloom { bool enable; int scale; - std::unique_ptr vao; + std::unique_ptr vao; struct Extractor { - Render::gl::FBO *fbo; - const Render::gl::Program *prog; + render::gl::FBO *fbo; + const render::gl::Program *prog; GLuint att_coord, att_texcoord, uni_mvp; } extractor; struct Renderer { - Render::gl::FBO *fbo; - const Render::gl::Program *prog; + render::gl::FBO *fbo; + const render::gl::Program *prog; GLuint att_coord, att_texcoord, uni_pixshift, uni_mvp; } renderer; Bloom(Game&); ~Bloom(); } bloom; - Render::gl::VBO *m_3dRenderVBO; + render::gl::VBO *m_3dRenderVBO; struct Coord2DTex { int16 x, y; uint8 u, v; }; Clouds *m_clouds; Skybox *m_sky; @@ -81,9 +83,9 @@ private: } m_crossHair; struct { - Render::gl::VBO vbo; - Render::gl::VAO vao; - const Render::gl::Program *program; + render::gl::VBO vbo; + render::gl::VAO vao; + const render::gl::Program *program; GLuint att_coord, uni_unicolor, uni_mvp; } m_highlightBox; @@ -101,7 +103,7 @@ private: std::thread m_networkThread; - Net::InMessage m_msg; + net::InMessage m_msg; float nextNetUpdate; struct { @@ -109,9 +111,9 @@ private: } debugInfo; struct { - std::shared_ptr FPS; - std::shared_ptr DebugInfo; - std::shared_ptr EM; + std::shared_ptr FPS; + std::shared_ptr DebugInfo; + std::shared_ptr EM; } UI; int fpsCounter; @@ -155,9 +157,10 @@ public: void drawUI(); bool processNetwork(); - void sendMsg(Net::OutMessage &msg, Net::Tfer mode, Net::Channels chan = Net::Channels::Base); + void sendMsg(net::OutMessage &msg, net::Tfer mode, net::Channels chan = net::Channels::Base); }; +} } -#endif +#endif /* DIGGLER_STATES_GAME_STATE_HPP */ diff --git a/src/MessageState.cpp b/src/states/MessageState.cpp similarity index 69% rename from src/MessageState.cpp rename to src/states/MessageState.cpp index cf6cb04..133a3c0 100644 --- a/src/MessageState.cpp +++ b/src/states/MessageState.cpp @@ -2,15 +2,16 @@ #include -#include "Audio.hpp" -#include "Game.hpp" -#include "GlobalProperties.hpp" -#include "Sound.hpp" -#include "render/Renderer.hpp" -#include "ui/Manager.hpp" -#include "ui/Text.hpp" +#include "../Audio.hpp" +#include "../Game.hpp" +#include "../GlobalProperties.hpp" +#include "../Sound.hpp" +#include "../render/Renderer.hpp" +#include "../ui/Manager.hpp" +#include "../ui/Text.hpp" -namespace Diggler { +namespace diggler { +namespace states { MessageState::MessageState(GameWindow *W, const std::string &msg, const std::string &submsg) : W(W), msg(msg), subMsg(submsg), txtMsg(nullptr), txtSubMsg(nullptr) { @@ -21,8 +22,8 @@ MessageState::~MessageState() { } void MessageState::onStart() { - txtMsg = W->G->UIM->add(msg, 2, 2); - txtSubMsg = W->G->UIM->add(subMsg); + txtMsg = W->G->UIM->add(msg, 2, 2); + txtSubMsg = W->G->UIM->add(subMsg); updateViewport(); if (GlobalProperties::IsSoundEnabled) { W->G->A->playSound("click-quiet"); @@ -30,10 +31,10 @@ void MessageState::onStart() { } void MessageState::updateViewport() { - UI::Text::Size txtMsgSize = txtMsg->getSize(); + ui::Text::Size txtMsgSize = txtMsg->getSize(); txtMsg->setPos(W->getW()/2 - txtMsgSize.x/2, W->getH()/2); - UI::Text::Size txtSubMsgSize = txtSubMsg->getSize(); + ui::Text::Size txtSubMsgSize = txtSubMsg->getSize(); txtSubMsg->setPos(W->getW()/2 - txtSubMsgSize.x / 2, W->getH()/2 - txtSubMsgSize.y); } @@ -54,3 +55,4 @@ void MessageState::onFrameTick() { } } +} diff --git a/src/MessageState.hpp b/src/states/MessageState.hpp similarity index 62% rename from src/MessageState.hpp rename to src/states/MessageState.hpp index fbff2f6..b2d8b8a 100644 --- a/src/MessageState.hpp +++ b/src/states/MessageState.hpp @@ -1,16 +1,21 @@ -#ifndef MESSAGE_STATE_HPP -#define MESSAGE_STATE_HPP +#ifndef DIGGLER_STATES_MESSAGE_STATE_HPP +#define DIGGLER_STATES_MESSAGE_STATE_HPP #include "State.hpp" -#include "GameWindow.hpp" -#include "ui/Text.hpp" -namespace Diggler { +#include +#include + +#include "../GameWindow.hpp" +#include "../ui/Text.hpp" + +namespace diggler { +namespace states { class MessageState : public State { private: GameWindow *W; std::string msg, subMsg; - std::shared_ptr txtMsg, txtSubMsg; + std::shared_ptr txtMsg, txtSubMsg; void setupUI(); @@ -29,6 +34,7 @@ public: void updateViewport(); }; +} } -#endif +#endif /* DIGGLER_STATES_MESSAGE_STATE_HPP */ diff --git a/src/State.hpp b/src/states/State.hpp similarity index 80% rename from src/State.hpp rename to src/states/State.hpp index e57e7f6..2b92be9 100644 --- a/src/State.hpp +++ b/src/states/State.hpp @@ -1,14 +1,16 @@ -#ifndef STATE_HPP -#define STATE_HPP -#include "Platform.hpp" +#ifndef DIGGLER_STATES_STATE_HPP +#define DIGGLER_STATES_STATE_HPP +#include "../platform/Types.hpp" -namespace Diggler { +namespace diggler { class GameWindow; +namespace states { + class State { private: - friend GameWindow; + friend diggler::GameWindow; double m_runTime, m_deltaTime; @@ -42,6 +44,7 @@ public: virtual void onResize(int w, int h) {} }; +} } -#endif +#endif /* DIGGLER_STATES_STATE_HPP */ diff --git a/src/UITestState.cpp b/src/states/UITestState.cpp similarity index 62% rename from src/UITestState.cpp rename to src/states/UITestState.cpp index 0d44ea9..39b3ad4 100644 --- a/src/UITestState.cpp +++ b/src/states/UITestState.cpp @@ -1,11 +1,12 @@ #include "UITestState.hpp" -#include "Game.hpp" -#include "GameWindow.hpp" -#include "ui/Button.hpp" -#include "ui/Manager.hpp" +#include "../Game.hpp" +#include "../GameWindow.hpp" +#include "../ui/Button.hpp" +#include "../ui/Manager.hpp" -namespace Diggler { +namespace diggler { +namespace states { UITestState::UITestState(GameWindow *W) : GW(W) { } @@ -14,16 +15,16 @@ UITestState::~UITestState() { } void UITestState::run() { - std::shared_ptr - b1 = GW->G->UIM->add(UI::Element::Area { 0, 0, 320, 60 }), - b2 = GW->G->UIM->add(UI::Element::Area { 320, 60, 320, 60 }); + std::shared_ptr + b1 = GW->G->UIM->add(ui::Element::Area { 0, 0, 320, 60 }), + b2 = GW->G->UIM->add(ui::Element::Area { 320, 60, 320, 60 }); while (!glfwWindowShouldClose(*GW)) { // Infinite loop \o/ glClearColor(sin(glfwGetTime()*4)*0.1+0.5, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - b1->setArea(UI::Element::Area{ 0, 0, 300+20*sin(glfwGetTime()*4), 60 }); - b2->setArea(UI::Element::Area{ 300+20*sin(glfwGetTime()*4), 60, 320, 60 }); + b1->setArea(ui::Element::Area{ 0, 0, 300+20*sin(glfwGetTime()*4), 60 }); + b2->setArea(ui::Element::Area{ 300+20*sin(glfwGetTime()*4), 60, 320, 60 }); GW->G->UIM->render(); @@ -48,3 +49,4 @@ void UITestState::onCursorPos(double x, double y) { } } +} diff --git a/src/UITestState.hpp b/src/states/UITestState.hpp similarity index 65% rename from src/UITestState.hpp rename to src/states/UITestState.hpp index 6248f85..caa0928 100644 --- a/src/UITestState.hpp +++ b/src/states/UITestState.hpp @@ -1,18 +1,20 @@ -#ifndef UI_TEST_STATE_HPP -#define UI_TEST_STATE_HPP +#ifndef DIGGLER_STATES_UI_TEST_STATE_HPP +#define DIGGLER_STATES_UI_TEST_STATE_HPP #include "State.hpp" -namespace Diggler { +namespace diggler { class GameWindow; -namespace UI { +namespace ui { class Text; } +namespace states { + class UITestState : public State { private: GameWindow *GW; - UI::Text *txt; + ui::Text *txt; public: UITestState(GameWindow*); @@ -27,6 +29,7 @@ public: void updateViewport(); }; +} } -#endif \ No newline at end of file +#endif /* DIGGLER_STATES_UI_TEST_STATE_HPP */ diff --git a/src/ui/Button.cpp b/src/ui/Button.cpp index 6a2bb3a..63e1ef2 100644 --- a/src/ui/Button.cpp +++ b/src/ui/Button.cpp @@ -3,8 +3,8 @@ #include "Manager.hpp" #include "Text.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { Button::Button(Manager *M, const Area &area, const std::string &label) : Element(M) { setArea(area); diff --git a/src/ui/Button.hpp b/src/ui/Button.hpp index 6d83cff..41c6da9 100644 --- a/src/ui/Button.hpp +++ b/src/ui/Button.hpp @@ -5,8 +5,8 @@ #include -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { class Text; diff --git a/src/ui/Element.cpp b/src/ui/Element.cpp index bd623eb..1b8a7c1 100644 --- a/src/ui/Element.cpp +++ b/src/ui/Element.cpp @@ -4,8 +4,8 @@ #include "Manager.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { bool Element::Area::isIn(int x, int y) const { return x >= this->x && x < (this->x + this->w) && diff --git a/src/ui/Element.hpp b/src/ui/Element.hpp index 46baa24..70094b7 100644 --- a/src/ui/Element.hpp +++ b/src/ui/Element.hpp @@ -5,11 +5,11 @@ #include -namespace Diggler { +namespace diggler { class Game; -namespace UI { +namespace ui { class Manager; diff --git a/src/ui/Font.cpp b/src/ui/Font.cpp index c943585..e4e9e7a 100644 --- a/src/ui/Font.cpp +++ b/src/ui/Font.cpp @@ -10,8 +10,8 @@ #include "../render/Renderer.hpp" #include "../Game.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { static const struct { float r, g, b; } ColorTable[16] = { {1.0f, 1.0f, 1.0f}, @@ -33,11 +33,10 @@ static const struct { float r, g, b; } ColorTable[16] = { }; Font::Font(Game *G, const std::string& path) : G(G) { - m_texture = Content::Texture::TextureLoader::load(*G, Content::Image::ImageFormats::PNG, path, + m_texture = content::Texture::TextureLoader::load(*G, content::Image::ImageFormats::PNG, path, PixelFormat::RGBA)->texture; - std::ifstream source(path + ".fdf", std::ios_base::binary); + std::ifstream source(path + ".fdf", std::ios_base::binary | std::ios_base::ate); if (source.good()) { - source.seekg(0, std::ios_base::end); int size = (int)source.tellg() - 1; // Last byte is font's height source.seekg(0, std::ios_base::beg); //widths = new uint8[size]; @@ -64,20 +63,20 @@ Font::Font(Game *G, const std::string& path) : G(G) { G->R->renderers.font->registerFont(*this); } -using Vertex = Render::FontRenderer::TextBuffer::Vertex; +using Vertex = render::FontRenderer::TextBuffer::Vertex; -Render::FontRendererTextBufferRef Font::createTextBuffer() const { +render::FontRendererTextBufferRef Font::createTextBuffer() const { return G->R->renderers.font->createTextBuffer(); } -Render::FontRendererTextBufferRef Font::createTextBuffer( - Render::FontRendererTextBufferUsage usage) const { +render::FontRendererTextBufferRef Font::createTextBuffer( + render::FontRendererTextBufferUsage usage) const { return G->R->renderers.font->createTextBuffer(usage); } #define eraseCurChar() vertCount -= 6; -void Font::updateTextBuffer(Render::FontRendererTextBufferRef &buf, const std::string &text) const { +void Font::updateTextBuffer(render::FontRendererTextBufferRef &buf, const std::string &text) const { uint vertCount = text.size()*6; std::unique_ptr verts(new Vertex[vertCount]); int16 c, w, line = 0, cx = 0, v = 0; @@ -129,7 +128,7 @@ void Font::updateTextBuffer(Render::FontRendererTextBufferRef &buf, const std::s G->R->renderers.font->updateTextBuffer(buf, verts.get(), vertCount); } -void Font::draw(const Render::FontRendererTextBufferRef &buf, const glm::mat4 &matrix) const { +void Font::draw(const render::FontRendererTextBufferRef &buf, const glm::mat4 &matrix) const { G->R->renderers.font->render(*this, buf, matrix); } diff --git a/src/ui/Font.hpp b/src/ui/Font.hpp index df4fa15..9b5dbb8 100644 --- a/src/ui/Font.hpp +++ b/src/ui/Font.hpp @@ -8,19 +8,19 @@ #include "../render/FontRendererFwd.hpp" -namespace Diggler { +namespace diggler { class Texture; class Program; class Game; -namespace UI { +namespace ui { class FontManager; class Font { private: - friend class Render::FontRenderer; + friend class render::FontRenderer; uintptr_t rendererData; std::shared_ptr m_texture; @@ -42,11 +42,11 @@ public: Font(Game *G, const std::string &path); ~Font(); - Render::FontRendererTextBufferRef createTextBuffer() const; - Render::FontRendererTextBufferRef createTextBuffer(Render::FontRendererTextBufferUsage) const; - void updateTextBuffer(Render::FontRendererTextBufferRef&, const std::string &text) const; + render::FontRendererTextBufferRef createTextBuffer() const; + render::FontRendererTextBufferRef createTextBuffer(render::FontRendererTextBufferUsage) const; + void updateTextBuffer(render::FontRendererTextBufferRef&, const std::string &text) const; - void draw(const Render::FontRendererTextBufferRef&, const glm::mat4 &matrix) const; + void draw(const render::FontRendererTextBufferRef&, const glm::mat4 &matrix) const; Size getSize(const std::string &text) const; int getHeight() const; const std::shared_ptr texture() const { diff --git a/src/ui/FontManager.cpp b/src/ui/FontManager.cpp index d9f0c3a..3d04b07 100644 --- a/src/ui/FontManager.cpp +++ b/src/ui/FontManager.cpp @@ -1,7 +1,7 @@ #include "FontManager.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { FontManager::FontManager(Game &G) : G(G) { } diff --git a/src/ui/FontManager.hpp b/src/ui/FontManager.hpp index 366b6e9..8431806 100644 --- a/src/ui/FontManager.hpp +++ b/src/ui/FontManager.hpp @@ -8,8 +8,8 @@ #include "Font.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { class FontManager { private: diff --git a/src/ui/Manager.cpp b/src/ui/Manager.cpp index 6d0024b..37c5198 100644 --- a/src/ui/Manager.cpp +++ b/src/ui/Manager.cpp @@ -11,11 +11,11 @@ #include "../Game.hpp" #include "../GameWindow.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { struct Renderer { - const Render::gl::Program *prog; + const render::gl::Program *prog; GLint att_texcoord, att_coord, uni_mvp, uni_unicolor; } R{}, RR{}; @@ -42,7 +42,7 @@ void Manager::setup(Game *G) { RR.uni_mvp = RR.prog->uni("mvp"); RR.uni_unicolor = RR.prog->uni("unicolor"); } - m_rectVbo.reset(new Render::gl::VBO); + m_rectVbo.reset(new render::gl::VBO); const uint8 verts[6*4] = { 0, 0, 0, 1, 1, 0, 1, 1, @@ -53,8 +53,8 @@ void Manager::setup(Game *G) { 1, 1, 1, 0 }; m_rectVbo->setData(verts, 6*4); - m_rectVao = std::make_unique(); - { Render::gl::VAO::Config cfg = m_rectVao->configure(); + m_rectVao = std::make_unique(); + { render::gl::VAO::Config cfg = m_rectVao->configure(); cfg.vertexAttrib(*m_rectVbo, RR.att_coord, 2, GL_UNSIGNED_BYTE, 4*sizeof(uint8)); cfg.vertexAttrib(*m_rectVbo, R.att_texcoord, 2, GL_UNSIGNED_BYTE, 4*sizeof(uint8), 2*sizeof(uint8)); cfg.commit(); diff --git a/src/ui/Manager.hpp b/src/ui/Manager.hpp index d1539a0..5f61f12 100644 --- a/src/ui/Manager.hpp +++ b/src/ui/Manager.hpp @@ -4,9 +4,9 @@ #include #include "Element.hpp" -namespace Diggler { +namespace diggler { -namespace Render { +namespace render { namespace gl { class VAO; class VBO; @@ -15,12 +15,12 @@ class VBO; class GameWindow; class Texture; -namespace UI { +namespace ui { class Manager { private: - std::unique_ptr m_rectVbo; - std::unique_ptr m_rectVao; + std::unique_ptr m_rectVbo; + std::unique_ptr m_rectVao; std::list> m_elements; std::weak_ptr m_hoveredElement; std::weak_ptr m_focusedElement; diff --git a/src/ui/README.md b/src/ui/README.md index 50db7a9..348ff70 100644 --- a/src/ui/README.md +++ b/src/ui/README.md @@ -9,6 +9,6 @@ Some elements are handled in a more "traditional" way: they are drawn manually b Making a control ---- -* Your class **must** derive from `Diggler::UI::Element` in order to be controlled by the `UIManager`. +* Your class **must** derive from `diggler::ui::Element` in order to be controlled by the `UIManager`. * All your constructors must take a `UIManager*` as first argument, called `M` if sticking to the projet's code style. They must then call `Element(M)` in the initializer list. * Override the `Element` methods you want, and implement the mandatory (pure virtual) `render()` one. diff --git a/src/ui/Rect.hpp b/src/ui/Rect.hpp index 88ea674..54a56e6 100644 --- a/src/ui/Rect.hpp +++ b/src/ui/Rect.hpp @@ -2,8 +2,8 @@ #define RECT_HPP #include "Element.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { class Rect : public Element { private: diff --git a/src/ui/Text.cpp b/src/ui/Text.cpp index 91a1913..36368be 100644 --- a/src/ui/Text.cpp +++ b/src/ui/Text.cpp @@ -8,14 +8,14 @@ #include "FontManager.hpp" #include "Manager.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { Text::Text(Manager *M) : Element(M), m_scaleX(1), m_scaleY(1), - m_textBufUsage(Render::FontRendererTextBufferUsage::Default) { + m_textBufUsage(render::FontRendererTextBufferUsage::Default) { updateMatrix(); } @@ -23,7 +23,7 @@ Text::Text(Manager *M, const std::string &text, int scaleX, int scaleY) : Element(M), m_scaleX(scaleX), m_scaleY(scaleY), - m_textBufUsage(Render::FontRendererTextBufferUsage::Default), + m_textBufUsage(render::FontRendererTextBufferUsage::Default), m_text(text) { updateText(); updateMatrix(); @@ -32,7 +32,7 @@ Text::Text(Manager *M, const std::string &text, int scaleX, int scaleY) : Text::~Text() { } -void Text::setUpdateFrequencyHint(Render::FontRendererTextBufferUsage usage) { +void Text::setUpdateFrequencyHint(render::FontRendererTextBufferUsage usage) { if (usage != m_textBufUsage) { m_textBufUsage = usage; m_textBuf.reset(); diff --git a/src/ui/Text.hpp b/src/ui/Text.hpp index fb1e43b..ef2a7d2 100644 --- a/src/ui/Text.hpp +++ b/src/ui/Text.hpp @@ -7,14 +7,14 @@ #include "Element.hpp" #include "../render/FontRendererFwd.hpp" -namespace Diggler { -namespace UI { +namespace diggler { +namespace ui { class Text : public Element { private: int m_scaleX, m_scaleY; - Render::FontRendererTextBufferUsage m_textBufUsage; - Render::FontRendererTextBufferRef m_textBuf; + render::FontRendererTextBufferUsage m_textBufUsage; + render::FontRendererTextBufferRef m_textBuf; std::string m_fontName; glm::mat4 m_matrix; std::string m_text; @@ -37,7 +37,7 @@ public: /** * Hints if frequent updates should be expected for this Text object */ - void setUpdateFrequencyHint(Render::FontRendererTextBufferUsage); + void setUpdateFrequencyHint(render::FontRendererTextBufferUsage); /** * @param text Text to display diff --git a/src/util/BitmapDumper.cpp b/src/util/BitmapDumper.cpp index 1fd2179..737e89b 100644 --- a/src/util/BitmapDumper.cpp +++ b/src/util/BitmapDumper.cpp @@ -1,7 +1,7 @@ #include "BitmapDumper.hpp" #include -namespace Diggler { +namespace diggler { bool BitmapDumper::dumpAsPpm(int w, int h, const void *data, const char *path) { const char *bytes = static_cast(data); diff --git a/src/util/BitmapDumper.hpp b/src/util/BitmapDumper.hpp index 8b30acf..8f6c7ec 100644 --- a/src/util/BitmapDumper.hpp +++ b/src/util/BitmapDumper.hpp @@ -5,7 +5,7 @@ #include "../PixelFormat.hpp" -namespace Diggler { +namespace diggler { class BitmapDumper final { BitmapDumper() = delete; diff --git a/src/util/ColorUtil.cpp b/src/util/ColorUtil.cpp index ace9e70..8a7099e 100644 --- a/src/util/ColorUtil.cpp +++ b/src/util/ColorUtil.cpp @@ -2,7 +2,7 @@ #include "Memset.hpp" -namespace Diggler { +namespace diggler { namespace Util { namespace ColorUtil { diff --git a/src/util/ColorUtil.hpp b/src/util/ColorUtil.hpp index 36f9a94..fc7e05b 100644 --- a/src/util/ColorUtil.hpp +++ b/src/util/ColorUtil.hpp @@ -3,7 +3,7 @@ #include "../platform/Types.hpp" -namespace Diggler { +namespace diggler { namespace Util { namespace ColorUtil { diff --git a/src/util/Encoding.cpp b/src/util/Encoding.cpp index 6ca98e2..e382603 100644 --- a/src/util/Encoding.cpp +++ b/src/util/Encoding.cpp @@ -3,7 +3,7 @@ #include #include -namespace Diggler { +namespace diggler { namespace Util { namespace Encoding { diff --git a/src/util/Encoding.hpp b/src/util/Encoding.hpp index 65d623d..26c1f24 100644 --- a/src/util/Encoding.hpp +++ b/src/util/Encoding.hpp @@ -3,7 +3,7 @@ #include -namespace Diggler { +namespace diggler { namespace Util { namespace Encoding { diff --git a/src/util/Log.cpp b/src/util/Log.cpp index 6cd9e4d..c1c30d8 100644 --- a/src/util/Log.cpp +++ b/src/util/Log.cpp @@ -2,7 +2,7 @@ #include "logging/AnsiConsoleLogger.hpp" -namespace Diggler { +namespace diggler { namespace Util { using namespace Logging; diff --git a/src/util/Log.hpp b/src/util/Log.hpp index a9d3e0c..dbb0331 100644 --- a/src/util/Log.hpp +++ b/src/util/Log.hpp @@ -5,7 +5,7 @@ #include "logging/LogInput.hpp" -namespace Diggler { +namespace diggler { namespace Util { extern std::unique_ptr CurrentLogger; diff --git a/src/util/MemoryTracker.cpp b/src/util/MemoryTracker.cpp index c9470b3..f927e83 100644 --- a/src/util/MemoryTracker.cpp +++ b/src/util/MemoryTracker.cpp @@ -131,7 +131,7 @@ void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept { } -namespace Diggler { +namespace diggler { namespace Util { namespace MemoryTracker { diff --git a/src/util/MemoryTracker.disabled.cpp b/src/util/MemoryTracker.disabled.cpp index b9d15b4..25da770 100644 --- a/src/util/MemoryTracker.disabled.cpp +++ b/src/util/MemoryTracker.disabled.cpp @@ -1,6 +1,6 @@ #include "MemoryTracker.hpp" -namespace Diggler { +namespace diggler { namespace Util { namespace MemoryTracker { diff --git a/src/util/MemoryTracker.hpp b/src/util/MemoryTracker.hpp index b969d72..aeb6b41 100644 --- a/src/util/MemoryTracker.hpp +++ b/src/util/MemoryTracker.hpp @@ -5,7 +5,7 @@ #include #include -namespace Diggler { +namespace diggler { namespace Util { namespace MemoryTracker { diff --git a/src/util/Memset.hpp b/src/util/Memset.hpp index d8171e0..3082d0b 100644 --- a/src/util/Memset.hpp +++ b/src/util/Memset.hpp @@ -5,7 +5,7 @@ #include "../platform/Types.hpp" -namespace Diggler { +namespace diggler { namespace Util { void memset8(void *dst, byte val, uint num) { diff --git a/src/util/StringUtil.cpp b/src/util/StringUtil.cpp index 9748407..4132d8b 100644 --- a/src/util/StringUtil.cpp +++ b/src/util/StringUtil.cpp @@ -3,7 +3,7 @@ #include #include -namespace Diggler { +namespace diggler { namespace Util { std::vector explode(const std::string &s, char delim) { diff --git a/src/util/StringUtil.hpp b/src/util/StringUtil.hpp index a135a80..c329b91 100644 --- a/src/util/StringUtil.hpp +++ b/src/util/StringUtil.hpp @@ -4,7 +4,7 @@ #include #include -namespace Diggler { +namespace diggler { namespace Util { class StringUtil { diff --git a/src/util/TexturePacker.cpp b/src/util/TexturePacker.cpp index e7c42f2..eba96c1 100644 --- a/src/util/TexturePacker.cpp +++ b/src/util/TexturePacker.cpp @@ -20,7 +20,7 @@ using namespace std; #include #endif -namespace Diggler { +namespace diggler { namespace Util { using namespace Logging::LogLevels; diff --git a/src/util/TexturePacker.hpp b/src/util/TexturePacker.hpp index 7e74130..9ec1a33 100644 --- a/src/util/TexturePacker.hpp +++ b/src/util/TexturePacker.hpp @@ -7,7 +7,7 @@ #include "../platform/Types.hpp" #include "../Texture.hpp" -namespace Diggler { +namespace diggler { class Game; diff --git a/src/util/Tipsify.cpp b/src/util/Tipsify.cpp index 55ad78d..9333568 100644 --- a/src/util/Tipsify.cpp +++ b/src/util/Tipsify.cpp @@ -79,7 +79,7 @@ int Get_next_vertex(const int i, int k, const std::map &N, const std: return n; } -namespace Diggler { +namespace diggler { namespace Util { std::vector Tipsify::tipsify(std::size_t vertexCount, const std::vector &I, int k) { diff --git a/src/util/Tipsify.hpp b/src/util/Tipsify.hpp index 85bbf6d..d6ae83a 100644 --- a/src/util/Tipsify.hpp +++ b/src/util/Tipsify.hpp @@ -3,7 +3,7 @@ #include -namespace Diggler { +namespace diggler { namespace Util { class Tipsify { diff --git a/src/util/logging/AnsiConsoleLogger.cpp b/src/util/logging/AnsiConsoleLogger.cpp index 1f24bb5..3cde161 100644 --- a/src/util/logging/AnsiConsoleLogger.cpp +++ b/src/util/logging/AnsiConsoleLogger.cpp @@ -5,7 +5,7 @@ using std::cout; -namespace Diggler { +namespace diggler { namespace Util { namespace Logging { diff --git a/src/util/logging/AnsiConsoleLogger.hpp b/src/util/logging/AnsiConsoleLogger.hpp index c2cd764..42a0ee8 100644 --- a/src/util/logging/AnsiConsoleLogger.hpp +++ b/src/util/logging/AnsiConsoleLogger.hpp @@ -6,7 +6,7 @@ #include "Logger.hpp" -namespace Diggler { +namespace diggler { namespace Util { namespace Logging { diff --git a/src/util/logging/LogInput.cpp b/src/util/logging/LogInput.cpp index e872a69..b5f4f3f 100644 --- a/src/util/logging/LogInput.cpp +++ b/src/util/logging/LogInput.cpp @@ -10,7 +10,7 @@ #include "../Encoding.hpp" -namespace Diggler { +namespace diggler { namespace Util { namespace Logging { diff --git a/src/util/logging/LogInput.hpp b/src/util/logging/LogInput.hpp index f845877..f1643a3 100644 --- a/src/util/logging/LogInput.hpp +++ b/src/util/logging/LogInput.hpp @@ -7,7 +7,7 @@ #include "Logger.hpp" -namespace Diggler { +namespace diggler { namespace Util { namespace Logging { diff --git a/src/util/logging/Logger.cpp b/src/util/logging/Logger.cpp index 4f3f002..671e838 100644 --- a/src/util/logging/Logger.cpp +++ b/src/util/logging/Logger.cpp @@ -1,6 +1,6 @@ #include "Logger.hpp" -namespace Diggler { +namespace diggler { namespace Util { namespace Logging { diff --git a/src/util/logging/Logger.hpp b/src/util/logging/Logger.hpp index f67df82..ce28587 100644 --- a/src/util/logging/Logger.hpp +++ b/src/util/logging/Logger.hpp @@ -3,7 +3,7 @@ #include -namespace Diggler { +namespace diggler { namespace Util { namespace Logging { diff --git a/src/util/logging/StdoutLogger.cpp b/src/util/logging/StdoutLogger.cpp index cfab3a8..dff9d57 100644 --- a/src/util/logging/StdoutLogger.cpp +++ b/src/util/logging/StdoutLogger.cpp @@ -2,7 +2,7 @@ #include -namespace Diggler { +namespace diggler { namespace Util { namespace Logging { diff --git a/src/util/logging/StdoutLogger.hpp b/src/util/logging/StdoutLogger.hpp index 7d755e1..02ee303 100644 --- a/src/util/logging/StdoutLogger.hpp +++ b/src/util/logging/StdoutLogger.hpp @@ -6,7 +6,7 @@ #include "Logger.hpp" -namespace Diggler { +namespace diggler { namespace Util { namespace Logging { diff --git a/src/util/unique_function.hpp b/src/util/unique_function.hpp index 2d573bb..36490fc 100644 --- a/src/util/unique_function.hpp +++ b/src/util/unique_function.hpp @@ -4,7 +4,7 @@ #include #include -namespace Diggler { +namespace diggler { namespace Util { template