fix warnings + cland-tidy
This commit is contained in:
27
.clang-tidy
Normal file
27
.clang-tidy
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
Checks: >-
|
||||||
|
-*,
|
||||||
|
readability-identifier-naming,
|
||||||
|
readability-redundant-string-cstr,
|
||||||
|
readability-redundant-string-init,
|
||||||
|
readability-simplify-boolean-expr,
|
||||||
|
performance-unnecessary-value-param,
|
||||||
|
performance-unnecessary-copy-initialization,
|
||||||
|
performance-for-range-copy,
|
||||||
|
performance-implicit-conversion-in-loop,
|
||||||
|
CheckOptions:
|
||||||
|
- key: readability-identifier-naming.PrivateMemberPrefix
|
||||||
|
value: 'm_'
|
||||||
|
- key: readability-identifier-naming.ClassConstantCase
|
||||||
|
value: aNy_CasE
|
||||||
|
# an empty *Prefix needs a *Case to work
|
||||||
|
- key: readability-identifier-naming.ClassConstantPrefix
|
||||||
|
value: ''
|
||||||
|
#- key: readability-identifier-naming.PrivateMemberCase
|
||||||
|
# value: CamelCase
|
||||||
|
#- key: readability-identifier-naming.FunctionCase
|
||||||
|
# value: CamelCase
|
||||||
|
#- key: readability-identifier-naming.EnumCase
|
||||||
|
# value: camelBack
|
||||||
|
|
||||||
|
WarningsAsErrors: '*'
|
||||||
|
FormatStyle: 'file'
|
||||||
@@ -17,7 +17,7 @@ class Spawn : public utils::shape::Rectangle {
|
|||||||
private:
|
private:
|
||||||
Direction m_Direction;
|
Direction m_Direction;
|
||||||
public:
|
public:
|
||||||
Spawn() {
|
Spawn() : m_Direction(Direction::PositiveX) {
|
||||||
SetWidth(5);
|
SetWidth(5);
|
||||||
SetHeight(5);
|
SetHeight(5);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class World {
|
|||||||
return m_CurrentState.m_Mobs;
|
return m_CurrentState.m_Mobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Color* GetTileColor(TilePtr tile) const;
|
const Color* GetTileColor(const TilePtr& tile) const;
|
||||||
|
|
||||||
Team& GetRedTeam() {
|
Team& GetRedTeam() {
|
||||||
return m_CurrentState.m_Teams[static_cast<std::uint8_t>(TeamColor::Red)];
|
return m_CurrentState.m_Teams[static_cast<std::uint8_t>(TeamColor::Red)];
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ static constexpr Color BLUE{0, 0, 255};
|
|||||||
|
|
||||||
struct Tile {
|
struct Tile {
|
||||||
virtual TileType GetType() const = 0;
|
virtual TileType GetType() const = 0;
|
||||||
|
virtual ~Tile() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TowerTile : Tile {
|
struct TowerTile : Tile {
|
||||||
@@ -118,4 +119,4 @@ struct hash<td::game::ChunkCoord> {
|
|||||||
return std::hash<std::int16_t>()(key.x << 16 | key.y);
|
return std::hash<std::int16_t>()(key.x << 16 | key.y);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ private:
|
|||||||
Point m_Center;
|
Point m_Center;
|
||||||
float m_Width, m_Height;
|
float m_Width, m_Height;
|
||||||
public:
|
public:
|
||||||
Rectangle() {}
|
Rectangle() : m_Center(), m_Width(0), m_Height(0) {}
|
||||||
|
|
||||||
const Point& GetCenter() const { return m_Center; }
|
const Point& GetCenter() const { return m_Center; }
|
||||||
float GetCenterX() const { return m_Center.GetX(); }
|
float GetCenterX() const { return m_Center.GetX(); }
|
||||||
@@ -92,5 +92,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace shape
|
} // namespace shape
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ struct RenderData {
|
|||||||
GL::VertexArray LoadMobModel();
|
GL::VertexArray LoadMobModel();
|
||||||
GL::VertexArray LoadWorldModel(const td::game::World* world);
|
GL::VertexArray LoadWorldModel(const td::game::World* world);
|
||||||
GL::VertexArray LoadTileSelectModel();
|
GL::VertexArray LoadTileSelectModel();
|
||||||
RenderData LoadTowerModel(game::TowerPtr tower);
|
RenderData LoadTowerModel(const game::TowerPtr& tower);
|
||||||
|
|
||||||
} // namespace WorldLoader
|
} // namespace WorldLoader
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace sim {
|
|||||||
class IWorldSystem {
|
class IWorldSystem {
|
||||||
public:
|
public:
|
||||||
virtual void Tick(const game::World& a_World, WorldSnapshot& a_State, FpFloat a_Delta) = 0;
|
virtual void Tick(const game::World& a_World, WorldSnapshot& a_State, FpFloat a_Delta) = 0;
|
||||||
|
virtual ~IWorldSystem() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WorldTicker {
|
class WorldTicker {
|
||||||
@@ -32,7 +33,7 @@ class WorldTicker {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AddSystem() {
|
void AddSystem() {
|
||||||
m_Systems.push_back(std::move(std::make_unique<T>()));
|
m_Systems.push_back(std::make_unique<T>());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
class WorldApply : public td::protocol::PacketHandler {
|
class WorldApply : public td::protocol::PacketHandler {
|
||||||
private:
|
private:
|
||||||
td::game::World& m_World;
|
td::game::World& m_World;
|
||||||
|
using td::protocol::PacketHandler::Handle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WorldApply(td::game::World& a_World) : m_World(a_World) {}
|
WorldApply(td::game::World& a_World) : m_World(a_World) {}
|
||||||
@@ -23,6 +24,7 @@ class WorldApply : public td::protocol::PacketHandler {
|
|||||||
void Handle(const td::protocol::packets::WorldHeaderPacket& a_Header) override {
|
void Handle(const td::protocol::packets::WorldHeaderPacket& a_Header) override {
|
||||||
m_World.LoadMap(*a_Header);
|
m_World.LoadMap(*a_Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(const td::protocol::packets::WorldDataPacket& a_Data) override {
|
void Handle(const td::protocol::packets::WorldDataPacket& a_Data) override {
|
||||||
m_World.LoadMap(*a_Data);
|
m_World.LoadMap(*a_Data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace game {
|
|||||||
|
|
||||||
World::World() : m_CurrentState{.m_Teams{Team{TeamColor::Red}, Team{TeamColor::Blue}}}, m_NextState{.m_Teams{Team{TeamColor::Red}, Team{TeamColor::Blue}}} {}
|
World::World() : m_CurrentState{.m_Teams{Team{TeamColor::Red}, Team{TeamColor::Blue}}}, m_NextState{.m_Teams{Team{TeamColor::Red}, Team{TeamColor::Blue}}} {}
|
||||||
|
|
||||||
const Color* World::GetTileColor(TilePtr tile) const {
|
const Color* World::GetTileColor(const TilePtr& tile) const {
|
||||||
switch (tile->GetType()) {
|
switch (tile->GetType()) {
|
||||||
case TileType::Tower: {
|
case TileType::Tower: {
|
||||||
TowerTile* towerTile = dynamic_cast<TowerTile*>(tile.get());
|
TowerTile* towerTile = dynamic_cast<TowerTile*>(tile.get());
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace render {
|
|||||||
namespace WorldLoader {
|
namespace WorldLoader {
|
||||||
|
|
||||||
const static int POSITION_VERTEX_SIZE = 3;
|
const static int POSITION_VERTEX_SIZE = 3;
|
||||||
const static int TEXTURE_VERTEX_SIZE = 2;
|
// const static int TEXTURE_VERTEX_SIZE = 2;
|
||||||
|
|
||||||
GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
||||||
std::vector<float> positions;
|
std::vector<float> positions;
|
||||||
@@ -173,7 +173,7 @@ GL::VertexArray LoadTileSelectModel() {
|
|||||||
return tileSelectVao;
|
return tileSelectVao;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderData LoadTowerModel(game::TowerPtr tower) {
|
RenderData LoadTowerModel(const game::TowerPtr& tower) {
|
||||||
RenderData renderData;
|
RenderData renderData;
|
||||||
|
|
||||||
float towerX, towerDX;
|
float towerX, towerDX;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace td {
|
|||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
EntityRenderer::EntityRenderer(Camera& a_Camera, const game::World& a_World) : Renderer(a_Camera), m_World(a_World) {
|
EntityRenderer::EntityRenderer(Camera& a_Camera, const game::World& a_World) : Renderer(a_Camera), m_World(a_World) {
|
||||||
m_EntityVao = std::make_unique<GL::VertexArray>(std::move(WorldLoader::LoadMobModel()));
|
m_EntityVao = std::make_unique<GL::VertexArray>(WorldLoader::LoadMobModel());
|
||||||
m_Shader->Start();
|
m_Shader->Start();
|
||||||
m_Shader->SetColorEffect({1, 0, 1});
|
m_Shader->SetColorEffect({1, 0, 1});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ unsigned int ShaderProgram::LoadShader(const std::string& source, GLenum type) {
|
|||||||
glCompileShader(shaderID);
|
glCompileShader(shaderID);
|
||||||
GLint compilesuccessful;
|
GLint compilesuccessful;
|
||||||
glGetShaderiv(shaderID, GL_COMPILE_STATUS, &compilesuccessful);
|
glGetShaderiv(shaderID, GL_COMPILE_STATUS, &compilesuccessful);
|
||||||
if (compilesuccessful == false) {
|
if (!compilesuccessful) {
|
||||||
GLsizei size;
|
GLsizei size;
|
||||||
glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &size);
|
glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &size);
|
||||||
std::vector<char> shaderError(static_cast<std::size_t>(size));
|
std::vector<char> shaderError(static_cast<std::size_t>(size));
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ set_languages("c++17")
|
|||||||
|
|
||||||
set_warnings("all")
|
set_warnings("all")
|
||||||
|
|
||||||
|
if is_mode("release") then
|
||||||
|
set_warnings("all", "error")
|
||||||
|
end
|
||||||
|
|
||||||
target("Tower-Defense2")
|
target("Tower-Defense2")
|
||||||
add_includedirs("include", {public = true})
|
add_includedirs("include", {public = true})
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
|
|||||||
Reference in New Issue
Block a user