diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..e6561bc --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: [-Wall, -Wextra, -Wpedantic, -Wno-unused-parameter] \ No newline at end of file diff --git a/include/Cubed/map_table.hpp b/include/Cubed/map_table.hpp index 99cd7f8..0fc5393 100644 --- a/include/Cubed/map_table.hpp +++ b/include/Cubed/map_table.hpp @@ -11,7 +11,7 @@ private: public: // please using reference static const std::string& get_name_from_id(unsigned id); - static const unsigned get_id_from_name(const std::string& name); + static unsigned get_id_from_name(const std::string& name); static void init_map(); }; diff --git a/src/app.cpp b/src/app.cpp index b1a85c4..05dff14 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -58,7 +58,6 @@ void App::init() { void App::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { App* app = static_cast(glfwGetWindowUserPointer(window)); ASSERT_MSG(app, "nullptr"); - auto& input = Input::get_input_state(); switch(key) { case GLFW_KEY_Q: if (action == GLFW_PRESS) { diff --git a/src/gameplay/chunk.cpp b/src/gameplay/chunk.cpp index 88e90e8..8f97993 100644 --- a/src/gameplay/chunk.cpp +++ b/src/gameplay/chunk.cpp @@ -13,8 +13,8 @@ namespace Cubed { Chunk::Chunk(World& world, ChunkPos chunk_pos) : - m_world(world), - m_chunk_pos(chunk_pos) + m_chunk_pos(chunk_pos), + m_world(world) { } @@ -27,16 +27,16 @@ Chunk::~Chunk() { } Chunk::Chunk(Chunk&& other) noexcept : - m_vbo(other.m_vbo), + m_dirty(other.is_dirty()), + m_need_upload(other.m_need_upload.load()), + m_is_on_gen_vertex_data(other.m_is_on_gen_vertex_data.load()), + m_vertex_sum(other.m_vertex_sum.load()), + m_biome(other.m_biome), m_chunk_pos(std::move(other.m_chunk_pos)), m_world(other.m_world), m_blocks(std::move(other.m_blocks)), - m_dirty(other.is_dirty()), - m_vertexs_data(std::move(other.m_vertexs_data)), - m_biome(other.m_biome), - m_is_on_gen_vertex_data(other.m_is_on_gen_vertex_data.load()), - m_need_upload(other.m_need_upload.load()), - m_vertex_sum(other.m_vertex_sum.load()) + m_vbo(other.m_vbo), + m_vertexs_data(std::move(other.m_vertexs_data)) { other.m_vbo = 0; } @@ -128,7 +128,7 @@ void Chunk::gen_vertex_data(const std::array*, 4>& ne int idx = Chunk::get_index(x, y, z); // not init - if (idx >= chunk_blocks->size()) { + if (static_cast(idx) >= chunk_blocks->size()) { Logger::warn("not init"); return false; } diff --git a/src/gameplay/player.cpp b/src/gameplay/player.cpp index c1cc806..9ab1ab1 100644 --- a/src/gameplay/player.cpp +++ b/src/gameplay/player.cpp @@ -10,8 +10,8 @@ namespace Cubed { Player::Player(World& world, const std::string& name) : - m_world(world), - m_name(name) + m_name(name), + m_world(world) { } @@ -61,7 +61,7 @@ const MoveState& Player::get_move_state() const { bool Player::ray_cast(const glm::vec3& start, const glm::vec3& front, glm::ivec3& block_pos, glm::vec3& normal, float distance) { glm::vec3 dir = glm::normalize(front); - float step = 0.1f; + //float step = 0.1f; glm::ivec3 cur = glm::floor(start); int ix = cur.x; int iy = cur.y; diff --git a/src/map_table.cpp b/src/map_table.cpp index 018d92c..00a5fd3 100644 --- a/src/map_table.cpp +++ b/src/map_table.cpp @@ -14,7 +14,7 @@ const std::string& MapTable::get_name_from_id(unsigned id) { ASSERT_MSG(it != id_to_name_map.end(), "Id: " + std::to_string(id) + " is not exist"); return it->second; } -const unsigned MapTable::get_id_from_name(const std::string& name) { +unsigned MapTable::get_id_from_name(const std::string& name) { auto it = name_to_id_map.find(HASH::str(name)); ASSERT_MSG(it != name_to_id_map.end(), "Name " + name + " is not exist"); return it->second; diff --git a/src/shader.cpp b/src/shader.cpp index e19633c..284da73 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -18,8 +18,8 @@ Shader::Shader(const std::string& name, const std::string& v_shader_path, const } Shader::Shader(Shader&& shader) noexcept: - m_hash(shader.m_hash), m_program(shader.m_program), + m_hash(shader.m_hash), m_name(std::move(shader.m_name)) { shader.m_hash = 0; diff --git a/src/ui/text.cpp b/src/ui/text.cpp index 4e13e81..b9e8abc 100644 --- a/src/ui/text.cpp +++ b/src/ui/text.cpp @@ -34,15 +34,15 @@ Text::~Text() { } Text::Text(Text&& other) noexcept : - UUID(other.UUID), - NAME(other.NAME), m_scale(other.m_scale), - m_vbo(other.m_vbo), + m_pos(other.m_pos), + NAME(other.NAME), + UUID(other.UUID), + m_text(std::move(other.m_text)), m_color(other.m_color), m_model_matrix(other.m_model_matrix), - m_pos(other.m_pos), - m_text(std::move(other.m_text)), - m_vertices(std::move(other.m_vertices)) + m_vertices(std::move(other.m_vertices)), + m_vbo(other.m_vbo) { other.m_vbo = 0; }