diff options
author | chai <chaifix@163.com> | 2021-12-13 15:00:32 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-12-13 15:00:32 +0800 |
commit | a5dd54fbf8b6768423c48786b6a2afaf9a8ece0e (patch) | |
tree | f85c85c991c36d105f6bcba7fd628dc9749e1462 | |
parent | bca78a2319400ef7e11a35f682fe45ac3fce0fbd (diff) |
*misc
30 files changed, 776 insertions, 2 deletions
diff --git a/Client/Project/VisualStudio/Ragdolls/Ragdolls/Ragdolls.vcxproj b/Client/Project/VisualStudio/Ragdolls/Ragdolls/Ragdolls.vcxproj index 27506d4..d3a9c40 100644 --- a/Client/Project/VisualStudio/Ragdolls/Ragdolls/Ragdolls.vcxproj +++ b/Client/Project/VisualStudio/Ragdolls/Ragdolls/Ragdolls.vcxproj @@ -81,7 +81,7 @@ <Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
- <AdditionalIncludeDirectories>$(SolutionDir)..\..\..\ThirdParty;$(SolutionDir)..\..\..\ThirdParty\imgui;$(SolutionDir)..\..\..\ThirdParty\SDL2\include;$(SolutionDir)..\..\..\ThirdParty\freetype\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\..\ThirdParty;$(SolutionDir)..\..\..\ThirdParty\imgui;$(SolutionDir)..\..\..\ThirdParty\SDL2\include;$(SolutionDir)..\..\..\ThirdParty\freetype\include;$(SolutionDir)..\..\..\Source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>RAGDOLL_WIN;_CRT_SECURE_NO_WARNINGS;RAGDOLL_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
@@ -122,7 +122,7 @@ <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
- <AdditionalIncludeDirectories>$(SolutionDir)..\..\..\ThirdParty;$(SolutionDir)..\..\..\ThirdParty\imgui;$(SolutionDir)..\..\..\ThirdParty\SDL2\include;$(SolutionDir)..\..\..\ThirdParty\freetype\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\..\ThirdParty;$(SolutionDir)..\..\..\ThirdParty\imgui;$(SolutionDir)..\..\..\ThirdParty\SDL2\include;$(SolutionDir)..\..\..\ThirdParty\freetype\include;$(SolutionDir)..\..\..\Source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>RAGDOLL_WIN;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
@@ -136,6 +136,7 @@ <ItemGroup>
<ClCompile Include="..\..\..\..\Source\Common\DataBuffer.cpp" />
<ClCompile Include="..\..\..\..\Source\Debug\Log.cpp" />
+ <ClCompile Include="..\..\..\..\Source\Filesystem\Filesystem.cpp" />
<ClCompile Include="..\..\..\..\Source\Graphics\Color.cpp" />
<ClCompile Include="..\..\..\..\Source\Graphics\CustomVertexLayout.cpp" />
<ClCompile Include="..\..\..\..\Source\Graphics\DefaultVertexLayout.cpp" />
@@ -165,22 +166,29 @@ <ClCompile Include="..\..\..\..\Source\GUI\UISquare.cpp" />
<ClCompile Include="..\..\..\..\Source\GUI\UITextMesh.cpp" />
<ClCompile Include="..\..\..\..\Source\GUI\utf8.cpp" />
+ <ClCompile Include="..\..\..\..\Source\Local\LocalPlayer.cpp" />
<ClCompile Include="..\..\..\..\Source\Math\Functions.cpp" />
<ClCompile Include="..\..\..\..\Source\Network\Address.cpp" />
<ClCompile Include="..\..\..\..\Source\Network\Connection.cpp" />
+ <ClCompile Include="..\..\..\..\Source\Network\http.cpp" />
<ClCompile Include="..\..\..\..\Source\Network\NetPacket.cpp" />
<ClCompile Include="..\..\..\..\Source\Network\Socket.cpp" />
<ClCompile Include="..\..\..\..\Source\Persistent\Database.cpp" />
<ClCompile Include="..\..\..\..\Source\Persistent\DatabaseFile.cpp" />
<ClCompile Include="..\..\..\..\Source\Persistent\DatabaseRedis.cpp" />
<ClCompile Include="..\..\..\..\Source\Persistent\DatabaseSqlite.cpp" />
+ <ClCompile Include="..\..\..\..\Source\Physics\raycast.cpp" />
<ClCompile Include="..\..\..\..\Source\RagdollMain.cpp" />
+ <ClCompile Include="..\..\..\..\Source\Remote\RemotePlayer.cpp" />
+ <ClCompile Include="..\..\..\..\Source\Serialization\serialization.cpp" />
+ <ClCompile Include="..\..\..\..\Source\Threading\Event.cpp" />
<ClCompile Include="..\..\..\..\Source\Threading\Job.cpp" />
<ClCompile Include="..\..\..\..\Source\Threading\JobSystem.cpp" />
<ClCompile Include="..\..\..\..\Source\Threading\Mutex.cpp" />
<ClCompile Include="..\..\..\..\Source\Threading\Semaphore.cpp" />
<ClCompile Include="..\..\..\..\Source\Threading\Thread.cpp" />
<ClCompile Include="..\..\..\..\Source\Threading\WorkThread.cpp" />
+ <ClCompile Include="..\..\..\..\Source\Utilities\base64.cpp" />
<ClCompile Include="..\..\..\..\Source\Utilities\sha1.cpp" />
<ClCompile Include="..\..\..\..\Source\Utilities\sha256.c" />
<ClCompile Include="..\..\..\..\ThirdParty\glad\glad.c" />
@@ -195,6 +203,7 @@ <ItemGroup>
<ClInclude Include="..\..\..\..\Source\Common\DataBuffer.h" />
<ClInclude Include="..\..\..\..\Source\Debug\Log.h" />
+ <ClInclude Include="..\..\..\..\Source\Filesystem\Filesystem.h" />
<ClInclude Include="..\..\..\..\Source\Graphics\Color.h" />
<ClInclude Include="..\..\..\..\Source\Graphics\CustomVertexLayout.h" />
<ClInclude Include="..\..\..\..\Source\Graphics\DefaultVertexLayout.h" />
@@ -228,6 +237,7 @@ <ClInclude Include="..\..\..\..\Source\GUI\UISquare.h" />
<ClInclude Include="..\..\..\..\Source\GUI\UITextMesh.h" />
<ClInclude Include="..\..\..\..\Source\GUI\utf8.h" />
+ <ClInclude Include="..\..\..\..\Source\Local\LocalPlayer.h" />
<ClInclude Include="..\..\..\..\Source\Math\Functions.h" />
<ClInclude Include="..\..\..\..\Source\Math\Math.h" />
<ClInclude Include="..\..\..\..\Source\Math\Matrix22.h" />
@@ -238,12 +248,17 @@ <ClInclude Include="..\..\..\..\Source\Math\Vector4.hpp" />
<ClInclude Include="..\..\..\..\Source\Network\Address.h" />
<ClInclude Include="..\..\..\..\Source\Network\Connection.h" />
+ <ClInclude Include="..\..\..\..\Source\Network\http.h" />
<ClInclude Include="..\..\..\..\Source\Network\NetPacket.h" />
<ClInclude Include="..\..\..\..\Source\Network\Socket.h" />
<ClInclude Include="..\..\..\..\Source\Persistent\Database.h" />
<ClInclude Include="..\..\..\..\Source\Persistent\DatabaseFile.h" />
<ClInclude Include="..\..\..\..\Source\Persistent\DatabaseRedis.h" />
<ClInclude Include="..\..\..\..\Source\Persistent\DatabaseSqlite.h" />
+ <ClInclude Include="..\..\..\..\Source\Physics\raycast.h" />
+ <ClInclude Include="..\..\..\..\Source\Remote\RemotePlayer.h" />
+ <ClInclude Include="..\..\..\..\Source\Serialization\serialization.h" />
+ <ClInclude Include="..\..\..\..\Source\Threading\Event.h" />
<ClInclude Include="..\..\..\..\Source\Threading\Job.h" />
<ClInclude Include="..\..\..\..\Source\Threading\JobSystem.h" />
<ClInclude Include="..\..\..\..\Source\Threading\Mutex.h" />
@@ -251,6 +266,7 @@ <ClInclude Include="..\..\..\..\Source\Threading\Thread.h" />
<ClInclude Include="..\..\..\..\Source\Utilities\Assert.h" />
<ClInclude Include="..\..\..\..\Source\Utilities\AutoInvoke.h" />
+ <ClInclude Include="..\..\..\..\Source\Utilities\base64.h" />
<ClInclude Include="..\..\..\..\Source\Utilities\Exception.h" />
<ClInclude Include="..\..\..\..\Source\Utilities\md32_common.h" />
<ClInclude Include="..\..\..\..\Source\Utilities\sha1.h" />
diff --git a/Client/Project/VisualStudio/Ragdolls/Ragdolls/Ragdolls.vcxproj.filters b/Client/Project/VisualStudio/Ragdolls/Ragdolls/Ragdolls.vcxproj.filters index 63eb02b..6e0768e 100644 --- a/Client/Project/VisualStudio/Ragdolls/Ragdolls/Ragdolls.vcxproj.filters +++ b/Client/Project/VisualStudio/Ragdolls/Ragdolls/Ragdolls.vcxproj.filters @@ -43,6 +43,27 @@ <Filter Include="Persistent">
<UniqueIdentifier>{c6dc4916-d04c-45ae-9cd9-868a55f979d3}</UniqueIdentifier>
</Filter>
+ <Filter Include="Filesystem">
+ <UniqueIdentifier>{993ff0e4-3779-4143-8987-8051dcd6dbed}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Profiling">
+ <UniqueIdentifier>{a816541a-4fc2-4d86-968f-44a498544d43}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Physics">
+ <UniqueIdentifier>{983e3658-5991-4175-98be-ef907edc5199}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Remote">
+ <UniqueIdentifier>{3410850d-bd0b-4b53-92fd-bdf3da189756}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Serialization">
+ <UniqueIdentifier>{1fef6e26-4cb1-424d-933c-a343d3a4e691}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Scripting">
+ <UniqueIdentifier>{ce78bf9b-da4d-4dd9-ae65-cdc8d48f975d}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Local">
+ <UniqueIdentifier>{d614da35-9a6a-4edb-9c2f-55517c089a2b}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\ThirdParty\glad\glad.c">
@@ -214,6 +235,30 @@ <ClCompile Include="..\..\..\..\Source\Utilities\sha256.c">
<Filter>Utilities</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Source\Filesystem\Filesystem.cpp">
+ <Filter>Filesystem</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Source\Network\http.cpp">
+ <Filter>Network</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Source\Physics\raycast.cpp">
+ <Filter>Physics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Source\Remote\RemotePlayer.cpp">
+ <Filter>Remote</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Source\Serialization\serialization.cpp">
+ <Filter>Serialization</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Source\Threading\Event.cpp">
+ <Filter>Threading</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Source\Utilities\base64.cpp">
+ <Filter>Utilities</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Source\Local\LocalPlayer.cpp">
+ <Filter>Local</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\ThirdParty\glad\glad.h">
@@ -447,5 +492,29 @@ <ClInclude Include="..\..\..\..\Source\Utilities\md32_common.h">
<Filter>Utilities</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\Source\Filesystem\Filesystem.h">
+ <Filter>Filesystem</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Source\Network\http.h">
+ <Filter>Network</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Source\Physics\raycast.h">
+ <Filter>Physics</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Source\Remote\RemotePlayer.h">
+ <Filter>Remote</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Source\Serialization\serialization.h">
+ <Filter>Serialization</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Source\Threading\Event.h">
+ <Filter>Threading</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Source\Utilities\base64.h">
+ <Filter>Utilities</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Source\Local\LocalPlayer.h">
+ <Filter>Local</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file diff --git a/Client/Source/Filesystem/Filesystem.cpp b/Client/Source/Filesystem/Filesystem.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Filesystem/Filesystem.cpp diff --git a/Client/Source/Filesystem/Filesystem.h b/Client/Source/Filesystem/Filesystem.h new file mode 100644 index 0000000..5919022 --- /dev/null +++ b/Client/Source/Filesystem/Filesystem.h @@ -0,0 +1,4 @@ +#pragma once
+
+
+
diff --git a/Client/Source/Local/LocalPlayer.cpp b/Client/Source/Local/LocalPlayer.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Local/LocalPlayer.cpp diff --git a/Client/Source/Local/LocalPlayer.h b/Client/Source/Local/LocalPlayer.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Local/LocalPlayer.h diff --git a/Client/Source/Network/Socket.h b/Client/Source/Network/Socket.h index e69de29..3749a34 100644 --- a/Client/Source/Network/Socket.h +++ b/Client/Source/Network/Socket.h @@ -0,0 +1,2 @@ +
+// UDP socket
\ No newline at end of file diff --git a/Client/Source/Network/http.cpp b/Client/Source/Network/http.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Network/http.cpp diff --git a/Client/Source/Network/http.h b/Client/Source/Network/http.h new file mode 100644 index 0000000..50e9667 --- /dev/null +++ b/Client/Source/Network/http.h @@ -0,0 +1 @@ +#pragma once
diff --git a/Client/Source/Physics/raycast.cpp b/Client/Source/Physics/raycast.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Physics/raycast.cpp diff --git a/Client/Source/Physics/raycast.h b/Client/Source/Physics/raycast.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Physics/raycast.h diff --git a/Client/Source/Remote/RemotePlayer.cpp b/Client/Source/Remote/RemotePlayer.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Remote/RemotePlayer.cpp diff --git a/Client/Source/Remote/RemotePlayer.h b/Client/Source/Remote/RemotePlayer.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Remote/RemotePlayer.h diff --git a/Client/Source/Serialization/serialization.cpp b/Client/Source/Serialization/serialization.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Serialization/serialization.cpp diff --git a/Client/Source/Serialization/serialization.h b/Client/Source/Serialization/serialization.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Serialization/serialization.h diff --git a/Client/Source/Threading/Event.cpp b/Client/Source/Threading/Event.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Threading/Event.cpp diff --git a/Client/Source/Threading/Event.h b/Client/Source/Threading/Event.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Client/Source/Threading/Event.h diff --git a/Client/Source/Utilities/Optional.h b/Client/Source/Utilities/Optional.h new file mode 100644 index 0000000..eda7fff --- /dev/null +++ b/Client/Source/Utilities/Optional.h @@ -0,0 +1,105 @@ +/* +Minetest +Copyright (C) 2021 rubenwardy + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#pragma once + +#include <utility> +#include "debug.h" + +struct nullopt_t +{ +}; +constexpr nullopt_t nullopt{}; + +/** + * An implementation of optional for C++11, which aims to be + * compatible with a subset of std::optional features. + * + * Unfortunately, Minetest doesn't use C++17 yet. + * + * @tparam T The type to be stored + */ +template <typename T> +class Optional +{ + bool m_has_value = false; + T m_value; + +public: + Optional() noexcept {} + Optional(nullopt_t) noexcept {} + + Optional(const T &value) noexcept : m_has_value(true), m_value(value) {} + Optional(T &&value) noexcept : m_has_value(true), m_value(std::move(value)) {} + + Optional(const Optional<T> &other) noexcept : + m_has_value(other.m_has_value), m_value(other.m_value) + {} + Optional(Optional<T> &&other) noexcept : + m_has_value(other.m_has_value), m_value(std::move(other.m_value)) + { + other.m_has_value = false; + } + + Optional<T> &operator=(nullopt_t) noexcept { m_has_value = false; return *this; } + + Optional<T> &operator=(const Optional<T> &other) noexcept + { + if (&other == this) + return *this; + m_has_value = other.m_has_value; + m_value = other.m_value; + return *this; + } + + Optional<T> &operator=(Optional<T> &&other) noexcept + { + if (&other == this) + return *this; + m_has_value = other.m_has_value; + m_value = std::move(other.m_value); + other.m_has_value = false; + return *this; + } + + T &value() + { + FATAL_ERROR_IF(!m_has_value, "optional doesn't have value"); + return m_value; + } + + const T &value() const + { + FATAL_ERROR_IF(!m_has_value, "optional doesn't have value"); + return m_value; + } + + const T &value_or(const T &def) const { return m_has_value ? m_value : def; } + + // Unchecked access consistent with std::optional + T* operator->() { return &m_value; } + const T* operator->() const { return &m_value; } + + T& operator*() { return m_value; } + const T& operator*() const { return m_value; } + + bool has_value() const noexcept { return m_has_value; } + + explicit operator bool() const { return m_has_value; } +}; diff --git a/Client/Source/Utilities/base64.cpp b/Client/Source/Utilities/base64.cpp new file mode 100644 index 0000000..0c24552 --- /dev/null +++ b/Client/Source/Utilities/base64.cpp @@ -0,0 +1,154 @@ +/* +base64.cpp and base64.h + +Copyright (C) 2004-2008 René Nyffenegger + +This source code is provided 'as-is', without any express or implied +warranty. In no event will the author be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + +3. This notice may not be removed or altered from any source distribution. + +René Nyffenegger rene.nyffenegger@adp-gmbh.ch + +*/ + +#include "base64.h" +#include <iostream> + +static const std::string base64_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +static const std::string base64_chars_padding_1 = "AEIMQUYcgkosw048"; +static const std::string base64_chars_padding_2 = "AQgw"; + +static inline bool is_base64(unsigned char c) +{ + return (c >= '0' && c <= '9') + || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z') + || c == '+' || c == '/'; +} + +bool base64_is_valid(std::string const& s) +{ + size_t i = 0; + for (; i < s.size(); ++i) + if (!is_base64(s[i])) + break; + unsigned char padding = 3 - ((i + 3) % 4); + if ((padding == 1 && base64_chars_padding_1.find(s[i - 1]) == std::string::npos) + || (padding == 2 && base64_chars_padding_2.find(s[i - 1]) == std::string::npos) + || padding == 3) + return false; + int actual_padding = s.size() - i; + // omission of padding characters is allowed + if (actual_padding == 0) + return true; + + // remaining characters (max. 2) may only be padding + for (; i < s.size(); ++i) + if (s[i] != '=') + return false; + // number of padding characters needs to match + return padding == actual_padding; +} + +std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) { + std::string ret; + int i = 0; + int j = 0; + unsigned char char_array_3[3]; + unsigned char char_array_4[4]; + + while (in_len--) { + char_array_3[i++] = *(bytes_to_encode++); + if (i == 3) { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for(i = 0; (i <4) ; i++) + ret += base64_chars[char_array_4[i]]; + i = 0; + } + } + + if (i) + { + for(j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; (j < i + 1); j++) + ret += base64_chars[char_array_4[j]]; + + // Don't pad it with = + /*while((i++ < 3)) + ret += '=';*/ + + } + + return ret; + +} + +std::string base64_decode(std::string const& encoded_string) { + int in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + unsigned char char_array_4[4], char_array_3[3]; + std::string ret; + + while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i ==4) { + for (i = 0; i <4; i++) + char_array_4[i] = base64_chars.find(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret += char_array_3[i]; + i = 0; + } + } + + if (i) { + for (j = i; j <4; j++) + char_array_4[j] = 0; + + for (j = 0; j <4; j++) + char_array_4[j] = base64_chars.find(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; (j < i - 1); j++) ret += char_array_3[j]; + } + + return ret; +} diff --git a/Client/Source/Utilities/base64.h b/Client/Source/Utilities/base64.h new file mode 100644 index 0000000..7f2bf13 --- /dev/null +++ b/Client/Source/Utilities/base64.h @@ -0,0 +1,26 @@ +/* +Minetest +Copyright (C) 2013-2017 celeron55, Perttu Ahola <celeron55@gmail.com> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#pragma once + +#include <string> + +bool base64_is_valid(std::string const& s); +std::string base64_encode(unsigned char const* , unsigned int len); +std::string base64_decode(std::string const& s); diff --git a/Client/Source/Utilities/hex.h b/Client/Source/Utilities/hex.h new file mode 100644 index 0000000..708f330 --- /dev/null +++ b/Client/Source/Utilities/hex.h @@ -0,0 +1,60 @@ +/* +Minetest +Copyright (C) 2013 Jonathan Neuschäfer <j.neuschaefer@gmx.net> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#pragma once + +#include <string> + +static const char hex_chars[] = "0123456789abcdef"; + +static inline std::string hex_encode(const char *data, unsigned int data_size) +{ + std::string ret; + ret.reserve(data_size * 2); + + char buf2[3]; + buf2[2] = '\0'; + + for (unsigned int i = 0; i < data_size; i++) { + unsigned char c = (unsigned char)data[i]; + buf2[0] = hex_chars[(c & 0xf0) >> 4]; + buf2[1] = hex_chars[c & 0x0f]; + ret.append(buf2); + } + + return ret; +} + +static inline std::string hex_encode(const std::string &data) +{ + return hex_encode(data.c_str(), data.size()); +} + +static inline bool hex_digit_decode(char hexdigit, unsigned char &value) +{ + if (hexdigit >= '0' && hexdigit <= '9') + value = hexdigit - '0'; + else if (hexdigit >= 'A' && hexdigit <= 'F') + value = hexdigit - 'A' + 10; + else if (hexdigit >= 'a' && hexdigit <= 'f') + value = hexdigit - 'a' + 10; + else + return false; + return true; +} diff --git a/Client/Source/metadata.cpp b/Client/Source/metadata.cpp new file mode 100644 index 0000000..453ac1c --- /dev/null +++ b/Client/Source/metadata.cpp @@ -0,0 +1,115 @@ +/* +Minetest +Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "metadata.h" +#include "log.h" + +/* + Metadata +*/ + +void Metadata::clear() +{ + m_stringvars.clear(); + m_modified = true; +} + +bool Metadata::empty() const +{ + return m_stringvars.empty(); +} + +size_t Metadata::size() const +{ + return m_stringvars.size(); +} + +bool Metadata::contains(const std::string &name) const +{ + return m_stringvars.find(name) != m_stringvars.end(); +} + +bool Metadata::operator==(const Metadata &other) const +{ + if (size() != other.size()) + return false; + + for (const auto &sv : m_stringvars) { + if (!other.contains(sv.first) || other.getString(sv.first) != sv.second) + return false; + } + + return true; +} + +const std::string &Metadata::getString(const std::string &name, u16 recursion) const +{ + StringMap::const_iterator it = m_stringvars.find(name); + if (it == m_stringvars.end()) { + static const std::string empty_string = std::string(""); + return empty_string; + } + + return resolveString(it->second, recursion); +} + +bool Metadata::getStringToRef( + const std::string &name, std::string &str, u16 recursion) const +{ + StringMap::const_iterator it = m_stringvars.find(name); + if (it == m_stringvars.end()) { + return false; + } + + str = resolveString(it->second, recursion); + return true; +} + +/** + * Sets var to name key in the metadata storage + * + * @param name + * @param var + * @return true if key-value pair is created or changed + */ +bool Metadata::setString(const std::string &name, const std::string &var) +{ + if (var.empty()) { + m_stringvars.erase(name); + return true; + } + + StringMap::iterator it = m_stringvars.find(name); + if (it != m_stringvars.end() && it->second == var) { + return false; + } + + m_stringvars[name] = var; + m_modified = true; + return true; +} + +const std::string &Metadata::resolveString(const std::string &str, u16 recursion) const +{ + if (recursion <= 1 && str.substr(0, 2) == "${" && str[str.length() - 1] == '}') { + return getString(str.substr(2, str.length() - 3), recursion + 1); + } + + return str; +} diff --git a/Client/Source/metadata.h b/Client/Source/metadata.h new file mode 100644 index 0000000..5333f8a --- /dev/null +++ b/Client/Source/metadata.h @@ -0,0 +1,63 @@ +/* +Minetest +Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#pragma once + +#include "irr_v3d.h" +#include <iostream> +#include <vector> +#include "util/string.h" + +class Metadata +{ + bool m_modified = false; +public: + virtual ~Metadata() = default; + + virtual void clear(); + virtual bool empty() const; + + bool operator==(const Metadata &other) const; + inline bool operator!=(const Metadata &other) const + { + return !(*this == other); + } + + // + // Key-value related + // + + size_t size() const; + bool contains(const std::string &name) const; + const std::string &getString(const std::string &name, u16 recursion = 0) const; + bool getStringToRef(const std::string &name, std::string &str, u16 recursion = 0) const; + virtual bool setString(const std::string &name, const std::string &var); + inline bool removeString(const std::string &name) { return setString(name, ""); } + const StringMap &getStrings() const + { + return m_stringvars; + } + // Add support for variable names in values + const std::string &resolveString(const std::string &str, u16 recursion = 0) const; + + inline bool isModified() const { return m_modified; } + inline void setModified(bool v) { m_modified = v; } +protected: + StringMap m_stringvars; +}; diff --git a/Documents/设计/设计.xlsx b/Documents/设计/设计.xlsx Binary files differindex 1a76cea..269b802 100644 --- a/Documents/设计/设计.xlsx +++ b/Documents/设计/设计.xlsx diff --git a/Server/Project/RagdollServer/.vs/RagdollServer/v15/.suo b/Server/Project/RagdollServer/.vs/RagdollServer/v15/.suo Binary files differnew file mode 100644 index 0000000..8fb755f --- /dev/null +++ b/Server/Project/RagdollServer/.vs/RagdollServer/v15/.suo diff --git a/Server/Project/RagdollServer/.vs/RagdollServer/v15/Browse.VC.db b/Server/Project/RagdollServer/.vs/RagdollServer/v15/Browse.VC.db Binary files differnew file mode 100644 index 0000000..74057cd --- /dev/null +++ b/Server/Project/RagdollServer/.vs/RagdollServer/v15/Browse.VC.db diff --git a/Server/Project/RagdollServer/RagdollServer.sln b/Server/Project/RagdollServer/RagdollServer.sln new file mode 100644 index 0000000..f1ab946 --- /dev/null +++ b/Server/Project/RagdollServer/RagdollServer.sln @@ -0,0 +1,31 @@ +
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.902
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RagdollServer", "RagdollServer\RagdollServer.vcxproj", "{8BC61D58-41D9-43F2-9B52-A97F5AF992C6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8BC61D58-41D9-43F2-9B52-A97F5AF992C6}.Debug|x64.ActiveCfg = Debug|x64
+ {8BC61D58-41D9-43F2-9B52-A97F5AF992C6}.Debug|x64.Build.0 = Debug|x64
+ {8BC61D58-41D9-43F2-9B52-A97F5AF992C6}.Debug|x86.ActiveCfg = Debug|Win32
+ {8BC61D58-41D9-43F2-9B52-A97F5AF992C6}.Debug|x86.Build.0 = Debug|Win32
+ {8BC61D58-41D9-43F2-9B52-A97F5AF992C6}.Release|x64.ActiveCfg = Release|x64
+ {8BC61D58-41D9-43F2-9B52-A97F5AF992C6}.Release|x64.Build.0 = Release|x64
+ {8BC61D58-41D9-43F2-9B52-A97F5AF992C6}.Release|x86.ActiveCfg = Release|Win32
+ {8BC61D58-41D9-43F2-9B52-A97F5AF992C6}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {FCB3BA56-98AE-4D1D-B599-F7A1F1E9CF24}
+ EndGlobalSection
+EndGlobal
diff --git a/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj b/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj new file mode 100644 index 0000000..c13234c --- /dev/null +++ b/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{8BC61D58-41D9-43F2-9B52-A97F5AF992C6}</ProjectGuid>
+ <RootNamespace>RagdollServer</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup />
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj.filters b/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj.filters new file mode 100644 index 0000000..ef1ebf5 --- /dev/null +++ b/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj.filters @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
\ No newline at end of file diff --git a/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj.user b/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj.user new file mode 100644 index 0000000..6e2aec7 --- /dev/null +++ b/Server/Project/RagdollServer/RagdollServer/RagdollServer.vcxproj.user @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup />
+</Project>
\ No newline at end of file |