[external/gamekit] Updated. Fixed build for MSVC (VS2019).

Also fixed a lot of warning from MSVC.
master
Quentin Bazin 2021-06-23 16:28:38 +02:00
parent 029d8baa0b
commit e2f288cc86
32 changed files with 78 additions and 78 deletions

2
external/gamekit vendored

@ -1 +1 @@
Subproject commit 907610cbc8f6606d5453b430a913d8fb87a1ce59 Subproject commit 792cb11ce6fe131d742141152b2e23ceaf6de900

View File

@ -300,7 +300,7 @@ void ChunkRenderer::drawChunks(gk::RenderTarget &target, gk::RenderStates states
states.shader->setUniform(modelMatrixUniform, it.second); states.shader->setUniform(modelMatrixUniform, it.second);
gk::VertexArray::bind(&it.first->getVertexArray()); 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); gk::VertexArray::bind(nullptr);
if (!it.first->hasBeenDrawn()) if (!it.first->hasBeenDrawn())

View File

@ -250,12 +250,12 @@ PlayerBox::PlayerBox(const gk::Camera &camera)
: m_camera(camera), : m_camera(camera),
m_texture(gk::ResourceHandler::getInstance().get<gk::Texture>("texture-player")) m_texture(gk::ResourceHandler::getInstance().get<gk::Texture>("texture-player"))
{ {
m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d))); m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d)));
m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord))); m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord)));
m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color))); m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color)));
m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal))); m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal)));
m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue))); m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue)));
m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion))); m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion)));
updateVertexBuffer(); updateVertexBuffer();
} }

View File

@ -123,7 +123,7 @@ void TextureAtlas::addFile(const std::string &path, const std::string &filename)
if (m_tileSize != surface->w || m_tileSize != surface->h) 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); 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)); m_textures.emplace_back(std::move(surface));
} }

View File

@ -42,14 +42,14 @@
InventoryCube::InventoryCube(float size, bool isEntity) InventoryCube::InventoryCube(float size, bool isEntity)
: m_textureAtlas(&gk::ResourceHandler::getInstance().get<TextureAtlas>("atlas-blocks")) : m_textureAtlas(&gk::ResourceHandler::getInstance().get<TextureAtlas>("atlas-blocks"))
{ {
m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d))); m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d)));
m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord))); m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord)));
m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color))); m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color)));
if (isEntity) { if (isEntity) {
m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal))); m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal)));
m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue))); m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue)));
m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion))); m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion)));
} }
m_size = size; m_size = size;

View File

@ -159,7 +159,7 @@ void InventoryWidget::loadItemWidgets(u16 offset, u16 size, std::string search)
ItemWidget &widget = m_itemWidgets.back(); ItemWidget &widget = m_itemWidgets.back();
widget.update(); 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++; itemCounter++;
} }

View File

