From e2f288cc86931cc8383108373e62d51d0a62d3fb Mon Sep 17 00:00:00 2001 From: Quentin Bazin Date: Wed, 23 Jun 2021 16:28:38 +0200 Subject: [PATCH] [external/gamekit] Updated. Fixed build for MSVC (VS2019). Also fixed a lot of warning from MSVC. --- external/gamekit | 2 +- source/client/graphics/ChunkRenderer.cpp | 2 +- source/client/graphics/PlayerBox.cpp | 12 +++++------ source/client/graphics/TextureAtlas.cpp | 2 +- source/client/gui/InventoryCube.cpp | 12 +++++------ source/client/gui/InventoryWidget.cpp | 2 +- source/client/gui/ScrollableList.cpp | 2 +- source/client/gui/SliderWidget.cpp | 2 +- source/client/gui/TextButton.cpp | 6 +++--- source/client/hud/BlockCursor.cpp | 14 ++++++------- source/client/hud/Minimap.cpp | 4 ++-- source/client/states/ServerConnectState.cpp | 4 ++-- source/client/states/ServerLoadingState.cpp | 4 ++-- source/client/states/SettingsMenuState.cpp | 4 ++-- .../states/TexturePackSelectionState.cpp | 2 +- source/client/states/TitleScreenState.cpp | 4 ++-- source/client/states/WorldCreationState.cpp | 4 ++-- source/client/states/WorldDeletionState.cpp | 2 +- source/client/states/WorldSavingState.cpp | 4 ++-- source/client/states/WorldSelectionState.cpp | 2 +- source/client/world/ClientChunk.cpp | 12 +++++------ source/client/world/ClientChunk.hpp | 2 +- source/client/world/ClientPlayer.cpp | 4 ++-- source/client/world/ClientPlayer.hpp | 2 +- source/client/world/ClientWorld.cpp | 4 ++-- source/client/world/mesh/XShapeMesher.hpp | 2 +- source/common/core/Registry.cpp | 20 +++++++++---------- source/common/core/Registry.hpp | 8 ++++---- source/common/network/CompressedPacket.cpp | 4 ++-- source/common/world/Block.cpp | 4 ++-- source/server/network/ServerInfo.cpp | 2 +- source/server/world/ServerChunk.cpp | 2 +- 32 files changed, 78 insertions(+), 78 deletions(-) diff --git a/external/gamekit b/external/gamekit index 907610cb..792cb11c 160000 --- a/external/gamekit +++ b/external/gamekit @@ -1 +1 @@ -Subproject commit 907610cbc8f6606d5453b430a913d8fb87a1ce59 +Subproject commit 792cb11ce6fe131d742141152b2e23ceaf6de900 diff --git a/source/client/graphics/ChunkRenderer.cpp b/source/client/graphics/ChunkRenderer.cpp index 53e3734e..63b476ab 100644 --- a/source/client/graphics/ChunkRenderer.cpp +++ b/source/client/graphics/ChunkRenderer.cpp @@ -300,7 +300,7 @@ void ChunkRenderer::drawChunks(gk::RenderTarget &target, gk::RenderStates states states.shader->setUniform(modelMatrixUniform, it.second); gk::VertexArray::bind(&it.first->getVertexArray()); - target.drawArrays(GL_TRIANGLES, it.first->getBufferOffset(layer), (GLsizei)verticesCount); + target.drawArrays(GL_TRIANGLES, (GLint)it.first->getBufferOffset(layer), (GLsizei)verticesCount); gk::VertexArray::bind(nullptr); if (!it.first->hasBeenDrawn()) diff --git a/source/client/graphics/PlayerBox.cpp b/source/client/graphics/PlayerBox.cpp index e1b63317..deda6bd2 100644 --- a/source/client/graphics/PlayerBox.cpp +++ b/source/client/graphics/PlayerBox.cpp @@ -250,12 +250,12 @@ PlayerBox::PlayerBox(const gk::Camera &camera) : m_camera(camera), m_texture(gk::ResourceHandler::getInstance().get("texture-player")) { - m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); - m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texCoord))); - m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, color))); - m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); - m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, lightValue))); - m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, ambientOcclusion))); + m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); + m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texCoord))); + m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, color))); + m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); + m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, lightValue))); + m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, ambientOcclusion))); updateVertexBuffer(); } diff --git a/source/client/graphics/TextureAtlas.cpp b/source/client/graphics/TextureAtlas.cpp index 5a6d71c2..a9407bce 100644 --- a/source/client/graphics/TextureAtlas.cpp +++ b/source/client/graphics/TextureAtlas.cpp @@ -123,7 +123,7 @@ void TextureAtlas::addFile(const std::string &path, const std::string &filename) if (m_tileSize != surface->w || m_tileSize != surface->h) throw EXCEPTION("Texture size unexpected for", path + filename + ". Got", surface->w, surface->h, "instead of", m_tileSize, m_tileSize); - m_textureMap.emplace(filename, m_textures.size()); + m_textureMap.emplace(filename, (u16)m_textures.size()); m_textures.emplace_back(std::move(surface)); } diff --git a/source/client/gui/InventoryCube.cpp b/source/client/gui/InventoryCube.cpp index 220aa8e8..23869a5c 100644 --- a/source/client/gui/InventoryCube.cpp +++ b/source/client/gui/InventoryCube.cpp @@ -42,14 +42,14 @@ InventoryCube::InventoryCube(float size, bool isEntity) : m_textureAtlas(&gk::ResourceHandler::getInstance().get("atlas-blocks")) { - m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); - m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texCoord))); - m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, color))); + m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); + m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texCoord))); + m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, color))); if (isEntity) { - m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); - m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, lightValue))); - m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, ambientOcclusion))); + m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); + m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, lightValue))); + m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, ambientOcclusion))); } m_size = size; diff --git a/source/client/gui/InventoryWidget.cpp b/source/client/gui/InventoryWidget.cpp index f83b4de8..da62f320 100644 --- a/source/client/gui/InventoryWidget.cpp +++ b/source/client/gui/InventoryWidget.cpp @@ -159,7 +159,7 @@ void InventoryWidget::loadItemWidgets(u16 offset, u16 size, std::string search) ItemWidget &widget = m_itemWidgets.back(); widget.update(); - widget.setPosition((itemCounter % m_inventory->width()) * 18, (itemCounter / m_inventory->width()) * 18, 0); + widget.setPosition((itemCounter % m_inventory->width()) * 18.f, (itemCounter / m_inventory->width()) * 18.f, 0); itemCounter++; } diff --git a/source/client/gui/ScrollableList.cpp b/source/client/gui/ScrollableList.cpp index a5440c00..2d2d704b 100644 --- a/source/client/gui/ScrollableList.cpp +++ b/source/client/gui/ScrollableList.cpp @@ -84,7 +84,7 @@ void ScrollableList::onEvent(const SDL_Event &event) { } void ScrollableList::addElement(const std::string &line1, const std::string &line2, const std::string &line3, bool isSelected) { - m_elements.emplace_back(m_elements.size(), line1, line2, line3, this); + m_elements.emplace_back((u16)m_elements.size(), line1, line2, line3, this); ScrollableListElement &element = m_elements.back(); element.setPosition(0.f, float(m_elements.size() - 1) * float(m_elements.back().height() + 4) + 2.f); diff --git a/source/client/gui/SliderWidget.cpp b/source/client/gui/SliderWidget.cpp index 5e650cb9..4e851987 100644 --- a/source/client/gui/SliderWidget.cpp +++ b/source/client/gui/SliderWidget.cpp @@ -41,7 +41,7 @@ SliderWidget::SliderWidget(u16 width, Widget *parent) : Widget(width, 20, parent m_backgroundBorder.setClipRect(200 - 2, 46, 2, 20); m_sliderBorder.setPosition(8 - 2, 0); - m_backgroundBorder.setPosition(width - 2, 0); + m_backgroundBorder.setPosition(width - 2.f, 0); } void SliderWidget::onEvent(const SDL_Event &event) { diff --git a/source/client/gui/TextButton.cpp b/source/client/gui/TextButton.cpp index 0fc83cad..de39639c 100644 --- a/source/client/gui/TextButton.cpp +++ b/source/client/gui/TextButton.cpp @@ -41,9 +41,9 @@ TextButton::TextButton(u16 width, Widget *parent) : Widget(width, 20, parent) { m_hoverBackgroundBorder.setClipRect(200 - 2, 86, 2, 20); m_disabledBackgroundBorder.setClipRect(200 - 2, 46, 2, 20); - m_backgroundBorder.setPosition(width - 2, 0); - m_hoverBackgroundBorder.setPosition(width - 2, 0); - m_disabledBackgroundBorder.setPosition(width - 2, 0); + m_backgroundBorder.setPosition(width - 2.f, 0); + m_hoverBackgroundBorder.setPosition(width - 2.f, 0); + m_disabledBackgroundBorder.setPosition(width - 2.f, 0); } TextButton::TextButton(const CppCallback &callback, Widget *parent) : TextButton(parent) { diff --git a/source/client/hud/BlockCursor.cpp b/source/client/hud/BlockCursor.cpp index b84fca6b..d2bd7920 100644 --- a/source/client/hud/BlockCursor.cpp +++ b/source/client/hud/BlockCursor.cpp @@ -46,14 +46,14 @@ BlockCursor::BlockCursor(ClientPlayer &player, ClientWorld &world, ClientCommand { m_blockDestroyTexture = &gk::ResourceHandler::getInstance().get("texture-block_destroy"); - m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); + m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); - m_animationVBO.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); - m_animationVBO.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texCoord))); - m_animationVBO.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, color))); - m_animationVBO.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); - m_animationVBO.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, lightValue))); - m_animationVBO.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, ambientOcclusion))); + m_animationVBO.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); + m_animationVBO.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texCoord))); + m_animationVBO.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, color))); + m_animationVBO.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); + m_animationVBO.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, lightValue))); + m_animationVBO.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, ambientOcclusion))); } void BlockCursor::onEvent(const SDL_Event &event, const Hotbar &hotbar) { diff --git a/source/client/hud/Minimap.cpp b/source/client/hud/Minimap.cpp index 6aeda19e..5dd7c4ec 100644 --- a/source/client/hud/Minimap.cpp +++ b/source/client/hud/Minimap.cpp @@ -124,10 +124,10 @@ void Minimap::updatePlayerFovVertexBuffer() { vertices[0].coord3d[1] = 0.f; vertices[1].coord3d[0] = -sinf(glm::radians(Config::cameraFOV / 2.f)) * Config::renderDistance * (chunkSize + 2) / cosf(glm::radians(Config::cameraFOV / 2.f)); - vertices[1].coord3d[1] = -(Config::renderDistance * (chunkSize + 2)); + vertices[1].coord3d[1] = -(Config::renderDistance * (chunkSize + 2.f)); vertices[2].coord3d[0] = sinf(glm::radians(Config::cameraFOV / 2.f)) * Config::renderDistance * (chunkSize + 2) / cosf(glm::radians(Config::cameraFOV / 2.f)); - vertices[2].coord3d[1] = -(Config::renderDistance * (chunkSize + 2)); + vertices[2].coord3d[1] = -(Config::renderDistance * (chunkSize + 2.f)); gk::Color color = gk::Color::Blue; for (u8 i = 0 ; i < 3 ; ++i) { diff --git a/source/client/states/ServerConnectState.cpp b/source/client/states/ServerConnectState.cpp index 6a4e4ffd..eb260dba 100644 --- a/source/client/states/ServerConnectState.cpp +++ b/source/client/states/ServerConnectState.cpp @@ -31,7 +31,7 @@ #include "ServerLoadingState.hpp" ServerConnectState::ServerConnectState(gk::ApplicationState *parent) : InterfaceState(parent) { - m_background.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_background.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192)); @@ -68,7 +68,7 @@ ServerConnectState::ServerConnectState(gk::ApplicationState *parent) : Interface try { port = std::stoi(m_addressInput.string().substr(sep + 1)); } - catch (const std::invalid_argument &e) { + catch (std::invalid_argument &) { isPortInvalid = true; } } diff --git a/source/client/states/ServerLoadingState.cpp b/source/client/states/ServerLoadingState.cpp index 7dda01ae..35b5ceb7 100644 --- a/source/client/states/ServerLoadingState.cpp +++ b/source/client/states/ServerLoadingState.cpp @@ -41,14 +41,14 @@ ServerLoadingState::ServerLoadingState(GameState &game, bool showLoadingState, const std::string &host, u16 port, gk::ApplicationState *parent) : InterfaceState(parent), m_game(game), m_showLoadingState(showLoadingState) { - m_background.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_background.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192)); m_text.setString("Loading world..."); m_text.setColor(gk::Color::White); m_text.updateVertexBuffer(); - m_text.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_text.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); updateWidgetPosition(); diff --git a/source/client/states/SettingsMenuState.cpp b/source/client/states/SettingsMenuState.cpp index c3fef138..dcb4f09c 100644 --- a/source/client/states/SettingsMenuState.cpp +++ b/source/client/states/SettingsMenuState.cpp @@ -44,7 +44,7 @@ #include "World.hpp" SettingsMenuState::SettingsMenuState(gk::ApplicationState *parent) : InterfaceState(parent) { - m_background.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_background.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_filter1.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192)); m_filter2.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 120)); @@ -101,7 +101,7 @@ void SettingsMenuState::onEvent(const SDL_Event &event) { } void SettingsMenuState::onGuiScaleChanged(const GuiScaleChangedEvent &event) { - m_background.setScale(event.guiScale * 2, event.guiScale * 2); + m_background.setScale(event.guiScale * 2.f, event.guiScale * 2.f); m_title.setScale(event.guiScale, event.guiScale); m_menuWidget.setScale(event.guiScale, event.guiScale); diff --git a/source/client/states/TexturePackSelectionState.cpp b/source/client/states/TexturePackSelectionState.cpp index aa3e016c..dda85683 100644 --- a/source/client/states/TexturePackSelectionState.cpp +++ b/source/client/states/TexturePackSelectionState.cpp @@ -38,7 +38,7 @@ namespace fs = ghc::filesystem; TexturePackSelectionState::TexturePackSelectionState(gk::ApplicationState *parent) : InterfaceState(parent) { - m_background.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_background.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_filter1.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192)); m_filter2.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 120)); diff --git a/source/client/states/TitleScreenState.cpp b/source/client/states/TitleScreenState.cpp index cb943584..6707f9d7 100644 --- a/source/client/states/TitleScreenState.cpp +++ b/source/client/states/TitleScreenState.cpp @@ -59,7 +59,7 @@ TitleScreenState::TitleScreenState(u16 port) : m_port(port) { m_stateStack->pop(); }); - m_titleText.setScale(Config::guiScale * 4, Config::guiScale * 4); + m_titleText.setScale(Config::guiScale * 4.f, Config::guiScale * 4.f); m_titleText.setString(APP_NAME); m_titleText.updateVertexBuffer(); @@ -148,7 +148,7 @@ void TitleScreenState::onGuiScaleChanged(const GuiScaleChangedEvent &event) { m_menuWidget.setScale(event.guiScale, event.guiScale); m_menuWidget.onGuiScaleChanged(event); - m_titleText.setScale(event.guiScale * 4, event.guiScale * 4); + m_titleText.setScale(event.guiScale * 4.f, event.guiScale * 4.f); m_versionText.setScale(event.guiScale, event.guiScale); m_copyrightText.setScale(event.guiScale, event.guiScale); m_licenseText.setScale(event.guiScale, event.guiScale); diff --git a/source/client/states/WorldCreationState.cpp b/source/client/states/WorldCreationState.cpp index f473796b..8e407df1 100644 --- a/source/client/states/WorldCreationState.cpp +++ b/source/client/states/WorldCreationState.cpp @@ -45,7 +45,7 @@ WorldCreationState::WorldCreationState(TitleScreenState *titleScreen, const std: if (!originalName.empty()) m_isEdition = true; - m_background.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_background.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192)); @@ -94,7 +94,7 @@ WorldCreationState::WorldCreationState(TitleScreenState *titleScreen, const std: m_stateStack->pop(); if (!m_isEdition) { - Random::seed(time(nullptr)); + Random::seed((unsigned int)std::time(nullptr)); s32 seed = Random::get(std::numeric_limits::min(), std::numeric_limits::max()); if (!m_seedInput.string().empty()) { try { diff --git a/source/client/states/WorldDeletionState.cpp b/source/client/states/WorldDeletionState.cpp index 851d9508..d178defb 100644 --- a/source/client/states/WorldDeletionState.cpp +++ b/source/client/states/WorldDeletionState.cpp @@ -36,7 +36,7 @@ namespace fs = ghc::filesystem; WorldDeletionState::WorldDeletionState(const std::string &worldName, TitleScreenState *titleScreen) : InterfaceState(titleScreen) { - m_background.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_background.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 176)); diff --git a/source/client/states/WorldSavingState.cpp b/source/client/states/WorldSavingState.cpp index 917558b2..1d930ce7 100644 --- a/source/client/states/WorldSavingState.cpp +++ b/source/client/states/WorldSavingState.cpp @@ -36,14 +36,14 @@ WorldSavingState::WorldSavingState(Client &client, bool closeClient, gk::Applica { m_closeClient = closeClient; - m_background.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_background.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192)); m_text.setString("Saving world..."); m_text.setColor(gk::Color::White); m_text.updateVertexBuffer(); - m_text.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_text.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_client.setCommandCallback(Network::Command::ServerClosed, [&](sf::Packet &) { m_isWorldSaved = true; diff --git a/source/client/states/WorldSelectionState.cpp b/source/client/states/WorldSelectionState.cpp index be1b3d5f..b027374c 100644 --- a/source/client/states/WorldSelectionState.cpp +++ b/source/client/states/WorldSelectionState.cpp @@ -40,7 +40,7 @@ namespace fs = ghc::filesystem; WorldSelectionState::WorldSelectionState(TitleScreenState *titleScreen) : InterfaceState(titleScreen), m_titleScreen(titleScreen) { - m_background.setScale(Config::guiScale * 2, Config::guiScale * 2); + m_background.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f); m_filter1.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192)); m_filter2.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 120)); diff --git a/source/client/world/ClientChunk.cpp b/source/client/world/ClientChunk.cpp index 48afaa49..991e918e 100644 --- a/source/client/world/ClientChunk.cpp +++ b/source/client/world/ClientChunk.cpp @@ -48,12 +48,12 @@ ClientChunk::ClientChunk(s32 x, s32 y, s32 z, const Dimension &dimension, Client : Chunk(x, y, z, (World &)world), m_world(world), m_dimension(dimension) { // Setup VBO attributes - m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); - m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texCoord))); - m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, color))); - m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); - m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, lightValue))); - m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, ambientOcclusion))); + m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, coord3d))); + m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texCoord))); + m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, color))); + m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); + m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, lightValue))); + m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast(offsetof(Vertex, ambientOcclusion))); // Prepare VAO gk::VertexArray::bind(&m_vao); diff --git a/source/client/world/ClientChunk.hpp b/source/client/world/ClientChunk.hpp index acf3387a..40f9eec3 100644 --- a/source/client/world/ClientChunk.hpp +++ b/source/client/world/ClientChunk.hpp @@ -64,7 +64,7 @@ class ClientChunk : public Chunk { const gk::VertexBuffer &getVertexBuffer() { return m_vbo; } const gk::VertexArray &getVertexArray() { return m_vao; } - GLint getBufferOffset(u8 layer) const { return std::accumulate(m_verticesCount.begin(), m_verticesCount.begin() + layer, 0); } + std::size_t getBufferOffset(u8 layer) const { return std::accumulate(m_verticesCount.begin(), m_verticesCount.begin() + layer, std::size_t(0)); } std::size_t getVerticesCount(u8 layer) const { return m_verticesCount[layer]; } void setVerticesCount(u8 layer, std::size_t count) { m_verticesCount[layer] = count; } diff --git a/source/client/world/ClientPlayer.cpp b/source/client/world/ClientPlayer.cpp index c9c47561..18798869 100644 --- a/source/client/world/ClientPlayer.cpp +++ b/source/client/world/ClientPlayer.cpp @@ -138,7 +138,7 @@ void ClientPlayer::updatePosition(const ClientWorld &world) { } // Block player until the chunk loads, unless "no clip" mode is enabled else if (!Config::isNoClipEnabled) { - m_velocity = gk::Vector3f::Zero; + m_velocity.reset(0, 0, 0); } if (!Config::isNoClipEnabled) @@ -225,7 +225,7 @@ void ClientPlayer::testPoint(const ClientWorld &world, double x, double y, doubl } void ClientPlayer::applyViewBobbing(float &viewAngleH, float &viewAngleV, float &viewAngleRoll) { - if (m_velocity != gk::Vector3f::Zero && m_velocity.z == 0 && !Config::isFlyModeEnabled) { + if (!m_velocity.isZero() && m_velocity.z == 0 && !Config::isFlyModeEnabled) { if (!m_isMoving) { m_movementStartTime = gk::GameClock::getInstance().getTicks(); m_isMoving = true; diff --git a/source/client/world/ClientPlayer.hpp b/source/client/world/ClientPlayer.hpp index 35426ed1..09ba3dcc 100644 --- a/source/client/world/ClientPlayer.hpp +++ b/source/client/world/ClientPlayer.hpp @@ -78,7 +78,7 @@ class ClientPlayer : public Player { gk::Vector3f m_cameraLocalPos; - gk::Vector3f m_velocity = gk::Vector3f::Zero; + gk::Vector3f m_velocity{0, 0, 0}; // For view bobbing only bool m_isMoving = false; diff --git a/source/client/world/ClientWorld.cpp b/source/client/world/ClientWorld.cpp index 8b16d370..f9dd49cc 100644 --- a/source/client/world/ClientWorld.cpp +++ b/source/client/world/ClientWorld.cpp @@ -62,8 +62,8 @@ void ClientWorld::update(bool allowWorldReload) { ClientChunk::chunkUpdateTime = time; } if (time > ClientChunk::chunkDrawTime) { - ClientChunk::chunksRenderedPerFrame = ClientChunk::chunkDrawCounter / std::max(1ul, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame); - ClientChunk::chunkDrawCallPerFrame = ClientChunk::chunkDrawCallCounter / std::max(1ul, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame); + ClientChunk::chunksRenderedPerFrame = ClientChunk::chunkDrawCounter / std::max(1, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame); + ClientChunk::chunkDrawCallPerFrame = ClientChunk::chunkDrawCallCounter / std::max(1, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame); ClientChunk::chunkDrawCounter = 0; ClientChunk::chunkDrawCallCounter = 0; ClientChunk::chunkDrawTime = time; diff --git a/source/client/world/mesh/XShapeMesher.hpp b/source/client/world/mesh/XShapeMesher.hpp index c344cb5c..8005f040 100644 --- a/source/client/world/mesh/XShapeMesher.hpp +++ b/source/client/world/mesh/XShapeMesher.hpp @@ -29,7 +29,7 @@ #include -class ChunkMeshBuildingJob; +struct ChunkMeshBuildingJob; class BlockState; class XShapeMesher { diff --git a/source/common/core/Registry.cpp b/source/common/core/Registry.cpp index a5a22143..664b4c40 100644 --- a/source/common/core/Registry.cpp +++ b/source/common/core/Registry.cpp @@ -34,7 +34,7 @@ Registry *Registry::s_instance = nullptr; Sky &Registry::registerSky(const std::string &stringID) { - size_t id = m_skies.size(); + u16 id = (u16)m_skies.size(); m_skiesID.emplace(stringID, id); m_skies.emplace_back(id, stringID); return m_skies.back(); @@ -44,14 +44,14 @@ Sky &Registry::registerSerializedSky(sf::Packet &packet) { m_skies.emplace_back(); m_skies.back().deserialize(packet); - size_t id = m_skies.size() - 1; + u16 id = u16(m_skies.size() - 1); m_skiesID.emplace(m_skies.back().stringID(), id); return m_skies.back(); } Tree &Registry::registerTree(const std::string &stringID) { - size_t id = m_trees.size(); + u16 id = (u16)m_trees.size(); m_treesID.emplace(stringID, id); m_trees.emplace_back(id, stringID); return m_trees.back(); @@ -61,14 +61,14 @@ Tree &Registry::registerSerializedTree(sf::Packet &packet) { m_trees.emplace_back(); m_trees.back().deserialize(packet); - size_t id = m_trees.size() - 1; + u16 id = u16(m_trees.size() - 1); m_treesID.emplace(m_trees.back().stringID(), id); return m_trees.back(); } Biome &Registry::registerBiome(const std::string &stringID, const std::string &label) { - size_t id = m_biomes.size(); + u16 id = (u16)m_biomes.size(); m_biomesID.emplace(stringID, id); m_biomes.emplace_back(id, stringID, label); return m_biomes.back(); @@ -78,14 +78,14 @@ Biome &Registry::registerSerializedBiome(sf::Packet &packet) { m_biomes.emplace_back(); m_biomes.back().deserialize(packet); - size_t id = m_biomes.size() - 1; + u16 id = u16(m_biomes.size() - 1); m_biomesID.emplace(m_biomes.back().stringID(), id); return m_biomes.back(); } Dimension &Registry::registerDimension(const std::string &stringID, const std::string &label) { - size_t id = m_dimensions.size(); + u16 id = (u16)m_dimensions.size(); m_dimensionsID.emplace(stringID, id); m_dimensions.emplace_back(id, stringID, label); return m_dimensions.back(); @@ -95,14 +95,14 @@ Dimension &Registry::registerSerializedDimension(sf::Packet &packet) { m_dimensions.emplace_back(); m_dimensions.back().deserialize(packet); - size_t id = m_dimensions.size() - 1; + u16 id = u16(m_dimensions.size() - 1); m_dimensionsID.emplace(m_dimensions.back().stringID(), id); return m_dimensions.back(); } Key &Registry::registerKey(const std::string &stringID, const std::string &label) { - size_t id = GameKey::KeyCount + m_keys.size(); + u16 id = u16(GameKey::KeyCount + m_keys.size()); m_keysID.emplace(stringID, id); m_keys.emplace_back(id, stringID, label); return m_keys.back(); @@ -112,7 +112,7 @@ Key &Registry::registerSerializedKey(sf::Packet &packet) { m_keys.emplace_back(); m_keys.back().deserialize(packet); - size_t id = GameKey::KeyCount + m_keys.size() - 1; + u16 id = u16(GameKey::KeyCount + m_keys.size() - 1); m_keysID.emplace(m_biomes.back().stringID(), id); return m_keys.back(); diff --git a/source/common/core/Registry.hpp b/source/common/core/Registry.hpp index 050b669a..cb733d88 100644 --- a/source/common/core/Registry.hpp +++ b/source/common/core/Registry.hpp @@ -48,7 +48,7 @@ class Registry : public gk::ISerializable { public: template auto registerBlock(const std::string &stringID) -> typename std::enable_if::value, T&>::type { - size_t id = m_blocks.size(); + u16 id = (u16)m_blocks.size(); m_blocksID.emplace(stringID, id); m_blocks.emplace_back(std::make_unique(id, stringID)); return *static_cast(m_blocks.back().get()); @@ -59,7 +59,7 @@ class Registry : public gk::ISerializable { m_blocks.emplace_back(std::make_unique()); m_blocks.back()->deserialize(packet); - size_t id = m_blocks.size() - 1; + u16 id = u16(m_blocks.size() - 1); m_blocksID.emplace(m_blocks.back()->stringID(), id); return *static_cast(m_blocks.back().get()); @@ -67,7 +67,7 @@ class Registry : public gk::ISerializable { template auto registerItem(const TilesDef &tiles, const std::string &stringID, const std::string &label) -> typename std::enable_if::value, T&>::type { - size_t id = m_items.size(); + u16 id = (u16)m_items.size(); m_itemsID.emplace(stringID, id); m_items.emplace_back(std::make_unique(id, tiles, stringID, label)); return *static_cast(m_items.back().get()); @@ -78,7 +78,7 @@ class Registry : public gk::ISerializable { m_items.emplace_back(std::make_unique()); m_items.back()->deserialize(packet); - size_t id = m_items.size() - 1; + u16 id = u16(m_items.size() - 1); m_itemsID.emplace(m_items.back()->stringID(), id); return *static_cast(m_items.back().get()); diff --git a/source/common/network/CompressedPacket.cpp b/source/common/network/CompressedPacket.cpp index 0cf0cb91..358425d1 100644 --- a/source/common/network/CompressedPacket.cpp +++ b/source/common/network/CompressedPacket.cpp @@ -43,7 +43,7 @@ const void* CompressedPacket::onSend(std::size_t& size) { const Bytef* srcData = static_cast(getData()); // Get the size of the packet to send - uLong srcSize = getDataSize(); + uLong srcSize = (uLong)getDataSize(); // Compute the size of the compressed data uLong dstSize = compressBound(srcSize); @@ -86,7 +86,7 @@ void CompressedPacket::onReceive(const void* data, std::size_t size) { uLong dstSize = uncompressedSize; // Uncompress the data (remove the first two bytes) - int result = uncompress(m_compressionBuffer.data(), &dstSize, (srcData + 2), size - 2); + int result = uncompress(m_compressionBuffer.data(), &dstSize, (srcData + 2), (uLong)(size - 2)); if (result != Z_OK) gkError() << "Failed to uncompress packet"; diff --git a/source/common/world/Block.cpp b/source/common/world/Block.cpp index 2d8f4596..36b93008 100644 --- a/source/common/world/Block.cpp +++ b/source/common/world/Block.cpp @@ -67,9 +67,9 @@ void Block::deserialize(sf::Packet &packet) { BlockState &Block::addState() { if (!m_states.empty()) - m_states.emplace_back(m_states.size(), this, &getState(0)); + m_states.emplace_back((u16)m_states.size(), this, &getState(0)); else - m_states.emplace_back(m_states.size(), this, nullptr); + m_states.emplace_back((u16)m_states.size(), this, nullptr); return m_states.back(); } diff --git a/source/server/network/ServerInfo.cpp b/source/server/network/ServerInfo.cpp index 057dca47..0696917b 100644 --- a/source/server/network/ServerInfo.cpp +++ b/source/server/network/ServerInfo.cpp @@ -27,7 +27,7 @@ #include "ServerInfo.hpp" ClientInfo &ServerInfo::addClient(const std::shared_ptr &socket) { - m_clients.emplace_back(m_clients.size() + 1, socket); + m_clients.emplace_back(u16(m_clients.size() + 1), socket); return m_clients.back(); } diff --git a/source/server/world/ServerChunk.cpp b/source/server/world/ServerChunk.cpp index 8de39d1b..ade633ba 100644 --- a/source/server/world/ServerChunk.cpp +++ b/source/server/world/ServerChunk.cpp @@ -37,7 +37,7 @@ #include "World.hpp" ServerChunk::ServerChunk(s32 x, s32 y, s32 z, ServerWorld &world) : Chunk(x, y, z, world), m_world(world) { - m_random.seed(std::time(nullptr)); + m_random.seed((unsigned int)std::time(nullptr)); } void ServerChunk::update() {