diff --git a/include/game/Mobs.h b/include/game/Mobs.h index 9cf73f3..c84c2a8 100644 --- a/include/game/Mobs.h +++ b/include/game/Mobs.h @@ -95,10 +95,10 @@ public: void heal(float heal){ m_Health = std::min((float)getStats()->getMaxLife(), m_Health + heal); } float getX() const{ return m_X; } - float setX(float x){ m_X = x; } + void setX(float x){ m_X = x; } float getY() const{ return m_Y; } - float setY(float y){ m_Y = y; } + void setY(float y){ m_Y = y; } Direction getDirection() const{ return m_Direction; } void setDirection(Direction dir){ m_Direction = dir; } diff --git a/include/game/Player.h b/include/game/Player.h index b7f825d..990aa64 100644 --- a/include/game/Player.h +++ b/include/game/Player.h @@ -13,7 +13,7 @@ private: game::TeamColor m_TeamColor = game::TeamColor::None; std::uint32_t m_Gold = 0; - std::int32_t m_EXP; + std::int32_t m_EXP = 0; std::string m_Name; std::uint8_t m_ID; diff --git a/include/game/Towers.h b/include/game/Towers.h index f00e2db..14113a5 100644 --- a/include/game/Towers.h +++ b/include/game/Towers.h @@ -27,7 +27,7 @@ enum class TowerSize : bool{ }; enum class TowerPath : std::uint8_t{ - Top = 1, // Base path + Top = 0, // Base path Bottom }; diff --git a/include/game/World.h b/include/game/World.h index 3dcd5c6..1578f4b 100644 --- a/include/game/World.h +++ b/include/game/World.h @@ -160,7 +160,7 @@ public: const MobList& getMobList() const{ return m_Mobs; } MobList& getMobList(){ return m_Mobs; } - const Color& getTileColor(TilePtr tile) const; + const Color* getTileColor(TilePtr tile) const; Team& getRedTeam(); const Team& getRedTeam() const; diff --git a/include/game/server/ServerWorld.h b/include/game/server/ServerWorld.h index b6c6fde..5ae17b4 100644 --- a/include/game/server/ServerWorld.h +++ b/include/game/server/ServerWorld.h @@ -10,7 +10,7 @@ class ServerGame; class ServerWorld : public game::World{ private: - game::MobID m_CurrentMobID = 0; + game::MobID m_CurrentMobID; Server* m_Server; public: ServerWorld(Server* server, ServerGame* game); diff --git a/include/window/Display.h b/include/window/Display.h index ea86cad..8310d5a 100644 --- a/include/window/Display.h +++ b/include/window/Display.h @@ -19,7 +19,7 @@ void pollEvents(); bool isCloseRequested(); -const bool isMouseDown(int button); +bool isMouseDown(int button); float getAspectRatio(); int getWindowWidth(); diff --git a/src/game/Connexion.cpp b/src/game/Connexion.cpp index 729a43f..72f9fc4 100644 --- a/src/game/Connexion.cpp +++ b/src/game/Connexion.cpp @@ -16,7 +16,7 @@ Connexion::Connexion() : protocol::PacketHandler(nullptr){ } -Connexion::Connexion(Connexion&& move) : m_Socket(std::move(move.m_Socket)), protocol::PacketHandler(&m_Dispatcher){ +Connexion::Connexion(Connexion&& move) : protocol::PacketHandler(&m_Dispatcher), m_Socket(std::move(move.m_Socket)){ } @@ -24,7 +24,7 @@ Connexion::Connexion(protocol::PacketDispatcher* dispatcher) : protocol::PacketH } -Connexion::Connexion(protocol::PacketDispatcher* dispatcher, network::TCPSocket& socket) : protocol::PacketHandler(dispatcher), m_Socket(std::move(socket)){ +Connexion::Connexion(protocol::PacketDispatcher* dispatcher, network::TCPSocket& socket) : protocol::PacketHandler(dispatcher), m_Socket(std::move(socket)) { } diff --git a/src/game/World.cpp b/src/game/World.cpp index 340b96f..0a76e88 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -316,8 +316,7 @@ bool World::saveMap(const std::string& fileName) const{ DataBuffer buffer = mapHeaderCompressed << mapDataCompressed; std::cout << "Total Size : " << buffer.GetSize() << std::endl; - buffer.WriteFile(fileName); - std::cout << "----- Map Saved ! -----\n"; + return buffer.WriteFile(fileName); } void World::tick(std::uint64_t delta){ @@ -336,8 +335,6 @@ void World::moveMobs(std::uint64_t delta){ for(MobPtr mob : m_Mobs){ TilePtr tile = getTile(mob->getX(), mob->getY()); - Direction tileDir; - if(tile != nullptr && tile->getType() == TileType::Walk){ WalkableTile* walkTile = dynamic_cast(tile.get()); mob->setDirection(walkTile->direction); @@ -368,22 +365,25 @@ void World::moveMobs(std::uint64_t delta){ } } -const Color& World::getTileColor(TilePtr tile) const{ +const Color* World::getTileColor(TilePtr tile) const{ switch(tile->getType()){ case TileType::Tower:{ TowerTile* towerTile = (TowerTile*) tile.get(); - return m_TowerPlacePalette[towerTile->color_palette_ref]; + return &m_TowerPlacePalette[towerTile->color_palette_ref]; } case TileType::Walk:{ - return m_WalkablePalette; + return &m_WalkablePalette; } case TileType::Decoration:{ DecorationTile* towerTile = (DecorationTile*) tile.get(); - return m_DecorationPalette[towerTile->color_palette_ref]; + return &m_DecorationPalette[towerTile->color_palette_ref]; break; } + case TileType::None:{ + return nullptr; + } } - return m_DecorationPalette[0]; + return nullptr; } Team& World::getRedTeam(){ diff --git a/src/game/client/WorldClient.cpp b/src/game/client/WorldClient.cpp index 384cd8b..3707c67 100644 --- a/src/game/client/WorldClient.cpp +++ b/src/game/client/WorldClient.cpp @@ -6,7 +6,7 @@ namespace td{ namespace client{ -WorldClient::WorldClient(ClientGame* game) : m_Game(game), game::World(game), protocol::PacketHandler(game->GetDispatcher()){ +WorldClient::WorldClient(ClientGame* game) : game::World(game), protocol::PacketHandler(game->GetDispatcher()), m_Game(game){ GetDispatcher()->RegisterHandler(protocol::PacketType::WorldBeginData, this); GetDispatcher()->RegisterHandler(protocol::PacketType::WorldData, this); GetDispatcher()->RegisterHandler(protocol::PacketType::SpawnMob, this); diff --git a/src/game/server/ServerGame.cpp b/src/game/server/ServerGame.cpp index fa70d09..2529aca 100644 --- a/src/game/server/ServerGame.cpp +++ b/src/game/server/ServerGame.cpp @@ -4,7 +4,7 @@ namespace td { namespace server { -ServerGame::ServerGame(server::Server* server) : m_Server(server), m_ServerWorld(server, this), game::Game(&m_ServerWorld){ +ServerGame::ServerGame(server::Server* server) : game::Game(&m_ServerWorld), m_Server(server), m_ServerWorld(server, this){ } diff --git a/src/game/server/ServerWorld.cpp b/src/game/server/ServerWorld.cpp index d304a24..28de2af 100644 --- a/src/game/server/ServerWorld.cpp +++ b/src/game/server/ServerWorld.cpp @@ -7,7 +7,7 @@ namespace td { namespace server { -ServerWorld::ServerWorld(Server* server, ServerGame* game) : m_Server(server), game::World(game){ +ServerWorld::ServerWorld(Server* server, ServerGame* game) : game::World(game), m_CurrentMobID(0), m_Server(server){ } diff --git a/src/network/IPAddress.cpp b/src/network/IPAddress.cpp index 7a8eccb..8816a97 100644 --- a/src/network/IPAddress.cpp +++ b/src/network/IPAddress.cpp @@ -16,15 +16,14 @@ namespace network { /* Create an invalid address */ IPAddress::IPAddress() noexcept - : m_Valid(false), m_Address(0) -{ - -} + : m_Address(0), m_Valid(false){ + + } /* Initialize by string IP */ IPAddress::IPAddress(const std::string& ip) - : m_Valid(false), m_Address(0) -{ + : m_Address(0), m_Valid(false){ + std::sregex_iterator begin(ip.begin(), ip.end(), IPRegex); std::sregex_iterator end; @@ -42,8 +41,8 @@ IPAddress::IPAddress(const std::string& ip) } IPAddress::IPAddress(const std::wstring& ip) - : m_Address(0), m_Valid(false) -{ + : m_Address(0), m_Valid(false){ + std::wsregex_iterator begin(ip.begin(), ip.end(), IPRegexW); std::wsregex_iterator end; @@ -62,8 +61,7 @@ IPAddress::IPAddress(const std::wstring& ip) /* Initialize by octets */ IPAddress::IPAddress(uint8_t octet1, uint8_t octet2, uint8_t octet3, uint8_t octet4) noexcept - : m_Valid(true) -{ + : m_Valid(true){ m_Address = (octet1 << 24) | (octet2 << 16) | (octet3 << 8) | octet4; } diff --git a/src/network/Socket.cpp b/src/network/Socket.cpp index 21f0dd7..1babaa1 100644 --- a/src/network/Socket.cpp +++ b/src/network/Socket.cpp @@ -13,10 +13,10 @@ namespace td { namespace network { Socket::Socket(Type type) - : m_Handle(INVALID_SOCKET), + : m_Blocking(false), m_Type(type), - m_Blocking(false), - m_Status(Disconnected) + m_Status(Disconnected), + m_Handle(INVALID_SOCKET) { } @@ -33,6 +33,8 @@ bool Socket::SetBlocking(bool block) { } m_Blocking = block; + + return true; } bool Socket::IsBlocking() const noexcept { diff --git a/src/protocol/Protocol.cpp b/src/protocol/Protocol.cpp index 64edc0c..cda09cc 100644 --- a/src/protocol/Protocol.cpp +++ b/src/protocol/Protocol.cpp @@ -19,20 +19,22 @@ DataBuffer& operator<<(DataBuffer& buffer, game::TilePtr tile){ buffer << tile->getType(); switch (tile->getType()){ case game::TileType::Tower:{ - const std::shared_ptr& towerTile = (const std::shared_ptr&) tile; + const game::TowerTile* towerTile = (const game::TowerTile*) tile.get(); buffer << towerTile->color_palette_ref << towerTile->team_owner; break; } case game::TileType::Walk:{ - const std::shared_ptr& walkTile = (const std::shared_ptr&) tile; + const game::WalkableTile* walkTile = (const game::WalkableTile*) tile.get(); buffer << walkTile->direction; break; } case game::TileType::Decoration:{ - const std::shared_ptr& decoTile = (const std::shared_ptr&) tile; + const game::DecorationTile* decoTile = (const game::DecorationTile*) tile.get(); buffer << decoTile->color_palette_ref; break; } + default: + break; } return buffer; } @@ -59,6 +61,8 @@ DataBuffer& operator>>(DataBuffer& buffer, game::TilePtr& tile){ tile = tilePtr; break; } + default: + break; } return buffer; } @@ -85,7 +89,7 @@ DataBuffer WorldBeginDataPacket::Serialize() const{ std::size_t bufferSize = data.GetSize(); data.Resize(bufferSize + decoTilePalette.size() * sizeof(game::Color)); - memcpy((void*)data.data() + bufferSize, decoTilePalette.data(), decoTilePalette.size() * sizeof(game::Color)); + memcpy((std::uint8_t*)data.data() + bufferSize, decoTilePalette.data(), decoTilePalette.size() * sizeof(game::Color)); const game::Spawn& redSpawn = m_World->getRedTeam().getSpawn(), blueSpawn = m_World->getBlueTeam().getSpawn(); const game::TeamCastle& redCastle = m_World->getRedTeam().getCastle(), blueCastle = m_World->getBlueTeam().getCastle(); @@ -127,7 +131,7 @@ void WorldBeginDataPacket::Deserialize(DataBuffer& data){ m_TilePalette.reserve(tilePaletteSize); - for (int i = 0; i < tilePaletteSize; i++){ + for (std::uint64_t tileNumber = 0; tileNumber < tilePaletteSize; tileNumber++){ game::TilePtr tile; data >> tile; m_TilePalette.push_back(tile); @@ -149,7 +153,7 @@ DataBuffer WorldDataPacket::Serialize() const{ std::size_t bufferSize = data.GetSize(); data.Resize(data.GetSize() + chunk->palette.size() * sizeof(game::ChunkPalette::value_type)); - memcpy((void*)data.data() + bufferSize, chunk->palette.data(), chunk->palette.size() * sizeof(game::ChunkPalette::value_type)); + memcpy((std::uint8_t*)data.data() + bufferSize, chunk->palette.data(), chunk->palette.size() * sizeof(game::ChunkPalette::value_type)); std::uint8_t bitsPerTile = countBits(chunk->palette.size()); @@ -176,7 +180,7 @@ DataBuffer WorldDataPacket::Serialize() const{ bufferSize = data.GetSize(); data.Resize(data.GetSize() + chunkData.size() * sizeof(ChunkPackedData::value_type)); - memcpy((void*)data.data() + bufferSize, chunkData.data(), chunkData.size() * sizeof(ChunkPackedData::value_type)); + memcpy((std::uint8_t*)data.data() + bufferSize, chunkData.data(), chunkData.size() * sizeof(ChunkPackedData::value_type)); } return data; } @@ -185,7 +189,7 @@ void WorldDataPacket::Deserialize(DataBuffer& data){ std::uint64_t chunkCount; data >> chunkCount; - for (int chunkNumber = 0; chunkNumber < chunkCount; chunkNumber++){ + for (std::uint64_t chunkNumber = 0; chunkNumber < chunkCount; chunkNumber++){ game::ChunkPtr chunk = std::make_shared(); game::ChunkCoord::first_type chunkX, chunkY; diff --git a/src/render/gui/TowerGui.cpp b/src/render/gui/TowerGui.cpp index c619701..3c54e93 100644 --- a/src/render/gui/TowerGui.cpp +++ b/src/render/gui/TowerGui.cpp @@ -161,12 +161,13 @@ void renderMainMenu(){ ImVec4 getImGuiTeamColor(td::game::TeamColor color){ switch (color){ case td::game::TeamColor::None: - return ImVec4(1, 1, 1, 1); + break; case td::game::TeamColor::Red: return ImVec4(1, 0, 0, 1); case td::game::TeamColor::Blue: return ImVec4(0, 0, 1, 1); } + return ImVec4(1, 1, 1, 1); } void showPlayers(){ diff --git a/src/render/gui/imgui/imgui_filebrowser.cpp b/src/render/gui/imgui/imgui_filebrowser.cpp index 62ac6db..9ce387e 100644 --- a/src/render/gui/imgui/imgui_filebrowser.cpp +++ b/src/render/gui/imgui/imgui_filebrowser.cpp @@ -227,7 +227,7 @@ namespace imgui_addons ImGui::BeginChild("##NavigationWindow", nw_size, true, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar); ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f)); - for(int i = 0; i < current_dirlist.size(); i++) + for(std::size_t i = 0; i < current_dirlist.size(); i++) { if( ImGui::Button(current_dirlist[i].c_str()) ) { @@ -259,7 +259,7 @@ namespace imgui_addons if(ImGui::ListBoxHeader("##NavBarDropBox", ImVec2(0, list_item_height* 5))) { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f)); - for(int j = i+1; j < current_dirlist.size(); j++) + for(std::size_t j = i+1; j < current_dirlist.size(); j++) { if(ImGui::Selectable(current_dirlist[j].c_str(), false) && j != current_dirlist.size() - 1) { @@ -345,12 +345,12 @@ namespace imgui_addons //Output directories in yellow ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f)); int items = 0; - for (int i = 0; i < filtered_dirs.size(); i++) + for (std::size_t i = 0; i < filtered_dirs.size(); i++) { if(!filtered_dirs[i]->is_hidden || show_hidden) { items++; - if(ImGui::Selectable(filtered_dirs[i]->name.c_str(), selected_idx == i && is_dir, ImGuiSelectableFlags_AllowDoubleClick)) + if(ImGui::Selectable(filtered_dirs[i]->name.c_str(), selected_idx == (int) i && is_dir, ImGuiSelectableFlags_AllowDoubleClick)) { selected_idx = i; is_dir = true; @@ -372,14 +372,13 @@ namespace imgui_addons ImGui::PopStyleColor(1); //Output files - for (int i = 0; i < filtered_files.size(); i++) + for (std::size_t i = 0; i < filtered_files.size(); i++) { if(!filtered_files[i]->is_hidden || show_hidden) { items++; - if(ImGui::Selectable(filtered_files[i]->name.c_str(), selected_idx == i && !is_dir, ImGuiSelectableFlags_AllowDoubleClick)) + if(ImGui::Selectable(filtered_files[i]->name.c_str(), selected_idx == (int) i && !is_dir, ImGuiSelectableFlags_AllowDoubleClick)) { - int len = filtered_files[i]->name.length(); selected_idx = i; is_dir = false; @@ -406,7 +405,6 @@ namespace imgui_addons { std::string label = (dialog_mode == DialogMode::SAVE) ? "Save As:" : "Open:"; ImGuiStyle& style = ImGui::GetStyle(); - ImGuiIO& io = ImGui::GetIO(); ImVec2 pw_pos = ImGui::GetWindowPos(); ImVec2 pw_content_sz = ImGui::GetWindowSize() - style.WindowPadding * 2.0; @@ -452,7 +450,7 @@ namespace imgui_addons if(dialog_mode == DialogMode::OPEN || dialog_mode == DialogMode::SAVE) { inputcb_filter_files.clear(); - for(int i = 0; i < subfiles.size(); i++) + for(std::size_t i = 0; i < subfiles.size(); i++) { if(ImStristr(subfiles[i].name.c_str(), nullptr, input_fn, nullptr) != nullptr) inputcb_filter_files.push_back(std::ref(subfiles[i].name)); @@ -463,7 +461,7 @@ namespace imgui_addons else if(dialog_mode == DialogMode::SELECT) { inputcb_filter_files.clear(); - for(int i = 0; i < subdirs.size(); i++) + for(std::size_t i = 0; i < subdirs.size(); i++) { if(ImStristr(subdirs[i].name.c_str(), nullptr, input_fn, nullptr) != nullptr) inputcb_filter_files.push_back(std::ref(subdirs[i].name)); @@ -642,7 +640,7 @@ namespace imgui_addons ImGui::PushItemWidth(ext_box_width); if(ImGui::BeginCombo("##FileTypes", valid_exts[selected_ext_idx].c_str())) { - for(int i = 0; i < valid_exts.size(); i++) + for(std::size_t i = 0; i < valid_exts.size(); i++) { if(ImGui::Selectable(valid_exts[i].c_str(), selected_ext_idx == i)) { @@ -653,7 +651,7 @@ namespace imgui_addons size_t idx = name.find_last_of("."); if(idx == std::string::npos) idx = strlen(input_fn); - for(int j = 0; j < valid_exts[selected_ext_idx].size(); j++) + for(std::size_t j = 0; j < valid_exts[selected_ext_idx].size(); j++) input_fn[idx++] = valid_exts[selected_ext_idx][j]; input_fn[idx++] = '\0'; } @@ -910,8 +908,6 @@ namespace imgui_addons bool ret_val = false; if (ImGui::BeginPopupModal(repfile_modal_id.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize)) { - float frame_height = ImGui::GetFrameHeightWithSpacing(); - std::string text = "A file with the following filename already exists. Are you sure you want to replace the existing file?"; ImGui::TextWrapped("%s", text.c_str()); @@ -942,9 +938,7 @@ namespace imgui_addons void ImGuiFileBrowser::showInvalidFileModal() { - ImGuiStyle& style = ImGui::GetStyle(); std::string text = "Selected file either doesn't exist or is not supported. Please select a file with the following extensions..."; - ImVec2 text_size = ImGui::CalcTextSize(text.c_str(), nullptr, true, 350 - style.WindowPadding.x * 2.0); ImVec2 button_size = getButtonSize("OK"); float frame_height = ImGui::GetFrameHeightWithSpacing(); @@ -958,7 +952,7 @@ namespace imgui_addons ImGui::TextWrapped("%s", text.c_str()); ImGui::BeginChild("##SupportedExts", ImVec2(0, cw_height), true); - for(int i = 0; i < valid_exts.size(); i++) + for(std::size_t i = 0; i < valid_exts.size(); i++) ImGui::BulletText("%s", valid_exts[i].c_str()); ImGui::EndChild(); @@ -1010,7 +1004,7 @@ namespace imgui_addons { if(dialog_mode == DialogMode::SELECT) { - for(int i = 0; i < subdirs.size(); i++) + for(std::size_t i = 0; i < subdirs.size(); i++) { if(subdirs[i].name == selected_fn) { @@ -1022,7 +1016,7 @@ namespace imgui_addons } else { - for(int i = 0; i < subfiles.size(); i++) + for(std::size_t i = 0; i < subfiles.size(); i++) { if(subfiles[i].name == selected_fn) { @@ -1051,7 +1045,7 @@ namespace imgui_addons if(ext == "*.*") return true; } - int idx = selected_fn.find_last_of('.'); + auto idx = selected_fn.find_last_of('.'); std::string file_ext = idx == std::string::npos ? "" : selected_fn.substr(idx, selected_fn.length() - idx); return (std::find(valid_exts.begin(), valid_exts.end(), file_ext) != valid_exts.end()); } diff --git a/src/render/gui/imgui/imgui_filebrowser.h b/src/render/gui/imgui/imgui_filebrowser.h index b567373..9cc8d2d 100644 --- a/src/render/gui/imgui/imgui_filebrowser.h +++ b/src/render/gui/imgui/imgui_filebrowser.h @@ -99,7 +99,8 @@ namespace imgui_addons ImVec2 min_size, max_size, input_combobox_pos, input_combobox_sz; DialogMode dialog_mode; - int filter_mode, col_items_limit, selected_idx, selected_ext_idx; + std::size_t filter_mode, col_items_limit, selected_ext_idx; + int selected_idx; float col_width, ext_box_width; bool show_hidden, show_inputbar_combobox, is_dir, is_appearing, filter_dirty, validate_file; char input_fn[256]; diff --git a/src/render/loader/GLLoader.cpp b/src/render/loader/GLLoader.cpp index 9eb6f01..4c8d14d 100644 --- a/src/render/loader/GLLoader.cpp +++ b/src/render/loader/GLLoader.cpp @@ -68,7 +68,7 @@ namespace GL{ void VBO::bindVertexAttribs() const{ for(const VertexAttribPointer& pointer : m_VertexAttribs){ glEnableVertexAttribArray(pointer.m_Index); - glVertexAttribPointer(pointer.m_Index, pointer.m_Size, GL_FLOAT, false, m_DataStride * sizeof(float), (void*) pointer.m_Offset); + glVertexAttribPointer(pointer.m_Index, pointer.m_Size, GL_FLOAT, false, m_DataStride * sizeof(float), (void*)(intptr_t) pointer.m_Offset); } } } \ No newline at end of file diff --git a/src/render/loader/WorldLoader.cpp b/src/render/loader/WorldLoader.cpp index 9188763..bf9cfbe 100644 --- a/src/render/loader/WorldLoader.cpp +++ b/src/render/loader/WorldLoader.cpp @@ -98,13 +98,13 @@ GL::VAO loadWorldModel(const td::game::World* world){ positions.push_back(chunkX + tileX + 1); positions.push_back(chunkY + tileY + 1);*/ - const td::game::Color& tileColor = world->getTileColor(tile); + const td::game::Color* tileColor = world->getTileColor(tile); for (int i = 0; i < 6; i++){ int color = 255; - color |= tileColor.r << 24; - color |= tileColor.g << 16; - color |= tileColor.b << 8; + color |= tileColor->r << 24; + color |= tileColor->g << 16; + color |= tileColor->b << 8; int newColorIndex = colors.size(); colors.push_back(0); diff --git a/src/render/shaders/ShaderProgram.cpp b/src/render/shaders/ShaderProgram.cpp index f0396a6..011537a 100755 --- a/src/render/shaders/ShaderProgram.cpp +++ b/src/render/shaders/ShaderProgram.cpp @@ -35,14 +35,6 @@ int ShaderProgram::getUniformLocation(const std::string& uniformName) const{ const int location = glGetUniformLocation(programID, uniformName.c_str()); if (location == -1){ std::cout << "Warning ! Uniform variable " << uniformName << " not found !\n"; - const GLenum error = glGetError(); - switch (error){ - case GL_INVALID_VALUE: - break; - - case GL_INVALID_OPERATION: - break; - } } return location; } diff --git a/src/window/Display.cpp b/src/window/Display.cpp index 285298a..e609e50 100644 --- a/src/window/Display.cpp +++ b/src/window/Display.cpp @@ -21,7 +21,6 @@ namespace Display { static GLFWwindow* window; -static bool closeRequested = false; static int lastWidth = 0, lastHeight = 0; static float aspectRatio; @@ -83,7 +82,7 @@ bool isCloseRequested() { return glfwWindowShouldClose(window); } -const bool isMouseDown(int button) { +bool isMouseDown(int button) { return glfwGetMouseButton(window, button); } diff --git a/xmake.lua b/xmake.lua index 4f65884..c10eb77 100644 --- a/xmake.lua +++ b/xmake.lua @@ -26,12 +26,16 @@ target("Tower Defense") -- strip all symbols add_ldflags("-s") + set_warnings("all", "error") + set_optimize("smallest") if is_os("windows") then add_ldflags("-static-libgcc", "-static-libstdc++", "-pthread") end + else + add_cxflags("-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused") end --