@ -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) { 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(); ScrollableListElement &element = m_elements.back();
element.setPosition(0.f, float(m_elements.size() - 1) * float(m_elements.back().height() + 4) + 2.f); element.setPosition(0.f, float(m_elements.size() - 1) * float(m_elements.back().height() + 4) + 2.f);

View File

@ -41,7 +41,7 @@ SliderWidget::SliderWidget(u16 width, Widget *parent) : Widget(width, 20, parent
m_backgroundBorder.setClipRect(200 - 2, 46, 2, 20); m_backgroundBorder.setClipRect(200 - 2, 46, 2, 20);
m_sliderBorder.setPosition(8 - 2, 0); 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) { void SliderWidget::onEvent(const SDL_Event &event) {

View File

@ -41,9 +41,9 @@ TextButton::TextButton(u16 width, Widget *parent) : Widget(width, 20, parent) {
m_hoverBackgroundBorder.setClipRect(200 - 2, 86, 2, 20); m_hoverBackgroundBorder.setClipRect(200 - 2, 86, 2, 20);
m_disabledBackgroundBorder.setClipRect(200 - 2, 46, 2, 20); m_disabledBackgroundBorder.setClipRect(200 - 2, 46, 2, 20);
m_backgroundBorder.setPosition(width - 2, 0); m_backgroundBorder.setPosition(width - 2.f, 0);
m_hoverBackgroundBorder.setPosition(width - 2, 0); m_hoverBackgroundBorder.setPosition(width - 2.f, 0);
m_disabledBackgroundBorder.setPosition(width - 2, 0); m_disabledBackgroundBorder.setPosition(width - 2.f, 0);
} }
TextButton::TextButton(const CppCallback &callback, Widget *parent) : TextButton(parent) { TextButton::TextButton(const CppCallback &callback, Widget *parent) : TextButton(parent) {

View File

@ -46,14 +46,14 @@ BlockCursor::BlockCursor(ClientPlayer &player, ClientWorld &world, ClientCommand
{ {
m_blockDestroyTexture = &gk::ResourceHandler::getInstance().get<gk::Texture>("texture-block_destroy"); m_blockDestroyTexture = &gk::ResourceHandler::getInstance().get<gk::Texture>("texture-block_destroy");
m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d))); m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d)));
m_animationVBO.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d))); m_animationVBO.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d)));
m_animationVBO.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord))); m_animationVBO.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord)));
m_animationVBO.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color))); m_animationVBO.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color)));
m_animationVBO.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal))); m_animationVBO.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal)));
m_animationVBO.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue))); m_animationVBO.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue)));
m_animationVBO.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion))); m_animationVBO.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion)));
} }
void BlockCursor::onEvent(const SDL_Event &event, const Hotbar &hotbar) { void BlockCursor::onEvent(const SDL_Event &event, const Hotbar &hotbar) {

View File

@ -124,10 +124,10 @@ void Minimap::updatePlayerFovVertexBuffer() {
vertices[0].coord3d[1] = 0.f; 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[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[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; gk::Color color = gk::Color::Blue;
for (u8 i = 0 ; i < 3 ; ++i) { for (u8 i = 0 ; i < 3 ; ++i) {

View File

@ -31,7 +31,7 @@
#include "ServerLoadingState.hpp" #include "ServerLoadingState.hpp"
ServerConnectState::ServerConnectState(gk::ApplicationState *parent) : InterfaceState(parent) { 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)); m_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192));
@ -68,7 +68,7 @@ ServerConnectState::ServerConnectState(gk::ApplicationState *parent) : Interface
try { try {
port = std::stoi(m_addressInput.string().substr(sep + 1)); port = std::stoi(m_addressInput.string().substr(sep + 1));
} }
catch (const std::invalid_argument &e) { catch (std::invalid_argument &) {
isPortInvalid = true; isPortInvalid = true;
} }
} }

View File

@ -41,14 +41,14 @@
ServerLoadingState::ServerLoadingState(GameState &game, bool showLoadingState, const std::string &host, u16 port, gk::ApplicationState *parent) ServerLoadingState::ServerLoadingState(GameState &game, bool showLoadingState, const std::string &host, u16 port, gk::ApplicationState *parent)
: InterfaceState(parent), m_game(game), m_showLoadingState(showLoadingState) : 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_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192));
m_text.setString("Loading world..."); m_text.setString("Loading world...");
m_text.setColor(gk::Color::White); m_text.setColor(gk::Color::White);
m_text.updateVertexBuffer(); m_text.updateVertexBuffer();
m_text.setScale(Config::guiScale * 2, Config::guiScale * 2); m_text.setScale(Config::guiScale * 2.f, Config::guiScale * 2.f);
updateWidgetPosition(); updateWidgetPosition();

View File

