From 142e303cbb5b645eba36ae38c44daab82e68a8d0 Mon Sep 17 00:00:00 2001 From: Euxiniar Date: Wed, 24 Oct 2018 17:08:26 +0200 Subject: [PATCH 1/2] fix OpenGL exception, the Lua CMake, and some warnings --- deps/Lua/src/CMakeLists.txt | 2 +- src/app/Application.cpp | 6 +++--- src/entity/AStar.h | 6 +++--- src/entity/Entity.h | 2 +- src/graphics/Renderer2D.cpp | 7 +++++-- src/level/gen/WorldGenerator.cpp | 12 ++++++------ src/level/tile/TileMap.cpp | 6 +++--- src/util/Log.h | 6 +++--- 8 files changed, 25 insertions(+), 22 deletions(-) diff --git a/deps/Lua/src/CMakeLists.txt b/deps/Lua/src/CMakeLists.txt index 520d056..fa77cfd 100644 --- a/deps/Lua/src/CMakeLists.txt +++ b/deps/Lua/src/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 2.6) - +cmake_policy(SET CMP0015 NEW) project (lua) # project here actually means solution in premake if(WIN32) diff --git a/src/app/Application.cpp b/src/app/Application.cpp index cf82176..a9356dd 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -1,4 +1,4 @@ -#include "Application.h" +#include "Application.h" #include "states/StateMenu.h" #include "states/StatePlaying.h" @@ -79,7 +79,7 @@ void Application::start() updates++; upTimer += UP_TICK; m_states.back()->update(timestep); - for (int32 i = m_panels.size() - 1; i >= 0; i--) + for (int32 i = static_cast(m_panels.size()) - 1; i >= 0; i--) m_panels[i]->update(); } @@ -124,7 +124,7 @@ void Application::render() sf::View oldView = m_window.getView(); m_window.setView(m_uiView); - for (int32 i = m_panels.size() - 1; i >= 0; i--) + for (int32 i = static_cast(m_panels.size()) - 1; i >= 0; i--) m_panels[i]->render(m_window); m_fpsLabel->render(m_window); diff --git a/src/entity/AStar.h b/src/entity/AStar.h index a7d2c22..27be640 100644 --- a/src/entity/AStar.h +++ b/src/entity/AStar.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "../Common.h" @@ -63,7 +63,7 @@ namespace std auto h1 = hasher(std::get<0>(pos)); auto h2 = hasher(std::get<1>(pos)); - return std::hash{}((h1 ^ h2) >> 2); + return std::hash{}((static_cast(h1 ^ h2)) >> 2); } }; -} \ No newline at end of file +} diff --git a/src/entity/Entity.h b/src/entity/Entity.h index 4255c1b..5fedc48 100644 --- a/src/entity/Entity.h +++ b/src/entity/Entity.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "../components/Component.h" diff --git a/src/graphics/Renderer2D.cpp b/src/graphics/Renderer2D.cpp index 4b1faa8..cf153d7 100644 --- a/src/graphics/Renderer2D.cpp +++ b/src/graphics/Renderer2D.cpp @@ -1,4 +1,4 @@ -#include "Renderer2D.h" +#include "Renderer2D.h" #include "../maths/maths.h" #include "../maths/Color.h" @@ -8,7 +8,10 @@ namespace Graphics Renderer2D::Renderer2D() { m_before.buffer = new sf::Vertex[MAX_VERTICES]; + m_before.vertexCount = 0; + m_after.buffer = new sf::Vertex[MAX_VERTICES]; + m_after.vertexCount = 0; } Renderer2D::~Renderer2D() @@ -76,4 +79,4 @@ namespace Graphics render.vertexCount += 4; } -} \ No newline at end of file +} diff --git a/src/level/gen/WorldGenerator.cpp b/src/level/gen/WorldGenerator.cpp index 6835588..807a5bb 100644 --- a/src/level/gen/WorldGenerator.cpp +++ b/src/level/gen/WorldGenerator.cpp @@ -1,4 +1,4 @@ -#include "WorldGenerator.h" +#include "WorldGenerator.h" #include "../../util/FileUtil.h" namespace WGenerator @@ -11,8 +11,8 @@ namespace WGenerator if (! (mainJSON["seed"] == "random")) m_generator.setSeed(mainJSON["seed"]); - for (int i=0; i < mainJSON["width"]; i++) { - for (int j=0; j(mainJSON["width"]); i++) { + for (int j=0; j < static_cast(mainJSON["height"]); j++) { addList.push_back({i, j, mainJSON["defaultWall"], 0}); } } @@ -32,7 +32,7 @@ namespace WGenerator if (!m_leafs[i]->leftChild && !m_leafs[i]->rightChild) { int randomizedValue = m_generator.intInRange(0, 100); - if (m_leafs[i]->block.width > mainJSON["maxLeafSize"] || m_leafs[i]->block.height > mainJSON["maxLeafSize"] || + if (m_leafs[i]->block.width > static_cast(mainJSON["maxLeafSize"]) || m_leafs[i]->block.height > static_cast(mainJSON["maxLeafSize"]) || randomizedValue > 25) { if (m_leafs[i]->split()) @@ -113,7 +113,7 @@ namespace WGenerator data.push_back(std::make_pair>, byte>(getHalls(), mainJSON["defaultFloor"])); renderRooms(); render(data); - uint numberOfRooms = getRooms().size(); + uint numberOfRooms = static_cast(getRooms().size()); map.addList = addList; map.playerPosition = placePlayer(static_cast(m_generator.uint64InRange(0, numberOfRooms))); return map; @@ -147,7 +147,7 @@ namespace WGenerator uint i=0; while (true){ if (i >= random.size()) break; - if (random.at(i)["chance"] > x) { + if (static_cast(random.at(i)["chance"]) > x) { renderRoom(*rooms[roomIterator], random[i]); break; } diff --git a/src/level/tile/TileMap.cpp b/src/level/tile/TileMap.cpp index 80850e8..afd9ccd 100644 --- a/src/level/tile/TileMap.cpp +++ b/src/level/tile/TileMap.cpp @@ -1,4 +1,4 @@ -#include "TileMap.h" +#include "TileMap.h" #include "TileDatabase.h" @@ -114,8 +114,8 @@ namespace Level // -- // Do not render tiles that can not be seen (dark) - int32 xa = x - 1 <= 0 ? 1 : x - 1, xb = x + 1 >= height ? height - 1 : x + 1; - int32 ya = y - 1 <= 0 ? 1 : y - 1, yb = y + 1 >= height ? height - 1 : y + 1; + int32 xa = x - 1 <= 0 ? 1 : x - 1, xb = x + 1 >= (int32)height ? height - 1 : x + 1; + int32 ya = y - 1 <= 0 ? 1 : y - 1, yb = y + 1 >= (int32)height ? height - 1 : y + 1; if (layer->tiles[xa][ya]->light.color == Color::Black && layer->tiles[xb][yb]->light.color == Color::Black && layer->tiles[xa][yb]->light.color == Color::Black && layer->tiles[xb][ya]->light.color == Color::Black) diff --git a/src/util/Log.h b/src/util/Log.h index 642ecc5..87b2e8f 100644 --- a/src/util/Log.h +++ b/src/util/Log.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "../Common.h" @@ -107,7 +107,7 @@ namespace Log inline void print_log_internal(char* buffer, int32& position, First&& first) { const char* formatted = Log::to_string(first); - int32 length = strlen(formatted); + int32 length = static_cast(strlen(formatted)); memcpy(&buffer[position], formatted, length); position += length; } @@ -116,7 +116,7 @@ namespace Log inline void print_log_internal(char* buffer, int32& position, First&& first, Args&&... args) { const char* formatted = Log::to_string(first); - int32 length = strlen(formatted); + int32 length = static_cast(strlen(formatted)); memcpy(&buffer[position], formatted, length); position += length; if (sizeof...(Args)) From 1f2165e719c5f9e6e03c466c992e061d426c21e2 Mon Sep 17 00:00:00 2001 From: Euxiniar Date: Wed, 24 Oct 2018 17:33:08 +0200 Subject: [PATCH 2/2] Update .travis.yml --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index deca3c7..e47b46a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,5 @@ before_install: - export CXX="g++-6" CC="gcc-6" before_script: - - sudo apt-get install -y libudev-dev libjpeg62-dev libsndfile1-dev libglew1.5 libglew1.5-dev libfreetype6 libjpeg-turbo8 libjpeg8 libopenal-data libopenal1 libopenal-dev libxrandr2 libxrender1 libsoil1 - -script: mkdir build && cd build && cmake .. && make \ No newline at end of file + - sudo apt-get install -y libudev-dev libjpeg62-dev libsndfile1-dev libglew1.5 libglew1.5-dev libfreetype6 libjpeg-turbo8 libjpeg8 libopenal-data libopenal1 libopenal-dev libxrandr2 libxrender1 libsoil1 xorg-dev libglu1-mesa-dev +script: mkdir build && cd build && cmake .. && make