From bdc3f4a198c3f047389b159e67f7e6131e053ea6 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Wed, 3 Jan 2018 21:47:11 +0500 Subject: Fixed compilation errors --- CMakeLists.txt | 2 +- src/Chat.hpp | 1 + src/GameState.hpp | 4 ++-- src/GlobalState.cpp | 4 ++++ src/Packet.hpp | 8 ++++---- src/Render.cpp | 2 +- src/RendererWorld.hpp | 1 + src/Section.cpp | 1 + src/Stream.cpp | 6 +++--- src/Stream.hpp | 6 +++--- src/Vector.hpp | 12 ++++++++++-- src/Window.cpp | 2 +- src/Window.hpp | 4 ++-- src/World.hpp | 1 + 14 files changed, 35 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95ebca0..1e8e8c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ add_definitions(${LOGGER_DEFINITIONS}) #Set compiler's flags and setup platfrom-dependent libraries if (CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Wno-error=unused-parameter") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") diff --git a/src/Chat.hpp b/src/Chat.hpp index 4d147be..9ab5691 100644 --- a/src/Chat.hpp +++ b/src/Chat.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include struct TextModifier { size_t offset; diff --git a/src/GameState.hpp b/src/GameState.hpp index bee89bf..4894628 100644 --- a/src/GameState.hpp +++ b/src/GameState.hpp @@ -42,8 +42,8 @@ public: int g_PlayerEid = 0; int g_Gamemode = 0; int g_Dimension = 0; - byte g_Difficulty = 0; - byte g_MaxPlayers = 0; + unsigned char g_Difficulty = 0; + unsigned char g_MaxPlayers = 0; std::string g_LevelType = ""; bool g_ReducedDebugInfo = false; Vector g_SpawnPosition; diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp index c7a36ad..297d5e8 100644 --- a/src/GlobalState.cpp +++ b/src/GlobalState.cpp @@ -114,6 +114,8 @@ void PhysExec() { case SDL_SCANCODE_SPACE: isMoving[GameState::JUMP] = true; break; + default: + break; } }); @@ -136,6 +138,8 @@ void PhysExec() { case SDL_SCANCODE_SPACE: isMoving[GameState::JUMP] = false; break; + default: + break; } }); diff --git a/src/Packet.hpp b/src/Packet.hpp index f31fa59..4457893 100644 --- a/src/Packet.hpp +++ b/src/Packet.hpp @@ -896,7 +896,7 @@ struct PacketWindowItems : Packet { } unsigned char WindowId; - std::vector SlotData; + std::vector SlotData; }; struct PacketWindowProperty : Packet { @@ -936,7 +936,7 @@ struct PacketSetSlot : Packet { signed char WindowId; short Slot; - SlotData SlotData; + SlotDataType SlotData; }; struct PacketConfirmTransactionCB : Packet { @@ -1004,9 +1004,9 @@ struct PacketClickWindow : Packet { signed char Button; short ActionNumber; int Mode; - SlotData ClickedItem; + SlotDataType ClickedItem; - PacketClickWindow(unsigned char windowId, short slot, signed char button, short actionNumber, int mode, SlotData ClickedItem) : WindowId(windowId), Slot(slot), + PacketClickWindow(unsigned char windowId, short slot, signed char button, short actionNumber, int mode, SlotDataType ClickedItem) : WindowId(windowId), Slot(slot), Button(button), ActionNumber(actionNumber), Mode(mode), ClickedItem(ClickedItem) {}; }; diff --git a/src/Render.cpp b/src/Render.cpp index 1e7f45c..a5f1e8b 100644 --- a/src/Render.cpp +++ b/src/Render.cpp @@ -389,7 +389,7 @@ void Render::RenderGui() { break; } case State::Inventory: { - auto renderSlot = [](const SlotData &slot, int i) -> bool { + auto renderSlot = [](const SlotDataType &slot, int i) -> bool { return ImGui::Button(((slot.BlockId == -1 ? " ##" : AssetManager::Instance().GetAssetNameByBlockId(BlockId{ (unsigned short)slot.BlockId,0 }) + " x" + std::to_string(slot.ItemCount) + "##") + std::to_string(i)).c_str()); diff --git a/src/RendererWorld.hpp b/src/RendererWorld.hpp index a961a84..b9d1113 100644 --- a/src/RendererWorld.hpp +++ b/src/RendererWorld.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "RendererSection.hpp" #include "RendererEntity.hpp" diff --git a/src/Section.cpp b/src/Section.cpp index c105b06..1083538 100644 --- a/src/Section.cpp +++ b/src/Section.cpp @@ -1,6 +1,7 @@ #include "Section.hpp" #include +#include void Section::CalculateHash() const { size_t offset = 0; diff --git a/src/Stream.cpp b/src/Stream.cpp index 8f5d519..a7884d6 100644 --- a/src/Stream.cpp +++ b/src/Stream.cpp @@ -128,8 +128,8 @@ std::vector StreamInput::ReadEntityMetadata() { return std::vector(); } -SlotData StreamInput::ReadSlot() { - SlotData slot; +SlotDataType StreamInput::ReadSlot() { + SlotDataType slot; slot.BlockId = ReadShort(); if (slot.BlockId == -1) @@ -275,7 +275,7 @@ void StreamOutput::WriteEntityMetadata(const std::vector &value) LOG(FATAL) << "Used unimplemented WriteEntityMetadata: " << value.size(); } -void StreamOutput::WriteSlot(const SlotData &value) { +void StreamOutput::WriteSlot(const SlotDataType &value) { WriteShort(value.BlockId); if (value.BlockId == -1) return; diff --git a/src/Stream.hpp b/src/Stream.hpp index b733d3b..8269300 100644 --- a/src/Stream.hpp +++ b/src/Stream.hpp @@ -8,7 +8,7 @@ class Socket; -struct SlotData { +struct SlotDataType { short BlockId = -1; signed char ItemCount = 1; short ItemDamage = 0; @@ -38,7 +38,7 @@ public: int ReadVarInt(); long long ReadVarLong(); std::vector ReadEntityMetadata(); - SlotData ReadSlot(); + SlotDataType ReadSlot(); std::vector ReadNbtTag(); Vector ReadPosition(); unsigned char ReadAngle(); @@ -64,7 +64,7 @@ public: void WriteVarInt(int value); void WriteVarLong(long long value); void WriteEntityMetadata(const std::vector &value); - void WriteSlot(const SlotData &value); + void WriteSlot(const SlotDataType &value); void WriteNbtTag(const std::vector &value); void WritePosition(const Vector &value); void WriteAngle(unsigned char value); diff --git a/src/Vector.hpp b/src/Vector.hpp index 0046b4a..5795db2 100644 --- a/src/Vector.hpp +++ b/src/Vector.hpp @@ -93,9 +93,17 @@ struct Vector3 { } bool operator<(const Vector3 &rhs) const { - return std::tie(x, y, z) < std::tie(rhs.x, rhs.y, rhs.z); + if (x < rhs.x) + return true; + if (rhs.x < x) + return false; + if (y < rhs.y) + return true; + if (rhs.y < y) + return false; + return z < rhs.z; } - + friend std::ostream &operator<<(std::ostream &os, const Vector3 &vector3) { os << vector3.x << ", " << vector3.y << ", " << vector3.z; diff --git a/src/Window.cpp b/src/Window.cpp index f3ad6d5..37d9c74 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -7,7 +7,7 @@ void Window::MakeClick(short ClickedSlot, bool Lmb, bool dropMode) { std::swap(slots[ClickedSlot], handSlot); transactions.push_back(std::make_pair(actions, std::make_pair(ClickedSlot, -1))); } else { - PacketClickWindow packet(WindowId, ClickedSlot, Lmb ? 0 : 1, actions++, 0, SlotData()); + PacketClickWindow packet(WindowId, ClickedSlot, Lmb ? 0 : 1, actions++, 0, SlotDataType()); this->pendingTransactions.push(packet); transactions.push_back(std::make_pair(actions, std::make_pair(ClickedSlot, -1))); } diff --git a/src/Window.hpp b/src/Window.hpp index 94fdca3..15af487 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -8,9 +8,9 @@ struct Window { unsigned char WindowId = 0; std::string type; - SlotData handSlot; + SlotDataType handSlot; const short HandSlotId = -1; - std::vector slots; + std::vector slots; short actions = 1; diff --git a/src/World.hpp b/src/World.hpp index c245947..6d10491 100644 --- a/src/World.hpp +++ b/src/World.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include -- cgit v1.2.3