@ -44,7 +44,7 @@
#include "World.hpp" #include "World.hpp"
SettingsMenuState::SettingsMenuState(gk::ApplicationState *parent) : InterfaceState(parent) { 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_filter1.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192));
m_filter2.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 120)); 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) { 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_title.setScale(event.guiScale, event.guiScale);
m_menuWidget.setScale(event.guiScale, event.guiScale); m_menuWidget.setScale(event.guiScale, event.guiScale);

View File

@ -38,7 +38,7 @@
namespace fs = ghc::filesystem; namespace fs = ghc::filesystem;
TexturePackSelectionState::TexturePackSelectionState(gk::ApplicationState *parent) : InterfaceState(parent) { 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_filter1.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192));
m_filter2.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 120)); m_filter2.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 120));

View File

@ -59,7 +59,7 @@ TitleScreenState::TitleScreenState(u16 port) : m_port(port) {
m_stateStack->pop(); 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.setString(APP_NAME);
m_titleText.updateVertexBuffer(); m_titleText.updateVertexBuffer();
@ -148,7 +148,7 @@ void TitleScreenState::onGuiScaleChanged(const GuiScaleChangedEvent &event) {
m_menuWidget.setScale(event.guiScale, event.guiScale); m_menuWidget.setScale(event.guiScale, event.guiScale);
m_menuWidget.onGuiScaleChanged(event); 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_versionText.setScale(event.guiScale, event.guiScale);
m_copyrightText.setScale(event.guiScale, event.guiScale); m_copyrightText.setScale(event.guiScale, event.guiScale);
m_licenseText.setScale(event.guiScale, event.guiScale); m_licenseText.setScale(event.guiScale, event.guiScale);

View File

@ -45,7 +45,7 @@ WorldCreationState::WorldCreationState(TitleScreenState *titleScreen, const std:
if (!originalName.empty()) if (!originalName.empty())
m_isEdition = true; 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)); m_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192));
@ -94,7 +94,7 @@ WorldCreationState::WorldCreationState(TitleScreenState *titleScreen, const std:
m_stateStack->pop(); m_stateStack->pop();
if (!m_isEdition) { if (!m_isEdition) {
Random::seed(time(nullptr)); Random::seed((unsigned int)std::time(nullptr));
s32 seed = Random::get<s32>(std::numeric_limits<s32>::min(), std::numeric_limits<s32>::max()); s32 seed = Random::get<s32>(std::numeric_limits<s32>::min(), std::numeric_limits<s32>::max());
if (!m_seedInput.string().empty()) { if (!m_seedInput.string().empty()) {
try { try {

View File

@ -36,7 +36,7 @@
namespace fs = ghc::filesystem; namespace fs = ghc::filesystem;
WorldDeletionState::WorldDeletionState(const std::string &worldName, TitleScreenState *titleScreen) : InterfaceState(titleScreen) { 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)); m_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 176));

View File

@ -36,14 +36,14 @@ WorldSavingState::WorldSavingState(Client &client, bool closeClient, gk::Applica
{ {
m_closeClient = closeClient; 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_filter.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192));
m_text.setString("Saving world..."); m_text.setString("Saving world...");
m_text.setColor(gk::Color::White); m_text.setColor(gk::Color::White);
m_text.updateVertexBuffer(); 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_client.setCommandCallback(Network::Command::ServerClosed, [&](sf::Packet &) {
m_isWorldSaved = true; m_isWorldSaved = true;

View File

@ -40,7 +40,7 @@ namespace fs = ghc::filesystem;
WorldSelectionState::WorldSelectionState(TitleScreenState *titleScreen) WorldSelectionState::WorldSelectionState(TitleScreenState *titleScreen)
: InterfaceState(titleScreen), m_titleScreen(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_filter1.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 192));
m_filter2.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 120)); m_filter2.setFillColor(gk::Color::fromRGBA32(0, 0, 0, 120));

View File

@ -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) : Chunk(x, y, z, (World &)world), m_world(world), m_dimension(dimension)
{ {
// Setup VBO attributes // Setup VBO attributes
m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d))); m_vbo.layout().addAttribute(0, "coord3d", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d)));
m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord))); m_vbo.layout().addAttribute(1, "texCoord", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord)));
m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color))); m_vbo.layout().addAttribute(2, "color", 4, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color)));
m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal))); m_vbo.layout().addAttribute(3, "normal", 3, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal)));
m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue))); m_vbo.layout().addAttribute(4, "lightValue", 2, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue)));
m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion))); m_vbo.layout().addAttribute(5, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, (GLsizei)sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion)));
// Prepare VAO // Prepare VAO
gk::VertexArray::bind(&m_vao); gk::VertexArray::bind(&m_vao);

