chore: add .clangd configuration

This commit is contained in:
2026-04-21 22:53:34 +08:00
parent c2321a0a6e
commit c7a0aff0c1
8 changed files with 24 additions and 23 deletions

2
.clangd Normal file
View File

@@ -0,0 +1,2 @@
CompileFlags:
Add: [-Wall, -Wextra, -Wpedantic, -Wno-unused-parameter]

View File

@@ -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();
};

View File

@@ -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<App*>(glfwGetWindowUserPointer(window));
ASSERT_MSG(app, "nullptr");
auto& input = Input::get_input_state();
switch(key) {
case GLFW_KEY_Q:
if (action == GLFW_PRESS) {

View File

@@ -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<const std::vector<uint8_t>*, 4>& ne
int idx = Chunk::get_index(x, y, z);
// not init
if (idx >= chunk_blocks->size()) {
if (static_cast<size_t>(idx) >= chunk_blocks->size()) {
Logger::warn("not init");
return false;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}