diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-01-03 17:47:11 +0100 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-01-13 03:39:33 +0100 |
commit | bdc3f4a198c3f047389b159e67f7e6131e053ea6 (patch) | |
tree | c0f473147116e4ba0fed8cfb5f9780982b5a3c8c /src | |
parent | Fixed CMake error (diff) | |
download | AltCraft-bdc3f4a198c3f047389b159e67f7e6131e053ea6.tar AltCraft-bdc3f4a198c3f047389b159e67f7e6131e053ea6.tar.gz AltCraft-bdc3f4a198c3f047389b159e67f7e6131e053ea6.tar.bz2 AltCraft-bdc3f4a198c3f047389b159e67f7e6131e053ea6.tar.lz AltCraft-bdc3f4a198c3f047389b159e67f7e6131e053ea6.tar.xz AltCraft-bdc3f4a198c3f047389b159e67f7e6131e053ea6.tar.zst AltCraft-bdc3f4a198c3f047389b159e67f7e6131e053ea6.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Chat.hpp | 1 | ||||
-rw-r--r-- | src/GameState.hpp | 4 | ||||
-rw-r--r-- | src/GlobalState.cpp | 4 | ||||
-rw-r--r-- | src/Packet.hpp | 8 | ||||
-rw-r--r-- | src/Render.cpp | 2 | ||||
-rw-r--r-- | src/RendererWorld.hpp | 1 | ||||
-rw-r--r-- | src/Section.cpp | 1 | ||||
-rw-r--r-- | src/Stream.cpp | 6 | ||||
-rw-r--r-- | src/Stream.hpp | 6 | ||||
-rw-r--r-- | src/Vector.hpp | 12 | ||||
-rw-r--r-- | src/Window.cpp | 2 | ||||
-rw-r--r-- | src/Window.hpp | 4 | ||||
-rw-r--r-- | src/World.hpp | 1 |
13 files changed, 34 insertions, 18 deletions
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 <vector> +#include <string> 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> SlotData; + std::vector<SlotDataType> 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 <mutex> #include <queue> #include <memory> +#include <thread> #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 <bitset> +#include <cstring> 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<unsigned char> StreamInput::ReadEntityMetadata() { return std::vector<unsigned char>(); } -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<unsigned char> &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<unsigned char> ReadEntityMetadata(); - SlotData ReadSlot(); + SlotDataType ReadSlot(); std::vector<unsigned char> 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<unsigned char> &value); - void WriteSlot(const SlotData &value); + void WriteSlot(const SlotDataType &value); void WriteNbtTag(const std::vector<unsigned char> &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<SlotData> slots; + std::vector<SlotDataType> 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 <queue> #include <memory> #include <vector> +#include <list> #include <easylogging++.h> |