View File

@ -64,7 +64,7 @@ class ClientChunk : public Chunk {
const gk::VertexBuffer &getVertexBuffer() { return m_vbo; } const gk::VertexBuffer &getVertexBuffer() { return m_vbo; }
const gk::VertexArray &getVertexArray() { return m_vao; } 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]; } std::size_t getVerticesCount(u8 layer) const { return m_verticesCount[layer]; }
void setVerticesCount(u8 layer, std::size_t count) { m_verticesCount[layer] = count; } void setVerticesCount(u8 layer, std::size_t count) { m_verticesCount[layer] = count; }

View File

@ -138,7 +138,7 @@ void ClientPlayer::updatePosition(const ClientWorld &world) {
} }
// Block player until the chunk loads, unless "no clip" mode is enabled // Block player until the chunk loads, unless "no clip" mode is enabled
else if (!Config::isNoClipEnabled) { else if (!Config::isNoClipEnabled) {
m_velocity = gk::Vector3f::Zero; m_velocity.reset(0, 0, 0);
} }
if (!Config::isNoClipEnabled) 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) { 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) { if (!m_isMoving) {
m_movementStartTime = gk::GameClock::getInstance().getTicks(); m_movementStartTime = gk::GameClock::getInstance().getTicks();
m_isMoving = true; m_isMoving = true;

View File

@ -78,7 +78,7 @@ class ClientPlayer : public Player {
gk::Vector3f m_cameraLocalPos; gk::Vector3f m_cameraLocalPos;
gk::Vector3f m_velocity = gk::Vector3f::Zero; gk::Vector3f m_velocity{0, 0, 0};
// For view bobbing only // For view bobbing only
bool m_isMoving = false; bool m_isMoving = false;

View File

@ -62,8 +62,8 @@ void ClientWorld::update(bool allowWorldReload) {
ClientChunk::chunkUpdateTime = time; ClientChunk::chunkUpdateTime = time;
} }
if (time > ClientChunk::chunkDrawTime) { if (time > ClientChunk::chunkDrawTime) {
ClientChunk::chunksRenderedPerFrame = ClientChunk::chunkDrawCounter / std::max(1ul, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame); ClientChunk::chunksRenderedPerFrame = ClientChunk::chunkDrawCounter / std::max<u64>(1, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame);
ClientChunk::chunkDrawCallPerFrame = ClientChunk::chunkDrawCallCounter / std::max(1ul, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame); ClientChunk::chunkDrawCallPerFrame = ClientChunk::chunkDrawCallCounter / std::max<u64>(1, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame);
ClientChunk::chunkDrawCounter = 0; ClientChunk::chunkDrawCounter = 0;
ClientChunk::chunkDrawCallCounter = 0; ClientChunk::chunkDrawCallCounter = 0;
ClientChunk::chunkDrawTime = time; ClientChunk::chunkDrawTime = time;

View File

@ -29,7 +29,7 @@
#include <gk/core/IntTypes.hpp> #include <gk/core/IntTypes.hpp>
class ChunkMeshBuildingJob; struct ChunkMeshBuildingJob;
class BlockState; class BlockState;
class XShapeMesher { class XShapeMesher {

View File

@ -34,7 +34,7 @@
Registry *Registry::s_instance = nullptr; Registry *Registry::s_instance = nullptr;
Sky &Registry::registerSky(const std::string &stringID) { 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_skiesID.emplace(stringID, id);
m_skies.emplace_back(id, stringID); m_skies.emplace_back(id, stringID);
return m_skies.back(); return m_skies.back();
@ -44,14 +44,14 @@ Sky &Registry::registerSerializedSky(sf::Packet &packet) {
m_skies.emplace_back(); m_skies.emplace_back();
m_skies.back().deserialize(packet); 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); m_skiesID.emplace(m_skies.back().stringID(), id);
return m_skies.back(); return m_skies.back();
} }
Tree &Registry::registerTree(const std::string &stringID) { 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_treesID.emplace(stringID, id);
m_trees.emplace_back(id, stringID); m_trees.emplace_back(id, stringID);
return m_trees.back(); return m_trees.back();
@ -61,14 +61,14 @@ Tree &Registry::registerSerializedTree(sf::Packet &packet) {
m_trees.emplace_back(); m_trees.emplace_back();
m_trees.back().deserialize(packet); 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); m_treesID.emplace(m_trees.back().stringID(), id);
return m_trees.back(); return m_trees.back();
} }
Biome &Registry::registerBiome(const std::string &stringID, const std::string &label) { 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_biomesID.emplace(stringID, id);
m_biomes.emplace_back(id, stringID, label); m_biomes.emplace_back(id, stringID, label);
return m_biomes.back(); return m_biomes.back();
@ -78,14 +78,14 @@ Biome &Registry::registerSerializedBiome(sf::Packet &packet) {
m_biomes.emplace_back(); m_biomes.emplace_back();
m_biomes.back().deserialize(packet); 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); m_biomesID.emplace(m_biomes.back().stringID(), id);
return m_biomes.back(); return m_biomes.back();
} }
Dimension &Registry::registerDimension(const std::string &stringID, const std::string &label) { 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_dimensionsID.emplace(stringID, id);
m_dimensions.emplace_back(id, stringID, label); m_dimensions.emplace_back(id, stringID, label);
return m_dimensions.back(); return m_dimensions.back();
@ -95,14 +95,14 @@ Dimension &Registry::registerSerializedDimension(sf::Packet &packet) {
m_dimensions.emplace_back(); m_dimensions.emplace_back();
m_dimensions.back().deserialize(packet); 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); m_dimensionsID.emplace(m_dimensions.back().stringID(), id);
return m_dimensions.back(); return m_dimensions.back();
} }
Key &Registry::registerKey(const std::string &stringID, const std::string &label) { 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_keysID.emplace(stringID, id);
m_keys.emplace_back(id, stringID, label); m_keys.emplace_back(id, stringID, label);
return m_keys.back(); return m_keys.back();
@ -112,7 +112,7 @@ Key &Registry::registerSerializedKey(sf::Packet &packet) {
m_keys.emplace_back(); m_keys.emplace_back();
m_keys.back().deserialize(packet); 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); m_keysID.emplace(m_biomes.back().stringID(), id);
return m_keys.back(); return m_keys.back();

View File

@ -48,7 +48,7 @@ class Registry : public gk::ISerializable {
public: public:
template<typename T> template<typename T>
auto registerBlock(const std::string &stringID) -> typename std::enable_if<std::is_base_of<Block, T>::value, T&>::type { auto registerBlock(const std::string &stringID) -> typename std::enable_if<std::is_base_of<Block, T>::value, T&>::type {
size_t id = m_blocks.size(); u16 id = (u16)m_blocks.size();
m_blocksID.emplace(stringID, id); m_blocksID.emplace(stringID, id);
m_blocks.emplace_back(std::make_unique<T>(id, stringID)); m_blocks.emplace_back(std::make_unique<T>(id, stringID));
return *static_cast<T*>(m_blocks.back().get()); return *static_cast<T*>(m_blocks.back().get());
@ -59,7 +59,7 @@ class Registry : public gk::ISerializable {
m_blocks.emplace_back(std::make_unique<T>()); m_blocks.emplace_back(std::make_unique<T>());
m_blocks.back()->deserialize(packet); 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); m_blocksID.emplace(m_blocks.back()->stringID(), id);
return *static_cast<T*>(m_blocks.back().get()); return *static_cast<T*>(m_blocks.back().get());
@ -67,7 +67,7 @@ class Registry : public gk::ISerializable {
template<typename T> template<typename T>
auto registerItem(const TilesDef &tiles, const std::string &stringID, const std::string &label) -> typename std::enable_if<std::is_base_of<Item, T>::value, T&>::type { auto registerItem(const TilesDef &tiles, const std::string &stringID, const std::string &label) -> typename std::enable_if<std::is_base_of<Item, T>::value, T&>::type {
size_t id = m_items.size(); u16 id = (u16)m_items.size();
m_itemsID.emplace(stringID, id); m_itemsID.emplace(stringID, id);
m_items.emplace_back(std::make_unique<T>(id, tiles, stringID, label)); m_items.emplace_back(std::make_unique<T>(id, tiles, stringID, label));
return *static_cast<T*>(m_items.back().get()); return *static_cast<T*>(m_items.back().get());
@ -78,7 +78,7 @@ class Registry : public gk::ISerializable {
m_items.emplace_back(std::make_unique<T>()); m_items.emplace_back(std::make_unique<T>());
m_items.back()->deserialize(packet); 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); m_itemsID.emplace(m_items.back()->stringID(), id);
return *static_cast<T*>(m_items.back().get()); return *static_cast<T*>(m_items.back().get());

View File

@ -43,7 +43,7 @@ const void* CompressedPacket::onSend(std::size_t& size) {
const Bytef* srcData = static_cast<const Bytef*>(getData()); const Bytef* srcData = static_cast<const Bytef*>(getData());
// Get the size of the packet to send // Get the size of the packet to send
uLong srcSize = getDataSize(); uLong srcSize = (uLong)getDataSize();
// Compute the size of the compressed data // Compute the size of the compressed data
uLong dstSize = compressBound(srcSize); uLong dstSize = compressBound(srcSize);
@ -86,7 +86,7 @@ void CompressedPacket::onReceive(const void* data, std::size_t size) {
uLong dstSize = uncompressedSize; uLong dstSize = uncompressedSize;
// Uncompress the data (remove the first two bytes) // 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) if (result != Z_OK)
gkError() << "Failed to uncompress packet"; gkError() << "Failed to uncompress packet";

View File

@ -67,9 +67,9 @@ void Block::deserialize(sf::Packet &packet) {
BlockState &Block::addState() { BlockState &Block::addState() {
if (!m_states.empty()) 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 else
m_states.emplace_back(m_states.size(), this, nullptr); m_states.emplace_back((u16)m_states.size(), this, nullptr);
return m_states.back(); return m_states.back();
} }

View File

@ -27,7 +27,7 @@
#include "ServerInfo.hpp" #include "ServerInfo.hpp"
ClientInfo &ServerInfo::addClient(const std::shared_ptr<sf::TcpSocket> &socket) { ClientInfo &ServerInfo::addClient(const std::shared_ptr<sf::TcpSocket> &socket) {
m_clients.emplace_back(m_clients.size() + 1, socket); m_clients.emplace_back(u16(m_clients.size() + 1), socket);
return m_clients.back(); return m_clients.back();
} }

View File

@ -37,7 +37,7 @@
#include "World.hpp" #include "World.hpp"
ServerChunk::ServerChunk(s32 x, s32 y, s32 z, ServerWorld &world) : Chunk(x, y, z, world), m_world(world) { 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() { void ServerChunk::update() {